Access 2013

 Copy code hover
[image]

Access 2013
Send feedback

Published: July 16, 2012

Access product logo

Use Access 2013 to create data-centric web applications.

Explore Access 2013 developer resources

New features and scenarios

New features

What's new for Access 2013 developers

Get started

Get started

How to: Create and customize a web app in Access 2013

References

Reference

Welcome to the Access 2013 developer reference

Find training and other resources about Office

Email us to suggest content Subscribe to the Office developer RSS Read Office developer blogs Read Office developer forums Visit MSDN Office and SharePoint on Facebook Follow @MSDN_Office on Twitter

Download

Office updates

Office 365

Office code samples

Office scripts and sample files

Office downloads

Office 365 downloads

How To

Train Office 2010 end users

Office developer videos

Office IT pro training

Office IT pro videos

Sites

Office 365 IT pros

Office 2013 Resource Kit

SharePoint developers

SharePoint IT pros

Office.com

Microsoft.com: Office 365

Additional resources

  • Excel 2013

  • InfoPath 2013

  • Office 2013

  • OneNote 2013

  • Outlook 2013

  • PowerPoint 2013

  • Project 2013

  • Publisher 2013

  • SharePoint 2013

  • Visio 2013

  • Word 2013

© 2013 Microsoft Corporation. All rights reserved.


ADP Objects

 Copy code hover
[image]

ADP Objects
Send feedback

In this section

  • CopyDatabaseFile Macro Action

  • OpenDiagram Macro Action

  • OpenFunction Macro Action

  • OpenStoredProcedure Macro Action

  • OpenView Macro Action

  • TransferSQLDatabase Macro Action


FormatConditions Object (Access)

 Copy code hover
[image]

FormatConditions Object (Access)
See also Send feedback

Published: July 16, 2012

The FormatConditions collection represents the collection of conditional formats for a combo box or text box control. Each format is represented by a FormatCondition object.

Remarks

Use the FormatConditions property of a combo box or text box in Visual Basic or in an expression to return a FormatConditions collection. Use the Add method to create a new conditional format, and use the Modify method to change an existing conditional format.

You can use the Modify method to change one of the formats, or the Delete method to delete a format.

See also

Concepts

Access Object Model Reference

Other resources

FormatConditions Object Members


Application.DLast Method (Access)

 Copy code hover
[image]

Application.DLast Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the DLast function to return a random record from a particular field in a table or query when you simply need any value from that field. .

Syntax

expression .DLast(Expr, Domain, Criteria)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Expr | Required | String | An expression that identifies the field from which you want to find the first or last value. It can be either a string expression identifying a field in a table or query, or an expression that performs a calculation on data in that field. In expr, you can include the name of a field in a table, a control on a form, a constant, or a function. If expr includes a function, it can be either built-in or user-defined, but not another domain aggregate or SQL aggregate function.
Domain | Required | String | A string expression identifying the set of records that constitutes the domain.
Criteria | Optional | Variant | An optional string expression used to restrict the range of data on which the DLast function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the wrd WHERE. If criteria is omitted, the DLast function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain; otherwise, the DLast function returns a Null.

Return Value

Variant

Remarks

Note Note

If you want to return the first or last record in a set of records (a domain), you should create a query sorted as either ascending or descending and set the TopValues property to 1. From Visual Basic, you can also create an ADO Recordset object and use the MoveFirst or MoveLast method to return the first or last record in a set of records.

Example

The following examples show how to use various types of criteria with the DLast function.

Sample code provided by: Community Member Icon The UtterAccess community | About the Contributors

Copy code Copy code
    ' ***************************
    ' Typical Use
    ' Numerical values. Replace "number" with the number to use.
    variable = DLast("[FieldName]", "TableName", "[Criteria] = number")

    ' Strings.
    ' Numerical values. Replace "string" with the string to use.
    variable = DLast("[FieldName]", "TableName", "[Criteria]= 'string'")

    ' Dates. Replace "date" with the string to use.
    variable = DLast("[FieldName]", "TableName", "[Criteria]= #date#")
    ' ***************************

    ' ***************************
    ' Referring to a control on a form
    ' Numerical values
    variable = DLast("[FieldName]", "TableName", "[Criteria] = " & Forms!FormName!ControlName)

    ' Strings
    variable = DLast("[FieldName]", "TableName", "[Criteria] = '" & Forms!FormName!ControlName & "'")

    ' Dates
    variable = DLast("[FieldName]", "TableName", "[Criteria] = #" & Forms!FormName!ControlName & "#")
    ' ***************************

    ' ***************************
    ' Combinations
    ' Multiple types of criteria
    variable = DLast("[FieldName]", "TableName", "[Criteria1] = " & Forms![FormName]![Control1] _
             & " AND [Criteria2] = '" & Forms![FormName]![Control2] & "'" _
            & " AND [Criteria3] =#" & Forms![FormName]![Control3] & "#")

    ' Use two fields from a single record.
    variable = DLast("[LastName] & ', ' & [FirstName]", "tblPeople", "[PrimaryKey] = 7")

    ' Expressions
    variable = DLast("[Field1] + [Field2]", "tableName", "[PrimaryKey] = 7")

    ' Control Structures
    variable = DLast("IIf([LastName] Like 'Smith', 'True', 'False')", "tableName", "[PrimaryKey] = 7")
    ' ***************************

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Application Object

Other resources

Application Object Members


Pi Function (Access 2013 custom web app)

 Copy code hover
[image]

Pi Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the constant value of PI.

Syntax

Pi()


SortColumn Property (RDS)

 Copy code hover
[image]

SortColumn Property (RDS)
Send feedback

Indicates by which column to sort the records.

Syntax

DataControl.SortColumn = String

Parameters

  • DataControl

  • An object variable that represents an RDS.DataControl object.

  • String

  • A String value that represents the name or alias of the column by which to sort the records.

Remarks

The SortColumn, SortDirection, FilterValue, FilterCriterion, and FilterColumn properties provide sorting and filtering functionality on the client-side cache. The sorting functionality orders records by values from one column. The filtering functionality displays a subset of records based on find criteria, while the full Recordset is maintained in the cache. The Reset method will execute the criteria and replace the current Recordset with an updatable Recordset.

To sort on a Recordset, you must first save any pending changes. If you are using the RDS.DataControl, you can use the SubmitChanges method. For example, if your RDS.DataControl is named ADC1, your code would be ADC1.SubmitChanges . If you are using an ADO Recordset, you can use its UpdateBatch method. Using UpdateBatch is the recommended method for Recordset objects created with the CreateRecordset method. For example, your code could be myRS.UpdateBatch or . If you are using an ADO Recordset, you can use its UpdateBatch method. Using UpdateBatch is the recommended method for Recordset objects created with the CreateRecordset method. For example, your code could be myRS.UpdateBatch or ADC1.Recordset.UpdateBatch .


Fabricating Hierarchical Recordsets

 Copy code hover
[image]

Fabricating Hierarchical Recordsets
Send feedback

The following example shows how to fabricate a hierarchical Recordset without an underlying data source by using the data shaping grammar to define columns for parent, child, and grandchild Recordsets.

To fabricate a hierarchical Recordset, you must specify the Microsoft Data Shaping Service for OLE DB (MSDataShape), and you may specify a Data Provider value of NONE in the connection string parameter of the Connection object's Open method. For more information, see Required Providers for Data Shaping.

Copy code Copy code
Dim cn As New ADODB.Connection
Dim rsCustomers As New ADODB.Recordset

cn.Open "Provider=MSDataShape;Data Provider=NONE;"

strShape = _
"SHAPE APPEND NEW adInteger AS CustID," & _
            " NEW adChar(25) AS FirstName," & _
            " NEW adChar(25) AS LastName," & _
            " NEW adChar(12) AS SSN," & _
            " NEW adChar(50) AS Address," & _
         " ((SHAPE APPEND NEW adChar(80) AS VIN_NO," & _
                        " NEW adInteger AS CustID," & _
                        " NEW adChar(20) AS BodyColor, " & _
                     " ((SHAPE APPEND NEW adChar(80) AS VIN_NO," & _
                                    " NEW adChar(20) AS Make, " & _
                                    " NEW adChar(20) AS Model," & _
                                    " NEW adChar(4) AS Year) " & _
                        " AS VINS RELATE VIN_NO TO VIN_NO))" & _
            " AS Vehicles RELATE CustID TO CustID) "

rsCustomers.Open strShape, cn, adOpenStatic, adLockOptimistic, -1

Once the Recordset has been fabricated, it can be populated, manipulated, or persisted to a file.


One of the records in the Recordset was deleted by another process. (Error 3643)

 Copy code hover
[image]

One of the records in the Recordset was deleted by another process. (Error 3643)
Send feedback

One or more of the records in the Recordset was deleted after the query was performed. You should refresh the Recordset and try the query again.


SetOptionEnum Enumeration (DAO)

 Copy code hover
[image]

SetOptionEnum Enumeration (DAO)
Send feedback

Used with the SetOption method to specify a Microsoft Access database engine key in the Windows Registry to override.

Name | Value | Description
dbExclusiveAsyncDelay | 60 | The ExclusiveAsyncDelay key.
dbFlushTransactionTimeout | 66 | The FlushTransactionTimeout key.
dbImplicitCommitSync | 59 | The ImplicitCommitSync key.
dbLockDelay | 63 | The LockDelay key.
dbLockRetry | 57 | The LockRetry key.
dbMaxBufferSize | 8 | The MaxBufferSize key.
dbMaxLocksPerFile | 62 | The MaxLocksPerFile key.
dbPageTimeout | 6 | The PageTimeout key.
dbPasswordEncryptionAlgorithm | 81 | The name of the encryption algorithm.
dbPasswordEncryptionKeyLength | 82 | The encryption key length. Must be a multiple of 8, starting at 40.
dbPasswordEncryptionProvider | 80 | The name of the encryption provider.
dbRecycleLVs | 65 | The RecycleLVs key.
dbSharedAsyncDelay | 61 | The SharedAsyncDelay key.
dbUserCommitSync | 58 | The UserCommitSync key.


BoundObjectFrame.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

BoundObjectFrame.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified frame. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthLeft

expression A variable that represents a BoundObjectFrame object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


GetObjectOwner and SetObjectOwner Methods Example (VB)

 Copy code hover
[image]

GetObjectOwner and SetObjectOwner Methods Example (VB)
Send feedback

This example demonstrates the GetObjectOwner and SetObjectOwner methods. This code assumes the existence of the group Accounting (see the Groups and Users Append, ChangePassword Methods Example (VB) to see how to add this group to the system). The owner of the Categories table is set to Accounting.

Copy code Copy code

' BeginOwnersVB
Sub Main()
 On Error GoTo OwnersXError

 Dim tblLoop As New ADOX.Table
 Dim cat As New ADOX.Catalog
 Dim strOwner As String

 ' Open the Catalog.
 cat.ActiveConnection = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\" & _
 "Microsoft Office\Office\Samples\Northwind.mdb';" & _
 "jet oledb:system database=" & _
 "'c:\Program Files\Microsoft Office\Office\system.mdw'"

 ' Print the original owner of Categories
 strOwner = cat.GetObjectOwner("Categories", adPermObjTable)
 Debug.Print "Owner of Categories: " & strOwner

 ' Set the owner of Categories to Accounting
 cat.SetObjectOwner "Categories", adPermObjTable, "Accounting"

 ' List the owners of all tables and columns in the catalog.
 For Each tblLoop In cat.Tables
 Debug.Print "Table: " & tblLoop.Name
 Debug.Print " Owner: " & _
 cat.GetObjectOwner(tblLoop.Name, adPermObjTable)
 Next tblLoop

 ' Restore the original owner of Categories
 cat.SetObjectOwner "Categories", adPermObjTable, strOwner

 'Clean up
 Set cat.ActiveConnection = Nothing
 Set cat = Nothing
 Exit Sub

OwnersXError:

 Set cat = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If

End Sub
' EndOwnersVB


WebBrowserControl.Width Property (Access)

 Copy code hover
[image]

WebBrowserControl.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .Width

expression A variable that represents a WebBrowserControl object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Cannot perform cascading operation on table

 Copy code hover
[image]

Cannot perform cascading operation on table <name>. (Error 3413)
Send feedback

This error occurs when referential integrity is defined with one of the following actions: CASCADE DELETE, UPDATE or NULL. The error occurs when making a change to a table that contains a referenced primary key and one or more of the foreign key tables is opened in a mode that prevents the foreign key tables from being opened in a shared read/write mode.


QueryDef.Parameters Property (DAO)

 Copy code hover
[image]

QueryDef.Parameters Property (DAO)
Send feedback

Returns a Parameters collection that contains all of the Parameter objects of the specified QueryDef. Read-only.

Syntax

expression .Parameters

expression A variable that represents a QueryDef object.


TextBox.AddColon Property (Access)

 Copy code hover
[image]

TextBox.AddColon Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.

Syntax

expression .AddColon

expression A variable that represents a TextBox object.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Recordset.MoveNext Method (DAO)

 Copy code hover
[image]

Recordset.MoveNext Method (DAO)
Send feedback

Moves to the next record in a specified Recordset object and make that record the current record.

Syntax

expression .MoveNext

expression A variable that represents a Recordset object.

Remarks

Use the Move methods to move from record to record without applying a condition.

If you edit the current record, be sure you use the Update method to save the changes before you move to another record. If you move to another record without updating, your changes are lost without warning.

When you open a Recordset, the first record is current and the BOF property is False. If the Recordset contains no records, the BOF property is True, and there is no current record.

If you use MoveNext when the last record is current, the EOF property is True, and there is no current record. If you use MoveNext again, an error occurs, and EOF remains True.

If recordset refers to a table-type Recordset (Microsoft Access workspaces only), movement follows the current index. You can set the current index by using the Index property. If you don't set the current index, the order of returned records is undefined.

You can't use the MoveFirst, MoveLast, and MovePrevious methods on a forward-only-type Recordset object.

To move the position of the current record in a Recordset object a specific number of records forward or backward, use the Move method.


Report.FontBold Property (Access)

 Copy code hover
[image]

Report.FontBold Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontBold property to specify whether a font appears in a bold style in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontBold

expression A variable that represents a Report object.

Remarks

The FontBold property uses the following settings.

Setting | Description
True | The text is bold.
False | (Default) The text isn't bold.

To use the FontBold property on a report, first create a Printevent procedure that prints the desired text.

A font's appearance on screen and in print may differ, depending on your computer and printer.

The FontWeight property, which is available in the property sheet for controls, can also be used to set the line width for a control's text. The FontBold property gives you a quick way to make text bold; the FontWeight property gives you finer control over the line width setting for text. The following table shows the relationship between these properties' settings.

If | Then
FontBold = False | FontWeight = Normal (400)
FontBold = True | FontWeight = Bold (700)
FontWeight < 700 | FontBold = False
FontWeight > = 700 | FontBold = True

Example

The following Print event procedure prints a report title and the current date in a bold style on a report at the coordinates specified by the CurrentX and CurrentY property settings.

VBA Copy code Copy code
Private Sub ReportHeader0_Print(Cancel As Integer, _
 PrintCount As Integer)
 Dim MyDate

 MyDate = Date
 Me.FontBold = True
 ' Print report title in bold.
 Me.Print("Sales Management Report")
 Me.Print(MyDate)
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


CustomControl.VerticalAnchor Property (Access)

 Copy code hover
[image]

CustomControl.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified text box is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2010

Syntax

expression .VerticalAnchor

expression A variable that represents a CustomControl object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Properties.Count Property (Access)

 Copy code hover
[image]

Properties.Count Property (Access)
Send feedback

Published: July 16, 2012

Returns the number of objects in the specified collection. Read-only.

Syntax

expression .Count

expression A variable that represents a Properties object.

Remarks

Because members of a collection begin with 0, you should always code loops starting with the 0 member and ending with the value of the Count property minus 1. If you want to loop through the members of a collection without checking the Count property, you can use a For Each...Next command.

The Count property setting is never Null. If its value is 0, there are no objects in the collection.


Configuring Virtual Servers on IIS

 Copy code hover
[image]

Configuring Virtual Servers on IIS
Send feedback

When creating virtual servers in Internet Information Services 4.0, the following two extra steps are needed in order to configure the virtual server to work with RDS:

  1. When setting up the server, check "Allow Execute Access."

  2. Move msadcs.dll to vroot\msadc, where vroot is the home directory of your virtual server.


Attachment.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

Attachment.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified attachment. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleLeft

expression A variable that represents an Attachment object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


NavigationControl.LeftPadding Property (Access)

 Copy code hover
[image]

NavigationControl.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .LeftPadding

expression A variable that represents a NavigationControl object.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Form.DataEntry Property (Access)

 Copy code hover
[image]

Form.DataEntry Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DataEntry property to specify whether a bound form opens to allow data entry only. The Data Entry property doesn't determine whether records can be added; it only determines whether existing records are displayed. Read/write Boolean.

Syntax

expression .DataEntry

expression A variable that represents a Form object.

Remarks

This property can be set in any view.

The DataEntry property has an effect only when the AllowAdditions property is set to Yes.

Setting the DataEntry property to Yes by using Visual Basic has the same effect as clicking Data Entry on the Records menu. Setting it to No by using Visual Basic is equivalent to clicking Remove Filter/Sort on the Records menu.

See also

Concepts

Form Object

Other resources

Form Object Members


PrimaryKey and Unique Properties Example (VC++)

 Copy code hover
[image]

PrimaryKey and Unique Properties Example (VC++)
Send feedback

This example demonstrates the PrimaryKey and Unique properties of an Index. The code creates a new table with two columns. The PrimaryKey and Unique properties are used to make one column the primary key for which duplicate values are not allowed.

Copy code Copy code

// BeginPrimaryKeyCpp
#import "c:\program files\common files\system\ado\msadox.dll" no_namespace
#import "c:\program files\common files\system\ado\msado15.dll"

#include "iostream.h"
#include "stdio.h"
#include "conio.h"

//Function Declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void PrimaryKeyX(void);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 PrimaryKeyX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// PrimaryKeyX Function //
// //
//////////////////////////////////////////////////////////
void PrimaryKeyX()
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.
 _CatalogPtr m_pCatalog = NULL;
 _TablePtr m_pTableNew = NULL;
 _IndexPtr m_pIndexNew = NULL;
 _IndexPtr m_pIndex = NULL;
 _ColumnPtr m_pColumn = NULL;

 //Define string variable
 _bstr_t strcnn("Provider='Microsoft.JET.OLEDB.4.0';"
 "Data Source = 'c:\\Program Files\\"
 "Microsoft Office\\Office\\Samples\\Northwind.mdb';");

 try
 {
 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof(Catalog)));
 TESTHR(hr = m_pTableNew.CreateInstance(__uuidof(Table)));
 TESTHR(hr = m_pIndexNew.CreateInstance(__uuidof(Index)));
 TESTHR(hr = m_pIndex.CreateInstance(__uuidof(Index)));
 TESTHR(hr = m_pColumn.CreateInstance(__uuidof(Column)));

 // Connect the catalog
 m_pCatalog->PutActiveConnection(strcnn);

 // Name new table
 m_pTableNew->Name = "NewTable";

 // Append a numeric and a text field to new table.
 m_pTableNew->Columns->Append("NumField", adInteger, 20);
 m_pTableNew->Columns->Append("TextField", adVarWChar, 20);

 // Append new Primary Key index on NumField column
 // to new table
 m_pIndexNew->Name = "NumIndex";
 m_pIndexNew->Columns->Append("NumField",adInteger,0);
 // here "-1" is required instead of "true".
 m_pIndexNew->PutPrimaryKey(-1);
 m_pIndexNew->PutUnique(-1);
 m_pTableNew->Indexes->Append(
 _variant_t ((IDispatch*)m_pIndexNew));

 // Append an index on Textfield to new table.
 // Note the different technique: Specifying index and
 // column name as parameters of the Append method
 m_pTableNew->Indexes->Append("TextIndex", "TextField");

 // Append the new table
 m_pCatalog->Tables->Append(_variant_t ((IDispatch*)m_pTableNew));

 cout << m_pTableNew->Indexes->Count << " Indexes in "
 << m_pTableNew->Name << " Table" << endl;
 m_pCatalog->Tables->Refresh();

 _variant_t vIndex;
 // Enumerate Indexes collection.
 for (long lIndex = 0;lIndex < m_pTableNew->Indexes->Count;
 lIndex++)
 {
 vIndex = lIndex;
 m_pIndex = m_pTableNew->Indexes->GetItem(vIndex);
 cout << "Index " << m_pIndex->Name << endl;
 cout << " Primary key = " << (m_pIndex->GetPrimaryKey() ?
 "True" : "False") << endl;
 cout << " Unique = " << (m_pIndex->GetUnique() ? "True" :
 "False") << endl;

 // Enumerate Columns collection of each Index
 // object.
 cout << " Columns" << endl;

 for (long lIndex = 0;lIndex < m_pIndex->Columns->Count;
 lIndex++)
 {
 vIndex = lIndex ;
 m_pColumn = m_pIndex->Columns->GetItem(vIndex);
 cout << " " << m_pColumn->Name << endl;
 }
 }

 // Delete new table as this is a demonstration
 m_pCatalog->Tables->Delete(m_pTableNew->Name);
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }
 catch(...)
 {
 cout << "Error occured in PrimaryKeyX...."<< endl;
 }

 m_pCatalog = NULL;
}
// EndPrimaryKeyCpp


AdditionalData Members (Access)

 Copy code hover
[image]

AdditionalData Members (Access)
Send feedback

Published: July 16, 2012

Represents the collection of tables and queries that will be included with the parent table that is exported by the ExportXML method.

Methods

Name | Description
Add | Adds an add table or query that will be included when the ExportXML method is called.

Properties

Name | Description
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AdditionalData.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.


ComboBox.CanGrow Property (Access)

 Copy code hover
[image]

ComboBox.CanGrow Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the control contains. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .CanGrow

expression A variable that represents a ComboBox object.

Remarks

A control's displayed information location is the distance measured from the control's left, top, right, or bottom border to the left, top, right, or bottom edge of the displayed information. To use a unit of measurement different from the setting in the regional settings of Windows, specify the unit (for example, cm or in).

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


SmartTagProperties Methods (Access)

 Copy code hover
[image]

SmartTagProperties Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Add | Adds a custom property to a smart tag.


ReturnVars.Parent Property (Access)

 Copy code hover
[image]

ReturnVars.Parent Property (Access)
Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only Object.

Version Information

Version Added: Access 2010

Syntax

expression .Parent

expression A variable that represents a ReturnVars object.


DBEngine Properties (DAO)

 Copy code hover
[image]

DBEngine Properties (DAO)
Send feedback

In this section

  • DBEngine.DefaultPassword Property (DAO)

  • DBEngine.DefaultType Property (DAO)

  • DBEngine.DefaultUser Property (DAO)

  • DBEngine.Errors Property (DAO)

  • DBEngine.IniPath Property (DAO)

  • DBEngine.LoginTimeout Property (DAO)

  • DBEngine.Version Property (DAO)

  • DBEngine.Properties Property (DAO)

  • DBEngine.Workspaces Property (DAO)


ADOX Enumerated Constants

 Copy code hover
[image]

ADOX Enumerated Constants
Send feedback

To assist debugging, the ADOX enumerated constants list a value for each constant. However, this value is purely advisory, and may change from one release of ADOX to another. Your code should only depend on the name, not the actual value, of enumerated constants.

The following enumerated constants are defined.

Enumeration | Description
ActionEnum | Specifies the type of action to be performed when SetPermissions is called.
AllowNullsEnum | Specifies whether records with null values are indexed.
ColumnAttributesEnum | Specifies characteristics of a Column.
DataTypeEnum | Specifies the data type of a Field, Parameter, or Property.
InheritTypeEnum | Specifies how objects will inherit permissions set with SetPermissions.
KeyTypeEnum | Specifies the type of Key: primary, foreign, or unique.
ObjectTypeEnum | Specifies the type of database object for which to set permissions or ownership.
RightsEnum | Specifies the rights or permissions for a group or user on an object.
RuleEnum | Specifies the rule to follow when a Key is deleted.
SortOrderEnum | Specifies the sort sequence for an indexed column.


Columns Collection (ADOX) Reference

 Copy code hover
[image]

Columns Collection (ADOX) Reference
Send feedback

In this section

  • Columns Collection (ADOX)

  • Columns Collection Properties, Methods, and Events (ADOX)


Form.Page Property (Access)

 Copy code hover
[image]

Form.Page Property (Access)
See also Send feedback

Published: July 16, 2012

The Page property specifies the current page number when a form is being printed. Read/write Long.

Syntax

expression .Page

expression A variable that represents a Form object.

Remarks

Although you can set the Page property to a value, you most often use this property to return information about page numbers.

This property is only available in Print Preview or when printing.

See also

Concepts

Form Object

Other resources

Form Object Members


Update Resync Property--Dynamic (ADO)

 Copy code hover
[image]

Update Resync Property--Dynamic (ADO)
Send feedback

Specifies whether the UpdateBatch method is followed by an implicit Resync method operation, and if so, the scope of that operation.

Settings and Return Values

Sets or returns one or more of the ADCPROP_UPDATERESYNC_ENUM values.

Remarks

The values of ADCPROP_UPDATERESYNC_ENUM may be combined, except for adResyncAll which already represents the combination of the rest of the values.

The constant adResyncConflicts stores the resync values as underlying values, but does not override pending changes.

Update Resync is a dynamic property appended to the Recordset object Properties collection when the CursorLocation property is set to adUseClient.


TableDef.Updatable Property (DAO)

 Copy code hover
[image]

TableDef.Updatable Property (DAO)
Send feedback

Returns a value that indicates whether you can change a DAO object. Read-only Boolean.

Syntax

expression .Updatable

expression A variable that represents a TableDef object.

Remarks

The Updatable property setting is always True for a newly created TableDef object and False for a linked TableDef object. A new TableDef object can be appended only to a database for which the current user has write permission.


QueryDef Object (DAO)

 Copy code hover
[image]

QueryDef Object (DAO)
Send feedback

A QueryDef object is a stored definition of a query in a Microsoft Access database engine database.

Remarks

You can use the QueryDef object to define a query. For example, you can:

  • Use the SQL property to set or return the query definition.

  • Use the QueryDef object's Parameters collection to set or return query parameters.

  • Use the Type property to return a value indicating whether the query selects records from an existing table, makes a new table, inserts records from one table into another table, deletes records, or updates records.

  • Use the MaxRecords property to limit the number of records returned from a query.

  • Use the ODBCTimeout property to indicate how long to wait before the query returns records. The ODBCTimeout property applies to any query that accesses ODBC data.

  • Use the ReturnsRecords property to indicate that the query returns records. The ReturnsRecords property is only valid on SQL pass-through queries.

  • Use the Connect property to make an SQL pass-through query to an ODC database.

You can also create temporary QueryDef objects. Unlike permanent QueryDef objects, temporary QueryDef objects are not saved to disk or appended to the QueryDefs collection. Temporary QueryDef objects are useful for queries that you must run repeatedly during run time but do not not need to save to disk, particularly if you create their SQL statements during run time.

You can think of a permanent QueryDef object in a Microsoft Access workspace as a compiled SQL statement. If you execute a query from a permanent QueryDef object, the query will run faster than if you run the equivalent SQL statement from the OpenRecordset method. This is because the Microsoft Access database engine doesn't need to compile the query before executing it.

The preferred way to use the native SQL dialect of an external database engine accessed through the Microsoft Access database engine is through QueryDef objects. For example, you can create a Microsoft SQL Server query and store it in a QueryDef object. When you need to use a non-Microsoft Access database engine SQL query, you must provide a Connect property string that points to the external data source. Queries with valid Connect properties bypass the Microsoft Access database engine and pass the query directly to the external database server for processing.

To create a new QueryDef object, use the CreateQueryDef method. In a Microsoft Access workspace, if you supply a string for the name argument or if you explicitly set the Name property of the new QueryDef object to a non-zero-length string, you will create a permanent QueryDef that will automatically be appended to the QueryDefs collection and saved to disk. Supplying a zero-length string as the name argument or explicitly setting the Name property to a zero-length string will result in a temporary QueryDef object.

To refer to a QueryDef object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

QueryDefs(0)

QueryDefs("name")

QueryDefs![ name]

You can refer to temporary QueryDef objects only by the object variables that you have assigned to them.

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Queries: Document SQL to Word

Example

This example creates a new QueryDef object and appends it to the QueryDefs collection of the Northwind Database object. It then enumerates the QueryDefs collection and the Properties collection of the new QueryDef.

VBA Copy code Copy code
Sub QueryDefX()

   Dim dbsNorthwind As Database
   Dim qdfNew As QueryDef
   Dim qdfLoop As QueryDef
   Dim prpLoop As Property

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   ' Create new QueryDef object. Because it has a
   ' name, it is automatically appended to the
   ' QueryDefs collection.
   Set qdfNew = dbsNorthwind.CreateQueryDef("NewQueryDef", _
         "SELECT * FROM Categories")

   With dbsNorthwind
      Debug.Print .QueryDefs.Count & _
         " QueryDefs in " & .Name

      ' Enumerate QueryDefs collection.
      For Each qdfLoop In .QueryDefs
         Debug.Print "  " & qdfLoop.Name
      Next qdfLoop

      With qdfNew
         Debug.Print "Properties of " & .Name

         ' Enumerate Properties collection of new
         ' QueryDef object.
         For Each prpLoop In .Properties
            On Error Resume Next
            Debug.Print "  " & prpLoop.Name & " - " & _
               IIf(prpLoop = "", "[empty]", prpLoop)
            On Error Goto 0
         Next prpLoop
      End With

      ' Delete new QueryDef because this is a
      ' demonstration.
      .QueryDefs.Delete qdfNew.Name
      .Close
   End With

End Sub

This example uses the CreateQueryDef method to create and execute both a temporary and a permanent QueryDef. The GetrstTemp function is required for this procedure to run.

VBA Copy code Copy code
Sub CreateQueryDefX()

   Dim dbsNorthwind As Database
   Dim qdfTemp As QueryDef
   Dim qdfNew As QueryDef

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   With dbsNorthwind
      ' Create temporary QueryDef.
      Set qdfTemp = .CreateQueryDef("", _
         "SELECT * FROM Employees")
      ' Open Recordset and print report.
      GetrstTemp qdfTemp
      ' Create permanent QueryDef.
      Set qdfNew = .CreateQueryDef("NewQueryDef", _
         "SELECT * FROM Categories")
      ' Open Recordset and print report.
      GetrstTemp qdfNew
      ' Delete new QueryDef because this is a demonstration.
      .QueryDefs.Delete qdfNew.Name
      .Close
   End With

End Sub

Function GetrstTemp(qdfTemp As QueryDef)

   Dim rstTemp As Recordset

   With qdfTemp
      Debug.Print .Name
      Debug.Print "  " & .SQL
      ' Open Recordset from QueryDef.
      Set rstTemp = .OpenRecordset(dbOpenSnapshot)

      With rstTemp
         ' Populate Recordset and print number of records.
         .MoveLast
         Debug.Print "  Number of records = " & _
            .RecordCount
         Debug.Print
         .Close
      End With

   End With

End Function

The following example shows how to replace the Structured Query Language (SQL) statement in a saved query.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
'To change the Where clause in a saved query
Dim qdf as QueryDef
Dim db as Database
Set db = CurrentDB
Set qdf = db.QueryDefs("YourQueryName")
qdf.SQL = ReplaceWhereClause(qdf.SQL, strYourNewWhereClause)
set qdf = Nothing
set db = Nothing

Public Function ReplaceWhereClause(strSQL As Variant, strNewWHERE As Variant)
On Error GoTo Error_Handler

'This subroutine accepts a valid SQL string and Where clause, and
'returns the same SQL statement with the original Where clause (if any)
'replaced by the passed in Where clause.
'
'INPUT:
' strSQL valid SQL string to change
'OUTPUT:
' strNewWHERE New WHERE clause to insert into SQL statement
'
    Dim strSELECT As String, strWhere As String
    Dim strOrderBy As String, strGROUPBY As String, strHAVING As String

    Call ParseSQL(strSQL, strSELECT, strWhere, strOrderBy, _
        strGROUPBY, strHAVING)

    ReplaceWhereClause = strSELECT &""& strNewWHERE &""_
        & strGROUPBY &""& strHAVING &""& strOrderBy

    Exit_Procedure:
        Exit Function

    Error_Handler:
        MsgBox (Err.Number & ": " & Err.Description)
        Resume Exit_Procedure

End Function

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


ComboBox.AutoExpand Property (Access)

 Copy code hover
[image]

ComboBox.AutoExpand Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AutoExpand property to specify whether Microsoft Access automatically fills the text box portion of a combo box with a value from the combo box list that matches the characters you enter as you type in the combo box. This lets you quickly enter an existing value in a combo box without displaying the list box portion of the combo box. Read/write Boolean.

Syntax

expression .AutoExpand

expression A variable that represents a ComboBox object.

Remarks

When you enter characters in the text box portion of a combo box, Office Access 2007 searches the values in the list to find those that match the characters you have typed. If the AutoExpand property is set to Yes, Microsoft Access automatically displays the first underlying value that matches the characters entered so far.

When the LimitToList property is set to Yes and the combo box list is dropped down, Microsoft Access selects matching values in the list as the user enters characters in the text box portion of the combo box, even if the AutoExpand property is set to No. If the user presses ENTER or moves to another control or record, the selected value appears in the combo box.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


SubForm.Section Property (Access)

 Copy code hover
[image]

SubForm.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Syntax

expression .Section

expression A variable that represents a SubForm object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


RTrim Function (Access 2013 custom web app)

 Copy code hover
[image]

RTrim Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns a text value after truncating all trailing blanks.

Syntax

RTrim(TextExpression)

The RTrim function contains the following argument.

Argument Name | Description
TextExpression | A string expression.


Append and CreateParameter Methods Example (VB)

 Copy code hover
[image]

Append and CreateParameter Methods Example (VB)
Send feedback

This example uses the Append and CreateParameter methods to execute a stored procedure with an input parameter.

Copy code Copy code

'BeginAppendVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 'recordset, command and connection variables
 Dim Cnxn As ADODB.Connection
 Dim cmdByRoyalty As ADODB.Command
 Dim prmByRoyalty As ADODB.Parameter
 Dim rstByRoyalty As ADODB.Recordset
 Dim rstAuthors As ADODB.Recordset
 Dim strCnxn As String
 Dim strSQLAuthors As String
 Dim strSQLByRoyalty As String
 'record variables
 Dim intRoyalty As Integer
 Dim strAuthorID As String

 ' Open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open command object with one parameter
 Set cmdByRoyalty = New ADODB.Command
 cmdByRoyalty.CommandText = "byroyalty"
 cmdByRoyalty.CommandType = adCmdStoredProc

 ' Get parameter value and append parameter
 intRoyalty = Trim(InputBox("Enter royalty:"))
 Set prmByRoyalty = cmdByRoyalty.CreateParameter("percentage", adInteger, adParamInput)
 cmdByRoyalty.Parameters.Append prmByRoyalty
 prmByRoyalty.Value = intRoyalty

 ' Create recordset by executing the command
 Set cmdByRoyalty.ActiveConnection = Cnxn
 Set rstByRoyalty = cmdByRoyalty.Execute

 ' Open the Authors Table to get author names for display
 ' and set cursor client-side
 Set rstAuthors = New ADODB.Recordset
 strSQLAuthors = "Authors"
 rstAuthors.Open strSQLAuthors, Cnxn, adUseClient, adLockOptimistic, adCmdTable

 ' Print recordset adding author names from Authors table
 Debug.Print "Authors with " & intRoyalty & " percent royalty"

 Do Until rstByRoyalty.EOF
 strAuthorID = rstByRoyalty!au_id
 Debug.Print " " & rstByRoyalty!au_id & ", ";
 rstAuthors.Filter = "au_id = '" & strAuthorID & "'"
 Debug.Print rstAuthors!au_fname & " " & rstAuthors!au_lname
 rstByRoyalty.MoveNext
 Loop

 ' clean up
 rstByRoyalty.Close
 rstAuthors.Close
 Cnxn.Close
 Set rstByRoyalty = Nothing
 Set rstAuthors = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstByRoyalty Is Nothing Then
 If rstByRoyalty.State = adStateOpen Then rstByRoyalty.Close
 End If
 Set rstByRoyalty = Nothing

 If Not rstAuthors Is Nothing Then
 If rstAuthors.State = adStateOpen Then rstAuthors.Close
 End If
 Set rstAuthors = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndAppendVB


ObjectFrame.Tag Property (Access)

 Copy code hover
[image]

ObjectFrame.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents an ObjectFrame object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Internet Publishing Scenario Topics

 Copy code hover
[image]

Internet Publishing Scenario Topics
Send feedback

Insert introduction here.

Section Heading

Insert section body here.

Subsection Heading

Insert subsection body here.


ObjectFrame Events (Access)

 Copy code hover
[image]

ObjectFrame Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.
Updated | The Updated event occurs when an OLE object's data has been modified.


ListBox.SizeToFit Method (Access)

 Copy code hover
[image]

ListBox.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents a ListBox object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


CheckBox.Section Property (Access)

 Copy code hover
[image]

CheckBox.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Syntax

expression .Section

expression A variable that represents a CheckBox object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Form.PrtMip Property (Access)

 Copy code hover
[image]

Form.PrtMip Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PrtMip property in Visual Basic to set or return the device mode information specified for a form or report in the Print dialog box.

Syntax

expression .PrtMip

expression A variable that represents a Form object.

Remarks

The PrtMip property setting is a 28-byte structure that maps to settings on the Margins tab for a form or report in the Page Setup dialog box.

The PrtMip property has the following members.

Member | Description
LeftMargin, RightMargin, TopMargin, BottomMargin | A Long that specifies the distance between the edge of the page and the item to be printed in twips.
DataOnly | A Long that specifies the elements to be printed. When True, prints only the data in a table or query in Datasheet view, form, or report, and suppresses labels, control borders, grid lines, and display graphics such as lines and boxes. When False, prints data, labels, and graphics.
ItemsAcross | A Long that specifies the number of columns across for multiple-column reports or labels. This member is equivalent to the value of the Number of Columns box under Grid Settings on the Columns tab of the Page Setup dialog box.
RowSpacing | A Long that specifies the horizontal space between detail sections in units of 1/20 of a point.
ColumnSpacing | A Long that specifies the vertical space between detail sections in twips.
DefaultSize | A Long. When True, uses the size of the detail section in Design view. When False, uses the values specified by the ItemSizeWidth and ItemSizeHeight members.
ItemSizeWidth | A Long that specifies the width of the detail section in twips. This member is equivalent to the value of the Width box under Column Size on the Columns tab of the Page Setup dialog box.
ItemSizeHeight | A Long that specifies the height of the detail section twips. This member is equivalent to the value of the Height box under Column Size on the Columns tab of the Page Setup dialog box.
ItemLayout | A Long that specifies horizontal (1953) or vertical (1954) layout of columns. This member is equivalent to Across, then Down or Down, then Across respectively under Column Layout on the Columns tab of the Page Setup dialog box.
FastPrint | Reserved.
Datasheet | Reserved.

The PrtMip property setting is read/write in Design view and read-only in other views.

See also

Concepts

Form Object

Other resources

Form Object Members


Expected query name after EXECUTE (Error 3732)

 Copy code hover
[image]

Expected query name after EXECUTE (Error 3732)
Send feedback

This error occurs when using the EXECUTE statement. A valid stored query (view or procedure) is needed after the EXECUTE statement.


BoundObjectFrame.Click Event (Access)

 Copy code hover
[image]

BoundObjectFrame.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Syntax

expression .Click

expression A variable that represents a BoundObjectFrame object.

Remarks

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Item not found in this collection. (Error 3265)

 Copy code hover
[image]

Item not found in this collection. (Error 3265)
Send feedback

An attempt to reference a name in a collection failed.

Possible causes:

  • The object does not exist in this collection. Make sure the object is appended to a collection before referencing it.

  • There is more than one object with this name in the collection; using its name is an ambiguous reference. Reference the object by its ordinal position in the collection (for example, Recordsets(3) ).


Failed to load RDOCURS.DLL. (Error 3672)

 Copy code hover
[image]

Failed to load RDOCURS.DLL. (Error 3672)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for more information.


ComboBox.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

ComboBox.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified combo box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleLeft

expression A variable that represents a ComboBox object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Form.ActiveControl Property (Access)

 Copy code hover
[image]

Form.ActiveControl Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ActiveControl property together with the Screen object to identify or refer to the control that has the focus. Read-only Control object.

Syntax

expression .ActiveControl

expression A variable that represents a Form object.

Remarks

This property setting contains a reference to the Control object that has the focus at run time.

You can use the ActiveControl property to refer to the control that has the focus at run time together with one of its properties or methods. The following example assigns the name of the control with the focus to the strControlName variable.

VBA Copy code Copy code
Dim ctlCurrentControl As Control
Dim strControlName As String
Set ctlCurrentControl = Screen.ActiveControl
strControlName = ctlCurrentControl.Name

If no control has the focus when you use the ActiveControl property, or if all of the active form's controls are hidden or disabled, an error occurs.

Example

The following example assigns the active control to the ctlCurrentControl variable and then takes different actions depending on the value of the control's Name property.

VBA Copy code Copy code
Dim ctlCurrentControl As Control

Set ctlCurrentControl = Screen.ActiveControl
If ctlCurrentControl.Name = "txtCustomerID" Then
 .
 . ' Do something here.
 .
ElseIf ctlCurrentControl.Name = "btnCustomerDetails" Then
 .
 . ' Do something here.
 .
End If

See also

Concepts

Form Object

Other resources

Form Object Members


TextBox.Width Property (Access)

 Copy code hover
[image]

TextBox.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents a TextBox object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


NavigationButton.BorderColor Property (Access)

 Copy code hover
[image]

NavigationButton.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderColor

expression A variable that represents a NavigationButton object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


ComboBox.OnExit Property (Access)

 Copy code hover
[image]

ComboBox.OnExit Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnExit

expression A variable that represents a ComboBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Exit event occurs just before a control loses the focus to another control on the same form.

The OnExit value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Exit box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Exit box is blank, the property value is an empty string.

Example

The following example associates the Exit event with the macro "Exit_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnExit = "Exit_Macro"

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


CommandButton.DblClick Event (Access)

 Copy code hover
[image]

CommandButton.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Syntax

expression .DblClick(Cancel)

expression A variable that represents a CommandButton object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the DblClick event occurs. Setting the Cancel argument to True (-1) cancels the DblClick event.

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Form.PrtDevNames Property (Access)

 Copy code hover
[image]

Form.PrtDevNames Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PrtDevNames property to set or return information about the printer selected in the Print dialog box for a form or report. Read/write Variant.

Syntax

expression .PrtDevNames

expression A variable that represents a Form object.

Remarks

It is strongly recommended that you consult the Win32 Software Development Kit for complete documentation on the PrtDevMode, PrtDevNames, and PrtMip properties.

The PrtDevNames property is a variable-length structure that mirrors the DEVNAMES structure defined in the Win32 Software Development Kit.

The PrtDevNames property uses the following members.

Member | Description
DriverOffset | Specifies the offset from the beginning of the structure to a Null-terminated string that specifies the file name (without an extension) of the device driver. This string is used to specify which printer is initially displayed in the Print dialog box.
DeviceOffset | Specifies the offset from the beginning of the structure to the Null-terminated string that specifies the name of the device. This string can't be longer than 32 bytes (including the null character) and must be identical to the DeviceName member of the DEVMODE structure.
OutputOffset | Specifies the offset from the beginning of the structure to the Null-terminated string that specifies the MS-DOS device name for the physical output medium (output port); for example, "LPT1:".
Default | Specifies whether the strings specified in the DEVNAMES structure identify the default printer. Before the Print dialog box is displayed, if Default is set to 1 and all of the values in the DEVNAMES structure match the current default printer, the selected printer is set to the default printer. Default is set to 1 if the current default printer has been selected.

Microsoft Access sets the PrtDevNames property when you make selections in the Printer section of the Print dialog box. You can also set the property by using Visual Basic .

Microsoft Access uses the DEVNAMES structure to initialize the Print dialog box. When the user chooses OK to close the dialog box, information about the selected printer is returned by the PrtDevNames property.

See also

Concepts

Form Object

Other resources

Form Object Members


If...Then...Else Macro Block

 Copy code hover
[image]

If...Then...Else Macro Block
Send feedback

You can use the If macro block to conditionally execute a group of actions, depending on the value of an expression.

VBA Copy code Copy code
                      If
                      expression
                      Then
 Insert macro actions here ...
Else If expression
 Insert macro actions here ...
Else
 Insert macro actions here ...
End If

Setting

For both If and Else If, the following arguments are required.

Action argument | Description
Expression | The condition that you wish to test. It must be an expression that evaluates to True or False.

Remarks

When you select the If macro block, a textbox appears so that you can enter an expression that represents the condition you wish to test. In addition, a combo box appears where you can insert a macro action, below which the text "End If" automatically displays. The If and the End If bracket an area in which you can enter a group, or block, of actions. The block executes only if the expression that you enter is True.

To evaluate a different expression when the first expression is false, you can click Add Else If to insert an optional Else If block. You must enter an expression that evaluates to True or False. In this case, the block executes only if the expression is True and the first expression is False.

You can add as many Else If blocks as you like to an If block.

You can click Add Else to insert an optional Else block. In this case, the actions that you insert below the Else form the Else block, which executes only when the actions above do not. You can add a single Else block to an If block.

In the following code example, the macro actions in the first block execute if the value of [Status] is greater than 0. If the value of [Status] is not greater than 0, the expression that follows the Else If is evaluated. The macro actions in the Else If block execute if the value of [Status] is equal to 0. Finally, if neither the first block nor the second block execute, the actions in the Else block execute.

VBA Copy code Copy code
                      If
                      [Status] > 0
                      Then
 Insert macro actions here ...
Else If [Status] = 0
 Insert macro actions here ...
Else
 Insert macro actions here ...
End If

You can nest If blocks. You should consider nesting an If block within an If block if you want to evaluate a second expression when the first expression is True. In the following code example, the inner If block only executes when the value of [Status] is both greater than 0 and greater than 100.

VBA Copy code Copy code
                      If
                      [Status] > 0
                      Then
 Insert macro actions here ...
 If [Status] > 100
 Insert macro actions here ...
 EndifEnd If


MacroError.Arguments Property (Access)

 Copy code hover
[image]

MacroError.Arguments Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the arguments specified for the macro action that was executing when an error occurred. Read-only String.

Version Information

Version Added: Access 2007

Syntax

expression .Arguments

expression A variable that represents a MacroError object.

Remarks

When an error occurs in a macro, information about the error is stored in the MacroError object. If you have not used the OnError action to suppress error messages, the macro stops and the error information is displayed in a standard error message. However, if you have used the OnError action to suppress error messages, you may want to use the information stored in the MacroError object in a condition or a custom error message.

After an error has been handled, the information in the MacroError object is out of date, so it is a good idea to clear the object using the ClearMacroError action. This resets the error number in the MacroError object back to zero, and clears any other information about the error that is stored in the object, such as the error description, macro name, action name, condition, and arguments. This way, you can inspect the MacroError object again later to see if another error has occurred.

See also

Concepts

MacroError Object

Other resources

MacroError Object Members


Entities.Parent Property (Access)

 Copy code hover
[image]

Entities.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Parent

expression A variable that represents an Entities object.

See also

Concepts

Entities Collection

Other resources

Entities Object Members


Macro commands (Access 2013 custom web app)

 Copy code hover
[image]

Macro commands (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • RunDataMacro Macro Action (Access 2013 custom web app)

  • RunMacro Macro Action (Access 2013 custom web app)

  • SetVariable Macro Action (Access 2013 custom web app)


Resultant table not allowed to have more than one AutoNumber field. (Error 3090)

 Copy code hover
[image]

Resultant table not allowed to have more than one AutoNumber field. (Error 3090)
Send feedback

You tried to execute a query that would result in a table with more than one field that has an AutoNumber data type. Change the query to include only one AutoNumber field.


AccessObjectProperty Properties (Access)

 Copy code hover
[image]

AccessObjectProperty Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Name | You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.
Value | Determines or specifies the value of a built-in property of an AccessObject object. Read/write Variant.


DBEngine.CommitTrans Method (DAO)

 Copy code hover
[image]

DBEngine.CommitTrans Method (DAO)
Send feedback

Ends the current transaction and saves the changes.

Syntax

expression .CommitTrans(Option)

expression A variable that represents a DBEngine object.

Parameters

Name | Required/Optional | Data Type | Description
Option | Optional | Long | In a Microsoft Access workspace, you can include the dbForceOSFlush constant with CommitTrans. This forces the database engine to immediately flush all updates to disk, instead of caching them temporarily. Without using this option, a user could get control back immediately after the application program calls CommitTrans, turn the computer off, and not have the data written to disk. While using this option may affect your application's performance, it is useful in situations where the computer could be shut off before cached updates are saved to disk.

Remarks

The transaction methods BeginTrans, CommitTrans, and Rollback manage transaction processing during a session defined by a Workspace object. You use these methods with a Workspace object when you want to treat a series of changes made to the databases in a session as one unit.

Typically, you use transactions to maintain the integrity of your data when you must both update records in two or more tables and ensure changes are completed (committed) in all tables or none at all (rolled back). For example, if you transfer money from one account to another, you might subtract an amount from one and add the amount to another. If either update fails, the accounts no longer balance. Use the BeginTrans method before updating the first record, and then, if any subsequent update fails, you can use the Rollback method to undo all of the updates. Use the CommitTrans method after you successfully update the last record.

Note Note

Within one Workspace object, transactions are always global to the Workspace and aren't limited to only one Connection or Database object. If you perform operations on more than one connection or database within a Workspace transaction, resolving the transaction (that is, using the CommitTrans or Rollback method) affects all operations on all connections and databases within that workspace.

After you use CommitTrans, you can't undo changes made during that transaction unless the transaction is nested within another transaction that is itself rolled back. If you nest transactions, you must resolve the current transaction before you can resolve a transaction at a higher level of nesting.

If you want to have simultaneous transactions with overlapping, non-nested scopes, you can create additional Workspace objects to contain the concurrent transactions.

If you close a Workspace object without resolving any pending transactions, the transactions are automatically rolled back.

If you use the CommitTrans or Rollback method without first using the BeginTrans method, an error occurs.

Some ISAM databases used in a Microsoft Access workspace may not support transactions, in which case the Transactions property of the Database object or Recordset object is False. To make sure the database supports transactions, check the value of the Transactions property of the Database object before using the BeginTrans method. If you are using a Recordset object based on more than one database, check the Transactions property of the Recordset object. If a Recordset is based entirely on Microsoft Access database engine tables, you can always use transactions. Recordset objects based on tables created by other database products, however, may not support transactions. For example, you can't use transactions in a Recordset based on a Paradox table. In this case, the Transactions property is False. If the Database or Recordset doesn't support transactions, the methods are ignored and no error occurs.

You can't nest transactions if you are accessing ODBC data sources through the Microsoft Access database engine.

In ODBC workspaces, when you use CommitTrans your cursor may no longer be valid. Use the Requery method to view the changes in the Recordset, or close and re-open the Recordset.

Note Note

  • You can often improve the performance of your application by breaking operations that require disk access into transaction blocks. This buffers your operations and may significantly reduce the number of times a disk is accessed.

  • In a Microsoft Access workspace, transactions are logged in a file kept in the directory specified by the TEMP environment variable on the workstation. If the transaction log file exhausts the available storage on your TEMP drive, the database engine triggers a run-time error. At this point, if you use CommitTrans, an indeterminate number of operations are committed, but the remaining uncompleted operations are lost, and the operation has to be restarted. Using a Rollback method releases the transaction log and rolls back all operations in the transaction.

  • Closing a clone Recordset within a pending transaction will cause an implicit Rollback operation.


Syntax error in JOIN operation. (Error 3135)

 Copy code hover
[image]

Syntax error in JOIN operation. (Error 3135)
Send feedback

You entered an SQL statement that has an invalid join operation. It could be an inner join, outer join, or self-join.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


ObjectFrame.OnMouseUp Property (Access)

 Copy code hover
[image]

ObjectFrame.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Syntax

expression .OnMouseUp

expression A variable that represents an ObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


PageBreak.IsVisible Property (Access)

 Copy code hover
[image]

PageBreak.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Syntax

expression .IsVisible

expression A variable that represents a PageBreak object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

PageBreak Object

Other resources

PageBreak Object Members


Hierarchy Object (ADO MD Reference)

 Copy code hover
[image]

Hierarchy Object (ADO MD Reference)
Send feedback

In this section

  • Hierarchy Object (ADO MD)

  • Hierarchy Properties, Methods, and Events (ADO MD)


Cannot have aggregate function in ORDER BY clause

 Copy code hover
[image]

Cannot have aggregate function in ORDER BY clause <clause>. (Error 3097)
Send feedback

You cannot use an aggregate function in the ORDER BY clause of an SQL statement.


CommandButton.Top Property (Access)

 Copy code hover
[image]

CommandButton.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Syntax

expression .Top

expression A variable that represents a CommandButton object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


QueryDefs Methods (DAO)

 Copy code hover
[image]

QueryDefs Methods (DAO)
Send feedback

In this section

  • QueryDefs.Append Method (DAO)

  • QueryDefs.Delete Method (DAO)

  • QueryDefs.Refresh Method (DAO)


TabControl.HoverForeTint Property (Access)

 Copy code hover
[image]

TabControl.HoverForeTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .HoverForeTint

expression A variable that represents a TabControl object.

Remarks

The HoverForeTint property contains a numeric expression that can be used to lighten the theme color in the HoverForeColor property. The default value of the HoverForeTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Report.KeyPress Event (Access)

 Copy code hover
[image]

Report.KeyPress Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a report has the focus. This event also occurs if you send an ANSI keystroke to a report by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Version Information

Version Added: Access 2007

Syntax

expression .KeyPress(KeyAscii, )

expression A variable that represents a Report object.

Parameters

Name | Required/Optional | Data Type | Description
KeyAscii | Required | Integer | Returns a numeric ANSI key code. The KeyAscii argument is passed by reference; changing it sends a different character to the object. Setting the KeyAscii argument to 0 cancels the keystroke so that the object doesn't recognize that a key was pressed.

Remarks

To run a macro or event procedure when this event occurs, set the OnKeyPress property to the name of the macro or to [Event Procedure].

A report will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the report to Yes. With this property setting, all keyboard events occur first for the report, and then for the control that has the focus. You can respond to specific keys pressed in the report, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a report.

If you press and hold down an ANSI key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, and then the KeyUp event occurs.

A KeyPress event can involve any printable keyboard character, the CTRL key combined with a character from the standard alphabet or a special character, and the ENTER or BACKSPACE key. You can use the KeyDown and KeyUp event procedures to handle any keystroke not recognized by the KeyPress event, such as function keys, navigation keys, and any combinations of these with keyboard modifiers (ALT, SHIFT, or CTRL keys). Unlike the KeyDown and KeyUp events, the KeyPress event doesn't indicate the physical state of the keyboard; instead, it indicates the ANSI character that corresponds to the pressed key or key combinations.

KeyPress interprets the uppercase and lowercase version of each character as a separate key code and, therefore, as two separate characters.

Note Note

The BACKSPACE key is part of the ANSI character set, but the DEL key is not. If you delete a character in a control by using the BACKSPACE key, you cause a KeyPress event; if you use the DEL key, you don't.

The KeyDown and KeyPress events occur when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

See also

Concepts

Report Object

Other resources

Report Object Members


Attachment.Enter Event (Access)

 Copy code hover
[image]

Attachment.Enter Event (Access)
See also Send feedback

Published: July 16, 2012

The Enter event occurs before a control actually receives the focus from a control on the same form.

Version Information

Version Added: Access 2007

Syntax

expression .Enter

expression A variable that represents an Attachment object.

Remarks

The Enter event applies only to controls on a form, not controls on a report. This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when these events occur, set the OnEnter or OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Enter event occurs before the GotFocus event. The Exit event occurs before the LostFocus event.

Unlike the GotFocus and LostFocus events, the Enter and Exit events don't occur when a form receives or loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control to which you moved.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform to which the focus moved)

ß

GotFocus (for the control on the subform to which the focus moved)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


OptionButton.Section Property (Access)

 Copy code hover
[image]

OptionButton.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Syntax

expression .Section

expression A variable that represents an OptionButton object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Report.Report Property (Access)

 Copy code hover
[image]

Report.Report Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Report property to refer to a report or to refer to the report associated with a subreport control. Read-only Report.

Syntax

expression .Report

expression A variable that represents a Report object.

Remarks

This property is typically used to refer to the report contained in a subreport control.

Note Note

When you use the Reports collection, you must specify the name of the report.

Example

The following example uses the Report property to refer to a control on a subreport.

VBA Copy code Copy code
Dim curTotalSales As Currency

curTotalSales = Reports!Sales!Employees.Report!TotalSales

See also

Concepts

Report Object

Other resources

Report Object Members


TextBox.IMEHold Property (Access)

 Copy code hover
[image]

TextBox.IMEHold Property (Access)
See also Send feedback

Published: July 16, 2012

Language-specific information You can use the IMEHold/Hold KanjiConversionMode property to show whether the Kanji Conversion Mode is maintained when the control loses the focus. Read/write Boolean.

Syntax

expression .IMEHold

expression A variable that represents a TextBox object.

Remarks

The IMEHold/Hold KanjiConversionMode property uses the following settings.

Setting | Description
True | Maintains the Kanji Conversion Mode set in the last control.
False | Does not maintain the Kanji Conversion Mode set in the last control (default).

By setting the IMEMode/KanjiConversionMode property, you can designate whether or not the Kanji Conversion Mode is maintained when the control loses the focus. If this property is set to Yes, the Kanji Conversion Mode setting is maintained when the control loses the focus and once that control regains the focus, the Kanji Conversion Mode setting for that control is restored. If this property is set to No (default setting), the Kanji Conversion Mode will be set by the IMEMode/KanjiConversionMode property for that control.

Note Note

To set the Kanji Conversion Mode when the focus shifts to the control, set the IMEMode/KanjiConversionMode property.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Label.DblClick Event (Access)

 Copy code hover
[image]

Label.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Syntax

expression .DblClick(Cancel)

expression A variable that represents a Label object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the DblClick event occurs. Setting the Cancel argument to True (-1) cancels the DblClick event.

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

Label Object

Other resources

Label Object Members


Cannot change a rule while the rules for this table are in use. (Error 3302)

 Copy code hover
[image]

Cannot change a rule while the rules for this table are in use. (Error 3302)
Send feedback

A record in this table has been changed by another user, or has been changed by you in a separate session of your application, and is currently locked. You cannot modify the rules in a table while a record in that table is locked.

If you have locked the record in a separate session, save the record, and then make your changes. If another user has locked the record, wait a little while, and then save your rule modifications.


SmartTagAction.Execute Method (Access)

 Copy code hover
[image]

SmartTagAction.Execute Method (Access)
See also Send feedback

Published: July 16, 2012

The Execute method performs the specified smart tag action.

Syntax

expression .Execute

expression A variable that represents a SmartTagAction object.

Remarks

Smart tag actions are processes that are programmed into smart tags that allow users to perform certain functions related to the smart tag. For example, one action for a smart tag might be to access a Web site, while another action inserts contact information from Microsoft Outlook, while yet another action displays a map and driving directions.

Calling the Execute method will result in a run-time error if the smart tag is:

  • Located on a report.

  • Located on a form in Design view, PivotTable view, or PivotChart view.

See also

Concepts

SmartTagAction Object

Other resources

SmartTagAction Object Members


Form.PopUp Property (Access)

 Copy code hover
[image]

Form.PopUp Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether a form opens as a pop-up window. Read/write Boolean.

Syntax

expression .PopUp

expression A variable that represents a Form object.

Remarks

The PopUp property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The form opens as a pop-up window. It remains on top of all other Microsoft Access windows.
No | False | (Default) The form isn't a pop-up window.

The PopUp property can be set only in form Design view.

To specify the type of border you want on a pop-up window, use the BorderStyle property. You typically set the BorderStyle property to Thin for pop-up windows.

To create a custom dialog box, set the Modal property to Yes, the PopUp property to Yes, and the BorderStyle property to Dialog.

Setting the PopUp property to Yes makes the form a pop-up window only when you do one of the following:

  • Open it in Form view from the Database window.

  • Open it in Form view by using a macro or Visual Basic.

  • Switch from Design view to Form view.

When the PopUp property is set to Yes, you can't switch to other views from Form view because the form's toolbar isn't available. (You can't switch a pop-up form from Form view to Datasheet view, even in a macro or Visual Basic.) You must close the form and reopen it in Design or Datasheet view.

The form isn't a pop-up form in Design or Datasheet view, and also isn't if you switch from Datasheet to Form view.

Note Note

You can use the Dialog setting of the Window Mode argument of the OpenForm action to open a form with its PopUp and Modal properties set to Yes.

When you maximize a window in Microsoft Access, all other windows are also maximized when you open them or switch to them. However, pop-up forms aren't maximized. If you want a form to maintain its size when other windows are maximized, set its PopUp property to Yes.

See also

Concepts

Form Object

Other resources

Form Object Members


Rectangle Methods (Access)

 Copy code hover
[image]

Rectangle Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.


AcFindMatch Enumeration (Access)

 Copy code hover
[image]

AcFindMatch Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies where the data is located in the field.

Name | Value | Description
acAnywhere | 0 | Search for data in any part of the field.
acEntire | 1 | Search for data that fills the entire field.
acStart | 2 | Search for data located at the beginning of the field.


How to: Use User Input to Build Filter Criteria

 Copy code hover
[image]

How to: Use User Input to Build Filter Criteria
Send feedback

The BuildCriteria method enables you to easily construct criteria for a filter based on user input. It parses the expression argument in the same way that the expression would be parsed had it been entered in the query design grid, in Filter By Form or Server Filter By Form mode.

The following example prompts the user to enter the first few letters of a product's name and then uses the BuildCriteria method to construct a criteria string based on the user's input. Next, the procedure provides this string as an argument to the Filter property of a form named Products. Finally, the FilterOn property is set to apply the filter.

VBA Copy code Copy code
Sub SetFilter()
    Dim frm As Form, strMsg As String
    Dim strInput As String, strFilter As String

    ' Open Products form in Form view.
    DoCmd.OpenForm "Products"

    ' Return Form object variable pointing to Products form.
    Set frm = Forms!Products

    strMsg = "Enter one or more letters of product name " _
        & "followed by an asterisk."

    ' Prompt user for input.
    strInput = InputBox(strMsg)

    ' Build criteria string.
    strFilter = BuildCriteria("ProductName", dbText, strInput)

    ' Set Filter property to apply filter.
    frm.Filter = strFilter

    ' Set FilterOn property; form now shows filtered records.
    frm.FilterOn = True
End Sub


TextBox.LeftPadding Property (Access)

 Copy code hover
[image]

TextBox.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .LeftPadding

expression A variable that represents a TextBox object.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


The Microsoft Access database engine could not execute the SQL statement because it contains a field that has an invalid data type. (Error 3169)

 Copy code hover
[image]

The Microsoft Access database engine could not execute the SQL statement because it contains a field that has an invalid data type. (Error 3169)
Send feedback

You tried to execute an SQL statement that contains a field that has an invalid field data type.

Possible causes:

  • You included a Memo or OLE Object field in an expression where it is not allowed.

  • You included a numeric aggregate function, such as Sum or StDev, that tried to perform a calculation on a Text field. Choose a different aggregate function.


Label.BottomMargin Property (Access)

 Copy code hover
[image]

Label.BottomMargin Property (Access)
See also Send feedback

Published: July 16, 2012

Along with the LeftMargin, RightMargin, and TopMargin properties, specifies the location of information displayed within a label control. Read/write Integer.

Syntax

expression .BottomMargin

expression A variable that represents a Label object.

Remarks

A control's displayed information location is the distance measured from the control's left, top, right, or bottom border to the left, top, right, or bottom edge of the displayed information. To use a unit of measurement different from the setting in the regional settings of Windows, specify the unit (for example, cm or in).

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

Example

The following example offsets the caption in the label "EmployeeID_Label" of the "Purchase Orders" form by 100 twips from the bottom of the label's border.

VBA Copy code Copy code
With Forms.Item("Purchase Orders").Controls.Item("EmployeeID_Label")
 .BottomMargin = 100
End With

See also

Concepts

Label Object

Other resources

Label Object Members


Application.DDETerminateAll Method (Access)

 Copy code hover
[image]

Application.DDETerminateAll Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the DDETerminateAll statement to close all open dynamic data exchange (DDE) channels.

Syntax

expression .DDETerminateAll

expression A variable that represents an Application object.

Return Value

Nothing

Remarks

For example, suppose you've opened two DDE channels between Microsoft Excel and Microsoft Access, one to retrieve system information about Microsoft Excel and one to transfer data. You can use the DDETerminateAll statement to close both channels simultaneously.

Using the DDETerminateAll statement is equivalent to executing a DDETerminate statement for each open channel number. Like the DDETerminate statement, the DDETerminateAll statement has no effect on active DDE link expressions in fields on forms or reports.

If there are no DDE channels open, the DDETerminateAll statement runs without causing a run-time error.

Tips

  • If you interrupt a procedure that performs DDE, you may inadvertently leave channels open. To avoid exhausting system resources, use the DDETerminateAll statement in your code or from the Immediate (lower) pane of the Debug window while debugging code that performs DDE.

  • If you need to manipulate another application's objects from Microsoft Access, you may want to consider using Automation.

See also

Concepts

Application Object

Other resources

Application Object Members


Attachment.HorizontalAnchor Property (Access)

 Copy code hover
[image]

Attachment.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the attachment is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .HorizontalAnchor

expression A variable that represents an Attachment object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


CommandButton.HoverColor Property (Access)

 Copy code hover
[image]

CommandButton.HoverColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color displayed on the control when the user rests the mouse cursor over it. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HoverColor

expression A variable that represents a CommandButton object.

Remarks

The HoverColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet . Using the Color Builder enables you to define custom colors.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


CheckBox.Left Property (Access)

 Copy code hover
[image]

CheckBox.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Syntax

expression .Left

expression A variable that represents a CheckBox object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


TextBox.Controls Property (Access)

 Copy code hover
[image]

TextBox.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Syntax

expression .Controls

expression A variable that represents a TextBox object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ListBox.FontItalic Property (Access)

 Copy code hover
[image]

ListBox.FontItalic Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontItalic property to specify whether text is italic in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontItalic

expression A variable that represents a ListBox object.

Remarks

The FontItalic property uses the following settings.

Setting | Description
True | The text is italic.
False | (Default) The text isn't italic.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Creating the Connection String

 Copy code hover
[image]

Creating the Connection String
Send feedback

ADO directly supports five arguments in a connection string. Other arguments are passed to the provider that is named in the Provider argument without any processing by ADO.

Argument | Description
Provider | Specifies the name of a provider to use for the connection.
File Name | Specifies the name of a provider-specific file (for example, a persisted data source object) containing preset connection information.
URL | Specifies the connection string as an absolute URL identifying a resource, such as a file or directory.
Remote Provider | Specifies the name of a provider to use when opening a client-side connection. (Remote Data Service only.)
Remote Server | Specifies the path name of the server to use when opening a client-side connection. (Remote Data Service only.)
Note Note

In the following examples and throughout the ADO Programmer's Guide, the user id "MyId" with a password of "123aBc" is used to authenticate against the server. You should substitute these values with valid login credentials for your server. Also, substitute the name of your server for "MySqlServer".

The HelloData application in Chapter 1 used the following connection string:

Copy code Copy code

m_sConnStr = "Provider='SQLOLEDB';Data Source='MySqlServer';" & _
 "Initial Catalog='Northwind';Integrated Security='SSPI';"

The only ADO parameter supplied in this connection string was "Provider=SQLOLEDB", which indicated the Microsoft OLE DB Provider for SQL Server. Other valid parameters that can be passed in the connection string can be determined by referring to individual providers' documentation. According to the OLE DB Provider for SQL Server documentation, you can substitute "Server" for the Data Source parameter and "Database" for the Initial Catalog parameter. Thus, the following connection string would produce results identical to the first:

Copy code Copy code

m_sConnStr = "Provider='SQLOLEDB';Server='MySqlServer';" & _
 "Database='Northwind';Integrated Security='SSPI';"

To open the connection, simply pass the connection string as the first argument in the Connection object Open method:

Copy code Copy code

objConn.Open m_sConnStr

It is also possible to supply much of this information by setting properties of the Connection object before opening the connection. For example, you could achieve the same effect as the connection string above by using the following code:

Copy code Copy code

With objConn
 .Provider = "SQLOLEDB"
 .DefaultDatabase = "Northwind"
 .Properties("Data Source") = "MySqlServer"
 .Properties("Integrated Security") = "SSPI"
 .Open
End With


TextBox.BeforeUpdate Event (Access)

 Copy code hover
[image]

TextBox.BeforeUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The BeforeUpdate event occurs before changed data in a control or record is updated.

Syntax

expression .BeforeUpdate(Cancel)

expression A variable that represents a TextBox object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the BeforeUpdate event occurs. Setting the Cancel argument to True (-1) cancels the BeforeUpdate event.

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's BeforeUpdate event does occur.

To run a macro or event procedure when this event occurs, set the BeforeUpdate property to the name of the macro or to [Event Procedure].

This event does not apply to option buttons, check boxes, or toggle buttons in an option group. It applies only to the option group itself.

The BeforeUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB. When the focus leaves the record or if the user clicks Save Record on the Records menu, the entire record is updated, and the data is saved in the database.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

BeforeUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. BeforeUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For forms, you can use the BeforeUpdate event to cancel updating of a record before moving to another record.

If the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

You often use the BeforeUpdate event to validate data, especially when you perform complex validations, such as those that:

  • Involve conditions for more than one value on a form.

  • Display different error messages for different data entered.

  • Can be overridden by the user.

  • Contain references to controls on other forms or contain user-defined functions.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

A run-time error will occur if you attempt to modify the data contained in the control that fired the BeforeUpdate event in the event's procedure.

Example

The following example shows how you can use a BeforeUpdate event procedure to check whether a product name has already been entered in the database. After the user types a product name in the ProductName box, the value is compared to the ProductName field in the Products table. If there is a matching value in the Products table, a message is displayed that informs the user that the product has already been entered.

To try the example, add the following event procedure to a form named Products that contains a text box called ProductName.

VBA Copy code Copy code
Private Sub ProductName_BeforeUpdate(Cancel As Integer)
 If(Not IsNull(DLookup("[ProductName]", _
 "Products", "[ProductName] ='" _
 & Me!ProductName & "'"))) Then
 MsgBox "Product has already been entered in the database."
 Cancel = True
 Me!ProductName.Undo
 End If
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


How to: Insert, Update, and Delete Records From a Table Using Access SQL

 Copy code hover
[image]

How to: Insert, Update, and Delete Records From a Table Using Access SQL
Send feedback

Inserting Records into a Table

There are essentially two methods for adding records to a table. The first is to add one record at a time; the second is to add many records at a time. In both cases, you use the SQL statement INSERT INTO to accomplish the task. INSERT INTO statements are commonly referred to as append queries.

To add one record to a table, you must use the field list to define which fields to put the data in, and then you must supply the data itself in a value list. To define the value list, use the VALUES clause. For example, the following statement will insert the values "1", "Kelly", and "Jill" into the CustomerID, Last Name, and First Name fields, respectively.

VBA Copy code Copy code
INSERT INTO tblCustomers (CustomerID, [Last Name], [First Name])
    VALUES (1, 'Kelly', 'Jill')

You can omit the field list, but only if you supply all the values that record can contain.

VBA Copy code Copy code
INSERT INTO tblCustomers
    VALUES (1, Kelly, 'Jill', '555-1040', 'someone@microsoft.com')

To add many records to a table at one time, use the INSERT INTO statement along with a SELECT statement. When you are inserting records from another table, each value being inserted must be compatible with the type of field that will be receiving the data.

The following INSERT INTO statement inserts all the values in the CustomerID, Last Name, and First Name fields from the tblOldCustomers table into the corresponding fields in the tblCustomers table.

VBA Copy code Copy code
INSERT INTO tblCustomers (CustomerID, [Last Name], [First Name])
    SELECT CustomerID, [Last Name], [First Name]
    FROM tblOldCustomers

If the tables are defined exactly alike, you can leave out the field lists.

VBA Copy code Copy code
INSERT INTO tblCustomers
    SELECT * FROM tblOldCustomers

Updating Records in a Table

To modify the data that is currently in a table, you use the UPDATE statement, which is commonly referred to as an update query. The UPDATE statement can modify one or more records and generally takes this form.

VBA Copy code Copy code
UPDATE table name
    SET field name = some value

To update all the records in a table, specify the table name, and then use the SET clause to specify the field or fields to be changed.

VBA Copy code Copy code
UPDATE tblCustomers
    SET Phone = 'None'

In most cases, you will want to qualify the UPDATE statement with a WHERE clause to limit the number of records changed.

VBA Copy code Copy code
UPDATE tblCustomers
    SET Email = 'None'
    WHERE [Last Name] = 'Smith'

Deleting Records from a Table

To delete the data that is currently in a table, you use the DELETE statement, which is commonly referred to as a delete query. This is also known as truncating a table. The DELETE statement can remove one or more records from a table and generally takes this form:

VBA Copy code Copy code
DELETE FROM table list

The DELETE statement does not remove the table structure—only the data that is currently being held by the table structure. To remove all the records from a table, use the DELETE statement and specify which table or tables from which you want to delete all the records.

VBA Copy code Copy code
DELETE FROM tblInvoices

In most cases, you will want to qualify the DELETE statement with a WHERE clause to limit the number of records to be removed.

VBA Copy code Copy code
DELETE FROM tblInvoices
    WHERE InvoiceID = 3

If you want to remove data only from certain fields in a table, use the UPDATE statement and set those fields equal to NULL, but only if they are nullable fields.

VBA Copy code Copy code
UPDATE tblCustomers
    SET Email = Null

Inserting Records into a Table

There are essentially two methods for adding records to a table. The first is to add one record at a time; the second is to add many records at a time. In both cases, you use the SQL statement INSERT INTO to accomplish the task. INSERT INTO statements are commonly referred to as append queries.

To add one record to a table, you must use the field list to define which fields to put the data in, and then you must supply the data itself in a value list. To define the value list, use the VALUES clause. For example, the following statement will insert the values "1", "Kelly", and "Jill" into the CustomerID, Last Name, and First Name fields, respectively.

VBA Copy code Copy code
INSERT INTO tblCustomers (CustomerID, [Last Name], [First Name])
    VALUES (1, 'Kelly', 'Jill')

You can omit the field list, but only if you supply all the values that record can contain.

VBA Copy code Copy code
INSERT INTO tblCustomers
    VALUES (1, Kelly, 'Jill', '555-1040', 'someone@microsoft.com')

To add many records to a table at one time, use the INSERT INTO statement along with a SELECT statement. When you are inserting records from another table, each value being inserted must be compatible with the type of field that will be receiving the data.

The following INSERT INTO statement inserts all the values in the CustomerID, Last Name, and First Name fields from the tblOldCustomers table into the corresponding fields in the tblCustomers table.

VBA Copy code Copy code
INSERT INTO tblCustomers (CustomerID, [Last Name], [First Name])
    SELECT CustomerID, [Last Name], [First Name]
    FROM tblOldCustomers

If the tables are defined exactly alike, you can leave out the field lists.

VBA Copy code Copy code
INSERT INTO tblCustomers
    SELECT * FROM tblOldCustomers

Updating Records in a Table

To modify the data that is currently in a table, you use the UPDATE statement, which is commonly referred to as an update query. The UPDATE statement can modify one or more records and generally takes this form:

VBA Copy code Copy code
UPDATE table name
    SET field name = some value

To update all the records in a table, specify the table name, and then use the SET clause to specify the field or fields to be changed.

VBA Copy code Copy code
UPDATE tblCustomers
    SET Phone = 'None'

In most cases, you will want to qualify the UPDATE statement with a WHERE clause to limit the number of records changed.

VBA Copy code Copy code
UPDATE tblCustomers
    SET Email = 'None'
    WHERE [Last Name] = 'Smith'

Deleting Records from a Table

To delete the data that is currently in a table, you use the DELETE statement, which is commonly referred to as a delete query. This is also known as truncating a table. The DELETE statement can remove one or more records from a table and generally takes this form:

VBA Copy code Copy code
DELETE FROM table list

The DELETE statement does not remove the table structure—only the data that is currently being held by the table structure. To remove all the records from a table, use the DELETE statement and specify which table or tables from which you want to delete all the records.

VBA Copy code Copy code
DELETE FROM tblInvoices

In most cases, you will want to qualify the DELETE statement with a WHERE clause to limit the number of records to be removed.

VBA Copy code Copy code
DELETE FROM tblInvoices
    WHERE InvoiceID = 3

If you want to remove data only from certain fields in a table, use the UPDATE statement and set those fields equal to NULL, but only if they are nullable fields.

VBA Copy code Copy code
UPDATE tblCustomers
    SET Email = Null


FetchOptions Property (RDS)

 Copy code hover
[image]

FetchOptions Property (RDS)
Send feedback

Indicates the type of asynchronous fetching.

Setting and Return Values

Sets or returns one of the following values.

Constant | Description
adcFetchUpFront | All the records of the Recordset are fetched before control is returned to the application. The complete Recordset is fetched before the application is allowed to do anything with it.
adcFetchBackground | Control can return to the application as soon as the first batch of records has been fetched. A subsequent read of the Recordset that attempts to access a record not fetched in the first batch will be delayed until the sought record is actually fetched, at which time control returns to the application.
adcFetchAsync | Default. Control returns immediately to the application while records are fetched in the background. If the application attempts to read a record that hasn't yet been fetched, the record closest to the sought record will be read and control will return immediately, indicating that the current end of the Recordset has been reached. For example, a call to MoveLast will move the current record position to the last record actually fetched, even though more records will continue to populate the Recordset.
Note Note

Each client-side executable file that uses these constants must provide declarations for them. You can cut and paste the constant declarations you want from the file Adcvbs.inc, located in the C:\Program Files\Common Files\System\MSADC folder.

Remarks

In a Web application, you will usually want to use adcFetchAsync (the default value), because it provides better performance. In a compiled client application, you will usually want to use adcFetchBackground.


Label.FontUnderline Property (Access)

 Copy code hover
[image]

Label.FontUnderline Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontUnderline property to specify whether text is underlined in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontUnderline

expression A variable that represents a Label object.

Remarks

The FontUnderline property uses the following settings.

Setting | Description
True | The text is underlined.
False | (Default) The text isn't underlined.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

Label Object

Other resources

Label Object Members


WSParameter Properties (Access)

 Copy code hover
[image]

WSParameter Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Type | Get the data type of the specified parameter. Read-only Integer.


Keys Collection (ADOX)

 Copy code hover
[image]

Keys Collection (ADOX)
Send feedback

Contains all Key objects of a table.

Remarks

The Append method for a Keys collection is unique for ADOX. You can:

  • Add a new key to the collection with the Append method.

The remaining properties and methods are standard to ADO collections. You can:

  • Access a key in the collection with the Item property.

  • Return the number of keys contained in the collection with the Count property.

  • Remove a key from the collection with the Delete method.

  • Update the objects in the collection to reflect the current database's schema with the Refresh method.


SubForm.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

SubForm.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified subform. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthBottom

expression A variable that represents a SubForm object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


This is not a Microsoft Excel 5.0 file. (Error 3431)

 Copy code hover
[image]

This is not a Microsoft Excel 5.0 file. (Error 3431)
Send feedback

You attempted to read a file as a Microsoft Excel version 5.0 file, but the file is not in this format.


Section.OnRetreat Property (Access)

 Copy code hover
[image]

Section.OnRetreat Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Retreat box in the Properties window of a report section. Read/write String.

Syntax

expression .OnRetreat

expression A variable that represents a Section object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Retreat event occurs when Microsoft Access returns to a previous report section during report formatting.

The OnRetreat value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Retreat box in the report section's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Retreat box is blank, the property value is an empty string.

Example

The following example prints the value of the OnRetreat property in the Immediate window for the "GroupHeader0" section in the "Purchase Order" report.

VBA Copy code Copy code
Debug.Print Reports("Purchase Order").Section("GroupHeader0").OnRetreat

See also

Concepts

Section Object

Other resources

Section Object Members


ComboBox.GridlineWidthTop Property (Access)

 Copy code hover
[image]

ComboBox.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified combo box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthTop

expression A variable that represents a ComboBox object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Property.Name Property (DAO)

 Copy code hover
[image]

Property.Name Property (DAO)
Send feedback

Returns or sets the name of the specified object. Read/write String if the object has not been appended to a collection. Read-only String if the object has been appended to a collection.

Syntax

expression .Name

expression A variable that represents a Property object.

Remarks

The Name property of a built-in property is always read-only.

The maximum length for the name of a Property object is 64 characters.


NavigationControl.Name Property (Access)

 Copy code hover
[image]

NavigationControl.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .Name

expression A variable that represents a NavigationControl object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Form.SubdatasheetHeight Property (Access)

 Copy code hover
[image]

Form.SubdatasheetHeight Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SubdatasheetHeight property to specify or determine the default display height of a subdatasheet when expanded. Read/write Integer.

Syntax

expression .SubdatasheetHeight

expression A variable that represents a Form object.

Remarks

the SubdatasheetHeight property's value is expressed in twips.

To set the SubdatasheetHeight property by using Visual Basic, you must first create the property by using the DAO CreateProperty method.

If the subdatasheet includes more records than the height setting can accommodate, a vertical scrollbar is displayed.

The SubdatasheetHeight property setting includes the New Record row if adding new records is supported. It does not include the column header row or scrollbar region.

The SubdatasheetHeight and SubdatasheetExpanded properties take effect on the subform control when the form is in datasheet view.

Example

The following example resizes the height of the subdatasheet in the "Purchase Orders" form (containing a subform) to show only one line of the subdatasheet at a time (measured at about 400 twips), accompanied by a vertical scrollbar. The number 400 is arbitrary, and will vary based on monitor resolution and default font size. This behavior can only be seen in Datasheet View.

VBA Copy code Copy code
Forms("Purchase Orders").SubdatasheetHeight = 400

See also

Concepts

Form Object

Other resources

Form Object Members


TableDef.ConflictTable Property (DAO)

 Copy code hover
[image]

TableDef.ConflictTable Property (DAO)
Send feedback

Returns the name of a conflict table containing the database records that conflicted during the synchronization of two replicas (Microsoft Access workspaces only). Read-only String.

Syntax

expression .ConflictTable

expression An expression that returns a TableDef object.

Remarks

The return value is a String data type that is a zero-length string ("") if there is no conflict table or the database isn't a replica.

If two users at two separate replicas each make a change to the same record in the database, the changes made by one user will fail to be applied to the other replica. Consequently, the user with the failed change must resolve the conflicts.

Conflicts occur at the record level, not between fields. For example, if one user changes the Address field and another updates the Phone field in the same record, then one change is rejected. Because conflicts occur at the record level, the rejection occurs even though the successful change and the rejected change are unlikely to result in a true conflict of information.

The synchronization mechanism handles the record conflicts by creating conflict tables, which contain the information that would have been placed in the table, if the change had been successful. You can examine these conflict tables and work through them row by row, fixing whatever is appropriate.

All conflict tables are named table_conflict, where table is the original name of the table, truncated to the maximum table name length.


Filtering for Updated Records
Send feedback

Filtering for Updated Records

Before you call UpdateBatch, you can use the Recordset Filter property to view only those records which have been changed since the Recordset was opened or the last call to UpdateBatch. To do this, set Filter equal to adFilterPendingRecords to determine how many records will be updated, as shown below.

This example extends the previous UpdateBatch example by filtering the Recordset just before calling the UpdateBatch, showing the user which records will change and allowing her to cancel the update (using the CancelBatch method).

Copy code Copy code

'BeginFilterAffected
    objRs1.Filter = adFilterPendingRecords
    objRs1.MoveFirst

    strMsg = "The following " & objRs1.RecordCount & " values will " & _
             "be updated. Do you wish to proceed?"
    While Not objRs1.EOF
        strMsg = strMsg & vbCrLf & objRs1(0) & vbTab & objRs1(1) & vbTab & _
                 objRs1(2) & vbCrLf
        objRs1.MoveNext
    Wend

    blnResp = MsgBox(strMsg, vbYesNo, "Proceed with Update?")
    If blnResp = True Then
        objRs1.UpdateBatch
    Else
        objRs1.CancelBatch
    End If
'EndFilterAffected


PARAMETERS Declaration (Microsoft Access SQL)

 Copy code hover
[image]

PARAMETERS Declaration (Microsoft Access SQL)
Send feedback

Declares the name and data type of each parameter in a parameter query.

Syntax

PARAMETERS name datatype [, name datatype [, …]]

The PARAMETERS declaration has these parts:

Part | Description
name | The name of the parameter. Assigned to the Name property of the Parameter object and used to identify this parameter in the Parameters collection. You can use name as a string that is displayed in a dialog box while your application runs the query. Use brackets ([ ]) to enclose text that contains spaces or punctuation. For example, [Low price] and [Begin report with which month?] are valid name arguments.
datatype | One of the primary Microsoft Access SQL data types or their synonyms.

Remarks

For queries that you run regularly, you can use a PARAMETERS declaration to create a parameter query. A parameter query can help automate the process of changing query criteria. With a parameter query, your code will need to provide the parameters each time the query is run.

The PARAMETERS declaration is optional but when included precedes any other statement, including SELECT.

If the declaration includes more than one parameter, separate them with commas. The following example includes two parameters:

SQL Copy code Copy code
PARAMETERS [Low price] Currency, [Beginning date] DateTime;

You can use name but not datatype in a WHERE or HAVING clause. The following example expects two parameters to be provided and then applies the criteria to records in the Orders table:

SQL Copy code Copy code
PARAMETERS [Low price] Currency,
[Beginning date] DateTime;
SELECT OrderID, OrderAmount
FROM Orders
WHERE OrderAmount > [Low price]
AND OrderDate >= [Beginning date];

Example

This example requires the user to provide a job title and then uses that job title as the criteria for the query.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

VBA Copy code Copy code
Sub ParametersX()

    Dim dbs As Database, qdf As QueryDef
    Dim rst As Recordset
    Dim strSql As String, strParm As String
    Dim strMessage As String
    Dim intCommand As Integer

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("NorthWind.mdb")

    ' Define the parameters clause.
    strParm = "PARAMETERS [Employee Title] CHAR; "

    ' Define an SQL statement with the parameters
    ' clause.
    strSql = strParm & "SELECT LastName, FirstName, " _
        & "EmployeeID " _
        & "FROM Employees " _
        & "WHERE Title =[Employee Title];"

    ' Create a QueryDef object based on the
    ' SQL statement.
    Set qdf = dbs.CreateQueryDef _
        ("Find Employees", strSql)

    Do While True
        strMessage = "Find Employees by Job " _
            & "title:" & Chr(13) _
            & "  Choose Job Title:" & Chr(13) _
            & "   1 - Sales Manager" & Chr(13) _
            & "   2 - Sales Representative" & Chr(13) _
            & "   3 - Inside Sales Coordinator"

        intCommand = Val(InputBox(strMessage))

        Select Case intCommand
            Case 1
                qdf("Employee Title") = _
                    "Sales Manager"
            Case 2
                qdf("Employee Title") = _
                    "Sales Representative"
            Case 3
                qdf("Employee Title") = _
                    "Inside Sales Coordinator"
            Case Else
                Exit Do
        End Select

        ' Create a temporary snapshot-type Recordset.
        Set rst = qdf.OpenRecordset(dbOpenSnapshot)

        ' Populate the Recordset.
        rst.MoveLast

        ' Call EnumFields to print the contents of the
        ' Recordset. Pass the Recordset object and desired
        ' field width.
        EnumFields rst, 12

    Loop

    ' Delete the QueryDef because this is a
    ' demonstration.
    dbs.QueryDefs.Delete "Find Employees"

    dbs.Close

End Sub


Report.DrawStyle Property (Access)

 Copy code hover
[image]

Report.DrawStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DrawStyle property to specify the line style when using the Line and Circle methods to print lines on reports. Read/write Integer.

Syntax

expression .DrawStyle

expression A variable that represents a Report object.

Remarks

The DrawStyle property uses the following settings.

Setting | Description
0 | (Default) Solid line, transparent interior
1 | Dash, transparent interior
2 | Dot, transparent interior
3 | Dash-dot, transparent interior
4 | Dash-dot-dot, transparent interior
5 | Invisible line, transparent interior
6 | Invisible line, solid interior
Note Note

You can set this property in an event procedure specified by a section's OnPrint property setting.

The DrawStyle property produces the results described in the preceding table if the DrawWidth property is set to 1. If the DrawWidth property setting is greater than 3, the DrawStyle property settings 1 through 4 produce a solid line (the DrawStyle property value isn't changed).

See also

Concepts

Report Object

Other resources

Report Object Members


CheckBox.InSelection Property (Access)

 Copy code hover
[image]

CheckBox.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents a CheckBox object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ReadyState Property Example (VBScript)

 Copy code hover
[image]

ReadyState Property Example (VBScript)
Send feedback

The following example shows how to read the ReadyState property of the RDS.DataControl object at run time in VBScript code. ReadyState is a read-only property.

To test this example, cut and paste this code between the <Body> and </Body> tags in a normal HTML document and name it RDSReadySt.asp. Use Find to locate the file Adovbs.inc and place it in the directory you plan to use. ASP script will identify your server.

Copy code Copy code
<!-- BeginReadyStateVBS --><%@ Language=VBScript %>
<% 'use the following META tag instead of adovbs.inc%><!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->
<html><head>
<meta name="VI60_DefaultClientScript" content=VBScript><meta name="GENERATOR" content="Microsoft Visual Studio 6.0">
<title>RDS.DataControl ReadyState Property</title><style>
<!--body {
font-family: 'Verdana','Arial','Helvetica',sans-serif;BACKGROUND-COLOR:white;
COLOR:black;}
.thead {background-color: #008080;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.thead2 {background-color: #800000;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.tbody {text-align: center;
background-color: #f7efde;font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;}
--></style>
</head>
<body><H1>RDS.DataControl ReadyState Property</H1>
<H2>RDS API Code Examples </H2><HR>
<!-- RDS.DataControl with parameters set at design time --><OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID=RDS>
<PARAM NAME="SQL" VALUE="Select * from Orders"><PARAM NAME="SERVER" VALUE="http://<%=Request.ServerVariables("SERVER_NAME")%>">
<PARAM NAME="CONNECT" VALUE="Provider='sqloledb';Integrated Security='SSPI';Initial Catalog='Northwind'"><PARAM NAME="ExecuteOptions" VALUE="2">
<PARAM NAME="FetchOptions" VALUE="3"></OBJECT>
<TABLE DATASRC=#RDS><TBODY>
<TR><TD><SPAN DATAFLD="OrderID"></SPAN></TD>
</TR></TBODY>
</TABLE>
<Script Language="VBScript">
Sub Window_OnLoad
Select Case RDS.ReadyStatecase 2 'adcReadyStateLoaded
MsgBox "Executing Query"case 3 'adcReadyStateInteractive
MsgBox "Fetching records in background"case 4 'adcReadyStateComplete
MsgBox "All records fetched"End Select
End Sub</Script>
</body></html>
<!-- EndReadyStateVBS -->


CommandText Property (ADO)

 Copy code hover
[image]

CommandText Property (ADO)
Send feedback

Indicates the text of a command to be issued against a provider.

Settings and Return Values

Sets or returns a String value that contains a provider command, such as an SQL statement, a table name, a relative URL, or a stored procedure call. Default is "" (zero-length string).

Remarks

Use the CommandText property to set or return the text of a command represented by a Command object. Usually this will be an SQL statement, but can also be any other type of command statement recognized by the provider, such as a stored procedure call. An SQL statement must be of the particular dialect or version supported by the provider's query processor.

If the Prepared property of the Command object is set to True and the Command object is bound to an open connection when you set the CommandText property, ADO prepares the query (that is, a compiled form of the query that is stored by the provider) when you call the Execute or Open methods.

Depending on the CommandType property setting, ADO may alter the CommandText property. You can read the CommandText property at any time to see the actual command text that ADO will use during execution.

Use the CommandText property to set or return a relative URL that specifies a resource, such as a file or directory. The resource is relative to a location specified explicitly by an absolute URL, or implicitly by an open Connection object.

Note Note

URLs using the http scheme will automatically invoke the Microsoft OLE DB Provider for Internet Publishing. For more information, see Absolute and Relative URLs.


Recordset.Restartable Property (DAO)

 Copy code hover
[image]

Recordset.Restartable Property (DAO)
Send feedback

Returns a value that indicates whether a Recordset object supports the Requery method, which re-executes the query on which the Recordset object is based.

Syntax

expression .Restartable

expression A variable that represents a Recordset object.

Remarks

Table-type Recordset objects always return False.

Check the Restartable property before using the Requery method on a Recordset object. If the object's Restartable property is set to False, use the OpenRecordset method on the underlying QueryDef object to re-execute the query.

Example

This example demonstrates the Restartable property with different Recordset objects.

VBA Copy code Copy code
Sub RestartableX()

 Dim dbsNorthwind As Database
 Dim rstTemp As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind
 ' Open a table-type Recordset and print its
 ' Restartable property.
 Set rstTemp = .OpenRecordset("Employees", dbOpenTable)
 Debug.Print _
 "Table-type recordset from Employees table"
 Debug.Print " Restartable = " & rstTemp.Restartable
 rstTemp.Close

 ' Open a Recordset from an SQL statement and print its
 ' Restartable property.
 Set rstTemp = _
 .OpenRecordset("SELECT * FROM Employees")
 Debug.Print "Recordset based on SQL statement"
 Debug.Print " Restartable = " & rstTemp.Restartable
 rstTemp.Close

 ' Open a Recordset from a saved QueryDef object and
 ' print its Restartable property.
 Set rstTemp = .OpenRecordset("Current Product List")
 Debug.Print _
 "Recordset based on permanent QueryDef (" & _
 rstTemp.Name & ")"
 Debug.Print " Restartable = " & rstTemp.Restartable
 rstTemp.Close

 .Close
 End With

End Sub


Form.ResyncCommand Property (Access)

 Copy code hover
[image]

Form.ResyncCommand Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ResyncCommand property to specify or determine the SQL statement or stored procedure that will be used in an updateable snapshot of a table. Read/write String.

Syntax

expression .ResyncCommand

expression A variable that represents a Form object.

Remarks

The ResyncCommand property is a string expression representing a SQL statement or stored procedure that is parameterized by the key columns from the Unique Table in the output cursor, using ? as parameter markers.

The parameters must match in number and ordering to the set of key columns for the table identified by the UniqueTable property. The purpose of the ResyncCommand property is to pull in the "fixed up" values of a row in a recordset after an update has been made, including an update to a join column.

For data access pages and for forms based on views or non-parameterized SQL queries containing a join, if the ResyncCommand property is null, Microsoft Access determines an appropriate query to use for the resync operation. For data access pages and forms based on stored procedures or parameterized SQL statements, Access cannot determine an appropriate resync query at run time, so the user must supply the ResyncCommand string in order to get the correct row fix up behavior. If the ResyncCommand property is empty and Access cannot determine an appropriate query to use, the default ADO resync operation (to display the current values) occurs after an update or insert.

See also

Concepts

Form Object

Other resources

Form Object Members


TempVars.Parent Property (Access)

 Copy code hover
[image]

TempVars.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only Object.

Version Information

Version Added: Access 2007

Syntax

expression .Parent

expression A variable that represents a TempVars object.

See also

Concepts

TempVars Collection

Other resources

TempVars Object Members


TextBox.MouseUp Event (Access)

 Copy code hover
[image]

TextBox.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents a TextBox object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was released to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ComboBox.InSelection Property (Access)

 Copy code hover
[image]

ComboBox.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents a ComboBox object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ToggleButton.PressedForeColor Property (Access)

 Copy code hover
[image]

ToggleButton.PressedForeColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the text displayed on the control when the user clicks it. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .PressedForeColor

expression A variable that represents a ToggleButton object.

Remarks

The PressedForeColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Label.LayoutID Property (Access)

 Copy code hover
[image]

Label.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified label. Read-only Long.

Version Information

Version Added: Access 2007

Syntax

expression .LayoutID

expression A variable that represents a Label object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

Label Object

Other resources

Label Object Members


AcDataObjectType Enumeration (Access)

 Copy code hover
[image]

AcDataObjectType Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the GoToRecord method to specify the type of object that contains the record to make current.

Name | Value | Description
acActiveDataObject | -1 | The active object contains the record.
acDataForm | 2 | A form contains the record.
acDataFunction | 10 | A user-defined function contains the record (Microsoft Access project only).
acDataQuery | 1 | A query contains the record.
acDataReport | 3 | A report contains the record.
acDataServerView | 7 | A server view contains the record (Microsoft Access project only).
acDataStoredProcedure | 9 | A stored procedure contains the record (Microsoft Access project only).
acDataTable | 0 | A table contains the record.


Rectangle.Application Property (Access)

 Copy code hover
[image]

Rectangle.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a Rectangle object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


Attachment.FileType Property (Access)

 Copy code hover
[image]

Attachment.FileType Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the file extension of the specifed attachment. Read-only String.

Version Information

Version Added: Access 2007

Syntax

expression .FileType(var)

expression A variable that represents an Attachment object.

Parameters

Name | Required/Optional | Data Type | Description
var | Optional | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Field (ADO for Visual C++ Syntax)

 Copy code hover
[image]

Field (ADO for Visual C++ Syntax)
Send feedback

Methods

AppendChunk(VARIANT Data) GetChunk(long Length, VARIANT *pvar)

Properties

            get_ActualSize(long *pl)

get_Attributes(long *pl)

put_Attributes(long lAttributes)

get_DataFormat(IUnknown **ppiDF)

put_DataFormat(IUnknown *piDF)

get_DefinedSize(long *pl)

put_DefinedSize(long lSize)

get_Name(BSTR *pbstr)

get_NumericScale(BYTE *pbNumericScale)

put_NumericScale(BYTE bScale)

get_OriginalValue(VARIANT *pvar)

get_Precision(BYTE *pbPrecision)

put_Precision(BYTE bPrecision)

get_Type(DataTypeEnum *pDataType)

put_Type(DataTypeEnum DataType)

get_UnderlyingValue(VARIANT *pvar)

get_Value(VARIANT *pvar)

put_Value(VARIANT Val)


Cannot import password-protected spreadsheet. (Error 3244)

 Copy code hover
[image]

Cannot import password-protected spreadsheet. (Error 3244)
Send feedback

Return to the application that was used to save the spreadsheet, save the spreadsheet again without a password, and then try to import the spreadsheet again.


Recordset.StillExecuting Property (DAO)

 Copy code hover
[image]

Recordset.StillExecuting Property (DAO)
Send feedback

Syntax

expression .StillExecuting

expression A variable that represents a Recordset object.

Remarks

Use the StillExecuting property to determine if the most recently called asynchronous Execute or OpenConnection method (that is, a method executed with the dbRunAsync option) is complete. While the StillExecuting property is True, any returned object cannot be accessed.

Once the StillExecuting property returns False, following the OpenConnection call that returns the associated Connection object, the object can be referenced. So long as StillExecuting remains True, the object may not be referenced, other than to read the StillExecuting property.

Use the Cancel method to terminate execution of a task in progress.


Catalog ActiveConnection Property Example (VC++)

 Copy code hover
[image]

Catalog ActiveConnection Property Example (VC++)
Send feedback

Setting the ActiveConnection property to a valid, open connection "opens" the catalog. From an open catalog, you can access the schema objects contained within that catalog.

Copy code Copy code

// BeginActiveConnectionCpp
#import "c:\Program Files\Common Files\system\ado\msado15.dll"
#import "c:\Program Files\Common Files\system\ado\msadox.dll" no_namespace

#include "iostream.h"
#include "stdio.h"
#include "conio.h"

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void OpenConnectionX(void);
void OpenConnectionWithStringX(void);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 OpenConnectionX();

 OpenConnectionWithStringX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// OpenConnectionX Function //
// //
//////////////////////////////////////////////////////////
void OpenConnectionX(void)
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.
 _CatalogPtr m_pCatalog = NULL;

 //Define ADODB object pointers
 ADODB::_ConnectionPtr m_pCnn = NULL;

 // Define string variables.
 _bstr_t strcnn("Provider='Microsoft.JET.OLEDB.4.0';"
 "Data source = 'c:\\Program Files\\Microsoft Office\\"
 "Office\\Samples\\Northwind.mdb';");

 try
 {
 TESTHR(hr = m_pCnn.CreateInstance(__uuidof(ADODB::Connection)));
 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof (Catalog)));
 m_pCnn->Open(strcnn,"","",NULL);
 m_pCatalog->PutActiveConnection(_variant_t((IDispatch *) m_pCnn));
 _variant_t vIndex = (short) 0;
 cout<<m_pCatalog->Tables->GetItem(vIndex)->Type<<endl;
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }
 catch(...)
 {
 cout << "Error occured in OpenConnectionX...."<< endl;
 }

 if (m_pCnn)
 if (m_pCnn->State == 1)
 m_pCnn->Close();
}

//////////////////////////////////////////////////////////
// //
// OpenConnectionWithStringX Function //
// //
//////////////////////////////////////////////////////////
void OpenConnectionWithStringX(void)
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.
 _CatalogPtr m_pCatalog = NULL;

 // Define string variables.
 _bstr_t strcnn("Provider='Microsoft.JET.OLEDB.4.0';"
 "Data source = 'c:\\Program Files\\Microsoft Office\\"
 "Office\\Samples\\Northwind.mdb';");

 try
 {
 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof (Catalog)));
 m_pCatalog->PutActiveConnection(strcnn);
 _variant_t vIndex = (short) 0;
 cout<<m_pCatalog->Tables->GetItem(vIndex)->Type<<endl;
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }
 catch(...)
 {
 cout << "Error occured in OpenConnectionWithStringX...."<< endl;
 }
}
// EndActiveConnectionCpp


CommandButton.FontName Property (Access)

 Copy code hover
[image]

CommandButton.FontName Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontName property to specify the font for text in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write String.

Syntax

expression .FontName

expression A variable that represents a CommandButton object.

Remarks

The FontName property setting is the name of the font that the text is displayed in.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set this property only in an event procedure or in a macro specified by the OnPrint event property setting.

Font availability depends on your system and printer. If you select a font that your system can't display or that isn't installed, Windows substitutes a similar font.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Illegal Operation performed on a SQL Server Replica. (Error 3777)

 Copy code hover
[image]

Illegal Operation performed on a SQL Server Replica. (Error 3777)
Send feedback

Many operations cannot be executed from Microsoft SQL replicas. For example, you cannot delete or rename a table, add, delete, or rename a column in a table, make a local table replicable, exchange with another Jet Subscriber in the SQL replica set, or execute an exchange with the SQL Publication in any manner other than a Direct synchronization.


Errors Properties (DAO)

 Copy code hover
[image]

Errors Properties (DAO)
Send feedback

In this section

  • Errors.Count Property (DAO)


Cannot modify the design of table

 Copy code hover
[image]

Cannot modify the design of table <name>. It is in a read-only database. (Error 3370)
Send feedback

You cannot modify tables in a read-only database.


OptionGroup.BeforeUpdate Property (Access)

 Copy code hover
[image]

OptionGroup.BeforeUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.

Syntax

expression .BeforeUpdate

expression A variable that represents an OptionGroup object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeUpdate event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the BeforeUpdate event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).BeforeUpdate = "[Event Procedure]"

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Pass-through query must contain at least one character. (Error 3359)

 Copy code hover
[image]

Pass-through query must contain at least one character. (Error 3359)
Send feedback

The SQL string of a pass-through query must contain at least one character.


CommandButton.HoverTint Property (Access)

 Copy code hover
[image]

CommandButton.HoverTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the HoverColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .HoverTint

expression A variable that represents a CommandButton object.

Remarks

The HoverTint property contains a numeric expression that can be used to lighten the theme color in the HoverColor property. The default value of the HoverTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Operation canceled by user. (Error 3059)

 Copy code hover
[image]

Operation canceled by user. (Error 3059)
Send feedback

You stopped the operation before its normal completion. Some data changes may not have been saved.


ObjectFrame Object (Access)

 Copy code hover
[image]

ObjectFrame Object (Access)
See also Send feedback

Published: July 16, 2012

This object corresponds to an unbound object frame. The unbound object frame control displays a picture, chart, or any OLE object not stored in a table.

Remarks

For example, you can use an unbound object frame to display a chart that you created and stored in Microsoft Graph.

This control allows you to create or edit the object from within a Microsoft Access form or report by using the application in which the object was originally created.

To display objects that are stored in a Microsoft Access database, use a Bound object frame.

The object in an unbound object frame is the same for every record.

The unbound object frame can display linked or embedded objects.

You can use the unbound object frame or an image control to display unbound pictures in a form or report. The advantage of using the unbound object frame is that you can edit the object directly from the form or report. The advantage of using the image control is that it's faster to display.

See also

Concepts

Access Object Model Reference

Other resources

ObjectFrame Object Members


Report.OnUnload Property (Access)

 Copy code hover
[image]

Report.OnUnload Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Unload box in the Properties window of a form. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnUnload

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Unload event occurs after a report is closed but before it's removed from the screen.

The OnUnload value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Unload box in the report's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Unload box is blank, the property value is an empty string.

See also

Concepts

Report Object

Other resources

Report Object Members


ComboBox.FormatConditions Property (Access)

 Copy code hover
[image]

ComboBox.FormatConditions Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FormatConditions property to return a read-only reference to the FormatConditions collection and its related properties.

Syntax

expression .FormatConditions

expression A variable that represents a ComboBox object.

Example

The following example sets format properties for an existing conditional format for the "Textbox1" control.

VBA Copy code Copy code
With forms("forms1").Controls("Textbox1").FormatConditions(1)
 .BackColor = RGB(255,255,255)
 .FontBold = True
 .ForeColor = RGB(255,0,0)
End With

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Recordset2.MoveNext Method (DAO)

 Copy code hover
[image]

Recordset2.MoveNext Method (DAO)
Send feedback

Moves to the next record in a specified Recordset object and make that record the current record.

Syntax

expression .MoveNext

expression A variable that represents a Recordset2 object.

Remarks

Use the Move methods to move from record to record without applying a condition.

If you edit the current record, be sure you use the Update method to save the changes before you move to another record. If you move to another record without updating, your changes are lost without warning.

When you open a Recordset, the first record is current and the BOF property is False. If the Recordset contains no records, the BOF property is True, and there is no current record.

If you use MoveNext when the last record is current, the EOF property is True, and there is no current record. If you use MoveNext again, an error occurs, and EOF remains True.

If recordset refers to a table-type Recordset (Microsoft Access workspaces only), movement follows the current index. You can set the current index by using the Index property. If you don't set the current index, the order of returned records is undefined.

You can't use the MoveFirst, MoveLast, and MovePrevious methods on a forward-only-type Recordset object.

To move the position of the current record in a Recordset object a specific number of records forward or backward, use the Move method.


CommandButton.Section Property (Access)

 Copy code hover
[image]

CommandButton.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Syntax

expression .Section

expression A variable that represents a CommandButton object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ToggleButton.BorderColor Property (Access)

 Copy code hover
[image]

ToggleButton.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderColor

expression A variable that represents a ToggleButton object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Cannot define field more than once. (Error 3191)

 Copy code hover
[image]

Cannot define field more than once. (Error 3191)
Send feedback

You tried to create a table in which more than one field was defined with the same name. Each field name in a table must be unique.


CheckBox.Locked Property (Access)

 Copy code hover
[image]

CheckBox.Locked Property (Access)
See also Send feedback

Published: July 16, 2012

The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.

Syntax

expression .Locked

expression A variable that represents a CheckBox object.

Remarks

The default setting of the Locked property is True. This setting allows editing, adding, and deleting data.

Use the Locked property to protect data in a field by making it read-only. For example, you might want a control to only display information without allowing editing, or you might want to lock a control until a specific condition is met.

Example

The following example toggles the Enabled property of a command button and the Enabled and Locked properties of a control, depending on the type of employee displayed in the current record. If the employee is a manager, then the SalaryDetails button is enabled and the PersonalInfo control is unlocked and enabled.

VBA Copy code Copy code
Sub Form_Current()
 If Me!EmployeeType = "Manager" Then
 Me!SalaryDetails.Enabled = True
 Me!PersonalInfo.Enabled = True
 Me!PersonalInfo.Locked = False
 Else
 Me!SalaryDetails.Enabled = False
 Me!PersonalInfo.Enabled = False
 Me!PersonalInfo.Locked = True
 End If
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Report.BorderStyle Property (Access)

 Copy code hover
[image]

Report.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Syntax

expression .BorderStyle

expression A variable that represents a Report object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

Report Object

Other resources

Report Object Members


Error Members (DAO)

 Copy code hover
[image]

Error Members (DAO)
Send feedback

Error object contains details about data access errors, each of which pertains to a single operation involving DAO.

Properties

Name | Description
Description | Returns a descriptive string associated with an error. This is the default property for the Error object.
Number | Returns a numeric value specifying an error.
Source | Returns the name of the object or application that originally generated the error.


Label.Section Property (Access)

 Copy code hover
[image]

Label.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Syntax

expression .Section

expression A variable that represents a Label object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

Label Object

Other resources

Label Object Members


Sort Property Example (VC++)

 Copy code hover
[image]

Sort Property Example (VC++)
Send feedback

This example uses the Recordset object's Sort property to reorder the rows of a Recordset derived from the Authors table of the Pubs database. A secondary utility routine prints each row.

Copy code Copy code

// BeginSortCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void SortX(void);
void SortXprint(_bstr_t title, _RecordsetPtr rstp);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 SortX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// SortX Function //
// //
//////////////////////////////////////////////////////////
void SortX(void)
{
 HRESULT hr = S_OK;

 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _ConnectionPtr pConnection = NULL;
 _RecordsetPtr pRstAuthors = NULL;

 // Define string variables.
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));

 TESTHR(pRstAuthors.CreateInstance(__uuidof(Recordset)));

 pRstAuthors->CursorLocation = adUseClient;
 pConnection->Open (strCnn, "", "", adConnectUnspecified);
 pRstAuthors->Open("SELECT * FROM authors",
 _variant_t((IDispatch *) pConnection),
 adOpenStatic, adLockReadOnly, adCmdText);

 SortXprint(" Initial Order ", pRstAuthors);

 //Clear the screen for the next display.
 printf("\nPress any key to continue...");
 getch();
 system("cls");

 pRstAuthors->Sort = "au_lname ASC, au_fname ASC";
 SortXprint("Last Name Ascending", pRstAuthors);

 //Clear the screen for the next display.
 printf("\nPress any key to continue...");
 getch();
 system("cls");

 pRstAuthors->Sort = "au_lname DESC, au_fname ASC";
 SortXprint("Last Name Descending", pRstAuthors);
 }
 catch(_com_error &e)
 {
 PrintProviderError(pConnection);
 PrintComError(e);
 }

 // Clean up objects before exit.
 if (pRstAuthors)
 if (pRstAuthors->State == adStateOpen)
 pRstAuthors->Close();
 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

//////////////////////////////////////////////////////////
// //
// SortXprint Function //
// //
//////////////////////////////////////////////////////////
//This is the secondary utility routine that prints
//the given title, and the contents of the specified Recordset.
void SortXprint(_bstr_t title, _RecordsetPtr rstp)
{
 printf("---------------%s---------------\n", (LPCSTR)title);
 printf("First Name Last Name\n"
 "---------------------------------------------------\n");
 rstp->MoveFirst();
 int intLineCnt = 4;
 while (!(rstp->EndOfFile))
 {
 _bstr_t aufname;
 _bstr_t aulname;
 aufname = rstp->GetFields()->GetItem("au_fname")->Value;
 aulname = rstp->GetFields()->GetItem("au_lname")->Value,
 printf("%s %s\n",(LPCSTR) aufname, (LPCSTR) aulname);
 rstp->MoveNext();
 intLineCnt++;
 if (intLineCnt % 20 ==0)
 {
 printf("\nPress any key to continue...\n");
 getch();
 }
 }
}

//////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
//////////////////////////////////////////////////////////
void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

//////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
//////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);

}

// EndSortCpp


ParentSameAsPrev Property (ADO MD)

 Copy code hover
[image]

ParentSameAsPrev Property (ADO MD)
Send feedback

Indicates whether the parent of this position member is the same as the parent of the immediately preceding member.

Return Values

Returns a Boolean value and is read-only.

Remarks

This property is supported only on Member objects belonging to a Position object. An error occurs when this property is referenced from Member objects belonging to a Level object.


Recordset Object (ADO)

 Copy code hover
[image]

Recordset Object (ADO)
Send feedback

Represents the entire set of records from a base table or the results of an executed command. At any time, the Recordset object refers to only a single record within the set as the current record.

Remarks

You use Recordset objects to manipulate data from a provider. When you use ADO, you manipulate data almost entirely using Recordset objects. All Recordset objects consist of records (rows) and fields (columns). Depending on the functionality supported by the provider, some Recordset methods or properties may not be available.

ADODB.Recordset is the ProgID that should be used to create a Recordset object. Existing applications that reference the outdated ADOR.Recordset ProgID will continue to work without recompiling, but new development should reference ADODB.Recordset.

There are four different cursor types defined in ADO:

  • Dynamic cursor — allows you to view additions, changes, and deletions by other users; allows all types of movement through the Recordset that doesn't rely on bookmarks; and allows bookmarks if the provider supports them.

  • Keyset cursor — behaves like a dynamic cursor, except that it prevents you from seeing records that other users add, and prevents access to records that other users delete. Data changes by other users will still be visible. It always supports bookmarks and therefore allows all types of movement through the Recordset.

  • Static cursor — provides a static copy of a set of records for you to use to find data or generate reports; always allows bookmarks and therefore allows all types of movement through the Recordset. Additions, changes, or deletions by other users will not be visible. This is the only type of cursor allowed when you open a client-side Recordset object.

  • Forward-only cursor — allows you to only scroll forward through the Recordset. Additions, changes, or deletions by other users will not be visible. This improves performance in situations where you need to make only a single pass through a Recordset.

Set the CursorType property prior to opening the Recordset to choose the cursor type, or pass a CursorType argument with the Open method. Some providers don't support all cursor types. Check the documentation for the provider. If you don't specify a cursor type, ADO opens a forward-only cursor by default.

If the CursorLocation property is set to adUseClient to open a Recordset, the UnderlyingValue property on Field objects is not available in the returned Recordset object. When used with some providers (such as the Microsoft ODBC Provider for OLE DB in conjunction with Microsoft SQL Server), you can create Recordset objects independently of a previously defined Connection object by passing a connection string with the Open method. ADO still creates a Connection object, but it doesn't assign that object to an object variable. However, if you are opening multiple Recordset objects over the same connection, you should explicitly create and open a Connection object; this assigns the Connection object to an object variable. If you do not use this object variable when opening your Recordset objects, ADO creates a new Connection object for each new Recordset, even if you pass the same connection string.

You can create as many Recordset objects as needed.

When you open a Recordset, the current record is positioned to the first record (if any) and the BOF and EOF properties are set to False. If there are no records, the BOF and EOF property settings are True.

You can use the MoveFirst, MoveLast, MoveNext, and MovePrevious methods; the Move method; and the AbsolutePosition, AbsolutePage, and Filter properties to reposition the current record, assuming the provider supports the relevant functionality. Forward-only Recordset objects support only the MoveNext method. When you use the Move methods to visit each record (or enumerate the Recordset), you can use the BOF and EOF properties to determine if you've moved beyond the beginning or end of the Recordset.

Recordset objects can support two types of updating: immediate and batched. In immediate updating, all changes to data are written immediately to the underlying data source once you call the Update method. You can also pass arrays of values as parameters with the AddNew and Update methods and simultaneously update several fields in a record.

If a provider supports batch updating, you can have the provider cache changes to more than one record and then transmit them in a single call to the database with the UpdateBatch method. This applies to changes made with the AddNew, Update, and Delete methods. After you call the UpdateBatch method, you can use the Status property to check for any data conflicts in order to resolve them.

Note Note

To execute a query without using a Command object, pass a query string to the Open method of a Recordset object. However, a Command object is required when you want to persist the command text and re-execute it, or use query parameters.

The Mode property governs access permissions.

The Fields collection is the default member of the Recordset object. As a result, the following two code statements are equivalent.

Copy code Copy code
Debug.Print objRs.Fields.Item(0)  ' Both statements print
Debug.Print objRs(0)              '  the Value of Item(0).


WebBrowserControl.Hyperlink Property (Access)

 Copy code hover
[image]

WebBrowserControl.Hyperlink Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Hyperlink

expression A variable that represents a WebBrowserControl object.

Example

The CreateHyperlink procedure in the following example sets the hyperlink properties for a command button, label, or image control to the address and subaddress values passed to the procedure. The address setting is an optional argument, because a hyperlink to an object in the current database uses only the subaddress setting, To try this example, create a form with two text box controls (txtAddress and txtSubAddress) and a command button (cmdFollowLink) and paste the following into the Declarations section of the form's module:

VBA Copy code Copy code
Private Sub cmdFollowLink_Click()
 CreateHyperlink Me!cmdFollowLink, Me!txtSubAddress, _
 Me!txtAddress
End Sub

Sub CreateHyperlink(ctlSelected As Control, _
 strSubAddress As String, Optional strAddress As String)
 Dim hlk As Hyperlink
 Select Case ctlSelected.ControlType
 Case acLabel, acImage, acCommandButton
 Set hlk = ctlSelected.Hyperlink
 With hlk
 If Not IsMissing(strAddress) Then
 .Address = strAddress
 Else
 .Address = ""
 End If
 .SubAddress = strSubAddress
 .Follow
 .Address = ""
 .SubAddress = ""
 End With
 Case Else
 MsgBox "The control '" & ctlSelected.Name _
 & "' does not support hyperlinks."
 End Select
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


CHECK constraint

 Copy code hover
[image]

CHECK constraint <name> already exists. (Error 3756)
Send feedback

This error occurs when, using the ALTER TABLE ALTER COLUMN syntax, you try to use a constraint name for a CHECK constraint that is already used on that table. This error can also occur when using the Microsoft Access Database Engine OLE DB Provider and attempting to add a CHECK constraint that has the same name as another CHECK constraint in the same table.


OptionButton.ControlType Property (Access)

 Copy code hover
[image]

OptionButton.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Syntax

expression .ControlType

expression A variable that represents an OptionButton object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


ObjectFrame.MouseUp Event (Access)

 Copy code hover
[image]

ObjectFrame.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents an ObjectFrame object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was released to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


OptionGroup.OnMouseMove Property (Access)

 Copy code hover
[image]

OptionGroup.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Syntax

expression .OnMouseMove

expression A variable that represents an OptionGroup object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


TabControl.Gradient Property (Access)

 Copy code hover
[image]

TabControl.Gradient Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the gradient fill applied to the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .Gradient

expression A variable that represents a TabControl object.

Remarks

The Gradient property contains a numeric expression that represents the gradient fill applied to the specified object. The default value of the Gradient property is 0, which does not apply a gradient. The values are listed in the following table.

Value | Gradient Fill
0 | None
1 | Linear Diagonal - Top Left to Bottom Right, Light
2 | Linear Down, Light
3 | Linear Diagonal - Top Right to Bottom Left, Light
4 | From Bottom Right Corner, Light
5 | From Bottom Left Corner, Light
6 | Linear Left, Light
7 | Linear Center, Light
8 | Linear Right, Light
9 | From Top Right Corner, Light
10 | From Top Left Corner, Light
11 | Linear Diagonal - Bottom Left to Top Right, Light
12 | Linear Up, Light
13 | Linear Diagonal - Bottom Right to Top Left, Light
14 | Linear Diagonal - Top Left to Bottom Right, Dark
15 | Linear Down, Dark
16 | Linear Diagonal - Top Right to Bottom Left, Dark
17 | From Bottom Right Corner, Dark
18 | From Bottom Left Corner, Dark
19 | Linear Left, Dark
20 | Linear Center, Dark
21 | Linear Right, Dark
22 | From Top Right Corner, Dark
23 | From Top Left Corner, Dark
24 | Linear Diagonal - Bottom Left to Top Right, Dark
25 | Linear Up, Dark
26 | Linear Diagonal - Bottom Right to Top Left, Light

To see the available gradient fills and apply a gradient through the user interface, first open the form or report in Layout view or Design view by right-clicking the form or report in the Navigation Pane, and then clicking the view you want. Then, click the object to which you want to apply a gradient fill. Next, on the Format tab, in the Control Formatting group, click Shape Fill, then click Gradient and choose a gradient fill. You can hover over a gradient fill to see a description.

This property is not surfaced in the property sheet.

Example

The following code example sets the gradient fill to Linear Down, Light.

VBA Copy code Copy code
Me.ctl.Gradient = 2

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Using Visual C++ Extensions

 Copy code hover
[image]

Using Visual C++ Extensions
Send feedback

The IADORecordBinding Interface

The Microsoft Visual C++ Extensions for ADO associate, or bind, fields of a Recordset object to C/C++ variables. Whenever the current row of the bound Recordset changes, all the bound fields in the Recordset are copied to the C/C++ variables. If necessary, the copied data is converted to the declared data type of the C/C++ variable.

The BindToRecordset method of the IADORecordBinding interface binds fields to C/C++ variables. The AddNew method adds a new row to the bound Recordset. The Update method populates fields in new rows of the Recordset, or updates fields in existing rows, with the value of the C/C++ variables.

The IADORecordBinding interface is implemented by the Recordset object. You do not code the implementation yourself.

Binding Entries

The Visual C++ Extensions for ADO map fields of a Recordset object to C/C++ variables. The definition of a mapping between a field and a variable is called a binding entry. Macros provide binding entries for numeric, fixed-length, and variable-length data. The binding entries and C/C++ variables are declared in a class derived from the Visual C++ Extensions class, CADORecordBinding. The CADORecordBinding class is defined internally by the binding entry macros.

ADO internally maps the parameters in these macros to an OLE DB DBBINDING structure and creates an OLE DB Accessor object to manage the movement and conversion of data between fields and variables. OLE DB defines data as consisting of three parts: A buffer where the data is stored; a status that indicates whether a field was successfully stored in the buffer, or how the variable should be restored to the field; and the length of the data. (See the OLE DB Programmer's Reference, Chapter 6: Getting and Setting Data for more information.)

Header File

Include the following file in your application in order to use the Visual C++ Extensions for ADO:

Copy code Copy code

#include <icrsint.h>

Binding Recordset Fields

To Bind Recordset Fields to C/C++ Variables

  1. Create a class derived from the CADORecordBinding class.

  2. Specify binding entries and corresponding C/C++ variables in the derived class. Bracket the binding entries between BEGIN_ADO_BINDING and END_ADO_BINDING macros. Do not terminate the macros with commas or semicolons. Appropriate delimiters are specified automatically by each macro. Specify one binding entry for each field to be mapped to a C/C++ variable. Use an appropriate member from the ADO_FIXED_LENGTH_ENTRY, ADO_NUMERIC_ENTRY, or ADO_VARIABLE_LENGTH_ENTRY family of macros.

  3. In your application, create an instance of the class derived from CADORecordBinding. Get the IADORecordBinding interface from the Recordset. Then call the BindToRecordset method to bind the Recordset fields to the C/C++ variables.

See the Visual C++ Extensions Example for more information.

Interface Methods

The IADORecordBinding interface has three methods: BindToRecordset, AddNew, and Update. The sole argument to each method is a pointer to an instance of the class derived from CADORecordBinding. Therefore, the AddNew and Update methods cannot specify any of the parameters of their ADO method namesakes.

Syntax

The BindToRecordset method associates the Recordset fields with C/C++ variables.

Copy code Copy code
                      BindToRecordset(CADORecordBinding *binding)

The AddNew method invokes its namesake, the ADO AddNew method, to add a new row to the Recordset.

Copy code Copy code
                      AddNew(CADORecordBinding *binding)

The Update method invokes its namesake, the ADO Update method, to update the Recordset.

Copy code Copy code
                      Update(CADORecordBinding *binding)

Binding Entry Macros

Binding entry macros define the association of a Recordset field and a variable. A beginning and ending macro delimits the set of binding entries.

Families of macros are provided for fixed-length data, such as adDate or adBoolean; numeric data, such as adTinyInt, adInteger, or adDouble; and variable-length data, such as adChar, adVarChar or adVarBinary. All numeric types, except for adVarNumeric, are also fixed-length types. Each family has differing sets of parameters so that you can exclude binding information that is of no interest.

See the OLE DB Programmer's Reference, Appendix A: Data Types for additional information.

Begin Binding Entries

BEGIN_ADO_BINDING(Class)

Fixed-Length Data

ADO_FIXED_LENGTH_ENTRY(Ordinal, DataType, Buffer, Status, Modify)
ADO_FIXED_LENGTH_ENTRY2(Ordinal, DataType, Buffer, Modify)

Numeric Data

ADO_NUMERIC_ENTRY(Ordinal, DataType, Buffer, Precision, Scale, Status, Modify)
ADO_NUMERIC_ENTRY2(Ordinal, DataType, Buffer, Precision, Scale, Modify)

Variable-Length Data

ADO_VARIABLE_LENGTH_ENTRY(Ordinal, DataType, Buffer, Size, Status, Length, Modify)
ADO_VARIABLE_LENGTH_ENTRY2(Ordinal, DataType, Buffer, Size, Status, Modify)
ADO_VARIABLE_LENGTH_ENTRY3(Ordinal, DataType, Buffer, Size, Length, Modify)
ADO_VARIABLE_LENGTH_ENTRY4(Ordinal, DataType, Buffer, Size, Modify)

End Binding Entries

END_ADO_BINDING()

Parameter | Description
Class | Class in which the binding entries and C/C++ variables are defined.
Ordinal | Ordinal number, counting from one, of the Recordset field corresponding to your C/C++ variable.
DataType | Equivalent ADO data type of the C/C++ variable (see DataTypeEnum for a list of valid data types). The value of the Recordset field will be converted to this data type if necessary.
Buffer | Name of the C/C++ variable where the Recordset field will be stored.
Size | Maximum size in bytes of Buffer. If Buffer will contain a variable-length string, allow room for a terminating zero.
Status | Name of a variable that will indicate whether the contents of Buffer are valid, and whether the conversion of the field to DataType was successful. The two most important values for this variable are adFldOK, which means the conversion was successful; and adFldNull, which means the value of the field would be a VARIANT of type VT_NULL and not merely empty. Possible values for Status are listed in the next table, "Status Values."
Modify | Boolean flag; if TRUE, indicates ADO is allowed to update the corresponding Recordset field with the value contained in Buffer. Set the Boolean modify parameter to TRUE to enable ADO to update the bound field, and FALSE if you want to examine the field but not change it.
Precision | Number of digits that can be represented in a numeric variable.
Scale | Number of decimal places in a numeric variable.
Length | Name of a four-byte variable that will contain the actual length of the data in Buffer.

Status Values

The value of the Status variable indicates whether a field was successfully copied to a variable.

When setting data, Status may be set to adFldNull to indicate the Recordset field should be set to null.

Constant | Value | Description
adFldOK | 0 | A non-null field value was returned.
adFldBadAccessor | 1 | Binding was invalid.
adFldCantConvertValue | 2 | Value couldn't be converted for reasons other than sign mismatch or data overflow.
adFldNull | 3 | When getting a field, indicates a null value was returned. When setting a field, indicates the field should be set to NULL when the field cannot encode NULL itself (for example, a character array or an integer).
adFldTruncated | 4 | Variable-length data or numeric digits were truncated.
adFldSignMismatch | 5 | Value is signed and variable data type is unsigned.
adFldDataOverFlow | 6 | Value is larger than could be stored in the variable data type.
adFldCantCreate | 7 | Unknown column type and field already open.
adFldUnavailable | 8 | Field value could not be determined — for example, on a new, unassigned field with no default value.
adFldPermissionDenied | 9 | When updating, no permission to write data.
adFldIntegrityViolation | 10 | When updating, field value would violate column integrity.
adFldSchemaViolation | 11 | When updating, field value would violate column schema.
adFldBadStatus | 12 | When updating, invalid status parameter.
adFldDefault | 13 | When updating, a default value was used.


TextBox.SelLength Property (Access)

 Copy code hover
[image]

TextBox.SelLength Property (Access)
See also Send feedback

Published: July 16, 2012

The SelLength property specifies or determines the number of characters selected in a text box. Read/write Integer.

Syntax

expression .SelLength

expression A variable that represents a TextBox object.

Remarks

The SelLength property uses an Integer in the range 0 to the total number of characters in a text box or text box portion of a combo box.

To set or return this property for a control, the control must have the focus. To move the focus to a control, use the SetFocus method.

Setting the SelLength property to a number less than 0 produces a run-time error.

Example

The following example uses two event procedures to search for text specified by a user. The text to search is set in the form's Load event procedure. The Click event procedure for the Find button (which the user clicks to start the search) prompts the user for the text to search for and selects the text in the text box if the search is successful.

VBA Copy code Copy code
Private Sub Form_Load()

 Dim ctlTextToSearch As Control
 Set ctlTextToSearch = Forms!Form1!Textbox1

 ' SetFocus to text box.
 ctlTextToSearch.SetFocus
 ctlTextToSearch.Text = "This company places large orders twice " & _
 "a year for garlic, oregano, chilies and cumin."
 Set ctlTextToSearch = Nothing

End Sub

Public Sub Find_Click()

 Dim strSearch As String
 Dim intWhere As Integer
 Dim ctlTextToSearch As Control

 ' Get search string from user.
 With Me!Textbox1
 strSearch = InputBox("Enter text to find:")

 ' Find string in text.
 intWhere = InStr(.Value, strSearch)
 If intWhere Then
 ' If found.
 .SetFocus
 .SelStart = intWhere - 1
 .SelLength = Len(strSearch)
 Else
 ' Notify user.
 MsgBox "String not found."
 End If
 End With

End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Label.Click Event (Access)

 Copy code hover
[image]

Label.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Syntax

expression .Click

expression A variable that represents a Label object.

Remarks

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Clicking an attached label has the same effect as clicking the associated control. The normal events for the control occur, not any events for the attached label.

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

Label Object

Other resources

Label Object Members


Report.OnMouseUp Property (Access)

 Copy code hover
[image]

Report.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnMouseUp

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the report's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

See also

Concepts

Report Object

Other resources

Report Object Members


Report.FillStyle Property (Access)

 Copy code hover
[image]

Report.FillStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FillStyle property to specify whether a circle or line drawn by the Circle or Line method on a report is transparent, opaque, or filled with a pattern. Read/write Integer.

Syntax

expression .FillStyle

expression A variable that represents a Report object.

Remarks

The FillStyle property uses the following settings.

Setting | Description
0 | Opaque
1 | (Default) Transparent
2 | Horizontal Line
3 | Vertical Line
4 | Upward Diagonal
5 | Downward Diagonal
6 | Cross
7 | Diagonal Cross
Note Note

You can set the FillStyle property in an event procedure specified by a section's OnPrint property setting.

When the FillStyle property is set to 0, a circle or line has the color set by the FillColor property. When the FillStyle property is set to 1, the interior of the circle or line is transparent and has the color of the report behind it.

To use the FillStyle property, the SpecialEffect property must be set to Normal.

The following example uses the Circle method to draw a circle and create a pie slice within the circle. Then it uses the FillColor and FillStyle properties to color the pie slice red. It also draws a line from the upper left to the center of the circle.

Example

To try this example in Microsoft Access, create a new report. Set the OnPrint property of the Detail section to [Event Procedure]. Enter the following code in the report's module, then switch to Print Preview.

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

 Const conPI = 3.14159265359

 Dim sngHCtr As Single
 Dim sngVCtr As Single
 Dim sngRadius As Single
 Dim sngStart As Single
 Dim sngEnd As Single

 sngHCtr = Me.ScaleWidth / 2 ' Horizontal center.
 sngVCtr = Me.ScaleHeight / 2 ' Vertical center.
 sngRadius = Me.ScaleHeight / 3 ' Circle radius.
 Me.Circle (sngHCtr, sngVCtr), sngRadius ' Draw circle.
 sngStart = -0.00000001 ' Start of pie slice.

 sngEnd = -2 * conPI / 3 ' End of pie slice.
 Me.FillColor = RGB(255, 0, 0) ' Color pie slice red.
 Me.FillStyle = 0 ' Fill pie slice.

 ' Draw Pie slice within circle
 Me.Circle (sngHCtr, sngVCtr), sngRadius, , sngStart, sngEnd

 ' Draw line to center of circle.
 Dim intColor As Integer
 Dim sngTop As Single, sngLeft As Single
 Dim sngWidth As Single, sngHeight As Single

 Me.ScaleMode = 3 ' Set scale to pixels.
 sngTop = Me.ScaleTop ' Top inside edge.
 sngLeft = Me.ScaleLeft ' Left inside edge.
 sngWidth = Me.ScaleWidth / 2 ' Width inside edge.
 sngHeight = Me.ScaleHeight / 2 ' Height inside edge.
 intColor = RGB(255, 0, 0) ' Make color red.

 ' Draw line.
 Me.Line (sngTop, sngLeft)-(sngWidth, sngHeight), intColor

End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


ADO API Reference

 Copy code hover
[image]

ADO API Reference
Send feedback

This section of the ADO documentation contains topics for each ADO object, collection, property, dynamic property, method, event, and enumeration. In addition, it contains a list of ADO syntax indexes to be used with Microsoft Visual C++ and Windows Foundation Classes (WFC).

For more information, search for a specific topic in the index or refer to the following topics:

  • ADO Objects

  • ADO Collections

  • ADO Properties

  • ADO Dynamic Properties

  • ADO Methods

  • ADO Events

  • ADO Enumerated Constants

  • ADO Syntax Indexes


Rectangle.BorderTint Property (Access)

 Copy code hover
[image]

Rectangle.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Syntax

expression .BorderTint

expression A variable that represents a Rectangle object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens BorderColor by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


ObjectFrame.IsVisible Property (Access)

 Copy code hover
[image]

ObjectFrame.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Syntax

expression .IsVisible

expression A variable that represents an ObjectFrame object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


PageBreak Object (Access)

 Copy code hover
[image]

PageBreak Object (Access)
See also Send feedback

Published: July 16, 2012

This object corresponds to a page break control. The page break control marks the start of a new screen or printed page on a form or report.

Remarks

Control: | Tool:

In a form, a page break is active only when you set the form's DefaultView property to Single Form. Page breaks don't affect a form's datasheet.

In Form view, press the PAGE UP or PAGE DOWN key to move to the previous or next page break.

Position page breaks above or below other controls. Placing a page break on the same line as another control splits that control's data.

See also

Concepts

Access Object Model Reference

Other resources

PageBreak Object Members


Internet dll (wininet.dll) could not be found or loaded. (Error 3674)

 Copy code hover
[image]

Internet dll (wininet.dll) could not be found or loaded. (Error 3674)
Send feedback

The wininet.dll could not be found in your path. Please re-run setup.


NavigationButton.HyperlinkSubAddress Property (Access)

 Copy code hover
[image]

NavigationButton.HyperlinkSubAddress Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the HyperlinkSubAddress property to specify or determine a location within the target document specified by the HyperlinkAddress property. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .HyperlinkSubAddress

expression A variable that represents a NavigationButton object.

Remarks

The HyperlinkSubAddress property can be an object within a Microsoft Access database, a bookmark within a Microsoft Word document, a named range within a Microsoft Excel spreadsheet, a slide within a Microsoft PowerPoint presentation, or a location within an HTML document.

The HyperlinkSubAddress property is a string expression representing a named location within the target document specified by the HyperlinkAddress property.

Note Note

When you create a hyperlink by using the Insert Hyperlink dialog box, Microsoft Access automatically sets the HyperlinkAddress property and HyperlinkSubAddress to the location specified in the Type the file or Web page name box. The HyperlinkSubAddress property can also be set to the location specified in the Select an object in this database box.

If you copy a hyperlink from another application and paste it into a form or report, Microsoft Access creates a label control with its Caption property, HyperlinkAddress property, and HyperlinkSubAddress property automatically set.

When you move the cursor over a command button, image control, or label control whose HyperlinkAddress property is set, the cursor changes to an upward-pointing hand. Clicking the control displays the object or Web page specified by the link.

To open objects in the current database, leave the HyperlinkAddress property blank and specify the object type and object name you want to open in the HyperlinkSubAddress property by using the syntax "objecttype objectname". If you want to open an object contained in another Microsoft Access database, enter the database path and file name in the HyperlinkAddress property and specify the database object to open by using the HyperlinkSubAddress property.

The HyperlinkAddress property can contain an absolute or a relative path to a target document. An absolute path is a fully qualified URL or UNC path to a document. A relative path is a path related to the base path specified in the Hyperlink Base setting in the Properties dialog box (available by clicking Database Properties on the File menu) or to the current database path. If Microsoft Access can't resolve the HyperlinkAddress property setting to a valid URL or UNC path, it will assume you've specified a path relative to the base path contained in the Hyperlink Base setting or the current database path.

Note Note

When you follow a hyperlink to another Microsoft Access database object, the database Startup properties are applied. For example, if the destination database has a Display form set, that form is displayed when the database opens.

The following table contains examples of HyperlinkAddress and HyperlinkSubAddress property settings.

HyperlinkAddress | HyperlinkSubAddress | Description
http://www.microsoft.com/ |  | The Microsoft home page on the Web.
C:\Program Files\Microsoft Office\Office\Samples\Cajun.htm |  | The Cajun Delights page in the Access sample applications subdirectory.
C:\Program Files\Microsoft Office\Office\Samples\Cajun.htm | NewProducts | The "NewProducts" Name tag in the Cajun Delights page.
C:\Personal\MyResume.doc | References | The bookmark named "References" in the Microsoft Word document "MyResume.doc".
C:\Finance\First Quarter.xls | Sheet1!TotalSales | The range named "TotalSales" in the Microsoft Excel spreadsheet "First Quarter.xls".
C:\Presentation\NewPlans.ppt | 10 | The 10th slide in the Microsoft PowerPoint document "NewPlans.ppt".

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


NavigationButton.HoverForeThemeColorIndex Property (Access)

 Copy code hover
[image]

NavigationButton.HoverForeThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverForeColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HoverForeThemeColorIndex

expression A variable that represents a NavigationButton object.

Remarks

The HoverForeThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 (Default) | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the HoverThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


OptionGroup.AutoLabel Property (Access)

 Copy code hover
[image]

OptionGroup.AutoLabel Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.

Syntax

expression .AutoLabel

expression A variable that represents an OptionGroup object.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Attachment.Forward Method (Access)

 Copy code hover
[image]

Attachment.Forward Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the focus to the next file in the specified Attachment control.

Version Information

Version Added: Access 2007

Syntax

expression .Forward

expression A variable that represents an Attachment object.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Printer.Port Property (Access)

 Copy code hover
[image]

Printer.Port Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a String indicating the port name of the specified printer. Read-only.

Syntax

expression .Port

expression A variable that represents a Printer object.

Example

The following example displays information about all the printers available to the system.

VBA Copy code Copy code
Dim prtLoop As Printer

For Each prtLoop In Application.Printers
 With prtLoop
 MsgBox "Device name: " & .DeviceName & vbCr _
 & "Driver name: " & .DriverName & vbCr _
 & "Port: " & .Port
 End With
Next prtLoop

See also

Concepts

Printer Object

Other resources

Printer Object Members


Database Object Reference (DAO)

 Copy code hover
[image]

Database Object Reference (DAO)
Send feedback

In this section

  • Database Object (DAO)

  • Database Members (DAO)

  • Database Properties (DAO)

  • Database Methods (DAO)


Microsoft OLE DB Provider for SQL Server

 Copy code hover
[image]

Microsoft OLE DB Provider for SQL Server
Send feedback

The Microsoft OLE DB Provider for SQL Server, SQLOLEDB, allows ADO to access Microsoft SQL Server.

Connection String Parameters

To connect to this provider, set the Provider argument to the ConnectionString property to:

Copy code Copy code

SQLOLEDB

This value can also be set or read using the Provider property.

Typical Connection String

A typical connection string for this provider is:

Copy code Copy code

"Provider=SQLOLEDB;Data Source=serverName;"
Initial Catalog=databaseName;
User ID=userName;Password=userPassword;"

The string consists of these keywords:

Keyword | Description
Provider | Specifies the OLE DB Provider for SQL Server.
Data Source or Server | Specifies the name of a server.
Initial Catalog or Database | Specifies the name of a database on the server.
User ID or uid | Specifies the user name (for SQL Server Authentication).
Password or pwd | Specifies the user password (for SQL Server Authentication).

Provider-Specific Connection Parameters

The provider supports several provider-specific connection parameters in addition to those defined by ADO. As with the ADO connection properties, these provider-specific properties can be set via the Properties collection of a Connection or can be set as part of the ConnectionString.

Parameter | Description
Trusted_Connection | Indicates the user authentication mode. This can be set to Yes or No. The default value is No. If this property is set to Yes, then SQLOLEDB uses Microsoft Windows NT Authentication Mode to authorize user access to the SQL Server database specified by the Location and Datasource property values. If this property is set to No, then SQLOLEDB uses Mixed Mode to authorize user access to the SQL Server database. The SQL Server login and password are specified in the User Id and Password properties.
Current Language | Indicates a SQL Server language name. Identifies the language used for system message selection and formatting. The language must be installed on the SQL Server, otherwise opening the connection will fail.
Network Address | Indicates the network address of the SQL Server specified by the Location property.
Network Library | Indicates the name of the network library (dynamic-link libraries) used to communicate with the SQL Server. The name should not include the path or the .dll file name extension. The default is provided by the SQL Server client configuration.
Use Procedure for Prepare | Determines whether SQL Server creates temporary stored procedures when Commands are prepared (by the Prepared property).
Auto Translate | Indicates whether OEM/ANSI characters are converted. This property can be set to True or False. The default value is True. If this property is set to True, then SQLOLEDB performs OEM/ANSI character conversion when multi-byte character strings are retrieved from, or sent to, the SQL Server. If this property is set to False, then SQLOLEDB does not perform OEM/ANSI character conversion on multi-byte character string data.
Packet Size | Indicates a network packet size in bytes. The packet size property value must be between 512 and 32767. The default SQLOLEDB network packet size is 4096.
Application Name | Indicates the client application name.
Workstation ID | A string identifying the workstation.

Command Object Usage

SQLOLEDB accepts an amalgam of ODBC, ANSI, and SQL Server-specific Transact-SQL as valid syntax. For example, the following SQL statement uses an ODBC SQL escape sequence to specify the LCASE string function:

Copy code Copy code

SELECT customerid={fn LCASE(CustomerID)} FROM Customers

LCASE returns a character string, converting all uppercase characters to their lowercase equivalents. The ANSI SQL string function LOWER performs the same operation, so the following SQL statement is an ANSI equivalent to the ODBC statement presented above:

Copy code Copy code

SELECT customerid=LOWER(CustomerID) FROM Customers

SQLOLEDB successfully processes either form of the statement when specified as text for a command.

Stored Procedures

When executing a SQL Server stored procedure using a SQLOLEDB command, use the ODBC procedure call escape sequence in the command text. SQLOLEDB then uses the remote procedure call mechanism of SQL Server to optimize command processing. For example, the following ODBC SQL statement is the preferred command text over the Transact-SQL form:

ODBC SQL

Copy code Copy code

{call SalesByCategory('Produce', '1995')}

Transact-SQL

Copy code Copy code

EXECUTE SalesByCategory 'Produce', '1995'

Recordset Behavior

SQLOLEDB cannot use SQL Server cursors to support the multiple-result generated by many commands. If a consumer requests a recordset requiring SQL Server cursor support, an error occurs if the command text used generates more than a single recordset as its result.

Scrollable SQLOLEDB recordsets are supported by SQL Server cursors. SQL Server imposes limitations on cursors that are sensitive to changes made by other users of the database. Specifically, the rows in some cursors cannot be ordered, and attempting to create a recordset using a command containing an SQL ORDER BY clause can fail.

Dynamic Properties

The Microsoft OLE DB Provider for SQL Server inserts several dynamic properties into the Properties collection of the unopened Connection, Recordset, and Command objects.

The following tables are a cross-index of the ADO and OLE DB names for each dynamic property. The OLE DB Programmer's Reference refers to an ADO property name by the term "Description." You can find more information about these properties in the OLE DB Programmer's Reference. Search for the OLE DB property name in the Index or see Appendix C: OLE DB Properties.

Connection Dynamic Properties

The following properties are added to the Connection object's Properties collection.

ADO Property Name | OLE DB Property Name
Active Sessions | DBPROP_ACTIVESESSIONS
Asynchable Abort | DBPROP_ASYNCTXNABORT
Asynchable Commit | DBPROP_ASYNCTNXCOMMIT
Autocommit Isolation Levels | DBPROP_SESS_AUTOCOMMITISOLEVELS
Catalog Location | DBPROP_CATALOGLOCATION
Catalog Term | DBPROP_CATALOGTERM
Column Definition | DBPROP_COLUMNDEFINITION
Connect Timeout | DBPROP_INIT_TIMEOUT
Current Catalog | DBPROP_CURRENTCATALOG
Data Source | DBPROP_INIT_DATASOURCE
Data Source Name | DBPROP_DATASOURCENAME
Data Source Object Threading Model | DBPROP_DSOTHREADMODEL
DBMS Name | DBPROP_DBMSNAME
DBMS Version | DBPROP_DBMSVER
Extended Properties | DBPROP_INIT_PROVIDERSTRING
GROUP BY Support | DBPROP_GROUPBY
Heterogeneous Table Support | DBPROP_HETEROGENEOUSTABLES
Identifier Case Sensitivity | DBPROP_IDENTIFIERCASE
Initial Catalog | DBPROP_INIT_CATALOG
Isolation Levels | DBPROP_SUPPORTEDTXNISOLEVELS
Isolation Retention | DBPROP_SUPPORTEDTXNISORETAIN
Locale Identifier | DBPROP_INIT_LCID
Maximum Index Size | DBPROP_MAXINDEXSIZE
Maximum Row Size | DBPROP_MAXROWSIZE
Maximum Row Size Includes BLOB | DBPROP_MAXROWSIZEINCLUDESBLOB
Maximum Tables in SELECT | DBPROP_MAXTABLESINSELECT
Multiple Parameter Sets | DBPROP_MULTIPLEPARAMSETS
Multiple Results | DBPROP_MULTIPLERESULTS
Multiple Storage Objects | DBPROP_MULTIPLESTORAGEOBJECTS
Multi-Table Update | DBPROP_MULTITABLEUPDATE
NULL Collation Order | DBPROP_NULLCOLLATION
NULL Concatenation Behavior | DBPROP_CONCATNULLBEHAVIOR
OLE DB Version | DBPROP_PROVIDEROLEDBVER
OLE Object Support | DBPROP_OLEOBJECTS
Open Rowset Support | DBPROP_OPENROWSETSUPPORT
ORDER BY Columns in Select List | DBPROP_ORDERBYCOLUMNSINSELECT
Output Parameter Availability | DBPROP_OUTPUTPARAMETERAVAILABILITY
Pass By Ref Accessors | DBPROP_BYREFACCESSORS
Password | DBPROP_AUTH_PASSWORD
Persist Security Info | DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO
Persistent ID Type | DBPROP_PERSISTENTIDTYPE
Prepare Abort Behavior | DBPROP_PREPAREABORTBEHAVIOR
Prepare Commit Behavior | DBPROP_PREPARECOMMITBEHAVIOR
Procedure Term | DBPROP_PROCEDURETERM
Prompt | DBPROP_INIT_PROMPT
Provider Friendly Name | DBPROP_PROVIDERFRIENDLYNAME
Provider Name | DBPROP_PROVIDERFILENAME
Provider Version | DBPROP_PROVIDERVER
Read-Only Data Source | DBPROP_DATASOURCEREADONLY
Rowset Conversions on Command | DBPROP_ROWSETCONVERSIONSONCOMMAND
Schema Term | DBPROP_SCHEMATERM
Schema Usage | DBPROP_SCHEMAUSAGE
SQL Support | DBPROP_SQLSUPPORT
Structured Storage | DBPROP_STRUCTUREDSTORAGE
Subquery Support | DBPROP_SUBQUERIES
Table Term | DBPROP_TABLETERM
Transaction DDL | DBPROP_SUPPORTEDTXNDDL
User ID | DBPROP_AUTH_USERID
User Name | DBPROP_USERNAME
Window Handle | DBPROP_INIT_HWND

Recordset Dynamic Properties

The following properties are added to the Recordset object's Properties collection.

ADO Property Name | OLE DB Property Name
Access Order | DBPROP_ACCESSORDER
Blocking Storage Objects | DBPROP_BLOCKINGSTORAGEOBJECTS
Bookmark Type | DBPROP_BOOKMARKTYPE
Bookmarkable | DBPROP_IROWSETLOCATE
Change Inserted Rows | DBPROP_CHANGEINSERTEDROWS
Column Privileges | DBPROP_COLUMNRESTRICT
Column Set Notification | DBPROP_NOTIFYCOLUMNSET
Command Time Out | DBPROP_COMMANDTIMEOUT
Defer Column | DBPROP_DEFERRED
Delay Storage Object Updates | DBPROP_DELAYSTORAGEOBJECTS
Fetch Backwards | DBPROP_CANFETCHBACKWARDS
Hold Rows | DBPROP_CANHOLDROWS
IAccessor | DBPROP_IAccessor
IColumnsInfo | DBPROP_IColumnsInfo
IColumnsRowset | DBPROP_IColumnsRowset
IConnectionPointContainer | DBPROP_IConnectionPointContainer
IConvertType | DBPROP_IConvertType
Immobile Rows | DBPROP_IMMOBILEROWS
IRowset | DBPROP_IRowset
IRowsetChange | DBPROP_IRowsetChange
IRowsetIdentity | DBPROP_IRowsetIdentity
IRowsetInfo | DBPROP_IRowsetInfo
IRowsetLocate | DBPROP_IRowsestLocate
IRowsetResynch |
IRowsetScroll | DBPROP_IRowsetScroll
IRowsetUpdate | DBPROP_IRowsetUpdate
ISequentialStream | DBPROP_ISequentialStream
ISupportErrorInfo | DBPROP_ISupportErrorInfo
Literal Bookmarks | DBPROP_LITERALBOOKMARKS
Literal Row Identity | DBPROP_LITERALIDENTITY
Maximum Open Rows | DBPROP_MAXOPENROWS
Maximum Pending Rows | DBPROP_MAXPENDINGROWS
Maximum Rows | DBPROP_MAXROWS
Notification Granularity | DBPROP_NOTIFICATIONGRANULARITY
Notification Phases | DBPROP_NOTIFICATIONPHASES
Objects Transacted | DBPROP_TRANSACTEDOBJECT
Others' Changes Visible | DBPROP_OTHERUPDATEDELETE
Others' Inserts Visible | DBPROP_OTHERINSERT
Own Changes Visible | DBPROP_OWNUPDATEDELETE
Own Inserts Visible | DBPROP_OWNINSERT
Preserve on Abort | DBPROP_ABORTPRESERVE
Preserve on Commit | DBPROP_COMMITPRESERVE
Quick Restart | DBPROP_QUICKRESTART
Reentrant Events | DBPROP_REENTRANTEVENTS
Remove Deleted Rows | DBPROP_REMOVEDELETED
Report Multiple Changes | DBPROP_REPORTMULTIPLECHANGES
Return Pending Inserts | DBPROP_RETURNPENDINGINSERTS
Row Delete Notification | DBPROP_NOTIFYROWDELETE
Row First Change Notification | DBPROP_NOTIFYROWFIRSTCHANGE
Row Insert Notification | DBPROP_NOTIFYROWINSERT
Row Privileges | DBPROP_ROWRESTRICT
Row Resynchronization Notification | DBPROP_NOTIFYROWRESYNCH
Row Threading Model | DBPROP_ROWTHREADMODEL
Row Undo Change Notification | DBPROP_NOTIFYROWUNDOCHANGE
Row Undo Delete Notification | DBPROP_NOTIFYROWUNDODELETE
Row Undo Insert Notification | DBPROP_NOTIFYROWUNDOINSERT
Row Update Notification | DBPROP_NOTIFYROWUPDATE
Rowset Fetch Position Change Notification | DBPROP_NOTIFYROWSETFETCHPOSISIONCHANGE
Rowset Release Notification | DBPROP_NOTIFYROWSETRELEASE
Scroll Backwards | DBPROP_CANSCROLLBACKWARDS
Server Cursor | DBPROP_SERVERCURSOR
Skip Deleted Bookmarks | DBPROP_BOOKMARKSKIPPED
Strong Row Identity | DBPROP_STRONGITDENTITY
Unique Rows | DBPROP_UNIQUEROWS
Updatability | DBPROP_UPDATABILITY
Use Bookmarks | DBPROP_BOOKMARKS

Command Dynamic Properties

The following properties are added to the Command object's Properties collection.

ADO Property Name | OLE DB Property Name
Access Order | DBPROP_ACCESSORDER
Base Path | SSPROP_STREAM_BASEPATH
Blocking Storage Objects | DBPROP_BLOCKINGSTORAGEOBJECTS
Bookmark Type | DBPROP_BOOKMARKTYPE
Bookmarkable | DBPROP_IROWSETLOCATE
Change Inserted Rows | DBPROP_CHANGEINSERTEDROWS
Column Privileges | DBPROP_COLUMNRESTRICT
Column Set Notification | DBPROP_NOTIFYCOLUMNSET
Content Type | SSPROP_STREAM_CONTENTTYPE
Cursor Auto Fetch | SSPROP_CURSORAUTOFETCH
Defer Column | DBPROP_DEFERRED
Defer Prepare | SSPROP_DEFERPREPARE
Delay Storage Object Updates | DBPROP_DELAYSTORAGEOBJECTS
Fetch Backwards | DBPROP_CANFETCHBACKWARDS
Hold Rows | DBPROP_CANHOLDROWS
IAccessor | DBPROP_IAccessor
IColumnsInfo | DBPROP_IColumnsInfo
IColumnsRowset | DBPROP_IColumnsRowset
IConnectionPointContainer | DBPROP_IConnectionPointContainer
IConvertType | DBPROP_IConvertType
Immobile Rows | DBPROP_IMMOBILEROWS
IRowset | DBPROP_IRowset
IRowsetChange | DBPROP_IRowsetChange
IRowsetIdentity | DBPROP_IRowsetIdentity
IRowsetInfo | DBPROP_IRowsetInfo
IRowsetLocate | DBPROP_IRowsetLocate
IRowsetResynch | DBPROP_IRowsetResynch
IRowsetScroll | DBPROP_IRowsetScroll
IRowsetUpdate | DBPROP_IRowsetUpdate
ISequentialStream | DBPROP_ISequentialStream
ISupportErrorInfo | DBPROP_ISupportErrorInfo
Literal Bookmarks | DBPROP_LITERALBOOKMARKS
Literal Row Identity | DBPROP_LITERALIDENTITY
Lock Mode | DBPROP_LOCKMODE
Maximum Open Rows | DBPROP_MAXOPENROWS
Maximum Pending Rows | DBPROP_MAXPENDINGROWS
Maximum Rows | DBPROP_MAXROWS
Notification Granularity | DBPROP_NOTIFICATIONGRANULARITY
Notification Phases | DBPROP_NOTIFICATIONPHASES
Objects Transacted | DBPROP_TRANSACTEDOBJECT
Others' Changes Visible | DBPROP_OTHERUPDATEDELETE
Others' Inserts Visible | DBPROP_OTHERINSERT
Output Encoding Property | DBPROP_OUTPUTENCODING
Output Stream Property | DBPROP_OUTPUTSTREAM
Own Changes Visible | DBPROP_OWNUPDATEDELETE
Own Inserts Visible | DBPROP_OWNINSERT
Preserve on Abort | DBPROP_ABORTPRESERVE
Preserve on Commit | DBPROP_COMMITPRESERVE
Quick Restart | DBPROP_QUICKRESTART
Reentrant Events | DBPROP_REENTRANTEVENTS
Remove Deleted Rows | DBPROP_REMOVEDELETED
Report Multiple Changes | DBPROP_REPORTMULTIPLECHANGES
Return Pending Inserts | DBPROP_RETURNPENDINGINSERTS
Row Delete Notification | DBPROP_NOTIFYROWDELETE
Row First Change Notification | DBPROP_NOTIFYROWFIRSTCHANGE
Row Insert Notification | DBPROP_NOTIFYROWINSERT
Row Privileges | DBPROP_ROWRESTRICT
Row Resynchronization Notification | DBPROP_NOTIFYROWRESYNCH
Row Threading Model | DBPROP_ROWTHREADMODEL
Row Undo Change Notification | DBPROP_NOTIFYROWUNDOCHANGE
Row Undo Delete Notification | DBPROP_NOTIFYROWUNDODELETE
Row Undo Insert Notification | DBPROP_NOTIFYROWUNDOINSERT
Row Update Notification | DBPROP_NOTIFYROWUPDATE
Rowset Fetch Position Change Notification | DBPROP_NOTIFYROWSETFETCHPOSITIONCHANGE
Rowset Release Notification | DBPROP_NOTIFYROWSETRELEASE
Scroll Backwards | DBPROP_CANSCROLLBACKWARDS
Server Cursor | DBPROP_SERVERCURSOR
Server Data on Insert | DBPROP_SERVERDATAONINSERT
Skip Deleted Bookmarks | DBPROP_BOOKMARKSKIP
Strong Row Identity | DBPROP_STRONGIDENTITY
Updatability | DBPROP_UPDATABILITY
Use Bookmarks | DBPROP_BOOKMARKS
XML Root | SSPROP_STREAM_XMLROOT
XSL | SSPROP_STREAM_XSL

For specific implementation details and functional information about the Microsoft SQL Server OLE DB Provider, consult the OLE DB Provider for SQL Server documentation in the OLE DB section of the MDAC SDK.


Rowset Property (ADO)

 Copy code hover
[image]

Rowset Property (ADO)
Send feedback

Gets or sets an OLE DB Rowset object from/on an ADORecordsetConstruction object. When you use put_Rowset, the rowset is turned into an ADO Recordset object.

Read/write.

Syntax

HRESULT get_Rowset([out, retval] IUnknown** ppRowset);

HRESULT put_Rowset([in] IUnknown* pRowset);

Parameters

  • ppRowset

  • Pointer to an OLE DB Rowset object.

  • PRowset

  • An OLE DB Rowset object.

Return Values

This property method returns the standard HRESULT values, including S_OK and E_FAIL.

Applies To

ADORecordsetConstruction


ADOX Methods

 Copy code hover
[image]

ADOX Methods
Send feedback
Append (Columns) | Adds a new Column object to the Columns collection.
Append (Groups) | Adds a new Group object to the Groups collection.
Append (Indexes) | Adds a new Index object to the Indexes collection.
Append (Keys) | Adds a new Key object to the Keys collection.
Append (Procedures) | Adds a new Procedure object to the Procedures collection.
Append (Tables) | Adds a new Table object to the Tables collection.
Append (Users) | Adds a new User object to the Users collection.
Append (Views) | Adds a new View object to the Views collection.
ChangePassword | Changes the password for a user account.
Create | Creates a new catalog.
Delete | Removes an object from a collection.
GetObjectOwner | Returns the owner of an object in a catalog.
GetPermissions | Returns the permissions for a group or user on an object.
SetObjectOwner | Specifies the owner of an object in a catalog.
SetPermissions | Specifies the permissions for group or user on an object.


Named Commands

 Copy code hover
[image]

Named Commands
Send feedback

You can set the Name property on a Command object and then execute the command by calling it as if it were a method on the Command object ActiveConnection property. This is illustrated in the following example, in which the command is named GetCustomers. Notice that the code passes in a declared and instantiated Recordset object to the GetCustomers "method." You can also pass in parameters to the "method" if they are required by the Command.

Copy code Copy code

'BeginNamedCmd
 On Error GoTo ErrHandler:

 Dim objConn As New ADODB.Connection
 Dim objCmd As New ADODB.Command
 Dim objRs As New ADODB.Recordset

 ' Connect to the data source.
 Set objConn = GetNewConnection

 objCmd.CommandText = "SELECT CustomerID, CompanyName FROM Customers"
 objCmd.CommandType = adCmdText

 'Name the command.
 objCmd.Name = "GetCustomers"

 objCmd.ActiveConnection = objConn

 ' Execute using Command.Name from the Connection.
 objConn.GetCustomers objRs

 ' Display.
 Do While Not objRs.EOF
 Debug.Print objRs(0) & vbTab & objRs(1)
 objRs.MoveNext
 Loop

 'clean up
 objRs.Close
 objConn.Close
 Set objRs = Nothing
 Set objConn = Nothing
 Set objCmd = Nothing
 Exit Sub

ErrHandler:
 'clean up
 If objRs.State = adStateOpen Then
 objRs.Close
 End If

 If objConn.State = adStateOpen Then
 objConn.Close
 End If

 Set objRs = Nothing
 Set objConn = Nothing
 Set objCmd = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
'EndNamedCmd


Microsoft Access SQL reference

 Copy code hover
[image]

Microsoft Access SQL reference
Send feedback

In this section

  • Overview of the Access SQL Reference

  • Data Definition Language

  • Data Manipulation Language

  • Windows Registry Settings for External Data Sources


Before Delete Macro Event

 Copy code hover
[image]

Before Delete Macro Event
Send feedback

The Before Delete event occurs when a record is deleted, but before the change is committed.

Note Note

The Before Delete event is available only in Data Macros.

Remarks

Use the Before Delete event to perform any actions that you want to occur before a record is deleted. The Before Change is comonly used to perform validation and to raise custom error messges.

You can use access a value in the record to be deleted by using the following syntax.

Copy code Copy code
[Old].[Field Name]

For example, to access the value of the QuantityInStock field in the record to be deleted, use the following syntax.

Copy code Copy code
[Old].[QuantityInStock]

The values contained in the record to be deleted are deleted permanently when the Before Delete event ends.

You can cancel the Before Delete event by using the RaiseError action. When an error is raised the changes contained in the Before Delete event are discarded.

The following table lists macro commands that can be used in theBefore Delete event.

Command Type | Command
Program Flow | Comment Macro Statement
Program Flow | Group Macro Statement
Program Flow | If...Then...Else Macro Block
Data Block | LookupRecord Macro Action
Data Action | ClearMacroError Macro Action
Data Action | OnError Macro Action
Data Action | RaiseError Macro Action
Data Action | SetLocalVar Macro Action
Data Action | StopMacro Macro Action

To create a Data macro that captures the Before Delete event, use the following steps.

  1. Open the table for which you want to capture the Before Delete event.

  2. On the Table tab, in the Before Events group, click Before Delete.


How to: Perform Joins Using Access SQL

 Copy code hover
[image]

How to: Perform Joins Using Access SQL
Send feedback

In a relational database system like Access, you often need to extract information from more than one table at a time. This can be accomplished by using an SQL JOIN statement, which enables you to retrieve records from tables that have defined relationships, whether they are one-to-one, one-to-many, or many-to-many.

INNER JOINs

The INNER JOIN, also known as an equi-join, is the most commonly used type of join. This join is used to retrieve rows from two or more tables by matching a field value that is common between the tables. The fields you join on must have similar data types, and you cannot join on MEMO or OLEOBJECT data types. To build an INNER JOIN statement, use the INNER JOIN keywords in the FROM clause of a SELECT statement. This example uses the INNER JOIN to build a result set of all customers who have invoices, in addition to the dates and amounts of those invoices.

VBA Copy code Copy code
SELECT [Last Name], InvoiceDate, Amount
   FROM tblCustomers INNER JOIN tblInvoices
   ON tblCustomers.CustomerID=tblInvoices.CustomerID
   ORDER BY InvoiceDate

Be aware that the table names are divided by the INNER JOIN keywords and that the relational comparison is after the ON keyword. For the relational comparisons, you can also use the <, >, <=, >=, or <> operators, and you can also use the BETWEEN keyword. Also note that the ID fields from both tables are used only in the relational comparison; they are not part of the final result set.

To further qualify the SELECT statement, you can use a WHERE clause after the join comparison in the ON clause. The following example narrows the result set to include only invoices dated after January 1, 1998.

VBA Copy code Copy code
SELECT [Last Name], InvoiceDate, Amount
   FROM tblCustomers INNER JOIN tblInvoices
   ON tblCustomers.CustomerID=tblInvoices.CustomerID
   WHERE tblInvoices.InvoiceDate > #01/01/1998#
   ORDER BY InvoiceDate

When you must join more than one table, you can nest the INNER JOIN clauses. The following example builds on a previous SELECT statement to create the result set, but also includes the city and state of each customer by adding the INNER JOIN for the tblShipping table.

VBA Copy code Copy code
SELECT [Last Name], InvoiceDate, Amount, City, State
   FROM (tblCustomers INNER JOIN tblInvoices
   ON tblCustomers.CustomerID=tblInvoices.CustomerID)
      INNER JOIN tblShipping
      ON tblCustomers.CustomerID=tblShipping.CustomerID
   ORDER BY InvoiceDate

Be aware that the first JOIN clause is enclosed in parentheses to keep it logically separated from the second JOIN clause. It is also possible to join a table to itself by using an alias for the second table name in the FROM clause. Suppose that you want to find all customer records that have duplicate last names. You can do this by creating the alias "A" for the second table and checking for first names that are different.

VBA Copy code Copy code
SELECT tblCustomers.[Last Name],
   tblCustomers.[First Name]
   FROM tblCustomers INNER JOIN tblCustomers AS A
   ON tblCustomers.[Last Name]=A.[Last Name]
   WHERE tblCustomers.[First Name]<>A.[First Name]
   ORDER BY tblCustomers.[Last Name]

OUTER JOINs

An OUTER JOIN is used to retrieve records from multiple tables while preserving records from one of the tables, even if there is no matching record in the other table. There are two types of OUTER JOINs that the Access database engine supports: LEFT OUTER JOINs and RIGHT OUTER JOINs. Think of two tables that are beside each other, a table on the left and a table on the right. The LEFT OUTER JOIN selects all rows in the right table that match the relational comparison criteria, and also selects all rows from the left table, even if no match exists in the right table. The RIGHT OUTER JOIN is simply the reverse of the LEFT OUTER JOIN; all rows in the right table are preserved instead.

As an example, suppose that you want to determine the total amount invoiced to each customer, but if a customer has no invoices, you want to show it by displaying the word "NONE."

VBA Copy code Copy code
SELECT [Last Name] & ', ' &  [First Name] AS Name,
   IIF(Sum(Amount) IS NULL,'NONE',Sum(Amount)) AS Total
   FROM tblCustomers LEFT OUTER JOIN tblInvoices
   ON tblCustomers.CustomerID=tblInvoices.CustomerID
   GROUP BY [Last Name] & ', ' &  [First Name]

Several things occur in the previous SQL statement. The first is the use of the string concatenation operator "&". This operator allows you to join two or more fields together as one string. The second is the immediate if (IIf) statement, which checks to see if the total is null. If it is, the statement returns the word "NONE." If the total is not null, the value is returned. The final thing is the OUTER JOIN clause. Using the LEFT OUTER JOIN preserves the rows in the left table so that you see all customers, even those who do not have invoices.

OUTER JOINs can be nested inside INNER JOINs in a multi-table join, but INNER JOINs cannot be nested inside OUTER JOINs.

The Cartesian product

A term that often comes up when discussing joins is the Cartesian product. A Cartesian product is defined as "all possible combinations of all rows in all tables." For example, if you were to join two tables without any kind of qualification or join type, you would get a Cartesian product.

VBA Copy code Copy code
SELECT *
   FROM tblCustomers, tblInvoices

This is not a good thing, especially with tables that contain hundreds or thousands of rows. You should avoid creating Cartesian products by always qualifying your joins.

The UNION operator

Although the UNION operator, also known as a union query, is not technically a join, it is included here because it does involve combining data from multiple sources of data into one result set, which is similar to some types of joins. The UNION operator is used to splice together data from tables, SELECT statements, or queries, while leaving out any duplicate rows. Both data sources must have the same number of fields, but the fields do not have to be the same data type. Suppose that you have an Employees table that has the same structure as the Customers table, and you want to build a list of names and e-mail addresses by combining both tables.

VBA Copy code Copy code
SELECT [Last Name], [First Name], Email
   FROM tblCustomers
UNION
SELECT [Last Name], [First Name], Email
   FROM tblEmployees

To retrieve all fields from both tables, you could use the TABLE keyword, like this.

VBA Copy code Copy code
TABLE tblCustomers
UNION
TABLE tblEmployees

The UNION operator will not display any records that are exact duplicates in both tables, but this can be overridden by using the ALL predicate after the UNION keyword, like this:

VBA Copy code Copy code
SELECT [Last Name], [First Name], Email
   FROM tblCustomers
UNION ALL
SELECT [Last Name], [First Name], Email
   FROM tblEmployees

The TRANSFORM statement

Although the TRANSFORM statement, also known as a crosstab query, is also not technically considered a join, it is included here because it does involve combining data from multiple sources of data into one result set, which is similar to some types of joins.

A TRANSFORM statement is used to calculate a sum, average, count, or other type of aggregate total on records. It then displays the information in a grid or spreadsheet format with data grouped both vertically (rows) and horizontally (columns). The general form for a TRANSFORM statement is the following.

VBA Copy code Copy code
   TRANSFORM aggregating function
   SELECT statement
   PIVOT column heading field

An example scenario could be if you want to build a datasheet that displays the invoice totals for each customer on a year-by-year basis. The vertical headings will be the customer names, and the horizontal headings will be the years. You can modify a previous SQL statement to fit the transform statement.

VBA Copy code Copy code
TRANSFORM
IIF(Sum([Amount]) IS NULL,'NONE',Sum([Amount]))
   AS Total
SELECT [Last Name] & ', ' & [First Name] AS Name
      FROM tblCustomers LEFT JOIN tblInvoices
      ON tblCustomers.CustomerID=tblInvoices.CustomerID
      GROUP BY [Last Name] & ', ' & [First Name]
PIVOT Format(InvoiceDate, 'yyyy')
   IN ('1996','1997','1998','1999','2000')

Be aware that the aggregating function is the Sum function, the vertical headings are in the GROUP BY clause of the SELECT statement, and the horizontal headings are determined by the field listed after the PIVOT keyword.


ListBox.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

ListBox.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified list box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleBottom

expression A variable that represents a ListBox object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Reports Properties (Access)

 Copy code hover
[image]

Reports Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Report.
Parent | Returns the parent object for the specified object. Read-only.


Could not find installable ISAM. (Error 3170)

 Copy code hover
[image]

Could not find installable ISAM. (Error 3170)
Send feedback

The DLL for an installable ISAM file could not be found. This file is required for linking external tables (other than ODBC or Microsoft Access database engine tables). The locations for all ISAM drivers are maintained in the Microsoft Windows Registry. These entries are created automatically when you install your application. If you change the location of these drivers, you need to correct your application Setup program to reflect this change and make the correct entries in the Registry.

Possible causes:

  • An entry in the Registry is not valid. For example, this error occurs if you are using a Paradox external database, and the Paradox entry points to a nonexistent directory or driver. Exit the application, correct the Windows Registry, and try the operation again.

  • One of the entries in the Registry points to a network drive and that network is not connected. Make sure the network is available, and then try the operation again.


WebBrowserControl.MouseMove Event (Access)

 Copy code hover
[image]

WebBrowserControl.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Version Information

Version Added: Access 2010

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents a WebBrowserControl object.

Parameters

Name | Required/Optional | Data Type | Description
Button | Required | Integer |
Shift | Required | Integer |
X | Required | Single |
Y | Required | Single |

Return Value

nothing

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


WebBrowserControl.ProgressChange Event (Access)

 Copy code hover
[image]

WebBrowserControl.ProgressChange Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when the progress of a download operation is updated.

Version Information

Version Added: Access 2010

Syntax

expression .ProgressChange(Progress, ProgressMax)

expression A variable that represents a WebBrowserControl object.

Parameters

Name | Required/Optional | Data Type | Description
Progress | Required | Long | Specifies the amount of total progress to show, or -1 when progress is complete.
ProgressMax | Required | Long | Specifies the maximum progress value.

Return Value

nothing

Remarks

You can use the information provided by this event to display the number of bytes downloaded or to update a progress indicator.

To calculate the percent of progress to show in a progress indicator, multiply the value of Progress by 100, and divide by the value of ProgressMax; unless Progress is -1, in which case the container indicates that the operation is finished or hides the progress indicator.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


SQL Reserved Words

 Copy code hover
[image]

SQL Reserved Words
Send feedback

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

The following list includes all words reserved by the Microsoft Access database engine for use in SQL statements. The words in the list that are not in all uppercase letters are also reserved by other applications. Consequently, the individual Help topics for these words provide general descriptions that do not focus on SQL usage.

Note Note

Words followed by an asterisk (*) are reserved but currently have no meaning in the context of a Microsoft® Access SQL statement (for example, Level and TableID). Words that are not underlined do not have linked explanations.

A

ABSOLUTE | ANY
ADD | ARE
ADMINDB | AS
ALL | ASC
Alphanumeric — See TEXT | ASSERTION
ALTER | AUTHORIZATION
ALTER TABLE | AUTOINCREMENT — See COUNTER
And | Avg
AS |

B-C

BEGIN | COLLATION
Between | COLUMN
BINARY | COMMIT
BIT | COMP, COMPRESSION
BIT_LENGTH | CONNECT
BOOLEAN — See BIT | CONNECTION
BOTH | CONSTRAINT, CONSTRAINTS
BY | CONTAINER
BYTE | CONTAINS
CASCADE | CONVERT
CATALOG | Count
CHAR, CHARACTER — See TEXT | COUNTER
CHAR_LENGTH | CREATE
CHARACTER_LENGTH | CURRENCY
CHECK | CURRENT_DATE
CLOSE | CURRENT_TIME
CLUSTERED | CURRENT_TIMESTAMP
COALESCE | CURRENT_USER
COLLATE | CURSOR

D

DATABASE | DISALLOW
DATE — See DATETIME | DISCONNECT
DATETIME | DISTINCT
DAY | DISTINCTROW
DEC, DECIMAL | DOMAIN
DECLARE | DOUBLE
DELETE | DROP
DESC |

E-H

Eqv | FOREIGN
EXCLUSIVECONNECT | FROM
EXEC, EXECUTE | FROM Clause
EXISTS | GENERAL — See LONGBINARY
EXTRACT | GRANT
FALSE | GROUP
FETCH | GUID
FIRST | HAVING
FLOAT, FLOAT8 — See DOUBLE | HOUR
FLOAT4 — See SINGLE |

I

IDENTITY | INPUT
IEEEDOUBLE — See DOUBLE | INSENSITIVE
IEEESINGLE — See SINGLE | INSERT
IGNORE | INSERT INTO
IMAGE | INT, INTEGER, INTEGER4 — See LONG
Imp | INTEGER1 — See BYTE
In | INTEGER2 — See SHORT
IN | INTERVAL
INDEX | INTO
INDEXCREATEDB | Is
INNER | ISOLATION

J-M

JOIN | LONGTEXT
KEY | LOWER
LANGUAGE | MATCH
LAST | Max
LEFT | MEMO — See LONGTEXT
Level* | Min
Like | MINUTE
LOGICAL, LOGICAL1 — See BIT | Mod
LONG | MONEY — See CURRENCY
LONGBINARY | MONTH
LONGCHAR |

N-P

NATIONAL | Outer*
NCHAR | OUTPUT
NONCLUSTERED | OWNERACCESS
Not | PAD
NTEXT | PARAMETERS
NULL | PARTIAL
NUMBER — See DOUBLE | PASSWORD
NUMERIC — See DECIMAL | PERCENT
NVARCHAR | PIVOT
OCTET_LENGTH | POSITION
OLEOBJECT — See LONGBINARY | PRECISION
ON | PREPARE
OPEN | PRIMARY
OPTION | PRIVILEGES
Or | PROC, PROCEDURE
ORDER | PUBLIC

Q-S

REAL — See SINGLE | SMALLDATETIME
REFERENCES | SMALLINT — See SHORT
RESTRICT | SMALLMONEY
REVOKE | SOME
RIGHT | SPACE
ROLLBACK | SQL
SCHEMA | SQLCODE, SQLERROR, SQLSTATE
SECOND | StDev
SELECT | StDevP
SELECTSCHEMA | STRING — See TEXT
SELECTSECURITY | SUBSTRING
SET | Sum
SHORT | SYSNAME
SINGLE | SYSTEM_USER
SIZE |

T-Z

TABLE | UPDATEOWNER
TableID* | UPDATESECURITY
TEMPORARY | UPPER
TEXT | USAGE
TIME — See DATETIME | USER
TIMESTAMP | USING
TIMEZONE_HOUR | VALUE
TIMEZONE_MINUTE | VALUES
TINYINT | Var
TO | VARBINARY — See BINARY
TOP | VARCHAR — See TEXT
TRAILING | VarP
TRANSACTION | VARYING
TRANSFORM | VIEW
TRANSLATE | WHEN
TRANSLATION | WHENEVER
TRIM | WHERE
TRUE | WITH
UNION | WORK
UNIQUE | Xor
UNIQUEIDENTIFIER | YEAR
UNKNOWN | YESNO — See BIT
UPDATE | ZONE
UPDATEIDENTITY |


Filter/query/search (Access 2013 custom web app)

 Copy code hover
[image]

Filter/query/search (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • RequeryRecords Macro Action (Access 2013 custom web app)


Invalid arguments used with domain function. (Error 2428)

 Copy code hover
[image]

Invalid arguments used with domain function. (Error 2428)
Send feedback

You have entered an invalid argument in an aggregate function. For information on the function's arguments, see SQL Aggregate Functions, and then choose the name of the function.


CommandButton.OnMouseUp Property (Access)

 Copy code hover
[image]

CommandButton.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Syntax

expression .OnMouseUp

expression A variable that represents a CommandButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ToggleButton.IsVisible Property (Access)

 Copy code hover
[image]

ToggleButton.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Syntax

expression .IsVisible

expression A variable that represents a ToggleButton object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


TabControl.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

TabControl.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthBottom

expression A variable that represents a TabControl object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


TabControl.PressedThemeColorIndex Property (Access)

 Copy code hover
[image]

TabControl.PressedThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .PressedThemeColorIndex

expression A variable that represents a TabControl object.

Remarks

The PressedThemeColorIndex uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 (Default) | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the PressedThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Static Cursors

 Copy code hover
[image]

Static Cursors
Send feedback

The static cursor always displays the result set as it was when the cursor was first opened. Depending on implementation, static cursors are either read-only or read/write and provide forward and backward scrolling. The static cursor does not usually detect changes made to the membership, order, or values of the result set after the cursor is opened. Static cursors may detect their own updates, deletes, and inserts, although they are not required to do so.

Static cursors never detect other updates, deletes, and inserts. For example, suppose a static cursor fetches a row, and another application then updates that row. If the application refetches the row from the static cursor, the values it sees are unchanged, despite the changes made by the other application. All types of scrolling are supported, but providers may or may not support bookmarks.

If your application does not need to detect data changes and requires scrolling, the static cursor is the best choice. Use the adOpenStatic CursorTypeEnum to indicate that you want to use a static cursor in ADO.


Open Method (ADO Connection)

 Copy code hover
[image]

Open Method (ADO Connection)
Send feedback

Opens a connection to a data source.

Syntax

connection.Open ConnectionString, UserID, Password, Options

Parameters

  • ConnectionString

  • Optional. A String value that contains connection information. See the ConnectionString property for details on valid settings.

  • UserID

  • Optional. A String value that contains a user name to use when establishing the connection.

  • Password

  • Optional. A String value that contains a password to use when establishing the connection.

  • Options

  • Optional. A ConnectOptionEnum value that determines whether this method should return after (synchronously) or before (asynchronously) the connection is established.

Remarks

Using the Open method on a Connection object establishes the physical connection to a data source. After this method successfully completes, the connection is live and you can issue commands against it and process the results.

Use the optional ConnectionString argument to specify either a connection string containing a series of argument = value statements separated by semicolons, or a file or directory resource identified with a URL. The ConnectionString property automatically inherits the value used for the ConnectionString argument. Therefore, you can either set the ConnectionString property of the Connection object before opening it, or use the ConnectionString argument to set or override the current connection parameters during the Open method call.

If you pass user and password information both in the ConnectionString argument and in the optional UserID and Password arguments, the UserID and Password arguments will override the values specified in ConnectionString.

When you have concluded your operations over an open Connection, use the Close method to free any associated system resources. Closing an object does not remove it from memory; you can change its property settings and use the Open method to open it again later. To completely eliminate an object from memory, set the object variable to Nothing.

Remote Data Service UsageWhen used on a client-side Connection object, the Open method doesn't actually establish a connection to the server until a Recordset is opened on the Connection object.

Note Note

URLs using the http scheme will automatically invoke the Microsoft OLE DB Provider for Internet Publishing. For more information, see Absolute and Relative URLs.


BoundObjectFrame.OnUpdated Property (Access)

 Copy code hover
[image]

BoundObjectFrame.OnUpdated Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Updated box in the Properties window of a form or report. Read/write String.

Syntax

expression .OnUpdated

expression A variable that represents a BoundObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The OnUpdated value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Updated box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Updated box is blank, the property value is an empty string.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


ListBox.OnClick Property (Access)

 Copy code hover
[image]

ListBox.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Syntax

expression .OnClick

expression A variable that represents a ListBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


BoundObjectFrame.OnClick Property (Access)

 Copy code hover
[image]

BoundObjectFrame.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Syntax

expression .OnClick

expression A variable that represents a BoundObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Cannot use HAVING clause in TRANSFORM statement. (Error 3092)

 Copy code hover
[image]

Cannot use HAVING clause in TRANSFORM statement. (Error 3092)
Send feedback

If you want to specify selection criteria, use a WHERE clause.


SmartTagProperties Object (Access)

 Copy code hover
[image]

SmartTagProperties Object (Access)
See also Send feedback

Published: July 16, 2012

A collection of SmartTagProperty objects that represents the properties related to a smart tag.

Remarks

To return the SmartTagProperties collection for a smart tag, use the Properties property of the SmartTag object. To create a custom property from within a Visual Basic for Applications (VBA) project, use the Add method of the SmartTagProperties collection.

See also

Concepts

Access Object Model Reference

Other resources

SmartTagProperties Object Members


Update/RI conflict. (Error 3718)

 Copy code hover
[image]

Update/RI conflict. (Error 3718)
Send feedback

The primary key record has been updated by another replica, therefore this referencing record has been rejected. Either create a new primary key record that satisfies the referential integrity constraint and then resubmit your update, modify the foreign key value in this conflict record to match a valid primary key value and then resubmit your update, or delete this conflict record.


Line Control

 Copy code hover
[image]

Line Control
Send feedback

Published: July 16, 2012

The line control displays a horizontal, vertical, or diagonal line on a form or report.

Remarks

You can use Border Width to change the line width. You can use Border Color to change the color of the border or make it transparent. You can change the line style (dots, dashes, and so on) of the border by using the BorderStyle property.


Recordset Positioning

 Copy code hover
[image]

Recordset Positioning
Send feedback

Use the AbsolutePosition property to move to a record, based on its ordinal position in the Recordset object, or to determine the ordinal position of the current record. The provider must support the appropriate functionality for this property to be available.

AbsolutePosition is 1-based and equals 1 when the current record is the first record in the Recordset. As mentioned previously, you can obtain the total number of records in the Recordset object from the RecordCount property.

When you set the AbsolutePosition property, even if it is to a record in the current cache, ADO reloads the cache with a new group of records starting with the record you specified. The CacheSize property determines the size of this group.

Note Note

You should not use the AbsolutePosition property as a surrogate record number. The position of a given record changes when you delete a preceding record. There also is no assurance that a given record will have the same AbsolutePosition if the Recordset object is requeried or reopened. Bookmarks are the recommended way of retaining and returning to a given position and are the only way of positioning across all types of Recordset objects.


CommandButton.OnMouseMove Property (Access)

 Copy code hover
[image]

CommandButton.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Syntax

expression .OnMouseMove

expression A variable that represents a CommandButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


StayInSync Property Example (VB)

 Copy code hover
[image]

StayInSync Property Example (VB)
Send feedback

This example demonstrates how the StayInSync property facilitates accessing rows in a hierarchical Recordset.

The outer loop displays each author's first and last name, state, and identification. The appended Recordset for each row is retrieved from the Fields collection and automatically assigned to rstTitleAuthor by the StayInSync property whenever the parent Recordset moves to a new row. The inner loop displays four fields from each row in the appended recordset.

Copy code Copy code

'BeginStayInSyncVB
Public Sub Main()
 On Error GoTo ErrorHandler

 'To integrate this code create a DSN called Pubs
 'with a user_id = sa and no password

 Dim Cnxn As ADODB.Connection
 Dim rst As ADODB.Recordset
 Dim rstTitleAuthor As New ADODB.Recordset
 Dim strCnxn As String

 ' open connection with Data Shape attributes
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider=MSDataShape;Data Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' create recordset
 Set rst = New ADODB.Recordset
 rst.StayInSync = True
 rst.Open "SHAPE {select * from Authors} " & _
 "APPEND ( { select * from titleauthor} AS chapTitleAuthor " & _
 "RELATE au_id TO au_id) ", Cnxn, , , adCmdText

 Set rstTitleAuthor = rst("chapTitleAuthor").Value
 Do Until rst.EOF
 Debug.Print rst!au_fname & " " & rst!au_lname & " " & _
 rst!State & " " & rst!au_id

 Do Until rstTitleAuthor.EOF
 Debug.Print rstTitleAuthor(0) & " " & rstTitleAuthor(1) & " " & _
 rstTitleAuthor(2) & " " & rstTitleAuthor(3)
 rstTitleAuthor.MoveNext
 Loop

 rst.MoveNext
 Loop

 ' clean up
 rst.Close
 Cnxn.Close
 Set rst = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rst Is Nothing Then
 If rst.State = adStateOpen Then rst.Close
 End If
 Set rst = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndStayInSyncVB


TextBox.ReadingOrder Property (Access)

 Copy code hover
[image]

TextBox.ReadingOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.

Syntax

expression .ReadingOrder

expression A variable that represents a TextBox object.

Remarks

The ReadingOrder property uses the following settings.

Setting | Visual Basic | Description
Context | 0 | Reading order is determined by the language of the first character entered. If a right-to-left language character is entered first, reading order is right to left. If a left-to-right language character is entered first, reading order is left to right.
Left-to-Right | 1 | Sets the reading order to left to right.
Right-to-Left | 2 | Sets the reading order to right to left.

Example

The following example sets the reading order to right to left for the "Address" text box on the "International Shipping" form.

VBA Copy code Copy code
Forms("International Shipping").Controls("Address").ReadingOrder = 2

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ObjectFrame.Enabled Property (Access)

 Copy code hover
[image]

ObjectFrame.Enabled Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.

Syntax

expression .Enabled

expression A variable that represents an ObjectFrame object.

Remarks

The Enabled property setting is a value that indicates whether the conditional format is enabled or disabled. True enables the conditional format. False disables the conditional format. The default is True.

When the Enabled property is True, the conditional format can be displayed in the Conditional Formatting dialog box.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


TabControl.BorderShade Property (Access)

 Copy code hover
[image]

TabControl.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents a TabControl object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens BorderColor by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


ListBox.FontUnderline Property (Access)

 Copy code hover
[image]

ListBox.FontUnderline Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontUnderline property to specify whether text is underlined in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontUnderline

expression A variable that represents a ListBox object.

Remarks

The FontUnderline property uses the following settings.

Setting | Description
True | The text is underlined.
False | (Default) The text isn't underlined.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


WebBrowserControl.NavigateError Event (Access)

 Copy code hover
[image]

WebBrowserControl.NavigateError Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when an error occurs during navigation.

Version Information

Version Added: Access 2010

Syntax

expression .NavigateError(pDisp, URL, TargetFrameName, StatusCode, Cancel)

expression A variable that represents a WebBrowserControl object.

Parameters

Name | Required/Optional | Data Type | Description
pDisp | Required | Object | A pointer to an IDispatch interface for the WebBrowser object that represents the window or frame in which the navigation error occurred.
URL | Required | Variant | Contains the URL for which navigation failed.
TargetFrameName | Required | Variant | Contains the name of the frame in which to display the resource, or NULL if no named frame was targeted for the resource.
StatusCode | Required | Variant | Contains an error status code, if available.
Cancel | Required | Boolean | Specifies whether to cancel the navigation to an error page or to any further autosearch.

Return Value

nothing

Remarks

This event fires before the WebBrowser control displays an error page due to an error in navigation. You can stop the display of the error page by setting the Cancel parameter to True. However, if the server contacted in the original navigation supplies its own substitute page navigation, when you set Cancel to True, it has no effect, and the navigation to the server's alternate page proceeds. For example, assume that a navigation to http://www.www.wingtiptoys.com/BigSale.htm causes this event to fire because the page does not exist. However, the server is set to redirect the navigation to http://www.www.wingtiptoys.com/home.htm. In this case, when you set Cancel to True, it has no effect, and navigation proceeds to http://www.www.wingtiptoys.com/home.htm.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


TempVars.RemoveAll Method (Access)

 Copy code hover
[image]

TempVars.RemoveAll Method (Access)
See also Send feedback

Published: July 16, 2012

Removes all of the TempVar objects from the TempVars collection.

Version Information

Version Added: Access 2007

Syntax

expression .RemoveAll

expression A variable that represents a TempVars object.

See also

Concepts

TempVars Collection

Other resources

TempVars Object Members


SubForm.TabStop Property (Access)

 Copy code hover
[image]

SubForm.TabStop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.

Syntax

expression .TabStop

expression A variable that represents a SubForm object.

Remarks

This property doesn't apply to toggle button controls when they appear in an option group. It applies only to the option group itself.

The TabStop property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) You can move the focus to the control by pressing the TAB key.
No | False | You can't move the focus to the control by pressing the TAB key.

When you create a control on a form, Microsoft Access automatically assigns the control a position in the form's tab order. Each new control is placed last in the tab order. If you want to prevent a control from being available when you tab through the controls in a form, set the control's TabStop property to No.

In Form view, hidden or disabled controls remain in the tab order but are skipped when you move through the controls by pressing TAB, even if their TabStop properties are set to Yes.

As long as a control's Enabled property is set to Yes, you can click the control or use an access key to select it, regardless of its TabStop property setting. For example, you can set the TabStop property of a command button to No to prevent users from selecting the button by pressing TAB. However, they can still click the command button to choose it.

Example

The following example disables the ability to move the focus to the "City" text box on the "Suppliers" form by using the TAB key.

VBA Copy code Copy code
Forms("Suppliers").Controls("City").TabStop = False

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


OptionButton.GridlineWidthTop Property (Access)

 Copy code hover
[image]

OptionButton.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified option button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthTop

expression A variable that represents an OptionButton object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Provider Property (ADO)

 Copy code hover
[image]

Provider Property (ADO)
Send feedback

Indicates the name of the provider for a Connection object.

Settings and Return Values

Sets or returns a String value that indicates the provider name.

Remarks

Use the Provider property to set or return the name of the provider for a connection. This property can also be set by the contents of the ConnectionString property or the ConnectionString argument of the Open method; however, specifying a provider in more than one place while calling the Open method can have unpredictable results. If no provider is specified, the property will default to MSDASQL (Microsoft OLE DB Provider for ODBC).

The Provider property is read/write when the connection is closed and read-only when it is open. The setting does not take effect until you either open the Connection object or access the Properties collection of the Connection object. If the setting is not valid, an error occurs.


ListBox.Top Property (Access)

 Copy code hover
[image]

ListBox.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Syntax

expression .Top

expression A variable that represents a ListBox object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Step 1: Set Up the Visual Basic Project
Send feedback

Step 1: Set Up the Visual Basic Project

In this scenario, it is assumed that you have Microsoft Visual Basic 6.0 or later, ADO 2.5 or later, and the Microsoft OLE DB Provider for Internet Publishing installed on your system.

To create an ADO project

  1. In Microsoft Visual Basic, create a new Standard EXE project.

  2. From the Project menu, choose References.

  3. Select "Microsoft ActiveX Data Objects 2.5 Library" and click OK.

To insert controls on the main form

  1. Add a ListBox control to Form1. Set its Name property to lstMain.

  2. Add another ListBox control to Form1. Set its Name property to lstDetails.

  3. Add a TextBox control to Form1. Set its Name property to txtDetails.


NavigationButton.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

NavigationButton.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified list box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleBottom

expression A variable that represents a NavigationButton object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Recordset2.Update Method (DAO)

 Copy code hover
[image]

Recordset2.Update Method (DAO)
Send feedback

Syntax

expression .Update(UpdateType, Force)

expression A variable that represents a Recordset2 object.

Parameters

Name | Required/Optional | Data Type | Description
UpdateType | Optional | Long | A UpdateTypeEnum constant indicating the type of update, as specified in Settings (ODBCDirect workspaces only).
Force | Optional | Boolean | A Boolean value indicating whether or not to force the changes into the database, regardless of whether the underlying data has been changed by another user since the AddNew, Delete, or Edit call. If True, the changes are forced and changes made by other users are simply overwritten. If False (default), changes made by another user while the update is pending will cause the update to fail for those changes that are in conflict. No error occurs, but the BatchCollisionCount and BatchCollisions properties will indicate the number of conflicts and the rows affected by conflicts, respectively (ODBCDirect workspaces only).

Remarks

Use Update to save the current record and any changes you've made to it.

Important note Important

Changes to the current record are lost if:

  • You use the Edit or AddNew method, and then move to another record without first using Update.

  • You use Edit or AddNew, and then use Edit or AddNew again without first using Update.

  • You set the Bookmark property to another record.

  • You close the Recordset without first using Update.

  • You cancel the Edit operation by using CancelUpdate.

To edit a record, use the Edit method to copy the contents of the current record to the copy buffer. If you don't use Edit first, an error occurs when you use Update or attempt to change a field's value.

In an ODBCDirect workspace, you can do batch updates, provided the cursor library supports batch updates, and the Recordset was opened with the optimistic batch locking option.

In a Microsoft Access workspace, when the Recordset object's LockEdits property setting is True (pessimistically locked) in a multiuser environment, the record remains locked from the time Edit is used until the Update method is executed or the edit is canceled. If the LockEdits property setting is False (optimistically locked), the record is locked and compared with the pre-edited record just before it is updated in the database. If the record has changed since you used the Edit method, the Update operation fails. Microsoft Access database engine-connected ODBC and installable ISAM databases always use optimistic locking. To continue the Update operation with your changes, use the Update method again. To revert to the record as the other user changed it, refresh the current record by using Move 0.

Note Note

To add, edit, or delete a record, there must be a unique index on the record in the underlying data source. If not, a "Permission denied" error will occur on the AddNew, Delete, or Edit method call in a Microsoft Access workspace, or an "Invalid argument" error will occur on the Update call in an ODBCDirect workspace.


Line.Move Method (Access)

 Copy code hover
[image]

Line.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a Line object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

Line Object

Other resources

Line Object Members


Access Reports How Do I...

 Copy code hover
[image]

Access Reports How Do I...
Send feedback

This page links to help on widely used report-related tasks. To view other categories of popular tasks covered in Help, see How Do I… in Access.

Design

  • How to: Apply a Custom Ribbon to a Form or Report

    • Describes how to display a custom ribbon when a particular form or report is opened.

  • How to: Call Procedures in a Subform or Subreport

    • Describes how to call a procedure that is stored in a subform or subreport from the main form or report.

  • How to: Create Alternating Row Colors on a Report

    • Describes how to apply shading to every other row in a report.

Controls

  • How to: Assign a Control a Value From a Table

    • Describes how to use the DLookup function to display the value of a field that is not in the record source for your form or report.

  • How to: Set Form, Report, and Control Properties in Code

    • Describes how to set properties of forms, reports, and controls.

Printing

  • How to: Programmatically Retrieve Printer Capabilities

    • Describes how to use the Windows API to determine a printer's capabilities.

  • How to: Retrieve a List of Installed Printers

    • Describes how to use the Printers collection to determine the installed printers.

  • How to: Work with Form and Report Printer Settings

    • Describes how to set or retrieve printer settings for a specific form or report.

Events

  • How to: Apply a Filter When Opening a Form or Report

    • Describes several techniques for filtering a form or report as it opens.

  • How to: Cancel an Event

    • Lists the events that can be canceled programmatically.

  • How to: Change the Filter or Sort Order of a Form or Report

    • Describes how to change the filter or sort order of a form or report in response to users' actions.

  • How to: Close a Report Automatically If It Does Not Contain Any Records

    • Describes how to to cancel opening or printing a report when it has no data.

  • How to: Filter a Report Using a Form's Filter

    • Describes how to open a report that contains only the filtered records of a form.

  • How Do I... in Access


Form.OnKeyPress Property (Access)

 Copy code hover
[image]

Form.OnKeyPress Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Press box in the Properties window. Read/write String.

Syntax

expression .OnKeyPress

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyPress event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyPress value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Press box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Press box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyPress property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyPress

See also

Concepts

Form Object

Other resources

Form Object Members


Procedures Collection (ADOX) Reference

 Copy code hover
[image]

Procedures Collection (ADOX) Reference
Send feedback

In this section

  • Procedures Collection (ADOX)

  • Procedures Collection Properties, Methods, and Events (ADOX)


DefinedSize Property Example (VB)

 Copy code hover
[image]

DefinedSize Property Example (VB)
Send feedback

This example demonstrates the DefinedSize property of a Column. The code will redefine the size of the FirstName column of the Employees table of the Northwind database. Then, the change in the values of the FirstName Field of a Recordset based on the Employees table is displayed. Note that by default, the FirstName field becomes padded with spaces after you redefine the DefinedSize property.

Copy code Copy code

' BeginDefinedSizeVB
Public Sub Main()
 On Error GoTo DefinedSizeXError

 Dim rstEmployees As ADODB.Recordset
 Dim catNorthwind As New ADOX.Catalog
 Dim colFirstName As ADOX.Column
 Dim colNewFirstName As New ADOX.Column
 Dim aryFirstName() As String
 Dim i As Integer
 Dim strCnn As String

 strCnn = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\" & _
 "Microsoft Office\Office\Samples\Northwind.mdb';"

 ' Open a Recordset for the Employees table.
 Set rstEmployees = New ADODB.Recordset
 rstEmployees.Open "Employees", strCnn, adOpenKeyset, , adCmdTable
 ReDim aryFirstName(rstEmployees.RecordCount)

 ' Open a Catalog for the Northwind database,
 ' using same connection as rstEmployees
 Set catNorthwind.ActiveConnection = rstEmployees.ActiveConnection

 ' Loop through the recordset displaying the contents
 ' of the FirstName field, the field's defined size,
 ' and its actual size.
 ' Also store FirstName values in aryFirstName array.
 rstEmployees.MoveFirst
 Debug.Print " "
 Debug.Print "Original Defined Size and Actual Size"
 i = 0
 Do Until rstEmployees.EOF
 Debug.Print "Employee name: " & rstEmployees!FirstName & _
 " " & rstEmployees!LastName
 Debug.Print " FirstName Defined size: " _
 & rstEmployees!FirstName.DefinedSize
 Debug.Print " FirstName Actual size: " & _
 rstEmployees!FirstName.ActualSize
 If Not rstEmployees!FirstName = Null Then
 aryFirstName(i) = rstEmployees!FirstName
 End If
 rstEmployees.MoveNext
 i = i + 1
 Loop
 rstEmployees.Close

 ' Redefine the DefinedSize of FirstName in the catalog
 Set colFirstName = catNorthwind.Tables("Employees").Columns("FirstName")
 colNewFirstName.Name = colFirstName.Name
 colNewFirstName.Type = colFirstName.Type
 colNewFirstName.DefinedSize = colFirstName.DefinedSize + 1

 ' Append new FirstName column to catalog
 catNorthwind.Tables("Employees").Columns.Delete colFirstName.Name
 catNorthwind.Tables("Employees").Columns.Append colNewFirstName

 ' Open Employee table in Recordset for updating
 rstEmployees.Open "Employees", catNorthwind.ActiveConnection, _
 adOpenKeyset, adLockOptimistic, adCmdTable

 ' Loop through the recordset displaying the contents
 ' of the FirstName field, the field's defined size,
 ' and its actual size.
 ' Also restore FirstName values from aryFirstName.
 rstEmployees.MoveFirst
 Debug.Print " "
 Debug.Print "New Defined Size and Actual Size"
 i = 0
 Do Until rstEmployees.EOF
 rstEmployees!FirstName = aryFirstName(i)
 Debug.Print "Employee name: " & rstEmployees!FirstName & _
 " " & rstEmployees!LastName
 Debug.Print " FirstName Defined size: " _
 & rstEmployees!FirstName.DefinedSize
 Debug.Print " FirstName Actual size: " & _
 rstEmployees!FirstName.ActualSize
 rstEmployees.MoveNext
 i = i + 1
 Loop
 rstEmployees.Close

 ' Restore original FirstName column to catalog
 catNorthwind.Tables("Employees").Columns.Delete colNewFirstName.Name
 catNorthwind.Tables("Employees").Columns.Append colFirstName

 ' Restore original FirstName values to Employees table
 rstEmployees.Open "Employees", catNorthwind.ActiveConnection, _
 adOpenKeyset, adLockOptimistic, adCmdTable

 rstEmployees.MoveFirst
 i = 0
 Do Until rstEmployees.EOF
 rstEmployees!FirstName = aryFirstName(i)
 rstEmployees.MoveNext
 i = i + 1
 Loop
 rstEmployees.Close

 'Clean up
 Set catNorthwind = Nothing
 Set colNewFirstName = Nothing
 Set colFirstName = Nothing
 Set rstEmployees = Nothing
 Exit Sub

DefinedSizeXError:
 Set catNorthwind = Nothing
 Set colNewFirstName = Nothing
 Set colFirstName = Nothing

 If Not rstEmployees Is Nothing Then
 If rstEmployees.State = adStateOpen Then rstEmployees.Close
 End If
 Set rstEmployees = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If

End Sub
' EndDefinedSizeVB


CustomControl.GridlineStyleRight Property (Access)

 Copy code hover
[image]

CustomControl.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleRight

expression A variable that represents a CustomControl object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Line.Width Property (Access)

 Copy code hover
[image]

Line.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents a Line object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

Line Object

Other resources

Line Object Members


Image.Click Event (Access)

 Copy code hover
[image]

Image.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Syntax

expression .Click

expression A variable that represents an Image object.

Remarks

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

Image Object

Other resources

Image Object Members


Image Object (Access)

 Copy code hover
[image]

Image Object (Access)
See also Send feedback

Published: July 16, 2012

This object corresponds to an image control. The image control can add a picture to a form or report. For example, you could include an image control for a logo on an Invoice report.

Remarks

Control: | Tool:

You can use the image control or an Unbound object frame for unbound pictures. The advantage of using the image control is that it's faster to display. The advantage of using the unbound object frame is that you can edit the object directly from the form or report.

See also

Concepts

Access Object Model Reference

Other resources

Image Object Members


You cannot establish or maintain an enforced relationship between a replicated table and a local table. (Error 3453)

 Copy code hover
[image]

You cannot establish or maintain an enforced relationship between a replicated table and a local table. (Error 3453)
Send feedback

You are attempting to establish or maintain an enforced relationship between a replicated table and a non-replicated table. Replication does not allow an enforced relationship between:

  • A replicated table and a local table.

  • Two local tables that you are making replicable.

  • Two tables with different KeepLocal property settings.

Delete the relationship between the two tables before proceeding.


Report.DrawWidth Property (Access)

 Copy code hover
[image]

Report.DrawWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DrawWidth property to specify the line width for the Line , Circle , and Pset methods to print lines on reports. Read/write Integer.

Syntax

expression .DrawWidth

expression A variable that represents a Report object.

Remarks

You can set the DrawWidth property to an Integer value of 1 through 32,767. This value represents the width of the line in pixels. The default is 1, or 1 pixel wide.

You can set this property in an event procedure specified by a section's OnPrint property setting.

Increase the value of this property to increase the width of the line. If the DrawWidth property setting is greater than 3, DrawMode property settings 1 through 4 produce a solid line (the DrawStyle property setting isn't changed). Setting the DrawWidth property to 1 enables the DrawStyle property to produce the results shown in the setting table of the DrawStyle property.

See also

Concepts

Report Object

Other resources

Report Object Members


ImportExportSpecifications Members (Access)

 Copy code hover
[image]

ImportExportSpecifications Members (Access)
Send feedback

Published: July 16, 2012

Represents the collection of available ImportExportSpecification objects.

Methods

Name | Description
Add | Adds a new ImportExportSpecification object to the ImportExportSpecifications collection.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only ImportExportSpecification.
Parent | Returns the parent object for the specified object. Read-only Object.


Expression too complex. (Error 2445)

 Copy code hover
[image]

Expression too complex. (Error 2445)
Send feedback

This expression is too complex for the Microsoft Access database engine. Try to simplify the expression.


CopyTo Method (ADO)

 Copy code hover
[image]

CopyTo Method (ADO)
Send feedback

Copies the specified number of characters or bytes (depending on Type) in the Stream to another Stream object.

Syntax

Stream.CopyTo DestStream, NumChars

Parameters

  • DestStream

  • An object variable value that contains a reference to an open Stream object. The current Stream is copied to the destination Stream specified by DestStream. The destination Stream must already be open. If not, a run-time error occurs.

    Note Note

    The DestStream parameter may not be a proxy of Stream object because this requires access to a private interface on the Stream object that cannot be remoted to the client.

  • NumChars

  • Optional. An Integer value that specifies the number of bytes or characters to be copied from the current position in the source Stream to the destination Stream. The default value is -1, which specifies that all characters or bytes are copied from the current position to EOS.

Remarks

This method copies the specified number of characters or bytes, starting from the current position specified by the Position property. If the specified number is more than the available number of bytes until EOS, then only characters or bytes from the current position to EOS are copied. If the value of NumChars is -1, or omitted, all characters or bytes starting from the current position are copied.

If there are existing characters or bytes in the destination stream, all contents beyond the point where the copy ends remain, and are not truncated. Position becomes the byte immediately following the last byte copied. If you want to truncate these bytes, call SetEOS.

CopyTo should be used to copy data to a destination Stream of the same type as the source Stream (their Type property settings are both adTypeText or both adTypeBinary). For text Stream objects, you can change the Charset property setting of the destination Stream to translate from one character set to another. Also, text Stream objects can be successfully copied into binary Stream objects, but binary Stream objects cannot be copied into text Stream objects.


Database.NewPassword Method (DAO)

 Copy code hover
[image]

Database.NewPassword Method (DAO)
Send feedback

Changes the password of an existing Microsoft Access database engine database (Microsoft Access workspaces only).

Syntax

expression .NewPassword(bstrOld, bstrNew)

expression An expression that returns a Database object.

Parameters

Name

Required/Optional

Data Type

Description

bstrOld

Required

String

The current setting of the Password property of the Database object.

bstrNew

Required

String

The new setting of the Password property of the Database object.

Note Note

Use strong passwords that combine upper- and lowercase letters, numbers, and symbols. Weak passwords don't mix these elements. Strong password: Y6dh!et5. Weak password: House27. Use a strong password that you can remember so that you don't have to write it down.

Remarks

The bstrOld and bstrNew strings can be up to 20 characters long and can include any characters except the ASCII character 0 (null). To clear the password, use a zero-length string ("") for bstrNew.

Passwords are case-sensitive.

If a database has no password, the Microsoft Access database engine will automatically create one by passing a zero-length string ("") for the old password.

Important note Important

If you lose your password, you can never open the database again.


Could not find output table

 Copy code hover
[image]

Could not find output table <name>. (Error 3192)
Send feedback

You tried to use an INSERT INTO statement with the specified table, which does not exist. Make sure you entered the name correctly, and then try the operation again.

If you are attempting to execute a make-table query that creates the table for you, use the SELECT INTO syntax instead.


Form.MaxRecords Property (Access)

 Copy code hover
[image]

Form.MaxRecords Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies the maximum number of records by a query or view. Read/write Long.

Syntax

expression .MaxRecords

expression A variable that represents a Form object.

Remarks

When you set this property in Visual Basic you use the ADO MaxRecords property.

Records are returned in the order specified by the query's ORDER BY clause.

You can use the MaxRecords property in situations where limited system resources might prohibit a large number of returned records.

Example

To return the MaxRecords property for a form, you can use the following:

VBA Copy code Copy code
Dim l As Longl = Forms(formname).MaxRecords

To set the MaxRecords property, you can use the following:

VBA Copy code Copy code
Forms(formname).MaxRecords = numrecords

See also

Concepts

Form Object

Other resources

Form Object Members


Control.Report Property (Access)

 Copy code hover
[image]

Control.Report Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Report property to refer to a report or to refer to the report associated with a subreport control. Read-only Report.

Syntax

expression .Report

expression A variable that represents a Control object.

Remarks

This property is typically used to refer to the report contained in a subreport control.

Note Note

When you use the Reports collection, you must specify the name of the report.

Example

The following example uses the Report property to refer to a control on a subreport.

VBA Copy code Copy code
Dim curTotalSales As Currency

curTotalSales = Reports!Sales!Employees.Report!TotalSales

See also

Concepts

Control Object

Other resources

Control Object Members


Row Property (ADO)

 Copy code hover
[image]

Row Property (ADO)
Send feedback

Gets or sets an OLE DB Row object from/on an ADORecordConstruction object. When you use put_Row to set a Row object, a row is turned into an ADO Record object. Read/write.

Syntax

HRESULT get_Row([out, retval] IUnknown** ppRow);

HRESULT put_Row([in] IUnknown* pRow);

Parameters

  • ppRow

  • Pointer to an OLE DB Row object.

  • PRow

  • An OLE DB Row object.

Return Values

This property method returns the standard HRESULT values, including S_OK and E_FAIL.

Applies To

ADORecordConstruction


View Properties, Methods, and Events (ADOX)

 Copy code hover
[image]

View Properties, Methods, and Events (ADOX)
Send feedback

Properties

Command Property

DateCreated Property

DateModified Property

Name Property

Methods

None.

Events

None.


Microsoft OLE DB Provider for Microsoft Indexing Service

 Copy code hover
[image]

Microsoft OLE DB Provider for Microsoft Indexing Service
Send feedback

The Microsoft OLE DB Provider for Microsoft Indexing Service provides programmatic read-only access to file system and Web data indexed by Microsoft Indexing Service. ADO applications can issue SQL queries to retrieve content and file property information.

The provider is free-threaded and unicode enabled.

Connection String Parameters

To connect to this provider, set the Provider= argument to the ConnectionString property to:

Copy code Copy code

MSIDXS

Reading the Provider property will return this string as well.

Typical Connection String

A typical connection string for this provider is:

Copy code Copy code

"Provider=MSIDXS;Data Source=myCatalog;Locale Identifier=nnnn;"

The string consists of these keywords:

Keyword | Description
Provider | Specifies the OLE DB Provider for Microsoft Indexing Service. Typically this is the only keyword specified in the connection string.
Data Source | Specifies the Indexing Service catalog name. If this keyword is not specified, the default system catalog is used.
Locale Identifier | Specifies a unique 32-bit number (for example, 1033) that specifies preferences related to the user's language. These preferences indicate how dates and times are formatted, items are sorted alphabetically, strings are compared, and so on. If this keyword is not specified, the default system locale identifier is used.

Command Text

The Indexing Service SQL query syntax consists of extensions to the SQL-92 SELECT statement and its FROM and WHERE clauses. The results of the query are returned via OLE DB rowsets, which can be consumed by ADO and manipulated as Recordset objects.

You can search for exact words or phrases, or use wildcards to search for patterns or stems of words. The search logic can be based on Boolean decisions, weighted terms, or proximity to other words. You can also search by "free text," which finds matches based on meaning, rather than exact words.

The provider does not accept stored procedure calls or simple table names (for example, the CommandType property will always be adCmdText).

Recordset Behavior

The following tables list the features available with a Recordset object opened with this provider. Only the Static cursor type (adOpenStatic) is available.

For more detailed information about Recordset behavior for your provider configuration, run the Supports method and enumerate the Properties collection of the Recordset to determine whether provider-specific dynamic properties are present.

Availability of standard ADO Recordset properties:

Property | Availability
AbsolutePage | read/write
AbsolutePosition | read/write
ActiveConnection | read-only
BOF | read-only
Bookmark* | read/write
CacheSize | read/write
CursorLocation | always adUseServer
CursorType | always adOpenStatic
EditMode | always adEditNone
EOF | read-only
Filter | read/write
LockType | read/write
MarshalOptions | not available
MaxRecords | read/write
PageCount | read-only
PageSize | read/write
RecordCount | read-only
Source | read/write
State | read-only
Status | read-only

*Bookmarks must be enabled on the provider in order for this feature to exist on the Recordset.

Availability of standard ADO Recordset methods:

Method | Available?
AddNew | No
Cancel | Yes
CancelBatch | No
CancelUpdate | No
Clone | Yes
Close | Yes
Delete | No
GetRows | Yes
Move | Yes
MoveFirst | Yes
NextRecordset | Yes
Open | Yes
Requery | Yes
Resync | Yes
Supports | Yes
Update | No
UpdateBatch | No

See AlsoFor specific implementation details and functional information about the Microsoft OLE DB Provider for Microsoft Indexing Service, consult the Microsoft OLE DB Programmer's Reference.


BoundObjectFrame.KeyUp Event (Access)

 Copy code hover
[image]

BoundObjectFrame.KeyUp Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyUp(KeyCode, Shift)

expression A variable that represents a BoundObjectFrame object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyUp property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyUp event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyUp event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


AcProjectType Enumeration (Access)

 Copy code hover
[image]

AcProjectType Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the ProjectType property to determine the type of project that is currently open.

Name | Value | Description
acADP | 1 | The current project is a Microsoft Access project.
acMDB | 2 | The current project is a Microsoft Access database.
acNull | 0 |


ComboBox.NotInList Event (Access)

 Copy code hover
[image]

ComboBox.NotInList Event (Access)
See also Send feedback

Published: July 16, 2012

The NotInList event occurs when the user enters a value in the text box portion of a combo box that isn't in the combo box list.

Syntax

expression .NotInList(NewData, Response)

expression A variable that represents a ComboBox object.

Parameters

Name

Required/Optional

Data Type

Description

NewData

Required

String

A string that Microsoft Access uses to pass the text the user entered in the text box portion of the combo box to the event procedure.

Response

Required

Integer

The setting indicates how the NotInList event was handled. The Response argument can be one of the following intrinsic constants:

  • acDataErrDisplay (Default) Displays the default message to the user. You can use this when you don't want to allow the user to add a new value to the combo box list.

  • acDataErrContinue Doesn't display the default message to the user. You can use this when you want to display a custom message to the user. For example, the event procedure could display a custom dialog box asking if the user wanted to save the new entry. If the response is Yes, the event procedure would add the new entry to the list and set the Response argument to acDataErrAdded. If the response is No, the event procedure would set the Response argument to acDataErrContinue.

  • acDataErrAdded Doesn't display a message to the user but enables you to add the entry to the combo box list in the NotInList event procedure. After the entry is added, Microsoft Access updates the list by re-querying the combo box. Microsoft Access then rechecks the string against the combo box list, and saves the value in the NewData argument in the field the combo box is bound to. If the string is not in the list, then Microsoft Access displays an error message.

Remarks

To run a macro or event procedure when this event occurs, set the OnNotInList property to the name of the macro or to [Event Procedure].

This event enables the user to add a new value to the combo box list.

The LimitToList property must be set to Yes for the NotInList event to occur.

The NotInList event doesn't trigger the Error event.

The NotInList event occurs for combo boxes whose LimitToList property is set to Yes, after you enter a value that isn't in the list and attempt to move to another control or save the record. The event occurs after all the Change events for the combo box.

When the AutoExpand property is set to Yes, Microsoft Access selects matching values in the list as the user enters characters in the text box portion of the combo box. If the characters the user types match the first characters of a value in the list (for example, the user types "Smith" and "Smithson" is a value in the list), the NotInList event will not occur when the user moves to another control or saves the record. However, the characters that Microsoft Access adds to the characters the user types (in the example, "son") are selected in the text box portion of the combo box. If the user wants the NotInList event to fire in such cases (for example, the user wants to add the new name "Smith" to the combo box list), the user can enter a SPACE, BACKSPACE, or DEL character after the last character in the new value.

When the LimitToList property is set to Yes and the combo box list is dropped down, Microsoft Access selects matching values in the list as the user enters characters in the text box portion of the combo box, even if the AutoExpand property is set to No. If the user presses ENTER or moves to another control or record, the selected value appears in the combo box. In this case, the NotInList event will not fire. To allow the NotInList event to fire, the user should not drop down the combo box list.

Example

The following example uses the NotInList event to add an item to a combo box.

To try this example, create a combo box called Colors on a form. Set the combo box's LimitToList property to Yes. To populate the combo box, set the combo box's RowSourceType property to Value List, and supply a list of values separated by semicolons as the setting for the RowSource property. For example, you might supply the following values as the setting for this property: Red; Green; Blue.

Next add the following event procedure to the form. Switch to Form view and enter a new value in the text portion of the combo box.

Note Note

This example adds an item to an unbound combo box. When you add an item to a bound combo box, you add a value to a field in the underlying data source. In most cases you can't simply add one field in a new record — depending on the structure of data in the table, you probably will need to add one or more fields to fulfill data requirements. For instance, a new record must include values for any fields comprising the primary key. If you need to add items to a bound combo box dynamically, you must prompt the user to enter data for all required fields, save the new record, and then re-query the combo box to display the new value.

VBA Copy code Copy code
Private Sub Colors_NotInList(NewData As String, _
        Response As Integer)
    Dim ctl As Control

    ' Return Control object that points to combo box.
    Set ctl = Me!Colors
    ' Prompt user to verify they wish to add new value.
    If MsgBox("Value is not in list. Add it?", _
         vbOKCancel) = vbOK Then
        ' Set Response argument to indicate that data
        ' is being added.
        Response = acDataErrAdded
        ' Add string in NewData argument to row source.
        ctl.RowSource = ctl.RowSource & ";" & NewData
    Else
    ' If user chooses Cancel, suppress error message
    ' and undo changes.
        Response = acDataErrContinue
        ctl.Undo
    End If
End Sub

The following example shows how to use the NotInList event to add an item to a bound combo box.

Sample code provided by: MVP Contributor Bill Jelen, MrExcel.com | About the Contributors

VBA Copy code Copy code
Private Sub cboDept_NotInList(NewData As String, Response As Integer)
    Dim oRS As DAO.Recordset, i As Integer, sMsg As String
    Dim oRSClone As DAO.Recordset

    Response = acDataErrContinue

    If MsgBox("Add dept?", vbYesNo) = vbYes Then
        Set oRS = CurrentDb.OpenRecordset("tblDepartments", dbOpenDynaset)
        oRS.AddNew
        oRS.Fields(1) = NewData
        For i = 2 To oRS.Fields.Count - 1
            sMsg = "What do you want for " & oRS(i).Name
            oRS(i).Value = InputBox(sMsg, , oRS(i).DefaultValue)
        Next i
        oRS.Update
        cboDept = Null
        cboDept.Requery
        DoCmd.OpenTable "tblDepartments", acViewNormal, acReadOnly
        DoCmd.GoToRecord acDataTable, "tblDepartments", acLast
    End If
End Sub

The following example shows how to add an item to a bound combo box.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Private Sub cboMainCategory_NotInList(NewData As String, Response As Integer)

    On Error GoTo Error_Handler
    Dim intAnswer As Integer
    intAnswer = MsgBox("""" & NewData & """ is not an approved category. " & vbcrlf _
        & "Do you want to add it now?" _ vbYesNo + vbQuestion, "Invalid Category")

    Select Case intAnswer
        Case vbYes
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO tlkpCategoryNotInList (Category) "
                & _ "Select """ & NewData & """;"
            DoCmd.SetWarnings True
            Response = acDataErrAdded
        Case vbNo
            MsgBox "Please select an item from the list.", _
                vbExclamation + vbOKOnly, "Invalid Entry"
            Response = acDataErrContinue

    End Select

    Exit_Procedure:
        DoCmd.SetWarnings True
        Exit Sub

    Error_Handler:
        MsgBox Err.Number & ", " & Error Description
        Resume Exit_Procedure
        Resume

End Sub

About the Contributors

Holy Macro! Books publishes entertaining books for people who use Microsoft Office. See the complete catalog at MrExcel.com.

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


CommandButton.HyperlinkSubAddress Property (Access)

 Copy code hover
[image]

CommandButton.HyperlinkSubAddress Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the HyperlinkSubAddress property to specify or determine a location within the target document specified by the HyperlinkAddress property. Read/write String.

Syntax

expression .HyperlinkSubAddress

expression A variable that represents a CommandButton object.

Remarks

The HyperlinkSubAddress property can be an object within a Microsoft Access database, a bookmark within a Microsoft Word document, a named range within a Microsoft Excel spreadsheet, a slide within a Microsoft PowerPoint presentation, or a location within an HTML document.

The HyperlinkSubAddress property is a string expression representing a named location within the target document specified by the HyperlinkAddress property.

Note Note

When you create a hyperlink by using the Insert Hyperlink dialog box, Microsoft Access automatically sets the HyperlinkAddress property and HyperlinkSubAddress to the location specified in the Type the file or Web page name box. The HyperlinkSubAddress property can also be set to the location specified in the Select an object in this database box.

If you copy a hyperlink from another application and paste it into a form or report, Microsoft Access creates a label control with its Caption property, HyperlinkAddress property, and HyperlinkSubAddress property automatically set.

When you move the cursor over a command button, image control, or label control whose HyperlinkAddress property is set, the cursor changes to an upward-pointing hand. Clicking the control displays the object or Web page specified by the link.

To open objects in the current database, leave the HyperlinkAddress property blank and specify the object type and object name you want to open in the HyperlinkSubAddress property by using the syntax "objecttype objectname". If you want to open an object contained in another Microsoft Access database, enter the database path and file name in the HyperlinkAddress property and specify the database object to open by using the HyperlinkSubAddress property.

The HyperlinkAddress property can contain an absolute or a relative path to a target document. An absolute path is a fully qualified URL or UNC path to a document. A relative path is a path related to the base path specified in the Hyperlink Base setting in the Properties dialog box (available by clicking Database Properties on the File menu) or to the current database path. If Microsoft Access can't resolve the HyperlinkAddress property setting to a valid URL or UNC path, it will assume you've specified a path relative to the base path contained in the Hyperlink Base setting or the current database path.

Note Note

When you follow a hyperlink to another Microsoft Access database object, the database Startup properties are applied. For example, if the destination database has a Display form set, that form is displayed when the database opens.

The following table contains examples of HyperlinkAddress and HyperlinkSubAddress property settings.

HyperlinkAddress | HyperlinkSubAddress | Description
http://www.microsoft.com/ |  | The Microsoft home page on the Web.
C:\Program Files\Microsoft Office\Office\Samples\Cajun.htm |  | The Cajun Delights page in the Access sample applications subdirectory.
C:\Program Files\Microsoft Office\Office\Samples\Cajun.htm | NewProducts | The "NewProducts" Name tag in the Cajun Delights page.
C:\Personal\MyResume.doc | References | The bookmark named "References" in the Microsoft Word document "MyResume.doc".
C:\Finance\First Quarter.xls | Sheet1!TotalSales | The range named "TotalSales" in the Microsoft Excel spreadsheet "First Quarter.xls".
C:\Presentation\NewPlans.ppt | 10 | The 10th slide in the Microsoft PowerPoint document "NewPlans.ppt".

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Recordset2.LastModified Property (DAO)

 Copy code hover
[image]

Recordset2.LastModified Property (DAO)
Send feedback

Returns a ookmark indicating the most recently added or changed record.

Syntax

expression .LastModified

expression A variable that represents a Recordset2 object.

Remarks

You can use the LastModified property to move to the most recently added or updated record. Use the LastModified property with table- and dynaset-type Recordset objects. A record must be added or modified in the Recordset object itself in order for the LastModified property to have a value.

Example

This example uses the LastModified property to move the current record pointer to both a record that has been modified and a newly created record.

VBA Copy code Copy code
Sub LastModifiedX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset2
 Dim strFirst As String
 Dim strLast As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", _
 dbOpenDynaset)

 With rstEmployees
 ' Store current data.
 strFirst = !FirstName
 strLast = !LastName
 ' Change data in current record.
 .Edit
 !FirstName = "Julie"
 !LastName = "Warren"
 .Update
 ' Move current record pointer to the most recently
 ' changed or added record.
 .Bookmark = .LastModified
 Debug.Print _
 "Data in LastModified record after Edit: " & _
 !FirstName & " " & !LastName

 ' Restore original data because this is a demonstration.
 .Edit
 !FirstName = strFirst
 !LastName = strLast
 .Update

 ' Add new record.
 .AddNew
 !FirstName = "Roger"
 !LastName = "Harui"
 .Update
 ' Move current record pointer to the most recently
 ' changed or added record.
 .Bookmark = .LastModified
 Debug.Print _
 "Data in LastModified record after AddNew: " & _
 !FirstName & " " & !LastName

 ' Delete new record because this is a demonstration.
 .Delete
 .Close
 End With

 dbsNorthwind.Close

End Sub

This example uses the AddNew method to create a new record with the specified name. The AddName function is required for this procedure to run.

VBA Copy code Copy code
Sub AddNewX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset2
 Dim strFirstName As String
 Dim strLastName As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", dbOpenDynaset)

 ' Get data from the user.
 strFirstName = Trim(InputBox( _
 "Enter first name:"))
 strLastName = Trim(InputBox( _
 "Enter last name:"))

 ' Proceed only if the user actually entered something
 ' for both the first and last names.
 If strFirstName <> "" and strLastName <> "" Then

 ' Call the function that adds the record.
 AddName rstEmployees, strFirstName, strLastName

 ' Show the newly added data.
 With rstEmployees
 Debug.Print "New record: " & !FirstName & _
 " " & !LastName
 ' Delete new record because this is a demonstration.
 .Delete
 End With

 Else
 Debug.Print _
 "You must input a string for first and last name!"
 End If

 rstEmployees.Close
 dbsNorthwind.Close

End Sub

Function AddName(rstTemp As Recordset, _
 strFirst As String, strLast As String)

 ' Adds a new record to a Recordset using the data passed
 ' by the calling procedure. The new record is then made
 ' the current record.
 With rstTemp
 .AddNew
 !FirstName = strFirst
 !LastName = strLast
 .Update
 .Bookmark = .LastModified
 End With

End Function


ToggleButton Object (Access)

 Copy code hover
[image]

ToggleButton Object (Access)
See also Send feedback

Published: July 16, 2012

This object corresponds to a toggle button. A toggle button on a form is a stand-alone control used to display a Yes/No value from an underlying record source.

Remarks

Control: | Tool:
Note Note

When you click a toggle button that's bound to a Yes/No field, Microsoft Access displays the value in the underlying table according to the field's Format property (Yes/No, True/False, or On/Off).

Toggle buttons are most useful when used in an option group with other buttons.

You can also use a toggle button in a custom dialog box to accept user input.

See also

Concepts

Access Object Model Reference

Other resources

ToggleButton Object Members


RowSourceType Property (User-Defined Function) - Code Argument Values

 Copy code hover
[image]

RowSourceType Property (User-Defined Function) - Code Argument Values
Send feedback

Published: July 16, 2012

The Visual Basic function you create must accept five arguments. The first argument must be declared as a control and the remaining arguments as Variants. The function itself must return a Variant.

Function functionname (fld As Control, id As Variant, row As Variant, col As Variant, code As Variant) As Variant

The Function procedure has the following five required arguments.

Argument | Description
fld | A control variable that refers to the list box or combo box being filled.
id | A unique value that identifies the control being filled. This is useful when you want to use the same user-defined function for more than one list box or combo box and must distinguish between them. (The example sets this variable to the value of the Timer function.)
row | The row being filled (zero-based).
col | The column being filled (zero-based).
code | An intrinsic constant that specifies the kind of information being requested.
Note Note

Because Microsoft Access calls a user-defined function several times to insert items into a list, often you must preserve information from call to call. The best way to do this is to use Static variables.

Microsoft Access calls the user-defined function by repeatedly using different values in the code argument to specify the information it needs. The code argument can use the following intrinsic constants.

Constant | Meaning | Function returns
acLBInitialize | Initialize | Nonzero if the function can fill the list; False (0) or Null otherwise.
acLBOpen | Open | Nonzero ID value if the function can fill the list; False or Null otherwise.
acLBGetRowCount | Number of rows | Number of rows in the list (can be zero); -1 if unknown.
acLBGetColumnCount | Number of columns | Number of columns in the list (can't be zero); must match the property sheet value.
acLBGetColumnWidth | Column width | Width (in twips) of the column specified by the col argument; -1 to use the default width.
acLBGetValue | List entry | List entry to be displayed in the row and column specified by the row and col arguments.
acLBGetFormat | Format string | Format string to be used to format the list entry displayed in the row and column specified by the row and col arguments; -1 to use the default format.
acLBEnd | End (the last call to a user-defined function always uses this value) | Nothing.
acLBClose | (Not used) | Not used.

Microsoft Access calls your user-defined function once for acLBInitialize, acLBOpen, acLBGetRowCount, and acLBGetColumnCount. It initializes the user-defined function, opens the query, and determines the number of rows and columns.

Microsoft Access calls your user-defined function twice for acLBGetColumnWidth — once to determine the total width of the list box or combo box and a second time to set the column width.

The number of times your user-defined function is called for acLBGetValue and acLBGetFormat to get list entries and to format strings varies depending on the number of entries, the user's scrolling, and other factors.

Microsoft Access calls the user-defined function for acLBEnd when the form is closed or each time the list box or combo box is queried.

Whenever a particular value (such as the number of columns) is required, returning Null or any invalid value causes Microsoft Access to stop calling the user-defined function with that code.

Tip Tip

You can use the Select Case code structure from the example as a template for your own RowSourceType property user-defined functions.

Example

The following user-defined function returns a list of the next four Mondays following today's date. To call this function from a list box control, enter ListMondays as the RowSourceType property setting and leave the RowSource property setting blank.

Copy code Copy code
Function ListMondays(fld As Control,id As Variant, _
 row As Variant,col As Variant,code As Variant) _
 As Variant
 Dim intOffset As Integer
 Select Case code
 Case acLBInitialize ' Initialize.
 ListMondays = True
 Case acLBOpen ' Open.
 ListMondays = Timer ' Unique ID.
 Case acLBGetRowCount ' Get rows.
 ListMondays = 4
 Case acLBGetColumnCount ' Get columns.
 ListMondays = 1
 Case acLBGetColumnWidth ' Get column width.
 ListMondays = -1 ' Use default width.
 Case acLBGetValue ' Get the data.
 intOffset = Abs((9 - Weekday(Now))Mod 7)
 ListMondays = Format(Now() + _
 intOffset + 7 * row,"mmmm d")
 End Select
End Function

The next example uses a static array to store the names of the databases in the current directory. To call this function, enter ListMDBs as the RowSourceType property setting and leave the RowSource property setting blank.

Copy code Copy code
Function ListMDBs(fld As Control, id As Variant, _
 row As Variant, col As Variant, _
 code As Variant) As Variant
 Static dbs(127) As String, Entries As Integer
 Dim ReturnVal As Variant
 ReturnVal = Null
 Select Case code
 Case acLBInitialize ' Initialize.
 Entries = 0
 dbs(Entries ) = Dir("*.MDB")
 Do Until dbs(Entries) = "" Or Entries >= 127
 Entries = Entries+1
 dbs(Entries) = Dir
 Loop
 ReturnVal = Entries
 Case acLBOpen ' Open.
 ' Generate unique ID for control.
 ReturnVal = Timer
 Case acLBGetRowCount ' Get number of rows.
 ReturnVal = Entries
 Case acLBGetColumnCount ' Get number of columns.
 ReturnVal = 1
 Case acLBGetColumnWidth ' Column width.
 ' -1 forces use of default width.
 ReturnVal = -1
 Case acLBGetValue ' Get data.
 ReturnVal = dbs(row)
 Case acLBEnd ' End.
 Erase dbs
 End Select
 ListMDBs = ReturnVal
End Function


DateDiff Function (Access 2013 custom web app)

 Copy code hover
[image]

DateDiff Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the count of the specified date part boundaries crossed between the specified start date and end date.

Syntax

DateDiff(DatePart, StartDate, EndDate)

The DateDiff function contains the following arguments.

Argument name | Description
DatePart | Is the part of StartDate and EndDate that specifies the type of boundary crossed. Refer to the Remarks section for the list of valid settings.
StartDate | An expression that can be resolved to a Date/Time value. The Date argument expression, column expression, user-defined variable or string literal.
EndDate | An expression that can be resolved to a Date/Time value. The Date argument expression, column expression, user-defined variable or string literal.

Remarks

The following table lists all valid DatePart arguments.

DatePart

year

quarter

month

dayofyear

day

week

hour

minute

second

millisecond


DateCreated and DateModified Properties Example (VC++)

 Copy code hover
[image]

DateCreated and DateModified Properties Example (VC++)
Send feedback

This example demonstrates the DateCreated and DateModified properties by adding a new Column to an existing Table and by creating a new Table. The DateOutput procedure is required for this example to run.

Copy code Copy code

// BeginDateCreatedCpp
#import "c:\Program Files\Common Files\system\ado\msadox.dll" no_namespace
#import "c:\Program Files\Common Files\system\ado\msado15.dll"

#include "iostream.h"
#include "stdio.h"
#include "conio.h"

//Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void DateCreatedX(void);
void DateOutPut(_bstr_t strTemp , _TablePtr tblTemp);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 DateCreatedX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// DateCreatedX Function //
// //
//////////////////////////////////////////////////////////
void DateCreatedX()
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.
 _CatalogPtr m_pCatalog = NULL;
 _TablePtr m_pTblEmployees = NULL;
 _TablePtr m_pTblNew = NULL;

 //Set ActiveConnection of Catalog to this string
 _bstr_t strCnn("Provider='Microsoft.JET.OLEDB.4.0';"
 "Data Source= 'c:\\Program Files\\Microsoft Office\\"
 "Office\\Samples\\Northwind.mdb';");

 try
 {
 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof (Catalog)));

 // Connect the catalog.
 m_pCatalog->PutActiveConnection(strCnn);

 m_pTblEmployees = m_pCatalog->Tables->GetItem("Employees");

 // Print current information about the Employees table.
 DateOutPut((_bstr_t)"Current properties", m_pTblEmployees);

 // Create and append column to the Employees table.
 m_pTblEmployees->Columns->Append("NewColumn", adInteger,0);

 m_pCatalog->Tables->Refresh();

 // Print new information about the Employees table.
 DateOutPut((_bstr_t)"After creating a new column",
 m_pTblEmployees);

 // Delete new column because this is a demonstration.
 m_pTblEmployees->Columns->Delete("NewColumn");

 // Create and append new Table object to the Northwind database.
 TESTHR(hr = m_pTblNew.CreateInstance(__uuidof(Table)));

 m_pTblNew->Name = "NewTable";
 m_pTblNew->Columns->Append("NewColumn", adInteger,0);
 m_pCatalog->Tables->Append(_variant_t((IDispatch*)m_pTblNew));
 m_pCatalog->Tables->Refresh();

 //Print information about the new Table object.
 DateOutPut((_bstr_t)"After creating a new table", m_pCatalog->
 Tables->GetItem("NewTable"));

 // Delete new Table object because this is a demonstration.
 m_pCatalog->Tables->Delete(m_pTblNew->Name);
 }

 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }

 catch(...)
 {
 cout << "Error occured in include files...."<< endl;
 }
}

//////////////////////////////////////////////////////////
// //
// DateOutPut Function //
// //
//////////////////////////////////////////////////////////
void DateOutPut(_bstr_t strTemp , _TablePtr tblTemp)
{
 // Print DateCreated and DateModified information about
 // specified Table object.
 cout << strTemp << endl;
 cout << " Table: " << tblTemp->GetName() << endl;
 cout << " DateCreated = " << (_bstr_t)tblTemp->
 GetDateCreated() << endl;
 cout << " DateModified = " << (_bstr_t)tblTemp->
 GetDateModified() << endl;
}
// EndDateCreatedCpp


Scaling of decimal value resulted in data truncation. (Error 3759)

 Copy code hover
[image]

Scaling of decimal value resulted in data truncation. (Error 3759)
Send feedback

This error occurs when the data being updated or inserted into a DECIMAL data type does not match the defined scale and precision of the column.


Label.SmartTags Property (Access)

 Copy code hover
[image]

Label.SmartTags Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a SmartTags collection that represents the collection of smart tags that have been added to a control. .

Syntax

expression .SmartTags

expression A variable that represents a Label object.

Remarks

Note Note

Unlike the SmartTags collections in Microsoft Excel and Microsoft Word, the SmartTags collection in Microsoft Access is zero-based. Therefore, the code control.SmartTags(0) returns the first smart tag for the specified control.

See also

Concepts

Label Object

Other resources

Label Object Members


BoundObjectFrame.LabelY Property (Access)

 Copy code hover
[image]

BoundObjectFrame.LabelY Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelY

expression A variable that represents a BoundObjectFrame object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Database.RecordsAffected Property (DAO)

 Copy code hover
[image]

Database.RecordsAffected Property (DAO)
Send feedback

Returns the number of records affected by the most recently invoked Execute method.

Syntax

expression .RecordsAffected

expression A variable that represents a Database object.

Example

This example uses the RecordsAffected property with action queries executed from a Database object and from a QueryDef object. The RecordsAffectedOutput function is required for this procedure to run.

VBA Copy code Copy code
Sub RecordsAffectedX()

 Dim dbsNorthwind As Database
 Dim qdfTemp As QueryDef
 Dim strSQLChange As String
 Dim strSQLRestore As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind
 ' Print report of contents of the Employees
 ' table.
 Debug.Print _
 "Number of records in Employees table: " & _
 .TableDefs!Employees.RecordCount
 RecordsAffectedOutput dbsNorthwind

 ' Define and execute an action query.
 strSQLChange = "UPDATE Employees " & _
 "SET Country = 'United States' " & _
 "WHERE Country = 'USA'"
 .Execute strSQLChange

 ' Print report of contents of the Employees
 ' table.
 Debug.Print _
 "RecordsAffected after executing query " & _
 "from Database: " & .RecordsAffected
 RecordsAffectedOutput dbsNorthwind

 ' Define and run another action query.
 strSQLRestore = "UPDATE Employees " & _
 "SET Country = 'USA' " & _
 "WHERE Country = 'United States'"
 Set qdfTemp = .CreateQueryDef("", strSQLRestore)
 qdfTemp.Execute

 ' Print report of contents of the Employees
 ' table.
 Debug.Print _
 "RecordsAffected after executing query " & _
 "from QueryDef: " & qdfTemp.RecordsAffected
 RecordsAffectedOutput dbsNorthwind

 .Close

 End With

End Sub

Function RecordsAffectedOutput(dbsNorthwind As Database)

 Dim rstEmployees As Recordset

 ' Open a Recordset object from the Employees table.
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees")

 With rstEmployees
 ' Enumerate Recordset.
 .MoveFirst
 Do While Not .EOF
 Debug.Print " " & !LastName & ", " & !Country
 .MoveNext
 Loop
 .Close
 End With

End Function


WriteText Method (ADO)

 Copy code hover
[image]

WriteText Method (ADO)
Send feedback

Writes a specified text string to a Stream object.

Syntax

Stream.WriteText Data, Options

Parameters

  • Data

  • A String value that contains the text in characters to be written.

  • Options

  • Optional. A StreamWriteEnum value that specifies whether a line separator character must be written at the end of the specified string.

Remarks

Specified strings are written to the Stream object without any intervening spaces or characters between each string.

The current Position is set to the character following the written data. The WriteText method does not truncate the rest of the data in a stream. If you want to truncate these characters, call SetEOS.

If you write past the current EOS position, the Size of the Stream will be increased to contain any new characters, and EOS will move to the new last byte in the Stream.

Note Note

The WriteText method is used with text streams (Type is adTypeText). For binary streams (Type is adTypeBinary), use Write.


SubForm.OldBorderStyle Property (Access)

 Copy code hover
[image]

SubForm.OldBorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.

Syntax

expression .OldBorderStyle

expression A variable that represents a SubForm object.

Remarks

The OldBorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines
Note Note

  • If the OldBorderStyle property is set to None or Dialog, the form doesn't have Maximize or Minimize buttons, regardless of its MinMaxButtons property setting.

  • If the OldBorderStyle property is set to None, the form doesn't have a Control menu, regardless of its ControlBox property setting.

  • The OldBorderStyle property setting doesn't affect the display of the scroll bars, navigation buttons, the record number box, or record selectors.

Example

The following example demonstrates the effect of changing a control's BorderStyle property, while leaving the OldBorderStyle unaffected. The example concludes with setting the BorderStyle property to its original unedited value.

VBA Copy code Copy code
With Forms("Order Entry").Controls("Zip Code") .BorderStyle = 3 ' Short dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 3, 1.

    .BorderStyle = 2 ' Dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 2, 1

    .BorderStyle = .OldBorderStyle ' Solid (default) border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 1, 1
End With

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Program Flow

 Copy code hover
[image]

Program Flow
Send feedback

In this section

  • If...Then...Else Macro Block

  • Comment Macro Statement

  • Group Macro Statement

  • Submacro Macro Statement


Too many Memo or OLE Object fields. (Error 3054)

 Copy code hover
[image]

Too many Memo or OLE Object fields. (Error 3054)
Send feedback

You tried to perform a Btrieve operation that involves too many Memo or OLE Object fields. Reduce the number of Memo and OLE Object fields, and then try the operation again.


Procedures Delete Method Example (VB)

 Copy code hover
[image]

Procedures Delete Method Example (VB)
Send feedback

The following code demonstrates how to delete a procedure using the Procedures collection Delete method.

Copy code Copy code

' BeginDeleteProcedureVB
Sub Main()
 On Error GoTo DeleteProcedureError

 Dim cat As New ADOX.Catalog

 ' Open the Catalog.
 cat.ActiveConnection = _
 "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\Microsoft Office\" & _
 "Office\Samples\Northwind.mdb';"

 ' Delete the Procedure.
 cat.Procedures.Delete "CustomerById"

 'Clean up
 Set cat.ActiveConnection = Nothing
 Set cat = Nothing
 Exit Sub

DeleteProcedureError:
 Set cat = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndDeleteProcedureVB


MacroError.ActionName Property (Access)

 Copy code hover
[image]

MacroError.ActionName Property (Access)
Send feedback

Published: July 16, 2012

Gets the name of the macro action that was executing when an error occurred. Read-only.

Version Information

Version Added: Access 2007

Syntax

expression .ActionName

expression A variable that represents a MacroError object.

Remarks

When an error occurs in a macro, information about the error is stored in the MacroError object. If you have not used the OnError action to suppress error messages, the macro stops and the error information is displayed in a standard error message. However, if you have used the OnError action to suppress error messages, you may want to use the information stored in the MacroError object in a condition or a custom error message.

After an error has been handled, the information in the MacroError object is out of date, so it is a good idea to clear the object using the ClearMacroError action. This resets the error number in the MacroError object back to zero, and clears any other information about the error that is stored in the object, such as the error description, macro name, action name, condition, and arguments. This way, you can inspect the MacroError object again later to see if another error has occurred.


CustomControl.HorizontalAnchor Property (Access)

 Copy code hover
[image]

CustomControl.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the text box is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2010

Syntax

expression .HorizontalAnchor

expression A variable that represents a CustomControl object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Application.LoadFromAXL Method (Access)

 Copy code hover
[image]

Application.LoadFromAXL Method (Access)
See also Send feedback

Published: July 16, 2012

Imports the object defined in an Application XML (AXL) file into the database.

Version Information

Version Added: Access 2010

Syntax

expression .LoadFromAXL(ObjectType, ObjectName, FileName)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
ObjectType | Required | AcObjectType | Specifies the type of object to create.
ObjectName | Required | String | Specifies the name of the object.
FileName | Required | String | Specifies the full path and filename of the AXL file to import.

Remarks

The LoadFromAXL method does not provide a warning when the object specified in the ObjectName argument already exists. If an object of the same name already exists, it will be replaced by the object specified in the ObjectName argument.

For more information about AXL, see [MS-AXL]: Access Application Transfer Protocol Structure Specification.

See also

Concepts

Application Object

Other resources

Application Object Members


Operations.Count Property (Access)

 Copy code hover
[image]

Operations.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Version Information

Version Added: Access 2010

Syntax

expression .Count

expression A variable that represents an Operations object.

See also

Concepts

Operations Collection

Other resources

Operations Object Members


TabControl.FontName Property (Access)

 Copy code hover
[image]

TabControl.FontName Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontName property to specify the font for text in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write String.

Syntax

expression .FontName

expression A variable that represents a TabControl object.

Remarks

The FontName property setting is the name of the font that the text is displayed in.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set this property only in an event procedure or in a macro specified by the OnPrint event property setting.

Font availability depends on your system and printer. If you select a font that your system can't display or that isn't installed, Windows substitutes a similar font.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


How to: Use the Status Bar Progress Meter

 Copy code hover
[image]

How to: Use the Status Bar Progress Meter
Send feedback

This topic shows how to use the SysCmd method to create a progress meter on the status bar that gives a visual representation of the progress of an operation that has a known duration or number of steps.

There are three intrinsic constants that can be used with the SysCmd method's action argument to manipulate the progress meter on the status bar. The following table describes them.

Intrinsic constant | Description
acSysCmdInitMeter | Initialize the progress meter. The maximum value that the process will attain is specifed in the SysCmd method's value argument.
acSysCmdUpdateMeter | Update the progress meter. A numeric expression that represents the current progress toward completion is specified in the SysCmd method's value argument.
acSysCmdRemoveMeter | Remove progress meter.

The following procedure uses the SysCmd method to update the progress meter as data from the Customers table is printed in the Immediate window.

VBA Copy code Copy code
Sub ProgressMeter()
   Dim MyDB As DAO.Database, MyTable As DAO.Recordset
   Dim Count As Long
   Dim Progress_Amount As Integer

   Set MyDB = CurrentDb()
   Set MyTable = MyDB.OpenRecordset("Customers")

   ' Move to last record of the table to get the total number of records.
   MyTable.MoveLast
   Count = MyTable.RecordCount

   ' Move back to first record.
   MyTable.MoveFirst

   ' Initialize the progress meter.
    SysCmd acSysCmdInitMeter, "Reading Data...", Count

   ' Enumerate through all the records.
   For Progress_Amount = 1 To Count
     ' Update the progress meter.
      SysCmd acSysCmdUpdateMeter, Progress_Amount

     'Print the contact name and number of orders in the Immediate window.
      Debug.Print MyTable![ContactName]; _
                  DCount("[OrderID]", "Orders", "[CustomerID]='" & MyTable![CustomerID] & "'")

     ' Go to the next record.
      MyTable.MoveNext
   Next Progress_Amount

   ' Remove the progress meter.
   SysCmd acSysCmdRemoveMeter

End Sub


OptionGroup.TabIndex Property (Access)

 Copy code hover
[image]

OptionGroup.TabIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.

Syntax

expression .TabIndex

expression A variable that represents an OptionGroup object.

Remarks

You can set the TabIndex property to an integer representing the position of the control within the tab order of the form. Valid settings are 0 for the first tab position, up to the total number of controls minus 1 for the last tab position. For example, if a form has three controls that each have a TabIndex property, valid TabIndex property settings are 0, 1, and 2.

Setting the TabIndex property to an integer less than 0 produces an error.

By default, Microsoft Access assigns a tab order to controls in the order that you create them on a form. Each new control is placed last in the tab order. If you change the setting of a control's TabIndex property to adjust the tab order, Microsoft Access automatically renumbers the TabIndex property setting of other controls to reflect insertions and deletions.

In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the TAB key.

Changing the tab order of other controls on the form doesn't affect what happens when you press a control's access key. For example, if you've created an access key for the label of a text box, the focus will move to the text box whenever you press the label's access key — even if you change the TabIndex property setting for the text box.

If you press an access key for a control such as a label that doesn't have a TabIndex property (and thus isn't in the tab order), the focus moves to the next control in the tab order that can receive the focus.

Example

The following example reverses the tab order of a command button and a text box. Because TextBox1 was created first, it has a TabIndex property setting of 0 and Command1 has a setting of 1.

VBA Copy code Copy code
Sub Form_Click()
 Me!Command1.TabIndex = 0
 Me!TextBox1.TabIndex = 1
End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Application.CurrentUser Method (Access)

 Copy code hover
[image]

Application.CurrentUser Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the CurrentUser method to return the name of the current user of the database. .

Syntax

expression .CurrentUser

expression A variable that represents an Application object.

Return Value

String

Remarks

For example, use the CurrentUser method in a procedure that keeps track of the users who modify the database.

The CurrentUser method returns a string that contains the name of the current user account.

If you haven't established a security-enabled workgroup, the CurrentUser method returns the name of the default user account, Admin. The Admin user account gives the user full permissions to all database objects.

If you have enabled workgroup security, then the CurrentUser method returns the name of the current user account. For user accounts other than Admin, you can specify permissions that restrict the users' access to database objects.

Example

The following example obtains the name of the current user and displays it in a dialog box.

VBA Copy code Copy code
MsgBox("The current user is: " & CurrentUser)

See also

Concepts

Application Object

Other resources

Application Object Members


ComboBox Object (Access)

 Copy code hover
[image]

ComboBox Object (Access)
See also Send feedback

Published: July 16, 2012

This object corresponds to a combo box control. The combo box control combines the features of a text box and a list box. Use a combo box when you want the option of either typing a value or selecting a value from a predefined list.

Remarks

Control: | Tool:

In Form view, Microsoft Access doesn't display the list until you click the combo box's arrow.

If you have Control Wizards on before you select the combo box tool, you can create a combo box with a wizard. To turn Control Wizards on or off, click the Control Wizards tool in the toolbox.

The setting of the LimitToList property determines whether you can enter values that aren't in the list.

The list can be single- or multiple-column, and the columns can appear with or without headings.

Link provided by: Community Member Icon Luke Chung, FMS, Inc. | About the Contributors

  • Tips and Techniques for Using and Validating Combo Boxes

Links provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Combo Box

  • Cascading Combo Boxes

  • Cascading Combo Boxes: Demo

  • Cascading Combo Boxes - Leaving Null Values

  • Forms: Populate Controls/Text Boxes Based on Combobox Selection

Example

The following example shows how to use multiple ComboBox controls to supply criteria for a query.

Sample code provided by: Community Member Icon The UtterAccess community | About the Contributors

UtterAccess members can download a database that contains this example from here.

VBA Copy code Copy code
Private Sub cmdSearch_Click()
    Dim db As Database
    Dim qd As QueryDef
    Dim vWhere As Variant

    Set db = CurrentDb()

    On Error Resume Next
    db.QueryDefs.Delete "Query1"
    On Error GoTo 0

    vWhere = Null
    vWhere = vWhere & " AND [PymtTypeID]=" + Me.cboPaymentTypes
    vWhere = vWhere & " AND [RefundTypeID]=" + Me.cboRefundType
    vWhere = vWhere & " AND [RefundCDMID]=" + Me.cboRefundCDM
    vWhere = vWhere & " AND [RefundOptionID]=" + Me.cboRefundOption
    vWhere = vWhere & " AND [RefundCodeID]=" + Me.cboRefundCode

    If Nz(vWhere, "") = "" Then
        MsgBox "There are no search criteria selected." & vbCrLf & vbCrLf & _
        "Search Cancelled.", vbInformation, "Search Canceled."

    Else
        Set qd = db.CreateQueryDef("Query1", "SELECT * FROM tblRefundData WHERE " & _
        Mid(vWhere, 6))

        db.Close
        Set db = Nothing

        DoCmd.OpenQuery "Query1", acViewNormal, acReadOnly
    End If
End Sub

The following example shows how to set the RowSource property of a combo box when a form is loaded. When the form is displayed, the items stored in the Departments field of the tblDepartment combo box are displayed in the cboDept combo box.

Sample code provided by: MVP Contributor Bill Jelen, MrExcel.com | About the Contributors

VBA Copy code Copy code
Private Sub Form_Load()
    Me.Caption = "Today is " & Format$(Date, "dddd mmm-d-yyyy")
    Me.RecordSource = "tblDepartments"
    DoCmd.Maximize
    txtDept.ControlSource = "Department"
    cmdClose.Caption = "&Close"
    cboDept.RowSourceType = "Table/Query"
    cboDept.RowSource = "SELECT Department FROM tblDepartments"
End Sub

The following example show how to create a combo box that is bound to one column while displaying another. Setting the ColumnCount property to 2 specifies that the cboDept combo box will display the first two columns of the data source specified by the RowSource property. Setting the BoundColumn property to 1 specifies that the value stored in the first column will be returned when you inspect the value of the combo box.

The ColumnWidths property specifies the width of the two columns. By setting the width of the first column to 0in., the first column is not displayed in the combo box.

Sample code provided by: MVP Contributor Bill Jelen, MrExcel.com | About the Contributors

VBA Copy code Copy code
Private Sub cboDept_Enter()
    With cboDept
        .RowSource = "SELECT * FROM tblDepartments ORDER BY Department"
        .ColumnCount = 2
        .BoundColumn = 1
        .ColumnWidths = "0in.;1in."
    End With
End Sub

The following example shows how to add an item to a bound combo box.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Private Sub cboMainCategory_NotInList(NewData As String, Response As Integer)

    On Error GoTo Error_Handler
    Dim intAnswer As Integer
    intAnswer = MsgBox("""" & NewData & """ is not an approved category. " & vbcrlf _
        & "Do you want to add it now?" _ vbYesNo + vbQuestion, "Invalid Category")

    Select Case intAnswer
        Case vbYes
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO tlkpCategoryNotInList (Category) "
                & _ "Select """ & NewData & """;"
            DoCmd.SetWarnings True
            Response = acDataErrAdded
        Case vbNo
            MsgBox "Please select an item from the list.", _
                vbExclamation + vbOKOnly, "Invalid Entry"
            Response = acDataErrContinue

    End Select

    Exit_Procedure:
        DoCmd.SetWarnings True
        Exit Sub

    Error_Handler:
        MsgBox Err.Number & ", " & Error Description
        Resume Exit_Procedure
        Resume

End Sub

About the Contributors

Luke Chung is the founder and president of FMS, Inc., a leading provider of custom database solutions and developer tools.

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

Holy Macro! Books publishes entertaining books for people who use Microsoft Office. See the complete catalog at MrExcel.com.

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.

See also

Concepts

Access Object Model Reference

Other resources

ComboBox Object Members


Control.LayoutID Property (Access)

 Copy code hover
[image]

Control.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified control. Read-only Long.

Version Information

Version Added: Access 2007

Syntax

expression .LayoutID

expression A variable that represents a Control object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

Control Object

Other resources

Control Object Members


Control.GridlineStyleRight Property (Access)

 Copy code hover
[image]

Control.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified control. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleRight

expression A variable that represents a Control object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

Control Object

Other resources

Control Object Members


CommandButton.Picture Property (Access)

 Copy code hover
[image]

CommandButton.Picture Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Picture property to specify a bitmap or other type of graphic to be displayed on the specified control. Read/write String.

Syntax

expression .Picture

expression A variable that represents a CommandButton object.

Remarks

The Picture property contains (bitmap) or the path and file name of a bitmap or other type of graphic to be displayed.

The default setting is (none). After the graphic is loaded into the object, the property setting is (bitmap) or the path and file name of the graphic. If you delete (bitmap) or the path and file name of the graphic from the property setting, the picture is deleted from the object and the property setting is again (none).

If the PictureType property is set to Embedded, the graphic is stored with the object.

You can create custom bitmaps by using Microsoft Paintbrush or another application that creates bitmap files. A bitmap file must have a .bmp, .ico, or .dib extension. You can also use graphics files in the .wmf or .emf formats, or any other graphic file type for which you have a graphics filter. Forms, reports, and image controls support all graphics. Command buttons and toggle buttons only support bitmaps.

Buttons can display either a caption or a picture. If you assign both to a button, the picture will be visible, the caption won't. If the picture is deleted, the caption reappears. Microsoft Access displays the picture centered on the button and clipped if the picture is larger than the button.

To create a command button or toggle button with a caption and a picture, you could include the desired caption as part of the bitmap and assign the bitmap to the Picture property of the control.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ToggleButton.PictureData Property (Access)

 Copy code hover
[image]

ToggleButton.PictureData Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.

Syntax

expression .PictureData

expression A variable that represents a ToggleButton object.

Remarks

The PictureData property setting is the PictureData property of another control, form, or report.

You can use this property to display different background pictures in a form, depending on actions taken by the user. For example, you might open a Customers form using a different background picture depending on whether the form is opened for data entry or for browsing.

You can also use the PictureData property together with the Timer event and the TimerInterval property to perform simple animation on a form.

Example

The following example uses three image controls to animate a butterfly image across a form. The Hidden1 image control contains a picture of a butterfly with its wings up and the Hidden2 image control contains a picture of the same butterfly with its wings down. Both image controls have their Visible property set to False. The TimerInterval property is set to 200. Each time the Timer event occurs, the picture in the image control Visible1 is changed by using the PictureData property of the hidden image controls, and the visible image control is moved 200 twips to the right. The visible image control is moved back to the left side of the form when its Left property value is greater than the width of the form stored in the public variable gfrmWidth. The value of gfrmWidth is set to Me.Width in the form's open event.

VBA Copy code Copy code
Private Sub Form_Timer()

 Static intPic As Integer

 Select Case intPic
 Case Is = 1
 Me!Visible1.PictureData = Me!Hidden1.PictureData
 Case Is = 2
 Me!Visible1.PictureData = Me!Hidden2.PictureData
 Case Else
 End Select

 If intPic = 2 Then intPic = 0
 intPic = intPic + 1
 If (Me!Visible1.Left > gfrmWidth) Then Me!Visible1.Left = 0
 Me!Visible1.Left = Me!Visible1.Left + 200

End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Screen.Application Property (Access)

 Copy code hover
[image]

Screen.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a Screen object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

Screen Object

Other resources

Screen Object Members


Invalid setting in Excel key of the Engines section of the Windows Registry. (Error 3433)

 Copy code hover
[image]

Invalid setting in Excel key of the Engines section of the Windows Registry. (Error 3433)
Send feedback

One of the settings in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Access Connectivity Engine\Engines\Excel key of the Microsoft Windows Registry is not valid. Edit the Windows Registry to be sure all the parameters are valid.


TempVar Members (Access)

 Copy code hover
[image]

TempVar Members (Access)
Send feedback

Published: July 16, 2012

Represents a variable that be used in Visual Basic for Applications (VBA) code or from a macro.

Properties

Name | Description
Name | Gets the name of the specified TempVar. Read-only String.
Value | Gets or sets the value of the specified TempVar. Read/write Variant.


Module.Parent Property (Access)

 Copy code hover
[image]

Module.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a Module object.

See also

Concepts

Module Object

Other resources

Module Object Members


(Error 3072)

 Copy code hover
[image]

(Error 3072)
Send feedback

For example, a table level validation rule that references a numeric data type must have a numeric validation clause. If a string validation clause is used, then this error will be returned.


Image.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

Image.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Syntax

expression .ShortcutMenuBar

expression A variable that represents an Image object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

Example

The following example sets the "Suppliers_Toolbar" as the custom shortcut menu to display when the user clicks the right mouse button on the "Suppliers" form.

VBA Copy code Copy code
Forms("Suppliers").ShortcutMenuBar = "Suppliers_Toolbar"

See also

Concepts

Image Object

Other resources

Image Object Members


CurrentData Members (Access)

 Copy code hover
[image]

CurrentData Members (Access)
Send feedback

Published: July 16, 2012

The CurrentData object refers to the objects stored in the current database by the source (server) application.

Properties

Name | Description
AllDatabaseDiagrams | You can use the AllDatabaseDiagrams property to reference the AllDatabaseDiagrams collection and its related properties. Read-only AllDatabaseDiagrams object.
AllFunctions | You can use the AllFunctions property to reference the AllFunctions collection and its related properties. Read-only AllFunctions object.
AllQueries | You can use the AllQueries property to reference the AllQueries collection and its related properties. Read-only AllQueries object.
AllStoredProcedures | You can use the AllStoredProcedures property to reference the AllStoredProcedures collection and its related properties. Read-only AllStoredProcedures object.
AllTables | You can use the AllTables property to reference the AllTables collection and its related properties. Read-only AllTables object.
AllViews | You can use the AllViews property to reference the AllViews collection and its related properties. Read-only AllViews object.


NavigationButton.MouseUp Event (Access)

 Copy code hover
[image]

NavigationButton.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Version Information

Version Added: Access 2010

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents a NavigationButton object.

Parameters

Name | Required/Optional | Data Type | Description
Button | Required | Integer |
Shift | Required | Integer |
X | Required | Single |
Y | Required | Single |

Return Value

nothing

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


LockType Property (ADO)

 Copy code hover
[image]

LockType Property (ADO)
Send feedback

Indicates the type of locks placed on records during editing.

Settings and Return Values

Sets or returns a LockTypeEnum value. The default value is adLockReadOnly.

Remarks

Set the LockType property before opening a Recordset to specify what type of locking the provider should use when opening it. Read the property to return the type of locking in use on an open Recordset object.

Providers may not support all lock types. If a provider cannot support the requested LockType setting, it will substitute another type of locking. To determine the actual locking functionality available in a Recordset object, use the Supports method with adUpdate and adUpdateBatch.

The adLockPessimistic setting is not supported if the CursorLocation property is set to adUseClient. If an unsupported value is set, then no error will result; the closest supported LockType will be used instead.

The LockType property is read/write when the Recordset is closed and read-only when it is open.

Remote Data Service UsageWhen used on a client-side Recordset object, the LockType property can only be set to adLockBatchOptimistic.


Comment Macro Block (Access 2013 custom web app)

 Copy code hover
[image]

Comment Macro Block (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

The Comment statement can be used to provide explanatory remarks in a macro.

Remarks

A Comment may be up to 1000 characters in length. However, by default, only the first line of the comment is displayed.


Screen.ActiveControl Property (Access)

 Copy code hover
[image]

Screen.ActiveControl Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ActiveControl property together with the Screen object to identify or refer to the control that has the focus. Read-only Control object.

Syntax

expression .ActiveControl

expression A variable that represents a Screen object.

Remarks

This property setting contains a reference to the Control object that has the focus at run time.

You can use the ActiveControl property to refer to the control that has the focus at run time together with one of its properties or methods. The following example assigns the name of the control with the focus to the strControlName variable.

VBA Copy code Copy code
Dim ctlCurrentControl As Control
Dim strControlName As String
Set ctlCurrentControl = Screen.ActiveControl
strControlName = ctlCurrentControl.Name

If no control has the focus when you use the ActiveControl property, or if all of the active form's controls are hidden or disabled, an error occurs.

Example

The following example assigns the active control to the ctlCurrentControl variable and then takes different actions depending on the value of the control's Name property.

VBA Copy code Copy code
Dim ctlCurrentControl As Control

Set ctlCurrentControl = Screen.ActiveControl
If ctlCurrentControl.Name = "txtCustomerID" Then
 .
 . ' Do something here.
 .
ElseIf ctlCurrentControl.Name = "btnCustomerDetails" Then
 .
 . ' Do something here.
 .
End If

See also

Concepts

Screen Object

Other resources

Screen Object Members


BoundObjectFrame.GridlineThemeColorIndex Property (Access)

 Copy code hover
[image]

BoundObjectFrame.GridlineThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineThemeColorIndex

expression A variable that represents a BoundObjectFrame object.

Remarks

The GridlineThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 (Default) | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the GridlineThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


RequeryRecords Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

RequeryRecords Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

You can use the RequeryRecords action to refresh, sort, and filter the data in the active view by requerying the source of the view.

Setting

The RequeryRecords action has the following arguments.

Parameter | Required | Description
Where= | No | A SQL WHERE clause that restricts the records in the view. By default, this argument is blank.
OrderBy | No | A string expression that includes the name of the field or fields on which to sort records and the optional ASC or DESC keywords. By default, this argument is blank.

Remarks

Any sorting or filtering applied by the user is cleared when the RequeryRecords action is called.

The OrderBy argument is the name of the field or fields on which you want to sort records. When you use more than one field name, separate the names with a comma (,).

When you set the OrderBy argument, the records are sorted by default in ascending order.

To sort records in descending order, enter DESC at the end of the OrderBy argument expression. For example, to sort customer records in descending order by contact name, set the OrderBy argument to "ContactName DESC".

To sort names by LastName descending, and FirstName ascending, set the OrderBy argument to "LastName DESC, FirstName ASC".


Relation Properties (DAO)

 Copy code hover
[image]

Relation Properties (DAO)
Send feedback

In this section

  • Relation.Attributes Property (DAO)

  • Relation.Fields Property (DAO)

  • Relation.ForeignTable Property (DAO)

  • Relation.Name Property (DAO)

  • Relation.PartialReplica Property (DAO)

  • Relation.Properties Property (DAO)

  • Relation.Table Property (DAO)


Field Object (ADO)

 Copy code hover
[image]

Field Object (ADO)
Send feedback

Represents a column of data with a common data type.

Remarks

Each Field object corresponds to a column in the Recordset. You use the Value property of Field objects to set or return data for the current record. Depending on the functionality the provider exposes, some collections, methods, or properties of a Field object may not be available.

With the collections, methods, and properties of a Field object, you can do the following:

  • Return the name of a field with the Name property.

  • View or change the data in the field with the Value property. Value is the default property of the Field object.

  • Return the basic characteristics of a field with the Type, Precision, and NumericScale properties.

  • Return the declared size of a field with the DefinedSize property.

  • Return the actual size of the data in a given field with the ActualSize property.

  • Determine what types of functionality are supported for a given field with the Attributes property and Properties collection.

  • Manipulate the values of fields containing long binary or long character data with the AppendChunk and GetChunk methods.

  • If the provider supports batch updates, resolve discrepancies in field values during batch updating with the OriginalValue and UnderlyingValue properties.

All of the metadata properties (Name, Type, DefinedSize, Precision, and NumericScale) are available before opening the Field object's Recordset. Setting them at that time is useful for dynamically constructing forms.


The relationship

 Copy code hover
[image]

The relationship <name> in the partial filter expression is invalid. (Error 3480)
Send feedback

Specify a valid relationship.


Welcome to the Access 2013 developer reference

 Copy code hover
[image]

Welcome to the Access 2013 developer reference
See also Send feedback

Published: July 16, 2012

This reference contains conceptual overviews, programming tasks, samples, and reference documentation to guide you in developing solutions based on Microsoft Access 2013.

We welcome your comments or questions about this content. You can send feedback to docthis@microsoft.com.

This reference contains the following sections:

  • Access 2013 desktop database reference: Provides information about developing Access desktop (.accdb) databases.

  • Access 2013 custom web app reference: Provides information about developing Access 2013 apps.

See also

Concepts

Office 2013 documentation copyright notice

Other resources

Access Developer Center
Accessibility in Microsoft Products
Document Conventions
Microsoft Online Privacy Notice


Status Property Example (Field) (VB)

 Copy code hover
[image]

Status Property Example (Field) (VB)
Send feedback

The following example opens a document from a read/write folder using the Internet Publishing Provider. The Status property of a Field object of the Record will first be set to adFieldPendingInsert, then be updated to adFieldOk.

Copy code Copy code
'BeginStatusFieldVB

 ' to integrate this code replace the values in the source string

Sub Main()

   Dim File As ADODB.Record
   Dim strFile As String
   Dim Cnxn As ADODB.Connection
   Dim strCnxn As String

   Set Cnxn = New ADODB.Connection
   strCnxn = "url=http://MyServer/"
   Cnxn.Open strCnxn

   Set File = New ADODB.Record
   strFile = "Folder/FileName"
   ' Open a read/write document
   File.Source = strFile
   File.ActiveConnection = Cnxn
   File.Mode = adModeReadWrite
   File.Open

   Debug.Print "Append a couple of fields"

   File.Fields.Append "chektest:fld1", adWChar, 42, adFldUpdatable, "fld1"
   File.Fields.Append "chektest:fld2", adWChar, 42, adFldUpdatable, "fld2"

   Debug.Print "status for the fields"
   Debug.Print File.Fields("chektest:fld1").Status 'adfldpendinginsert
   Debug.Print File.Fields("chektest:fld2").Status 'adfldpendinginsert

    'turn off error-handling to verify field status
   On Error Resume Next

   File.Fields.Update

   Debug.Print "Update succeeds"
   Debug.Print File.Fields("chektest:fld1").Status 'adfldpendinginsert + adFieldUnavailable
   Debug.Print File.Fields("chektest:fld2").Status 'adfldpendinginsert + adFieldUnavailable

    ' resume default error-handling
   On Error GoTo 0

     ' clean up
    File.Close
    Cnxn.Close
    Set File = Nothing
    Set Cnxn = Nothing

End Sub
'EndStatusFieldVB

The following example deletes a known Field from a Record opened from a document. The Status property will first be set to adFieldOK, then adFieldPendingUnknown.

Copy code Copy code
'BeginStatusField2VB

' to integrate this code replace the values in the source string

Sub Main()

   Dim File As ADODB.Record
   Dim fld As ADODB.Field
   Dim strFile As String

   Dim Cnxn As ADODB.Connection
   Dim strCnxn As String

    ' create connection as a URL
   Set Cnxn = New ADODB.Connection
   strCnxn = "url=http://MyServer/"
   Cnxn.Open strCnxn
   Set File = New ADODB.Record
   strFile = "Folder/FileName"
   ' Open a read/write document
   File.Open strFile, Cnxn, adModeReadWrite
   Debug.Print File.Fields("chektest:fld1").Status ' should be adFldOK

   ' Delete a field which already exists in the collection
   File.Fields.Delete "chektest:fld1"
   Set fld = File.Fields("chektest:fld1")
   Debug.Print File.Fields("chektest:fld1").Status   ' Pending delete

    'turn off error-handling to verify field status
   On Error Resume Next

   File.Fields.Update

   Debug.Print "Deleted"
   Debug.Print fld.Status   ' Pending unknown

    ' resume default error-handling
   On Error GoTo 0

     ' clean up
    File.Close
    Cnxn.Close
    Set File = Nothing
    Set Cnxn = Nothing

End Sub
'EndStatusField2VB

The following code deletes a Field from a Record opened on a read-only document. Status will be set to adFieldPendingDelete. At Update, the delete will fail and Status will be adFieldPendingDelete plus adFieldPermissionDenied. CancelUpdate clears the pending Status setting.

Copy code Copy code
Sub Main()
   Dim File As ADODB.Record
   Dim fld As ADODB.Field
   Dim Cnxn As ADODB.Connection
   Dim strCnxn As String
   Dim strFile As String

    ' create connection as a URL
   Set Cnxn = New ADODB.Connection
   strCnxn = "url=http://MyServer/"
   Cnxn.Open strCnxn

   ' Open a read/write document
   Set File = New ADODB.Record
   strFile = "Folder/FileName"
   File.Open strFile, Cnxn, adModeReadWrite, adCreateCollection Or adOpenIfExists

   Debug.Print "Try to delete something without permission"
   File.Fields.Delete ("RESOURCE_PARSENAME")
   Set fld = File.Fields("RESOURCE_PARSENAME")

   Debug.Print "Pending delete"
   Debug.Print fld.Status   ' Pending delete
   Debug.Print "Delete should fail on Update"

    'turn off error-handling to verify field status
   On Error Resume Next

   File.Fields.Update   ' Should fail

   Debug.Print fld.Status   ' Pending delete plus error
   File.Fields.CancelUpdate
   Debug.Print fld.Status   ' Okay

    ' resume default error-handling
   On Error GoTo 0

     ' clean up
    File.Close
    Cnxn.Close
    Set File = Nothing
    Set Cnxn = Nothing

End Sub
'EndStatusField3VB


Using AddNew in Immediate and Batch Modes

 Copy code hover
[image]

Using AddNew in Immediate and Batch Modes
Send feedback

The behavior of the AddNew method depends on the updating mode of the Recordset object and whether you pass the FieldList and Values arguments.

In immediate update mode (in which the provider writes changes to the underlying data source once you call the Update method), calling the AddNew method without arguments sets the EditMode property to adEditAdd. The provider caches any field value changes locally. Calling the Update method posts the new record to the database and resets the EditMode property to adEditNone. If you pass the FieldList and Values arguments, ADO immediately posts the new record to the database (no Update call is necessary); the EditMode property value does not change (adEditNone).

In batch update mode, calling the AddNew method without arguments sets the EditMode property to adEditAdd. The provider caches any field value changes locally. Calling the Update method adds the new record to the current Recordset and resets the EditMode property to adEditNone, but the provider does not post the changes to the underlying database until you call the UpdateBatch method. If you pass the FieldList and Values arguments, ADO sends the new record to the provider for storage in a cache; you need to call the UpdateBatch method to post the new record to the underlying database. For more information about Update and UpdateBatch, see Chapter 5: Updating and Persisting Data.


Cannot set field

 Copy code hover
[image]

Cannot set field <name> in join key to Null. (Error 3100)
Send feedback

You have a join, and you tried to set a field on either side of the join to a Null value. Either select different fields or enter data in the fields, and then try the operation again.


Line.BorderStyle Property (Access)

 Copy code hover
[image]

Line.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Syntax

expression .BorderStyle

expression A variable that represents a Line object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

Line Object

Other resources

Line Object Members


DataFactory Object (RDSServer)

 Copy code hover
[image]

DataFactory Object (RDSServer)
Send feedback

This default server-side business object implements methods that provide read/write data access to specified data sources for client-side applications.

Remarks

The RDSServer.DataFactory object is designed as a server-side Automation object that receives client requests. In an Internet implementation, it resides on a Web server and is instantiated by the ADISAPI component. The RDSServer.DataFactory object provides read and write access to specified data sources, but doesn't contain any validation or business rules logic.

If you use a method that is available in both the RDSServer.DataFactory and RDS.DataControl objects, Remote Data Service uses the RDS.DataControl version by default. The default assumes a basic programming scenario, where the RDSServer.DataFactory serves as a generic server-side business object.

If you want your Web application to handle task-specific server-side processing, you can replace the RDSServer.DataFactory with a custom business object.

You can create server-side business objects that call the RDSServer.DataFactory methods, such as Query and CreateRecordset. This is helpful if you want to add functionality to your business objects, but take advantage of existing Remote Data Service technologies.

The class ID for the RDSServer.DataFactory object is 9381D8F5-0288-11D0-9501-00AA00B911A5.


ComboBox.BackStyle Property (Access)

 Copy code hover
[image]

ComboBox.BackStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.

Syntax

expression .BackStyle

expression A variable that represents a ComboBox object.

Remarks

The BackStyle property uses the following settings.

Setting | Visual Basic | Description
Normal | 1 | (Default for all controls except option group) The control has its interior color set by the BackColor property.
Transparent | 0 | (Default for option group) The control is transparent. The color of the form or report behind the control is visible.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

If the Transparent button on the Back Color button palette is selected, the BackStyle property is set to Transparent; otherwise the BackStyle property is set to Normal.

To make a command button invisible, set its Transparent property to Yes.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Cannot create index on the given field. (Error 3287)

 Copy code hover
[image]

Cannot create index on the given field. (Error 3287)
Send feedback

You are trying to create an index on a Memo or OLE Object field. Specify another field, and then try the operation again.

This can also occur if you try to create an index on a Btrieve table on a 1-byte field.


Image.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

Image.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified image control. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleBottom

expression A variable that represents an Image object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

Image Object

Other resources

Image Object Members


AcCurrentView Enumeration (Access)

 Copy code hover
[image]

AcCurrentView Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the CurrentView property to determine the current view of an object.

Name | Value | Description
acCurViewDatasheet | 2 | The object is in Datasheet view.
acCurViewDesign | 0 | The object is in Design view.
acCurViewFormBrowse | 1 | The object is in Form view.
acCurViewLayout | 7 | The object is in Layout view.
acCurViewPivotChart | 4 | The object is in PivotChart view.
acCurViewPivotTable | 3 | The object is in PivotTable view.
acCurViewPreview | 5 | The object is in Print Preview.
acCurViewReportBrowse | 6 | The object is in Report view.


Build SQL Statements That Include Variables and Controls

 Copy code hover
[image]

Build SQL Statements That Include Variables and Controls
Send feedback

When working with Data Access Objects (DAO) or ActiveX Data Objects (ADO), you may need to construct an SQL statement in code. This is sometimes referred to as taking your SQL code "inline". For example, if you're creating a new QueryDef object, you must set its SQL property to a valid SQL string. But if you are using an ADO Recordset object, you must set its Source property to a valid SQL string.

The easiest way to construct an SQL statement is to create a query in the query design grid, switch to SQL view, and copy and paste the corresponding SQL statement into your code.

Often a query must be based on values that the user supplies, or that change in different situations. If this is the case, you'll need to include variables or control values in your query. The Microsoft Access database engine processes all SQL statements, but not variables or controls. Therefore, you must construct your SQL statement so that Microsoft Access first determines these values and then concatenates them into the SQL statement that's passed to the Microsoft Access database engine.

Building SQL Statements With DAO

The following example shows how to create a QueryDef object with a simple SQL statement. This query returns all orders from an Orders table that were placed after 3-31-2006:

Copy code Copy code
Public Sub GetOrders()

 Dim dbs As DAO.Database
 Dim qdf As DAO.QueryDef
 Dim strSQL As String

 Set dbs = CurrentDb
 strSQL = "SELECT * FROM Orders WHERE OrderDate >#3-31-2006#;"
 Set qdf = dbs.CreateQueryDef("SecondQuarter", strSQL)

End Sub

The next example creates the same QueryDef object by using a value stored in a variable. Note that the number signs (#) that denote the date values must be included in the string so that they are concatenated with the date value.

Copy code Copy code
Dim dbs As Database, qdf As QueryDef, strSQL As String
Dim dteStart As Date
dteStart = #3-31-2006#
Set dbs = CurrentDb
strSQL = "SELECT * FROM Orders WHERE OrderDate" _
 & "> #" & dteStart & "#;"
Set qdf = dbs.CreateQueryDef("SecondQuarter", strSQL)

The following example creates a QueryDef object by using a value in a control called OrderDate on an Orders form. Note that you provide the full reference to the control, and that you include the number signs that denote the date within the string.

Copy code Copy code
Dim dbs As Database, qdf As QueryDef, strSQL As String
Set dbs = CurrentDb
strSQL = "SELECT * FROM Orders WHERE OrderDate" _
 & "> #" & Forms!Orders!OrderDate & "#;"
Set qdf = dbs.CreateQueryDef("SecondQuarter", strSQL)

Building SQL Statements With ADO

In this section, we will build the same statements as in the previous section, but this time using ADO as the data access method.

The following example shows how to create a QueryDef object with a simple SQL statement. This query returns all orders from an Orders table that were placed after 3-31-2006:

Copy code Copy code
Dim dbs As Database, qdf As QueryDef, strSQL As String
Set dbs = CurrentDb
strSQL = "SELECT * FROM Orders WHERE OrderDate >#3-31-2006#;"
Set qdf = dbs.CreateQueryDef("SecondQuarter", strSQL)

The next example creates the same QueryDef object by using a value stored in a variable. Note that the number signs (#) that denote the date values must be included in the string so that they are concatenated with the date value.

Copy code Copy code
Dim dbs As Database, qdf As QueryDef, strSQL As String
Dim dteStart As Date
dteStart = #3-31-2006#
Set dbs = CurrentDb
strSQL = "SELECT * FROM Orders WHERE OrderDate" _
 & "> #" & dteStart & "#;"
Set qdf = dbs.CreateQueryDef("SecondQuarter", strSQL)

The following example creates a QueryDef object by using a value in a control called OrderDate on an Orders form. Note that you provide the full reference to the control, and that you include the number signs that denote the date within the string.

Copy code Copy code
Dim dbs As Database, qdf As QueryDef, strSQL As String
Set dbs = CurrentDb
strSQL = "SELECT * FROM Orders WHERE OrderDate" _
 & "> #" & Forms!Orders!OrderDate & "#;"
Set qdf = dbs.CreateQueryDef("SecondQuarter", strSQL)


DrilledDown Property (ADO MD)

 Copy code hover
[image]

DrilledDown Property (ADO MD)
Send feedback

Indicates whether no children immediately follow the member on the axis.

Return Values

Returns a Boolean value and is read-only. DrilledDown returns True if there are no child members of the current member on the axis. DrilledDown returns False if there is one or more child members of the current member on the axis.

Remarks

Use the DrilledDown property to determine whether there is at least one child of this member on the axis immediately following this member. This information is useful when displaying the member.

This property is only supported on Member objects belonging to a Position object. An error occurs when this property is referenced from Member objects belonging to a Level object.


CommandButton.Name Property (Access)

 Copy code hover
[image]

CommandButton.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a CommandButton object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Image.OldValue Property (Access)

 Copy code hover
[image]

Image.OldValue Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.

Syntax

expression .OldValue

expression A variable that represents an Image object.

Remarks

The OldValue property contains the unedited data from a bound control and is read-only in all views.

Microsoft Access uses the OldValue property to store the original value of a bound control. When you edit a bound control on a form, your changes aren't saved until you move to another record. The OldValue property contains the unedited version of the underlying data.

You can provide your own undo capability by assigning the OldValue property setting to a control. The following example shows how you can undo any changes to text box controls on a form:

VBA Copy code Copy code
Private Sub btnUndo_Click()

 Dim ctlTextbox As Control

 For Each ctlTextbox in Me.Controls
 If ctlTextbox.ControlType = acTextBox Then
 ctlTextbox.Value = ctl.OldValue
 End If
 Next ctlTextbox

End Sub

If the control hasn't been edited, this code has no effect. When you move to another record, the record source is updated, so the current value and the OldValue property will be the same.

The OldValue property setting has the same data type as the field to which the control is bound.

Example

The following example checks to determine if new data entered in a field is within 10 percent of the value of the original data. If the change is greater than 10 percent, the OldValue property is used to restore the original value. This procedure could be called from the BeforeUpdate event of the control that contains data you want to validate.

VBA Copy code Copy code
Public Sub Validate_Field()

 Dim curNewValue As Currency
 Dim curOriginalValue As Currency
 Dim curChange As Currency
 Dim strMsg As String

 curNewValue = Forms!Products!UnitPrice
 curOriginalValue = Forms!Products!UnitPrice.OldValue
 curChange = Abs(curNewValue - curOriginalValue)

 If curChange > (curOriginalValue * .1) Then
 strMsg = "Change is more than 10% of original unit price. " _
 & "Restoring original unit price."
 MsgBox strMsg, vbExclamation, "Invalid change."
 Forms!Products!UnitPrice = curOriginalValue
 End If

End Sub

See also

Concepts

Image Object

Other resources

Image Object Members


BoundObjectFrame.LabelX Property (Access)

 Copy code hover
[image]

BoundObjectFrame.LabelX Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelX

expression A variable that represents a BoundObjectFrame object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


HelloData: A Simple ADO Application (ADO)

 Copy code hover
[image]

HelloData: A Simple ADO Application (ADO)
Send feedback

In this section

  • HelloData: A Simple ADO Application

  • HelloData Details

  • HelloData Code


ObjectFrame.LinkMasterFields Property (Access)

 Copy code hover
[image]

ObjectFrame.LinkMasterFields Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the LinkMasterFields property (along with the LinkChildFields property) together to specify how Microsoft Access links records in a form or report to records in a subform, subreport, or embedded object, such as a chart. If these properties are set, Microsoft Access automatically updates the related record in the subform when you change to a new record in a main form. Read/write String.

Syntax

expression .LinkMasterFields

expression A variable that represents an ObjectFrame object.

Remarks

You can set the LinkChildFields and LinkMasterFields properties for the subform, subreport, or embedded object as follows:

  • The LinkChildFields property. Enter the name of one or more linking fields in the subform, subreport, or embedded object.

  • The LinkMasterFields property. Enter the name of one or more linking fields or controls in the main form or report.

You can use the Subform/Subreport Field Linker to set these properties by clicking the Build button to the right of the property box in the property sheet.

The properties can only be set in Design view or during the Open event of a form or report.

The fields or controls you use to set these properties don't need to have the same names, but they must contain the same kind of data and have the same or a compatible data type and field size. For example, an AutoNumber field is compatible with a Number field if the FieldSize property for the Number field is set to Long Integer.

You can use the name of a control (including the name of a calculated control) to set the LinkMasterFields property, but you can't use the name of a control to set the LinkChildFields property. If you want to use a calculated value as the link for a subform, subreport, or embedded object, define a calculated field in the child object's underlying query and set the LinkChildFields property to the field.

When you specify more than one field or control name for these property settings, you must enter the same number of fields or controls for each property setting and separate the names with a semicolon (;).

When you create a subform or subreport by dragging a form or report from the Database window onto another form or report or by using the Form Wizard, Microsoft Access automatically sets the LinkChildFields and LinkMasterFields properties under the following conditions:

  • Both the main form or report and the child object are based on tables, and a relationship between those tables has been defined with the Relationships command. Microsoft Access uses the fields that relate the two tables as the linking fields.

  • The main form or report is based on a table with a primary key, and the subform or subreport is based on a table or query that contains a field with the same name and the same or a compatible data type as the primary key. Microsoft Access uses the primary key from the main object's underlying table and the identically named field from the child object's underlying table or query as the linking fields.

Note Note

The linking fields don't have to be included in the main object or in the child object. As long as they are contained in the objects' underlying tables or queries, you can use the fields to link the objects. When you use a wizard, Microsoft Access automatically includes the linking fields.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Report.ScaleLeft Property (Access)

 Copy code hover
[image]

Report.ScaleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ScaleLeft property to specify the units for the horizontal coordinates that describe the location of the left edge of a page when the Circle , Line , Pset , or Print method is used while a report is previewed, printed, or its output is saved to a file. Read / write Single.

Syntax

expression .ScaleLeft

expression A variable that represents a Report object.

Remarks

You can set the ScaleLeft property by using a macro or a Visual Basic event procedure specified by a section's OnPrint property setting.

By using these properties and the related ScaleHeight and ScaleWidth properties, you can set up a custom coordinate system with both positive and negative coordinates. All four of these Scale properties interact with the ScaleMode property in the following ways:

  • Setting any other Scale property to any value automatically sets the ScaleMode property to 0.

  • Setting the ScaleMode property to a number greater than 0 changes the ScaleHeight and ScaleWidth property settings to the new unit of measurement and sets the ScaleLeft and ScaleTop properties to 0. Also, the CurrentX and CurrentY property settings change to reflect the new coordinates of the current point.

You can also use the Scale method to set the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties in one statement.

Note Note

The ScaleLeft property isn't the same as the Left property.

Example

The following example uses the Circle method to draw a circle and create a pie slice within the circle. Then it uses the FillColor and FillStyle properties to color the pie slice red. It also draws a line from the upper left to the center of the circle.

To try this example in Microsoft Access, create a new report. Set the OnPrint property of the Detail section to [Event Procedure]. Enter the following code in the report's module, then switch to Print Preview.

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

 Const conPI = 3.14159265359

 Dim sngHCtr As Single
 Dim sngVCtr As Single
 Dim sngRadius As Single
 Dim sngStart As Single
 Dim sngEnd As Single

 sngHCtr = Me.ScaleWidth / 2 ' Horizontal center.
 sngVCtr = Me.ScaleHeight / 2 ' Vertical center.
 sngRadius = Me.ScaleHeight / 3 ' Circle radius.
 Me.Circle (sngHCtr, sngVCtr), sngRadius ' Draw circle.
 sngStart = -0.00000001 ' Start of pie slice.

 sngEnd = -2 * conPI / 3 ' End of pie slice.
 Me.FillColor = RGB(255, 0, 0) ' Color pie slice red.
 Me.FillStyle = 0 ' Fill pie slice.

 ' Draw Pie slice within circle
 Me.Circle (sngHCtr, sngVCtr), sngRadius, , sngStart, sngEnd

 ' Draw line to center of circle.
 Dim intColor As Integer
 Dim sngTop As Single, sngLeft As Single
 Dim sngWidth As Single, sngHeight As Single

 Me.ScaleMode = 3 ' Set scale to pixels.
 sngTop = Me.ScaleTop ' Top inside edge.
 sngLeft = Me.ScaleLeft ' Left inside edge.
 sngWidth = Me.ScaleWidth / 2 ' Width inside edge.
 sngHeight = Me.ScaleHeight / 2 ' Height inside edge.
 intColor = RGB(255, 0, 0) ' Make color red.

 ' Draw line.
 Me.Line (sngTop, sngLeft)-(sngWidth, sngHeight), intColor

End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


Field2.VisibleValue Property (DAO)

 Copy code hover
[image]

Field2.VisibleValue Property (DAO)
Send feedback

Syntax

expression .VisibleValue

expression A variable that represents a Field2 object.

Remarks

This property contains the value of the field that is currently in the database on the server. During an optimistic batch update, a collision may occur where a second client modified the same field and record in between the time the first client retrieved the data and the first client's update attempt. When this happens, the value that the second client set will be accessible through this property.


BoundObjectFrame.Parent Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a BoundObjectFrame object.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


How to: Create Multiple Instances of a Form

 Copy code hover
[image]

How to: Create Multiple Instances of a Form
Send feedback

Sometimes it is useful to display more than one instance of a form at a time. For example, you might want to display the records for an employee and the employee's manager at the same time. You can create one instance of the Employees form's class to display the employee's record, and one to display the manager's record.

When you create a new instance of a form or report class, the new instance has all the properties and methods of a Form or Report object, and its properties are set to the same values as those in the original Form or Report object. Additionally, any procedures that you have written in the form or report class module behave as methods and properties of the new instance.

To create a new instance of a form or report class, you declare a new object variable by using the Shell keyword and the name of the form's or report's class module. The name of the class module appears in the title bar of the module. It indicates whether the class is associated with a form or a report and includes the name of the form or report. For example, the class name for an Employee form is Form_Employees. The following line of code creates a new instance of the Employees form:

VBA Copy code Copy code
Dim frmInstance As New Form_Employees

By creating multiple instances of an Employees form class, you could show information about one employee on one form instance, and show information about another employee on another form instance.

Note Note

When you create an instance of a form class by using the New keyword, it is hidden. To show the form, set the Visible property to True.

You should declare the variable that represents the new instance of a form class at the module level. If you declare the variable at the procedure level, the variable goes out of scope when the procedure finishes running, and the new instance is removed from memory. The instance exists in memory only as long as the variable to which it is assigned remains in scope.

Any properties that you set will affect this instance of the form's class, but will not be saved with the form. Also, a new instance of the form's class cannot be created if the form is open in Design view.


SetProperty Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

SetProperty Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

You can use the SetProperty action to set a property for a control on a view.

Setting

The SetProperty action has the arguments listed in the following table.

Action argument | Description
Control Name | Type the name of the field or control for which you want to set the property value. Leave this argument blank to set the property for the view.
Property | Select the property that you want to set. See the Remarks section in this article for a list of the properties that can be set by using this action.
Value | Type the value that the property is to be set to. For properties whose values are either Yes or No, use -1 for Yes and 0 for No.

Remarks

You can use the SetProperty action to set the following properties of a control:

  • Caption

  • Enabled

  • ForeColor

  • Value

  • Visible

If you enter an invalid value for the Value argument, no error occurs, but Access might change the property to a different value, depending on how it interprets the argument.


User Object (ADOX) Reference

 Copy code hover
[image]

User Object (ADOX) Reference
Send feedback

In this section

  • User Object (ADOX)

  • User Properties, Methods, and Events (ADOX)


This operation requires a different cursor library. (Error 3663)

 Copy code hover
[image]

This operation requires a different cursor library. (Error 3663)
Send feedback

The cursor type selected when the recordset was opened does not support the operation being requested. Either re-open with an appropriate cursor type or use an appropriate operation for the current cursor type. This error occurs only when using ODBCDirect.


ComboBox.BottomPadding Property (Access)

 Copy code hover
[image]

ComboBox.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the combo box and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .BottomPadding

expression A variable that represents a ComboBox object.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


CustomControl.Height Property (Access)

 Copy code hover
[image]

CustomControl.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Syntax

expression .Height

expression A variable that represents a CustomControl object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Using ADO for Internet Publishing

 Copy code hover
[image]

Using ADO for Internet Publishing
Send feedback

The OLE DB Provider for Internet Publishing shows a specific example of accessing heterogeneous data with ADO. While the examples in this section will be specific to using the Internet Publishing Provider, the principles demonstrated should be similar when using ADO with other providers to heterogeneous data, such as a provider to an e-mail store.

URLs

Uniform Resource Locators (URLs) can be used as an alternative to connection strings and command text to specify data sources and the location of files and directories. You can use URLs with the existing Connection and Recordset objects as well as with the Record and Stream objects.

For more information about using URLs, see Absolute and Relative URLs.

Record Fields

The distinguishing difference between heterogeneous data and homogeneous data is that for the former, each row of data, or Record, can have a different set of columns, or Fields. For homogeneous data, each row has the same set of columns. For more information about the fields specific to the Internet Publishing Provider, see Records and Provider-Supplied Fields.

Appending New Fields

Several ADO objects have been enhanced to work in conjunction with Record and Stream objects.

  • The Fields collection Append method, which creates and adds a Field object to the collection, can also specify the value of the Field.

  • The Update method finalizes the addition or deletion of fields to the collection.

  • As a shortcut and alternative to the Append method, you may create fields by simply assigning a value to an undefined or previously deleted field.


Syntax error in PROCEDURE clause. (Error 3140)

 Copy code hover
[image]

Syntax error in PROCEDURE clause. (Error 3140)
Send feedback

You entered an SQL statement that has an invalid PROCEDURE clause.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


Data actions (Access 2013 custom web app)

 Copy code hover
[image]

Data actions (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • StopMacro Macro Action (Access 2013 custom web app)

  • CancelRecordChange Macro Action (Access 2013 custom web app)

  • DeleteRecord Data Macro Action (Access 2013 custom web app)

  • RaiseError Macro Action (Access 2013 custom web app)

  • SetField Macro Action (Access 2013 custom web app)

  • SetLocalVar Macro Action (Access 2013 custom web app)

  • ExitForEachRecord Macro Action (Access 2013 custom web app)

  • SetReturnVar Macro Action (Access 2013 custom web app)


Internet Information Services Error Codes

 Copy code hover
[image]

Internet Information Services Error Codes
Send feedback

The following table lists Microsoft Internet Information Services (IIS) error codes related to Remote Data Service usage. The positive decimal translation of the low two bytes, the negative decimal translation of the full error code, and the hexadecimal values are shown.

Internet Information Services errors | Number | Description
IDS_IIS_AccessDenied | 8208 -2146820080 0x800A2010 | Internet Server Error: Access Denied.
IDS_IIS_ObjectNotFound | 8209 -2146820079 0x800A2011 | Internet Server Error: Object/module not found.
IDS_IIS_RequestForbidden | 8210 -2146820078 0x800A2012 | Internet Server Error: Request Forbidden.
IDS_IIS_UnexpectedError | 8447 -2146819841 0x800A20FF | Internet Server Error.


NavigationControl Events (Access)

 Copy code hover
[image]

NavigationControl Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Change | The Change event occurs when the contents of the specified control changes.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Dirty | The Dirty event occurs when the contents of the specified control changes.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.
Undo | Occurs when the user undoes a change.


Image.GridlineShade Property (Access)

 Copy code hover
[image]

Image.GridlineShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineShade

expression A variable that represents an Image object.

Remarks

The GridlineShade property contains a numeric expression that can be used to darken the theme color in the GridlineColor property. The default value of the GridlineShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

Image Object

Other resources

Image Object Members


OptionGroup.OnEnter Property (Access)

 Copy code hover
[image]

OptionGroup.OnEnter Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnEnter

expression A variable that represents an OptionGroup object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Enter event occurs before a control actually receives the focus from a control on the same form.

The OnEnter value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Enter box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Enter box is blank, the property value is an empty string.

Example

The following example associates the Enter event with the macro "Enter_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnEnter = "Enter_Macro"

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Could not create replication system tables needed to make the database replicable. (Error 3579)

 Copy code hover
[image]

Could not create replication system tables needed to make the database replicable. (Error 3579)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


WebBrowserControl.Properties Property (Access)

 Copy code hover
[image]

WebBrowserControl.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Properties

expression A variable that represents a WebBrowserControl object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


BoundObjectFrame.BeforeUpdate Property (Access)

 Copy code hover
[image]

BoundObjectFrame.BeforeUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.

Syntax

expression .BeforeUpdate

expression A variable that represents a BoundObjectFrame object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeUpdate event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the BeforeUpdate event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).BeforeUpdate = "[Event Procedure]"

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


GetChunk Method (ADO)

 Copy code hover
[image]

GetChunk Method (ADO)
Send feedback

Returns all, or a portion, of the contents of a large text or binary data Field object.

Syntax

variable = field.GetChunk(Size )

Return Value

Returns a Variant.

Parameters

  • Size

  • A Long expression that is equal to the number of bytes or characters that you want to retrieve.

Remarks

Use the GetChunk method on a Field object to retrieve part or all of its long binary or character data. In situations where system memory is limited, you can use the GetChunk method to manipulate long values in portions, rather than in their entirety.

The data that a GetChunk call returns is assigned to variable. If Size is greater than the remaining data, the GetChunk method returns only the remaining data without padding variable with empty spaces. If the field is empty, the GetChunk method returns a null value.

Each subsequent GetChunk call retrieves data starting from where the previous GetChunk call left off. However, if you are retrieving data from one field and then you set or read the value of another field in the current record, ADO assumes you have finished retrieving data from the first field. If you call the GetChunk method on the first field again, ADO interprets the call as a new GetChunk operation and starts reading from the beginning of the data. Accessing fields in other Recordset objects that are not clones of the first Recordset object will not disrupt GetChunk operations.

If the adFldLong bit in the Attributes property of a Field object is set to True, you can use the GetChunk method for that field.

If there is no current record when you use the GetChunk method on a Field object, error 3021 (no current record) occurs.

Note Note

The GetChunk method does not operate on Field objects of a Record object. It does not perform any operation and will produce a run-time error.


WebBrowserControl.LocationURL Property (Access)

 Copy code hover
[image]

WebBrowserControl.LocationURL Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the Uniform Resource Locator (URL) of the current document. Read-only String.

Version Information

Version Added: Access 2010

Syntax

expression .LocationURL

expression A variable that represents a WebBrowserControl object.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


SubForm.Controls Property (Access)

 Copy code hover
[image]

SubForm.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Syntax

expression .Controls

expression A variable that represents a SubForm object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Field2 Object Reference (DAO)

 Copy code hover
[image]

Field2 Object Reference (DAO)
Send feedback

In this section

  • Field2 Object (DAO)

  • Field2 Members (DAO)

  • Field2 Properties (DAO)

  • Field2 Methods (DAO)


Set Form, Report, and Control Properties in Visual Basic

 Copy code hover
[image]

Set Form, Report, and Control Properties in Visual Basic
Send feedback

Published: July 16, 2012

Form , Report , and Control objects are Microsoft 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

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

Copy code Copy code
Forms!Customers.Visible = True

You can also set a property of a form or report from within the object's module by using the object's Me property. Code that uses the Me property executes faster than code that uses a fully qualified object name. For example, to set the RecordSource property of the Customers form to an SQL statement that returns all records with a CompanyName field entry beginning with "A" from within the Customers form module, use the following line of code:

Copy code Copy code
Me.RecordSource = "SELECT * FROM Customers " _
    & "WHERE CompanyName Like 'A*'"

To set a property of a control

Refer to the control in the Controls 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:

Copy code Copy code
' Faster method.
Me!CustomerID.Visible = True
Copy code Copy code
' Slower method.
Forms!Customers.Controls!CustomerID.Visible = True

The fastest way to set a property of a control is from within an object's module by using the object's Me property. For example, you can use the following code to toggle the Visible property of a text box called CustomerID on the Customers form:

Copy code Copy code
With Me!CustomerID
    .Visible = Not .Visible
End With

To 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:

Copy code Copy code
Forms!Customers.Section(3).Visible = False
Copy code Copy code
Me!Section(acPageHeader).Visible = False
Note Note

  • 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.

    • 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.

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


ToggleButton.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

ToggleButton.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified toggle button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleLeft

expression A variable that represents a ToggleButton object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


How to: Find the Current Position in a DAO Recordset

 Copy code hover
[image]

How to: Find the Current Position in a DAO Recordset
Send feedback

In some situations, you need to determine how far through a Recordset object you have moved the current record position, and perhaps indicate the current record position to a user. For example, you may want to indicate the current position on a dial, meter, or similar type of control. Two properties are available to indicate the current position: the AbsolutePosition property and the PercentPosition property.

The AbsolutePosition property value is the position of the current record relative to 0. However, do not think of this property as a record number; if the current record is undefined, the AbsolutePosition property returns 1. In addition, there is no assurance that a record will have the same absolute position if the Recordset object is recreated because the order of individual records within a Recordset object is not guaranteed unless it is created with an SQL statement that includes an ORDER BY clause.

The PercentPosition property shows the current position expressed as a percentage of the total number of records indicated by the RecordCount property. Because the RecordCount property does not reflect the total number of records in the Recordset object until the Recordset has been fully populated, the PercentPosition property reflects only the current record position as a percentage of the number of records that have been accessed since the Recordset was opened. To make sure that the PercentPosition property reflects the current record position relative to the entire Recordset, use the MoveLast and MoveFirst methods immediately after opening the Recordset. This fully populates the Recordset object before you use the PercentPosition property. If you have a large result set, using the MoveLast method may take a long time for Recordsets that are not of type table.

Note Note

The PercentPosition property is only an approximation and should not be used as a critical parameter. This property is best suited for driving an indicator that marks a user's progress while moving though a set of records. For example, you may want a control that indicates the percentage of records completed.

The following example opens a Recordset object on a table called Employees. The procedure then moves through the Employees table and uses the SysCmd method to display a progress bar showing the percentage of the table that has been processed. If the hire date of the employee is before Jan. 1, 1993, the text "Senior Staff" is appended to the Notes field.

VBA Copy code Copy code
Sub AddEmployeeNotes()

Dim dbsNorthwind As DAO.Database
Dim rstEmployees As DAO.Recordset
Dim strMsg As String
Dim intRet As Integer
Dim intCount As Integer
Dim strSQL As String
Dim sngPercent As Single
Dim varReturn As Variant
Dim lngEmpID() As Long

On Error GoTo ErrorHandler

   Set dbsNorthwind = CurrentDb

   strSQL = "SELECT * FROM Employees"
   Set rstEmployees = dbsNorthwind.OpenRecordset(strSQL, dbOpenDynaset)

   With rstEmployees
      If .EOF Then            ' If no records, exit.
         Exit Sub
      Else
         strMsg = "Processing Employees table..."
         intRet = SysCmd(acSysCmdInitMeter, strMsg, 100)
      End If

      Do Until .EOF
         If !HireDate < #1/1/93# Then
            .Edit
            !Notes = !Notes & ";" & "Senior Staff"
            .Update
         End If

         If .PercentPosition <> 0 Then
            intRet = SysCmd(acSysCmdUpdateMeter, .PercentPosition)
         End If
         .MoveNext
      Loop
   End With

   intRet = SysCmd(acSysCmdRemoveMeter)

   rstEmployees.Close
   dbsNorthwind.Close

   Set rstEmployees = Nothing
   Set dbsNorthwind = Nothing

Exit Sub

ErrorHandler:
   MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
   varReturn = SysCmd(acSysCmdSetStatus, " ")
End Sub


CheckBox.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

CheckBox.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Syntax

expression .ShortcutMenuBar

expression A variable that represents a CheckBox object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

Example

The following example sets the "Suppliers_Toolbar" as the custom shortcut menu to display when the user clicks the right mouse button on the "Suppliers" form.

VBA Copy code Copy code
Forms("Suppliers").ShortcutMenuBar = "Suppliers_Toolbar"

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ListBox.SmartTags Property (Access)

 Copy code hover
[image]

ListBox.SmartTags Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a SmartTags collection that represents the collection of smart tags that have been added to a control. .

Syntax

expression .SmartTags

expression A variable that represents a ListBox object.

Remarks

Note Note

Unlike the SmartTags collections in Microsoft Excel and Microsoft Word, the SmartTags collection in Microsoft Access is zero-based. Therefore, the code control.SmartTags(0) returns the first smart tag for the specified control.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


NavigationControl.BackStyle Property (Access)

 Copy code hover
[image]

NavigationControl.BackStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .BackStyle

expression A variable that represents a NavigationControl object.

Remarks

The BackStyle property uses the following settings.

Setting | Visual Basic | Description
Normal | 1 | (Default for all controls except option group) The control has its interior color set by the BackColor property.
Transparent | 0 | (Default for option group) The control is transparent. The color of the form or report behind the control is visible.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

If the Transparent button on the Back Color button palette is selected, the BackStyle property is set to Transparent; otherwise the BackStyle property is set to Normal.

To make a command button invisible, set its Transparent property to Yes.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


UpdateCriteriaEnum Enumeration (DAO)

 Copy code hover
[image]

UpdateCriteriaEnum Enumeration (DAO)
Send feedback

Used with the UpdateOptions method to specify how a batch update is constructed.

Name | Value | Description
dbCriteriaAllCols | 4 | Uses the key column(s) and all the columns in the where clause.
dbCriteriaDeleteInsert | 16 | Uses a pair of DELETE and INSERT statements for each modified row.
dbCriteriaKey | 1 | Uses just the key column(s) in the where clause.
dbCriteriaModValues | 2 | Uses the key column(s) and all updated columns in the where clause.
dbCriteriaTimestamp | 8 | Uses just the timestamp column if available (will generate a run-time error if no timestamp column is in the result set).
dbCriteriaUpdate | 32 | Uses an UPDATE statement for each modified row.


Partner replica is not managed by a Synchronizer. (Error 3628)

 Copy code hover
[image]

Partner replica is not managed by a Synchronizer. (Error 3628)
Send feedback

You are trying to synchronize with a partner replica that is not being managed by a Synchronizer.


AllViews.Parent Property (Access)

 Copy code hover
[image]

AllViews.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents an AllViews object.

See also

Concepts

AllViews Collection

Other resources

AllViews Object Members


AllDatabaseDiagrams.Item Property (Access)

 Copy code hover
[image]

AllDatabaseDiagrams.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.

Syntax

expression .Item(var)

expression A variable that represents an AllDatabaseDiagrams object.

Parameters

Name | Required/Optional | Data Type | Description
var | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

AllDatabaseDiagrams Collection

Other resources

AllDatabaseDiagrams Object Members


CustomControl.ControlSource Property (Access)

 Copy code hover
[image]

CustomControl.ControlSource Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.

Syntax

expression .ControlSource

expression A variable that represents a CustomControl object.

Remarks

The ControlSource property uses the following settings.

Setting | Description
A field name | The control is bound to a field in a table, query, or SQL statement. Data from the field is displayed in the control. Changes to the data inside the control change the corresponding data in the field. (To make the control read-only, set the Locked property to Yes.) If you click a control bound to a field that has a Hyperlink data type, you jump to the destination specified in the hyperlink address.
An expression | The control displays data generated by an expression. This data can be changed by the user but isn't saved in the database.

For reports, the ControlSource property applies only to report group levels.

Forms and reports act as "windows" into your database. You specify the primary source of data for a form or report by setting its RecordSource property to a table, query, or SQL statement. You can then set the ControlSource property to a field in the source of data or to an expression. If the ControlSource property setting is an expression, the value displayed is read-only and not saved in the database. For example, you can use the following settings.

Sample setting | Description
LastName | For a control, data from the LastName field is displayed in the control. For a report group level, Microsoft Access groups the data on last name.
=Date( ) + 7 | For a control, this expression displays a date seven days from today in the control.
=DatePart("q",ShippedDate) | For a control, this expression displays the quarter of the shipped date. For a report group level, Microsoft Access groups the data on the quarter of the shipped date.

Example

The following example sets the ControlSource property for a text box named AddressPart to a field named City:

VBA Copy code Copy code
Forms!Customers!AddressPart.ControlSource = "City"

The next example sets the ControlSource property for a text box named Expected to the expression =Date() + 7

VBA Copy code Copy code
Me!Expected.ControlSource = "=Date() + 7"

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


OptionButton.VerticalAnchor Property (Access)

 Copy code hover
[image]

OptionButton.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified option button is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .VerticalAnchor

expression A variable that represents an OptionButton object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Image Control (Misc)

 Copy code hover
[image]

Image Control (Misc)
Send feedback

Published: July 16, 2012

The image control can add a picture to a form or report. For example, you could include an image control for a logo on an Invoice report.

Remarks

You can use the image control or an unbound object frame for unbound pictures. The advantage of using the image control is that it's faster to display. The advantage of using the unbound object frame is that you can edit the object directly from the form or report.


NavigationControl.OnLostFocus Property (Access)

 Copy code hover
[image]

NavigationControl.OnLostFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnLostFocus

expression A variable that represents a NavigationControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The LostFocus event occurs when the object loses the focus.

The OnLostFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Lost Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Lost Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnLostFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnLostFocus

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Forms Properties (Access)

 Copy code hover
[image]

Forms Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Form.
Parent | Returns the parent object for the specified object. Read-only.


Move Method (ADO)

 Copy code hover
[image]

Move Method (ADO)
Send feedback

Moves the position of the current record in a Recordset object.

Syntax

recordset.Move NumRecords, Start

Parameters

  • NumRecords

  • A signed Long expression that specifies the number of records that the current record position moves.

  • Start

  • Optional. A String value or Variant that evaluates to a bookmark. You can also use a BookmarkEnum value.

Remarks

The Move method is supported on all Recordset objects.

If the NumRecords argument is greater than zero, the current record position moves forward (toward the end of the Recordset). If NumRecords is less than zero, the current record position moves backward (toward the beginning of the Recordset).

If the Move call would move the current record position to a point before the first record, ADO sets the current record to the position before the first record in the recordset (BOF is True). An attempt to move backward when the BOF property is already True generates an error.

If the Move call would move the current record position to a point after the last record, ADO sets the current record to the position after the last record in the recordset (EOF is True). An attempt to move forward when the EOF property is already True generates an error.

Calling the Move method from an empty Recordset object generates an error.

If you pass the Start argument, the move is relative to the record with this bookmark, assuming the Recordset object supports bookmarks. If not specified, the move is relative to the current record.

If you are using the CacheSize property to locally cache records from the provider, passing a NumRecords argument that moves the current record position outside the current group of cached records forces ADO to retrieve a new group of records, starting from the destination record. The CacheSize property determines the size of the newly retrieved group, and the destination record is the first record retrieved.

If the Recordset object is forward only, a user can still pass a NumRecords argument less than zero, provided the destination is within the current set of cached records. If the Move call would move the current record position to a record before the first cached record, an error will occur. Thus, you can use a record cache that supports full scrolling over a provider that supports only forward scrolling. Because cached records are loaded into memory, you should avoid caching more records than is necessary. Even if a forward-only Recordset object supports backward moves in this way, calling the MovePrevious method on any forward-only Recordset object will still generate an error.

Note Note

Support for moving backwards in a forward-only Recordset is not predictable, depending upon your provider. If the current record has been postioned after the last record in the Recordset, Move backwards may not result in the correct current position.


ToggleButton.PressedTint Property (Access)

 Copy code hover
[image]

ToggleButton.PressedTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the PressedColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .PressedTint

expression A variable that represents a ToggleButton object.

Remarks

The PressedTint property contains a numeric expression that can be used to lighten the theme color in the PressedColor property. The default value of the PressedTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


ToggleButton.Locked Property (Access)

 Copy code hover
[image]

ToggleButton.Locked Property (Access)
See also Send feedback

Published: July 16, 2012

The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.

Syntax

expression .Locked

expression A variable that represents a ToggleButton object.

Remarks

The default setting of the Locked property is True. This setting allows editing, adding, and deleting data.

Use the Locked property to protect data in a field by making it read-only. For example, you might want a control to only display information without allowing editing, or you might want to lock a control until a specific condition is met.

Example

The following example toggles the Enabled property of a command button and the Enabled and Locked properties of a control, depending on the type of employee displayed in the current record. If the employee is a manager, then the SalaryDetails button is enabled and the PersonalInfo control is unlocked and enabled.

VBA Copy code Copy code
Sub Form_Current()
 If Me!EmployeeType = "Manager" Then
 Me!SalaryDetails.Enabled = True
 Me!PersonalInfo.Enabled = True
 Me!PersonalInfo.Locked = False
 Else
 Me!SalaryDetails.Enabled = False
 Me!PersonalInfo.Enabled = False
 Me!PersonalInfo.Locked = True
 End If
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


CREATE PROCEDURE Statement (Microsoft Access SQL)

 Copy code hover
[image]

CREATE PROCEDURE Statement (Microsoft Access SQL)
Send feedback

Creates a stored procedure.

Note Note

The Microsoft Access database engine does not support the use of CREATE PROCEDURE, or any of the DDL statements, with non-Microsoft Jet database engine databases.

Syntax

CREATE PROCEDURE procedure [param1 datatype[, param2 datatype[, …]] AS sqlstatement

The CREATE PROCEDURE statement has these parts:

Part

Description

procedure

A name for the procedure. It must follow standard naming conventions.

param1, param2

From one to 255 field names or parameters. For example:

SQL Copy code Copy code
CREATE PROCEDURE Sales_By_Country [Beginning Date] DateTime, [Ending Date] DateTime;

For more information on parameters, see PARAMETERS.

datatype

One of the primary Microsoft Access SQL data types or their synonyms.

sqlstatement

An SQL statement such as SELECT, UPDATE, DELETE, INSERT, CREATE TABLE, DROP TABLE, and so on.

Remarks

An SQL procedure consists of a PROCEDURE clause that specifies the name of the procedure, an optional list of parameter definitions, and a single SQL statement.

A procedure name cannot be the same as the name of an existing table.

Example

This example names the query CategoryList.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

VBA Copy code Copy code
Sub ProcedureX()

    Dim dbs As Database, rst As Recordset
    Dim qdf As QueryDef, strSql As String

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    strSql = "PROCEDURE CategoryList; " _
        & "SELECT DISTINCTROW CategoryName, " _
        & "CategoryID FROM Categories " _
        & "ORDER BY CategoryName;"

    ' Create a named QueryDef based on the SQL
    ' statement.
    Set qdf = dbs.CreateQueryDef("NewQry", strSql)

    ' Create a temporary snapshot-type Recordset.
    Set rst = qdf.OpenRecordset(dbOpenSnapshot)

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 15

    ' Delete the QueryDef because this is a
    ' demonstration.
    dbs.QueryDefs.Delete "NewQry"

    dbs.Close

End Sub


Report.Shape Property (Access)

 Copy code hover
[image]

Report.Shape Property (Access)
Send feedback

Published: July 16, 2012

Returns a String representing the shape command corresponding to the sorting and grouping of the specified report. Read-only.

Syntax

expression .Shape

expression A variable that represents a Report object.

Remarks

Analyzing the shape command for a particular report can make it easier to create ADO recordsets that can be used with the report.

Example

The following example reads the shape command of the specified report and stores it to a string variable.

VBA Copy code Copy code
Dim strShape As String

strShape = Reports(0).Shape

Property value

STRING


Syntax error in CHECK CONSTRAINT clause. (Error 3765)

 Copy code hover
[image]

Syntax error in CHECK CONSTRAINT clause. (Error 3765)
Send feedback

This error occurs when using SQL DLL to define a CHECK constraint. It occurs when the search condition (SELECT statement) in the CHECK clause references an invalid table or column name.


Recordset2.Delete Method (DAO)

 Copy code hover
[image]

Recordset2.Delete Method (DAO)
Send feedback

Not supported for this object.

Syntax

expression .Delete

expression A variable that represents a Recordset2 object.


ADO Methods

 Copy code hover
[image]

ADO Methods
Send feedback
AddNew | Creates a new record for an updatable Recordset object.
Append | Appends an object to a collection. If the collection is Fields, a new Field object may be created before it is appended to the collection.
AppendChunk | Appends data to a large text or binary data Field, or to a Parameter object.
BeginTrans, CommitTrans, and RollbackTrans | Manages transaction processing within a Connection object as follows: BeginTrans — Begins a new transaction. CommitTrans — Saves any changes and ends the current transaction. It may also start a new transaction. RollbackTrans — Cancels any changes and ends the current transaction. It may also start a new transaction.
Cancel | Cancels execution of a pending, asynchronous method call.
CancelBatch | Cancels a pending batch update.
CancelUpdate | Cancels any changes made to the current or new row of a Recordset object, or the Fields collection of a Record object, before calling the Update method.
Clear | Removes all the Error objects from the Errors collection.
Clone | Creates a duplicate Recordset object from an existing Recordset object. Optionally, specifies that the clone be read-only.
Close | Closes an open object and any dependent objects.
CompareBookmarks | Compares two bookmarks and returns an indication of their relative values.
CopyRecord | Copies a file or directory, and its contents, to another location.
CopyTo | Copies the specified number of characters or bytes (depending on Type) in the Stream to another Stream object.
CreateParameter | Creates a new Parameter object with the specified properties.
Delete (ADO Parameters Collection) | Deletes an object from the Parameters collection.
Delete (ADO Fields Collection) | Deletes an object from the Fields collection.
Delete (ADO Recordset) | Deletes the current record or a group of records.
DeleteRecord | Deletes a file or directory, and all its subdirectories.
Execute (ADO Command) | Executes the query, SQL statement, or stored procedure specified in the CommandText property.
Execute (ADO Connection) | Executes the specified query, SQL statement, stored procedure, or provider-specific text.
Find | Searches a Recordset for the row that satisfies the specified criteria.
Flush | Forces the contents of the Stream remaining in the ADO buffer to the underlying object with which the Stream is associated.
GetChildren | Returns a Recordset whose rows represent the files and subdirectories in the directory represented by this Record.
GetChunk | Returns all, or a portion of, the contents of a large text or binary data Field object.
GetRows | Retrieves multiple records of a Recordset object into an array.
GetString | Returns the Recordset as a string.
LoadFromFile | Loads the contents of an existing file into a Stream.
Move | Moves the position of the current record in a Recordset object.
MoveFirst, MoveLast, MoveNext, and MovePrevious | Moves to the first, last, next, or previous record in a specified Recordset object and makes that record the current record.
MoveRecord | Moves a file, or a directory and its contents, to another location.
NextRecordset | Clears the current Recordset object and returns the next Recordset by advancing through a series of commands.
Open (ADO Connection) | Opens a connection to a data source.
Open (ADO Record) | Opens an existing Record object, or creates a new file or directory.
Open (ADO Recordset) | Opens a cursor.
Open (ADO Stream) | Opens a Stream object to manipulate streams of binary or text data.
OpenSchema | Obtains database schema information from the provider.
Read | Reads a specified number of bytes from a Stream object.
ReadText | Reads a specified number of characters from a text Stream object.
Refresh | Updates the objects in a collection to reflect objects available from, and specific to, the provider.
Requery | Updates the data in a Recordset object by re-executing the query on which the object is based.
Resync | Refreshes the data in the current Recordset object, or Fields collection of a Record object, from the underlying database.
Save | Saves the Recordset in a file or Stream object.
SaveToFile | Saves the binary contents of a Stream to a file.
Seek | Searches the index of a Recordset to quickly locate the row that matches the specified values, and changes the current row position to that row.
SetEOS | Sets the position that is the end of the stream.
SkipLine | Skips one entire line when reading a text stream.
Stat | Gets statistical information about an open stream.
Supports | Determines whether a specified Recordset object supports a particular type of functionality.
Update | Saves any changes you make to the current row of a Recordset object, or the Fields collection of a Record object.
UpdateBatch | Writes all pending batch updates to disk.
Write | Writes binary data to a Stream object.
WriteText | Writes a specified text string to a Stream object.


ADD USER Statement (Microsoft Access SQL)

 Copy code hover
[image]

ADD USER Statement (Microsoft Access SQL)
Send feedback

Adds one or more existing users to an existing group.

Syntax

ADD USER user[, user, …] TO group

The ADD USER statement has these parts:

Part | Description
user | The name of a user to be added to the workgroup information file.
group | The name of a group to be added to the workgroup information file.

Remarks

Once a user had been added to a group, the user has all the permissions that have been granted to the group.


ListBox.BeforeUpdate Event (Access)

 Copy code hover
[image]

ListBox.BeforeUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The BeforeUpdate event occurs before changed data in a control or record is updated.

Syntax

expression .BeforeUpdate(Cancel)

expression A variable that represents a ListBox object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the BeforeUpdate event occurs. Setting the Cancel argument to True (-1) cancels the BeforeUpdate event.

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's BeforeUpdate event does occur.

To run a macro or event procedure when this event occurs, set the BeforeUpdate property to the name of the macro or to [Event Procedure].

This event does not apply to option buttons, check boxes, or toggle buttons in an option group. It applies only to the option group itself.

The BeforeUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB. When the focus leaves the record or if the user clicks Save Record on the Records menu, the entire record is updated, and the data is saved in the database.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

BeforeUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. BeforeUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For forms, you can use the BeforeUpdate event to cancel updating of a record before moving to another record.

If the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

You often use the BeforeUpdate event to validate data, especially when you perform complex validations, such as those that:

  • Involve conditions for more than one value on a form.

  • Display different error messages for different data entered.

  • Can be overridden by the user.

  • Contain references to controls on other forms or contain user-defined functions.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

A run-time error will occur if you attempt to modify the data contained in the control that fired the BeforeUpdate event in the event's procedure.

Example

The following example shows how you can use a BeforeUpdate event procedure to check whether a product name has already been entered in the database. After the user types a product name in the ProductName box, the value is compared to the ProductName field in the Products table. If there is a matching value in the Products table, a message is displayed that informs the user that the product has already been entered.

To try the example, add the following event procedure to a form named Products that contains a text box called ProductName.

VBA Copy code Copy code
Private Sub ProductName_BeforeUpdate(Cancel As Integer)
 If(Not IsNull(DLookup("[ProductName]", _
 "Products", "[ProductName] ='" _
 & Me!ProductName & "'"))) Then
 MsgBox "Product has already been entered in the database."
 Cancel = True
 Me!ProductName.Undo
 End If
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


ToggleButton.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

ToggleButton.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified toggle button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleBottom

expression A variable that represents a ToggleButton object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


SaveOptionsEnum

 Copy code hover
[image]

SaveOptionsEnum
Send feedback

Specifies whether a file should be created or overwritten when saving from a Stream object. The values can be combined with an AND operator.

Constant | Value | Description
adSaveCreateNotExist | 1 | Default. Creates a new file if the file specified by the FileName parameter does not already exist.
adSaveCreateOverWrite | 2 | Overwrites the file with the data from the currently open Stream object, if the file specified by the Filename parameter already exists.

ADO/WFC Equivalent

These constants do not have ADO/WFC equivalents.


PositionEnum

 Copy code hover
[image]

PositionEnum
Send feedback

Specifies the current position of the record pointer within a Recordset.

Constant | Value | Description
adPosBOF | -2 | Indicates that the current record pointer is at BOF (that is, the BOF property is True).
adPosEOF | -3 | Indicates that the current record pointer is at EOF (that is, the EOF property is True).
adPosUnknown | -1 | Indicates that the Recordset is empty, the current position is unknown, or the provider does not support the AbsolutePage or AbsolutePosition property.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.Position.BOF

AdoEnums.Position.EOF

AdoEnums.Position.UNKNOWN


Recordset2.FindFirst Method (DAO)

 Copy code hover
[image]

Recordset2.FindFirst Method (DAO)
Send feedback

Locates the first record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only).

Syntax

expression .FindFirst(Criteria)

expression A variable that represents a Recordset2 object.

Parameters

Name | Required/Optional | Data Type | Description
Criteria | Required | String | A String used to locate the record. It is like the WHERE clause in an SQL statement, but without the word WHERE.

Remarks

If you want to include all the records in your search — not just those that meet a specific condition — use the Move methods to move from record to record. To locate a record in a table-type Recordset, use the Seek method.

If a record matching the criteria isn't located, the current record pointer is unknown, and the NoMatch property is set to True. If recordset contains more than one record that satisfies the criteria, FindFirst locates the first occurrence, FindNext locates the next occurrence, and so on.

Each of the Find methods begins its search from the location and in the direction specified in the following table.

Find method | Begins searching at | Search direction
FindFirst | Beginning of recordset | End of recordset
FindLast | End of recordset | Beginning of recordset
FindNext | Current record | End of recordset
FindPrevious | Current record | Beginning of recordset

Using one of the Find methods isn't the same as using a Move method, however, which simply makes the first, last, next, or previous record current without specifying a condition. You can follow a Find operation with a Move operation.

Always check the value of the NoMatch property to determine whether the Find operation has succeeded. If the search succeeds, NoMatch is False. If it fails, NoMatch is True and the current record isn't defined. In this case, you must position the current record pointer back to a valid record.

Using the Find methods with Microsoft Access database engine-connected ODBC-accessed recordsets can be inefficient. You may find that rephrasing your criteria to locate a specific record is faster, especially when working with large recordsets.

When working with Microsoft Access database engine-connected ODBC databases and large dynaset-type Recordset objects, you might discover that using the Find methods or using the Sort or Filter property is slow. To improve performance, use SQL queries with customized ORDER BY or WHERE clauses, parameter queries, or QueryDef objects that retrieve specific indexed records.

You should use the U.S. date format (month-day-year) when you search for fields containing dates, even if you're not using the U.S. version of the Microsoft Access database engine; otherwise, the data may not be found. Use the Visual Basic Format function to convert the date. For example:

VBA Copy code Copy code
rstEmployees.FindFirst "HireDate > #" _
    & Format(mydate, 'm-d-yy' ) & "#"

If criteria is composed of a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strSQL = "PRICE > " & lngPrice, and lngPrice = 125,50), an error occurs when you try to call the method. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and Microsoft Access SQL only accepts U.S. decimal characters.

Note Note

  • For best performance, the criteria should be in either the form "field = value" where field is an indexed field in the underlying base table, or "field LIKE prefix" where field is an indexed field in the underlying base table and prefix is a prefix search string (for example, "ART*" ).

  • In general, for equivalent types of searches, the Seek method provides better performance than the Find methods. This assumes that table-type Recordset objects alone can satisfy your needs.


DoCmd.OutputTo Method (Access)

 Copy code hover
[image]

DoCmd.OutputTo Method (Access)
See also Send feedback

Published: July 16, 2012

The OutputTo method carries out the OutputTo action in Visual Basic.

Syntax

expression .OutputTo(ObjectType, ObjectName, OutputFormat, OutputFile, AutoStart, TemplateFile, Encoding, OutputQuality)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
ObjectType | Required | AcOutputObjectType | An AcOutputObjectType constant that specifies the type of object to output.
ObjectName | Optional | Variant | A string expression that's the valid name of an object of the type selected by the ObjectType argument. If you want to output the active object, specify the object's type for the ObjectType argument and leave this argument blank. If you run Visual Basic code containing the OutputTo method in a library database, Microsoft Office Access searches for the object with this name, first in the library database, then in the current database.
OutputFormat | Optional | Variant | An AcFormat constant that specifies the output format. If you omit this argument, Access prompts you for the output format.
OutputFile | Optional | Variant | A string expression that's the full name, including the path, of the file you want to output the object to. If you leave this argument blank, Access prompts you for an output file name.
AutoStart | Optional | Variant | Use True (-1) to start the appropriate Microsoft Windows-based application immediately, with the file specified by the OutputFile argument loaded. Use False (0) if you don't want to start the application. This argument is ignored for Microsoft Internet Information Server (.htx, .idc) files and Microsoft ActiveX Server (*.asp) files. If you leave this argument blank, the default (False) is assumed.
TemplateFile | Optional | Variant | A string expression that's the full name, including the path, of the file you want to use as a template for an HTML, HTX, or ASP file.
Encoding | Optional | Variant | The type of character encoding format you want used to output the text or HTML data.
OutputQuality | Optional | AcExportQuality | An AcExportQuality constant that specifies the type of output device to optimize for. The default value is acExportQualityPrint.

Remarks

You can use the OutputTo method to output the data in the specified Access database object (a datasheet, form, report, module, data access page) to several output formats.

Modules can be output only in MS-DOS Text format, so if you specify acOutputModule for the ObjectType argument, you must specify acFormatTXT for the OutputFormat argument. Microsoft Internet Information Server and Microsoft ActiveX Server formats are available only for tables, queries, and forms, so if you specify acFormatIIS or acFormatASP for the OutputFormat argument, you must specify acOutputTable, acOutputQuery, or acOutputForm for the ObjectType argument.

The Access data is output in the selected format and can be read by any application that uses the same format. For example, you can output an Access report with its formatting to a rich-text format document and then open the document in Microsoft Word.

Note Note

You can save as a PDF or XPS file from a 2007 Microsoft Office system program only after you install an add-in. For more information, search for "Enable support for other file formats, such as PDF and XPS" on the Office Web site.

Example

The following code example outputs the Employees table in rich-text format (.rtf) to the Employee.rtf file and immediately opens the file in Microsoft Word for Windows.

VBA Copy code Copy code
DoCmd.OutputTo acOutputTable, "Employees", _
 acFormatRTF, "Employee.rtf", True

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


TabControl.KeyDown Event (Access)

 Copy code hover
[image]

TabControl.KeyDown Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyDown(KeyCode, Shift)

expression A variable that represents a TabControl object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyDown property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyDown event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyDown event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyDown event occurs when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

Example

The following example determines whether you have pressed the SHIFT, CTRL, or ALT key.

To try the example, add the following event procedure to a form containing a text box named KeyHandler.

VBA Copy code Copy code
Private Sub KeyHandler_KeyDown(KeyCode As Integer, _
     Shift As Integer)
    Dim intShiftDown As Integer, intAltDown As Integer
    Dim intCtrlDown As Integer

    ' Use bit masks to determine which key was pressed.
    intShiftDown = (Shift And acShiftMask) > 0
    intAltDown = (Shift And acAltMask) > 0
    intCtrlDown = (Shift And acCtrlMask) > 0
    ' Display message telling user which key was pressed.
    If intShiftDown Then MsgBox "You pressed the SHIFT key."
    If intAltDown Then MsgBox "You pressed the ALT key."
    If intCtrlDown Then MsgBox "You pressed the CTRL key."
End Sub

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Recordset.Name Property (DAO)

 Copy code hover
[image]

Recordset.Name Property (DAO)
Send feedback

Returns the name of the specified object. Read-only String.

Syntax

expression .Name

expression A variable that represents a Recordset object.

Remarks

The Name property of a Recordset object opened by using an SQL statement is the first 256 characters of the SQL statement.


ListBox.OnMouseMove Property (Access)

 Copy code hover
[image]

ListBox.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Syntax

expression .OnMouseMove

expression A variable that represents a ListBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


AccessObjectProperties Methods (Access)

 Copy code hover
[image]

AccessObjectProperties Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Add | You can use the Add method to add a new property as an AccessObjectProperty object to the AccessObjectProperties collection of an AccessObject object.
Remove | You can use the Remove method to remove an AccessObjectProperty object from the AccessObjectProperties collection of an AccessObject object.


Section II: Remote Data Service (Access)

 Copy code hover
[image]

Section II: Remote Data Service (Access)
Send feedback

In this section

  • Section II: Remote Data Service

  • Chapter 11: RDS Fundamentals (ADO)

  • Chapter 12: RDS Tutorial (ADO)

  • Chapter 13: RDS Usage and Security (ADO)


ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction Properties Example (JScript)

 Copy code hover
[image]

ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction Properties Example (JScript)
Send feedback

This example uses the ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction properties to execute a stored procedure. Cut and paste the following code to Notepad or another text editor, and save it as ActiveConnectionJS.asp.

Copy code Copy code

<!-- BeginActiveConnectionJS -->
<%@LANGUAGE="JScript"%>
<%// use this meta tag instead of adojavas.inc%>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->

<html>
<head>
 <title>ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction Properties</title>
<style>
<!--
BODY {
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 BACKGROUND-COLOR:white;
 COLOR:black;
 }
.thead {
 background-color: #008080;
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 font-size: x-small;
 color: white;
 }
.thead2 {
 background-color: #800000;
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 font-size: x-small;
 color: white;
 }
.tbody {
 text-align: center;
 background-color: #f7efde;
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 font-size: x-small;
 }
-->
</style>
</head>

<body bgcolor="White">

<%
 var iRoyalty = parseInt(Request.Form("RoyaltyValue"));
 // check user input

 if (iRoyalty > -1)
 {
 // connection and recordset variables
 var Cnxn = Server.CreateObject("ADODB.Connection")
 var strCnxn = "Provider='sqloledb';Data Source=" + Request.ServerVariables("SERVER_NAME") + ";" +
 "Initial Catalog='pubs';Integrated Security='SSPI';";
 var cmdByRoyalty = Server.CreateObject("ADODB.Command");
 var rsByRoyalty = Server.CreateObject("ADODB.Recordset");
 var rsAuthor = Server.CreateObject("ADODB.Recordset");
 // display variables
 var filter, strMessage;

 try
 {
 // open connection
 Cnxn.Open(strCnxn);

 cmdByRoyalty.CommandText = "byroyalty";
 cmdByRoyalty.CommandType = adCmdStoredProc;
 cmdByRoyalty.CommandTimeOut = 15;

 // The stored procedure called above is as follows:
 // CREATE PROCEDURE byroyalty
 // @percentage int
 // AS
 // SELECT au_id from titleauthor
 // WHERE titleauthor.royaltyper = @percentage
 // GO

 prmByRoyalty = Server.CreateObject("ADODB.Parameter");
 prmByRoyalty.Type = adInteger;
 prmByRoyalty.Size = 3;
 prmByRoyalty.Direction = adParamInput;
 prmByRoyalty.Value = iRoyalty;
 cmdByRoyalty.Parameters.Append(prmByRoyalty);

 cmdByRoyalty.ActiveConnection = Cnxn;

 // recordset by Command - Execute
 rsByRoyalty = cmdByRoyalty.Execute();

 // recordset by Recordset - Open
 rsAuthor.Open("Authors", Cnxn);

 while (!rsByRoyalty.EOF)
 {
 // set filter
 filter = "au_id='" + rsByRoyalty("au_id")
 rsAuthor.Filter = filter + "'";

 // start new line
 strMessage = "<P>";

 // get data
 strMessage += rsAuthor("au_fname") + " ";
 strMessage += rsAuthor("au_lname") + " ";

 // end line
 strMessage += "</P>";

 // show data
 Response.Write(strMessage);

 // get next record
 rsByRoyalty.MoveNext;
 }
 }
 catch (e)
 {
 Response.Write(e.message);
 }
 finally
 {
 // clean up
 if (rsByRoyalty.State == adStateOpen)
 rsByRoyalty.Close;
 if (rsAuthor.State == adStateOpen)
 rsAuthor.Close;
 if (Cnxn.State == adStateOpen)
 Cnxn.Close;
 rsByRoyalty = null;
 rsAuthor = null;
 Cnxn = null;
 }
 }
%>

<hr>

<form method="POST" action="ActiveConnectionJS.asp">
 <p align="left">Enter royalty percentage to find (e.g., 40): <input type="text" name="RoyaltyValue" size="5"></p>
 <p align="left"><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
&nbsp;

</body>

</html>
<!-- EndActiveConnectionJS -->


Image.LeftPadding Property (Access)

 Copy code hover
[image]

Image.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the image control and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .LeftPadding

expression A variable that represents an Image object.

See also

Concepts

Image Object

Other resources

Image Object Members


Form.ViewsAllowed Property (Access)

 Copy code hover
[image]

Form.ViewsAllowed Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ViewsAllowed property to specify whether users can switch between Datasheet view and Form view by clicking the Form View or Datasheet View command on the View menu or by clicking the arrow next to the View button and clicking Form View or Datasheet View. Read/write Byte.

Syntax

expression .ViewsAllowed

expression A variable that represents a Form object.

Remarks

The ViewsAllowed property uses the following settings.

Setting | Description
0 | (Default) Users can switch between Form view and Datasheet view.
1 | Users can't switch to Datasheet view from Form view.
2 | Users can't switch to Form view from Datasheet view.

The views displayed in the View button list and on the View menu depend on the setting of the ViewsAllowed property. For example, if the ViewsAllowed property is set to Datasheet, Form View is disabled in the View button list and on the View menu.

The combination of these properties creates the following conditions.

DefaultView | ViewsAllowed | Description
Single, Continuous Forms, or Datasheet | Both | Users can switch between Form view and Datasheet view.
Single or Continuous Forms | Form | Users can't switch from Form view to Datasheet view.
Single or Continuous Forms | Datasheet | Users can switch from Form view to Datasheet view but not back again.
Datasheet | Form | Users can switch from Datasheet view to Form view but not back again.
Datasheet | Datasheet | Users can't switch from Datasheet view to Form view.

Example

The following example prints a message in the Immediate window indicating the state of how users can switch between Datasheet view and Form view for the "Switchboard" form.

VBA Copy code Copy code
Debug.Print "ViewsAllowed = " & Forms.Item("Switchboard").ViewsAllowed

See also

Concepts

Form Object

Other resources

Form Object Members


Properties.Count Property (DAO)

 Copy code hover
[image]

Properties.Count Property (DAO)
See also Send feedback

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents a Properties object.

See also

Concepts

Properties Collection

Other resources

Properties Members


ObjectFrame.SizeMode Property (Access)

 Copy code hover
[image]

ObjectFrame.SizeMode Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeMode property to specify how to size a picture or other object in a bound object frame, an unbound object frame, or an image control.

Syntax

expression .SizeMode

expression A variable that represents an ObjectFrame object.

Remarks

The SizeMode property uses the following settings.

Setting | Visual Basic | Description
Clip | acOLESizeClip | (Default) Displays the object at actual size. If the object is larger than the control, its image is clipped on the right and bottom by the control's borders.
Stretch | acOLESizeStretch | Sizes the object to fill the control. This setting may distort the proportions of the object.
Zoom | acOLESizeZoom | Displays the entire object, resizing it as necessary without distorting the proportions of the object. This setting may leave extra space in the control if the control is resized.

Use the Clip setting for the fastest display. You can use the Stretch setting for bar graphs and line graphs without concern for size adjustments. The Stretch setting can distort circles and photos.

Example

The following example creates a linked OLE object using an unbound object frame named OLE1 and sizes the control to display the object's entire contents when the user clicks a command button.

VBA Copy code Copy code
Sub Command1_Click
 OLE1.Class = "Excel.Sheet" ' Set class name.
 ' Specify type of object.
 OLE1.OLETypeAllowed = acOLELinked
 ' Specify source file.
 OLE1.SourceDoc = "C:\Excel\Oletext.xls"
 ' Specify data to create link to.
 OLE1.SourceItem = "R1C1:R5C5"
 ' Create linked object.
 OLE1.Action = acOLECreateLink
 ' Adjust control size.
 OLE1.SizeMode = acOLESizeZoom
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


SubForm.Application Property (Access)

 Copy code hover
[image]

SubForm.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a SubForm object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Rectangle.OnDblClick Property (Access)

 Copy code hover
[image]

Rectangle.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Syntax

expression .OnDblClick

expression A variable that represents a Rectangle object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_DblClick" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


Container.Properties Property (DAO)

 Copy code hover
[image]

Container.Properties Property (DAO)
Send feedback

Returns the Properties collection of the specified object. Read-only.

Syntax

expression .Properties

expression A variable that represents a Container object.


Operations.Parent Property (Access)

 Copy code hover
[image]

Operations.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Parent

expression A variable that represents an Operations object.

See also

Concepts

Operations Collection

Other resources

Operations Object Members


DoCmd.RunMacro Method (Access)

 Copy code hover
[image]

DoCmd.RunMacro Method (Access)
See also Send feedback

Published: July 16, 2012

The RunMacro method carries out the RunMacro action in Visual Basic.

Syntax

expression .RunMacro(MacroName, RepeatCount, RepeatExpression)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
MacroName | Required | Variant | A string expression that's the valid name of a macro in the current database. If you run Visual Basic code containing the RunMacro method in a library database, Microsoft Access looks for the macro with this name in the library database and doesn't look for it in the current database.
RepeatCount | Optional | Variant | A numeric expression that evaluates to an integer, which is the number of times the macro will run.
RepeatExpression | Optional | Variant | A numeric expression that's evaluated each time the macro runs. When it evaluates to False (0), the macro stops running.

Remarks

You can use the RunMacro method to run a macro.

You can use macrogroupname.macroname syntax for the macroname argument to run a particular macro in a macro group.

If you specify the repeatexpression argument and leave the repeatcount argument blank, you must include the repeatcount argument's comma. If you leave a trailing argument blank, don't use a comma following the last argument you specify.

Example

The following example runs the macro Print Sales that will print the sales report twice:

VBA Copy code Copy code
DoCmd.RunMacro "Print Sales", 2

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


TextBox.ThemeFontIndex Property (Access)

 Copy code hover
[image]

TextBox.ThemeFontIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ThemeFontIndex

expression A variable that represents a TextBox object.

Remarks

The ThemeFontIndex property uses one of the values listed in the following table.

Value | Description
0 | Header font
1 (Default) | Detail font

If no theme is applied, the ThemeFontIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Could not create index; too many indexes already defined. (Error 3039)

 Copy code hover
[image]

Could not create index; too many indexes already defined. (Error 3039)
Send feedback

You cannot create another index for this table. Consider deleting an existing index to make room for the new index. The limit is 32 indexes per table.


ErrorValueEnum

 Copy code hover
[image]

ErrorValueEnum
Send feedback

Specifies the type of ADO run-time error.

Three forms of the error number are listed:

  • Positive decimal — the low two bytes of the full number in decimal format. This number is displayed in the default Visual Basic error message dialog box. For example, Run-time error '3707'.

  • Negative decimal — The decimal translation of the full error number.

  • Hexadecimal — The hexadecimal representation of the full error number. The Windows facility code is in the fourth digit. The facility code for ADO error numbers is A. For example: 0x800A0E7B.

Note Note

OLE DB errors may be passed to your ADO application. Typically, these can be identified by a Windows facility code of 4. For example, 0x8004.... For more information about these numbers, see Chapter 16 of the OLE DB Programmer's Reference.

Constant | Value | Description
adErrBoundToCommand | 3707 -2146824581 0x800A0E7B | Cannot change the ActiveConnection property of a Recordset object which has a Command object as its source.
adErrCannotComplete | 3732 -2146824556 0x800A0E94 | Server cannot complete the operation.
adErrCantChangeConnection | 3748 -2146824540 0x800A0EA4 | Connection was denied. New connection you requested has different characteristics than the one already in use.
adErrCantChangeProvider | 3220 -2146825068 0X800A0C94 | Supplied provider is different from the one already in use.
adErrCantConvertvalue | 3724 -2146824564 0x800A0E8C | Data value cannot be converted for reasons other than sign mismatch or data overflow. For example, conversion would have truncated data.
adErrCantCreate | 3725 -2146824563 0x800A0E8D | Data value cannot be set or retrieved because the field data type was unknown, or the provider had insufficient resources to perform the operation.
adErrCatalogNotSet | 3747 -2146824541 0x800A0EA3 | Operation requires a valid ParentCatalog.
adErrColumnNotOnThisRow | 3726 -2146824562 0x800A0E8E | Record does not contain this field.
adErrDataConversion | 3421 -2146824867 0x800A0D5D | Application uses a value of the wrong type for the current operation.
adErrDataOverflow | 3721 -2146824567 0x800A0E89 | Data value is too large to be represented by the field data type.
adErrDelResOutOfScope | 3738 -2146824550 0x800A0E9A | URL of the object to be deleted is outside the scope of the current record.
adErrDenyNotSupported | 3750 -2146824538 0x800A0EA6 | Provider does not support sharing restrictions.
adErrDenyTypeNotSupported | 3751 -2146824537 0x800A0EA7 | Provider does not support the requested kind of sharing restriction.
adErrFeatureNotAvailable | 3251 -2146825037 0x800A0CB3 | Object or provider is not capable of performing requested operation.
adErrFieldsUpdateFailed | 3749 -2146824539 0x800A0EA5 | Fields update failed. For further information, examine the Status property of individual field objects.
adErrIllegalOperation | 3219 -2146825069 0x800A0C93 | Operation is not allowed in this context.
adErrIntegrityViolation | 3719 -2146824569 0x800A0E87 | Data value conflicts with the integrity constraints of the field.
adErrInTransaction | 3246 -2146825042 0x800A0CAE | Connection object cannot be explicitly closed while in a transaction.
adErrInvalidArgument | 3001 -2146825287 0x800A0BB9 | Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
adErrInvalidConnection | 3709 -2146824579 0x800A0E7D | The connection cannot be used to perform this operation. It is either closed or invalid in this context.
adErrInvalidParamInfo | 3708 -2146824580 0x800A0E7C | Parameter object is improperly defined. Inconsistent or incomplete information was provided.
adErrInvalidTransaction | 3714 -2146824574 0x800A0E82 | Coordinating transaction is invalid or has not started.
adErrInvalidURL | 3729 -2146824559 0x800A0E91 | URL contains invalid characters. Make sure the URL is typed correctly.
adErrItemNotFound | 3265 -2146825023 0x800A0CC1 | Item cannot be found in the collection corresponding to the requested name or ordinal.
adErrNoCurrentRecord | 3021 -2146825267 0x800A0BCD | Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
adErrNotExecuting | 3715 -2146824573 0x800A0E83 | Operation cannot be performed while not executing.
adErrNotReentrant | 3710 -2146824578 0x800A0E7E | Operation cannot be performed while processing event.
adErrObjectClosed | 3704 -2146824584 0x800A0E78 | Operation is not allowed when the object is closed.
adErrObjectInCollection | 3367 -2146824921 0x800A0D27 | Object is already in collection. Cannot append.
adErrObjectNotSet | 3420 -2146824868 0x800A0D5C | Object is no longer valid.
adErrObjectOpen | 3705 -2146824583 0x800A0E79 | Operation is not allowed when the object is open.
adErrOpeningFile | 3002 -2146825286 0x800A0BBA | File could not be opened.
adErrOperationCancelled | 3712 -2146824576 0x800A0E80 | Operation has been cancelled by the user.
adErrOutOfSpace | 3734 -2146824554 0x800A0E96 | Operation cannot be performed. Provider cannot obtain enough storage space.
adErrPermissionDenied | 3720 -2146824568 0x800A0E88 | Insufficent permission prevents writing to the field.
adErrProviderFailed | 3000 -2146825288 0x800A0BB8 | Provider failed to perform the requested operation.
adErrProviderNotFound | 3706 -2146824582 0x800A0E7A | Provider cannot be found. It may not be properly installed.
adErrReadFile | 3003 -2146825285 0x800A0BBB | File could not be read.
adErrResourceExists | 3731 -2146824557 0x800A0E93 | Copy operation cannot be performed. Object named by destination URL already exists. Specify adCopyOverwrite to replace the object.
adErrResourceLocked | 3730 -2146824558 0x800A0E92 | Object represented by the specified URL is locked by one or more other processes. Wait until the process has finished and attempt the operation again.
adErrResourceOutOfScope | 3735 -2146824553 0x800A0E97 | Source or destination URL is outside the scope of the current record.
adErrSchemaViolation | 3722 -2146824566 0x800A0E8A | Data value conflicts with the data type or constraints of the field.
adErrSignMismatch | 3723 -2146824565 0x800A0E8B | Conversion failed because the data value was signed and the field data type used by the provider was unsigned.
adErrStillConnecting | 3713 -2146824575 0x800A0E81 | Operation cannot be performed while connecting aynchronously.
adErrStillExecuting | 3711 -2146824577 0x800A0E7F | Operation cannot be performed while executing asynchronously.
adErrTreePermissionDenied | 3728 -2146824560 0x800A0E90 | Permissions are insufficient to access tree or subtree.
adErrUnavailable | 3736 -2146824552 0x800A0E98 | Operation failed to complete and the status is unavailable. The field may be unavailable or the operation was not attempted.
adErrUnsafeOperation | 3716 -2146824572 0x800A0E84 | Safety settings on this computer prohibit accessing a data source on another domain.
adErrURLDoesNotExist | 3727 -2146824561 0x800A0E8F | Either the source URL or the parent of the destination URL does not exist.
adErrURLNamedRowDoesNotExist | 3737 -2146824551 0x800A0E99 | Record named by this URL does not exist.
adErrVolumeNotFound | 3733 -2146824555 0x800A0E95 | Provider cannot locate the storage device indicated by the URL. Make sure the URL is typed correctly.
adErrWriteFile | 3004 -2146825284 0x800A0BBC | Write to file failed.
adWrnSecurityDialog | 3717 -2146824571 0x800A0E85 | For internal use only. Don't use.
adWrnSecurityDialogHeader | 3718 -2146824570 0x800A0E86 | For internal use only. Don't use.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Only the following subsets of ADO/WFC equivalents are defined.

Constant

AdoEnums.ErrorValue.BOUNDTOCOMMAND

AdoEnums.ErrorValue.DATACONVERSION

AdoEnums.ErrorValue.FEATURENOTAVAILABLE

AdoEnums.ErrorValue.ILLEGALOPERATION

AdoEnums.ErrorValue.INTRANSACTION

AdoEnums.ErrorValue.INVALIDARGUMENT

AdoEnums.ErrorValue.INVALIDCONNECTION

AdoEnums.ErrorValue.INVALIDPARAMINFO

AdoEnums.ErrorValue.ITEMNOTFOUND

AdoEnums.ErrorValue.NOCURRENTRECORD

AdoEnums.ErrorValue.NOTEXECUTING

AdoEnums.ErrorValue.NOTREENTRANT

AdoEnums.ErrorValue.OBJECTCLOSED

AdoEnums.ErrorValue.OBJECTINCOLLECTION

AdoEnums.ErrorValue.OBJECTNOTSET

AdoEnums.ErrorValue.OBJECTOPEN

AdoEnums.ErrorValue.OPERATIONCANCELLED

AdoEnums.ErrorValue.PROVIDERNOTFOUND

AdoEnums.ErrorValue.STILLCONNECTING

AdoEnums.ErrorValue.STILLEXECUTING

AdoEnums.ErrorValue.UNSAFEOPERATION


Need a version 4.x or greater format system database to perform this operation. (Error 3808)

 Copy code hover
[image]

Need a version 4.x or greater format system database to perform this operation. (Error 3808)
Send feedback

When using the Microsoft OLE DB Provider for Jet with security, it is necssary that the security database be in a Jet version 4.x file format. This can be done by compacting the existing security database or by creating a new one through the Microsoft OLE DB Provider for Jet.


Syntax error in UPDATE statement. (Error 3144)

 Copy code hover
[image]

Syntax error in UPDATE statement. (Error 3144)
Send feedback

You entered an SQL statement that has an invalid UPDATE statement.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


Same table

 Copy code hover
[image]

Same table <table> referenced as both the source and destination in a make-table query. (Error 3610)
Send feedback

One of the source tables in a SELECT INTO statement is also named as the destination table. Either remove the table from the source tables or rename the destination table.


Reserved Words (Access 2013 custom web app)

 Copy code hover
[image]

Reserved Words (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Microsoft Access uses reserved keywords for defining, manipulating, and accessing databases. Reserved keywords are part of the grammar of the language that is used by Access to parse and understand SQL statements.

Reserved Keywords

The following table lists Access reserved keywords.

ADD | FILLFACTOR | Quarter
ALL | Float | RAISERROR
ALTER | FOR | READ
AND | FOREIGN | READTEXT
ANY | FREETEXT | RECONFIGURE
AS | FREETEXTTABLE | REFERENCES
ASC | FROM | REPLICATION
AUTHORIZATION | FULL | RESTORE
BACKUP | FUNCTION | RESTRICT
BEGIN | GOTO | RETURN
BETWEEN | GRANT | REVERT
BREAK | GROUP | REVOKE
BROWSE | HAVING | RIGHT
BULK | HOLDLOCK | ROLLBACK
BY | Hour | ROWCOUNT
CASCADE | IDENTITY | ROWGUIDCOL
CASE | IDENTITY_INSERT | RULE
CHECK | IDENTITYCOL | SAVE
CHECKPOINT | IF | SCHEMA
CLOSE | IN | Second
CLUSTERED | INDEX | SECURITYAUDIT
COALESCE | INNER | SELECT
COLLATE | INSERT | SEMANTICKEYPHRASETABLE
COLUMN | Integer | SEMANTICSIMILARITYDETAILSTABLE
COMMIT | INTERSECT | SEMANTICSIMILARITYTABLE
COMPUTE | INTO | SESSION_USER
CONSTRAINT | IS | SET
CONTAINS | ISO_Week | SETUSER
CONTAINSTABLE | JOIN | ShortText
CONTINUE | KEY | SHUTDOWN
CONVERT | KILL | SOME
CREATE | LEFT | STATISTICS
CROSS | LIKE | SYSTEM_USER
Currency | LINENO | TABLE
CURRENT | LOAD | TABLESAMPLE
CURRENT_DATE | LongText | Text
CURRENT_TIME | MERGE | TEXTSIZE
CURRENT_TIMESTAMP | Millisecond | THEN
CURRENT_USER | Minute | Time
CURSOR | Month | TO
DATABASE | NATIONAL | TOP
Date | No | TRAN
DateWithTime | NOCHECK | TRANSACTION
Day | NONCLUSTERED | TRIGGER
DayofYear | NOT | TRUNCATE
DBCC | NULL | TRY_CONVERT
DEALLOCATE | NULLIF | TSEQUAL
DECLARE | OF | UNION
DEFAULT | OFF | UNIQUE
DELETE | OFFSETS | UNPIVOT
DENY | ON | UPDATE
DESC | OPEN | UPDATETEXT
DISK | OPENDATASOURCE | USE
DISTINCT | OPENQUERY | USER
DISTRIBUTED | OPENROWSET | VALUES
DOUBLE | OPENXML | VARYING
DROP | OPTION | VIEW
DUMP | OR | WAITFOR
ELSE | ORDER | Week
END | OUTER | Weekday
ERRLVL | OVER | WHEN
ESCAPE | PERCENT | WHERE
EXCEPT | PIVOT | WHILE
EXEC | PLAN | WITH
EXECUTE | PRECISION | WITHIN GROUP
EXISTS | PRIMARY | WRITETEXT
EXIT | PRINT | Year
EXTERNAL | PROC | Yes
FETCH | PROCEDURE | YesNo
FILE | PUBLIC |

Additionally, the ISO standard defines a list of reserved keywords. Avoid using ISO reserved keywords for object names and identifiers. The ODBC reserved keyword list, shown in the following table, is the same as the ISO reserved keyword list.

ODBC Reserved Keywords

The following words are reserved for use in ODBC function calls. These words do not constrain the minimum SQL grammar; however, to ensure compatibility with drivers that support the core SQL grammar, applications should avoid using these keywords.

This is the current list of ODBC reserved keywords.

ABSOLUTE | EXEC | OVERLAPS
ACTION | EXECUTE | PAD
ADA | EXISTS | PARTIAL
ADD | EXTERNAL | PASCAL
ALL | EXTRACT | POSITION
ALLOCATE | FALSE | PRECISION
ALTER | FETCH | PREPARE
AND | FIRST | PRESERVE
ANY | FLOAT | PRIMARY
ARE | FOR | PRIOR
AS | FOREIGN | PRIVILEGES
ASC | FORTRAN | PROCEDURE
ASSERTION | FOUND | PUBLIC
AT | FROM | READ
AUTHORIZATION | FULL | REAL
AVG | GET | REFERENCES
BEGIN | GLOBAL | RELATIVE
BETWEEN | GO | RESTRICT
BIT | GOTO | REVOKE
BIT_LENGTH | GRANT | RIGHT
BOTH | GROUP | ROLLBACK
BY | HAVING | ROWS
CASCADE | HOUR | SCHEMA
CASCADED | IDENTITY | SCROLL
CASE | IMMEDIATE | SECOND
CAST | IN | SECTION
CATALOG | INCLUDE | SELECT
CHAR | INDEX | SESSION
CHAR_LENGTH | INDICATOR | SESSION_USER
CHARACTER | INITIALLY | SET
CHARACTER_LENGTH | INNER | SIZE
CHECK | INPUT | SMALLINT
CLOSE | INSENSITIVE | SOME
COALESCE | INSERT | SPACE
COLLATE | INT | SQL
COLLATION | INTEGER | SQLCA
COLUMN | INTERSECT | SQLCODE
COMMIT | INTERVAL | SQLERROR
CONNECT | INTO | SQLSTATE
CONNECTION | IS | SQLWARNING
CONSTRAINT | ISOLATION | SUBSTRING
CONSTRAINTS | JOIN | SUM
CONTINUE | KEY | SYSTEM_USER
CONVERT | LANGUAGE | TABLE
CORRESPONDING | LAST | TEMPORARY
COUNT | LEADING | THEN
CREATE | LEFT | TIME
CROSS | LEVEL | TIMESTAMP
CURRENT | LIKE | TIMEZONE_HOUR
CURRENT_DATE | LOCAL | TIMEZONE_MINUTE
CURRENT_TIME | LOWER | TO
CURRENT_TIMESTAMP | MATCH | TRAILING
CURRENT_USER | MAX | TRANSACTION
CURSOR | MIN | TRANSLATE
DATE | MINUTE | TRANSLATION
DAY | MODULE | TRIM
DEALLOCATE | MONTH | TRUE
DEC | NAMES | UNION
DECIMAL | NATIONAL | UNIQUE
DECLARE | NATURAL | UNKNOWN
DEFAULT | NCHAR | UPDATE
DEFERRABLE | NEXT | UPPER
DEFERRED | NO | USAGE
DELETE | NONE | USER
DESC | NOT | USING
DESCRIBE | NULL | VALUE
DESCRIPTOR | NULLIF | VALUES
DIAGNOSTICS | NUMERIC | VARCHAR
DISCONNECT | OCTET_LENGTH | VARYING
DISTINCT | OF | VIEW
DOMAIN | ON | WHEN
DOUBLE | ONLY | WHENEVER
DROP | OPEN | WHERE
ELSE | OPTION | WITH
END | OR | WORK
END-EXEC | ORDER | WRITE
ESCAPE | OUTER | YEAR
EXCEPT | OUTPUT | ZONE
EXCEPTION |  |

Future Keywords

The following keywords could be reserved in future releases of SQL Server as new features are implemented. Consider avoiding the use of these words as identifiers.

ABSOLUTE | HOST | RELATIVE
ACTION | HOUR | RELEASE
ADMIN | IGNORE | RESULT
AFTER | IMMEDIATE | RETURNS
AGGREGATE | INDICATOR | ROLE
ALIAS | INITIALIZE | ROLLUP
ALLOCATE | INITIALLY | ROUTINE
ARE | INOUT | ROW
ARRAY | INPUT | ROWS
ASENSITIVE | INT | SAVEPOINT
ASSERTION | INTEGER | SCROLL
ASYMMETRIC | INTERSECTION | SCOPE
AT | INTERVAL | SEARCH
ATOMIC | ISOLATION | SECOND
BEFORE | ITERATE | SECTION
BINARY | LANGUAGE | SENSITIVE
BIT | LARGE | SEQUENCE
BLOB | LAST | SESSION
BOOLEAN | LATERAL | SETS
BOTH | LEADING | SIMILAR
BREADTH | LESS | SIZE
CALL | LEVEL | SMALLINT
CALLED | LIKE_REGEX | SPACE
CARDINALITY | LIMIT | SPECIFIC
CASCADED | LN | SPECIFICTYPE
CAST | LOCAL | SQL
CATALOG | LOCALTIME | SQLEXCEPTION
CHAR | LOCALTIMESTAMP | SQLSTATE
CHARACTER | LOCATOR | SQLWARNING
CLASS | MAP | START
CLOB | MATCH | STATE
COLLATION | MEMBER | STATEMENT
COLLECT | METHOD | STATIC
COMPLETION | MINUTE | STDDEV_POP
CONDITION | MOD | STDDEV_SAMP
CONNECT | MODIFIES | STRUCTURE
CONNECTION | MODIFY | SUBMULTISET
CONSTRAINTS | MODULE | SUBSTRING_REGEX
CONSTRUCTOR | MONTH | SYMMETRIC
CORR | MULTISET | SYSTEM
CORRESPONDING | NAMES | TEMPORARY
COVAR_POP | NATURAL | TERMINATE
COVAR_SAMP | NCHAR | THAN
CUBE | NCLOB | TIME
CUME_DIST | NEW | TIMESTAMP
CURRENT_CATALOG | NEXT | TIMEZONE_HOUR
CURRENT_DEFAULT_TRANSFORM_GROUP | NO | TIMEZONE_MINUTE
CURRENT_PATH | NONE | TRAILING
CURRENT_ROLE | NORMALIZE | TRANSLATE_REGEX
CURRENT_SCHEMA | NUMERIC | TRANSLATION
CURRENT_TRANSFORM_GROUP_FOR_TYPE | OBJECT | TREAT
CYCLE | OCCURRENCES_REGEX | TRUE
DATA | OLD | UESCAPE
DATE | ONLY | UNDER
DAY | OPERATION | UNKNOWN
DEC | ORDINALITY | UNNEST
DECIMAL | OUT | USAGE
DEFERRABLE | OVERLAY | USING
DEFERRED | OUTPUT | VALUE
DEPTH | PAD | VAR_POP
DEREF | PARAMETER | VAR_SAMP
DESCRIBE | PARAMETERS | VARCHAR
DESCRIPTOR | PARTIAL | VARIABLE
DESTROY | PARTITION | WHENEVER
DESTRUCTOR | PATH | WIDTH_BUCKET
DETERMINISTIC | POSTFIX | WITHOUT
DICTIONARY | PREFIX | WINDOW
DIAGNOSTICS | PREORDER | WITHIN
DISCONNECT | PREPARE | WORK
DOMAIN | PERCENT_RANK | WRITE
DYNAMIC | PERCENTILE_CONT | XMLAGG
EACH | PERCENTILE_DISC | XMLATTRIBUTES
ELEMENT | POSITION_REGEX | XMLBINARY
END-EXEC | PRESERVE | XMLCAST
EQUALS | PRIOR | XMLCOMMENT
EVERY | PRIVILEGES | XMLCONCAT
EXCEPTION | RANGE | XMLDOCUMENT
FALSE | READS | XMLELEMENT
FILTER | REAL | XMLEXISTS
FIRST | RECURSIVE | XMLFOREST
FLOAT | REF | XMLITERATE
FOUND | REFERENCING | XMLNAMESPACES
FREE | REGR_AVGX | XMLPARSE
FULLTEXTTABLE | REGR_AVGY | XMLPI
FUSION | REGR_COUNT | XMLQUERY
GENERAL | REGR_INTERCEPT | XMLSERIALIZE
GET | REGR_R2 | XMLTABLE
GLOBAL | REGR_SLOPE | XMLTEXT
GO | REGR_SXX | XMLVALIDATE
GROUPING | REGR_SXY | YEAR
HOLD | REGR_SYY | ZONE


Attachment.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

Attachment.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified attachment. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthLeft

expression A variable that represents an Attachment object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


TextBox.TextAlign Property (Access)

 Copy code hover
[image]

TextBox.TextAlign Property (Access)
See also Send feedback

Published: July 16, 2012

The TextAlign property specifies the text alignment in new controls. Read/write Byte.

Syntax

expression .TextAlign

expression A variable that represents a TextBox object.

Remarks

The TextAlign property uses the following settings.

Setting | Visual Basic | Description
General | 0 | (Default) The text aligns to the left; numbers and dates align to the right.
Left | 1 | The text, numbers, and dates align to the left.
Center | 2 | The text, numbers, and dates are centered.
Right | 3 | The text, numbers, and dates align to the right.
Distribute | 4 | The text, numbers, and dates are evenly distributed.

You can set the default for the TextAlign property by using a control's default control style or the DefaultControl property in Visual Basic.

Example

The following example aligns the text in the "Address" text box on the "Suppliers" form to the right.

VBA Copy code Copy code
Forms("Suppliers").Controls("Address").TextAlign = 3

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Application.ReturnVars Property (Access)

 Copy code hover
[image]

Application.ReturnVars Property (Access)
Send feedback

Published: July 16, 2012

Returns the ReturnVars collection representing all the available ReturnVar variables. Read-only ReturnVars collection.

Version Information

Version Added: Access 2010

Syntax

expression .ReturnVars

expression A variable that represents an Application object.

Property value

RETURNVARS


AcHorizontalAnchor Enumeration (Access)

 Copy code hover
[image]

AcHorizontalAnchor Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the HorizontalAnchor property to specify how a control is anchored horizontally within its layout.

Version Information

Version Added: Access 2007

Name | Value | Description
acHorizontalAnchorBoth | 2 | The control is stretched horizontally across its layout.
acHorizontalAnchorLeft | 0 | The control is anchored to the left side of its layout.
acHorizontalAnchorRight | 1 | The control is anchored to the right side of its layout.


Report.OnDeactivate Property (Access)

 Copy code hover
[image]

Report.OnDeactivate Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Deactivate box in the Properties window of a form or report. Read/write String.

Syntax

expression .OnDeactivate

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Deactivate event occurs when the form or report loses the focus to a Table, Query, Form, Report, Macro, or Module window, or to the Database window.

The OnDeactivate value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Deactivate box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Deactivate box is blank, the property value is an empty string.

Example

The following example associates the Deactivate event with the macro "Deactivate_Macro" for the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").OnDeactivate = "Deactivate_Macro"

See also

Concepts

Report Object

Other resources

Report Object Members


Disk full for path

 Copy code hover
[image]

Disk full for path <name>. (Error 3472)
Send feedback

Remove files from the disk drive to free up space.


How to: Filter a Report Using a Form's Filter

 Copy code hover
[image]

How to: Filter a Report Using a Form's Filter
Send feedback

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 property as the value of the OpenReport method's WhereCondition argument.

VBA Copy code Copy code
Private Sub cmdOpenReport_Click()
    If Me.Filter = "" Then
        MsgBox "Apply a filter to the form first."
    Else
        DoCmd.OpenReport "rptCustomers", acViewReport, , Me.Filter
    End If
End Sub


ADORecordsetConstruction Interface (ADO)

 Copy code hover
[image]

ADORecordsetConstruction Interface (ADO)
Send feedback

The ADORecordsetConstruction interface is used to construct an ADO Recordset object from an OLE DB Rowset object in a C/C++ application.

This interface supports the following properties:

Properties

Chapter | Read/Write. Gets/sets an OLE DB Chapter object from/on this ADO Recordset object.
RowPosition | Read/Write. Gets/sets an OLE DB RowPosition object from/on this ADO Recordset object.
Rowset | Read/Write. Gets/sets an OLE DB Rowset object from/on this ADO Recordset object.

Methods

None.

Events

None.

Remarks

Given an OLE DB Rowset object (pRowset ), the construction of an ADO Recordset object (), the construction of an ADO Recordset object (adoRs ) amounts to the following three basic operations:

  1. Create an ADO Recordset object:

    Copy code Copy code
    Recordset20Ptr adoRs;
adoRs.CreateInstance(__uuidof(Recordset));

  2. Query the IADORecordsetConstruction interface on the Recordset object:

    Copy code Copy code
    adoRecordsetConstructionPtr adoRsConstruct=NULL;
adoRs->QueryInterface(__uuidof(ADORecordsetConstruction),
                     (void**)&adoRsConstruct);

  3. Call the IADORecordsetConstruction::put_Rowset property method to set the OLE DB Rowset object on the ADO Recordset object:

    Copy code Copy code
    IUnknown *pUnk=NULL;
pRowset->QueryInterface(IID_IUnknown, (void**)&pUnk);
adoRsConstruct->put_Rowset(pUnk);

The resultant object now represents the ADO Recordset object constructed from the OLE DB Rowset object.

You can also construct an ADO Recordset object from an OLE DB Chapter or RowPosition object.

Requirements

Version: ADO 2.0 and later

Library: msado15.dll

UUID: 00000283-0000-0010-8000-00AA006D2EA4


NavigationControl.KeyDown Event (Access)

 Copy code hover
[image]

NavigationControl.KeyDown Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Version Information

Version Added: Access 2010

Syntax

expression .KeyDown(KeyCode, Shift)

expression A variable that represents a NavigationControl object.

Parameters

Name | Required/Optional | Data Type | Description
KeyCode | Required | Integer |
Shift | Required | Integer |

Return Value

nothing

Remarks

To run a macro or event procedure when these events occur, set the OnKeyDown property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyDown event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyDown event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyDown event occurs when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

Example

The following example determines whether you have pressed the SHIFT, CTRL, or ALT key.

To try the example, add the following event procedure to a form containing a text box named KeyHandler.

VBA Copy code Copy code
Private Sub KeyHandler_KeyDown(KeyCode As Integer, _
 Shift As Integer)
 Dim intShiftDown As Integer, intAltDown As Integer
 Dim intCtrlDown As Integer

 ' Use bit masks to determine which key was pressed.
 intShiftDown = (Shift And acShiftMask) > 0
 intAltDown = (Shift And acAltMask) > 0
 intCtrlDown = (Shift And acCtrlMask) > 0
 ' Display message telling user which key was pressed.
 If intShiftDown Then MsgBox "You pressed the SHIFT key."
 If intAltDown Then MsgBox "You pressed the ALT key."
 If intCtrlDown Then MsgBox "You pressed the CTRL key."
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Unable to set a schedule for the Synchronizer. (Error 3497)

 Copy code hover
[image]

Unable to set a schedule for the Synchronizer. (Error 3497)
Send feedback

There was an internal problem setting the schedule. Try again.


Supports Method (ADO)

 Copy code hover
[image]

Supports Method (ADO)
Send feedback

Determines whether a specified Recordset object supports a particular type of functionality.

Syntax

boolean = recordset.Supports (CursorOptions)

Return Value

Returns a Boolean value that indicates whether all of the features identified by the CursorOptions argument are supported by the provider.

Parameters

  • CursorOptions

  • A Long expression that consists of one or more CursorOptionEnum values.

Remarks

Use the Supports method to determine what types of functionality a Recordset object supports. If the Recordset object supports the features whose corresponding constants are in CursorOptions, the Supports method returns True. Otherwise, it returns False.

Note Note

Although the Supports method may return True for a given functionality, it does not guarantee that the provider can make the feature available under all circumstances. The Supports method simply returns whether the provider can support the specified functionality, assuming certain conditions are met. For example, the Supports method may indicate that a Recordset object supports updates even though the cursor is based on a multiple table join, some columns of which are not updatable.


DoCmd.GoToControl Method (Access)

 Copy code hover
[image]

DoCmd.GoToControl Method (Access)
See also Send feedback

Published: July 16, 2012

The GoToControl method performs the GoToControl action action in Visual Basic.

Syntax

expression .GoToControl(ControlName)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
ControlName | Required | Variant | A string expression that is the name of a control on the active form or datasheet.

Remarks

You can use the GoToControl method to move the focus to the specified field or control in the current record of the open form, form datasheet, table datasheet, or query datasheet. You can use this method when you want a particular field or control to have the focus. This field or control can then be used for comparisons or FindRecord actions. You can also use this method to navigate in a form according to certain conditions. For example, if the user enters No in a Married control on a health insurance form, the focus can automatically skip the Spouse/partner Name control and move to the next control.

You cannot use the GoToControl method to move the focus to a control on a hidden form.

Use only the name of the control for the controlname argument, not the full syntax.

You can also use the SetFocus method to move the focus to a control on a form or any of its subforms, or to a field in an open table, query, or form datasheet. This is the preferred method for moving the focus in Visual Basic, especially to controls on subforms and nested subforms, because you can use the full syntax to specify the control you want to move to.

You can use the GoToControl method to move to a subform, which is a type of control. You can then use the GoToControl method to move to a particular record in the subform. You can also move to a control on a subform by using the GoToControl method to move first to the subform and then to the control on the subform.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Label.FontName Property (Access)

 Copy code hover
[image]

Label.FontName Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontName property to specify the font for text in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write String.

Syntax

expression .FontName

expression A variable that represents a Label object.

Remarks

The FontName property setting is the name of the font that the text is displayed in.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set this property only in an event procedure or in a macro specified by the OnPrint event property setting.

Font availability depends on your system and printer. If you select a font that your system can't display or that isn't installed, Windows substitutes a similar font.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

Label Object

Other resources

Label Object Members


WebBrowserControl.ControlTipText Property (Access)

 Copy code hover
[image]

WebBrowserControl.ControlTipText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .ControlTipText

expression A variable that represents a WebBrowserControl object.

Remarks

You set the ControlTipText property by using a string expression up to 255 characters long.

For controls on forms, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

You can set the ControlTipText property in any view.

The ControlTipText property provides an easy way to provide helpful information about controls on a form.

There are other ways to provide information about a form or a control on a form. You can use the StatusBarText property to display information in the status bar about a control. To provide more extensive help for a form or control, use the HelpFile and HelpContextID properties.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Form.OnLostFocus Property (Access)

 Copy code hover
[image]

Form.OnLostFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnLostFocus

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The LostFocus event occurs when the object loses the focus.

The OnLostFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Lost Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Lost Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnLostFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnLostFocus

See also

Concepts

Form Object

Other resources

Form Object Members


Parameters Collection Properties, Methods, and Events

 Copy code hover
[image]

Parameters Collection Properties, Methods, and Events
Send feedback

Properties

Count Property

Item Property

Methods

Append Method

Delete Method (ADO Parameters Collection)

Refresh Method

Events

None.


Module.Name Property (Access)

 Copy code hover
[image]

Module.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a Module object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

Module Object

Other resources

Module Object Members


CancelUpdate Method (ADO)

 Copy code hover
[image]

CancelUpdate Method (ADO)
Send feedback

Cancels any changes made to the current or new row of a Recordset object, or the Fields collection of a Record object, before calling the Update method.

Syntax

recordset.CancelUpdate

record.Fields.CancelUpdate

Remarks

Recordset

Use the CancelUpdate method to cancel any changes made to the current row or to discard a newly added row. You cannot cancel changes to the current row or a new row after you call the Update method, unless the changes are either part of a transaction that you can roll back with the RollbackTrans method, or part of a batch update. In the case of a batch update, you can cancel the Update with the CancelUpdate or CancelBatch method.

If you are adding a new row when you call the CancelUpdate method, the current row becomes the row that was current before the AddNew call.

If you are in edit mode and want to move off the current record (for example, with Move, NextRecordset, or Close), you can use CancelUpdate to cancel any pending changes. You may need to do this if the update cannot successfully be posted to the data source (for example, an attempted delete that fails due to referential integrity violations will leave the Recordset in edit mode after a call to Delete).

Record

The CancelUpdate method cancels any pending insertions or deletions of Field objects, and cancels pending updates of existing fields and restores them to their original values. The Status property of all fields in the Fields collection is set to adFieldOK.


Cannot update replication system column. (Error 3577)

 Copy code hover
[image]

Cannot update replication system column. (Error 3577)
Send feedback

The column you are attempting to update is a system column and is read-only.


OptionButton.Exit Event (Access)

 Copy code hover
[image]

OptionButton.Exit Event (Access)
See also Send feedback

Published: July 16, 2012

The Exit event occurs just before a control loses the focus to another control on the same form or report.

Syntax

expression .Exit(Cancel)

expression A variable that represents an OptionButton object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | Set to True to cancel the event.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when this event occurs, set the OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Exit event occurs before the LostFocus event.

Unlike the LostFocus event, the Exit event does not occur when a form loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Application.Application Property (Access)

 Copy code hover
[image]

Application.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents an Application object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

Application Object

Other resources

Application Object Members


WebBrowserControl.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

WebBrowserControl.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthLeft

expression A variable that represents a WebBrowserControl object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


FormatConditions.Application Property (Access)

 Copy code hover
[image]

FormatConditions.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a FormatConditions object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

FormatConditions Collection

Other resources

FormatConditions Object Members


Reference.BuiltIn Property (Access)

 Copy code hover
[image]

Reference.BuiltIn Property (Access)
See also Send feedback

Published: July 16, 2012

The BuiltIn property returns a Boolean value indicating whether a Reference object points to a default reference that's necessary for Microsoft Access to function properly. Read-only Boolean.

Syntax

expression .BuiltIn

expression A variable that represents a Reference object.

Remarks

The BuiltIn property is available only by using Visual Basic and is read-only.

Value | Description
True (-1) | The Reference object refers to a default reference that can't be removed.
False (0) | The Reference object refers to a nondefault reference that isn't necessary for Microsoft Access to function properly.

The default references in Microsoft Access include the Microsoft Access 12.0 object library, Microsoft Office 12.0 Access Connectivity Engine, the Visual Basic For Applications library, OLE Automation library, and Microsoft ActiveX Data Objects 2.5 library.

Example

The following example prints the default references in the References collection:

VBA Copy code Copy code
Sub ReferenceBuiltInOnly()
 Dim ref As Reference

 ' Enumerate through References collection.
 For Each ref In References
 ' Check BuiltIn property.
 If ref.BuiltIn = True Then
 Debug.Print ref.Name
 End If
 Next ref
End Sub

See also

Concepts

Reference Object

Other resources

Reference Object Members


AllTables.Application Property (Access)

 Copy code hover
[image]

AllTables.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents an AllTables object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

AllTables Collection

Other resources

AllTables Object Members


NavigationButton.BackThemeColorIndex Property (Access)

 Copy code hover
[image]

NavigationButton.BackThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackThemeColorIndex

expression A variable that represents a NavigationButton object.

Remarks

The BackThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BackThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Background Color to the Text 2 color by setting the BackThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BackThemeColorIndex=2

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


SubForm Methods (Access)

 Copy code hover
[image]

SubForm Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified subform by requerying the source of data for the subform.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.


OptionGroup.AddColon Property (Access)

 Copy code hover
[image]

OptionGroup.AddColon Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.

Syntax

expression .AddColon

expression A variable that represents an OptionGroup object.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


BoundObjectFrame.SizeMode Property (Access)

 Copy code hover
[image]

BoundObjectFrame.SizeMode Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeMode property to specify how to size a picture or other object in a bound object frame, an unbound object frame, or an image control.

Syntax

expression .SizeMode

expression A variable that represents a BoundObjectFrame object.

Remarks

The SizeMode property uses the following settings.

Setting | Visual Basic | Description
Clip | acOLESizeClip | (Default) Displays the object at actual size. If the object is larger than the control, its image is clipped on the right and bottom by the control's borders.
Stretch | acOLESizeStretch | Sizes the object to fill the control. This setting may distort the proportions of the object.
Zoom | acOLESizeZoom | Displays the entire object, resizing it as necessary without distorting the proportions of the object. This setting may leave extra space in the control if the control is resized.

Use the Clip setting for the fastest display. You can use the Stretch setting for bar graphs and line graphs without concern for size adjustments. The Stretch setting can distort circles and photos.

Example

The following example creates a linked OLE object using an unbound object frame named OLE1 and sizes the control to display the object's entire contents when the user clicks a command button.

VBA Copy code Copy code
Sub Command1_Click
 OLE1.Class = "Excel.Sheet" ' Set class name.
 ' Specify type of object.
 OLE1.OLETypeAllowed = acOLELinked
 ' Specify source file.
 OLE1.SourceDoc = "C:\Excel\Oletext.xls"
 ' Specify data to create link to.
 OLE1.SourceItem = "R1C1:R5C5"
 ' Create linked object.
 OLE1.Action = acOLECreateLink
 ' Adjust control size.
 OLE1.SizeMode = acOLESizeZoom
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


TextBox.GridlineThemeColorIndex Property (Access)

 Copy code hover
[image]

TextBox.GridlineThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineThemeColorIndex

expression A variable that represents a TextBox object.

Remarks

The GridlineThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 (Default) | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the GridlineThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Page

 Copy code hover
[image]

Page
Send feedback

Published: July 16, 2012

A Page object corresponds to an individual page on a tab control.

Each Page object can contain one or more controls, such as text boxes or option buttons. Controls on a Page object belong to that Page object's Controls collection. In order to work with a control on a Page object, you must refer to that control within the Page object's Control collection.

With the tab control, you can construct a single form or dialog box that contains several different tabs, and you can group similar options or data on each tab's page. For example, you might use a tab control on an Employees form to separate general and personal information.


Fields Object Reference (DAO)

 Copy code hover
[image]

Fields Object Reference (DAO)
Send feedback

In this section

  • Fields Collection (DAO)

  • Fields Members (DAO)

  • Fields Properties (DAO)

  • Fields Methods (DAO)


StayInSync Property (ADO)

 Copy code hover
[image]

StayInSync Property (ADO)
Send feedback

Indicates, in a hierarchical Recordset object, whether the reference to the underlying child records (that is, the chapter) changes when the parent row position changes.

Settings and Return Values

Sets or returns a Boolean value. The default value is True. If True, the chapter will be updated if the parent Recordset object changes row position; if False, the chapter will continue to refer to data in the previous chapter even though the parent Recordset object has changed row position.

Remarks

This property applies to hierarchical Recordsets, such as those supported by the Microsoft Data Shaping Service for OLE DB, and must be set on the parent Recordset before the child Recordset is retrieved. This property simplifies navigating hierarchical recordsets.


Source Property Example (VC++)

 Copy code hover
[image]

Source Property Example (VC++)
Send feedback

This example demonstrates the Source property by opening three Recordset objects based on different data sources.

Copy code Copy code

// BeginSourceCpp
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void SourceX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////
// //
// Main Function //
// //
///////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 SourceX();

 ::CoUninitialize();
}

///////////////////////////////////////////////
// //
// SourceX Function //
// //
///////////////////////////////////////////////
void SourceX(void)
{
 HRESULT hr = S_OK;

 // Define string variables.
 _bstr_t strCmdSQL("Select title,type,pubdate "
 "FROM titles ORDER BY title");
 _bstr_t strSQL("SELECT title_ID AS TitleID, title AS Title, "
 "publishers.pub_id AS PubID, pub_name AS PubName "
 "FROM publishers INNER JOIN titles "
 "ON publishers.pub_id = titles.pub_id "
 "ORDER BY Title");
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _ConnectionPtr pConnection = NULL;
 _RecordsetPtr pRstTitles = NULL;
 _RecordsetPtr pRstPublishers = NULL;
 _RecordsetPtr pRstPublishersDirect = NULL;
 _RecordsetPtr pRstTitlesPublishers = NULL;
 _CommandPtr pCmdSQL = NULL;

 try
 {
 // Open a connection.
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
 pConnection->Open (strCnn, "", "", adConnectUnspecified);

 // Open a recordset based on a command object.
 TESTHR(pCmdSQL.CreateInstance(__uuidof(Command)));
 pCmdSQL->ActiveConnection = pConnection;
 pCmdSQL->CommandText = strCmdSQL;
 pRstTitles = pCmdSQL->Execute(NULL,NULL,adCmdText);

 // Open a recordset based on a a table
 TESTHR(pRstPublishers.CreateInstance(__uuidof(Recordset)));
 pRstPublishers->Open ("publishers",
 _variant_t((IDispatch *) pConnection, true),
 adOpenForwardOnly, adLockReadOnly, adCmdTable);

 // Open a recordset based on a table
 TESTHR(pRstPublishersDirect.CreateInstance(
 __uuidof(Recordset)));
 pRstPublishersDirect->Open ("publishers",
 _variant_t((IDispatch *) pConnection, true),
 adOpenForwardOnly, adLockReadOnly, adCmdTableDirect);

 // Open a recordset based on a SQL string.
 TESTHR(pRstTitlesPublishers.CreateInstance(
 __uuidof(Recordset)));
 pRstTitlesPublishers->Open(strSQL,
 _variant_t((IDispatch *) pConnection, true),
 adOpenForwardOnly, adLockReadOnly, adCmdText);

 // Use the Source property to display the source of
 // each recordset.
 printf("rstTitles source: \n%s\n\n",
 (LPCSTR)(_bstr_t) pRstTitles->GetSource().bstrVal);
 printf("rstPublishers source: \n%s\n\n",
 (LPCSTR)(_bstr_t) pRstPublishers->GetSource().bstrVal);
 printf("rstPublishersDirect source: \n%s\n\n",
 (LPCSTR)(_bstr_t) pRstPublishersDirect->GetSource().bstrVal);
 printf("rstTitlesPublishers source: \n%s\n\n",
 (LPCSTR)(_bstr_t) pRstTitlesPublishers->GetSource().bstrVal);
 }
 catch (_com_error &e)
 {
 // Notify the user of errors if any.
 PrintProviderError(pConnection);
 PrintComError(e);
 }

 if (pRstTitles)
 if (pRstTitles->State == adStateOpen)
 pRstTitles->Close();
 if (pRstPublishers)
 if (pRstPublishers->State == adStateOpen)
 pRstPublishers->Close();
 if (pRstPublishersDirect)
 if (pRstPublishersDirect->State == adStateOpen)
 pRstPublishersDirect->Close();
 if (pRstTitlesPublishers)
 if (pRstTitlesPublishers->State == adStateOpen)
 pRstTitlesPublishers->Close();
 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

///////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////
void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

///////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////
void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);

}
// EndSourceCpp


Customization File SQL Section

 Copy code hover
[image]

Customization File SQL Section
Send feedback

The sql section can contain a new SQL string that replaces the client command string. If there is no SQL string in the section, the section will be ignored.

The new SQL string may be parameterized. That is, parameters in the sql section SQL string (designated by the '?' character) can be replaced by corresponding arguments in an identifier in the client command string (designated by a comma-delimited list in parentheses). The identifier and argument list behave like a function call.

For example, assume the client command string is "CustomerByID(4)" , the SQL section header is [SQL CustomerByID] , and the new SQL section string is "SELECT * FROM Customers WHERE CustomerID = ?". The Handler will generate , the SQL section header is [SQL CustomerByID] , and the new SQL section string is "SELECT * FROM Customers WHERE CustomerID = ?". The Handler will generate "SELECT * FROM Customers WHERE CustomerID = 4" and use that string to query the data source.

If the new SQL statement is the null string (""), then the section is ignored.

If the new SQL statement string is not valid, then the execution of the statement will fail. The client parameter is effectively ignored. You can do this intentionally to "turn off" all client SQL commands by specifying:

Copy code Copy code

[SQL default]
SQL = " "

Syntax

A replacement SQL string entry is of the form:

SQL=sqlString

Part | Description
SQL | A literal string that indicates this is an SQL section entry.
sqlString | An SQL string that replaces the client string.


Label.SpecialEffect Property (Access)

 Copy code hover
[image]

Label.SpecialEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.

Syntax

expression .SpecialEffect

expression A variable that represents a Label object.

Remarks

The SpecialEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | 0 | The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised | 1 | The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken | 2 | The object has a shadow on the top and left and a highlight on the bottom and right.
Etched | 3 | The object has a sunken line surrounding the control.
Shadowed | 4 | The object has a shadow below and to the right of the control.
Chiseled | 5 | The object has a sunken line below the control.

The SpecialEffect property setting affects related property settings for the BorderStyle , BorderColor , and BorderWidth properties. For example, if the SpecialEffect property is set to Raised, the settings for the BorderStyle, BorderColor, and BorderWidth properties are ignored. In addition, changing or setting the BorderStyle, BorderColor, and BorderWidth properties may cause Microsoft Access to change the SpecialEffect property setting to Flat.

Example

The following example sets the appearance of the text box "OrganizationName1" on the "Mailing List" form to raised.

VBA Copy code Copy code
Forms("Mailing List").Controls("OrganizationName1").SpecialEffect = 1

See also

Concepts

Label Object

Other resources

Label Object Members


Invalid scale for decimal data type. (Error 3701)

 Copy code hover
[image]

Invalid scale for decimal data type. (Error 3701)
Send feedback

The scale of a DECIMAL data type must always be less or equal to the precision. For example, the following SQL statement would return this error: CREATE TABLE foo (foo DECIMAL(10,12));


SharedResource.Parent Property (Access)

 Copy code hover
[image]

SharedResource.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Parent

expression A variable that represents a SharedResource object.

See also

Concepts

SharedResource Object

Other resources

SharedResource Object Members


Operations Object (Access)

 Copy code hover
[image]

Operations Object (Access)
See also Send feedback

Published: July 16, 2012

Represents the collection of operations defined for an Entity.

Version Information

Version Added: Access 2010

Remarks

Use the Operations property of the Entity object to return the collection of operations for an entity.

See also

Concepts

Access Object Model Reference

Other resources

Operations Object Members


Primary key already exists. (Error 3283)

 Copy code hover
[image]

Primary key already exists. (Error 3283)
Send feedback

You are attempting to define a second primary key for this table. Each table can have only one primary key. Remove the reference to the second primary key.


OptionGroup.Exit Event (Access)

 Copy code hover
[image]

OptionGroup.Exit Event (Access)
See also Send feedback

Published: July 16, 2012

The Exit event occurs just before a control loses the focus to another control on the same form or report.

Syntax

expression .Exit(Cancel)

expression A variable that represents an OptionGroup object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | Set to True to cancel the event.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when this event occurs, set the OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Exit event occurs before the LostFocus event.

Unlike the LostFocus event, the Exit event does not occur when a form loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


SmartTagProperty.Name Property (Access)

 Copy code hover
[image]

SmartTagProperty.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a SmartTagProperty object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

SmartTagProperty Object

Other resources

SmartTagProperty Object Members


ListBox.VerticalAnchor Property (Access)

 Copy code hover
[image]

ListBox.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified list box is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .VerticalAnchor

expression A variable that represents a ListBox object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


GroupLevel.SortOrder Property (Access)

 Copy code hover
[image]

GroupLevel.SortOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You use the SortOrder property to specify the sort order for fields and expressions in a report. For example, if you're printing a list of suppliers, you can sort the records alphabetically by company name. Read/write Boolean.

Syntax

expression .SortOrder

expression A variable that represents a GroupLevel object.

Remarks

The SortOrder property uses the following settings.

Setting | Visual Basic | Description
Ascending | False | (Default) Sorts values in ascending (A to Z, 0 to 9) order.
Descending | True | Sorts values in descending (Z to A, 9 to 0) order.

In Visual Basic, you set the SortOrder property in report Design view or in the Open event procedure of a report by using the GroupLevel property.

Example

The following example sets the sort order to ascending for the first group level in the "Product Summary" report.

VBA Copy code Copy code
Reports("Product Summary").GroupLevel(0).SortOrder = False

See also

Concepts

GroupLevel Object

Other resources

GroupLevel Object Members


DisplayHourglassPointer Macro Action

 Copy code hover
[image]

DisplayHourglassPointer Macro Action
Send feedback

You can use the DisplayHourglassPointer action to change the mouse pointer to an image of an hourglass (or another icon you've chosen) while a macro is running. This action can provide a visual indication that the macro is running. This is especially useful when a macro action or the macro itself takes a long time to run.

Setting

The DisplayHourglassPointer action has the following argument.

Action argument | Description
Hourglass On | Click Yes (display the icon) or No (display the normal mouse pointer) in the Hourglass On box in the Action Arguments section of the Macro Builder pane. The default is Yes.

Remarks

You often use this action if you have turned echo off by using the Echo action. When echo is off, Microsoft Access 2013 suspends screen updates until the macro is finished.

Access automatically resets the Hourglass On argument to No when the macro finishes running.

Note Note

  • In Microsoft Windows, this is the icon you set for Busy in the Mouse Properties dialog box of Windows Control Panel. The default for all Windows operating systems is an animated hourglass icon.

  • You can choose another icon if you want.

To run the DisplayHourglassPointer action in a Visual Basic for Applications (VBA) module, use the Hourglass method of the DoCmd object.


OptionButton.AfterUpdate Property (Access)

 Copy code hover
[image]

OptionButton.AfterUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.

Syntax

expression .AfterUpdate

expression A variable that represents an OptionButton object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the AfterUpdate event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the AfterUpdate event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).AfterUpdate = "[Event Procedure]"

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Var, VarP Functions (Microsoft Access SQL)

 Copy code hover
[image]

Var, VarP Functions (Microsoft Access SQL)
Send feedback

Published: July 16, 2012

Return estimates of the variance for a population or a population sample represented as a set of values contained in a specified field on a query.

Syntax

Var(expr)

VarP(expr)

The expr placeholder represents a string expression identifying the field that contains the numeric data you want to evaluate or an expression that performs a calculation using the data in that field. Operands in expr can include the name of a table field, a constant, or a function (which can be either intrinsic or user-defined but not one of the other SQL aggregate functions).

Remarks

The VarP function evaluates a population, and the Var function evaluates a population sample.

If the underlying query contains fewer than two records, the Var and VarP functions return a Null value, which indicates that a variance cannot be calculated.

You can use the Var and VarP functions in a query expression or in an SQL statement.

Example

This example uses the Orders table to estimate the variance of freight costs for orders shipped to the United Kingdom.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

Copy code Copy code
Sub VarX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Calculate the variance of freight costs for
    ' orders shipped to the United Kingdom.
    Set rst = dbs.OpenRecordset("SELECT " _
        & "Var(Freight) " _
        & "AS [UK Freight Variance] " _
        & "FROM Orders WHERE ShipCountry = 'UK';")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 20

    Debug.Print

    Set rst = dbs.OpenRecordset("SELECT " _
        & "VarP(Freight) " _
        & "AS [UK Freight VarianceP] " _
        & "FROM Orders WHERE ShipCountry = 'UK';")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 20

    dbs.Close

End Sub


ComboBox.BorderShade Property (Access)

 Copy code hover
[image]

ComboBox.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents a ComboBox object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ImportExportData Macro Action

 Copy code hover
[image]

ImportExportData Macro Action
Send feedback

You can use the ImportExportData action to import or export data between the current Access database (.mdb or .accdb) or Access project (.adp) and another database. For Microsoft Access databases, you can also link a table to the current Access database from another database. With a linked table, you have access to the table's data while the table itself remains in the other database.

Note 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.

Settings

The ImportExportData action has the following arguments.

Action argument

Description

Transfer Type

The type of transfer you want to make. Select Import, Export, or Link in the Transfer Type box in the Action Arguments section of the Macro Builder pane. The default is Import.

Note Note

The Link transfer type is not supported for Access projects (.adp).

Database Type

The type of database to import from, export to, or link to. You can select Microsoft Access or one of a number of other database types in the Database Type box. The default is Microsoft Access.

Database Name

The name of the database to import from, export to, or link to. Include the full path. This is a required argument. For types of databases that use separate files for each table, such as FoxPro, Paradox, and dBASE, enter the directory containing the file. Enter the file name in the Source argument (to import or link) or the Destination argument (to export). For ODBC databases, type the full Open Database Connectivity (ODBC) connection string.

To see an example of a connection string, link an external table to Access:

  2. In the Get External Data dialog box, enter the path of your source database in the File name box.

  3. Click Link to the data source by creating a linked table, and click OK.

  4. Select a table in the Link Tables dialog box, and click OK.

Open the newly linked table in Design view and view the table properties by clicking Property Sheet on the Design tab, under Tools. The text in the Description property setting is the connection string for this table.

For more information on ODBC connection strings, see the Help file or other documentation for the ODBC driver of this type of ODBC database.

Object Type

The type of object to import or export. If you select Microsoft Access for the Database Type argument, you can select Table, Query, Form, Report, Macro, Module, Data Access Page, Server View, Diagram, Stored Procedure, or Function in the Object Type box. The default is Table. If you select any other type of database, or if you select Link in the Transfer Type box, this argument is ignored. If you are exporting a select query to an Access database, select Table in this argument to export the result set of the query, and select Query to export the query itself. If you are exporting a select query to another type of database, this argument is ignored and the result set of the query is exported.

Source

The name of the table, select query, or Access object that you want to import, export, or link. For some types of databases, such as FoxPro, Paradox, or dBASE, this is a file name. Include the file name extension (such as .dbf) in the file name. This is a required argument.

Destination

The name of the imported, exported, or linked table, select query, or Access object in the destination database. For some types of databases, such as FoxPro, Paradox, or dBASE, this is a file name. Include the file name extension (such as .dbf) in the file name. This is a required argument. If you select Import in the Transfer Type argument and Table in the Object Type argument, Access creates a new table containing the data in the imported table. If you import a table or other object, Access adds a number to the name if it conflicts with an existing name. For example, if you import Employees and Employees already exists, Access renames the imported table or other object Employees1. If you export to an Access database or another database, Access automatically replaces any existing table or other object that has the same name.

Structure Only

Specifies whether to import or export only the structure of a database table without any of its data. Select Yes or No. The default is No.

Remarks

You can import and export tables between Access and other types of databases. You can also export Access select queries to other types of databases. Access exports the result set of the query in the form of a table. You can import and export any Access database object if both databases are Access databases.

If you import a table from another Access database (.mdb or .accdb) that's a linked table in that database, it will still be linked after you import it. That is, the link is imported, not the table itself.

If the database you're accessing requires a password, a dialog box appears when you run the macro. Type the password in this dialog box.

The ImportExportData action is similar to the commands on the External Data tab, under Import or Export. You can use these commands to select a source of data, such as an Access database or another type of database, a spreadsheet, or a text file. If you select a database, one or more dialog boxes appear in which you select the type of object to import or export (for Access databases), the name of the object, and other options, depending on the database you are importing from or exporting or linking to. The arguments for the ImportExportData action reflect the options in these dialog boxes.

If you want to supply index information for a linked dBASE table, first link the table:

  2. Click dBASE File.

  3. In the Get External Data dialog box, enter the path for the dBASE file in the File name box.

  4. Click Link to the data source by creating a linked table, then click OK.

  5. Specify the indexes in the dialog boxes for this command. Access stores the index information in a special information (.inf) file, located in the Microsoft Office folder.

  6. You can then delete the link to the linked table.

The next time you use the ImportExportData action to link this dBASE table, Access uses the index information that you've specified.

Note Note

If you query or filter a linked table, the query or filter is case-sensitive.

To run the ImportExportData action in a Visual Basic for Applications (VBA) module, use the TransferDatabase method of the DoCmd object.


BoundObjectFrame.GridlineColor Property (Access)

 Copy code hover
[image]

BoundObjectFrame.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified object frame. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineColor

expression A variable that represents a BoundObjectFrame object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


WillChangeRecordset and RecordsetChangeComplete Events (ADO)

 Copy code hover
[image]

WillChangeRecordset and RecordsetChangeComplete Events (ADO)
Send feedback

The WillChangeRecordset event is called before a pending operation changes the Recordset. The RecordsetChangeComplete event is called after the Recordset has changed.

Syntax

WillChangeRecordset adReason, adStatus, pRecordset

RecordsetChangeComplete adReason, pError, adStatus, pRecordset

Parameters

  • adReason

  • An EventReasonEnum value that specifies the reason for this event. Its value can be adRsnRequery, adRsnResynch, adRsnClose, adRsnOpen.

  • adStatus

  • EventStatusEnum

    When WillChangeRecordset is called, this parameter is set to adStatusOK if the operation that caused the event was successful. It is set to adStatusCantDeny if this event cannot request cancellation of the pending operation.

    When RecordsetChangeComplete is called, this parameter is set to adStatusOK if the operation that caused the event was successful, adStatusErrorsOccurred if the operation failed, or adStatusCancel if the operation associated with the previously accepted WillChangeRecordset event has been canceled.

    Before WillChangeRecordset returns, set this parameter to adStatusCancel to request cancellation of the pending operation or set this parameter to adStatusUnwantedEvent to prevent subsequent notifications.

    Before WillChangeRecordset or RecordsetChangeComplete returns, set this parameter to adStatusUnwantedEvent to prevent subsequent notifications.

  • pError

  • An Error object. It describes the error that occurred if the value of adStatus is adStatusErrorsOccurred; otherwise it is not set.

  • pRecordset

  • A Recordset object. The Recordset for which this event occurred.

Remarks

A WillChangeRecordset or RecordsetChangeComplete event may occur due to the Recordset Requery or Open methods.

If the provider does not support bookmarks, a RecordsetChange event notification occurs each time new rows are retrieved from the provider. The frequency of this event depends on the RecordsetCacheSize property.

You must set the adStatus parameter to adStatusUnwantedEvent for each possible adReason value in order to completely stop event notification for any event that includes an adReason parameter.


TabControl.OnKeyDown Property (Access)

 Copy code hover
[image]

TabControl.OnKeyDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Down box in the Properties window. Read/write String.

Syntax

expression .OnKeyDown

expression A variable that represents a TabControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyDown event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyDown

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


AddNew or Edit already used. (Error 3023)

 Copy code hover
[image]

AddNew or Edit already used. (Error 3023)
Send feedback

You have not saved or rolled back the current changes and are trying to add or change another record. Use the Rollback or Update method, and then use the AddNew or Edit method.


Power Function (Access 2013 custom web app)

 Copy code hover
[image]

Power Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the value of the specified expression to the specified power.

Syntax

Power(NumericExpression, Power)

The Power function contains the following arguments.

Argument name | Description
NumericExpression | A numeric expression.
Power | The power to which to raise NumericExpression.


FieldAttributeEnum

 Copy code hover
[image]

FieldAttributeEnum
Send feedback

Specifies one or more attributes of a Field object.

Constant | Value | Description
adFldCacheDeferred | 0x1000 | Indicates that the provider caches field values and that subsequent reads are done from the cache.
adFldFixed | 0x10 | Indicates that the field contains fixed-length data.
adFldIsChapter | 0x2000 | Indicates that the field contains a chapter value, which specifies a specific child recordset related to this parent field. Typically chapter fields are used with data shaping or filters.
adFldIsCollection | 0x40000 | Indicates that the field specifies that the resource represented by the record is a collection of other resources, such as a folder, rather than a simple resource, such as a text file.
adFldIsDefaultStream | 0x20000 | Indicates that the field contains the default stream for the resource represented by the record. For example, the default stream can be the HTML content of a root folder on a Web site, which is automatically served when the root URL is specified.
adFldIsNullable | 0x20 | Indicates that the field accepts null values.
adFldIsRowURL | 0x10000 | Indicates that the field contains the URL that names the resource from the data store represented by the record.
adFldLong | 0x80 | Indicates that the field is a long binary field. Also indicates that you can use the AppendChunk and GetChunk methods.
adFldMayBeNull | 0x40 | Indicates that you can read null values from the field.
adFldMayDefer | 0x2 | Indicates that the field is deferred — that is, the field values are not retrieved from the data source with the whole record, but only when you explicitly access them.
adFldNegativeScale | 0x4000 | Indicates that the field represents a numeric value from a column that supports negative scale values. The scale is specified by the NumericScale property.
adFldRowID | 0x100 | Indicates that the field contains a persistent row identifier that cannot be written to and has no meaningful value except to identify the row (such as a record number, unique identifier, and so forth).
adFldRowVersion | 0x200 | Indicates that the field contains some kind of time or date stamp used to track updates.
adFldUnknownUpdatable | 0x8 | Indicates that the provider cannot determine if you can write to the field.
adFldUnspecified | -1 0xFFFFFFFF | Indicates that the provider does not specify the field attributes.
adFldUpdatable | 0x4 | Indicates that you can write to the field.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.FieldAttribute.CACHEDEFERRED

AdoEnums.FieldAttribute.FIXED

AdoEnums.FieldAttribute.ISNULLABLE

AdoEnums.FieldAttribute.LONG

AdoEnums.FieldAttribute.MAYBENULL

AdoEnums.FieldAttribute.MAYDEFER

AdoEnums.FieldAttribute.NEGATIVESCALE

AdoEnums.FieldAttribute.ROWID

AdoEnums.FieldAttribute.ROWVERSION

AdoEnums.FieldAttribute.UNKNOWNUPDATABLE

AdoEnums.FieldAttribute.UNSPECIFIED

AdoEnums.FieldAttribute.UPDATABLE


Recordset.Updatable Property (DAO)

 Copy code hover
[image]

Recordset.Updatable Property (DAO)
Send feedback

Returns a value that indicates whether you can change a DAO object. Read-only Boolean.

Syntax

expression .Updatable

expression A variable that represents a Recordset object.

Remarks

Snapshot- and forward-only-type Recordset objects always return False.

Many types of objects can contain fields that can't be updated. For example, you can create a dynaset-type Recordset object in which only some fields can be changed. These fields can be fixed or contain data that increments automatically, or the dynaset can result from a query that combines updatable and nonupdatable tables.

If the object contains only read-only fields, the value of the Updatable property is False. When one or more fields are updatable, the property's value is True. You can edit only the updatable fields. A trappable error occurs if you try to assign a new value to a read-only field.

Because an updatable object can contain read-only fields, check the DataUpdatable property of each field in the Fields collection of a Recordset object before you edit a record.


NavigationControl.Hyperlink Property (Access)

 Copy code hover
[image]

NavigationControl.Hyperlink Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Hyperlink

expression A variable that represents a NavigationControl object.

Example

The CreateHyperlink procedure in the following example sets the hyperlink properties for a command button, label, or image control to the address and subaddress values passed to the procedure. The address setting is an optional argument, because a hyperlink to an object in the current database uses only the subaddress setting, To try this example, create a form with two text box controls (txtAddress and txtSubAddress) and a command button (cmdFollowLink) and paste the following into the Declarations section of the form's module:

VBA Copy code Copy code
Private Sub cmdFollowLink_Click()
 CreateHyperlink Me!cmdFollowLink, Me!txtSubAddress, _
 Me!txtAddress
End Sub

Sub CreateHyperlink(ctlSelected As Control, _
 strSubAddress As String, Optional strAddress As String)
 Dim hlk As Hyperlink
 Select Case ctlSelected.ControlType
 Case acLabel, acImage, acCommandButton
 Set hlk = ctlSelected.Hyperlink
 With hlk
 If Not IsMissing(strAddress) Then
 .Address = strAddress
 Else
 .Address = ""
 End If
 .SubAddress = strSubAddress
 .Follow
 .Address = ""
 .SubAddress = ""
 End With
 Case Else
 MsgBox "The control '" & ctlSelected.Name _
 & "' does not support hyperlinks."
 End Select
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


CurrentProject.AllModules Property (Access)

 Copy code hover
[image]

CurrentProject.AllModules Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllModules property to reference the AllModules collection and its related properties. Read-only AllModules object.

Syntax

expression .AllModules

expression A variable that represents a CurrentProject object.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


Recordset2.NoMatch Property (DAO)

 Copy code hover
[image]

Recordset2.NoMatch Property (DAO)
Send feedback

Indicates whether a particular record was found by using the Seek method or one of the Find methods (Microsoft Access workspaces only).

Syntax

expression .NoMatch

expression A variable that represents a Recordset2 object.

Remarks

When you open or create a Recordset object, its NoMatch property is set to False.

To locate a record, use the Seek method on a table-type Recordset object or one of the Find methods on a dynaset- or snapshot-type Recordset object. Check the NoMatch property setting to see whether the record was found.

If the Seek or Find method is unsuccessful and the NoMatch property is True, the current record will no longer be valid. Be sure to obtain the current record's bookmark before using the Seek method or a Find method if you'll need to return to that record.

Note Note

Using any of the Move methods on a Recordset object won't affect its NoMatch property setting.

Example

This example uses the NoMatch property to determine whether a Seek and a FindFirst were successful, and if not, to give appropriate feedback. The SeekMatch and FindMatch procedures are required for this procedure to run.

VBA Copy code Copy code
Sub NoMatchX()

 Dim dbsNorthwind As Database
 Dim rstProducts As Recordset2
 Dim rstCustomers As Recordset2
 Dim strMessage As String
 Dim strSeek As String
 Dim strCountry As String
 Dim varBookmark As Variant

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 ' Default is dbOpenTable; required if Index property will
 ' be used.
 Set rstProducts = dbsNorthwind.OpenRecordset("Products")

 With rstProducts
 .Index = "PrimaryKey"

 Do While True
 ' Show current record information; ask user for
 ' input.
 strMessage = "NoMatch with Seek method" & vbCr & _
 "Product ID: " & !ProductID & vbCr & _
 "Product Name: " & !ProductName & vbCr & _
 "NoMatch = " & .NoMatch & vbCr & vbCr & _
 "Enter a product ID."
 strSeek = InputBox(strMessage)
 If strSeek = "" Then Exit Do

 ' Call procedure that seeks for a record based on
 ' the ID number supplied by the user.
 SeekMatch rstProducts, Val(strSeek)
 Loop

 .Close
 End With

 Set rstCustomers = dbsNorthwind.OpenRecordset( _
 "SELECT CompanyName, Country FROM Customers " & _
 "ORDER BY CompanyName", dbOpenSnapshot)

 With rstCustomers

 Do While True
 ' Show current record information; ask user for
 ' input.
 strMessage = "NoMatch with FindFirst method" & _
 vbCr & "Customer Name: " & !CompanyName & _
 vbCr & "Country: " & !Country & vbCr & _
 "NoMatch = " & .NoMatch & vbCr & vbCr & _
 "Enter country on which to search."
 strCountry = Trim(InputBox(strMessage))
 If strCountry = "" Then Exit Do

 ' Call procedure that finds a record based on
 ' the country name supplied by the user.
 FindMatch rstCustomers, _
 "Country = '" & strCountry & "'"
 Loop

 .Close
 End With

 dbsNorthwind.Close

End Sub

Sub SeekMatch(rstTemp As Recordset2, _
 intSeek As Integer)

 Dim varBookmark As Variant
 Dim strMessage As String

 With rstTemp
 ' Store current record location.
 varBookmark = .Bookmark
 .Seek "=", intSeek

 ' If Seek method fails, notify user and return to the
 ' last current record.
 If .NoMatch Then
 strMessage = _
 "Not found! Returning to current record." & _
 vbCr & vbCr & "NoMatch = " & .NoMatch
 MsgBox strMessage
 .Bookmark = varBookmark
 End If

 End With

End Sub

Sub FindMatch(rstTemp As Recordset, _
 strFind As String)

 Dim varBookmark As Variant
 Dim strMessage As String

 With rstTemp
 ' Store current record location.
 varBookmark = .Bookmark
 .FindFirst strFind

 ' If Find method fails, notify user and return to the
 ' last current record.
 If .NoMatch Then
 strMessage = _
 "Not found! Returning to current record." & _
 vbCr & vbCr & "NoMatch = " & .NoMatch
 MsgBox strMessage
 .Bookmark = varBookmark
 End If

 End With

End Sub


Cannot add a new column to conflict table

 Copy code hover
[image]

Cannot add a new column to conflict table <name>. Delete obsolete columns and compact the database. (Error 3740)
Send feedback

You have exceeded the column limit for a conflict table. Design your base table with fewer columns.


Field2 Methods (DAO)

 Copy code hover
[image]

Field2 Methods (DAO)
Send feedback

In this section

  • Field2.AppendChunk Method (DAO)

  • Field2.CreateProperty Method (DAO)

  • Field2.GetChunk Method (DAO)

  • Field2.LoadFromFile Method (DAO)

  • Field2.SaveToFile Method (DAO)


AllStoredProcedures Properties (Access)

 Copy code hover
[image]

AllStoredProcedures Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


CommandButton.Properties Property (Access)

 Copy code hover
[image]

CommandButton.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a CommandButton object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


WebBrowserControl.OldValue Property (Access)

 Copy code hover
[image]

WebBrowserControl.OldValue Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.

Version Information

Version Added: Access 2010

Syntax

expression .OldValue

expression A variable that represents a WebBrowserControl object.

Remarks

The OldValue property contains the unedited data from a bound control and is read-only in all views.

Microsoft Access uses the OldValue property to store the original value of a bound control. When you edit a bound control on a form, your changes aren't saved until you move to another record. The OldValue property contains the unedited version of the underlying data.

You can provide your own undo capability by assigning the OldValue property setting to a control. The following example shows how you can undo any changes to text box controls on a form:

VBA Copy code Copy code
Private Sub btnUndo_Click()

 Dim ctlTextbox As Control

 For Each ctlTextbox in Me.Controls
 If ctlTextbox.ControlType = acTextBox Then
 ctlTextbox.Value = ctl.OldValue
 End If
 Next ctlTextbox

End Sub

If the control hasn't been edited, this code has no effect. When you move to another record, the record source is updated, so the current value and the OldValue property will be the same.

The OldValue property setting has the same data type as the field to which the control is bound.

Example

The following example checks to determine if new data entered in a field is within 10 percent of the value of the original data. If the change is greater than 10 percent, the OldValue property is used to restore the original value. This procedure could be called from the BeforeUpdate event of the control that contains data you want to validate.

VBA Copy code Copy code
Public Sub Validate_Field()

 Dim curNewValue As Currency
 Dim curOriginalValue As Currency
 Dim curChange As Currency
 Dim strMsg As String

 curNewValue = Forms!Products!UnitPrice
 curOriginalValue = Forms!Products!UnitPrice.OldValue
 curChange = Abs(curNewValue - curOriginalValue)

 If curChange > (curOriginalValue * .1) Then
 strMsg = "Change is more than 10% of original unit price. " _
 & "Restoring original unit price."
 MsgBox strMsg, vbExclamation, "Invalid change."
 Forms!Products!UnitPrice = curOriginalValue
 End If

End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Save Method (ADO)

 Copy code hover
[image]

Save Method (ADO)
Send feedback

Saves the Recordset in a file or Stream object.

Syntax

recordset.Save Destination, PersistFormat

Parameters

  • Destination

  • Optional. A Variant that represents the complete path name of the file where the Recordset is to be saved, or a reference to a Stream object.

  • PersistFormat

  • Optional. A PersistFormatEnum value that specifies the format in which the Recordset is to be saved (XML or ADTG). The default value is adPersistADTG.

Remarks

The Save method can only be invoked on an open Recordset. Use the Open method to later restore the Recordset from Destination.

If the Filter property is in effect for the Recordset, then only the rows accessible under the filter are saved. If the Recordset is hierarchical, then the current child Recordset and its children are saved, including the parent Recordset. If the Save method of a child Recordset is called, the child and all its children are saved, but the parent is not.

The first time you save the Recordset, it is optional to specify Destination. If you omit Destination, a new file will be created with a name set to the value of the Source property of the Recordset.

Omit Destination when you subsequently call Save after the first save, or a run-time error will occur. If you subsequently call Save with a new Destination, the Recordset is saved to the new destination. However, the new destination and the original destination will both be open.

Save does not close the Recordset or Destination, so you can continue to work with the Recordset and save your most recent changes. Destination remains open until the Recordset is closed.

For reasons of security, the Save method permits only the use of low and custom security settings from a script executed by Microsoft Internet Explorer. For a more detailed explanation of security issues, see "ADO and RDS Security Issues in Microsoft Internet Explorer" under ActiveX Data Objects (ADO) Technical Articles in Microsoft Data Access Technical Articles.

If the Save method is called while an asynchronous Recordset fetch, execute, or update operation is in progress, then Save waits until the asynchronous operation is complete.

Records are saved beginning with the first row of the Recordset. When the Save method is finished, the current row position is moved to the first row of the Recordset.

For best results, set the CursorLocation property to adUseClient with Save. If your provider does not support all of the functionality necessary to save Recordset objects, the Cursor Service will provide that functionality.

When a Recordset is persisted with the CursorLocation property set to adUseServer, the update capability for the Recordset is limited. Typically, only single-table updates, insertions, and deletions are allowed (dependant upon provider functionality). The Resync method is also unavailable in this configuration.

Note Note

Saving a Recordset with Fields of type adVariant, adIDispatch, or adIUnknown is not supported by ADO and can cause unpredictable results.

Only Filters in the form of Criteria Strings (e.g. OrderDate > '12/31/1999') affect the contents of a persisted Recordset. Filters created with an Array of Bookmarks or using a value from the FilterGroupEnum will not affect the contents of the persisted Recordset. These rules apply to Recordsets created with either client-side or server-side cursors.

Because the Destination parameter can accept any object that supports the OLE DB IStream interface, you can save a Recordset directly to the ASP Response object. For more details, please see the XML Recordset Persistence Scenario.

You can also save a Recordset in XML format to an instance of an MSXML DOM object, as is shown in the following Visual Basic code:

Note Note

Two limitations apply when saving hierarchical Recordsets (data shapes) in XML format. You cannot save into XML if the hierarchical Recordset contains pending updates, and you cannot save a parameterized hierarchical Recordset.

A Recordset saved in XML format is saved using UTF-8 format. When such a file is loaded into an ADO Stream, the Stream object will not attempt to open a Recordset from the stream unless the Charset property of the stream is set to the appropriate value for UTF-8 format.


Invalid field name

 Copy code hover
[image]

Invalid field name <name> in definition of index or relationship. (Error 3409)
Send feedback

Possible causes:

  • The field name you have specified might be misspelled. Check the spelling of the field name.

  • The field type you are using is a Memo or OLE Object, which cannot be indexed.


Cell Object (ADO MD Reference)

 Copy code hover
[image]

Cell Object (ADO MD Reference)
Send feedback

In this section

  • Cell Object (ADO MD)

  • Cell Properties, Methods, and Events (ADO MD)


CommandButton.StatusBarText Property (Access)

 Copy code hover
[image]

CommandButton.StatusBarText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.

Syntax

expression .StatusBarText

expression A variable that represents a CommandButton object.

Remarks

You set the StatusBarText property by using a string expression up to 255 characters long.

Note Note

The length of the text you can display in the status bar depends on your computer hardware and video display.

You can use the StatusBarText property to provide specific information about a control. For example, when a text box has the focus, a brief instruction can tell the user what kind of data to enter

Note Note

You can also use the ControlTipText property to display a ScreenTip for a control.

If you create a control by dragging a field from the field list, the value in a field's Description property is copied to the StatusBarText property.

Example

The following example sets the status bar text to be displayed when the "Address_TextBox" control in the "Mailing List" form has the focus in Form View.

VBA Copy code Copy code
Forms("Mailing List").Controls("Address_TextBox"). _
 StatusBarText = "Enter the company's mailing address."

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


FieldAttributeEnum Enumeration (DAO)

 Copy code hover
[image]

FieldAttributeEnum Enumeration (DAO)
Send feedback

Insert introduction here.

Section Heading

Insert section body here.

Subsection Heading

Insert subsection body here.


SmartTag.Delete Method (Access)

 Copy code hover
[image]

SmartTag.Delete Method (Access)
See also Send feedback

Published: July 16, 2012

Deletes the specified object.

Syntax

expression .Delete

expression A variable that represents a SmartTag object.

Return Value

Nothing

See also

Concepts

SmartTag Object

Other resources

SmartTag Object Members


Access object model reference (Access 2013 developer reference)

 Copy code hover
[image]

Access object model reference (Access 2013 developer reference)
Send feedback

This section of the Microsoft Access 2010 Developer Reference contains documentation for all the objects, properties, methods, and events contained in the Access object model.

Are You Viewing Help in a Microsoft Office Product?

If you are viewing Help from inside your installed version of the documentation, you can use the table of contents to navigate through the topics. To open the table of contents, click the Show Table of Contents toolbar button [image] in the Help window. Click a topic in the table of contents to view it.

If Connected to Office.com appears in the lower-right corner of the Help window, you are searching Help from the Office Web site. If Offline appears, you are searching Help from the files stored on your computer.

Are You Viewing the Content in the MSDN Library?

If you are viewing the content on MSDN, you can use the table of contents located to the left of the topic to navigate through the documentation.


Printer.DataOnly Property (Access)

 Copy code hover
[image]

Printer.DataOnly Property (Access)
See also Send feedback

Published: July 16, 2012

True if Microsoft Access prints only the data from a table or query in Datasheet View and not the labels, control borders, gridlines, and display graphics. Read/write Boolean.

Syntax

expression .DataOnly

expression A variable that represents a Printer object.

Example

The following example sets a variety of printer settings for the form specified in the strFormname argument of the procedure.

VBA Copy code Copy code
Sub SetPrinter(strFormname As String)

 DoCmd.OpenForm FormName:=strFormname, view:=acDesign, _
 datamode:=acFormEdit, windowmode:=acHidden

 With Forms(form1).Printer

 .TopMargin = 1440
 .BottomMargin = 1440
 .LeftMargin = 1440
 .RightMargin = 1440

 .ColumnSpacing = 360
 .RowSpacing = 360

 .ColorMode = acPRCMColor
  .DataOnly = False
 .DefaultSize = False
 .ItemSizeHeight = 2880
 .ItemSizeWidth = 2880
 .ItemLayout = acPRVerticalColumnLayout
 .ItemsAcross = 6

 .Copies = 1
 .Orientation = acPRORLandscape
 .Duplex = acPRDPVertical
 .PaperBin = acPRBNAuto
 .PaperSize = acPRPSLetter
 .PrintQuality = acPRPQMedium

 End With

 DoCmd.Close objecttype:=acForm, objectname:=strFormname, _
 Save:=acSaveYes

End Sub

See also

Concepts

Printer Object

Other resources

Printer Object Members


AccessObjectProperties Object (Access)

 Copy code hover
[image]

AccessObjectProperties Object (Access)
See also Send feedback

Published: July 16, 2012

The AccessObjectProperties collection contains all of the custom AccessObjectProperty objects of a specific instance of an object. These AccessObjectProperty objects (which are often just called properties) uniquely characterize that instance of the object.

Remarks

Use the AccessObjectProperties collection in Visual Basic or in an expression to refer to properties of the CurrentProject, CodeProject, or AccessObject object. For example, you can enumerate the AccessObjectProperties collection to set or return the values of properties of an individual report.

Note Note

The AccessObjectProperties collection isn't accessible for objects derived from the CurrentData object (for example, CurrentData.AllTables!Table1). For objects derived in this manner, you can only access their built-in properties by direct calls to the desired property (for example, CurrentData.AllTables!Table1.Name).

To add a user-defined property to an existing instance of an object, first define its characteristics and add it to the collection with the Add method. Referencing a user-defined AccessObjectProperty object that has not yet been appended to an AccessObjectProperties collection will cause an error, as will appending a user-defined AccessObjectProperty object to an AccessObjectProperties collection containing an AccessObjectProperty object of the same name.

You can use the Remove method to remove user-defined properties from the AccessObjectProperties collection.

Note Note

A built-in or user-defined AccessObjectProperty object is associated only with the specific instance of an object. The property isn't defined for all instances of objects of the selected type.

To refer to a built-in or user-defined AccessObjectProperty object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

VBA Copy code Copy code
CurrentProject.AllForms("Form1").Properties(0)
CurrentProject.AllForms("Form1").Properties("name")
CurrentProject.AllForms("Form1").Properties![name]

With the same syntax forms, you can also refer to the Value property of a AccessObjectProperty object. The context of the reference will determine whether you are referring to the AccessObjectProperty object itself or the Value property of the AccessObjectProperty object.

Note Note

Properties in the AccessObjectProperties collection are not stored and can be lost when the object they are associated with is checked in or out using the Source Code Control add-in.

See also

Concepts

Access Object Model Reference

Other resources

AccessObjectProperties Object Members


CodeProject.Parent Property (Access)

 Copy code hover
[image]

CodeProject.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a CodeProject object.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


TabControl.LayoutID Property (Access)

 Copy code hover
[image]

TabControl.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified text box. Read-only Long.

Version Information

Version Added: Access 2010

Syntax

expression .LayoutID

expression A variable that represents a TabControl object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


The Synchronizer's client is no longer present and cannot be notified. (Error 3537)

 Copy code hover
[image]

The Synchronizer's client is no longer present and cannot be notified. (Error 3537)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


ListBox.KeyUp Event (Access)

 Copy code hover
[image]

ListBox.KeyUp Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyUp(KeyCode, Shift)

expression A variable that represents a ListBox object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyUp property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyUp event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyUp event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Reports.Application Property (Access)

 Copy code hover
[image]

Reports.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a Reports object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

Reports Collection

Other resources

Reports Object Members


Criteria Expressions (Access)

 Copy code hover
[image]

Criteria Expressions (Access)
Send feedback

In this section

  • Date and Time Criteria Expressions

  • Date and Time Criteria from a Control on a Form

  • Multiple Fields in Criteria Expressions

  • Numeric Criteria Expressions

  • Numeric Criteria from a Control on a Form

  • Textual Criteria Expressions

  • Textual Criteria from a Control on a Form

  • Quotation Marks in Strings

  • Restrict Data to a Subset of Records

  • Calculate Fields in Domain Aggregate Functions

  • Functions (Alphabetical List)

  • Functions (Category List)


Recordset2.CacheStart Property (DAO)

 Copy code hover
[image]

Recordset2.CacheStart Property (DAO)
Send feedback

Sets or returns a value that specifies the bookmark of the first record in a dynaset-type Recordset object containing data to be locally cached from an ODBC data source (Microsoft Access workspaces only).

Syntax

expression .CacheStart

expression A variable that represents a Recordset2 object.

Remarks

Data caching improves performance if you use Recordset objects to retrieve data from a remote server. A cache is a space in local memory that holds the data most recently retrieved from the server; this is useful if users request the data again while the application is running. When users request data, the Microsoft Access database engine checks the cache for the requested data first rather than retrieving it from the server, which takes more time. The cache only saves data that comes from an ODBC data source.

Any Microsoft Access database engine-connected ODBC data source, such as a linked table, can have a local cache. To create the cache, open a Recordset object from the remote data source, set the CacheSize and CacheStart properties, and then use the FillCache method, or step through the records by using the Move methods.

The CacheStart property setting is the bookmark of the first record in the Recordset object to be cached. You can use the bookmark of any record to set the CacheStart property. Make the record you want to start the cache the current record, and set the CacheStart property equal to the Bookmark property.

The Microsoft Access database engine requests records within the cache range from the cache, and it requests records outside the cache range from the server.

Records retrieved from the cache don't reflect changes made concurrently to the source data by other users.

To force an update of all the cached data, set the CacheSize property of the Recordset object to 0, re-set it to the size of the cache you originally requested, and then use the FillCache method.


Using ADO with Scripting Languages

 Copy code hover
[image]

Using ADO with Scripting Languages
Send feedback

Within a scripting environment, ADO allows you to expose data by way of server-side scripting. In this scenario, ADO, the underlying OLE DB provider that it utilizes, and any other components needed to reference a given data store are installed on a server running Internet Information Services (IIS). Using Active Server Pages (ASP), ADO is a component referenced in a script that can generate HTML, for example. This HTML content can be passed via HTTP to a client Web browser. Through the use of scripting, the Web page can send actions back to the server-side script, allowing you to update, traverse, or view specific data.

ODBC Data Sources

One notable difference between scripting and non-scripting ADO code is the ODBC Data Source, if used. For non-scripting applications, you can create a User DSN in the ODBC Data Source Administrator. For scripts that are running under IIS, you must create a System DSN; otherwise your scripts won't recognize the data source you created. This applies to any ADO scripting application using the Microsoft OLE DB Provider for ODBC through Microsoft IIS.

Referencing the ADO Library

N/A with scripting languages.

Handling events

N/A with scripting languages.

The following topics contain more specific information about using ADO with scripting languages:

  • ADO in VBScript

  • ADO in JScript


NavigationControl.HorizontalAnchor Property (Access)

 Copy code hover
[image]

NavigationControl.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the text box is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2010

Syntax

expression .HorizontalAnchor

expression A variable that represents a NavigationControl object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Index not found. (Error 3015)

 Copy code hover
[image]

Index not found. (Error 3015)
Send feedback

You tried to use a value that is not an index. You can determine the valid index names by looking in the Indexes collection of the TableDef object.


Page.Enabled Property (Access)

 Copy code hover
[image]

Page.Enabled Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.

Syntax

expression .Enabled

expression A variable that represents a Page object.

Remarks

The Enabled property setting is a value that indicates whether the conditional format is enabled or disabled. True enables the conditional format. False disables the conditional format. The default is True.

When the Enabled property is True, the conditional format can be displayed in the Conditional Formatting dialog box.

See also

Concepts

Page Object

Other resources

Page Object Members


Updating Data

 Copy code hover
[image]

Updating Data
Send feedback

Update behavior and functionality is largely dependent upon update mode (lock type), cursor type, and cursor location.

Use the Update method to save any changes you have made to the current record of a Recordset object since calling the AddNew method or since changing any field values in an existing record. The Recordset object must support updates.

If the Recordset object supports batch updating, you can cache multiple changes to one or more records locally until you call the UpdateBatch method. If you are editing the current record or adding a new record when you call the UpdateBatch method, ADO will automatically call the Update method to save any pending changes to the current record before transmitting the batched changes to the provider.

The current record remains current after you call the Update or UpdateBatch methods.


AllFunctions.Parent Property (Access)

 Copy code hover
[image]

AllFunctions.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents an AllFunctions object.

See also

Concepts

AllFunctions Collection

Other resources

AllFunctions Object Members


Indexes Collection (ADOX) Reference

 Copy code hover
[image]

Indexes Collection (ADOX) Reference
Send feedback

In this section

  • Indexes Collection (ADOX)

  • Indexes Collection Properties, Methods, and Events (ADOX)


Properties Collection Properties, Methods, and Events

 Copy code hover
[image]

Properties Collection Properties, Methods, and Events
Send feedback

Properties

Count Property

Item Property

Methods

Refresh Method

Events

None.


Hyperlink Object (Access)

 Copy code hover
[image]

Hyperlink Object (Access)
See also Send feedback

Published: July 16, 2012

The Hyperlink object represents a hyperlink associated with a control on a form, report, or data access page.

Remarks

Use the Hyperlink property to return a reference to a hyperlink object.

See also

Concepts

Access Object Model Reference

Other resources

Hyperlink Object Members


CurrentProject.Resources Property (Access)

 Copy code hover
[image]

CurrentProject.Resources Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the SharedResources collection for the specified object. Read-only SharedResources.

Version Information

Version Added: Access 2010

Syntax

expression .Resources

expression A variable that represents a CurrentProject object.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


OptionButton.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

OptionButton.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified option button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthLeft

expression A variable that represents an OptionButton object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


TextBox.AsianLineBreak Property (Access)

 Copy code hover
[image]

TextBox.AsianLineBreak Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Boolean indicating whether line breaks in text boxes follow rules governing East Asian languages. True to control line breaks based on East Asian language rules. Read/write.

Syntax

expression .AsianLineBreak

expression A variable that represents a TextBox object.

Remarks

Setting the AsianLineBreak property to True moves any punctuation marks and closing parentheses at the beginning of a line to the end of the previous line, and moves opening parentheses at the end of a line to the beginning of the next line.

Example

This example sets all the text boxes on the specified form to break lines according to East Asian language rules.

VBA Copy code Copy code
Dim ctlLoop As Control

For Each ctlLoop In Forms(0).Controls
 If ctlLoop.ControlType = acTextBox Then
 ctlLoop.AsianLineBreak = True
 End If
Next ctlLoop

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ComboBox.OnDirty Property (Access)

 Copy code hover
[image]

ComboBox.OnDirty Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dirty box in the Properties window of a form or report. Read/write String.

Syntax

expression .OnDirty

expression A variable that represents a ComboBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Dirty event occurs when the contents of a form or the text portion of a combo box changes. It also occurs when you move from one page to another page in a tab control.

The OnClose value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dirty box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dirty box is blank, the property value is an empty string.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Label.GridlineStyleTop Property (Access)

 Copy code hover
[image]

Label.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified label. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleTop

expression A variable that represents a Label object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

Label Object

Other resources

Label Object Members


The Design Master or replica is not being managed by a Synchronizer. (Error 3502)

 Copy code hover
[image]

The Design Master or replica is not being managed by a Synchronizer. (Error 3502)
Send feedback

You are attempting to get information about the Design Master or a replica that is not managed by a Synchronizer.


Field.Required Property (DAO)

 Copy code hover
[image]

Field.Required Property (DAO)
Send feedback

Sets or returns a value that indicates whether a Field object requires a non-Null value.

Syntax

expression .Required

expression A variable that represents a Field object.

Remarks

For a Field not yet appended to the Fields collection, this property is read/write.

The availability of the Required property depends on the object that contains the Fields collection, as shown in the following table.

If the Fields collection belongs to a | Then Required is
Index object | Not supported
QueryDef object | Read-only
Recordset object | Read-only
Relation object | Not supported
TableDef object | Read/write

You can use the Required property along with the AllowZeroLength, ValidateOnSet, or ValidationRule property to determine the validity of the Value property setting for that Field object. If the Required property is set to False, the field can contain null values as well as values that meet the conditions specified by the AllowZeroLength and ValidationRule property settings.

Note Note

When you can set this property for either an Index object or a Field object, set it for the Field object. The validity of the property setting for a Field object is checked before that of an Index object.

Example

This example uses the Required property to report which fields in three different tables must contain data in order for a new record to be added. The RequiredOutput procedure is required for this procedure to run.

VBA Copy code Copy code
Sub RequiredX()

 Dim dbsNorthwind As Database
 Dim tdfloop As TableDef

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind
 ' Show which fields are required in the Fields
 ' collections of three different TableDef objects.
 RequiredOutput .TableDefs("Categories")
 RequiredOutput .TableDefs("Customers")
 RequiredOutput .TableDefs("Employees")
 .Close
 End With

End Sub

Sub RequiredOutput(tdfTemp As TableDef)

 Dim fldLoop As Field

 ' Enumerate Fields collection of the specified TableDef
 ' and show the Required property.
 Debug.Print "Fields in " & tdfTemp.Name & ":"
 For Each fldLoop In tdfTemp.Fields
 Debug.Print , fldLoop.Name & ", Required = " & _
 fldLoop.Required
 Next fldLoop

End Sub


ListBox Events (Access)

 Copy code hover
[image]

ListBox Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.


Section.Application Property (Access)

 Copy code hover
[image]

Section.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a Section object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

Section Object

Other resources

Section Object Members


ToggleButton.KeyPress Event (Access)

 Copy code hover
[image]

ToggleButton.KeyPress Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyPress(KeyAscii)

expression A variable that represents a ToggleButton object.

Parameters

Name | Required/Optional | Data Type | Description
KeyAscii | Required | Integer | Returns a numeric ANSI key code. The KeyAscii argument is passed by reference; changing it sends a different character to the object. Setting the KeyAscii argument to 0 cancels the keystroke so that the object doesn't recognize that a key was pressed.

Remarks

To run a macro or event procedure when this event occurs, set the OnKeyPress property to the name of the macro or to [Event Procedure].

The object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down an ANSI key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

A KeyPress event can involve any printable keyboard character, the CTRL key combined with a character from the standard alphabet or a special character, and the ENTER or BACKSPACE key. You can use the KeyDown and KeyUp event procedures to handle any keystroke not recognized by the KeyPress event, such as function keys, navigation keys, and any combinations of these with keyboard modifiers (ALT, SHIFT, or CTRL keys). Unlike the KeyDown and KeyUp events, the KeyPress event doesn't indicate the physical state of the keyboard; instead, it indicates the ANSI character that corresponds to the pressed key or key combinations.

KeyPress interprets the uppercase and lowercase of each character as separate key codes and, therefore, as two separate characters.

Note Note

The BACKSPACE key is part of the ANSI character set, but the DEL key isn't. If you delete a character in a control by using the BACKSPACE key, you cause a KeyPress event; if you use the DEL key, you don't.

The KeyDown and KeyPress events occur when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

For example, if you go to a new record and type a character in the first control in the record, the following events occur:

Current (for the new record)

ß

Enter (for the first control in the new record)

ß

GotFocus (for the control)

ß

KeyDown (for the control)

ß

KeyPress (for the control)

ß

BeforeInsert (for the new record in the form)

ß

Change (for the control if it's a text box or combo box)

ß

KeyUp (for the control)

Example

The following example converts text entered in a text box to uppercase as the text is typed in, one character at a time.

To try the example, add the following event procedure to a form that contains a text box named ShipRegion.

VBA Copy code Copy code
Private Sub ShipRegion_KeyPress(KeyAscii As Integer)
 Dim strCharacter As String

 ' Convert ANSI value to character string.
 strCharacter = Chr(KeyAscii)
 ' Convert character to upper case, then to ANSI value.
 KeyAscii = Asc(UCase(strCharacter))
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


CommandButton.Hyperlink Property (Access)

 Copy code hover
[image]

CommandButton.Hyperlink Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.

Syntax

expression .Hyperlink

expression A variable that represents a CommandButton object.

Example

The CreateHyperlink procedure in the following example sets the hyperlink properties for a command button, label, or image control to the address and subaddress values passed to the procedure. The address setting is an optional argument, because a hyperlink to an object in the current database uses only the subaddress setting, To try this example, create a form with two text box controls (txtAddress and txtSubAddress) and a command button (cmdFollowLink) and paste the following into the Declarations section of the form's module:

VBA Copy code Copy code
Private Sub cmdFollowLink_Click()
 CreateHyperlink Me!cmdFollowLink, Me!txtSubAddress, _
 Me!txtAddress
End Sub

Sub CreateHyperlink(ctlSelected As Control, _
 strSubAddress As String, Optional strAddress As String)
 Dim hlk As Hyperlink
 Select Case ctlSelected.ControlType
 Case acLabel, acImage, acCommandButton
 Set hlk = ctlSelected.Hyperlink
 With hlk
 If Not IsMissing(strAddress) Then
 .Address = strAddress
 Else
 .Address = ""
 End If
 .SubAddress = strSubAddress
 .Follow
 .Address = ""
 .SubAddress = ""
 End With
 Case Else
 MsgBox "The control '" & ctlSelected.Name _
 & "' does not support hyperlinks."
 End Select
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ToggleButton.ValidationRule Property (Access)

 Copy code hover
[image]

ToggleButton.ValidationRule Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.

Syntax

expression .ValidationRule

expression A variable that represents a ToggleButton object.

Remarks

Enter an expression for the ValidationRule property setting and text for the ValidationText property setting. The maximum length for the ValidationRule property setting is 2048 characters. The maximum length for the ValidationText property setting is 255 characters.

For controls, you can set the ValidationRule property to any valid expression. For field and record validation rules, the expression can't contain user-defined functions, domain aggregate or aggregate functions, the Eval function, or CurrentUser method, or references to forms, queries, or tables. In addition, field validation rules can't contain references to other fields. For records, expressions can include references to fields in that table.

For table fields and records, you can also set these properties in Visual Basic by using the DAO ValidationRule property.

Note Note

The ValidationRule and ValidationText properties don't apply to check box, option button, or toggle buttoncontrols when they are in an option group. They apply only to the option group itself.

Microsoft Access automatically validates values based on a field's data type; for example, Microsoft Access doesn't allow text in a numeric field. You can set rules that are more specific by using the ValidationRule property.

If you set the ValidationRule property but not the ValidationText property, Microsoft Access displays a standard error message when the validation rule is violated. If you set the ValidationText property, the text you enter is displayed as the error message.

For example, when a record is added for a new employee, you can enter a ValidationRule property requiring that the value in the employee's StartDate field fall between the company's founding date and the current date. If the date entered isn't in this range, you can display the ValidationText property message: "Start date is incorrect."

If you create a control by dragging a field from the field list, the field's validation rule remains in effect, although it isn't displayed in the control's ValidationRule property box in the property sheet. This is because a field's validation rule is inherited by a control bound to that field.

Control, field, and record validation rules are applied as follows:

  • Validation rules you set for fields and controls are applied when you edit the data and the focus leaves the field or control.

  • Validation rules for records are applied when you move to another record.

  • If you create validation rules for both a field and a control bound to the field, both validation rules are applied when you edit data and the focus leaves the control.

The following table contains expression examples for the ValidationRule and ValidationText properties.

ValidationRule property | ValidationText property
<> 0 | Entry must be a nonzero value.
> 1000 Or Is Null | Entry must be blank or greater than 1000.
Like "A????" | Entry must be 5 characters and begin with the letter "A".
>= #1/1/96# And <#1/1/97# | Entry must be a date in 1996.
DLookup("CustomerID", "Customers", "CustomerID = Forms!Customers!CustomerID") Is Null | Entry must be a unique CustomerID (domain aggregate functions are allowed only for form-level validation).

If you create a validation rule for a field, Microsoft Access doesn't normally allow a Null value to be stored in the field. If you want to allow a Null value, add "Is Null" to the validation rule, as in "<> 8 Or Is Null" and make sure the Required property is set to No.

You can't set field or record validation rules for tables created outside Microsoft Access (for example, dBASE, Paradox, or SQL Server). For these kinds of tables, you can create validation rules for controls only.

Example

The following example creates a validation rule for a field that allows only values over 65 to be entered. If a number less than 65 is entered, a message is displayed. The properties are set by using the SetFieldValidation function.

VBA Copy code Copy code
Dim strTblName As String, strFldName As String
Dim strValidRule As String
Dim strValidText As String, intX As Integer

strTblName = "Customers"
strFldName = "Age"
strValidRule = ">= 65"
strValidText = "Enter a number greater than or equal to 65."
intX = SetFieldValidation(strTblName, strFldName, _
 strValidRule, strValidText)

Function SetFieldValidation(strTblName As String, _
 strFldName As String, strValidRule As String, _
 strValidText As String) As Integer

 Dim dbs As Database, tdf As TableDef, fld As Field

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 Set fld = tdf.Fields(strFldName)
 fld.ValidationRule = strValidRule
 fld.ValidationText = strValidText
End Function

The next example uses the SetTableValidation function to set record-level validation to ensure that the value in the EndDate field comes after the value in the StartDate field.

VBA Copy code Copy code
Dim strTblName As String, strValidRule As String
Dim strValidText As String
Dim intX As Integer

strTblName = "Employees"
strValidRule = "EndDate > StartDate"
strValidText = "Enter an EndDate that is later than the StartDate."
intX = SetTableValidation(strTblName, strValidRule, strValidText)

Function SetTableValidation(strTblName As String, _
 strValidRule As String, strValidText As String) _
 As Integer

 Dim dbs As Database, tdf As TableDef

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 tdf.ValidationRule = strValidRule
 tdf.ValidationText = strValidText
End Function

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Control.SmartTags Property (Access)

 Copy code hover
[image]

Control.SmartTags Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a SmartTags collection that represents the collection of smart tags that have been added to a control. .

Syntax

expression .SmartTags

expression A variable that represents a Control object.

Remarks

Using the SmartTags property will result in a run-time error if the control is not a ComboBox, Label, or TextBox object.

Note Note

Unlike the SmartTags collections in Microsoft Excel and Microsoft Word, the SmartTags collection in Microsoft Access is zero-based. Therefore, the code control.SmartTags(0) returns the first smart tag for the specified control.

See also

Concepts

Control Object

Other resources

Control Object Members


Could not find field

 Copy code hover
[image]

Could not find field <name>. (Error 3799)
Send feedback

A column name that does not exist is being referenced.


ADO Code Examples (Access)

 Copy code hover
[image]

ADO Code Examples (Access)
Send feedback

In this section

  • ADO Code Examples

  • ADO Code Examples in Microsoft Visual Basic (Access)

  • ADO Code Examples in Microsoft Visual Basic Scripting Edition (Access)

  • ADO Code Examples in Microsoft Visual C++ (Access)

  • ADO Code Examples in Microsoft Visual J++ (Access)

  • ADO Code Examples in Microsoft JScript (Access)


GetString Method Example (VC++)

 Copy code hover
[image]

GetString Method Example (VC++)
Send feedback

This example demonstrates the GetString method.

Assume you are debugging a data access problem and want a quick, simple way of printing the current contents of a small Recordset.

Copy code Copy code

// BeginGetStringCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void GetStringX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 GetStringX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// GetStringX Function //
// //
//////////////////////////////////////////////////////////

void GetStringX(void)
{
 HRESULT hr = S_OK;

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _ConnectionPtr pConnection = NULL;
 _RecordsetPtr pRstAuthors = NULL;

 // Define string variables.
 _bstr_t strCnn("Provider='sqloledb';Data Source='localhost';"
 "Initial Catalog='Northwind';Integrated Security='SSPI';");
 _bstr_t varOutput;
 char *strPrompt = "Enter a state (CA, IN, KS, MD, MI, OR, TN, UT): ";
 char strState[2], *pState;

 try
 {
 // Open connection.
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));

 // Open a command object for a stored procedure,
 // with one parameter.
 TESTHR(pRstAuthors.CreateInstance(__uuidof(Recordset)));

 printf("%s",strPrompt);
 gets(strState);

 pState = strtok(strState," \t");

 char strQry[100] = "SELECT au_fname, au_lname, address, city "
 "FROM authors WHERE state = ";

 strcat(strQry,"'");
 strcat(strQry,pState);
 strcat(strQry,"'");

 _bstr_t strQuery(strQry);

 pConnection->Open (strCnn, "", "", adConnectUnspecified);

 pRstAuthors->Open(strQuery, _variant_t((IDispatch*)pConnection,
 true),
 adOpenStatic, adLockReadOnly, adCmdText);

 if (pRstAuthors->RecordCount > 0)
 {
 // Use all defaults: get all rows, TAB column delimiter,
 // CARRIAGE RETURN row delimiter, empty-string null delimiter
 long lRecCount = pRstAuthors->RecordCount;
 _bstr_t varTab("\t");
 _bstr_t varRet("\r");
 _bstr_t varNull("");
 varOutput = pRstAuthors->GetString(adClipString,lRecCount,
 varTab,varRet,varNull);
 printf("State = '%s'\n", strState);
 printf ("Name Address City\n");
 printf ("%s\n", (LPCTSTR)varOutput);
 }
 else
 {
 printf("\nNo rows found for state = '%s'\n",pState);
 }
 // Clean up objects before exit.
 pRstAuthors->Close();
 pConnection->Close();
 }

 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 PrintProviderError(pConnection);
 PrintComError(e);
 }
}

//////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
//////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,
 pErr->Description);
 }
 }
}

//////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
//////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);

}
// EndGetStringCpp


Intrinsic Constants as Bit Masks

 Copy code hover
[image]

Intrinsic Constants as Bit Masks
Send feedback

Published: July 16, 2012

To test for the Button or Shift arguments, use a bit mask.

The Button argument is a bit field with bits corresponding to the left mouse button (bit 0), right mouse button (bit 1), and middle mouse button (bit 2). These bits correspond to the values 1, 2, and 4, respectively. Only one of the bits is set, indicating which button triggered the event.

The intrinsic constants that Microsoft Access provides for the Button argument have the following values.

Constant | Value
acLeftButton | 1
acRightButton | 2
acMiddleButton | 4

The Shift argument is a bit field, with the least significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. The Shift argument indicates the state of these keys. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys is pressed. For example, if both CTRL and ALT were pressed, the value of the Shift argument would be 6.

The intrinsic constants that Microsoft Access provides for the Shift argument have the following values.

Constant | Value
acShiftMask | 1
acCtrlMask | 2
acAltMask | 4

You can use the constants to test for any combination of buttons and keys without having to figure out the unique bit field value for each combination. A bit is set if the button or key is pressed.


Could not read; currently locked by user

 Copy code hover
[image]

Could not read; currently locked by user <name> on machine <name>. (Error 3187)
Send feedback

You tried to read information on a database page that is currently locked by the specified user. Wait for the other user to finish, and then try the operation again.


ObjectFrame.BorderWidth Property (Access)

 Copy code hover
[image]

ObjectFrame.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Syntax

expression .BorderWidth

expression A variable that represents an ObjectFrame object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Report.ScaleTop Property (Access)

 Copy code hover
[image]

Report.ScaleTop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ScaleTop property to specify the units for the vertical coordinates that describe the location of the top edge of a page when the Circle , Line , Pset , or Print method is used while a report is previewed, printed, or its output is saved to a file. Read / write Single.

Syntax

expression .ScaleTop

expression A variable that represents a Report object.

Remarks

You can set the ScaleTop property by using a macro or a Visual Basic event procedure specified by a section's OnPrint property setting.

By using these properties and the related ScaleHeight and ScaleWidth properties, you can set up a custom coordinate system with both positive and negative coordinates. All four of these Scale properties interact with the ScaleMode property in the following ways:

  • Setting any other Scale property to any value automatically sets the ScaleMode property to 0.

  • Setting the ScaleMode property to a number greater than 0 changes the ScaleHeight and ScaleWidth property settings to the new unit of measurement and sets the ScaleLeft and ScaleTop properties to 0. Also, the CurrentX and CurrentY property settings change to reflect the new coordinates of the current point.

You can also use the Scale method to set the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties in one statement.

Note Note

The ScaleTop property isn't the same as the Top property.

Example

The following example uses the Circle method to draw a circle and create a pie slice within the circle. Then it uses the FillColor and FillStyle properties to color the pie slice red. It also draws a line from the upper left to the center of the circle.

To try this example in Microsoft Access, create a new report. Set the OnPrint property of the Detail section to [Event Procedure]. Enter the following code in the report's module, then switch to Print Preview.

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

 Const conPI = 3.14159265359

 Dim sngHCtr As Single
 Dim sngVCtr As Single
 Dim sngRadius As Single
 Dim sngStart As Single
 Dim sngEnd As Single

 sngHCtr = Me.ScaleWidth / 2 ' Horizontal center.
 sngVCtr = Me.ScaleHeight / 2 ' Vertical center.
 sngRadius = Me.ScaleHeight / 3 ' Circle radius.
 Me.Circle (sngHCtr, sngVCtr), sngRadius ' Draw circle.
 sngStart = -0.00000001 ' Start of pie slice.

 sngEnd = -2 * conPI / 3 ' End of pie slice.
 Me.FillColor = RGB(255, 0, 0) ' Color pie slice red.
 Me.FillStyle = 0 ' Fill pie slice.

 ' Draw Pie slice within circle
 Me.Circle (sngHCtr, sngVCtr), sngRadius, , sngStart, sngEnd

 ' Draw line to center of circle.
 Dim intColor As Integer
 Dim sngTop As Single, sngLeft As Single
 Dim sngWidth As Single, sngHeight As Single

 Me.ScaleMode = 3 ' Set scale to pixels.
 sngTop = Me.ScaleTop ' Top inside edge.
 sngLeft = Me.ScaleLeft ' Left inside edge.
 sngWidth = Me.ScaleWidth / 2 ' Width inside edge.
 sngHeight = Me.ScaleHeight / 2 ' Height inside edge.
 intColor = RGB(255, 0, 0) ' Make color red.

 ' Draw line.
 Me.Line (sngTop, sngLeft)-(sngWidth, sngHeight), intColor

End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


NavigationButton.GridlineColor Property (Access)

 Copy code hover
[image]

NavigationButton.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified list box. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineColor

expression A variable that represents a NavigationButton object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


ODBC - call failed. (Error 3146)

 Copy code hover
[image]

ODBC - call failed. (Error 3146)
Send feedback

Using an ODBC connection, you tried to perform an operation on data in an ODBC data source. This error may occur when the ODBC data source is on a network drive and you are not connected to the network. Make sure the network is available, and then try the operation again.


CheckBox.IsVisible Property (Access)

 Copy code hover
[image]

CheckBox.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Syntax

expression .IsVisible

expression A variable that represents a CheckBox object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Report.Application Property (Access)

 Copy code hover
[image]

Report.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a Report object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

Report Object

Other resources

Report Object Members


Error.Number Property (DAO)

 Copy code hover
[image]

Error.Number Property (DAO)
Send feedback

Returns a numeric value specifying an error.

Syntax

expression .Number

expression A variable that represents an Error object.

Remarks

Use the Number property to determine the error that occurred. The value of the property corresponds to a unique trap number that corresponds to an error condition.

Example

This example forces an error, traps it, and displays the Description, Number, Source, HelpContext, and HelpFile properties of the resulting Error object.

VBA Copy code Copy code
Sub DescriptionX()

 Dim dbsTest As Database

 On Error GoTo ErrorHandler

 ' Intentionally trigger an error.
 Set dbsTest = OpenDatabase("NoDatabase")

 Exit Sub

ErrorHandler:
 Dim strError As String
 Dim errLoop As Error

 ' Enumerate Errors collection and display properties of
 ' each Error object.
 For Each errLoop In Errors
 With errLoop
 strError = _
 "Error #" & .Number & vbCr
 strError = strError & _
 " " & .Description & vbCr
 strError = strError & _
 " (Source: " & .Source & ")" & vbCr
 strError = strError & _
 "Press F1 to see topic " & .HelpContext & vbCr
 strError = strError & _
 " in the file " & .HelpFile & "."
 End With
 MsgBox strError
 Next

 Resume Next

End Sub


Form.SplitFormSize Property (Access)

 Copy code hover
[image]

Form.SplitFormSize Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the size in twips of the form when it's displayed in Split Form view. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .SplitFormSize

expression A variable that represents a Form object.

Remarks

Use the SplitFormSize property when you want to adjust the size of the form and datatsheet. Larger settings for the SplitFormSize property display more of the form, and less of the datasheet.

Setting the SplitFormSize property to 0 resets the form's default size.

See also

Concepts

Form Object

Other resources

Form Object Members


TabControl.Layout Property (Access)

 Copy code hover
[image]

TabControl.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified text box. Read-only AcLayoutType.

Version Information

Version Added: Access 2010

Syntax

expression .Layout

expression A variable that represents a TabControl object.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


NavigationControl.TabIndex Property (Access)

 Copy code hover
[image]

NavigationControl.TabIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .TabIndex

expression A variable that represents a NavigationControl object.

Remarks

You can set the TabIndex property to an integer representing the position of the control within the tab order of the form. Valid settings are 0 for the first tab position, up to the total number of controls minus 1 for the last tab position. For example, if a form has three controls that each have a TabIndex property, valid TabIndex property settings are 0, 1, and 2.

Setting the TabIndex property to an integer less than 0 produces an error.

By default, Microsoft Access assigns a tab order to controls in the order that you create them on a form. Each new control is placed last in the tab order. If you change the setting of a control's TabIndex property to adjust the tab order, Microsoft Access automatically renumbers the TabIndex property setting of other controls to reflect insertions and deletions.

In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the TAB key.

Changing the tab order of other controls on the form doesn't affect what happens when you press a control's access key. For example, if you've created an access key for the label of a text box, the focus will move to the text box whenever you press the label's access key — even if you change the TabIndex property setting for the text box.

If you press an access key for a control such as a label that doesn't have a TabIndex property (and thus isn't in the tab order), the focus moves to the next control in the tab order that can receive the focus.

Example

The following example reverses the tab order of a command button and a text box. Because TextBox1 was created first, it has a TabIndex property setting of 0 and Command1 has a setting of 1.

VBA Copy code Copy code
Sub Form_Click()
 Me!Command1.TabIndex = 0
 Me!TextBox1.TabIndex = 1
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


ADO Errors

 Copy code hover
[image]

ADO Errors
Send feedback

ADO Errors are reported to your program as run-time errors. You can use the error-trapping mechanism of your programming language to trap and handle them. For example, in Visual Basic, use the On Error statement. In Visual J++, use a try-catch block. In Visual C++, it depends on the method you are using to access the ADO libraries. With #import, use a try-catch block. Otherwise, C++ programmers need to explicitly retrieve the error object by calling GetErrorInfo. The following Visual Basic sub procedure demonstrates trapping an ADO error:

Copy code Copy code

' BeginErrorHandlingVB01
Private Sub Form_Load()
 ' Turn on error handling
 On Error GoTo FormLoadError

 'Open the database and the recordset for processing.
 '
 Dim strCnn As String
 strCnn = "Provider='sqloledb';" & _
 "Data Source='MySqlServer';" & _
 "Initial Catalog='Northwind';Integrated Security='SSPI';"

 ' cnn is a Public Connection Object because
 ' it was defined WithEvents
 Set cnn = New ADODB.Connection
 cnn.Open strCnn

 ' The next line of code intentionally causes
 ' an error by trying to open a connection
 ' that has already been opened.
 cnn.Open strCnn

 ' rst is a Public Recordset because it
 ' was defined WithEvents
 Set rst = New ADODB.Recordset
 rst.Open "Customers", cnn

 Exit Sub

' Error handler
FormLoadError:
 Dim strErr As String
 Select Case Err
 Case adErrObjectOpen
 strErr = "Error #" & Err.Number & ": " & Err.Description & vbCrLf
 strErr = strErr & "Error reported by: " & Err.Source & vbCrLf
 strErr = strErr & "Help File: " & Err.HelpFile & vbCrLf
 strErr = strErr & "Topic ID: " & Err.HelpContext
 MsgBox strErr
 Debug.Print strErr
 Err.Clear
 Resume Next
 ' If some other error occurs that
 ' has nothing to do with ADO, show
 ' the number and description and exit.
 Case Else
 strErr = "Error #" & Err.Number & ": " & Err.Description & vbCrLf
 MsgBox strErr
 Debug.Print strErr
 Unload Me
 End Select
End Sub
' EndErrorHandlingVB01

This Form_Load event procedure intentionally creates an error by trying to open the same Connection object twice. The second time the Open method is called, the error handler is activated. In this case the error is of type adErrObjectOpen, so the error handler displays the following message before resuming program execution:

Copy code Copy code

Error #3705: Operation is not allowed when the object is open.
Error reported by: ADODB.Connection
Help File: E:\WINNT\HELP\ADO260.CHM Topic ID: 1003705

The error message includes each piece of information provided by the Visual Basic Err object except for the LastDLLError value, which does not apply here. The error number tells you which error has occurred. The description is useful in cases in which you do not want to handle the error yourself. You can simply pass it along to the user. Although you will usually want to use messages customized for your application, you cannot anticipate every error; the description gives some clue as to what went wrong. In the sample code, the error was reported by the Connection object. You will see the object's type or programmatic ID here — not a variable name.

Note Note

The Visual Basic Err object only contains information about the most recent error. The ADO Errors collection of the Connection object contains one Error object for each error raised by the most recent ADO operation. Use the Errors collection rather than the Err object to handle multiple errors. For more information about the Errors collection, see Provider Errors. However, if there is no valid Connection object, the Err object is the only source for information about ADO errors.

What kinds of operations are likely to cause ADO errors? Common ADO errors can involve opening an object such as a Connection or Recordset, attempting to update data, or calling a method or property that is not supported by your provider.

OLE DB errors can also be passed to your application as run-time errors in the Errors collection. For more information about OLE DB error numbers, see Chapter 16 of the OLE DB Programmer's Reference.


Keys Collection Properties, Methods, and Events (ADOX)

 Copy code hover
[image]

Keys Collection Properties, Methods, and Events (ADOX)
Send feedback

Properties

Count Property

Item Property

Methods

Append Method (Keys)

Delete Method (Collections)

Refresh Method

Events

None.


NavigationControl.LayoutID Property (Access)

 Copy code hover
[image]

NavigationControl.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified text box. Read-only Long.

Version Information

Version Added: Access 2010

Syntax

expression .LayoutID

expression A variable that represents a NavigationControl object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


OptionGroup.LabelX Property (Access)

 Copy code hover
[image]

OptionGroup.LabelX Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelX

expression A variable that represents an OptionGroup object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


OpenSchema Method Example (VB)

 Copy code hover
[image]

OpenSchema Method Example (VB)
Send feedback

This example uses the OpenSchema method to display the name and type of each table in the Pubs database.

Copy code Copy code

'BeginOpenSchemaVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub OpenSchemaX()
 On Error GoTo ErrorHandler

 Dim Cnxn As ADODB.Connection
 Dim rstSchema As ADODB.Recordset
 Dim strCnxn As String

 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 Set rstSchema = Cnxn.OpenSchema(adSchemaTables)

 Do Until rstSchema.EOF
 Debug.Print "Table name: " & _
 rstSchema!TABLE_NAME & vbCr & _
 "Table type: " & rstSchema!TABLE_TYPE & vbCr
 rstSchema.MoveNext
 Loop

 ' clean up
 rstSchema.Close
 Cnxn.Close
 Set rstSchema = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstSchema Is Nothing Then
 If rstSchema.State = adStateOpen Then rstSchema.Close
 End If
 Set rstSchema = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndOpenSchemaVB

This example specifies a TABLE_TYPE query constraint in the OpenSchema method Criteria argument. As a result, only schema information for the Views specified in the Pubs database are returned. The example then displays the name(s) and type(s) of each table(s).

Copy code Copy code

'BeginOpenSchema2VB
Public Sub Main()
 On Error GoTo ErrorHandler

 Dim Cnxn2 As ADODB.Connection
 Dim rstSchema As ADODB.Recordset
 Dim strCnxn As String

 Set Cnxn2 = New ADODB.Connection
 strCnxn = "Provider=sqloledb;" & _
 "Data Source=MySqlServer;Initial Catalog=Pubs;Integrated Security=SSPI; "
 Cnxn2.Open strCnxn

 Set rstSchema = Cnxn2.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "VIEW"))

 Do Until rstSchema.EOF
 Debug.Print "Table name: " & _
 rstSchema!TABLE_NAME & vbCr & _
 "Table type: " & rstSchema!TABLE_TYPE & vbCr
 rstSchema.MoveNext
 Loop

 ' clean up
 rstSchema.Close
 Cnxn2.Close
 Set rstSchema = Nothing
 Set Cnxn2 = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstSchema Is Nothing Then
 If rstSchema.State = adStateOpen Then rstSchema.Close
 End If
 Set rstSchema = Nothing

 If Not Cnxn2 Is Nothing Then
 If Cnxn2.State = adStateOpen Then Cnxn2.Close
 End If
 Set Cnxn2 = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndOpenSchema2VB


OptionButton.AutoLabel Property (Access)

 Copy code hover
[image]

OptionButton.AutoLabel Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.

Syntax

expression .AutoLabel

expression A variable that represents an OptionButton object.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


OriginalValue Property (ADO)

 Copy code hover
[image]

OriginalValue Property (ADO)
Send feedback

Indicates the value of a Field that existed in the record before any changes were made.

Return Value

Returns a Variant value that represents the value of a field prior to any change.

Remarks

Use the OriginalValue property to return the original field value for a field from the current record.

In immediate update mode (in which the provider writes changes to the underlying data source after you call the Update method), the OriginalValue property returns the field value that existed prior to any changes (that is, since the last Update method call). This is the same value that the CancelUpdate method uses to replace the Value property.

In batch update mode (in which the provider caches multiple changes and writes them to the underlying data source only when you call the UpdateBatch method), the OriginalValue property returns the field value that existed prior to any changes (that is, since the last UpdateBatch method call). This is the same value that the CancelBatch method uses to replace the Value property. When you use this property with the UnderlyingValue property, you can resolve conflicts that arise from batch updates.

Record

For Record objects, the OriginalValue property will be empty for fields added before Update is called.


Syntax error in FROM clause. (Error 3131)

 Copy code hover
[image]

Syntax error in FROM clause. (Error 3131)
Send feedback

You entered an SQL statement that has an invalid FROM clause.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


Label.RightMargin Property (Access)

 Copy code hover
[image]

Label.RightMargin Property (Access)
See also Send feedback

Published: July 16, 2012

Along with the TopMargin, Left Margin, and BottomMargin properties, specifies the location of information displayed within a label control. Read/write Integer.

Syntax

expression .RightMargin

expression A variable that represents a Label object.

Remarks

A control's displayed information location is measured from the control's left, top, right, or bottom border to the left, top, right, or bottom edge of the displayed information. To use a unit of measurement different from the setting in the regional settings of Windows, specify the unit (for example, cm or in).

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

Example

The following example offsets the caption in the label "EmployeeID_Label" in the "Purchase Orders" form by 100 twips from the right of the label's border.

VBA Copy code Copy code
With Forms.Item("Purchase Orders").Controls.Item("EmployeeID_Label")
 .RightMargin = 100
End With

See also

Concepts

Label Object

Other resources

Label Object Members


RecordsetOptionEnum Enumeration (DAO)

 Copy code hover
[image]

RecordsetOptionEnum Enumeration (DAO)
Send feedback

Used with the OpenRecordset method to specify characteristics of a new Recordset object.

Name | Value | Description
dbAppendOnly | 8 | Allows user to add new records to the dynaset, but prevents user from reading existing records.
dbConsistent | 32 | Applies updates only to those fields that will not affect other records in the dynaset (dynaset- and snapshot-type only).
dbDenyRead | 2 | Prevents other users from reading Recordset records (table-type only).
dbDenyWrite | 1 | Prevents other users from changing Recordset records.
dbExecDirect | 2048 | Executes the query without first calling the SQLPrepare ODBC function.
dbFailOnError | 128 | Rolls back updates if an error occurs.
dbForwardOnly | 256 | Creates a forward-only scrolling snapshot-type Recordset (snapshot-type only).
dbInconsistent | 16 | Applies updates to all dynaset fields, even if other records are affected (dynaset- and snapshot-type only).
dbReadOnly | 4 | Opens the Recordset as read-only.
dbRunAsync | 1024 | Executes the query asynchronously.
dbSeeChanges | 512 | Generates a run-time error if another user is changing data you are editing (dynaset-type only).
dbSQLPassThrough | 64 | Sends an SQL statement to an ODBC database (snapshot-type only).


ActualSize and DefinedSize Properties Example (VJ++)

 Copy code hover
[image]

ActualSize and DefinedSize Properties Example (VJ++)
Send feedback

This example uses the ActualSize and DefinedSize properties to display the defined size and actual size of a field.

Copy code Copy code

// BeginActualSizeJ
import com.ms.wfc.data.*;
import java.io.*;

public class ActualSizeX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 ActualSizeX();
 System.exit(0);
 }

 // ActualSizeX function

 static void ActualSizeX()
 {

 // Define ADO Objects.
 Recordset rstStores = null;

 // Declarations.
 BufferedReader in = new
 BufferedReader(new InputStreamReader(System.in));
 String line = null;
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";

 String strStoreName;
 String strMessage;
 String strDSize,strASize;
 int intDefinedSize;
 int intActualSize;
 int intChoice = 0;

 try
 {
 // Open recordset with Stores table.
 rstStores = new Recordset();
 rstStores.open("stores", strCnn,
 AdoEnums.CursorType.FORWARDONLY ,
 AdoEnums.LockType.READONLY ,
 AdoEnums.CommandType.TABLE);

 // Loop through the Recordset displaying the contents
 // of the stor_name field, the field's defined size
 // and it's actual size.

 while ( !(rstStores.getEOF( ))) // continuous loop
 {
 // Read data field in the variables.
 strStoreName = rstStores.getField("stor_name").getString();
 intDefinedSize =
 rstStores.getField("stor_name").getDefinedSize();
 strDSize = Integer.toString(intDefinedSize);
 intActualSize = rstStores.getField
 ("stor_name").getActualSize ();
 strASize = Integer.toString(intActualSize);

 // Display current record information.
 strMessage = "\nStore name: " + strStoreName + "\n"
 + "Defined Size : " + strDSize + "\n"
 + "Actual Size : " + strASize;

 System.out.println(strMessage);
 System.out.println("\nPress <Enter> key to continue.");
 in.readLine();
 rstStores.moveNext();
 }
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // Check for null pointer for connection object.
 if (rstStores.getActiveConnection()==null)
 System.out.println("Exception: " + ae.getMessage());
 // As passing a Recordset, check for null pointer first.
 if (rstStores != null)
 {
 PrintProviderError(rstStores.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstStores != null)
 if (rstStores.getState() == 1)
 rstStores.close();
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 //.PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndActualSizeJ


How to: Prompt a User Before Closing a Form

 Copy code hover
[image]

How to: Prompt a User Before Closing a Form
Send feedback

The following example illustrates how to prompt the user to verify that the form should closed.

VBA Copy code Copy code
Private Sub Form_Unload(Cancel As Integer)
 If MsgBox("Are you sure that you want to close this form?", vbYesNo) = vbYes Then
 Exit Sub
 Else
 Cancel = True
 End If
End Sub


MinimizeWindow Macro Action

 Copy code hover
[image]

MinimizeWindow Macro Action
Send feedback

If Microsoft Access 2013 is configured to use overlapping windows instead of tabbed documents, you can use the MinimizeWindow action to reduce the active window to a small title bar at the bottom of the Access window.

Note Note

This action can't be applied to code windows in the Visual Basic Editor. For information about how to affect code windows, see the WindowState property topic.

Setting

The MinimizeWindow action doesn't have any arguments.

Remarks

You can use this action to remove a window from the screen while leaving the object open. You can also use this action to open an object without displaying its window. To display the object, use the SelectObject action with either the MaximizeWindow or RestoreWindow action. The RestoreWindow action restores a minimized window to its previous size.

The MinimizeWindow action has the same effect as clicking the Minimize button in the window's upper-right corner or clicking Minimize on the window's Control menu.

Tips

  • You may first need to use the SelectObject action if the window you want to minimize isn't the active window.

  • To hide the Navigation Pane, use the SelectObject action with the In Navigation Pane argument set to Yes and then use the MinimizeWindow action. The object you select in the SelectObject action can be any object in the database.

  • You can hide the active window by clicking Manage This Window on the View menu, and then clicking Hide. Instead of being reduced to an icon, the window becomes invisible. Use the Unhide command on the same menu to make the window reappear. You can use the RunMenuCommand action to carry out either of these commands from a macro.

  • You can also use the SetValue action to set a form's Visible property to hide or show the form's window.

To run the MinimizeWindow action in a Visual Basic for Applications (VBA) module, use the Minimize method of the DoCmd object.


TextBox.OnGotFocus Property (Access)

 Copy code hover
[image]

TextBox.OnGotFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnGotFocus

expression A variable that represents a TextBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The GotFocus event occurs when the object receives the focus.

The OnGotFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Got Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Got Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnGotFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnGotFocus

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


NavigationButton.PressedTint Property (Access)

 Copy code hover
[image]

NavigationButton.PressedTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the PressedColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .PressedTint

expression A variable that represents a NavigationButton object.

Remarks

The PressedTint property contains a numeric expression that can be used to lighten the theme color in the PressedColor property. The default value of the PressedTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


The Microsoft Access database engine cannot find the input table or query

 Copy code hover
[image]

The Microsoft Access database engine cannot find the input table or query <name>. Make sure it exists and that its name is spelled correctly. (Error 3078)
Send feedback

Possible causes:

  • The specified table or query does not exist.

  • You misspelled the table or query name. Check for missing underscores ( _ ) or other punctuation, and make sure you did not enter leading spaces.


Using the Connection Object Reference (ADO)

 Copy code hover
[image]

Using the Connection Object Reference (ADO)
Send feedback

In this section

  • Using the Connection Object (Access)

  • Creating the Connection String

  • Controlling Transactions


FormatConditions.Count Property (Access)

 Copy code hover
[image]

FormatConditions.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents a FormatConditions object.

See also

Concepts

FormatConditions Collection

Other resources

FormatConditions Object Members


Disk failure while accessing log file

 Copy code hover
[image]

Disk failure while accessing log file <name>. (Error 3473)
Send feedback

The disk drive for the log file may have a bad sector.


CheckBox.Tag Property (Access)

 Copy code hover
[image]

CheckBox.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents a CheckBox object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ADO Technology Table

 Copy code hover
[image]

ADO Technology Table
Send feedback

The following table lists the Microsoft products, tools, and technologies discussed in the ADO Programmer's Guide. It provides links, wherever possible, to relevant topics in the guide.

Microsoft Product or Technology | References
Access/Jet | Working with Recordsets Chapter 15: ADOX Fundamentals Microsoft Jet and Replication Objects OLE DB Provider for Microsoft Jet
Active Directory Service Interfaces | Microsoft OLE DB Provider for Microsoft Active Directory Service
COM/DCOM | Prerequisites Marking Business Objects as Safe for Scripting Registering Business Objects on the Client for Use with DCOM Setting DCOM Stream Marshaling Format Enabling a DLL to Run on DCOM Running Business Objects in Component Services
FrontPage | Microsoft OLE DB Provider for Internet Publishing
Indexing Service | Microsoft OLE DB Provider for Microsoft Indexing Service
Internet Explorer | Internet Explorer Error Codes
Internet Information Services | Chapter 10: Records and Streams Streams and Persistence Using ADO for Internet Publishing Solutions for Remote Data Access Configuring Virtual Servers on IIS Specifying Threads Per Processor on IIS Securing RDS Applications "Internet Server Error: Access Denied" Microsoft OLE DB Provider for Internet Publishing Internet Information Services Error Codes
JScript | Handling Errors in Other Languages JScript ADO Programming ADO Code Examples in Microsoft JScript
ODBC | The Role of ADO in Microsoft Data Access Using the Connection Object Using RDS with ODBC Connection Pooling Microsoft OLE DB Provider for ODBC
OLE DB | The Role of ADO in Microsoft Data Access OLE DB Providers Appendix A: Providers Provider Errors
Oracle | Microsoft OLE DB Provider for Oracle
SQL Server 2000 | Controlling Transactions Calling a Stored Procedure with a Command Counting Rows Forward-Only Cursors Ensuring Sufficient TempDB Space Minimizing Log File Space Usage Microsoft OLE DB Provider for SQL Server
Transaction Server | Running Business Objects in Component Services
VBScript | Handling Errors in Other Languages Visual Basic for Applications Functions Solutions for Remote Data Access RDS Tutorial (VBScript) VBScript ADO Programming ADO Code Examples in Microsoft Visual Basic Scripting Edition
Visual Basic | Errors ADO Errors ADO Event Instantiation By Language Visual Basic for Applications Functions Chapter 12: RDS Tutorial Using ADO with Microsoft Visual Basic ADO Code Examples in Microsoft Visual Basic
Visual C++ | Handling Errors in Other Languages ADO Event Instantiation By Language Using ADO with Microsoft Visual C++ ADO Code Examples in Microsoft Visual C++
Visual J++ | Handling Errors in Other Languages ADO Event Instantiation By Language RDS Tutorial (Visual J++) Using ADO with Microsoft Visual J++ ADO Code Examples in Microsoft Visual J++
Visual Studio | Appendix D: ADO Samples
Windows 2000 | System Requirements for the Address Book Application Granting Guest Privileges to a Web Server Computer Registering a Custom Business Object Securing RDS Applications Configuring RDS on Windows 2000
XML | Persisting Records in XML Format Chapter 10: Records and Streams


Application Members (Access)

 Copy code hover
[image]

Application Members (Access)
Send feedback

Published: July 16, 2012

The Application object refers to the active Microsoft Access application.

Methods

Name | Description
AccessError | You can use the AccessError method to return the descriptive string associated with a Microsoft Access or DAO error.
AddToFavorites | The AddToFavorites method adds a hyperlink address to the Favorites folder.
BuildCriteria | The BuildCriteria method returns a parsed criteria string as it would appear in the query design grid, in Filter By Form or Server Filter By Form mode. For example, you may want to set a form's Filter or ServerFilter property based on varying criteria from the user. You can use the BuildCriteria method to construct the string expression argument for the Filter or ServerFilter property. String.
CloseCurrentDatabase | You can use the CloseCurrentDatabase method to close the current database (either a Microsoft Access database or an Access project (.adp) from another application that has opened a database through Automation.
CodeDb | You can use the CodeDb method in a code module to determine the name of the Database object that refers to the database in which code is currently running. Use the CodeDb method to access Data Access Objects (DAO) that are part of a library database.
ColumnHistory | Gets the history of values that have been stored in a Memo field.
CompactRepair | Compacts and repairs the specified database or Microsoft Access project (.adp) file. Returns a Boolean; True if the process was successful.
ConvertAccessProject | Converts the specified Microsoft Access file from one version to another.
CreateAccessProject | You can use the CreateAccessProject method to create a new Microsoft Access project (.adp) on disk.
CreateAdditionalData | Creates an AdditionalData object that can be used to add additional tables and queries to the parent table that is being exported by the ExportXML method.
CreateControl | The CreateControl method creates a control on a specified open form. For example, suppose you are building a custom wizard that allows users to easily construct a particular form. You can use the CreateControl method in your wizard to add the appropriate controls to the form.
CreateForm | The CreateForm method creates a form and returns a Form object.
CreateGroupLevel | You can use the CreateGroupLevel method to specify a field or expression on which to group or sort data in a report. .
CreateReport | The CreateReport method creates a report and returns a Report object. For example, suppose you are building a custom wizard to create a sales report. You can use the CreateReport method in your wizard to create a new report based on a specified report template.
CreateReportControl | The CreateReportControl method creates a control on a specified open report. For more information, see the CreateControl method.
CurrentDb | The CurrentDb method returns an object variable of type Database that represents the database currently open in the Microsoft Access window.
CurrentUser | You can use the CurrentUser method to return the name of the current user of the database. .
CurrentWebUser | Gets information about the current user of a Web database on Microsoft SharePoint Foundation 2010.
CurrentWebUserGroups | Gets the collection of Microsoft SharePoint Foundation 2010 groups of which the user is a member.
DAvg | You can use the DAvg function to calculate the average of a set of values in a specified set of records (a domain).
DCount | You can use the DCount function to determine the number of records that are in a specified set of records (a domain).
DDEExecute | You can use the DDEExecute statement to send a command from a client application to a server application over an open dynamic data exchange (DDE) channel.
DDEInitiate | You can use the DDEInitiate function to begin a dynamic data exchange (DDE) conversation with another application. The DDEInitiate function opens a DDE channel for transfer of data between a DDE server and client application.
DDEPoke | You can use the DDEPoke statement to supply text data from a client application to a server application over an open dynamic data exchange (DDE) channel.
DDERequest | You can use the DDERequest function over an open dynamic data exchange (DDE) channel to request an item of information from a DDE server application.
DDETerminate | You can use the DDETerminate statement to close a specified dynamic data exchange (DDE) channel.
DDETerminateAll | You can use the DDETerminateAll statement to close all open dynamic data exchange (DDE) channels.
DefaultWorkspaceClone | You can use the DefaultWorkspaceClone method to create a new Workspace object without requiring the user to log on again. For example, if you need to conduct two sets of transactions simultaneously in separate workspaces, you can use the DefaultWorkspaceClone method to create a second Workspace object with the same user name and password without prompting the user for this information again.
DeleteControl | The DeleteControl method deletes a specified control from a form.
DeleteReportControl | The DeleteReportControl method deletes a specified control from a report.
DFirst | You can use the DFirst function to return a random record from a particular field in a table or query when you simply need any value from that field.
DirtyObject | Marks a form or report as dirty.
DLast | You can use the DLast function to return a random record from a particular field in a table or query when you simply need any value from that field. .
DLookup | You can use the DLookup function to get the value of a particular field from a specified set of records (a domain).
DMax | You can use DMax function to determine maximum value in a specified set of records (a domain).
DMin | You can use DMin function to determine minnimum value in a specified set of records (a domain). .
DStDev | Estimates the standard deviation across a population sample in a specified set of records (a domain). .
DStDevP | Estimates the standard deviation across a population in a specified set of records (a domain). .
DSum | You can use the DSum function to calculate the sum of a set of values in a specified set of records (a domain). .
DVar | Estimates the variance across a sample in a specified set of records (a domain).
DVarP | Calculates the variance of a population in a specified set of records (a domain).
Echo | The Echo method specifies whether Microsoft Access repaints the display screen.
EuroConvert | You can use the EuroConvert function to convert a number to euro or from euro to a participating currency. You can also use it to convert a number from one participating currency to another by using the euro as an intermediary (triangulation). The EuroConvert function uses fixed conversion rates established by the European Union.
Eval | You can use the Eval function to evaluate an expression that results in a text string or a numeric value.
ExportNavigationPane | Saves the current configuration of the Navigation Pane to an XML file.
ExportXML | The ExportXML method allows developers to export XML data, schemas, and presentation information from Microsoft SQL Server 2000 Desktop Engine (MSDE 2000), Microsoft SQL Server 6.5 or later, or the Microsoft Access database engine.
FollowHyperlink | The FollowHyperlink method opens the document or Web page specified by a hyperlink address.
GetHiddenAttribute | The GetHiddenAttribute method returns the value of hidden attribute of a Microsoft Access object in the object's Properties dialog box, available by selecting the object in the Database window and clicking Properties on the View menu.
GetOption | The GetOption method returns the current value of an option in the Access Options dialog box, available by clicking the Microsoft Office Button [image] and then clicking Access Options. Variant.
GUIDFromString | The GUIDFromString function converts a string to a GUID, which is an array of type Byte.
HtmlEncode | Converts a string to an HTML-encoded string.
hWndAccessApp | You can use the hWndAccessApp method to determine the handle assigned by Microsoft Windows to the main Microsoft Access window.
HyperlinkPart | The HyperlinkPart method returns information about data stored as a Hyperlink data type. .
ImportNavigationPane | Loads a saved Navigation Pane configuration from disk.
ImportXML | The ImportXML method allows developers to import XML data and/or schema information into Microsoft SQL Server 2000 Desktop Engine (MSDE 2000), Microsoft SQL Server 7.0 or later, or the Microsoft Access database engine.
InstantiateTemplate | Opens a new database and applies the specified template.
IsCurrentWebUserInGroup | Gets whether or not the current user of a Web databse is a member of the specified Microsoft SharePoint Foundation 2010 group.
LoadCustomUI | Loads XML markup that represents a customized ribbon.
LoadFromAXL | Imports the object defined in an Application XML (AXL) file into the database.
LoadPicture | The LoadPicture method loads a graphic into an ActiveX control.
NewAccessProject | You can use the NewAccessProject method to create and open a new Microsoft Access project (.adp) as the current Access project in the Microsoft Access window.
NewCurrentDatabase | Creates a new Microsoft Access database.
Nz | You can use the Nz function to return zero, a zero-length string (" "), or another specified value when a Variant is Null. For example, you can use this function to convert a Null value to another value and prevent it from propagating through an expression.
OpenAccessProject | You can use the OpenAccessProject method to open an existing Microsoft Access project (.adp) as the current Access project in the Microsoft Access window.
OpenCurrentDatabase | You can use the OpenCurrentDatabase method to open an existing Microsoft Access database as the current database.
PlainText | Strips the rich text formatting from a string and returns an unformatted text string.
Quit | The Quit method quits Microsoft Access. You can select one of several options for saving a database object before quitting.
RefreshDatabaseWindow | The RefreshDatabaseWindow method updates the Database window after a database object has been created, deleted, or renamed.
RefreshTitleBar | The RefreshTitleBar method refreshes the Microsoft Access title bar after the AppTitle or AppIcon property has been set in Visual Basic.
Run | You can use the Run method to carry out a specified Microsoft Access or user-defined Function or Sub procedure. Variant.
RunCommand | The RunCommand method runs a built-in command.
SaveAsAXL | Exports the specified object to an Application XML (AXL) file.
SaveAsTemplate | Converts an existing Access database file to a database template (*.accdt) format file.
SetDefaultWorkgroupFile | Sets the default workgroup file to the specified file.
SetHiddenAttribute | The SetHiddenAttribute method sets the hidden attribute of an Access object.
SetOption | The SetOption method sets the current value of an option in the Access Options dialog box.
StringFromGUID | The StringFromGUID function converts a GUID, which is an array of type Byte, to a string.
SysCmd | You can use the SysCmd method to, display a progress meter or optional specified text in the status bar, return information about Microsoft Access and its associated files, or return the state of a specified database object (to indicate whether the object is open, is a new object, or has been changed but not saved). Variant.
TransformXML | Applies an Extensible Stylesheet Language (XSL) stylesheet to an XML data file and writes the resulting XML to an XML data file.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Assistance | Returns an IAssistance object that represents the Microsoft Office Help Viewer. Read-only.
AutoCorrect | Returns an AutoCorrect object that represents the AutoCorrect settings for Microsoft Access. Read-only.
AutomationSecurity | Returns or sets an MsoAutomationSecurity constant that represents the security mode that Microsoft Access uses when it is programmatically opening files. Read/write. .
BrokenReference | Returns a Boolean indicating whether the current database has any broken references to databases or type libraries. True if there are any broken references. Read-only.
Build | Returns as a Long representing the build number of the currently installed copy of Microsoft Access. Read-only.
CodeContextObject | You can use the CodeContextObject property to determine the object in which a macro or Visual Basic code is executing. Read-only Object.
CodeData | You can use the CodeData property to access the CodeData object and its related collections. Read-only CodeData object.
CodeProject | You can use the CodeProject property to access the CodeProject object and its related collections, properties, and methods. Read-only CodeProject object.
COMAddIns | You can use the COMAddIns property to return a reference to the current COMAddIns collection object and its related properties. Read-only COMAddIns object.
CommandBars | You can use the CommandBars property to return a reference to the CommandBars collection object. Read-only CommandBars object.
CurrentData | You can use the CurrentData property to access the CurrentData object and its related collections. Read-only CurrentData object.
CurrentObjectName | You can use the CurrentObjectName property with the Application object to determine the name of the active database object. The active database object is the object that has the focus or in which code is running. Read-only String.
CurrentObjectType | You can use the CurrentObjectType property together with the Application object to determine the type of the active database object (table, query, form, report, macro, module, server view, database diagram, or stored procedure). The active database object is the object that has the focus or in which code is running. Read-only AcObjectType.
CurrentProject | You can use the CurrentProject property to access the CurrentProject object and its related collections, properties, and methods. Read-only CurrentProject object.
DBEngine | You can use the DBEngine property in Visual Basic to access the current DBEngine object and its related properties. Read-only DBEngine.
DoCmd | You can use the DoCmd property to access the read-only DoCmd object and its related methods. Read-only DoCmd.
FeatureInstall | You can use the FeatureInstall property to specify or determine how Microsoft Access handles calls to methods and properties that require features not yet installed. Read/write MsoFeatureInstall.
FileDialog | Returns a FileDialog object which represents a single instance of a file dialog box. Read-only.
Forms | You can use the Forms property to return a read-only reference to the Forms collection and its related properties.
IsCompiled | The IsCompiled property returns a Boolean value indicating whether the Visual Basic project is in a compiled state. Read-only Boolean.
LanguageSettings | You can use the LanguageSettings property to return a read-only reference to the current LanguageSettings object and its related properties.
MacroError | Returns a MacroError object that contains information about the latest error to occur in a macro. Read-only.
MenuBar | Specifies a custom menu to display for a Microsoft Access database. Read/write String.
Modules | You can use the Modules property to access the Modules collection and its related properties. Read-only Modules object.
Name | You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.
NewFileTaskPane | Returns a NewFile object that represents a document listed on the New File task pane. Read-only NewFile object.
Parent | Returns the parent object for the specified object. Read-only.
Printer | Returns or sets a Printer object representing the default printer on the current system. Read/write.
Printers | Returns the Printers collection representing all the available printers on the current system. Read-only Printers collection.
ProductCode | You can use the ProductCode property to determine the Microsoft Access 2013 globally unique identifier (GUID). Read-only String.
References | You can use the References property to access the References collection and its related properties, methods, and events. Read-only References collection.
Reports | You can use the Reports property to access the read-only Reports collection and its related properties.
ReturnVars | Returns the ReturnVars collection representing all the available ReturnVar variables. Read-only ReturnVars collection.
Screen | You can use the Screen property to return a reference the Screen object and its related properties. Read-only.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
TempVars | Returns the collection of TempVar objects. Read-only TempVars.
UserControl | You can use the UserControl property to determine whether the current Microsoft Access application was started by the user or by another application with Automation, formerly called OLE Automation. Read/write Boolean.
VBE | You can use the VBE property to return a reference to the current VBE object and its related properties. The VBE property of the Application object represents the Microsoft Visual Basic for Applications editor. Read-only VBE object.
Version | Returns a String indicating the version number of the currently installed copy of Microsoft Access 2013. Read-only.
Visible | Returns or sets whether a Microsoft Access application is minimized. Read/write Boolean.
WebServices | Gets the collection of installed Data Service data connections. Read-only WebServices.


TextBox.LineSpacing Property (Access)

 Copy code hover
[image]

TextBox.LineSpacing Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the LineSpacing property to specify or determine the location of information displayed within a label or text box control. Read/write Integer.

Syntax

expression .LineSpacing

expression A variable that represents a TextBox object.

Remarks

A control's displayed information location is the distance measured between each line of the displayed information. To use a unit of measurement different from the setting in the Regional Options dialog box in Windows Control Panel, specify the unit, such as cm or in (for example, 3 cm or 2 in).

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

Example

The following example sets the line spacing to 0.25 inches for the text box "PurchaseOrderInformation" on the "Purchase Order Form"

VBA Copy code Copy code
' 0.25 inches = 360/1440 twips.
 Forms("Purchase Orders").Controls("PurchaseOrderDescription").LineSpacing = 360

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


NavigationButton.GotFocus Event (Access)

 Copy code hover
[image]

NavigationButton.GotFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The GotFocus event occurs when the specified object receives the focus.

Version Information

Version Added: Access 2010

Syntax

expression .GotFocus

expression A variable that represents a NavigationButton object.

Return Value

nothing

Remarks

To run a macro or event procedure when these events occur, set the OnGotFocus property to the name of the macro or to [Event Procedure].

These events occur when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The GotFocus event differs from the Enter event in that the GotFocus event occurs every time a control receives the focus. For example, suppose the user clicks a check box on a form, then clicks a report, and finally clicks the check box on the form to bring it to the foreground. The GotFocus event occurs both times the check box receives the focus. In contrast, the Enter event occurs only the first time the user clicks the check box. The GotFocus event occurs after the Enter event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Invalid file format. (Error 3182)

 Copy code hover
[image]

Invalid file format. (Error 3182)
Send feedback

Possible causes:

  • The file you tried to read or link is corrupted. Restore a backup copy of the file to your disk, and then try the operation again.

  • The file format is not recognized. If the file is a Btrieve, dBASE, or Paradox file, run Setup to install the installable ISAM, and then link the file.


OptionGroup.Visible Property (Access)

 Copy code hover
[image]

OptionGroup.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents an OptionGroup object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


ObjectFrame.ControlType Property (Access)

 Copy code hover
[image]

ObjectFrame.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Syntax

expression .ControlType

expression A variable that represents an ObjectFrame object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Containers.Count Property (DAO)

 Copy code hover
[image]

Containers.Count Property (DAO)
Send feedback

Returns the number of Connection objects in the Connections collection.

Syntax

expression .Count

expression A variable that represents a Connections object.

Remarks

Because members of a collection begin with 0, you should always code loops starting with the 0 member and ending with the value of the Count property minus 1. If you want to loop through the members of a collection without checking the Count property, you can use a For Each...Next command.

The Count property setting is never Null. If its value is 0, there are no objects in the collection.


LineSeparatorsEnum

 Copy code hover
[image]

LineSeparatorsEnum
Send feedback

Specifies the character used as a line separator in text Stream objects.

Constant | Value | Description
adCR | 13 | Indicates carriage return.
adCRLF | -1 | Default. Indicates carriage return line feed.
adLF | 10 | Indicates line feed.

ADO/WFC Equivalent

These constants do not have ADO/WFC equivalents.


View Object (ADOX)

 Copy code hover
[image]

View Object (ADOX)
Send feedback

Represents a filtered set of records or a virtual table. When used in conjunction with the ADO Command object, the View object can be used for adding, deleting, or modifying views.

Remarks

A view is a virtual table, created from other database tables or views. The View object allows you to create a view without having to know or use the provider's "CREATE VIEW" syntax.

With the properties of a View object, you can:

  • Identify the view with the Name property.

  • Specify the ADO Command object that can be used to add, delete, or modify views with the Command property.

  • Return date information with the DateCreated and DateModified properties.


PageBreak.SizeToFit Method (Access)

 Copy code hover
[image]

PageBreak.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents a PageBreak object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

PageBreak Object

Other resources

PageBreak Object Members


Report.CurrentX Property (Access)

 Copy code hover
[image]

Report.CurrentX Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the CurrentX property (along with the CurrentY property) to specify the horizontal and vertical coordinates for the starting position of the next printing and drawing method on a report. Read/write Single.

Syntax

expression .CurrentX

expression A variable that represents a Report object.

Remarks

For example, you can use these properties to determine where the center point of a circle is drawn on a report section.

The coordinates are measured from the upper-left corner of the report section that contains the reference to the CurrentX or CurrentY property. The CurrentX property setting is 0 at the section's left edge, and the CurrentY property setting is 0 at its top edge.

You can set the CurrentX and CurrentY properties in an event procedure specified by the OnPrint property setting of a report section.

Use the ScaleMode property to define the unit of measure, such as points, pixels, characters, inches, millimeters, or centimeters, that the coordinates will be based on.

When you use the following graphics methods, the CurrentX and CurrentY property settings are changed as indicated.

Method | Sets CurrentX, CurrentY properties to
Circle | The center of the object.
Line | The end point of the line (the x2, y2 coordinates).
Print | The next print position.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


Index Object (ADOX) Reference

 Copy code hover
[image]

Index Object (ADOX) Reference
Send feedback

In this section

  • Index Object (ADOX)

  • Index Properties, Methods, and Events (ADOX)


SQL Subqueries (Microsoft Access SQL)

 Copy code hover
[image]

SQL Subqueries (Microsoft Access SQL)
Send feedback

A subquery is a SELECT statement nested inside a SELECT, SELECT…INTO, INSERT…INTO, DELETE, or UPDATE statement or inside another subquery.

Syntax

You can use three forms of syntax to create a subquery:

comparison [ANY | ALL | SOME] (sqlstatement)

expression [NOT] IN (sqlstatement)

[NOT] EXISTS (sqlstatement)

A subquery has these parts:

Part | Description
comparison | An expression and a comparison operator that compares the expression with the results of the subquery.
expression | An expression for which the result set of the subquery is searched.
sqlstatement | A SELECT statement, following the same format and rules as any other SELECT statement. It must be enclosed in parentheses.

Remarks

You can use a subquery instead of an expression in the field list of a SELECT statement or in a WHERE or HAVING clause. In a subquery, you use a SELECT statement to provide a set of one or more specific values to evaluate in the WHERE or HAVING clause expression.

Use the ANY or SOME predicate, which are synonymous, to retrieve records in the main query that satisfy the comparison with any records retrieved in the subquery. The following example returns all products whose unit price is greater than that of any product sold at a discount of 25 percent or more:

SQL Copy code Copy code
SELECT * FROM Products
WHERE UnitPrice > ANY
(SELECT UnitPrice FROM OrderDetails
WHERE Discount >= .25);

Use the ALL predicate to retrieve only those records in the main query that satisfy the comparison with all records retrieved in the subquery. If you changed ANY to ALL in the previous example, the query would return only those products whose unit price is greater than that of all products sold at a discount of 25 percent or more. This is much more restrictive.

Use the IN predicate to retrieve only those records in the main query for which some record in the subquery contains an equal value. The following example returns all products with a discount of 25 percent or more:

SQL Copy code Copy code
SELECT * FROM Products
WHERE ProductID IN
(SELECT ProductID FROM OrderDetails
WHERE Discount >= .25);

Conversely, you can use NOT IN to retrieve only those records in the main query for which no record in the subquery contains an equal value.

Use the EXISTS predicate (with the optional NOT reserved word) in true/false comparisons to determine whether the subquery returns any records.

You can also use table name aliases in a subquery to refer to tables listed in a FROM clause outside the subquery. The following example returns the names of employees whose salaries are equal to or greater than the average salary of all employees having the same job title. The Employees table is given the alias "T1":

SQL Copy code Copy code
SELECT LastName,
FirstName, Title, Salary
FROM Employees AS T1
WHERE Salary >= (SELECT Avg(Salary)
FROM Employees
WHERE T1.Title = Employees.Title) Order by Title;

In the preceding example, the AS reserved word is optional.

Some subqueries are allowed in crosstab queries— specifically, as predicates (those in the WHERE clause). Subqueries as output (those in the SELECT list) are not allowed in crosstab queries.

Example

This example lists the name and contact of every customer who placed an order in the second quarter of 1995.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

VBA Copy code Copy code
Sub SubQueryX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' List the name and contact of every customer
    ' who placed an order in the second quarter of
    ' 1995.
    Set rst = dbs.OpenRecordset("SELECT ContactName," _
        & " CompanyName, ContactTitle, Phone" _
        & " FROM Customers" _
        & " WHERE CustomerID" _
        & " IN (SELECT CustomerID FROM Orders" _
        & " WHERE OrderDate Between #04/1/95#" _
        & " And #07/1/95#);")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 25

    dbs.Close

End Sub


MemberTypeEnum

 Copy code hover
[image]

MemberTypeEnum
Send feedback

Specifies the setting for the Type property of a Member object.

Constant | Value | Description
adMemberAll | 4 | Indicates that the Member object represents all members of the level.
adMemberFormula | 3 | Indicates that the Member object is calculated using a formula expression.
adMemberMeasure | 2 | Indicates that the Member object belongs to the Measures dimension and represents a quantitative attribute.
adMemberRegular | 1 | Default. Indicates that the Member object represents an instance of a business entity.
adMemberUnknown | 0 | Cannot determine the type of the member.


SendKeys Macro Action

 Copy code hover
[image]

SendKeys Macro Action
Send feedback

Security note Security Note
Avoid using the SendKeys statement or an AutoKeys macro with sensitive or confidential information. A malicious user could intercept the keystrokes and compromise the security of your computer and data.

You can use the SendKeys action to send keystrokes directly to Microsoft Access or to an active Windows-based application.

Note 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.

Setting

The SendKeys action has the following arguments.

Action argument | Description
Keystrokes | The keystrokes you want Access or the application to process. Enter the keystrokes in the Keystrokes box in the Action Arguments section of the Macro Builder pane. You can type up to 255 characters. This is a required argument.
Wait | Specifies whether the macro should pause until the keystrokes have been processed. Click Yes (to pause) or No (to not pause). The default is No.

Remarks

Access processes the keystrokes it receives through the SendKeys action exactly as if you had typed them directly in an Access window.

To specify the keystrokes, use the same syntax as you would for the SendKeys statement.

Note Note

An error can occur if the Keystrokes argument contains incorrect syntax, misspelled text, or other values that aren't appropriate for the window the keystrokes are sent to.

You can use this action to enter information in a dialog box, particularly if you don't want to interrupt the macro to respond manually to the dialog box. Some Access actions, such as PrintOut and FindRecord, automatically select the options in certain frequently used dialog boxes. You can use the SendKeys action to select the options in less commonly used dialog boxes.

Note Note

  • Because the dialog box suspends the macro, you must put the SendKeys action before the action that causes the dialog box to open and set the Wait argument to No.

  • The timing of the keystrokes reaching Access or another application can be tricky. As a result, it's recommended that if there's some other method (such as the FindRecord action) you can use to achieve a desired task, use that method rather than using the SendKeys action to fill in the options in a dialog box.

If you want to send more than 255 characters to Access or another Windows-based application, you can use several SendKeys actions in succession in a macro.

Using the SendKeys action to send keystrokes triggers the appropriate KeyDown, KeyUp, and KeyPress events. Sending non-ANSI keystrokes (such as a function key) doesn't trigger the KeyPress event.

This action isn't available from a Visual Basic for Applications (VBA) module. Use the SendKeys statement instead.


DoCmd.PrintOut Method (Access)

 Copy code hover
[image]

DoCmd.PrintOut Method (Access)
See also Send feedback

Published: July 16, 2012

The PrintOut method carries out the PrintOut action in Visual Basic.

Syntax

expression .PrintOut(PrintRange, PageFrom, PageTo, PrintQuality, Copies, CollateCopies)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
PrintRange | Optional | AcPrintRange | A AcPrintRange constant that specifies the range to print. The default value is acPrintAll.
PageFrom | Optional | Variant | The first page to print. A numeric expression that's a valid page number in the active form or datasheet. This argument is required if you specify acPages for the printrange argument.
PageTo | Optional | Variant | The last page to print. A numeric expression that's a valid page number in the active form or datasheet. This argument is required if you specify acPages for the printrange argument.
PrintQuality | Optional | AcPrintQuality | A AcPrintQuality constant that specifies the print quality. the default value is acHigh.
Copies | Optional | Variant | The number of copies to print. If you leave this argument blank, the default (1) is assumed.
CollateCopies | Optional | Variant | Use True (-1) to collate copies and False (0) to print without collating. If you leave this argument blank, the default (True) is assumed.

Remarks

You can use the PrintOut action to print the active object in the open database. You can print datasheets, reports, forms, data access pages, and modules.

Example

The following example prints two collated copies of the first four pages of the active form or datasheet:

VBA Copy code Copy code
DoCmd.PrintOut acPages, 1, 4, , 2

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


CommandButton.HorizontalAnchor Property (Access)

 Copy code hover
[image]

CommandButton.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the button is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .HorizontalAnchor

expression A variable that represents a CommandButton object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


WebBrowserControl.SizeToFit Method (Access)

 Copy code hover
[image]

WebBrowserControl.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Version Information

Version Added: Access 2010

Syntax

expression .SizeToFit

expression A variable that represents a WebBrowserControl object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


ComboBox.Column Property (Access)

 Copy code hover
[image]

ComboBox.Column Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Column property to refer to a specific column, or column and row combination, in a multiple-column combo box or list box. Read-only Variant.

Syntax

expression .Column(Index, Row)

expression A variable that represents a ComboBox object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Long | A long integer that can range from 0 to the setting of the ColumnCount property minus one.
Row | Optional | Variant | An integer that can range from 0 to the setting of the ListCount property minus 1.

Remarks

Use 0 to refer to the first column, 1 to refer to the second column, and so on. Use 0 to refer to the first row, 1 to refer to the second row, and so on. For example, in a list box containing a column of customer IDs and a column of customer names, you could refer to the customer name in the second column and fifth row as:

VBA Copy code Copy code
Forms!Contacts!Customers.Column(1, 4)

You can use the Column property to assign the contents of a combo box or list box to another control, such as a text box. For example, to set the ControlSource property of a text box to the value in the second column of a list box, you could use the following expression:

VBA Copy code Copy code
=Forms!Customers!CompanyName.Column(1)

If the user has made no selection when you refer to a column in a combo box or list box, the Column property setting will be Null. You can use the IsNull function to determine if a selection has been made, as in the following example:

VBA Copy code Copy code
If IsNull(Forms!Customers!Country)
 Then MsgBox "No selection."
End If
Note Note

To determine how many columns a combo box or list box has, you can inspect the ColumnCount property setting.

Example

The following example uses the Column property and the ColumnCount property to print the values of a list box selection.

VBA Copy code Copy code
Public Sub Read_ListBox()

 Dim intNumColumns As Integer
 Dim intI As Integer
 Dim frmCust As Form

 Set frmCust = Forms!frmCustomers
 If frmCust!lstCustomerNames.ItemsSelected.Count > 0 Then

 ' Any selection?
 intNumColumns = frmCust!lstCustomerNames.ColumnCount
 Debug.Print "The list box contains "; intNumColumns; _
 IIf(intNumColumns = 1, " column", " columns"); _
 " of data."

 Debug.Print "The current selection contains:"
 For intI = 0 To intNumColumns - 1
 ' Print column data.
 Debug.Print frmCust!lstCustomerNames.Column(intI)
 Next intI
 Else
 Debug.Print "You haven't selected an entry in the " _
 & "list box."
 End If

 Set frmCust = Nothing

End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Application.TransformXML Method (Access)

 Copy code hover
[image]

Application.TransformXML Method (Access)
See also Send feedback

Published: July 16, 2012

Applies an Extensible Stylesheet Language (XSL) stylesheet to an XML data file and writes the resulting XML to an XML data file.

Syntax

expression .TransformXML(DataSource, TransformSource, OutputTarget, WellFormedXMLOutput, ScriptOption)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
DataSource | Required | String | The name and path of the XML file to import.
TransformSource | Required | String | The name and path to the XSL file to apply to the XML data file.
OutputTarget | Required | String | The file name and path for the resulting XML data file after applying the XSL file.
WellFormedXMLOutput | Optional | Boolean | Setting this argument to True will create a well-formed XML file. Setting this argument to False will encode the resulting XML file in UTF-16 format. The default value is False.
ScriptOption | Optional | AcTransformXMLScriptOption | A AcTransformXMLScriptOption constant that specifies the action taken if the XSL file contains scripting code. The default value is acPromptScript.

Return Value

Nothing

Remarks

Setting the WellFormedXMLOutput argument to True will result in a run-time error if the XSL file that you apply does not result in well-formed XML.

See also

Concepts

Application Object

Other resources

Application Object Members


Form.AfterLayout Event (Access)

 Copy code hover
[image]

Form.AfterLayout Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs after all charts in the specfied PivotChart view have been laid out, but before they have been rendered.

Syntax

expression .AfterLayout(drawObject, )

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
drawObject | Required | Object | A ChChartDraw object. Use the methods and properties of this object to draw objects on the chart.

Return Value

nothing

Remarks

During this event, you can reposition the ChTitle, ChLegend, ChChart, and ChAxis objects of each PivotChart view by changing their Left and Top properties. You can reposition the ChPlotArea object by changing its Left, Top, Right, and Bottom properties. These properties cannot be changed outside of this event.

Example

The following example demonstrates the syntax for a subroutine that traps the AfterLayout event.

VBA Copy code Copy code
Private Sub Form_AfterLayout(ByVal drawObject As Object)
 MsgBox "The PivotChart view has been laid out."
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


QueryDef.LastUpdated Property (DAO)

 Copy code hover
[image]

QueryDef.LastUpdated Property (DAO)
Send feedback

Returns the date and time of the most recent change made to an object. Read-only Variant.

Syntax

expression .LastUpdated

expression A variable that represents a QueryDef object.

Remarks

DateCreated and LastUpdated return the date and time that the object was created or last updated. In a multiuser environment, users should get these settings directly from the file server to avoid discrepancies in the DateCreated and LastUpdated property settings.


One or more values are prohibited by the validation rule

 Copy code hover
[image]

One or more values are prohibited by the validation rule <rule> set for <name>. Enter a value that the expression for this field can accept. (Error 3317)
Send feedback

The ValidationRule property for this field contains an expression that limits the values that can be entered in the field. You must enter a value that is not prohibited by the expression.


Chapter 2: Getting Data (ADO)

 Copy code hover
[image]

Chapter 2: Getting Data (ADO)
Send feedback

In this section

  • Chapter 2: Getting Data

  • Making a Connection

  • Using the Connection Object Reference (ADO)

  • Using the Command Object Reference (ADO)

  • Adding Data to a Recordset (ADO)


Report.Section Property (Access)

 Copy code hover
[image]

Report.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Section property to identify a section of a report and provide access to the properties of that section. Read-only Section object.

Syntax

expression .Section(Index)

expression A variable that represents a Report object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | The section number or name.

Remarks

The Section property corresponds to a particular section. You can use the following constants listed below. It is recommended that you use the constants to make your code easier to read.

Setting | Constant | Description
0 | acDetail | Report detail section
1 | acHeader | Report header section
2 | acFooter | Report footer section
3 | acPageHeader | Report page header section
4 | acPageFooter | Report page footer section
5 | acGroupLevel1Header | Group-level 1 header section
6 | acGroupLevel1Footer | Group-level 1 footer section
7 | acGroupLevel2Header | Group-level 2 header section
8 | acGroupLevel2Footer | Group-level 2 footer section
Note Note

If a report has additional group-level sections, the header/footer pairs are numbered consecutively beginning with 9.

The Section property is an array of all existing sections in the form or report specified by the section number. For example, Section(0) refers to a form's detail section and Section(3) refers to a form's page header section.

You can also refer to a section by name. The following statements refer to the Detail0 section for the Customers form and are equivalent.

VBA Copy code Copy code
Forms!Customers.Section(acDetail).Visible
VBA Copy code Copy code
Forms!Customers.Section(0).Visible
VBA Copy code Copy code
Forms!Customers.Detail0.Visible

You must combine the Section property with other properties that apply to form or report sections.

See also

Concepts

Report Object

Other resources

Report Object Members


Parameters Collection, Command Property Example (VB)

 Copy code hover
[image]

Parameters Collection, Command Property Example (VB)
Send feedback

The following code demonstrates how to use the Command property with the Command object to retrieve parameter information for the procedure.

Copy code Copy code

' BeginParametersVB
Sub Main()
 On Error GoTo ProcedureParametersError

 Dim cnn As New ADODB.Connection
 Dim cmd As ADODB.Command
 Dim prm As ADODB.Parameter
 Dim cat As New ADOX.Catalog

 ' Open the Connection
 cnn.Open _
 "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\Microsoft Office\" & _
 "Office\Samples\Northwind.mdb';"

 ' Open the catalog
 Set cat.ActiveConnection = cnn

 ' Get the command object
 Set cmd = cat.Procedures("CustomerById").Command

 ' Retrieve Parameter information
 cmd.Parameters.Refresh
 For Each prm In cmd.Parameters
 Debug.Print prm.Name & ":" & prm.Type
 Next

 'Clean up
 cnn.Close
 Set cat = Nothing
 Set cmd = Nothing
 Set cnn = Nothing
 Exit Sub

ProcedureParametersError:

 Set cat = Nothing
 Set cmd = Nothing

 If Not cnn Is Nothing Then
 If cnn.State = adStateOpen Then cnn.Close
 End If
 Set cnn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndParametersVB


TempVar.Value Property (Access)

 Copy code hover
[image]

TempVar.Value Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the value of the specified TempVar. Read/write Variant.

Version Information

Version Added: Access 2007

Syntax

expression .Value

expression A variable that represents a TempVar object.

Remarks

A TempVar can store only numeric or text data. Setting the Value property to anObject data type will result in a run-time error.

See also

Concepts

TempVar Object

Other resources

TempVar Object Members


Form.FetchDefaults Property (Access)

 Copy code hover
[image]

Form.FetchDefaults Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Boolean indicating whether Microsoft Access shows default values for new rows on the specified form before the row is saved. True if Access shows the default values for new rows on the specified form. Read/write.

Syntax

expression .FetchDefaults

expression A variable that represents a Form object.

Example

The following example sets a form to show default values for new rows.

VBA Copy code Copy code
Forms(0).FetchDefaults = True

See also

Concepts

Form Object

Other resources

Form Object Members


CheckBox.DefaultValue Property (Access)

 Copy code hover
[image]

CheckBox.DefaultValue Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.

Syntax

expression .DefaultValue

expression A variable that represents a CheckBox object.

Remarks

The DefaultValue property applies to all table fields except those fields with the data type of AutoNumber or OLE Object.

The DefaultValue property specifies text or an expression that's automatically entered in a control or field when a new record is created. For example, if you set the DefaultValue property for a text box control to =Now(), the control displays the current date and time. The maximum length for a DefaultValue property setting is 255 characters.

The DefaultValue property doesn't apply to check box, option button, or toggle buttoncontrols when they are in an option group. It does however apply to the option group itself.

In Visual Basic, use a string expression to set the value of this property. For example, the following code sets the DefaultValue property for a text box control named PaymentMethod to "Cash"

VBA Copy code Copy code
Forms!frmInvoice!PaymentMethod.DefaultValue = """Cash"""
Note Note

To set this property for a field by using Visual Basic, use the ADO DefaultValue property or the DAO DefaultValue property.

The DefaultValue property is applied only when you add a new record. If you change the DefaultValue property, the change isn't automatically applied to existing records.

If you set the DefaultValue property for a form control that's bound to a field that also has a DefaultValue property setting defined in the table, the control setting overrides the table setting.

If you create a control by dragging a field from the field list, the field's DefaultValue property setting, as defined in the table, is applied to the control on the form although the control's DefaultValue property setting will remain blank.

One control can provide the default value for another control. For example, if you set the DefaultValue property for a control to the following expression, the control's default value is set to the DefaultValue property setting for the txtShipTo control.

VBA Copy code Copy code
=Forms!frmInvoice!txtShipTo

If the controls are on the same form, the control that's the source of the default value must appear earlier in the tab order than the control containing the expression.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ToggleButton.HideDuplicates Property (Access)

 Copy code hover
[image]

ToggleButton.HideDuplicates Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.

Syntax

expression .HideDuplicates

expression A variable that represents a ToggleButton object.

Remarks

The HideDuplicates property applies only to controls (check box, combo box, list box, option button, option group, text box, toggle button) on a report.

The HideDuplicates property uses the following settings.

Setting | Description
True | If the value of a control or the data it contains is the same as in the preceding record, the control is hidden.
False | (Default) The control is visible regardless of the value in the preceding record.

The DefaultValue property doesn't apply to check box, option button, or toggle buttoncontrols when they are in an option group. It does however apply to the option group itself.

You can set the HideDuplicates property only in report Design view.

You can use the HideDuplicates property to create a grouped report by using only the detail section rather than a group header and the detail section.

Example

The following example returns the HideDuplicates property setting for the CategoryName text box and assigns the value to the intCurVal variable.

VBA Copy code Copy code
Dim intCurVal As Integer
intCurVal = Me!CategoryName.HideDuplicates

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


ParentCatalog Property Example (VB)

 Copy code hover
[image]

ParentCatalog Property Example (VB)
Send feedback

The following code demonstrates how to use the ParentCatalog property to access a provider-specific property prior to appending a table to a catalog. The property is AutoIncrement, which creates an AutoIncrement field in a Microsoft Jet database.

Copy code Copy code

' BeginCreateAutoIncrColumnVB
Sub Main()
 On Error GoTo CreateAutoIncrColumnError

 Dim cnn As New ADODB.Connection
 Dim cat As New ADOX.Catalog
 Dim tbl As New ADOX.Table

 cnn.Open "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\" & _
 "Microsoft Office\Office\Samples\Northwind.mdb';"
 Set cat.ActiveConnection = cnn

 With tbl
 .Name = "MyContacts"
 Set .ParentCatalog = cat
 ' Create fields and append them to the new Table object.
 .Columns.Append "ContactId", adInteger
 ' Make the ContactId column and auto incrementing column
 .Columns("ContactId").Properties("AutoIncrement") = True
 .Columns.Append "CustomerID", adVarWChar
 .Columns.Append "FirstName", adVarWChar
 .Columns.Append "LastName", adVarWChar
 .Columns.Append "Phone", adVarWChar, 20
 .Columns.Append "Notes", adLongVarWChar
 End With

 cat.Tables.Append tbl
 Debug.Print "Table 'MyContacts' is added."

 ' Delete the table as this is a demonstration.
 cat.Tables.Delete tbl.Name
 Debug.Print "Table 'MyContacts' is delete."

 'Clean up
 cnn.Close
 Set cat = Nothing
 Set tbl = Nothing
 Set cnn = Nothing
 Exit Sub

CreateAutoIncrColumnError:

 Set cat = Nothing
 Set tbl = Nothing

 If Not cnn Is Nothing Then
 If cnn.State = adStateOpen Then cnn.Close
 End If
 Set cnn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If

End Sub
' EndCreateAutoIncrColumnVB


The Fields Collection

 Copy code hover
[image]

The Fields Collection
Send feedback

The Fields collection is one of ADO's intrinsic collections. A collection is an ordered set of items that can be referred to as a unit.

The Fields collection contains a Field object for every field (column) in the Recordset. Like all ADO collections, it has Count and Item properties, as well as Append and Refresh methods. It also has CancelUpdate, Delete, Resync, and Update methods, which are not available to other ADO collections.

Examining the Fields Collection

Consider the Fields collection of the sample Recordset introduced in this chapter. The sample Recordset was derived from the SQL statement

Copy code Copy code

SELECT ProductID, ProductName, UnitPrice FROM Products WHERE CategoryID = 7

Thus, you should find that the Recordset Fields collection contains three fields.

Copy code Copy code

'BeginWalkFields
 Dim objFields As ADODB.Fields

 objRs.Open strSQL, strConnStr, adOpenForwardOnly, adLockReadOnly, adCmdText

 Set objFields = objRs.Fields

 For intLoop = 0 To (objFields.Count - 1)
 Debug.Print objFields.Item(intLoop).Name
 Next
'EndWalkFields

This code simply determines the number of Field objects in the Fields collection using the Count property and loops through the collection, returning the value of the Name property for each Field object. You can use many more Field properties to get information about a field. For more information about querying a Field, see The Field Object.

Counting Columns

As you might expect, the Count property returns the actual number of Field objects in the Fields collection. Because numbering for members of a collection begins with zero, you should always code loops starting with the zero member and ending with the value of the Count property minus 1. If you are using Microsoft Visual Basic and want to loop through the members of a collection without checking the Count property, use the For Each...Next command.

If the Count property is zero, there are no objects in the collection.

Getting to the Field

As with any ADO collection, the Item property is the default property of the collection. It returns the individual Field object specified by the name or index passed to it. Therefore, the following statements are equivalent for the sample Recordset:

Copy code Copy code

objField = objRecordset.Fields.Item("ProductID")
objField = objRecordset.Fields("ProductID")
objField = objRecordset.Fields.Item(0)
objField = objRecordset.Fields(0)

If these methods are equivalent, which is best? It depends. Using an index to retrieve a Field from the collection is faster because it accesses the Field directly without having to perform a string lookup. On the other hand, the order of Fields within the collection must be known, and if the order changes, the reference to the Field's index will have to be changed wherever it occurs. Although slightly slower, using the name of the Field is more flexible because it doesn't depend on the order of the Fields in the collection.

Using the Refresh Method

Unlike some other ADO collections, using the Refresh method on the Fields collection has no visible effect. To retrieve changes from the underlying database structure, you must use either the Requery method, or if the Recordset object does not support bookmarks, the MoveFirst method, which will cause the command to be executed against the provider again.

Adding Fields to a Recordset

The Append method is used to add fields to a Recordset.

You can use the Append method to fabricate a Recordset programmatically without opening a connection to a data source. A run-time error will occur if the Append method is called on the Fields collection of an open Recordset or on a Recordset where the ActiveConnection property has been set. You can append fields only to a Recordset that is not open and has not yet been connected to a data source. However, to specify values for the newly appended Fields, the Recordset must first be opened.

Developers often need a place to temporarily store some data, or want some data to act as if it came from a server so it can participate in data binding in a user interface. ADO (in conjunction with the Microsoft Cursor Service for OLE DB) enables the developer to build an empty Recordset object by specifying column information and calling Open. In the following example, three new fields are appended to a new Recordset object. Then the Recordset is opened, two new records are added, and the Recordset is persisted to a file. (For more information about Recordset persistence, see Chapter 5: Updating and Persisting Data.)

Copy code Copy code

 'BeginFabricate
 Dim objRs As New ADODB.Recordset

 With objRs.Fields
 .Append "StudentID", adChar, 11, adFldUpdatable
 .Append "FullName", adVarChar, 50, adFldUpdatable
 .Append "PhoneNmbr", adVarChar, 20, adFldUpdatable
 End With

 With objRs
 .Open

 .AddNew
 .Fields(0) = "123-45-6789"
 .Fields(1) = "John Doe"
 .Fields(2) = "(425) 555-5555"
 .Update

 .AddNew
 .Fields(0) = "123-45-6780"
 .Fields(1) = "Jane Doe"
 .Fields(2) = "(615) 555-1212"
 .Update
 End With

 objRs.Save App.Path & "\FabriTest.adtg", adPersistADTG

 objRs.Close
 'EndFabricate

The usage of the Fields Append method differs between the Recordset object and the Record object. For more information about the Record object, see Chapter 10: Records and Streams.


How to: Retrieve the Name of the User Logged On To the Network

 Copy code hover
[image]

How to: Retrieve the Name of the User Logged On To the Network
Send feedback

This topic contians a user-defined function, GetLogonName, that returns the current user name. The GetLogonName function utilizes the GetUserNameA Windows API to retrieve the current user name.

VBA Copy code Copy code
' Access the GetUserNameA function in advapi32.dll and
' call the function GetUserName.
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
 (ByVal lpBuffer As String, nSize As Long) As Long

' Main routine to retrieve user name.
Function GetLogonName() As String

 ' Dimension variables
 Dim lpBuff As String * 255
 Dim ret As Long

 ' Get the user name minus any trailing spaces found in the name.
 ret = GetUserName(lpBuff, 255)

 If ret > 0 Then
 GetLogonName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
 Else
 GetLogonName = vbNullString
 End If
End Function


ToggleButton.OnMouseMove Property (Access)

 Copy code hover
[image]

ToggleButton.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Syntax

expression .OnMouseMove

expression A variable that represents a ToggleButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


EmptyCell.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

EmptyCell.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified list box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleBottom

expression A variable that represents an EmptyCell object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


Execute, Requery, and Clear Methods Example (JScript)

 Copy code hover
[image]

Execute, Requery, and Clear Methods Example (JScript)
Send feedback

This example demonstrates the Execute method when run from both a Command object and a Connection object. It also uses the Requery method to retrieve current data in a Recordset, and the Clear method to clear the contents of the Errors collection. (The Errors collection is accessed via the Connection object of the ActiveConnection property of the Recordset.) Name the file ExecuteJS.asp.

Copy code Copy code

<!-- BeginExecuteJS -->
<%@LANGUAGE="JScript"%>
<%// use this meta tag instead of adojavas.inc%>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->

<%
 strLastName = new String(Request.Form("AuthorLName"));

 if (strLastName.indexOf("undefined") > -1)
 strLastName = "";
%>

<html>

<head>
<title>Execute, Requery and Clear Methods Example (JScript)</title>
<style>
<!--
BODY {
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 BACKGROUND-COLOR:white;
 COLOR:black;
 }
-->
</style>
</head>

<body bgcolor="White">
<h1>Execute, Requery and Clear Methods Example (JScript)</h1>
<%
 if (strLastName.length > 0)
 {
 // command and recordset variables
 var Connect = "Provider='sqloledb';Data Source=" + Request.ServerVariables("SERVER_NAME") + ";" +
 "Initial Catalog='pubs';Integrated Security='SSPI';";
 var Cnxn = Server.CreateObject("ADODB.Connection");
 var cmdAuthor = Server.CreateObject("ADODB.Command");
 var rsAuthor = Server.CreateObject("ADODB.Recordset");
 var rsAuthor2 = Server.CreateObject("ADODB.Recordset");
 var SQLAuthor2, strMessage, strMessage2;
 var Err, ErrCount;

 try
 {
 // open connection
 Cnxn.Open(Connect);

 // command object parameters
 cmdAuthor.CommandText = "SELECT * FROM Authors WHERE au_lname = ?";
 cmdAuthor.Parameters.Append(cmdAuthor.CreateParameter("Last Name", adChar, adParamInput, 20, strLastName));
 cmdAuthor.ActiveConnection = Cnxn;

 // recordset from command.execute
 rsAuthor = cmdAuthor.Execute();

 // recordset from connection.execute
 SQLAuthor2 = "SELECT * FROM Authors";
 rsAuthor2 = Cnxn.Execute(SQLAuthor2);

 // check for errors
 ErrCount = Cnxn.errors.count;
 if(ErrCount !== 0) //write the errors
 {
 for(Err = 0; Err = ErrCount; Err++){
 Err = Cnxn.errors.item;
 Response.Write(Err);
 }
 // clean out any existing errors
 Cnxn.Errors.Clear;
 }

 // show the data
 Response.Write("<HR><HR>");

 // first recordset
 Response.Write("<b>Command.Execute results</b>")
 while (!rsAuthor.EOF)
 {
 // build output string by starting a new line
 strMessage = "<P>";
 strMessage += "<br>";

 // recordset data
 strMessage += rsAuthor("au_fname") + " ";
 strMessage += rsAuthor("au_lname") + " ";

 // end the line
 strMessage += "</P>";

 // show the results
 Response.Write(strMessage);

 // get next record
 rsAuthor.MoveNext;
 }

 Response.Write("<HR><HR>");

 // second recordset
 Response.Write("<b>Connection.Execute results</b>")
 while (!rsAuthor2.EOF)
 {
 // start a new line
 strMessage2 = "<P>";

 // first and last name are in first column
 strMessage2 += rsAuthor2("au_fname") + " "
 strMessage2 += rsAuthor2("au_lname") + " ";

 // end the line
 strMessage2 += "</P>";

 // show results
 Response.Write(strMessage2);

 // get next record
 rsAuthor2.MoveNext;
 }
 }
 catch (e)
 {
 Response.Write(e.message);
 }
 finally
 {
 // clean up
 if (rsAuthor.State == adStateOpen)
 rsAuthor.Close;
 if (rsAuthor2.State == adStateOpen)
 rsAuthor2.Close;
 if (Cnxn.State == adStateOpen)
 Cnxn.Close;
 rsAuthor1 = null;
 rsAuthor2 = null;
 Cnxn = null;
 }
 }
%>

<hr>

<form method="POST" action="ExecuteJS.asp" id=form1 name=form1>
 <p align="left">Enter last name of author to find (e.g., Ringer): <input type="text" name="AuthorLName" size="40"></p>
 <p align="left"><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>

</html>
<!-- EndExecuteJS -->


TableDef.SourceTableName Property (DAO)

 Copy code hover
[image]

TableDef.SourceTableName Property (DAO)
Send feedback

Sets or returns a value that specifies the name of a linked table or the name of a base table (Microsoft Access workspaces only).

Syntax

expression .SourceTableName

expression A variable that represents a TableDef object.

Remarks

This property setting is read-only for a base table and read/write for a linked table or an object not appended to a collection. For a base table, the setting is a zero-length string ("").

Example

This example uses the Connect and SourceTableName properties to link various external tables to a Microsoft Access database. The ConnectOutput procedure is required for this procedure to run.

VBA Copy code Copy code
Sub ConnectX()

 Dim dbsTemp As Database
 Dim strMenu As String
 Dim strInput As String

 ' Open a Microsoft Access database to which you will link
 ' a table.
 Set dbsTemp = OpenDatabase("DB1.mdb")

 ' Build menu text.
 strMenu = "Enter number for data source:" & vbCr
 strMenu = strMenu & _
 " 1. Microsoft Access database" & vbCr
 strMenu = strMenu & _
 " 2. Microsoft FoxPro 3.0 table" & vbCr
 strMenu = strMenu & _
 " 3. dBASE table" & vbCr
 strMenu = strMenu & _
 " 4. Paradox table" & vbCr
 strMenu = strMenu & _
 " M. (see choices 5-9)"

 ' Get user's choice.
 strInput = InputBox(strMenu)

 If UCase(strInput) = "M" Then

 ' Build menu text.
 strMenu = "Enter number for data source:" & vbCr
 strMenu = strMenu & _
 " 5. Microsoft Excel spreadsheet" & vbCr
 strMenu = strMenu & _
 " 6. Lotus spreadsheet" & vbCr
 strMenu = strMenu & _
 " 7. Comma-delimited text (CSV)" & vbCr
 strMenu = strMenu & _
 " 8. HTML table" & vbCr
 strMenu = strMenu & _
 " 9. Microsoft Exchange folder"

 ' Get user's choice.
 strInput = InputBox(strMenu)

 End If

 ' Call the ConnectOutput procedure. The third argument
 ' will be used as the Connect string, and the fourth
 ' argument will be used as the SourceTableName.
 Select Case Val(strInput)
 Case 1
 ConnectOutput dbsTemp, _
 "AccessTable", _
 ";DATABASE=C:\My Documents\Northwind.mdb", _
 "Employees"
 Case 2
 ConnectOutput dbsTemp, _
 "FoxProTable", _
 "FoxPro 3.0;DATABASE=C:\FoxPro30\Samples", _
 "Q1Sales"
 Case 3
 ConnectOutput dbsTemp, _
 "dBASETable", _
 "dBase IV;DATABASE=C:\dBASE\Samples", _
 "Accounts"
 Case 4
 ConnectOutput dbsTemp, _
 "ParadoxTable", _
 "Paradox 3.X;DATABASE=C:\Paradox\Samples", _
 "Accounts"
 Case 5
 ConnectOutput dbsTemp, _
 "ExcelTable", _
 "Excel 5.0;" & _
 "DATABASE=C:\Excel\Samples\Q1Sales.xls", _
 "January Sales"
 Case 6
 ConnectOutput dbsTemp, _
 "LotusTable", _
 "Lotus WK3;" & _
 "DATABASE=C:\Lotus\Samples\Sales.xls", _
 "THIRDQTR"
 Case 7
 ConnectOutput dbsTemp, _
 "CSVTable", _
 "Text;DATABASE=C:\Samples", _
 "Sample.txt"
 Case 8
 ConnectOutput dbsTemp, _
 "HTMLTable", _
 "HTML Import;DATABASE=http://" & _
 "www.server1.com/samples/page1.html", _
 "Q1SalesData"
 Case 9
 ConnectOutput dbsTemp, _
 "ExchangeTable", _
 "Exchange 4.0;MAPILEVEL=" & _
 "Mailbox - Michelle Wortman (Exchange)" & _
 "|People\Important;", _
 "Jerry Wheeler"
 End Select

 dbsTemp.Close

End Sub

Sub ConnectOutput(dbsTemp As Database, _
 strTable As String, strConnect As String, _
 strSourceTable As String)

 Dim tdfLinked As TableDef
 Dim rstLinked As Recordset
 Dim intTemp As Integer

 ' Create a new TableDef, set its Connect and
 ' SourceTableName properties based on the passed
 ' arguments, and append it to the TableDefs collection.
 Set tdfLinked = dbsTemp.CreateTableDef(strTable)

 tdfLinked.Connect = strConnect
 tdfLinked.SourceTableName = strSourceTable
 dbsTemp.TableDefs.Append tdfLinked

 Set rstLinked = dbsTemp.OpenRecordset(strTable)

 Debug.Print "Data from linked table:"

 ' Display the first three records of the linked table.
 intTemp = 1
 With rstLinked
 Do While Not .EOF And intTemp <= 3
 Debug.Print , .Fields(0), .Fields(1)
 intTemp = intTemp + 1
 .MoveNext
 Loop
 If Not .EOF Then Debug.Print , "[additional records]"
 .Close
 End With

 ' Delete the linked table because this is a demonstration.
 dbsTemp.TableDefs.Delete strTable

End Sub


Values for the DefaultSource Member

 Copy code hover
[image]

Values for the DefaultSource Member
Send feedback

Published: July 16, 2012

Value | Meaning
1 | Upper or only one bin
2 | Lower bin
3 | Middle bin
4 | Manual bin
5 | Envelope bin
6 | Envelope manual bin
7 | Automatic bin
8 | Tractor bin
9 | Small-format bin
10 | Large-format bin
11 | Large-capacity bin
14 | Cassette bin
256 | Device-specific bins start here


MAPI folder or address book not found. (Error 3710)

 Copy code hover
[image]

MAPI folder or address book not found. (Error 3710)
Send feedback

The Microsoft Outlook/Exchange driver could not find the folder or address book that was requested.

  • Check that you have access and permissions to the MAPI store where the folder or address book is held.

  • Check that the connection information is not specific to the location, such as drive mappings of another machine.

  • Check that the name of the folder or address book is spelled correctly.


NavigationControl.BackShade Property (Access)

 Copy code hover
[image]

NavigationControl.BackShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackShade

expression A variable that represents a NavigationControl object.

Remarks

The BackShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the BackShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackShade=25

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


NavigationButton.OnGotFocus Property (Access)

 Copy code hover
[image]

NavigationButton.OnGotFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnGotFocus

expression A variable that represents a NavigationButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The GotFocus event occurs when the object receives the focus.

The OnGotFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Got Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Got Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnGotFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnGotFocus

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


CheckBox.OnDblClick Property (Access)

 Copy code hover
[image]

CheckBox.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Syntax

expression .OnDblClick

expression A variable that represents a CheckBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_DblClick" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Cancel Method Example (VBScript)

 Copy code hover
[image]

Cancel Method Example (VBScript)
Send feedback

The following example shows how to read the Cancel method at run time. Cut and paste the following code to Notepad or another text editor and save it as CancelVBS.asp. You can view the result in any client browser.

VBS Copy code Copy code
<!-- BeginCancelVBS --><Script Language="VBScript">
<!--Sub cmdCancelAsync_OnClick
' Terminates currently running AsyncExecute,' ReadyState property set to adcReadyStateLoaded,
' Recordset set to NothingADC.Cancel
End Sub
Sub cmdRefreshTable_OnClickADC.Refresh
End Sub-->
</Script>
<OBJECT CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID="ADC">.
<PARAM NAME="SQL" VALUE="Select FirstName, LastName from Employees"><PARAM NAME="CONNECT" VALUE="Provider='sqloledb';Integrated Security='SSPI';Initial Catalog='Northwind'">
<PARAM NAME="Server" VALUE="http://<%=Request.ServerVariables("SERVER_NAME")%>">.
</OBJECT>
<TABLE DATASRC=#ADC><TBODY>
<TR><TD><SPAN DATAFLD="FirstName"></SPAN></TD>
<TD><SPAN DATAFLD="LastName"></SPAN></TD></TR>
</TBODY></TABLE>
<FORM><INPUT type="button" value="Refresh" id=cmdRefreshTable name=cmdRefreshTable>
<INPUT type="button" value="Cancel" id=cmdCancelAsync name=cmdCancelAsync></FORM>
<!-- EndCancelVBS -->


CommandButton.PressedForeTint Property (Access)

 Copy code hover
[image]

CommandButton.PressedForeTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .PressedForeTint

expression A variable that represents a CommandButton object.

Remarks

The PressedForeTint property contains a numeric expression that can be used to lighten the theme color in the PressedForeColor property. The default value of the PressedForeTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Parameter (Visual C++ Syntax Index with #import)

 Copy code hover
[image]

Parameter (Visual C++ Syntax Index with #import)
Send feedback

Methods

Copy code Copy code

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthappchunk_HV10294090.xml( const _variant_t & Val );

Properties

Copy code Copy code

long GetAttributes( );
void PutAttributes( long plParmAttribs );
__declspec(property(get=GetAttributes,put=PutAttributes)) long
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdproattributes_HV10294098.xml;

enum ParameterDirectionEnum GetDirection( );
void PutDirection( enum ParameterDirectionEnum plParmDirection );
__declspec(property(get=GetDirection,put=PutDirection)) enum
 ParameterDirectionEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdprodirection_HV10294320.xml;

_bstr_t GetName( );
void PutName( _bstr_t pbstr );
__declspec(property(get=GetName,put=PutName)) _bstr_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdproname_HV10294535.xml;

unsigned char GetNumericScale( );
void PutNumericScale( unsigned char pbScale );
__declspec(property(get=GetNumericScale,put=PutNumericScale)) unsigned
 char Invalid DDUE based on source, error:link not allowed in code, link filename:mdpronumericscale_HV10294551.xml;

unsigned char GetPrecision( );
void PutPrecision( unsigned char pbPrecision );
__declspec(property(get=GetPrecision,put=PutPrecision)) unsigned char
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdproprecision_HV10294615.xml;

long GetSize( );
void PutSize( long pl );
__declspec(property(get=GetSize,put=PutSize)) long Invalid DDUE based on source, error:link not allowed in code, link filename:mdprosize_HV10294779.xml;

enum DataTypeEnum GetType( );
void PutType( enum DataTypeEnum psDataType );
__declspec(property(get=GetType,put=PutType)) enum DataTypeEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdprotype_HV10294866.xml;

_variant_t GetValue( );
void PutValue( const _variant_t & pvar );
__declspec(property(get=GetValue,put=PutValue)) _variant_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdprovalue_HV10294920.xml;


NavigationButton.PressedForeThemeColorIndex Property (Access)

 Copy code hover
[image]

NavigationButton.PressedForeThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedForeColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .PressedForeThemeColorIndex

expression A variable that represents a NavigationButton object.

Remarks

The PressedForeThemeColorIndex uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 (Default) | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the PressedForeThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Control.RightPadding Property (Access)

 Copy code hover
[image]

Control.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the control and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .RightPadding

expression A variable that represents a Control object.

See also

Concepts

Control Object

Other resources

Control Object Members


ObjectFrame.UpdateMethod Property (Access)

 Copy code hover
[image]

ObjectFrame.UpdateMethod Property (Access)
See also Send feedback

Published: July 16, 2012

This property has been deprecated. Use the UpdateOptions property to specify how a linkedOLE object is updated.

Syntax

expression .UpdateMethod

expression A variable that represents an ObjectFrame object.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Saving to the XML DOM Object
Send feedback

Saving to the XML DOM Object

You can save a Recordset in XML format to an instance of an MSXML DOM object, as shown in the following Visual Basic code:

Copy code Copy code

Dim xDOM As New MSXML.DOMDocument
Dim rsXML As New ADODB.Recordset
Dim sSQL As String, sConn As String

sSQL = "SELECT customerid, companyname, contactname FROM customers"
sConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Program Files" & _
        "\Common Files\System\msadc\samples\NWind.mdb"
rsXML.Open sSQL, sConn
rsXML.Save xDOM, adPersistADO   'Save Recordset directly into a DOM tree.
...


Error.Source Property (DAO)

 Copy code hover
[image]

Error.Source Property (DAO)
Send feedback

Returns the name of the object or application that originally generated the error.

Syntax

expression .Source

expression A variable that represents an Error object.

Remarks

The Source property value is usually the object's class name or programmatic ID. Use the Source property to provide your users with information when your code is unable to handle an error generated in an object in another application.

For example, if you access Microsoft Excel and it generates a "Division by zero" error, Microsoft Excel sets Error.Number to the Microsoft Excel code for that error and sets the Source property to Excel.Application. Note that if the error is generated in another object called by Microsoft Excel, Microsoft Excel intercepts the error and still sets Error.Number to the Microsoft Excel code. However, the other Error object properties (including Source) will retain the values as set by the object that generated the error. The Source property always contains the name of the object that originally generated the error.

Based on all of the error documentation, you can write code that will handle the error appropriately. If your error handler fails, you can use the Error object information to describe the error to your user, using the Source property and the other Error properties to give the user information about which object originally caused the error, the description of the error, and so forth.

Note Note

The On Error Resume Next construct may be preferable to On Error GoTo when dealing with errors generated during access to other objects. Checking the Error object property after each interaction with an object removes ambiguity about which object your code was accessing when the error occurred. Thus, you can be sure which object placed the error code in Error.Number, as well as which object originally generated the error (Error.Source).

Example

This example forces an error, traps it, and displays the Description, Number, Source, HelpContext, and HelpFile properties of the resulting Error object.

VBA Copy code Copy code
Sub DescriptionX()

 Dim dbsTest As Database

 On Error GoTo ErrorHandler

 ' Intentionally trigger an error.
 Set dbsTest = OpenDatabase("NoDatabase")

 Exit Sub

ErrorHandler:
 Dim strError As String
 Dim errLoop As Error

 ' Enumerate Errors collection and display properties of
 ' each Error object.
 For Each errLoop In Errors
 With errLoop
 strError = _
 "Error #" & .Number & vbCr
 strError = strError & _
 " " & .Description & vbCr
 strError = strError & _
 " (Source: " & .Source & ")" & vbCr
 strError = strError & _
 "Press F1 to see topic " & .HelpContext & vbCr
 strError = strError & _
 " in the file " & .HelpFile & "."
 End With
 MsgBox strError
 Next

 Resume Next

End Sub


CursorOptionEnum

 Copy code hover
[image]

CursorOptionEnum
Send feedback

Specifies what functionality the Supports method should test for.

Constant | Value | Description
adAddNew | 0x1000400 | Supports the AddNew method to add new records.
adApproxPosition | 0x4000 | Supports the AbsolutePosition and AbsolutePage properties.
adBookmark | 0x2000 | Supports the Bookmark property to gain access to specific records.
adDelete | 0x1000800 | Supports the Delete method to delete records.
adFind | 0x80000 | Supports the Find method to locate a row in a Recordset.
adHoldRecords | 0x100 | Retrieves more records or changes the next position without committing all pending changes.
adIndex | 0x100000 | Supports the Index property to name an index.
adMovePrevious | 0x200 | Supports the MoveFirst and MovePrevious methods, and Move or GetRows methods to move the current record position backward without requiring bookmarks.
adNotify | 0x40000 | Indicates that the underlying data provider supports notifications (which determines whether Recordset events are supported).
adResync | 0x20000 | Supports the Resync method to update the cursor with the data that is visible in the underlying database.
adSeek | 0x200000 | Supports the Seek method to locate a row in a Recordset.
adUpdate | 0x1008000 | Supports the Update method to modify existing data.
adUpdateBatch | 0x10000 | Supports batch updating (UpdateBatch and CancelBatch methods) to transmit groups of changes to the provider.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.CursorOption.ADDNEW

AdoEnums.CursorOption.APPROXPOSITION

AdoEnums.CursorOption.BOOKMARK

AdoEnums.CursorOption.DELETE

AdoEnums.CursorOption.FIND

AdoEnums.CursorOption.HOLDRECORDS

AdoEnums.CursorOption.INDEX

AdoEnums.CursorOption.MOVEPREVIOUS

AdoEnums.CursorOption.NOTIFY

AdoEnums.CursorOption.RESYNC

AdoEnums.CursorOption.SEEK

AdoEnums.CursorOption.UPDATE

AdoEnums.CursorOption.UPDATEBATCH


Description, HelpContext, HelpFile, NativeError, Number, Source, and SQLState Properties Example (VB)

 Copy code hover
[image]

Description, HelpContext, HelpFile, NativeError, Number, Source, and SQLState Properties Example (VB)
Send feedback

This example triggers an error, traps it, and displays the Description, HelpContext, HelpFile, NativeError, Number, Source, and SQLState properties of the resulting Error object.

Copy code Copy code
'BeginDescriptionVB
Public Sub Main()

    Dim Cnxn As ADODB.Connection
    Dim Err As ADODB.Error
    Dim strError As String

    On Error GoTo ErrorHandler

    ' Intentionally trigger an error
    Set Cnxn = New ADODB.Connection
    Cnxn.Open "nothing"

    Set Cnxn = Nothing
    Exit Sub

ErrorHandler:

    ' Enumerate Errors collection and display
    ' properties of each Error object
    For Each Err In Cnxn.Errors
        strError = "Error #" & Err.Number & vbCr & _
            "   " & Err.Description & vbCr & _
            "   (Source: " & Err.Source & ")" & vbCr & _
            "   (SQL State: " & Err.SQLState & ")" & vbCr & _
            "   (NativeError: " & Err.NativeError & ")" & vbCr
        If Err.HelpFile = "" Then
            strError = strError & "   No Help file available"
        Else
            strError = strError & _
               "   (HelpFile: " & Err.HelpFile & ")" & vbCr & _
               "   (HelpContext: " & Err.HelpContext & ")" & _
               vbCr & vbCr
        End If

        Debug.Print strError
    Next

    Resume Next
End Sub
'EndDescriptionVB


MarshalOptions Property Example (VJ++)

 Copy code hover
[image]

MarshalOptions Property Example (VJ++)
Send feedback

This example uses the MarshalOptions property to specify what rows are sent back to the server — All Rows or only Modified Rows.

Copy code Copy code

// BeginMarshalOptionsJ
import java.io.*;
import com.ms.wfc.data.*;

public class MarshalOptionsX
{
 // The main entry point for the application.
 public static void main (String[] args)
 {
 MarshalOptionsX();
 System.exit(0);
 }
 // MarshalX Function

 static void MarshalOptionsX()
 {
 // Define ADO Objects
 Recordset rstEmployees = null;

 // Declarations
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));
 String line = null;

 try
 {

 // Open Recordset with names from Employees Table.
 String strCnn = " Provider='sqloledb';Data Source='MySqlServer';" +
 "Initial Catalog='Pubs';Integrated Security='SSPI';";

 rstEmployees = new Recordset();
 rstEmployees.setCursorType(AdoEnums.CursorType.KEYSET);
 rstEmployees.setLockType(AdoEnums.LockType.OPTIMISTIC);
 rstEmployees.setCursorLocation(AdoEnums.CursorLocation.CLIENT);

 rstEmployees.open(
 "SELECT fname,lname from Employee ORDER BY lname",
 strCnn,AdoEnums.CursorType.KEYSET,
 AdoEnums.LockType.OPTIMISTIC, AdoEnums.CommandType.TEXT);

 // Store original data
 String strOldFirst = rstEmployees.getField("fname").getString();
 String strOldLast = rstEmployees.getField("lname").getString();

 // Change data in edit buffer
 rstEmployees.getField("fname").setString("Linda");
 rstEmployees.getField("lname").setString("Kobara");

 // Show contents of buffer and get user input
 String strMessage = "Edit in progress: "+ "\n"+
 "Original Data = \t"+ strOldFirst +" "+
 strOldLast + "\n" + "Data in Buffer = \t"+
 rstEmployees.getField("fname").getString()+ " " +
 rstEmployees.getField("lname").getString()+"\n"+"\n"+
 "Use Update to replace the original data with " +
 "the buffered data in the recordset";
 String strMarshalAll = "Would you like to send all the rows" +
 " in the recordset back to the server";
 String strMarshalModified = "Would you like to send only "+
 " modified rows back to the server";

 System.out.println(strMessage + "\nEnter (Y/N)...");

 if (in.readLine().equalsIgnoreCase("Y"))
 {
 System.out.println(strMarshalAll);
 System.out.println("\nEnter (Y/N)...");

 if(in.readLine().equalsIgnoreCase("Y"))
 {
 rstEmployees.setMarshalOptions(AdoEnums.MarshalOptions.ALL);
 rstEmployees.update();
 }
 else
 {
 System.out.println(strMarshalModified);
 System.out.println("\nEnter (Y/N)...");

 if (in.readLine().equalsIgnoreCase("Y"))
 {
 rstEmployees.setMarshalOptions(
 AdoEnums.MarshalOptions.MODIFIEDONLY);
 rstEmployees.update();
 }
 }

 }

 // Show the resulting data
 System.out.println("\nData in recordset = " +
 rstEmployees.getField("fname").getString() +
 " " + rstEmployees.getField("lname").getString());

 // Restore original data because this is a demonstration
 if (!((strOldFirst.equals(rstEmployees.getField("fname")))
 &&(strOldLast.equals(rstEmployees.getField("lname")))))
 {
 rstEmployees.getField("fname").setString(strOldFirst);
 rstEmployees.getField("lname").setString(strOldLast);
 rstEmployees.update();
 }

 System.out.println("\n\nPress <Enter> to continue..");
 in.readLine();
 }

 catch(AdoException ae)
 {
 // Notify the user of any errors that result from ADO

 // As passing a connection, check for null pointer first
 if(rstEmployees!= null)
 {
 PrintProviderError(rstEmployees.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getLocalizedMessage());
 }
 }

 // System Read requires this catch
 catch(java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstEmployees != null)
 if (rstEmployees.getState() == 1)
 rstEmployees.close();
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndMarshalOptionsJ


TabControl.OnDblClick Property (Access)

 Copy code hover
[image]

TabControl.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Syntax

expression .OnDblClick

expression A variable that represents a TabControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_DblClick" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


DoCmd.OpenReport Method (Access)

 Copy code hover
[image]

DoCmd.OpenReport Method (Access)
See also Send feedback

Published: July 16, 2012

The OpenReport method carries out the OpenReport action in Visual Basic.

Syntax

expression .OpenReport(ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
ReportName | Required | Variant | A string expression that's the valid name of a report in the current database. If you execute Visual Basic code containing the OpenReport method in a library database, Microsoft Access looks for the report with this name, first in the library database, then in the current database.
View | Optional | AcView | A AcView constant that specifies the view in which the report will open. The default value is acViewNormal.
FilterName | Optional | Variant | A string expression that's the valid name of a query in the current database.
WhereCondition | Optional | Variant | A string expression that's a valid SQL WHERE clause without the word WHERE.
WindowMode | Optional | AcWindowMode | A AcWindowMode constant that specifies the mode in which the form opens. The default valus is acWindowNormal.
OpenArgs | Optional | Variant | Sets the OpenArgs property.

Remarks

You can use the OpenReport method to open a report in Design view or Print Preview, or to print the report immediately. You can also restrict the records that are printed in the report.

The maximum length of the WhereCondition argument is 32,768 characters (unlike the Where Condition action argument in the Macro window, whose maximum length is 256 characters).

Example

The following example prints Sales Report while using the existing query Report Filter.

VBA Copy code Copy code
DoCmd.OpenReport "Sales Report", acViewNormal, "Report Filter"

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


ListBox.Width Property (Access)

 Copy code hover
[image]

ListBox.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents a ListBox object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


AllFunctions Members (Access)

 Copy code hover
[image]

AllFunctions Members (Access)
Send feedback

Published: July 16, 2012

The AllFunctions collection contains an AccessObject object for each function in the CurrentData or CodeData object.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


Label.GridlineThemeColorIndex Property (Access)

 Copy code hover
[image]

Label.GridlineThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineThemeColorIndex

expression A variable that represents a Label object.

Remarks

The GridlineThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 (Default) | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the GridlineThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

Label Object

Other resources

Label Object Members


ComboBox.MouseDown Event (Access)

 Copy code hover
[image]

ComboBox.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents a ComboBox object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
         Shift As Integer, X As Single, _
         Y As Single)
    If Button = acLeftButton Then
        MsgBox "You pressed the left button."
    End If
    If Button = acRightButton Then
        MsgBox "You pressed the right button."
    End If
    If Button = acMiddleButton Then
        MsgBox "You pressed the middle button."
    End If
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Relation.PartialReplica Property (DAO)

 Copy code hover
[image]

Relation.PartialReplica Property (DAO)
Send feedback

Sets or returns a value on a Relation object indicating whether that relation should be considered when populating a partial replica from a full replica. (Microsoft Access database engine databases only). Read/write Boolean.

Syntax

expression .PartialReplica

expression An expression that returns a Relation object.

Remarks

The setting or return value is a Boolean data type that is True when the relation should be enforced during synchronization.

This property enables you to replicate data from the full replica to the partial replica based on relationships between tables. You can use the PartialReplica property when setting the ReplicaFilter property alone can't adequately specify what data should be replicated to the partial. For example, suppose you have a database in which the Customers table has a one-to-many relationship with the Orders table, and you want to configure a partial replica that only replicates orders from customers in the California region (instead of all orders). It is not possible to set the ReplicaFilter property on the Orders table to Region = 'CA' because the Region field is in the Customers table, not the Orders table.

To replicate all orders from the California region, you must indicate that the relation between the Orders and Customers tables will be active during replication. Once you've created a partial replica, the following steps will populate it with all orders from the California region:

  1. Set the ReplicaFilter property on the Customers TableDef object to "Region = 'CA'".

  2. Set the value of the PartialReplica property to True on the Relation object corresponding to the relationship between Orders and Customers.

  3. Invoke the PopulatePartial method.

    Note Note

    When you set a replica filter or replica relation, be aware that records in the partial replica that don't satisfy the restriction criteria will be removed from the partial replica, but not from the full replica. For example, suppose you set the ReplicaFilter property on the Customers TableDef in the partial replica to "Region = 'CA'" and you then repopulate the database. This will insert or update all records for California-based customers. If you then reset the ReplicaFilter property to "Region = 'FL'" and repopulate the database, all California region records in the partial replica will be removed, and all records from Florida-based customers will be inserted from the full replica. No records in the full replica will be deleted. Before setting either the ReplicaFilter or PartialReplica property, it's a good idea to synchronize the partial replica in which you are setting these properties with the full replica. This will ensure that pending changes in the partial replica will be merged into the full replica before any records are removed in the partial replica.


ReturnVars Object (Access)

 Copy code hover
[image]

ReturnVars Object (Access)
Send feedback

Published: July 16, 2012

Represents the collection of ReturnVar objects.

Version Information

Version Added: Access 2010

Remove

The RetunVars collection can store up to 255 ReturnVar objects.


Extra ). (Error 2435)

 Copy code hover
[image]

Extra ). (Error 2435)
Send feedback

You entered an expression that has too many closing parentheses. Delete any parenthesis that does not have a matching opening parenthesis.


DoCmd Object (Access)

 Copy code hover
[image]

DoCmd Object (Access)
See also Send feedback

Published: July 16, 2012

You can use the methods of the DoCmd object to run Microsoft Office Access actions from Visual Basic. An action performs tasks such as closing windows, opening forms, and setting the value of controls.

Remarks

For example, you can use the OpenForm method of the DoCmd object to open a form, or use the Hourglass method to change the mouse pointer to an hourglass icon.

Most of the methods of the DoCmd object have arguments — some are required, while others are optional. If you omit optional arguments, the arguments assume the default values for the particular method. For example, the OpenForm method uses seven arguments, but only the first argument, FormName, is required. The following example shows how you can open the Employees form in the current database. Only employees with the title Sales Representative are included.

VBA Copy code Copy code
DoCmd.OpenForm "Employees", , ,"[Title] = 'Sales Representative'"

The DoCmd object doesn't support methods corresponding to the following actions:

  • AddMenu.

  • MsgBox. Use the MsgBox function.

  • RunApp. Use the Shell function to run another application.

  • RunCode. Run the function directly in Visual Basic.

  • SendKeys. Use the SendKeys statement.

  • SetValue. Set the value directly in Visual Basic.

  • StopAllMacros.

  • StopMacro.

Example

The following example opens a form in Form view and moves to a new record.

VBA Copy code Copy code
Sub ShowNewRecord()
 DoCmd.OpenForm "Employees", acNormal
 DoCmd.GoToRecord , , acNewRec
End Sub

See also

Concepts

Access Object Model Reference

Other resources

DoCmd Object Members


Label.Properties Property (Access)

 Copy code hover
[image]

Label.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a Label object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

Label Object

Other resources

Label Object Members


CommandButton.FontSize Property (Access)

 Copy code hover
[image]

CommandButton.FontSize Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontSize property to specify the point size for text in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Integer.

Syntax

expression .FontSize

expression A variable that represents a CommandButton object.

Remarks

The FontSize property uses the following settings.

Setting | Description
8 | (Default for all reports and controls except command buttons) The text is 8-point type.
10 | (Default for command buttons) The text is 10-point type.
Other sizes | The text is the indicated size.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set this property only in an event procedure or in a macro specified by the OnPrint event property setting.

In Visual Basic, you set the FontSize property by using a numeric expression equal to the desired size of the font. The setting for the FontSize property can be between 1 and 127, inclusive.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Cannot delete a field that is part of an index or is needed by the system. (Error 3280)

 Copy code hover
[image]

Cannot delete a field that is part of an index or is needed by the system. (Error 3280)
Send feedback

To delete a field that is part of an index, you must first delete the index.


Recordset.EditMode Property (DAO)

 Copy code hover
[image]

Recordset.EditMode Property (DAO)
Send feedback

Returns a value that indicates the state of editing for the current record.

Syntax

expression .EditMode

expression A variable that represents a Recordset object.

Remarks

The return value is a Long that indicates the state of editing. The value can be one of the EditModeEnum constants.

The EditMode property is useful when an editing process is interrupted, for example, by an error during validation. You can use the value of the EditMode property to determine whether you should use the Update or CancelUpdate method.

You can also check to see if the LockEdits property setting is True and the EditMode property setting is dbEditInProgress to determine whether the current page is locked.

Example

This example shows the value of the EditMode property under various conditions. The EditModeOutput function is required for this procedure to run.

VBA Copy code Copy code
Sub EditModeX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", _
 dbOpenDynaset)

 ' Show the EditMode property under different editing
 ' states.
 With rstEmployees
 EditModeOutput "Before any Edit or AddNew:", .EditMode
 .Edit
 EditModeOutput "After Edit:", .EditMode
 .Update
 EditModeOutput "After Update:", .EditMode
 .AddNew
 EditModeOutput "After AddNew:", .EditMode
 .CancelUpdate
 EditModeOutput "After CancelUpdate:", .EditMode
 .Close
 End With

 dbsNorthwind.Close

End Sub

Function EditModeOutput(strTemp As String, _
 intEditMode As Integer)

 ' Print report based on the value of the EditMode
 ' property.
 Debug.Print strTemp
 Debug.Print " EditMode = ";

 Select Case intEditMode
 Case dbEditNone
 Debug.Print "dbEditNone"
 Case dbEditInProgress
 Debug.Print "dbEditInProgress"
 Case dbEditAdd
 Debug.Print "dbEditAdd"
 End Select

End Function


Column Properties, Methods, and Events (ADOX)

 Copy code hover
[image]

Column Properties, Methods, and Events (ADOX)
Send feedback

Properties/Collections

Attributes Property

DefinedSize Property

Name Property

NumericScale Property

ParentCatalog Property

Precision Property

Properties Collection

RelatedColumn Property

SortOrder Property

Type Property (Column)

Methods

None.

Events

None.


DoCmd.OpenModule Method (Access)

 Copy code hover
[image]

DoCmd.OpenModule Method (Access)
See also Send feedback

Published: July 16, 2012

The OpenModule method carries out the OpenModule action in Visual Basic.

Syntax

expression .OpenModule(ModuleName, ProcedureName)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
ModuleName | Optional | Variant | A string expression that's the valid name of the Visual Basic module you want to open. If you leave this argument blank, Microsoft Access searches all the standard modules in the database for the procedure you selected with the procedurename argument and opens the module containing the procedure to that procedure. If you execute Visual Basic code containing the OpenModule method in a library database, Microsoft Access looks for the module with this name first in the library database, then in the current database.
ProcedureName | Optional | Variant | A string expression that's the valid name for the procedure you want to open the module to. If you leave this argument blank, the module opens to the Declarations section.

Remarks

You can use the OpenModule method to open a specified Visual Basic module at a specified procedure. This can be a Sub procedure, a Function procedure, or an event procedure.

You must include at least one of the two OpenModule action arguments. If you enter a value for both arguments, Microsoft Access opens the specified module at the specified procedure.

Example

The following example opens the Utility Functions module to the IsLoaded( ) Function procedure:

VBA Copy code Copy code
DoCmd.OpenModule "Utility Functions", "IsLoaded"

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


QueryDef.ReturnsRecords Property (DAO)

 Copy code hover
[image]

QueryDef.ReturnsRecords Property (DAO)
Send feedback

Sets or returns a value that indicates whether an SQL pass-through query to an external database returns records (Microsoft Access workspaces only).

Syntax

expression .ReturnsRecords

expression A variable that represents a QueryDef object.

Remarks

Not all SQL pass-through queries to external databases return records. For example, an SQL UPDATE statement updates records without returning records, while an SQL SELECT statement does return records. If the query returns records, set the ReturnsRecords property to True; if the query doesn't return records, set the ReturnsRecords property to False.

Note Note

You must set the Connect property before you set the ReturnsRecords property.

Example

This example uses the Connect and ReturnsRecords properties to select the top five book titles from a Microsoft SQL Server database based on year-to-date sales amounts. In the event of an exact match in sales amounts, the example increases the size of the list displaying the results of the query and prints a message explaining why this occurred.

VBA Copy code Copy code
Sub ClientServerX1()

 Dim dbsCurrent As Database
 Dim qdfPassThrough As QueryDef
 Dim qdfLocal As QueryDef
 Dim rstTopFive As Recordset
 Dim strMessage As String

 ' Open a database from which QueryDef objects can be
 ' created.
 Set dbsCurrent = OpenDatabase("DB1.mdb")

 ' Create a pass-through query to retrieve data from
 ' a Microsoft SQL Server database.
 Set qdfPassThrough = _
 dbsCurrent.CreateQueryDef("AllTitles")
 ' Note: The DSN referenced below must be set to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 qdfPassThrough.Connect = _
 "ODBC;DATABASE=pubs;DSN=Publishers"
 qdfPassThrough.SQL = "SELECT * FROM titles " & _
 "ORDER BY ytd_sales DESC"
 qdfPassThrough.ReturnsRecords = True

 ' Create a temporary QueryDef object to retrieve
 ' data from the pass-through query.
 Set qdfLocal = dbsCurrent.CreateQueryDef("")
 qdfLocal.SQL = "SELECT TOP 5 title FROM AllTitles"

 Set rstTopFive = qdfLocal.OpenRecordset()

 ' Display results of queries.
 With rstTopFive
 strMessage = _
 "Our top 5 best-selling books are:" & vbCr

 Do While Not .EOF
 strMessage = strMessage & " " & !Title & _
 vbCr
 .MoveNext
 Loop

 If .RecordCount > 5 Then
 strMessage = strMessage & _
 "(There was a tie, resulting in " & _
 vbCr & .RecordCount & _
 " books in the list.)"
 End If

 MsgBox strMessage
 .Close
 End With

 ' Delete new pass-through query because this is a
 ' demonstration.
 dbsCurrent.QueryDefs.Delete "AllTitles"
 dbsCurrent.Close

This example uses the ReturnsRecords property and the custom LogMessages property to create a pass-through query that will return data and any messages generated by the remote server.

VBA Copy code Copy code
Sub LogMessagesX()

 Dim wrkAcc As Workspace
 Dim dbsCurrent As Database
 Dim qdfTemp As QueryDef
 Dim prpNew As Property
 Dim rstTemp As Recordset

 ' Create Microsoft Access Workspace object.
 Set wrkAcc = CreateWorkspace("", "admin", "", dbUseJet)

 Set dbsCurrent = wrkAcc.OpenDatabase("DB1.mdb")

 ' Create a QueryDef that will log any messages from the
 ' server in temporary tables.
 Set qdfTemp = dbsCurrent.CreateQueryDef("NewQueryDef")

 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 qdfTemp.Connect = _
 "ODBC;DATABASE=pubs;DSN=Publishers"
 qdfTemp.SQL = "SELECT * FROM stores"
 qdfTemp.ReturnsRecords = True
 Set prpNew = qdfTemp.CreateProperty("LogMessages", _
 dbBoolean, True)
 qdfTemp.Properties.Append prpNew

 ' Execute query and display results.
 Set rstTemp = qdfTemp.OpenRecordset()

 Debug.Print "Contents of recordset:"
 With rstTemp
 Do While Not .EOF
 Debug.Print , .Fields(0), .Fields(1)
 .MoveNext
 Loop
 .Close
 End With

 ' Delete new QueryDef because this is a demonstration.
 dbsCurrent.QueryDefs.Delete qdfTemp.Name
 dbsCurrent.Close
 wrkAcc.Close

End Sub


The Synchronizer is unable to open the Synchronizer log. (Error 3506)

 Copy code hover
[image]

The Synchronizer is unable to open the Synchronizer log. (Error 3506)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


ListBox.ForeTint Property (Access)

 Copy code hover
[image]

ListBox.ForeTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .ForeTint

expression A variable that represents a ListBox object.

Remarks

The ForeTint property contains a numeric expression that can be used to lighten the theme color in the ForeColor property. The default value of the ForeTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the ForeColor property by 75%.

VBA Copy code Copy code
Me.ctl.ForeTint=25

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


TempVars.Count Property (Access)

 Copy code hover
[image]

TempVars.Count Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the number of TempVar objects in the TempVars collection. Read-only Long.

Version Information

Version Added: Access 2007

Syntax

expression .Count

expression A variable that represents a TempVars object.

See also

Concepts

TempVars Collection

Other resources

TempVars Object Members


Color Builder

 Copy code hover
[image]

Color Builder
Send feedback

Published: July 16, 2012

The Color Builder is a Microsoft Access tool used to select colors from the palette or to create custom colors that you can save and use in forms and reports.

To run this builder, click the Build button next to the appropriate property in the property sheet.


Using Source Code Control In Your Development Environment

 Copy code hover
[image]

Using Source Code Control In Your Development Environment
Send feedback

Published: July 16, 2012

Source code control, also known as version control, is ideal for team development of software applications, publications, manufacturing procedures, or any work that benefits from keeping up with each new version of an object or document. Source code control systems track and store changes to files developed over time. By using Microsoft Visual SourceSafe or another source code control program, team members can review an object's history, revert to earlier versions of an object, and develop applications concurrently.

Visual SourceSafe (and most other source code control programs) provides the following services:

  • Displays differences between two versions of an object.

  • Prevents accidental deletion of objects.

  • Organizes databases into a nearly unlimited hierarchy of projects and subprojects.

  • Checks objects in and out easily, allowing users to add comments to describe what they have done.

  • Enables two or more users to share objects across projects.

  • Works with modular or object-oriented code.

  • Tracks changes users make to objects.

  • Makes older versions of objects readily available for software updates and other purposes.

  • Tracks date and time of changes to all objects in the database.

  • Creates reports on object or project activity.

  • Creates journal files, with records of each change to a database.

  • Controls access to files.

When you have your development projects under Visual SourceSafe control, the contents of your project and the contents of your Visual SourceSafe project remain synchronized. The most common source code control commands are available from the Source Control tab in Microsoft Access.


Deadlocks With Read Repeatable Isolation Level

 Copy code hover
[image]

Deadlocks With Read Repeatable Isolation Level
Send feedback

If a custom business object uses an isolation level of read repeatable to access a SQL Server, and the business object is called simultaneously by two clients that send a query and update in the same transaction, a deadlock is possible. Remote Data Service is designed to allow one of the processes to time out to release the deadlock, but the update will fail for that client.

Use the Cursor Service Command Time Out dynamic property to modify the length of the timeout.


Command Object Overview

 Copy code hover
[image]

Command Object Overview
Send feedback

With the collections, methods, and properties of a Command object, you can do the following:

  • Define the executable text of the command (for example, a SQL statement or a stored procedure) by using the CommandText property.

  • Define parameterized queries or stored procedure arguments by using Parameter objects and the Parameters collection.

  • Execute a command and return a Recordset object, if appropriate, by using the Execute method.

  • Specify the type of command by using the CommandType property prior to execution to optimize performance.

  • Control whether the provider saves a prepared (or compiled) version of the command prior to execution by using the Prepared property.

  • Set the number of seconds that a provider will wait for a command to execute by using the CommandTimeout property.

  • Associate an open connection with a Command object by setting its ActiveConnection property.

  • Set the Name property to identify the Command object as a method on the associated Connection object.

  • Pass a Command object to the Source property of a Recordset in order to obtain data.


FormatCondition.ForeColor Property (Access)

 Copy code hover
[image]

FormatCondition.ForeColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ForeColor property to specify the color for text in a control. Read/write Long.

Syntax

expression .ForeColor

expression A variable that represents a FormatCondition object.

Remarks

You can use this property for controls on forms or reports to make them easy to read or to convey a special meaning. For example, you can change the color of the text in the UnitsInStock control when its value falls below the reorder level.

You can also use this property on reports to create special visual effects when you print with a color printer. When used on a report, this property specifies the printing and drawing color for the Print , Line , and Circle methods.

The ForeColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors for text in controls.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set the Circle property only by using a macro or a Visual Basic event procedure specified in a section's OnPrint event property setting.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

FormatCondition Object

Other resources

FormatCondition Object Members


ResyncEnum

 Copy code hover
[image]

ResyncEnum
Send feedback

Specifies whether underlying values are overwritten by a call to Resync.

Constant | Value | Description
adResyncAllValues | 2 | Default. Overwrites data, and pending updates are canceled.
adResyncUnderlyingValues | 1 | Does not overwrite data, and pending updates are not canceled.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.Resync.ALLVALUES

AdoEnums.Resync.UNDERLYINGVALUES


Invalid Mark setting in the Xbase key of the Windows Registry. (Error 3214)

 Copy code hover
[image]

Invalid Mark setting in the Xbase key of the Windows Registry. (Error 3214)
Send feedback

There is an invalid Mark setting in the Xbase key of the Microsoft Windows Registry.

To fix the Mark setting

  1. Exit your application.

  2. Start the Registry Editor, navigate to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Access Connectivity Engine\Engines\Xbase key, and select the Mark value.

  3. On the Edit menu, click Modify.

  4. Correct the Mark data in the Value data box.

  5. Restart your application, and then try the operation again.


Label Object (Access)

 Copy code hover
[image]

Label Object (Access)
See also Send feedback

Published: July 16, 2012

This object corresponds to a label control. Labels on a form or report display descriptive text such as titles, captions, or brief instructions.

Remarks

Labels have certain characteristics:

  • Labels don't display values from fields or expressions.

  • Labels are always unbound.

  • Labels don't change as you move from record to record.

Control: | Tool:

A label can be attached to another control. When you create a text box, for example, it has an attached label that displays a caption for that text box. This label appears as a column heading in the Datasheet view of a form.

When you create a label by using the Label tool, the label stands on its own — it isn't attached to any other control. You use stand-alone labels for information such as the title of a form or report, or for other descriptive text. Stand-alone labels don't appear in Datasheet view.

See also

Concepts

Access Object Model Reference

Other resources

Label Object Members


Rectangle.MouseMove Event (Access)

 Copy code hover
[image]

Rectangle.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents a Rectangle object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


OptionGroup.Locked Property (Access)

 Copy code hover
[image]

OptionGroup.Locked Property (Access)
See also Send feedback

Published: July 16, 2012

The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.

Syntax

expression .Locked

expression A variable that represents an OptionGroup object.

Remarks

The default setting of the Locked property is True. This setting allows editing, adding, and deleting data.

Use the Locked property to protect data in a field by making it read-only. For example, you might want a control to only display information without allowing editing, or you might want to lock a control until a specific condition is met.

Example

The following example toggles the Enabled property of a command button and the Enabled and Locked properties of a control, depending on the type of employee displayed in the current record. If the employee is a manager, then the SalaryDetails button is enabled and the PersonalInfo control is unlocked and enabled.

VBA Copy code Copy code
Sub Form_Current()
 If Me!EmployeeType = "Manager" Then
 Me!SalaryDetails.Enabled = True
 Me!PersonalInfo.Enabled = True
 Me!PersonalInfo.Locked = False
 Else
 Me!SalaryDetails.Enabled = False
 Me!PersonalInfo.Enabled = False
 Me!PersonalInfo.Locked = True
 End If
End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


SubForm.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

SubForm.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified subform. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleLeft

expression A variable that represents a SubForm object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


NavigationButton.HoverForeTint Property (Access)

 Copy code hover
[image]

NavigationButton.HoverForeTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .HoverForeTint

expression A variable that represents a NavigationButton object.

Remarks

The HoverForeTint property contains a numeric expression that can be used to lighten the theme color in the HoverForeColor property. The default value of the HoverForeTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


CodeProject.Path Property (Access)

 Copy code hover
[image]

CodeProject.Path Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Path property to determine the location where data is stored for a Microsoft Access project (.adp) or Microsoft Access database. Read-only String.

Syntax

expression .Path

expression A variable that represents a CodeProject object.

Remarks

You can use the Path property to determine the location of information stored through the CurrentProject or CodeProject objects of a project or database.

Example

The following example displays a message indicating the disk location of the current Access project or database.

VBA Copy code Copy code
MsgBox "The current database is located at " & Application.CurrentProject.Path & "."

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


TextBox.TextFormat Property (Access)

 Copy code hover
[image]

TextBox.TextFormat Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether rich text is displayed in the specified text box. Read/write AcTextFormat.

Version Information

Version Added: Access 2007

Syntax

expression .TextFormat

expression A variable that represents a TextBox object.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


/ (Divide) (Access 2013 custom web app)

 Copy code hover
[image]

/ (Divide) (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Divides one number by another.

Syntax

dividend / divisor

dividend Is the numeric expression to divide. Can be any valid expression of any one of the data types of the numeric data type category, except the datetime data type.

Divisor Is the numeric expression by which to divide the dividend. Can be any valid expression of any one of the data types of the numeric data type category, except the datetime data type.

Return Type

Returns the data type of the argument with the higher precedence.

If an integer dividend is divided by an integer divisor, the result is an integer that has any fractional part of the result truncated.

Remarks

The actual value returned by the / operator is the quotient of the first expression divided by the second expression.


NavigationControl.AutoTab Property (Access)

 Copy code hover
[image]

NavigationControl.AutoTab Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AutoTab property to specify whether an automatic tab occurs when the last character permitted by a text box control's input mask is entered. An automatic tab moves the focus to the next control in the form's tab order. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .AutoTab

expression A variable that represents a NavigationControl object.

Remarks

The AutoTab property uses the following settings.

Setting | Visual Basic | Description
Yes | True | Generates a tab when the last allowable character in a text box is entered.
No | False | (Default) Doesn't generate a tab when the last allowable character in a text box is entered.

You can also set the default for this property by setting a control's DefaultControl property in Visual Basic.

You can also create an input mask for a text box control bound to a field by setting the InputMask property for the field in the form's underlying table or query. If the field is dragged to a form from the field list, the field's input mask is inherited by the text box control.

You could use the AutoTab property if you have a text box on a form for which you usually enter the maximum number of characters for each record. After you have entered the maximum number of characters, focus automatically moves to the next control in the tab order. For example, you could use this property for a CategoryType field that must always be five characters long.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


PageBreak.InSelection Property (Access)

 Copy code hover
[image]

PageBreak.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents a PageBreak object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

PageBreak Object

Other resources

PageBreak Object Members


Recordset.Connection Property (DAO)

 Copy code hover
[image]

Recordset.Connection Property (DAO)
Send feedback

Returns the Connection object that corresponds to the database.

Syntax

expression .Connection

expression A variable that represents a Recordset object.


Label.NumeralShapes Property (Access)

 Copy code hover
[image]

Label.NumeralShapes Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .NumeralShapes

expression A variable that represents a Label object.

Remarks

The NumeralShapes property uses the following settings.

Setting | Visual Basic | Description
System | 0 | Numeral shapes determined by the Numeral Shapes system setting.
Arabic | 1 | Arabic digit shapes will be used to display and print numerals.
National | 2 | National digit shapes will be used to display and print numerals.
Context | 3 | Numeral shapes determined by Unicode context rules for adjacent text.

Example

The following example changes the NumeralShapes property for the selected control to 0 (numeral shapes will be determined by the Numeral Shapes system setting).

VBA Copy code Copy code
Public Sub ChangeNumeralShapes(ctl As Control)
 ctl.NumeralShapes = 0
End Sub

See also

Concepts

Label Object

Other resources

Label Object Members


NavigationButton.OnEnter Property (Access)

 Copy code hover
[image]

NavigationButton.OnEnter Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .

Version Information

Version Added: Access 2010

Syntax

expression .OnEnter

expression A variable that represents a NavigationButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Enter event occurs before a control actually receives the focus from a control on the same form.

The OnEnter value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Enter box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Enter box is blank, the property value is an empty string.

Example

The following example associates the Enter event with the macro "Enter_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnEnter = "Enter_Macro"

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Filter and RecordCount Properties Example (VB)

 Copy code hover
[image]

Filter and RecordCount Properties Example (VB)
Send feedback

This example open a Recordset on the Publishers table in the Pubs database. It then uses the Filter property to limit the number of visible records to those publishers in a particular country/region. The RecordCount property is used to show the difference between the filtered and unfiltered recordsets.

Copy code Copy code

'BeginFilterVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 ' recordset variables
 Dim rstPublishers As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim SQLPublishers As String

 ' criteria variables
 Dim intPublisherCount As Integer
 Dim strCountry As String
 Dim strMessage As String

 ' open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' open recordset with data from Publishers table
 Set rstPublishers = New ADODB.Recordset
 SQLPublishers = "publishers"
 rstPublishers.Open SQLPublishers, strCnxn, adOpenStatic, , adCmdTable

 intPublisherCount = rstPublishers.RecordCount

 ' get user input
 strCountry = Trim(InputBox("Enter a country to filter on (e.g. USA):"))

 If strCountry <> "" Then
 ' open a filtered Recordset object
 rstPublishers.Filter = "Country ='" & strCountry & "'"

 If rstPublishers.RecordCount = 0 Then
 MsgBox "No publishers from that country."
 Else
 ' print number of records for the original recordset
 ' and the filtered recordset
 strMessage = "Orders in original recordset: " & _
 vbCr & intPublisherCount & vbCr & _
 "Orders in filtered recordset (Country = '" & _
 strCountry & "'): " & vbCr & _
 rstPublishers.RecordCount
 MsgBox strMessage
 End If
 End If

 ' clean up
 rstPublishers.Close
 Cnxn.Close
 Set rstPublishers = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstPublishers Is Nothing Then
 If rstPublishers.State = adStateOpen Then rstPublishers.Close
 End If
 Set rstPublishers = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If

End Sub
'EndFilterVB
Note Note

When you know the data you want to select, it's usually more efficient to open a Recordset with an SQL statement. This example shows how you can create just one Recordset and obtain records from a particular country/region.
Copy code Copy code

'BeginFilter2VB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 Dim rstPublishers As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strSQLPublishers As String
 Dim strCnxn As String

 ' open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' open recordset with criteria from Publishers table
 Set rstPublishers = New ADODB.Recordset
 strSQLPublishers = "SELECT * FROM publishers WHERE Country = 'USA'"
 rstPublishers.Open strSQLPublishers, Cnxn, adOpenStatic, adLockReadOnly, adCmdText

 ' print recordset
 rstPublishers.MoveFirst
 Do While Not rstPublishers.EOF
 Debug.Print rstPublishers!pub_name & ", " & rstPublishers!country
 rstPublishers.MoveNext
 Loop

 ' clean up
 rstPublishers.Close
 Cnxn.Close
 Set rstPublishers = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstPublishers Is Nothing Then
 If rstPublishers.State = adStateOpen Then rstPublishers.Close
 End If
 Set rstPublishers = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndFilter2VB


Image.MouseDown Event (Access)

 Copy code hover
[image]

Image.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents an Image object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
         Shift As Integer, X As Single, _
         Y As Single)
    If Button = acLeftButton Then
        MsgBox "You pressed the left button."
    End If
    If Button = acRightButton Then
        MsgBox "You pressed the right button."
    End If
    If Button = acMiddleButton Then
        MsgBox "You pressed the middle button."
    End If
End Sub

See also

Concepts

Image Object

Other resources

Image Object Members


EmptyCell.HorizontalAnchor Property (Access)

 Copy code hover
[image]

EmptyCell.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the text box is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2010

Syntax

expression .HorizontalAnchor

expression A variable that represents an EmptyCell object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


ListBox.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

ListBox.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents a ListBox object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BorderThemeColorIndex=2

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


OptionGroup.Width Property (Access)

 Copy code hover
[image]

OptionGroup.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents an OptionGroup object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


QueryDef.Type Property (DAO)

 Copy code hover
[image]

QueryDef.Type Property (DAO)
Send feedback

Sets or returns a value that indicates the operational type or data type of an object. Read-onlyInteger.

Syntax

expression .Type

expression A variable that represents a QueryDef object.

Remarks

For a QueryDef object, the possible settings and return values are shown in the following table.

Constant

Query type

dbQAction

Action

dbQAppend

Append

dbQCompound

Compound

dbQCrosstab

Crosstab

dbQDDL

Data-definition

dbQDelete

Delete

dbQMakeTable

Make-table

dbQProcedure

Procedure (ODBCDirect workspaces only)

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

dbQSelect

Select

dbQSetOperation

Union

dbQSPTBulk

Used with dbQSQLPassThrough to specify a query that doesn't return records (Microsoft Access workspaces only).

dbQSQLPassThrough

Pass-through (Microsoft Access workspaces only)

dbQUpdate

Update

When you append a new Field, Parameter, or Property object to the collection of an Index, QueryDef, Recordset, or TableDef object, an error occurs if the underlying database doesn't support the data type specified for the new object.


AccessObject.Parent Property (Access)

 Copy code hover
[image]

AccessObject.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents an AccessObject object.

See also

Concepts

AccessObject Object

Other resources

AccessObject Object Members


Conversion functions (Access 2013 custom web app)

 Copy code hover
[image]

Conversion functions (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • Cast Function (Access 2013 custom web app)

  • Coalesce Function (Access 2013 custom web app)

  • DateWithTimeFromParts Function (Access 2013 custom web app)

  • Format Function (Access 2013 custom web app)

  • Parse Function (Access 2013 custom web app)

  • TimeFromParts Function (Access 2013 custom web app)

  • Try_Parse Function (Access 2013 custom web app)


ToggleButton.LostFocus Event (Access)

 Copy code hover
[image]

ToggleButton.LostFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The LostFocus event occurs when the specified object loses the focus.

Syntax

expression .LostFocus

expression A variable that represents a ToggleButton object.

Remarks

To run a macro or event procedure when these events occur, set the OnLostFocus property to the name of the macro or to [Event Procedure].

This events occurs when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The LostFocus event differs from the Exit event in that the LostFocus event occurs every time a control loses the focus. The Exit event occurs only before a control loses the focus to another control on the same form. The LostFocus event occurs after the Exit event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


WITH (Microsoft Access SQL reserved word)

 Copy code hover
[image]

WITH (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The WITH keyword is used in these contexts:

CREATE INDEX Statement

WITH OWNERACCESS OPTION Declaration


ReturnVar.Name Property (Access)

 Copy code hover
[image]

ReturnVar.Name Property (Access)
Send feedback

Published: July 16, 2012

Gets the name of the specified ReturnVar. Read-only String.

Version Information

Version Added: Access 2010

Syntax

expression .Name

expression A variable that represents a ReturnVar object.


SharedResources Members (Access)

 Copy code hover
[image]

SharedResources Members (Access)
Send feedback

Published: July 16, 2012

Represents the collection of shared resources in the database.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Object.
Parent | Returns the parent object for the specified object. Read-only.


EmptyCell.GridlineThemeColorIndex Property (Access)

 Copy code hover
[image]

EmptyCell.GridlineThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineThemeColorIndex

expression A variable that represents an EmptyCell object.

Remarks

The GridlineThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 (Default) | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the GridlineThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


ListBox.BorderWidth Property (Access)

 Copy code hover
[image]

ListBox.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Syntax

expression .BorderWidth

expression A variable that represents a ListBox object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Chapter 15: ADOX Fundamentals (ADO)

 Copy code hover
[image]

Chapter 15: ADOX Fundamentals (ADO)
Send feedback

In this section

  • Chapter 15: ADOX Fundamentals

  • Provider Support for ADOX


BoundObjectFrame.VarOleObject Property (Access)

 Copy code hover
[image]

BoundObjectFrame.VarOleObject Property (Access)
See also Send feedback

Published: July 16, 2012

Gets a pointer to an IOLEObject that represents the memory address of an OLE object. Read-only Variant.

Version Information

Version Added: Access 2010

Syntax

expression .VarOleObject

expression A variable that represents a BoundObjectFrame object.

Remarks

Note Note

The VarOleObject property is compatible with 32-bit and 64-bit OLE objects. It replaces the LpOLEObject, which was available in earlier versions of Microsoft Access.

You can use the VarOleObject property to refer to the address of the active OLE object. If no object is displayed, the setting is 0.

This property setting is not available in Design view and is read-only in other views.

In the OLE dynamic link libraries (DLLs), many function calls require the address of the OLE object as an argument. You can pass the value specified by the VarOleObject property when you make application programming interface (API) calls to the OLE DLLs.

If an API call is made to a function that performs a callback to the control, the results are unpredictable.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


NavigationControl.Left Property (Access)

 Copy code hover
[image]

NavigationControl.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .Left

expression A variable that represents a NavigationControl object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


DoCmd.CopyObject Method (Access)

 Copy code hover
[image]

DoCmd.CopyObject Method (Access)
See also Send feedback

Published: July 16, 2012

The CopyObject method carries out the CopyObject action in Visual Basic.

Syntax

expression .CopyObject(DestinationDatabase, NewName, SourceObjectType, SourceObjectName)

expression A variable that represents a DoCmd object.

Parameters

Name

Required/Optional

Data Type

Description

DestinationDatabase

Optional

Variant

A string expression that's the valid path and file name for the database you want to copy the object into. To select the current database, leave this argument blank.

Note Note

In a Microsoft Access project (.adp) you must leave the destinationdatabase argument blank. If you execute Visual Basic code containing the CopyObject method in a library database and leave this argument blank, Microsoft Access copies the object into the library database.

NewName

Optional

Variant

A string expression that's the new name for the object you want to copy. To use the same name if you are copying into another database, leave this argument blank.

SourceObjectType

Optional

AcObjectType

A AcObjectType constant that represents the type of object to copy.

SourceObjectName

Optional

Variant

A string expression that's the valid name of an object of the type selected by the sourceobjecttype argument. If you run Visual Basic code containing the CopyObject method in a library database, Microsoft Access looks for the object with this name first in the library database, then in the current database.

Remarks

You can use the CopyObject action to copy the specified database object to a different Microsoft Access database or to the same database or Access project (.adp) under a new name. For example, you can copy or back up an existing object in another database or quickly create a similar object with a few changes.

You must include either the destinationdatabase or newname argument or both for this method.

If you leave the sourceobjecttype and sourceobjectname arguments blank (the default constant, acDefault, is assumed for sourceobjecttype), Microsoft Access copies the object selected in the Database window. To select an object in the Database window, you can use the SelectObject action or SelectObject method with the In Database Window argument set to Yes (True).

If you specify the sourceobjecttype and sourceobjectname arguments but leave either the newname argument or the destinationdatabase argument blank, you must include the newname or destinationdatabase argument's comma. If you leave a trailing argument blank, don't use a comma following the last argument you specify.

Example

The following example uses the CopyObject method to copy the Employees table and give it a new name in the current database:

VBA Copy code Copy code
DoCmd.CopyObject, "Employees Copy", acTable, "Employees"

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Create Method Example (VB)

 Copy code hover
[image]

Create Method Example (VB)
Send feedback

The following code shows how to create a new Microsoft Jet database with the Create method.

Copy code Copy code

' BeginCreateDatabseVB
Sub CreateDatabase()
 On Error GoTo CreateDatabaseError

 Dim cat As New ADOX.Catalog
 cat.Create "Provider='Microsoft.Jet.OLEDB.4.0';Data Source='c:\new.mdb'"

 'Clean up
 Set cat = Nothing
 Exit Sub

CreateDatabaseError:
 Set cat = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndCreateDatabaseVB


TABLE (Microsoft Access SQL reserved word)

 Copy code hover
[image]

TABLE (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The TABLE keyword is used in these contexts:

ALTER TABLE Statement

CREATE INDEX Statement

CREATE TABLE Statement

DROP Statement

UNION Operation

GRANT Statement

REVOKE Statement


DoCmd Members (Access)

 Copy code hover
[image]

DoCmd Members (Access)
Send feedback

Published: July 16, 2012

You can use the methods of the DoCmd object to run Microsoft Office Access actions from Visual Basic. An action performs tasks such as closing windows, opening forms, and setting the value of controls.

Methods

Name | Description
AddMenu | The AddMenu method carries out the AddMenu action in Visual Basic.
ApplyFilter | The ApplyFilter method carries out the ApplyFilter action in Visual Basic.
Beep | The Beep method carries out the Beep action in Visual Basic.
BrowseTo | The BrowseTo method performs the BrowseTo action in Visual Basic.
CancelEvent | The CancelEvent method carries out the CancelEvent action in Visual Basic.
ClearMacroError | Removes information about an error that is stored in the MacroError object.
Close | The Close method carries out the Close action in Visual Basic.
CloseDatabase | Closes the current database.
CopyDatabaseFile | Copies the database connected to the current project to a Microsoft SQL Server database file for export.
CopyObject | The CopyObject method carries out the CopyObject action in Visual Basic.
DeleteObject | The DeleteObject method carries out the DeleteObject action in Visual Basic.
DoMenuItem | Displays the appropriate menu or toolbar command for Microsoft Access.
Echo | Carries out the Echo action in Visual Basic.
FindNext | The FindNext method carries out the FindNext action in Visual Basic.
FindRecord | The FindRecord method carries out the FindRecord action in Visual Basic.
GoToControl | The GoToControl method performs the GoToControl action action in Visual Basic.
GoToPage | Carries out the GoToPage action in Visual Basic. .
GoToRecord | The GoToRecord method carries out the GoToRecord action in Visual Basic.
Hourglass | The Hourglass method carries out the Hourglass action in Visual Basic.
LockNavigationPane | You can use the LockNavigationPane action to prevent users from deleting database objects that are displayed in the Navigation Pane.
Maximize | The Maximize method carries out the Maximize action in Visual Basic.
Minimize | The Minimize method carries out the Minimize action in Visual Basic.
MoveSize | The MoveSize method carries out the MoveSize action in Visual Basic.
NavigateTo | You can use the NavigateTo method to control the display of database objects in the Navigation Pane. .
OpenDataAccessPage | The OpenDataAccessPage method carries out the OpenDataAccessPage action in Visual Basic.
OpenDiagram | The OpenDiagram method carries out the OpenDiagram action in Visual Basic.
OpenForm | The OpenForm method carries out the OpenForm action in Visual Basic.
OpenFunction | Opens a user-defined function in a Microsoft SQL Server database for viewing in Microsoft Access.
OpenModule | The OpenModule method carries out the OpenModule action in Visual Basic.
OpenQuery | The OpenQuery method carries out the OpenQuery action in Visual Basic.
OpenReport | The OpenReport method carries out the OpenReport action in Visual Basic.
OpenStoredProcedure | The OpenStoredProcedure method carries out the OpenStoredProcedure action in Visual Basic.
OpenTable | The OpenTable method carries out the OpenTable action in Visual Basic.
OpenView | The OpenView method carries out the OpenView action in Visual Basic.
OutputTo | The OutputTo method carries out the OutputTo action in Visual Basic.
PrintOut | The PrintOut method carries out the PrintOut action in Visual Basic.
Quit | The Quit method quits Microsoft Access. You can select one of several options for saving a database object before quitting.
RefreshRecord | The RefreshRecord method performs the RefreshRecord macro operation from Visual Basic.
Rename | The Rename method carries out the Rename action in Visual Basic.
RepaintObject | The RepaintObject method carries out the RepaintObject action in Visual Basic.
Requery | Carries out the Requery action in Visual Basic.
Restore | The Restore method carries out the Restore action in Visual Basic.
RunCommand | The RunCommand method runs a built-in command.
RunDataMacro | Use the RunDataMacro method to run a named data macro from Visual Basic.
RunMacro | The RunMacro method carries out the RunMacro action in Visual Basic.
RunSavedImportExport | Rrun a saved import or export specification.
RunSQL | The RunSQL method carries out the RunSQL action in Visual Basic.
Save | The Save method carries out the Save action in Visual Basic.
SearchForRecord | You can use the SearchForRecord method to search for a specific record in a table, query, form, or report.
SelectObject | The SelectObject method carries out the SelectObject action in Visual Basic.
SendObject | The SendObject method carries out the SendObject action in Visual Basic.
SetDisplayedCategories | Specifies which categories are displayed under Navigate to Category in the title bar of the Navigation Pane. .
SetFilter | Use the SetFilter method to apply a filter to the records in the active datasheet, form, report, or table.
SetMenuItem | The SetMenuItem method carries out the SetMenuItem action in Visual Basic.
SetOrderBy | Use the SetOrderBy method to apply a sort to the active datasheet, form, report, or table.
SetParameter | Use the SetParameter method to create a parameter for use by the BrowseTo , OpenForm, OpenQuery, OpenReport, or RunDataMacro methods.
SetProperty | The SetProperty method carries out the SetProperty action in Visual Basic.
SetWarnings | The SetWarnings method carries out the SetWarnings action in Visual Basic.
ShowAllRecords | The ShowAllRecords method carries out the ShowAllRecords action in Visual Basic.
ShowToolbar | The ShowToolbar method carries out the ShowToolbar action in Visual Basic.
SingleStep | Pauses macro execution and opens the Macro Single Step dialog box.
TransferDatabase | The TransferDatabase method carries out the TransferDatabase action in Visual Basic.
TransferSharePointList | You can use the TransferSharePointList method to import or link data from a SharePoint Foundation site.
TransferSpreadsheet | The TransferSpreadsheet method carries out the TransferSpreadsheet action in Visual Basic.
TransferSQLDatabase | Transfers the entire specified Microsoft SQL Server database to another SQL Server database.
TransferText | The TransferText method carries out the TransferText action in Visual Basic.


Shape Append Clause (ADO)

 Copy code hover
[image]

Shape Append Clause (ADO)
Send feedback

In this section

  • Shape Append Clause

  • Operation of Non-Parameterized Commands

  • Operation of Parameterized Commands

  • Hybrid Commands

  • Intervening Shape COMPUTE Clauses


Intervening Shape COMPUTE Clauses

 Copy code hover
[image]

Intervening Shape COMPUTE Clauses
Send feedback

It is valid to embed one or more COMPUTE clauses between the parent and child in a parameterized shape command, as in the following example:

Copy code Copy code

SHAPE {select au_lname, state from authors} APPEND
 ((SHAPE
 (SHAPE
 {select * from authors where state = ?} rs
 COMPUTE rs, ANY(rs.state) state, ANY(rs.au_lname) au_lname
 BY au_id) rs2
 COMPUTE rs2, ANY(rs2.state) BY au_lname)
RELATE state TO PARAMETER 0)


Cannot open a database created with a previous version of your application. (Error 3041)

 Copy code hover
[image]

Cannot open a database created with a previous version of your application. (Error 3041)
Send feedback

You tried to access a database that is in an outdated format. Compact the database and then try the operation again.


PageBreak.Properties Property (Access)

 Copy code hover
[image]

PageBreak.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a PageBreak object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

PageBreak Object

Other resources

PageBreak Object Members


TextBox.BorderTint Property (Access)

 Copy code hover
[image]

TextBox.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderTint

expression A variable that represents a TextBox object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code lightens BorderColor by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


CustomControl.Exit Event (Access)

 Copy code hover
[image]

CustomControl.Exit Event (Access)
See also Send feedback

Published: July 16, 2012

The Exit event occurs just before a control loses the focus to another control on the same form or report.

Syntax

expression .Exit(Cancel)

expression A variable that represents a CustomControl object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | Set to True to cancel the event.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when this event occurs, set the OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Exit event occurs before the LostFocus event.

Unlike the LostFocus event, the Exit event does not occur when a form loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


StreamTypeEnum

 Copy code hover
[image]

StreamTypeEnum
Send feedback

Specifies the type of data stored in a Stream object.

Constant | Value | Description
adTypeBinary | 1 | Indicates binary data.
adTypeText | 2 | Default. Indicates text data, which is in the character set specified by Charset.

ADO/WFC Equivalent

These constants do not have ADO/WFC equivalents.


ComboBox.TopPadding Property (Access)

 Copy code hover
[image]

ComboBox.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the combo box and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .TopPadding

expression A variable that represents a ComboBox object.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Type Property (Column) (ADOX)

 Copy code hover
[image]

Type Property (Column) (ADOX)
Send feedback

Indicates the data type of a column.

Settings and Return Values

Sets or returns a Long value that can be one of the DataTypeEnum constants. The default value is adVarWChar.

Remarks

This property is read/write until the Column object is appended to a collection or to another object, after which it is read-only.


DependencyInfo.OutOfDateObjects Property (Access)

 Copy code hover
[image]

DependencyInfo.OutOfDateObjects Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a DependencyObjects collection that represents the AccessObject objects for which the dependency information is outdated. Read-only.

Syntax

expression .OutOfDateObjects

expression A variable that represents a DependencyInfo object.

Remarks

You can use the following code to update the dependency information for all of the objects in the database:

VBA Copy code Copy code
Application.CurrentProject.UpdateDependencyInfo

See also

Concepts

DependencyInfo Object

Other resources

DependencyInfo Object Members


BoundObjectFrame.ColumnWidth Property (Access)

 Copy code hover
[image]

BoundObjectFrame.ColumnWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.

Syntax

expression .ColumnWidth

expression A variable that represents a BoundObjectFrame object.

Remarks

In Visual Basic , the ColumnWidth property setting is an Integer value that represents the column width in twips. You can specify a width or use one of the following predefined settings.

Setting | Description
0 | Hides the column.
-1 | (Default) Sizes the column to the default width.
Note Note

The ColumnWidth property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

Setting this property to 0, or resizing the field to a zero width in Datasheet view, sets the field's ColumnHidden property to True (-1) and hides the field in Datasheet view.

Setting a field's ColumnHidden property to False (0) restores the field's ColumnWidth property to the value it had before the field was hidden. For example, if the ColumnWidth property was -1 prior to the field being hidden by setting the property to 0, changing the field's ColumnHidden property to False resets the ColumnWidth to -1.

The ColumnWidth property for a field isn't available when the field's ColumnHidden property is set to True.

Example

This example takes effect in Datasheet view of the open Customers form. It sets the row height to 450 twips and sizes the column to fit the size of the visible text.

VBA Copy code Copy code
Forms![Customers].RowHeight = 450
Forms![Customers]![Address].ColumnWidth = -2

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


DoCmd.OpenQuery Method (Access)

 Copy code hover
[image]

DoCmd.OpenQuery Method (Access)
See also Send feedback

Published: July 16, 2012

The OpenQuery method carries out the OpenQuery action in Visual Basic.

Syntax

expression .OpenQuery(QueryName, View, DataMode)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
QueryName | Required | Variant | A string expression that's the valid name of a query in the current database. If you execute Visual Basic code containing the OpenQuery method in a library database, Microsoft Access looks for the query with this name first in the library database, then in the current database.
View | Optional | AcView | A AcView constant that specifies the view in which the query will open. The default value is acViewNormal.
DataMode | Optional | AcOpenDataMode | A AcOpenDataMode constant that specifies the data entry mode for the query. The default value is acEdit.

Remarks

You can use the OpenQuery method to open a select or crosstab query in Datasheet view, Design view, or Print Preview. This action runs an action query. You can also select a data entry mode for the query.

Note Note

This method is only available in the Microsoft Access database environment. See the OpenView or OpenStoredProcedure methods if using the Microsoft Access Project environment (.adp).

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Calling Action Queries

Example

The following example opens Sales Totals Query in Datasheet view and enables the user to view but not to edit or add records:

VBA Copy code Copy code
DoCmd.OpenQuery "Sales Totals Query", , acReadOnly

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


ComboBox.ValidationRule Property (Access)

 Copy code hover
[image]

ComboBox.ValidationRule Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.

Syntax

expression .ValidationRule

expression A variable that represents a ComboBox object.

Remarks

Enter an expression for the ValidationRule property setting and text for the ValidationText property setting. The maximum length for the ValidationRule property setting is 2048 characters. The maximum length for the ValidationText property setting is 255 characters.

For controls, you can set the ValidationRule property to any valid expression. For field and record validation rules, the expression can't contain user-defined functions, domain aggregate or aggregate functions, the Eval function, or CurrentUser method, or references to forms, queries, or tables. In addition, field validation rules can't contain references to other fields. For records, expressions can include references to fields in that table.

For table fields and records, you can also set these properties in Visual Basic by using the DAO ValidationRule property.

Microsoft Access automatically validates values based on a field's data type; for example, Microsoft Access doesn't allow text in a numeric field. You can set rules that are more specific by using the ValidationRule property.

If you set the ValidationRule property but not the ValidationText property, Microsoft Access displays a standard error message when the validation rule is violated. If you set the ValidationText property, the text you enter is displayed as the error message.

For example, when a record is added for a new employee, you can enter a ValidationRule property requiring that the value in the employee's StartDate field fall between the company's founding date and the current date. If the date entered isn't in this range, you can display the ValidationText property message: "Start date is incorrect."

If you create a control by dragging a field from the field list, the field's validation rule remains in effect, although it isn't displayed in the control's ValidationRule property box in the property sheet. This is because a field's validation rule is inherited by a control bound to that field.

Control, field, and record validation rules are applied as follows:

  • Validation rules you set for fields and controls are applied when you edit the data and the focus leaves the field or control.

  • Validation rules for records are applied when you move to another record.

  • If you create validation rules for both a field and a control bound to the field, both validation rules are applied when you edit data and the focus leaves the control.

The following table contains expression examples for the ValidationRule and ValidationText properties.

ValidationRule property | ValidationText property
<> 0 | Entry must be a nonzero value.
> 1000 Or Is Null | Entry must be blank or greater than 1000.
Like "A????" | Entry must be 5 characters and begin with the letter "A".
>= #1/1/96# And <#1/1/97# | Entry must be a date in 1996.
DLookup("CustomerID", "Customers", "CustomerID = Forms!Customers!CustomerID") Is Null | Entry must be a unique CustomerID (domain aggregate functions are allowed only for form-level validation).

If you create a validation rule for a field, Microsoft Access doesn't normally allow a Null value to be stored in the field. If you want to allow a Null value, add "Is Null" to the validation rule, as in "<> 8 Or Is Null" and make sure the Required property is set to No.

You can't set field or record validation rules for tables created outside Microsoft Access (for example, dBASE, Paradox, or SQL Server). For these kinds of tables, you can create validation rules for controls only.

Example

The following example creates a validation rule for a field that allows only values over 65 to be entered. If a number less than 65 is entered, a message is displayed. The properties are set by using the SetFieldValidation function.

VBA Copy code Copy code
Dim strTblName As String, strFldName As String
Dim strValidRule As String
Dim strValidText As String, intX As Integer

strTblName = "Customers"
strFldName = "Age"
strValidRule = ">= 65"
strValidText = "Enter a number greater than or equal to 65."
intX = SetFieldValidation(strTblName, strFldName, _
 strValidRule, strValidText)

Function SetFieldValidation(strTblName As String, _
 strFldName As String, strValidRule As String, _
 strValidText As String) As Integer

 Dim dbs As Database, tdf As TableDef, fld As Field

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 Set fld = tdf.Fields(strFldName)
 fld.ValidationRule = strValidRule
 fld.ValidationText = strValidText
End Function

The next example uses the SetTableValidation function to set record-level validation to ensure that the value in the EndDate field comes after the value in the StartDate field.

VBA Copy code Copy code
Dim strTblName As String, strValidRule As String
Dim strValidText As String
Dim intX As Integer

strTblName = "Employees"
strValidRule = "EndDate > StartDate"
strValidText = "Enter an EndDate that is later than the StartDate."
intX = SetTableValidation(strTblName, strValidRule, strValidText)

Function SetTableValidation(strTblName As String, _
 strValidRule As String, strValidText As String) _
 As Integer

 Dim dbs As Database, tdf As TableDef

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 tdf.ValidationRule = strValidRule
 tdf.ValidationText = strValidText
End Function

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


The Microsoft Access database engine stopped the process because you and another user are attempting to change the same data at the same time. (Error 3197)

 Copy code hover
[image]

The Microsoft Access database engine stopped the process because you and another user are attempting to change the same data at the same time. (Error 3197)
Send feedback

This error can occur in a multiuser environment.

Another user has changed the data you are trying to update. This error can occur when multiple users open a table or create a Recordset and use optimistic locking. Between the time you used the Edit method and the Update method, another user changed the same data.

To overwrite the other user's changes with your own, execute the Update method again.


ObjectFrame.TabIndex Property (Access)

 Copy code hover
[image]

ObjectFrame.TabIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.

Syntax

expression .TabIndex

expression A variable that represents an ObjectFrame object.

Remarks

You can set the TabIndex property to an integer representing the position of the control within the tab order of the form. Valid settings are 0 for the first tab position, up to the total number of controls minus 1 for the last tab position. For example, if a form has three controls that each have a TabIndex property, valid TabIndex property settings are 0, 1, and 2.

Setting the TabIndex property to an integer less than 0 produces an error.

By default, Microsoft Access assigns a tab order to controls in the order that you create them on a form. Each new control is placed last in the tab order. If you change the setting of a control's TabIndex property to adjust the tab order, Microsoft Access automatically renumbers the TabIndex property setting of other controls to reflect insertions and deletions.

In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the TAB key.

Changing the tab order of other controls on the form doesn't affect what happens when you press a control's access key. For example, if you've created an access key for the label of a text box, the focus will move to the text box whenever you press the label's access key — even if you change the TabIndex property setting for the text box.

If you press an access key for a control such as a label that doesn't have a TabIndex property (and thus isn't in the tab order), the focus moves to the next control in the tab order that can receive the focus.

Example

The following example reverses the tab order of a command button and a text box. Because TextBox1 was created first, it has a TabIndex property setting of 0 and Command1 has a setting of 1.

VBA Copy code Copy code
Sub Form_Click()
 Me!Command1.TabIndex = 0
 Me!TextBox1.TabIndex = 1
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


BoundObjectFrame.AfterUpdate Property (Access)

 Copy code hover
[image]

BoundObjectFrame.AfterUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.

Syntax

expression .AfterUpdate

expression A variable that represents a BoundObjectFrame object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the AfterUpdate event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the AfterUpdate event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).AfterUpdate = "[Event Procedure]"

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Modules Members (Access)

 Copy code hover
[image]

Modules Members (Access)
Send feedback

Published: July 16, 2012

The Modules collection contains all open standard modules and class modules in a Microsoft Access database.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Module.
Parent | Returns the parent object for the specified object. Read-only.


WebServices.Parent Property (Access)

 Copy code hover
[image]

WebServices.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Parent

expression A variable that represents a WebServices object.

See also

Concepts

WebServices Collection

Other resources

WebServices Object Members


OptionButton.LabelAlign Property (Access)

 Copy code hover
[image]

OptionButton.LabelAlign Property (Access)
See also Send feedback

Published: July 16, 2012

The property specifies the text alignment within attached labels on new controls. Read/write Byte.

Syntax

expression .LabelAlign

expression A variable that represents an OptionButton object.

Remarks

The LabelAlign property uses the following settings.

Setting | Description
0 | (Default) The label text aligns to the left.
1 | The label text aligns to the left.
2 | The label text is centered.
3 | The label text aligns to the right.
4 | The label text is evenly distributed.

You can set the LabelAlign property by using a control's default control style or the DefaultControl property in Visual Basic.

When created, controls have an attached label (as long as their AutoLabel property is set to Yes). Changes to the LabelAlign default control style setting affect only controls created on the current form or report.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Rectangle.BorderWidth Property (Access)

 Copy code hover
[image]

Rectangle.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Syntax

expression .BorderWidth

expression A variable that represents a Rectangle object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


Window Management

 Copy code hover
[image]

Window Management
Send feedback

In this section

  • CloseWindow Macro Action

  • MaximizeWindow Macro Action

  • MoveAndSizeWindow Macro Action

  • MinimizeWindow Macro Action

  • RestoreWindow Macro Action


ADORecordConstruction Interface (ADO)

 Copy code hover
[image]

ADORecordConstruction Interface (ADO)
Send feedback

The ADORecordConstruction interface is used to construct an ADO Record object from an OLE DB Row object in a C/C++ application.

This interface supports the following properties:

Properties

ParentRow | Write-only. Sets the container of an OLE DB Row object on this ADO Record object.
Row | Read/Write. Gets/sets an OLE DB Row object from/on this ADO Record object.

Methods

None.

Events

None.

Remarks

Given an OLE DB Row object (pRow), the construction of an ADO Record object (), the construction of an ADO Record object (adoR), amounts to the following three basic operations:

  1. Create an ADO Record object:

    Copy code Copy code
    _RecordPtr adoR;
adoRs.CreateInstance(__uuidof(_Record));

  2. Query the IADORecordConstruction interface on the Record object:

    Copy code Copy code
    adoRecordConstructionPtr adoRConstruct=NULL;
adoR->QueryInterface(__uuidof(ADORecordConstruction),
                    (void**)&adoRConstruct);

  3. Call the IADORecordConstruction::put_Row property method to set the OLE DB Row object on the ADO Record object:

    Copy code Copy code
    IUnknown *pUnk=NULL;
pRow->QueryInterface(IID_IUnknown, (void**)&pUnk);
adoRConstruct->put_Row(pUnk);

The resultant adoR object now represents the ADO Record object constructed from the OLE DB Row object.

An ADO Record object can also be constructed from the container of an OLE DB Row object.

Requirements

Version: ADO 2.0 and later

Library: msado15.dll

UUID: 00000567-0000-0010-8000-00AA006D2EA4


Failure to write to an internet handle. Try the operation again. (Error 3676)

 Copy code hover
[image]

Failure to write to an internet handle. Try the operation again. (Error 3676)
Send feedback

An internet error occurred writing to a file.


ParameterDirectionEnum Enumeration (DAO)

 Copy code hover
[image]

ParameterDirectionEnum Enumeration (DAO)
Send feedback

Used with the Direction property to specify the type for a Parameter object.

Name | Value | Description
dbParamInput | 1 | (Default) Passes information to the procedure.
dbParamInputOutput | 3 | Passes information both to and from the procedure.
dbParamOutput | 2 | Returns information from the procedure as an output parameter in SQL.
dbParamReturnValue | 4 | Passes the return value from a procedure.


Synchronizer could not be shut down properly and is still active. (Error 3541)

 Copy code hover
[image]

Synchronizer could not be shut down properly and is still active. (Error 3541)
Send feedback

A programmatic request to terminate the Synchronizer was not completed successfully and the Synchronizer is still running in the background.

To terminate the Synchronizer

  1. Press CTRL+ALT+DELETE to display the Close Program dialog box.

  2. Click Synchronizer.

  3. Click End Task.


DBEngine.CompactDatabase Method (DAO)

 Copy code hover
[image]

DBEngine.CompactDatabase Method (DAO)
Send feedback

Copies and compacts a closed database, and gives you the option of changing its version, collating order, and encryption. (Microsoft Access workspaces only). .

Syntax

expression .CompactDatabase(SrcName, DstName, DstLocale, Options, password)

expression An expression that returns a DBEngine object.

Parameters

Name

Required/Optional

Data Type

Description

SrcName

Required

String

Identifies an existing, closed database. It can be a full path and file name, such as "C:\db1.mdb". If the file name has an extension, you must specify it. If your network supports it, you can also specify a network path, such as "\\server1\share1\dir1\db1.mdb"

DstName

Required

String

the file name (and path) of the compacted database that you're creating. You can also specify a network path. You can't use this argument to specify the same database file as SrcName.

DstLocale

Optional

Variant

A string expression that specifies a collating order for creating DstName, as specified in Remarks.

  • If you omit this argument, the locale of DstName is the same as SrcName.

  • You can also create a password for DstName by concatenating the password string (starting with ";pwd=") with a constant in the DstLocale argument, like this: dbLangSpanish & ";pwd=NewPassword".

  • If you want to use the same DstLocale as SrcName (the default value), but specify a new password, simply enter a password string for DstLocale: ";pwd=NewPassword"

Options

Optional

Variant

Optional. A constant or combination of constants that indicates one or more options, as specified in Remarks. You can combine options by summing the corresponding constants.

password

Optional

Variant

A string expression containing a password, if the database is password protected. The string ";pwd=" must precede the actual password. If you include a password setting in DstLocale, this setting is ignored.

Note Note

Use strong passwords that combine upper- and lowercase letters, numbers, and symbols. Weak passwords don't mix these elements. Strong password: Y6dh!et5. Weak password: House27. Use a strong password that you can remember so that you don't have to write it down.

Remarks

You can use one of the following constants for the DstLocale argument to specify the CollatingOrder property for string comparisons of text.

Constant | Collating order
dbLangGeneral | English, German, French, Portuguese, Italian, and Modern Spanish
dbLangArabic | Arabic
dbLangChineseSimplified | Simplified Chinese
dbLangChineseTraditional | Traditional Chinese
dbLangCyrillic | Russian
dbLangCzech | Czech
dbLangDutch | Dutch
dbLangGreek | Greek
dbLangHebrew | Hebrew
dbLangHungarian | Hungarian
dbLangIcelandic | Icelandic
dbLangJapanese | Japanese
dbLangKorean | Korean
dbLangNordic | Nordic languages (Microsoft Jet database engine version 1.0 only)
dbLangNorwDan | Norwegian and Danish
dbLangPolish | Polish
dbLangSlovenian | Slovenian
dbLangSpanish | Traditional Spanish
dbLangSwedFin | Swedish and Finnish
dbLangThai | Thai
dbLangTurkish | Turkish

You can use one of the following constants in the options argument to specify whether to encrypt or to decrypt the database while it's compacted.

Constant | Description
dbEncrypt | Encrypt the database while compacting.
dbDecrypt | Decrypt the database while compacting.

If you omit an encryption constant or if you include both dbDecrypt and dbEncrypt, DstName will have the same encryption as SrcName.

You can use one of the following constants in the options argument to specify the version of the data format for the compacted database. This constant affects only the version of the data format of DstName and doesn't affect the version of any Microsoft Access-defined objects, such as forms and reports.

Constant | Description
dbVersion10 | Creates a database that uses the Microsoft Jet database engine version 1.0 file format while compacting.
dbVersion11 | Creates a database that uses the Microsoft Jet database engine version 1.1 file format while compacting.
dbVersion20 | Creates a database that uses the Microsoft Jet database engine version 2.0 file format while compacting.
dbVersion30 | Creates a database that uses the Microsoft Jet database engine version 3.0 file format (compatible with version 3.5) while compacting.
dbVersion40 | Creates a database that uses the Microsoft Jet database engine version 4.0 file format while compacting.
dbVersion120 | Creates a database that uses the Microsoft Access database engine version 12.0 file format while compacting.

You can specify only one version constant. If you omit a version constant, DstName will have the same version as SrcName. You can compact DstName only to a version that is the same or later than that of SrcName.

As you change data in a database, the database file can become fragmented and use more disk space than is necessary. Periodically, you can use the CompactDatabase method to compact your database to defragment the database file. The compacted database is usually smaller and often runs faster. You can also change the collating order, the encryption, or the version of the data format while you copy and compact the database.

You must close SrcName before you compact it. In a multiuser environment, other users can't have SrcName open while you're compacting it. If SrcName isn't closed or isn't available for exclusive use, an error occurs.

Because CompactDatabase creates a copy of the database, you must have enough disk space for both the original and the duplicate databases. The compact operation fails if there isn't enough disk space available. The DstName duplicate database doesn't have to be on the same disk as SrcName. After successfully compacting a database, you can delete the SrcName file and rename the compacted DstName file to the original file name.

The CompactDatabase method copies all the data and the security permission settings from the database specified by SrcName to the database specified by DstName.

Note Note

Because the CompactDatabase method doesn't convert Microsoft Access objects, you shouldn't use CompactDatabase to convert a database containing such objects.


Cannot open

 Copy code hover
[image]

Cannot open <tablename>. Another user has the table open using a different network control file or locking style. (Error 3418)
Send feedback

The Microsoft Access database engine cannot open an external Paradox table because of inconsistencies between your initialization settings and those of another user who currently has the table open. The ParadoxNetPath and the ParadoxNetStyle settings in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Access Connectivity Engine\Engines\Paradox key of the Microsoft Windows Registry must be consistent for all users sharing a database. Make sure your initialization settings match those of all other users sharing the database, and then try opening the table again.


TextBox.Height Property (Access)

 Copy code hover
[image]

TextBox.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Syntax

expression .Height

expression A variable that represents a TextBox object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Attachment Properties (Access)

 Copy code hover
[image]

Attachment Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AttachmentCount | Gets the number of documents attached to the specified Attachment control. Read-only Long.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears. Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme that is associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the attachment and its bottom gridline. Read/write Integer.
ColumnHidden | You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.
ColumnOrder | You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.
ColumnWidth | You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in the specified Attachment control. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
CurrentAttachment | Gets the index number of the file that has the focus in the Attachment control. Read/write Long.
DefaultPicture | Gets or sets the path and file name of the graphic to be used as a background picture on an attachment control. Read/write String.
DefaultPictureType | Gets or sets the method used to store the image specified by the DefaultPicture property in the database. Read/write Byte.
DisplayAs | Gets or sets an AcDisplayAs constant that specifies how a file should be displayed in the Attachment control. Read/write.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FileName | Returns the full file name of the specified attachment. Read-only String.
FileType | Returns the file extension of the specifed attachment. Read-only String.
FileURL | Returns the Uniform Resource Locator (URL) of the specified attachment. Read-only String.
GridlineColor | Gets or sets the color of the gridline for the specified attachment. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified attachment. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified attachment. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified attachment. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified attachment. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified attachment. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified attachment. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified attachment. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified attachment. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the attachment is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property to determine whether a control on a report is visible. Read/write Boolean.
LabelAlign | The LabelAlign property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified attachment. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified attachment. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the attachment and its left gridline. Read/write Integer.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
OldBorderStyle | You can use this property to set or return the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnAttachmentCurrent | Sets or gets the value of the On Attachment Current box in the Properties window of the specified Attachment. Read/write.
OnChange | Sets or returns the value of the On Change box in the Properties window of one of the objects in the Applies To list. Read/write String.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnDirty | Sets or returns the value of the On Dirty box in the Properties window of a form or report. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of the specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of the specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
PictureAlignment | You can use the PictureAlignment property to specify where a background picture will appear in the Attachment control. Read/write Byte.
PictureSizeMode | You can use the PictureSizeMode property to specify how a picture for an attachment control is sized. Read/write Byte.
PictureTiling | You can use the PictureTiling property to specify whether a background picture is tiled across the entire attachment control. Read/write Boolean.
Properties | Returns a reference to a control's Properties collection object. Read-only.
RightPadding | Gets or sets the amount of space (in inches) between the attachment and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click the specified object. Read/write String.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control in Form view. Read/write Boolean.
Tag | Stores extra information about a control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the attachment and its top gridline. Read/write Integer.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified attachment is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


Label.HyperlinkSubAddress Property (Access)

 Copy code hover
[image]

Label.HyperlinkSubAddress Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the HyperlinkSubAddress property to specify or determine a location within the target document specified by the HyperlinkAddress property. Read/write String.

Syntax

expression .HyperlinkSubAddress

expression A variable that represents a Label object.

Remarks

The HyperlinkSubAddress property can be an object within a Microsoft Access database, a bookmark within a Microsoft Word document, a named range within a Microsoft Excel spreadsheet, a slide within a Microsoft PowerPoint presentation, or a location within an HTML document.

The HyperlinkSubAddress property is a string expression representing a named location within the target document specified by the HyperlinkAddress property.

Note Note

When you create a hyperlink by using the Insert Hyperlink dialog box, Microsoft Access automatically sets the HyperlinkAddress property and HyperlinkSubAddress to the location specified in the Type the file or Web page name box. The HyperlinkSubAddress property can also be set to the location specified in the Select an object in this database box.

If you copy a hyperlink from another application and paste it into a form or report, Microsoft Access creates a label control with its Caption property, HyperlinkAddress property, and HyperlinkSubAddress property automatically set.

When you move the cursor over a command button, image control, or label control whose HyperlinkAddress property is set, the cursor changes to an upward-pointing hand. Clicking the control displays the object or Web page specified by the link.

To open objects in the current database, leave the HyperlinkAddress property blank and specify the object type and object name you want to open in the HyperlinkSubAddress property by using the syntax "objecttype objectname". If you want to open an object contained in another Microsoft Access database, enter the database path and file name in the HyperlinkAddress property and specify the database object to open by using the HyperlinkSubAddress property.

The HyperlinkAddress property can contain an absolute or a relative path to a target document. An absolute path is a fully qualified URL or UNC path to a document. A relative path is a path related to the base path specified in the Hyperlink Base setting in the Properties dialog box (available by clicking Database Properties on the File menu) or to the current database path. If Microsoft Access can't resolve the HyperlinkAddress property setting to a valid URL or UNC path, it will assume you've specified a path relative to the base path contained in the Hyperlink Base setting or the current database path.

Note Note

When you follow a hyperlink to another Microsoft Access database object, the database Startup properties are applied. For example, if the destination database has a Display form set, that form is displayed when the database opens.

The following table contains examples of HyperlinkAddress and HyperlinkSubAddress property settings.

HyperlinkAddress | HyperlinkSubAddress | Description
http://www.microsoft.com/ |  | The Microsoft home page on the Web.
C:\Program Files\Microsoft Office\Office\Samples\Cajun.htm |  | The Cajun Delights page in the Access sample applications subdirectory.
C:\Program Files\Microsoft Office\Office\Samples\Cajun.htm | NewProducts | The "NewProducts" Name tag in the Cajun Delights page.
C:\Personal\MyResume.doc | References | The bookmark named "References" in the Microsoft Word document "MyResume.doc".
C:\Finance\First Quarter.xls | Sheet1!TotalSales | The range named "TotalSales" in the Microsoft Excel spreadsheet "First Quarter.xls".
C:\Presentation\NewPlans.ppt | 10 | The 10th slide in the Microsoft PowerPoint document "NewPlans.ppt".

See also

Concepts

Label Object

Other resources

Label Object Members


Connection.Recordsets Property (DAO)

 Copy code hover
[image]

Connection.Recordsets Property (DAO)
Send feedback

Returns a Recordsets collection that contains all of the open recordsets in the for the specified connection. Read-only.

Syntax

expression .Recordsets

expression A variable that represents a Connection object.


Synchronizer received an invalid message for a member of the replica set that it manages. (Error 3536)

 Copy code hover
[image]

Synchronizer received an invalid message for a member of the replica set that it manages. (Error 3536)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


TabControl.Top Property (Access)

 Copy code hover
[image]

TabControl.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Syntax

expression .Top

expression A variable that represents a TabControl object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


CustomControl Properties (Access)

 Copy code hover
[image]

CustomControl Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
About | Returns or sets a String representing version and copyright information for an ActiveX control. Read/write.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.
Cancel | You can use the Cancel property to specify whether a command button is also the Cancel button on a form. Read/write Boolean.
Class | You can use the Class property to specify or determine the class name of an embeddedOLE object. Read/write String.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
Custom | Returns or sets a String representing the custom properties dialog box for an ActiveX control. Read/write.
Default | You can use the Default property to specify whether a command button is the default button on a form. Read/write Boolean.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
GridlineColor | Gets or sets the color of the gridline for the specified list box. Read/write Long.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified list box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified text box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified text box. Read/write Byte.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified text box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified text box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified text box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the text box is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Layout | Returns the type of layout for the specified text box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified text box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Object | You can use the Object property in Visual Basic to return a reference to the ActiveX object that is associated with a linked or embedded OLE object in a control. By using this reference, you can access the properties or invoke the methods of the OLE object. Read-only Object.
ObjectPalette | The ObjectPalette property specifies the palette in the application used to create an OLE object. Read/write Variant.
ObjectVerbs | You can use the ObjectVerbs property in Visual Basic to determine the list of verbs an OLE object supports. Read-only String.
ObjectVerbsCount | You can use the ObjectVerbsCount property in Visual Basic to determine the number of verbs supported by an OLE object. Read-only Long.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OLEClass | You can use the OLEClass property to obtain a description of the kind of OLE object contained in a chart control or an unbound object frame. Read-only String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnUpdated | Sets or returns the value of the On Updated box in the Properties window of a form or report. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
RightPadding | Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.
Value | Gets or sets the value displayed in the specified control. Read/write Variant.
VarOleObject | Gets a pointer to an IOLEObject that represents the memory address of an OLE object. Read-only Variant.
Verb | You can use the Verb property to specify the operation to perform when an OLE object is activated, which is permitted when the control'sAction property is set to acOLEActivate. Read/write Long.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified text box is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


WebBrowserControl.BorderStyle Property (Access)

 Copy code hover
[image]

WebBrowserControl.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .BorderStyle

expression A variable that represents a WebBrowserControl object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Label.GridlineTint Property (Access)

 Copy code hover
[image]

Label.GridlineTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineTint

expression A variable that represents a Label object.

Remarks

The GridlineTint property contains a numeric expression that can be used to lighten the theme color in the GridlineColor property. The default value of the GridlineTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

Label Object

Other resources

Label Object Members


Form.Width Property (Access)

 Copy code hover
[image]

Form.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents a Form object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

Form Object

Other resources

Form Object Members


WebBrowserControl.ControlType Property (Access)

 Copy code hover
[image]

WebBrowserControl.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .ControlType

expression A variable that represents a WebBrowserControl object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


QueryDef Members (DAO)

 Copy code hover
[image]

QueryDef Members (DAO)
Send feedback

A QueryDef object is a stored definition of a query in a Microsoft Access database engine database.

Methods

Name

Description

Cancel

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Cancels execution of a pending asynchronous method call (ODBCDirect workspaces only).

Close

Closes an open QueryDef.

CreateProperty

Creates a new user-defined Property object (Microsoft Access workspaces only).

Execute

Executes an SQL statement on the specified object.

OpenRecordset

Creates a new Recordset object and appends it to the Recordsets collection.

Properties

Name

Description

CacheSize

Sets or returns the number of records retrieved from an ODBC data source that will be cached locally. Read/write Long.

Connect

Sets or returns a value that provides information about the source of database used in a pass-through query. Read-only String.

DateCreated

Returns the date and time that an object was created (Microsoft Access workspaces only). Read-only Variant.

Fields

Returns a Fields collection that represents all stored Field objects for the specified object. Read-only.

LastUpdated

Returns the date and time of the most recent change made to an object. Read-only Variant.

MaxRecords

Sets or returns the maximum number of records to return from a query against an ODBC data source.

Name

Returns or sets the name of the specified object. Read/write String.

ODBCTimeout

Indicates the number of seconds to wait before a timeout error occurs when a QueryDef is executed on an ODBC database.

Parameters

Returns a Parameters collection that contains all of the Parameter objects of the specified QueryDef. Read-only.

Prepare

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Sets or returns a value that indicates whether the query should be prepared on the server as a temporary stored procedure, using the ODBC SQLPrepare API function, prior to execution, or just executed using the ODBC SQLExecDirect API function (ODBCDirect workspaces only). Read/Write QueryDefStateEnum.

Properties

Returns the Properties collection of the specified object. Read-only.

RecordsAffected

Returns the number of records affected by the most recently invoked Execute method.

ReturnsRecords

Sets or returns a value that indicates whether an SQL pass-through query to an external database returns records (Microsoft Access workspaces only).

SQL

Sets or returns the SQL statement that defines the query executed by a QueryDef object.

StillExecuting

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Indicates whether or not an asynchronous operation (that is, a method called with the dbRunAsync option) has finished executing (ODBCDirect workspaces only).

Type

Sets or returns a value that indicates the operational type or data type of an object. Read-onlyInteger.

Updatable

Returns a value that indicates whether you can change a DAO object. Read-only Boolean.


Collections (ADO for Visual C++ Syntax)

 Copy code hover
[image]

Collections (ADO for Visual C++ Syntax)
Send feedback

Parameters

Methods

            Append(IDispatch *Object)

Delete(VARIANT Index)

Refresh(void)

Properties

get_Count(long *c) get_Item(VARIANT Index, _ADOParameter **ppvObject)

Fields

Methods

Append(BSTR bstrName, DataTypeEnum Type, long DefinedSize, FieldAttributeEnum Attrib) Delete(VARIANT Index) Refresh(void)

Properties

get_Count(long *c) get_Item(VARIANT Index, ADOField **ppvObject)

Errors

Methods

Clear(void) Refresh(void)

Properties

get_Count(long *c) get_Item(VARIANT Index, ADOError **ppvObject)

Properties

Methods

Refresh(void)

Properties

get_Count(long *c) get_Item(VARIANT Index, ADOProperty **ppvObject)


Out of MS-DOS file handles. (Error 3042)

 Copy code hover
[image]

Out of MS-DOS file handles. (Error 3042)
Send feedback

Either close some files, close other applications, or increase the number of available MS-DOS file handles.

To increase the number of file handles

  1. Edit your CONFIG.sys file using Microsoft Windows Notepad or another text editor. The CONFIG.sys file is usually located in the root directory of your boot drive. If you do not have a CONFIG.sys file on your system, you must create one that contains the line listed in step 2.

  2. Look for the line that reads FILES = x, where x is some number. Increase the number specified by the FILES command; the exact number of handles you enter depends on the applications you run and the number of files that are open at any given time. If other applications open multiple files, you may need to specify more file handles. As you increase the number of file handles, remember that each handle consumes more memory. For additional information, refer to your operating system manual.

  3. Exit Microsoft Windows.

  4. Reboot your system, and then try the operation again.


The connection for viewing your linked Microsoft Excel worksheet was lost. (Error 3620)

 Copy code hover
[image]

The connection for viewing your linked Microsoft Excel worksheet was lost. (Error 3620)
Send feedback

The connection for viewing your linked Microsoft Excel worksheet was lost. The session of Microsoft Excel may have been terminated.


Form.AllowEdits Property (Access)

 Copy code hover
[image]

Form.AllowEdits Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllowEdits property to specify whether a user can edit saved records when using a form. Read/write Boolean.

Syntax

expression .AllowEdits

expression A variable that represents a Form object.

Remarks

You can use the AllowEdits property to prevent changes to existing data displayed by a form. If you want to prevent changes to data in a specific control, use the Enabled or Locked property.

If you want to prevent changes to existing records (make a form read-only), set the AllowAdditions , AllowDeletions , and AllowEdits properties to No. You can also make records read-only by setting the RecordsetType property to Snapshot.

When the AllowEdits property is set to No, the Delete Record and Data Entry menu commands aren't available for existing records. (They may still be available for new records if the AllowAdditions property is set to Yes.)

Changing a field value programmatically causes the current record to be editable, regardless of the AllowEdits property setting. If you want to prevent the user from making changes to a record (AllowEdits is No) that you need to edit programmatically, save the record after any programmatic changes; the AllowEdits property setting will be honored once again after any unsaved changes to the current record are saved.

Note Note

When the Data Mode argument of the OpenForm action is set, Microsoft Access will override a number of form property settings. If the Data Mode argument of the OpenForm action is set to Edit, Microsoft Access will open the form with the following property settings:

  • AllowEdits — Yes

  • AllowDeletions — Yes

  • AllowAdditions — Yes

  • DataEntry — No

To prevent the OpenForm action from overriding any of these existing property settings, omit the Data Mode argument setting so that Microsoft Access will use the property settings defined by the form.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Application.SaveAsTemplate Method (Access)

 Copy code hover
[image]

Application.SaveAsTemplate Method (Access)
See also Send feedback

Published: July 16, 2012

Converts an existing Access database file to a database template (*.accdt) format file.

Version Information

Version Added: Access 2010

Syntax

expression .SaveAsTemplate(Path, Title, IconPath, CoreTable, Category, PreviewPath, Description, InstantiationForm, ApplicationPart, IncludeData)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Path | Required | String | The full path and file name of the database template to create.
Title | Required | String | The name of the database that is created when the instantiates the template.
IconPath | Required | String | An image file to be used as an icon for the database template.
CoreTable | Required | String | The table that contains the data that users would most want to create a relationship with when they instantiate the template. The Application Part argument must be set to True if you set use this argument.
Category | Required | String | The template category under which the database template will appear on the Available Templates page.
PreviewPath | Optional | Variant | An image file to be used as a preview for the database template on the Available Templates page.
Description | Optional | Variant | A description to be displayed when the user selects the database template in the Available Templates page.
InstantiationForm | Optional | Variant | Specifies the name of the form to be displayed when the template is instantiated.
ApplicationPart | Optional | Variant | Specifies whether the template will be displayed when the user clicks Application Parts in the Templates group of the Create ribbon tab. Set to True to display the template when the user clicks Application Parts.
IncludeData | Optional | Variant | Specifies whether the table data is included in the template. Set to True to include the table data.

Remarks

The SaveAsTemplate method replaces the SaveAsTemplate method that was installed with the Microsoft Office Access 2007 Developer Extensions.

Templates created by the SaveAsTemplate method cannot be used in Microsoft Office Access 2007 or earlier versions.

See also

Concepts

Application Object

Other resources

Application Object Members


To make changes to this field, first save the record. (Error 3331)

 Copy code hover
[image]

To make changes to this field, first save the record. (Error 3331)
Send feedback

This error occurs when the user is trying to edit a row based on a view or stored query that is based on more than one table.


Relation.ForeignTable Property (DAO)

 Copy code hover
[image]

Relation.ForeignTable Property (DAO)
Send feedback

Sets or returns the name of the foreign table in a relationship (Microsoft Access workspaces only). .

Syntax

expression .ForeignTable

expression A variable that represents a Relation object.

Remarks

This property is read/write for a new Relation object not yet appended to a collection and read-only for an existing Relation object in the Relations collection.

The ForeignTable property setting of a Relation object is the Name property setting of the TableDef or QueryDef object that represents the foreign table or query; the Table property setting is the Name property setting of the TableDef or QueryDef object that represents the primary table or query.

For example, if you had a list of valid part codes (in a field named PartNo) stored in a ValidParts table, you could establish a relationship with an OrderItem table such that if a part code were entered into the OrderItem table, it would have to already be in the ValidParts table. If the part code didn't exist in the ValidParts table and you had not set the Attributes property of the Relation object to dbRelationDontEnforce, a trappable error would occur.

In this case, the ValidParts table is the primary table, so the Table property of the Relation object would be set to ValidParts and the ForeignTable property of the Relation object would be set to OrderItem. The Name and ForeignName properties of the Field object in the Relation object's Fields collection would be set to PartNo.

Example

This example shows how the Table, ForeignTable, and ForeignName properties define the terms of a Relation between two tables.

VBA Copy code Copy code
Sub ForeignNameX()

 Dim dbsNorthwind As Database
 Dim relLoop As Relation

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 Debug.Print "Relation"
 Debug.Print " Table - Field"
 Debug.Print " Primary (One) ";
 Debug.Print ".Table - .Fields(0).Name"
 Debug.Print " Foreign (Many) ";
 Debug.Print ".ForeignTable - .Fields(0).ForeignName"

 ' Enumerate the Relations collection of the Northwind
 ' database to report on the property values of
 ' the Relation objects and their Field objects.
 For Each relLoop In dbsNorthwind.Relations
 With relLoop
 Debug.Print
 Debug.Print .Name & " Relation"
 Debug.Print " Table - Field"
 Debug.Print " Primary (One) ";
 Debug.Print .Table & " - " & .Fields(0).Name
 Debug.Print " Foreign (Many) ";
 Debug.Print .ForeignTable & " - " & _
 .Fields(0).ForeignName
 End With
 Next relLoop

 dbsNorthwind.Close

End Sub


AppendChunk Method (ADO)

 Copy code hover
[image]

AppendChunk Method (ADO)
Send feedback

Appends data to a large text or binary data Field, or to a Parameter object.

Syntax

object. AppendChunk Data

Parameters

  • object

  • A Field or Parameter object.

  • Data

  • A Variant that contains the data to append to the object.

Remarks

Use the AppendChunk method on a Field or Parameter object to fill it with long binary or character data. In situations where system memory is limited, you can use the AppendChunk method to manipulate long values in portions rather than in their entirety.

Field

If the adFldLong bit in the Attributes property of a Field object is set to true, you can use the AppendChunk method for that field.

The first AppendChunk call on a Field object writes data to the field, overwriting any existing data. Subsequent AppendChunk calls add to existing data. If you are appending data to one field and then you set or read the value of another field in the current record, ADO assumes that you are finished appending data to the first field. If you call the AppendChunk method on the first field again, ADO interprets the call as a new AppendChunk operation and overwrites the existing data. Accessing fields in other Recordset objects that are not clones of the first Recordset object will not disrupt AppendChunk operations.

If there is no current record when you call AppendChunk on a Field object, an error occurs.

Note Note

The AppendChunk method does not operate on Field objects of a Record object. It does not perform any operation and will produce a run-time error.

Parameter

If the adParamLong bit in the Attributes property of a Parameter object is set to true, you can use the AppendChunk method for that parameter.

The first AppendChunk call on a Parameter object writes data to the parameter, overwriting any existing data. Subsequent AppendChunk calls on a Parameter object add to existing parameter data. An AppendChunk call that passes a null value discards all of the parameter data.


Set Properties by Using Visual Basic

 Copy code hover
[image]

Set Properties by Using Visual Basic
Send feedback

You can set most properties from Visual Basic code. How you set a property depends on whether you are setting it for a Form , Report , or Control object, an ActiveX Data Object (ADO), or for a Data Access Object (DAO). The following topics outline the steps involved for setting properties of each type of object:

Set Form, Report, and Control Properties in Visual Basic

Set Properties of ActiveX Data Objects in Visual Basic

Set Properties of Data Access Objects in Visual Basic


CodeProject.Connection Property (Access)

 Copy code hover
[image]

CodeProject.Connection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Connection property to return a reference to the current ActiveX Data Objects (ADO) Connection object and its related properties. Read-only Connection.

Syntax

expression .Connection

expression A variable that represents a CodeProject object.

Remarks

Use the Connection property to refer to the Connection object of the Access project or Access database code database object. You can use the Connection property to call methods on the Connection object such as BeginTrans and CommitTrans.

Note Note

The Connection property actually returns a reference to a copy of the ActiveX Data Object (ADO) connection for the active database. Thus, applying the Close method or in anyway attempting to alter the connection through the Connection object's methods or properties will have no affect on the actual connection object used by Microsoft Access to hold a live connection to the current database. Since the Connection property is the main Shape provider connection, the following information is necessary when using this property.

  1. MSDataShape uses Recordset.CursorLocation = adUseClient. Do not set CursorLocation prior to assigning a recordset to CurrentProject.Connect.

  2. MSDataShape uses Recordset.CursorType = adOpenStatic. Do not set CursorType prior to assinging a recordset to CurrentProject.Connection.

  3. MSDataShape accepts Recordset.LockType = adLockOptimistic, adLockBatchOptimistic, or adLockReadOnly (default). If set to adLockPessimistic, it is changed to adLockOptimistic.

  4. The shape connection does not support the all ADOX operation, specifically the Columns.Properties collection is not supported.

  5. In order to ensure that a shape connection will work correctly, the Command.CommandType must be set to adCmdTable.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


Documents.Count Property (DAO)

 Copy code hover
[image]

Documents.Count Property (DAO)
Send feedback

Returns the number of objects in the specified collection. Read-only.

Syntax

expression .Count

expression A variable that represents a Documents object.

Remarks

Because members of a collection begin with 0, you should always code loops starting with the 0 member and ending with the value of the Count property minus 1. If you want to loop through the members of a collection without checking the Count property, you can use a For Each...Next command.

The Count property setting is never Null. If its value is 0, there are no objects in the collection.


The Synchronizer or Replication Manager found unread data in the shared memory. The existing data will be overwritten. (Error 3529)

 Copy code hover
[image]

The Synchronizer or Replication Manager found unread data in the shared memory. The existing data will be overwritten. (Error 3529)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


Application.Version Property (Access)

 Copy code hover
[image]

Application.Version Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a String indicating the version number of the currently installed copy of Microsoft Access 2013. Read-only.

Syntax

expression .Version

expression A variable that represents an Application object.

Example

The following example displays the version and build number of the currently-installed copy of Microsoft Access.

VBA Copy code Copy code
MsgBox "You are currently running Microsoft Access, " _
 & " version " & Application.Version & ", build " _
 & Application.Build & "."

See also

Concepts

Application Object

Other resources

Application Object Members


DoCmd.Close Method (Access)

 Copy code hover
[image]

DoCmd.Close Method (Access)
See also Send feedback

Published: July 16, 2012

The Close method carries out the Close action in Visual Basic.

Syntax

expression .Close(ObjectType, ObjectName, Save)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
ObjectType | Optional | AcObjectType | A AcObjectType constant that represents the type of object to close.
ObjectName | Optional | Variant | A string expression that's the valid name of an object of the type selected by the objecttype argument.
Save | Optional | AcCloseSave | A AcCloseSave constant tha specifies whether or not to save changes to the object. The default value is acSavePrompt.

Remarks

You can use the Close method to close either a specified Microsoft Access window or the active window if none is specified.

If you leave the objecttype and objectname arguments blank (the default constant, acDefault, is assumed for objecttype), Microsoft Access closes the active window. If you specify the save argument and leave the objecttype and objectname arguments blank, you must include the objecttype and objectname arguments' commas.

Note Note

If a form has a control bound to a field that has its Required property set to 'Yes,' and the form is closed using the Close method without entering any data for that field, an error message is not displayed. Any changes made to the record will be aborted. When the form is closed using the user interface, Microsoft Access displays an alert.

To display an error message, use the RunCommand method to invoke the acCmdSaveRecord command before calling the Close method. This will cause a run-time error if one or more required fields are Null. This technique is illustrated in the following example.

VBA Copy code Copy code
Private Sub cmdCloseForm_Click()
On Error GoTo Err_cmdCloseForm_Click

 DoCmd.RunCommand acCmdSaveRecord
 DoCmd.Close

Exit_cmdCloseForm_Click:
 Exit Sub

Err_cmdCloseForm_Click:
 MsgBox Err.Description
 Resume Exit_cmdCloseForm_Click

End Sub

Example

The following example uses the Close method to close the form Order Review, saving any changes to the form without prompting:

VBA Copy code Copy code
DoCmd.Close acForm, "Order Review", acSaveYes

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


WebBrowserControl.Click Event (Access)

 Copy code hover
[image]

WebBrowserControl.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Version Information

Version Added: Access 2010

Syntax

expression .Click

expression A variable that represents a WebBrowserControl object.

Return Value

nothing

Remarks

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


ReturnVar Members (Access)

 Copy code hover
[image]

ReturnVar Members (Access)
Send feedback

Published: July 16, 2012

Represents a variable that was initialized by the SetReturnVar function in a Data Macro.

Properties

Name | Description
Name | Gets the name of the specified ReturnVar. Read-only String.
Value | Gets the value of the specified ReturnVar. Read-only Variant.


BoundObjectFrame.GridlineShade Property (Access)

 Copy code hover
[image]

BoundObjectFrame.GridlineShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineShade

expression A variable that represents an ObjectFrame object.

Remarks

The GridlineShade property contains a numeric expression that can be used to darken the theme color in the GridlineColor property. The default value of the GridlineShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Delete Method (ADO Parameters Collection)

 Copy code hover
[image]

Delete Method (ADO Parameters Collection)
Send feedback

Deletes an object from the Parameters collection.

Syntax

Parameters.Delete Index

Parameters

  • Index

  • A String value that contains the name of the object you want to delete, or the objects ordinal position (index) in the collection.

Remarks

Using the Delete method on a collection lets you remove one of the objects in the collection. This method is available only on the Parameters collection of a Command object. You must use the Parameter object's Name property or its collection index when calling the Delete method — an object variable is not a valid argument.


OptionButton.ValidationText Property (Access)

 Copy code hover
[image]

OptionButton.ValidationText Property (Access)
See also Send feedback

Published: July 16, 2012

Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.

Syntax

expression .ValidationText

expression A variable that represents an OptionButton object.

Remarks

Enter an expression for the ValidationRule property setting and text for the ValidationText property setting. The maximum length for the ValidationRule property setting is 2048 characters. The maximum length for the ValidationText property setting is 255 characters.

For controls, you can set the ValidationRule property to any valid expression. For field and record validation rules, the expression can't contain user-defined functions, domain aggregate or aggregate functions, the Eval function, or CurrentUser method, or references to forms, queries, or tables. In addition, field validation rules can't contain references to other fields. For records, expressions can include references to fields in that table.

For table fields and records, you can also set these properties in Visual Basic by using the DAO ValidationRule property.

Note Note

The ValidationRule and ValidationText properties don't apply to check box, option button, or toggle buttoncontrols when they are in an option group. They apply only to the option group itself.

Microsoft Access automatically validates values based on a field's data type; for example, Microsoft Access doesn't allow text in a numeric field. You can set rules that are more specific by using the ValidationRule property.

If you set the ValidationRule property but not the ValidationText property, Microsoft Access displays a standard error message when the validation rule is violated. If you set the ValidationText property, the text you enter is displayed as the error message.

For example, when a record is added for a new employee, you can enter a ValidationRule property requiring that the value in the employee's StartDate field fall between the company's founding date and the current date. If the date entered isn't in this range, you can display the ValidationText property message: "Start date is incorrect."

If you create a control by dragging a field from the field list, the field's validation rule remains in effect, although it isn't displayed in the control's ValidationRule property box in the property sheet. This is because a field's validation rule is inherited by a control bound to that field.

Control, field, and record validation rules are applied as follows:

  • Validation rules you set for fields and controls are applied when you edit the data and the focus leaves the field or control.

  • Validation rules for records are applied when you move to another record.

  • If you create validation rules for both a field and a control bound to the field, both validation rules are applied when you edit data and the focus leaves the control.

The following table contains expression examples for the ValidationRule and ValidationText properties.

ValidationRule property | ValidationText property
<> 0 | Entry must be a nonzero value.
> 1000 Or Is Null | Entry must be blank or greater than 1000.
Like "A????" | Entry must be 5 characters and begin with the letter "A".
>= #1/1/96# And <#1/1/97# | Entry must be a date in 1996.
DLookup("CustomerID", "Customers", "CustomerID = Forms!Customers!CustomerID") Is Null | Entry must be a unique CustomerID (domain aggregate functions are allowed only for form-level validation).

If you create a validation rule for a field, Microsoft Access doesn't normally allow a Null value to be stored in the field. If you want to allow a Null value, add "Is Null" to the validation rule, as in "<> 8 Or Is Null" and make sure the Required property is set to No.

You can't set field or record validation rules for tables created outside Microsoft Access (for example, dBASE, Paradox, or SQL Server). For these kinds of tables, you can create validation rules for controls only.

Example

The following example creates a validation rule for a field that allows only values over 65 to be entered. If a number less than 65 is entered, a message is displayed. The properties are set by using the SetFieldValidation function.

VBA Copy code Copy code
Dim strTblName As String, strFldName As String
Dim strValidRule As String
Dim strValidText As String, intX As Integer

strTblName = "Customers"
strFldName = "Age"
strValidRule = ">= 65"
strValidText = "Enter a number greater than or equal to 65."
intX = SetFieldValidation(strTblName, strFldName, _
 strValidRule, strValidText)

Function SetFieldValidation(strTblName As String, _
 strFldName As String, strValidRule As String, _
 strValidText As String) As Integer

 Dim dbs As Database, tdf As TableDef, fld As Field

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 Set fld = tdf.Fields(strFldName)
 fld.ValidationRule = strValidRule
 fld.ValidationText = strValidText
End Function

The next example uses the SetTableValidation function to set record-level validation to ensure that the value in the EndDate field comes after the value in the StartDate field.

VBA Copy code Copy code
Dim strTblName As String, strValidRule As String
Dim strValidText As String
Dim intX As Integer

strTblName = "Employees"
strValidRule = "EndDate > StartDate"
strValidText = "Enter an EndDate that is later than the StartDate."
intX = SetTableValidation(strTblName, strValidRule, strValidText)

Function SetTableValidation(strTblName As String, _
 strValidRule As String, strValidText As String) _
 As Integer

 Dim dbs As Database, tdf As TableDef

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 tdf.ValidationRule = strValidRule
 tdf.ValidationText = strValidText
End Function

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


OptionButton.ControlTipText Property (Access)

 Copy code hover
[image]

OptionButton.ControlTipText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.

Syntax

expression .ControlTipText

expression A variable that represents an OptionButton object.

Remarks

You set the ControlTipText property by using a string expression up to 255 characters long.

For controls on forms, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

You can set the ControlTipText property in any view.

The ControlTipText property provides an easy way to provide helpful information about controls on a form.

There are other ways to provide information about a form or a control on a form. You can use the StatusBarText property to display information in the status bar about a control. To provide more extensive help for a form or control, use the HelpFile and HelpContextID properties.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Recordset.NextRecordset Method (DAO)

 Copy code hover
[image]

Recordset.NextRecordset Method (DAO)
Send feedback

Syntax

expression .NextRecordset

expression A variable that represents a Recordset object.

Return Value

Boolean

Remarks

In an ODBCDirect workspace, you can open a Recordset containing more than one select query in the source argument of OpenRecordset, or the SQL property of a select query QueryDef object, as in the following example.

Copy code Copy code
SELECT LastName, FirstName FROM Authors
WHERE LastName = 'Smith';
SELECT Title, ISBN FROM Titles
WHERE Pub_ID = 9999

The returned Recordset will open with the results of the first query. To obtain the result sets of records from subsequent queries, use the NextRecordset method.

If more records are available (that is, there was another select query in the OpenRecordset call or in the SQL property), the records returned from the next query will be loaded into the Recordset, and NextRecordset will return True, indicating that the records are available. When no more records are available (that is, results of the last select query have been loaded into the Recordset), then NextRecordset will return False, and the Recordset will be empty.

You can also use the Cancel method to flush the contents of a Recordset. However, Cancel also flushes any additional records not yet loaded.

Example

This example uses the NextRecordset method to view the data from a compound SELECT query. The DefaultCursorDriver property must be set to dbUseODBCCursor when executing such queries. The NextRecordset method will return True even if some or all of the SELECT statements return zero records; it will return False only after all the individual SQL clauses have been checked.

VBA Copy code Copy code
Sub NextRecordsetX()

 Dim wrkODBC As Workspace
 Dim conPubs As Connection
 Dim rstTemp As Recordset
 Dim intCount As Integer
 Dim booNext As Boolean

 ' Create ODBCDirect Workspace object and open Connection
 ' object. The DefaultCursorDriver setting is required
 ' when using compound SQL statements.
 Set wrkODBC = CreateWorkspace("", _
 "admin", "", dbUseODBC)
 wrkODBC.DefaultCursorDriver = dbUseODBCCursor

 ' Note: The DSN referenced below must be set to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conPubs = wrkODBC.OpenConnection("Publishers", , , _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 ' Construct compound SELECT statement.
 Set rstTemp = conPubs.OpenRecordset("SELECT * " & _
 "FROM authors; " & _
 "SELECT * FROM stores; " & _
 "SELECT * FROM jobs")

 ' Try printing results from each of the three SELECT
 ' statements.
 booNext = True
 intCount = 1
 With rstTemp
 Do While booNext
 Debug.Print "Contents of recordset #" & intCount
 Do While Not .EOF
 Debug.Print , .Fields(0), .Fields(1)
 .MoveNext
 Loop
 booNext = .NextRecordset
 Debug.Print " rstTemp.NextRecordset = " & _
 booNext
 intCount = intCount + 1
 Loop
 End With

 rstTemp.Close
 conPubs.Close
 wrkODBC.Close

End Sub

Another way to accomplish the same task would be to create a prepared statement containing the compound SQL statement. The CacheSize property of the QueryDef object must be set to 1, and the Recordset object must be forward-only and read-only.

VBA Copy code Copy code
Sub NextRecordsetX2()

 Dim wrkODBC As Workspace
 Dim conPubs As Connection
 Dim qdfTemp As QueryDef
 Dim rstTemp As Recordset
 Dim intCount As Integer
 Dim booNext As Boolean

 ' Create ODBCDirect Workspace object and open Connection
 ' object. The DefaultCursorDriver setting is required
 ' when using compound SQL statements.
 Set wrkODBC = CreateWorkspace("", _
 "admin", "", dbUseODBC)
 wrkODBC.DefaultCursorDriver = dbUseODBCCursor

 ' Note: The DSN referenced below must be set to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conPubs = wrkODBC.OpenConnection("Publishers", , , _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 ' Create a temporary stored procedure with a compound
 ' SELECT statement.
 Set qdfTemp = conPubs.CreateQueryDef("", _
 "SELECT * FROM authors; " & _
 "SELECT * FROM stores; " & _
 "SELECT * FROM jobs")
 ' Set CacheSize and open Recordset object with arguments
 ' that will allow access to multiple recordsets.
 qdfTemp.CacheSize = 1
 Set rstTemp = qdfTemp.OpenRecordset(dbOpenForwardOnly, _
 dbReadOnly)

 ' Try printing results from each of the three SELECT
 ' statements.
 booNext = True
 intCount = 1
 With rstTemp
 Do While booNext
 Debug.Print "Contents of recordset #" & intCount
 Do While Not .EOF
 Debug.Print , .Fields(0), .Fields(1)
 .MoveNext
 Loop
 booNext = .NextRecordset
 Debug.Print " rstTemp.NextRecordset = " & _
 booNext
 intCount = intCount + 1
 Loop
 End With

 rstTemp.Close
 qdfTemp.Close
 conPubs.Close
 wrkODBC.Close

End Sub


Resync Method Example (VC++)

 Copy code hover
[image]

Resync Method Example (VC++)
Send feedback

This example demonstrates using the Resync method to refresh data in a static recordset.

Copy code Copy code

// BeginResyncCpp
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void ResyncX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

/////////////////////////////
// //
// Main Function //
// //
/////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 ResyncX();

 ::CoUninitialize();
}

/////////////////////////////////
// //
// ResyncX Function //
// //
/////////////////////////////////

void ResyncX(void)
{
 HRESULT hr = S_OK;

 // Define string variables.
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstTitles = NULL;

 try
 {
 // Open recordset for titles table.
 TESTHR(pRstTitles.CreateInstance(__uuidof(Recordset)));
 pRstTitles->CursorLocation = adUseClient;
 pRstTitles->CursorType = adOpenStatic;
 pRstTitles->LockType = adLockBatchOptimistic;
 pRstTitles->Open ("titles",strCnn,
 adOpenStatic, adLockBatchOptimistic, adCmdTable);

 // Change the type of the first title in the recordset.
 pRstTitles->Fields->GetItem("type")->Value =
 (_bstr_t) ("database");

 // Display the results of the change.
 printf("\nBefore resync: \n\n");

 printf("Title - %s\n\n",(LPSTR) (_bstr_t) pRstTitles->
 Fields->GetItem("title")->Value);

 printf("Type - %s\n\n",(LPSTR) (_bstr_t) pRstTitles->
 Fields->GetItem("type")->Value);

 // Resync with database.
 pRstTitles->Resync(adAffectAll,adResyncAllValues);

 // Display the results of the resynch.
 printf("\n\nAfter resync: \n\n");

 printf("Title - %s\n\n",(LPSTR) (_bstr_t) pRstTitles->
 Fields->GetItem("title")->Value);

 printf("Type - %s\n\n",(LPSTR) (_bstr_t) pRstTitles->
 Fields->GetItem("type")->Value);
 }
 catch (_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstTitles->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 if (pRstTitles)
 if (pRstTitles->State == adStateOpen)
 {
 pRstTitles->CancelBatch(adAffectAll);
 pRstTitles->Close();
 }
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////
void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;

 // Collection ranges from 0 to nCount -1.
 for(long i = 0;i < nCount;i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s\n", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////
void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print COM errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndResyncCpp


Form.CommandEnabled Event (Access)

 Copy code hover
[image]

Form.CommandEnabled Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when the specified Microsoft Office Web Component determines whether the specified command is enabled.

Syntax

expression .CommandEnabled(Command, Enabled)

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Command | Required | Variant | The command that has been verified as being enabled.
Enabled | Required | Object | Set the Value property of this object to False to disable the command.

Return Value

nothing

Remarks

The OCCommandId, ChartCommandIdEnum, and PivotCommandId constants contain lists of the supported commands for each of the Microsoft Office Web Components.

Example

The following example demonstrates the syntax for a subroutine that traps the CommandEnabled event.

VBA Copy code Copy code
Private Sub Form_CommandEnabled( _
 ByVal Command As Variant, ByVal Enabled As Object) Dim intResponse As Integer
 Dim strPrompt As String

 strPrompt = "Disable the command?"

 intResponse = MsgBox(strPrompt, vbYesNo)

 If intResponse = vbYes Then
 Enabled.Value = False
 Else
 Enabled.Value = True
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


CodeData.AllStoredProcedures Property (Access)

 Copy code hover
[image]

CodeData.AllStoredProcedures Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllStoredProcedures property to reference the AllStoredProcedures collection and its related properties. Read-only AllStoredProcedures object.

Syntax

expression .AllStoredProcedures

expression A variable that represents a CodeData object.

See also

Concepts

CodeData Object

Other resources

CodeData Object Members


Form.Picture Property (Access)

 Copy code hover
[image]

Form.Picture Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Picture property to specify a bitmap or other type of graphic to be used as a background picture on a form. Read/write String.

Syntax

expression .Picture

expression A variable that represents a Form object.

Remarks

The Picture property contains (bitmap) or the path and file name of a bitmap or other type of graphic to be displayed.

The default setting is (none). After the graphic is loaded into the object, the property setting is (bitmap) or the path and file name of the graphic. If you delete (bitmap) or the path and file name of the graphic from the property setting, the picture is deleted from the object and the property setting is again (none).

If the PictureType property is set to Embedded, the graphic is stored with the object.

You can create custom bitmaps by using Microsoft Paintbrush or another application that creates bitmap files. A bitmap file must have a .bmp, .ico, or .dib extension. You can also use graphics files in the .wmf or .emf formats, or any other graphic file type for which you have a graphics filter. Forms, reports, and image controls support all graphics. Command buttons and toggle buttons only support bitmaps.

See also

Concepts

Form Object

Other resources

Form Object Members


CollatingOrderEnum Enumeration (DAO)

 Copy code hover
[image]

CollatingOrderEnum Enumeration (DAO)
Send feedback

Specifies the sequence of the sort order in text for string comparison or sorting.

Name | Value | Description
dbSortArabic | 1025 | Arabic collating order
dbSortChineseSimplified | 2052 | Simplified Chinese collating order
dbSortChineseTraditional | 1028 | Traditional Chinese collating order
dbSortCyrillic | 1049 | Russian collating order
dbSortCzech | 1029 | Czech collating order
dbSortDutch | 1043 | Dutch collating order
dbSortGeneral | 1033 | English, German, French, and Portuguese collating order
dbSortGreek | 1032 | Greek collating order
dbSortHebrew | 1037 | Hebrew collating order
dbSortHungarian | 1038 | Hungarian collating order
dbSortIcelandic | 1039 | Icelandic collating order
dbSortJapanese | 1041 | Japanese collating order
dbSortKorean | 1042 | Korean collating order
dbSortNeutral | 1024 | Neutral collating order
dbSortNorwdan | 1030 | Norwegian and Danish collating order
dbSortPDXIntl | 1033 | Paradox international collating order
dbSortPDXNor | 1030 | Paradox Norwegian and Danish collating order
dbSortPDXSwe | 1053 | Paradox Swedish and Finnish collating order
dbSortPolish | 1045 | Polish collating order
dbSortSlovenian | 1060 | Slovenian collating order
dbSortSpanish | 1034 | Spanish collating order
dbSortSwedFin | 1053 | Swedish and Finnish collating order
dbSortThai | 1054 | Thai collating order
dbSortTurkish | 1055 | Turkish collating order
dbSortUndefined | -1 | Collating order undefined or unknown


Too many expressions in ORDER BY clause. (Error 3088)

 Copy code hover
[image]

Too many expressions in ORDER BY clause. (Error 3088)
Send feedback

You created an SQL statement that has an ORDER BY clause with more than ten expressions. Remove some of the fields listed in the ORDER BY clause.


Microsoft OLE DB Provider for Microsoft Jet

 Copy code hover
[image]

Microsoft OLE DB Provider for Microsoft Jet
Send feedback

The OLE DB Provider for Microsoft Jet allows ADO to access Microsoft Jet databases.

Connection String Parameters

To connect to this provider, set the Provider argument of the ConnectionString property to:

Copy code Copy code

Microsoft.Jet.OLEDB.4.0

Reading the Provider property will return this string as well.

Typical Connection String

A typical connection string for this provider is:

Copy code Copy code

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=databaseName;User ID=userName;Password=userPassword;"

The string consists of these keywords:

Keyword | Description
Provider | Specifies the OLE DB Provider for Microsoft Jet.
Data Source | Specifies the database path and file name (for example, c:\Northwind.mdb).
User ID | Specifies the user name. If this keyword is not specified, the string, "admin", is used by default.
Password | Specifies the user password. If this keyword is not specified, the empty string (""), is used by default.

Provider-Specific Connection Parameters

The OLE DB Provider for Microsoft Jet supports several provider-specific dynamic properties in addition to those defined by ADO. As with all other Connection parameters, they can be set via the Connection object's Properties collection or as part of the connection string.

The following table lists these properties with the corresponding OLE DB property name in parentheses.

Parameter | Description
Jet OLEDB:Compact Reclaimed Space Amount (DBPROP_JETOLEDB_COMPACTFREESPACESIZE) | Indicates an estimate of the amount of space, in bytes, that can be reclaimed by compacting the database. This value is only valid after a database connection has been established.
Jet OLEDB:Connection Control (DBPROP_JETOLEDB_CONNECTIONCONTROL) | Indicates whether users can connect to the database.
Jet OLEDB:Create System Database (DBPROP_JETOLEDB_CREATESYSTEMDATABASE) | Indicates whether a system database should be created when creating a new data source.
Jet OLEDB:Database Locking Mode (DBPROP_JETOLEDB_DATABASELOCKMODE) | Indicates the locking mode for this database. The first user to open the database determines the mode used while the database is open.
Jet OLEDB:Database Password (DBPROP_JETOLEDB_DATABASEPASSWORD) | Indicates the database password.
Jet OLEDB:Don't Copy Locale on Compact (DBPROP_JETOLEDB_COMPACT_DONTCOPYLOCALE) | Indicates whether Jet should copy locale information when compacting a database.
Jet OLEDB:Encrypt Database (DBPROP_JETOLEDB_ENCRYPTDATABASE) | Indicates whether a compacted database should be encrypted. If this property is not set, the compacted database will be encrypted if the original database was also encrypted.
Jet OLEDB:Engine Type (DBPROP_JETOLEDB_ENGINE) | Indicates the storage engine used to access the current data store.
Jet OLEDB:Exclusive Async Delay (DBPROP_JETOLEDB_EXCLUSIVEASYNCDELAY) | Indicates the maximum length of time, in milliseconds, that Jet can delay asynchronous writes to disk when the database is opened exclusively. This property is ignored unless Jet OLEDB:Flush Transaction Timeout is set to 0.
Jet OLEDB:Flush Transaction Timeout (DBPROP_JETOLEDB_FLUSHTRANSACTIONTIMEOUT) | Indicates the amount of time to wait before data stored in a cache for asynchronous writing is actually written to disk. This setting overrides the values for Jet OLEDB:Shared Async Delay and Jet OLEDB:Exclusive Async Delay.
Jet OLEDB:Global Bulk Transactions (DBPROP_JETOLEDB_GLOBALBULKNOTRANSACTIONS) | Indicates whether SQL bulk transactions are transacted.
Jet OLEDB:Global Partial Bulk Ops (DBPROP_JETOLEDB_GLOBALBULKPARTIAL) | Indicates the password used to open the database.
Jet OLEDB:Implicit Commit Sync (DBPROP_JETOLEDB_IMPLICITCOMMITSYNC) | Indicates whether changes made in internal implicit transactions are written in synchronous or asynchronous mode.
Jet OLEDB:Lock Delay (DBPROP_JETOLEDB_LOCKDELAY) | Indicates the number of milliseconds to wait before attempting to acquire a lock after a previous attempt has failed.
Jet OLEDB:Lock Retry (DBPROP_JETOLEDB_LOCKRETRY) | Indicates how many times an attempt to access a locked page is repeated.
Jet OLEDB:Max Buffer Size (DBPROP_JETOLEDB_MAXBUFFERSIZE) | Indicates the maximum amount of memory, in kilobytes, Jet can use before it starts flushing changes to disk.
Jet OLEDB:Max Locks Per File (DBPROP_JETOLEDB_MAXLOCKSPERFILE) | Indicates the maximum number of locks Jet can place on a database. The default value is 9500.
Jet OLEDB:New Database Password (DBPROP_JETOLEDB_NEWDATABASEPASSWORD) | Indicates the new password to be set for this database. The old password is stored in Jet OLEDB:Database Password.
Jet OLEDB:ODBC Command Time Out (DBPROP_JETOLEDB_ODBCCOMMANDTIMEOUT) | Indicates the number of milliseconds before a remote ODBC query from Jet will timeout.
Jet OLEDB:Page Locks to Table Lock (DBPROP_JETOLEDB_PAGELOCKSTOTABLELOCK) | Indicates how many pages need to be locked within a transaction before Jet attempts to promote the lock to a table lock. If this value is 0, then the lock is never promoted.
Jet OLEDB:Page Timeout (DBPROP_JETOLEDB_PAGETIMEOUT) | Indicates the number of milliseconds Jet will wait before checking to see if its cache is out of date with the database file.
Jet OLEDB:Recycle Long-Valued Pages (DBPROP_JETOLEDB_RECYCLELONGVALUEPAGES) | Indicates whether Jet should aggressively try to reclaim BLOB pages when they are freed.
Jet OLEDB:Registry Path (DBPROP_JETOLEDB_REGPATH) | Indicates the Windows registry key that contains values for the Jet database engine.
Jet OLEDB:Reset ISAM Stats (DBPROP_JETOLEDB_RESETISAMSTATS) | Indicates whether the schema Recordset DBSCHEMA_JETOLEDB_ISAMSTATS should reset its performance counters after returning performance information.
Jet OLEDB:Shared Async Delay (DBPROP_JETOLEDB_SHAREDASYNCDELAY) | Indicates the maximum amount of time, in milliseconds, Jet can delay asynchronous writes to disk when the database is opened in multi-user mode.
Jet OLEDB:System Database (DBPROP_JETOLEDB_SYSDBPATH) | Indicates the path and file name for the workgroup information file (system database).
Jet OLEDB:Transaction Commit Mode (DBPROP_JETOLEDB_TXNCOMMITMODE) | Indicates whether Jet writes data to disk synchronously or asynchronously when a transaction is committed.
Jet OLEDB:User Commit Sync (DBPROP_JETOLEDB_USERCOMMITSYNC) | Indicates whether changes made in transactions are written in synchronous or asynchronous mode.

Provider-Specific Recordset and Command Properties

The Jet provider also supports several provider-specific Recordset and Command properties. These properties are accessed and set through the Properties collection of the Recordset or Command object. The table lists the ADO property name and its corresponding OLE DB property name in parentheses.

Property Name | Description
Jet OLEDB:Bulk Transactions (DBPROP_JETOLEDB_BULKNOTRANSACTIONS) | Indicates whether SQL bulk operations are transacted. Large bulk operations might fail when transacted, due to resource delays.
Jet OLEDB:Enable Fat Cursors (DBPROP_JETOLEDB_ENABLEFATCURSOR) | Indicates whether Jet should cache multiple rows when populating a recordset for remote row sources.
Jet OLEDB:Fat Cursor Cache Size (DBPROP_JETOLEDB_FATCURSORMAXROWS) | Indicates the number of rows to cache when using remote data store row caching. This value is ignored unless Jet OLEDB:Enable Fat Cursors is True.
Jet OLEDB:Inconsistent (DBPROP_JETOLEDB_INCONSISTENT) | Indicates whether query results allow inconsistent updates.
Jet OLEDB:Locking Granularity (DBPROP_JETOLEDB_LOCKGRANULARITY) | Indicates whether a table is opened using row-level locking.
Jet OLEDB:ODBC Pass-Through Statement (DBPROP_JETOLEDB_ODBCPASSTHROUGH) | Indicates that Jet should pass the SQL text in a Command object to the back end unaltered.
Jet OLEDB:Partial Bulk Ops (DBPROP_JETOLEDB_BULKPARTIAL) | Indicates Jet's behavior when SQL DML operations fail.
Jet OLEDB:Pass Through Query Bulk-Op (DBPROP_JETOLEDB_PASSTHROUGHBULKOP) | Indicates whether queries that do not return a Recordset are passed unaltered to the data source.
Jet OLEDB:Pass Through Query Connect String (DBPROP_JETOLEDB_ODBCPASSTHROUGHCONNECTSTRING) | Indicates the Jet connect string used to connect to a remote data store. This value is ignored unless Jet OLEDB:ODBC Pass-Through Statement is True.
Jet OLEDB:Stored Query (DBPROP_JETOLEDB_STOREDQUERY) | Indicates whether the command text should be interpreted as a stored query instead of an SQL command.
Jet OLEDB:Validate Rules On Set (DBPROP_JETOLEDB_VALIDATEONSET) | Indicates whether the Jet validation rules are evaluated when column data is set or when the changes are committed to the database.

By default, the OLE DB Provider for Microsoft Jet opens Microsoft Jet databases in read/write mode. To open a database in read-only mode, set the Mode property on the ADO Connection object to adModeRead.

Command Object Usage

Command text in the Command object uses the Microsoft Jet SQL dialect. You can specify row-returning queries, action queries, and table names in the command text; however, stored procedures are not supported and should not be specified.

Recordset Behavior

The Microsoft Jet database engine does not support dynamic cursors. Therefore, the OLE DB Provider for Microsoft Jet does not support the adLockDynamic cursor type. When a dynamic cursor is requested, the provider will return a keyset cursor and reset the CursorType property to indicate the type of Recordset returned. Further, if an updatable Recordset is requested (LockType is adLockOptimistic, adLockBatchOptimistic, or adLockPessimistic) the provider will also return a keyset cursor and reset the CursorType property.

Dynamic Properties

The OLE DB Provider for Microsoft Jet inserts several dynamic properties into the Properties collection of the unopened Connection, Recordset, and Command objects.

The tables below are a cross-index of the ADO and OLE DB names for each dynamic property. The OLE DB Programmer's Reference refers to an ADO property name by the term, "Description." You can find more information about these properties in the OLE DB Programmer's Reference. Search for the OLE DB property name in the Index or see Appendix C: OLE DB Properties.

Connection Dynamic Properties

The following properties are added to the Connection object's Properties collection.

ADO Property Name | OLE DB Property Name
Active Sessions | DBPROP_ACTIVESESSIONS
Asynchable Abort | DBPROP_ASYNCTXNABORT
Asynchable Commit | DBPROP_ASYNCTNXCOMMIT
Autocommit Isolation Levels | DBPROP_SESS_AUTOCOMMITISOLEVELS
Catalog Location | DBPROP_CATALOGLOCATION
Catalog Term | DBPROP_CATALOGTERM
Column Definition | DBPROP_COLUMNDEFINITION
Current Catalog | DBPROP_CURRENTCATALOG
Data Source | DBPROP_INIT_DATASOURCE
Data Source Name | DBPROP_DATASOURCENAME
Data Source Object Threading Model | DBPROP_DSOTHREADMODEL
DBMS Name | DBPROP_DBMSNAME
DBMS Version | DBPROP_DBMSVER
GROUP BY Support | DBPROP_GROUPBY
Heterogeneous Table Support | DBPROP_HETEROGENEOUSTABLES
Identifier Case Sensitivity | DBPROP_IDENTIFIERCASE
Isolation Levels | DBPROP_SUPPORTEDTXNISOLEVELS
Isolation Retention | DBPROP_SUPPORTEDTXNISORETAIN
Locale Identifier | DBPROP_INIT_LCID
Maximum Index Size | DBPROP_MAXINDEXSIZE
Maximum Row Size | DBPROP_MAXROWSIZE
Maximum Row Size Includes BLOB | DBPROP_MAXROWSIZEINCLUDESBLOB
Maximum Tables in SELECT | DBPROP_MAXTABLESINSELECT
Mode | DBPROP_INIT_MODE
Multiple Parameter Sets | DBPROP_MULTIPLEPARAMSETS
Multiple Results | DBPROP_MULTIPLERESULTS
Multiple Storage Objects | DBPROP_MULTIPLESTORAGEOBJECTS
Multi-Table Update | DBPROP_MULTITABLEUPDATE
NULL Collation Order | DBPROP_NULLCOLLATION
NULL Concatenation Behavior | DBPROP_CONCATNULLBEHAVIOR
OLE DB Version | DBPROP_PROVIDEROLEDBVER
OLE Object Support | DBPROP_OLEOBJECTS
Open Rowset Support | DBPROP_OPENROWSETSUPPORT
ORDER BY Columns in Select List | DBPROP_ORDERBYCOLUMNSINSELECT
Output Parameter Availability | DBPROP_OUTPUTPARAMETERAVAILABILITY
Pass By Ref Accessors | DBPROP_BYREFACCESSORS
Password | DBPROP_AUTH_PASSWORD
Persistent ID Type | DBPROP_PERSISTENTIDTYPE
Prepare Abort Behavior | DBPROP_PREPAREABORTBEHAVIOR
Prepare Commit Behavior | DBPROP_PREPARECOMMITBEHAVIOR
Procedure Term | DBPROP_PROCEDURETERM
Prompt | DBPROP_INIT_PROMPT
Provider Friendly Name | DBPROP_PROVIDERFRIENDLYNAME
Provider Name | DBPROP_PROVIDERFILENAME
Provider Version | DBPROP_PROVIDERVER
Read-Only Data Source | DBPROP_DATASOURCEREADONLY
Rowset Conversions on Command | DBPROP_ROWSETCONVERSIONSONCOMMAND
Schema Term | DBPROP_SCHEMATERM
Schema Usage | DBPROP_SCHEMAUSAGE
SQL Support | DBPROP_SQLSUPPORT
Structured Storage | DBPROP_STRUCTUREDSTORAGE
Subquery Support | DBPROP_SUBQUERIES
Table Term | DBPROP_TABLETERM
Transaction DDL | DBPROP_SUPPORTEDTXNDDL
User ID | DBPROP_AUTH_USERID
User Name | DBPROP_USERNAME
Window Handle | DBPROP_INIT_HWND

Recordset Dynamic Properties

The following properties are added to the Recordset object's Properties collection.

ADO Property Name | OLE DB Property Name
Access Order | DBPROP_ACCESSORDER
Append-Only Rowset | DBPROP_APPENDONLY
Blocking Storage Objects | DBPROP_BLOCKINGSTORAGEOBJECTS
Bookmark Type | DBPROP_BOOKMARKTYPE
Bookmarkable | DBPROP_IROWSETLOCATE
Bookmarks Ordered | DBPROP_ORDEREDBOOKMARKS
Cache Deferred Columns | DBPROP_CACHEDEFERRED
Change Inserted Rows | DBPROP_CHANGEINSERTEDROWS
Column Privileges | DBPROP_COLUMNRESTRICT
Column Set Notification | DBPROP_NOTIFYCOLUMNSET
Column Writable | DBPROP_MAYWRITECOLUMN
Defer Column | DBPROP_DEFERRED
Delay Storage Object Updates | DBPROP_DELAYSTORAGEOBJECTS
Fetch Backwards | DBPROP_CANFETCHBACKWARDS
Hold Rows | DBPROP_CANHOLDROWS
IAccessor | DBPROP_IAccessor
IColumnsInfo | DBPROP_IColumnsInfo
IColumnsRowset | DBPROP_IColumnsRowset
IConnectionPointContainer | DBPROP_IConnectionPointContainer
IConvertType | DBPROP_IConvertType
ILockBytes | DBPROP_ILockBytes
Immobile Rows | DBPROP_IMMOBILEROWS
IRowset | DBPROP_IRowset
IRowsetChange | DBPROP_IRowsetChange
IRowsetIdentity | DBPROP_IRowsetIdentity
IRowsetIndex | DBPROP_IRowsetIndex
IRowsetInfo | DBPROP_IRowsetInfo
IRowsetLocate | DBPROP_IRowsestLocate
IRowsetResynch |
IRowsetScroll | DBPROP_IRowsetScroll
IRowsetUpdate | DBPROP_IRowsetUpdate
ISequentialStream | DBPROP_ISequentialStream
IStorage | DBPROP_IStorage
IStream | DBPROP_IStream
ISupportErrorInfo | DBPROP_ISupportErrorInfo
Literal Bookmarks | DBPROP_LITERALBOOKMARKS
Literal Row Identity | DBPROP_LITERALIDENTITY
Maximum Open Rows | DBPROP_MAXOPENROWS
Maximum Pending Rows | DBPROP_MAXPENDINGROWS
Maximum Rows | DBPROP_MAXROWS
Memory Usage | DBPROP_MEMORYUSAGE
Notification Granularity | DBPROP_NOTIFICATIONGRANULARITY
Notification Phases | DBPROP_NOTIFICATIONPHASES
Objects Transacted | DBPROP_TRANSACTEDOBJECT
Others' Changes Visible | DBPROP_OTHERUPDATEDELETE
Others' Inserts Visible | DBPROP_OTHERINSERT
Own Changes Visible | DBPROP_OWNUPDATEDELETE
Own Inserts Visible | DBPROP_OWNINSERT
Preserve on Abort | DBPROP_ABORTPRESERVE
Preserve on Commit | DBPROP_COMMITPRESERVE
Quick Restart | DBPROP_QUICKRESTART
Reentrant Events | DBPROP_REENTRANTEVENTS
Remove Deleted Rows | DBPROP_REMOVEDELETED
Report Multiple Changes | DBPROP_REPORTMULTIPLECHANGES
Return Pending Inserts | DBPROP_RETURNPENDINGINSERTS
Row Delete Notification | DBPROP_NOTIFYROWDELETE
Row First Change Notification | DBPROP_NOTIFYROWFIRSTCHANGE
Row Insert Notification | DBPROP_NOTIFYROWINSERT
Row Privileges | DBPROP_ROWRESTRICT
Row Resynchronization Notification | DBPROP_NOTIFYROWRESYNCH
Row Threading Model | DBPROP_ROWTHREADMODEL
Row Undo Change Notification | DBPROP_NOTIFYROWUNDOCHANGE
Row Undo Delete Notification | DBPROP_NOTIFYROWUNDODELETE
Row Undo Insert Notification | DBPROP_NOTIFYROWUNDOINSERT
Row Update Notification | DBPROP_NOTIFYROWUPDATE
Rowset Fetch Position Change Notification | DBPROP_NOTIFYROWSETFETCHPOSISIONCHANGE
Rowset Release Notification | DBPROP_NOTIFYROWSETRELEASE
Scroll Backwards | DBPROP_CANSCROLLBACKWARDS
Skip Deleted Bookmarks | DBPROP_BOOKMARKSKIPPED
Strong Row Identity | DBPROP_STRONGITDENTITY
Updatability | DBPROP_UPDATABILITY
Use Bookmarks | DBPROP_BOOKMARKS

Command Dynamic Properties

The following properties are added to the Command object's Properties collection.

ADO Property Name | OLE DB Property Name
Access Order | DBPROP_ACCESSORDER
Append-Only Rowset | DBPROP_APPENDONLY
Blocking Storage Objects | DBPROP_BLOCKINGSTORAGEOBJECTS
Bookmark Type | DBPROP_BOOKMARKTYPE
Bookmarkable | DBPROP_IROWSETLOCATE
Change Inserted Rows | DBPROP_CHANGEINSERTEDROWS
Column Privileges | DBPROP_COLUMNRESTRICT
Column Set Notification | DBPROP_NOTIFYCOLUMNSET
Defer Column | DBPROP_DEFERRED
Delay Storage Object Updates | DBPROP_DELAYSTORAGEOBJECTS
Fetch Backwards | DBPROP_CANFETCHBACKWARDS
Hold Rows | DBPROP_CANHOLDROWS
IAccessor | DBPROP_IAccessor
IColumnsInfo | DBPROP_IColumnsInfo
IColumnsRowset | DBPROP_IColumnsRowset
IConnectionPointContainer | DBPROP_IConnectionPointContainer
IConvertType | DBPROP_IConvertType
ILockBytes | DBPROP_ILockBytes
Immobile Rows | DBPROP_IMMOBILEROWS
IRowset | DBPROP_IRowset
IRowsetChange | DBPROP_IRowsetChange
IRowsetIdentity | DBPROP_IRowsetIdentity
IRowsetIndex | DBPROP_IRowsetIndex
IRowsetInfo | DBPROP_IRowsetInfo
IRowsetLocate | DBPROP_IRowsetLocate
IRowsetResynch |
IRowsetScroll | DBPROP_IRowsetScroll
IRowsetUpdate | DBPROP_IRowsetUpdate
ISequentialStream | DBPROP_ISequentialStream
IStorage | DBPROP_IStorage
IStream | DBPROP_IStream
ISupportErrorInfo | DBPROP_ISupportErrorInfo
Literal Bookmarks | DBPROP_LITERALBOOKMARKS
Literal Row Identity | DBPROP_LITERALIDENTITY
Lock Mode | DBPROP_LOCKMODE
Maximum Open Rows | DBPROP_MAXOPENROWS
Maximum Pending Rows | DBPROP_MAXPENDINGROWS
Maximum Rows | DBPROP_MAXROWS
Notification Granularity | DBPROP_NOTIFICATIONGRANULARITY
Notification Phases | DBPROP_NOTIFICATIONPHASES
Objects Transacted | DBPROP_TRANSACTEDOBJECT
Others' Changes Visible | DBPROP_OTHERUPDATEDELETE
Others' Inserts Visible | DBPROP_OTHERINSERT
Own Changes Visible | DBPROP_OWNUPDATEDELETE
Own Inserts Visible | DBPROP_OWNINSERT
Preserve on Abort | DBPROP_ABORTPRESERVE
Preserve on Commit | DBPROP_COMMITPRESERVE
Quick Restart | DBPROP_QUICKRESTART
Reentrant Events | DBPROP_REENTRANTEVENTS
Remove Deleted Rows | DBPROP_REMOVEDELETED
Report Multiple Changes | DBPROP_REPORTMULTIPLECHANGES
Return Pending Inserts | DBPROP_RETURNPENDINGINSERTS
Row Delete Notification | DBPROP_NOTIFYROWDELETE
Row First Change Notification | DBPROP_NOTIFYROWFIRSTCHANGE
Row Insert Notification | DBPROP_NOTIFYROWINSERT
Row Privileges | DBPROP_ROWRESTRICT
Row Resynchronization Notification | DBPROP_NOTIFYROWRESYNCH
Row Threading Model | DBPROP_ROWTHREADMODEL
Row Undo Change Notification | DBPROP_NOTIFYROWUNDOCHANGE
Row Undo Delete Notification | DBPROP_NOTIFYROWUNDODELETE
Row Undo Insert Notification | DBPROP_NOTIFYROWUNDOINSERT
Row Update Notification | DBPROP_NOTIFYROWUPDATE
Rowset Fetch Position Change Notification | DBPROP_NOTIFYROWSETFETCHPOSITIONCHANGE
Rowset Release Notification | DBPROP_NOTIFYROWSETRELEASE
Scroll Backwards | DBPROP_CANSCROLLBACKWARDS
Server Data on Insert | DBPROP_SERVERDATAONINSERT
Skip Deleted Bookmarks | DBPROP_BOOKMARKSKIP
Strong Row Identity | DBPROP_STRONGIDENTITY
Updatability | DBPROP_UPDATABILITY
Use Bookmarks | DBPROP_BOOKMARKS

See AlsoFor specific implementation details and functional information about the OLE DB Provider for Microsoft Jet, consult the OLE DB Provider for Microsoft Jet documentation in the MDAC SDK.


TempVar Object (Access)

 Copy code hover
[image]

TempVar Object (Access)
See also Send feedback

Published: July 16, 2012

Represents a variable that be used in Visual Basic for Applications (VBA) code or from a macro.

Version Information

Version Added: Access 2007

Remarks

A TempVar objects provide a convenient way to exchange data between VBA procedures and macros.

Although a TempVar object can be used to store information for use in VBA procedures, it does not have the same funcitonality as a VBA variable.

  • By default, a TempVar object remains in memory until Access is closed. You can use the Remove method or the RemoveTempVar macro action to remove a TempVar object.

  • In VBA, a TempVar object is accessible only to the members of the Access Application object, referenced databases, or add-ins.

  • A TempVar object can store only text or numeric data. TempVar objects cannot store objects.

To refer to a TempVar object in a collection by its ordinal number or by its Name property setting, use the following syntax form:

  • TempVar![name]

See also

Concepts

Access Object Model Reference

Other resources

TempVar Object Members


Error Properties (DAO)

 Copy code hover
[image]

Error Properties (DAO)
Send feedback

In this section

  • Error.Description Property (DAO)

  • Error.Number Property (DAO)

  • Error.Source Property (DAO)


Unbound Object Frame Control

 Copy code hover
[image]

Unbound Object Frame Control
Send feedback

Published: July 16, 2012

The unbound object frame control displays a picture, chart, or any OLE object not stored in a table. For example, you can use an unbound object frame to display a chart that you created and stored in Microsoft Graph.

Remarks

This control allows you to create or edit the object from within a Microsoft Access form or report by using the application in which the object was originally created.

To display objects that are stored in a Microsoft Access database, use a bound object frame control.

The object in an unbound object frame is the same for every record.

The unbound object frame can display linked or embedded objects.

Tip Tip

You can use the unbound object frame or an image control to display unbound pictures in a form or report. The advantage of using the unbound object frame is that you can edit the object directly from the form or report. The advantage of using the image control is that it's faster to display.


ComboBox.GridlineWidthRight Property (Access)

 Copy code hover
[image]

ComboBox.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified combo box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthRight

expression A variable that represents a ComboBox object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


OptionButton.OnMouseMove Property (Access)

 Copy code hover
[image]

OptionButton.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Syntax

expression .OnMouseMove

expression A variable that represents an OptionButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


FormatCondition.ShortestBarLimit Property (Access)

 Copy code hover
[image]

FormatCondition.ShortestBarLimit Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets how the shortest data bar is evaluated for the specified FormatCondition. Read/write AcFormatBarLimits.

Version Information

Version Added: Access 2010

Syntax

expression .ShortestBarLimit

expression A variable that represents a FormatCondition object.

Remarks

By default, the lowest value is used to determine the length of the shortest data bar.

See also

Concepts

FormatCondition Object

Other resources

FormatCondition Object Members


SmartTagProperties.Application Property (Access)

 Copy code hover
[image]

SmartTagProperties.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a SmartTagProperties object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

SmartTagProperties Collection

Other resources

SmartTagProperties Object Members


Required Property (Access)

 Copy code hover
[image]

Required Property (Access)
Send feedback

Published: July 16, 2012

You can use the Required property to specify whether a value is required in a field. If this property is set to Yes, when you enter data in a record, you must enter a value in the field or in any control bound to the field, and the value cannot be Null. For example, you might want to be sure that a LastName control has a value for each record. When you want to permit Null values in a field, you must not only set the Required property to No but, if there is a ValidationRule property setting, it must also explicitly state "validationrule Or Is Null".

Note Note

The Required property doesn't apply to AutoNumber fields.

Setting

The Required property uses the following settings.

Setting | Visual Basic | Description
Yes | True (-1) | The field requires a value.
No | False (0) | (Default) The field doesn't require a value.

You can set this property for all table fields (except AutoNumber data type fields) by using the table's property sheet or Visual Basic .

Note Note

To access a field's Required property in Visual Basic, use the DAO Required property.

Remarks

The Required property is enforced at the table level by the Microsoft Jet database engine. If you set this property to Yes, the field must receive or already contain a value when it has the focus — when a user enters data in a table (or in a form or datasheet based on the table), when a macro or Visual Basic sets the value of the field, or when data is imported into the table.

You can use the Required and AllowZeroLength properties to differentiate between information that doesn't exist (stored as a zero-length string (" ") in the field) and information that may exist but is unknown (stored as a Null value in the field). If you set the AllowZeroLength property to Yes, a zero-length string will be a valid entry in the field regardless of the Required property setting. If you set Required to Yes and AllowZeroLength to No, you must enter a value in the field, and a zero-length string won't be a valid entry.

Tip Tip

You can use an input mask when data is entered in a field to distinguish between the display of a Null value and a zero-length string. For example, the string "None" could be displayed when a zero-length string is entered.

The following table shows the results you can expect when you combine the settings of the Required and AllowZeroLength properties.

Required | AllowZeroLength | User's action | Value stored
No | No | Presses ENTER Presses SPACEBAR Enters a zero-length string | Null Null (not allowed)
No | Yes | Presses ENTER Presses SPACEBAR Enters a zero-length string | Null Null Zero-length string
Yes | No | Presses ENTER Presses SPACEBAR Enters a zero-length string | (not allowed) (not allowed) (not allowed)
Yes | Yes | Presses ENTER Presses SPACEBAR Enters a zero-length string | (not allowed) Zero-length string Zero-length string

If you set the Required property to Yes for a field in a table that already contains data, Microsoft Access gives you the option of checking whether the field has a value in all existing records. However, you can require that a value be entered in this field in all new records even if there are existing records with Null values in the field.

Note Note

To enforce a relationship between related tables that don't allow Null values, set the Required property of the foreign key field in the related table to Yes. The Jet database engine then ensures that you have a related record in the parent table before you can create a record in the child table. If the foreign key field is part of the primary key of the child table, this is unnecessary, because a primary key field can't contain a Null value.


How to: Determine Whether The Current Record is a New Record In a Form

 Copy code hover
[image]

How to: Determine Whether The Current Record is a New Record In a Form
Send feedback

The following example shows how to use the NewRecord property to determine if the current record is a new record. The NewRecordMark procedure sets the current record to the variable intnewrec. If the record is new, a message notifies the user. You could call this procedure when the Current event for a form occurs.

VBA Copy code Copy code
Sub NewRecordMark(frm As Form)
    Dim intnewrec As Integer

    intnewrec = frm.NewRecord
    If intnewrec = True Then
    MsgBox "You're in a new record." _
        & "@Do you want to add new data?" _
        & "@If not, move to an existing record."
    End If
End Sub


Type Property (ADO MD)

 Copy code hover
[image]

Type Property (ADO MD)
Send feedback

Indicates the type of the current member.

Return Values

Returns a MemberTypeEnum value and is read-only.

Remarks

This property is supported only on Member objects belonging to a Level object. An error occurs when this property is referenced from Member objects belonging to a Position object.


Image.Top Property (Access)

 Copy code hover
[image]

Image.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Syntax

expression .Top

expression A variable that represents an Image object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

Image Object

Other resources

Image Object Members


ListBox.FontSize Property (Access)

 Copy code hover
[image]

ListBox.FontSize Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontSize property to specify the point size for text in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Integer.

Syntax

expression .FontSize

expression A variable that represents a ListBox object.

Remarks

The FontSize property uses the following settings.

Setting | Description
8 | (Default for all reports and controls except command buttons) The text is 8-point type.
10 | (Default for command buttons) The text is 10-point type.
Other sizes | The text is the indicated size.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set this property only in an event procedure or in a macro specified by the OnPrint event property setting.

In Visual Basic, you set the FontSize property by using a numeric expression equal to the desired size of the font. The setting for the FontSize property can be between 1 and 127, inclusive.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


ListBox.ColumnWidths Property (Access)

 Copy code hover
[image]

ListBox.ColumnWidths Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnWidths property to specify the width of each column in a multiple-column list box. Read/write String.

Syntax

expression .ColumnWidths

expression A variable that represents a ListBox object.

Remarks

The ColumnWidths property holds a value specifying the width of each column in inches or centimeters, depending on the measurement system (U.S. or Metric) selected in the Measurement system box on the Number tab of the Regional Options dialog box of Windows Control Panel. The default setting is 1 inch or 2.54 centimeters. The ColumnWidths property setting must be a value from 0 to 22 inches (55.87 cm) for each column in the list box or combo box.

To separate your column entries, use semicolons (;) as list separators (or the list separator selected in the List separator box on the Number tab of the Regional Options dialog box).

A width of 0 hides a column. Any or all of the ColumnWidths property settings can be blank. You create a blank setting by typing a list separator without a preceding value. Blank values result in Microsoft Access automatically setting a default column width that varies depending on the number of columns and the width of the combo box or list box.

In Visual Basic, use a string expression to set the column width values in twips. Column widths are separated by semicolons. To specify a different unit of measurement, include the unit of measure (cm or in). For example, the following string expression specifies three column widths in centimeters.

VBA Copy code Copy code
"6 cm;0;6 cm"

You can also use this property to hide one or more columns.

If you leave the ColumnWidths property setting blank, Microsoft Access sets the width of each column as the overall width of the list box or combo box divided by the number of columns.

If the column widths you set are too wide to be fully displayed within the combo box or list box, the rightmost columns are hidden and a horizontal scroll bar appears.

If you specify the width for some columns but leave the setting for others blank, Microsoft Access divides the remaining width by the number of columns for which you haven't specified a width. The minimum calculated column width is 1,440 twips (1 inch).

For example, the following settings are applied to a 4-inch list box with three columns.

Setting | Description
1.5 in;0;2.5 in | The first column is 1.5 inches, the second column is hidden, and the third column is 2.5 inches.
2 in;;2 in | The first column is 2 inches, the second column is 1 inch (default), and the third column is 2 inches. Because only half of the third column is visible, a horizontal scroll bar appears.
(Blank) | The three columns are the same width (1.33 inches).
Note Note

This property is different than the ColumnWidth property, which specifies the width of a specified column in a datasheet.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Attachment.LabelY Property (Access)

 Copy code hover
[image]

Attachment.LabelY Property (Access)
See also Send feedback

Published: July 16, 2012

Version Information

Version Added: Access 2007

Syntax

expression .LabelY

expression A variable that represents an Attachment object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper-right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is right to left, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Round Function (Access 2013 custom web app)

 Copy code hover
[image]

Round Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns a numeric value, either rounded or truncated, to the specified length or precision.

Syntax

Round (Number, Precision, [TruncateInsteadOfRound])

The Round function contains the following arguments.

Argument name | Description
Number | A numeric expression.
Precision | The precision to which Number is to be rounded. Precision must be a numeric expression. When Precision is a positive number, Number is rounded to the number of decimal positions specified by length. When Precision is a negative number, Number is rounded on the left side of the decimal point, as specified by length.
TruncateInsteadOfRound | The type of operation to perform. When omitted or set to 0, Number is rounded. When a value other than 0 is specified, Number is truncated. The default value is 0.

Remarks

Round always returns a value. If length is negative and larger than the number of digits before the decimal point, Round returns 0.


Line Members (Access)

 Copy code hover
[image]

Line Members (Access)
Send feedback

Published: July 16, 2012

The line control displays a horizontal, vertical, or diagonal line on a form or report.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the line is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LineSlant | You use the LineSlant property to specify whether a line control slants from upper left to lower right or from upper right to lower left. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified line is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


How to: Calculate Age

 Copy code hover
[image]

How to: Calculate Age
Send feedback

Microsoft Access does not include a function that will calculate the age of a person or thing based on a given date. This topic contains Microsoft Visual Basic for Applications (VBA) code for two custom functions, Age and AgeMonths, that will calculate age based on a given date.

The following function calculates age in years from a given date to today's date.

VBA Copy code Copy code
 Function Age (varBirthDate As Variant) As Integer
 Dim varAge As Variant

 If IsNull(varBirthdate) then Age = 0: Exit Function

 varAge = DateDiff("yyyy", varBirthDate, Now)
 If Date < DateSerial(Year(Now), Month(varBirthDate), _
 Day(varBirthDate)) Then
 varAge = varAge - 1
 End If
 Age = CInt(varAge)
 End Function

The following function calculates the number of months that have transpired since the last month supplied by the given date. If the given date is a birthday, the function returns the number of months since the last birthday.

VBA Copy code Copy code
 Function AgeMonths(ByVal StartDate As String) As Integer
 Dim tAge As Double
 tAge = (DateDiff("m", StartDate, Now))
 If (DatePart("d", StartDate) > DatePart("d", Now)) Then
 tAge = tAge - 1
 End If

 If tAge < 0 Then
 tAge = tAge + 1
 End If

 AgeMonths = CInt(tAge Mod 12)

 End Function


What is a Lock? (ADO)

 Copy code hover
[image]

What is a Lock? (ADO)
Send feedback

In this section

  • What is a Lock?

  • Types of Locks


MacroError Properties (Access)

 Copy code hover
[image]

MacroError Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
ActionName | Gets the name of the macro action that was executing when an error occurred. Read-only.
Arguments | Gets the arguments specified for the macro action that was executing when an error occurred. Read-only String.
Condition | Gets the condition of the macro action that was executing when an error occurred. Read-only String.
Description | Gets the text that represents the current error message. Read-only String.
MacroName | Gets the name of the macro that was running when an error occurred. Read-only String.
Number | Gets the current error number. Read-only Long.


SubForm.GridlineColor Property (Access)

 Copy code hover
[image]

SubForm.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified subform. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineColor

expression A variable that represents a SubForm object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Field Members (DAO)

 Copy code hover
[image]

Field Members (DAO)
Send feedback

A Field object represents a column of data with a common data type and a common set of properties.

Methods

Name | Description
AppendChunk | Appends data from a string expression to a Memo or Long Binary Field object in a Recordset.
CreateProperty | Creates a new user-defined Property object (Microsoft Access workspaces only).
GetChunk | Returns all or a portion of the contents of a Memo or Long Binary Field object in the Fields collection of a Recordset object.

Properties

Name

Description

AllowZeroLength

Sets or returns a value that indicates whether a zero-length string ("") is a valid setting for the Value property of the Field object with a Text or Memo data type (Microsoft Access workspaces only).

Attributes

Sets or returns a value that indicates one or more characteristics of a Field object. Read/write Long.

CollatingOrder

Returns a value that specifies the sequence of the sort order in text for string comparison or sorting (Microsoft Access workspaces only). Read-only Long.

DataUpdatable

Returns a value that indicates whether the data in the field represented by a Field object is updatable.

DefaultValue

Sets or returns the default value of a Field object. For a Field object not yet appended to the Fields collection, this property is read/write (Microsoft Access workspaces only).

FieldSize

Returns the number of bytes used in the database (rather than in memory) of a Memo or Long Binary Field object in the Fields collection of a Recordset object.

ForeignName

Sets or returns a value that specifies the name of the Field object in a foreign table that corresponds to a field in a primary table for a relationship (Microsoft Access workspaces only).

Name

Returns or sets the name of the specified object. Read/write String if the object has not been appended to a collection. Read-only String if the object has been appended to a collection.

OrdinalPosition

Sets or returns the relative position of a Field object within a Fields collection. .

OriginalValue

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Returns the value of a Field in the database that existed when the last batch update began (ODBCDirect workspaces only).

Properties

Returns the Properties collection of the specified object. Read-only.

Required

Sets or returns a value that indicates whether a Field object requires a non-Null value.

Size

Returns the number of bytes used in the database (rather than in memory) of a Memo or Long Binary Field object in the Fields collection of a Recordset object.

SourceField

Returns a value that indicates the name of the field that is the original source of the data for a Field object. Read-only String.

SourceTable

Returns a value that indicates the name of the table that is the original source of the data for a Field object. Read-only String.

Type

Sets or returns a value that indicates the operational type or data type of an object. Read/write Integer.

ValidateOnSet

Sets or returns a value that specifies whether or not the value of a Field object is immediately validated when the object's Value property is set (Microsoft Access workspaces only).

ValidationRule

Sets or returns a value that validates the data in a field as it's changed or added to a table (Microsoft Access workspaces only). Read/write String.

ValidationText

Sets or returns a value that specifies the text of the message that your application displays if the value of a Field object doesn't satisfy the validation rule specified by the ValidationRule property setting (Microsoft Access workspaces only). Read/write String.

Value

Sets or returns the value of an object. Read/write Variant.

VisibleValue

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Returns a value currently in the database that is newer than the OriginalValue property as determined by a batch update conflict (ODBCDirect workspaces only).


Keyset Cursors

 Copy code hover
[image]

Keyset Cursors
Send feedback

The keyset cursor provides functionality between a static and a dynamic cursor in its ability to detect changes. Like a static cursor, it does not always detect changes to the membership and order of the result set. Like a dynamic cursor, it does detect changes to the values of rows in the result set.

Keyset-driven cursors are controlled by a set of unique identifiers (keys) known as the keyset. The keys are built from a set of columns that uniquely identify the rows in the result set. The keyset is the set of key values from all the rows returned by the query statement.

With keyset-driven cursors, a key is built and saved for each row in the cursor and stored either on the client workstation or on the server. When you access each row, the stored key is used to fetch the current data values from the data source. In a keyset-driven cursor, result set membership is frozen when the keyset is fully populated. Thereafter, additions or updates that affect membership are not a part of the result set until it is reopened.

Changes to data values (made either by the keyset owner or other processes) are visible as the user scrolls through the result set. Inserts made outside the cursor (by other processes) are visible only if the cursor is closed and reopened. Inserts made from inside the cursor are visible at the end of the result set.

When a keyset-driven cursor attempts to retrieve a row that has been deleted, the row appears as a "hole" in the result set. The key for the row exists in the keyset, but the row no longer exists in the result set. If the key values in a row are updated, the row is considered to have been deleted and then inserted, so such rows also appear as holes in the result set. While a keyset-driven cursor can always detect rows deleted by other processes, it can optionally remove the keys for rows it deletes itself. Keyset-driven cursors that do this cannot detect their own deletes because the evidence has been removed.

An update to a key column operates like a delete of the old key followed by an insert of the new key. The new key value is not visible if the update was not made through the cursor. If the update was made through the cursor, the new key value is visible at the end of the result set.

There is a variation on keyset-driven cursors called keyset-driven standard cursors. In a keyset-driven standard cursor, the membership of rows in the result set and the order of the rows are fixed at cursor open time, but changes to values that are made by the cursor owner and committed changes made by other processes are visible. If a change disqualifies a row for membership or affects the order of a row, the row does not disappear or move unless the cursor is closed and reopened. Inserted data does not appear, but changes to existing data do appear as the rows are fetched.

The keyset-driven cursor is difficult to use correctly because the sensitivity to data changes depends on many differing circumstances, as described above. However, if your application is not concerned with concurrent updates, can programmatically handle bad keys, and must directly access certain keyed rows, the keyset-driven cursor might work for you. Use the adOpenKeyset CursorTypeEnum to indicate that you want to use a keyset cursor in ADO.


Form.PicturePalette Property (Access)

 Copy code hover
[image]

Form.PicturePalette Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PicturePalette property to specify a palette to be used by a form. Read/write Variant.

Syntax

expression .PicturePalette

expression A variable that represents a Form object.

See also

Concepts

Form Object

Other resources

Form Object Members


NavigationButton.PictureCaptionArrangement Property (Access)

 Copy code hover
[image]

NavigationButton.PictureCaptionArrangement Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets how the specified button's caption is arranged in relation to its picture. Read/write AcPictureCaptionArrangement.

Version Information

Version Added: Access 2010

Syntax

expression .PictureCaptionArrangement

expression A variable that represents a NavigationButton object.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


SubForm.AutoLabel Property (Access)

 Copy code hover
[image]

SubForm.AutoLabel Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.

Syntax

expression .AutoLabel

expression A variable that represents a SubForm object.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Attachment.KeyUp Event (Access)

 Copy code hover
[image]

Attachment.KeyUp Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyUp(KeyCode, Shift)

expression A variable that represents an Attachment object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

Note Note

The KeyUp event applies only to forms and controls on a form, not controls on a report.

To run a macro or event procedure when these events occur, set the OnKeyUp property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, and then the KeyUp event occurs.

Although the KeyUp event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyUp event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Name Property (ADO)

 Copy code hover
[image]

Name Property (ADO)
Send feedback

Indicates the name of an object.

Settings and Return Values

Sets or returns a String value that indicates the name of an object.

Remarks

Use the Name property to assign a name to or retrieve the name of a Command, Property, Field, or Parameter object.

The value is read/write on a Command object and read-only on a Property object.

For a Field object, Name is normally read-only. However, for new Field objects that have been appended to the Fields collection of a Record, Name is read/write only after the Value property for the Field has been specified and the data provider has successfully added the new Field by calling the Update method of the Fields collection.

For Parameter objects not yet appended to the Parameters collection, the Name property is read/write. For appended Parameter objects and all other objects, the Name property is read-only. Names do not have to be unique within a collection.

You can retrieve the Name property of an object by an ordinal reference, after which you can refer to the object directly by name. For example, if rstMain.Properties(20).Name yields Updatability , you can subsequently refer to this property as yields Updatability , you can subsequently refer to this property as rstMain.Properties("Updatability") .


Data Macro Events

 Copy code hover
[image]

Data Macro Events
Send feedback

In this section

  • After Delete Macro Event

  • After Insert Macro Event

  • After Update Macro Event

  • Before Change Macro Event

  • Before Delete Macro Event


TabControl.KeyPress Event (Access)

 Copy code hover
[image]

TabControl.KeyPress Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyPress(KeyAscii)

expression A variable that represents a TabControl object.

Parameters

Name | Required/Optional | Data Type | Description
KeyAscii | Required | Integer | Returns a numeric ANSI key code. The KeyAscii argument is passed by reference; changing it sends a different character to the object. Setting the KeyAscii argument to 0 cancels the keystroke so that the object doesn't recognize that a key was pressed.

Remarks

To run a macro or event procedure when this event occurs, set the OnKeyPress property to the name of the macro or to [Event Procedure].

The object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down an ANSI key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

A KeyPress event can involve any printable keyboard character, the CTRL key combined with a character from the standard alphabet or a special character, and the ENTER or BACKSPACE key. You can use the KeyDown and KeyUp event procedures to handle any keystroke not recognized by the KeyPress event, such as function keys, navigation keys, and any combinations of these with keyboard modifiers (ALT, SHIFT, or CTRL keys). Unlike the KeyDown and KeyUp events, the KeyPress event doesn't indicate the physical state of the keyboard; instead, it indicates the ANSI character that corresponds to the pressed key or key combinations.

KeyPress interprets the uppercase and lowercase of each character as separate key codes and, therefore, as two separate characters.

Note Note

The BACKSPACE key is part of the ANSI character set, but the DEL key isn't. If you delete a character in a control by using the BACKSPACE key, you cause a KeyPress event; if you use the DEL key, you don't.

The KeyDown and KeyPress events occur when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

For example, if you go to a new record and type a character in the first control in the record, the following events occur:

Current (for the new record)

ß

Enter (for the first control in the new record)

ß

GotFocus (for the control)

ß

KeyDown (for the control)

ß

KeyPress (for the control)

ß

BeforeInsert (for the new record in the form)

ß

Change (for the control if it's a text box or combo box)

ß

KeyUp (for the control)

Example

The following example converts text entered in a text box to uppercase as the text is typed in, one character at a time.

To try the example, add the following event procedure to a form that contains a text box named ShipRegion.

VBA Copy code Copy code
Private Sub ShipRegion_KeyPress(KeyAscii As Integer)
 Dim strCharacter As String

 ' Convert ANSI value to character string.
 strCharacter = Chr(KeyAscii)
 ' Convert character to upper case, then to ANSI value.
 KeyAscii = Asc(UCase(strCharacter))
End Sub

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Application.CreateReport Method (Access)

 Copy code hover
[image]

Application.CreateReport Method (Access)
See also Send feedback

Published: July 16, 2012

The CreateReport method creates a report and returns a Report object. For example, suppose you are building a custom wizard to create a sales report. You can use the CreateReport method in your wizard to create a new report based on a specified report template.

Syntax

expression .CreateReport(Database, ReportTemplate)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Database | Optional | Variant | The name of the database that contains the report template you want to use to create a report. If you want the current database, omit this argument. If you want to use an open library database, specify the library database with this argument.
ReportTemplate | Optional | Variant | The name of the report you want to use as a template to create a new report.

Return Value

Report

Remarks

You can use the CreateReport method when designing a wizard that creates a new report.

The CreateReport method open a new, minimized report in report Design view.

If the name you use for the reporttemplate argument isn't valid, Visual Basic uses the report template specified by the Report Template setting on the Forms/Reports tab of the Options dialog box.

Example

The following example creates a report in the current database by using the template specified by the Report Template setting on the Forms/Reports tab of the Options dialog box.

VBA Copy code Copy code
Sub NormalReport()
 Dim rpt As Report

 Set rpt = CreateReport ' Create minimized report.
 DoCmd.Restore ' Restore report.
End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


CodeProject.AccessConnection Property (Access)

 Copy code hover
[image]

CodeProject.AccessConnection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AccessConnection property to return a reference to the current Microsoft ActiveX Data Objects (ADO) Connection object and its related properties. Read-only Connection.

Syntax

expression .AccessConnection

expression A variable that represents a CodeProject object.

Remarks

You should use the AccessConnection property if you intend to create ADO recordsets that will be bound to Access forms. The form will not be updateable unless it is created by using the OLE DB Provider for Microsoft Access, even if the recordset is updateable in ADO.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


Cannot create a new replica because the

 Copy code hover
[image]

Cannot create a new replica because the <name> object in <name> container could not be replicated. (Error 3490)
Send feedback

The Microsoft Access database engine was in the process of creating a replica. The operation failed when it attempted to act on the object and container identified in the error message.


Prepared Property Example (VJ++)

 Copy code hover
[image]

Prepared Property Example (VJ++)
Send feedback

This example demonstrates the Prepared property by opening two Command objects — one prepared and one not prepared.

Copy code Copy code

// BeginPreparedJ
import com.ms.wfc.data.*;
import java.io.* ;

public class PreparedX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 PreparedX();
 System.exit(0);
 }

 // PreparedX function

 static void PreparedX()
 {
 // Define string variables.
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";
 String strCmd = "SELECT title, type FROM Titles ORDER BY type";

 // Define ADO Objects.
 Connection cnConn1 = null;
 Command cmd1 = null;
 Command cmd2 = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 long timeStart;
 long timeEnd;
 float timeNotPrepared ;
 float timePrepared;
 int intLoop;
 String strTemp;

 try
 {
 // Open a connection.
 cnConn1 = new Connection();
 cnConn1.open(strCnn);

 // Create two command objects for the same
 // command - one prepared and one not prepared.
 cmd1 = new Command();
 cmd1.setActiveConnection(cnConn1);
 cmd1.setCommandType(AdoEnums.CommandType.TEXT);
 cmd1.setCommandText(strCmd);

 cmd2 = new Command();
 cmd2.setActiveConnection(cnConn1);
 cmd2.setCommandType(AdoEnums.CommandType.TEXT);
 cmd2.setCommandText(strCmd);
 cmd2.setPrepared(true);

 // Set a timer, then execute the unprepared
 // command 20 times.
 timeStart = System.currentTimeMillis();
 for ( intLoop = 0; intLoop < 20; intLoop++)
 cmd1.execute();
 timeEnd = System.currentTimeMillis();
 timeNotPrepared =(float)(timeEnd - timeStart)/1000f;

 // Reset the timer, then execute the prepared
 // command 20 times.
 timeStart = System.currentTimeMillis();
 for ( intLoop = 0; intLoop < 20; intLoop++)
 cmd2.execute();
 timeEnd = System.currentTimeMillis();
 timePrepared =(float)(timeEnd - timeStart)/1000f;

 // Display performance results.
 System.out.println("\nPerformance Results:");
 System.out.println("\n\tNot Prepared: " + timeNotPrepared +
 " seconds");
 System.out.println("\n\tPrepared: " + timePrepared +
 " seconds");
 System.out.println("\n\nPress <Enter> to continue..");
 in.readLine();

 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Connection, check for null pointer first.
 if (cnConn1!= null)
 {
 PrintProviderError(cnConn1);
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 }

 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndPreparedJ


You attempted to open a database that is already opened exclusively by user

 Copy code hover
[image]

You attempted to open a database that is already opened exclusively by user <name> on machine <name>. Try again when the database is available. (Error 3356)
Send feedback

Possible causes:

  • You attempted to open a database that is already opened exclusively by the specified user <name>. You cannot open the database until the other user closes it.

  • You attempted to open exclusively a database that is already open in shared (non-exclusive) mode by the specified user <name>. You can open the database only in shared mode until the other user closes it.


How to: Prompt a User Before Saving a Record

 Copy code hover
[image]

How to: Prompt a User Before Saving a Record
Send feedback

The following example illustrates how to use the BeforeUpdate event to prompt users to confirm their changes each time they save a record in a form.

VBA Copy code Copy code
Private Sub Form_BeforeUpdate(Cancel As Integer)
   Dim strMsg As String
   Dim iResponse As Integer

   ' Specify the message to display.
   strMsg = "Do you wish to save the changes?" & Chr(10)
   strMsg = strMsg & "Click Yes to Save or No to Discard changes."

   ' Display the message box.
   iResponse = MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?")

   ' Check the user's response.
   If iResponse = vbNo Then

      ' Undo the change.
      DoCmd.RunCommand acCmdUndo

      ' Cancel the update.
      Cancel = True
   End If
End Sub


Attachment.AttachmentCurrent Event (Access)

 Copy code hover
[image]

Attachment.AttachmentCurrent Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when the focus moves to or from a file contained in the specified Attachment control, making it the current attachment, or when the form is refreshed or requeried.

Version Information

Version Added: Access 2007

Syntax

expression .AttachmentCurrent

expression A variable that represents an Attachment object.

Remarks

By running a macro or event procedure when the AttachmentCurrent event occurs, you can display a message or synchronize controls in the form related to the current attachment.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


WorkflowTasks Macro Action

 Copy code hover
[image]

WorkflowTasks Macro Action
Send feedback

You can use the WorkflowTasks action to display the Workflow Task dialog box.

Setting

The WorkflowTasks action has the following argument.

Action argument | Description
Record Number | The position of the item in the Microsoft SharePoint Foundation list, starting with 1 for the first item in the list, 2 for the second item, and so on. You can also enter an expression for this argument.

Remarks

  • The WorkflowTasks action opens the Workflow Tasks dialog box. This dialog box displays all tasks that are available for the specified item. A workflow must be defined for the list in SharePoint Foundation.

  • The WorkflowTasks action can only be used after a linked SharePoint Foundation list has been opened and selected. To open and select the linked list, use the OpenTable action. If the list is already open, use the SelectObject action to select it.

  • The WorkflowTasks action has the same effect as right-clicking any cell in a linked SharePoint Foundation list while it is open in datasheet view, pointing to Workflow, and then clicking Workflow Tasks.

  • To run the WorkflowTasks action in a VBA module, use the WorkflowTasks method of the DoCmd object.


Not a valid file name. (Error 3055)

 Copy code hover
[image]

Not a valid file name. (Error 3055)
Send feedback

You tried to use a file name that does not follow the naming conventions for your operating system. Specify the file name again, and then retry the operation.


Application.CreateReportControl Method (Access)

 Copy code hover
[image]

Application.CreateReportControl Method (Access)
See also Send feedback

Published: July 16, 2012

The CreateReportControl method creates a control on a specified open report. For more information, see the CreateControl method.

Syntax

expression .CreateReportControl(ReportName, ControlType, Section, Parent, ColumnName, Left, Top, Width, Height)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
ReportName | Required | String | The name of the open report on which you want to create the control.
ControlType | Required | AcControlType | An AcControlType constant that represents the type of control you want to create.
Section | Optional | AcSection | An AcSection constant that identifying the section that will contain the new control.
Parent | Optional | Variant | A string expression identifying the name of the parent control of an attached control. For controls that have no parent control, use a zero-length string for this argument, or omit it.
ColumnName | Optional | Variant | The name of the field to which the control will be bound, if it is to be a data-bound control.
Left, Top | Optional | Variant | The coordinates for the upper-left corner of the control in twips.
Width, Height | Optional | Variant | The width and height of the control in twips.

Return Value

Control

See also

Concepts

Application Object

Other resources

Application Object Members


Axis Object (ADO MD Reference)

 Copy code hover
[image]

Axis Object (ADO MD Reference)
Send feedback

In this section

  • Axis Object (ADO MD)

  • Axis Properties, Methods, and Events (ADO MD)


AddNew Method Example (VB)

 Copy code hover
[image]

AddNew Method Example (VB)
Send feedback

This example uses the AddNew method to create a new record with the specified name.

Copy code Copy code

'BeginAddNewVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 'recordset and connection variables
 Dim Cnxn As ADODB.Connection
 Dim rstEmployees As ADODB.Recordset
 Dim strCnxn As String
 Dim strSQL As String
 'record variables
 Dim strID As String
 Dim strFirstName As String
 Dim strLastName As String
 Dim blnRecordAdded As Boolean

 ' Open a connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Northwind';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open Employees Table with a cursor that allows updates
 Set rstEmployees = New ADODB.Recordset
 strSQL = "Employees"
 rstEmployees.Open strSQL, strCnxn, adOpenKeyset, adLockOptimistic, adCmdTable

 ' Get data from the user
 strFirstName = Trim(InputBox("Enter first name:"))
 strLastName = Trim(InputBox("Enter last name:"))

 ' Proceed only if the user actually entered something
 ' for both the first and last names
 If strFirstName <> "" And strLastName <> "" Then

 rstEmployees.AddNew
 rstEmployees!firstname = strFirstName
 rstEmployees!LastName = strLastName
 rstEmployees.Update
 blnRecordAdded = True

 ' Show the newly added data
 MsgBox "New record: " & rstEmployees!EmployeeId & " " & _
 rstEmployees!firstname & " " & rstEmployees!LastName

 Else
 MsgBox "Please enter a first name and last name."
 End If

 ' Delete the new record because this is a demonstration
 Cnxn.Execute "DELETE FROM Employees WHERE EmployeeID = '" & strID & "'"

 ' clean up
 rstEmployees.Close
 Cnxn.Close
 Set rstEmployees = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstEmployees Is Nothing Then
 If rstEmployees.State = adStateOpen Then rstEmployees.Close
 End If
 Set rstEmployees = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndAddNewVB


Image.BorderColor Property (Access)

 Copy code hover
[image]

Image.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Syntax

expression .BorderColor

expression A variable that represents an Image object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

Image Object

Other resources

Image Object Members


ToggleButton.MouseDown Event (Access)

 Copy code hover
[image]

ToggleButton.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents a ToggleButton object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
         Shift As Integer, X As Single, _
         Y As Single)
    If Button = acLeftButton Then
        MsgBox "You pressed the left button."
    End If
    If Button = acRightButton Then
        MsgBox "You pressed the right button."
    End If
    If Button = acMiddleButton Then
        MsgBox "You pressed the middle button."
    End If
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


CustomControl.Parent Property (Access)

 Copy code hover
[image]

CustomControl.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a CustomControl object.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Fields Collection (DAO)

 Copy code hover
[image]

Fields Collection (DAO)
Send feedback

A Fields collection contains all stored Field objects of an Index, QueryDef, Recordset, Relation, or TableDef object.

Remarks

The Fields collections of the Index, QueryDef, Relation, and TableDef objects contain the specifications for the fields those objects represent. The Fields collection of a Recordset object represents the Field objects in a row of data, or in a record. You use the Field objects in a Recordset object to read and to set values for the fields in the current record of the Recordset object.

To refer to a Field object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

Fields(0)

Fields("name")

Fields![name]

With the same syntax forms, you can also refer to the Value property of a Field object that you create and append to a Fields collection. The context of the field reference will determine whether you are referring to the Field object or the Value property of the Field object.

Example

This example shows what properties are valid for a Field object depending on where the Field resides (for example, the Fields collection of a TableDef, the Fields collection of a QueryDef, and so forth). The FieldOutput procedure is required for this procedure to run.

VBA Copy code Copy code
Sub FieldX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset
 Dim fldTableDef As Field
 Dim fldQueryDef As Field
 Dim fldRecordset As Field
 Dim fldRelation As Field
 Dim fldIndex As Field
 Dim prpLoop As Property

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees")

 ' Assign a Field object from different Fields
 ' collections to object variables.
 Set fldTableDef = _
 dbsNorthwind.TableDefs(0).Fields(0)
 Set fldQueryDef =dbsNorthwind.QueryDefs(0).Fields(0)
 Set fldRecordset = rstEmployees.Fields(0)
 Set fldRelation =dbsNorthwind.Relations(0).Fields(0)
 Set fldIndex = _
 dbsNorthwind.TableDefs(0).Indexes(0).Fields(0)

 ' Print report.
 FieldOutput "TableDef", fldTableDef
 FieldOutput "QueryDef", fldQueryDef
 FieldOutput "Recordset", fldRecordset
 FieldOutput "Relation", fldRelation
 FieldOutput "Index", fldIndex

 rstEmployees.Close
 dbsNorthwind.Close

End Sub

Sub FieldOutput(strTemp As String, fldTemp As Field)
 ' Report function for FieldX.

 Dim prpLoop As Property

 Debug.Print "Valid Field properties in " & strTemp

 ' Enumerate Properties collection of passed Field
 ' object.
 For Each prpLoop In fldTemp.Properties
 ' Some properties are invalid in certain
 ' contexts (the Value property in the Fields
 ' collection of a TableDef for example). Any
 ' attempt to use an invalid property will
 ' trigger an error.
 On Error Resume Next
 Debug.Print " " & prpLoop.Name & " = " & _
 prpLoop.Value
 On Error GoTo 0
 Next prpLoop

End Sub

This example uses the CreateField method to create three Fields for a new TableDef. It then displays the properties of those Field objects that are automatically set by the CreateField method. (Properties whose values are empty at the time of Field creation are not shown.)

VBA Copy code Copy code
Sub CreateFieldX()

 Dim dbsNorthwind As Database
 Dim tdfNew As TableDef
 Dim fldLoop As Field
 Dim prpLoop As Property

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 Set tdfNew = dbsNorthwind.CreateTableDef("NewTableDef")

 ' Create and append new Field objects for the new
 ' TableDef object.
 With tdfNew
 ' The CreateField method will set a default Size
 ' for a new Field object if one is not specified.
 .Fields.Append .CreateField("TextField", dbText)
 .Fields.Append .CreateField("IntegerField", dbInteger)
 .Fields.Append .CreateField("DateField", dbDate)
 End With

 dbsNorthwind.TableDefs.Append tdfNew

 Debug.Print "Properties of new Fields in " & tdfNew.Name

 ' Enumerate Fields collection to show the properties of
 ' the new Field objects.
 For Each fldLoop In tdfNew.Fields
 Debug.Print " " & fldLoop.Name

 For Each prpLoop In fldLoop.Properties
 ' Properties that are invalid in the context of
 ' TableDefs will trigger an error if an attempt
 ' is made to read their values.
 On Error Resume Next
 Debug.Print " " & prpLoop.Name & " - " & _
 IIf(prpLoop = "", "[empty]", prpLoop)
 On Error GoTo 0
 Next prpLoop

 Next fldLoop

 ' Delete new TableDef because this is a demonstration.
 dbsNorthwind.TableDefs.Delete tdfNew.Name
 dbsNorthwind.Close

End Sub


CheckBox.BorderShade Property (Access)

 Copy code hover
[image]

CheckBox.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents a CheckBox object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


NavigationButton.Requery Method (Access)

 Copy code hover
[image]

NavigationButton.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.

Version Information

Version Added: Access 2010

Syntax

expression .Requery

expression A variable that represents a NavigationButton object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts .

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate function.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

Example

The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form:

VBA Copy code Copy code
Public Sub RequeryList()

    Dim ctlCombo As Control

    ' Return Control object pointing to a combo box.
    Set ctlCombo = Forms!Employees!ReportsTo

    ' Requery source of data for list box.
    ctlCombo.Requery

End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


ObjectFrame.Parent Property (Access)

 Copy code hover
[image]

ObjectFrame.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents an ObjectFrame object.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Attachment.OnMouseMove Property (Access)

 Copy code hover
[image]

Attachment.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnMouseMove

expression A variable that represents an Attachment object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


ListBox.InSelection Property (Access)

 Copy code hover
[image]

ListBox.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents a ListBox object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Attachment.SpecialEffect Property (Access)

 Copy code hover
[image]

Attachment.SpecialEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .SpecialEffect

expression A variable that represents an Attachment object.

Remarks

The SpecialEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | 0 | The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised | 1 | The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken | 2 | The object has a shadow on the top and left and a highlight on the bottom and right.
Etched | 3 | The object has a sunken line surrounding the control.
Shadowed | 4 | The object has a shadow below and to the right of the control.
Chiseled | 5 | The object has a sunken line below the control.

The SpecialEffect property setting affects related property settings for the BorderStyle , BorderColor , and BorderWidth properties. For example, if the SpecialEffect property is set to Raised, the settings for the BorderStyle, BorderColor, and BorderWidth properties are ignored. In addition, changing or setting the BorderStyle, BorderColor, and BorderWidth properties may cause Microsoft Access to change the SpecialEffect property setting to Flat.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


TextBox.LostFocus Event (Access)

 Copy code hover
[image]

TextBox.LostFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The LostFocus event occurs when the specified object loses the focus.

Syntax

expression .LostFocus

expression A variable that represents a TextBox object.

Remarks

To run a macro or event procedure when these events occur, set the OnLostFocus property to the name of the macro or to [Event Procedure].

This events occurs when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The LostFocus event differs from the Exit event in that the LostFocus event occurs every time a control loses the focus. The Exit event occurs only before a control loses the focus to another control on the same form. The LostFocus event occurs after the Exit event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Requested exchange failed because

 Copy code hover
[image]

Requested exchange failed because <name>. (Error 3661)
Send feedback

The exchange has been cancelled.


Date is out of range or is in an invalid format. (Error 3175)

 Copy code hover
[image]

Date is out of range or is in an invalid format. (Error 3175)
Send feedback

Only dates from December 30, 1899, through December 30, 9999 are recognized.

Possible causes:

  • You entered a date that was outside the valid range.

  • You entered a valid date, but it was not in a recognized format. Make sure you entered it correctly, and then try the operation again.


OptionButton.OnGotFocus Property (Access)

 Copy code hover
[image]

OptionButton.OnGotFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnGotFocus

expression A variable that represents an OptionButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The GotFocus event occurs when the object receives the focus.

The OnGotFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Got Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Got Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnGotFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnGotFocus

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Incorrect version of the DLL file

 Copy code hover
[image]

Incorrect version of the DLL file <name> was found. (Error 3445)
Send feedback

For Microsoft Access Database Engine databases, the installed Microsoft Access Database Engine DLL (acedao.dll) must be version 14.0 or later.

For ODBCDirect databases, the installed Remote Data Objects (RDO) DLL (msrdo32.dll) must be version 1.0 or later.

Try reinstalling the application that returned the error.


Form.SelectionChange Event (Access)

 Copy code hover
[image]

Form.SelectionChange Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs whenever the user makes a new selection in a PivotChart view or PivotTable view.

Syntax

expression .SelectionChange

expression A variable that represents a Form object.

Return Value

nothing

Remarks

The user cannot cancel this event.

Example

The following example demonstrates the syntax for a subroutine that traps the SelectionChange event.

VBA Copy code Copy code
Private Sub Form_SelectionChange()
 MsgBox "The selection has changed!"
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


ToggleButton.BeforeUpdate Event (Access)

 Copy code hover
[image]

ToggleButton.BeforeUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The BeforeUpdate event occurs before changed data in a control or record is updated.

Syntax

expression .BeforeUpdate(Cancel)

expression A variable that represents a ToggleButton object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the BeforeUpdate event occurs. Setting the Cancel argument to True (-1) cancels the BeforeUpdate event.

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's BeforeUpdate event does occur.

To run a macro or event procedure when this event occurs, set the BeforeUpdate property to the name of the macro or to [Event Procedure].

This event does not apply to option buttons, check boxes, or toggle buttons in an option group. It applies only to the option group itself.

The BeforeUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB. When the focus leaves the record or if the user clicks Save Record on the Records menu, the entire record is updated, and the data is saved in the database.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

BeforeUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. BeforeUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For forms, you can use the BeforeUpdate event to cancel updating of a record before moving to another record.

If the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

You often use the BeforeUpdate event to validate data, especially when you perform complex validations, such as those that:

  • Involve conditions for more than one value on a form.

  • Display different error messages for different data entered.

  • Can be overridden by the user.

  • Contain references to controls on other forms or contain user-defined functions.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

A run-time error will occur if you attempt to modify the data contained in the control that fired the BeforeUpdate event in the event's procedure.

Example

The following example shows how you can use a BeforeUpdate event procedure to check whether a product name has already been entered in the database. After the user types a product name in the ProductName box, the value is compared to the ProductName field in the Products table. If there is a matching value in the Products table, a message is displayed that informs the user that the product has already been entered.

To try the example, add the following event procedure to a form named Products that contains a text box called ProductName.

VBA Copy code Copy code
Private Sub ProductName_BeforeUpdate(Cancel As Integer)
 If(Not IsNull(DLookup("[ProductName]", _
 "Products", "[ProductName] ='" _
 & Me!ProductName & "'"))) Then
 MsgBox "Product has already been entered in the database."
 Cancel = True
 Me!ProductName.Undo
 End If
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Process stopped when attempting to terminate Synchronizer client. (Error 3542)

 Copy code hover
[image]

Process stopped when attempting to terminate Synchronizer client. (Error 3542)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


ComboBox.BeforeUpdate Event (Access)

 Copy code hover
[image]

ComboBox.BeforeUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The BeforeUpdate event occurs before changed data in a control or record is updated.

Syntax

expression .BeforeUpdate(Cancel)

expression A variable that represents a ComboBox object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the BeforeUpdate event occurs. Setting the Cancel argument to True (-1) cancels the BeforeUpdate event.

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's BeforeUpdate event does occur.

To run a macro or event procedure when this event occurs, set the BeforeUpdate property to the name of the macro or to [Event Procedure].

This event does not apply to option buttons, check boxes, or toggle buttons in an option group. It applies only to the option group itself.

The BeforeUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB. When the focus leaves the record or if the user clicks Save Record on the Records menu, the entire record is updated, and the data is saved in the database.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

BeforeUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. BeforeUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For forms, you can use the BeforeUpdate event to cancel updating of a record before moving to another record.

If the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

You often use the BeforeUpdate event to validate data, especially when you perform complex validations, such as those that:

  • Involve conditions for more than one value on a form.

  • Display different error messages for different data entered.

  • Can be overridden by the user.

  • Contain references to controls on other forms or contain user-defined functions.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

A run-time error will occur if you attempt to modify the data contained in the control that fired the BeforeUpdate event in the event's procedure.

Link provided by: Community Member Icon Luke Chung, FMS, Inc. | About the Contributors

  • Tips and Techniques for Using and Validating Combo Boxes

Example

The following example shows how you can use a BeforeUpdate event procedure to check whether a product name has already been entered in the database. After the user types a product name in the ProductName box, the value is compared to the ProductName field in the Products table. If there is a matching value in the Products table, a message is displayed that informs the user that the product has already been entered.

To try the example, add the following event procedure to a form named Products that contains a text box called ProductName.

VBA Copy code Copy code
Private Sub ProductName_BeforeUpdate(Cancel As Integer)
    If(Not IsNull(DLookup("[ProductName]", _
        "Products", "[ProductName] ='" _
        & Me!ProductName & "'"))) Then
        MsgBox "Product has already been entered in the database."
        Cancel = True
        Me!ProductName.Undo
    End If
End Sub

About the Contributors

Luke Chung is the founder and president of FMS, Inc., a leading provider of custom database solutions and developer tools.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


CustomControl.Updated Event (Access)

 Copy code hover
[image]

CustomControl.Updated Event (Access)
See also Send feedback

Published: July 16, 2012

The Updated event occurs when an OLE object's data has been modified.

Syntax

expression .Updated(Code)

expression A variable that represents a CustomControl object.

Remarks

To run a macro or event procedure when this event occurs, set the OnUpdated property to the name of the macro or to [Event Procedure].

You can use this event to determine if an object's data has been changed since it was last saved.

The Updated event occurs when the data in an OLE object has been modified. This update can come from the application in which the object was created or from one of the linked copies of this object. As a result, this event is asynchronous with other Microsoft Access control events.

Note Note

The Updated event and the BeforeUpdate and AfterUpdate events for bound and unbound object frames are not related. The Updated event occurs when an OLE object's data is changed, and the BeforeUpdate and AfterUpdate events occur when data is updated. Although not related, all three events usually occur when an OLE object's data is changed. The Updated event generally occurs before the BeforeUpdate and AfterUpdate events; however, this may not happen every time.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Cannot append an Index that is already a part of an Indexes collection. (Error 3269)

 Copy code hover
[image]

Cannot append an Index that is already a part of an Indexes collection. (Error 3269)
Send feedback

An Index object was specified as an argument to an Append operation when it already is a member of an existing Indexes collection. Use the Dim statement and CreateIndex method to declare a new Index object and specify its values, and retry the operation with the new Index object.


TextBox.Value Property (Access)

 Copy code hover
[image]

TextBox.Value Property (Access)
See also Send feedback

Published: July 16, 2012

Determines or specifies the text in the text box. Read/write Variant.

Syntax

expression .Value

expression A variable that represents a TextBox object.

Remarks

The Text property returns the formatted string. The Text property may be different than the Value property for a text box control. The Text property is the current contents of the control. The Value property is the saved value of the text box control. The Text property is always current while the control has the focus.

The Value property returns or sets a control's default property, which is the property that is assumed when you don't explicitly specify a property name.

Note Note

The Value property is not the same as the DefaultValue property, which specifies the value that a property is assigned when a new record is created.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Attributes Property (ADO)

 Copy code hover
[image]

Attributes Property (ADO)
Send feedback

Attributes Property

Indicates one or more characteristics of an object.

Settings and Return Values

Sets or returns a Long value.

For a Connection object, the Attributes property is read/write, and its value can be the sum of one or more XactAttributeEnum values. The default is zero (0).

For a Parameter object, the Attributes property is read/write, and its value can be the sum of any one or more ParameterAttributesEnum values. The default is adParamSigned.

For a Field object, the Attributes property can be the sum of one or more FieldAttributeEnum values. It is normally read-only, However, for new Field objects that have been appended to the Fields collection of a Record, Attributes is read/write only after the Value property for the Field has been specified and the new Field has been successfully added by the data provider by calling the Update method of the Fields collection.

For a Property object, the Attributes property is read-only, and its value can be the sum of any one or more PropertyAttributesEnum values.

Remarks

Use the Attributes property to set or return characteristics of Connection objects, Parameter objects, Field objects, or Property objects.

When you set multiple attributes, you can sum the appropriate constants. If you set the property value to a sum including incompatible constants, an error occurs.

Remote Data Service UsageThis property is not available on a client-side Connection object.


Index Property (ADO)

 Copy code hover
[image]

Index Property (ADO)
Send feedback

Indicates the name of the index currently in effect for a Recordset object.

Settings and Return Values

Sets or returns a String value, which is the name of the index.

Remarks

The index named by the Index property must have previously been declared on the base table underlying the Recordset object. That is, the index must have been declared programmatically either as an ADOX Index object, or when the base table was created.

A run-time error will occur if the index cannot be set. The Index property cannot be set:

  • Within a WillChangeRecordset or RecordsetChangeComplete event handler.

  • If the Recordset is still executing an operation (which can be determined by the State property).

  • If a filter has been set on the Recordset with the Filter property.

The Index property can always be set successfully if the Recordset is closed, but the Recordset will not open successfully, or the index will not be usable, if the underlying provider does not support indexes.

If the index can be set, the current row position may change. This will cause an update to the AbsolutePosition property, and the generation of WillChangeRecordset, RecordsetChangeComplete, WillMove, and MoveComplete events.

If the index can be set and the LockType property is adLockPessimistic or adLockOptimistic, then an implicit UpdateBatch operation is performed. This releases the current and affected groups. Any existing filter is released, and the current row position is changed to the first row of the reordered Recordset.

The Index property is used in conjunction with the Seek method. If the underlying provider does not support the Index property, and thus the Seek method, consider using the Find method instead. Determine whether the Recordset object supports indexes with the Supports (adIndex) method.

The built-in Index property is not related to the dynamic Optimize property, although they both deal with indexes.


TextBox.ControlType Property (Access)

 Copy code hover
[image]

TextBox.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Syntax

expression .ControlType

expression A variable that represents a TextBox object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Label.ForeShade Property (Access)

 Copy code hover
[image]

Label.ForeShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .ForeShade

expression A variable that represents a Label object.

Remarks

The ForeShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the ForeShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the ForeColor property by 75%.

VBA Copy code Copy code
Me.ctl.ForeShade=25

See also

Concepts

Label Object

Other resources

Label Object Members


Properties Members (DAO)

 Copy code hover
[image]

Properties Members (DAO)
Send feedback

A Properties collection contains all the Property objects for a specific instance of an object.

Methods

Name | Description
Append | Adds a new Property to the Properties collection.
Delete | Deletes the specified Property object from the Properties collection.
Refresh | Updates the objects in the specified colletion to reflect the database's current schema.

Properties

Name | Description
Count | The description for this member will appear in the final release of Office 14.


Application.Run Method (Access)

 Copy code hover
[image]

Application.Run Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the Run method to carry out a specified Microsoft Access or user-defined Function or Sub procedure. Variant.

Syntax

expression .Run(Procedure, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10, Arg11, Arg12, Arg13, Arg14, Arg15, Arg16, Arg17, Arg18, Arg19, Arg20, Arg21, Arg22, Arg23, Arg24, Arg25, Arg26, Arg27, Arg28, Arg29, Arg30)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Procedure | Required | String | The name of the Function or Sub procedure to be run. If you are calling a procedure in another database use the project name and the procedure name separated by a dot in the form: "projectname.procedurename". If you execute Visual Basic code containing the Run method in a library database, Microsoft Access looks for the procedure first in the library database, then in the current database.
Arg1, Arg2, ...Arg30 | Optional | Variant | The arguments that should be passed to the Function or Sub specified in the Procedure argument.

Return Value

Variant

Remarks

This method is useful when you are controlling Microsoft Access from another application through Automation, formerly called OLE Automation. For example, you can use the Run method from an ActiveX component to carry out a Sub procedure that is defined within a Microsoft Access database.

You can set a reference to the Microsoft Access type library from any other ActiveX component and use the objects, methods, and properties defined in that library in your code. However, you can't set a reference to an individual Microsoft Access database from any application other than Microsoft Access.

For example, suppose you have defined a procedure named NewForm in a database with its ProjectName property set to "WizCode." The NewForm procedure takes a string argument. You can call NewForm in the following manner from Visual Basic:

VBA Copy code Copy code
Dim appAccess As New Access.Application
appAccess.OpenCurrentDatabase ("C:\My Documents\WizCode.mdb")
appAccess.Run "WizCode.NewForm", "Some String"

If another procedure with the same name may reside in a different database, qualify the procedure argument, as shown in the preceding example, with the name of the database in which the desired procedure resides.

You can also use the Run method to call a procedure in a referenced Microsoft Access database from another database.

Example

The following example runs a user-defined Sub procedure in a module in a Microsoft Access database from another application that acts as an Active X component.

To try this example, create a new database called WizCode.mdb and set its ProjectName property to WizCode. Open a new module in that database and enter the following code. Save the module, and close the database.

Note Note

You set the ProjectName by selecting Tools, WizCode Properties... from the VBE main menu.

VBA Copy code Copy code
Public Sub Greeting(ByVal strName As String)
 MsgBox ("Hello, " & strName & "!"), vbInformation, "Greetings"
End Sub

Once you have completed this step, run the following code from Microsoft Excel or Microsoft Visual Basic. Make sure that you have added a reference to the Microsoft Access type library by clicking References on the Tools menu and selecting Microsoft Access 12.0 Object Library in the References dialog box.

VBA Copy code Copy code
Private Sub RunAccessSub()

 Dim appAccess As Access.Application

 ' Create instance of Access Application object.
 Set appAccess = CreateObject("Access.Application")

 ' Open WizCode database in Microsoft Access window.
 appAccess.OpenCurrentDatabase "C:\My Documents\WizCode.mdb", False

 ' Run Sub procedure.
 appAccess.Run "Greeting", "Joe"
 Set appAccess = Nothing

End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


ADO Code Examples in Microsoft JScript (Access)

 Copy code hover
[image]

ADO Code Examples in Microsoft JScript (Access)
Send feedback

In this section

  • ADO Code Examples in Microsoft JScript

  • AbsolutePage, PageCount, and PageSize Properties Example (JScript)

  • AbsolutePosition and CursorLocation Properties Example (JScript)

  • ActiveCommand Property Example (JScript)

  • ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction Properties Example (JScript)

  • ActualSize and DefinedSize Properties Example (JScript)

  • AddNew Method Example (JScript)

  • Append and CreateParameter Methods Example (JScript)

  • CacheSize Property Example (JScript)

  • Execute, Requery, and Clear Methods Example (JScript)

  • Filter and RecordCount Properties Example (JScript)

  • Find Method Example (JScript)

  • GetRows Method Example (JScript)


Wrong data type for parameter

 Copy code hover
[image]

Wrong data type for parameter <parameter>. (Error 3060)
Send feedback

You tried to use an argument with a data type that conflicts with the data type defined for this parameter. For example, you might have tried to use a string expression that expects a numeric argument with a parameter. Use an argument that has the correct data type, and then try the operation again.


Form.OnFilter Property (Access)

 Copy code hover
[image]

Form.OnFilter Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Filter box in the Properties window of a form. Read/write String.

Syntax

expression .OnFilter

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Filter event occurs when a form is opened and its records are displayed.

The OnFilter value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Filter box in the form's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Filter box is blank, the property value is an empty string.

Example

The following example associates the Filter property for the "Order Entry" form to the event "Form_Filter".

VBA Copy code Copy code
Forms("Order Entry").OnFilter = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


OpenView Macro Action

 Copy code hover
[image]

OpenView Macro Action
Send feedback

In an Access project, you can use the OpenView action to open a view in Datasheet view, Design view, or Print Preview. This action runs the named view when opened in Datasheet view. You can select data entry for the view and restrict the records that the view displays.

Note 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.

Setting

The OpenView action has the following arguments.

Action argument | Description
View Name | The name of the view to open. The View Name box in the Action Arguments section of the Macro Builder pane shows all views in the current database. This is a required argument. If you run a macro containing the OpenView action in a library database, Microsoft Access first looks for the view with this name in the library database, and then in the current database.
View | The view in which the view will open. Click Datasheet, Design, Print Preview, PivotTable, or PivotChart in the View box. The default is Datasheet.
Data Mode | The data entry mode for the view. This applies only to views opened in Datasheet view. Click Add (the user can add new records but can't view or edit existing records), Edit (the user can view or edit existing records and add new records), or Read Only (the user can only view records). The default is Edit.

Remarks

This action is similar to double-clicking a view in the Navigation Pane, or right-clicking the view in the Navigation Pane and then clicking the command you want.

Tips

  • You can drag a view from the Navigation Pane to a macro action row. This automatically creates an OpenView action that opens the view in Datasheet view.

  • If you don't want to display the system messages that normally appear when a view is run (indicating it is a view and showing how many records will be affected), you can use the SetWarning action to suppress the display of these messages.

To run the OpenView action in a Visual Basic for Applications (VBA) module, use the OpenView method of the DoCmd object.


TextBox.LabelX Property (Access)

 Copy code hover
[image]

TextBox.LabelX Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelX

expression A variable that represents a TextBox object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


DependencyObjects.Count Property (Access)

 Copy code hover
[image]

DependencyObjects.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents a DependencyObjects object.

See also

Concepts

DependencyObjects Collection

Other resources

DependencyObjects Object Members


WebServices.Count Property (Access)

 Copy code hover
[image]

WebServices.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Version Information

Version Added: Access 2010

Syntax

expression .Count

expression A variable that represents a WebServices object.

See also

Concepts

WebServices Collection

Other resources

WebServices Object Members


ObjectFrame.BackStyle Property (Access)

 Copy code hover
[image]

ObjectFrame.BackStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.

Syntax

expression .BackStyle

expression A variable that represents an ObjectFrame object.

Remarks

The BackStyle property uses the following settings.

Setting | Visual Basic | Description
Normal | 1 | (Default for all controls except option group) The control has its interior color set by the BackColor property.
Transparent | 0 | (Default for option group) The control is transparent. The color of the form or report behind the control is visible.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

If the Transparent button on the Back Color button palette is selected, the BackStyle property is set to Transparent; otherwise the BackStyle property is set to Normal.

To make a command button invisible, set its Transparent property to Yes.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Stuff Function (Access 2013 custom web app)

 Copy code hover
[image]

Stuff Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Inserts a text string into another text string. It deletes a specified length of characters in the first string at the start position and then inserts the second string into the first string at the start position.

Syntax

Stuff (IntoTextExpression, Start, Length, ThisTextExpression)

The Stuff function contains the following arguments.

Argument name | Description
IntoTextExpression | A text expression that specifies the text into which the text specified by the ThisTextExpression will be inserted.
Start | An integer value that specifies the location to start deletion and insertion. If start or length is negative, a null string is returned. If start is longer than the first IntoTextExpression, a null string is returned.
Length | An integer that specifies the number of characters to delete. If length is longer than the first IntoTextExpression, deletion occurs up to the last character in the last IntoTextExpression.
ThisTextExpression | A text expression hat specifies the text to insert into IntoTextExpression. This expression will replace length characters of IntoTextExpression beginning at Start.

Remarks

If the Start or Length arguments are negative, or if the starting position is larger than length of the first string, a null string is returned. If the start position is 0, a null value is returned. If the length to delete is longer than the first string, it is deleted to the first character in the first string.


NavigationButton.ForeTint Property (Access)

 Copy code hover
[image]

NavigationButton.ForeTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .ForeTint

expression A variable that represents a NavigationButton object.

Remarks

The ForeTint property contains a numeric expression that can be used to lighten the theme color in the ForeColor property. The default value of the ForeTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the ForeColor property by 75%.

VBA Copy code Copy code
Me.ctl.ForeTint=25

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


ListBox.ListIndex Property (Access)

 Copy code hover
[image]

ListBox.ListIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ListIndex property to determine which item is selected in a list box. Read/write Long.

Syntax

expression .ListIndex

expression A variable that represents a ListBox object.

Remarks

The ListIndex property is an integer from 0 to the total number of items in a list box or combo box minus 1. Microsoft Access sets the ListIndex property value when an item is selected in a list box or list box portion of a combo box. The ListIndex property value of the first item in a list is 0, the value of the second item is 1, and so on.

This property is available only by using a macro or Visual Basic . You can read this property only in Form view and Datasheet view. This property is read-only and isn't available in other views.

The ListIndex property value is also available by setting the BoundColumn property to 0 for a combo box or list box. If the BoundColumn property is set to 0, the underlying table field to which the combo box or list box is bound will contain the same value as the ListIndex property setting.

List boxes also have a MultiSelect property that allows the user to select multiple items from the control. When multiple selections are made in a list box, you can determine which items are selected by using the Selected property of the control. The Selected property is an array of values from 0 to the ListCount property value minus 1. For each item in the list box the Selected property will be True if the item is selected and False if it is not selected.

The ItemsSelected collection also provides a way to access data in the selected rows of a list box or combo box.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Operation must use an updatable query. (Error 3073)

 Copy code hover
[image]

Operation must use an updatable query. (Error 3073)
Send feedback

You tried to run, open, or modify a query that is not updatable.

Possible causes:

  • You attempted to run a query that tried to update a field that cannot be updated. For example, you may have created the query in such a way that you tried to update a field on the one side of a one-to-many relationship.

  • You tried to use the obsolete OpenQueryDef method on a query that is in a database opened for read-only access.

The database is read-only for one of the following reasons:

  • You used the OpenDatabase method or the Visual Basic Data control, and opened the database for read-only access.

  • The database file has been defined as read-only in your network operating system.

  • In a network environment, you do not have write privileges for the database file.

Close the database, resolve the read-only condition, and then reopen it for read/write access.

  • You do not have permission to make changes to the query. To change your permission assignments, see your system administrator or the query's creator.


How to: Recover Tables Deleted from a Database

 Copy code hover
[image]

How to: Recover Tables Deleted from a Database
Send feedback

This topic shows how to create a sample Visual Basic for Applications (VBA) function that you can use to recover tables deleted from a Microsoft Access database under the following conditions:

  • The database has not been closed since the tables were deleted.

  • The database has not been compacted since the tables were deleted.

  • The tables were deleted using the Microsoft Access user interface.

  • The table does not contain any multivalue or Attachment fields.

Paste the following procedure into a standard module.

VBA Copy code Copy code
Sub RecoverDeletedTable()
On Error GoTo ExitHere

 Dim db As DAO.Database
 Dim strTableName As String
 Dim strSQL As String
 Dim intCount As Integer
 Dim blnRestored As Boolean

 Set db = CurrentDb()

 For intCount = 0 To db.TableDefs.Count - 1
 strTableName = db.TableDefs(intCount).Name
 If Left(strTableName, 4) = "~tmp" Then
 strSQL = "SELECT DISTINCTROW [" & strTableName & "].* INTO " & Mid(strTableName, 5) & " FROM [" & strTableName & "];"
 DoCmd.SetWarnings False
 DoCmd.RunSQL strSQL
 MsgBox "A deleted table has been restored, using the name '" & Mid(strTableName, 5) & "'", vbOKOnly, "Restored"
 blnRestored = True
 End If
 Next intCount

 If blnRestored = False Then
MsgBox "No recoverable tables found", vbOKOnly
 End If

'*EXIT/ERROR*
ExitHere:
 DoCmd.SetWarnings True
 Set db = Nothing
 Exit Sub

ErrorHandler:
 MsgBox Err.Description
 Resume ExitHere

End Sub


Attachment.FileName Property (Access)

 Copy code hover
[image]

Attachment.FileName Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the full file name of the specified attachment. Read-only String.

Version Information

Version Added: Access 2007

Syntax

expression .FileName(var)

expression A variable that represents an Attachment object.

Parameters

Name | Required/Optional | Data Type | Description
var | Optional | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


5 Database Engine Driver (2 of 2)

 Copy code hover
[image]

5 Database Engine Driver (2 of 2)
Send feedback

Published: July 16, 2012

When you install the Microsoft® Jet version 2.5 Engine database driver, the Setup program writes a set of default values to the Microsoft Windows® Registry in the Engines and ISAM Formats subkeys. You must use the Registry Editor to add, remove, or change these settings. The following sections describe initialization and ISAM Format settings for the Microsoft Jet Engine database driver.

Microsoft Jet Engine Initialization Settings

The Access Connectivity Engine\Engines\Jet 2.x folder includes initialization settings for the Acer2x.dll driver, used for access to Microsoft Access 2.0 worksheets. Typical initialization settings for the entries in this folder are shown in the following example.

Copy code Copy code
win32=<path>\ACER2X.DLL

PageTimeout=5

LockedPageTimeout=5

CursorTimeout=5

LockRetry=20

CommitLockRetry=20

MaxBufferSize=512

ReadAheadPages=16

IdleFrequency=10

ForceOsFlush = 0

The following entries are used to configure the Microsoft Access database engine.

Entry | Description
win32 | Location of the database engine driver (.dll). The path is determined at the time of installation. Values are of type REG_SZ.
PageTimeout | The length of time between when data that is not read-locked is placed in an internal cache and when it is invalidated, expressed in 100 millisecond units. The default is 5 units (or 0.5 seconds). Values are of type REG_DWORD.
LockedPageTimeout | The length of time between when data that is read-locked is placed in an internal cache and when it is invalidated, expressed in 100 millisecond units. The default is 5 units (or 0.5 seconds). Values are of type REG_DWORD.
CursorTimeout | The length of time a reference to a page will remain on that page, expressed in 100 millisecond units. The default is 5 units (or 0.5 seconds). This setting applies only to databases created with version 1.x of the Microsoft Jet database engine. Values are of type REG_DWORD.
LockRetry | The number of times to repeat attempts to access a locked page before returning a lock conflict message. The default is 20 times; LockRetry is related to CommitLockRetry. Values are of type REG_DWORD.
CommitLockRetry | The number of times the Microsoft Jet database engine attempts to acquire a lock on data to commit changes to that data. If the Microsoft Jet database engine cannot acquire a commit lock, changes to the data will be unsuccessful. The number of attempts the Microsoft Jet database engine makes to get a commit lock is directly related to the LockRetry value. For each attempt made to acquire a commit lock, the Microsoft Jet database engine will make as many attempts as specified by the LockRetry value to acquire a lock. For example, if CommitLockRetry is set to 20 and LockRetry is set to 20, the Microsoft Access database engine will try to acquire a commit lock as many as 20 times; for each of those attempts, the Microsoft Access database engine will try to acquire a lock as many as 20 times, for a total of 400 attempts. The default value for CommitLockRetry is 20. Values are of type REG_DWORD.
MaxBufferSize | The size of the database engine internal cache, measured in kilobytes (K). MaxBufferSize must be a whole number value between 9 and 4096, inclusive. The default is 512. Values are of type REG_DWORD.
ReadAheadPages | The number of pages to read ahead when performing sequential scans. The default is 16. Values are of type REG_DWORD.
ForceOSFlush | Any setting other than 0 means a commit or a write will force flushing the OS cache to disk. A setting of 0 (the default setting) means no force flush occurs. Values are of type REG_DWORD.
IdleFrequency | The amount of time, in 100 millisecond units, that Microsoft Jet will wait before releasing a read lock. The default is 10 units or one second. Values are of type REG_DWORD.

Microsoft Jet Engine ISAM Formats

The Access Connectivity Engine\ISAM Formats\Jet 2.x folder contains the following entries.

Entry name | Type | Value
Engine | REG_SZ | Jet 2.x
OneTablePerFile | REG_BINARY | 00
IndexDialog | REG_BINARY | 00
CreateDBOnExport | REG_BINARY | 00
IsamType | REG_DWORD | 0
Note Note

When you change Windows Registry settings, you must exit and then restart the database engine for the new settings to take effect.


Properties Collection (ADO)

 Copy code hover
[image]

Properties Collection (ADO)
Send feedback

Contains all the Property objects for a specific instance of an object.

Remarks

Some ADO objects have a Properties collection made up of Property objects. Each Property object corresponds to a characteristic of the ADO object specific to the provider.

Note Note

See the Property object topic for a more detailed explanation of how to use Property objects.

The Dynamic Properties of the Recordset object go out of scope (become unavailable) when the Recordset is closed.


CommandButton.OnGotFocus Property (Access)

 Copy code hover
[image]

CommandButton.OnGotFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnGotFocus

expression A variable that represents a CommandButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The GotFocus event occurs when the object receives the focus.

The OnGotFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Got Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Got Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnGotFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnGotFocus

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ComboBox Methods (Access)

 Copy code hover
[image]

ComboBox Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
AddItem | Adds a new item to the list of values displayed by the specified combo box control.
Dropdown | You can use the Dropdown method to force the list in the specified combo box to drop down.
Move | Moves the specified object to the coordinates specified by the argument values.
RemoveItem | Removes an item from the list of values displayed by the specified combo box control.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.
Undo | You can use the Undo method to reset a control or form when its value has been changed.


EditModeEnum

 Copy code hover
[image]

EditModeEnum
Send feedback

Specifies the editing status of a record.

Constant | Value | Description
adEditNone | 0 | Indicates that no editing operation is in progress.
adEditInProgress | 1 | Indicates that data in the current record has been modified but not saved.
adEditAdd | 2 | Indicates that the AddNew method has been called, and the current record in the copy buffer is a new record that has not been saved in the database.
adEditDelete | 4 | Indicates that the current record has been deleted.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.EditMode.NONE

AdoEnums.EditMode.INPROGRESS

AdoEnums.EditMode.ADD

AdoEnums.EditMode.DELETE


BoundObjectFrame.BeforeUpdate Event (Access)

 Copy code hover
[image]

BoundObjectFrame.BeforeUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The BeforeUpdate event occurs before changed data in a control or record is updated.

Syntax

expression .BeforeUpdate(Cancel)

expression A variable that represents a BoundObjectFrame object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the BeforeUpdate event occurs. Setting the Cancel argument to True (-1) cancels the BeforeUpdate event.

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's BeforeUpdate event does occur.

To run a macro or event procedure when this event occurs, set the BeforeUpdate property to the name of the macro or to [Event Procedure].

This event does not apply to option buttons, check boxes, or toggle buttons in an option group. It applies only to the option group itself.

The BeforeUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB. When the focus leaves the record or if the user clicks Save Record on the Records menu, the entire record is updated, and the data is saved in the database.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

BeforeUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. BeforeUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For forms, you can use the BeforeUpdate event to cancel updating of a record before moving to another record.

If the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

You often use the BeforeUpdate event to validate data, especially when you perform complex validations, such as those that:

  • Involve conditions for more than one value on a form.

  • Display different error messages for different data entered.

  • Can be overridden by the user.

  • Contain references to controls on other forms or contain user-defined functions.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

A run-time error will occur if you attempt to modify the data contained in the control that fired the BeforeUpdate event in the event's procedure.

Example

The following example shows how you can use a BeforeUpdate event procedure to check whether a product name has already been entered in the database. After the user types a product name in the ProductName box, the value is compared to the ProductName field in the Products table. If there is a matching value in the Products table, a message is displayed that informs the user that the product has already been entered.

To try the example, add the following event procedure to a form named Products that contains a text box called ProductName.

VBA Copy code Copy code
Private Sub ProductName_BeforeUpdate(Cancel As Integer)
 If(Not IsNull(DLookup("[ProductName]", _
 "Products", "[ProductName] ='" _
 & Me!ProductName & "'"))) Then
 MsgBox "Product has already been entered in the database."
 Cancel = True
 Me!ProductName.Undo
 End If
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


ListBox.OldBorderStyle Property (Access)

 Copy code hover
[image]

ListBox.OldBorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.

Syntax

expression .OldBorderStyle

expression A variable that represents a ListBox object.

Remarks

The OldBorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines
Note Note

  • If the OldBorderStyle property is set to None or Dialog, the form doesn't have Maximize or Minimize buttons, regardless of its MinMaxButtons property setting.

  • If the OldBorderStyle property is set to None, the form doesn't have a Control menu, regardless of its ControlBox property setting.

  • The OldBorderStyle property setting doesn't affect the display of the scroll bars, navigation buttons, the record number box, or record selectors.

Example

The following example demonstrates the effect of changing a control's BorderStyle property, while leaving the OldBorderStyle unaffected. The example concludes with setting the BorderStyle property to its original unedited value.

VBA Copy code Copy code
With Forms("Order Entry").Controls("Zip Code") .BorderStyle = 3 ' Short dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 3, 1.

    .BorderStyle = 2 ' Dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 2, 1

    .BorderStyle = .OldBorderStyle ' Solid (default) border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 1, 1
End With

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


WebBrowserControl.LostFocus Event (Access)

 Copy code hover
[image]

WebBrowserControl.LostFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The LostFocus event occurs when the specified object loses the focus.

Version Information

Version Added: Access 2010

Syntax

expression .LostFocus

expression A variable that represents a WebBrowserControl object.

Return Value

nothing

Remarks

To run a macro or event procedure when these events occur, set the OnLostFocus property to the name of the macro or to [Event Procedure].

This events occurs when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The LostFocus event differs from the Exit event in that the LostFocus event occurs every time a control loses the focus. The Exit event occurs only before a control loses the focus to another control on the same form. The LostFocus event occurs after the Exit event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


TextBox.FontWeight Property (Access)

 Copy code hover
[image]

TextBox.FontWeight Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.

Syntax

expression .FontWeight

expression A variable that represents a TextBox object.

Remarks

The DatasheetFontWeight property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

These properties are only available in Visual Basic within a Microsoft Access database.

In Visual Basic, the DatasheetFontWeight property setting uses the following Integer values.

Setting | Description
100 | Thin
200 | Extra Light
300 | Light
400 | (Default) Normal
500 | Medium
600 | Semi-bold
700 | Bold
800 | Extra Bold
900 | Heavy

The following table contains the properties that don't exist in the DAO Properties collection of until you set them by using the Formatting (Datasheet) toolbar or you can add them in an Access database by using the CreateProperty method and append it to the DAO Properties collection.

DatasheetFontItalic * | DatasheetForeColor *
DatasheetFontHeight * | DatasheetBackColor
DatasheetFontName * | DatasheetGridlinesColor
DatasheetFontUnderline * | DatasheetGridlinesBehavior
DatasheetFontWeight * | DatasheetCellsEffect
Note Note

When you add or set any property listed with an asterisk, Microsoft Access automatically adds all the properties listed with an asterisk to the Properties collection of the database.

Example

The following example sets the font to MS Serif, the font size to 10 points, and the font weight to medium (500) in Datasheet view of the Products table.

VBA Copy code Copy code

Sub SetDatasheetFont

   Dim dbs As Object, objProducts As Object
   Set dbs = CurrentDb
   Const DB_Text As Long = 10
   Const DB_Integer As Long = 3
   Set objProducts = dbs!Products

   SetTableProperty objProducts, "DatasheetFontName", DB_Text, "MS Serif"
   SetTableProperty objProducts, "DatasheetFontHeight", DB_Integer, 10
   SetTableProperty objProducts, "DatasheetFontWeight", DB_Integer, 500

End Sub

Sub SetTableProperty(objTableObj As Object, strPropertyName As String, _
        intPropertyType As Integer, varPropertyValue As Variant)
    ' Set Microsoft Access-defined table property without causing
    ' nonrecoverable run-time error.
    Const conErrPropertyNotFound = 3270
    Dim prpProperty As Variant
    On Error Resume Next                ' Don't trap errors.
    objTableObj.Properties(strPropertyName) = varPropertyValue
    If Err <> 0 Then                    ' Error occurred when value set.
        If Err <> conErrPropertyNotFound Then
            On Error GoTo 0
            MsgBox "Couldn't set property '" & strPropertyName _
                & "' on table '" & objTableObj.Name & "'", 48, "SetTableProperty"
        Else
            On Error GoTo 0
            Set prpProperty = objTableObj.CreateProperty(strPropertyName, _
                intPropertyType, varPropertyValue)
            objTableObj.Properties.Append prpProperty
        End If
    End If
    objTableObj.Properties.Refresh
End Sub

The next example makes the same changes as the preceding example in Datasheet view of the open Products form.

VBA Copy code Copy code
Forms!Products.DatasheetFontName = "MS Serif"
Forms!Products.DatasheetFontHeight = 10
Forms!Products.DatasheetFontWeight = 500

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


SubForm.LabelY Property (Access)

 Copy code hover
[image]

SubForm.LabelY Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelY

expression A variable that represents a SubForm object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Toggle Button Control

 Copy code hover
[image]

Toggle Button Control
Send feedback

Published: July 16, 2012

A toggle button on a form is a stand-alone control used to display a Yes/No value from an underlying record source.

Remarks

When you click a toggle button that's bound to a Yes/No field, Microsoft Access displays the value in the underlying table according to the field's Format property (Yes/No, True/False, or On/Off).

Toggle buttons are most useful when used in an option group with other buttons.

You can also use a toggle button in a custom dialog box to accept user input.


State Property (ADO MD)

 Copy code hover
[image]

State Property (ADO MD)
Send feedback

Indicates the current state of the cellset.

Return Values

Returns a Long integer indicating the current condition of the Cellset object and is read-only. The following values are valid: adStateClosed (0) and adStateOpen (1).

Remarks

To use the ObjectStateEnum constant names, you must have the ADO type library referenced in your project. See Using ADO with ADO MD for more information.


ComboBox.FontWeight Property (Access)

 Copy code hover
[image]

ComboBox.FontWeight Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.

Syntax

expression .FontWeight

expression A variable that represents a ComboBox object.

Remarks

The DatasheetFontWeight property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

These properties are only available in Visual Basic within a Microsoft Access database.

In Visual Basic, the DatasheetFontWeight property setting uses the following Integer values.

Setting | Description
100 | Thin
200 | Extra Light
300 | Light
400 | (Default) Normal
500 | Medium
600 | Semi-bold
700 | Bold
800 | Extra Bold
900 | Heavy

The following table contains the properties that don't exist in the DAO Properties collection of until you set them by using the Formatting (Datasheet) toolbar or you can add them in an Access database by using the CreateProperty method and append it to the DAO Properties collection.

DatasheetFontItalic * | DatasheetForeColor *
DatasheetFontHeight * | DatasheetBackColor
DatasheetFontName * | DatasheetGridlinesColor
DatasheetFontUnderline * | DatasheetGridlinesBehavior
DatasheetFontWeight * | DatasheetCellsEffect
Note Note

When you add or set any property listed with an asterisk, Microsoft Access automatically adds all the properties listed with an asterisk to the Properties collection of the database.

Example

The following example sets the font to MS Serif, the font size to 10 points, and the font weight to medium (500) in Datasheet view of the Products table.

VBA Copy code Copy code

Sub SetDatasheetFont

   Dim dbs As Object, objProducts As Object
   Set dbs = CurrentDb
   Const DB_Text As Long = 10
   Const DB_Integer As Long = 3
   Set objProducts = dbs!Products

   SetTableProperty objProducts, "DatasheetFontName", DB_Text, "MS Serif"
   SetTableProperty objProducts, "DatasheetFontHeight", DB_Integer, 10
   SetTableProperty objProducts, "DatasheetFontWeight", DB_Integer, 500

End Sub

Sub SetTableProperty(objTableObj As Object, strPropertyName As String, _
        intPropertyType As Integer, varPropertyValue As Variant)
    ' Set Microsoft Access-defined table property without causing
    ' nonrecoverable run-time error.
    Const conErrPropertyNotFound = 3270
    Dim prpProperty As Variant
    On Error Resume Next                ' Don't trap errors.
    objTableObj.Properties(strPropertyName) = varPropertyValue
    If Err <> 0 Then                    ' Error occurred when value set.
        If Err <> conErrPropertyNotFound Then
            On Error GoTo 0
            MsgBox "Couldn't set property '" & strPropertyName _
                & "' on table '" & objTableObj.Name & "'", 48, "SetTableProperty"
        Else
            On Error GoTo 0
            Set prpProperty = objTableObj.CreateProperty(strPropertyName, _
                intPropertyType, varPropertyValue)
            objTableObj.Properties.Append prpProperty
        End If
    End If
    objTableObj.Properties.Refresh
End Sub

The next example makes the same changes as the preceding example in Datasheet view of the open Products form.

VBA Copy code Copy code
Forms!Products.DatasheetFontName = "MS Serif"
Forms!Products.DatasheetFontHeight = 10
Forms!Products.DatasheetFontWeight = 500

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


CustomControl.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

CustomControl.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents a CustomControl object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.BorderThemeColorIndex=2

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Section.EventProcPrefix Property (Access)

 Copy code hover
[image]

Section.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents a Section object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

Section Object

Other resources

Section Object Members


Cannot make the

 Copy code hover
[image]

Cannot make the <name> object in <name> container replicable. (Error 3456)
Send feedback

The Microsoft Access database engine was in the process of making the object replicable. The operation failed because there were insufficient resources to manipulate the object. If the object is a table, make sure the total number of fields after replication does not exceed 255 and the total number of bytes in a record does not exceed 2048. If the number of fields or characters is over the limit, decrease the size of the record.


Using Related Technologies with RDS

 Copy code hover
[image]

Using Related Technologies with RDS
Send feedback

This section contains specific information about using RDS with aspects of the following technologies:

  • Using RDS with ODBC Connection Pooling

  • Running Business Objects in Component Services

Internet Information Services For more information about Microsoft Internet Information Services (IIS), see the Microsoft Internet Information Services Web site.

Active Server Pages For more information about Microsoft Active Server Pages (ASP), see the Microsoft Active Server Pages Web site.

Microsoft Component Services For more information about Component Services, see the Microsoft Transaction Server Web site.

Microsoft SQL Server For more information about Microsoft SQL Server, see the Microsoft SQL Server Web site.

Microsoft Internet Explorer For more information about Microsoft Internet Explorer, see the Microsoft Internet Explorer Web site and the MSDN Library and Web Workshop Web site.

Microsoft Windows NT Server/Windows 2000 Server For more information about security in Microsoft Windows NT Server or Windows 2000 Server, see the Microsoft Windows Web site.


Record is deleted. (Error 3167)

 Copy code hover
[image]

Record is deleted. (Error 3167)
Send feedback

You referred to a record that you deleted or that another user in a multiuser environment deleted. Move to another record, and then try the operation again.


NavigationButton.GridlineStyleRight Property (Access)

 Copy code hover
[image]

NavigationButton.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleRight

expression A variable that represents a NavigationButton object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


System Requirements for the Address Book Application

 Copy code hover
[image]

System Requirements for the Address Book Application
Send feedback

To set up the Address Book sample application, you need to meet the following software and database requirements:

Software Requirements

The server computer software requirements for running this Web application include:

  • Microsoft Windows NT® Server 4.0, with Service Pack 3 or later, or Microsoft Windows® 2000 Server.

  • Microsoft Internet Information Services (IIS) version 3.0 or later, with Active Server Pages.

The client computer software requirements for running this Web application include:

  • Microsoft Internet Explorer 4.0 or later.

  • Microsoft Windows NT 4.0 Workstation or Server, Windows 2000, or Microsoft Windows 98.

Database Requirements

To use this sample, you must have:

  • An operational Microsoft® SQL Server version 6.5 or later database server.

  • Privileges to create the database and populate it with the sample data.

  • Verification of the populated data through Enterprise Manager or the ISQL utilities (called Query Analyzer in SQL Server 7.0).

If you do not have privileges, your database administrator may need to set up the system and give you access permission to the database, or set up the database for you.


Report.DisplayOnSharePointSite Property (Access)

 Copy code hover
[image]

Report.DisplayOnSharePointSite Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the specified report can be made available as a view on a Microsoft SharePoint Foundation site. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .DisplayOnSharePointSite

expression A variable that represents a Report object.

Remarks

The DisplayOnSharePointSite property uses the following settings.

Setting | Description
Do Not Display | Do not make the report an available view.
Follow Table Setting | (Default) Make the report an available view if the report's parent table is configured to be displayed as a view.

See also

Concepts

Report Object

Other resources

Report Object Members


WebBrowserControl.Left Property (Access)

 Copy code hover
[image]

WebBrowserControl.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .Left

expression A variable that represents a WebBrowserControl object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


OptionGroup.BackTint Property (Access)

 Copy code hover
[image]

OptionGroup.BackTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackTint

expression A variable that represents an OptionGroup object.

Remarks

The BackTint property contains a numeric expression that can be used to lighten the theme color in the BackColor property. The default value of the BackTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens BackColor by 75%.

VBA Copy code Copy code
Me.ctl.BackTint=25

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


CheckBox.KeyUp Event (Access)

 Copy code hover
[image]

CheckBox.KeyUp Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyUp(KeyCode, Shift)

expression A variable that represents a CheckBox object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyUp property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyUp event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyUp event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


CommandButton.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

CommandButton.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleLeft

expression A variable that represents a CommandButton object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


TabControl.Visible Property (Access)

 Copy code hover
[image]

TabControl.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents a TabControl object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


The name selected for the system object is already in use. (Error 3526)

 Copy code hover
[image]

The name selected for the system object is already in use. (Error 3526)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


CurrentProject.IsConnected Property (Access)

 Copy code hover
[image]

CurrentProject.IsConnected Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsConnected property to determine if the CurrentProject object is currently connected. Read-only Boolean.

Syntax

expression .IsConnected

expression A variable that represents a CurrentProject object.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


Databases.Refresh Method (DAO)

 Copy code hover
[image]

Databases.Refresh Method (DAO)
Send feedback

Not supported for this object.

Syntax

expression .Refresh

expression A variable that represents a Databases object.

Remarks

You can't use the Refresh method with collections that aren't persistent, such as Connections, Databases, Recordsets, Workspaces, or the QueryDefs collection of a Connection object.


NavigationButton.LayoutID Property (Access)

 Copy code hover
[image]

NavigationButton.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified text box. Read-only Long.

Version Information

Version Added: Access 2010

Syntax

expression .LayoutID

expression A variable that represents a NavigationButton object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Groups and Users Append, ChangePassword Methods Example (VC++)

 Copy code hover
[image]

Groups and Users Append, ChangePassword Methods Example (VC++)
Send feedback

This example demonstrates the Append method of Groups, as well as the Append method of Users by adding a new Group and a new User to the system. The new Group is appended to the Groups collection of the new User. Consequently, the new User is added to the Group. Also, the ChangePassword method is used to specify the User password.

Copy code Copy code

// BeginGroupCpp
#import "c:\Program Files\Common Files\system\ado\msadox.dll" no_namespace

#include "iostream.h"
#include "stdio.h"
#include "conio.h"

//Function declarations
void GroupX(void);
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 GroupX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// GroupX Function //
// //
//////////////////////////////////////////////////////////
void GroupX(void)
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.
 _CatalogPtr m_pCatalog = NULL;
 _UserPtr m_pUserNew = NULL;
 _UserPtr m_pUser = NULL;
 _GroupPtr m_pGroup = NULL;

 // Define String Variables.
 _bstr_t strCnn("Provider='Microsoft.JET.OLEDB.4.0';"
 "Data source = 'c:\\Program Files\\Microsoft Office\\"
 "Office\\Samples\\Northwind.mdb';"
 "jet oledb:system database='c:\\Program Files\\Microsoft Office\\"
 "Office\\system.mdw'");

 try
 {
 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof (Catalog)));
 m_pCatalog->PutActiveConnection(strCnn);

 // Create and append new group with a string.
 m_pCatalog->Groups->Append("Accounting");

 // Create and append new user with an object.
 TESTHR(hr = m_pUserNew.CreateInstance(__uuidof(User)));
 m_pUserNew->PutName("Pat Smith");
 m_pUserNew->ChangePassword("","Password1");
 m_pCatalog->Users->Append(
 _variant_t((IDispatch *)m_pUserNew),"");

 // Make the user Pat Smith a member of the
 // Accounting group by creating and adding the
 // appropriate Group object to the user's Groups
 // collection.The same is accomplished if a User
 // object representing Pat Smith is created and
 // appended to the Accounting group Users collection
 m_pUserNew->Groups->Append("Accounting");

 // Enumerate all User objects in the
 // catalog's Users collection.
 long lUsrIndex;
 long lGrpIndex;
 _variant_t vIndex;
 for (lUsrIndex=0; lUsrIndex<m_pCatalog->Users->Count; lUsrIndex++)
 {
 vIndex = lUsrIndex;
 m_pUser = m_pCatalog->Users->GetItem(vIndex);
 cout<<" "<<m_pUser->Name <<endl;
 cout<<" Belongs to these groups:"<<endl;

 // Enumerate all Group objects in each User
 // object's Groups collection.
 if(m_pUser->Groups->Count != 0)
 {
 for(lGrpIndex=0;lGrpIndex<m_pUser->Groups->Count;lGrpIndex++)
 {
 vIndex = lGrpIndex;
 m_pGroup = m_pUser->Groups->GetItem(vIndex);
 cout<<" "<< m_pGroup->Name<<endl;
 }
 }
 else
 cout<<" [None]"<<endl;
 }

 // Enumerate all Group objects in the default
 // workspace's Groups collection.
 for (lGrpIndex=0; lGrpIndex<m_pCatalog->Groups->Count; lGrpIndex++)
 {
 vIndex = lGrpIndex;
 m_pGroup = m_pCatalog->Groups->GetItem(vIndex);
 cout<<" "<< m_pGroup->Name <<endl;
 cout<<" Has as its members:"<<endl;

 // Enumerate all User objects in each Group
 // object's Users Collection.
 if(m_pGroup->Users->Count != 0)
 {
 for (lUsrIndex=0; lUsrIndex<m_pGroup->Users->Count; lUsrIndex++)
 {
 vIndex = lUsrIndex;
 m_pUser = m_pGroup->Users->GetItem(vIndex);
 cout<<" "<<m_pUser->Name<<endl;
 }
 }
 else
 cout<<" [None]"<<endl;
 }

 // Delete new User and Group object because this
 // is only a demonstration.
 m_pCatalog->Users->Delete("Pat Smith");
 m_pCatalog->Groups->Delete("Accounting");
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }
 catch(...)
 {
 cout << "Error occured in include files...."<< endl;
 }
}
// EndGroupCpp


AddMenu Macro Action

 Copy code hover
[image]

AddMenu Macro Action
Send feedback

This article describes the basic operation of the AddMenu macro action.

You can use the AddMenu action to create:

  • Custom menus on the Add-Ins tab for a particular form or report.

  • A custom shortcut menu for a form, report, or control. The custom shortcut menu replaces the built-in shortcut menu for the form, report, or control.

  • A global shortcut menu. The global shortcut menu replaces the built-in shortcut menu for fields in table and query datasheets, forms, and reports, except where you've added a custom shortcut menu for a form, report, or control.

Setting

The AddMenu action has the following arguments.

Action argument

Description

Menu Name

The name of the menu, for example, "Report Commands" or "Tools". To create an access key so that you can use the keyboard to choose the menu, type an ampersand (&) before the letter you want to be the access key. This letter will be underlined in the menu name on the Add-Ins tab.

Menu Macro Name

The name of the macro group that contains the macros for the menu's commands. This is a required argument.

Note Note

If you run a macro containing the AddMenu action in a library database, Microsoft Office Access 2007 looks for the macro group with this name in the current database only.

Status Bar Text

The text to display in the status bar when the menu is selected. This argument is ignored for shortcut menus.

Remarks

To run the AddMenu action in a Visual Basic for Applications (VBA) module, use the AddMenu method of the DoCmd object. You can also set the MenuBar or ShortcutMenuBar property in VBA to create a custom menu on the Add-Ins tab or to attach a custom shortcut menu to a form, report, or control. You can set the ShortcutMenuBar property of the Application object to create a global shortcut menu.


TextBox.FontName Property (Access)

 Copy code hover
[image]

TextBox.FontName Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontName property to specify the font for text in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write String.

Syntax

expression .FontName

expression A variable that represents a TextBox object.

Remarks

The FontName property setting is the name of the font that the text is displayed in.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set this property only in an event procedure or in a macro specified by the OnPrint event property setting.

Font availability depends on your system and printer. If you select a font that your system can't display or that isn't installed, Windows substitutes a similar font.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


CheckBox.BeforeUpdate Property (Access)

 Copy code hover
[image]

CheckBox.BeforeUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.

Syntax

expression .BeforeUpdate

expression A variable that represents a CheckBox object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeUpdate event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the BeforeUpdate event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).BeforeUpdate = "[Event Procedure]"

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


How to: Create a Deployment Package Programmatically

 Copy code hover
[image]

How to: Create a Deployment Package Programmatically
Send feedback

The CreateInstallPackage method enables you to create a deployment package programmatically.

Syntax

expression .CreateInstallPackage(WizardSettingsFile)

expression A variable that represents an AccessDeveloperExtensions object.

The following table describes the arguments of the CreateInstallPackage method.

Name | Required/Optional | Data Type | Description
WizardSettingsFile | Required | String | The path and file name of the wizard template file that contains the settings to use when creating the deployment package. To create a wizard template (.adepsws), click Save Wizard Settings on any Package Solution Wizard page.

Usage

You must instantiate the AccessDeveloperExtensions object before you call the CreateInstallPackage method. Instantiating the AccessDeveloperExtensions object requires a different technique from instantiating the built-in objects in Access. To instantiate the AccessDeveloperExtensions object, you can use the COMAddins collection or the CreateObject method.

The following code illustrates how to instantiate the AccessDeveloperExtensions object through the COMAddins collection.

VBA Copy code Copy code
Set objADE = Application.COMAddIns("AccessAddIn.ADE").Object

The following code illustrates how to instantiate the AccessDeveloperExtensions object by using the CreateObject method.

VBA Copy code Copy code
Set objADE = CreateObject("AccessAddIn.ADE")

The following example wraps the steps necessary to call the CreateInstallPackage method in a subroutine named CreatePackage. To use this example, pass the path and file name of the wizard template file to the subroutine. A deployment package will be created.

VBA Copy code Copy code
Sub CreatePackage(strSettingsPath As String)

    Dim objAde As AccessDeveloperExtensions

    ' Instantiate a AccessDeveloperExtensions object.
    Set objAde = Application.COMAddIns("AccessAddIn.ADE").Object

    ' Create the deployment package.
    objAde.CreateInstallPackage strSettingsFilePath

    Set objAde = Nothing
End Sub

To use this example, you must set a reference to the Access Developer Extensions type library. To do this, follow these steps:

  1. On the Tools menu, click References.

  2. Select the Microsoft Office Access Developer Extensions Type Library 1.0 check box, and then click OK.


CheckBox.ValidationRule Property (Access)

 Copy code hover
[image]

CheckBox.ValidationRule Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.

Syntax

expression .ValidationRule

expression A variable that represents a CheckBox object.

Remarks

Enter an expression for the ValidationRule property setting and text for the ValidationText property setting. The maximum length for the ValidationRule property setting is 2048 characters. The maximum length for the ValidationText property setting is 255 characters.

For controls, you can set the ValidationRule property to any valid expression. For field and record validation rules, the expression can't contain user-defined functions, domain aggregate or aggregate functions, the Eval function, or CurrentUser method, or references to forms, queries, or tables. In addition, field validation rules can't contain references to other fields. For records, expressions can include references to fields in that table.

For table fields and records, you can also set these properties in Visual Basic by using the DAO ValidationRule property.

Note Note

The ValidationRule and ValidationText properties don't apply to check box, option button, or toggle buttoncontrols when they are in an option group. They apply only to the option group itself.

Microsoft Access automatically validates values based on a field's data type; for example, Microsoft Access doesn't allow text in a numeric field. You can set rules that are more specific by using the ValidationRule property.

If you set the ValidationRule property but not the ValidationText property, Microsoft Access displays a standard error message when the validation rule is violated. If you set the ValidationText property, the text you enter is displayed as the error message.

For example, when a record is added for a new employee, you can enter a ValidationRule property requiring that the value in the employee's StartDate field fall between the company's founding date and the current date. If the date entered isn't in this range, you can display the ValidationText property message: "Start date is incorrect."

If you create a control by dragging a field from the field list, the field's validation rule remains in effect, although it isn't displayed in the control's ValidationRule property box in the property sheet. This is because a field's validation rule is inherited by a control bound to that field.

Control, field, and record validation rules are applied as follows:

  • Validation rules you set for fields and controls are applied when you edit the data and the focus leaves the field or control.

  • Validation rules for records are applied when you move to another record.

  • If you create validation rules for both a field and a control bound to the field, both validation rules are applied when you edit data and the focus leaves the control.

The following table contains expression examples for the ValidationRule and ValidationText properties.

ValidationRule property | ValidationText property
<> 0 | Entry must be a nonzero value.
> 1000 Or Is Null | Entry must be blank or greater than 1000.
Like "A????" | Entry must be 5 characters and begin with the letter "A".
>= #1/1/96# And <#1/1/97# | Entry must be a date in 1996.
DLookup("CustomerID", "Customers", "CustomerID = Forms!Customers!CustomerID") Is Null | Entry must be a unique CustomerID (domain aggregate functions are allowed only for form-level validation).

If you create a validation rule for a field, Microsoft Access doesn't normally allow a Null value to be stored in the field. If you want to allow a Null value, add "Is Null" to the validation rule, as in "<> 8 Or Is Null" and make sure the Required property is set to No.

You can't set field or record validation rules for tables created outside Microsoft Access (for example, dBASE, Paradox, or SQL Server). For these kinds of tables, you can create validation rules for controls only.

Example

The following example creates a validation rule for a field that allows only values over 65 to be entered. If a number less than 65 is entered, a message is displayed. The properties are set by using the SetFieldValidation function.

VBA Copy code Copy code
Dim strTblName As String, strFldName As String
Dim strValidRule As String
Dim strValidText As String, intX As Integer

strTblName = "Customers"
strFldName = "Age"
strValidRule = ">= 65"
strValidText = "Enter a number greater than or equal to 65."
intX = SetFieldValidation(strTblName, strFldName, _
 strValidRule, strValidText)

Function SetFieldValidation(strTblName As String, _
 strFldName As String, strValidRule As String, _
 strValidText As String) As Integer

 Dim dbs As Database, tdf As TableDef, fld As Field

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 Set fld = tdf.Fields(strFldName)
 fld.ValidationRule = strValidRule
 fld.ValidationText = strValidText
End Function

The next example uses the SetTableValidation function to set record-level validation to ensure that the value in the EndDate field comes after the value in the StartDate field.

VBA Copy code Copy code
Dim strTblName As String, strValidRule As String
Dim strValidText As String
Dim intX As Integer

strTblName = "Employees"
strValidRule = "EndDate > StartDate"
strValidText = "Enter an EndDate that is later than the StartDate."
intX = SetTableValidation(strTblName, strValidRule, strValidText)

Function SetTableValidation(strTblName As String, _
 strValidRule As String, strValidText As String) _
 As Integer

 Dim dbs As Database, tdf As TableDef

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 tdf.ValidationRule = strValidRule
 tdf.ValidationText = strValidText
End Function

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Cannot use the crosstab of a non-fixed column as a subquery. (Error 3637)

 Copy code hover
[image]

Cannot use the crosstab of a non-fixed column as a subquery. (Error 3637)
Send feedback

You have attempted to sort on a variable column crosstab. You should save the results of the query, and then sort the results with the Sort Ascending or Sort Descending button.


Granting Guest Privileges to a Web Server Computer; RDS guest privileges [ADO]

 Copy code hover
[image]

Granting Guest Privileges to a Web Server Computer; RDS guest privileges [ADO]
Send feedback

The anonymous Web server account (IUSR_ComputerName) must be added to the Guests local group on the Web server computer to use RDS.

To grant guest privileges to a Web server computer

  1. On your Microsoft Windows® 2000 Server computer, click Start, point to Programs, point to Administrative Tools, and then click Computer Management.

  2. In the console tree, in Local Users and Groups, click Groups.

  3. Select the Guests local group. From the Action menu, choose Properties.

  4. In the Guests Properties dialog box, click Add.

  5. If the anonymous Web server account does not appear in the list in the Select Users or Groups dialog box, type its name (IUSR_ComputerName) into the bottom blank box, and then click Add.

  6. Click OK.


Address Book Navigation Buttons

 Copy code hover
[image]

Address Book Navigation Buttons
Send feedback

The Address Book application displays the navigation buttons at the bottom of the Web page. You can use the navigation buttons to navigate through the data in the HTML grid display by selecting either the first or last row of data, or rows adjacent to the current selection.

Navigation Sub Procedures

The Address Book application contains several procedures that allow users to click the First, Next, Previous, and Last buttons to move around the data.

For example, clicking the First button activates the VBScript First_OnClick Sub procedure. The procedure executes a MoveFirst method, which makes the first row of data the current selection. Clicking the Last button activates the Last_OnClick Sub procedure, which invokes the MoveLast method, making the last row of data the current selection. The remaining navigation buttons work in a similar fashion.

Copy code Copy code

' Move to the first record in the bound Recordset.
Sub First_OnClick
 DC1.Recordset.MoveFirst
End Sub

' Move to the next record from the current position
' in the bound Recordset.
Sub Next_OnClick
 If Not DC1.Recordset.EOF Then ' Cannot move beyond bottom record.
 DC1.Recordset.MoveNext
 Exit Sub
 End If
End Sub

' Move to the previous record from the current position in the bound
' Recordset.
Sub Prev_OnClick
 If Not DC1.Recordset.BOF Then ' Cannot move beyond top record.
 DC1.Recordset.MovePrevious
 Exit Sub
 End If
End Sub

' Move to the last record in the bound Recordset.
Sub Last_OnClick
 DC1.Recordset.MoveLast
End Sub


Connection (ADO for Visual C++ Syntax)

 Copy code hover
[image]

Connection (ADO for Visual C++ Syntax)
Send feedback

Methods

            BeginTrans(long *TransactionLevel)

CommitTrans(void)

RollbackTrans(void)

Cancel(void)

Close(void)

Execute(BSTR CommandText, VARIANT *RecordsAffected, long Options,_ADORecordset **ppiRset)

Open(BSTR ConnectionString, BSTR UserID, BSTR Password, long Options)

OpenSchema(SchemaEnum Schema, VARIANT Restrictions, VARIANT SchemaID,_ADORecordset **pprset)

Properties

            get_Attributes(long *plAttr)

put_Attributes(long lAttr)

get_CommandTimeout(LONG *plTimeout)

put_CommandTimeout(LONG lTimeout)

get_ConnectionString(BSTR *pbstr)

put_ConnectionString(BSTR bstr)

get_ConnectionTimeout(LONG *plTimeout)

put_ConnectionTimeout(LONG lTimeout)

get_CursorLocation(CursorLocationEnum *plCursorLoc)

put_CursorLocation(CursorLocationEnum lCursorLoc)

get_DefaultDatabase(BSTR *pbstr)

put_DefaultDatabase(BSTR bstr)

get_IsolationLevel(IsolationLevelEnum *Level)

put_IsolationLevel(IsolationLevelEnum Level)

get_Mode(ConnectModeEnum *plMode)

put_Mode(ConnectModeEnum lMode)

get_Provider(BSTR *pbstr)

put_Provider(BSTR Provider)

get_State(LONG *plObjState)

get_Version(BSTR *pbstr)

get_Errors(ADOErrors **ppvObject)

Events

BeginTransComplete(LONG TransactionLevel, ADOError *pError, EventStatusEnum *adStatus, _ADOConnection *pConnection) CommitTransComplete(ADOError *pError, EventStatusEnum *adStatus, _ADOConnection *pConnection) ConnectComplete(ADOError *pError, EventStatusEnum *adStatus, _ADOConnection *pConnection) Disconnect(EventStatusEnum *adStatus, _ADOConnection *pConnection) ExecuteComplete(LONG RecordsAffected, ADOError *pError, EventStatusEnum *adStatus, _ADOCommand *pCommand, _ADORecordset *pRecordset, _ADOConnection *pConnection) InfoMessage(ADOError *pError, EventStatusEnum *adStatus, _ADOConnection *pConnection) RollbackTransComplete(ADOError *pError, EventStatusEnum *adStatus, _ADOConnection *pConnection) WillConnect(BSTR *ConnectionString, BSTR *UserID, BSTR *Password, long *Options, EventStatusEnum *adStatus, _ADOConnection *pConnection) WillExecute(BSTR *Source, CursorTypeEnum *CursorType, LockTypeEnum *LockType, long *Options, EventStatusEnum *adStatus, _ADOCommand *pCommand, _ADORecordset *pRecordset, _ADOConnection *pConnection)


ComboBox.RightMargin Property (Access)

 Copy code hover
[image]

ComboBox.RightMargin Property (Access)
See also Send feedback

Published: July 16, 2012

Along with the TopMargin, Left Margin, and BottomMargin properties, specifies the location of information displayed within a combo box control. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .RightMargin

expression A variable that represents a ComboBox object.

Remarks

A control's displayed information location is measured from the control's left, top, right, or bottom border to the left, top, right, or bottom edge of the displayed information. To use a unit of measurement different from the setting in the regional settings of Windows, specify the unit (for example, cm or in).

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Recordset2 Object Reference (DAO)

 Copy code hover
[image]

Recordset2 Object Reference (DAO)
Send feedback

In this section

  • Recordset2 Object (DAO)

  • Recordset2 Members (DAO)

  • Recordset2 Properties (DAO)

  • Recordset2 Methods (DAO)


OptionGroup.DblClick Event (Access)

 Copy code hover
[image]

OptionGroup.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Syntax

expression .DblClick(Cancel)

expression A variable that represents an OptionGroup object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the DblClick event occurs. Setting the Cancel argument to True (-1) cancels the DblClick event.

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Application.CurrentProject Property (Access)

 Copy code hover
[image]

Application.CurrentProject Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the CurrentProject property to access the CurrentProject object and its related collections, properties, and methods. Read-only CurrentProject object.

Syntax

expression .CurrentProject

expression A variable that represents an Application object.

Remarks

Use the CurrentProject property to refer to one of the following current database collections together with one of its properties or methods.

AllForms | AllMacros
AllModules | AccessObjectProperties
AllReports |

See also

Concepts

Application Object

Other resources

Application Object Members


Recordset2.Properties Property (DAO)

 Copy code hover
[image]

Recordset2.Properties Property (DAO)
Send feedback

Returns the Properties collection of the specified object. Read-only.

Syntax

expression .Properties

expression A variable that represents a Recordset2 object.


About compressing the data in a Text, Memo, or Hyperlink field

 Copy code hover
[image]

About compressing the data in a Text, Memo, or Hyperlink field
Send feedback

Microsoft Access uses the Unicode character-encoding scheme to represent the data in a Text, Memo, or Hyperlink field. Unicode represents each character as two bytes, so the data in a Text, Memo, or Hyperlink field requires more storage space than it did in Access 97 or earlier, where each character is represented as one byte.

To offset this effect of Unicode character representation and to ensure optimal performance, the default value of the Unicode Compression property for a Text, Memo, or Hyperlink field is Yes. When a field's Unicode Compression property is set to Yes, any character whose first byte is 0 is compressed when it is stored and uncompressed when it is retrieved. Because the first byte of a Latin character — a character of a Western European language such as English, Spanish, or German — is 0, Unicode character representation does not affect how much storage space is required for compressed data that consists entirely of Latin characters.

In a single field, you can store any combination of characters that Unicode supports. However, if the first byte of a particular character is not 0, that character is not compressed.

Data in a Memo field is not compressed unless it requires 4,096 bytes or less of storage space after compression. As a result, the contents of a Memo field might be compressed in one record, but might not be compressed in another record.


Form.OnGotFocus Property (Access)

 Copy code hover
[image]

Form.OnGotFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnGotFocus

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The GotFocus event occurs when the object receives the focus.

The OnGotFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Got Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Got Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnGotFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnGotFocus

See also

Concepts

Form Object

Other resources

Form Object Members


Form.CommandChecked Property (Access)

 Copy code hover
[image]

Form.CommandChecked Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the CommandChecked event occurs. Read/write.

Syntax

expression .CommandChecked

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the CommandChecked event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).CommandChecked = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


Report.Circle Method (Access)

 Copy code hover
[image]

Report.Circle Method (Access)
See also Send feedback

Published: July 16, 2012

The Circle method draws a circle, an ellipse, or an arc on a Report object when the Print event occurs.

Syntax

expression.Circle(Step(x, y), radius, color, start, end, aspect)

Parameters

Step A keyword that indicates that the center of the circle, ellipse, or arc is relative to the current coordinates given by the current settings for the CurrentX < and CurrentY properties of the object argument.

X, YSingle values indicating the coordinates of the center point of the circle, ellipse, or arc. The Scale properties (ScaleMode, ScaleLeft, ScaleTop, ScaleHeight, and ScaleWidth) of the Report object specified by the object argument determine the unit of measure used.

Radiums A Single value indicating the radius of the circle, ellipse, or arc. The Scale properties (ScaleMode, ScaleLeft, ScaleTop, ScaleHeight, and ScaleWidth) of the Report object specified by the object argument determine the unit of measure used. By default, distances are measured in twips.

Color A Long value indicating the RGB (red-green-blue) color of the circle outline. If this argument is omitted, the value of the ForeColor property is used. You can also use the RGB function or QBColor function to specify the color.

Start Single. When a partial circle or ellipse is drawn, the start argument specifies (in radians) the beginning position of the arc. The default value for the start argument is 0 radians. The range is -2 pi radians to 2 pi radians.End Single. When a partial circle or ellipse is drawn, the end argument specifies (in radians) the end position of the arc. The default value for the end argument is 2 pi radians. The range is -2 pi radians to 2 pi radians.

aspect A Single value indicating the aspect ratio of the circle. The default value is 1.0, which yields a perfect (nonelliptical) circle on any screen.

Remarks

You can use this method only in an event procedure or a macro specified by the event properties for a report section, or the OnPage event property for a report.

When drawing a partial circle or ellipse, if the start argument is negative, the Circle method draws a radius to the position specified by the start argument and treats the angle as positive. If the end argument is negative, the Circle method draws a radius to the position specified by the end argument and again treats the angle as positive. The Circle method always draws in a counterclockwise (positive) direction.

To fill a circle, set the FillColor and FillStyle properties of the report. Only a closed figure can be filled. Closed figures include circles, ellipses, and pie slices, which are arcs with radius lines drawn at both ends.

When drawing pie slices, if you need to draw a radius to angle 0 to form a horizontal line segment to the right, specify a very small negative value for the start argument rather than 0. For example, you might specify -.00000001 for the start argument.

You can omit an argument in the middle of the syntax, but you must include the argument's comma before including the next argument. If you omit a trailing argument, don't use any commas following the last argument you specify.

The width of the line used to draw the circle, ellipse, or arc depends on the DrawWidth property setting. The way the circle is drawn on the background depends on the settings of the DrawMode and DrawStyle properties.

When you apply the Circle method, the CurrentX and CurrentY properties are set to the center point specified by the x and y arguments.

Example

The following example uses the Circle method to draw a circle, and then create a pie slice within the circle and color it red.

To try this example in Microsoft Access, create a new report. Set the OnPrint property of the Detail section to [Event Procedure]. Enter the following code in the report's module, then switch to Print Preview.

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    Const conPI = 3.14159265359
    Dim sngHCtr As Single, sngVCtr As Single
    Dim sngRadius As Single
    Dim sngStart As Single, sngEnd As Single

    sngHCtr = Me.ScaleWidth / 2     ' Horizontal center.
    sngVCtr = Me.ScaleHeight / 2     ' Vertical center.
    sngRadius = Me.ScaleHeight / 3     ' Circle radius.
    ' Draw circle.
    Me.Circle(sngHCtr, sngVCtr), sngRadius
    sngStart = -0.00000001             ' Start of pie slice.
    sngEnd = -2 * conPI / 3             ' End of pie slice.
    Me.FillColor = RGB(255,0,0)     ' Color pie slice red.
    Me.FillStyle = 0                     ' Fill pie slice.
    ' Draw pie slice within circle.
    Me.Circle(sngHCtr, sngVCtr), sngRadius, , sngStart, sngEnd
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


ADO Properties

 Copy code hover
[image]

ADO Properties
Send feedback
AbsolutePage | Indicates on which page the current record resides.
AbsolutePosition | Indicates the ordinal position of a Recordset object's current record.
ActiveCommand | Indicates the Command object that created the associated Recordset object.
ActiveConnection | Indicates to which Connection object the specified Command, Recordset, or Record object currently belongs.
ActualSize | Indicates the actual length of a field's value.
Attributes | Indicates one or more characteristics of an object.
BOF and EOF | BOF — indicates that the current record position is before the first record in a Recordset object. EOF — indicates that the current record position is after the last record in a Recordset object.
Bookmark | Indicates a bookmark that uniquely identifies the current record in a Recordset object or sets the current record in a Recordset object to the record identified by a valid bookmark.
CacheSize | Indicates the number of records from a Recordset object that are cached locally in memory.
Chapter | Gets or sets an OLE DB Chapter object from/on an ADORecordsetConstruction object.
CharSet | Indicates the character set into which the contents of a text Stream should be translated.
CommandText | Indicates the text of a command to be issued against a provider.
CommandTimeout | Indicates how long to wait while executing a command before terminating the attempt and generating an error.
CommandType | Indicates the type of a Command object.
ConnectionString Property | Indicates the information used to establish a connection to a data source.
ConnectionTimeout | Indicates how long to wait while establishing a connection before terminating the attempt and generating an error.
Count | Indicates the number of objects in a collection.
CursorLocation | Indicates the location of the cursor service.
CursorType | Indicates the type of cursor used in a Recordset object.
DataMember | Indicates the name of the data member that will be retrieved from the object referenced by the DataSource property.
DataSource | Indicates an object that contains data to be represented as a Recordset object.
DefaultDatabase | Indicates the default database for a Connection object.
DefinedSize | Indicates the data capacity of a Field object.
Description | Describes an Error object.
Direction | Indicates whether the Parameter represents an input parameter, an output parameter, or both, or if the parameter is the return value from a stored procedure.
EditMode | Indicates the editing status of the current record.
EOS | Indicates whether the current position is at the end of the stream.
Filter | Indicates a filter for data in a Recordset.
HelpContext and HelpFile | Indicates the help file and topic associated with an Error object. HelpContextID — returns a context ID, as a Long value, for a topic in a Help file. HelpFile — returns a String value that evaluates to a fully resolved path to a Help file.
Index | Indicates the name of the index currently in effect for a Recordset object.
IsolationLevel | Indicates the level of isolation for a Connection object.
Item | Indicates a specific member of a collection, by name or ordinal number.
LineSeparator | Indicates the binary character to be used as the line separator in text Stream objects.
LockType | Indicates the type of locks placed on records during editing.
MarshalOptions | Indicates which records are to be marshaled back to the server.
MaxRecords | Indicates the maximum number of records to return to a Recordset from a query.
Mode | Indicates the available permissions for modifying data in a Connection, Record, or Stream object.
Name | Indicates the name of an object.
NativeError | Indicates the provider-specific error code for a given Error object.
Number | Indicates the number that uniquely identifies an Error object.
NumericScale | Indicates the scale of numeric values in a Parameter or Field object.
OriginalValue | Indicates the value of a Field that existed in the record before any changes were made.
PageCount | Indicates how many pages of data the Recordset object contains.
PageSize | Indicates how many records constitute one page in the Recordset.
ParentRow | Sets the container of an OLE DB Row object on an ADORecordConstruction object, so that the parent of the row is turned into an ADO Record object.
ParentURL | Indicates an absolute URL string that points to the parent Record of the current Record object.
Position | Indicates the current position within a Stream object.
Precision | Indicates the degree of precision for numeric values in a Parameter object or for numeric Field objects.
Prepared | Indicates whether to save a compiled version of a command before execution.
Provider | Indicates the name of the provider for a Connection object.
RecordCount | Indicates the number of records in a Recordset object.
RecordType | Indicates the type of Record object.
Row | Gets or sets an OLE DB Row object from/on an ADORecordConstruction object.
RowPosition | Gets or sets an OLE DB RowPosition object from/on an ADORecordsetConstruction object.
Rowset | Gets or sets an OLE DB Rowset object from/on an ADORecordsetConstruction object.
Size | Indicates the maximum size, in bytes or characters, of a Parameter object.
Size (ADO Stream) | Indicates the total size of the stream in number of bytes.
Sort | Indicates one or more field names on which the Recordset is sorted, and whether each field is sorted in ascending or descending order.
Source (ADO Error) | Indicates the name of the object or application that originally generated an error.
Source (ADO Record) | Indicates the entity represented by the Record object.
Source (ADO Recordset) | Indicates the source for the data in a Recordset object
SQLState | Indicates the SQL state for a given Error object.
State | Indicates for all applicable objects whether the state of the object is open or closed. Indicates for all applicable objects executing an asynchronous method, whether the current state of the object is connecting, executing, or retrieving
Status (ADO Field) | Indicates the status of a Field object.
Status (ADO Recordset) | Indicates the status of the current record with respect to batch updates or other bulk operations.
StayInSync | Indicates, in a hierarchical Recordset object, whether the reference to the underlying child records (that is, the chapter) changes when the parent row position changes.
Type | Indicates the operational type or data type of a Parameter, Field, or Property object.
Type (ADO Stream) | Indicates the type of data contained in the Stream (binary or text).
UnderlyingValue | Indicates a Field object's current value in the database.
Value | Indicates the value assigned to a Field, Parameter, or Property object.
Version | Indicates the ADO version number.


AllMacros Members (Access)

 Copy code hover
[image]

AllMacros Members (Access)
Send feedback

Published: July 16, 2012

The AllMacros collection contains an AccessObject for each macro in the CurrentProject or CodeProject object.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


The cascading options for the new reference conflict with existing reference

 Copy code hover
[image]

The cascading options for the new reference conflict with existing reference <name>. (Error 3707)
Send feedback

This error occurs if a CASCADE action is defined on a column that already has another type of CASCADE action. For example, if CASCADE DELETE is already specified, the user will be prevented from trying to add CASCADE UPDATE. To apply the desired CASCADE action, the original CONSTRAINT must be dropped. This can be done with the ALTER TABLE ALTER COLUMN syntax or with the DROP CONSTRAINT syntax.


RDS Code Examples in Microsoft Visual Basic

 Copy code hover
[image]

RDS Code Examples in Microsoft Visual Basic
Send feedback

Use the following code examples to learn how to use RDS properties when writing in Visual Basic.

Note Note

Paste the entire code example, from Sub to End Sub, into your code editor. The example may not run correctly if partial examples are used or if paragraph formatting is lost.

Properties

  • Handler Property Example

  • InternetTimeout Property Example


ASC/DESC (Microsoft Access SQL reserved words)

 Copy code hover
[image]

ASC/DESC (Microsoft Access SQL reserved words)
Send feedback

Published: July 16, 2012

The ASC and DESC keywords are used in these contexts:

CREATE INDEX Statement

ORDER BY Clause


How to: Export Data, Schema, and Related Tables to XML

 Copy code hover
[image]

How to: Export Data, Schema, and Related Tables to XML
Send feedback

The ExportXML method can be used to export the data and formatting contained in a table, along with any additonal data that you specify.

To specify the additional data to export, you must must use the CreateAdditionalData method to create an AdditionalData object. Then, use the Add method to add additonal tables to export along with the main table.

The following procedure illustrates how to include additional data when exporting a table to XML. The Orders table is exported along with several other tables. The schema and the formatting are also exported as separate .xsd and .xsl files, respectively.

VBA Copy code Copy code
Private Sub ExportRelTables()
   ' Purpose: Exports the Orders table as well as
   ' a number of related databases to an XML file.
   ' XSD and XSL files are also created.

   Dim objAD As AdditionalData

   ' Create the AdditionalData object.
   Set objAD = Application.CreateAdditionalData

   ' Add the related tables to the object.
   With objAD
      .Add "Order Details"
      objAD(Item:="Order Details").Add "Order Details Details"
      .Add "Customers"
      .Add "Shippers"
      .Add "Employees"
      .Add "Products"
      objAD(Item:="Products").Add "Product Details"
      objAD(Item:="Products")(Item:="Product Details").Add _
         "Product Details Details"
      .Add "Suppliers"
      .Add "Categories"
   End With

   ' Export the Orders table along with the addtional data.
   Application.ExportXml acExportTable, "Orders", _
       "C:\Orders.xml", "C:\OrdersSchema.xsd", _
       "C:\OrdersStyle.xsl", AdditionalData:= objAD
End Sub


DateFromParts Function (Access 2013 custom web app)

 Copy code hover
[image]

DateFromParts Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns a date value for the specified year, month, and day.

Syntax

DateFromParts(Year, Month, Day)

The DateFromParts function contains the following arguments.

Argument name | Description
Year | Integer expression specifying a year.
Month | Integer expression specifying a month, from 1 to 12.
Day | Integer expression specifying a day.

Remarks

DateFromParts returns a date value with the date portion set to the specified year, month and day, and the time portion set to the default. If the arguments are not valid, then an error is raised. If required arguments are null, then NULL is returned.

Example

The following expression uses the DateFromParts function to calculate the first day of the current month.

Copy code Copy code
DateFromParts(Year(Today()),Month(Today()),1)


Report.FillColor Property (Access)

 Copy code hover
[image]

Report.FillColor Property (Access)
See also Send feedback

Published: July 16, 2012

You use the FillColor property to specify the color that fills in boxes and circles drawn on reports with the Line and Circle methods. You can also use this property with Visual Basic to create special visual effects on custom reports when you print using a color printer or preview the reports on a color monitor. Read/write Long.

Syntax

expression .FillColor

expression A variable that represents a Report object.

Remarks

You can set this property only in an event procedure specified by a section's OnPrint event property.

The following example uses the Circle method to draw a circle and create a pie slice within the circle. Then it uses the FillColor and FillStyle properties to color the pie slice red. It also draws a line from the upper left to the center of the circle.

You can use the RGB or QBColor functions to set this property. The FillColor property setting has a data type of Long.

Example

To try this example in Microsoft Access, create a new report. Set the OnPrint property of the Detail section to [Event Procedure]. Enter the following code in the report's module, then switch to Print Preview.

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

 Const conPI = 3.14159265359

 Dim sngHCtr As Single
 Dim sngVCtr As Single
 Dim sngRadius As Single
 Dim sngStart As Single
 Dim sngEnd As Single

 sngHCtr = Me.ScaleWidth / 2 ' Horizontal center.
 sngVCtr = Me.ScaleHeight / 2 ' Vertical center.
 sngRadius = Me.ScaleHeight / 3 ' Circle radius.
 Me.Circle (sngHCtr, sngVCtr), sngRadius ' Draw circle.
 sngStart = -0.00000001 ' Start of pie slice.

 sngEnd = -2 * conPI / 3 ' End of pie slice.
 Me.FillColor = RGB(255, 0, 0) ' Color pie slice red.
 Me.FillStyle = 0 ' Fill pie slice.

 ' Draw Pie slice within circle
 Me.Circle (sngHCtr, sngVCtr), sngRadius, , sngStart, sngEnd

 ' Draw line to center of circle.
 Dim intColor As Integer
 Dim sngTop As Single, sngLeft As Single
 Dim sngWidth As Single, sngHeight As Single

 Me.ScaleMode = 3 ' Set scale to pixels.
 sngTop = Me.ScaleTop ' Top inside edge.
 sngLeft = Me.ScaleLeft ' Left inside edge.
 sngWidth = Me.ScaleWidth / 2 ' Width inside edge.
 sngHeight = Me.ScaleHeight / 2 ' Height inside edge.
 intColor = RGB(255, 0, 0) ' Make color red.

 ' Draw line.
 Me.Line (sngTop, sngLeft)-(sngWidth, sngHeight), intColor

End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


Constants Enumeration (Access)

 Copy code hover
[image]

Constants Enumeration (Access)
Send feedback

Published: July 16, 2012

Name | Value | Description
acAltMask | 4 |
acApplyFilter | 1 |
acApplyServerFilter | 3 |
acCloseFilterWindow | 2 |
acCloseServerFilterWindow | 4 |
acCopy | 2 |
acCtrlMask | 2 |
acCut | 1 |
acDataErrAdded | 2 |
acDataErrContinue | 0 |
acDataErrDisplay | 1 |
acDelete | 6 |
acDeleteCancel | 1 |
acDeleteOK | 0 |
acDeleteUserCancel | 2 |
acEditMenu | 1 |
acEffectChisel | 5 |
acEffectEtched | 3 |
acEffectNormal | 0 |
acEffectRaised | 1 |
acEffectShadow | 4 |
acEffectSunken | 2 |
acExit | 2 |
acFile | 0 |
acFilterAdvanced | 1 |
acFilterByForm | 0 |
acFormatASP | Microsoft |
acFormatHTML | HTML |
acFormatIIS | Microsoft |
acFormatPDF | PDF |
acFormatRTF | Rich |
acFormatSNP | Snapshot |
acFormatTXT | MS-DOS |
acFormatXLS | Microsoft |
acFormatXPS | XPS |
acFormBar | 0 |
acGridlinesBoth | 3 |
acGridlinesBothV2 | -1 |
acGridlinesHoriz | 1 |
acGridlinesNone | 0 |
acGridlinesVert | 2 |
acLBClose | 8 |
acLBEnd | 9 |
acLBGetColumnCount | 4 |
acLBGetColumnWidth | 5 |
acLBGetFormat | 7 |
acLBGetRowCount | 3 |
acLBGetValue | 6 |
acLBInitialize | 0 |
acLBOpen | 1 |
acLeftButton | 1 |
acMenuCheck | 3 |
acMenuGray | 1 |
acMenuUncheck | 2 |
acMenuUngray | 0 |
acMenuVer1X | 11 |
acMenuVer20 | 20 |
acMenuVer70 | 70 |
acMiddleButton | 4 |
acNew | 0 |
acObject | 14 |
acObjectUpdate | 3 |
acObjectVerb | 0 |
acObjStateDirty | 2 |
acObjStateNew | 4 |
acObjStateOpen | 1 |
acOLEActivate | 7 |
acOLEActivateDoubleClick | 2 |
acOLEActivateGetFocus | 1 |
acOLEActivateManual | 0 |
acOLEChanged | 0 |
acOLEClose | 9 |
acOLEClosed | 2 |
acOLECopy | 4 |
acOLECreateEmbed | 0 |
acOLECreateFromFile | 1 |
acOLECreateLink | 1 |
acOLECreateNew | 0 |
acOLEDelete | 10 |
acOLEDisplayContent | 0 |
acOLEDisplayIcon | 1 |
acOLEEither | 2 |
acOLEEmbedded | 1 |
acOLEFetchVerbs | 17 |
acOLEInsertObjDlg | 14 |
acOLELinked | 0 |
acOLENone | 3 |
acOLEPaste | 5 |
acOLEPasteSpecialDlg | 15 |
acOLERenamed | 3 |
acOLESaved | 1 |
acOLESizeAutoSize | 2 |
acOLESizeClip | 0 |
acOLESizeStretch | 1 |
acOLESizeZoom | 3 |
acOLEUpdate | 6 |
acOLEUpdateAutomatic | 0 |
acOLEUpdateFrozen | 1 |
acOLEUpdateManual | 2 |
acOLEVerbHide | -3 |
acOLEVerbInPlaceActivate | -5 |
acOLEVerbInPlaceUIActivate | -4 |
acOLEVerbOpen | -2 |
acOLEVerbPrimary | 0 |
acOLEVerbShow | -1 |
acPaste | 3 |
acPrompt | 0 |
acRecordsMenu | 5 |
acRefresh | 5 |
acRightButton | 2 |
acSave | 1 |
acSaveForm | 4 |
acSaveFormAs | 5 |
acSaveRecord | 4 |
acSecFrmRptExecute | 256 |
acSecFrmRptReadDef | 4 |
acSecFrmRptWriteDef | 65548 |
acSecMacExecute | 8 |
acSecMacReadDef | 10 |
acSecMacWriteDef | 65542 |
acSecModReadDef | 2 |
acSecModWriteDef | 65542 |
acSelectAllRecords | 9 |
acSelectRecord | 8 |
acServerFilterByForm | 2 |
acShiftMask | 1 |
acShowAllRecords | 0 |
acUndo | 0 |
vbKey0 | 48 |
vbKey1 | 49 |
vbKey2 | 50 |
vbKey3 | 51 |
vbKey4 | 52 |
vbKey5 | 53 |
vbKey6 | 54 |
vbKey7 | 55 |
vbKey8 | 56 |
vbKey9 | 57 |
vbKeyA | 65 |
vbKeyAdd | 107 |
vbKeyB | 66 |
vbKeyBack | 8 |
vbKeyC | 67 |
vbKeyCancel | 3 |
vbKeyCapital | 20 |
vbKeyClear | 12 |
vbKeyControl | 17 |
vbKeyD | 68 |
vbKeyDecimal | 110 |
vbKeyDelete | 46 |
vbKeyDivide | 111 |
vbKeyDown | 40 |
vbKeyE | 69 |
vbKeyEnd | 35 |
vbKeyEscape | 27 |
vbKeyExecute | 43 |
vbKeyF | 70 |
vbKeyF1 | 112 |
vbKeyF10 | 121 |
vbKeyF11 | 122 |
vbKeyF12 | 123 |
vbKeyF13 | 124 |
vbKeyF14 | 125 |
vbKeyF15 | 126 |
vbKeyF16 | 127 |
vbKeyF2 | 113 |
vbKeyF3 | 114 |
vbKeyF4 | 115 |
vbKeyF5 | 116 |
vbKeyF6 | 117 |
vbKeyF7 | 118 |
vbKeyF8 | 119 |
vbKeyF9 | 120 |
vbKeyG | 71 |
vbKeyH | 72 |
vbKeyHelp | 47 |
vbKeyHome | 36 |
vbKeyI | 73 |
vbKeyInsert | 45 |
vbKeyJ | 74 |
vbKeyK | 75 |
vbKeyL | 76 |
vbKeyLButton | 1 |
vbKeyLeft | 37 |
vbKeyM | 77 |
vbKeyMButton | 4 |
vbKeyMenu | 18 |
vbKeyMultiply | 106 |
vbKeyN | 78 |
vbKeyNumlock | 144 |
vbKeyNumpad0 | 96 |
vbKeyNumpad1 | 97 |
vbKeyNumpad2 | 98 |
vbKeyNumpad3 | 99 |
vbKeyNumpad4 | 100 |
vbKeyNumpad5 | 101 |
vbKeyNumpad6 | 102 |
vbKeyNumpad7 | 103 |
vbKeyNumpad8 | 104 |
vbKeyNumpad9 | 105 |
vbKeyO | 79 |
vbKeyP | 80 |
vbKeyPageDown | 34 |
vbKeyPageUp | 33 |
vbKeyPause | 19 |
vbKeyPrint | 42 |
vbKeyQ | 81 |
vbKeyR | 82 |
vbKeyRButton | 2 |
vbKeyReturn | 13 |
vbKeyRight | 39 |
vbKeyS | 83 |
vbKeySelect | 41 |
vbKeySeparator | 108 |
vbKeyShift | 16 |
vbKeySnapshot | 44 |
vbKeySpace | 32 |
vbKeySubtract | 109 |
vbKeyT | 84 |
vbKeyTab | 9 |
vbKeyU | 85 |
vbKeyUp | 38 |
vbKeyV | 86 |
vbKeyW | 87 |
vbKeyX | 88 |
vbKeyY | 89 |
vbKeyZ | 90 |


Form.CommandBeforeExecute Event (Access)

 Copy code hover
[image]

Form.CommandBeforeExecute Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs before a specified command is executed. Use this event when you want to impose certain restrictions before a particular command is executed.

Syntax

expression .CommandBeforeExecute(Command, Cancel)

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Command | Required | Variant | The command that is going to be executed.
Cancel | Required | Object | Set the Value property of this object to True to cancel the command.

Return Value

nothing

Remarks

The OCCommandId, ChartCommandIdEnum, and PivotCommandId constants contain lists of the supported commands for each of the Microsoft Office Web Components.

Example

The following example demonstrates the syntax for a subroutine that traps the CommandBeforeExecute event.

VBA Copy code Copy code
Private Sub Form_CommandBeforeExecute( _
 ByVal Command As Variant, ByVal Cancel As Object)
 Dim intResponse As Integer
 Dim strPrompt As String

 strPrompt = "Cancel the command?"

 intResponse = MsgBox(strPrompt, vbYesNo)

 If intResponse = vbYes Then
 Cancel.Value = True
 Else
 Cancel.Value = False
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Line Methods (Access)

 Copy code hover
[image]

Line Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.


TextBox.PostalAddress Property (Access)

 Copy code hover
[image]

TextBox.PostalAddress Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PostalAddress Property property to specify or determine the postal code and the Customer Barcode data corresponding to the address information displayed in a specified field/textbox. The PostalAddress Property wizard enables the setting of these properties. Read/write String.

Syntax

expression .PostalAddress

expression A variable that represents a TextBox object.

Remarks

For processing the conversion, correct settings are necessary for all properties of field/textbox that will contain postal code, address, Customer Barcode data.

For settings, use section 1 to 3, delimiting with semicolon (;).

Setting for field/textbox for Postal code

Specifies the type of postal code for the field/textbox.

Section | Description
1 | Specifies field/textbox for Prefecture names
2 | Specifies field/textbox for City/Ward/County
3 | Specifies field/textbox for Street/Town/Village

Setting for field/textbox for address

Specifies the field/textbox contains a postal code or Customer Barcode data.

Section | Description
1 | Specifies field/textbox for postal code
2 | Specifies field/textbox for Customer Barcode data
Note Note

Two semicolons are required at the end of the value.

Setting for field/textbox for Customer Barcode data

Specifies the type of Customer Barcode data in the field/textbox. This setting is the same as the field/textbox for postal code.

Section | Description
1 | Specifies field/textbox for Prefecture names
2 | Specifies field/textbox for City/Ward/County
3 | Specifies field/textbox for Street/Town/Village

The postal code consists of 3 address items; Prefecture, City/Ward/County, Street/Town/Village. Sections in PostalAddress Property property of field/textbox for a postal code can be omitted. The following table shows how to omit sections from the property setting.

Property Settings | Address input in field/textbox
 | Address1 | Address2 | Address3
Address1 | Prefecture+City/Ward/County+Street/Town/Village |  |
Address1; | Prefecture |  |
;Address1 | City/Ward/County+Street/Town/Village |  |
;Address1; | City/Ward/County |  |
;;Address1 | Street/Town/Village |  |
Address1;Address2 | Prefecture | City/Ward/County+Street/Town/Village |
Address1;Address1 | Prefecture+City/Ward/County+Street/Town/Village |  |
Address1;Address2; | Prefecture | City/Ward/County |
Address1;Address1; | Prefecture+City/Ward/County |  |
;Address1;Address2 | City/Ward/County | Street/Town/Village |
;Address1;Address1 | City/Ward/County+Street/Town/Village |  |
Address1;Address2;Address3 | Prefecture | City/Ward/County | Street/Town/Village
Address1;Address2;Address2 | Prefecture | City/Ward/County+Street/Town/Village |
Address1;Address1;Address2 | Prefecture+City/Ward/County | Street/Town/Village |
Address1;Address1;Address1 | Prefecture+City/Ward/County+Street/Town/Village |  |

The postal code converter program has been developed and licensed by Advanced Giken Corporation for Microsoft Corporation.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


TableDef.Connect Property (DAO)

 Copy code hover
[image]

TableDef.Connect Property (DAO)
Send feedback

Sets or returns a value that provides information about a linked table. Read/write String.

Syntax

expression .Connect

expression A variable that represents a TableDef object.

Remarks

The Connect property setting is a String composed of a database type specifier and zero or more parameters separated by semicolons. The Connect property passes additional information to ODBC and certain ISAM drivers as needed.

For a TableDef object that represents a linked table, the Connect property setting consists of one or two parts (a database type specifier and a path to the database), each of which ends with a semicolon.

The path as shown in the following table is the full path for the directory containing the database files and must be preceded by the identifier DATABASE=. In some cases (as with Microsoft Excel and Microsoft Access database engine databases), you should include a specific file name in the database path argument.

The following table shows possible database types and their corresponding database specifiers and paths for the Connect property setting.

Database type | Specifier | Example
Microsoft Access Database | [database]; | drive:\path\filename
dBASE III | dBASE III; | drive:\path
dBASE IV | dBASE IV; | drive:\path
dBASE 5 | dBASE 5.0; | drive:\path
Paradox 3.x | Paradox 3.x; | drive:\path
Paradox 4.x | Paradox 4.x; | drive:\path
Paradox 5.x | Paradox 5.x; | drive:\path
Microsoft Excel 3.0 | Excel 3.0; | drive:\path\filename.xls
Microsoft Excel 4.0 | Excel 4.0; | drive:\path\filename.xls
Microsoft Excel 5.0 or Microsoft Excel 95 | Excel 5.0; | drive:\path\filename.xls
Microsoft Excel 97 | Excel 8.0; | drive:\path\filename.xls
Lotus 1-2-3 WKS and WK1 | Lotus WK1; | drive:\path\filename.wk1
Lotus 1-2-3 WK3 | Lotus WK3; | drive:\path\filename.wk3
Lotus 1-2-3 WK4 | Lotus WK4; | drive:\path\filename.wk4
HTML Import | HTML Import; | drive:\path\filename
HTML Export | HTML Export; | drive:\path
Text | Text; | drive:\path
ODBC | ODBC; DATABASE=database; UID=user; PWD=password; DSN= datasourcename; [LOGINTIMEOUT=seconds;] | None
Microsoft Exchange | Exchange 4.0; MAPILEVEL=folderpath; [TABLETYPE={ 0 | 1 }];[PROFILE=profile;] [PWD=password;] [DATABASE=database;] | drive:\path\filename

If a password is required but not provided in the Connect property setting, a login dialog box is displayed the first time a table is accessed by the ODBC driver and again if the connection is closed and reopened.

For data in Microsoft Exchange, the required MAPILEVEL key should be set to a fully-resolved folder path (for example, "Mailbox - Pat SmithIAlpha/Today"). The path does not include the name of the folder that will be opened as a table; that folder's name should instead be specified as the name argument to the CreateTable method. The TABLETYPE key should be set to "0" to open a folder (default) or "1" to open an address book. The PROFILE key defaults to the profile currently in use.

For base tables in a Micorosoft Access database, the Connect property setting is a zero-length string ("").

Note Note

  • You must set the Connect property before you set the ReturnsRecords property.

  • You must have access permissions to the computer that contains the database server you're trying to access.


Cannot find the executable file for the Synchronizer (mstran40.exe). (Error 3627)

 Copy code hover
[image]

Cannot find the executable file for the Synchronizer (mstran40.exe). (Error 3627)
Send feedback

You are trying to start the Synchronizer and the file Mstran40.exe cannot be found on the specified path.


SQL Data Types

 Copy code hover
[image]

SQL Data Types
Send feedback

The Microsoft Access database engine SQL data types consist of 13 primary data types defined by the Microsoft® Jet database engine and several valid synonyms recognized for these data types.

The following table lists the primary data types. The synonyms are identified in Microsoft Access Database Engine SQL Reserved Words.

Data type | Storage size | Description
BINARY | 1 byte per character | Any type of data may be stored in a field of this type. No translation of the data (for example, to text) is made. How the data is input in a binary field dictates how it will appear as output.
BIT | 1 byte | Yes and No values and fields that contain only one of two values.
TINYINT | 1 byte | An integer value between 0 and 255.
MONEY | 8 bytes | A scaled integer between - 922,337,203,685,477.5808 and 922,337,203,685,477.5807.
DATETIME (See DOUBLE) | 8 bytes | A date or time value between the years 100 and 9999.
UNIQUEIDENTIFIER | 128 bits | A unique identification number used with remote procedure calls.
REAL | 4 bytes | A single-precision floating-point value with a range of - 3.402823E38 to - 1.401298E-45 for negative values, 1.401298E-45 to 3.402823E38 for positive values, and 0.
FLOAT | 8 bytes | A double-precision floating-point value with a range of - 1.79769313486232E308 to - 4.94065645841247E-324 for negative values, 4.94065645841247E-324 to 1.79769313486232E308 for positive values, and 0.
SMALLINT | 2 bytes | A short integer between - 32,768 and 32,767. (See Notes)
INTEGER | 4 bytes | A long integer between - 2,147,483,648 and 2,147,483,647. (See Notes)
DECIMAL | 17 bytes | An exact numeric data type that holds values from 1028 - 1 through - 1028 - 1. You can define both precision (1 - 28) and scale (0 - defined precision). The default precision and scale are 18 and 0, respectively.
TEXT | 2 bytes per character (See Notes) | Zero to a maximum of 2.14 gigabytes.
IMAGE | As required | Zero to a maximum of 2.14 gigabytes. Used for OLE objects.
CHARACTER | 2 bytes per character (See Notes) | Zero to 255 characters.
Note Note

  • Both the seed and the increment can be modified using an ALTER TABLE statement. New rows inserted into the table will have values, based on the new seed and increment values, that are automatically generated for the column. If the new seed and increment can yield values that match values generated based on the preceding seed and increment, duplicates will be generated. If the column is a primary key, then inserting new rows may result in errors when duplicate values are generated.

  • To find the last value that was used for an auto-increment column, you can use the following statement: SELECT @@IDENTITY. You cannot specify a table name. The value returned is from the last table, containing an auto-increment column, that was updated.


HAVING Clause (Microsoft Access SQL)

 Copy code hover
[image]

HAVING Clause (Microsoft Access SQL)
Send feedback

Published: July 16, 2012

Specifies which grouped records are displayed in a SELECT statement with a GROUP BY clause. After GROUP BY combines records, HAVING displays any records grouped by the GROUP BY clause that satisfy the conditions of the HAVING clause.

Syntax

SELECT fieldlist FROM table WHERE selectcriteria GROUP BY groupfieldlist [HAVING groupcriteria]

A SELECT statement containing a HAVING clause has these parts:

Part | Description
fieldlist | The name of the field or fields to be retrieved along with any field-name aliases, SQL aggregate functions, selection predicates (ALL, DISTINCT, DISTINCTROW, or TOP), or other SELECT statement options.
table | The name of the table from which records are retrieved. For more information, see the FROM clause.
selectcriteria | Selection criteria. If the statement includes a WHERE clause, the Microsoft Access database engine groups values after applying the WHERE conditions to the records.
groupfieldlist | The names of up to 10 fields used to group records. The order of the field names in groupfieldlist determines the grouping levels from the highest to the lowest level of grouping.
groupcriteria | An expression that determines which grouped records to display.

Remarks

HAVING is optional.

HAVING is similar to WHERE, which determines which records are selected. After records are grouped with GROUP BY, HAVING determines which records are displayed:

SQL Copy code Copy code
SELECT CategoryID,
Sum(UnitsInStock)
FROM Products
GROUP BY CategoryID
HAVING Sum(UnitsInStock) > 100 And Like "BOS*";

A HAVING clause can contain up to 40 expressions linked by logical operators, such as And and Or.

Example

This example selects the job titles assigned to more than one employee in the Washington region.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

VBA Copy code Copy code
Sub HavingX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Select the job titles assigned to more than one
    ' employee in the Washington region.
    Set rst = dbs.OpenRecordset("SELECT Title, " _
        & "Count(Title) as Total FROM Employees " _
        & "WHERE Region = 'WA' " _
        & "GROUP BY Title HAVING Count(Title) > 1;")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print recordset contents.
    EnumFields rst, 25

    dbs.Close

End Sub


Syntax error in TRANSFORM statement. (Error 3143)

 Copy code hover
[image]

Syntax error in TRANSFORM statement. (Error 3143)
Send feedback

You entered an SQL statement that has an invalid TRANSFORM statement.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


How to: Read From and Write To a Field in a DAO Recordset

 Copy code hover
[image]

How to: Read From and Write To a Field in a DAO Recordset
Send feedback

When you read or write data to a field, you are actually reading or setting the DAO Value property of a Field object. The DAO Value property is the default property of a Field object. Therefore, you can set the DAO Value property of the LastName field in the rstEmployees Recordset in any of the following ways.

VBA Copy code Copy code
rstEmployees!LastName.Value = strName
rstEmployees!LastName = strName
rstEmployees![LastName] = strName

The tables underlying a Recordset object may not permit you to modify data, even though the Recordset is of type dynaset or table, which are usually updatable. Check the Updatable property of the Recordset to determine whether its data can be changed. If the property is True, the Recordset object can be updated.

Individual fields within an updatable Recordset object may not be updatable, and trying to write to these fields generates a run-time error. To determine whether a given field is updatable, check the DataUpdatable property of the corresponding Field object in the Fields collection of the Recordset. The following example returns True if all fields in the dynaset created by strQuery are updatable and returns False otherwise.

VBA Copy code Copy code
Function RecordsetUpdatable(strSQL As String) As Boolean

Dim dbsNorthwind As DAO.Database
Dim rstDynaset As DAO.Recordset
Dim intPosition As Integer

On Error GoTo ErrorHandler

   ' Initialize the function's return value to True.
   RecordsetUpdatable = True

   Set dbsNorthwind = CurrentDb
   Set rstDynaset = dbsNorthwind.OpenRecordset(strSQL, dbOpenDynaset)

   ' If the entire dynaset isn't updatable, return False.
   If rstDynaset.Updatable = False Then
      RecordsetUpdatable = False
   Else
      ' If the dynaset is updatable, check if all fields in the
      ' dynaset are updatable. If one of the fields isn't updatable,
      ' return False.
      For intPosition = 0 To rstDynaset.Fields.Count - 1
         If rstDynaset.Fields(intPosition).DataUpdatable = False Then
            RecordsetUpdatable = False
            Exit For
         End If
      Next intPosition
   End If

   rstDynaset.Close
   dbsNorthwind.Close

   Set rstDynaset = Nothing
   Set dbsNorthwind = Nothing

Exit Sub

ErrorHandler:
   MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Function

Any single field can impose a number of criteria on data in that field when records are added or updated. These criteria are defined by a handful of properties. The DAO AllowZeroLength property on a Text or Memo field indicates whether or not the field will accept a zero-length string (""). The DAO Required property indicates whether or not some value must be entered in the field, or if it instead can accept a Null value. For a Field object on a Recordset, these properties are read-only; their state is determined by the underlying table.

Validation is the process of determining whether data entered into a field's DAO Value property is within an acceptable range. A Field object on a Recordset may have the DAO ValidationRule and ValidationText properties set. The DAO ValidationRule property is simply a criteria expression, similar to the criteria of an SQL WHERE clause, without the WHERE keyword. The DAO ValidationText property is a string that Access displays in an error message if you try to enter data in the field that is outside the limits of the DAO ValidationRule property. If you are using DAO in your code, then you can use the DAO ValidationText for a message that you want to display to the user.

Note Note

The DAO ValidationRule and ValidationText properties also exist at the Recordset level. These are read-only properties, reflecting the table-level validation scheme established on the table from which the current record is retrieved.

A Field object on a Recordset also features the ValidateOnSet property. When the ValidateOnSet property is set to True, Access checks validation as soon as the field's DAO Value property is set. When it is set to False (the default), Access checks validation only when the completed record is updated. For example, if you are adding data to a record that contains a large Memo or OLE Object field and that has the DAO ValidationRule property set, you should determine whether the new data violates the validation rule before trying to write the data. To do so, set the ValidateOnSet property to True. If you wait to check validation until the entire record is written to disk, you may waste time trying to write an invalid record to disk.


The fetch buffer was too small for the amount of data you requested. (Error 3640)

 Copy code hover
[image]

The fetch buffer was too small for the amount of data you requested. (Error 3640)
Send feedback

When performing a GetRows or GetRowsEx method the fetch buffer was too small to contain the specified rows.


TableDefAttributeEnum Enumeration (DAO)

 Copy code hover
[image]

TableDefAttributeEnum Enumeration (DAO)
Send feedback

Used with the Attributes property to determine attributes of a TableDef object.

Name | Value | Description
dbAttachedODBC | 536870912 | Linked ODBC database table.
dbAttachedTable | 1073741824 | Linked non-ODBC database table.
dbAttachExclusive | 65536 | Opens a linked Microsoft Access database engine table for exclusive use.
dbAttachSavePWD | 131072 | Saves user ID and password for linked remote table.
dbHiddenObject | 1 | Hidden table (for temporary use).
dbSystemObject | -2147483646 | System table.


Report.OnLostFocus Property (Access)

 Copy code hover
[image]

Report.OnLostFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Lost Focus box in the Properties window of the specified report. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnLostFocus

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The LostFocus event occurs when the report loses the focus.

The OnLostFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Lost Focus box in the report's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Lost Focus box is blank, the property value is an empty string.

See also

Concepts

Report Object

Other resources

Report Object Members


ListBox.RemoveItem Method (Access)

 Copy code hover
[image]

ListBox.RemoveItem Method (Access)
See also Send feedback

Published: July 16, 2012

Removes an item from the list of values displayed by the specified list box control.

Syntax

expression .RemoveItem(Index)

expression A variable that represents a ListBox object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | The item to be removed from the list, expressed as either an item number or the list item text.

Remarks

This method is only valid for list box or combo box controls on forms. Also, the RowSourceType property of the control must be set to "Value List".

List item numbers start from zero. If the value of the Index argument doesn't correspond to an existing item number or the text of an existing item, an error occurs.

Use the AddItem method to add items to the list of values.

Example

This example removes the specified item from the list in a list box control. For the function to work, you must pass it a ListBox object representing a list box control on a form and a Variant value representing the item to be removed.

VBA Copy code Copy code
Function RemoveListItem(ctrlListBox As ListBox, _
 ByVal varItem As Variant) As Boolean

 ' Trap for errors.
 On Error GoTo ERROR_HANDLER

 ' Remove the list box item and set the return value
 ' to True, indicating success.
 ctrlListBox.RemoveItem Index:=varItem
 RemoveListItem = True

 ' Reset the error trap and exit the function.
 On Error GoTo 0
 Exit Function

' Return False if an error occurs.
ERROR_HANDLER:
 RemoveListItem = False

End Function

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


GetRows Method Example (VB)

 Copy code hover
[image]

GetRows Method Example (VB)
Send feedback

This example uses the GetRows method to retrieve a specified number of rows from a Recordset and to fill an array with the resulting data. The GetRows method will return fewer than the desired number of rows in two cases: either if EOF has been reached, or if GetRows tried to retrieve a record that was deleted by another user. The function returns False only if the second case occurs. The GetRowsOK function is required for this procedure to run.

Copy code Copy code

'BeginGetRowsVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 ' connection and recordset variables
 Dim rstEmployees As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strSQLEmployees As String
 Dim strCnxn As String
 ' array variable
 Dim arrEmployees As Variant
 ' detail variables
 Dim strMessage As String
 Dim intRows As Integer
 Dim intRecord As Integer

 ' open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' open recordset client-side to enable RecordCount
 Set rstEmployees = New ADODB.Recordset
 strSQLEmployees = "SELECT fName, lName, hire_date FROM Employee ORDER BY lName"
 rstEmployees.Open strSQLEmployees, Cnxn, adOpenStatic, adLockReadOnly, adCmdText

 ' get user input for number of rows
 Do
 strMessage = "Enter number of rows to retrieve:"
 intRows = Val(InputBox(strMessage))

 ' if bad user input exit the loop
 If intRows <= 0 Then
 MsgBox "Please enter a positive number", vbOKOnly, "Not less than zero!"
 ' if number of requested records is over the total
 ElseIf intRows > rstEmployees.RecordCount Then
 MsgBox "Not enough records in Recordset to retrieve " & intRows & " rows.", _
 vbOKOnly, "Over the available total"
 Else
 Exit Do
 End If
 Loop

 ' else put the data in an array and print
 arrEmployees = rstEmployees.GetRows(intRows)

 Dim x As Integer, y As Integer

 For x = 0 To intRows - 1
 For y = 0 To 2
 Debug.Print arrEmployees(y, x) & " ";
 Next y
 Debug.Print vbCrLf
 Next x

 ' clean up
 rstEmployees.Close
 Cnxn.Close
 Set rstEmployees = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstEmployees Is Nothing Then
 If rstEmployees.State = adStateOpen Then rstEmployees.Close
 End If
 Set rstEmployees = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndGetRowsVB


NavigationControl.KeyboardLanguage Property (Access)

 Copy code hover
[image]

NavigationControl.KeyboardLanguage Property (Access)
See also Send feedback

Published: July 16, 2012

Version Information

Version Added: Access 2010

Syntax

expression .KeyboardLanguage

expression A variable that represents a NavigationControl object.

Remarks

Valid values for this property are 0 (zero), which corresponds to the default system language, or plid + 2 where plid is the primary language ID of a language installed on the current system. For example, the primary language ID of English is 9, so the corresponding KeyboardLanguage setting is 11. For a list of languages and their primary language IDs, search for "Primary Language IDs" in the MSDN Web site. (An exception to this list is Traditional Chinese which is represented by the value 200.)

Setting this property to a language that is not installed may either have no effect or cause an error.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Could not add rows needed to make the database replicable. (Error 3580)

 Copy code hover
[image]

Could not add rows needed to make the database replicable. (Error 3580)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


ComboBox Properties (Access)

 Copy code hover
[image]

ComboBox Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
AllowAutoCorrect | You can use the AllowAutoCorrect property to specify whetherthe specified control will automatically correct entries made by the user. Read/write Boolean.
AllowValueListEdits | Gets or sets whether the Edit List Items command is available when the user right-clicks a combo box. Read/write Boolean.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoExpand | You can use the AutoExpand property to specify whether Microsoft Access automatically fills the text box portion of a combo box with a value from the combo box list that matches the characters you enter as you type in the combo box. This lets you quickly enter an existing value in a combo box without displaying the list box portion of the combo box. Read/write Boolean.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomMargin | Along with the LeftMargin, RightMargin, and TopMargin properties, specifies the location of information displayed within a text box control. Read/write Integer.
BottomPadding | Gets or sets the amount of space (in inches) between the combo box and its bottom gridline. Read/write Integer.
BoundColumn | When you make a selection from a combo box, the BoundColumn property tells Microsoft Access which column's values to use as the value of the control. If the control is bound to a field, the value in the column specified by the BoundColumn property is stored in the field named in the ControlSource property. Read/write Long.
CanGrow | Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the control contains. Read/write Boolean.
CanShrink | Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the control contains. Read/write Boolean.
Column | You can use the Column property to refer to a specific column, or column and row combination, in a multiple-column combo box or list box. Read-only Variant.
ColumnCount | You can use the ColumnCount property to specify the number of columns displayed in a list box or in the list box portion of a combo box, or sent to OLE objects in a chart control or unbound object frame . Read/write Integer.
ColumnHeads | You can use the ColumnHeads property to display a single row of column headings for list boxes, combo boxes, and OLE objects that accept column headings. You can also use this property to create a label for each entry in a chart control . What is actually displayed as the first-row column heading depends on the object's RowSourceType property setting. Read/write Boolean.
ColumnHidden | You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.
ColumnOrder | You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.
ColumnWidth | You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.
ColumnWidths | You can use the ColumnWidths property to specify the width of each column in a multiple-column combo box. Read/write String.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DecimalPlaces | You can use the DecimalPlaces property to specify the number of decimal places Microsoft Access uses to display numbers. Read/write Byte.
DefaultValue | Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.
DisplayAsHyperlink | Gets or sets an AcDisplayAsHyperlink constant that specifies whether to display the contents of the specified combo box as a hyperlink. Read/write.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontName | You can use the FontName property to specify the font for text in the following situations:
FontSize | You can use the FontSize property to specify the point size for text in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
FontWeight | You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
ForeShade | Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
ForeThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.
ForeTint | Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
Format | You can use the Format property to customize the way numbers, dates, times, and text are displayed and printed. Read/write String.
FormatConditions | You can use the FormatConditions property to return a read-only reference to the FormatConditions collection and its related properties.
GridlineColor | Gets or sets the color of the gridline for the specified combo box. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified combo box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified combo box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified combo box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified combo box. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified combo box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified combo box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified combo box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified combo box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HideDuplicates | You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the combo box is anchored horizontally within its layout. Read/write.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
IMEHold | Language-specific information You can use the IMEHold/Hold KanjiConversionMode property to show whether the Kanji Conversion Mode is maintained when the control loses the focus. Read/write Boolean.
IMEMode |
IMESentenceMode |
InheritValueList | Gets or sets whether a combo box's value list is inherited from its field. Read/write Boolean.
InputMask | You can use the InputMask property to make data entry easier and to control the values users can enter in a combo box control. Read/write String.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsHyperlink | You can use the IsHyperlink property to specify or determine if the data contained in a combo box is a hyperlink. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
ItemData | The ItemData property returns the data in the bound column for the specified row in a combo box. Read-only Variant.
ItemsSelected | You can use the ItemsSelected property to return a read-only reference to the hidden ItemsSelected collection. This hidden collection can be used to access data in the selected rows of a multiselect combo box control.
KeyboardLanguage |
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified combo box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified combo box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftMargin | Along with the TopMargin, RightMargin, and BottomMargin properties, specifies the location of information displayed within a text box control. Read/write Integer. .
LeftPadding | Gets or sets the amount of space (in inches) between the combo box and its left gridline. Read/write Integer.
LimitToList | You can use the LimitToList property to limit a combo box's values to the listed items. Read/write Boolean.
ListCount | You can use the ListCount property to determine the number of rows in the list box portion of a combo box. Read/write Long.
ListIndex | You can use the ListIndex property to determine which item is selected in a combo box. Read/write Long.
ListItemsEditForm | Gets or sets the name of the form that is displayed when the user clicks Edit List Items. Read/write String.
ListRows | You can use the ListRows property to set the maximum number of rows to display in the list box portion of a combo box. Read/write Integer.
ListWidth | You can use the ListWidth property to set the width of the list box portion of a combo box. Read/write String.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
NumeralShapes |
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnChange | Sets or returns the value of the On Change box in the Properties window of one of the objects in the Applies To list. Read/write String.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnDirty | Sets or returns the value of the On Dirty box in the Properties window of a form or report. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnNotInList | Sets or returns the value of the On Not in List box in the Properties window of a combo box. Read/write String.
OnUndo | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the Undo event occurs. Read/write..
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
Recordset | Returns or sets the ADO Recordset or DAO Recordset object representing the record source for the specified object. Read/write Object.
RightMargin | Along with the TopMargin, Left Margin, and BottomMargin properties, specifies the location of information displayed within a combo box control. Read/write Integer.
RightPadding | Gets or sets the amount of space (in inches) between the combo box and its right gridline. Read/write Integer.
RowSource | You can use the RowSource property (along with the RowSourceType property) to tell Microsoft Access how to provide data tothe specified object. Read/write String.
RowSourceType | You can use the RowSourceType property (along with the RowSource property) to tell Microsoft Access how to provide data tothe specified object. Read/write String.
ScrollBarAlign | You can use the ScrollBarAlign to specify or determine the alignment of a vertical scroll bar. Read/write Byte.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
Selected | You can use the Selected property in Visual Basic to determine if an item in a combo box is selected. Read/write Long.
SelLength | The SelLength property specifies or determines the number of characters selected in the text box portion of a combo box. Read/write Integer.
SelStart | The SelStart property specifies or determines the starting point of the selected text or the position of the insertion point if no text is selected. Read/write Integer.
SelText | The SelText property returns a string containing the selected text. Read/write String.
SeparatorCharacters | Gets or sets the separator displayed between values when the combo box is bound to a multi-valued field. Read/write AcSeparatorCharacters.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
ShowOnlyRowSourceValues | Gets or sets whether the combo box can display values that aren't specified by the RowSource property. Read/write Boolean.
SmartTags | Returns a SmartTags collection that represents the collection of smart tags that have been added to a control. .
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Text | You can use the Text property to set or return the text contained in the text box portion of a combo box. Read/write String.
TextAlign | The TextAlign property specifies the text alignment in new controls. Read/write Byte.
ThemeFontIndex | Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopMargin | Along with the LeftMargin, RightMargin, and BottomMargin properties, specifies the location of information displayed within a text box control. Read/write Integer.
TopPadding | Gets or sets the amount of space (in inches) between the combo box and its top gridline. Read/write Integer.
ValidationRule | You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.
ValidationText | Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.
Value | Determines or specifies which value or option in the combo box is selected. Read/write Variant.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified combo box is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


TextBox.ScrollBarAlign Property (Access)

 Copy code hover
[image]

TextBox.ScrollBarAlign Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ScrollBarAlign to specify or determine the alignment of a vertical scroll bar. Read/write Byte.

Syntax

expression .ScrollBarAlign

expression A variable that represents a TextBox object.

Remarks

The ScrollBarAlign property uses the following settings.

Setting | Visual Basic | Description
System | 0 | Vertical scroll bar is placed on the left if the form or report Orientation property is right to left; and on the right if the form or report Orientation property is left to right.
Right | 1 | Aligns vertical scroll bar on the right side of the control.
Left | 2 | Aligns vertical scroll bar on the left side of the control.

Example

The following example aligns the vertical scroll bar on the left side of the "Country" combo box in the "International Shipping" form.

VBA Copy code Copy code
Forms("International Shipping").Controls("Country").ScrollBarAlign = 2

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


BoundObjectFrame.BorderShade Property (Access)

 Copy code hover
[image]

BoundObjectFrame.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents a BoundObjectFrame object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


CommandButton.ReadingOrder Property (Access)

 Copy code hover
[image]

CommandButton.ReadingOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.

Syntax

expression .ReadingOrder

expression A variable that represents a CommandButton object.

Remarks

The ReadingOrder property uses the following settings.

Setting | Visual Basic | Description
Context | 0 | Reading order is determined by the language of the first character entered. If a right-to-left language character is entered first, reading order is right to left. If a left-to-right language character is entered first, reading order is left to right.
Left-to-Right | 1 | Sets the reading order to left to right.
Right-to-Left | 2 | Sets the reading order to right to left.

Example

The following example sets the reading order to right to left for the "Address" text box on the "International Shipping" form.

VBA Copy code Copy code
Forms("International Shipping").Controls("Address").ReadingOrder = 2

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ToggleButton.TopPadding Property (Access)

 Copy code hover
[image]

ToggleButton.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the toggle button and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .TopPadding

expression A variable that represents a ToggleButton object.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


NavigationButton.PressedForeShade Property (Access)

 Copy code hover
[image]

NavigationButton.PressedForeShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .PressedForeShade

expression A variable that represents a NavigationButton object.

Remarks

The PressedForeShade property contains a numeric expression that can be used to darken the theme color in the PressedForeColor property. The default value of the PressedForeShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


> (Greater Than) (Access 2013 custom web app)

 Copy code hover
[image]

> (Greater Than) (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Compares two expressions. When you compare non-null expressions, the result is TRUE if the left operand has a value higher than the right operand; otherwise, the result is FALSE.

Syntax

expression > expression

expression Is any valid expression. Both expressions must have implicitly convertible data types. The conversion depends on the rules of data type precedence.

Return Type

Boolean


TableDef Object Reference (DAO)

 Copy code hover
[image]

TableDef Object Reference (DAO)
Send feedback

In this section

  • TableDef Object (DAO)

  • TableDef Members (DAO)

  • TableDef Properties (DAO)

  • TableDef Methods (DAO)


Using the SetOption Method from DAO

 Copy code hover
[image]

Using the SetOption Method from DAO
Send feedback

Published: July 16, 2012

Microsoft® Windows® Registry settings can be modified at run time with the SetOption method. To customize the Windows Registry settings, you can use the SetOption method from DAO. With this option, your application obtains the maximum flexibility and control. This approach allows you to create applications that are easier to maintain and that are tuned for maximum performance.

The syntax for doing this is dbEngine.SetOption, constant, NewValueSetting. For example, the following syntax, dbEngine.SetOption dbMaxLocksPerfFile, 20000, would allow the Microsoft Access database engine to track 20,000 locks at one time. The names of defined constants are the same as the registry name with db added as a prefix.

This is the recommended way to fine tune registry settings for your application. This method is the most flexible approach and provides you with the most control over how the registry is changed. With The SetOption method you can specify new settings for any of the following default settings:

  • PageTimeout key

  • SharedAsyncDelay key

  • ExclusiveAsyncDelay key

  • LockRetry key

  • UserCommitSync key

  • ImplicitCommitSync key

  • MaxBufferSize key

  • MaxLocksPerFile key

  • LockDelay key

  • RecycleLVs

  • FlushTransactionTimeout key


CheckBox.Exit Event (Access)

 Copy code hover
[image]

CheckBox.Exit Event (Access)
See also Send feedback

Published: July 16, 2012

The Exit event occurs just before a control loses the focus to another control on the same form or report.

Syntax

expression .Exit(Cancel )

expression A variable that represents a CheckBox object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | Set to True to cancel the event.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when this event occurs, set the OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Exit event occurs before the LostFocus event.

Unlike the LostFocus event, the Exit event does not occur when a form loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


AcPrintQuality Enumeration (Access)

 Copy code hover
[image]

AcPrintQuality Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the PrintOut method to specify the print quality of a particular print job.

Name | Value | Description
acDraft | 3 | Draft quality
acHigh | 0 | (Default) High quality
acLow | 2 | Low quality
acMedium | 1 | Medium quality


WebBrowserControl.BorderShade Property (Access)

 Copy code hover
[image]

WebBrowserControl.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents a WebBrowserControl object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BorderColor by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


LTrim Function (Access 2013 custom web app)

 Copy code hover
[image]

LTrim Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns a character expression after it removes leading blanks.

Section Heading

LTrim(TextExpression)

The LTrim function contains the following argument.

Argument Name | Description
TextExpression | A string expression.


You cannot change the data master attribute for the replica set. (Error 3593)

 Copy code hover
[image]

You cannot change the data master attribute for the replica set. (Error 3593)
Send feedback

Whether a replica set allows users to change data at all replicas or only at the Design Master is determined when the database is first converted into a Design Master. After the database has been converted, the single or multiple data master attribute cannot be changed.


PersistFormatEnum

 Copy code hover
[image]

PersistFormatEnum
Send feedback

Specifies the format in which to save a Recordset.

Constant | Value | Description
adPersistADTG | 0 | Indicates Microsoft Advanced Data TableGram (ADTG) format.
adPersistADO | 1 | Indicates that ADO's own Extensible Markup Language (XML) format will be used. This value is the same as adPersistXML and is included for backwards compatibility.
adPersistXML | 1 | Indicates Extensible Markup Language (XML) format.
adPersistProviderSpecific | 2 | Indicates that the provider will persist the Recordset using its own format.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.PersistFormat.ADTG

AdoEnums.PersistFormat.XML


Dimensions Collection (ADO MD)

 Copy code hover
[image]

Dimensions Collection (ADO MD)
Send feedback

Contains the Dimension objects that make up a cube.

Remarks

Dimensions is a standard ADO collection. With the properties and methods of a collection, you can do the following:

  • Obtain the number of objects in the collection with the Count property.

  • Return an object from the collection with the default Item property.

  • Update the objects in the collection from the provider with the Refresh method.


Attachment.OnEnter Property (Access)

 Copy code hover
[image]

Attachment.OnEnter Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Enter box in the Properties window of the specified object. Read/write String. .

Version Information

Version Added: Access 2007

Syntax

expression .OnEnter

expression A variable that represents an Attachment object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Enter event occurs before a control actually receives the focus from a control on the same form.

The OnEnter value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Enter box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Enter box is blank, the property value is an empty string.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


CodeProject.Name Property (Access)

 Copy code hover
[image]

CodeProject.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.

Syntax

expression .Name

expression A variable that represents a CodeProject object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


UniqueRecords Property

 Copy code hover
[image]

UniqueRecords Property
Send feedback

Published: July 16, 2012

You can use the UniqueRecords property to specify whether to return only unique records based on all fields in the underlying data source, not just those fields present in the query itself.

Note Note

The UniqueRecords property applies only to append and make-table action queries and select queries.

Setting

The UniqueRecords property uses the following settings.

Setting | Description
Yes | Doesn't return duplicate records.
No | (Default) Returns duplicate records.

You can set the UniqueRecords property in the query's property sheet or in SQL view of the Query window.

Note Note

You set this property when you create a new query by using an SQL statement. The DISTINCTROW predicate corresponds to the UniqueRecords property setting. The DISTINCT predicate corresponds to the UniqueValues property setting.

Remarks

You can use the UniqueRecords property when you want to omit data based on entire duplicate records, not just duplicate fields. Microsoft Access considers a record to be unique as long as the value in one field in the record differs from the value in the same field in another record.

The UniqueRecords property has an effect only when you use more than one table in the query and select fields from the tables used in the query. The UniqueRecords property is ignored if the query includes only one table.

The UniqueRecords and UniqueValues properties are related in that only one of them can be set to Yes at a time. When you set UniqueRecords to Yes, for example, Microsoft Access automatically sets UniqueValues to No. You can, however, set both of them to No. When both properties are set to No, all records are returned.

Example

The query in this example returns a list of customers from the Customers table who have at least one order in the Orders table.

Customers table

Company name | Customer ID
Ernst Handel | ERNSH
Familia Arquibaldo | FAMIA
FISSA Fabrica Inter. Salchichas S.A. | FISSA
Folies gourmandes | FOLIG

Orders table

Customer ID | Order ID
ERNSH | 10698
FAMIA | 10512
FAMIA | 10725
FOLIG | 10763
FOLIG | 10408

The following SQL statement returns the customer names in the following table:

Copy code Copy code
SELECT DISTINCTROW Customers.CompanyName, Customers.CustomerID
FROM Customers INNER JOIN Orders
ON Customers.CustomerID = Orders.CustomerID;

Customers returned | Customer ID
Ernst Handel | ERNSH
Familia Arquibaldo | FAMIA
Folies gourmandes | FOLIG


Parameters Properties (DAO)

 Copy code hover
[image]

Parameters Properties (DAO)
Send feedback

In this section

  • Parameters.Count Property (DAO)


Filter Property (ADO)

 Copy code hover
[image]

Filter Property (ADO)
Send feedback

Indicates a filter for data in a Recordset.

Settings and Return Values

Sets or returns a Variant value, which can contain one of the following:

  • Criteria string — a string made up of one or more individual clauses concatenated with AND or OR operators.

  • Array of bookmarks — an array of unique bookmark values that point to records in the Recordset object.

  • A FilterGroupEnum value.

Remarks

Use the Filter property to selectively screen out records in a Recordset object. The filtered Recordset becomes the current cursor. Other properties that return values based on the current cursor are affected, such as AbsolutePosition, AbsolutePage, RecordCount, and PageCount. This is because setting the Filter property to a specific value will move the current record to the first record that satisfies the new value.

The criteria string is made up of clauses in the form FieldName-Operator-Value (for example, "LastName = 'Smith'"). You can create compound clauses by concatenating individual clauses with AND (for example, "LastName = 'Smith' AND FirstName = 'John'") or OR (for example, "). You can create compound clauses by concatenating individual clauses with AND (for example, "LastName = 'Smith' AND FirstName = 'John'") or OR (for example, "LastName = 'Smith' OR LastName = 'Jones'"). Use the following guidelines for criteria strings:

  • FieldName must be a valid field name from the Recordset. If the field name contains spaces, you must enclose the name in square brackets.

  • Operator must be one of the following: <, >, <=, >=, <>, =, or LIKE.

  • Value is the value with which you will compare the field values (for example, 'Smith', #8/24/95#, 12.345, or $50.00). Use single quotes with strings and pound signs (#) with dates. For numbers, you can use decimal points, dollar signs, and scientific notation. If Operator is LIKE, Value can use wildcards. Only the asterisk (*) and percent sign (%) wild cards are allowed, and they must be the last character in the string. Value cannot be null.

    Note Note

    To include single quotation marks (') in the filter Value, use two single quotation marks to represent one. For example, to filter on O'Malley, the criteria string should be "col1 = 'O''Malley'". To include single quotation marks at both the beginning and the end of the filter value, enclose the string with pound signs (#). For example, to filter on '1', the criteria string should be "col1 = #'1'#".

  • There is no precedence between AND and OR. Clauses can be grouped within parentheses. However, you cannot group clauses joined by an OR and then join the group to another clause with an AND, like this:

  • Instead, you would construct this filter as

  • In a LIKE clause, you can use a wildcard at the beginning and end of the pattern (for example, LastName Like '*mit*'), or only at the end of the pattern (for example, LastName Like 'Smit*').

The filter constants make it easier to resolve individual record conflicts during batch update mode by allowing you to view, for example, only those records that were affected during the last UpdateBatch method call.

Setting the Filter property itself may fail because of a conflict with the underlying data (for example, a record has already been deleted by another user). In such a case, the provider returns warnings to the Errors collection but does not halt program execution. A run-time error occurs only if there are conflicts on all the requested records. Use the Status property to locate records with conflicts.

Setting the Filter property to a zero-length string ("") has the same effect as using the adFilterNone constant.

Whenever the Filter property is set, the current record position moves to the first record in the filtered subset of records in the Recordset. Similarly, when the Filter property is cleared, the current record position moves to the first record in the Recordset.

See the Bookmark property for an explanation of bookmark values from which you can build an array to use with the Filter property.

Only Filters in the form of Criteria Strings (e.g. OrderDate > '12/31/1999') affect the contents of a persisted Recordset. Filters created with an Array of Bookmarks or using a value from the FilterGroupEnum will not affect the contents of the persisted Recordset. These rules apply to Recordsets created with either client-side or server-side cursors.

Note Note

When you apply the adFilterPendingRecords flag to a filtered and modified Recordset in the batch update mode, the resultant Recordset is empty if the filtering was based on the key field of a single-keyed table and the modification was made on the key field values. The resultant Recordset will be non-empty if one of the following is true:

  • The filtering was based on non-key fields in a single-keyed table.

  • The filtering was based on any fields in a multiple-keyed table.

  • Modifications were made on non-key fields in a single-keyed table.

  • Modifications were made on any fields in a multiple-keyed table.

The following table summarizes the effects of adFilterPendingRecords in different combinations of filtering and modifications. The left column shows the possible modifications; modifications can be made on any of the non-keyed fields, on the key field in a single-keyed table, or on any of the key fields in a multiple-keyed table. The top row shows the filtering criterion; filtering can be based on any of the non-keyed fields, the key field in a single-keyed table, or any of the key fields in a multiple-keyed table. The intersecting cells show the results: + means that applying adFilterPendingRecords results in a non-empty Recordset; - means an empty Recordset.

 | Non keys | Single Key | Multiple Keys
Non keys | + | + | +
Single Key | + | - | N/A
Multiple Keys | + | N/A | +


Min, Max Functions (Microsoft Access SQL)

 Copy code hover
[image]

Min, Max Functions (Microsoft Access SQL)
Send feedback

Published: July 16, 2012

Return the minimum or maximum of a set of values contained in a specified field on a query.

Syntax

Min(expr)

Max(expr)

The expr placeholder represents a string expression identifying the field that contains the data you want to evaluate or an expression that performs a calculation using the data in that field. Operands in expr can include the name of a table field, a constant, or a function (which can be either intrinsic or user-defined but not one of the other SQL aggregate functions).

Remarks

You can use Min and Max to determine the smallest and largest values in a field based on the specified aggregation, or grouping. For example, you could use these functions to return the lowest and highest freight cost. If there is no aggregation specified, then the entire table is used.

You can use Min and Max in a query expression and in the SQL property of a QueryDef object or when creating a Recordset object based on an SQL query.

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Record Order

Example

This example uses the Orders table to return the lowest and highest freight charges for orders shipped to the United Kingdom.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

Copy code Copy code
Sub MinMaxX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Return the lowest and highest freight charges for
    ' orders shipped to the United Kingdom.
    Set rst = dbs.OpenRecordset("SELECT " _
        & "Min(Freight) AS [Low Freight], " _
        & "Max(Freight)AS [High Freight] " _
        & "FROM Orders WHERE ShipCountry = 'UK';")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 12

    dbs.Close

End Sub

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.


Rectangle Control

 Copy code hover
[image]

Rectangle Control
Send feedback

Published: July 16, 2012

The rectangle control displays a rectangle on a form or report.

Remarks

You can move a rectangle and the controls in it as a single unit by dragging the mouse pointer diagonally across the entire rectangle to select all of the controls. The entire selection can then be moved to a new position.


Parameter.Name Property (DAO)

 Copy code hover
[image]

Parameter.Name Property (DAO)
Send feedback

Returns the name of the specified object. Read-only String.

Syntax

expression .Name

expression A variable that represents a Parameter object.


How to: Compact and Repair a Database

 Copy code hover
[image]

How to: Compact and Repair a Database
Send feedback

The following procedure compacts and repairs a database, creates a log if there is any corruption in the source file, and returns a Boolean value based on whether the recovery was successful.

VBA Copy code Copy code
Function RepairDatabase(strSource As String, _
 strDestination As String) As Boolean
 ' Input values: the paths and file names of
 ' the source and destination files.

 ' Trap for errors.
 On Error GoTo error_handler

 ' Compact and repair the database. Use the return value of
 ' the CompactRepair method to determine if the file was
 ' successfully compacted.
 RepairDatabase = _
 Application.CompactRepair( _
 LogFile:=True, _
 SourceFile:=strSource, _
 DestinationFile:=strDestination)

 ' Reset the error trap and exit the function.
 On Error GoTo 0
 Exit Function

' Return False if an error occurs.
error_handler:
 RepairDatabase = False

End Function


Data Access (Access)

 Copy code hover
[image]

Data Access (Access)
Send feedback

In this section

  • Access Data Access How Do I...

  • Structured Query Language (SQL)

  • Data Access Objects (DAO)

  • ActiveX Data Objects (ADO)

  • XML


TabControl.Left Property (Access)

 Copy code hover
[image]

TabControl.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Syntax

expression .Left

expression A variable that represents a TabControl object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Section.MouseMove Event (Access)

 Copy code hover
[image]

Section.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents a Section object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

Section Object

Other resources

Section Object Members


Form.AutoResize Property (Access)

 Copy code hover
[image]

Form.AutoResize Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Boolean indicating whether a Form window opens automatically sized to display complete records. Read/write.

Syntax

expression .AutoResize

expression A variable that represents a Form object.

Remarks

The AutoResize property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) The Form window is automatically sized to display a complete record.
No | False | When opened, the Form window has the last saved size. To save a window's size, open the form, size the window, save the form by clicking Save on the File menu, and close the form or report. When you next open the form or report, it will be the saved window size.

This property can be set only in Design view.

The Form window resizes only if opened in Form view. If you open the form first in Design view or Datasheet view and then change to Form view, the Form window won't resize.

If you make any changes in Design view to a form whose AutoResize property is set to No and whose AutoCenter property is set to Yes, switch to Form view before saving the form. If you don't, Microsoft Access clips the form on the right and bottom edges the next time you open the form.

If the AutoCenter property is set to No, a Form window opens with its upper-left corner in the same location as when it was closed.

See also

Concepts

Form Object

Other resources

Form Object Members


ObjectFrame.InSelection Property (Access)

 Copy code hover
[image]

ObjectFrame.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents an ObjectFrame object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Miscellaneous Topics in Access User Interface

 Copy code hover
[image]

Miscellaneous Topics in Access User Interface
Send feedback

In this section

  • How to: Detect User Idle Time or Inactivity

  • How to: Detect Whether an Object Is Open

  • How to: Display and Use the File Dialog Box

  • How to: Use the Status Bar Progress Meter

  • How to: Create a Shortcut Menu for a Form, Form Control, or Report

  • How to: Use Existing Custom Menus and Toolbars


DateCreated and DateModified Properties Example (VB)

 Copy code hover
[image]

DateCreated and DateModified Properties Example (VB)
Send feedback

This example demonstrates the DateCreated and DateModified properties by adding a new Column to an existing Table and by creating a new Table. The DateOutput procedure is required for this example to run.

Copy code Copy code

' BeginDateCreatedVB
Sub Main()
 On Error GoTo DateCreatedXError

 Dim cat As New ADOX.Catalog
 Dim tblEmployees As ADOX.Table
 Dim tblNewTable As ADOX.Table

 ' Connect the catalog.
 cat.ActiveConnection = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\" & _
 "Microsoft Office\Office\Samples\Northwind.mdb';"

 With cat
 Set tblEmployees = .Tables("Employees")

 ' Print current information about the Employees table.
 DateOutput "Current properties", tblEmployees

 ' Create and append column to the Employees table.
 tblEmployees.Columns.Append "NewColumn", adInteger
 .Tables.Refresh

 ' Print new information about the Employees table.
 DateOutput "After creating a new column", tblEmployees

 ' Delete new column because this is a demonstration.
 tblEmployees.Columns.Delete "NewColumn"

 ' Create and append new Table object to the Northwind database.
 Set tblNewTable = New ADOX.Table
 tblNewTable.Name = "NewTable"
 tblNewTable.Columns.Append "NewColumn", adInteger
 .Tables.Append tblNewTable
 .Tables.Refresh

 ' Print information about the new Table object.
 DateOutput "After creating a new table", .Tables("NewTable")

 ' Delete new Table object because this is a demonstration.
 .Tables.Delete tblNewTable.Name
 End With

 'Clean up
 Set cat.ActiveConnection = Nothing
 Set cat = Nothing
 Exit Sub

DateCreatedXError:
 Set cat = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If

End Sub

Sub DateOutput(strTemp As String, tblTemp As ADOX.Table)
 ' Print DateCreated and DateModified information about
 ' specified Table object.
 Debug.Print strTemp
 Debug.Print " Table: " & tblTemp.Name
 Debug.Print " DateCreated = " & tblTemp.DateCreated
 Debug.Print " DateModified = " & tblTemp.DateModified
 Debug.Print
End Sub
' EndDateCreatedVB


BoundObjectFrame.SourceDoc Property (Access)

 Copy code hover
[image]

BoundObjectFrame.SourceDoc Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SourceDoc property to specify the file to create a link to or to embed when you create a linked object or embedded object by using the Action property in Visual Basic. Read/write String.

Syntax

expression .SourceDoc

expression A variable that represents a BoundObjectFrame object.

Remarks

For an embedded object, enter the full path and file name for the file you want to use as a template and set the Action property to acOLECreateEmbed.

For a linked object, enter the full path and file name of the file to create a link to and set the Action property to acOLECreateLink.

While this property appears in the property sheet, it takes effect only after the Action property is set in a macro or by using Visual Basic.

You can use the SourceDoc property to specify the file to create a link to and the control's SourceItem property to specify the data within that file. If you want to create a link to the entire object, leave the SourceItem property blank.

When a linked unbound object is created, the control's SourceItem property setting is concatenated with its SourceItem property setting. In Form view, Datasheet view, and Print Preview, the control's SourceItem property setting is a zero-length string (" "), and its SourceDoc property setting is the full path to the linked file, followed by an exclamation point (!) or a backslash (\) and the SourceItem property setting, as in the following example:

VBA Copy code Copy code
"C:\Work\Qtr1\Revenue.xls!R1C1:R30C15"

Example

The following example creates a linked OLE object using an unbound object frame named OLE1 and sizes the control to display the object's entire contents when the user clicks a command button.

VBA Copy code Copy code
Sub Command1_Click
 OLE1.Class = "Excel.Sheet" ' Set class name.
 ' Specify type of object.
 OLE1.OLETypeAllowed = acOLELinked
 ' Specify source file.
 OLE1.SourceDoc = "C:\Excel\Oletext.xls"
 ' Specify data to create link to.
 OLE1.SourceItem = "R1C1:R5C5"
 ' Create linked object.
 OLE1.Action = acOLECreateLink
 ' Adjust control size.
 OLE1.SizeMode = acOLESizeZoom
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


CustomControl.InSelection Property (Access)

 Copy code hover
[image]

CustomControl.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents a CustomControl object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Recordset2.Filter Property (DAO)

 Copy code hover
[image]

Recordset2.Filter Property (DAO)
Send feedback

Sets or returns a value that determines the records included in a subsequently opened Recordset object (Microsoft Access workspaces only). Read/write String.

Syntax

expression .Filter

expression An expression that returns a Recordset2 object.

Remarks

The setting or return value is a String data type that contains the WHERE clause of an SQL statement without the reserved word WHERE.

Use the Filter property to apply a filter to a dynaset-, snapshot-, or forward-only-type Recordset object.

You can use the Filter property to restrict the records returned from an existing object when a new Recordset object is opened based on an existing Recordset object.

Use the U.S. date format (month-day-year) when you filter fields containing dates, even if you're not using the U.S. version of the Microsoft Access database engine (in which case you must assemble any dates by concatenating strings, for example, strMonth & "-" & strDay & "-" & strYear). Otherwise, the data may not be filtered as you expect.

In many cases, it's faster to open a new Recordset object by using an SQL statement that includes a WHERE clause.

If you set the property to a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strFilter = "PRICE > " & lngPrice, and lngPrice = 125,50), an error occurs when you try to open the next Recordset. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and Microsoft Access SQL only accepts U.S. decimal characters.


Syntax error in string. (Error 2422)

 Copy code hover
[image]

Syntax error in string. (Error 2422)
Send feedback

You entered an expression that includes an invalid string. Check the expression to make sure you entered it correctly.


TextBox.Exit Event (Access)

 Copy code hover
[image]

TextBox.Exit Event (Access)
See also Send feedback

Published: July 16, 2012

The Exit event occurs just before a control loses the focus to another control on the same form or report.

Syntax

expression .Exit(Cancel)

expression A variable that represents a TextBox object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | Set to True to cancel the event.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when this event occurs, set the OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Exit event occurs before the LostFocus event.

Unlike the LostFocus event, the Exit event does not occur when a form loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


BoundObjectFrame.Application Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a BoundObjectFrame object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Printing in Access Reports

 Copy code hover
[image]

Printing in Access Reports
Send feedback

In this section

  • How to: Retrieve a List of Installed Printers


Invalid Date setting in the Xbase key of the Windows Registry. (Error 3213)

 Copy code hover
[image]

Invalid Date setting in the Xbase key of the Windows Registry. (Error 3213)
Send feedback

There is an invalid Date setting in the Xbase key of the Microsoft Windows Registry.

To fix the Date setting

  1. Exit your application.

  2. Start the Registry Editor, navigate to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Access Connectivity Engine\Engines\Xbase key, and select the Date value.

  3. On the Edit menu, click Modify.

  4. Correct the Date data in the Value data box.

  5. Restart your application, and then try the operation again.


CheckBox.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

CheckBox.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents a CheckBox object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.BorderThemeColorIndex=2

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


RuleEnum

 Copy code hover
[image]

RuleEnum
Send feedback

Specifies the rule to follow when a Key is deleted.

Constant | Value | Description
adRICascade | 1 | Cascade changes.
adRINone | 0 | Default. No action is taken.
adRISetDefault | 3 | Foreign key value is set to the default.
adRISetNull | 2 | Foreign key value is set to null.


CheckBox.StatusBarText Property (Access)

 Copy code hover
[image]

CheckBox.StatusBarText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.

Syntax

expression .StatusBarText

expression A variable that represents a CheckBox object.

Remarks

You set the StatusBarText property by using a string expression up to 255 characters long.

Note Note

The length of the text you can display in the status bar depends on your computer hardware and video display.

You can use the StatusBarText property to provide specific information about a control. For example, when a text box has the focus, a brief instruction can tell the user what kind of data to enter

Note Note

You can also use the ControlTipText property to display a ScreenTip for a control.

If you create a control by dragging a field from the field list, the value in a field's Description property is copied to the StatusBarText property.

Example

The following example sets the status bar text to be displayed when the "Address_TextBox" control in the "Mailing List" form has the focus in Form View.

VBA Copy code Copy code
Forms("Mailing List").Controls("Address_TextBox"). _
 StatusBarText = "Enter the company's mailing address."

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Form.FrozenColumns Property (Access)

 Copy code hover
[image]

Form.FrozenColumns Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FrozenColumns property to determine how many columns in a datasheet are frozen. Read/write Integer.

Syntax

expression .FrozenColumns

expression A variable that represents a Form object.

Remarks

Frozen columns are displayed on the left side of the datasheet and don't move when you scroll horizontally through the datasheet.

Note Note

The FrozenColumns property applies only to tables, forms, and queries in Datasheet view.

In Visual Basic, this property setting is an Integer value indicating the number of columns in the datasheet that have been frozen by using the Freeze Columns command. The record selector column is always frozen, so the default value is 1. Consequently, if you freeze one column, the FrozenColumns property is set to 2; if you freeze two columns, it's set to 3; and so on.

Example

The following example uses the FrozenColumns property to determine how many columns are frozen in a table in Datasheet view. If more than three columns are frozen, the table size is maximized so you can see as many unfrozen columns as possible.

VBA Copy code Copy code
Sub CheckFrozen(strTableName As String)
 Dim dbs As Object
 Dim tdf As Object
 Dim prp As Variant
 Const DB_Integer As Integer = 3
 Const conPropertyNotFound = 3270 ' Property not found error.
 Set dbs = CurrentDb ' Get current database.
 Set tdf = dbs.TableDefs(strTableName) ' Get object for table.
 DoCmd.OpenTable strTableName, acNormal ' Open table.
 tdf.Properties.Refresh
 On Error GoTo Frozen_Err
 If tdf.Properties("FrozenColumns") > 3 Then ' Check property.
 DoCmd.Maximize
 End If
Frozen_Bye:
 Exit Sub
Frozen_Err:
 If Err = conPropertyNotFound Then ' Property not in collection.
 Set prp = tdf.CreateProperty("FrozenColumns", DB_Integer, 1)
 tdf.Properties.Append prp
 Resume Frozen_Bye
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


OptionGroup.ColumnWidth Property (Access)

 Copy code hover
[image]

OptionGroup.ColumnWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.

Syntax

expression .ColumnWidth

expression A variable that represents an OptionGroup object.

Remarks

In Visual Basic , the ColumnWidth property setting is an Integer value that represents the column width in twips. You can specify a width or use one of the following predefined settings.

Setting | Description
0 | Hides the column.
-1 | (Default) Sizes the column to the default width.
Note Note

The ColumnWidth property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

Setting this property to 0, or resizing the field to a zero width in Datasheet view, sets the field's ColumnHidden property to True (-1) and hides the field in Datasheet view.

Setting a field's ColumnHidden property to False (0) restores the field's ColumnWidth property to the value it had before the field was hidden. For example, if the ColumnWidth property was -1 prior to the field being hidden by setting the property to 0, changing the field's ColumnHidden property to False resets the ColumnWidth to -1.

The ColumnWidth property for a field isn't available when the field's ColumnHidden property is set to True.

Example

This example takes effect in Datasheet view of the open Customers form. It sets the row height to 450 twips and sizes the column to fit the size of the visible text.

VBA Copy code Copy code
Forms![Customers].RowHeight = 450
Forms![Customers]![Address].ColumnWidth = -2

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


ADO Events Reference

 Copy code hover
[image]

ADO Events Reference
Send feedback

In this section

  • ADO Events

  • BeginTransComplete, CommitTransComplete, and RollbackTransComplete Events (ADO)

  • ConnectComplete and Disconnect Events (ADO)

  • EndOfRecordset Event (ADO)

  • ExecuteComplete Event (ADO)

  • FetchComplete Event (ADO)

  • FetchProgress Event (ADO)

  • InfoMessage Event (ADO)

  • WillChangeField and FieldChangeComplete Events (ADO)

  • WillChangeRecord and RecordChangeComplete Events (ADO)

  • WillChangeRecordset and RecordsetChangeComplete Events (ADO)

  • WillConnect Event (ADO)

  • WillExecute Event (ADO)

  • WillMove and MoveComplete Events (ADO)


Workspace Properties (DAO)

 Copy code hover
[image]

Workspace Properties (DAO)
Send feedback

In this section

  • Workspace.Connections Property (DAO)

  • Workspace.Databases Property (DAO)

  • Workspace.DefaultCursorDriver Property (DAO)

  • Workspace.IsolateODBCTrans Property (DAO)

  • Workspace.LoginTimeout Property (DAO)

  • Workspace.Name Property (DAO)

  • Workspace.Properties Property (DAO)

  • Workspace.Type Property (DAO)


Attachment.Change Event (Access)

 Copy code hover
[image]

Attachment.Change Event (Access)
See also Send feedback

Published: July 16, 2012

The Change event occurs when the contents of the specified control change.

Version Information

Version Added: Access 2007

Syntax

expression .Change

expression A variable that represents an Attachment object.

Return Value

nothing

Remarks

Note Note

  • Setting the value of a control by using a macro or Visual Basic doesn't trigger this event for the control. You must type the data directly into the control, or set the control's Text property.

  • This event applies only to controls on a form, not controls on a report.

To run a macro or event procedure when this event occurs, set the OnChange property to the name of the macro or to [Event Procedure].

By running a macro or event procedure when a Change event occurs, you can coordinate data display among controls. You can also display data or a formula in one control and the results in another control.

The Change event doesn't occur when a value changes in a calculated control.

Note Note

A Change event can cause a cascading event. This occurs when a macro or event procedure that runs in response to the control's Change event alters the control's contents — for example, by changing a property setting that determines the control's value, such as the Text property for a text box. To prevent a cascading event:

  • If possible, avoid attaching a Change macro or event procedure to a control that alters the control's contents.

  • Avoid creating two or more controls having Change events that affect each other — for example, two text boxes that update each other.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


CustomControl.OnLostFocus Property (Access)

 Copy code hover
[image]

CustomControl.OnLostFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnLostFocus

expression A variable that represents a CustomControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The LostFocus event occurs when the object loses the focus.

The OnLostFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Lost Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Lost Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnLostFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnLostFocus

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


IN Clause (Microsoft Access SQL)

 Copy code hover
[image]

IN Clause (Microsoft Access SQL)
Send feedback

Published: July 16, 2012

Identifies tables in any external database to which the Microsoft Access database engine can connect, such as a dBASE or Paradox database or an external Microsoft® Access database engine database.

Syntax

To identify a destination table:

[SELECT | INSERT] INTO destination IN {path | ["path" "type"] | ["" [type; DATABASE = path]]}

To identify a source table:

FROM tableexpression IN {path | ["path" "type"] | ["" [type; DATABASE = path]]}

A SELECT statement containing an IN clause has these parts:

Part | Description
destination | The name of the external table into which data is inserted.
tableexpression | The name of the table or tables from which data is retrieved. This argument can be a single table name, a saved query, or a compound resulting from an INNER JOIN, LEFT JOIN, or RIGHT JOIN.
path | The full path for the directory or file containing table.
type | The name of the database type used to create table if a database is not a Microsoft Access database engine database (for example, dBASE III, dBASE IV, Paradox 3.x, or Paradox 4.x).

Remarks

You can use IN to connect to only one external database at a time.

In some cases, the path argument refers to the directory containing the database files. For example, when working with dBASE, Microsoft FoxPro®, or Paradox database tables, the path argument specifies the directory containing .dbf or .db files. The table file name is derived from the destination or tableexpression argument.

To specify a non-Microsoft Access database engine database, append a semicolon (;) to the name, and enclose it in single (' ') or double (" ") quotation marks. For example, either 'dBASE IV;' or "dBASE IV;" is acceptable.

You can also use the DATABASE reserved word to specify the external database. For example, the following lines specify the same table:

SQL Copy code Copy code
…FROM Table IN "" [dBASE IV; DATABASE=C:\DBASE\DATA\SALES;];

…FROM Table IN "C:\DBASE\DATA\SALES" "dBASE IV;"
Note Note

  • For improved performance and ease of use, use a linked table instead of IN.

  • You can also use the IN reserved word as a comparison operator in an expression. For more information, see the In operator.

Example

The following table shows how you can use the IN clause to retrieve data from an external database. In each example, assume the hypothetical Customers table is stored in an external database.

External database

SQL statement

Microsoft® Access atabase engine database

Copy code Copy code
SELECT CustomerID
FROM Customers
IN OtherDB.mdb
WHERE CustomerID Like "A*";

dBASE III or IV. To retrieve data from a dBASE III table, substitute "dBASE III;" for "dBASE IV;".

Copy code Copy code
SELECT CustomerID
FROM Customer
IN "C:\DBASE\DATA\SALES" "dBASE IV;"
WHERE CustomerID Like "A*";

dBASE III or IV using Database syntax.

Copy code Copy code
SELECT CustomerID
FROM Customer
IN "" [dBASE IV; Database=C:\DBASE\DATA\SALES;]
WHERE CustomerID Like "A*";

Paradox 3.x or 4.x. To retrieve data from a Paradox version 3.x table, substitute "Paradox 3.x;" for "Paradox 4.x;".

Copy code Copy code
SELECT CustomerID
FROM Customer
IN "C:\PARADOX\DATA\SALES" "Paradox 4.x;"
WHERE CustomerID Like "A*";

Paradox 3.x or 4.x using Database syntax

Copy code Copy code
SELECT CustomerID
FROM Customer
IN "" [Paradox 4.x;Database=C:\PARADOX\DATA\SALES;]
WHERE CustomerID Like "A*";

A Microsoft Excel worksheet

Copy code Copy code
SELECT CustomerID, CompanyName
FROM [Customers$]
IN "c:\documents\xldata.xls" "EXCEL 5.0;"
WHERE CustomerID Like "A*"
ORDER BY CustomerID;

A named range in a worksheet

Copy code Copy code
SELECT CustomerID, CompanyName
FROM CustomersRange
IN "c:\documents\xldata.xls" "EXCEL 5.0;"
WHERE CustomerID Like "A*"
ORDER BY CustomerID;


CustomControl.LeftPadding Property (Access)

 Copy code hover
[image]

CustomControl.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .LeftPadding

expression A variable that represents a CustomControl object.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


There are no scheduled synchronizations between the two Synchronizers. (Error 3495)

 Copy code hover
[image]

There are no scheduled synchronizations between the two Synchronizers. (Error 3495)
Send feedback

The schedule between two Synchronizers has been deleted or you are attempting to set a schedule between the Synchronizer on your computer and itself. Use the Replication Manager to set the schedule with the correct Synchronizer.


Attachment.OnDblClick Property (Access)

 Copy code hover
[image]

Attachment.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnDblClick

expression A variable that represents an Attachment object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Resync Command Property--Dynamic (ADO)

 Copy code hover
[image]

Resync Command Property--Dynamic (ADO)
Send feedback

Specifies a user-supplied command string that the Resync method issues to refresh the data in the table named in the Unique Table dynamic property.

Settings and Return Values

Sets or returns a String value which is a command string.

Remarks

The Recordset object is the result of a JOIN operation executed on multiple base tables. The rows affected depend on the AffectRecords parameter of the Resync method. The standard Resync method is executed if the Unique Table and Resync Command properties are not set.

The command string of the Resync Command property is a parameterized command or stored procedure that uniquely identifies the row being refreshed, and returns a single row containing the same number and order of columns as the row to be refreshed. The command string contains a parameter for each primary key column in the Unique Table; otherwise, a run-time error is returned. The parameters are automatically filled in with primary key values from the row to be refreshed.

Here are two examples based on SQL:

1) The Recordset is defined by a command:

SQL Copy code Copy code
SELECT * FROM Customers JOIN Orders ON
   Customers.CustomerID = Orders.CustomerID
   WHERE city = Seattle
   ORDER BY CustomerID

The Resync Command property is set to:

SQL Copy code Copy code
"SELECT * FROM
   (SELECT * FROM Customers JOIN Orders
   ON Customers.CustomerID = Orders.CustomerID
   city = Seattle ORDER BY CustomerID)
WHERE Orders.OrderID = ?"

The Unique Table is Orders and its primary key, OrderID, is parameterized. The sub-select provides a simple way to programmatically ensure that the same number and order of columns are returned as by the original command.

2) The Recordset is defined by a stored procedure:

SQL Copy code Copy code
CREATE PROC Custorders @CustomerID char(5) AS
SELECT * FROM Customers JOIN Orders ON
Customers.CustomerID = Orders.CustomerID
WHERE Customers.CustomerID = @CustomerID

The Resync method should execute the following stored procedure:

SQL Copy code Copy code
CREATE PROC CustordersResync @ordid int AS
SELECT * FROM Customers JOIN Orders ON
Customers.CustomerID = Orders.CustomerID
WHERE Orders.ordid  = @ordid

The Resync Command property is set to:

Copy code Copy code
"{call CustordersResync (?)}"

Once again, the Unique Table is Orders and its primary key, OrderID, is parameterized.

Resync Command is a dynamic property appended to the Recordset object Properties collection when the CursorLocation property is set to adUseClient.


Open and Close Methods Example (VB)

 Copy code hover
[image]

Open and Close Methods Example (VB)
Send feedback

This example uses the Open and Close methods on both Recordset and Connection objects that have been opened.

Copy code Copy code

'BeginOpenVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub OpenX()
 On Error GoTo ErrorHandler

 Dim Cnxn As ADODB.Connection
 Dim rstEmployees As ADODB.Recordset
 Dim strCnxn As String
 Dim strSQLEmployees As String
 Dim varDate As Variant

 ' Open connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Set Cnxn = New ADODB.Connection
 Cnxn.Open strCnxn

 ' Open employee table
 Set rstEmployees = New ADODB.Recordset
 strSQLEmployees = "employee"
 rstEmployees.Open strSQLEmployees, Cnxn, adOpenKeyset, adLockOptimistic, adCmdTable

 ' Assign the first employee record's hire date
 ' to a variable, then change the hire date
 varDate = rstEmployees!hire_date
 Debug.Print "Original data"
 Debug.Print " Name - Hire Date"
 Debug.Print " " & rstEmployees!fname & " " & _
 rstEmployees!lname & " - " & rstEmployees!hire_date
 rstEmployees!hire_date = #1/1/1900#
 rstEmployees.Update
 Debug.Print "Changed data"
 Debug.Print " Name - Hire Date"
 Debug.Print " " & rstEmployees!fname & " " & _
 rstEmployees!lname & " - " & rstEmployees!hire_date

 ' Requery Recordset and reset the hire date
 rstEmployees.Requery
 rstEmployees!hire_date = varDate
 rstEmployees.Update
 Debug.Print "Data after reset"
 Debug.Print " Name - Hire Date"
 Debug.Print " " & rstEmployees!fname & " " & _
 rstEmployees!lname & " - " & rstEmployees!hire_date

 ' clean up
 rstEmployees.Close
 Cnxn.Close
 Set rstEmployees = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstEmployees Is Nothing Then
 If rstEmployees.State = adStateOpen Then rstEmployees.Close
 End If
 Set rstEmployees = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndOpenVB


TabControl.TabIndex Property (Access)

 Copy code hover
[image]

TabControl.TabIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.

Syntax

expression .TabIndex

expression A variable that represents a TabControl object.

Remarks

You can set the TabIndex property to an integer representing the position of the control within the tab order of the form. Valid settings are 0 for the first tab position, up to the total number of controls minus 1 for the last tab position. For example, if a form has three controls that each have a TabIndex property, valid TabIndex property settings are 0, 1, and 2.

Setting the TabIndex property to an integer less than 0 produces an error.

By default, Microsoft Access assigns a tab order to controls in the order that you create them on a form. Each new control is placed last in the tab order. If you change the setting of a control's TabIndex property to adjust the tab order, Microsoft Access automatically renumbers the TabIndex property setting of other controls to reflect insertions and deletions.

In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the TAB key.

Changing the tab order of other controls on the form doesn't affect what happens when you press a control's access key. For example, if you've created an access key for the label of a text box, the focus will move to the text box whenever you press the label's access key — even if you change the TabIndex property setting for the text box.

If you press an access key for a control such as a label that doesn't have a TabIndex property (and thus isn't in the tab order), the focus moves to the next control in the tab order that can receive the focus.

Example

The following example reverses the tab order of a command button and a text box. Because TextBox1 was created first, it has a TabIndex property setting of 0 and Command1 has a setting of 1.

VBA Copy code Copy code
Sub Form_Click()
 Me!Command1.TabIndex = 0
 Me!TextBox1.TabIndex = 1
End Sub

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


DataSource Property (ADO)

 Copy code hover
[image]

DataSource Property (ADO)
Send feedback

Indicates an object that contains data to be represented as a Recordset object.

Remarks

This property is used to create data-bound controls with the Data Environment. The Data Environment maintains collections of data (data sources) containing named objects (data members) that will be represented as a Recordset object.

The DataMember and DataSource properties must be used in conjunction.

The object referenced must implement the IDataSource interface and must contain an IRowset interface.

Usage

Copy code Copy code
Dim rs as New ADODB.Recordset
rs.DataMember = "Command"     'Name of the rowset to bind to
Set rs.DataSource = myDE      'Name of the object containing an IRowset


Visual J++

 Copy code hover
[image]

Visual J++
Send feedback

This short Microsoft Visual J++ example shows how you can associate your own function with a particular event.

Copy code Copy code

// BeginEventExampleVJ
import com.ms.wfc.data.*;

public class EventExampleVJ
{
 ConnectionEventHandler handler = new ConnectionEventHandler(this,"onConnectComplete");

 public void onConnectComplete(Object sender,ConnectionEvent e)
 {
 if (e.adStatus == AdoEnums.EventStatus.ERRORSOCCURRED)
 System.out.println("Connection failed");
 else
 System.out.println("Connection completed");
 return;
 }

 public static void main (String[] args)
 {
 EventExampleVJ Class1 = new EventExampleVJ();
 Connection conn = new Connection();

 conn.addOnConnectComplete(Class1.handler); // Enable event support.
 conn.open("DSN=Pubs");
 conn.close();
 conn.removeOnConnectComplete(Class1.handler); // Disable event support.
 }
}
// EndEventExampleVJ

First, the class method onConnectionComplete is associated with the ConnectionComplete event by creating a new ConnectionEventHandler object and assigning the onConnectComplete function to the object.

The main function then creates a Connection object and enables event handling by calling the addOnConnectComplete method and passing it the address of the handler function.


Report Properties (Access)

 Copy code hover
[image]

Report Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
ActiveControl | You can use the ActiveControl property together with the Screen object to identify or refer to the control that has the focus. Read-only Control object.
AllowLayoutView | Gets or sets whether the specified report can be used in Layout View. Read/write Boolean.
AllowReportView | Gets or sets whether the user is allowed to enter Report view while using the specified report. Read/write Boolean.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoCenter | Returns or sets a Boolean indicating whether a report will be centered automatically in the application window when the form is opened. Read/write.
AutoResize | Returns or sets a Boolean indicating whether a Report window opens automatically sized to display complete records. Read/write.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
Caption | Gets or sets the title of the report in Print Preview. Read/write String.
CloseButton | Specifies whether the Close button on a form is enabled. Read/write Boolean.
ControlBox | Specifies whether a report has a Control menu in Report view. Read/write Boolean.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Integer.
CurrentRecord | You can use the CurrentRecord property to identify the current record in the recordset being viewed. Read/write Long.
CurrentView | You can use the CurrentView property to determine how a report is currently displayed. Read/write Integer.
CurrentX | You can use the CurrentX property (along with the CurrentY property) to specify the horizontal and vertical coordinates for the starting position of the next printing and drawing method on a report. Read/write Single.
CurrentY | You can use the CurrentY property (along with the CurrentX property) to specify the horizontal and vertical coordinates for the starting position of the next printing and drawing method on a report. Read/write Single.
Cycle | You can use the Cycle property to specify what happens when you press the TAB key and the focus is in the last control on a report. Read/write Byte.
DateGrouping | You can use the DateGrouping property to specify how you want to group dates in a report. Read/write Byte.
DefaultControl | The DefaultControl property returns a Control object with which you can set the default properties for a particular type of control on a particular report. Read-only.
DefaultView | You can use the DefaultView property to specify the opening view of a report. Read/write Byte.
Dirty | You can use the Dirty property to determine whether the current record has been modified since it was last saved. Read/write Boolean.
DisplayOnSharePointSite | Gets or sets whether the specified report can be made available as a view on a Microsoft SharePoint Foundation site. Read/write Byte.
DrawMode | You can use the DrawMode property to specify how the pen (the color used in drawing) interacts with existing background colors on a report when the Line , Circle , or Pset method is used to draw on a report when printing. Read/write Integer.
DrawStyle | You can use the DrawStyle property to specify the line style when using the Line and Circle methods to print lines on reports. Read/write Integer.
DrawWidth | You can use the DrawWidth property to specify the line width for the Line , Circle , and Pset methods to print lines on reports. Read/write Integer.
FastLaserPrinting | You can use the FastLaserPrinting property to specify whether lines and rectangles are replaced by text character lines — similar to the underscore (_) and vertical bar (|) characters — when you print a report using most laser printers. Replacing lines and rectangles with text character lines can make printing much faster. Read/write Boolean.
FillColor | You use the FillColor property to specify the color that fills in boxes and circles drawn on reports with the Line and Circle methods. You can also use this property with Visual Basic to create special visual effects on custom reports when you print using a color printer or preview the reports on a color monitor. Read/write Long.
FillStyle | You can use the FillStyle property to specify whether a circle or line drawn by the Circle or Line method on a report is transparent, opaque, or filled with a pattern. Read/write Integer.
Filter | You can use the Filter property to specify a subset of records to be displayed when a filter is applied to a form, reportquery, or table. Read/write String.
FilterOn | You can use the FilterOn property to specify or determine whether the Filter property for a form or report is applied. Read/write Boolean.
FilterOnLoad | Gets or sets whether the filter specified by the Filter property is applied when the report is loaded. Read/write Boolean.
FitToPage | Gets or sets whether the width of the specified report is sized to automatically fit the page. Read/write Boolean.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontName | You can use the FontName property to specify the font for text in the following situations:
FontSize | You can use the FontSize property to specify the point size for text in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
FormatCount | You can use the FormatCount property to determine the number of times the OnFormat property has been evaluated for the current section on a report. Read/write Integer.
GridX | You can use the GridX property (along with the GridY property) to specify the horizontal and vertical divisions of the alignment grid in report Design view. Read/write Integer.
GridY | You can use the GridY property (along with the GridX property) to specify the horizontal and vertical divisions of the alignment grid in report Design view. Read/write Integer.
GroupLevel | You can use the GroupLevel property in Visual Basic to refer to the group level you are grouping or sorting on in a report. Read-only GroupLevel object.
GrpKeepTogether | You can use the GrpKeepTogether property to specify whether groups in a multiple column report that have their KeepTogether property for a group set to Whole Group or With First Detail will be kept together by page or by column. Read/write Byte.
HasData | You can use the HasData property to determine if a report is bound to an empty recordset. Read/write Long.
HasModule | You can use the HasModule property to specify or determine whether a form or report has a class module. Read/write Boolean.
Height | Gets or sets the height of the specified object in twips. Read/write Long.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HelpFile | The name of a help file associated with a report. Read/write String.
Hwnd | You can use the hWnd property to determine the handle (a unique Long Integer value) assigned by Microsoft Windows to the current window. Read/write Long.
InputParameters | You can use the InputParameters property to specify or determine the input parameters that are passed to a SQL statement in the RecordSource property of a form or report or a stored procedure when used as the record source within a Microsoft Access project (.adp). Read/write String.
KeyPreview | You can use the KeyPreview property to specify whether the report-level keyboard event procedures are invoked before a control's keyboard event procedures. Read/write Boolean.
LayoutForPrint | You can use the LayoutForPrint property to specify whether the report uses printer or screen fonts. Read/write Boolean.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Long.
MenuBar | Specifies a custom menu to display for a report. Read/write String.
MinMaxButtons | You can use the MinMaxButtons property to specify whether the Maximize and Minimize buttons will be visible on a report. Read/write Byte.
Modal | You can use the Modal property to specify whether a report opens as a modal window. When a report opens as a modal window, you must close the window before you can move the focus to another object. Read/write Boolean.
Module | You can use the Module property to specify a report module. Read-only Module object.
MouseWheel | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the MouseWheel event occurs. Read/write.
Moveable | Returns or sets a Boolean indicating whether the specified report can be moved by the user; True if it can be moved. Read/write.
MoveLayout | The MoveLayout property specifies whether Microsoft Access should move to the next printing location on the page. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
NextRecord | The NextRecord property specifies whether a section should advance to the next record. Read/write Boolean.
OnActivate | Sets or returns the value of the On Activate box in the Properties window of a form or report. Read/write String.
OnApplyFilter | Sets or returns the value of the On Apply Filter box in the Properties window of a report. Read/write String.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnClose | Sets or returns the value of the On Close box in the Properties window of a form or report. Read/write String.
OnCurrent | Sets or returns the value of the On Current box in the Properties window of a report. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnDeactivate | Sets or returns the value of the On Deactivate box in the Properties window of a form or report. Read/write String.
OnError | Sets or returns the value of the OnError box in the Properties window of a form or report. Read/write String.
OnFilter | Sets or returns the value of the On Filter box in the Properties window of a report. Read/write String.
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified report. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLoad | Sets or returns the value of the On Load box in the Properties window of a report. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified report. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnNoData | Sets or returns the value of the On No Data box in the Properties window of a report. Read/write String.
OnOpen | Sets or returns the value of the On Open box in the Properties window of a form or report. Read/write String.
OnPage | Sets or returns the value of the On Page box in the Properties window of a report. Read/write String.
OnResize | Sets or returns the value of the On Resize box in the Properties window of a report. Read/write String.
OnTimer | Sets or returns the value of the On Timer box in the Properties window of a form. Read/write String.
OnUnload | Sets or returns the value of the On Unload box in the Properties window of a form. Read/write String.
OpenArgs | Determines the string expression specified by the OpenArgs argument of the OpenReport method that opened a Report. Read/write Variant.
OrderBy | You can use the OrderBy property to specify how you want to sort records in a report. Read/write String.
OrderByOn | You can use the OrderByOn property to specify whether an object's OrderBy property setting is applied. Read/write Boolean.
OrderByOnLoad | Gets or sets whether the sorting specified by the OrderBy property is applied when the report is loaded. Read/write Boolean.
Orientation | You can use the Orientation property to specify or determine the view orientation. Read/write Byte.
Page | The Page property specifies the current page number when a report is being printed. Read/write Long.
PageFooter | You can use the PageFooter property to specify whether a report's page footer is printed on the same page as a report footer. Read/write Byte.
PageHeader | You can use the PageHeader property to specify whether a report's page header is printed on the same page as a report header. Read/write Byte.
Pages | You can use the Pages property to return information needed to print page numbers in a report. Read/write Integer.
Painting | You can use the Painting property to specify whether a report is repainted. Read/write Boolean.
PaintPalette | You can use the PaintPalette property to specify a palette to be used by a report. Read/write Variant.
PaletteSource | You can use the PaletteSource property to specify the palette for a report. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Picture | You can use the Picture property to specify a bitmap or other type of graphic to be used as a background picture on a report. Read/write String.
PictureAlignment | You can use the PictureAlignment property to specify where a background picture will appear in an image control or on a form or report. Read/write Byte.Read/write.
PictureData | You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.
PicturePages | You can use the PicturePages property to specify on which page or pages of a report a picture will be displayed. Read/write Byte.
PicturePalette | You can use the PicturePalette property to specify a palette to be used by a report. Read/write Variant.
PictureSizeMode | You can use the PictureSizeMode property to specify how a picture for a form or report is sized. Read/write Byte.
PictureTiling | You can use the PictureTiling property to specify whether a background picture is tiled across the entire image control, Form window, form, or page of a report. Read/write Boolean.
PictureType | You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.
PopUp | Specifies whether a report opens as a pop-up window. Read/write Boolean.
PrintCount | You can use the PrintCount property to identify the number of times the OnPrint property has been evaluated for the current section of a report. Read/write Integer.
Printer | Returns or sets a Printer object representing the default printer on the current system. Read/write.
PrintSection | The PrintSection property specifies whether a section should be printed. Read/write Boolean.
Properties | Returns a reference to a control's Properties collection object. Read-only.
PrtDevMode | You can use the PrtDevMode property to set or return printing device mode information specified for a form or report in the Print dialog box. Read/write Variant.
PrtDevNames | You can use the PrtDevNames property to set or return information about the printer selected in the Print dialog box for a form or report. Read/write Variant.
PrtMip | You can use the PrtMip property in Visual Basic to set or return the device mode information specified for a form or report in the Print dialog box.
RecordLocks | You can use the RecordLocks property to determine how records are locked and what happens when two users try to edit the same record at the same time. Read/write.
Recordset | Returns or sets the ADO Recordset or DAO Recordset object representing the record source for the specified object. Read/write Object.
RecordSource | You can use the RecordSource property to specify the source of the data for a report. Read/write String.
RecordSourceQualifier | Returns or sets a String indicating the SQL Server owner name of the record source for the specified report. Read/write.
Report | You can use the Report property to refer to a report or to refer to the report associated with a subreport control. Read-only Report.
RibbonName | Gets or set the name of the customized ribbon to be displayed when the specified report is loaded. Read/write String.
ScaleHeight | You can use the ScaleHeight property to specify the number of units for the vertical measurement of the page when the Circle , Line , Pset , or Print method is used while a report is printed or previewed, or its output is saved to a file. Read/write Single.
ScaleLeft | You can use the ScaleLeft property to specify the units for the horizontal coordinates that describe the location of the left edge of a page when the Circle , Line , Pset , or Print method is used while a report is previewed, printed, or its output is saved to a file. Read / write Single.
ScaleMode | You can use the ScaleMode property in Visual Basic to specify the unit of measurement for coordinates on a page when the Circle , Line , Pset , or Print method is used while a report is previewed or printed, or its output is saved to a file. Read/write Integer.
ScaleTop | You can use the ScaleTop property to specify the units for the vertical coordinates that describe the location of the top edge of a page when the Circle , Line , Pset , or Print method is used while a report is previewed, printed, or its output is saved to a file. Read / write Single.
ScaleWidth | You can use the ScaleWidth property to specify the number of units for the horizontal measurement of the page when the Circle , Line , Pset , or Print method is used while a report is printed or previewed, or its output is saved to a file. Read/write Single.
ScrollBars | Gets or sets whether scroll bars appear on a report. Read/write Byte.
Section | You can use the Section property to identify a section of a report and provide access to the properties of that section. Read-only Section object.
ServerFilter | You can use the ServerFilter property to specify a subset of records to be displayed when a server filter is applied to a report within a Microsoft Access project (.adp) or database. Read/write String.
Shape | Returns a String representing the shape command corresponding to the sorting and grouping of the specified report. Read-only.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
ShowPageMargins | Gets or sets whether page margins are displayed when the specified report is in Layout view. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
TimerInterval | You can use the TimerInterval property to specify the interval, in milliseconds, between Timer events on a report. Read/write Long.
Toolbar | Specifies a custom toolbar to display for a report. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Long. .
UseDefaultPrinter | Returns or sets a Boolean indicating whether the specified report uses the default printer for the system; True if the form or report uses the default printer. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.
WindowHeight | Returns the height of a report in twips. Read-only Integer.
WindowLeft | Returns an Integer indicating the screen position in twips of the left edge of a report relative to the left edge of the Microsoft Access window. Read-only.
WindowTop | Returns an Integer indicating the screen position in twips of the top edge of a report relative to the top of the Microsoft Access window. Read-only.
WindowWidth | Returns the width of a report in twips. Read-only Integer.


IndexNulls Property (ADOX)

 Copy code hover
[image]

IndexNulls Property (ADOX)
Send feedback

Indicates whether records that have null values in their index fields have index entries.

Settings and Return Values

Sets and returns an AllowNullsEnum value. The default value is adIndexNullsDisallow.

Remarks

This property is read-only on Index objects already appended to a collection.


TempVars Members (Access)

 Copy code hover
[image]

TempVars Members (Access)
Send feedback

Published: July 16, 2012

Represents the collection of TempVar objects.

Methods

Name | Description
Add | Adds a variable to the TempVars collection.
Remove | Removes the specified TempVar object from the TempVars collection.
RemoveAll | Removes all of the TempVar objects from the TempVars collection.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | Gets the number of TempVar objects in the TempVars collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only TempVar.
Parent | Returns the parent object for the specified object. Read-only Object.


Clone Method Example (VB)

 Copy code hover
[image]

Clone Method Example (VB)
Send feedback

This example uses the Clone method to create copies of a Recordset and then lets the user position the record pointer of each copy independently.

Copy code Copy code

'BeginCloneVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 'recordset array and connection variables
 Dim arstStores(1 To 3) As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strSQLStore As String
 Dim strCnxn As String
 'record variables
 Dim intLoop As Integer
 Dim strMessage As String
 Dim strFind As String

 ' Open a connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open recordset as a static cursor type recordset
 Set arstStores(1) = New ADODB.Recordset
 strSQLStore = "SELECT stor_name FROM Stores ORDER BY stor_name"
 arstStores(1).Open strSQLStore, strCnxn, adOpenStatic, adLockBatchOptimistic, adCmdText

 ' Create two clones of the original Recordset
 Set arstStores(2) = arstStores(1).Clone
 Set arstStores(3) = arstStores(1).Clone

 ' Loop through the array so that on each pass the user
 ' is searching a different copy of the same Recordset
 Do
 For intLoop = 1 To 3
 ' Ask for search string while showing where
 ' the current record pointer is for each Recordset
 strMessage = _
 "Recordsets from stores table:" & vbCr & _
 " 1 - Original - Record pointer at " & arstStores(1)!stor_name & vbCr & _
 " 2 - Clone - Record pointer at " & arstStores(2)!stor_name & vbCr & _
 " 3 - Clone - Record pointer at " & arstStores(3)!stor_name & vbCr & _
 "Enter search string for #" & intLoop & ":"

 strFind = Trim(InputBox(strMessage))
 ' make sure something was entered, if not then EXIT loop
 If strFind = "" Then Exit Do

 ' otherwise locate the record from the entered string
 arstStores(intLoop).Filter = "stor_name = '" & strFind & "'"

 'if there's no match, jump to the last record
 If arstStores(intLoop).EOF Then
 arstStores(intLoop).Filter = adFilterNone
 arstStores(intLoop).MoveLast
 Else
 MsgBox "Found " & strFind
 End If
 Next intLoop
 Loop

 ' clean up
 arstStores(1).Close
 arstStores(2).Close
 arstStores(3).Close
 Cnxn.Close
 Set arstStores(1) = Nothing
 Set arstStores(2) = Nothing
 Set arstStores(3) = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not arstStores(1) Is Nothing Then
 If arstStores(1).State = adStateOpen Then arstStores(1).Close
 End If
 Set arstStores(1) = Nothing
 If Not arstStores(2) Is Nothing Then
 If arstStores(2).State = adStateOpen Then arstStores(2).Close
 End If
 Set arstStores(2) = Nothing
 If Not arstStores(3) Is Nothing Then
 If arstStores(3).State = adStateOpen Then arstStores(3).Close
 End If
 Set arstStores(3) = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndCloneVB


Form.CurrentSectionLeft Property (Access)

 Copy code hover
[image]

Form.CurrentSectionLeft Property (Access)
See also Send feedback

Published: July 16, 2012

You can use this property to determine the distance in twips from the left side of the current section to the left side of the form. Read/write Integer.

Syntax

expression .CurrentSectionLeft

expression A variable that represents a Form object.

Remarks

The CurrentSectionLeft property setting changes whenever a user scrolls through a form.

For forms whose DefaultView property is set to Single Form, if the user scrolls to the right of the left edge of the form, the property setting is a negative value.

The CurrentSectionLeft property is useful for finding the positions of detail sections displayed in Form view as continuous forms or in Datasheet view.

Example

The following example displays the CurrentSectionLeft and CurrentSectionTop property settings for a control on a continuous form. Whenever the user moves to a new record, the property settings for the current section are displayed in the lblStatus label in the form's header.

VBA Copy code Copy code
Private Sub Form_Current()

 Dim intCurTop As Integer
 Dim intCurLeft As Integer

 intCurTop = Me.CurrentSectionTop
 intCurLeft = Me.CurrentSectionLeft
 Me!lblStatus.Caption = intCurLeft & " , " & intCurTop

End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


GetRowsOptionEnum

 Copy code hover
[image]

GetRowsOptionEnum
Send feedback

Specifies how many records to retrieve from a Recordset.

Constant | Value | Description
adGetRowsRest | -1 | Retrieves the rest of the records in the Recordset, from either the current position or a bookmark specified by the Start parameter of the GetRows method.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.GetRowsOption.REST


The database has been placed in a state by user

 Copy code hover
[image]

The database has been placed in a state by user <name> on machine <name> that prevents it from being opened or locked. (Error 3734)
Send feedback

This error occurs when the new passive shutdown/connection control is being used. This error message indicates that a user set the database in a mode that will prevent other users from opening it.


OnError Macro Action

 Copy code hover
[image]

OnError Macro Action
Send feedback

You can use the OnError action to specify what should happen when an error occurs in a macro.

Setting

The OnError action has the following arguments.

Action argument

Description

Go to

Specify the general behavior that should occur when an error is encountered. Click the drop-down arrow and then click one of the following settings:

Setting | Description
Next | Microsoft Office Access 2007 records the details of the error in the MacroError object but does not stop the macro. The macro continues with the next action.
Macro Name | Access stops the current macro and runs the macro that is named in the Macro Name argument.
Fail | Access stops the current macro and displays an error message.

Macro Name

If the Go to argument is set to Macro Name, type the name of the macro to be used for error handling. The name you type must match a name in the Macro Name column of the current macro; you can't enter the name of a different macro object. In the example below, the ErrorHandler macro is contained in the same macro object as the OnError action. This argument must be left blank if the Go to argument is set to Next or Fail.

Remarks

  • The OnError action is usually placed at the beginning of a macro, but you can also place the action later in the macro. The rules established by the action will take effect whenever the action is run.

  • If you set the Go to argument to Fail, Access behaves the same way it would if there were no OnError action in the macro. That is, if an error is encountered, Access stops the macro and displays a standard error message. The main use for the Fail setting is to turn off any error handling that you established earlier in a macro.

Example

The following macro demonstrates the use of the OnError action. In this example, the OnError action specifies that Access run a custom error handling macro named ErrorHandler when an error occurs. When an error occurs, the CatchErrors submacro is called. If the error number is 2102, a specific message is displayed and macro execution is halted. Otherwise, a message describing the error is displayed and the macro is paused so that you can perform additional troubleshooting. The ErrorHandler macro displays a message box that refers to the MacroError object to display information about the error.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

Copy code Copy code
/* MACRO: mcrThrowErrors                                  */
/* PURPOSE: Error handling using macros in Access 2010    */

OnError
    Go to Macro Name
    Macro Name CatchErrors

OpenForm
    Form Name frmSamples
    View Form
    Filter Name
    Where Condition
    Data Mode
    Window Mode Normal

MessageBox
    Message This message appears after the OpenForm action
    Beep Yes
    Type None
    Title

/* SUBMACRO: CatchErrors                                   */

SubMacro: CatchErrors
    If [MacroError].[Number]=2101 Then
        MessageBox
            Message Cannot find the specified form!
            Beep Yes
            Type Critical
            Title
        StopMacro

    Else
        MessageBox
            Message =[MacroErro].[Description]
            Beep Yes
            Type None
            Title Unhandled Error

        SingleStep
    End If

End SubMacro

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Printer.ColorMode Property (Access)

 Copy code hover
[image]

Printer.ColorMode Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets an AcPrintColor constant representing whether the specified printer should print output in color or monochrome. Read/write.

Syntax

expression .ColorMode

expression A variable that represents a Printer object.

Example

The following example sets a variety of printer settings for the form specified in the strFormname argument of the procedure.

VBA Copy code Copy code
Sub SetPrinter(strFormname As String)

 DoCmd.OpenForm FormName:=strFormname, view:=acDesign, _
 datamode:=acFormEdit, windowmode:=acHidden

 With Forms(form1).Printer

 .TopMargin = 1440
 .BottomMargin = 1440
 .LeftMargin = 1440
 .RightMargin = 1440

 .ColumnSpacing = 360
 .RowSpacing = 360

  .ColorMode = acPRCMColor
 .DataOnly = False
 .DefaultSize = False
 .ItemSizeHeight = 2880
 .ItemSizeWidth = 2880
 .ItemLayout = acPRVerticalColumnLayout
 .ItemsAcross = 6

 .Copies = 1
 .Orientation = acPRORLandscape
 .Duplex = acPRDPVertical
 .PaperBin = acPRBNAuto
 .PaperSize = acPRPSLetter
 .PrintQuality = acPRPQMedium

 End With

 DoCmd.Close objecttype:=acForm, objectname:=strFormname, _
 Save:=acSaveYes

End Sub

See also

Concepts

Printer Object

Other resources

Printer Object Members


TextBox.FilterLookup Property (Access)

 Copy code hover
[image]

TextBox.FilterLookup Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FilterLookup property to specify whether values appear in a bound text box control when using the Filter By Form or Server Filter By Form window. Read/write Byte.

Syntax

expression .FilterLookup

expression A variable that represents a TextBox object.

Remarks

The FilterLookup property uses the following settings.

Setting | Visual Basic | Description
Never | 0 | The field values aren't displayed. You can specify whether the filtered records can contain null values.
Database Default | 1 | (Default) The field values are displayed according to the settings under Filter lookup options on the Current Database tab of the Access Options dialog box, available by clicking the Microsoft Office Button [image] and the clicking Access Options.
Always | 2 | The field values are always displayed.

You can also set the default for this property by setting a control's DefaultControl property in Visual Basic.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Attachment.OnExit Property (Access)

 Copy code hover
[image]

Attachment.OnExit Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Exit box in the Properties window of the specified object. Read/write String. .

Version Information

Version Added: Access 2007

Syntax

expression .OnExit

expression A variable that represents an Attachment object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Exit event occurs just before a control loses the focus to another control on the same form.

The OnExit value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Exit box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Exit box is blank, the property value is an empty string.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Beep Macro Action

 Copy code hover
[image]

Beep Macro Action
Send feedback

You can use the Beep action to sound a beep tone through the computer's speaker.

Setting

The Beep action doesn't have any arguments.

Remarks

You can use the Beep action to signal the following occurrences:

  • Important screen changes have occurred.

  • The wrong kind of data has been entered in a control. For example, the user has entered numeric data in a text box control.

  • A macro has reached a specified point or has completed its actions.

The frequency and duration of the beep depend on the hardware, which may vary between computers.

To run the Beep action in a Visual Basic for Applications (VBA) module, use the Beep method of the DoCmd object.


OptionGroup.Requery Method (Access)

 Copy code hover
[image]

OptionGroup.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.

Syntax

expression .Requery

expression A variable that represents an OptionGroup object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts .

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate function.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

Example

The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form:

VBA Copy code Copy code
Public Sub RequeryList()

    Dim ctlCombo As Control

    ' Return Control object pointing to a combo box.
    Set ctlCombo = Forms!Employees!ReportsTo

    ' Requery source of data for list box.
    ctlCombo.Requery

End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


FormatCondition.LongestBarLimit Property (Access)

 Copy code hover
[image]

FormatCondition.LongestBarLimit Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets how the longest data bar is evaluated for the specified FormatCondition. Read/write AcFormatBarLimits.

Version Information

Version Added: Access 2010

Syntax

expression .LongestBarLimit

expression A variable that represents a FormatCondition object.

Remarks

By default, the highest value is used to determine the length of the longest data bar.

See also

Concepts

FormatCondition Object

Other resources

FormatCondition Object Members


FieldSize Property

 Copy code hover
[image]

FieldSize Property
Send feedback

Published: July 16, 2012

You can use the FieldSize property to set the maximum size for data stored in a field set to the Text, Number, or AutoNumber data type.

Setting

If the DataType property is set to Text, enter a number from 0 to 255. The default setting is 50.

If the DataType property is set to AutoNumber, the FieldSize property can be set to Long Integer or Replication ID.

If the DataType property is set to Number, the FieldSize property settings and their values are related in the following way.

Setting | Description | Decimal precision | Storage size
Byte | Stores numbers from 0 to 255 (no fractions). | None | 1 byte
Decimal | Stores numbers from -10^38-1 through 10^38-1 (.adp) Stores numbers from -10^28-1 through 10^28-1 (.mdb, .accdb) | 28 | 2 bytes
Integer | Stores numbers from -32,768 to 32,767 (no fractions). | None | 2 bytes
Long Integer | (Default) Stores numbers from -2,147,483,648 to 2,147,483,647 (no fractions). | None | 4 bytes
Single | Stores numbers from -3.402823E38 to -1.401298E-45 for negative values and from 1.401298E-45 to 3.402823E38 for positive values. | 7 | 4 bytes
Double | Stores numbers from -1.79769313486231E308 to -4.94065645841247E-324 for negative values and from 4.94065645841247E-324 to 1.79769313486231E308 for positive values. | 15 | 8 bytes
Replication ID | Globally unique identifier (GUID) | N/A | 16 bytes

You can set this property only from the table's property sheet.

To set the size of a field from Visual Basic , use the DAO Size property to read and set the maximum size of Text fields (for data types other than Text, the DAO Type property setting automatically determines the Size property setting).

Remarks

You should use the smallest possible FieldSize property setting because smaller data sizes can be processed faster and require less memory.

Caution note Caution

If you convert a large FieldSize setting to a smaller one in a field that already contains data, you might lose data. For example, if you change the FieldSize setting for a Text data type field from 255 to 50, data beyond the new 50-character setting will be discarded.

If the data in a Number data type field doesn't fit in a new FieldSize setting, fractional numbers may be rounded or you might get a Null value. For example, if you change from a Single to an Integer field size, fractional values will be rounded to the nearest whole number and values greater than 32,767 or less than -32,768 will result in null fields.

You can't undo changes to data that result from a change to the FieldSize property after saving those changes in table Design view.

Note Note

You can use the Currency data type if you plan to perform many calculations on a field that contains data with one to four decimal places. Single and Double data type fields require floating-point calculation. Currency data type fields use a faster fixed-point calculation.


Screen.ActiveForm Property (Access)

 Copy code hover
[image]

Screen.ActiveForm Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ActiveForm property together with the Screen object to identify or refer to the form that has the focus. Read-only Form object.

Syntax

expression .ActiveForm

expression A variable that represents a Screen object.

Remarks

This property setting contains a reference to the Form object that has the focus at run time.

You can use the ActiveForm property to refer to an active form together with one of its properties or methods. The following example displays the Name property setting of the active form.

VBA Copy code Copy code
Dim frmCurrentForm As Form
Set frmCurrentForm = Screen.ActiveForm
MsgBox "Current form is " & frmCurrentForm.Name

If a subform has the focus, ActiveForm refers to the main form. If no form or subform has the focus when you use the ActiveForm property, an error occurs.

See also

Concepts

Screen Object

Other resources

Screen Object Members


Form.DatasheetFontHeight Property (Access)

 Copy code hover
[image]

Form.DatasheetFontHeight Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DatasheetFontHeight property to specify the font point size used to display and print field names and data in Datasheet view. Read/write Integer.

Syntax

expression .DatasheetFontHeight

expression A variable that represents a Form object.

Remarks

This property is only available within a Microsoft Access database.

For the DatasheetFontHeight property, the font size you specify must be valid for the font specified by the DatasheetFontName property. For example, MS Sans Serif is available only in sizes 8, 10, 12, 14, 18, and 24 points.

The following table contains the properties that don't exist in the DAO Properties collection of until you set them by using the Formatting (Datasheet) toolbar or you can add them in an Access database (.mdb) by using the CreateProperty method and append it to the DAO Properties collection.

DatasheetFontItalic * | DatasheetForeColor *
DatasheetFontHeight * | DatasheetBackColor
DatasheetFontName * | DatasheetGridlinesColor
DatasheetFontUnderline * | DatasheetGridlinesBehavior
DatasheetFontWeight * | DatasheetCellsEffect
Note Note

When you add or set any property listed with an asterisk, Microsoft Access automatically adds all the properties listed with an asterisk to the Properties collection of the database.

Example

The following example sets the font to MS Serif, the font size to 10 points, and the font weight to medium (500) in Datasheet view of the Products table.

VBA Copy code Copy code
Sub SetDatasheetFont

 Dim dbs As Object, objProducts As Object
 Set dbs = CurrentDb
 Const DB_Text As Long = 10
 Const DB_Integer As Long = 3
 Set objProducts = dbs!Products

 SetTableProperty objProducts, "DatasheetFontName", DB_Text, "MS Serif"
 SetTableProperty objProducts, "DatasheetFontHeight", DB_Integer, 10
 SetTableProperty objProducts, "DatasheetFontWeight", DB_Integer, 500

End Sub

Sub SetTableProperty(objTableObj As Object, strPropertyName As String, _
 intPropertyType As Integer, varPropertyValue As Variant)
 ' Set Microsoft Access-defined table property without causing
 ' nonrecoverable run-time error.
 Const conErrPropertyNotFound = 3270
 Dim prpProperty As Variant
 On Error Resume Next ' Don't trap errors.
 objTableObj.Properties(strPropertyName) = varPropertyValue
 If Err <> 0 Then ' Error occurred when value set.
 If Err <> conErrPropertyNotFound Then
 On Error GoTo 0
 MsgBox "Couldn't set property '" & strPropertyName _
 & "' on table '" & objTableObj.Name & "'", 48, "SetTableProperty"
 Else
 On Error GoTo 0
 Set prpProperty = objTableObj.CreateProperty(strPropertyName, _
 intPropertyType, varPropertyValue)
 objTableObj.Properties.Append prpProperty
 End If
 End If
 objTableObj.Properties.Refresh
End Sub

The next example makes the same changes as the preceding example in Datasheet view of the open Products form.

VBA Copy code Copy code
Forms!Products.DatasheetFontName = "MS Serif"
Forms!Products.DatasheetFontHeight = 10
Forms!Products.DatasheetFontWeight = 500

See also

Concepts

Form Object

Other resources

Form Object Members


Microsoft OLE DB Provider for Internet Publishing

 Copy code hover
[image]

Microsoft OLE DB Provider for Internet Publishing
Send feedback

The Microsoft OLE DB Provider for Internet Publishing allows ADO to access resources served by Microsoft FrontPage or Microsoft Internet Information Server. Resources include web source files such as HTML files, or Windows 2000 web folders.

Connection String Parameters

To connect to this provider, set the Provider argument of the ConnectionString property to:

Copy code Copy code

MSDAIPP.DSO

This value can also be set or read using the Provider property.

Typical Connection String

A typical connection string for this provider is:

Copy code Copy code

"Provider=MSDAIPP.DSO;Data Source=ResourceURL;User ID=userName;Password=userPassword;"

-or-

Copy code Copy code

"URL=ResourceURL;User ID=userName;Password=userPassword;"

The string consists of these keywords:

Keyword | Description
Provider | Specifies the OLE DB Provider for Internet Publishing.
Data Source -or- URL | Specifies the URL of a file or directory published in a Web Folder.
User ID | Specifies the user name.
Password | Specifies the user password.

If you set the ResourceURL value from the "URL=" in the connection string to an invalid value, by default the Internet Publishing Provider raises a dialog box to prompt for a valid value. This is undesirable behavior for a component in the middle tier of an application, because it suspends program execution until the dialog box is cleared and the client appears to freeze because it has not received a response from the component.

Note Note

If MSDAIPP.DSO is explicitly specified as the value of the provider, either with the Provider connection string keyword or the Provider property, you cannot use "URL=" in the connection string. If you do, an error will occur. Instead, simply specify the URL as shown in the topic Using ADO with the OLE DB Provider for Internet Publishing.


IndexNulls Property Example (VC++)

 Copy code hover
[image]

IndexNulls Property Example (VC++)
Send feedback

This example demonstrates the IndexNulls property of an Index. The code creates a new index and sets the value of IndexNulls based on user input. Then, the Index is appended to the Employees Table in the Northwind Catalog. The new Index is applied to a Recordset based on the Employees table, and the Recordset is opened. A new record is added to the Employees table, with a Null value in the indexed field. Whether this new record is displayed depends on the setting of the IndexNulls property.

Copy code Copy code

// BeignIndexNullCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" rename("EOF", "EndOfFile")
#import "c:\Program Files\Common Files\system\ado\msadox.dll" no_namespace

#include "iostream.h"
#include "stdio.h"
#include "conio.h"
#include "ADOXIndexNullsX.h"

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void IndexNullsX(_bstr_t);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 printf("\nShow records having indexed field value = NULL? (Y/N):");
 char input = getche();

 if(toupper(input)=='Y')
 {
 IndexNullsX("Allow");
 }
 else if(toupper(input)=='N')
 {
 IndexNullsX("Ignore");
 }
 else
 {
 exit(0);
 }

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// IndexNullsX Function //
// //
//////////////////////////////////////////////////////////
void IndexNullsX(_bstr_t strSel)
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.
 _CatalogPtr m_pCatalog = NULL;
 _IndexPtr m_pIndexNew = NULL;

 // Define ADODB object pointers
 ADODB::_ConnectionPtr m_pCnn = NULL;
 ADODB::_RecordsetPtr m_pRstEmployees = NULL;

 // Define other variables
 IADORecordBinding *picRs = NULL; // Interface Pointer Declared
 CEmployeeRs emprs; // C++ Class Object

 // Define string variable.
 _bstr_t strCnn("Provider='Microsoft.JET.OLEDB.4.0';"
 "data source='c:\\Program Files\\Microsoft Office\\Office\\"
 "Samples\\Northwind.mdb';");

 try
 {
 TESTHR(hr = m_pCnn.CreateInstance(__uuidof(ADODB::Connection)));
 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof (Catalog)));
 TESTHR(hr = m_pIndexNew.CreateInstance(__uuidof(Index)));
 TESTHR(hr = m_pRstEmployees.CreateInstance(
 __uuidof(ADODB::Recordset)));

 // Connect the catalog.
 m_pCnn->Open(strCnn,"","",NULL);
 m_pCatalog->PutActiveConnection(_variant_t((IDispatch *)m_pCnn));

 // Append Country column to new index.
 m_pIndexNew->Columns->Append("Country",adVarWChar,0);
 m_pIndexNew->Name = "NewIndex";

 // Set IndexNulls based on user input
 if(strcmp((LPSTR)strSel,"Allow")==0)
 {
 m_pIndexNew->IndexNulls = adIndexNullsAllow;
 }
 else if(strcmp((LPSTR)strSel,"Ignore")==0)
 {
 m_pIndexNew->IndexNulls = adIndexNullsIgnore;
 }

 // Append new index to Employees table
 m_pCatalog->Tables->GetItem("Employees")->Indexes->Append(
 _variant_t((IDispatch *)m_pIndexNew));
 m_pRstEmployees->Index = m_pIndexNew->Name;
 m_pRstEmployees->Open("Employees",
 _variant_t((IDispatch *)m_pCnn),
 ADODB::adOpenKeyset,ADODB::adLockOptimistic,
 ADODB::adCmdTableDirect);

 // Add a new record to the Employees table.
 m_pRstEmployees->AddNew();
 m_pRstEmployees->Fields->GetItem("FirstName")->Value =
 (_bstr_t) "Gary";
 m_pRstEmployees->Fields->GetItem("LastName")->Value =
 (_bstr_t) "Haarsager";
 m_pRstEmployees->Update();

 // Bookmark the newly added record.
 _variant_t varBookmark = m_pRstEmployees->Bookmark;

 // Use the new index to set the order of the records.
 m_pRstEmployees->MoveFirst();
 printf("\n\nIndex = %s,",(LPSTR) m_pRstEmployees->Index);
 printf("IndexNulls = %d\n\n",m_pIndexNew->IndexNulls);
 cout<<"Country - Name"<<endl;

 // Open an IADORecordBinding interface pointer which
 // we will use for binding Recordset to a class
 TESTHR(hr = m_pRstEmployees->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 // Bind the Recordset to a C++ class here
 TESTHR(hr = picRs->BindToRecordset(&emprs));

 // Enumerate the Recordset.The value of the
 // IndexNulls property will determine if the newly
 // added record appears in the output.
 while(!(m_pRstEmployees->EndOfFile))
 {
 printf("%s - %s %s\n",
 emprs.lemp_CountryStatus == adFldOK ?
 emprs.m_szemp_Country :"[Null]",
 emprs.lemp_FirstNameStatus == adFldOK ?
 emprs.m_szemp_FirstName :"<NULL>",
 emprs.lemp_LastNameStatus == adFldOK ?
 emprs.m_szemp_LastName :"<NULL>");
 m_pRstEmployees->MoveNext();
 }

 // Delete new record because this is a demonstration.
 m_pRstEmployees->Bookmark = varBookmark;
 m_pRstEmployees->Delete(ADODB::adAffectCurrent);
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }
 catch(...)
 {
 cout << "Error occured in include files...."<< endl;
 }

 if (m_pRstEmployees)
 {
 if (m_pRstEmployees->State == 1)
 {
 m_pRstEmployees->Close();
 m_pRstEmployees = NULL;
 }
 }

 // Delete new Index because this is a demonstration.
 if (m_pCatalog)
 m_pCatalog->Tables->GetItem("Employees")->Indexes->
 Delete(m_pIndexNew->Name);

 if (m_pCnn)
 {
 if (m_pCnn->State == 1)
 {
 m_pCnn->Close();
 m_pCnn = NULL;
 }
 }

 m_pCatalog = NULL;
}
// EndIndexNullCpp

IndexNullX.h

Copy code Copy code
                      // BeginIndexNullsH
// IndexNullsX.h

#include "icrsint.h"

//This class extracts LastName,Country,FirstName from Employees table

class CEmployeeRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CEmployeeRs)
 // Column LastName is the 2nd field in the table
 ADO_VARIABLE_LENGTH_ENTRY2(2,adVarChar,m_szemp_LastName,
 sizeof(m_szemp_LastName),lemp_LastNameStatus,TRUE)
 // Column Country is the 11th field in the table
 ADO_VARIABLE_LENGTH_ENTRY2(11,adVarChar,m_szemp_Country,
 sizeof(m_szemp_Country),lemp_CountryStatus,TRUE)
 // Column Country is the 17th field in the table
 ADO_VARIABLE_LENGTH_ENTRY2(17,adVarChar,m_szemp_FirstName,
 sizeof(m_szemp_FirstName),lemp_FirstNameStatus,TRUE)
END_ADO_BINDING()

public:
 CHAR m_szemp_LastName[21];
 ULONG lemp_LastNameStatus;
 CHAR m_szemp_Country[16];
 ULONG lemp_CountryStatus;
 CHAR m_szemp_FirstName[11];
 ULONG lemp_FirstNameStatus;
};
// EndIndexNullsH


Field2.GetChunk Method (DAO)

 Copy code hover
[image]

Field2.GetChunk Method (DAO)
Send feedback

Returns all or a portion of the contents of a Memo or Long BinaryField2 object in the Fields collection of a Recordset object.

Syntax

expression .GetChunk(Offset, Bytes)

expression A variable that represents a Field2 object.

Parameters

Name | Required/Optional | Data Type | Description
Offset | Required | Long | The number of bytes to skip before copying begins.
Bytes | Required | Long | The number of bytes you want to return.

Return Value

Variant

Remarks

The bytes returned by GetChunk are assigned to variable. Use GetChunk to return a portion of the total data value at a time. You can use the AppendChunk method to reassemble the pieces.

If offset is 0, GetChunk begins copying from the first byte of the field.

If numbytes is greater than the number of bytes in the field, GetChunk returns the actual number of remaining bytes in the field.

Note Note

Use a Memo field for text, and put binary data only in Long Binary fields. Doing otherwise will cause undesirable results.

Example

This example uses the AppendChunk and GetChunk methods to fill an OLE object field with data from another record, 32K at a time. In a real application, one might use a procedure like this to copy an employee record (including the employee's photo) from one table to another. In this example, the record is simply being copied back to same table. Note that all the chunk manipulation takes place within a single AddNew-Update sequence.

VBA Copy code Copy code
Sub AppendChunkX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset
 Dim rstEmployees2 As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 ' Open two recordsets from the Employees table.
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", _
 dbOpenDynaset)
 Set rstEmployees2 = rstEmployees.Clone

 ' Add a new record to the first Recordset and copy the
 ' data from a record in the second Recordset.
 With rstEmployees
 .AddNew
 !FirstName = rstEmployees2!FirstName
 !LastName = rstEmployees2!LastName
 CopyLargeField rstEmployees2!Photo, !Photo
 .Update

 ' Delete new record because this is a demonstration.
 .Bookmark = .LastModified
 .Delete
 .Close
 End With

 rstEmployees2.Close
 dbsNorthwind.Close

End Sub

Function CopyLargeField(fldSource As Field2, _
 fldDestination As Field2)

 ' Set size of chunk in bytes.
 Const conChunkSize = 32768

 Dim lngOffset As Long
 Dim lngTotalSize As Long
 Dim strChunk As String

 ' Copy the photo from one Recordset to the other in 32K
 ' chunks until the entire field is copied.
 lngTotalSize = fldSource.FieldSize
 Do While lngOffset < lngTotalSize
 strChunk = fldSource.GetChunk(lngOffset, conChunkSize)
 fldDestination.AppendChunk strChunk
 lngOffset = lngOffset + conChunkSize
 Loop

End Function


TextBox.ValidationText Property (Access)

 Copy code hover
[image]

TextBox.ValidationText Property (Access)
See also Send feedback

Published: July 16, 2012

Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.

Syntax

expression .ValidationText

expression A variable that represents a TextBox object.

Remarks

Enter an expression for the ValidationRule property setting and text for the ValidationText property setting. The maximum length for the ValidationRule property setting is 2048 characters. The maximum length for the ValidationText property setting is 255 characters.

For controls, you can set the ValidationRule property to any valid expression. For field and record validation rules, the expression can't contain user-defined functions, domain aggregate or aggregate functions, the Eval function, or CurrentUser method, or references to forms, queries, or tables. In addition, field validation rules can't contain references to other fields. For records, expressions can include references to fields in that table.

For table fields and records, you can also set these properties in Visual Basic by using the DAO ValidationRule property.

Microsoft Access automatically validates values based on a field's data type; for example, Microsoft Access doesn't allow text in a numeric field. You can set rules that are more specific by using the ValidationRule property.

If you set the ValidationRule property but not the ValidationText property, Microsoft Access displays a standard error message when the validation rule is violated. If you set the ValidationText property, the text you enter is displayed as the error message.

For example, when a record is added for a new employee, you can enter a ValidationRule property requiring that the value in the employee's StartDate field fall between the company's founding date and the current date. If the date entered isn't in this range, you can display the ValidationText property message: "Start date is incorrect."

If you create a control by dragging a field from the field list, the field's validation rule remains in effect, although it isn't displayed in the control's ValidationRule property box in the property sheet. This is because a field's validation rule is inherited by a control bound to that field.

Control, field, and record validation rules are applied as follows:

  • Validation rules you set for fields and controls are applied when you edit the data and the focus leaves the field or control.

  • Validation rules for records are applied when you move to another record.

  • If you create validation rules for both a field and a control bound to the field, both validation rules are applied when you edit data and the focus leaves the control.

The following table contains expression examples for the ValidationRule and ValidationText properties.

ValidationRule property | ValidationText property
<> 0 | Entry must be a nonzero value.
> 1000 Or Is Null | Entry must be blank or greater than 1000.
Like "A????" | Entry must be 5 characters and begin with the letter "A".
>= #1/1/96# And <#1/1/97# | Entry must be a date in 1996.
DLookup("CustomerID", "Customers", "CustomerID = Forms!Customers!CustomerID") Is Null | Entry must be a unique CustomerID (domain aggregate functions are allowed only for form-level validation).

If you create a validation rule for a field, Microsoft Access doesn't normally allow a Null value to be stored in the field. If you want to allow a Null value, add "Is Null" to the validation rule, as in "<> 8 Or Is Null" and make sure the Required property is set to No.

You can't set field or record validation rules for tables created outside Microsoft Access (for example, dBASE, Paradox, or SQL Server). For these kinds of tables, you can create validation rules for controls only.

Example

The following example creates a validation rule for a field that allows only values over 65 to be entered. If a number less than 65 is entered, a message is displayed. The properties are set by using the SetFieldValidation function.

VBA Copy code Copy code
Dim strTblName As String, strFldName As String
Dim strValidRule As String
Dim strValidText As String, intX As Integer

strTblName = "Customers"
strFldName = "Age"
strValidRule = ">= 65"
strValidText = "Enter a number greater than or equal to 65."
intX = SetFieldValidation(strTblName, strFldName, _
 strValidRule, strValidText)

Function SetFieldValidation(strTblName As String, _
 strFldName As String, strValidRule As String, _
 strValidText As String) As Integer

 Dim dbs As Database, tdf As TableDef, fld As Field

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 Set fld = tdf.Fields(strFldName)
 fld.ValidationRule = strValidRule
 fld.ValidationText = strValidText
End Function

The next example uses the SetTableValidation function to set record-level validation to ensure that the value in the EndDate field comes after the value in the StartDate field.

VBA Copy code Copy code
Dim strTblName As String, strValidRule As String
Dim strValidText As String
Dim intX As Integer

strTblName = "Employees"
strValidRule = "EndDate > StartDate"
strValidText = "Enter an EndDate that is later than the StartDate."
intX = SetTableValidation(strTblName, strValidRule, strValidText)

Function SetTableValidation(strTblName As String, _
 strValidRule As String, strValidText As String) _
 As Integer

 Dim dbs As Database, tdf As TableDef

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 tdf.ValidationRule = strValidRule
 tdf.ValidationText = strValidText
End Function

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Report.OnNoData Property (Access)

 Copy code hover
[image]

Report.OnNoData Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On No Data box in the Properties window of a report. Read/write String.

Syntax

expression .OnNoData

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The NoData event occurs after Microsoft Access formats a report for printing that has no data (the report is bound to an empty recordset), but before the report is printed.

The OnNoData value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On No Data box in the report's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On No Data box is blank, the property value is an empty string.

Example

The following example prints the value of the OnNoData property in the Immediate window for the "Purchase Order" report.

VBA Copy code Copy code
Debug.Print Reports("Purchase Order").OnNoData

See also

Concepts

Report Object

Other resources

Report Object Members


Control.GridlineWidthTop Property (Access)

 Copy code hover
[image]

Control.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified control. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthTop

expression A variable that represents a Control object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Control Object

Other resources

Control Object Members


DoCmd.RunCommand Method (Access)

 Copy code hover
[image]

DoCmd.RunCommand Method (Access)
See also Send feedback

Published: July 16, 2012

The RunCommand method runs a built-in command.

Syntax

expression .RunCommand(Command)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
Command | Required | AcCommand | An AcCommand constant that specifies the commend to run.

Remarks

Each menu and toolbar command in Microsoft Access has an associated constant that you can use with the RunCommand method to run that command from Visual Basic.

You can't use the RunCommand method to run a command on a custom menu or toolbar. You can only use it with built-in menus and toolbars.

The RunCommand method replaces the DoMenuItem method of the DoCmd object.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


CustomControl.GridlineStyleTop Property (Access)

 Copy code hover
[image]

CustomControl.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleTop

expression A variable that represents a CustomControl object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


OptionButton.ColumnOrder Property (Access)

 Copy code hover
[image]

OptionButton.ColumnOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.

Syntax

expression .ColumnOrder

expression A variable that represents an OptionButton object.

Remarks

To set or change this property for a table or query by using Visual Basic, you must use a column's Properties collection. For details on using the Properties collection, see Properties .

Note Note

The ColumnOrder property isn't available in Design view.

The ColumnOrder property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

In Datasheet view, a field's ColumnOrder property setting is determined by the field's position. For example, the field in the leftmost column in Datasheet view has a ColumnOrder property setting of 1, the next field has a setting of 2, and so on. Changing a field's ColumnOrder property resets the property for that field and every field to the left of its original position in Datasheet view.

In other views, the property setting is 0 unless you explicitly change the order of one or more fields in Datasheet view (either by dragging the fields to new positions or by changing their ColumnOrder property settings). Fields to the right of the moved field's new position will have a property setting of 0 in views other than Datasheet view.

The order of the fields in Datasheet view doesn't affect the order of the fields in table Design view or Form view.

Example

The following example displays the ProductName and QuantityPerUnit fields in the first two columns in Datasheet view of the Products form.

VBA Copy code Copy code
Forms!Products!ProductName.ColumnOrder = 1
Forms!Products!QuantityPerUnit.ColumnOrder = 2

The next example displays the ProductName and QuantityPerUnit fields in the first two columns of the Products table in Datasheet view. To set the ColumnOrder property, the example uses the SetFieldProperty procedure. If this procedure is run while the table is open, changes will not be displayed until it is closed and reopened.

VBA Copy code Copy code
Public Sub SetColumnOrder()

 Dim dbs As DAO.Database
 Dim tdf As DAO.TableDef

 Set dbs = CurrentDb
 Set tdf = dbs!Products

 ' Call the procedure to set the ColumnOrder property.
 SetFieldProperty tdf!ProductName, "ColumnOrder", dbLong, 2
 SetFieldProperty tdf!QuantityPerUnit, "ColumnOrder", dbLong, 3

 Set tdf = Nothing
 Set dbs = Nothing

End Sub

Private Sub SetFieldProperty(ByRef fld As DAO.Field, _
 ByVal strPropertyName As String, _
 ByVal intPropertyType As Integer, _
 ByVal varPropertyValue As Variant)
 ' Set field property without producing nonrecoverable run-time error.

 Const conErrPropertyNotFound = 3270
 Dim prp As Property

 ' Turn off error handling.
 On Error Resume Next

 fld.Properties(strPropertyName) = varPropertyValue

 ' Check for errors in setting the property.
 If Err <> 0 Then
 If Err <> conErrPropertyNotFound Then
 On Error GoTo 0
 MsgBox "Couldn't set property '" & strPropertyName & _
 "' on field '" & fld.Name & "'", vbCritical
 Else
 On Error GoTo 0
 Set prp = fld.CreateProperty(strPropertyName, intPropertyType, _
 varPropertyValue)
 fld.Properties.Append prp
 End If
 End If

 Set prp = Nothing

End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


InfoMessage Event (ADO)

 Copy code hover
[image]

InfoMessage Event (ADO)
Send feedback

The InfoMessage event is called whenever a warning occurs during a ConnectionEvent operation.

Syntax

InfoMessage pError, adStatus, pConnection

Parameters

  • pError

  • An Error object. This parameter contains any errors that are returned. If multiple errors are returned, enumerate the Errors collection to find them.

  • adStatus

  • EventStatusEnum

    Before this event returns, set this parameter to adStatusUnwantedEvent to prevent subsequent notifications.

  • pConnection

  • A Connection object. The connection for which the warning occurred. For example, warnings can occur when opening a Connection object or executing a Command on a Connection.


Precision Property (ADOX)

 Copy code hover
[image]

Precision Property (ADOX)
Send feedback

Indicates the maximum precision of data values in the column.

Settings and Return Values

Sets and returns a Long value that is the maximum precision of data values in the column when the Type property is a numeric type. Precision is ignored for all other data types.

Remarks

The default value is zero (0).

This property is read-only for Column objects already appended to a collection.


This operation is not allowed in subqueries. (Error 3787)

 Copy code hover
[image]

This operation is not allowed in subqueries. (Error 3787)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for more information.


DestConnectStr, DestinationDB, DestinationTable Properties

 Copy code hover
[image]

DestConnectStr, DestinationDB, DestinationTable Properties
Send feedback

Published: July 16, 2012

  • The DestinationDB property specifies the type of application used to create an external database.

  • The DestConnectStr property specifies the connection string for the name of the database that will contain the new table (for make-table queries) or the name of the database that contains the table to which data will be appended (for append queries).

  • The DestinationTable property specifies the name of the table that will hold the results of the make-table or append query.

Note Note

The DestConnectStr, DestinationDB, and DestinationTable properties apply only to make-table and append queries.

Setting

You set the DestConnectStr, DestinationDB, and DestinationTable properties by using a string expression.

The default setting for DestinationDB property is "(current)", which refers to the currently active database.

You can set these properties in the query's property sheet, or in SQL view of the Query window.

In the SQL statement for an append query, the table name in the INSERT INTO statement corresponds to the DestinationTable property setting. The IN clause corresponds to the DestinationDB and DestConnectStr property settings.

In the SQL statement for a make-table query, the table name in the INTO clause corresponds to the DestinationTable property setting. The IN clause corresponds to the DestinationDB and DestConnectStr property settings.

Note Note

Microsoft Access sets these properties automatically based on the information you enter in the query's property sheet or in SQL view of the Query window.

Remarks

When you click Make Table or Append on the Query menu, Microsoft Access prompts you for the information needed to set these properties. Microsoft Access uses the value you enter in the Table Name box to set the DestinationTable property, and it uses the information you type in the File Name box to set the DestConnectStr and DestinationDB properties.

To use the query's property sheet to specify a table in a Microsoft Access database, enter the name of the table in the DestinationTable property box (for example, Clients). In the DestinationDB property box, enter the path and database name without the file name extension (for example, C:\Accounts\Customers). Microsoft Access adds the extension automatically. You don't need to set the DestConnectStr property.

To specify a table in a database created by a different product, such as Paradox, enter the name of the table in the DestinationTable property box. In the DestinationDB property box, enter the path (for example, C:\Pdoxdata). In the DestConnectStr property box, enter the specifier for the database type (for example, Paradox 3.x). For a list of specifiers, see the ADO Connect property.

To specify an Open Database Connectivity (ODBC) database, enter the name of the database in the DestConnectStr property box along with additional information, such as a logon identification (ID) and password, as required by the product. For example, you might use the following setting for a Microsoft SQL Server database:

Copy code Copy code
ODBC;DSN=salessrv;UID=jace;PWD=password;DATABASE=sales;

For more information about ODBC drivers, such as Microsoft SQL Server, see the Help provided with the driver.

You don't need to set the DestinationDB property for ODBC databases.


Invalid address for destination dropbox folder. (Error 3557)

 Copy code hover
[image]

Invalid address for destination dropbox folder. (Error 3557)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


Data blocks (Access 2013 custom web app)

 Copy code hover
[image]

Data blocks (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • CreateRecord Data Block (Access 2013 custom web app)

  • EditRecord Data Block (Access 2013 custom web app)

  • ForEachRecord Data Block (Access 2013 custom web app)

  • LookupRecord Data Block (Access 2013 custom web app)


ComboBox.IsHyperlink Property (Access)

 Copy code hover
[image]

ComboBox.IsHyperlink Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsHyperlink property to specify or determine if the data contained in a combo box is a hyperlink. Read/write Boolean.

Syntax

expression .IsHyperlink

expression A variable that represents a ComboBox object.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Clear Method (ADO)

 Copy code hover
[image]

Clear Method (ADO)
Send feedback

Removes all the Error objects from the Errors collection.

Syntax

Errors.Clear

Remarks

Use the Clear method on the Errors collection to remove all existing Error objects from the collection. When an error occurs, ADO automatically clears the Errors collection and fills it with Error objects based on the new error.

Some properties and methods return warnings that appear as Error objects in the Errors collection but do not halt a program's execution. Before you call the Resync, UpdateBatch, or CancelBatch methods on a Recordset object; the Open method on a Connection object; or set the Filter property on a Recordset object, call the Clear method on the Errors collection. That way, you can read the Count property of the Errors collection to test for returned warnings.


CustomControl.DisplayWhen Property (Access)

 Copy code hover
[image]

CustomControl.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Syntax

expression .DisplayWhen

expression A variable that represents a CustomControl object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


ComboBox.DecimalPlaces Property (Access)

 Copy code hover
[image]

ComboBox.DecimalPlaces Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DecimalPlaces property to specify the number of decimal places Microsoft Access uses to display numbers. Read/write Byte.

Syntax

expression .DecimalPlaces

expression A variable that represents a ComboBox object.

Remarks

The DecimalPlaces property uses the following settings.

Setting | Visual Basic | Description
Auto | 255 | (Default) Numbers appear as specified by the Format property setting.
0 to 15 | 0 to 15 | Digits to the right of the decimal separator appear with the specified number of decimal places; digits to the left of the decimal separator appear as specified by the Format property setting.

You should set the DecimalPlaces property in the table's property sheet. A bound control you create on a form or report inherits the DecimalPlaces property set in the field in the underlying table or query, so you won't have to specify the property individually for every bound control you create.

The DecimalPlaces property setting has no effect if the Format property is blank or is set to General Number.

The DecimalPlaces property affects only the number of decimal places that display, not how many decimal places are stored. To change the way a number is stored you must change the FieldSize property in table Design view.

You can use the DecimalPlaces property to display numbers differently from the Format property setting or from the way they are stored. For example, the Currency setting of the Format property displays only two decimal places ($5.35). To display Currency numbers with four decimal places (for example, $5.3523), set the DecimalPlaces property to 4.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ToggleButton.BorderTint Property (Access)

 Copy code hover
[image]

ToggleButton.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderTint

expression A variable that represents a ToggleButton object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BorderColor by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


DoCmd.RunSQL Method (Access)

 Copy code hover
[image]

DoCmd.RunSQL Method (Access)
See also Send feedback

Published: July 16, 2012

The RunSQL method carries out the RunSQL action in Visual Basic.

Syntax

expression .RunSQL(SQLStatement, UseTransaction)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
SQLStatement | Required | Variant | A string expression that's a valid SQL statement for an action query or a data-definition query. It uses an INSERT INTO, DELETE, SELECT...INTO, UPDATE, CREATE TABLE, ALTER TABLE, DROP TABLE, CREATE INDEX, or DROP INDEX statement. Include an IN clause if you want to access another database.
UseTransaction | Optional | Variant | Use True (-1) to include this query in a transaction. Use False (0) if you don't want to use a transaction. If you leave this argument blank, the default (True) is assumed.

Remarks

You can use the RunSQL action to run a Microsoft Access action query by using the corresponding SQL statement. You can also run a data-definition query.

This method only applies to Microsoft Access databases.

The maximum length of the sqlstatement argument is 32,768 characters (unlike the SQL Statement action argument in the Macro window, whose maximum length is 256 characters).

Links provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Calling Action Queries

  • Queries/SQL: Use Statements Stored in Table

Example

The following example updates the Employees table, changing each sales manager's title to Regional Sales Manager:

VBA Copy code Copy code
Public Sub DoSQL()

    Dim SQL As String

    SQL = "UPDATE Employees " & _
          "SET Employees.Title = 'Regional Sales Manager' " & _
          "WHERE Employees.Title = 'Sales Manager'"

    DoCmd.RunSQL SQL

End Sub

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Rectangle.Tag Property (Access)

 Copy code hover
[image]

Rectangle.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents a Rectangle object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


Multi-level GROUP BY clause is not allowed in a subquery. (Error 3612)

 Copy code hover
[image]

Multi-level GROUP BY clause is not allowed in a subquery. (Error 3612)
Send feedback

An SQL subquery cannot list more than one field in a GROUP BY clause.


NavigationButton.ReadingOrder Property (Access)

 Copy code hover
[image]

NavigationButton.ReadingOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .ReadingOrder

expression A variable that represents a NavigationButton object.

Remarks

The ReadingOrder property uses the following settings.

Setting | Visual Basic | Description
Context | 0 | Reading order is determined by the language of the first character entered. If a right-to-left language character is entered first, reading order is right to left. If a left-to-right language character is entered first, reading order is left to right.
Left-to-Right | 1 | Sets the reading order to left to right.
Right-to-Left | 2 | Sets the reading order to right to left.

Example

The following example sets the reading order to right to left for the "Address" text box on the "International Shipping" form.

VBA Copy code Copy code
Forms("International Shipping").Controls("Address").ReadingOrder = 2

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Cannot create a relationship on linked ODBC tables. (Error 3613)

 Copy code hover
[image]

Cannot create a relationship on linked ODBC tables. (Error 3613)
Send feedback

The Microsoft Access database engine cannot create a relationship on linked tables in ODBC data source tables.


TextBox.ShowDatePicker Property (Access)

 Copy code hover
[image]

TextBox.ShowDatePicker Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the date picker control is displayed for the specified text box. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .ShowDatePicker

expression A variable that represents a TextBox object.

Remarks

The ShowDatePicker property.

Value | Description
0 | The date picker control is not displayed.
1 | The date picker control is displayed when the text box is bound to a Date field.

The ShowDatePicker property is not available for text boxes on reports.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Label.Name Property (Access)

 Copy code hover
[image]

Label.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a Label object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

Label Object

Other resources

Label Object Members


ListBox.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

ListBox.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Syntax

expression .ShortcutMenuBar

expression A variable that represents a ListBox object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

Example

The following example sets the "Suppliers_Toolbar" as the custom shortcut menu to display when the user clicks the right mouse button on the "Suppliers" form.

VBA Copy code Copy code
Forms("Suppliers").ShortcutMenuBar = "Suppliers_Toolbar"

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Views Collection, CommandText Property Example (VB)

 Copy code hover
[image]

Views Collection, CommandText Property Example (VB)
Send feedback

The following code demonstrates how to use the Command property to update the text of a view.

Copy code Copy code

' BeginViewsCollectionVB
Sub Main()
 On Error GoTo ViewTextError

 Dim cnn As New ADODB.Connection
 Dim cat As New ADOX.Catalog
 Dim cmd As New ADODB.Command

 ' Open the Connection
 cnn.Open _
 "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\Microsoft Office\" & _
 "Office\Samples\Northwind.mdb';"

 ' Open the catalog
 Set cat.ActiveConnection = cnn

 ' Get the command
 Set cmd = cat.Views("AllCustomers").Command

 ' Update the CommandText of the Command
 cmd.CommandText = _
 "Select CustomerId, CompanyName, ContactName From Customers"

 ' Update the View
 Set cat.Views("AllCustomers").Command = cmd

 'Clean up
 cnn.Close
 Set cat = Nothing
 Set cmd = Nothing
 Set cnn = Nothing
 Exit Sub

ViewTextError:

 Set cat = Nothing
 Set cmd = Nothing

 If Not cnn Is Nothing Then
 If cnn.State = adStateOpen Then cnn.Close
 End If
 Set cnn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndViewsCollectionVB


RDS Code Examples in Microsoft Visual Basic Scripting Edition

 Copy code hover
[image]

RDS Code Examples in Microsoft Visual Basic Scripting Edition
Send feedback

Use the following code examples to learn how to use the RDS objects, methods, and properties when writing in Microsoft Visual Basic Scripting Edition (VBScript).

Note Note

Paste the entire code example into your code editor. The example may not run correctly if partial examples are used or if paragraph formatting is lost.

Objects

  • DataControl Object Example

  • DataSpace Object Example

  • DataFactory Object Example

Methods

  • Cancel Method Example

  • CancelUpdate Method Example

  • ConvertToString Method Example

  • CreateObject Method

  • CreateRecordset Method Example

  • Query Method Example

  • Refresh Method Example

  • Reset Method Example

  • SubmitChanges Method Example

Properties

  • Connect Property Example

  • ExecuteOptions and FetchOptions Properties Example

  • FilterColumn, FilterCriterion, FilterValue, SortColumn, and SortDirection Properties Example

  • ReadyState Property Example

  • Recordset and SourceRecordset Properties Example

  • Server Property Example

  • SQL Property Example

  • URL Property Example


ComboBox.ListItemsEditForm Property (Access)

 Copy code hover
[image]

ComboBox.ListItemsEditForm Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the name of the form that is displayed when the user clicks Edit List Items. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .ListItemsEditForm

expression A variable that represents a ComboBox object.

Remarks

The AllowValueEditLists property determines whether the Edit List Items command is available when the user right-clicks a combo box that's bound to a Lookup field.

If the Lookup field is bound to a table or query, then the form specified by the ListItemsEditForm property is displayed when the user clicks Edit List Items. The user can use the form to add, delete, or edit the items to be displayed in the combo box.

The ListItemsEditForm property is not available for combo boxes on a report.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Label.BorderStyle Property (Access)

 Copy code hover
[image]

Label.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Syntax

expression .BorderStyle

expression A variable that represents a Label object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

Label Object

Other resources

Label Object Members


TextBox.GridlineTint Property (Access)

 Copy code hover
[image]

TextBox.GridlineTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineTint

expression A variable that represents a TextBox object.

Remarks

The GridlineTint property contains a numeric expression that can be used to lighten the theme color in the GridlineColor property. The default value of the GridlineTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


The specified field

 Copy code hover
[image]

The specified field <field> could refer to more than one table listed in the FROM clause of your SQL statement. (Error 3079)
Send feedback

The specified field reference could refer to more than one table listed in the FROM clause of your SQL statement. In the following example, the OrderID field exists in both the Orders and Order Details tables:

SQL Copy code Copy code
SELECT OrderID
FROM Orders, [Order Details];

Because the statement does not specify which table OrderID belongs to, it produces this error. To complete this operation, fully qualify the field reference by adding a table name. For example:

SQL Copy code Copy code
SELECT Orders.OrderID
FROM Orders, [Order Details];


DefinedSize Property (ADOX)

 Copy code hover
[image]

DefinedSize Property (ADOX)
Send feedback

Indicates the stated maximum size of the column.

Settings and Return Values

Sets and returns a Long value that is the maximum length in characters of data values.

Remarks

The default value is zero (0).

This property is read-only for Column objects already appended to a collection.


Synchronizer could not delete a file. (Error 3568)

 Copy code hover
[image]

Synchronizer could not delete a file. (Error 3568)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


Month Function (Access 2013 custom web app)

 Copy code hover
[image]

Month Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns an integer that represents the month of the specified date.

Syntax

Month (Date)

The Month function contains the following argument.

Argument name | Description
Date | An expression that can be resolved to a Date/Time value.

Remarks

Monthreturns the same value as DatePart(month, date).

If Date contains only a time part, the return value is 1, the base month.


The Recordset Object Open Method

 Copy code hover
[image]

The Recordset Object Open Method
Send feedback

Everything you need to open an ADO Recordset is built into the Open method. You can use it without explicitly creating any other objects. The syntax of this method is as follows:

Copy code Copy code
                      recordset.Open Source, ActiveConnection, CursorType, LockType, Options

All arguments are optional because the information they pass can be communicated to ADO in other ways. However, understanding each argument will help you to understand many important ADO concepts. The following topics will examine each argument of this method in more detail.

Source and Options Arguments

The Source and Options arguments appear in the same topic because they are closely related.

Copy code Copy code
                      recordset.Open Source, ActiveConnection, CursorType, LockType, Options

The Source argument is a Variant that evaluates to a valid Command object, a text command (e.g., a SQL statement), a table name, a stored procedure call, a URL, or the name of a file or Stream object containing a persistently stored Recordset. If Source is a file path name, it can be a full path ("C:\dir\file.rst"), a relative path ("..\file.rst"), or a URL ("http://files/file.rst"). You can also specify this information in the Recordset object Source property and leave the Source argument blank.

The Options argument is a Long value that indicates either or both of the following:

  • How the provider should evaluate the Source argument if it represents something other than a Command object.

  • That the Recordset should be restored from a file where it was previously saved.

This argument can contain a bitmask of CommandTypeEnum or ExecuteOptionEnum values. A CommandTypeEnum passed in the Options argument sets the CommandType property of the Recordset.

Note Note

The ExecuteOpenEnum values of adExecuteNoRecords and adExecuteStream cannot be used with Open.

If the CommandType property value equals adCmdUnknown (the default value), you might experience diminished performance, because ADO must make calls to the provider to determine whether the CommandText property is a SQL statement, a stored procedure, or a table name. If you know what type of command you are using, setting the CommandType property instructs ADO to go directly to the relevant code. If the CommandType property does not match the type of command in the CommandText property, an error occurs when you call the Open method.

For more information about using these enumerated constants for Options and with other ADO methods and properties, see CommandTypeEnum and ExecuteOptionEnum.

ActiveConnection Argument

You can pass in either a Connection object or a connection string as the ActiveConnection argument.

Copy code Copy code
                      recordset.Open Source, ActiveConnection, CursorType, LockType, Options

The ActiveConnection argument corresponds to the ActiveConnection property and specifies in which connection to open the Recordset object. If you pass a connection definition for this argument, ADO opens a new connection using the specified parameters. After opening the Recordset with a client-side cursor (CursorLocation = adUseClient), you can change the value of this property to send updates to another provider. Or you can set this property to Nothing (in Microsoft Visual Basic) or NULL to disconnect the Recordset from any provider. Changing ActiveConnection for a server-side cursor generates an error, however.

If you pass a Command object in the Source argument and also pass an ActiveConnection argument, an error occurs because the ActiveConnection property of the Command object must already be set to a valid Connection object or connection string.

CursorType Argument

Copy code Copy code
                      recordset.Open Source, ActiveConnection, CursorType, LockType, Options

As discussed in The Significance of Cursor Location, the type of cursor that your application uses will determine which capabilities are available to the resultant Recordset (if any). For a detailed examination of cursor types, see Chapter 8: Understanding Cursors and Locks.

The CursorType argument can accept any of the CursorTypeEnum values.

LockType Argument

Copy code Copy code
                      recordset.Open Source, ActiveConnection, CursorType, LockType, Options

Set the LockType argument to specify what type of locking the provider should use when opening the Recordset. The different types of locking are discussed in Chapter 8: Understanding Cursors and Locks.

The LockType argument can accept any of the LockTypeEnum values.

Retrieving Multiple Recordsets

You might occasionally need to execute a command that will return more than one result set. A common example is a stored procedure that runs against a SQL Server database, as in the following example. The stored procedure contains a COMPUTE clause to return the average price of all products in the table. The definition of the stored procedure is as follows:

Copy code Copy code

CREATE PROCEDURE ProductsWithAvgPrice
AS
SELECT ProductID, ProductName, UnitPrice
  FROM PRODUCTS
  COMPUTE AVG(UnitPrice)

The Microsoft OLE DB Provider for SQL Server returns multiple result sets to ADO when the command contains a COMPUTE clause. Therefore, the ADO code must use the NextRecordset method to access the data in the second result set, as shown here:

Copy code Copy code

'BeginNextRs
    On Error GoTo ErrHandler:

    Dim objConn As New ADODB.Connection
    Dim objCmd As New ADODB.Command
    Dim objRs As New ADODB.Recordset

    Set objConn = GetNewConnection
    objCmd.ActiveConnection = objConn

    objCmd.CommandText = "ProductsWithAvgPrice"
    objCmd.CommandType = adCmdStoredProc

    Set objRs = objCmd.Execute

    Do While Not objRs.EOF
        Debug.Print objRs(0) & vbTab & objRs(1) & vbTab & _
                    objRs(2)
        objRs.MoveNext
    Loop

    Set objRs = objRs.NextRecordset

    Debug.Print "AVG. PRICE = $ " & objRs(0)

    'clean up
    objRs.Close
    objConn.Close
    Set objRs = Nothing
    Set objConn = Nothing
    Set objCmd = Nothing
    Exit Sub

ErrHandler:
    'clean up
    If objRs.State = adStateOpen Then
        objRs.Close
    End If

    If objConn.State = adStateOpen Then
        objConn.Close
    End If

    Set objRs = Nothing
    Set objConn = Nothing
    Set objCmd = Nothing

    If Err <> 0 Then
        MsgBox Err.Source & "-->" & Err.Description, , "Error"
    End If
'EndNextRs

For more information, see NextRecordset.


The KeepLocal property cannot be set on a database; it can be set only on the objects in a database. (Error 3458)

 Copy code hover
[image]

The KeepLocal property cannot be set on a database; it can be set only on the objects in a database. (Error 3458)
Send feedback

The KeepLocal property is set to "T" for objects in a database that you do not want replicated. You cannot set this property for the entire database.


Using ADO with Microsoft Visual Basic

 Copy code hover
[image]

Using ADO with Microsoft Visual Basic
Send feedback

Setting up an ADO project and writing ADO code is similar whether you use Visual Basic or Visual Basic for Applications. This topic addresses using ADO with both Visual Basic and Visual Basic for Applications and notes any differences.

Referencing the ADO Library

The ADO library must be referenced by your project.

To reference ADO from Microsoft Visual Basic

  1. In Visual Basic, from the Project menu, select References....

  2. Select Microsoft ActiveX Data Objects x.x Library from the list. Verify that at least the following libraries are also selected:

    • Visual Basic for Applications

    • Visual Basic runtime objects and procedures

    • Visual Basic objects and procedures

    • OLE Automation

  3. Click OK.

You can use ADO just as easily with Visual Basic for Applications, using Microsoft Access, for example.

To reference ADO from Microsoft Access

  1. In Microsoft Access, select or create a module from the Modules tab in the Database window.

  2. From the Tools menu, select References....

  3. Select Microsoft ActiveX Data Objects x.x Library from the list. Verify that at least the following libraries are also selected:

    • Visual Basic for Applications

    • Microsoft Access 11.0 Object Library (or later)

  4. Click OK.

Creating ADO Objects in Visual Basic

To create an automation variable and an instance of an object for that variable, you can use two methods: Dim or CreateObject.

Dim

You can use the New keyword with Dim to declare and instantiate ADO objects in one step:

Copy code Copy code

Dim conn As New ADODB.Connection

Alternately, the Dim statement declaration and object instantiation can also be two steps:

Copy code Copy code

Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
Note Note

It is not required to explicitly use the ADODB progid with the Dim statement, assuming you have properly referenced the ADO library in your project. However, using it ensures that you won't have naming conflicts with other libraries.

For example, if you include references to both ADO and DAO in the same project, you should include a qualifier to specify which object model to use when instantiating Recordset objects, as in the following code:
Dim adoRS As ADODB.Recordset

Dim daoRS As DAO.Recordset

CreateObject

With the CreateObject method, the declaration and object instantiation must be two discrete steps:

Copy code Copy code

Dim conn1
Set conn1 = CreateObject("ADODB.Connection") As Object

Objects instantiated with CreateObject are late-bound, which means that they are not strongly typed and command-line completion is disabled. However, it does allow you to skip referencing the ADO library from your project, and enables you to instantiate specific versions of objects. For example:

Copy code Copy code

Set conn1 = CreateObject("ADODB.Connection.2.0") As Object

You could also accomplish this by specifically creating a reference to the ADO version 2.0 type library and creating the object.

Instantiating objects with the CreateObject method is typically slower than using the Dim statement.

Handling Events

In order to handle ADO events in Microsoft Visual Basic, you must declare a module-level variable using the WithEvents keyword. The variable can be declared only as part of a class module and must be declared at the module level. For a more complete discussion of handling ADO events, see Chapter 7: Handling ADO Events.

Visual Basic Examples

Many Visual Basic examples are included with the ADO documentation. For more information, see ADO Code Examples in Microsoft Visual Basic.


Count Property Example (VC++)

 Copy code hover
[image]

Count Property Example (VC++)
Send feedback

This example demonstrates the Count property with two collections in the Employee database. The property obtains the number of objects in each collection, and sets the upper limit for loops that enumerate these collections. Another way to enumerate these collections without using the Count property would be to use statements.

Copy code Copy code

// BeginCountCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include<conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void CountX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 CountX();

 //Wait here for user to see the output..
 printf("\nPress any key to Exit...");
 getch();

 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// CountX Function //
// //
///////////////////////////////////////////////////////////

void CountX()
{
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace
 _RecordsetPtr pRstEmployee = NULL;

 //Define Other Variables
 HRESULT hr = S_OK;
 _variant_t Index;
 Index.vt = VT_I2;
 int j = 0;

 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 // Open recordset with data from Employee table.
 TESTHR(pRstEmployee.CreateInstance(__uuidof(Recordset)));
 pRstEmployee->Open("Employee", strCnn, adOpenForwardOnly,
 adLockReadOnly, adCmdTable);

 // Print information about Fields collection.
 printf("%d Fields in Employee\n", pRstEmployee->Fields->Count);
 for (int intLoop = 0;
 intLoop <= (pRstEmployee->Fields->Count-1);
 intLoop++)
 {
 Index.iVal = intLoop;
 printf(" %s\n",(LPSTR) pRstEmployee->Fields->
 GetItem(Index)->Name);
 }

 // Print information about Properties collection.
 printf("\n%d Properties in Employee\n", pRstEmployee->
 Properties->Count);
 for (intLoop = 0;
 intLoop <= (pRstEmployee->Properties->Count - 1);
 intLoop++)
 {
 j++;
 Index.iVal = intLoop;
 printf(" %s\n" ,(LPSTR)pRstEmployee->Properties->
 GetItem(Index)->Name);
 if (((j % 23) == 0) || (intLoop == 11))
 {
 printf("\nPress any key to continue...");
 getch();

 //Clear the screen for the next display
 system("cls");
 j = 0;
 }
 }
 }
 catch(_com_error &e)
 {
 // Notify user of any errors that result from
 // executing the query.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstEmployee->GetActiveConnection();

 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }
 // Clean up objects before exit.
 if (pRstEmployee)
 if (pRstEmployee->State == adStateOpen)
 pRstEmployee->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;

 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n",pErr->Number,
 pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndCountCpp


Form.Form Property (Access)

 Copy code hover
[image]

Form.Form Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Form property to refer to a form or to refer to the form associated with a subformcontrol. Read-only Form.

Syntax

expression .Form

expression A variable that represents a Form object.

Remarks

This property refers to a form object. It is read-only in all views.

This property is typically used to refer to the form or report contained in a subform control. For example, the following code uses the Form property to access the OrderID control on a subform contained in the OrderDetails subform control.

VBA Copy code Copy code
Dim intOrderID As Integer
intOrderID = Forms!Orders!OrderDetails.Form!OrderID

The next example calls a function from a property sheet by using the Form property to refer to the active form that contains the control named CustomerID.

VBA Copy code Copy code
=MyFunction(Form!CustomerID)

When you use the Form property in this manner, you are referring to the active form, and the name of the form isn't necessary.

The next example is the Visual Basic equivalent of the preceding example.

VBA Copy code Copy code
X = MyFunction(Forms!Customers!CustomerID)
Note Note

When you use the Forms collection, you must specify the name of the form.

Example

The following example uses the Form property to refer to a control on a subform.

VBA Copy code Copy code
Dim curTotalAmount As Currency

curTotalAmount = Forms!Orders!OrderDetails.Form!TotalAmount

See also

Concepts

Form Object

Other resources

Form Object Members


RaiseError Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

RaiseError Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

The RaiseError action displays a popup window that contains a specified error message.

Note Note

The RaiseError action is available only in Data Macros.

Setting

The RaiseError action has the following argument.

Argument | Description
Error Description | A string expression that describes the error.

Remarks

When the RaiseError action is called, all of the operations in the current transaction are rolled back.


Chart Control

 Copy code hover
[image]

Chart Control
Send feedback

Published: July 16, 2012

You can use the chart control to embed a chart that displays Microsoft Access data from a form or report. You can then edit the chart by using Microsoft Graph from within the form or report.

Remarks

When you place a chart control on a form or report, Microsoft Access displays the Chart Wizard to help you create the chart.

Note Note

To embed or link a chart containing data from other applications, use an unbound object frame or bound object frame control.


OptionButton.LeftPadding Property (Access)

 Copy code hover
[image]

OptionButton.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the option button and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .LeftPadding

expression A variable that represents an OptionButton object.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Printer.ItemLayout Property (Access)

 Copy code hover
[image]

Printer.ItemLayout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets an AcPrintItemLayout constant indicating whether the printer lays columns across, then down, or down, then across. Read/write.

Syntax

expression .ItemLayout

expression A variable that represents a Printer object.

Example

The following example sets a variety of printer settings for the form specified in the strFormname argument of the procedure.

VBA Copy code Copy code
Sub SetPrinter(strFormname As String)

 DoCmd.OpenForm FormName:=strFormname, view:=acDesign, _
 datamode:=acFormEdit, windowmode:=acHidden

 With Forms(form1).Printer

 .TopMargin = 1440
 .BottomMargin = 1440
 .LeftMargin = 1440
 .RightMargin = 1440

 .ColumnSpacing = 360
 .RowSpacing = 360

 .ColorMode = acPRCMColor
 .DataOnly = False
 .DefaultSize = False
 .ItemSizeHeight = 2880
 .ItemSizeWidth = 2880
 .ItemLayout = acPRVerticalColumnLayout
 .ItemsAcross = 6

 .Copies = 1
 .Orientation = acPRORLandscape
 .Duplex = acPRDPVertical
 .PaperBin = acPRBNAuto
 .PaperSize = acPRPSLetter
 .PrintQuality = acPRPQMedium

 End With

 DoCmd.Close objecttype:=acForm, objectname:=strFormname, _
 Save:=acSaveYes

End Sub

See also

Concepts

Printer Object

Other resources

Printer Object Members


TextBox.CanGrow Property (Access)

 Copy code hover
[image]

TextBox.CanGrow Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the control contains. Read/write Boolean.

Syntax

expression .CanGrow

expression A variable that represents a TextBox object.

Remarks

The CanGrow property uses the following settings.

Setting | Visual Basic | Description
Yes | True (-1) | The section or control grows vertically so that all data it contains can be printed or previewed.
No | False (0) | (Default) The section or control doesn't grow. Data that doesn't fit within the fixed size of the section or control won't be printed or previewed.

This property setting is read-only in a macro or Visual Basic in any view but Design view.

You can use this property to control the appearance of printed forms and reports. When you set the property to Yes, the object automatically adjusts so any amount of data can be printed. When a control grows, the controls below it move down the page.

If you set a control's CanGrow property to Yes, Microsoft Access automatically sets the CanGrow property of the section containing the control to Yes.

Sections grow vertically across their entire width. To grow the data independently, you can place two subform or subreport controls side by side, and set their CanGrow property to Yes.

When you use the CanGrow property, remember that:

  • The property settings don't affect the horizontal spacing between controls; they affect only the vertical space the controls occupy.

  • Overlapping controls can't grow.

Note Note

  • The CanGrow property does not apply to a form or report page header and page footer sections, although it does apply to controls in such sections.

  • This property affects the display of form sections and controls only when the form is printed or previewed, not when the form is displayed in Form view, Datasheet view, or Design view.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Form.OnApplyFilter Property (Access)

 Copy code hover
[image]

Form.OnApplyFilter Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Apply Filter box in the Properties window of a form. Read/write String.

Syntax

expression .OnApplyFilter

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Apply Filter event occurs when a filter is applied or removed.

The OnApplyFilter value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Apply Filter box in the form's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Apply Filter box is blank, the property value is an empty string.

Example

The following example associates the OnApplyFilter property for the "Order Entry" form to the event "Form_ApplyFilter".

VBA Copy code Copy code
Forms("Order Entry").OnFilter = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


Database.Synchronize Method (DAO)

 Copy code hover
[image]

Database.Synchronize Method (DAO)
Send feedback

Synchronizes two replicas. (Microsoft Access workspaces only).

Syntax

expression .Synchronize(DbPathName, ExchangeType)

expression A variable that represents a Database object.

Parameters

Name | Required/Optional | Data Type | Description
DbPathName | Required | String | The path to the target replica with which database will be synchronized.
ExchangeType | Optional | Variant | A SynchronizeTypeEnum constant indicating which direction to synchronize changes between the two databases.

Remarks

You use Synchronize to exchange data and design changes between two databases. Design changes always happen first. Both databases must be at the same design level before they can exchange data. For example, an exchange of type dbRepExportChanges might cause design changes at a replica even though data changes flow only from the database to DbPathName.

The replica identified in DbPathName must be part of the same replica set. If both replicas have the same ReplicaID property setting or are Design Masters for two different replica sets, the synchronization fails.

When you synchronize two replicas over the Internet, you must use the dbRepSyncInternet constant. In this case, you specify a Uniform Resource Locator (URL) address for the DbPathName argument instead of specifying a local area network path.

Note Note

You can't synchronize partial replicas with other partial replicas. See the PopulatePartial method for more information.


Sign Function (Access 2013 custom web app)

 Copy code hover
[image]

Sign Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the positive (+1), zero (0), or negative (-1) sign of the specified expression.

Syntax

Sign (NumericExpression)

The Sign function contains the following argument.

Argument name | Description
NumericExpression | A numeric expression.


CheckBox.SpecialEffect Property (Access)

 Copy code hover
[image]

CheckBox.SpecialEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.

Syntax

expression .SpecialEffect

expression A variable that represents a CheckBox object.

Remarks

The SpecialEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | 0 | The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised | 1 | The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken | 2 | The object has a shadow on the top and left and a highlight on the bottom and right.
Etched | 3 | The object has a sunken line surrounding the control.
Shadowed | 4 | The object has a shadow below and to the right of the control.
Chiseled | 5 | The object has a sunken line below the control.

The SpecialEffect property setting affects related property settings for the BorderStyle , BorderColor , and BorderWidth properties. For example, if the SpecialEffect property is set to Raised, the settings for the BorderStyle, BorderColor, and BorderWidth properties are ignored. In addition, changing or setting the BorderStyle, BorderColor, and BorderWidth properties may cause Microsoft Access to change the SpecialEffect property setting to Flat.

Example

The following example sets the appearance of the text box "OrganizationName1" on the "Mailing List" form to raised.

VBA Copy code Copy code
Forms("Mailing List").Controls("OrganizationName1").SpecialEffect = 1

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


AccessObject.IsLoaded Property (Access)

 Copy code hover
[image]

AccessObject.IsLoaded Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsLoaded property to determine if an AccessObject is currently loaded. Read-only Boolean.

Syntax

expression .IsLoaded

expression A variable that represents an AccessObject object.

Remarks

The IsLoaded property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The specified AccessObject is loaded.
No | False | The specified AccessObject is not loaded.

Example

The following example shows how to prevent a user form opening a particular form directly from the Navigation Pane.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
'Don't let this form be opened from the Navigator
If Not CurrentProject.AllForms(cFormUsage).IsLoaded Then
    MsgBox "This form cannot be opened from the Navigation Pane.", _
        vbInformation + vbOKOnly, "Invalid form usage"
    Cancel = True
    Exit Sub
End If

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.

See also

Concepts

AccessObject Object

Other resources

AccessObject Object Members


Synchronizer cannot find the source file for messages. (Error 3564)

 Copy code hover
[image]

Synchronizer cannot find the source file for messages. (Error 3564)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


Workspaces Members (DAO)

 Copy code hover
[image]

Workspaces Members (DAO)
Send feedback

A Workspaces collection contains all active, unhidden Workspace objects of the DBEngine object. (Hidden Workspace objects are not appended to the collection and referenced by the variable to which they are assigned.)

Methods

Name | Description
Append | Adds a new Workspace to the Workspaces collection.
Delete | Deletes the specified Workspace form the Workspaces collection.
Refresh | Not supported for this object.

Properties

Name | Description
Count | Returns the number of objects in the specified collection. Read-only.


ComboBox.KeyboardLanguage Property (Access)

 Copy code hover
[image]

ComboBox.KeyboardLanguage Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .KeyboardLanguage

expression A variable that represents a ComboBox object.

Remarks

Valid values for this property are 0 (zero), which corresponds to the default system language, or plid + 2 where plid is the primary language ID of a language installed on the current system. For example, the primary language ID of English is 9, so the corresponding KeyboardLanguage setting is 11. For a list of languages and their primary language IDs, search for "Primary Language IDs" in the MSDN Web site. (An exception to this list is Traditional Chinese which is represented by the value 200.)

Setting this property to a language that is not installed may either have no effect or cause an error.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Control.ItemData Property (Access)

 Copy code hover
[image]

Control.ItemData Property (Access)
See also Send feedback

Published: July 16, 2012

The ItemData property returns the data in the bound column for the specified row in a combo box or list box. Read-only Variant.

Syntax

expression .ItemData(Index)

expression A variable that represents a Control object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Long | The row in the combo box or list box containing the data you want to return. Rows in combo and list boxes are indexed starting with zero. For example, to return the item in the sixth row of a combo box, you'd specify 5 for the rowindex argument.

Remarks

The ItemData property enables you to iterate through the list of entries in a combo box or list box. For example, suppose you wanted to iterate through all of the items in a list box to search for a particular entry. You can use the ListCount property to determine the number of rows in the list box, and then use the ItemData property to return the data for the bound column in each row.

You can also use the ItemData property to return data only from selected rows in a list box. You can iterate through the ItemsSelected collection to determine which row or rows in the list box have been selected, and use the ItemData property to return the data in those rows. You must set the MultiSelect property of the list box to Simple or Extended to enable the user to select more than one row at a time.

You can use the Column property to return data from a specified row and column, even if the specified column isn't the bound column.

See also

Concepts

Control Object

Other resources

Control Object Members


Form.Filter Property (Access)

 Copy code hover
[image]

Form.Filter Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Filter property to specify a subset of records to be displayed when a filter is applied to a form, reportquery, or table. Read/write String.

Syntax

expression .Filter

expression A variable that represents a Form object.

Remarks

If you want to specify a server filter within a Microsoft Access project (.adp) for data located on a server, use the ServerFilter property.

The Filter property is a string expression consisting of a WHERE clause without the WHERE keyword. For example, the following Visual Basic code defines and applies a filter to show only customers from the USA:

VBA Copy code Copy code
Me.Filter = "Country = 'USA'"
Me.FilterOn = True
Note Note

Setting the Filter property has no effect on the ADO Filter property.

You can use the Filter property to save a filter and apply it at a later time. Filters are saved with the objects in which they are created. They are automatically loaded when the object is opened, but they aren't automatically applied.

When a new object is created, it inherits the RecordSource , Filter, OrderBy , and OrderByOn properties of the table or query it was created from.

To apply a saved filter to a form, query, or table, you can click Apply Filter on the toolbar, click Apply Filter/Sort on the Records menu, or use a macro or Visual Basic to set the FilterOn property to True. For reports, you can apply a filter by setting the FilterOn property to Yes in the report's property sheet.

The Apply Filter button indicates the state of the Filter and FilterOn properties. The button remains disabled until there is a filter to apply. If an existing filter is currently applied, the Apply Filter button appears pressed in.

To apply a filter automatically when a form is opened, specify in the OnOpen event property setting of the form either a macro that uses the ApplyFilter action or an event procedure that uses the ApplyFilter method of the DoCmd object.

You can remove a filter by clicking the pressed-in Apply Filter button, clicking Remove Filter/Sort on the Records menu, or using Visual Basic to set the FilterOn property to False.

When the Filter property is set in form Design view, Microsoft Access does not attempt to validate the SQL expression. If the SQL expression is invalid, an error occurs when the filter is applied.

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Forms: Populate Controls/Text Boxes Based on Combobox Selection

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Form Object

Other resources

Form Object Members


ADO Code Examples in Microsoft Visual Basic

 Copy code hover
[image]

ADO Code Examples in Microsoft Visual Basic
Send feedback

Use the following code examples to learn how to use the ADO methods, properties, and events when writing in Visual Basic.

Note Note

Paste the entire code example, from Sub to End Sub, into your code editor. The example may not run correctly if partial examples are used or if paragraph formatting is lost.

Methods

  • AddNew Method Example

  • Append and CreateParameter Methods Example

  • AppendChunk and GetChunk Methods Example

  • BeginTrans, CommitTrans, and RollbackTrans Methods Example

  • Cancel Method Example

  • Clone Method Example

  • CompareBookmarks Method Example

  • ConvertToString Method Example

  • CopyRecord, CopyTo, and SaveToFile Methods Example

  • CreateRecordset Method Example

  • Delete Method Example

  • DeleteRecord and MoveRecord Methods Example

  • Execute, Requery, and Clear Methods Example

  • Find Method Example

  • GetRows Method Example

  • GetString Method Example

  • SkipLine Method, EOS, and LineSeparator Properties Example

  • Move Method Example

  • MoveFirst, MoveLast, MoveNext, and MovePrevious Methods Example

  • NextRecordset Method Example

  • Open and Close Methods Example

  • OpenSchema Method Example

  • Read, ReadText, Write, and WriteText Methods Example

  • Refresh Method Example

  • Resync Method Example

  • Save and Open Methods Example

  • Seek Method and Index Property Example

  • Supports Method Example

  • Update and CancelUpdate Methods Example

  • UpdateBatch and CancelBatch Methods Example

Properties

  • AbsolutePage, PageCount, and PageSize Properties Example

  • AbsolutePosition and CursorLocation Properties Example

  • ActiveCommand Property Example

  • ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction Properties Example

  • ActualSize and DefinedSize Properties Example

  • Attributes and Name Properties Example

  • BOF, EOF, and Bookmark Properties Example

  • CacheSize Property Example

  • ConnectionString, ConnectionTimeout, and State Properties Example

  • Count Property Example

  • CursorType, LockType, and EditMode Properties Example

  • Description, HelpContext, HelpFile, NativeError, Number, Source, and SQLState Properties Example

  • EOS and LineSeparator Properties, SkipLine Method Example

  • Filter and RecordCount Properties Example

  • IsolationLevel and Mode Properties Example

  • Item Property Example

  • MarshalOptions Property Example

  • MaxRecords Property Example

  • NumericScale and Precision Properties Example

  • Optimize Property Example

  • OriginalValue and UnderlyingValue Properties Example

  • Prepared Property Example

  • Provider and DefaultDatabase Properties Example

  • Sort Property Example

  • Source Property Example

  • State Property Example

  • Status Property Example

  • StayInSync Property Example

  • Type Property Example (Field)

  • Type Property Example (Property)

  • Value Property Example

  • Version Property Example


Errors Object Reference (DAO)

 Copy code hover
[image]

Errors Object Reference (DAO)
Send feedback

In this section

  • Errors Collection (DAO)

  • Errors Members (DAO)

  • Errors Properties (DAO)

  • Errors Methods (DAO)


ComboBox.OnKeyUp Property (Access)

 Copy code hover
[image]

ComboBox.OnKeyUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Up box in the Properties window. Read/write String.

Syntax

expression .OnKeyUp

expression A variable that represents a ComboBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyUp event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyUp

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Form.FitToScreen Property (Access)

 Copy code hover
[image]

Form.FitToScreen Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the width of the form is reduced to fit the width of the screen. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .FitToScreen

expression A variable that represents a Form object.

See also

Concepts

Form Object

Other resources

Form Object Members


NavigationControl.OnKeyPress Property (Access)

 Copy code hover
[image]

NavigationControl.OnKeyPress Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Press box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnKeyPress

expression A variable that represents a NavigationControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyPress event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyPress value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Press box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Press box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyPress property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyPress

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


ADO Dynamic Properties Reference

 Copy code hover
[image]

ADO Dynamic Properties Reference
Send feedback

In this section

  • ADO Dynamic Properties

  • ADO Dynamic Property Index

  • Optimize Property--Dynamic (ADO)

  • Prompt Property--Dynamic (ADO)

  • Reshape Name Property--Dynamic (ADO)

  • Resync Command Property--Dynamic (ADO)

  • Unique Table, Unique Schema, Unique Catalog Properties--Dynamic (ADO)

  • Update Resync Property--Dynamic (ADO)


Report.Unload Event (Access)

 Copy code hover
[image]

Report.Unload Event (Access)
See also Send feedback

Published: July 16, 2012

The Unload event occurs after a report is closed but before it's removed from the screen.

Version Information

Version Added: Access 2007

Syntax

expression .Unload(Cancel, )

expression A variable that represents a Report object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer |

Remarks

To run a macro or event procedure when these events occur, set the OnUnload property to the name of the macro or to [Event Procedure].

The Unload event is caused by user actions such as:

  • Closing the report.

  • Running the Close action in a macro.

  • Quitting an application by right-clicking the application's taskbar button and then clicking Close.

  • Quitting Windows while an application is running.

By running a macro or an event procedure when a report's Unload event occurs, you can verify that the report should be unloaded or specify actions that should take place when the report is unloaded. You can also open another report or display a dialog box requesting the user's name to make a log entry indicating who used the report.

When you close a report, the following events occur in this order:

Unload → Deactivate → Close

The Unload event occurs before the Close event. The Unload event can be canceled, but the Close event cannot.

Note Note

When you create macros or event procedures for events related to the Unload event, such as Deactivate and LostFocus, be sure that they don't conflict (for example, make sure you don't cause something to happen in one macro or procedure that is canceled in another) and that they don't cause cascading events.

See also

Concepts

Report Object

Other resources

Report Object Members


ListBox.KeyDown Event (Access)

 Copy code hover
[image]

ListBox.KeyDown Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyDown(KeyCode, Shift)

expression A variable that represents a ListBox object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyDown property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyDown event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyDown event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyDown event occurs when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

Example

The following example determines whether you have pressed the SHIFT, CTRL, or ALT key.

To try the example, add the following event procedure to a form containing a text box named KeyHandler.

VBA Copy code Copy code
Private Sub KeyHandler_KeyDown(KeyCode As Integer, _
     Shift As Integer)
    Dim intShiftDown As Integer, intAltDown As Integer
    Dim intCtrlDown As Integer

    ' Use bit masks to determine which key was pressed.
    intShiftDown = (Shift And acShiftMask) > 0
    intAltDown = (Shift And acAltMask) > 0
    intCtrlDown = (Shift And acCtrlMask) > 0
    ' Display message telling user which key was pressed.
    If intShiftDown Then MsgBox "You pressed the SHIFT key."
    If intAltDown Then MsgBox "You pressed the ALT key."
    If intCtrlDown Then MsgBox "You pressed the CTRL key."
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Fields Properties (DAO)

 Copy code hover
[image]

Fields Properties (DAO)
Send feedback

In this section

  • Fields.Count Property (DAO)


ComplexType Members (DAO)

 Copy code hover
[image]

ComplexType Members (DAO)
Send feedback

Represents a multi-valued field.

Properties

Name | Description
Fields | Returns a Fields collection that represents all stored Field objects for the specified object. Read-only.


Workspace.LoginTimeout Property (DAO)

 Copy code hover
[image]

Workspace.LoginTimeout Property (DAO)
Send feedback

Sets or returns the number of seconds before an error occurs when you attempt to log on to an ODBC database.

Syntax

expression .LoginTimeout

expression A variable that represents a Workspace object.

Remarks

The default LoginTimeout property setting is 20 seconds. When the LoginTimeout property is set to 0, no timeout occurs.

When you're attempting to log on to an ODBC database, such as Microsoft SQL Server, the connection can fail as a result of network errors or because the server isn't running. Rather than waiting for the default 20 seconds to connect, you can specify how long to wait before raising an error. Logging on to the server happens implicitly as part of a number of different events, such as running a query on an external server database.


SmartTag.Parent Property (Access)

 Copy code hover
[image]

SmartTag.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a SmartTag object.

See also

Concepts

SmartTag Object

Other resources

SmartTag Object Members


NavigationButton.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

NavigationButton.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents a NavigationButton object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.BorderThemeColorIndex=2

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Connection.Name Property (DAO)

 Copy code hover
[image]

Connection.Name Property (DAO)
Send feedback

Rreturns the name of a Connection.

Syntax

expression .Name

expression A variable that represents a Connection object.

Remarks

You can use an object's Name property with the Visual Basic for Applications Dim statement in code to create other instances of the object.


Recordset, SourceRecordset Properties (RDS)

 Copy code hover
[image]

Recordset, SourceRecordset Properties (RDS)
Send feedback

Indicates the Recordset object returned from a custom business object.

Syntax

DataControl.SourceRecordset = Recordset

Recordset = DataControl.Recordset

Parameters

  • DataControl

  • An object variable that represents an RDS.DataControl object.

  • Recordset

  • An object variable that represents a Recordset object.

Remarks

You can set the SourceRecordset property to a Recordset returned from a custom business object.

These properties allow an application to handle the binding process by means of a custom process. They receive a rowset wrapped in a Recordset so that you can interact directly with the Recordset, performing actions such as setting properties or iterating through the Recordset.

You can set the SourceRecordset property or read the Recordset property at run time in scripting code.

SourceRecordset is a write-only property, in contrast to the Recordset property, which is a read-only property.


Attachment.Name Property (Access)

 Copy code hover
[image]

Attachment.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents an Attachment object.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


TabControl Object (Access)

 Copy code hover
[image]

TabControl Object (Access)
See also Send feedback

Published: July 16, 2012

A tab control contains multiple pages on which you can place other controls, such as text boxes or option buttons. When a user clicks the corresponding tab, that page becomes active.

Remarks

With the tab control, you can construct a single form or dialog box that contains several different tabs, and you can group similar options or data on each tab's page. For example, you might use a tab control on an Employees form to separate general and personal information.

See also

Concepts

Access Object Model Reference

Other resources

TabControl Object Members


How to: Set Properties of Data Access Objects in Visual Basic

 Copy code hover
[image]

How to: Set Properties of Data Access Objects in Visual Basic
Send feedback

Data Access Objects (DAO) enable you to manipulate the structure of your database and the data it contains from Visual Basic. Many DAO objects correspond to objects that you see in your database—for example, a TableDef object corresponds to a Microsoft Access table. A Field object corresponds to a field in a table.

Most of the properties you can set for DAO objects are DAO properties. These properties are defined by the Microsoft Access database engine and are set the same way in any application that includes the Access database engine. Some properties that you can set for DAO objects are defined by Microsoft Access, and are not automatically recognized by the Access database engine. How you set properties for DAO objects depends on whether a property is defined by the Access database engine or by Microsoft Access.

Setting DAO Properties for DAO Objects

To set a property that is defined by the Access database engine, refer to the object in the DAO hierarchy. The easiest and fastest way to do this is to create object variables that represent the different objects you need to work with, and refer to the object variables in subsequent steps in your code. For example, the following code example creates a new TableDef object and sets its Name property.

Copy code Copy code
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Set dbs = CurrentDb
Set tdf = dbs.CreateTableDef
tdf.Name = "Contacts"

Setting Microsoft Access Properties for DAO Objects

When you set a property that is defined by Microsoft Access, but applies to a DAO object, the Access database engine does not automatically recognize the property as a valid property. The first time you set the property, you must create the property and append it to the Properties collection of the object to which it applies. Once the property is in the Properties collection, it can be set in the same manner as any DAO property.

If the property is set for the first time in the user interface, it is automatically added to the Properties collection, and you can set it normally.

When writing procedures to set properties defined by Microsoft Access, you should include error-handling code to verify that the property you are setting already exists in the Properties collection. See the Help topic about the CreateProperty method or the individual property topic for more information.

Keep in mind that when you create the property, you must correctly specify its Type property before you append it to the Properties collection. You can determine the Type property based on the information in the Settings section of the Help topic for the individual property. The following table lists some guidelines for determining the setting of the Type property.

If the property setting is | Then the Type property setting should be
A string | dbText
True/False | dbBoolean
An integer | dbInteger

The following table lists some Microsoft Access-defined properties that apply to DAO objects.

DAO object | Microsoft Access-defined properties
Database | AppTitle, AppIcon, StartupShowDBWindow, StartupShowStatusBar, AllowShortcutMenus, AllowFullMenus, AllowBuiltInToolbars, AllowToolbarChanges, AllowBreakIntoCode, AllowSpecialKeys, Replicable, ReplicationConflictFunction
Container | Title, Subject, Author, Manager, Company, Category, Keywords, Comments, Hyperlink Base (See the Summary tab of the DatabaseName Properties dialog box. To view the database properties, click the Microsoft Office Button [image] , point to the arrow next to Manage, and then click Database Properties.)
TableDef | DatasheetBackColor, DatasheetCellsEffect, DatasheetFontHeight, DatasheetFontItalic, DatasheetFontName, DatasheetFontUnderline, DatasheetFontWeight, DatasheetForeColor, DatasheetGridlinesBehavior, DatasheetGridlinesColor, Description, FrozenColumns, RowHeight, ShowGrid
QueryDef | DatasheetBackColor, DatasheetCellsEffect, DatasheetFontHeight, DatasheetFontItalic, DatasheetFontName, DatasheetFontUnderline, DatasheetFontWeight, DatasheetForeColor, DatasheetGridlinesBehavior, DatasheetGridlinesColor, Description, FailOnError, FrozenColumns, LogMessages, MaxRecords, RecordLocks, RowHeight, ShowGrid, UseTransaction
Field | Caption, ColumnHidden, ColumnOrder, ColumnWidth, DecimalPlaces, Description, Format, InputMask


Cursor and Lock Characteristics

 Copy code hover
[image]

Cursor and Lock Characteristics
Send feedback

While the characteristics of a cursor depend upon capabilities of the provider, the following advantages and disadvantages generally apply to the various types of cursors and locks.

Cursor or lock type

Advantages

Disadvantages

adOpenForwardOnly

  • Low resource requirements

  • Cannot scroll backward

  • No data concurrency

adOpenStatic

  • Scrollable

  • No data concurrency

adOpenKeyset

  • Some data concurrency

  • Scrollable

  • Higher resource requirements

  • Not available in disconnected scenario

adOpenDynamic

  • High data concurrency

  • Scrollable

  • Highest resource requirements

  • Not available in disconnected scenario

adLockReadOnly

  • Low resource requirements

  • Highly scalable

  • Data not updatable through cursor

adLockBatchOptimistic

  • Batch updates

  • Allows disconnected scenarios

  • Other users able to access data

  • Data can be changed by multiple users at once

adLockPessimistic

  • Data cannot be changed by other users while locked

  • Prevents other users from accessing data while locked

adLockOptimistic

  • Other users able to access data

  • Data can be changed by multiple users at once


Hierarchies Collection (ADO MD)

 Copy code hover
[image]

Hierarchies Collection (ADO MD)
Send feedback

Contains the set Hierarchy objects from a dimension.

Remarks

Hierarchies is a standard ADO collection. With the properties and methods of a collection, you can do the following:

  • Obtain the number of objects in the collection with the Count property.

  • Return an object from the collection with the default Item property.

  • Update the objects in the collection from the provider with the Refresh method.


Attachment.IsVisible Property (Access)

 Copy code hover
[image]

Attachment.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property to determine whether a control on a report is visible. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .IsVisible

expression A variable that represents an Attachment object.

Remarks

You can set the IsVisible property only in the Print event of a report section that contains the control.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


The INSERT INTO statement contains the following unknown field name:

 Copy code hover
[image]

The INSERT INTO statement contains the following unknown field name: <field name>. Make sure you have typed the name correctly, and try the operation again.(Error 3127)
Send feedback

You tried to use an INSERT INTO statement with the specified field name, but that field does not exist in the output table. Make sure you have typed the name correctly, and then try the operation again.


SubForm.FilterOnEmptyMaster Property (Access)

 Copy code hover
[image]

SubForm.FilterOnEmptyMaster Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether all records are displayed when the subform's master field is Null. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .FilterOnEmptyMaster

expression A variable that represents a SubForm object.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Application.DDEPoke Method (Access)

 Copy code hover
[image]

Application.DDEPoke Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the DDEPoke statement to supply text data from a client application to a server application over an open dynamic data exchange (DDE) channel.

Syntax

expression .DDEPoke(ChanNum, Item, Data)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
ChanNum | Required | Variant | A channel number, an integer returned by the DDEInitiate function.
Item | Required | String | The name of a data item recognized by the application specified by the DDEInitiate function. Check the application's documentation for a list of possible items.
Data | Required | String | The data to be supplied to the other application.

Remarks

For example, if you have an open DDE channel between Microsoft Access and Microsoft Excel, you can use the DDEPoke statement to transfer text from a Microsoft Access database to a Microsoft Excel spreadsheet. In this example, Microsoft Access acts as the client application, and Microsoft Excel acts as the server application.

The value of the item argument depends on the application and topic specified when the channel indicated by the channum argument is opened. For example, the item argument may be a range of cells in a Microsoft Excel spreadsheet.

The string contained in the data argument must be an alphanumeric text string. No other formats are supported. For example, the data argument could be a number to fill a cell in a specified range in an Excel worksheet.

If the channum argument isn't an integer corresponding to an open channel or if the other application doesn't recognize or accept the specified data, a run-time error occurs.

If you need to manipulate another application's objects from Microsoft Access, you may want to consider using Automation.

See also

Concepts

Application Object

Other resources

Application Object Members


BoundObjectFrame.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

BoundObjectFrame.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Syntax

expression .ShortcutMenuBar

expression A variable that represents a BoundObjectFrame object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

Example

The following example sets the "Suppliers_Toolbar" as the custom shortcut menu to display when the user clicks the right mouse button on the "Suppliers" form.

VBA Copy code Copy code
Forms("Suppliers").ShortcutMenuBar = "Suppliers_Toolbar"

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


CustomControl Events (Access)

 Copy code hover
[image]

CustomControl Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
Updated | The Updated event occurs when an OLE object's data has been modified.


Setting DCOM Stream Marshaling Format

 Copy code hover
[image]

Setting DCOM Stream Marshaling Format
Send feedback

A client computer using components from RDS 1.5 or earlier is not compatible with a server using components from RDS 2.0 or later. When using DCOM as the underlying protocol, the support for RDS 2.0 or later is more efficient in transporting Recordset objects. If your client is running components from RDS 1.5 or earlier, you can set your server to work with the previous RDS support (called RDS 1.0) or the newer RDS support (called RDS 2.0 or later). Set either of the following registry entries:

Copy code Copy code

[HKEY_CLASSES_ROOT]
\CLSID
 \[58ECEE30-E715-11CF-B0E3-00AA003F000F}
 \ADTGOptions]"MarshalFormat"="RDS10"

-or-

Copy code Copy code

[HKEY_CLASSES_ROOT]
\CLSID
 \[58ECEE30-E715-11CF-B0E3-00AA003F000F}
 \ADTGOptions]"MarshalFormat"="RDS20"


Field.ForeignName Property (DAO)

 Copy code hover
[image]

Field.ForeignName Property (DAO)
Send feedback

Sets or returns a value that specifies the name of the Field object in a foreign table that corresponds to a field in a primary table for a relationship (Microsoft Access workspaces only).

Syntax

expression .ForeignName

expression A variable that represents a Field object.

Remarks

If the Relation object isn't appended to the Database, but the Field is appended to the Relation object, the ForeignName property is read/write. Once the Relation object is appended to the database, the ForeignName property is read-only.

Only a Field object that belongs to the Fields collection of a Relation object can support the ForeignName property.

The Name and ForeignName property settings for a Field object specify the names of the corresponding fields in the primary and foreign tables of a relationship. The Table and ForeignTable property settings for a Relation object determine the primary and foreign tables of a relationship.

For example, if you had a list of valid part codes (in a field named PartNo) stored in a ValidParts table, you could establish a relationship with an OrderItem table such that if a part code were entered into the OrderItem table, it would have to already exist in the ValidParts table. If the part code didn't exist in the ValidParts table and you had not set the Attributes property of the Relation object to dbRelationDontEnforce, a trappable error would occur.

In this case, the ValidParts table is the foreign table, so the ForeignTable property of the Relation object would be set to ValidParts and the Table property of the Relation object would be set to OrderItem. The Name and ForeignName properties of the Field object in the Relation object's Fields collection would be set to PartNo.

Example

This example shows how the Table, ForeignTable, and ForeignName properties define the terms of a Relation between two tables.

VBA Copy code Copy code
Sub ForeignNameX()

 Dim dbsNorthwind As Database
 Dim relLoop As Relation

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 Debug.Print "Relation"
 Debug.Print " Table - Field"
 Debug.Print " Primary (One) ";
 Debug.Print ".Table - .Fields(0).Name"
 Debug.Print " Foreign (Many) ";
 Debug.Print ".ForeignTable - .Fields(0).ForeignName"

 ' Enumerate the Relations collection of the Northwind
 ' database to report on the property values of
 ' the Relation objects and their Field objects.
 For Each relLoop In dbsNorthwind.Relations
 With relLoop
 Debug.Print
 Debug.Print .Name & " Relation"
 Debug.Print " Table - Field"
 Debug.Print " Primary (One) ";
 Debug.Print .Table & " - " & .Fields(0).Name
 Debug.Print " Foreign (Many) ";
 Debug.Print .ForeignTable & " - " & _
 .Fields(0).ForeignName
 End With
 Next relLoop

 dbsNorthwind.Close

End Sub


WSParameters Members (Access)

 Copy code hover
[image]

WSParameters Members (Access)
Send feedback

Published: July 16, 2012

Represents the collection of parameters of defined for an Operation.

Properties

Name | Description
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Object.
Parent | Returns the parent object for the specified object. Read-only.


Type mismatch in JOIN expression. (Error 3615)

 Copy code hover
[image]

Type mismatch in JOIN expression. (Error 3615)
Send feedback

A JOIN expression is attempting to join two tables on fields of incompatible data types. For example, you will get this error if you attempt to join a Memo field with a Text field.


AllMacros.Item Property (Access)

 Copy code hover
[image]

AllMacros.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.

Syntax

expression .Item(var)

expression A variable that represents an AllMacros object.

Parameters

Name | Required/Optional | Data Type | Description
var | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

AllMacros Collection

Other resources

AllMacros Object Members


AllViews.Item Property (Access)

 Copy code hover
[image]

AllViews.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.

Syntax

expression .Item(var)

expression A variable that represents an AllViews object.

Parameters

Name | Required/Optional | Data Type | Description
var | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

AllViews Collection

Other resources

AllViews Object Members


Recordset.FindFirst Method (DAO)

 Copy code hover
[image]

Recordset.FindFirst Method (DAO)
Send feedback

Locates the first record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only).

Syntax

expression .FindFirst(Criteria)

expression A variable that represents a Recordset object.

Parameters

Name | Required/Optional | Data Type | Description
Criteria | Required | String | A String used to locate the record. It is like the WHERE clause in an SQL statement, but without the word WHERE.

Remarks

If you want to include all the records in your search — not just those that meet a specific condition — use the Move methods to move from record to record. To locate a record in a table-type Recordset, use the Seek method.

If a record matching the criteria isn't located, the current record pointer is unknown, and the NoMatch property is set to True. If recordset contains more than one record that satisfies the criteria, FindFirst locates the first occurrence, FindNext locates the next occurrence, and so on.

Each of the Find methods begins its search from the location and in the direction specified in the following table.

Find method | Begins searching at | Search direction
FindFirst | Beginning of recordset | End of recordset
FindLast | End of recordset | Beginning of recordset
FindNext | Current record | End of recordset
FindPrevious | Current record | Beginning of recordset

Using one of the Find methods isn't the same as using a Move method, however, which simply makes the first, last, next, or previous record current without specifying a condition. You can follow a Find operation with a Move operation.

Always check the value of the NoMatch property to determine whether the Find operation has succeeded. If the search succeeds, NoMatch is False. If it fails, NoMatch is True and the current record isn't defined. In this case, you must position the current record pointer back to a valid record.

Using the Find methods with Microsoft Access database engine-connected ODBC-accessed recordsets can be inefficient. You may find that rephrasing your criteria to locate a specific record is faster, especially when working with large recordsets.

When working with Microsoft Access database engine-connected ODBC databases and large dynaset-type Recordset objects, you might discover that using the Find methods or using the Sort or Filter property is slow. To improve performance, use SQL queries with customized ORDER BY or WHERE clauses, parameter queries, or QueryDef objects that retrieve specific indexed records.

You should use the U.S. date format (month-day-year) when you search for fields containing dates, even if you're not using the U.S. version of the Microsoft Access database engine; otherwise, the data may not be found. Use the Visual Basic Format function to convert the date. For example:

VBA Copy code Copy code
rstEmployees.FindFirst "HireDate > #" _
    & Format(mydate, 'm-d-yy' ) & "#"

If criteria is composed of a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strSQL = "PRICE > " & lngPrice, and lngPrice = 125,50), an error occurs when you try to call the method. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and Microsoft Access SQL only accepts U.S. decimal characters.

Note Note

  • For best performance, the criteria should be in either the form "field = value" where field is an indexed field in the underlying base table, or "field LIKE prefix" where field is an indexed field in the underlying base table and prefix is a prefix search string (for example, "ART*" ).

  • In general, for equivalent types of searches, the Seek method provides better performance than the Find methods. This assumes that table-type Recordset objects alone can satisfy your needs.

Example

The following example shows how to use the FindFirst and FindNext methods to find a record in a Recordset.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Sub FindOrgName()

    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset

    'Get the database and Recordset
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("tblCustomers")

    'Search for the first matching record
    rst.FindFirst "[OrgName] LIKE '*parts*'"

    'Check the result
    If rst.NoMatch Then
        MsgBox "Record not found."
        GotTo Cleanup
    Else
        Do While Not rst.NoMatch
            MsgBox "Customer name: " & rst!CustName
            rst.FindNext "[OrgName] LIKE '*parts*'"
        Loop

        'Search for the next matching record
        rst.FindNext "[OrgName] LIKE '*parts*'"
    End If

    Cleanup:
        rst.Close
        Set rst = Nothing
        Set dbs = Nothing

End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Syntax error in number. (Error 2420)

 Copy code hover
[image]

Syntax error in number. (Error 2420)
Send feedback

You entered a value that is invalid. This can occur if a nonnumeric value is provided as part of the expression.


BoundObjectFrame.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

BoundObjectFrame.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified frame. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthBottom

expression A variable that represents a BoundObjectFrame object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


ComboBox.GridlineThemeColorIndex Property (Access)

 Copy code hover
[image]

ComboBox.GridlineThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineThemeColorIndex

expression A variable that represents a ComboBox object.

Remarks

The GridlineThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 (Default) | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the GridlineThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Image.BorderWidth Property (Access)

 Copy code hover
[image]

Image.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Syntax

expression .BorderWidth

expression A variable that represents an Image object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

Image Object

Other resources

Image Object Members


Recordset2.FindLast Method (DAO)

 Copy code hover
[image]

Recordset2.FindLast Method (DAO)
Send feedback

Locates the last record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only).

Syntax

expression .FindLast(Criteria)

expression A variable that represents a Recordset2 object.

Parameters

Name | Required/Optional | Data Type | Description
Criteria | Required | String | A String used to locate the record. It is like the WHERE clause in an SQL statement, but without the word WHERE.

Remarks

If you want to include all the records in your search — not just those that meet a specific condition — use the Move methods to move from record to record. To locate a record in a table-type Recordset, use the Seek method.

If a record matching the criteria isn't located, the current record pointer is unknown, and the NoMatch property is set to True. If recordset contains more than one record that satisfies the criteria, FindFirst locates the first occurrence, FindNext locates the next occurrence, and so on.

Each of the Find methods begins its search from the location and in the direction specified in the following table.

Find method | Begins searching at | Search direction
FindFirst | Beginning of recordset | End of recordset
FindLast | End of recordset | Beginning of recordset
FindNext | Current record | End of recordset
FindPrevious | Current record | Beginning of recordset

When you use the FindLast method, the Microsoft Access database engine fully populates your Recordset before beginning the search, if this hasn't already happened.

Using one of the Find methods isn't the same as using a Move method, however, which simply makes the first, last, next, or previous record current without specifying a condition. You can follow a Find operation with a Move operation.

Always check the value of the NoMatch property to determine whether the Find operation has succeeded. If the search succeeds, NoMatch is False. If it fails, NoMatch is True and the current record isn't defined. In this case, you must position the current record pointer back to a valid record.

Using the Find methods with Microsoft Access database engine-connected ODBC-accessed recordsets can be inefficient. You may find that rephrasing your criteria to locate a specific record is faster, especially when working with large recordsets.

When working with Microsoft Access database engine-connected ODBC databases and large dynaset-type Recordset objects, you might discover that using the Find methods or using the Sort or Filter property is slow. To improve performance, use SQL queries with customized ORDER BY or WHERE clauses, parameter queries, or QueryDef objects that retrieve specific indexed records.

You should use the U.S. date format (month-day-year) when you search for fields containing dates, even if you're not using the U.S. version of the Microsoft Access database engine; otherwise, the data may not be found. Use the Visual Basic Format function to convert the date. For example:

VBA Copy code Copy code
rstEmployees.FindFirst "HireDate > #" _
    & Format(mydate, 'm-d-yy' ) & "#"

If criteria is composed of a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strSQL = "PRICE > " & lngPrice, and lngPrice = 125,50), an error occurs when you try to call the method. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and Microsoft Access SQL only accepts U.S. decimal characters.

Note Note

  • For best performance, the criteria should be in either the form "field = value" where field is an indexed field in the underlying base table, or "field LIKE prefix" where field is an indexed field in the underlying base table and prefix is a prefix search string (for example, "ART*" ).

  • In general, for equivalent types of searches, the Seek method provides better performance than the Find methods. This assumes that table-type Recordset objects alone can satisfy your needs.


ListBox.Exit Event (Access)

 Copy code hover
[image]

ListBox.Exit Event (Access)
See also Send feedback

Published: July 16, 2012

The Exit event occurs just before a control loses the focus to another control on the same form or report.

Syntax

expression .Exit(Cancel)

expression A variable that represents a ListBox object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | Set to True to cancel the event.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when this event occurs, set the OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Exit event occurs before the LostFocus event.

Unlike the LostFocus event, the Exit event does not occur when a form loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Call Procedures in a Subform or Subreport

 Copy code hover
[image]

Call Procedures in a Subform or Subreport
Send feedback

You can call a procedure in a module associated with a subform or subreport in one of two ways. If the form containing the subform is open in Form view, you can refer to the procedure as a method on the subform. The following example shows how to call the procedure GetProductID in the Orders Subform, which is bound to a subform control on the Orders form:

In the Orders Subform class module enter:

Copy code Copy code
Public Function GetProductID() As Variant
 ' Return current productID.
 GetProductID = ProductID
End Function
Copy code Copy code
Forms!Orders![Orders Subform].Form.GetProductID

You can also create a new instance of the form that is being used as a subform, even if neither the main form nor the subform is open, and call the procedure. This will work for any form, whether or not it is being used as a subform. The following example shows how to create an instance of the Orders Subform and call the GetProductID procedure:

Copy code Copy code
Dim frm As New [Form_Orders Subform]
frm.GetProductID
Note Note

When you create a new instance of a form with a name consisting of more than one word, enclose the class name of the form in brackets, as shown in the preceding example.


TextBox.Top Property (Access)

 Copy code hover
[image]

TextBox.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Syntax

expression .Top

expression A variable that represents a TextBox object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Report.Scale Method (Access)

 Copy code hover
[image]

Report.Scale Method (Access)
See also Send feedback

Published: July 16, 2012

The Scale method defines the coordinate system for a Report object.

Syntax

expression .Scale(flags, x1, y1, x2, y2)

expression A variable that represents a Report object.

Parameters

Name | Required/Optional | Data Type | Description
flags | Required | Integer |
x1 | Required | Single | A value for the horizontal coordinate that defines the position of the upper-left corner of the object.
y1 | Required | Single | A value for the horizontal coordinate that defines the position of the upper-left corner of the object.
x2 | Required | Single | A value for the horizontal coordinate that defines the position of the lower-right corner of the object.
y2 | Required | Single | A value for the vertical coordinate that defines the position of the lower-right corner of the object.

Return Value

Nothing

Remarks

You can use this method only in an event procedure or a macro specified by the OnPrint or OnFormat event property for a report section, or the OnPage event property for a report.

You can use the Scale method to reset the coordinate system to any scale you choose. Using the Scale method with no arguments resets the coordinate system to twips. The Scale method affects the coordinate system for the Print method and the report graphics methods, which include the Circle , Line , and PSet methods.

Example

The following example draws a circle with one scale, then uses the Scale method to change the scale and draw another circle with the new scale.

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 DrawCircle
End Sub

Sub DrawCircle()
 Dim sngHCtr As Single, sngVCtr As Single
 Dim sngNewH As Single, sngNewV As Single
 Dim sngRadius As Single

 Me.ScaleMode = 3 ' Set scale to pixels.
 sngHCtr = Me.ScaleWidth / 2 ' Horizontal center.
 sngVCtr = Me.ScaleHeight / 2 ' Vertical center.
 sngRadius = Me.ScaleHeight / 3 ' Circle radius.
 ' Draw circle.
 Me.Circle (sngHCtr, sngVCtr), sngRadius
 ' New horizontal scale.
 sngNewH = Me.ScaleWidth * 0.9
 ' New vertical scale.
 sngNewV = Me.ScaleHeight * 0.9
 ' Change to new scale.
 Me.Scale(0, 0)-(sngNewH, sngNewV)
 ' Draw circle.
 Me.Circle (sngHCtr + 100, sngVCtr), sngRadius, RGB(0, 256, 0)
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


ImportSharePointList Macro Action

 Copy code hover
[image]

ImportSharePointList Macro Action
Send feedback

You can use the ImportSharePointList action to import or link data from a Microsoft SharePoint Foundation site.

Note 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.

Setting

The ImportSharePointList action has the following arguments.

Action argument

Description

Transfer Type

Select the type of transfer.

  • Select Import to copy the SharePoint Foundation data into a table in Microsoft Access. Updates to the data in Access do not affect the data in SharePoint Foundation. Likewise, updates to the data in SharePoint Foundation do not affect the data in Access.

  • Select Link to create a linked table in Access that links to the data in SharePoint Foundation. Updates to the data in Access are reflected in SharePoint Foundation. Likewise, updates to the data in SharePoint Foundation are reflected in Access.

Site Address

Enter the full path of the SharePoint site.

List ID

Enter the name or GUID of the list to be transferred. Required argument.

View ID

Enter the GUID of the view for the list you want to use. Leave this argument blank to transfer all rows and columns in the list.

Table Name

Enter the name you want displayed for the table or linked table in Access.

Get Lookup Display Values

Select Yes to transfer display values for Lookup fields instead of the ID used to perform the lookup.

Remarks

  • This action has the same effect as clicking SharePoint List in the Import group on the External Data tab. The arguments for the action correspond to the choices you make in the Get External Data Wizard.

  • To run the ImportSharePointList action in a VBA module, use the TransferSharePointList method of the DoCmd object.

  • If you specify a nonexistent list or view, no error occurs, and no data is transferred.

  • A GUID is a unique hexadecimal identifier for a list or a view. A GUID must be entered in the following format, where each "F" is a hexadecimal number (0 through 9 or A through F).

    Copy code Copy code
    {FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF}

    You can obtain the GUID for a list or view from the SharePoint site by using the following procedure:

    1. Open the list in SharePoint Foundation.

    2. If the view you want is not displayed, click the View drop-down arrow and then select the view you want.

    3. Click the View drop-down arrow and then select Modify this View.The address in the browser's address bar contains the GUIDs for both the list and the view. The GUID for the list follows List=, and the GUID for the view follows View=. However, in the address, each { (left brace) character is represented by the string %7B, each - (hyphen) character is represented by the string %2D, and each } (right brace) character is represented by the string %7D. For example:

      Copy code Copy code
      http://MySite12/_layouts/ViewEdit.aspx?List=%7B2A82A404%2D5529%2D47DC%2DAE13%2DAC1D9BC0A84F%7D&View=%7B357B4FE6%2D44CF%2D4275%2DB91F%2D46558301579B%7D

      Before you can use the GUIDs from the address as arguments in this macro action, you must replace each %7B string with the { character, replace each %2D string with the - character, and replace each %7D string with the } character. Do not include the & (ampersand) character that follows the %7D string in the list GUID.


AcQuitOption Enumeration (Access)

 Copy code hover
[image]

AcQuitOption Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the Quit method to specify whether or not to save changes to the database when quitting Microsoft Access.

Name | Value | Description
acQuitPrompt | 0 | Displays a dialog box that asks whether you want to save any database objects that have been changed but not saved.
acQuitSaveAll | 1 | (Default) Saves all objects without displaying a dialog box.
acQuitSaveNone | 2 | Quits Microsoft Access without saving any objects.


CommandButton.FontBold Property (Access)

 Copy code hover
[image]

CommandButton.FontBold Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontBold property to specify whether a font appears in a bold style in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontBold

expression A variable that represents a CommandButton object.

Remarks

The FontBold property uses the following settings.

Setting | Description
True | The text is bold.
False | (Default) The text isn't bold.

To use the FontBold property on a report, first create a Printevent procedure that prints the desired text.

A font's appearance on screen and in print may differ, depending on your computer and printer.

The FontWeight property, which is available in the property sheet for controls, can also be used to set the line width for a control's text. The FontBold property gives you a quick way to make text bold; the FontWeight property gives you finer control over the line width setting for text. The following table shows the relationship between these properties' settings.

If | Then
FontBold = False | FontWeight = Normal (400)
FontBold = True | FontWeight = Bold (700)
FontWeight < 700 | FontBold = False
FontWeight > = 700 | FontBold = True

Example

The following Print event procedure prints a report title and the current date in a bold style on a report at the coordinates specified by the CurrentX and CurrentY property settings.

VBA Copy code Copy code
Private Sub ReportHeader0_Print(Cancel As Integer, _
 PrintCount As Integer)
 Dim MyDate

 MyDate = Date
 Me.FontBold = True
 ' Print report title in bold.
 Me.Print("Sales Management Report")
 Me.Print(MyDate)
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


NavigationButton.BorderTint Property (Access)

 Copy code hover
[image]

NavigationButton.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderTint

expression A variable that represents a NavigationButton object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


XSLT Transformations
Send feedback

XSLT Transformations

XSLT can be applied to the generated XML to transform it into another format. Understanding the XML format in ADO helps in developing XSLT templates that can transform it into a more user-friendly form.

For example, you know that each row of the Recordset is saved as the z:row element inside the rs:data element. Similarly, each field of the Recordset is saved as an attribute-value pair for this element.

The following XSLT script can be applied to the XML shown in the previous section to transform it into an HTML table to be displayed in the browser:

Copy code Copy code

<?xml version="1.0" encoding="ISO-8859-1"?>
<html xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<body STYLE="font-family:Arial, helvetica, sans-serif; font-size:12pt; background-color:white">
<table border="1" style="table-layout:fixed" width="600">
  <col width="200"></col>
  <tr bgcolor="teal">
    <th><font color="white">CustomerId</font></th>
    <th><font color="white">CompanyName</font></th>
    <th><font color="white">ContactName</font></th>
  </tr>
<xsl:for-each select="xml/rs:data/z:row">
  <tr bgcolor="navy">
    <td><font color="white"><xsl:value-of select="@CustomerID"/></font></td>
    <td><font color="white"><xsl:value-of select="@CompanyName"/></font></td>
    <td><font color="white"><xsl:value-of select="@ContactName"/></font></td>
  </tr>
</xsl:for-each>
</table>
</body>
</html>

The XSLT converts the XML stream generated by the ADO Save method into an HTML table which displays each field of the Recordset along with a table heading. Table headings and rows also are assigned different fonts and colors.


Dimension Properties, Methods, and Events (ADO MD)

 Copy code hover
[image]

Dimension Properties, Methods, and Events (ADO MD)
Send feedback

Properties/Collections

Description Property

Hierarchies Collection

Name Property

Properties Collection

UniqueName Property

Methods

None.

Events

None.


CommandButton.Gradient Property (Access)

 Copy code hover
[image]

CommandButton.Gradient Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the gradient fill applied to the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .Gradient

expression A variable that represents a CommandButton object.

Remarks

The Gradient property contains a numeric expression that represents the gradient fill applied to the specified object. The default value of the Gradient property is 0, which does not apply a gradient. The values are listed in the following table.

Value | Gradient Fill
0 | None
1 | Linear Diagonal - Top Left to Bottom Right, Light
2 | Linear Down, Light
3 | Linear Diagonal - Top Right to Bottom Left, Light
4 | From Bottom Right Corner, Light
5 | From Bottom Left Corner, Light
6 | Linear Left, Light
7 | Linear Center, Light
8 | Linear Right, Light
9 | From Top Right Corner, Light
10 | From Top Left Corner, Light
11 | Linear Diagonal - Bottom Left to Top Right, Light
12 | Linear Up, Light
13 | Linear Diagonal - Bottom Right to Top Left, Light
14 | Linear Diagonal - Top Left to Bottom Right, Dark
15 | Linear Down, Dark
16 | Linear Diagonal - Top Right to Bottom Left, Dark
17 | From Bottom Right Corner, Dark
18 | From Bottom Left Corner, Dark
19 | Linear Left, Dark
20 | Linear Center, Dark
21 | Linear Right, Dark
22 | From Top Right Corner, Dark
23 | From Top Left Corner, Dark
24 | Linear Diagonal - Bottom Left to Top Right, Dark
25 | Linear Up, Dark
26 | Linear Diagonal - Bottom Right to Top Left, Light

To see the available gradient fills and apply a gradient through the user interface, first open the form or report in Layout view or Design view by right-clicking the form or report in the Navigation Pane, and then clicking the view you want. Then, click the object to which you want to apply a gradient fill. Next, on the Format tab, in the Control Formatting group, click Shape Fill, then click Gradient and choose a gradient fill. You can hover over a gradient fill to see a description.

This property is not surfaced in the property sheet.

Example

The following code example sets the gradient fill to Linear Down, Light.

VBA Copy code Copy code
Me.ctl.Gradient = 2

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


TextBox.GridlineWidthRight Property (Access)

 Copy code hover
[image]

TextBox.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthRight

expression A variable that represents a TextBox object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


OptionButton.OnKeyPress Property (Access)

 Copy code hover
[image]

OptionButton.OnKeyPress Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Press box in the Properties window. Read/write String.

Syntax

expression .OnKeyPress

expression A variable that represents an OptionButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyPress event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyPress value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Press box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Press box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyPress property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyPress

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


ImportExportSpecification.Application Property (Access)

 Copy code hover
[image]

ImportExportSpecification.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents an ImportExportSpecification object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

ImportExportSpecification Object

Other resources

ImportExportSpecification Object Members


Chapter 6: Error Handling

 Copy code hover
[image]

Chapter 6: Error Handling
Send feedback

ADO uses several different methods to notify an application of errors that occur. This chapter discusses the types of errors that can occur when you are using ADO and how your application is notified. It concludes by making suggestions about how to handle those errors.

How Does ADO Report Errors?

ADO notifies you about errors in several ways:

  • ADO errors generate a run-time error. Handle an ADO error the same way you would any other run-time error, such as using an On Error statement in Visual Basic.

  • Your program can receive errors from OLE DB. An OLE DB error generates a run-time error as well.

  • If the error is specific to your data provider, one or more Error objects are placed in the Errors collection of the Connection object that was used to access the data store when the error occurred.

  • If the process that raised an event also produced an error, error information is placed in an Error object and passed as a parameter to the event. See Chapter 7: Handling ADO Events for more information about events.

  • Problems that occur when processing batch updates or other bulk operations involving a Recordset can be indicated by the Status property of the Recordset. For example, schema constraint violations or insufficient permissions can be specified by RecordStatusEnum values.

  • Problems that occur involving a particular Field in the current record are also indicated by the Status property of each Field in the Fields collection of the Record or Recordset. For example, updates that could not be completed or incompatible data types can be specified by FieldStatusEnum values.

The following sections describe each of these notification methods in more detail.


Attachment.Requery Method (Access)

 Copy code hover
[image]

Attachment.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.

Version Information

Version Added: Access 2007

Syntax

expression .Requery

expression A variable that represents an Attachment object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records, or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts.

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate functions.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method requeries the record source only for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


StopAllMacros Macro Action

 Copy code hover
[image]

StopAllMacros Macro Action
Send feedback

You can use the StopAllMacros action to stop all macros that are currently running.

Setting

The StopAllMacros action doesn't have any arguments.

Remarks

You typically use this action when an error condition makes it necessary to stop all macros. You can use a conditional expression in the macro's action row that contains this action. When the expression evaluates to True (-1), Microsoft Access stops all macros.

For example, you might have a macro that displays a message box as one of a number of complex actions, including running other macros. If the user clicks Cancel in this message box, the StopAllMacros action can stop all the macros that are running.

If a macro has used the Echo or SetWarnings actions to turn echo or the display of system messages off, the StopAllMacros action automatically turns them back on.

This action isn't available in a Visual Basic for Applications (VBA) module.


ObjectFrame.ControlTipText Property (Access)

 Copy code hover
[image]

ObjectFrame.ControlTipText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.

Syntax

expression .ControlTipText

expression A variable that represents an ObjectFrame object.

Remarks

You set the ControlTipText property by using a string expression up to 255 characters long.

For controls on forms, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

You can set the ControlTipText property in any view.

The ControlTipText property provides an easy way to provide helpful information about controls on a form.

There are other ways to provide information about a form or a control on a form. You can use the StatusBarText property to display information in the status bar about a control. To provide more extensive help for a form or control, use the HelpFile and HelpContextID properties.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Attachment.LeftPadding Property (Access)

 Copy code hover
[image]

Attachment.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the attachment and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .LeftPadding

expression A variable that represents an Attachment object.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Set Startup Properties and Options in Code

 Copy code hover
[image]

Set Startup Properties and Options in Code
Send feedback

Startup properties affect how your database application appears when it's opened. For example, startup properties enable you to customize the application's title bar, menus, toolbars, and startup form. The startup properties are available in the Current Database category of the Access Options dialog box. To view the Access Options dialog box, click the Microsoft Office Button [image] and then click Access Options.

You can set options in the Access Options dialog box to change various aspects of the application's environment while you're working in it. For example, you can set form, report, table, and query default options.

The following topics provide specific information about setting startup properties and options in code.

Set Startup Properties from Visual Basic

Set Options from Visual Basic


RDS Events (Access)

 Copy code hover
[image]

RDS Events (Access)
Send feedback

In this section

  • RDS Events

  • onError Event (RDS)

  • onReadyStateChange Event (RDS)


Module.Find Method (Access)

 Copy code hover
[image]

Module.Find Method (Access)
See also Send feedback

Published: July 16, 2012

Finds specified text in a standard module or class module.

Syntax

expression .Find(Target, StartLine, StartColumn, EndLine, EndColumn, WholeWord, MatchCase, PatternSearch)

expression A variable that represents a Module object.

Parameters

Name | Required/Optional | Data Type | Description
Target | Required | String | The text that you want to find.
StartLine | Required | Long | The line on which to begin searching. If a match is found, the value of the StartLine argument is set to the line on which the beginning character of the matching text is found.
StartColumn | Required | Long | The column on which to begin searching. Each character in a line is in a separate column, beginning with zero on the left side of the module. If a match is found, the value of the StartColumn argument is set to the column on which the beginning character of the matching text is found.
EndLine | Required | Long | The line on which to stop searching. If a match is found, the value of the EndLine argument is set to the line on which the ending character of the matching text is found.
EndColumn | Required | Long | The column on which to stop searching. If a match is found, the value of the EndColumn argument is set to the column on which the beginning character of the matching text is found.
WholeWord | Optional | Boolean | True results in a search for whole words only. The default is False.
MatchCase | Optional | Boolean | True results in a search for words with case matching the Target argument. The default is False.
PatternSearch | Optional | Boolean | True results in a search in which the Target argument may contain wildcard characters such as an asterisk (*) or a question mark (?). The default is False.

Return Value

Boolean

Remarks

The Find method searches for the specified text string in a Module object. If the string is found, the Find method returns True.

To determine the position in the module at which the search text was found, pass empty variables to the Find method for the StartLine, StartColumn, EndLine, and EndColumn arguments. If a match is found, these arguments will contain the line number and column position at which the search text begins (StartLine, StartColumn) and ends (EndLine, EndColumn).

For example, if the search text is found on line 5, begins at column 10, and ends at column 20, the values of these arguments will be: StartLine = 5, StartColumn = 10, EndLine = 5, EndColumn = 20.

Example

The following function finds a specified string in a module and replaces the line that contains that string with a new specified line.

VBA Copy code Copy code
Function FindAndReplace(strModuleName As String, _
 strSearchText As String, _
 strNewText As String) As Boolean
 Dim mdl As Module
 Dim lngSLine As Long, lngSCol As Long
 Dim lngELine As Long, lngECol As Long
 Dim strLine As String, strNewLine As String
 Dim intChr As Integer, intBefore As Integer, _
 intAfter As Integer
 Dim strLeft As String, strRight As String

 ' Open module.
 DoCmd.OpenModule strModuleName
 ' Return reference to Module object.
 Set mdl = Modules(strModuleName)

 ' Search for string.
 If mdl.Find(strSearchText, lngSLine, lngSCol, lngELine, _
 lngECol) Then
 ' Store text of line containing string.
 strLine = mdl.Lines(lngSLine, Abs(lngELine - lngSLine) + 1)
 ' Determine length of line.
 intChr = Len(strLine)
 ' Determine number of characters preceding search text.
 intBefore = lngSCol - 1
 ' Determine number of characters following search text.
 intAfter = intChr - CInt(lngECol - 1)
 ' Store characters to left of search text.
 strLeft = Left$(strLine, intBefore)
 ' Store characters to right of search text.
 strRight = Right$(strLine, intAfter)
 ' Construct string with replacement text.
 strNewLine = strLeft & strNewText & strRight
 ' Replace original line.
 mdl.ReplaceLine lngSLine, strNewLine
 FindAndReplace = True
 Else
 MsgBox "Text not found."
 FindAndReplace = False
 End If

Exit_FindAndReplace:
 Exit Function

Error_FindAndReplace:

MsgBox Err & ": " & Err.Description
 FindAndReplace = False
 Resume Exit_FindAndReplace
End Function

See also

Concepts

Module Object

Other resources

Module Object Members


Program with Class Modules

 Copy code hover
[image]

Program with Class Modules
Send feedback

In Microsoft Access, there were two types of modules: standard modules and class modules. In Microsoft Access 95, class modules existed only in association with a form or report. In Microsoft Access 97, they also existed on the Modules tab of the Database window.

Creating Custom Objects with Class Modules

You can use a class module to create a definition for a custom object. The name with which you save the class module becomes the name of your custom object. Public Sub and Function procedures that you define within a class module become custom methods of the object. Public Property Let, Property Get, and Property Set procedures become properties of the object.

Once you've defined procedures within the class module, you can create the new object by creating a new instance of the class. To create a new instance of a class, you declare a variable of the type defined by that class. For example, if the name of your class is ABasicClass, you would create a new instance of it in the following manner:

Copy code Copy code
Dim abc As New ABasicClass

When you run the code containing this declaration, Visual Basic creates the new instance. You can then apply its methods and properties by using the variable . For example, if you've defined a custom method called ListNames, you could apply it as follows:

Copy code Copy code
abc.ListNames

New in Microsoft Access 95: Creating the Default Instance of a Form Class

When you open a form in Form view, whether from the user interface or from Visual Basic, you create an instance of that form's class module. In other words, you designate space in memory where the object now exists, and you can then call its methods and set or return its properties from code, as you would for any built-in object. The same is true when you open a report in Print Preview.

When you refer to a form in Visual Basic code, you're usually working with the default instance of the form's class. A form's class has only one default instance. You can also create multiple instances of the same form's class from Visual Basic. When you create multiple instances of a form's class, you create nondefault instances.

There are four ways to create the default instance of a form. You can open an existing form by using the user interface, by executing the OpenForm method of the DoCmd object, by calling the CreateForm method and switching the new form into Form view, or by using Visual Basic to create a variable of type Form to refer to the default instance. The following example opens an Employees form and points a Form object variable to it:

Copy code Copy code
Dim frm As Form
DoCmd.OpenForm "Employees"
Set frm = Forms!Employees

Microsoft Access also provides a shortcut that enables you to open a form and refer to a method or property of that form or one of its controls in one step. You refer to the form's class module as shown in the following example:

Copy code Copy code
Form_Employees.Visible = True
Form_Employees.Caption = "New Employees"

When you run this code, Microsoft Access opens the Employees form in Form view if it's not already open and sets the form's caption to "New Employees." The form isn't visible until you explicitly set its Visible property to True. When the procedure that calls this code has finished executing, this instance of the form is destroyed; that is, the form is closed.

If you try to run this code when the Employees form is open in Design view, Microsoft Access generates a run-time error. The form must either be open in Form view or not open at all.

If you use this syntax to change a property of the form or one of its controls, that change is lost when the instance of the form is destroyed. This holds true any time you change a property setting for a form in Form view. You must change the property in Design view and save the change with the form.

Creating Multiple Nondefault Instances of Forms

You can create multiple nondefault instances of a form's class if you want to display more than one instance of a form at a time. For example, you might want to display the records for an employee and the employee's manager at the same time. You can create one instance of the Employees form's class to display the employee's record, and one to display the manager's record.

To create new, nondefault instances of a form's class from Visual Basic, declare a variable for which the type is the name of the form class module. You must include the New keyword in the variable declaration. For example, the following code creates a new instance of the Employees form and assigns it to a variable of type Form:

Copy code Copy code
Dim frm As New Form_Employees

This nondefault instance of the form isn't visible until you explicitly set its Visible property.

When the procedure that creates this instance has finished executing, the instance is removed from memory unless you've declared the variable representing it as a module-level variable. Since module-level variables retain their values until they are reset with the Reset command on the Run menu or the Reset button on the toolbar, the form will stay open if the variable has been declared as a module-level variable.

Any properties that you set will affect this instance of the form's class, but won't be saved with the form. Also, a new instance of the form's class can't be created if the form is open in Design view.

A nondefault instance of a form's class can't be referred to by name in the Forms collection. You can refer to it by index number only. Since you can create multiple nondefault instances of a form, and each instance has the same name, you can have more than one form with the same name in the Forms collection, without any means of distinguishing them other than by index number.


ListBox.BorderStyle Property (Access)

 Copy code hover
[image]

ListBox.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Syntax

expression .BorderStyle

expression A variable that represents a ListBox object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Page.MouseDown Event (Access)

 Copy code hover
[image]

Page.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents a Page object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
         Shift As Integer, X As Single, _
         Y As Single)
    If Button = acLeftButton Then
        MsgBox "You pressed the left button."
    End If
    If Button = acRightButton Then
        MsgBox "You pressed the right button."
    End If
    If Button = acMiddleButton Then
        MsgBox "You pressed the middle button."
    End If
End Sub

See also

Concepts

Page Object

Other resources

Page Object Members


You cannot modify the replication system object

 Copy code hover
[image]

You cannot modify the replication system object <name>. (Error 3666)
Send feedback

You are trying to execute an invalid operation, such as deleting a system table, renaming a table, or deleting a replication column, on an internal replication system object.


Cannot create this type of replica from the given source replica. (Error 3737)

 Copy code hover
[image]

Cannot create this type of replica from the given source replica. (Error 3737)
Send feedback

You cannot create a replica of a different visibility, except from a Global replica. For example, a Local replica can only create another Local replica, and an Anonymous replica can only create another Anonymous replica. Global replicas can create Global, Local, or Anonymous replicas.


The filter expression for the partial replica is invalid. (Error 3482)

 Copy code hover
[image]

The filter expression for the partial replica is invalid. (Error 3482)
Send feedback

The ReplicaFilter property was set to an invalid string.


DoCmd.Maximize Method (Access)

 Copy code hover
[image]

DoCmd.Maximize Method (Access)
See also Send feedback

Published: July 16, 2012

The Maximize method carries out the Maximize action in Visual Basic.

Syntax

expression .Maximize

expression A variable that represents a DoCmd object.

Remarks

You can use theMaximize method to enlarge the active window so that it fills the Microsoft Access window. This action will allow you to see as much of the object in the active window as possible

You can use the Restore method to restore a maximized window to its previous size.

You may need to use the SelectObject method if the window you want to maximize isn't the active window.

When you maximize a window in Access, all other windows are also maximized when you open them or switch to them. However, pop-up forms aren't maximized. If you want a form to maintain its size when other windows are maximized, set its PopUp property to True.

This method cannot be applied to module windows in the Visual Basic Editor (VBE). For information about how to affect module windows see the WindowState property topic.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


QueryDef Properties (DAO)

 Copy code hover
[image]

QueryDef Properties (DAO)
Send feedback

In this section

  • QueryDef.CacheSize Property (DAO)

  • QueryDef.Connect Property (DAO)

  • QueryDef.DateCreated Property (DAO)

  • QueryDef.Fields Property (DAO)

  • QueryDef.LastUpdated Property (DAO)

  • QueryDef.MaxRecords Property (DAO)

  • QueryDef.Name Property (DAO)

  • QueryDef.ODBCTimeout Property (DAO)

  • QueryDef.Parameters Property (DAO)

  • QueryDef.Prepare Property (DAO)

  • QueryDef.Properties Property (DAO)

  • QueryDef.RecordsAffected Property (DAO)

  • QueryDef.ReturnsRecords Property (DAO)

  • QueryDef.SQL Property (DAO)

  • QueryDef.StillExecuting Property (DAO)

  • QueryDef.Type Property (DAO)

  • QueryDef.Updatable Property (DAO)


SubForm.OnExit Property (Access)

 Copy code hover
[image]

SubForm.OnExit Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnExit

expression A variable that represents a SubForm object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Exit event occurs just before a control loses the focus to another control on the same form.

The OnExit value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Exit box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Exit box is blank, the property value is an empty string.

Example

The following example associates the Exit event with the macro "Exit_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnExit = "Exit_Macro"

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


OptionButton.SizeToFit Method (Access)

 Copy code hover
[image]

OptionButton.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents an OptionButton object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


ImportExportSpecification Methods (Access)

 Copy code hover
[image]

ImportExportSpecification Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Delete | Deletes the specified ImportExportSpecification object from the ImportExportSpecifications collection.
Execute | Executes the specfied import or export specification.


StopMacro Macro Action

 Copy code hover
[image]

StopMacro Macro Action
Send feedback

You can use the StopMacro action to stop the currently running macro.

Setting

The StopMacro action doesn't have any arguments.

Remarks

You typically use this action when a condition makes it necessary to stop the macro. You can use a conditional expression in the macro's action row that contains this action. When the expression evaluates to True (-1), Microsoft Access stops the macro.

For example, you might create a macro that opens a form showing the daily order totals for the date entered in a custom dialog box. You could use a conditional expression to be sure that the Order Date control on the dialog box contains a valid date. If it doesn't, the MessageBox action can display an error message and the StopMacro action can stop the macro.

If the macro has used the Echo or SetWarnings actions to turn echo or the display of system messages off, the StopMacro action automatically turns them back on.

This action isn't available in a Visual Basic for Applications (VBA) module.

Example

The following macro demonstrates the use of the OnError action. In this example, the OnError action specifies that Access run a custom error handling macro named ErrorHandler when an error occurs. When an error occurs, the CatchErrors submacro is called. If the error number is 2102, a specific message is displayed and macro execution is halted. Otherwise, a message describing the error is displayed and the macro is paused so that you can perform additional troubleshooting. The ErrorHandler macro displays a message box that refers to the MacroError object to display information about the error.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

Copy code Copy code
/* MACRO: mcrThrowErrors                                  */
/* PURPOSE: Error handling using macros in Access 2010    */

OnError
    Go to Macro Name
    Macro Name CatchErrors

OpenForm
    Form Name frmSamples
    View Form
    Filter Name
    Where Condition
    Data Mode
    Window Mode Normal

MessageBox
    Message This message appears after the OpenForm action
    Beep Yes
    Type None
    Title

/* SUBMACRO: CatchErrors                                   */

SubMacro: CatchErrors
    If [MacroError].[Number]=2101 Then
        MessageBox
            Message Cannot find the specified form!
            Beep Yes
            Type Critical
            Title
        StopMacro

    Else
        MessageBox
            Message =[MacroErro].[Description]
            Beep Yes
            Type None
            Title Unhandled Error

        SingleStep
    End If

End SubMacro

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


TabControl.Parent Property (Access)

 Copy code hover
[image]

TabControl.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a TabControl object.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


ListBox Object (Access)

 Copy code hover
[image]

ListBox Object (Access)
See also Send feedback

Published: July 16, 2012

This object corresponds to a list box control. The list box control displays a list of values or alternatives.

Remarks

In many cases, it's quicker and easier to select a value from a list than to remember a value to type. A list of choices also helps ensure that the value that's entered in a field is correct.

Control: | Tool:
Note Note

The list in a list box consists of rows of data. Rows can have one or more columns, which can appear with or without headings.

If a multiple-column list box is bound, Microsoft Access stores the values from one of the columns.

You can use an unbound list box to store a value that you can use with another control. For example, you could use an unbound list box to limit the values in another list box or in a custom dialog box. You could also use an unbound list box to find a record based on the value you select in the list box.

If you don't have room on your form to display a list box, or if you want to be able to type new values as well as select values from a list, use a combo box instead of a list box.

Links provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Create a Query that uses a Multi-select Listbox as Criteria

  • ListBox Picker

  • Move/Change Order of List Box Items with Up/Down Buttons

  • Populate a Listbox with Files from a Directory

Example

This example demonstrates how to filter the contents of a list box while you are typing in a text box.

In this example, a list box named ColorID displays a list of colors stored in the Colors table. As you type in the FilterBy text box, the items in ColorID are filtered dynamically

To do this, use the Change event of the text box to build a SQL statement that will serve as the new RowSource of the list box.

Sample code provided by: Community Member Icon The UtterAccess community | About the Contributors

Copy code Copy code
Private Sub FilterBy_Change()

    Dim sql As String

    'This will match any entry in the list that begins with what the user
    'has typed in the FilterBy control
    sql = "SELECT ColorID, ColorName FROM Colors WHERE ColorName Like '" & Me.FilterBy.Text & "*' ORDER BY ColorName"

    'If you want to match any part of the string then add wildcard (*) before
    'the FilterBy.Text, too:
    'sql = "SELECT ColorID, ColorName FROM Colors WHERE ColorName Like '*" & Me.FilterBy.Text & "*' ORDER BY ColorName"

    Me.ColorID.RowSource = sql

End Sub

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Access Object Model Reference

Other resources

ListBox Object Members


Hierarchies Collection Properties, Methods, and Events (ADO MD)

 Copy code hover
[image]

Hierarchies Collection Properties, Methods, and Events (ADO MD)
Send feedback

Properties

Count Property

Item Property

Methods

Refresh Method

Events

None.


NavigationControl.Tag Property (Access)

 Copy code hover
[image]

NavigationControl.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .Tag

expression A variable that represents a NavigationControl object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Pages.Count Property (Access)

 Copy code hover
[image]

Pages.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents a Pages object.

See also

Concepts

Pages Collection

Other resources

Pages Object Members


SubForm.StatusBarText Property (Access)

 Copy code hover
[image]

SubForm.StatusBarText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.

Syntax

expression .StatusBarText

expression A variable that represents a SubForm object.

Remarks

You set the StatusBarText property by using a string expression up to 255 characters long.

Note Note

The length of the text you can display in the status bar depends on your computer hardware and video display.

You can use the StatusBarText property to provide specific information about a control. For example, when a text box has the focus, a brief instruction can tell the user what kind of data to enter

Note Note

You can also use the ControlTipText property to display a ScreenTip for a control.

If you create a control by dragging a field from the field list, the value in a field's Description property is copied to the StatusBarText property.

Example

The following example sets the status bar text to be displayed when the "Address_TextBox" control in the "Mailing List" form has the focus in Form View.

VBA Copy code Copy code
Forms("Mailing List").Controls("Address_TextBox"). _
 StatusBarText = "Enter the company's mailing address."

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Command and CommandText Properties Example (VB)

 Copy code hover
[image]

Command and CommandText Properties Example (VB)
Send feedback

The following code demonstrates how to use the Command property to update the text of a procedure.

Copy code Copy code

' BeginProcedureTextVB
Sub Main()
 On Error GoTo ProcedureTextError

 Dim cnn As New ADODB.Connection
 Dim cat As New ADOX.Catalog
 Dim cmd As New ADODB.Command

 ' Open the Connection
 cnn.Open "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\Microsoft Office\" & _
 "Office\Samples\Northwind.mdb';"

 ' Open the catalog
 Set cat.ActiveConnection = cnn

 ' Get the Command
 Set cmd = cat.Procedures("CustomerById").Command

 ' Update the CommandText
 cmd.CommandText = "Select CustomerId, CompanyName, ContactName " & _
 "From Customers " & _
 "Where CustomerId = [CustId]"

 ' Update the Procedure
 Set cat.Procedures("CustomerById").Command = cmd

 'Clean up
 cnn.Close
 Set cat = Nothing
 Set cmd = Nothing
 Set cnn = Nothing
 Exit Sub

ProcedureTextError:
 Set cat = Nothing
 Set cmd = Nothing

 If Not cnn Is Nothing Then
 If cnn.State = adStateOpen Then cnn.Close
 End If
 Set cnn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndProcedureTextVB


Workspace.Name Property (DAO)

 Copy code hover
[image]

Workspace.Name Property (DAO)
Send feedback

Returns or sets the name of the specified object. Read/write String if the object has not been appended to a collection. Read-only String if the object has been appended to a collection.

Syntax

expression .Name

expression A variable that represents a Workspace object.

Remarks

The maximum length for the name of a Workspace object is 20 characters.


Field.Value Property (DAO)

 Copy code hover
[image]

Field.Value Property (DAO)
Send feedback

Sets or returns the value of an object. Read/write Variant.

Syntax

expression .Value

expression A variable that represents a Field object.

Remarks

The setting or return value is a Variant data type that evaluates to a value appropriate for the data type, as specified by the Type property of an object.

Generally, the Value property is used to retrieve and alter data in Recordset objects.

The Value property is the default property of the Field, Parameter, and Property objects. Therefore, you can set or return the value of one of these objects by referring to them directly instead of specifying the Value property.

Trying to set or return the Value property in an inappropriate context (for example, the Value property of a Field object in the Fields collection of a TableDef object) will cause a trappable error.

Note Note

When reading decimal values from a Microsoft SQL Server database, they will be formatted using scientific notation through a Microsoft Access workspace, but will appear as normal decimal values through an ODBCDirect workspace.


AccessObjectProperty.Value Property (Access)

 Copy code hover
[image]

AccessObjectProperty.Value Property (Access)
See also Send feedback

Published: July 16, 2012

Determines or specifies the value of a built-in property of an AccessObject object. Read/write Variant.

Syntax

expression .Value

expression A variable that represents an AccessObjectProperty object.

Remarks

The Value property of a custom property contains the value of the specified custom property of an AccessObject object. For more information about custom properties, see the topics about the AccessObject object, AccessObjectProperty object, and the AccessObjectProperties collection.

See also

Concepts

AccessObjectProperty Object

Other resources

AccessObjectProperty Object Members


Attachment.ControlSource Property (Access)

 Copy code hover
[image]

Attachment.ControlSource Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlSource property to specify what data appears in the specified Attachment control. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .ControlSource

expression A variable that represents an Attachment object.

Remarks

The ControlSource property uses the following settings.

Setting | Description
A field name | The ControlSource property must be set to the name of a field that stores attachments.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Module.CountOfLines Property (Access)

 Copy code hover
[image]

Module.CountOfLines Property (Access)
See also Send feedback

Published: July 16, 2012

The CountOfLines property returns a Long value indicating the number of lines of code in a standard module or class module. Read-only Long.

Syntax

expression .CountOfLines

expression A variable that represents a Module object.

Remarks

Lines in a module are numbered beginning with 1.

The line number of the last line in a module is the value of the CountOfLines property.

Example

The following example counts the number of lines and declaration lines in each standard module in the Modules collection. Note that the Modules collection contains only modules that are open in the module editor.

VBA Copy code Copy code
Public Sub ModuleLineTotal(ByVal strModuleName As String)

 Dim mdl As Module

 ' Open module to include in Modules collection.
 DoCmd.OpenModule strModuleName

 ' Return reference to Module object.
 Set mdl = Modules(strModuleName)

 ' Print number of lines in module.
 Debug.Print "Number of lines: ", mdl.CountOfLines

 ' Print number of declaration lines.
 Debug.Print "Number of declaration lines: ", _
 mdl.CountOfDeclarationLines

End Sub

See also

Concepts

Module Object

Other resources

Module Object Members


BoundObjectFrame.OLETypeAllowed Property (Access)

 Copy code hover
[image]

BoundObjectFrame.OLETypeAllowed Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OLETypeAllowed property to specify the type of OLE object a control can contain. Read/write Byte.

Syntax

expression .OLETypeAllowed

expression A variable that represents a BoundObjectFrame object.

Remarks

The OLETypeAllowed property uses the following settings.

Setting | Constant | Description
Linked | acOLELinked | The control can contain only a linked object.
Embedded | acOLEEmbedded | The control can contain only an embedded object.
Either | acOLEEither | (Default) The control can contain either a linked or an embedded object.
Note Note

For unbound object frames and charts , you can't change the OLETypeAllowed setting after an object is created. For bound object frames, you can change the setting after the object is created. Changing the OLETypeAllowed property setting only affects new objects that you add to the control.

To determine the type of OLE object a control already contains, you can use the OLEType property.

Example

The following example creates a linked OLE object using an unbound object frame named OLE1 and sizes the control to display the object's entire contents when the user clicks a command button.

VBA Copy code Copy code
Sub Command1_Click
 OLE1.Class = "Excel.Sheet" ' Set class name.
 ' Specify type of object.
 OLE1.OLETypeAllowed = acOLELinked
 ' Specify source file.
 OLE1.SourceDoc = "C:\Excel\Oletext.xls"
 ' Specify data to create link to.
 OLE1.SourceItem = "R1C1:R5C5"
 ' Create linked object.
 OLE1.Action = acOLECreateLink
 ' Adjust control size.
 OLE1.SizeMode = acOLESizeZoom
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Initializing the Microsoft Excel Driver

 Copy code hover
[image]

Initializing the Microsoft Excel Driver
Send feedback

When you install the Microsoft® Excel driver, the Setup program writes a set of default values to the Microsoft Windows® Registry in the Engines and ISAM Formats subkeys. You should not modify these settings directly; use the setup program for your application to add, remove, or change these settings. The following sections describe initialization and ISAM Format settings for the Microsoft Excel database driver.

Microsoft Excel Initialization Settings

The Access Connectivity Engine\Engines\Excel folder includes initialization settings for the Aceexcl.dll driver, used for external access to Microsoft Excel worksheets. Typical settings for the entries in this folder are shown in the following example.

Copy code Copy code
win32=<path>\ Aceexcl.dll

TypeGuessRows=8

ImportMixedTypes=Text

AppendBlankRows=1

FirstRowHasNames=Yes

The Microsoft Access database engine uses the Excel folder entries as follows.

Entry | Description
win32 | The location of msexcl40.dll. The full path is determined at the time of installation. Values are of type REG_SZ.
TypeGuessRows | The number of rows to be checked for the data type. The data type is determined given the maximum number of kinds of data found. If there is a tie, the data type is determined in the following order: Number, Currency, Date, Text, Boolean. If data is encountered that does not match the data type guessed for the column, it is returned as a Null value. On import, if a column has mixed data types, the entire column will be cast according to the ImportMixedTypes setting. The default number of rows to be checked is 8. Values are of type REG_DWORD.
ImportMixedTypes | Can be set to MajorityType or Text. If set to MajorityType, columns of mixed data types will be cast to the predominate data type on import. If set to Text, columns of mixed data types will be cast to Text on import. The default is Text. Values are of type REG_SZ.
AppendBlankRows | The number of blank rows to be appended to the end of a Version 3.5 or Version 4.0 worksheet before new data is added. For example, if AppendBlankRows is set to 4, Microsoft Jet will append 4 blank rows to the end of the worksheet before appending rows that contain data. Integer values for this setting can range from 0 to 16; the default is 01 (one additional row appended). Values are of type REG_DWORD.
FirstRowHasNames | A binary value that indicates whether the first row of the table contains column names. A value of 01 indicates that, during import, column names are taken from the first row. A value of 00 indicates no column names in the first row; column names appear as F1, F2, F3, and so on. The default is 01. Values are of type REG_BINARY.

The Access Connectivity Engine\Engines\Excel 8.0 folder contains the following entries, which apply to Microsoft Excel 97.

Entry name | Type | Value
Engine | REG_SZ | Excel
ExportFilter | REG_SZ | Microsoft Excel 97-2000 (*.xls)
CanLink | REG_BINARY | 01
OneTablePerFile | REG_BINARY | 00
IsamType | REG_DWORD | 1
IndexDialog | REG_BINARY | 00
CreateDBOnExport | REG_BINARY | 01
ResultTextExport | REG_SZ | Export data from the current database into a Microsoft Excel 97 file. This process will overwrite the data if exported to an existing file.
SupportsLongNames | REG_BINARY | 01
Note Note

When you change Windows Registry settings, you must exit and then restart the database engine for the new settings to take effect.


Database has reached maximum size. (Error 3036)

 Copy code hover
[image]

Database has reached maximum size. (Error 3036)
Send feedback

To add data to this database, you must first reduce its size by deleting data. The maximum size for a Microsoft Access database engine database is 2.14 gb.


TabControl.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

TabControl.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified list box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleBottom

expression A variable that represents a TabControl object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


TextBox.FormatConditions Property (Access)

 Copy code hover
[image]

TextBox.FormatConditions Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FormatConditions property to return a read-only reference to the FormatConditions collection and its related properties.

Syntax

expression .FormatConditions

expression A variable that represents a TextBox object.

Example

The following example sets format properties for an existing conditional format for the "Textbox1" control.

VBA Copy code Copy code
With forms("forms1").Controls("Textbox1").FormatConditions(1)
 .BackColor = RGB(255,255,255)
 .FontBold = True
 .ForeColor = RGB(255,0,0)
End With

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


- (Subtract) (Access 2013 custom web app)

 Copy code hover
[image]

- (Subtract) (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Subtracts two numbers. This arithmetic subtraction operator can also subtract a number, in days, from a date.

Syntax

expression - expression

expression Any valid expression of any one of the data types in the numeric category except the bit data type. Cannot be used with date or time data types.

Return Value

Returns the data type of the argument with the higher precedence.


Prompt Property--Dynamic (ADO)

 Copy code hover
[image]

Prompt Property--Dynamic (ADO)
Send feedback

Specifies whether the OLE DB provider should prompt the user for initialization information.

Settings and Return Values

Sets and returns a ConnectPromptEnum value.

Remarks

Prompt is a dynamic property, which may be appended to the Connection object's Properties collection by the OLE DB provider. To prompt for initialization information, OLE DB providers will typically display a dialog box to the user.

Dynamic properties of a Connection object are lost when the Connection is closed. The Prompt property must be reset before re-opening the Connection to use a value other than the default.

Note Note

Do not specify that the provider should prompt the user in scenarios in which the user will not be able to respond to the dialog box. For example, the user will not be able to respond if the application is running on a server system instead of on the user's client, or if the application is running on a system with no user logged on. In these cases, the application will wait indefinitely for a response and seem to lock up.

Usage

Copy code Copy code
Set cn = New Connection
cn.Provider = "SQLOLEDB"
cn.Properties("Prompt") = adPromptNever    ' do not prompt the user


GoToControl Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

GoToControl Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

You can use the GoToControl action to move the focus to the specified control in the current record of the open view.

Setting

The GoToControl action has the following argument.

Action argument | Description
Control Name | The name of the field or control where you want the focus. This is a required argument.

Remarks

You can use this action when you want a particular field or control to have the focus. You can also use this action to navigate in a form according to certain conditions. For example, if the user enters No in a Married control on a health insurance form, the focus can automatically skip the Spouse/partner Name control and move to the next control.


Replicate Function (Access 2013 custom web app)

 Copy code hover
[image]

Replicate Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Repeats a text value a specified number of times.

Syntax

Replicate (TextExpression, NumberOfTimes)

The Replicate function contains the following arguments.

Argument name | Description
TextExpression | A text expression.
NumberOfTimes | An integer that specifies the number of times to repeat the TextExpression.


Form.OrderBy Property (Access)

 Copy code hover
[image]

Form.OrderBy Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OrderBy property to specify how you want to sort records in a form. Read/write String.

Syntax

expression .OrderBy

expression A variable that represents a Form object.

Remarks

The OrderBy property is a string expression that is the name of the field or fields on which you want to sort records. When you use more than one field name, separate the names with a comma (,). Use the OrderBy property to save an ordering value and apply it at a later time. OrderBy values are saved with the objects in which they are created. They are automatically loaded when the object is opened, but they aren't automatically applied.

When you set the OrderBy property by entering one or more field names, the records are sorted in ascending order. Similarly, Visual Basic sorts these fields in ascending order by default.

If you want to sort records in descending order, type DESC at the end of the string expression. For example, to sort customer records in descending order by contact name, set the OrderBy property to "ContactName DESC".

Select the field by which you want to sort the records and either click the appropriate Sort button on the toolbar, or point to Sort on the Records menu and click the appropriate command on the submenu. You can also set the OrderByOn property for either forms or reports by using Visual Basic.

Note Note

When a new object is created, it inherits the RecordSource , Filter , OrderBy, and OrderByOn properties of the table or query it was created from. For forms and reports, inherited filters aren't automatically applied when an object is opened.

See also

Concepts

Form Object

Other resources

Form Object Members


Section V: Appendixes (Access)

 Copy code hover
[image]

Section V: Appendixes (Access)
Send feedback

In this section

  • Section V: Appendixes

  • Appendix A: Providers (ADO)

  • Appendix B: ADO Errors (ADO)

  • Appendix C: Programming with ADO (ADO)

  • Appendix D: ADO Samples (ADO)


CustomControl.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

CustomControl.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified list box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleBottom

expression A variable that represents a CustomControl object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Application.SetOption Method (Access)

 Copy code hover
[image]

Application.SetOption Method (Access)
See also Send feedback

Published: July 16, 2012

The SetOption method sets the current value of an option in the Access Options dialog box.

Syntax

expression .SetOption(OptionName, Setting)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
OptionName | Required | String | The name of the option. For a list of optionname argument strings, see Set Options from Visual Basic.
Setting | Required | Variant | A value corresponding to the option setting. The value of the setting argument depends on the possible settings for a particular option.

Remarks

The available option settings depend on the type of option being set. There are three general types of options:

  • Yes/No options that can be set by selecting or clearing a check box.

  • Options that can be set by entering a string or numeric value.

  • Predefined options that can be chosen from a list box, combo box, or option group.

For options that the user sets by selecting or clearing a check box, using the SetOption method, specify True or False for the setting argument, as in the following example:

VBA Copy code Copy code
Application.SetOption "Show Status Bar", True

To set a type of option using the SetOption method, specify the string or numeric value that would be typed in the dialog box. The following example sets the default form template to OrderTemplate:

VBA Copy code Copy code
Application.SetOption "Form Template", "OrderTemplate"

For options with settings that are choices in list boxes or combo boxes, specify the option's numeric position within the list as the setting argument for the SetOption method. The following example sets the Default Field Type option to AutoNumber:

VBA Copy code Copy code
Application.SetOption "Default Field Type", 5

To set an option that's a member of an option group, specify the index number of the option within the group. The following example sets Selection Behavior to Fully Enclosed:

VBA Copy code Copy code
Application.SetOption "Selection Behavior", 1
Note Note

  • When you use the SetOption method to set an option in the Access Options dialog box, you don't need to specify the individual tab on which the option is found.

  • If your database may run on a version of Microsoft Access for a language other than the one in which you created it, then you must supply the arguments for the SetOption method in English.

When you quit Microsoft Access, you can reset all options to their original settings by using the SetOption method on all changed options. You may want to create public variables to store the values of the original settings. You might include code to reset options in the Close event procedure for a form, or in a custom exit procedure that the user must run to quit the application.

See also

Concepts

Application Object

Other resources

Application Object Members


CustomControl.OnUpdated Property (Access)

 Copy code hover
[image]

CustomControl.OnUpdated Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Updated box in the Properties window of a form or report. Read/write String.

Syntax

expression .OnUpdated

expression A variable that represents a CustomControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The OnUpdated value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Updated box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Updated box is blank, the property value is an empty string.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


AbsolutePage, PageCount, and PageSize Properties Example (VJ++)

 Copy code hover
[image]

AbsolutePage, PageCount, and PageSize Properties Example (VJ++)
Send feedback

This example uses the AbsolutePage, PageCount, and PageSize properties to display names and hire dates from the Employees table, five records at a time.

Copy code Copy code

// BeginAbsolutePageJ
// The WFC class includes the ADO objects.

import com.ms.wfc.data.*;
import java.io.* ;

public class AbsolutePageX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 AbsolutePageX();
 System.exit(0);
 }

 // AbsolutePageX function

 static void AbsolutePageX()
 {
 // Define ADO Objects.
 Recordset rstEmployees = null;

 // Declarations.
 BufferedReader in = new BufferedReader (new
 InputStreamReader(System.in));
 String line = null;
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";

 String strName;
 String strFName;
 String strLName;
 String strHDate;
 int intPage;
 int intRecord;

 try
 {
 rstEmployees = new Recordset();

 // Use client cursor to enable AbsolutePosition property.
 rstEmployees.setCursorLocation( AdoEnums.CursorLocation.CLIENT);

 // Open a recordset using client cursor for the Employees table.
 rstEmployees.open("employee", strCnn,
 AdoEnums.CursorType.FORWARDONLY,
 AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TABLE);

 // Display names and hire dates, five records at a time.

 rstEmployees.setPageSize(5);
 int intPageCount = rstEmployees.getPageCount();
 for ( intPage = 1; intPage <= intPageCount; intPage++)
 {
 strName = "";
 rstEmployees.setAbsolutePage(intPage);
 for ( intRecord = 1; intRecord <= rstEmployees.getPageSize();
 intRecord++)
 {
 strFName = rstEmployees.getField("fname").getString();
 strLName = rstEmployees.getField("lname").getString();
 strHDate = rstEmployees.getField("hire_date").getString();

 strHDate = strHDate.substring(5,7) + "/" +
 strHDate.substring(8,10) +
 "/" + strHDate.substring(2,4);

 strName = strName + "\n" + strFName + " " + strLName +
 " " + strHDate;
 rstEmployees.moveNext();
 if ( rstEmployees.getEOF())
 break;
 }
 System.out.println(strName);
 // Get user input to display next records.

 System.out.println("\n\nPress <Enter> key to Continue.");
 line = in.readLine();
 }
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // Check for null pointer for connection object.
 if (rstEmployees.getActiveConnection()==null)
 System.out.println("Exception: " + ae.getMessage());

 // As passing a Recordset, check for null pointer first.
 if (rstEmployees != null)
 {
 PrintProviderError(rstEmployees.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }
 finally
 {
 // Cleanup objects before exit.
 if (rstEmployees != null)
 if (rstEmployees.getState() == 1)
 rstEmployees.close();
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 //.PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndAbsolutePageJ


Label.Vertical Property (Access)

 Copy code hover
[image]

Label.Vertical Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Vertical property to set a form control for vertical display and editing or set a report control for vertical display and printing. Read/write Boolean.

Syntax

expression .Vertical

expression A variable that represents a Label object.

Remarks

The Vertical property uses the following settings:

Setting | Visual Basic | Description
Yes | True | Displays, edits, and prints vertical text.
No | False | (Default) Does not display, edit, or print vertical text.

You can specify how vertical text will be displayed, edited, or printed in the control by setting the Vertical property. If set to Yes, the starting point for inputting text is the upper right corner of the control (the ending point is the lower left corner of the control). If using full pitch characters, the display and print directions are the same as the control for horizontal text. If using half pitch characters, it shifts 90 degrees to the right. The cursor is also rotated 90 degrees to the right in a vertical text control.

Note Note

Text selection using key combinations is different for vertical text control and horizontal text control. Key combinations and their effect on range selection are described below.

Key combination | Selected range
Shift+Up | Vertical: One character before the cursor. Horizontal: One line before the cursor.
Shift+Down | Vertical: One character after the cursor. Horizontal: One line after the cursor.
Shift+Right | Vertical: One line after the cursor. Horizontal: One character before the cursor.
Shift+Left | Vertical: One line before the cursor. Horizontal: One character after the cursor.

See also

Concepts

Label Object

Other resources

Label Object Members


Database Object (DAO)

 Copy code hover
[image]

Database Object (DAO)
Send feedback

A Database object represents an open database.

Remarks

You use the Database object and its methods and properties to manipulate an open database. In any type of database, you can:

  • Use the Execute method to run an action query.

  • Set the Connect property to establish a connection to an ODBC data source.

  • Set the QueryTimeout property to limit the length of time to wait for a query to execute against an ODBC data source.

  • Use the RecordsAffected property to determine how many records were changed by an action query.

  • Use the OpenRecordset method to execute a select query and create a Recordset object.

  • Use the Version property to determine which version of a database engine created the database.

With a Microsoft Access database engine database, you can also use other methods, properties, and collections to manipulate a Database object, as well as create, modify, or get information about its tables, queries, and relationships. For example, you can:

  • Use the CreateTableDef and CreateRelation methods to create tables and relations, respectively.

  • Use the CreateProperty method to define new Database properties.

  • Use the CreateQueryDef method to create a persistent or temporary query definition.

  • Use MakeReplica, Synchronize, and PopulatePartial methods to create and synchronize full or partial replicas of your database.

  • Set the CollatingOrder property to establish the alphabetic sorting order for character-based fields in different languages.

You use the CreateDatabase method to create a persistent Database object that is automatically appended to the Databases collection, thereby saving it to disk.

You don't need to specify the DBEngine object when you use the OpenDatabase method.

Opening a database with linked tables doesn't automatically establish links to the specified external files. You must either reference the table's TableDef or Field objects or open a Recordset object. If you can't establish links to these tables, a trappable error occurs. You may also need permission to access the database, or another user might have the database opened exclusively. In these cases, trappable errors occur.

When a procedure that declares a Database object has executed, local Database objects are closed along with any open Recordset objects. Any pending updates are lost and any pending transactions are rolled back, but no trappable error occurs. You should explicitly complete any pending transactions or edits and close Recordset objects and Database objects before exiting procedures that declare these object variables locally.

When you use one of the transaction methods (BeginTrans, CommitTrans, or Rollback) on the Workspace object, these transactions apply to all databases opened on the Workspace from which the Database object was opened. If you want to use independent transactions, you must first open an additional Workspace object, and then open another Database object in that Workspace object.

Note Note

You can open the same data source or database more than once, creating duplicate names in the Databases collection. You should assign Database objects to object variables and refer to them by variable name.

Example

This example creates a new Database object and opens an existing Database object in the default Workspace object. Then it enumerates the Database collection and the Properties collection of each Database object.

VBA Copy code Copy code
Sub DatabaseObjectX()

 Dim wrkAcc As Workspace
 Dim dbsNorthwind As Database
 Dim dbsNew As Database
 Dim dbsLoop As Database
 Dim prpLoop As Property

 Set wrkAcc = CreateWorkspace("AccessWorkspace", "admin", _
 "", dbUseJet)

 ' Make sure there isn't already a file with the name of
 ' the new database.
 If Dir("NewDB.mdb") <> "" Then Kill "NewDB.mdb"

 ' Create a new database with the specified
 ' collating order.
 Set dbsNew = wrkAcc.CreateDatabase("NewDB.mdb", _
 dbLangGeneral)
 Set dbsNorthwind = wrkAcc.OpenDatabase("Northwind.mdb")

 ' Enumerate the Databases collection.
 For Each dbsLoop In wrkAcc.Databases
 With dbsLoop
 Debug.Print "Properties of " & .Name
 ' Enumerate the Properties collection of each
 ' Database object.
 For Each prpLoop In .Properties
 If prpLoop <> "" Then Debug.Print " " & _
 prpLoop.Name & " = " & prpLoop
 Next prpLoop
 End With
 Next dbsLoop

 dbsNew.Close
 dbsNorthwind.Close
 wrkAcc.Close

End Sub

This example uses CreateDatabase to create a new, encrypted Database object.

VBA Copy code Copy code
Sub CreateDatabaseX()

 Dim wrkDefault As Workspace
 Dim dbsNew As DATABASE
 Dim prpLoop As Property

 ' Get default Workspace.
 Set wrkDefault = DBEngine.Workspaces(0)

 ' Make sure there isn't already a file with the name of
 ' the new database.
 If Dir("NewDB.mdb") <> "" Then Kill "NewDB.mdb"

 ' Create a new encrypted database with the specified
 ' collating order.
 Set dbsNew = wrkDefault.CreateDatabase("NewDB.mdb", _
 dbLangGeneral, dbEncrypt)

 With dbsNew
 Debug.Print "Properties of " & .Name
 ' Enumerate the Properties collection of the new
 ' Database object.
 For Each prpLoop In .Properties
 If prpLoop <> "" Then Debug.Print " " & _
 prpLoop.Name & " = " & prpLoop
 Next prpLoop
 End With

 dbsNew.Close

End Sub


Report.Page Property (Access)

 Copy code hover
[image]

Report.Page Property (Access)
See also Send feedback

Published: July 16, 2012

The Page property specifies the current page number when a report is being printed. Read/write Long.

Syntax

expression .Page

expression A variable that represents a Report object.

Remarks

Although you can set the Page property to a value, you most often use this property to return information about page numbers.

This property is only available in Print Preview or when printing.

Example

The following example updates the report's caption to display the current position in the report as the user pages back and forth in the report.

VBA Copy code Copy code
Private Sub Report_Page()
    Me.Caption = "Now Viewing Page " & Me.Page & " Of " & Me.Pages & " Page(s)"
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


Attachment.Tag Property (Access)

 Copy code hover
[image]

Attachment.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a control needed by a Microsoft Access application. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .Tag

expression A variable that represents an Attachment object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Description Property (ADO MD)

 Copy code hover
[image]

Description Property (ADO MD)
Send feedback

Returns a text explanation of the current object.

Return Values

Returns a String and is read-only.

Remarks

For Member objects, Description applies only to measure and formula members. Description returns an empty string ("") for all other types of members. For more information about the various types of members, see the Type property.

This property is only supported on Member objects belonging to a Level object. An error occurs when this property is referenced from Member objects belonging to a Position object.


CommandButton.OnEnter Property (Access)

 Copy code hover
[image]

CommandButton.OnEnter Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnEnter

expression A variable that represents a CommandButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Enter event occurs before a control actually receives the focus from a control on the same form.

The OnEnter value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Enter box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Enter box is blank, the property value is an empty string.

Example

The following example associates the Enter event with the macro "Enter_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnEnter = "Enter_Macro"

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Field.ValidationText Property (DAO)

 Copy code hover
[image]

Field.ValidationText Property (DAO)
Send feedback

Sets or returns a value that specifies the text of the message that your application displays if the value of a Field object doesn't satisfy the validation rule specified by the ValidationRule property setting (Microsoft Access workspaces only). Read/write String.

Syntax

expression .ValidationText

expression A variable that represents a Field object.

Remarks

The setting or return value is a String that specifies the text displayed if a user tries to enter an invalid value for a field. For an object not yet appended to a collection, this property is read/write.

For a Field object, use of the ValidationText property depends on the object that contains the Fields collection to which the Field object is appended, as the following table shows.

Object appended to | Usage
Index | Not supported
QueryDef | Read-only
Recordset | Read-only
Relation | Not supported
TableDef | Read/write


WSParameter Object (Access)

 Copy code hover
[image]

WSParameter Object (Access)
See also Send feedback

Published: July 16, 2012

Represents a parameter defined for an Operation.

Version Information

Version Added: Access 2010

See also

Concepts

Access Object Model Reference

Other resources

WSParameter Object Members


CommandButton.ForeColor Property (Access)

 Copy code hover
[image]

CommandButton.ForeColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ForeColor property to specify the color for text in a control. Read/write Long.

Syntax

expression .ForeColor

expression A variable that represents a CommandButton object.

Remarks

You can use this property for controls on forms or reports to make them easy to read or to convey a special meaning. For example, you can change the color of the text in the UnitsInStock control when its value falls below the reorder level.

You can also use this property on reports to create special visual effects when you print with a color printer. When used on a report, this property specifies the printing and drawing color for the Print , Line , and Circle methods.

The ForeColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors for text in controls.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set the Circle property only by using a macro or a Visual Basic event procedure specified in a section's OnPrint event property setting.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


SubForm.Parent Property (Access)

 Copy code hover
[image]

SubForm.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a SubForm object.

Remarks

You can use the Parent property to determine which form or report is currently the parent when you have a subform or subreport that has been inserted in multiple forms or reports.

For example, you might insert an OrderDetails subform into both a form and a report. The following example uses the Parent property to refer to the OrderID field, which is present on the main form and report. You can enter this expression in a bound control on the subform.

VBA Copy code Copy code
=Parent!OrderID

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


SmartTags.Item Property (Access)

 Copy code hover
[image]

SmartTags.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only SmartTag.

Syntax

expression .Item(Index)

expression A variable that represents a SmartTags object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

SmartTags Collection

Other resources

SmartTags Object Members


AcExportXMLEncoding Enumeration (Access)

 Copy code hover
[image]

AcExportXMLEncoding Enumeration (Access)
Send feedback

Published: July 16, 2012

Use with the ExportXML method to specify the text encoding to use for exporting XML data.

Name | Value | Description
acUTF16 | 1 | UTF16 encoding.
acUTF8 | 0 | (Default) UTF8 encoding.


Invalid SQL Syntax: expected token: COMPRESSION to follow WITH (Error 3723)

 Copy code hover
[image]

Invalid SQL Syntax: expected token: COMPRESSION to follow WITH (Error 3723)
Send feedback

This error occurs when using CREATE TABLE or ALTER TABLE ALTER COLUMN syntax. It occurs when referencing one of the NATIONAL CHARACTER synonyms for a column type and not using the COMPRESSION keyword following the WITH keyword. The following is a valid SQL statement: CREATE TABLE foo (foo NCHAR WITH COMP);. The following SQL statement would return the error: CREATE TABLE foo (foo NCHAR WITH);.


Could not write to file

 Copy code hover
[image]

Could not write to file <name>. (Error 3180)
Send feedback

You tried to export data to the specified text or spreadsheet file, but the file could not be modified.

Possible causes:

  • Another user is currently accessing the file. Wait for the other user to finish using the file and then try the operation again.

  • The file has been defined as read-only in the operating system or by your network. Resolve the read-only condition and then try the operation again.

  • In a network environment, you do not have write privileges for the file.

You may need to contact your system administrator or network administrator.


OptionGroup.SpecialEffect Property (Access)

 Copy code hover
[image]

OptionGroup.SpecialEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.

Syntax

expression .SpecialEffect

expression A variable that represents an OptionGroup object.

Remarks

The SpecialEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | 0 | The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised | 1 | The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken | 2 | The object has a shadow on the top and left and a highlight on the bottom and right.
Etched | 3 | The object has a sunken line surrounding the control.
Shadowed | 4 | The object has a shadow below and to the right of the control.
Chiseled | 5 | The object has a sunken line below the control.

The SpecialEffect property setting affects related property settings for the BorderStyle , BorderColor , and BorderWidth properties. For example, if the SpecialEffect property is set to Raised, the settings for the BorderStyle, BorderColor, and BorderWidth properties are ignored. In addition, changing or setting the BorderStyle, BorderColor, and BorderWidth properties may cause Microsoft Access to change the SpecialEffect property setting to Flat.

Example

The following example sets the appearance of the text box "OrganizationName1" on the "Mailing List" form to raised.

VBA Copy code Copy code
Forms("Mailing List").Controls("OrganizationName1").SpecialEffect = 1

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


CheckBox.GridlineColor Property (Access)

 Copy code hover
[image]

CheckBox.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified check box. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineColor

expression A variable that represents a CheckBox object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Report.Error Event (Access)

 Copy code hover
[image]

Report.Error Event (Access)
See also Send feedback

Published: July 16, 2012

The Error event occurs when a run-time error is produced in Microsoft Access when a report has the focus.

Syntax

expression .Error(DataErr, Response)

expression A variable that represents a Report object.

Parameters

Name

Required/Optional

Data Type

Description

DataErr

Required

Integer

The error code returned by the Err object when an error occurs. You can use the DataErr argument with the Error function to map the number to the corresponding error message.

Response

Required

Integer

The setting determines whether or not an error message is displayed. The Response argument can be one of the following intrinsic constants.

  • acDataErrContinue Ignore the error and continue without displaying the default Microsoft Access error message. You can supply a custom error message in place of the default error message.

  • acDataErrDisplay (Default) Display the default Microsoft Access error message.

Return Value

nothing

Remarks

This includes Microsoft Access database engine errors, but not run-time errors in Visual Basic or errors from ADO.

To run a macro or event procedure when this event occurs, set the OnError property to the name of the macro or to [Event Procedure].

By running an event procedure or a macro when an Error event occurs, you can intercept a Microsoft Access error message and display a custom message that conveys a more specific meaning for your application.

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Handling Access Errors with VBA

Example

The following example shows how you can replace a default error message with a custom error message. When Microsoft Access returns an error message indicating it has found a duplicate key (error code 3022), this event procedure displays a message that gives more application-specific information to users.

To try the example, add the following event procedure to a form that is based on a table with a unique employee ID number as the key for each record.

VBA Copy code Copy code
Private Sub Form_Error(DataErr As Integer, Response As Integer)
    Const conDuplicateKey = 3022
    Dim strMsg As String

    If DataErr = conDuplicateKey Then
        Response = acDataErrContinue
        strMsg = "Each employee record must have a unique " _
            & "employee ID number. Please recheck your data."
        MsgBox strMsg
    End If
End Sub

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Report Object

Other resources

Report Object Members


Execute, Requery, and Clear Methods Example (VB)

 Copy code hover
[image]

Execute, Requery, and Clear Methods Example (VB)
Send feedback

This example demonstrates the Execute method when run from both a Command object and a Connection object. It also uses the Requery method to retrieve current data in a Recordset, and the Clear method to clear the contents of the Errors collection. (The Errors collection is accessed via the Connection object of the ActiveConnection property of the Recordset.) The ExecuteCommand and PrintOutput procedures are required for this procedure to run.

Copy code Copy code

'BeginExecuteVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo Err_Execute

 ' connection, command, and recordset variables
 Dim Cnxn As ADODB.Connection
 Dim cmdChange As ADODB.Command
 Dim rstTitles As ADODB.Recordset
 Dim Err As ADODB.Error
 Dim strSQLChange As String
 Dim strSQLRestore As String
 Dim strSQLTitles
 Dim strCnxn As String

 ' Define two SQL statements to execute as command text
 strSQLChange = "UPDATE Titles SET Type = 'self_help' WHERE Type = 'psychology'"
 strSQLRestore = "UPDATE Titles SET Type = 'psychology' WHERE Type = 'self_help'"

 ' Open connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Set Cnxn = New ADODB.Connection
 Cnxn.Open strCnxn

 ' Create command object
 Set cmdChange = New ADODB.Command
 Set cmdChange.ActiveConnection = Cnxn
 cmdChange.CommandText = strSQLChange

 ' Open titles table
 Set rstTitles = New ADODB.Recordset
 strSQLTitles = "titles"
 rstTitles.Open strSQLTitles, Cnxn, , , adCmdTable

 ' Print report of original data
 Debug.Print _
 "Data in Titles table before executing the query"
 PrintOutput rstTitles

 ' Call the ExecuteCommand subroutine below to execute cmdChange command
 ExecuteCommand cmdChange, rstTitles

 ' Print report of new data
 Debug.Print _
 "Data in Titles table after executing the query"
 PrintOutput rstTitles

 ' Use the Connection object's execute method to
 ' execute SQL statement to restore data and trap for
 ' errors, checking the Errors collection if necessary
 Cnxn.Execute strSQLRestore, , adExecuteNoRecords

 ' Retrieve the current data by requerying the recordset
 rstTitles.Requery

 ' Print report of restored data using sub from below
 Debug.Print "Data after executing the query to restore the original information "
 PrintOutput rstTitles

 ' clean up
 rstTitles.Close
 Cnxn.Close
 Set rstTitles = Nothing
 Set Cnxn = Nothing
 Exit Sub

Err_Execute:
 ' Notify user of any errors that result from
 ' executing the query
 If rstTitles.ActiveConnection.Errors.Count >= 0 Then
 For Each Err In rstTitles.ActiveConnection.Errors
 MsgBox "Error number: " & Err.Number & vbCr & _
 Err.Description
 Next Err
 End If

 ' clean up
 If Not rstTitles Is Nothing Then
 If rstTitles.State = adStateOpen Then rstTitles.Close
 End If
 Set rstTitles = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub

Public Sub ExecuteCommand(cmdTemp As ADODB.Command, rstTemp As ADODB.Recordset)

 Dim Err As Error

 ' Run the specified Command object and trap for
 ' errors, checking the Errors collection
 On Error GoTo Err_Execute
 cmdTemp.Execute
 On Error GoTo 0

 ' Retrieve the current data by requerying the recordset
 rstTemp.Requery

 Exit Sub

Err_Execute:

 ' Notify user of any errors that result from
 ' executing the query
 If rstTemp.ActiveConnection.Errors.Count > 0 Then
 For Each Err In rstTemp.ActiveConnection.Errors
 MsgBox "Error number: " & Err.Number & vbCr & _
 Err.Description
 Next Err
 End If

 Resume Next

End Sub

Public Sub PrintOutput(rstTemp As ADODB.Recordset)

 ' Enumerate Recordset
 Do While Not rstTemp.EOF
 Debug.Print " " & rstTemp!Title & _
 ", " & rstTemp!Type
 rstTemp.MoveNext
 Loop

End Sub
'EndExecuteVB


PageBreak.Section Property (Access)

 Copy code hover
[image]

PageBreak.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Syntax

expression .Section

expression A variable that represents a PageBreak object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

PageBreak Object

Other resources

PageBreak Object Members


WebBrowserControl.Enabled Property (Access)

 Copy code hover
[image]

WebBrowserControl.Enabled Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .Enabled

expression A variable that represents a WebBrowserControl object.

Remarks

The Enabled property setting is a value that indicates whether the conditional format is enabled or disabled. True enables the conditional format. False disables the conditional format. The default is True.

When the Enabled property is True, the conditional format can be displayed in the Conditional Formatting dialog box.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


ODBC -- remote query timeout expired. (Error 3234)

 Copy code hover
[image]

ODBC -- remote query timeout expired. (Error 3234)
Send feedback

The ODBC server may not be properly installed, or a required network connection is not active. Try increasing the value of the QueryTimeout property.


Select Query

 Copy code hover
[image]

Select Query
Send feedback

Published: July 16, 2012

A select query asks questions about the data stored in your database and returns the result of the query without changing the data. Once the result set is displayed, you can view and, in some cases, change the data in the underlying tables. In contrast, an action query does make changes to your data.


Axis Properties, Methods, and Events (ADO MD)

 Copy code hover
[image]

Axis Properties, Methods, and Events (ADO MD)
Send feedback

Properties/Collections

DimensionCount Property

Name Property

Positions Collection

Properties Collection

Methods

None.

Events

None.


Requery Macro Action

 Copy code hover
[image]

Requery Macro Action
Send feedback

You can use the Requery action to update the data in a specified control on the active object by requerying the source of the control. If no control is specified, this action requeries the source of the object itself. Use this action to ensure that the active object or one of its controls displays the most current data.

Setting

The Requery action has the following argument.

Action argument | Description
Control Name | The name of the control you want to update. Enter the control name in the Control Name box in the Action Arguments section of the Macro Builder pane. You should use only the name of the control, not the fully qualified identifier (such as Forms!formname!controlname). Leave this argument blank to requery the source of the active object. If the active object is a datasheet or a query result set, you must leave this argument blank.

Remarks

The Requery action does one of the following:

  • Reruns the query on which the control or object is based.

  • Displays any new or changed records, and removes any deleted records from the table on which the control or object is based.

Note Note

The Requery action does not affect the position of the record pointer.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts.

  • Controls containing domain aggregate functions, such as DSum.

If the specified control isn't based on a query or table, this action forces a recalculation of the control.

If you leave the Control Name argument blank, the Requery action has the same effect as pressing SHIFT+F9 when the object has the focus. If a subform control has the focus, this action requeries only the source of the subform (just as pressing SHIFT+F9 does).

Note Note

The Requery action requeries the source of the control or object. In contrast, the RepaintObject action repaints controls in the specified object but doesn't requery the database or display new records. The ShowAllRecords action not only requeries the active object, but it also removes any applied filters, which the Requery action doesn't do.

If you want to requery a control that isn't on the active object, you must use the Requery method in a Visual Basic for Applications (VBA) module, not the Requery action or its corresponding Requery method of the DoCmd object. The Requery method in VBA is faster than the Requery action or the DoCmd.Requery method. In addition, when you use the Requery action or the DoCmd.Requery method, Microsoft Access closes the query and reloads it from the database, but when you use the Requery method, Access reruns the query without closing and reloading it. Note that the ActiveX Data Object (ADO) Requery method works the same way as the Access Requery method.


ToggleButton.QuickStyle Property (Access)

 Copy code hover
[image]

ToggleButton.QuickStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the Quick Style that is applied to the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .QuickStyle

expression A variable that represents a ToggleButton object.

Remarks

The QuickStyle uses one of the values listed in the following table.

Value | Effect
0 (Default) | No Quick Style
1 | Colored Outline - Black, Dark 1
2 | Colored Outline - Ice Blue, Accent 1
3 | Colored Outline - Orange, Accent 2
4 | Colored Outline - Olive Green, Accent 3
5 | Colored Outline - Gold, Accent 4
6 | Colored Outline - Green, Accent 5
7 | Colored Outline - Gray-50%, Accent 6
8 | Colored Fill - Black, Dark 1
9 | Colored Fill - Ice Blue, Accent 1
10 | Colored Fill - Orange, Accent 2
11 | Colored Fill - Olive Green, Accent 3
12 | Colored Fill - Gold, Accent 4
13 | Colored Fill - Green, Accent 5
14 | Colored Fill - Gray-50%, Accent 6
15 | Light 1 Outline, Colored Fill - Black, Dark 1
16 | Light 1 Outline, Colored Fill - Ice Blue, Accent 1
17 | Light 1 Outline, Colored Fill - Orange, Accent 2
18 | Light 1 Outline, Colored Fill - Olive Green, Accent 3
19 | Light 1 Outline, Colored Fill - Gold, Accent 4
10 | Light 1 Outline, Colored Fill - Green, Accent 5
21 | Light 1 Outline, Colored Fill - Gray-50%, Accent 6
22 | Subtle Effect - Black, Dark 1
23 | Subtle Effect - Ice Blue, Accent 1
24 | Subtle Effect - Orange, Accent 2
25 | Subtle Effect - Olive Green, Accent 3
26 | Subtle Effect - Gold, Accent 4
27 | Subtle Effect - Green, Accent 5
28 | Subtle Effect - Gray-50%, Accent 6
29 | Moderate Effect - Black, Dark 1
30 | Moderate Effect - Ice Blue, Accent 1
31 | Moderate Effect - Orange, Accent 2
32 | Moderate Effect - Olive Green, Accent 3
33 | Moderate Effect - Gold, Accent 4
34 | Moderate Effect - Green, Accent 5
35 | Moderate Effect - Gray-50%, Accent 6
36 | Intense Effect - Black, Dark 1
37 | Intense Effect - Ice Blue, Accent 1
38 | Intense Effect - Orange, Accent 2
39 | Intense Effect - Olive Green, Accent 3
40 | Intense Effect - Gold, Accent 4
41 | Intense Effect - Green, Accent 5
42 | Intense Effect - Gray-50%, Accent 6

To see the available Quick Styles and apply a Quick Style through the user interface, first open the form or report in Layout view or Design view by right-clicking the form or report in the Navigation Pane, and then clicking the view you want. Then, click the object to which you want to apply a shadow effect. Next, on the Format tab, in the Control Formatting group, click Quick Styles and choose a Quick Style. Notice that the Quick Styles are indexed from left to right, and then top to bottom. So the first item,Colored Outline - Black, Dark 1, has the value 1. The first row contains Quick Styles with values from 1 to 7. The second row from 8 to 14, and so on.

This property is not surfaced in the property sheet.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


The operation failed. There are too many indexes on table

 Copy code hover
[image]

The operation failed. There are too many indexes on table <name>. Delete some of the indexes on the table and try the operation again. (Error 3626)
Send feedback

A table in a Microsoft Access database engine database can have no more than 32 indexes. You cannot create additional indexes on a table with this many indexes.

Delete one or more indexes from the named table and try the operation again.


TabControl.Name Property (Access)

 Copy code hover
[image]

TabControl.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a TabControl object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Image.Name Property (Access)

 Copy code hover
[image]

Image.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents an Image object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

Image Object

Other resources

Image Object Members


ComboBox.FontSize Property (Access)

 Copy code hover
[image]

ComboBox.FontSize Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontSize property to specify the point size for text in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Integer.

Syntax

expression .FontSize

expression A variable that represents a ComboBox object.

Remarks

The FontSize property uses the following settings.

Setting | Description
8 | (Default for all reports and controls except command buttons) The text is 8-point type.
10 | (Default for command buttons) The text is 10-point type.
Other sizes | The text is the indicated size.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set this property only in an event procedure or in a macro specified by the OnPrint event property setting.

In Visual Basic, you set the FontSize property by using a numeric expression equal to the desired size of the font. The setting for the FontSize property can be between 1 and 127, inclusive.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Form.DatasheetFontWeight Property (Access)

 Copy code hover
[image]

Form.DatasheetFontWeight Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.

Syntax

expression .DatasheetFontWeight

expression A variable that represents a Form object.

Remarks

The DatasheetFontWeight property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

These properties are only available in Visual Basic within a Microsoft Access database.

In Visual Basic, the DatasheetFontWeight property setting uses the following Integer values.

Setting | Description
100 | Thin
200 | Extra Light
300 | Light
400 | (Default) Normal
500 | Medium
600 | Semi-bold
700 | Bold
800 | Extra Bold
900 | Heavy

The following table contains the properties that don't exist in the DAO Properties collection of until you set them by using the Formatting (Datasheet) toolbar or you can add them in an Access database by using the CreateProperty method and append it to the DAO Properties collection.

DatasheetFontItalic * | DatasheetForeColor *
DatasheetFontHeight * | DatasheetBackColor
DatasheetFontName * | DatasheetGridlinesColor
DatasheetFontUnderline * | DatasheetGridlinesBehavior
DatasheetFontWeight * | DatasheetCellsEffect
Note Note

When you add or set any property listed with an asterisk, Microsoft Access automatically adds all the properties listed with an asterisk to the Properties collection of the database.

Example

The following example sets the font to MS Serif, the font size to 10 points, and the font weight to medium (500) in Datasheet view of the Products table.

VBA Copy code Copy code

Sub SetDatasheetFont

   Dim dbs As Object, objProducts As Object
   Set dbs = CurrentDb
   Const DB_Text As Long = 10
   Const DB_Integer As Long = 3
   Set objProducts = dbs!Products

   SetTableProperty objProducts, "DatasheetFontName", DB_Text, "MS Serif"
   SetTableProperty objProducts, "DatasheetFontHeight", DB_Integer, 10
   SetTableProperty objProducts, "DatasheetFontWeight", DB_Integer, 500

End Sub

Sub SetTableProperty(objTableObj As Object, strPropertyName As String, _
        intPropertyType As Integer, varPropertyValue As Variant)
    ' Set Microsoft Access-defined table property without causing
    ' nonrecoverable run-time error.
    Const conErrPropertyNotFound = 3270
    Dim prpProperty As Variant
    On Error Resume Next                ' Don't trap errors.
    objTableObj.Properties(strPropertyName) = varPropertyValue
    If Err <> 0 Then                    ' Error occurred when value set.
        If Err <> conErrPropertyNotFound Then
            On Error GoTo 0
            MsgBox "Couldn't set property '" & strPropertyName _
                & "' on table '" & objTableObj.Name & "'", 48, "SetTableProperty"
        Else
            On Error GoTo 0
            Set prpProperty = objTableObj.CreateProperty(strPropertyName, _
                intPropertyType, varPropertyValue)
            objTableObj.Properties.Append prpProperty
        End If
    End If
    objTableObj.Properties.Refresh
End Sub

The next example makes the same changes as the preceding example in Datasheet view of the open Products form.

VBA Copy code Copy code
Forms!Products.DatasheetFontName = "MS Serif"
Forms!Products.DatasheetFontHeight = 10
Forms!Products.DatasheetFontWeight = 500

See also

Concepts

Form Object

Other resources

Form Object Members


Your swap file has reached its limit or is corrupted. (Error 3540)

 Copy code hover
[image]

Your swap file has reached its limit or is corrupted. (Error 3540)
Send feedback

The Synchronizer has encountered an unexpected system problem. Shut down, turn off, and then reboot your computer.


DoCmd.RepaintObject Method (Access)

 Copy code hover
[image]

DoCmd.RepaintObject Method (Access)
See also Send feedback

Published: July 16, 2012

The RepaintObject method carries out the RepaintObject action in Visual Basic.

Syntax

expression .RepaintObject(ObjectType, ObjectName)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
ObjectType | Optional | AcObjectType | A AcObjectType constant that specifies the type of object to repaint.
ObjectName | Optional | Variant | A string expression that's the valid name of an object of the type selected by the objecttype argument.

Remarks

You can use the RepaintObject method to complete any pending screen updates for a specified database object or for the active database object, if none is specified. Such updates include any pending recalculations for the object's controls.

Using the RepaintObject method with no arguments (the default constant, acDefault, is assumed for the objecttype argument) repaints the active window.

The RepaintObject method of the DoCmd object was added to provide backwards compatibility for running the RepaintObject method in Visual Basic code in Microsoft Access 95. If you want to repaint a form, it's recommended that you use the existing Repaint method of the Form object instead.

Example

The following example repaints the table Customers:

VBA Copy code Copy code
DoCmd.RepaintObject acTable, "Customers"

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


AbsolutePage, PageCount, and PageSize Properties Example (JScript)

 Copy code hover
[image]

AbsolutePage, PageCount, and PageSize Properties Example (JScript)
Send feedback

This example demonstrates the AbsolutePage, PageCount and PageSize properties. Cut and paste the following code to Notepad or another text editor, and save it as AbsolutePageJS.asp.

Copy code Copy code

<!-- BeginAbsolutePageJS -->
<%@LANGUAGE="JScript" %>
<%// use this meta tag instead of adojavas.inc%>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->

<html>

<head>
<title>AbsolutePage, PageSize, and PageSize Properties (JScript)</title>
<style>
<!--
BODY {
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 BACKGROUND-COLOR:white;
 COLOR:black;
 }
.thead2 {
 background-color: #800000;
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 font-size: x-small;
 color: white;
 }
.tbody {
 text-align: center;
 background-color: #f7efde;
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 font-size: x-small;
 }
-->
</style>
</head>

<body bgcolor="White">
<h1>AbsolutePage, PageSize, and PageSize Properties (JScript)</h1>
<%
 // connection and recordset variables
 var Cnxn = Server.CreateObject("ADODB.Connection")
 var strCnxn = "Provider='sqloledb';Data Source=" + Request.ServerVariables("SERVER_NAME") + ";" +
 "Initial Catalog='Northwind';Integrated Security='SSPI';";
 var rsEmployee = Server.CreateObject("ADODB.Recordset");
 // display variables
 var strMessage, iRecord, iPageCount;

 try
 {
 // open connection
 Cnxn.Open(strCnxn);

 // Open a recordset on the Employee table using
 // a client-side cursor to enable AbsolutePage property.
 rsEmployee.CursorLocation = adUseClient;
 rsEmployee.Open("employees", strCnxn, adOpenStatic, adLockOptimistic, adCmdTable);

 // Set PageSize to five to display names and hire dates of five employees at a time
 rsEmployee.PageSize = 5;
 iPageCount = rsEmployee.PageCount;

 // Write header information to the document
 Response.Write('<p align="center">There are ' + iPageCount);
 Response.Write(" pages, each containing ");
 Response.Write(rsEmployee.PageSize + " or fewer records.</p>");
 Response.Write('<table border="0" align="center">');
 Response.Write('<tr class="thead2">');
 Response.Write("<th>Page</th><th>Name</th><th>Hire Date</th></tr>");

 for (var i=1; i<=iPageCount; i++)
 {
 rsEmployee.AbsolutePage = i;

 for (iRecord = 1; iRecord <= rsEmployee.PageSize; iRecord++)
 {
 strMessage = "";

 // Start a new table row.
 strMessage = '<tr class="tbody">';

 // First column in row contains page number on
 // first record of each page. Otherwise, the column
 // contains a non-breaking space.
 if (iRecord == 1)
 strMessage += "<td>Page " + i + " of " + rsEmployee.PageCount + "</td>"
 else
 strMessage += "<td>&nbsp;</td>";

 // First and last name are in first column.
 strMessage += "<TD>" + rsEmployee.Fields("FirstName") + " ";
 strMessage += rsEmployee.Fields("LastName") + " " + "</td>";

 // Hire date in second column.
 strMessage += "<td>" + rsEmployee.Fields("HireDate") + "</td>";

 // End the row.
 strMessage += "</tr>";

 // Write line to document.
 Response.Write(strMessage);

 // Get next record.
 rsEmployee.MoveNext;

 if (rsEmployee.EOF)
 break;
 }
 }

 // Finish writing table.
 Response.Write("</table>");
 }
 catch (e)
 {
 Response.Write(e.message);
 }
 finally
 {
 // 'clean up
 if (rsEmployee.State == adStateOpen)
 rsEmployee.Close;
 if (Cnxn.State == adStateOpen)
 Cnxn.Close;
 rsEmployee = null;
 Cnxn = null;
 }
%>

</body>

</html>
<!-- EndAbsolutePageJS -->


Account name already exists. (Error 3390)

 Copy code hover
[image]

Account name already exists. (Error 3390)
Send feedback

This is a security problem. You tried to establish a user account using a name that already exists. Check the Users collection to see if the user name already exists, or try again using a different user name.


MoveFirst, MoveLast, MoveNext, and MovePrevious Methods Example (VJ++)

 Copy code hover
[image]

MoveFirst, MoveLast, MoveNext, and MovePrevious Methods Example (VJ++)
Send feedback

This example uses the MoveFirst, MoveLast, MoveNext, and MovePrevious methods to move the record pointer of a Recordset based on the supplied command. The MoveAny procedure is required for this procedure to run.

Copy code Copy code

// BeginMoveFirstJ
import com.ms.wfc.data.*;
import java.io.*;

public class MoveFirstX // DLL name.
{
 // Main Function

 public static void main( String rgArg[] )
 {
 MoveFirstX();
 }

 // MoveFirstX Function

 static void MoveFirstX()
 {
 // Declarations
 Recordset rsAuthors = null;
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));
 String line = null;

 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";

 String strMessage = "UPDATE Titles SET type = 'psychology' "
 +"WHERE type = 'self_help'";

 int intCommand = 0;
 String strFName;
 String strLName;

 try
 {
 // Open recordset from Authors table.
 rsAuthors = new Recordset();
 rsAuthors.setCursorLocation( AdoEnums.CursorLocation.CLIENT );

 // Use client cursor to enable AbsolutePosition property.
 rsAuthors.open( "Authors", strCnn, AdoEnums.CursorType.STATIC,
 AdoEnums.LockType.BATCHOPTIMISTIC, AdoEnums.CommandType.TABLE );

 // Get user's move requests and show current record information.
 while( true ) // Continuous loop.
 {
 // Assign field information to variable to simplify output code.
 strFName = rsAuthors.getField("au_fname").getString();
 strLName = rsAuthors.getField("au_lname").getString();

 System.out.println
 ( "\nName: " + strFName + " " + strLName + "\n"
 + "Record " + rsAuthors.getAbsolutePosition()
 + " of " + rsAuthors.getRecordCount() + "\n\n" );
 System.out.println( "[1 - MoveFirst, 2 - MoveLast, \n");
 System.out.println( " 3 - MoveNext, 4 - MovePrevious]\n");

 // User types a number followed by enter (cr-lf).
 line = in.readLine();

 // No entry exits program loop.
 if (line.length() == 0) break;
 // Convert string entry to int.
 intCommand = Integer.parseInt(line);
 // Out of range entry exits program loop.
 if ((intCommand < 1) || (intCommand > 4)) break;

 // Call method based on user's validated selection.
 MoveAny(intCommand, rsAuthors);
 }
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rsAuthors != null)
 {
 PrintProviderError(rsAuthors.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 // System Read requires this catch.
 catch( java.io.IOException je )
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rsAuthors != null)
 if (rsAuthors.getState() == 1)
 rsAuthors.close();
 }
 }

 // MoveAny Function

 static void MoveAny(int intChoice, Recordset rsTemp)
 {
 // Move per selection from user, checking for BOF and EOF.
 try
 {
 switch(intChoice)
 {
 case 1: // Equals char of 1.
 rsTemp.moveFirst();
 break;
 case 2: // Equals char of 2.
 rsTemp.moveLast();
 break;
 case 3: // Equals char of 3.
 rsTemp.moveNext();
 if(rsTemp.getEOF())
 {
 System.out.println("\nAlready at end of recordset!\n");
 rsTemp.moveLast();
 }
 break;
 case 4: // Equals char of 4.
 rsTemp.movePrevious();
 if(rsTemp.getBOF())
 {
 System.out.println
 ("\nAlready at beginning of recordset!\n");
 rsTemp.moveFirst();
 }
 break;
 default:
 break;
 }
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rsTemp != null)
 {
 PrintProviderError(rsTemp.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndMoveFirstJ


Label.Tag Property (Access)

 Copy code hover
[image]

Label.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents a Label object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

Label Object

Other resources

Label Object Members


TableDefs.Count Property (DAO)

 Copy code hover
[image]

TableDefs.Count Property (DAO)
Send feedback

Returns the number of objects in the specified collection. Read-only.

Syntax

expression .Count

expression A variable that represents a TableDefs object.

Remarks

Because members of a collection begin with 0, you should always code loops starting with the 0 member and ending with the value of the Count property minus 1. If you want to loop through the members of a collection without checking the Count property, you can use a For Each...Next command.

The Count property setting is never Null. If its value is 0, there are no objects in the collection.


SharedResource.Type Property (Access)

 Copy code hover
[image]

SharedResource.Type Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the type of the SharedResource object. Read-only AcResourceType.

Version Information

Version Added: Access 2010

Syntax

expression .Type

expression A variable that represents a SharedResource object.

See also

Concepts

SharedResource Object

Other resources

SharedResource Object Members


TextBox.DisplayWhen Property (Access)

 Copy code hover
[image]

TextBox.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Syntax

expression .DisplayWhen

expression A variable that represents a TextBox object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Microsoft Data Shaping Service for OLE DB (ADO Service Provider)

 Copy code hover
[image]

Microsoft Data Shaping Service for OLE DB (ADO Service Provider)
Send feedback

The Microsoft Data Shaping Service for OLE DB service provider supports the construction of hierarchical (shaped) Recordset objects from a data provider.

Provider Keyword

To invoke the Data Shaping Service for OLE DB, specify the following keyword and value in the connection string.

Copy code Copy code

"Provider=MSDataShape"

Dynamic Properties

When this service provider is invoked, the following dynamic properties are added to the Connection object's Properties collection.

Dynamic Property Name | Description
Unique Reshape Names | Indicates whether Recordset objects with duplicate values for their Reshape Name properties are allowed. If this dynamic property is True and a new Recordset is created with the same user-specified reshape name as an existing Recordset, then the new Recordset object's reshape name is modified to make it unique. If this property is False and a new Recordset is created with the same user-specified reshape name as the existing Recordset, both Recordset objects will have the same reshape name. Therefore, neither Recordset can be reshaped as long as both recordsets exist. The default value of the property is False.
Data Provider | Indicates the name of the provider that will supply rows to be shaped. This value may be NONE if a provider will not be used to supply rows.

You may also set writable dynamic properties by specifying their names as keywords in the connection string. For example, in Microsoft Visual Basic, set the Data Provider dynamic property to "MSDASQL" by specifying:

Copy code Copy code

Dim cn as New ADODB.Connection
cn.Open "Provider=MSDataShape;Data Provider=MSDASQL"

You may also set or retrieve a dynamic property by specifying its name as the index to the Properties property. For example, get and print the current value of the Data Provider dynamic property, then set a new value, like this:

Copy code Copy code

Debug.Print cn.Properties("Data Provider")
cn.Properties("Data Provider") = "MSDASQL"

For more information about data shaping, see Data Shaping.


Using RDS with ODBC Connection Pooling

 Copy code hover
[image]

Using RDS with ODBC Connection Pooling
Send feedback

If you're using an ODBC data source, you can use the connection pooling option in Internet Information Services (IIS) to achieve high performance handling of client load. Connection pooling is a resource manager for connections, maintaining the open state on frequently used connections.

To enable connection pooling, refer to the Internet Information Services documentation.

Please note that enabling connection pooling may subject the Web server to other restrictions, as noted in the Microsoft Internet Information Services documentation.

To ensure that connection pooling is stable and provides additional performance gains, you must configure Microsoft SQL Server to use the TCP/IP Socket network library.

To do this, you need to:

  • Configure the SQL Server computer to use TCP/IP Sockets.

  • Configure the Web server to use TCP/IP Sockets.

Configuring the SQL Server Computer to Use TCP/IP Sockets

On the SQL Server computer, run the SQL Server Setup program so that interactions with the data source use the TCP/IP Socket network library.

To specify the TCP/IP Socket network library on the SQL Server computer

In Microsoft SQL Server 6.5:

  1. From the Start menu, point to Programs, point to Microsoft SQL Server 6.5, and then click SQL Setup.

  2. Click Continue twice.

  3. In the Microsoft SQL Server — Options dialog box, select Change Network Support, and then click Continue.

  4. Make sure the TCP/IP Sockets check box is selected, and click OK.

  5. Click Continue to finish, and exit setup.

In Microsoft SQL Server 7.0:

  1. From the Start menu, point to Programs, point to Microsoft SQL Server 7.0, and then click Server Network Utility.

  2. On the General tab of the dialog box, click Add.

  3. In the Add Network Library Configuration dialog box, click TCP/IP.

  4. In the Port number and Proxy address boxes, enter the port number and proxy address provided by your network administrator.

  5. Click OK to finish, and exit setup.

Configuring the Web Server to Use TCP/IP Sockets

There are two options for configuring the Web server to use TCP/IP Sockets. What you do depends on whether all SQL Servers are accessed from the Web server, or only a specific SQL Server is accessed from the Web server.

If all SQL Servers are accessed from the Web server, you need to run the SQL Server Client Configuration Utility on the Web server computer. The following steps change the default network library for all SQL Server connections made from this IIS Web server to use the TCP/IP Sockets network library.

To configure the Web server (all SQL Servers)

For Microsoft SQL Server 6.5:

  1. From the Start menu, point to Programs, point to Microsoft SQL Server 6.5, and then click SQL Client Configuration Utility.

  2. Click the Net Library tab.

  3. In the Default Network box, select TCP/IP Sockets.

  4. Click Done to save changes and exit the utility.

For Microsoft SQL Server 7.0:

  1. From the Start menu, point to Programs, point to Microsoft SQL Server 7.0, and then click Client Network Utility.

  2. Click the General tab.

  3. In the Default network library box, click TCP/IP.

  4. Click OK to save changes and exit the utility.

If a specific SQL Server is accessed from a Web server, you need to run the SQL Server Client Configuration Utility on the Web server computer. To change the network library for a specific SQL Server connection, configure the SQL Server Client software on the Web server computer as follows.

To configure the Web server (a specific SQL Server)

For Microsoft SQL Server 6.5:

  1. From the Start menu, point to Programs, point to Microsoft SQL Server 6.5, and then click SQL Client Configuration Utility.

  2. Click the Advanced tab.

  3. In the Server box, type the name of the server to connect to using TCP/IP Sockets.

  4. In the DLL Name box, select TCP/IP Sockets.

  5. Click Add/Modify. All data sources pointing to this server will now use TCP/IP Sockets.

  6. Click Done.

For Microsoft SQL Server 7.0:

  1. From the Start menu, point to Programs, point to Microsoft SQL Server 7.0, and then click Client Configuration Utility.

  2. Click the General tab.

  3. Click Add.

  4. Enter the alias of the server in the Server alias box. In the Network libraries box, click TCP/IP. In the Computer name box, enter the computer name of the computer that listens for TCP/IP Sockets clients. In the Port number box, enter the port on which the SQL Server listens.

  5. Click OK, and then OK again to exit the utility.


Entities.Item Property (Access)

 Copy code hover
[image]

Entities.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only Object.

Version Information

Version Added: Access 2010

Syntax

expression .Item(Index)

expression A variable that represents an Entities object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant |

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

Entities Collection

Other resources

Entities Object Members


NavigationButton.Shadow Property (Access)

 Copy code hover
[image]

NavigationButton.Shadow Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the Shadow effect applied to the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .Shadow

expression A variable that represents a NavigationButton object.

Remarks

The Shadow property uses one of the values listed in the following table.

Value | Effect
0 Default) | None
1 | Offset Diagonal Bottom Right
2 | Offset Bottom
3 | Offset Diagonal Bottom Left
4 | Offset Right
5 | Offset Center
6 | Offset Left
7 | Offset Diagonal Top Right
8 | Offset Top
9 | Offset Diagonal Top Left
10 | Inside Diagonal Top Left
11 | Inside Top
12 | Inside Diagonal Top Right
13 | Inside Left
14 | Inside Center
15 | Inside Right
16 | Inside Diagonal Bottom Left
17 | Inside Bottom
18 | Inside Diagonal Bottom Right
19 | Perspective Diagonal Upper Left
20 | Perspective Diagonal Upper Right
21 | Below
22 | Perspective Diagonal Lower Left
23 | Perspective Diagonal Lower Right

To see the available shadow effects and apply a shadow through the user interface, first open the form or report in Layout view or Design view by right-clicking the form or report in the Navigation Pane, and then clicking the view you want. Then, click the object to which you want to apply a shadow effect. Next, on the Format tab, in the Control Formatting group, click Shape Effects, then click Shadow and choose a shadow effect. Notice that the shadow effects are indexed from left to right, and then top to bottom. So the first item, under No Shadow, has the value 0. Then, under Outer, the first row contains shadow effects with values from 1 to 3. The second row from 4 to 6, and so on.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Line.BorderWidth Property (Access)

 Copy code hover
[image]

Line.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Syntax

expression .BorderWidth

expression A variable that represents a Line object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

Line Object

Other resources

Line Object Members


ToggleButton.LabelY Property (Access)

 Copy code hover
[image]

ToggleButton.LabelY Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelY

expression A variable that represents a ToggleButton object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Relations Object Reference (DAO)

 Copy code hover
[image]

Relations Object Reference (DAO)
Send feedback

In this section

  • Relations Collection (DAO)

  • Relations Members (DAO)

  • Relations Properties (DAO)

  • Relations Methods (DAO)


Syntax error (missing operator). (Error 2431)

 Copy code hover
[image]

Syntax error (missing operator). (Error 2431)
Send feedback

The expression or statement is missing an operator.


Field2.Value Property (DAO)

 Copy code hover
[image]

Field2.Value Property (DAO)
Send feedback

Sets or returns the value of an object. Read/write Variant.

Syntax

expression .Value

expression A variable that represents a Field2 object.

Remarks

The setting or return value is a Variant data type that evaluates to a value appropriate for the data type, as specified by the Type property of an object.

Generally, the Value property is used to retrieve and alter data in Recordset objects.

The Value property is the default property of the Field2, Parameter, and Property objects. Therefore, you can set or return the value of one of these objects by referring to them directly instead of specifying the Value property.

Trying to set or return the Value property in an inappropriate context (for example, the Value property of a Field2 object in the Fields collection of a TableDef object) will cause a trappable error.

Note Note

When reading decimal values from a Microsoft SQL Server database, they will be formatted using scientific notation through a Microsoft Access workspace, but will appear as normal decimal values through an ODBCDirect workspace.


ListBox.ScrollBarAlign Property (Access)

 Copy code hover
[image]

ListBox.ScrollBarAlign Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ScrollBarAlign to specify or determine the alignment of a vertical scroll bar. Read/write Byte.

Syntax

expression .ScrollBarAlign

expression A variable that represents a ListBox object.

Remarks

The ScrollBarAlign property uses the following settings.

Setting | Visual Basic | Description
System | 0 | Vertical scroll bar is placed on the left if the form or report Orientation property is right to left; and on the right if the form or report Orientation property is left to right.
Right | 1 | Aligns vertical scroll bar on the right side of the control.
Left | 2 | Aligns vertical scroll bar on the left side of the control.

For combo and list boxes, ScrollBarAlign also controls the placement of the box button above the scroll bar.

Example

The following example aligns the vertical scroll bar on the left side of the "Country" combo box in the "International Shipping" form.

VBA Copy code Copy code
Forms("International Shipping").Controls("Country").ScrollBarAlign = 2

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


TextBox.InSelection Property (Access)

 Copy code hover
[image]

TextBox.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents a TextBox object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Supports Method Example (VB)

 Copy code hover
[image]

Supports Method Example (VB)
Send feedback

This example uses the Supports method to display the options supported by a recordset opened with different cursor types. The DisplaySupport procedure is required for this procedure to run.

Copy code Copy code

'BeginSupportsVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 ' recordset and connection variables
 Dim rstTitles As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim strSQLTitles As String
 ' array variables
 Dim arrCursorType(4) As Integer
 Dim intIndex As Integer

 ' open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Fill array with CursorType constants
 arrCursorType(0) = adOpenForwardOnly
 arrCursorType(1) = adOpenKeyset
 arrCursorType(2) = adOpenDynamic
 arrCursorType(3) = adOpenStatic

 ' open recordset using each CursorType and optimistic locking
 For intIndex = 0 To 3
 Set rstTitles = New ADODB.Recordset
 rstTitles.CursorType = arrCursorType(intIndex)
 rstTitles.LockType = adLockOptimistic

 strSQLTitles = "Titles"
 rstTitles.Open strSQLTitles, Cnxn, , , adCmdTable

 Select Case arrCursorType(intIndex)
 Case adOpenForwardOnly
 Debug.Print "ForwardOnly cursor supports:"
 Case adOpenKeyset
 Debug.Print "Keyset cursor supports:"
 Case adOpenDynamic
 Debug.Print "Dynamic cursor supports:"
 Case adOpenStatic
 Debug.Print "Static cursor supports:"
 End Select

 ' call the DisplaySupport procedure from below
 ' to display the supported options
 DisplaySupport rstTitles

 Next intIndex

 ' clean up
 rstTitles.Close
 Cnxn.Close
 Set rstTitles = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstTitles Is Nothing Then
 If rstTitles.State = adStateOpen Then rstTitles.Close
 End If
 Set rstTitles = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndSupportsVB

'BeginSupports2VB
Public Sub DisplaySupport(rstTemp As ADODB.Recordset)

 Dim arrConstants(11) As Long
 Dim blnSupports As Boolean
 Dim intIndex As Integer

 ' Fill array with cursor option constants
 arrConstants(0) = adAddNew
 arrConstants(1) = adApproxPosition
 arrConstants(2) = adBookmark
 arrConstants(3) = adDelete
 arrConstants(4) = adFind
 arrConstants(5) = adHoldRecords
 arrConstants(6) = adMovePrevious
 arrConstants(7) = adNotify
 arrConstants(8) = adResync
 arrConstants(9) = adUpdate
 arrConstants(10) = adUpdateBatch

 For intIndex = 0 To 10
 blnSupports = _
 rstTemp.Supports(arrConstants(intIndex))
 If blnSupports Then
 Select Case arrConstants(intIndex)
 Case adAddNew
 Debug.Print " AddNew"
 Case adApproxPosition
 Debug.Print " AbsolutePosition and AbsolutePage"
 Case adBookmark
 Debug.Print " blnkmark"
 Case adDelete
 Debug.Print " Delete"
 Case adFind
 Debug.Print " Find"
 Case adHoldRecords
 Debug.Print " Holding Records"
 Case adMovePrevious
 Debug.Print " MovePrevious and Move"
 Case adNotify
 Debug.Print " Notifications"
 Case adResync
 Debug.Print " Resyncing data"
 Case adUpdate
 Debug.Print " Update"
 Case adUpdateBatch
 Debug.Print " batch updating"
 End Select
 End If
 Next intIndex

End Sub
'EndSupports2VB


The combined length of Internet Server Name, HTTP Share name, and FTP alias name should not be greater than 252 characters. (Error 3745)

 Copy code hover
[image]

The combined length of Internet Server Name, HTTP Share name, and FTP alias name should not be greater than 252 characters. (Error 3745)
Send feedback

The indirect or internet values specified exceed the internal limit of 252 characters. You must shorten the name that violates this limit.


BoundObjectFrame.Width Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents a BoundObjectFrame object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


AllQueries.Parent Property (Access)

 Copy code hover
[image]

AllQueries.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents an AllQueries object.

See also

Concepts

AllQueries Collection

Other resources

AllQueries Object Members


Multiple Fields in Criteria Expressions

 Copy code hover
[image]

Multiple Fields in Criteria Expressions
Send feedback

You can specify multiple fields in a criteria argument.

To specify multiple fields in the criteria argument, you must ensure that multiple string expressions are concatenated correctly to form a valid SQL WHERE clause. In an SQL WHERE clause with multiple fields, fields may be joined with one of three keywords: AND, OR, or NOT. Your expression must evaluate to a string that includes one of these keywords.

For example, suppose that you wish to set the Filter property of an Employees form to display records restricted by two sets of criteria. The following example filters the form so that it displays only those employees whose title is "Sales Representative" and who were hired since January 1, 1993:

Copy code Copy code
Dim datHireDate As Date
Dim strTitle As String

datHireDate = #1/1/93#
strTitle = "Sales Representative"

Forms!Employees.Filter = "[HireDate] >= #" & _
 datHireDate & "# AND [Title] = '" & strTitle & "'"
Forms!Employees.FilterOn = True

The criteria argument evaluates to the following string:

Copy code Copy code
"[HireDate] >= #1-1-93# AND [Title] = 'Sales Representative'"
Tip Tip

To troubleshoot an expression in the criteria argument, break the expression into smaller components and test each individually in the Immediate window. When all of the components are working correctly, put them back together one at a time until the complete expression works correctly.


ObjectFrame.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

ObjectFrame.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Syntax

expression .ShortcutMenuBar

expression A variable that represents an ObjectFrame object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

Example

The following example sets the "Suppliers_Toolbar" as the custom shortcut menu to display when the user clicks the right mouse button on the "Suppliers" form.

VBA Copy code Copy code
Forms("Suppliers").ShortcutMenuBar = "Suppliers_Toolbar"

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Recordset Dynamic Properties in XML
Send feedback

Recordset Dynamic Properties in XML

The following Recordset provider-specific properties (from the Client Cursor Engine) are currently persisted into the XML format:

  • Update Resync

  • Unique Table

  • Unique Schema

  • Unique Catalog

  • Resync Command

  • IRowsetChange

  • IRowsetUpdate

  • CommandTimeout

  • BatchSize

  • UpdateCriteria

  • Reshape Name

  • AutoRecalc

These properties are saved in the schema section as attributes of the element definition for the Recordset being persisted. These attributes are defined in the rowset schema namespace and must have the prefix "rs:".


ComboBox.Locked Property (Access)

 Copy code hover
[image]

ComboBox.Locked Property (Access)
See also Send feedback

Published: July 16, 2012

The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.

Syntax

expression .Locked

expression A variable that represents a ComboBox object.

Remarks

The default setting of the Locked property is True. This setting allows editing, adding, and deleting data.

Use the Locked property to protect data in a field by making it read-only. For example, you might want a control to only display information without allowing editing, or you might want to lock a control until a specific condition is met.

Example

The following example toggles the Enabled property of a command button and the Enabled and Locked properties of a control, depending on the type of employee displayed in the current record. If the employee is a manager, then the SalaryDetails button is enabled and the PersonalInfo control is unlocked and enabled.

VBA Copy code Copy code
Sub Form_Current()
 If Me!EmployeeType = "Manager" Then
 Me!SalaryDetails.Enabled = True
 Me!PersonalInfo.Enabled = True
 Me!PersonalInfo.Locked = False
 Else
 Me!SalaryDetails.Enabled = False
 Me!PersonalInfo.Enabled = False
 Me!PersonalInfo.Locked = True
 End If
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Recordset2 Members (DAO)

 Copy code hover
[image]

Recordset2 Members (DAO)
Send feedback

A Recordset2 object represents the records in a base table or the records that result from running a query.

Methods

Name

Description

AddNew

Creates a new record for an updatable Recordset2 object.

Cancel

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Cancels execution of a pending asynchronous method call (ODBCDirect workspaces only).

CancelUpdate

Cancels any pending updates for a Recordset object.

Clone

Creates a duplicate Recordset object that refers to the original Recordset2 object.

Close

Closes an open Recordset.

CopyQueryDef

Returns a QueryDef object that is a copy of the QueryDef used to create the Recordset object represented by the recordset placeholder (Microsoft Access workspaces only). .

Delete

Not supported for this object.

Edit

Copies the current record from an updatable Recordset object to the copy buffer for subsequent editing.

FillCache

Fills all or a part of a local cache for a Recordset object that contains data from a Microsoft Access database engine-connected ODBC data source (Microsoft Access database engine-connected ODBC databases only).

FindFirst

Locates the first record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only).

FindLast

Locates the last record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only).

FindNext

Locates the next record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only). .

FindPrevious

Locates the previous record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only). .

GetRows

Retrieves multiple rows from a Recordset object.

Move

Moves the position of the current record in a Recordset object.

MoveFirst

Moves to the first record in a specified Recordset object and make that record the current record.

MoveLast

Moves to the last record in a specified Recordset object and make that record the current record.

MoveNext

Moves to the next record in a specified Recordset object and make that record the current record.

MovePrevious

Moves to the previous record in a specified Recordset object and make that record the current record.

NextRecordset

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Gets the next set of records, if any, returned by a multi-part select query in an OpenRecordset call, and returns a Boolean value indicating whether one or more additional records are pending (ODBCDirect workspaces only).

OpenRecordset

Creates a new Recordset object and appends it to the Recordsets collection.

Requery

Updates the data in a Recordset object by re-executing the query on which the object is based.

Seek

Locates the record in an indexed table-type Recordset object that satisfies the specified criteria for the current index and makes that record the current record (Microsoft Access workspaces only).

Update

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Saves the contents of the copy buffer to an updatable Recordset object.

Properties

Name

Description

AbsolutePosition

Sets or returns the relative record number of a Recordset2 object's current record.

BatchCollisionCount

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Returns the number of records that did not complete the last batch update (ODBCDirect workspaces only).

BatchCollisions

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Returns an array of bookmarks indicating the rows that generated collisions in the last batch update operation (ODBCDirect workspaces only).

BatchSize

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Sets or returns the number of statements sent back to the server in each batch (ODBCDirect workspaces only).

BOF

Returns a value that indicates whether the current record position is before the first record in a Recordset object. Read-only Boolean.

Bookmark

Sets or returns a bookmark that uniquely identifies the current record in a Recordset object.

Bookmarkable

Returns a value that indicates whether a Recordset object supports bookmarks, which you can set by using the Bookmark property.

CacheSize

Sets or returns the number of records retrieved from an ODBC data source that will be cached locally. Read/write Long.

CacheStart

Sets or returns a value that specifies the bookmark of the first record in a dynaset-type Recordset object containing data to be locally cached from an ODBC data source (Microsoft Access workspaces only).

Connection

Returns the Connection object that corresponds to the database.

DateCreated

Returns the date and time a base table was created (Microsoft Access workspaces only). Read-only Variant.

EditMode

Returns a value that indicates the state of editing for the current record.

EOF

Returns a value that indicates whether the current record position is after the last record in a Recordset object. Read-only Boolean.

Fields

Returns a Fields collection that represents all stored Field objects for the specified object. Read-only.

Filter

Sets or returns a value that determines the records included in a subsequently opened Recordset object (Microsoft Access workspaces only). Read/write String.

Index

Sets or returns a value that indicates the name of the current Index object in a table-type Recordset object (Microsoft Access workspaces only).

LastModified

Returns a ookmark indicating the most recently added or changed record.

LastUpdated

Returns the date and time of the most recent change made to a base table. Read-only Variant.

LockEdits

Sets or returns a value indicating the type of locking that is in effect while editing.

Name

Returns the name of the specified object. Read-only String.

NoMatch

Indicates whether a particular record was found by using the Seek method or one of the Find methods (Microsoft Access workspaces only).

ParentRecordset

Returns the parent Recordset of the specified recordset. Read-only.

PercentPosition

Sets or returns a value indicating the approximate location of the current record in the Recordset object based on a percentage of the records in the Recordset.

Properties

Returns the Properties collection of the specified object. Read-only.

RecordCount

Returns the number of records accessed in a Recordset object, or the total number of records in a table-type Recordset object. or TableDef object. Read-only Long.

RecordStatus

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Returns a value indicating the update status of the current record if it is part of a batch update (ODBCDirect workspaces only). Read-only RecordStatusEnum.

Restartable

Returns a value that indicates whether a Recordset object supports the Requery method, which re-executes the query on which the Recordset object is based.

Sort

Sets or returns the sort order for records in a Recordset object (Microsoft Access workspaces only).

StillExecuting

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013 . Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Indicates whether or not an asynchronous operation (that is, a method called with the dbRunAsync option) has finished executing (ODBCDirect workspaces only).

Transactions

Returns a value that indicates whether an object supports transactions. Read-only Boolean.

Type

Sets or returns a value that indicates the operational type or data type of an object. Read-only Integer.

Updatable

Returns a value that indicates whether you can change a DAO object. Read-only Boolean.

UpdateOptions

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Sets or returns a value that indicates how the WHERE clause is constructed for each record during a batch update, and whether the batch update should use an UPDATE statement or a DELETE followed by an INSERT (ODBCDirect workspaces only). Read/write UpdateCriteriaEnum.

ValidationRule

Sets or returns a value that validates the data in a field as it's changed or added to a table (Microsoft Access workspaces only).Read/write String.

ValidationText

Sets or returns a value that specifies the text of the message that your application displays if the value of a Field object doesn't satisfy the validation rule specified by the ValidationRule property setting (Microsoft Access workspaces only). Read-only String.


Relation.Fields Property (DAO)

 Copy code hover
[image]

Relation.Fields Property (DAO)
Send feedback

Returns a Fields collection that represents all stored Field objects for the specified object. Read-only.

Syntax

expression .Fields

expression A variable that represents a Relation object.


SmartTagProperty Members (Access)

 Copy code hover
[image]

SmartTagProperty Members (Access)
Send feedback

Published: July 16, 2012

Represents a single instance of a custom property for a smart tag. The SmartTagProperty object is a member of the SmartTagProperties collection.

Methods

Name | Description
Delete | Deletes the specified object.

Properties

Name | Description
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Value | Gets or sets the value of the specified object. Read/write Variant.


Form.MaxRecButton Property (Access)

 Copy code hover
[image]

Form.MaxRecButton Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the MaxRecButton property to specify or determine if the maximum record limit button is available on the navigation bar of a form in Datasheet view or Form view. Read/write Boolean.

Syntax

expression .MaxRecButton

expression A variable that represents a Form object.

Remarks

This property is only available for forms within a Microsoft Access project (.adp).

The default value is True.

Example

This example makes the maximum record limit button on the "Order Entry" form unavailable to the user.

VBA Copy code Copy code
Forms("Order Entry").MaxRecButton = False

See also

Concepts

Form Object

Other resources

Form Object Members


PageBreak.Application Property (Access)

 Copy code hover
[image]

PageBreak.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a PageBreak object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

PageBreak Object

Other resources

PageBreak Object Members


ToggleButton.GotFocus Event (Access)

 Copy code hover
[image]

ToggleButton.GotFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The GotFocus event occurs when the specified object receives the focus.

Syntax

expression .GotFocus

expression A variable that represents a ToggleButton object.

Remarks

To run a macro or event procedure when these events occur, set the OnGotFocus property to the name of the macro or to [Event Procedure].

These events occur when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The GotFocus event differs from the Enter event in that the GotFocus event occurs every time a control receives the focus. For example, suppose the user clicks a check box on a form, then clicks a report, and finally clicks the check box on the form to bring it to the foreground. The GotFocus event occurs both times the check box receives the focus. In contrast, the Enter event occurs only the first time the user clicks the check box. The GotFocus event occurs after the Enter event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


BoundObjectFrame.ObjectPalette Property (Access)

 Copy code hover
[image]

BoundObjectFrame.ObjectPalette Property (Access)
See also Send feedback

Published: July 16, 2012

The ObjectPalette property specifies the palette in the application used to create an OLE object. Read/write Variant.

Syntax

expression .ObjectPalette

expression A variable that represents a BoundObjectFrame object.

Remarks

Microsoft Access sets the value of the ObjectPalette property to a String data type containing the palette information. You can use this setting to set the value of the PaintPalette property for a form or report.

If the application associated with the OLE object doesn't have an associated palette, the ObjectPalette property is set to an zero-length string.

The ObjectPalette property is read-only in Form view.

The setting of the ObjectPalette property makes the palette of the application associated with the OLE object contained in a control available to the PaintPalette property of a form or report. For example, to make the palette used in Microsoft Graph available when you're designing a form in Microsoft Access, you set the form's PaintPalette property to the ObjectPalette value of an existing chart control.

Note Note

Windows can have only one color palette active at a time. Microsoft Access allows you to have multiple graphics on a form, each using a different color palette. The PaintPalette and PaletteSource properties let you specify which color palette a form should use when displaying graphics.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


SubForm.DisplayWhen Property (Access)

 Copy code hover
[image]

SubForm.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Syntax

expression .DisplayWhen

expression A variable that represents a SubForm object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


ComboBox.CanShrink Property (Access)

 Copy code hover
[image]

ComboBox.CanShrink Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the control contains. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .CanShrink

expression A variable that represents a ComboBox object.

Remarks

The CanShrink property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The control shrinks vertically so that the data it contains can be printed or previewed without leaving blank lines.
No | False | (Default) The control doesn't shrink.

This property setting is read-only in a macro or Visual Basic in any view but Design view.

You can use this property to control the appearance of printed forms and reports. When you set the property to Yes, the object automatically adjusts so any amount of data can be printed. When a control shrinks, the controls below it move up the page.

If you set a control's CanShrink property to Yes, Microsoft Access does not set the section's CanShrink property to Yes.

Sections shrink vertically across their entire width. For example, suppose a form has two text boxes side by side in a section, and each control has its CanShrink property set to Yes. If one text box contains one line of data and the other text box contains two lines of data, both text boxes will be two lines long because the section is sized across its entire width. To shrink the data independently, you can place two subform or subreport controls side by side, and set their CanShrink property to Yes.

When you use the CanShrink property, remember that:

  • The property settings don't affect the horizontal spacing between controls; they affect only the vertical space the controls occupy.

  • Overlapping controls can't shrink.

  • The height of a large control can prevent controls beside it from shrinking. For example, if several short controls are on the left side of a report's detail section and one tall control, such as an unbound object frame, is on the right side, the controls on the left won't shrink, even if they contain no data.

Note Note

  • The CanShrink property does not apply to form or report page header and page footer sections, although it does apply to controls in such sections.

  • This property affects the display of form sections and controls only when the form is printed or previewed, not when the form is displayed in Form view, Datasheet view, or Design view.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Report Object (Access)

 Copy code hover
[image]

Report Object (Access)
See also Send feedback

Published: July 16, 2012

A Report object refers to a particular Microsoft Access report.

Remarks

A Report object is a member of the Reports collection, which is a collection of all currently open reports. Within the Reports collection, individual reports are indexed beginning with zero. You can refer to an individual Report object in the Reports collection either by referring to the report by name, or by referring to its index within the collection. If the report name includes a space, the name must be surrounded by brackets ([ ]).

Syntax | Example
Reports!reportname | Reports!OrderReport
Reports![report name] | Reports![Order Report]
Reports("reportname") | Reports("OrderReport")
Reports(index) | Reports(0)
Note Note

Each Report object has a Controls collection, which contains all controls on the report. You can refer to a control on a report either by implicitly or explicitly referring to the Controls collection. Your code will be faster if you refer to the Controls collection implicitly. The following examples show two of the ways you might refer to a control named NewData on a report called OrderReport.

VBA Copy code Copy code
' Implicit reference.
Reports!OrderReport!NewData
VBA Copy code Copy code
' Explicit reference.
Reports!OrderReport.Controls!NewData

Example

The following example shows how to use the NoData event of a report to prevent the report form opening when there is no data to be displayed.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Private Sub Report_NoData(Cancel As Integer)

    'Add code here that will be executed if no data
    'was returned by the Report's RecordSource
    MsgBox "No customers ordered this product this month. " & _
        "The report will now close."
    Cancel = True

End Sub

The following example shows how to use the Page event to add a watermark to a report before it is printed.

VBA Copy code Copy code
Private Sub Report_Page()
    Dim strWatermarkText As String
    Dim sizeHor As Single
    Dim sizeVer As Single

#If RUN_PAGE_EVENT = True Then
    With Me
        '// Print page border
        Me.Line (0, 0)-(.ScaleWidth - 1, .ScaleHeight - 1), vbBlack, B

        '// Print watermark
        strWatermarkText = "Confidential"

        .ScaleMode = 3
        .FontName = "Segoe UI"
        .FontSize = 48
        .ForeColor = RGB(255, 0, 0)

        '// Calculate text metrics
        sizeHor = .TextWidth(strWatermarkText)
        sizeVer = .TextHeight(strWatermarkText)

        '// Set the print location
        .CurrentX = (.ScaleWidth / 2) - (sizeHor / 2)
        .CurrentY = (.ScaleHeight / 2) - (sizeVer / 2)

        '// Print the watermark
        .Print strWatermarkText
    End With
#End If

End Sub

The following example shows how to set the BackColor property of a control based on its value.

VBA Copy code Copy code
Private Sub SetControlFormatting()
    If (Me.AvgOfRating >= 8) Then
        Me.AvgOfRating.BackColor = vbGreen
    ElseIf (Me.AvgOfRating >= 5) Then
        Me.AvgOfRating.BackColor = vbYellow
    Else
        Me.AvgOfRating.BackColor = vbRed
    End If
End Sub

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    ' size the width of the rectangle
    Dim lngOffset As Long
    lngOffset = (Me.boxInside.Left - Me.boxOutside.Left) * 2
    Me.boxInside.Width = (Me.boxOutside.Width * (Me.AvgOfRating / 10)) - lngOffset

    ' do conditional formatting for the control in print preview
    SetControlFormatting
End Sub

Private Sub Detail_Paint()
    ' do conditional formatting for the control in report view
    SetControlFormatting
End Sub

The following example shows how to format a report to show progress bars. The example uses a pair of rectangle controls, boxInside and boxOutside, to create a progress bar based on the value of AvgOfRating. The progress bars are visible only when the report is opened in Print Preview mode or it is printed.

VBA Copy code Copy code
Private Sub Report_Load()
    If (Me.CurrentView = AcCurrentView.acCurViewPreview) Then
        Me.boxInside.Visible = True
        Me.boxOutside.Visible = True
    Else
        Me.boxInside.Visible = False
        Me.boxOutside.Visible = False
    End If
End Sub

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    ' size the width of the rectangle
    Dim lngOffset As Long
    lngOffset = (Me.boxInside.Left - Me.boxOutside.Left) * 2
    Me.boxInside.Width = (Me.boxOutside.Width * (Me.AvgOfRating / 10)) - lngOffset

    ' do conditional formatting for the control in print preview
    SetControlFormatting
End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.

See also

Concepts

Access Object Model Reference

Other resources

Report Object Members


Field2.Name Property (DAO)

 Copy code hover
[image]

Field2.Name Property (DAO)
Send feedback

Returns or sets the name of the specified object. Read/write String if the object has not been appended to a collection. Read-only String if the object has been appended to a collection.

Syntax

expression .Name

expression A variable that represents a Field2 object.

Remarks

The maximum length for the name of a Field2 object is 64 characters.


Sort Property Example (VB)

 Copy code hover
[image]

Sort Property Example (VB)
Send feedback

This example uses the Recordset object's Sort property to reorder the rows of a Recordset derived from the Authors table of the Pubs database. A secondary utility routine prints each row.

Copy code Copy code

'BeginSortVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 ' connection and recordset variables
 Dim Cnxn As New ADODB.Connection
 Dim rstAuthors As New ADODB.Recordset
 Dim strCnxn As String
 Dim strSQLAuthors As String

 Dim strTitle As String

 ' Open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' open client-side recordset to enable sort method
 Set rstAuthors = New ADODB.Recordset
 rstAuthors.CursorLocation = adUseClient
 strSQLAuthors = "SELECT * FROM Authors"
 rstAuthors.Open strSQLAuthors, Cnxn, adOpenStatic, adLockReadOnly, adCmdText

 ' sort the recordset last name ascending
 rstAuthors.Sort = "au_lname ASC, au_fname ASC"
 ' show output
 Debug.Print "Last Name Ascending:"
 Debug.Print "First Name Last Name" & vbCr

 rstAuthors.MoveFirst
 Do Until rstAuthors.EOF
 Debug.Print rstAuthors!au_fname & " " & rstAuthors!au_lname
 rstAuthors.MoveNext
 Loop

 ' sort the recordset last name descending
 rstAuthors.Sort = "au_lname DESC, au_fname ASC"
 ' show output
 Debug.Print "Last Name Descending"
 Debug.Print "First Name Last Name" & vbCr

 Do Until rstAuthors.EOF
 Debug.Print rstAuthors!au_fname & " " & rstAuthors!au_lname
 rstAuthors.MoveNext
 Loop

 ' clean up
 rstAuthors.Close
 Cnxn.Close
 Set rstAuthors = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstAuthors Is Nothing Then
 If rstAuthors.State = adStateOpen Then rstAuthors.Close
 End If
 Set rstAuthors = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndSortVB

This is the secondary utility routine that prints the given title, and the contents of the specified Recordset.

Copy code Copy code

Attribute VB_Name = "Sort"


Report.Print Method (Access)

 Copy code hover
[image]

Report.Print Method (Access)
See also Send feedback

Published: July 16, 2012

The Print method prints text on a Report object using the current color and font.

Syntax

expression .Print(Expr)

expression A variable that represents a Report object.

Parameters

Name | Required/Optional | Data Type | Description
Expr | Required | String | The string expressions to print. If this argument is omitted, the Print method prints a blank line. Multiple expressions can be separated with a space, a semicolon (;), or a comma. A space has the same effect as a semicolon.

Return Value

Nothing

Remarks

You can use this method only in a event procedure or macro specified by a section's OnPrint event property setting.

The expressions specified by the Expr argument are printed on the object starting at the position indicated by the CurrentX and CurrentY property settings.

When the Expr argument is printed, a carriage return is usually appended so that the next Print method begins printing on the next line. When a carriage return occurs, the CurrentY property setting is increased by the height of the Expr argument (the same as the value returned by the TextHeight method) and the CurrentX property is set to 0.

When a semicolon follows the Expr argument, no carriage return is appended, and the next Print method prints on the same line that the current Print method printed on. The CurrentX and CurrentY properties are set to the point immediately after the last character printed. If the Expr argument itself contains carriage returns, each such embedded carriage return sets the CurrentX and CurrentY properties as described for the Print method without a semicolon.

When a comma follows the Expr argument, the CurrentX and CurrentY properties are set to the next print zone on the same line.

When the Expr argument is printed on a Report object, lines that can't fit in the specified position don't scroll. The text is clipped to fit the object.

Because the Print method usually prints with proportionally spaced characters, it's important to remember that there's no correlation between the number of characters printed and the number of fixed-width columns those characters occupy. For example, a wide letter (such as W) occupies more than one fixed-width column, whereas a narrow letter (such as I) occupies less. You should make sure that your tabular columns are positioned far enough apart to accommodate the text you wish to print. Alternately, you can print with a fixed-pitch font (such as Courier) to ensure that each character uses only one column.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


ShowAllRecords Macro Action

 Copy code hover
[image]

ShowAllRecords Macro Action
Send feedback

You can use the ShowAllRecords action to remove any applied filter from the active table, query result set, or form, and display all records in the table or result set or all records in the form's underlying table or query.

Setting

The ShowAllRecords action doesn't have any arguments.

Remarks

You can use this action to ensure that all records (including any changed or new records) are displayed for a table, query result set, or form. This action causes a requery of the records for a form or subform.

You can also use this action to remove any filter that was applied with the ApplyFilter action, the Filter command on the Home tab, or the Filter Name or Where Condition argument of the OpenForm action.

This action has the same effect as clicking Toggle Filter on the Home tab, or right-clicking the filtered field and clicking Clear filter from... in Form view, Layout view, or Datasheet view.

To run the ShowAllRecords action in a Visual Basic for Applications (VBA) module, use the ShowAllRecords method of the DoCmd object.

Example

Apply a filter by using a macro

The following macro contains a set of actions, each of which filters the records for a Customer Phone List form. It shows the use of the ApplyFilter, ShowAllRecords, and GoToControl actions. It also shows the use of conditions to determine which toggle button in an option group has been selected on the form. Each action row is associated with a toggle button that selects the set of records starting with A, B, C, and so on, or all records. This macro should be attached to the AfterUpdate event of the CompanyNameFilter option group.

Condition | Action | Arguments: Setting | Comment
[Company Name Filters] =1 | ApplyFilter | Where Condition: [Company Name] Like "[AÀÁÂÃÄ]*" | Filter for company names that start with A, À, Á, Â, Ã, or Ä.
[Company Name Filters] =2 | ApplyFilter | Where Condition: [Company Name] Like "B*" | Filter for company names that start with B.
[Company Name Filters] =3 | ApplyFilter | Where Condition: [Company Name] Like "[CÇ]*" | Filter for company names that start with C or Ç.
... Action rows for D through Y have the same format as A through C ...
[Company Name Filters] =26 | ApplyFilter | Where Condition: [Company Name] Like "[ZÆØÅ]*" | Filter for company names that start with Z, Æ, Ø, or Å.
[Company Name Filters] =27 | ShowAllRecords |  | Show all records.
[RecordsetClone].[RecordCount]>0 | GoToControl | Control Name: CompanyName | If records are returned for the selected letter, move focus to the CompanyName control.


CheckBox.GridlineShade Property (Access)

 Copy code hover
[image]

CheckBox.GridlineShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineShade

expression A variable that represents an CheckBox object.

Remarks

The GridlineShade property contains a numeric expression that can be used to darken the theme color in the GridlineColor property. The default value of the GridlineShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Image.ControlType Property (Access)

 Copy code hover
[image]

Image.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Syntax

expression .ControlType

expression A variable that represents an Image object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

Image Object

Other resources

Image Object Members


Client has asked the Synchronizer to terminate operation. (Error 3535)

 Copy code hover
[image]

Client has asked the Synchronizer to terminate operation. (Error 3535)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


Style for Intrinsic Constants

 Copy code hover
[image]

Style for Intrinsic Constants
Send feedback

Published: July 16, 2012

In Microsoft Access, all intrinsic constants are contained in type libraries and are visible in the Object Browser. Microsoft Access includes type libraries for Microsoft Access, ActiveX Data Objects (ADO), Data Access Objects (DAO), and Visual Basic. Each of these type libraries includes intrinsic constants.

Additionally, intrinsic constants in Microsoft Access are a mix of lowercase and uppercase, and parts of the constant are concatenated rather than separated by underscores. For example, the constant A_NORMAL in versions 1.x and 2.0 is now acNormal.

Intrinsic constants in databases created with previous versions of Microsoft Access won't automatically be converted to the new constant format, but old constants will continue to work without errors. However, it's recommended that you use the new format when writing new code.


SmartTags Members (Access)

 Copy code hover
[image]

SmartTags Members (Access)
Send feedback

Published: July 16, 2012

Represents the collection of smart tags for a control on a form, report, or data access page.

Methods

Name | Description
Add | Adds a smart tag to a form or control.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only SmartTag.
Parent | Returns the parent object for the specified object. Read-only.


ComboBox.OnGotFocus Property (Access)

 Copy code hover
[image]

ComboBox.OnGotFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnGotFocus

expression A variable that represents a ComboBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The GotFocus event occurs when the object receives the focus.

The OnGotFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Got Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Got Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnGotFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnGotFocus

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Form.Painting Property (Access)

 Copy code hover
[image]

Form.Painting Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Painting property to specify whether a form is repainted. Read/write Boolean.

Syntax

expression .Painting

expression A variable that represents a Form object.

Remarks

This property can be set and applies only in Form view and is unavailable in other views.

The Painting property is similar to the Echo action. However, the Painting property prevents repainting of a single form, whereas the Echo action prevents repainting of all open windows in an application.

Setting the Painting property for a form to False also prevents all controls (except subform controls) on a form from being repainted. To prevent a subform control from being repainted, you must set the Painting property for the subform to False. (Note that you set the Painting property for the subform, not the subform control.)

The Painting property is automatically set to True whenever the form gets or loses the focus. You can set this property to False while you are working on a form if you don't want to see changes to the form or to its controls. For example, if a form has a set of controls that are automatically resized when the form is resized and you don't want the user to see each individual control move, you can turn Painting off, and then move all of the controls, then turn Painting back on.

Example

The following example uses the Painting property to enable or disable form painting depending on whether the SetPainting variable is set to True or False. If form painting is turned off, Microsoft Access displays the hourglass icon while painting is turned off.

VBA Copy code Copy code
Public Sub EnablePaint(ByRef frmName As Form, _
 ByVal SetPainting As Integer)

 frmName.Painting = SetPainting

 ' Form painting is turned off.
 If SetPainting = False Then
 DoCmd.Hourglass True
 Else
 DoCmd.Hourglass False
 End If

End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Recordset.RecordStatus Property (DAO)

 Copy code hover
[image]

Recordset.RecordStatus Property (DAO)
Send feedback

Syntax

expression .RecordStatus

expression A variable that represents a Recordset object.

Remarks

The value of the RecordStatus property indicates whether and how the current record will be involved in the next optimistic batch update.

When a user changes a record, the RecordStatus for that record automatically changes to dbRecordModified. Similarly, if a record is added or deleted, RecordStatus reflects the appropriate constant. When you then use a batch-mode Update method, DAO will submit an appropriate operation to the remote server for each record, based on the record's RecordStatus property.

Example

This example uses the RecordStatus and DefaultCursorDriver properties to show how changes to a local Recordset are tracked during batch updating. The RecordStatusOutput function is required for this procedure to run.

VBA Copy code Copy code
Sub RecordStatusX()

 Dim wrkMain As Workspace
 Dim conMain As Connection
 Dim rstTemp As Recordset

 Set wrkMain = CreateWorkspace("ODBCWorkspace", _
 "admin", "", dbUseODBC)
 ' This DefaultCursorDriver setting is required for
 ' batch updating.
 wrkMain.DefaultCursorDriver = dbUseClientBatchCursor

 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conMain = wrkMain.OpenConnection("Publishers", _
 dbDriverNoPrompt, False, _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 ' The following locking argument is required for
 ' batch updating.
 Set rstTemp = conMain.OpenRecordset( _
 "SELECT * FROM authors", dbOpenDynaset, 0, _
 dbOptimisticBatch)

 With rstTemp
 .MoveFirst
 Debug.Print "Original record: " & !au_lname
 Debug.Print , RecordStatusOutput2(.RecordStatus)

 .Edit
 !au_lname = "Bowen"
 .Update
 Debug.Print "Edited record: " & !au_lname
 Debug.Print , RecordStatusOutput2(.RecordStatus)

 .AddNew
 !au_lname = "NewName"
 .Update
 Debug.Print "New record: " & !au_lname
 Debug.Print , RecordStatusOutput2(.RecordStatus)

 .Delete
 Debug.Print "Deleted record: " & !au_lname
 Debug.Print , RecordStatusOutput2(.RecordStatus)

 ' Close the local recordset without updating the
 ' data on the server.
 .Close
 End With

 conMain.Close
 wrkMain.Close

End Sub

Function RecordStatusOutput(lngTemp As Long) As String

 Dim strTemp As String

 strTemp = ""

 ' Construct an output string based on the RecordStatus
 ' value.
If lngTemp = dbRecordUnmodified Then _
 strTemp = "[dbRecordUnmodified]"
 If lngTemp = dbRecordModified Then _
 strTemp = "[dbRecordModified]"
 If lngTemp = dbRecordNew Then _
 strTemp = "[dbRecordNew]"
 If lngTemp = dbRecordDeleted Then _
 strTemp = "[dbRecordDeleted]"
 If lngTemp = dbRecordDBDeleted Then _
 strTemp = "[dbRecordDBDeleted]"

 RecordStatusOutput = strTemp

End Function


Printer.ItemsAcross Property (Access)

 Copy code hover
[image]

Printer.ItemsAcross Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Long indicating the number of columns to print across a page for multiple-column reports or labels. Read/write.

Syntax

expression .ItemsAcross

expression A variable that represents a Printer object.

Example

The following example sets a variety of printer settings for the form specified in the strFormname argument of the procedure.

VBA Copy code Copy code
Sub SetPrinter(strFormname As String)

 DoCmd.OpenForm FormName:=strFormname, view:=acDesign, _
 datamode:=acFormEdit, windowmode:=acHidden

 With Forms(form1).Printer

 .TopMargin = 1440
 .BottomMargin = 1440
 .LeftMargin = 1440
 .RightMargin = 1440

 .ColumnSpacing = 360
 .RowSpacing = 360

 .ColorMode = acPRCMColor
 .DataOnly = False
 .DefaultSize = False
 .ItemSizeHeight = 2880
 .ItemSizeWidth = 2880
 .ItemLayout = acPRVerticalColumnLayout
  .ItemsAcross = 6

 .Copies = 1
 .Orientation = acPRORLandscape
 .Duplex = acPRDPVertical
 .PaperBin = acPRBNAuto
 .PaperSize = acPRPSLetter
 .PrintQuality = acPRPQMedium

 End With

 DoCmd.Close objecttype:=acForm, objectname:=strFormname, _
 Save:=acSaveYes

End Sub

See also

Concepts

Printer Object

Other resources

Printer Object Members


The Microsoft Access database engine sorting dlls could not be loaded properly. (Error 3757)

 Copy code hover
[image]

The Microsoft Access database engine sorting dlls could not be loaded properly. (Error 3757)
Send feedback

The Microsoft Access database engine uses two sorting DLLs for comparisons and indexing, ACEWSTR.DLL and ACEWDAT.DLL. Make sure that those DLLs are in the path used to load DLLs.


ALL, DISTINCT, DISTINCTROW, TOP Predicates (Microsoft Access SQL)

 Copy code hover
[image]

ALL, DISTINCT, DISTINCTROW, TOP Predicates (Microsoft Access SQL)
Send feedback

Published: July 16, 2012

Specifies records selected with SQL queries.

Syntax

SELECT [ALL | DISTINCT | DISTINCTROW | [TOP n [PERCENT]]] FROM table

A SELECT statement containing these predicates has the following parts:

Part

Description

ALL

Assumed if you do not include one of the predicates. The Microsoft Access database engine selects all of the records that meet the conditions in the SQL statement. The following two examples are equivalent and return all records from the Employees table:

SQL Copy code Copy code
SELECT ALL *
FROM Employees
ORDER BY EmployeeID;
SQL Copy code Copy code
SELECT *
FROM Employees
ORDER BY EmployeeID;

DISTINCT

Omits records that contain duplicate data in the selected fields. To be included in the results of the query, the values for each field listed in the SELECT statement must be unique. For example, several employees listed in an Employees table may have the same last name. If two records contain Smith in the LastName field, the following SQL statement returns only one record that contains Smith:

SQL Copy code Copy code
SELECT DISTINCT
LastName
FROM Employees;

If you omit DISTINCT, this query returns both Smith records.

If the SELECT clause contains more than one field, the combination of values from all fields must be unique for a given record to be included in the results.

The output of a query that uses DISTINCT is not updatable and does not reflect subsequent changes made by other users.

DISTINCTROW

Omits data based on entire duplicate records, not just duplicate fields. For example, you could create a query that joins the Customers and Orders tables on the CustomerID field. The Customers table contains no duplicate CustomerID fields, but the Orders table does because each customer can have many orders. The following SQL statement shows how you can use DISTINCTROW to produce a list of companies that have at least one order but without any details about those orders:

SQL Copy code Copy code
SELECT DISTINCTROW CompanyName
FROM Customers INNER JOIN Orders
ON Customers.CustomerID = Orders.CustomerID
ORDER BY CompanyName;

If you omit DISTINCTROW, this query produces multiple rows for each company that has more than one order.

DISTINCTROW has an effect only when you select fields from some, but not all, of the tables used in the query. DISTINCTROW is ignored if your query includes only one table, or if you output fields from all tables.

TOP n [PERCENT]

Returns a certain number of records that fall at the top or the bottom of a range specified by an ORDER BY clause. Suppose you want the names of the top 25 students from the class of 1994:

SQL Copy code Copy code
SELECT TOP 25
FirstName, LastName
FROM Students
WHERE GraduationYear = 1994
ORDER BY GradePointAverage DESC;

If you do not include the ORDER BY clause, the query will return an arbitrary set of 25 records from the Students table that satisfy the WHERE clause.

The TOP predicate does not choose between equal values. In the preceding example, if the twenty-fifth and twenty-sixth highest grade point averages are the same, the query will return 26 records.

You can also use the PERCENT reserved word to return a certain percentage of records that fall at the top or the bottom of a range specified by an ORDER BY clause. Suppose that, instead of the top 25 students, you want the bottom 10 percent of the class:

SQL Copy code Copy code
SELECT TOP 10 PERCENT
FirstName, LastName
FROM Students
WHERE GraduationYear = 1994
ORDER BY GradePointAverage ASC;

The ASC predicate specifies a return of bottom values. The value that follows TOP must be an unsigned Integer.

TOP does not affect whether or not the query is updatable.

table

The name of the table from which records are retrieved.

Example

This example creates a query that joins the Customers and Orders tables on the CustomerID field. The Customers table contains no duplicate CustomerID fields, but the Orders table does because each customer can have many orders. Using DISTINCTROW produces a list of companies that have at least one order but without any details about those orders.

VBA Copy code Copy code
Sub AllDistinctX()
    Dim dbs As Database, rst As Recordset
    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Join the Customers and Orders tables on the
    ' CustomerID field. Select a list of companies
    ' that have at least one order.

    Set rst = dbs.OpenRecordset("SELECT DISTINCTROW " _
        & "CompanyName FROM Customers " _
        & "INNER JOIN Orders " _
        & "ON Customers.CustomerID = " _
        & "Orders.CustomerID " _
        & "ORDER BY CompanyName;")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 25
    dbs.Close
End Sub


Form.FilterOn Property (Access)

 Copy code hover
[image]

Form.FilterOn Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FilterOn property to specify or determine whether the Filter property for a form or report is applied. Read/write Boolean.

Syntax

expression .FilterOn

expression A variable that represents a Form object.

Remarks

If you want to specify a server filter within a Microsoft Access project (.adp) for data located on a server, use the ServerFilter property.

To apply a saved filter, press the Apply Filter button for forms, or apply the filter by using a macro or Visual Basic by setting the FilterOn property to True for forms or reports. For reports, you can set the FilterOn property to Yes in the report's property sheet.

The Apply Filter button indicates the state of the Filter and FilterOn properties. The button remains disabled until there is a filter to apply. If an existing filter is currently applied, the Apply Filter button appears pressed in. To apply a filter automatically when a form or report is opened, specify in the OnOpen event property setting of the form either a macro that uses the ApplyFilter action or an event procedure that uses the ApplyFilter method of the DoCmd object.

You can remove a filter by clicking the pressed-in Apply Filter button, clicking Remove Filter/Sort on the Records menu, or by using Visual Basic to set the FilterOn property to False. For reports, you can remove a filter by setting the FilterOn property to No in the report's property sheet.

Note Note

When a new object is created, it inherits the RecordSource , Filter, ServerFilter . OrderBy , and OrderByOn properties of the table or query it was created from. For forms and reports, inherited filters aren't automatically applied when an object is opened.

See also

Concepts

Form Object

Other resources

Form Object Members


Form Properties (Access)

 Copy code hover
[image]

Form Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
ActiveControl | You can use the ActiveControl property together with the Screen object to identify or refer to the control that has the focus. Read-only Control object.
AfterDelConfirm | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the AfterDelConfirm event occurs. Read/write.
AfterFinalRender | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the AfterFinalRender event occurs. Read/write.
AfterInsert | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the AfterInsert event occurs. Read/write.
AfterLayout | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the AfterLayout event occurs. Read/write.
AfterRender | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the AfterRender event occurs. Read/write.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
AllowAdditions | You can use the AllowAdditions property to specify whether a user can add a record when using a form. Read/write Boolean.
AllowDatasheetView | Returns or sets a Boolean indicating whether the specified form may be viewed in Datasheet View. True if Datasheet View is allowed. Read/write.
AllowDeletions | You can use the AllowDeletions property to specify whether a user can delete a record when using a form. Read/write Boolean.
AllowEdits | You can use the AllowEdits property to specify whether a user can edit saved records when using a form. Read/write Boolean.
AllowFilters | You can use the AllowFilters property to specify whether records in a form can be filtered. Read/write Boolean.
AllowFormView | Returns or sets a Boolean indicating whether the specified form may be viewed in Form View. True if Form View is allowed. Read/write.
AllowLayoutView | Gets or sets whether the specified form can be used in Layout View. Read/write Boolean.
AllowPivotChartView | Returns or sets a Boolean indicating whether the specified form may be viewed in PivotChart View. True if PivotChart View is allowed. Read/write.
AllowPivotTableView | Returns or sets a Boolean indicating whether the specified form may be viewed in PivotTable View. True if PivotTable View is allowed. Read/write.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoCenter | Returns or sets a Boolean indicating whether a form will be centered automatically in the application window when the form is opened. Read/write.
AutoResize | Returns or sets a Boolean indicating whether a Form window opens automatically sized to display complete records. Read/write.
BeforeDelConfirm | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the BeforeDelConfirm event occurs. Read/write.
BeforeInsert | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the BeforeInsert event occurs. Read/write.
BeforeQuery | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the BeforeQuery event occurs. Read/write.
BeforeRender | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the BeforeRender event occurs. Read/write.
BeforeScreenTip | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the BeforeScreenTip event occurs. Read/write.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
Bookmark | You can use the Bookmark property with forms to set a bookmark that uniquely identifies a particular record in the form's underlying table, query, or SQL statement. Read/write Variant.
BorderStyle | Specifies the type of border and border elements (title bar, Control menu, Minimize and Maximize buttons, or Close button) to use for the form. You typically use different border styles for normal forms, pop-up forms, and custom dialog boxes. Read/write Byte.
Caption | Gets or sets the text that appears in the title bar in Form view. Read/write String.
ChartSpace | Returns a ChartSpace object. Read-only.
CloseButton | Specifies whether the Close button on a form is enabled. Read/write Boolean.
CommandBeforeExecute | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the CommandBeforeExecute event occurs. Read/write.
CommandChecked | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the CommandChecked event occurs. Read/write.
CommandEnabled | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the CommandEnabled event occurs. Read/write.
CommandExecute | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the CommandExecute event occurs. Read/write.
ControlBox | Specifies whether a form has a Control menu in Form view and Datasheet view. Read/write Boolean.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Integer.
CurrentRecord | You can use the CurrentRecord property to identify the current record in the recordset being viewed on a form. Read/write Long.
CurrentSectionLeft | You can use this property to determine the distance in twips from the left side of the current section to the left side of the form. Read/write Integer.
CurrentSectionTop | You can use this property to determine the distance in twips from the top edge of the current section to the top edge of the form. Read/write Integer.
CurrentView | You can use the CurrentView property to determine how a form is currently displayed. Read/write Integer.
Cycle | You can use the Cycle property to specify what happens when you press the TAB key and the focus is in the last control on a bound form. Read/write Byte.
DataChange | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the DataChange event occurs. Read/write.
DataEntry | You can use the DataEntry property to specify whether a bound form opens to allow data entry only. The Data Entry property doesn't determine whether records can be added; it only determines whether existing records are displayed. Read/write Boolean.
DataSetChange | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the DataSetChange event occurs. Read/write.
DatasheetAlternateBackColor | Gets or sets the color displayed on alternate rows of a form's datasheet. Read/write Long.
DatasheetBackColor | You can use the DatasheetBackColor property in Visual Basic to specify or determine the background color of an entire table, query, or form in Datasheet view within a Microsoft Access database. Read/write Long.
DatasheetBorderLineStyle | Returns or sets a Byte indicating the line style to use for the border of the specified datasheet. Read/write.
DatasheetCellsEffect | You can use the DatasheetCellsEffect property to specify whether special effects are applied to cells in a datasheet. Read/write Byte.
DatasheetColumnHeaderUnderlineStyle | Returns or sets a Byte indicating the line style to use for the bottom edge of the column headers on the specified datasheet. Read/write.
DatasheetFontHeight | You can use the DatasheetFontHeight property to specify the font point size used to display and print field names and data in Datasheet view. Read/write Integer.
DatasheetFontItalic | You can use the DatasheetFontItalic property to specify an italicized appearance for field names and data in Datasheet view. Read/write Boolean.
DatasheetFontName | You can use the DatasheetFontName property to specify the font used to display and print field names and data in Datasheet view. Read/write String.
DatasheetFontUnderline | You can use the DatasheetFontUnderline property to specify an underlined appearance for field names and data in Datasheet view. Read/write Boolean.
DatasheetFontWeight | You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.
DatasheetForeColor | You can use the DatasheetForeColor property in Visual Basic to specify or determine the color of all text in a table, query, or form in Datasheet view within an Access database. Read/write Long.
DatasheetGridlinesBehavior | You can use the DatasheetGridlinesBehavior property to specify which gridlines will appear in Datasheet view. Read/write Byte.
DatasheetGridlinesColor | You can use the DatasheetGridlinesColor property to specify the color of gridlines in a datasheet. Read/write Long.
DefaultControl | The DefaultControl property returns a Control object with which you can set the default properties for a particular type of control on a particular form. Read-only.
DefaultView | You can use the DefaultView property to specify the opening view of a form. Read/write Byte.
Dirty | You can use the Dirty property to determine whether the current record has been modified since it was last saved. Read/write Boolean.
DisplayOnSharePointSite | Gets or sets whether the specified form can be made available as a view on a Microsoft SharePoint Foundation site. Read/write Byte.
DividingLines | You can use the DividingLines property to specify whether dividing lines will separate sections on a form or records displayed on a continuous form. Read/write Boolean.
FastLaserPrinting | You can use the FastLaserPrinting property to specify whether lines and rectangles are replaced by text character lines — similar to the underscore (_) and vertical bar (|) characters — when you print a form using most laser printers. Replacing lines and rectangles with text character lines can make printing much faster. Read/write Boolean.
FetchDefaults | Returns or sets a Boolean indicating whether Microsoft Access shows default values for new rows on the specified form before the row is saved. True if Access shows the default values for new rows on the specified form. Read/write.
Filter | You can use the Filter property to specify a subset of records to be displayed when a filter is applied to a form, reportquery, or table. Read/write String.
FilterOn | You can use the FilterOn property to specify or determine whether the Filter property for a form or report is applied. Read/write Boolean.
FilterOnLoad | Gets or sets whether the filter specified by the Filter property is applied when the form is loaded. Read/write Boolean.
FitToScreen | Gets or sets whether the width of the form is reduced to fit the width of the screen. Read/write Boolean.
Form | You can use the Form property to refer to a form or to refer to the form associated with a subformcontrol. Read-only Form.
FrozenColumns | You can use the FrozenColumns property to determine how many columns in a datasheet are frozen. Read/write Integer.
GridX | You can use the GridX property (along with the GridY property) to specify the horizontal and vertical divisions of the alignment grid in form Design view. Read/write Integer.
GridY | You can use the GridY property (along with the GridX property) to specify the horizontal and vertical divisions of the alignment grid in form Design view. Read/write Integer.
HasModule | You can use the HasModule property to specify or determine whether a form or report has a class module. Read/write Boolean.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HelpFile | The name of a help file associated with a form. Read/write String.
HorizontalDatasheetGridlineStyle | Returns or sets a Byte indicating the line style to use for horizontal gridlines on the specified datasheet. Read/write.
Hwnd | You can use the hWnd property to determine the handle (a unique Long Integer value) assigned by Microsoft Windows to the current window. Read/write Long.
InputParameters | You can use the InputParameters property to specify or determine the input parameters that are passed to a SQL statement in the RecordSource property of a form or report or a stored procedure when used as the record source within a Microsoft Access project (.adp). Read/write String.
InsideHeight | You can use the InsideHeight property (along with the InsideWidth property) to determine the height and width (in twips) of the window containing a form. Read/write Long.
InsideWidth | You can use the InsideWidth property (along with the InsideHeight property) to determine the height and width (in twips) of the window containing a form. Read/write Long.
KeyPreview | You can use the KeyPreview property to specify whether the form-level keyboard event procedures are invoked before a control's keyboard event procedures. Read/write Boolean.
LayoutForPrint | You can use the LayoutForPrint property to specify whether the form uses printer or screen fonts. Read/write Boolean.
MaxRecButton | You can use the MaxRecButton property to specify or determine if the maximum record limit button is available on the navigation bar of a form in Datasheet view or Form view. Read/write Boolean.
MaxRecords | Specifies the maximum number of records by a query or view. Read/write Long.
MenuBar | Specifies a custom menu to display for a form. Read/write String.
MinMaxButtons | You can use the MinMaxButtons property to specify whether the Maximize and Minimize buttons will be visible on a form. Read/write Byte.
Modal | You can use the Modal property to specify whether a form opens as a modal window. When a form opens as a modal window, you must close the window before you can move the focus to another object. Read/write Boolean.
Module | You can use the Module property to specify a form module. Read-only Module object.
MouseWheel | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the MouseWheel event occurs. Read/write.
Moveable | Returns or sets a Boolean indicating whether the specified form can be moved by the user; True if it can be moved. Read/write.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
NavigationButtons | You can use the NavigationButtons property to specify whether navigation buttons and a record number box are displayed on a form. Read/write Boolean.
NavigationCaption | Gets or sets the text that appears to the left of the form's navigation buttons. Read/write String.
NewRecord | You can use the NewRecord property to determine whether the current record is a new record. Read-only Integer.
OnActivate | Sets or returns the value of the On Activate box in the Properties window of a form or report. Read/write String.
OnApplyFilter | Sets or returns the value of the On Apply Filter box in the Properties window of a form. Read/write String.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnClose | Sets or returns the value of the On Close box in the Properties window of a form or report. Read/write String.
OnConnect | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the OnConnect event occurs. Read/write.
OnCurrent | Sets or returns the value of the On Current box in the Properties window of a form. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnDeactivate | Sets or returns the value of the On Deactivate box in the Properties window of a form or report. Read/write String.
OnDelete | Sets or returns the value of the On Delete box in the Properties window of a form. Read/write String.
OnDirty | Sets or returns the value of the On Dirty box in the Properties window of a form or report. Read/write String.
OnDisconnect | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the OnDisconnect event occurs. Read/write.
OnError | Sets or returns the value of the OnError box in the Properties window of a form or report. Read/write String.
OnFilter | Sets or returns the value of the On Filter box in the Properties window of a form. Read/write String.
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnInsert | Sets or returns the value of the Before Insert box in the Properties window of a form. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLoad | Sets or returns the value of the On Load box in the Properties window of a form. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnOpen | Sets or returns the value of the On Open box in the Properties window of a form or report. Read/write String.
OnResize | Sets or returns the value of the On Resize box in the Properties window of a form. Read/write String.
OnTimer | Sets or returns the value of the On Timer box in the Properties window of a form. Read/write String.
OnUndo | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the Undo event occurs. Read/write..
OnUnload | Sets or returns the value of the On Unload box in the Properties window of a form. Read/write String.
OpenArgs | Determines the string expression specified by the OpenArgs argument of the OpenForm method that opened a form. Read/write Variant.
OrderBy | You can use the OrderBy property to specify how you want to sort records in a form. Read/write String.
OrderByOn | You can use the OrderByOn property to specify whether an object's OrderBy property setting is applied. Read/write Boolean.
OrderByOnLoad | Gets or sets whether the sorting specified by the OrderBy property is applied when the form is loaded. Read/write Boolean.
Orientation | You can use the Orientation property to specify or determine the view orientation. Read/write Byte.
Page | The Page property specifies the current page number when a form is being printed. Read/write Long.
Pages | You can use the Pages property to return information needed to print page numbers in a form. Read/write Integer.
Painting | You can use the Painting property to specify whether a form is repainted. Read/write Boolean.
PaintPalette | You can use the PaintPalette property to specify a palette to be used by a form. Read/write Variant.
PaletteSource | You can use the PaletteSource property to specify the palette for a form. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Picture | You can use the Picture property to specify a bitmap or other type of graphic to be used as a background picture on a form. Read/write String.
PictureAlignment | You can use the PictureAlignment property to specify where a background picture will appear in an image control or on a form or report. Read/write Byte.Read/write.
PictureData | You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.
PicturePalette | You can use the PicturePalette property to specify a palette to be used by a form. Read/write Variant.
PictureSizeMode | You can use the PictureSizeMode property to specify how a picture for a form or report is sized. Read/write Byte.
PictureTiling | You can use the PictureTiling property to specify whether a background picture is tiled across the entire image control, Form window, form, or page of a report. Read/write Boolean.
PictureType | You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.
PivotTable | Returns a PivotTable object representing a PivotTable View on a form. Read-only.
PivotTableChange | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the PivotTableChange event occurs. Read/write.
PopUp | Specifies whether a form opens as a pop-up window. Read/write Boolean.
Printer | Returns or sets a Printer object representing the default printer on the current system. Read/write.
Properties | Returns a reference to a control's Properties collection object. Read-only.
PrtDevMode | You can use the PrtDevMode property to set or return printing device mode information specified for a form or report in the Print dialog box. Read/write Variant.
PrtDevNames | You can use the PrtDevNames property to set or return information about the printer selected in the Print dialog box for a form or report. Read/write Variant.
PrtMip | You can use the PrtMip property in Visual Basic to set or return the device mode information specified for a form or report in the Print dialog box.
Query | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the Query event occurs. Read/write.
RecordLocks | You can use the RecordLocks property to determine how records are locked and what happens when two users try to edit the same record at the same time. Read/write.
RecordSelectors | You can use the RecordSelectors property to specify whether a form displays record selectors in Form view. Read/write Boolean.
Recordset | Returns or sets the ADO Recordset or DAO Recordset object representing the record source for the specified object. Read/write Object.
RecordsetClone | You can use the RecordsetClone property to refer to a form's Recordset object specified by the form's RecordSource property. Read-only.
RecordsetType | You can use the RecordsetType property to specify what kind of recordset is made available to a form. Read/write Byte.
RecordSource | You can use the RecordSource property to specify the source of the data for a form. Read/write String.
RecordSourceQualifier | Returns or sets a String indicating the SQL Server owner name of the record source for the specified form. Read/write.
ResyncCommand | You can use the ResyncCommand property to specify or determine the SQL statement or stored procedure that will be used in an updateable snapshot of a table. Read/write String.
RibbonName | Gets or set the name of the customized ribbon to be displayed when the specified form is loaded. Read/write String.
RowHeight | You can use the RowHeight property to specify the height of all rows in Datasheet view. Read/write Integer.
ScrollBars | You can use the ScrollBars property to specify whether scroll bars appear on a form. Read/write Byte.
Section | You can use the Section property to identify a section of a form and provide access to the properties of that section. Read-only Section object.
SelectionChange | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the SelectionChange event occurs. Read/write.
SelHeight | You can use the SelHeight property to specify or determine the number of selected rows (records) in the current selection rectangle in a table, query, or form datasheet, or the number of selected records in a continuous form. Read/write Long.
SelLeft | You can use the SelLeft property to specify or determine which column (field) is leftmost in the current selection rectangle. Read/write Long.
SelTop | You can use the SelTop property to specify or determine which row (record) is topmost in the current selection rectangle in a table, query, or form datasheet, or which selected record is topmost in a continuous form.Read/write Long.
SelWidth | You can use the SelWidth property to specify or determine the number of selected columns (fields) in the current selection rectangle. Read/write Long.
ServerFilter | You can use the ServerFilter property to specify a subset of records to be displayed when a server filter is applied to a form within a Microsoft Access project (.adp) or database. Read/write String.
ServerFilterByForm | You can use the ServerFilterByForm property to specify or determine whether a form is opened in the Server Filter By Form window. Read/write Boolean.
ShortcutMenu | You can use the ShortcutMenu property to specify whether a shortcut menu is displayed when you right-click an object on a form. For example, you might want to disable a shortcut menu to prevent the user from changing the form's underlying record source by using one of the filtering commands on the form's shortcut menu. Read/write Boolean.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SplitFormDatasheet | Gets or sets whether the user can edit records in the datasheet when a form is displayed in Split Form view. Read/write AcSplitFormDatasheet.
SplitFormOrientation | Gets or sets the position of the datasheet relative to the form when the form is displayed in Split Form view. Read/write AcSplitFormOrientation.
SplitFormPrinting | Gets or sets whether the contents of the form or the datasheet are printed when printing a form displayed in Split Form view. Read/write AcSplitFormPrinting.
SplitFormSize | Gets or sets the size in twips of the form when it's displayed in Split Form view. Read/write Long.
SplitFormSplitterBar | Gets or sets whether the splitter bar is available when the form is displayed in Split Form mode. Read/write Boolean.
SplitFormSplitterBarSave | Gets or sets whether the location of the splitter bar is saved when a form that's displayed in Split Form mode is closed. Read/write Boolean.
SubdatasheetExpanded | You can use the SubdatasheetExpanded property to specify or determine the saved state of all subdatasheets within a table or query. Read/write Boolean.
SubdatasheetHeight | You can use the SubdatasheetHeight property to specify or determine the default display height of a subdatasheet when expanded. Read/write Integer.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
TimerInterval | You can use the TimerInterval property to specify the interval, in milliseconds, between Timer events on a form. Read/write Long.
Toolbar | Specifies a custom toolbar to display for a form. Read/write String.
UniqueTable | Specifies the table to be updateable when A form is bound to a multiple table view or stored procedure within a Microsoft Access project (.adp).
UseDefaultPrinter | Returns or sets a Boolean indicating whether the specified form uses the default printer for the system; True if the form or report uses the default printer. Read/write.
VerticalDatasheetGridlineStyle | Returns or sets a Byte indicating the line style to use for vertical gridlines on the specified datasheet. Read/write.
ViewChange | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the ViewChange event occurs. Read/write.
ViewsAllowed | You can use the ViewsAllowed property to specify whether users can switch between Datasheet view and Form view by clicking the Form View or Datasheet View command on the View menu or by clicking the arrow next to the View button and clicking Form View or Datasheet View. Read/write Byte.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.
WindowHeight | Returns the height of a form in twips. Read-only Integer.
WindowLeft | Returns an Integer indicating the screen position in twips of the left edge of a form relative to the left edge of the Microsoft Access window. Read-only.
WindowTop | Returns an Integer indicating the screen position in twips of the top edge of a form relative to the top of the Microsoft Access window. Read-only.
WindowWidth | Returns the height of a form in twips. Read-only Integer.


Reference.IsBroken Property (Access)

 Copy code hover
[image]

Reference.IsBroken Property (Access)
See also Send feedback

Published: July 16, 2012

The IsBroken property returns a Boolean value indicating whether a Reference object points to a valid reference in the Windows Registry. Read-only Boolean.

Syntax

expression .IsBroken

expression A variable that represents a Reference object.

Remarks

The default value of the IsBroken property is False. The IsBroken property returns True only if the Reference object no longer points to a valid reference in the Registry.

By evaluating the IsBroken property, you can determine whether or not the file associated with a particular Reference object has been moved to a different directory or deleted.

If the IsBroken property is True, Microsoft Access generates an error when you try to read the Name or FullPath properties.

Example

The following example prints the value of the FullPath, GUID, IsBroken, Major, and Minor properties for each Reference object in the References collection:

VBA Copy code Copy code
Sub ReferenceProperties()
 Dim ref As Reference

 ' Enumerate through References collection.
 For Each ref In References
 ' Check IsBroken property.
 If ref.IsBroken = False Then
 Debug.Print "Name: ", ref.Name
 Debug.Print "FullPath: ", ref.FullPath
 Debug.Print "Version: ", ref.Major & "." & ref.Minor
 Else
 Debug.Print "GUIDs of broken references:"
 Debug.Print ref.GUID
 EndIf
 Next ref
End Sub

See also

Concepts

Reference Object

Other resources

Reference Object Members


Application.hWndAccessApp Method (Access)

 Copy code hover
[image]

Application.hWndAccessApp Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the hWndAccessApp method to determine the handle assigned by Microsoft Windows to the main Microsoft Access window.

Syntax

expression .hWndAccessApp

expression A variable that represents an Application object.

Return Value

Long

Remarks

The hWndAccessApp method returns a Long Integer value set by Microsoft Access and is read-only.

You can use this method by using Visual Basic when making calls to Windows application programming interface (API) functions or other external procedures that require a window handle as an argument.

To get the handle to a window containing a Microsoft Access object such as a Form or Report, use the hWnd property.

See also

Concepts

Application Object

Other resources

Application Object Members


Adding Records

 Copy code hover
[image]

Adding Records
Send feedback

Use the AddNew method to create and initialize a new record in an existing Recordset. You can use the Supports method with a CursorOptionEnum value of adAddNew to verify whether you can add records to the current Recordset object.

After you call the AddNew method, the new record becomes the current record and remains current after you call the Update method. If the Recordset object does not support bookmarks, you might not be able to access the new record once you move to another record. Therefore, depending on your cursor type, you might need to call the Requery method to make the new record accessible.

If you call AddNew while editing the current record or while adding a new record, ADO calls the Update method to save any changes and then creates the new record.


Status Property (ADO Field)

 Copy code hover
[image]

Status Property (ADO Field)
Send feedback

Indicates the status of a Field object.

Return Value

Returns a FieldStatusEnum value. The default value is adFieldOK.

Remarks

This property always returns adFieldOK for fields of a Recordset object.

Additions and deletions to the Fields collections of the Record object are cached until the Update method is called. The Status property enables you to determine which fields have been successfully added or deleted.

To enhance performance, schema changes are cached until Update is called, and then the changes are made in a batch optimistic update. If the Update method is not called, the server is not updated. If any updates fail then an error is returned and the Status property indicates the combined values of the operation and error status code. For example, adFieldPendingInsert OR adFieldPermissionDenied. The Status property for each Field can be used to determine why the Field was not added, modified, or deleted. Status is only meaningfully exposed on the Record.Fields collection and not the Recordset.Fields collection.

Two problems can arise when adding, modifying, or deleting a Field. If the user deletes a Field, it is marked for deletion from the Fields collection. If the subsequent Update returns an error because the user tried to delete a Field for which they do not have permission, the Field will have a status of adFieldPermissionDenied OR adFieldPendingDelete. Calling the CancelUpdate method restores original values and sets the Status to adFieldOK. Similarly, the Update method may return an error because a new Field was added and given an inappropriate value. In that case the new Field will be in the Fields collection and have a status of adFieldPendingInsert and perhaps adFieldCantCreate. You can supply an appropriate value for the new Field and call Update again. Note that calling Resync instead requeries the provider.


ClosePopup Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

ClosePopup Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

You can use the ClosePopup action to close the active document popup view.

Remarks

If the current record in the popup view is in edit mode, the changes to the record are automatically saved.


ObjectFrame.Width Property (Access)

 Copy code hover
[image]

ObjectFrame.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents an ObjectFrame object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Form.InsideHeight Property (Access)

 Copy code hover
[image]

Form.InsideHeight Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InsideHeight property (along with the InsideWidth property) to determine the height and width (in twips) of the window containing a form. Read/write Long.

Syntax

expression .InsideHeight

expression A variable that represents a Form object.

Remarks

If you want to determine the interior dimensions of the form itself, you use the Width property to determine the form width and the sum of the heights of the form's visible sections to determine its height (the Height property applies only to form sections, not to forms). The interior of a form is the region inside the form, excluding the scroll bars and the record selectors.

You can also use the WindowHeight and WindowWidth properties to determine the height and width of the window containing a form.

If a window is maximized, setting these properties doesn't have any effect until the window is restored to its normal size.

Example

The following example shows how to use the InsideHeight and InsideWidth properties to compare the inside height and width of a form with the height and width of the form's window. If the window's dimensions don't equal the size of the form, then the window is resized to match the form's height and width.

VBA Copy code Copy code
Sub ResetWindowSize(frm As Form)
 Dim intWindowHeight As Integer
 Dim intWindowWidth As Integer
 Dim intTotalFormHeight As Integer
 Dim intTotalFormWidth As Integer
 Dim intHeightHeader As Integer
 Dim intHeightDetail As Integer
 Dim intHeightFooter As Integer

 ' Determine form's height.
 intHeightHeader = frm.Section(acHeader).Height
 intHeightDetail = frm.Section(acDetail).Height
 intHeightFooter = frm.Section(acFooter).Height
 intTotalFormHeight = intHeightHeader _
 + intHeightDetail + intHeightFooter
 ' Determine form's width.
 intTotalFormWidth = frm.Width
 ' Determine window's height and width.
 intWindowHeight = frm.InsideHeight
 intWindowWidth = frm.InsideWidth

 If intWindowWidth <> intTotalFormWidth Then
 frm.InsideWidth = intTotalFormWidth
 End If
 If intWindowHeight <> intTotalFormHeight Then
 frm.InsideHeight = intTotalFormHeight
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


CheckBox.GridlineWidthRight Property (Access)

 Copy code hover
[image]

CheckBox.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified check box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthRight

expression A variable that represents a CheckBox object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ComboBox.SeparatorCharacters Property (Access)

 Copy code hover
[image]

ComboBox.SeparatorCharacters Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the separator displayed between values when the combo box is bound to a multi-valued field. Read/write AcSeparatorCharacters.

Version Information

Version Added: Access 2007

Syntax

expression .SeparatorCharacters

expression A variable that represents a ComboBox object.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Attachment.BackColor Property (Access)

 Copy code hover
[image]

Attachment.BackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the interior color of the specified object. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .BackColor

expression A variable that represents an Attachment object.

Remarks

The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

To use the BackColor property, the BackStyle property, if available, must be set to Normal.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


The query cannot be used as a row source. (Error 3323)

 Copy code hover
[image]

The query cannot be used as a row source. (Error 3323)
Send feedback

Possible causes:

The query being used as a record source is an action query or a data-definition query.


EmptyCell Members (Access)

 Copy code hover
[image]

EmptyCell Members (Access)
Send feedback

Published: July 16, 2012

Represents an empty cell in a control layout.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BottomPadding | Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
GridlineColor | Gets or sets the color of the gridline for the specified list box. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified list box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified text box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified text box. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified text box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified text box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified text box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the text box is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Layout | Returns the type of layout for the specified text box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified text box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
RightPadding | Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified text box is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


The object is not a stored procedure. (Error 3749)

 Copy code hover
[image]

The object is not a stored procedure. (Error 3749)
Send feedback

This error occurs when using the EXECUTE keyword and either passing a name of a procedure or view that does not exist in the database or passing the name of a base table.


The Microsoft Access database engine could not read the system clock on your computer. (Error 3515)

 Copy code hover
[image]

The Microsoft Access database engine could not read the system clock on your computer. (Error 3515)
Send feedback

The Microsoft Access database engine uses your computer's system clock for certain internal processes. It tried to read the computer's clock but was not able to. Shut down and restart your computer.


Property Properties, Methods, and Events (ADO)

 Copy code hover
[image]

Property Properties, Methods, and Events (ADO)
Send feedback

Properties

Attributes Property

Name Property

Type Property

Value Property

Methods

None.

Events

None.


RDS Tutorial (VBScript)

 Copy code hover
[image]

RDS Tutorial (VBScript)
Send feedback

This is the RDS Tutorial, written in Microsoft Visual Basic Scripting Edition. For a description of the purpose of this tutorial, see the RDS Tutorial.

In this tutorial, RDS.DataControl and RDS.DataSpace are created at design time — that is, they are defined with object tags, like this: . Alternatively, they could be created at run time with the Server.CreateObject method. For example, the RDS.DataControl object could be created like this:

Copy code Copy code
Set DC = Server.CreateObject("RDS.DataControl")
 <!-- RDS.DataControl -->
 <OBJECT
 ID="DC1" CLASSID="CLSID:BD96C556-65A3-11D0-983A-00C04FC29E33">
 </OBJECT>

 <!-- RDS.DataSpace -->
 <OBJECT
 ID="DS1" WIDTH=1 HEIGHT=1
 CLASSID="CLSID:BD96C556-65A3-11D0-983A-00C04FC29E36">
 </OBJECT>

 <SCRIPT LANGUAGE="VBScript">

 Sub RDSTutorial()
 Dim DF1

Step 1 — Specify a server program

VBScript can discover the name of the IIS Web server it is running on by accessing the VBScript Request.ServerVariables method available to Active Server Pages:

Copy code Copy code

"http://<%=Request.ServerVariables("SERVER_NAME")%>"

However, for this tutorial, use the imaginary server, "yourServer".

Note Note

Pay attention to the data type of ByRef arguments. VBScript does not let you specify the variable type, so you must always pass a Variant. When using HTTP, RDS will allow you to pass a Variant to a method that expects a non-Variant if you invoke it with the RDS.DataSpace object CreateObject method. When using DCOM or an in-process server, match the parameter types on the client and server sides or you will receive a "Type Mismatch" error.
Copy code Copy code

Set DF1 = DS1.CreateObject("RDSServer.DataFactory", "http://yourServer")

Step 2a — Invoke the server program with RDS.DataControl

This example is merely a comment demonstrating that the default behavior of the RDS.DataControl is to perform the specified query.

Copy code Copy code

<OBJECT CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID="DC1">
 <PARAM NAME="SQL" VALUE="SELECT * FROM Authors">
 <PARAM NAME="Connect" VALUE="DSN=Pubs;">
 <PARAM NAME="Server" VALUE="http://yourServer/">
</OBJECT>
...
<SCRIPT LANGUAGE="VBScript">

Sub RDSTutorial2A()
 Dim RS
 DC1.Refresh
 Set RS = DC1.Recordset
...

Step 2b — Invoke the server program with RDSServer.DataFactory

Step 3 — Server obtains a Recordset

Step 4 — Server returns the Recordset

Copy code Copy code

Set RS = DF1.Query("DSN=Pubs;", "SELECT * FROM Authors")

Step 5 — DataControl is made usable by visual controls

Copy code Copy code

' Assign the returned recordset to the DataControl.

DC1.SourceRecordset = RS

Step 6a — Changes are sent to the server with RDS.DataControl

This example is merely a comment demonstrating how the RDS.DataControl performs updates.

Copy code Copy code

<OBJECT CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID="DC1">
 <PARAM NAME="SQL" VALUE="SELECT * FROM Authors">
 <PARAM NAME="Connect" VALUE="DSN=Pubs;">
 <PARAM NAME="Server" VALUE="http://yourServer/">
</OBJECT>
...
<SCRIPT LANGUAGE="VBScript">

Sub RDSTutorial6A()
Dim RS
DC1.Refresh
...
Set RS = DC1.Recordset
' Edit the Recordset object...
' The SERVER and CONNECT properties are already set from Step 2A.
Set DC1.SourceRecordset = RS
...
DC1.SubmitChanges

Step 6b — Changes are sent to the server with RDSServer.DataFactory

Copy code Copy code

DF.SubmitChanges"DSN=Pubs", RS

End Sub
</SCRIPT>
</BODY>
</HTML>

This is the end of the tutorial.


Rectangle.EventProcPrefix Property (Access)

 Copy code hover
[image]

Rectangle.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents a Rectangle object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


TableDefs Members (DAO)

 Copy code hover
[image]

TableDefs Members (DAO)
Send feedback

A TableDefs collection contains all stored TableDef objects in a database (Microsoft Access workspaces only).

Methods

Name | Description
Append | Adds a new TableDef to the TableDefs collection.
Delete | Deletes the specified TableDef object from the TableDefs collection.
Refresh | Updates the objects in the specified colletion to reflect the database's current schema.

Properties

Name | Description
Count | Returns the number of objects in the specified collection. Read-only.


Image.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

Image.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents an Image object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.BorderThemeColorIndex=2

See also

Concepts

Image Object

Other resources

Image Object Members


OptionGroup.Click Event (Access)

 Copy code hover
[image]

OptionGroup.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Syntax

expression .Click

expression A variable that represents an OptionGroup object.

Remarks

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

The Click event for an option group occurs after you change the value of one of the controls in the option group by clicking the control. For example, if you click a toggle button, option button, or check box in an option group, the Click event for the option group occurs after the BeforeUpdate and AfterUpdate events for the option group.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


ComboBox.DisplayAsHyperlink Property (Access)

 Copy code hover
[image]

ComboBox.DisplayAsHyperlink Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcDisplayAsHyperlink constant that specifies whether to display the contents of the specified combo box as a hyperlink. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .DisplayAsHyperlink

expression A variable that represents a ComboBox object.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


UpdateTypeEnum Enumeration (DAO)

 Copy code hover
[image]

UpdateTypeEnum Enumeration (DAO)
Send feedback

Used with the Update method to specify which updates to write to disk.

Name | Value | Description
dbUpdateBatch | 4 | All pending changes in the update cache are written to disk.
dbUpdateCurrentRecord | 2 | Only the current record's pending changes are written to disk.
dbUpdateRegular | 1 | (Default) Pending changes are not cached and are written to disk immediately.


CompareEnum

 Copy code hover
[image]

CompareEnum
Send feedback

Specifies the relative position of two records represented by their bookmarks.

Constant | Value | Description
adCompareEqual | 1 | Indicates that the bookmarks are equal.
adCompareGreaterThan | 2 | Indicates that the first bookmark is after the second.
adCompareLessThan | 0 | Indicates that the first bookmark is before the second.
adCompareNotComparable | 4 | Indicates that the bookmarks cannot be compared.
adCompareNotEqual | 3 | Indicates that the bookmarks are not equal and not ordered.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.Compare.EQUAL

AdoEnums.Compare.GREATERTHAN

AdoEnums.Compare.LESSTHAN

AdoEnums.Compare.NOTCOMPARABLE

AdoEnums.Compare.NOTEQUAL


Relation.Name Property (DAO)

 Copy code hover
[image]

Relation.Name Property (DAO)
Send feedback

Returns or sets the name of the specified object. Read/write String if the object has not been appended to a collection. Read-only String if the object has been appended to a collection.

Syntax

expression .Name

expression A variable that represents a Relation object.

Remarks

The maximum length for the name of a Relation object is 64 characters.


ToggleButton.Caption Property (Access)

 Copy code hover
[image]

ToggleButton.Caption Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the text that appears in the control. Read/write String.

Syntax

expression .Caption

expression A variable that represents a ToggleButton object.

Remarks

The Caption property is a string expression that can contain up to 2,048 characters.

If you don't set a caption for a form, button, or label, Microsoft Access will assign the object a unique name based on the object, such as "Form1".

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


XML Recordset Persistence Scenario Topics

 Copy code hover
[image]

XML Recordset Persistence Scenario Topics
Send feedback

Insert introduction here.

Section Heading

Insert section body here.

Subsection Heading

Insert subsection body here.


Conflict tables cannot be renamed. (Error 3769)

 Copy code hover
[image]

Conflict tables cannot be renamed. (Error 3769)
Send feedback

A conflict table is a system table that cannot be renamed. To remove conflicts from your replica the contents of the conflict table can be deleted, and the conflict table itself can also be deleted.


ToggleButton.FontName Property (Access)

 Copy code hover
[image]

ToggleButton.FontName Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontName property to specify the font for text in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write String.

Syntax

expression .FontName

expression A variable that represents a ToggleButton object.

Remarks

The FontName property setting is the name of the font that the text is displayed in.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set this property only in an event procedure or in a macro specified by the OnPrint event property setting.

Font availability depends on your system and printer. If you select a font that your system can't display or that isn't installed, Windows substitutes a similar font.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Cannot set the specified Registry parameter for the Synchronizer. (Error 3493)

 Copy code hover
[image]

Cannot set the specified Registry parameter for the Synchronizer. (Error 3493)
Send feedback

You need to reconfigure the Synchronizer on your computer.

To configure the Synchronizer

  1. Start Replication Manager.

  2. On the Tools menu, click Configure Microsoft Replication Manager.

  3. Follow the instructions in the wizard.


Database.Relations Property (DAO)

 Copy code hover
[image]

Database.Relations Property (DAO)
Send feedback

Returns a Relations collection that contains all of the stored Relation objects for the specified database. Read-only.

Syntax

expression .Relations

expression A variable that represents a Database object.


DBEngine.Workspaces Property (DAO)

 Copy code hover
[image]

DBEngine.Workspaces Property (DAO)
Send feedback

Returns a Workspaces collection that contains all of the active, unhidden Workspace objects. Read-only.

Syntax

expression .Workspaces

expression A variable that represents a DBEngine object.


Workspace.Connections Property (DAO)

 Copy code hover
[image]

Workspace.Connections Property (DAO)
Send feedback

Returns a Connections collection that represents the current connections in the specified Workspace. Read-only.

Syntax

expression .Connections

expression A variable that represents a Workspace object.


Application.DDEInitiate Method (Access)

 Copy code hover
[image]

Application.DDEInitiate Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the DDEInitiate function to begin a dynamic data exchange (DDE) conversation with another application. The DDEInitiate function opens a DDE channel for transfer of data between a DDE server and client application.

Syntax

expression .DDEInitiate(Application, Topic)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Application | Required | String | A string expression identifying an application that can participate in a DDE conversation. Usually, the application argument is the name of an .exe file (without the .exe extension) for a Microsoft Windows-based application, such as Microsoft Excel.
Topic | Required | String | A string expression that is the name of a topic recognized by the application argument. Check the application's documentation for a list of topics.

Return Value

Variant

Remarks

For example, if you wish to transfer data from a Microsoft Excel spreadsheet to a Microsoft Access database, you can use the DDEInitiate function to open a channel between the two applications. In this example, Microsoft Access acts as the client application and Microsoft Excel acts as the server application.

If successful, the DDEInitiate function begins a DDE conversation with the application and topic specified by the application and topic arguments, and then returns a Long integer value. This return value represents a unique channel number identifying a channel through which data transfer can take place. This channel number is subsequently used with other DDE functions and statements.

If the application isn't already running or if it's running but doesn't recognize the topic argument or doesn't support DDE, the DDEInitiate function returns a run-time error.

The value of the topic argument depends on the application specified by the application argument. For applications that use documents or data files, valid topic names often include the names of those files.

Note Note

The maximum number of channels that can be open simultaneously is determined by Microsoft Windows and your computer's memory and resources. If you aren't using a channel, you should conserve resources by terminating it with a DDETerminate or DDETerminateAll statement.

If you need to manipulate another application's objects from Microsoft Access, you may want to consider using Automation.

See also

Concepts

Application Object

Other resources

Application Object Members


ListBox.InheritValueList Property (Access)

 Copy code hover
[image]

ListBox.InheritValueList Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether a list box's value list is inherited from its field. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .InheritValueList

expression A variable that represents a ListBox object.

Remarks

The InheritValueList property is effective only when the list box is bound to a Lookup field and the RowSourceType property is set to Value List.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


AcExportQuality Enumeration (Access)

 Copy code hover
[image]

AcExportQuality Enumeration (Access)
Send feedback

Published: July 16, 2012

Use with the OutputTo method to specify the type of output device to optimize for when exporting an object.

Name | Value | Description
acExportQualityPrint | 0 | The output is optimized for printing.
acExportQualityScreen | 1 | The output is optimized for onscreen display.


Tab Control

 Copy code hover
[image]

Tab Control
Send feedback

Published: July 16, 2012

A tab control contains multiple pages on which you can place other controls, such as text boxes or option buttons. When a user clicks the corresponding tab, that page becomes active.

With the tab control, you can construct a single form or dialog box that contains several different tabs, and you can group similar options or data on each tab's page. For example, you might use a tab control on an Employees form to separate general and personal information.


Open and Close Methods Example (VBScript)

 Copy code hover
[image]

Open and Close Methods Example (VBScript)
Send feedback

This example uses the Open and Close methods on both Recordset and Connection objects that have been opened.

Use the following example in an Active Server Page (ASP). Use Find to locate the file Adovbs.inc and place it in the directory you plan to use. Cut and paste the following code into Notepad or another text editor, and save it as OpenVBS.asp. You can view the result in any browser.

VBS Copy code Copy code

<!-- BeginOpenVBS -->
<%@ Language=VBScript %>
<%' use this meta tag instead of adovbs.inc%>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->
<HTML>
<HEAD>
<META name="VI60_DefaultClientScript"  content=VBScript>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<title>ADO Open Method</title>
<STYLE>
<!--
BODY {
   font-family: 'Verdana','Arial','Helvetica',sans-serif;
   BACKGROUND-COLOR:white;
   COLOR:black;
    }
.thead {
   background-color: #008080;
   font-family: 'Verdana','Arial','Helvetica',sans-serif;
   font-size: x-small;
   color: white;
   }
.thead2 {
   background-color: #800000;
   font-family: 'Verdana','Arial','Helvetica',sans-serif;
   font-size: x-small;
   color: white;
   }
.tbody {
   text-align: center;
   background-color: #f7efde;
   font-family: 'Verdana','Arial','Helvetica',sans-serif;
   font-size: x-small;
    }
-->
</STYLE>
</HEAD>

<BODY>
<H3>ADO Open Method</H3>

<TABLE WIDTH=600 BORDER=0>
<TR>
<TD VALIGN=TOP COLSPAN=3>
<FONT SIZE=2>
<% ' to integrate/test this code replace the
   ' Data Source value in the Connection string%>
<%
    ' connection and recordset variables
    Dim Cnxn, strCnxn
    Dim rsCustomers, strSQLCustomers
    Dim rsProducts, strSQLProducts

    ' open connection
    Set Cnxn = Server.CreateObject("ADODB.Connection")
    strCnxn = "Provider='sqloledb';Data Source=" & _
            Request.ServerVariables("SERVER_NAME") & ";" & _
            "Integrated Security='SSPI';Initial Catalog='Northwind';"

    Cnxn.Open strCnxn

    ' create and open first Recordset using Connection - execute
    Set rsCustomers = Server.CreateObject("ADODB.Recordset")
    strSQLCustomers = "SELECT CompanyName, ContactName, City FROM Customers"
    Set rsCustomers = Cnxn.Execute(strSQLCustomers)

    ' create and open second Recordset using recordset - open
    Set rsProducts = Server.CreateObject("ADODB.Recordset")
    strSQLProducts = "SELECT ProductName, UnitPrice FROM Products"
    rsProducts.Open strSQLProducts, Cnxn, adOpenDynamic, adLockPessimistic, adCmdText
    %>

    <TABLE COLSPAN=8 CELLPADDING=5 BORDER=0>
    <!-- BEGIN column header row for Customer Table-->
    <TR CLASS=thead>
       <TD>Company Name</TD>
       <TD>Contact Name</TD>
       <TD>City</TD>
    </TR>

    <!--Display ADO Data from Customer Table-->
    <% Do Until rsCustomers.EOF %>
    <TR CLASS=tbody>
      <TD> <%=rsCustomers("CompanyName")%> </TD>
      <TD> <%=rsCustomers("ContactName")%></TD>
      <TD> <%=rsCustomers("City")%> </TD>
    </TR>
    <%rsCustomers.MoveNext
    Loop
    %>
    </TABLE>

    <HR>

    <TABLE COLSPAN=8 CELLPADDING=5 BORDER=0>
    <!-- BEGIN column header row for Product List Table-->

    <TR CLASS=thead2>
       <TD>Product Name</TD>
       <TD>Unit Price</TD>
    </TR>
    <!-- Display ADO Data Product List-->
    <% Do Until rsProducts.EOF %>
      <TR CLASS=tbody>
      <TD> <%=rsProducts("ProductName")%> </TD>
      <TD> <%=rsProducts("UnitPrice")%> </TD>
      </TR>
      <!--  Next Row = Record -->
    <%rsProducts.MoveNext
    Loop

    ' clean up
    If rsProducts.State = adStateOpen then
        rsProducts.Close
    End If
    If rsCustomers.State = adStateOpen then
        rsCustomers.Close
    End If
    If Cnxn.State = adStateOpen then
        Cnxn.Close
    End If
    Set rsProducts = Nothing
    Set rsCustomers = Nothing
    Set Cnxn = Nothing

    %>
    </TABLE>

</BODY>
</HTML>
<!-- EndOpenVBS -->


Indexes Members (DAO)

 Copy code hover
[image]

Indexes Members (DAO)
Send feedback

An Indexes collection contains all the stored Index objects of a TableDef object (Microsoft Access workspaces only).

Methods

Name | Description
Append | Adds a new Index to the Indexes collection.
Delete | Deletes the specified Index from the Indexes collection.
Refresh | Updates the objects in the specified colletion to reflect the database's current schema.

Properties

Name | Description
Count | Returns the number of objects in the specified collection. Read-only.


Cannot open the Microsoft Jet engine workgroup information file. (Error 3358)

 Copy code hover
[image]

Cannot open the Microsoft Jet engine workgroup information file. (Error 3358)
Send feedback

You attempted to perform a security-related task, but the workgroup information file (typically System.mdw) required for the task cannot be found.


Group Object (ADOX) Reference

 Copy code hover
[image]

Group Object (ADOX) Reference
Send feedback

In this section

  • Group Object (ADOX)

  • Group Properties, Methods, and Events (ADOX)


Rectangle.OnClick Property (Access)

 Copy code hover
[image]

Rectangle.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Syntax

expression .OnClick

expression A variable that represents a Rectangle object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


AdditionalData Properties (Access)

 Copy code hover
[image]

AdditionalData Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AdditionalData.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.


ComboBox.GotFocus Event (Access)

 Copy code hover
[image]

ComboBox.GotFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The GotFocus event occurs when the specified object receives the focus.

Syntax

expression .GotFocus

expression A variable that represents a ComboBox object.

Remarks

To run a macro or event procedure when these events occur, set the OnGotFocus property to the name of the macro or to [Event Procedure].

These events occur when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The GotFocus event differs from the Enter event in that the GotFocus event occurs every time a control receives the focus. For example, suppose the user clicks a check box on a form, then clicks a report, and finally clicks the check box on the form to bring it to the foreground. The GotFocus event occurs both times the check box receives the focus. In contrast, the Enter event occurs only the first time the user clicks the check box. The GotFocus event occurs after the Enter event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Logical Operators (Access 2013 custom web app)

 Copy code hover
[image]

Logical Operators (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • AND (Access 2013 custom web app)

  • NOT (Access 2013 custom web app)

  • OR (Access 2013 custom web app)

  • IS [NOT] NULL (Access 2013 custom web app)


How to: Perform Simple Data Validation Checks When Editing a Record in a Form

 Copy code hover
[image]

How to: Perform Simple Data Validation Checks When Editing a Record in a Form
Send feedback

You can use the BeforeUpdate event of a form or a control to perform validation checks on data entered into a form or control. If the data in the form or control fails the validation check, you can set the BeforeUpdate event's Cancel argument to True to cancel the update.

The following example prevents the user from saving changes to the current record if the Unit Cost field does not contain a value.

VBA Copy code Copy code
Private Sub Form_BeforeUpdate(Cancel As Integer)

   ' Check for a blank value in the Unit Cost field.
    If IsNull(Me![Unit Cost]) Then

       ' Alert the user.
       MsgBox "You must supply a Unit Cost."

      ' Cancel the update.
      Cancel = True
    End If
End Sub


AllowNullsEnum

 Copy code hover
[image]

AllowNullsEnum
Send feedback

Specifies whether records with null values are indexed.

Constant | Value | Description
adIndexNullsAllow | 0 | The index does allow entries in which the key columns are null. If a null value is entered in a key column, the entry is inserted into the index.
adIndexNullsDisallow | 1 | Default. The index does not allow entries in which the key columns are null. If a null value is entered in a key column, an error will occur.
adIndexNullsIgnore | 2 | The index does not insert entries containing null keys. If a null value is entered in a key column, the entry is ignored and no error occurs.
adIndexNullsIgnoreAny | 4 | The index does not insert entries where some key column has a null value. For an index having a multi-column key, if a null value is entered in some column, the entry is ignored and no error occurs.


Key Object (ADOX) Reference

 Copy code hover
[image]

Key Object (ADOX) Reference
Send feedback

In this section

  • Key Object (ADOX)

  • Key Properties, Methods, and Events (ADOX)


SmartTag Properties (Access)

 Copy code hover
[image]

SmartTag Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
IsMissing | Returns True if the specified smart tag is not installed or is installed incorrectly. Read-only Boolean.
Name | You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a SmartTagProperties collection that represents the collection of properties for a particular smart tag. Read-only.
SmartTagActions | Returns a SmartTagActions collection that represents the actions available for a specific smart tag. Read-only.
XML | Returns a String that represents the related XML code for a smart tag. Read-only.


Tables Collection (ADOX)

 Copy code hover
[image]

Tables Collection (ADOX)
Send feedback

Contains all Table objects of a catalog.

Remarks

The Append method for a Tables collection is unique for ADOX. You can:

  • Add a new table to the collection with the Append method.

The remaining properties and methods are standard to ADO collections. You can:

  • Access a table in the collection with the Item property.

  • Return the number of tables contained in the collection with the Count property.

  • Remove a table from the collection with the Delete method.

  • Update the objects in the collection to reflect the current database's schema with the Refresh method.

Some providers may return other schema objects, such as a View, in the Tables collection. Therefore, some ADOX collections may contain references to the same object. Should you delete the object from one collection, the change will not be visible in another collection that references the deleted object until the Refresh method is called on the collection. For example, with the OLE DB Provider for Microsoft Jet, Views are returned with the Tables collection. If you drop a View, you must Refresh the Tables collection before the collection will reflect the change.


RemoveTempVar Macro Action

 Copy code hover
[image]

RemoveTempVar Macro Action
Send feedback

You can use the RemoveTempVar action to remove a single temporary variable that you created by using the SetTempVar action.

Setting

The RemoveTempVar action has the following argument.

Action argument | Description
Name | Enter the name of the temporary variable you want to remove.

Remarks

  • You can have up to 255 temporary variables defined at one time. If you do not remove a temporary variable, it will remain in memory until you close the database. It is a good practice to remove temporary variables when you are finished using them.

  • Access automatically removes all temporary variables when you close the database or project.

  • If you misspell the name of the variable to be removed, Access does not display an error. The variable you wanted to remove will remain in memory until you close the database.

  • If you have created more than one temporary variable and you want to remove them all at once, use the RemoveAllTempVars action.

  • To run the RemoveTempVar action in a VBA module, use the Remove method of the TempVars object.

Example

The following macro demonstrates how to create a temporary variable, use it in a condition and a message box, and then remove the temporary variable by using the RemoveTempVar action.

Condition | Action | Arguments
 | SetTempVar | Name: MyVarExpression: InputBox("Enter a non-zero number.")
[TempVars]![MyVar]<>0 | MessageBox | Message: ="You entered " & [TempVars]![MyVar] & "."Beep: Yes Type: Information
 | RemoveTempVar | Name: MyVar


NavigationButton.Top Property (Access)

 Copy code hover
[image]

NavigationButton.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Version Information

Version Added: Access 2010

Syntax

expression .Top

expression A variable that represents a NavigationButton object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


AccessObjectProperty.Name Property (Access)

 Copy code hover
[image]

AccessObjectProperty.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.

Syntax

expression .Name

expression A variable that represents an AccessObjectProperty object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

AccessObjectProperty Object

Other resources

AccessObjectProperty Object Members


CustomControl.Tag Property (Access)

 Copy code hover
[image]

CustomControl.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents a CustomControl object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Using the Connection Properties in the Microsoft OLE DB Provider for Access

 Copy code hover
[image]

Using the Connection Properties in the Microsoft OLE DB Provider for Access
Send feedback

Published: July 16, 2012

To customize the Microsoft® Windows® Registry settings, you can use the connection properties in the Microsoft OLE DB Provider for Access. This is accomplished by referencing a property in the connection object and changing its value. For example, assuming that your connection object is called ADOConnection, the following would yield the same results as going through ADO:

ADOConnection.Properties("Jet OLEDB:Max Locks Per File") = 20000

The property names are different than the DAO constants and the registry settings. The property names are as follows:

Jet OLEDB:Max Locks Per File

Jet OLEDB:Implicit Commit Sync

Jet OLEDB:Flush Transaction Timeout

Jet OLEDB:Lock Delay

Jet OLEDB:Max Buffer Size

Jet OLEDB:User Commit Sync

Jet OLEDB:Lock Retry

Jet OLEDB:Exclusive Async Delay

Jet OLEDB:Shared Async Delay

Jet OLEDB:Page Timeout

Jet OLEDB:Recycle Long-Valued Pages


ActiveX Data Objects (ADO)

 Copy code hover
[image]

ActiveX Data Objects (ADO)
Send feedback

In this section

  • How to: Bind a Form to an ADO Recordset

  • How to: Set Properties of ActiveX Data Objects in Visual Basic

  • How to: Create an ADO Connection String


ComboBox.ForeShade Property (Access)

 Copy code hover
[image]

ComboBox.ForeShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .ForeShade

expression A variable that represents a ComboBox object.

Remarks

The ForeShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the ForeShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the ForeColor property by 75%.

VBA Copy code Copy code
Me.ctl.ForeShade=25

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


WebBrowserControl.GridlineWidthRight Property (Access)

 Copy code hover
[image]

WebBrowserControl.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthRight

expression A variable that represents a WebBrowserControl object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


ListBox.FontWeight Property (Access)

 Copy code hover
[image]

ListBox.FontWeight Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.

Syntax

expression .FontWeight

expression A variable that represents a ListBox object.

Remarks

The DatasheetFontWeight property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

These properties are only available in Visual Basic within a Microsoft Access database.

In Visual Basic, the DatasheetFontWeight property setting uses the following Integer values.

Setting | Description
100 | Thin
200 | Extra Light
300 | Light
400 | (Default) Normal
500 | Medium
600 | Semi-bold
700 | Bold
800 | Extra Bold
900 | Heavy

The following table contains the properties that don't exist in the DAO Properties collection of until you set them by using the Formatting (Datasheet) toolbar or you can add them in an Access database by using the CreateProperty method and append it to the DAO Properties collection.

DatasheetFontItalic * | DatasheetForeColor *
DatasheetFontHeight * | DatasheetBackColor
DatasheetFontName * | DatasheetGridlinesColor
DatasheetFontUnderline * | DatasheetGridlinesBehavior
DatasheetFontWeight * | DatasheetCellsEffect
Note Note

When you add or set any property listed with an asterisk, Microsoft Access automatically adds all the properties listed with an asterisk to the Properties collection of the database.

Example

The following example sets the font to MS Serif, the font size to 10 points, and the font weight to medium (500) in Datasheet view of the Products table.

VBA Copy code Copy code

Sub SetDatasheetFont

   Dim dbs As Object, objProducts As Object
   Set dbs = CurrentDb
   Const DB_Text As Long = 10
   Const DB_Integer As Long = 3
   Set objProducts = dbs!Products

   SetTableProperty objProducts, "DatasheetFontName", DB_Text, "MS Serif"
   SetTableProperty objProducts, "DatasheetFontHeight", DB_Integer, 10
   SetTableProperty objProducts, "DatasheetFontWeight", DB_Integer, 500

End Sub

Sub SetTableProperty(objTableObj As Object, strPropertyName As String, _
        intPropertyType As Integer, varPropertyValue As Variant)
    ' Set Microsoft Access-defined table property without causing
    ' nonrecoverable run-time error.
    Const conErrPropertyNotFound = 3270
    Dim prpProperty As Variant
    On Error Resume Next                ' Don't trap errors.
    objTableObj.Properties(strPropertyName) = varPropertyValue
    If Err <> 0 Then                    ' Error occurred when value set.
        If Err <> conErrPropertyNotFound Then
            On Error GoTo 0
            MsgBox "Couldn't set property '" & strPropertyName _
                & "' on table '" & objTableObj.Name & "'", 48, "SetTableProperty"
        Else
            On Error GoTo 0
            Set prpProperty = objTableObj.CreateProperty(strPropertyName, _
                intPropertyType, varPropertyValue)
            objTableObj.Properties.Append prpProperty
        End If
    End If
    objTableObj.Properties.Refresh
End Sub

The next example makes the same changes as the preceding example in Datasheet view of the open Products form.

VBA Copy code Copy code
Forms!Products.DatasheetFontName = "MS Serif"
Forms!Products.DatasheetFontHeight = 10
Forms!Products.DatasheetFontWeight = 500

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


CursorTypeEnum

 Copy code hover
[image]

CursorTypeEnum
Send feedback

Specifies the type of cursor used in a Recordset object.

Constant | Value | Description
adOpenDynamic | 2 | Uses a dynamic cursor. Additions, changes, and deletions by other users are visible, and all types of movement through the Recordset are allowed, except for bookmarks, if the provider doesn't support them.
adOpenForwardOnly | 0 | Default. Uses a forward-only cursor. Identical to a static cursor, except that you can only scroll forward through records. This improves performance when you need to make only one pass through a Recordset.
adOpenKeyset | 1 | Uses a keyset cursor. Like a dynamic cursor, except that you can't see records that other users add, although records that other users delete are inaccessible from your Recordset. Data changes by other users are still visible.
adOpenStatic | 3 | Uses a static cursor. A static copy of a set of records that you can use to find data or generate reports. Additions, changes, or deletions by other users are not visible.
adOpenUnspecified | -1 | Does not specify the type of cursor.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.CursorType.DYNAMIC

AdoEnums.CursorType.FORWARDONLY

AdoEnums.CursorType.KEYSET

AdoEnums.CursorType.STATIC

AdoEnums.CursorType.UNSPECIFIED


Language-Specific Properties and Methods
Send feedback

Published: July 16, 2012

Language-Specific Properties and Methods

Properties and methods that are available only in Asian or right-to-left languages are listed in the following table.

Property or Method | Object
AsianLineBreak | TextBox
FuriganaControl | TextBox
IMEHold | ComboBox, ListBox, TextBox
IMEMode | ComboBox, Label, ListBox, TextBox
IMESentenceMode | ComboBox, Label, ListBox, TextBox
KeyboardLanguage | ComboBox, TextBox
NumeralShapes | ComboBox, Label, ListBox, TextBox
Orientation | Form
PostalAddress | TextBox
ReadingOrder | CheckBox, ComboBox, CommandButton, Label, ListBox, OptionButton, TextBox, ToggleButton
ScrollBarAlign | ComboBox, ListBox, TextBox


OptionGroup.Enabled Property (Access)

 Copy code hover
[image]

OptionGroup.Enabled Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.

Syntax

expression .Enabled

expression A variable that represents an OptionGroup object.

Remarks

The Enabled property setting is a value that indicates whether the conditional format is enabled or disabled. True enables the conditional format. False disables the conditional format. The default is True.

When the Enabled property is True, the conditional format can be displayed in the Conditional Formatting dialog box.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


InternetTimeout Property Example (VJ++)

 Copy code hover
[image]

InternetTimeout Property Example (VJ++)
Send feedback

This example demonstrates the InternetTimeout property, which exists on the DataControl and DataSpace objects. In this case, the InternetTimout property is demonstrated on the DataControl object and the timeout is set to 20 seconds.

Copy code Copy code
// BeginInternetTimeoutJ// The WFC class includes the ADO objects.
import com.ms.wfc.data.*;import com.ms.wfc.data.rds.*;
import java.io.* ;
public class InternetTimeoutX{
// The main entry point for the application.
public static void main (String[] args){
InternetTimeoutX();System.exit(0);
}
// InternetTimeoutX function
static void InternetTimeoutX(){
// Define ADO Objects.Recordset rstAuthors = null;
// Declarations.BufferedReader in =
new BufferedReader (new InputStreamReader(System.in));int intCount = 0;
int intDisplaysize = 15;
try{
IBindMgr dc = (IBindMgr) new DataControl();dc.setServer("http://MyServer");
dc.setConnect("DSN=pubs");dc.setSQL("SELECT * FROM Authors");
dc.setInternetTimeout(20000); // Wait at least 20 seconds.dc.Refresh();
rstAuthors = (Recordset)dc.getRecordset();while(!rstAuthors.getEOF())
{System.out.println(rstAuthors.getField
("au_fname").getString() + " " +rstAuthors.getField("au_lname").getString());
intCount++;if(intCount % intDisplaysize == 0)
{System.out.println("\nPress <Enter> to continue..");
in.readLine();intCount = 0;
}rstAuthors.moveNext();
}
System.out.println("\nPress <Enter> to continue..");in.readLine();
}catch( AdoException ae )
{// Notify user of any errors that result from ADO.
// As passing a Recordset, check for null pointer first.if (rstAuthors != null)
{PrintProviderError(rstAuthors.getActiveConnection());
}else
{System.out.println("Exception: " + ae.getMessage());
}}
// System read requires this catch.catch( java.io.IOException je)
{PrintIOError(je);
}catch(java.lang.UnsatisfiedLinkError e)
{System.out.println("Exception: " + e.getMessage());
}catch(java.lang.NullPointerException ne)
{System.out.println(
"Exception: Attempt to use null where an object is required.");}
finally{
// Cleanup objects before exit.if (rstAuthors != null)
if (rstAuthors.getState() == 1)rstAuthors.close();
}}
// PrintProviderError Function
static void PrintProviderError( Connection Cnn1 ){
// Print Provider errors from Connection object.// ErrItem is an item object in the Connection's Errors collection.
com.ms.wfc.data.Error ErrItem = null;long nCount = 0;
int i = 0;
nCount = Cnn1.getErrors().getCount();
// If there are any errors in the collection, print them.if( nCount > 0);
{// Collection ranges from 0 to nCount - 1
for (i = 0; i< nCount; i++){
ErrItem = Cnn1.getErrors().getItem(i);System.out.println("\t Error number: " + ErrItem.getNumber()
+ "\t" + ErrItem.getDescription() );}
}
}
// PrintIOError Function
static void PrintIOError( java.io.IOException je){
System.out.println("Error \n");System.out.println("\tSource = " + je.getClass() + "\n");
System.out.println("\tDescription = " + je.getMessage() + "\n");}
}// EndInternetTimeoutJ


WebBrowserControl.Requery Method (Access)

 Copy code hover
[image]

WebBrowserControl.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.

Version Information

Version Added: Access 2010

Syntax

expression .Requery

expression A variable that represents a WebBrowserControl object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts .

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate function.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

Example

The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form:

VBA Copy code Copy code
Public Sub RequeryList()

    Dim ctlCombo As Control

    ' Return Control object pointing to a combo box.
    Set ctlCombo = Forms!Employees!ReportsTo

    ' Requery source of data for list box.
    ctlCombo.Requery

End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


WebBrowserControl.OnMouseUp Property (Access)

 Copy code hover
[image]

WebBrowserControl.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnMouseUp

expression A variable that represents a WebBrowserControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Views and Fields Collections Example (VB)

 Copy code hover
[image]

Views and Fields Collections Example (VB)
Send feedback

The following code demonstrates how to use the Command property and the Recordset object to retrieve field information for the view.

Copy code Copy code

' BeginViewFieldsVB
Sub ViewFields()
 On Error GoTo ViewFieldsError

 Dim cnn As New ADODB.Connection
 Dim rst As New ADODB.Recordset
 Dim fld As ADODB.Field
 Dim cat As New ADOX.Catalog

 ' Open the Connection
 cnn.Open _
 "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\Microsoft Office\" & _
 "Office\Samples\Northwind.mdb';"

 ' Open the catalog
 Set cat.ActiveConnection = cnn

 ' Set the Source for the Recordset
 Set rst.Source = cat.Views("AllCustomers").Command

 ' Retrieve Field information
 rst.Fields.Refresh
 For Each fld In rst.Fields
 Debug.Print fld.Name & ":" & fld.Type
 Next

 'Clean up
 cnn.Close
 Set cat = Nothing
 Set rst = Nothing
 Set cnn = Nothing
 Exit Sub

ViewFieldsError:

 If Not cnn Is Nothing Then
 If cnn.State = adStateOpen Then cnn.Close
 End If

 Set cat = Nothing
 Set rst = Nothing
 Set cnn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If

End Sub
' EndViewFieldsVB


Reference.Minor Property (Access)

 Copy code hover
[image]

Reference.Minor Property (Access)
See also Send feedback

Published: July 16, 2012

The Minor property of a Reference object returns a Long value indicating the minor version number of the application to which you have set a reference.

Syntax

expression .Minor

expression A variable that represents a Reference object.

Remarks

The Minor property returns the value to the right of the decimal point in a version number. For example, if you've set a reference to an application whose version number is 2.5, the Minor property returns 5.

Example

The following example displays a message with information about all the references in the current project.

VBA Copy code Copy code
Dim r As Reference
Dim strInfo As String

For Each r In Application.References
 strInfo = strInfo & r.Name & " " & r.Major & "." & r.Minor & vbCrLf
Next

MsgBox "Current References: " & vbCrLf & strInfo

See also

Concepts

Reference Object

Other resources

Reference Object Members


Image.Application Property (Access)

 Copy code hover
[image]

Image.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents an Image object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

Image Object

Other resources

Image Object Members


Databases.Count Property (DAO)

 Copy code hover
[image]

Databases.Count Property (DAO)
Send feedback

Returns the number of objects in the specified collection. Read-only.

Syntax

expression .Count

expression A variable that represents a Databases object.

Remarks

Because members of a collection begin with 0, you should always code loops starting with the 0 member and ending with the value of the Count property minus 1. If you want to loop through the members of a collection without checking the Count property, you can use a For Each...Next command.

The Count property setting is never Null. If its value is 0, there are no objects in the collection.


ADO Enumerated Constants

 Copy code hover
[image]

ADO Enumerated Constants
Send feedback

To assist in debugging, the ADO enumerations list a value for each constant. However, this value is purely advisory, and may change from one release of ADO to another. Your code should only depend on the name, not the actual value, of each enumerated constant.

ADCPROP_ASYNCTHREADPRIORITY_ENUM | For an RDS Recordset object, specifies the execution priority of the asynchronous thread that retrieves data.
ADCPROP_AUTORECALC_ENUM | Specifies when the MSDataShape provider re-calculates aggregate and calculated columns in a hierarchical Recordset.
ADCPROP_UPDATECRITERIA_ENUM | Specifies which fields can be used to detect conflicts during an optimistic update of a row of the data source with a Recordset object.
ADCPROP_UPDATERESYNC_ENUM | Specifies whether the UpdateBatch method is followed by an implicit Resync method operation and if so, the scope of that operation.
AffectEnum | Specifies which records are affected by an operation.
BookmarkEnum | Specifies a bookmark indicating where the operation should begin.
CommandTypeEnum | Specifies how a command argument should be interpreted.
CompareEnum | Specifies the relative position of two records represented by their bookmarks.
ConnectModeEnum | Specifies the available permissions for modifying data in a Connection, opening a Record, or specifying values for the Mode property of the Record and Stream objects.
ConnectOptionEnum | Specifies whether the Open method of a Connection object should return after (synchronously) or before (asynchronously) the connection is established.
ConnectPromptEnum | Specifies whether a dialog box should be displayed to prompt for missing parameters when opening a connection to an ODBC data source.
CopyRecordOptionsEnum | Specifies the behavior of the CopyRecord method.
CursorLocationEnum | Specifies the location of the cursor engine.
CursorOptionEnum | Specifies what functionality the Supports method should test for.
CursorTypeEnum | Specifies the type of cursor used in a Recordset object.
DataTypeEnum | Specifies the data type of a Field, Parameter, or Property.
EditModeEnum | Specifies the editing status of a record.
ErrorValueEnum | Specifies the type of ADO run-time error.
EventReasonEnum | Specifies the reason that caused an event to occur.
EventStatusEnum | Specifies the current status of the execution of an event.
ExecuteOptionEnum | Specifies how a provider should execute a command.
FieldEnum | Specifies the special fields referenced in a Record object's Fields collection.
FieldAttributeEnum | Specifies one or more attributes of a Field object.
FieldStatusEnum | Specifies the status of a Field object.
FilterGroupEnum | Specifies the group of records to be filtered from a Recordset.
GetRowsOptionEnum | Specifies how many records to retrieve from a Recordset.
IsolationLevelEnum | Specifies the level of transaction isolation for a Connection object.
LineSeparatorsEnum | Specifies the character used as a line separator in text Stream objects.
LockTypeEnum | Specifies the type of lock placed on records during editing.
MarshalOptionsEnum | Specifies which records should be returned to the server.
MoveRecordOptionsEnum | Specifies the behavior of the Record object MoveRecord method.
ObjectStateEnum | Specifies whether an object is open or closed, connecting to a data source, executing a command, or fetching data.
ParameterAttributesEnum | Specifies the attributes of a Parameter object.
ParameterDirectionEnum | Specifies whether the Parameter represents an input parameter, an output parameter, or both, or if the parameter is the return value from a stored procedure.
PersistFormatEnum | Specifies the format in which to save a Recordset.
PositionEnum | Specifies the current position of the record pointer within a Recordset.
PropertyAttributesEnum | Specifies the attributes of a Property object.
RecordCreateOptionsEnum | Specifies for the Record object Open method whether an existing Record should be opened, or a new Record should be created.
RecordOpenOptionsEnum | Specifies options for opening a Record. These values may be combined by using an OR operator.
RecordStatusEnum | Specifies the status of a record with regard to batch updates and other bulk operations.
RecordTypeEnum | Specifies the type of Record object.
ResyncEnum | Specifies whether underlying values are overwritten by a call to Resync.
SaveOptionsEnum | Specifies whether a file should be created or overwritten when saving from a Stream object. The values can be combined with an AND operator.
SchemaEnum | Specifies the type of schema Recordset that the OpenSchema method retrieves. Specifies the direction of a record search within a Recordset.
SearchDirectionEnum | Specifies the direction of a record search within a Recordset.Specifies the type of Seek to execute.
SeekEnum | Specifies the type of Seek to execute.Specifies options for opening a Stream object. The values can be combined with an AND operator.
StreamOpenOptionsEnum | Specifies options for opening a Stream object. The values can be combined with an AND operator.Specifies whether the whole stream or the next line should be read from a Stream object.
StreamReadEnum | Specifies whether the whole stream or the next line should be read from a Stream object.Specifies the type of data stored in a Stream object.
StreamTypeEnum | Specifies the type of data stored in a Stream object.Specifies whether a line separator is appended to the string written to a Stream object.
StreamWriteEnum | Specifies whether a line separator is appended to the string written to a Stream object.Specifies the format when retrieving a Recordset as a string.
StringFormatEnum | Specifies the format when retrieving a Recordset as a string.Specifies the transaction attributes of a Connection object.
XactAttributeEnum | Specifies the transaction attributes of a Connection object.


Upper Function (Access 2013 custom web app)

 Copy code hover
[image]

Upper Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns a text expression with lowercase character data converted to uppercase.

Syntax

Upper(TextExpression)

The Upper function contains the following argument.

Argument name | Description
TextExpression | A text expression.


Axes Collection (ADO MD)

 Copy code hover
[image]

Axes Collection (ADO MD)
Send feedback

Contains the Axis objects that define a cellset.

Remarks

A Cellset object contains an Axes collection. Once the Cellset is opened, this collection will contain at least one Axis. See the Axis object for a more detailed explanation of how to use Axis objects.

Note Note

The filter axis of a Cellset is not contained in the Axes collection. See the FilterAxis property for more information.

Axes is a standard ADO collection. With the properties and methods of a collection, you can do the following:

  • Obtain the number of objects in the collection with the Count property.

  • Return an object from the collection with the default Item property.

  • Update the objects in the collection from the provider with the Refresh method.


Unable to change Column Level Tracking Property on objects that are already Replicable. (Error 3779)

 Copy code hover
[image]

Unable to change Column Level Tracking Property on objects that are already Replicable. (Error 3779)
Send feedback

Once an object is made replicable, the Column Level Tracking Property cannot be changed. If you want to change the tracking of the object, the object must be made local again. Then you can change the Column Level Tracking Property and make the object replicable again.


Transaction Processing

 Copy code hover
[image]

Transaction Processing
Send feedback

ADO provides the following methods for controlling transactions: BeginTrans, CommitTrans, and RollbackTrans. Use these methods with a Connection object when you want to save or cancel a series of changes made to the source data as a single unit. For example, to transfer money between accounts, you subtract an amount from one and add the same amount to the other. If either update fails, the accounts no longer balance. Making these changes within an open transaction ensures that either all or none of the changes go through.

Note Note

Not all providers support transactions. Verify that the provider-defined property "Transaction DDL" appears in the Connection object's Properties collection, indicating that the provider supports transactions. If the provider does not support transactions, calling one of these methods will return an error.

After you call the BeginTrans method, the provider will no longer instantaneously commit changes you make until you call CommitTrans or RollbackTrans to end the transaction.

Calling the CommitTrans method saves changes made within an open transaction on the connection and ends the transaction. Calling the RollbackTrans method reverses any changes made within an open transaction and ends the transaction. Calling either method when there is no open transaction generates an error.

Depending on the Connection object's Attributes property, calling either the CommitTrans or RollbackTrans method may automatically start a new transaction. If the Attributes property is set to adXactCommitRetaining, the provider automatically starts a new transaction after a CommitTrans call. If the Attributes property is set to adXactAbortRetaining, the provider automatically starts a new transaction after a RollbackTrans call.

Transaction Isolation Level

Use the IsolationLevel property to set the isolation level of a transaction on a Connection object. The setting does not take effect until the next time you call the BeginTrans method. If the level of isolation you request is unavailable, the provider may return the next greater level of isolation. Refer to the IsolationLevel property in the ADO Programmer's Reference for more details on valid values.

Nested Transactions

For providers that support nested transactions, calling the BeginTrans method within an open transaction starts a new, nested transaction. The return value indicates the level of nesting: a return value of "1" indicates you have opened a top-level transaction (that is, the transaction is not nested within another transaction), "2" indicates that you have opened a second-level transaction (a transaction nested within a top-level transaction), and so forth. Calling CommitTrans or RollbackTrans affects only the most recently opened transaction; you must close or roll back the current transaction before you can resolve any higher-level transactions.


Relations.Count Property (DAO)

 Copy code hover
[image]

Relations.Count Property (DAO)
Send feedback

Returns the number of objects in the specified collection. Read-only.

Syntax

expression .Count

expression A variable that represents a Relations object.

Remarks

Because members of a collection begin with 0, you should always code loops starting with the 0 member and ending with the value of the Count property minus 1. If you want to loop through the members of a collection without checking the Count property, you can use a For Each...Next command.

The Count property setting is never Null. If its value is 0, there are no objects in the collection.


GUIDs do not match or the requested GUID could not be found. (Error 3548)

 Copy code hover
[image]

GUIDs do not match or the requested GUID could not be found. (Error 3548)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


ListBox.SpecialEffect Property (Access)

 Copy code hover
[image]

ListBox.SpecialEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.

Syntax

expression .SpecialEffect

expression A variable that represents a ListBox object.

Remarks

The SpecialEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | 0 | The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised | 1 | The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken | 2 | The object has a shadow on the top and left and a highlight on the bottom and right.
Etched | 3 | The object has a sunken line surrounding the control.
Shadowed | 4 | The object has a shadow below and to the right of the control.
Chiseled | 5 | The object has a sunken line below the control.

The SpecialEffect property setting affects related property settings for the BorderStyle , BorderColor , and BorderWidth properties. For example, if the SpecialEffect property is set to Raised, the settings for the BorderStyle, BorderColor, and BorderWidth properties are ignored. In addition, changing or setting the BorderStyle, BorderColor, and BorderWidth properties may cause Microsoft Access to change the SpecialEffect property setting to Flat.

Example

The following example sets the appearance of the text box "OrganizationName1" on the "Mailing List" form to raised.

VBA Copy code Copy code
Forms("Mailing List").Controls("OrganizationName1").SpecialEffect = 1

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


DoCmd.BrowseTo Method (Access)

 Copy code hover
[image]

DoCmd.BrowseTo Method (Access)
See also Send feedback

Published: July 16, 2012

The BrowseTo method performs the BrowseTo action in Visual Basic.

Version Information

Version Added: Access 2010

Syntax

expression .BrowseTo(ObjectType, ObjectName, PathtoSubformControl, WhereCondition, Page, DataMode)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
ObjectType | Required | AcBrowseToObjectType | The object type to which to browse.
ObjectName | Required | Variant | The object that loads inside the subform control referenced by the PathtoSubformControl argument.
PathtoSubformControl | Optional | Variant | If specified, the path from the main form of the application to the target subform control that loads the object specified by the ObjectName argument.
WhereCondition | Optional | Variant | If specified, replaces the Where condition of the object record source.
Page | Optional | Variant | If specified, sets the page of the continuous form that will be made the current page. This argument is Web only.
DataMode | Optional | AcFormOpenDataMode | If specified, the data entry mode of the form.

Remarks

Use the BrowseTo method to navigate between objects in place. You can also change the source object of a subform control by specifying the PathToSubFormControl argument. You can use BrowseTo to navigate from form1 to form2 without opening up a new window.

The PathToSubFormControl argument must be specified using the syntax in the following example:

Main Form.SubForm Ctrl 1>Form 2.SubForm Ctrl 2>Form 3.SubFormCtrl3

In this example, the Main Form is the top level form in the Access client application. The PathToSubFormControl argument must alternately specify form and subform control names leading from the main form to the subform control that is the container of the object specified by the ObjectName argument. Each subform control specified must be a control on the form that precedes it. The path must end with a subform control.

Example

The following code example opens the "EventDS" form in place in edit mode in the "NavigationSubform" subform control of the "Main" form.

VBA Copy code Copy code
DoCmd.BrowseTo ObjectType:=acBrowseToForm, _
ObjectName:="EventDS", _
PathToSubformControl:="Main.NavigationSubform", _
WhereCondition:="", _
Page:="", _
DataMode:=acFormEdit

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


OLE DB Providers (ADO)

 Copy code hover
[image]

OLE DB Providers (ADO)
Send feedback

In this section

  • OLE DB Providers

  • Data Providers

  • Service Providers and Components


Recordset.OpenRecordset Method (DAO)

 Copy code hover
[image]

Recordset.OpenRecordset Method (DAO)
Send feedback

Creates a new Recordset object and appends it to the Recordsets collection.

Syntax

expression .OpenRecordset(Type, Options)

expression A variable that represents a Recordset object.

Parameters

Name

Required/Optional

Data Type

Description

Name

Required

String

The source of the records for the new Recordset. The source can be a table name, a query name, or an SQL statement that returns records. For table-type Recordset objects in Microsoft Access database engine databases, the source can only be a table name.

Type

Optional

Variant

A RecordsetTypeEnum constant that indicates the type of Recordset to open.

Note Note

If you open a Recordset in a Microsoft Access workspace and you don't specify a type, OpenRecordset creates a table-type Recordset, if possible. If you specify a linked table or query, OpenRecordset creates a dynaset-type Recordset.

Options

Optional

Variant

A combination of RecordsetOptionEnum constants that specify characteristics of the new Recordset.

Note Note

The constants dbConsistent and dbInconsistent are mutually exclusive, and using both causes an error. Supplying a lockedits argument when options uses the dbReadOnly constant also causes an error.

LockEdit

Optional

Variant

A LockTypeEnum constant that determines the locking for the Recordset.

Note Note

You can use dbReadOnly in either the options argument or the lockedits argument, but not both. If you use it for both arguments, a run-time error occurs.

Return Value

Recordset

Remarks

Typically, if the user gets this error while updating a record, your code should refresh the contents of the fields and retrieve the newly modified values. If the error occurs while deleting a record, your code could display the new record data to the user and a message indicating that the data has recently changed. At this point, your code can request a confirmation that the user still wants to delete the record.

You should also use the dbSeeChanges constant if you open a Recordset in a Microsoft Access database engine-connected ODBC workspace against a Microsoft SQL Server 6.0 (or later) table that has an IDENTITY column, otherwise an error may result.

Opening more than one Recordset on an ODBC data source may fail because the connection is busy with a prior OpenRecordset call. One way around this is to fully populate the Recordset by using the MoveLast method as soon as the Recordset is opened.

Closing a Recordset with the Close method automatically deletes it from the Recordsets collection.

Note Note

If source refers to an SQL statement composed of a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strSQL = "PRICE > " & lngPrice, and lngPrice = 125,50), an error occurs when you try to open the Recordset. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and SQL only accepts U.S. decimal characters.


ComboBox.Click Event (Access)

 Copy code hover
[image]

ComboBox.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Syntax

expression .Click

expression A variable that represents a ComboBox object.

Remarks

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • The user commits a change to the value of the combo box. In this case, the Click event fires after the AfterUpdate event and before the Exit event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Recordset2.BatchCollisions Property (DAO)

 Copy code hover
[image]

Recordset2.BatchCollisions Property (DAO)
Send feedback

Syntax

expression .BatchCollisions

expression A variable that represents a Recordset2 object.

Remarks

This property contains an array of bookmarks to rows that encountered a collision during the last attempted batch Update call. The BatchCollisionCount property indicates the number of elements in the array.

If you set the working Recordset object's Bookmark property to bookmark values in the BatchCollisions array, you can move to each record that failed to complete the most recent batch-mode Update operation.

After the collision records are corrected, you can call the batch mode Update method again. At this point DAO attempts another batch update, and the BatchCollisions property again reflects the set of records that failed the second attempt. Any records that succeeded in the previous attempt are not sent in the current attempt, as they now have a RecordStatus property of dbRecordUnmodified. This process can continue as long as collisions occur, or until you abandon the updates and close the result set.

This array is re-created each time you execute a batch-mode Update method.


ToggleButton.OnDblClick Property (Access)

 Copy code hover
[image]

ToggleButton.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Syntax

expression .OnDblClick

expression A variable that represents a ToggleButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_DblClick" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Field

 Copy code hover
[image]

Field <name> is based on an expression and cannot be edited. (Error 3327)
Send feedback

For example, if a stored query or view with a column made up of an expression was created, you would not be able to update that column. The following would return this error: CREATE VIEW VCustomer AS SELECT (FirstName & LastName) AS Test FROM Customer followed by UPDATE Test FROM VCustomer


Check Box Control

 Copy code hover
[image]

Check Box Control
Send feedback

Published: July 16, 2012

A check box on a form or report is a stand-alone control that display a Yes/No value from an underlying record source.

Remarks

When you select or clear a check box that's bound to a Yes/No field, Microsoft Access displays the value in the underlying table according to the field's Format property (Yes/No, True/False, or On/Off).

You can also use check boxes in an option group to display values to choose from.

It's also possible to use an unbound check box in a custom dialog box to accept user input.


Form.BeforeQuery Event (Access)

 Copy code hover
[image]

Form.BeforeQuery Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when the specified PivotTable view queries its data source.

Syntax

expression .BeforeQuery

expression A variable that represents a Form object.

Return Value

nothing

Remarks

This event occurs quite frequently. Some examples of actions that trigger this event include adding fields to the PivotTable view, moving fields, sorting, or filtering data.

Example

The following example demonstrates the syntax for a subroutine that traps the BeforeQuery event.

VBA Copy code Copy code
Private Sub Form_BeforeQuery()
 MsgBox "The PivotTable view is about to query its data source."
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Field2.Required Property (DAO)

 Copy code hover
[image]

Field2.Required Property (DAO)
Send feedback

Sets or returns a value that indicates whether a Field2 object requires a non-Null value.

Syntax

expression .Required

expression A variable that represents a Field2 object.

Remarks

For a Field2 not yet appended to the Fields collection, this property is read/write.

The availability of the Required property depends on the object that contains the Fields collection, as shown in the following table.

If the Fields collection belongs to a | Then Required is
Index object | Not supported
QueryDef object | Read-only
Recordset object | Read-only
Relation object | Not supported
TableDef object | Read/write

You can use the Required property along with the AllowZeroLength, ValidateOnSet, or ValidationRule property to determine the validity of the Value property setting for that Field2 object. If the Required property is set to False, the field can contain null values as well as values that meet the conditions specified by the AllowZeroLength and ValidationRule property settings.

Note Note

When you can set this property for either an Index object or a Field2 object, set it for the Field2 object. The validity of the property setting for a Field2 object is checked before that of an Index object.

Example

This example uses the Required property to report which fields in three different tables must contain data in order for a new record to be added. The RequiredOutput procedure is required for this procedure to run.

VBA Copy code Copy code
Sub RequiredX()

 Dim dbsNorthwind As Database
 Dim tdfloop As TableDef

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind
 ' Show which fields are required in the Fields
 ' collections of three different TableDef objects.
 RequiredOutput .TableDefs("Categories")
 RequiredOutput .TableDefs("Customers")
 RequiredOutput .TableDefs("Employees")
 .Close
 End With

End Sub

Sub RequiredOutput(tdfTemp As TableDef)

 Dim fldLoop As Field2

 ' Enumerate Fields collection of the specified TableDef
 ' and show the Required property.
 Debug.Print "Fields in " & tdfTemp.Name & ":"
 For Each fldLoop In tdfTemp.Fields
 Debug.Print , fldLoop.Name & ", Required = " & _
 fldLoop.Required
 Next fldLoop

End Sub


TextBox.FuriganaControl Property (Access)

 Copy code hover
[image]

TextBox.FuriganaControl Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .FuriganaControl

expression A variable that represents a TextBox object.

Remarks

The setting value is the name of the control for entering furigana.

If the FuriganaControl property is set in the control, furigana will automatically be created, and can be displayed in a separately designated control. Only if a control name in the same form is set with the FuriganaControl property will the form run properly when executed. If text is entered in a control other than the designated control name in the same form, an error will occur. The type of furigana characters is determined by the IMEMode/KanjiConversionMode property settings in the control.

FuriganaControl property in ADP

When you use FuriganaControl property in ADP file, be sure to change the data type from CHAR/NCHAR to VARCHAR/NVARCHR. Otherwise, you cannot insert any furigana string into the target field. The FuriganaControl property inserts furigana strings to an existing target field, but if the data type definition of the field stays as CHAR/NCHAR, any string insertion fails because the field length is fixed, which result in an error message.

Note Note

If you enter text in the target control, the furigana of the newly entered text is automatically added to the end of the designated target control content. Even if the text of the target control is revised or deleted, the characters before the change in the target control will not be revised or deleted. Changing the content of the target control revises the text in the furigana control as necessary. The FuriganaControl property will not run if text is pasted into the target control.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Field (Visual C++ Syntax Index with #import)

 Copy code hover
[image]

Field (Visual C++ Syntax Index with #import)
Send feedback

Methods

Copy code Copy code

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthappchunk_HV10294090.xml( const _variant_t & Data );

_variant_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthgetchunk_HV10294391.xml( long Length );

Properties

Copy code Copy code

long GetActualSize( );
__declspec(property(get=GetActualSize)) long Invalid DDUE based on source, error:link not allowed in code, link filename:mdproactualsize_HV10293998.xml;

long GetAttributes( );
void PutAttributes( long pl );
__declspec(property(get=GetAttributes,put=PutAttributes)) long Invalid DDUE based on source, error:link not allowed in code, link filename:mdproattributes_HV10294098.xml;

IUnknownPtr GetDataFormat( );
void PutRefDataFormat( IUnknown * ppiDF );
__declspec(property(get=GetDataFormat,put=PutRefDataFormat)) IunknownPtr
 DataFormat;

long GetDefinedSize( );
void PutDefinedSize( long pl );
__declspec(property(get=GetDefinedSize,put=PutDefinedSize)) long
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdprodefinedsize_HV10294289.xml;

_bstr_t GetName( );
__declspec(property(get=GetName)) _bstr_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdproname_HV10294535.xml;

unsigned char GetNumericScale( );
void PutNumericScale( unsigned char pbNumericScale );
__declspec(property(get=GetNumericScale,put=PutNumericScale)) unsigned
 char Invalid DDUE based on source, error:link not allowed in code, link filename:mdpronumericscale_HV10294551.xml;

_variant_t GetOriginalValue( );
__declspec(property(get=GetOriginalValue)) _variant_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdprooriginalvalue_HV10294583.xml;

unsigned char GetPrecision( );
void PutPrecision( unsigned char pbPrecision );
__declspec(property(get=GetPrecision,put=PutPrecision)) unsigned char
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdproprecision_HV10294615.xml;

enum DataTypeEnum GetType( );
void PutType( enum DataTypeEnum pDataType );
__declspec(property(get=GetType,put=PutType)) enum DataTypeEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdprotype_HV10294866.xml;

_variant_t GetUnderlyingValue( );
__declspec(property(get=GetUnderlyingValue)) _variant_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdprounderlyingvalue_HV10294879.xml;

_variant_t GetValue( );
void PutValue( const _variant_t & pvar );
__declspec(property(get=GetValue,put=PutValue)) _variant_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdprovalue_HV10294920.xml;


Label.BorderTint Property (Access)

 Copy code hover
[image]

Label.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderTint

expression A variable that represents a Label object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

Label Object

Other resources

Label Object Members


Attachment.PictureSizeMode Property (Access)

 Copy code hover
[image]

Attachment.PictureSizeMode Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureSizeMode property to specify how a picture for an attachment control is sized. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .PictureSizeMode

expression A variable that represents an Attachment object.

Remarks

The PictureSizeMode property uses the following settings.

Setting | Visual Basic | Description
Clip | 0 | (Default) The picture is displayed in its actual size. If the picture is larger than the attachment control, then the picture is clipped.
Stretch | 1 | The picture is stretched horizontally and vertically to fill the entire attachment control, even if its original ratio of height to width is distorted.
Zoom | 3 | The picture is enlarged to the maximum extent possible while keeping its original ratio of height to width.

When a small picture is used for the DefaultPicture property of an attachment control, setting the PictureSizeMode property to Stretch or Zoom can cause substantial distortion of its resolution. Smaller pictures can be tiled across the entire attachment control by using the PictureTiling property.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


TabControl.HoverShade Property (Access)

 Copy code hover
[image]

TabControl.HoverShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the HoverColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .HoverShade

expression A variable that represents a TabControl object.

Remarks

The HoverShade property contains a numeric expression that can be used to darken the theme color in the HoverColor property. The default value of the HoverShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


How to: Move Through a DAO Recordset

 Copy code hover
[image]

How to: Move Through a DAO Recordset
Send feedback

A Recordset object usually has a current position, most often at a record. When you refer to the fields in a Recordset, you obtain values from the record at the current position, which is known as the current record. However, the current position can also be immediately before the first record in a Recordset or immediately after the last record. In certain circumstances, the current position is undefined.

You can use the following Move methods to loop through the records in a Recordset:

  • The MoveFirst method moves to the first record.

  • The MoveLast method moves to the last record.

  • The MoveNext method moves to the next record.

  • The MovePrevious method moves to the previous record.

  • The Move method moves forward or backward the number of records you specify in its syntax.

You can use each of these methods on table-type, dynaset-type, and snapshot-type Recordset objects. On a forward-only-type Recordset object, you can use only the MoveNext and Move methods. If you use the Move method on a forward-only-type Recordset, the argument specifying the number of rows to move must be a positive integer.

The following code example opens a Recordset object on the Employees table containing all of the records that have a Null value in the ReportsTo field. The function then updates the records to indicate that these employees are temporary employees. For each record in the Recordset, the example changes the Title and Notes fields, and saves the changes with the Update method. It uses the MoveNext method to move to the next record.

VBA Copy code Copy code
Sub UpdateEmployees()

Dim dbsNorthwind As DAO.Database
Dim rstEmployees As DAO.Recordset
Dim strSQL As String
Dim intI As Integer

On Error GoTo ErrorHandler

   Set dbsNorthwind = CurrentDb

   ' Open a recordset on all records from the Employees table that have
   ' a Null value in the ReportsTo field.
   strSQL = "SELECT * FROM Employees WHERE ReportsTo IS NULL"
   Set rstEmployees = dbsNorthwind.OpenRecordset(strSQL, dbOpenDynaset)

   ' If the recordset is empty, exit.
   If rstEmployees.EOF Then Exit Sub

   intI = 1
   With rstEmployees
      Do Until .EOF
         .Edit
         ![ReportsTo] = 5
         ![Title] = "Temporary"
         ![Notes] = rstEmployees![Notes] & "Temp #" & intI
         .Update
         .MoveNext
         intI = intI + 1
      Loop
   End With

   RstEmployees.Close
   dbsNorthwind.Close

   Set rstEmployees = Nothing
   Set dbsNorthwind = Nothing

   Exit Sub

ErrorHandler:
   MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Sub
Note Note

The previous example is provided only for the purposes of illustrating the Update and MoveNext methods. For optimal performance, it is recommended that you perform this bulk operation with a SQL UPDATE query.


DependencyObjects Properties (Access)

 Copy code hover
[image]

DependencyObjects Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


The LEVEL clause includes a reserved word or argument that is misspelled or missing, or the punctuation is incorrect. (Error 3136)

 Copy code hover
[image]

The LEVEL clause includes a reserved word or argument that is misspelled or missing, or the punctuation is incorrect. (Error 3136)
Send feedback

You entered an SQL statement that has an invalid reserved word clause.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


CurrentData.AllTables Property (Access)

 Copy code hover
[image]

CurrentData.AllTables Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllTables property to reference the AllTables collection and its related properties. Read-only AllTables object.

Syntax

expression .AllTables

expression A variable that represents a CurrentData object.

See also

Concepts

CurrentData Object

Other resources

CurrentData Object Members


NavigationButton.InSelection Property (Access)

 Copy code hover
[image]

NavigationButton.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .InSelection

expression A variable that represents a NavigationButton object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


How to: Use Transactions in a DAO Recordset

 Copy code hover
[image]

How to: Use Transactions in a DAO Recordset
Send feedback

A transaction is a set of operations bundled together and handled as a single unit of work. The work in a transaction must be completed as a whole; if any part of the transaction fails, the entire transaction fails. Transactions offer the developer the ability to enforce data integrity. With multiple database operations bundled into a single unit that must succeed or fail as a whole, the database cannot reach an inconsistent state. Transactions are common to most database management systems.

The most common example of transaction processing involves a bank's automated teller machine (ATM). The processes of dispensing cash and then debiting the user's account are considered a logical unit of work and are wrapped in a transaction: The cash is not dispensed unless the system is also able to debit the account. By using a transaction, the entire operation either succeeds or fails. This maintains the consistent state of the ATM database.

You should consider using transactions if you want to make sure that each operation in a group of operations is successful before all operations are committed. Keep in mind that all transactions are invisible to other transactions. That is, no transaction can see another transaction's updates to the database until the transaction is committed.

Note Note

The behavior of transactions with Access databases differs from the behavior of ODBC data sources, such as Microsoft SQL Server. For example, if a database is connected to a file server, and the file server stops before a transaction has had time to commit its changes, then your database could be left in an inconsistent state. If you require true transaction support with respect to durability, you should investigate using a client/server architecture.

The Microsoft Access databse engine supports transactions through the DAO BeginTrans, CommitTrans, and Rollback methods of the Workspace object.

The following code example changes the job title of all sales representatives in the Employees table. After the BeginTrans method starts a transaction that isolates all of the changes made to the Employees table, the CommitTrans method saves the changes. Be aware that you can use the Rollback method to undo changes that you saved with the Update method.

VBA Copy code Copy code
Sub ChangeTitle()

Dim wrkCurrent As DAO.Workspace
Dim dbsNorthwind As DAO.Database
Dim rstEmployee As DAO.Recordset

On Error GoTo ErrorHandler

   Set wrkCurrent = DBEngine.Workspaces(0)
   Set dbsNorthwind = CurrentDB
   Set rstEmployee = dbsNorthwind.OpenRecordset("Employees")

   wrkCurrent.BeginTrans
   Do Until rstEmployee.EOF
      If rstEmployee!Title = "Sales Representative" Then
         rstEmployee.Edit
         rstEmloyee!Title = "Sales Associate"
         rstEmployee.Update
      End If
      rstEmployee.MoveNext
   Loop

   If MsgBox("Save all changes?", vbQuestion + vbYesNo) = vbYes Then
      wrkCurrent.CommitTrans
   Else
      wrkCurrent.Rollback
   End If

   rstEmployee.Close
   dbsNorthwind.Close
   wrkCurrent.Close

   Set rstEmployee = nothing
   Set dbsNorthwind = Nothing
   Set wrkCurrent = Nothing

   Exit Sub

ErrorHandler:
   MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Sub

When you use transactions, all databases and Recordset objects in the specified Workspace object are affected; transactions are global to the workspace, not to a specific database or Recordset. If you perform operations on more than one database or within a workspace transaction, the Commit and Rollback methods affect all the objects changed within that workspace during the transaction.

You can also use the BeginTrans, CommitTrans, and Rollback methods with the DBEngine object. In this case, the transaction is applied to the default workspace, which is DBEngine.Workspaces(0).


BoundObjectFrame.OldBorderStyle Property (Access)

 Copy code hover
[image]

BoundObjectFrame.OldBorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.

Syntax

expression .OldBorderStyle

expression A variable that represents a BoundObjectFrame object.

Remarks

The OldBorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines
Note Note

  • If the OldBorderStyle property is set to None or Dialog, the form doesn't have Maximize or Minimize buttons, regardless of its MinMaxButtons property setting.

  • If the OldBorderStyle property is set to None, the form doesn't have a Control menu, regardless of its ControlBox property setting.

  • The OldBorderStyle property setting doesn't affect the display of the scroll bars, navigation buttons, the record number box, or record selectors.

Example

The following example demonstrates the effect of changing a control's BorderStyle property, while leaving the OldBorderStyle unaffected. The example concludes with setting the BorderStyle property to its original unedited value.

VBA Copy code Copy code
With Forms("Order Entry").Controls("Zip Code") .BorderStyle = 3 ' Short dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 3, 1.

    .BorderStyle = 2 ' Dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 2, 1

    .BorderStyle = .OldBorderStyle ' Solid (default) border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 1, 1
End With

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


DataSpace Object (RDS)

 Copy code hover
[image]

DataSpace Object (RDS)
Send feedback

Creates client-side proxies to custom business objects located on the middle tier.

Remarks

Remote Data Service needs business object proxies so that client-side component can communicate with business objects located on the middle tier. Proxies facilitate the packaging, unpackaging, and transport (marshaling) of the application's Recordset data across process or machine boundaries.

Remote Data Service uses the RDS.DataSpace object's CreateObject method to create business object proxies. The business object proxy is dynamically created whenever an instance of its middle-tier business object counterpart is created. Remote Data Service supports the following protocols: HTTP, HTTPS (HTTP Secure Sockets), DCOM, and in-process (client components and the business object reside on the same computer).

Note Note

RDS behaves in a "stateless" manner when the RDS.DataSpace object uses the HTTP or HTTPS protocols. That is, any internal information about a client request is discarded after the server returns a response.

Although the business object appears to exist for the lifetime of the business object proxy, the business object actually exists only until a response is sent to a request. When a request is issued (that is, a method is invoked on the business object), the proxy opens a new connection to the server and the server creates a new instance of the business object. After the business object responds to the request, the server destroys the business object and closes the connection.

This behavior means you cannot pass data from one request to another using a business object property or variable. You must employ some other mechanism, such as a file or a method argument, to persist state data.

The class ID for the RDS.DataSpace object is BD96C556-65A3-11D0-983A-00C04FC29E36.


SubForm.GridlineTint Property (Access)

 Copy code hover
[image]

SubForm.GridlineTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineTint

expression A variable that represents a SubForm object.

Remarks

The GridlineTint property contains a numeric expression that can be used to lighten the theme color in the GridlineColor property. The default value of the GridlineTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


TableDef.ValidationRule Property (DAO)

 Copy code hover
[image]

TableDef.ValidationRule Property (DAO)
Send feedback

Sets or returns a value that validates the data in a field as it's changed or added to a table (Microsoft Access workspaces only).Read/write String.

Syntax

expression .ValidationRule

expression A variable that represents a TableDef object.

Remarks

The settings or return values is a String that describes a comparison in the form of an SQL WHERE clause without the WHERE reserved word. For an object not yet appended to the Fields collection, this property is read/write.

The ValidationRule property determines whether or not a field contains valid data. If the data is not valid, a trappable run-time error occurs. The returned error message is the text of the ValidationText property, if specified, or the text of the expression specified by ValidationRule.

Validation is supported only for databases that use the Microsoft Access database engine.

The string expression specified by the ValidationRule property of a Field object can refer only to that Field. The expression can't refer to user-defined functions, SQL aggregate functions, or queries. To set a Field object's ValidationRule property when its ValidateOnSet property setting is True, the expression must successfully parse (with the field name as an implied operand) and evaluate to True. If its ValidateOnSet property setting is False, the ValidationRule property setting is ignored.

The ValidationRule property of a Recordset or TableDef object can refer to multiple fields in that object. The restrictions noted earlier in this topic for the Field object apply.

For a TableDef object based on an linked table, the ValidationRule property inherits the ValidationRule property setting of the underlying base table. If the underlying base table doesn't support validation, the value of this property is a zero-length string ("").

Note Note

If you set the property to a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strRule = "PRICE > " & lngPrice, and lngPrice = 125,50), an error will result when your code attempts to validate any data. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and Microsoft Access SQL only accepts U.S. decimal characters.


How to: Apply a Custom Ribbon to a Form or Report

 Copy code hover
[image]

How to: Apply a Custom Ribbon to a Form or Report
Send feedback

The ribbon uses text-based, declarative XML markup that simplifies creating and customizing the ribbon. With a few lines of XML, you can create just the right interface for the user. Access provides flexibility in customizing the ribbon user interface. For example, customization markup can be stored in a table, embedded in a VBA procedure, stored in another Access database, or linked to from an Excel worksheet. This topic describes how to apply customized ribbons when loading a form or report.

Making the Ribbon Customization XML Available

Storing Ribbon Extensibility XML in a Table

One method that you can use to make ribbon customizations available is to store them in a table. If you store the customizations in a table named USysRibbons, the customizations can be implemented without using macros or VBA code.

USysRibbons is a user-created system table. The table must be created using specific column names in order for the ribbon customizations to be implemented. The following table lists the settings to use when creating the USysRibbons table.

Column Name | Data Type | Description
RibbonName | Text | Contains the name of the custom ribbon to be associated with this customization
RibbonXML | Memo | Contains the ribbon Extensibility XML (RibbonX) that defines the ribbon customization

Loading Ribbon Extensibility XML Programmatically

You can use the LoadCustomUI method to load ribbon customizations programmatically. Typically, to create and make the ribbon available to the application, you first create a module in the database with a procedure that calls the LoadCustomUI method, passing in the name of the ribbon and the XML customization markup.

The XML markup can come from a Recordset object created from a table, from a source external to the database such as an XML file that you parse into a string, or from XML markup embedded directly inside the procedure. You can make different ribbons using multiple calls to the LoadCustomUI method, passing in different XML markup as long as the name of each ribbon and the id attribute of the tabs that make up the ribbon are unique.

After the procedure is complete, you then create an AutoExec macro that calls the procedure by using the RunCode action. That way, when the application is started, the LoadCustomUI method is automatically executed and all of the custom ribbons are made available to the application.

Assigning Custom Ribbons to Forms or Reports

  1. Follow the process described previously to make the customized ribbon available to the application.

  2. Open the form or report in Design view.

  3. On the Design tab, click Property Sheet.

  4. On the All tab of the Property window, click the Ribbon Name list and then select a ribbon.

  5. Save, close, and then reopen the form or report. The ribbon UI you selected is displayed.

Note Note

The tabs displayed in the ribbon UI are additive. That is, unless you specifically hide the tabs or set the Start from Scratch attribute to True, the tabs displayed in a form's or report's ribbon user interface are in addition to the existing tabs.
Note Note

For more information about the ribbon UI in other Office applications, see Overview of the Office Fluent Ribbon.


Axis Example (VBScript)

 Copy code hover
[image]

Axis Example (VBScript)
Send feedback

This Active Server Page displays OLAP data from an MDX Query string and writes the resulting cellset to an HTML table structure.

VBS Copy code Copy code

<%@ Language=VBScript %>
<%
'************************************************************************
'*** Active Server Page displays OLAP data from default
'*** MDX Query string and writes resulting cell set to HTML table
'*** structure.
'************************************************************************
Response.Buffer=True
Response.Expires=0
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY bgcolor=Ivory>
<FONT FACE=Verdana>

<%

Dim cat,cst,i,j,strSource,csw,intDC0,intDC1,intPC0,intPC1

'************************************************************************
'*** Set Connection Objects for Multidimensional Catalog and Cellset
'************************************************************************
Set cat = Server.CreateObject("ADOMD.Catalog")
Set cst = Server.CreateObject("ADOMD.CellSet")

'************************************************************************
'*** Use default settings of a known OLAP Server
'*** for Server Name for Connection Set Server Name Session Object
'*** to default value
'************************************************************************
'*** Must set OLAPServerName to OLAP Server that is
'*** present on network
'************************************************************************
   OLAPServerName = "Please set to present OLAP Server"
   cat.ActiveConnection = "Data Source='" & OLAPServerName & _
      "';Initial Catalog='FoodMart';Provider='msolap';"

'************************************************************************
'*** Use default MDX Query string of a known query that works
'*** with default server Set MDXQuery Session Object to default value
'************************************************************************
   strSource = strSource & "SELECT "
   strSource = strSource & "{[Measures].members} ON COLUMNS,"
   strSource = strSource & _
      "NON EMPTY [Store].[Store City].members ON ROWS"
   strSource = strSource & " FROM Sales"

'************************************************************************
'*** Set Cell Set Source property to strSource to be passed on cell set '*** open method
'************************************************************************
    cst.Source = strSource

'************************************************************************
'*** Set Cell Sets Active connection to use the current Catalogs Active
'*** connection
'************************************************************************
Set cst.ActiveConnection = cat.ActiveConnection

'************************************************************************
'*** Using Open method, Open cell set
'************************************************************************
cst.Open

'************************************************************************
'*** Set Dimension Counts minus 1 for Both Axes to intDC0, intDC1
'*** Set Position Counts minus 1 for Both Axes to intPC0, intPC1
'************************************************************************
intDC0 = cst.Axes(0).DimensionCount-1
intDC1 = cst.Axes(1).DimensionCount-1

intPC0 = cst.Axes(0).Positions.Count - 1
intPC1 = cst.Axes(1).Positions.Count - 1

'************************************************************************
'*** Create HTML Table structure to hold MDX Query return Record set
'************************************************************************
      Response.Write "<Table width=100% border=1>"

'************************************************************************
'*** Loop to create Column header
'************************************************************************
      For h=0 to intDC0
         Response.Write "<TR>"

'************************************************************************
'*** Loop to create spaces in front of Column headers
'*** to align with Row header
'************************************************************************
         For c=0 to intDC1
            Response.Write "<TD></TD>"
         Next

'************************************************************************
'*** Iterate through Axes(0) Positions writing member captions to table
'*** header
'************************************************************************
         For i = 0 To intPC0
            Response.Write "<TH>"
            Response.Write "<FONT size=-2>"
            Response.Write cst.Axes(0).Positions(i).Members(h).Caption
            Response.Write "</FONT>"
            Response.Write "</TH>"
         Next
         Response.Write "</TR>"
      Next
'************************************************************************
'*** Use Array values for row header formatting to provide
'*** spaces under beginning row header titles
'************************************************************************
      For j = 0 To intPC1
         Response.Write "<TR>"
         For h=0 to intDC1
            Response.Write "<TD><B>"
            Response.Write "<FONT size=-2>"
            Response.Write cst.Axes(1).Positions(j).Members(h).Caption
            Response.Write "</FONT>"
            Response.Write "</B></TD>"
         Next
         For k = 0 To intPC0
            Response.Write "<TD align=right bgcolor="
            Response.Write csw
            Response.Write ">"
            Response.Write "<FONT size=-2>"
            Response.Write cst(k, j).FormattedValue
            Response.Write "</FONT>"
            Response.Write "</TD>"
         Next
         Response.Write "</TR>"
      Next
      Response.Write "</Table>"

%>
</FONT>
</BODY>
</HTML>


Page.Click Event (Access)

 Copy code hover
[image]

Page.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Syntax

expression .Click

expression A variable that represents a Page object.

Remarks

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

Page Object

Other resources

Page Object Members


State Property Example (VJ++)

 Copy code hover
[image]

State Property Example (VJ++)
Send feedback

This example uses the State property to display a message while asynchronous connections are opening and asynchronous commands are executing.

Copy code Copy code

// BeginStateJ
import com.ms.wfc.data.*;
import java.io.*;

public class StateX
{
 // The main entry point of the application.
 public static void main (String[] args)
 {
 StateX();
 System.exit(0);
 }
 // StateX Function
 static void StateX()
 {
 // Define ADO Objects.
 Connection cnn1 = null;
 Connection cnn2 = null;
 Command cmdChange = null;
 Command cmdRestore = null;

 // Declarations.
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"+
 "Initial Catalog='Pubs';Integrated Security='SSPI';";
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));

 try
 {
 // Open two Asynchronous connections, displaying
 // a message while connecting.
 cnn1 = new Connection();
 cnn2 = new Connection();

 cnn1.open(strCnn,"","",AdoEnums.ConnectOption.ASYNCCONNECT);
 while(cnn1.getState()==AdoEnums.ObjectState.CONNECTING)
 System.out.println("Opening the first connection....");

 cnn2.open(strCnn,"","",AdoEnums.ConnectOption.ASYNCCONNECT);
 while(cnn2.getState()==AdoEnums.ObjectState.CONNECTING)
 System.out.println("Opening the second connection....");

 // Create two command Objects.
 cmdChange = new Command();
 cmdChange.setActiveConnection(cnn1);
 cmdChange.setCommandText("UPDATE Titles SET type = 'self_help'"+
 "WHERE type = 'psychology'");

 cmdRestore = new Command();
 cmdRestore.setActiveConnection(cnn2);
 cmdRestore.setCommandText(
 "UPDATE Titles SET type = 'psychology'"+
 "WHERE type = 'self_help'");

 // Executing the commands, displaying a message
 // while they are executing.
 cmdChange.execute(null,AdoEnums.ExecuteOption.ASYNCEXECUTE);

 while(cmdChange.getState() == AdoEnums.ObjectState.EXECUTING)
 System.out.println("Change command executing....");

 cmdRestore.execute(null,AdoEnums.ExecuteOption.ASYNCEXECUTE);

 while(cmdRestore.getState() == AdoEnums.ObjectState.EXECUTING)
 System.out.println("Restore command executing....");

 System.out.println("Press <Enter> to continue..");
 in.readLine();
 }
 // System read requires this catch.
 catch(java.io.IOException je)
 {
 PrintIOError(je);
 }
 catch(AdoException ae)
 {
 // Notify user of any errors resulting from ADO.

 // As passing a connection, check for null pointer first.
 if(cnn1 != null)
 {
 System.out.println("The error has occured in cnn1:");
 PrintProviderError(cnn1);
 }
 else if(cnn2 != null)
 {
 System.out.println("The error has occured in cnn2:");
 PrintProviderError(cnn2);
 }
 else
 {
 System.out.println("Exception: "+ ae.getMessage());
 }
 }

 finally
 {
 // Cleanup objects before exit.
 if (cnn1 != null)
 if (cnn1.getState() == 1)
 cnn1.close();
 if (cnn2 != null)
 if (cnn2.getState() == 1)
 cnn2.close();
 }

 }
 // PrintProviderError Function
 static void PrintProviderError(Connection cnn1)
 {
 // Print Provider Errors from Connection Object.
 // ErrItem is an item object in the Connections Errors Collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if ( nCount > 0)
 {
 // Collection ranges from 0 to nCount-1.
 for ( i=0;i<nCount; i++)
 {
 ErrItem = cnn1.getErrors().getItem(i);
 System.out.println("\t Error Number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription());
 }
 }
 }
 // PrintIOError Function
 static void PrintIOError(java.io.IOException je)
 {
 System.out.println("Error: \n");
 System.out.println("\t Source: " + je.getClass() + "\n");
 System.out.println("\t Description: "+ je.getMessage() + "\n");
 }
}
// EndStateJ


CustomControl.VarOleObject Property (Access)

 Copy code hover
[image]

CustomControl.VarOleObject Property (Access)
See also Send feedback

Published: July 16, 2012

Gets a pointer to an IOLEObject that represents the memory address of an OLE object. Read-only Variant.

Version Information

Version Added: Access 2010

Syntax

expression .VarOleObject

expression A variable that represents a CustomControl object.

Remarks

Note Note

The VarOleObject property is compatible with 32-bit and 64-bit OLE objects. It replaces the LpOLEObject, which was available in earlier versions of Microsoft Access.

You can use the VarOleObject property to refer to the address of the active OLE object. If no object is displayed, the setting is 0.

This property setting is not available in Design view and is read-only in other views.

In the OLE dynamic link libraries (DLLs), many function calls require the address of the OLE object as an argument. You can pass the value specified by the VarOleObject property when you make application programming interface (API) calls to the OLE DLLs.

If an API call is made to a function that performs a callback to the control, the results are unpredictable.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


CodeProject.AddSharedImage Method (Access)

 Copy code hover
[image]

CodeProject.AddSharedImage Method (Access)
See also Send feedback

Published: July 16, 2012

Imports the specified image into the database and adds it to the SharedResources collection.

Version Information

Version Added: Access 2010

Syntax

expression .AddSharedImage(SharedImageName, FileName)

expression A variable that represents a CodeProject object.

Parameters

Name | Required/Optional | Data Type | Description
SharedImageName | Required | String | Specifies the string used to identify the image in the collection.
FileName | Required | String | Specifies the full name and path to the image file.

Remarks

Use the AddSharedImage method when you have an image that you want to use repeatedly, such as a companny logo. The AddSharedImage method makes the image available in the Insert Image dropdown of the Controls group in the Design tab.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


DoCmd.Save Method (Access)

 Copy code hover
[image]

DoCmd.Save Method (Access)
See also Send feedback

Published: July 16, 2012

The Save method carries out the Save action in Visual Basic.

Syntax

expression .Save(ObjectType, ObjectName)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
ObjectType | Optional | AcObjectType | A AcObjectType constant that specifies the type of object you want to save.
ObjectName | Optional | Variant | A string expression that's the valid name of an object of the type selected by the objecttype argument.

Remarks

The Save method works on all database objects that the user can explicitly open and save. The specified object must be open for the Save method to have any effect on the object.

If you leave the objecttype and objectname arguments blank (the default constant, acDefault, is assumed for the objecttype argument), Microsoft Access saves the active object. If you leave the objecttype argument blank, but enter a name in the objectname argument, Microsoft Access saves the active object with the specified name. If you enter an object type in the objecttype argument, you must enter an existing object's name in the objectname argument.

Note Note

You can't use the Save method to save any of the following with a new name:

  • A form in Form view or Datasheet view.

  • A report in Print Preview.

  • A module.

  • A server view in Datasheet view or Print Preview.

  • A table in Datasheet view or Print Preview.

  • A query in Datasheet view or Print Preview.

  • A stored procedure in Datasheet view or Print Preview.

Example

The following example uses the Save method to save the form named "New Employees Form". This form must be open when the code containing this method runs.

VBA Copy code Copy code
DoCmd.Save acForm, "New Employees Form"

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


ComboBox.ItemsSelected Property (Access)

 Copy code hover
[image]

ComboBox.ItemsSelected Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ItemsSelected property to return a read-only reference to the hidden ItemsSelected collection. This hidden collection can be used to access data in the selected rows of a multiselect combo box control.

Version Information

Version Added: Access 2007

Syntax

expression .ItemsSelected

expression A variable that represents a ComboBox object.

Remarks

The ItemsSelected collection is unlike other collections in that it is a collection of Variants rather than of objects. Each Variant is an integer index referring to a selected row in a list box or combo box.

Use the ItemsSelected collection in conjunction with the Column property or the ItemData property to retrieve data from selected rows in a list box or combo box. You can list the ItemsSelected collection by using the For Each...Next statement.

For example, if you have an Employees list box on a form, you can list the ItemsSelected collection and use the control's ItemData property to return the value of the bound column for each selected row in the list box.

The ItemsSelected collection has no methods and two properties, the Count and Item properties.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ComboBox.TabIndex Property (Access)

 Copy code hover
[image]

ComboBox.TabIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.

Syntax

expression .TabIndex

expression A variable that represents a ComboBox object.

Remarks

You can set the TabIndex property to an integer representing the position of the control within the tab order of the form. Valid settings are 0 for the first tab position, up to the total number of controls minus 1 for the last tab position. For example, if a form has three controls that each have a TabIndex property, valid TabIndex property settings are 0, 1, and 2.

Setting the TabIndex property to an integer less than 0 produces an error.

By default, Microsoft Access assigns a tab order to controls in the order that you create them on a form. Each new control is placed last in the tab order. If you change the setting of a control's TabIndex property to adjust the tab order, Microsoft Access automatically renumbers the TabIndex property setting of other controls to reflect insertions and deletions.

In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the TAB key.

Changing the tab order of other controls on the form doesn't affect what happens when you press a control's access key. For example, if you've created an access key for the label of a text box, the focus will move to the text box whenever you press the label's access key — even if you change the TabIndex property setting for the text box.

If you press an access key for a control such as a label that doesn't have a TabIndex property (and thus isn't in the tab order), the focus moves to the next control in the tab order that can receive the focus.

Example

The following example reverses the tab order of a command button and a text box. Because TextBox1 was created first, it has a TabIndex property setting of 0 and Command1 has a setting of 1.

VBA Copy code Copy code
Sub Form_Click()
 Me!Command1.TabIndex = 0
 Me!TextBox1.TabIndex = 1
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Errors Members (DAO)

 Copy code hover
[image]

Errors Members (DAO)
Send feedback

An Errors collection contains all stored Error objects, each of which pertains to a single operation involving DAO.

Methods

Name | Description
Refresh | Updates the objects in the specified colletion to reflect the database's current schema.

Properties

Name | Description
Count | Returns the number of objects in the specified collection. Read-only.


Attachment.BackStyle Property (Access)

 Copy code hover
[image]

Attachment.BackStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .BackStyle

expression A variable that represents an Attachment object.

Remarks

The BackStyle property uses the following settings.

Setting | Visual Basic | Description
Normal | 1 | (Default) The control has its interior color set by the BackColor property.
Transparent | 0 | The control is transparent. The color of the form or report behind the control is visible.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

If the Transparent button on the Back Color button palette is selected, the BackStyle property is set to Transparent; otherwise the BackStyle property is set to Normal.

To make a command button invisible, set its Transparent property to Yes.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Section.Height Property (Access)

 Copy code hover
[image]

Section.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Syntax

expression .Height

expression A variable that represents a Section object.

Remarks

The Height property applies only to form sections and report sections, not to forms and reports.

For report sections, you can't use a macro or Visual Basic to set the Height property when you print or preview a report. For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of sections is measured from the inside of their borders. The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

Section Object

Other resources

Section Object Members


How to: Export a Report to XML

 Copy code hover
[image]

How to: Export a Report to XML
Send feedback

This procedure exports the Invoice report in the current database to an XML file. It also exports presentation information, and places images in the Images folder. The procedure exports the report to the default HTML wrapper. In addition, it creates a file containing the ReportML list.

VBA Copy code Copy code
Private Sub ExportReport()

 Const CREATE_REPORTML = 16

 Application.ExportXML _
 ObjectType:=acExportReport, _
 DataSource:="Invoice", _
 DataTarget:="C:\Invoice.xml", _
 PresentationTarget:="C:\InvoiceReport.xsl", _
 ImageTarget:="C:\Images", _
 OtherFlags:=CREATE_REPORTML

End Sub


Properties Object (Access)

 Copy code hover
[image]

Properties Object (Access)
See also Send feedback

Published: July 16, 2012

The Properties collection contains all of the built-in properties in an instance of an open form, report, or control. These properties uniquely characterize that instance of the object.

Remarks

Use the Properties collection in Visual Basic or in an expression to refer to form, report, or control properties on forms or reports that are currently open.

You can use the Properties collection of an object to enumerate the object's built-in properties. You don't need to know beforehand exactly which properties exist or what their characteristics (Name and Value properties) are to manipulate them.

Note Note

In addition to the built-in properties, you can also create and add your own user-defined properties. To add a user-defined property to an existing instance of an object, see the AccessObjectProperties collection and Add method topics.

Example

The following example enumerates the Forms collection and prints the name of each open form in the Forms collection. It then enumerates the Properties collection of each form and prints the name of each property and value.

VBA Copy code Copy code
Sub AllOpenForms()
 Dim frm As Form, prp As Property

 ' Enumerate Forms collection.
 For Each frm In Forms
 ' Print name of form.
 Debug.Print frm.Name
 ' Enumerate Properties collection of each form.
 For Each prp In frm.Properties
 ' Print name of each property.
 Debug.Print prp.Name; " = "; prp.Value
 Next prp
 Next frm
End Sub

See also

Concepts

Access Object Model Reference

Other resources

Properties Members


Control.Column Property (Access)

 Copy code hover
[image]

Control.Column Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Column property to refer to a specific column, or column and row combination, in a multiple-column combo box or list box. Read-only Variant.

Syntax

expression .Column(Index, Row)

expression A variable that represents a Control object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Long | A long integer that can range from 0 to the setting of the ColumnCount property minus one.
Row | Optional | Variant | An integer that can range from 0 to the setting of the ListCount property minus 1.

Remarks

Use 0 to refer to the first column, 1 to refer to the second column, and so on. Use 0 to refer to the first row, 1 to refer to the second row, and so on. For example, in a list box containing a column of customer IDs and a column of customer names, you could refer to the customer name in the second column and fifth row as:

VBA Copy code Copy code
Forms!Contacts!Customers.Column(1, 4)

You can use the Column property to assign the contents of a combo box or list box to another control, such as a text box. For example, to set the ControlSource property of a text box to the value in the second column of a list box, you could use the following expression:

VBA Copy code Copy code
=Forms!Customers!CompanyName.Column(1)

If the user has made no selection when you refer to a column in a combo box or list box, the Column property setting will be Null. You can use the IsNull function to determine if a selection has been made, as in the following example:

VBA Copy code Copy code
If IsNull(Forms!Customers!Country)
 Then MsgBox "No selection."
End If
Note Note

To determine how many columns a combo box or list box has, you can inspect the ColumnCount property setting.

Example

The following example uses the Column property and the ColumnCount property to print the values of a list box selection.

VBA Copy code Copy code
Public Sub Read_ListBox()

 Dim intNumColumns As Integer
 Dim intI As Integer
 Dim frmCust As Form

 Set frmCust = Forms!frmCustomers
 If frmCust!lstCustomerNames.ItemsSelected.Count > 0 Then

 ' Any selection?
 intNumColumns = frmCust!lstCustomerNames.ColumnCount
 Debug.Print "The list box contains "; intNumColumns; _
 IIf(intNumColumns = 1, " column", " columns"); _
 " of data."

 Debug.Print "The current selection contains:"
 For intI = 0 To intNumColumns - 1
 ' Print column data.
 Debug.Print frmCust!lstCustomerNames.Column(intI)
 Next intI
 Else
 Debug.Print "You haven't selected an entry in the " _
 & "list box."
 End If

 Set frmCust = Nothing

End Sub

See also

Concepts

Control Object

Other resources

Control Object Members


Query input must contain at least one table or query. (Error 3067)

 Copy code hover
[image]

Query input must contain at least one table or query. (Error 3067)
Send feedback

In Microsoft Access database engine databases, this error occurs if you do not select a table name when you create a query. Select at least one table or query.

In ODBCDirect databases, this error occurs if you attempt to execute a query that does not contain an SQL statement. Include at least one query or stored procedure call in the QueryDef object's SQL property.


Form.CommandEnabled Property (Access)

 Copy code hover
[image]

Form.CommandEnabled Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the CommandEnabled event occurs. Read/write.

Syntax

expression .CommandEnabled

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the CommandEnabled event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).CommandEnabled = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


Report.Tag Property (Access)

 Copy code hover
[image]

Report.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents a Report object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

See also

Concepts

Report Object

Other resources

Report Object Members


Label.FontItalic Property (Access)

 Copy code hover
[image]

Label.FontItalic Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontItalic property to specify whether text is italic in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontItalic

expression A variable that represents a Label object.

Remarks

The FontItalic property uses the following settings.

Setting | Description
True | The text is italic.
False | (Default) The text isn't italic.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

Label Object

Other resources

Label Object Members


Using Enumerated Constants in Microsoft Access 2002 and Later

 Copy code hover
[image]

Using Enumerated Constants in Microsoft Access 2002 and Later
Send feedback

In Microsoft Access 2002, a number of intrinsic constants were added or changed. This was done to create lists of "enumerated" constants that are displayed in the Auto List Members list in the Module window for the arguments of various Microsoft Access methods, functions, and properties, or as the setting of various Microsoft Access properties. You can select the appropriate constant from the list in the Module window, instead of having to remember the constant or look it up in the Help topic.

The following information applies to enumerated constants:

  • The set of enumerated constants for each method, function, or property argument has a name, which is displayed in the syntax line for the method, function, or property in the Module window when the Auto Quick Info option is selected in the Editor tab of the Options dialog box, available by clicking Options on the Tools menu. (For property settings, the name isn't displayed, just the list of constants.) For example, the syntax line for the OpenForm method of the DoCmd object shows [View As AcFormView = acNormal] for the view argument of this method. AcFormView is the name of this set of enumerated constants, and acNormal is the default setting for the argument. The Object Browser also lists the names of the sets of enumerated constants in the Classes box and lists the intrinsic constants contained in each of these sets in the Members Of box.

  • For constant names that have changed, the old constants will still work. For example, one of the intrinsic constants for the save argument of the Close method of the DoCmd object was acPrompt. It's now acSavePrompt, but acPrompt will still work.

  • In a number of cases in previous versions of Microsoft Access, you could leave an argument setting blank, and Microsoft Access would perform the default action for that argument. For example, you could leave the objecttype (and objectname) arguments of the Close method blank, and Microsoft Access would close the active window. For the new sets of enumerated constants, the blank setting has been replaced with a new default constant. For example, the objecttype argument of the Close method now has a new default constant, acDefault. Setting this argument to the new constant has the same effect as leaving the argument blank. In addition, you can still leave such arguments blank, and Microsoft Access will assume the new default constant.

  • There's one exception to this. If you run Visual Basic code from previous versions of Visual Basic in Microsoft Access by using Automation, blank arguments will cause an error for those arguments that have the new default constants. This problem doesn't occur for old Visual Basic for Applications or Visual Basic code run directly in Microsoft Access.


ChangeView Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

ChangeView Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

You can use the ChangeView action to navigate between views in place.

Setting

The ChangeView action has the following arguments.

Action argument | Required | Description
Table | Yes | The name of the table to open.
View | Yes | The name of the view to open.
Where | No | If specified, replaces the Where condition of the object record source.
Order By | No | A string expression that includes the name of the field or fields on which to sort records and the optional ASC or DESC keywords. By default, this argument is blank.

Remarks

Any sorting or filtering applied by the user is cleared when the ChangeView action is called.

The OrderBy argument is the name of the field or fields on which you want to sort records. When you use more than one field name, separate the names with a comma (,).

When you set the OrderBy argument, the records are sorted by default in ascending order.


Source Property Example (VB)

 Copy code hover
[image]

Source Property Example (VB)
Send feedback

This example demonstrates the Source property by opening three Recordset objects based on different data sources.

Copy code Copy code

'BeginSourceVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 Dim Cnxn As ADODB.Connection
 Dim rstTitles As ADODB.Recordset
 Dim rstPublishers As ADODB.Recordset
 Dim rstPublishersDirect As ADODB.Recordset
 Dim rstTitlesPublishers As ADODB.Recordset
 Dim cmdSQL As ADODB.Command
 Dim strCnxn As String
 Dim strSQL As String

 ' Open a connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open a recordset based on a command object
 Set cmdSQL = New ADODB.Command
 Set cmdSQL.ActiveConnection = Cnxn
 strSQL = "Select title, type, pubdate FROM Titles ORDER BY title"
 cmdSQL.CommandText = strSQL
 Set rstTitles = cmdSQL.Execute()

 ' Open a recordset based on a table
 Set rstPublishers = New ADODB.Recordset
 strSQL = "Publishers"
 rstPublishers.Open strSQL, Cnxn, adOpenStatic, adLockReadOnly, adCmdTable
 'rstPublishers.Open strSQL, Cnxn, , , adCmdTable
 ' the above two lines of code are identical

 ' Open a recordset based on a table
 Set rstPublishersDirect = New ADODB.Recordset
 rstPublishersDirect.Open strSQL, strCnxn, , , adCmdTableDirect

 ' Open a recordset based on an SQL string.
 Set rstTitlesPublishers = New ADODB.Recordset
 strSQL = "SELECT title_ID AS TitleID, title AS Title, " & _
 "publishers.pub_id AS PubID, pub_name AS PubName " & _
 "FROM publishers INNER JOIN Titles " & _
 "ON publishers.pub_id = Titles.pub_id " & _
 "ORDER BY Title"
 rstTitlesPublishers.Open strSQL, strCnxn, , , adCmdText

 ' Use the Source property to display the source of each recordset.
 MsgBox "rstTitles source: " & vbCr & _
 rstTitles.Source & vbCr & vbCr & _
 "rstPublishers source: " & vbCr & _
 rstPublishers.Source & vbCr & vbCr & _
 "rstPublishersDirect source: " & vbCr & _
 rstPublishersDirect.Source & vbCr & vbCr & _
 "rstTitlesPublishers source: " & vbCr & _
 rstTitlesPublishers.Source

 ' clean up
 rstTitles.Close
 rstPublishers.Close
 rstTitlesPublishers.Close
 Cnxn.Close
 Set rstTitles = Nothing
 Set rstPublishers = Nothing
 Set rstTitlesPublishers = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstTitles Is Nothing Then
 If rstTitles.State = adStateOpen Then rstTitles.Close
 End If
 Set rstTitles = Nothing

 If Not rstPublishers Is Nothing Then
 If rstPublishers.State = adStateOpen Then rstPublishers.Close
 End If
 Set rstPublishers = Nothing

 If Not rstTitlesPublishers Is Nothing Then
 If rstTitlesPublishers.State = adStateOpen Then rstTitlesPublishers.Close
 End If
 Set rstTitlesPublishers = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndSourceVB


Attachment Methods (Access)

 Copy code hover
[image]

Attachment Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Back | Moves the focus to the previous file in the specified Attachment control.
Forward | Moves the focus to the next file in the specified Attachment control.
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.


Label.LeftMargin Property (Access)

 Copy code hover
[image]

Label.LeftMargin Property (Access)
See also Send feedback

Published: July 16, 2012

Along with the TopMargin, RightMargin, and BottomMargin properties, specifies the location of information displayed within a label control. Read/write Integer. .

Syntax

expression .LeftMargin

expression A variable that represents a Label object.

Remarks

A control's displayed information location is measured from the control's left, top, right, or bottom border to the left, top, right, or bottom edge of the displayed information. Setting the LeftMargin or TopMargin property to 0 places the displayed information's edge at the very left or top of the control. To use a unit of measurement different from the setting in the regional settings of Windows, specify the unit (for example, cm or in).

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

Label Object

Other resources

Label Object Members


WebBrowserControl.Transform Property (Access)

 Copy code hover
[image]

WebBrowserControl.Transform Property (Access)
See also Send feedback

Published: July 16, 2012

Read/write

Version Information

Version Added: Access 2010

Syntax

expression .Transform

expression A variable that represents a WebBrowserControl object.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


DoCmd.FindNext Method (Access)

 Copy code hover
[image]

DoCmd.FindNext Method (Access)
See also Send feedback

Published: July 16, 2012

The FindNext method carries out the FindNext action in Visual Basic.

Syntax

expression .FindNext

expression A variable that represents a DoCmd object.

Remarks

You can use the FindNext method to find the next record that meets the criteria specified by the previous FindRecord method or the Find and Replace dialog box, available by clicking Find on the Edit menu. You can use the FindNext method to search repeatedly for records. For example, you can move successively through all the records for a specific customer.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


RecordTypeEnum

 Copy code hover
[image]

RecordTypeEnum
Send feedback

Specifies the type of Record object.

Constant | Value | Description
adSimpleRecord | 0 | Indicates a simple record (does not contain child nodes).
adCollectionRecord | 1 | Indicates a collection record (contains child nodes).
adRecordUnknown | -1 | Indicates that the type of this Record is unknown.
adStructDoc | 2 | Indicates a special kind of collection record that represents COM structured documents.

ADO/WFC Equivalent

These constants do not have ADO/WFC equivalents.


ParentCatalog Property (ADOX)

 Copy code hover
[image]

ParentCatalog Property (ADOX)
Send feedback

Specifies the parent catalog of a table or column to provide access to provider-specific properties.

Settings and Return Values

Sets and returns a Catalog object. Setting ParentCatalog to an open Catalog allows access to provider-specific properties prior to appending a table or column to a Catalog collection.

Remarks

Some data providers allow provider-specific property values to be written only at creation (when a table or column is appended to its Catalog collection). To access these properties before appending these objects to a Catalog, specify the Catalog in the ParentCatalog property first.

An error occurs when the table or column is appended to a different Catalog than the ParentCatalog.


CommandButton.HyperlinkAddress Property (Access)

 Copy code hover
[image]

CommandButton.HyperlinkAddress Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the HyperlinkAddress property to specify or determine the path to an object, document, Web page or other destination for a hyperlink associated with a the specified control. Read/write String.

Syntax

expression .HyperlinkAddress

expression A variable that represents a CommandButton object.

Remarks

The HyperlinkAddress property is a string expression representing the path to a file (UNC path) or Web page (URL).

Note Note

When you set the HyperlinkAddress property, you automatically specify the Address property for the Hyperlink object associated with the control.

Note Note

When you create a hyperlink by using the Insert Hyperlink dialog box, Microsoft Access automatically sets the HyperlinkAddress property and HyperlinkSubAddress to the location specified in the Type the file or Web page name box. The HyperlinkSubAddress property can also be set to the location specified in the Select an object in this database box.

If you copy a hyperlink from another application and paste it into a form or report, Microsoft Access creates a label control with its Caption property, HyperlinkAddress property, and HyperlinkSubAddress property automatically set.

When you move the cursor over a command button, image control, or label control whose HyperlinkAddress property is set, the cursor changes to an upward-pointing hand. Clicking the control displays the object or Web page specified by the link.

To open objects in the current database, leave the HyperlinkAddress property blank and specify the object type and object name you want to open in the HyperlinkSubAddress property by using the syntax "objecttype objectname". If you want to open an object contained in another Microsoft Access database, enter the database path and file name in the HyperlinkAddress property and specify the database object to open by using the HyperlinkSubAddress property.

The HyperlinkAddress property can contain an absolute or a relative path to a target document. An absolute path is a fully qualified URL or UNC path to a document. A relative path is a path related to the base path specified in the Hyperlink Base setting in the Properties dialog box (available by clicking Database Properties on the File menu) or to the current database path. If Microsoft Access can't resolve the HyperlinkAddress property setting to a valid URL or UNC path, it will assume you've specified a path relative to the base path contained in the Hyperlink Base setting or the current database path.

Note Note

When you follow a hyperlink to another Microsoft Access database object, the database Startup properties are applied. For example, if the destination database has a Display form set, that form is displayed when the database opens.

The following table contains examples of HyperlinkAddress and HyperlinkSubAddress property settings.

HyperlinkAddress | HyperlinkSubAddress | Description
http://www.microsoft.com/ |  | The Microsoft home page on the Web.
C:\Program Files\Microsoft Office\Office\Samples\Cajun.htm |  | The Cajun Delights page in the Access sample applications subdirectory.
C:\Program Files\Microsoft Office\Office\Samples\Cajun.htm | NewProducts | The "NewProducts" Name tag in the Cajun Delights page.
C:\Personal\MyResume.doc | References | The bookmark named "References" in the Microsoft Word document "MyResume.doc".
C:\Finance\First Quarter.xls | Sheet1!TotalSales | The range named "TotalSales" in the Microsoft Excel spreadsheet "First Quarter.xls".
C:\Presentation\NewPlans.ppt | 10 | The 10th slide in the Microsoft PowerPoint document "NewPlans.ppt".

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


UpdateBatch and CancelBatch Methods Example (VB)

 Copy code hover
[image]

UpdateBatch and CancelBatch Methods Example (VB)
Send feedback

This example demonstrates the UpdateBatch method in conjunction with the CancelBatch method.

Copy code Copy code

'BeginUpdateBatchVB
Public Sub Main()
 On Error GoTo ErrorHandler

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

 'connection and recordset variables
 Dim rstTitles As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim strSQLTitles As String
 'record variables
 Dim strTitle As String
 Dim strMessage As String

 ' Open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' open recordset for batch uodate
 Set rstTitles = New ADODB.Recordset
 strSQLTitles = "titles"
 rstTitles.Open strSQLTitles, Cnxn, adOpenKeyset, adLockBatchOptimistic, adCmdTable

 rstTitles.MoveFirst
 ' Loop through recordset and ask user if she wants
 ' to change the type for a specified title.
 Do Until rstTitles.EOF
 If Trim(rstTitles!Type) = "psychology" Then
 strTitle = rstTitles!Title
 strMessage = "Title: " & strTitle & vbCr & _
 "Change type to self help?"

 If MsgBox(strMessage, vbYesNo) = vbYes Then
 rstTitles!Type = "self_help"
 End If
 End If

 rstTitles.MoveNext
 Loop

 ' Ask the user if she wants to commit to all the
 ' changes made above.
 If MsgBox("Save all changes?", vbYesNo) = vbYes Then
 rstTitles.UpdateBatch
 Else
 rstTitles.CancelBatch
 End If

 ' Print current data in recordset.
 rstTitles.Requery
 rstTitles.MoveFirst
 Do While Not rstTitles.EOF
 Debug.Print rstTitles!Title & " - " & rstTitles!Type
 rstTitles.MoveNext
 Loop

 ' Restore original values because this is a demonstration.
 rstTitles.MoveFirst
 Do Until rstTitles.EOF
 If Trim(rstTitles!Type) = "self_help" Then
 rstTitles!Type = "psychology"
 End If
 rstTitles.MoveNext
 Loop
 rstTitles.UpdateBatch

 ' clean up
 rstTitles.Close
 Cnxn.Close
 Set rstTitles = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstTitles Is Nothing Then
 If rstTitles.State = adStateOpen Then rstTitles.Close
 End If
 Set rstTitles = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndUpdateBatchVB


DoCmd.TransferDatabase Method (Access)

 Copy code hover
[image]

DoCmd.TransferDatabase Method (Access)
See also Send feedback

Published: July 16, 2012

The TransferDatabase method carries out the TransferDatabase action in Visual Basic.

Syntax

expression .TransferDatabase(TransferType, DatabaseType, DatabaseName, ObjectType, Source, Destination, StructureOnly, StoreLogin)

expression A variable that represents a DoCmd object.

Parameters

Name

Required/Optional

Data Type

Description

TransferType

Optional

AcDataTransferType

The type of transfer you want to make.

DatabaseType

Optional

Variant

A string expression that's the name of one of the types of databases you can use to import, export, or link data. Tye types or databases are:

  • Microsoft Access (default)

  • Jet 2.x

  • Jet 3.x

  • dBase III

  • dBase IV

  • dBase 5.0

  • Paradox 3.x

  • Paradox 4.x

  • Paradox 5.x

  • Paradox 7.x

  • ODBC Database

  • WSS

DatabaseName

Optional

Variant

A string expression that's the full name, including the path, of the database you want to use to import, export, or link data.

ObjectType

Optional

AcObjectType

The type of object to import or export.

Source

Optional

Variant

A string expression that's the name of the object whose data you want to import, export, or link.

Destination

Optional

Variant

A string expression that's the name of the imported, exported, or linked object in the destination database.

StructureOnly

Optional

Variant

Use True (-1) to import or export only the structure of a database table. Use False (0) to import or export the structure of the table and its data. If you leave this argument blank, the default (False) is assumed.

StoreLogin

Optional

Variant

Use True to store the login identification (ID) and password for an ODBC database in the connection string for a linked table from the database. If you do this, you don't have to log in each time you open the table. Use False if you don't want to store the login ID and password. If you leave this argument blank, the default (False) is assumed. This argument is available only in Visual Basic.

Remarks

You can use the TransferDatabase action to import or export data between the current Microsoft Access database or Microsoft Access project (.adp) and another database. For Access databases you can also link a table to the current Access database from another database. With a linked table, you have access to the table's data while the table itself remains in the other database.

You can import and export tables between Access and other types of databases. You can also export Access select queries to other types of databases. Access exports the result set of the query in the form of a table. You can import and export any Access database object if both databases are Access databases.

If you import a table from another Access database that's a linked table in that database, it will still be linked after you import it. That is, the link is imported, not the table itself.

The administrator of an ODBC database can disable the feature provided by the saveloginid argument, requiring all users to enter the login ID and password each time they connect to the ODBC database.

Note Note

You can also use ActiveX Data Objects (ADO) to create a link by using the ActiveConnection property for the Recordset object.

Example

The following example imports the NW Sales for April report from the Access database NWSales.mdb into the Corporate Sales for April report in the current database:

VBA Copy code Copy code
DoCmd.TransferDatabase acImport, "Microsoft Access", _
    "C:\My Documents\NWSales.mdb", acReport, "NW Sales for April", _
    "Corporate Sales for April"

The next example links the ODBC database table Authors to the current database:

VBA Copy code Copy code
DoCmd.TransferDatabase acLink, "ODBC Database", _
    "ODBC;DSN=DataSource1;UID=User2;PWD=www;LANGUAGE=us_english;" _
    & "DATABASE=pubs", acTable, "Authors", "dboAuthors"

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Application.CodeDb Method (Access)

 Copy code hover
[image]

Application.CodeDb Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the CodeDb method in a code module to determine the name of the Database object that refers to the database in which code is currently running. Use the CodeDb method to access Data Access Objects (DAO) that are part of a library database.

Syntax

expression .CodeDb

expression A variable that represents an Application object.

Return Value

Database

Remarks

For example, you can use the CodeDb method in a module in a library database to create a Database object referring to the library database. You can then open a recordset based on a table in the library database.

Set database = CodeDb

The CodeDb method returns a Database object for which the Name property is the full path and name of the database from which it is called. This method can be useful when you need to manipulate the Data Access Objects in your library database.

When you call a method in a library database, the database from which you have called the method remains the current database, even while code is running in a module in the library database. In order to refer to the Data Access Objects in the library database, you need to know the name of the Database object that represents the library database.

For example, suppose you have a table in a library database that lists error messages. To manipulate data in the table from code, you could use the CodeDb method to determine the name of the Database object that refers to the library database that contains the table.

If the CodeDb method is run from the current database, it returns the name of the current database, which is the same value returned by the CurrentDb method.

Example

The following example uses the CodeDb method to return a Database object that refers to a library database. The library database contains both a table named Errors and the code that is currently running. After the CodeDb method determines this information, the GetErrorString function opens a table-type recordset based on the Errors table. It then extracts an error message from a field named ErrorData based on the Integer value passed to the function.

VBA Copy code Copy code
Function GetErrorString(ByVal intError As Integer) As String
 Dim dbs As Database, rst As RecordSet

 ' Variable refers to database where code is running.
 Set dbs = CodeDb
 ' Create table-type Recordset object.
 Set rst = dbs.OpenRecordSet("Errors", dbOpenTable)
 ' Set index to primary key (ErrorID field).
 rst.Index = "PrimaryKey"
 ' Find error number passed to GetErrorString function.
 rst.Seek "=", intError
 ' Return associated error message.
 GetErrorString = rst.Fields!ErrorData.Value
 rst.Close
End Function

See also

Concepts

Application Object

Other resources

Application Object Members


Page.Caption Property (Access)

 Copy code hover
[image]

Page.Caption Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the text that appears at the top of the page. Read/write String.

Syntax

expression .Caption

expression A variable that represents a Page object.

Remarks

The Caption property is a string expression that can contain up to 2,048 characters.

If you don't set a caption for a form, button, or label, Microsoft Access will assign the object a unique name based on the object, such as "Form1".

You can use the Caption property to assign an access key to a label or command button. In the caption, include an ampersand (&) immediately preceding the character you want to use as an access key. The character will be underlined. You can press ALT plus the underlined character to move the focus to that control on a form.

Include two ampersands (&&) in the setting for a caption if you want to display an ampersand itself in the caption text. For example, to display "Save & Exit", you should type Save && Exit in the Caption property box.

See also

Concepts

Page Object

Other resources

Page Object Members


ToggleButton.QuickStyleMask Property (Access)

 Copy code hover
[image]

ToggleButton.QuickStyleMask Property (Access)
Send feedback

Published: July 16, 2012

Gets or sets modifications to the Quick Style that is applied to the specified object. Read/write Long.

Version information

Version Added: Access 2010

Syntax

expression .QuickStyle

expression A variable that represents a ToggleButton object.

Remarks

Set the QuickStyleMask property to -1 to remove modifications to the selected Quick Style.

Property value

INT32


RDS Methods

 Copy code hover
[image]

RDS Methods
Send feedback
Cancel (RDS) | Cancels execution of a pending, asynchronous method call.
CancelUpdate (RDS) | Cancels any changes made to the current or new row of a Recordset object.
ConvertToString (RDS) | Converts a Recordset to a MIME string that represents the recordset data.
CreateObject (RDS) | Creates the proxy for the target business object and returns a pointer to it.
CreateRecordset (RDS) | Creates an empty, disconnected Recordset.
MoveFirst, MoveLast, MoveNext, MovePrevious (RDS) | Moves to the first, last, next, or previous record in a specified Recordset object.
Query (RDS) | Uses a valid SQL query string to return a Recordset.
Refresh (RDS) | Requeries the data source specified in the Connect property and updates the query results.
Reset (RDS) | Executes the sort or filter on a client-side Recordset, based on the specified sort and filter properties.
SubmitChanges (RDS) | Submits pending changes of the locally cached and updatable Recordset to the data source specified in the Connect property.


ListBox.RowSource Property (Access)

 Copy code hover
[image]

ListBox.RowSource Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the RowSource property (along with the RowSourceType property) to tell Microsoft Access how to provide data tothe specified object. Read/write String.

Syntax

expression .RowSource

expression A variable that represents a ListBox object.

Remarks

For example, to display rows of data in a list box from a query named CustomerList, set the list box's RowSourceType property to Table/Query and its RowSource property to the query named CustomerList.

The RowSource property setting depends on the RowSourceType property setting.

For this RowSourceType setting | Enter this RowSource setting
Table/Query | A table name, query name, or SQL statement.
Value List | A list of items with semicolons (;) as separators.
Field List | A table name, query name, or SQL statement.

If the RowSourceType property is set to a user-defined function, the RowSource property can be left blank.

For table fields, you can set these properties on the Lookup tab in the Field Properties section of table Design view for fields with the DisplayControl property set to Combo Box or List Box.

Microsoft Access sets these properties automatically when you select Lookup Wizard as the data type for a field in table Design view.

In Visual Basic, set the RowSourceType property by using a string expression with one of these values: "Table/Query", "Value List", or "Field List". You also use a string expression to set the value of the RowSource property. To set the RowSourceType property to a user-defined function, enter the name of the function.

When you have a limited number of values that don't change, you can set the RowSourceType property to Value List and then enter the values that make up the list in the RowSource property.

Example

The following example sets the RowSourceType property for a combo box to Table/Query, and it sets the RowSource property to a query named EmployeeList.

VBA Copy code Copy code
Forms!Employees!cmboNames.RowSourceType = "Table/Query"
Forms!Employees!cmboNames.RowSource = "EmployeeList"

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Database.CollatingOrder Property (DAO)

 Copy code hover
[image]

Database.CollatingOrder Property (DAO)
Send feedback

Returns a value that specifies the sequence of the sort order in text for string comparison or sorting (Microsoft Access workspaces only). Read-only Long.

Syntax

expression .CollatingOrder

expression A variable that represents a Database object.

Remarks

The return value is a Long value or constant that can be one of the following values.

Constant | Sort order
dbSortGeneral | General (English, French, German, Portuguese, Italian, and Modern Spanish)
dbSortArabic | Arabic
dbSortChineseSimplified | Simplified Chinese
dbSortChineseTraditional | Traditional Chinese
dbSortCyrillic | Russian
dbSortCzech | Czech
dbSortDutch | Dutch
dbSortGreek | Greek
dbSortHebrew | Hebrew
dbSortHungarian | Hungarian
dbSortIcelandic | Icelandic
dbSortJapanese | Japanese
dbSortKorean | Korean
dbSortNeutral | Neutral
dbSortNorwDan | Norwegian or Danish
dbSortPDXIntl | Paradox International
dbSortPDXNor | Paradox Norwegian or Danish
dbSortPDXSwe | Paradox Swedish or Finnish
dbSortPolish | Polish
dbSortSlovenian | Slovenian
dbSortSpanish | Spanish
dbSortSwedFin | Swedish or Finnish
dbSortThai | Thai
dbSortTurkish | Turkish
dbSortUndefined | Undefined or unknown

The CollatingOrder property setting corresponds to the locale argument of the CreateDatabase method when the database was created or the CompactDatabase method when the database was most recently compacted.

Check the CollatingOrder property setting of a Database or Field object to determine the string comparison method for the database or field. You can set the CollatingOrder property of a new, unappended Field object if you want the setting of the Field object to differ from that of the Database object that contains it.


WebBrowserControl.BeforeNavigate2 Event (Access)

 Copy code hover
[image]

WebBrowserControl.BeforeNavigate2 Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs before navigation occurs in the given WebBrowserControl.

Version Information

Version Added: Access 2010

Syntax

expression .BeforeNavigate2(pDisp, URL, flags, TargetFrameName, PostData, Headers, Cancel)

expression A variable that represents a WebBrowserControl object.

Parameters

Name | Required/Optional | Data Type | Description
pDisp | Required | Object | A pointer to the IDispatch interface for the WebBrowser object that represents the window or frame.
URL | Required | Variant | Contains the URL to be navigated to.
flags | Required | Variant | Reserved. Must be set to NULL.
TargetFrameName | Required | Variant | Contains the name of the frame in which to display the resource, or NULL if no named frame is targeted for the resource.
PostData | Required | Variant | Contains the data to send to the server, if the HTTP POST transaction is used.
Headers | Required | Variant | Contains additional HTTP headers to send to the server (HTTP URLs only). The headers can specify information, such as the action required of the server, the type of data being passed to the server, or a status code.
Cancel | Required | Boolean | Contains the cancel flag. Set to True to cancel the navigation operation.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


ADO MD Code Examples in Visual Basic

 Copy code hover
[image]

ADO MD Code Examples in Visual Basic
Send feedback

The following examples require Microsoft Visual Basic version 5.0 with Service Pack 3 or Visual Basic version 6.0.

Note Note

Paste the entire code example, from beginning to end, into your code editor. The example may not run correctly if partial examples are used or if paragraph formatting is lost.

  • Cellset Example

  • Catalog Example


NavigationControl.BackThemeColorIndex Property (Access)

 Copy code hover
[image]

NavigationControl.BackThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackThemeColorIndex

expression A variable that represents a NavigationControl object.

Remarks

The BackThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BackThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Background Color to the Text 2 color by setting the BackThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BackThemeColorIndex=2

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


TextBox.RightPadding Property (Access)

 Copy code hover
[image]

TextBox.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .RightPadding

expression A variable that represents a TextBox object.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


NewRecord Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

NewRecord Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Creates a new, blank record in the current view.

Remarks

You can use the NewRecord action to add a blank record at the end of view so you can enter new data.

The NewRecord action is equivalent to using the Add button in the action bar to add a record.


CheckBox.LabelY Property (Access)

 Copy code hover
[image]

CheckBox.LabelY Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelY

expression A variable that represents a CheckBox object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


SaveRecord Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

SaveRecord Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Saves the current record.

Remarks

The SaveRecord action is equivalent to using the Save button in the action bar to save the current record.


Views Collection (ADOX) Reference

 Copy code hover
[image]

Views Collection (ADOX) Reference
Send feedback

In this section

  • Views Collection (ADOX)

  • Views Collection Properties, Methods, and Events (ADOX)


TimeFromParts Function (Access 2013 custom web app)

 Copy code hover
[image]

TimeFromParts Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns a time value based on specified parts.

Syntax

TimeFromParts (Hour, Minute, Second)

The TimeFromParts function contains the following arguments.

Argument name | Description
Hour | Integer expression specifying hours.
Minute | Integer expression specifying minutes.
Second | Integer expression specifying seconds.

Additional resources

TimeFromParts returns a fully initialized time value. If the arguments are invalid, then an error is raised. If any of the parameters are null, null is returned.


WebBrowserControl.ScrollBars Property (Access)

 Copy code hover
[image]

WebBrowserControl.ScrollBars Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ScrollBars property to specify whether scroll bars appear on a text box control. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .ScrollBars

expression A variable that represents a WebBrowserControl object.

Remarks

The ScrollBars property uses the following settings.

Setting | Visual Basic | Description
None | 0 | (Default) No scroll bars appear on the text box.
Vertical | 2 | Vertical scroll bar appears on the text box.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Field.OrdinalPosition Property (DAO)

 Copy code hover
[image]

Field.OrdinalPosition Property (DAO)
Send feedback

Sets or returns the relative position of a Field object within a Fields collection. .

Syntax

expression .OrdinalPosition

expression A variable that represents a Field object.

Remarks

For an object not yet appended to the Fields collection, this property is read/write.

The default is 0.

The availability of the OrdinalPosition property depends on the object that contains the Fields collection, as shown in the following table.

If the Fields collection belongs to a | Then OrdinalPosition is
Index object | Not supported
QueryDef object | Read-only
Recordset object | Read-only
Relation object | Not supported
TableDef object | Read/write

Generally, the ordinal position of an object that you append to a collection depends on the order in which you append the object. The first appended object is in the first position (0), the second appended object is in the second position (1), and so on. The last appended object is in ordinal position count - 1, where count is the number of objects in the collection as specified by the Count property setting.

You can use the OrdinalPosition property to specify an ordinal position for new Field objects that differs from the order in which you append those objects to a collection. This enables you to specify a field order for your tables, queries, and recordsets when you use them in an application. For example, the order in which fields are returned in a SELECT * query is determined by the current OrdinalPosition property values.

You can permanently reset the order in which fields are returned in recordsets by setting the OrdinalPosition property to any positive integer.

Two or more Field objects in the same collection can have the same OrdinalPosition property value, in which case they will be ordered alphabetically. For example, if you have a field named Age set to 4 and you set a second field named Weight to 4, Weight is returned after Age.

You can specify a number that is greater than the number of fields minus 1. The field will be returned in an order relative to the largest number. For example, if you set a field's OrdinalPosition property to 20 (and there are only 5 fields) and you've set the OrdinalPosition property for two other fields to 10 and 30, respectively, the field set to 20 is returned between the fields set to 10 and 30.

Note Note

Even if the Fields collection of a TableDef has not been refreshed, the field order in a Recordset opened from the TableDef will reflect the OrdinalPosition data of the TableDef object. A table-type Recordset will have the same OrdinalPosition data as the underlying table, but any other type of Recordset will have new OrdinalPosition data (starting with 0) that follow the order determined by the OrdinalPosition data of the TableDef.

Example

This example changes the OrdinalPosition property values in the Employees TableDef in order to control the Field order in a resulting Recordset. By setting the OrdinalPosition of all the Fields to 1, any resulting Recordset will order the Fields alphabetically. Note that the OrdinalPosition values in the Recordset don't match the values in the TableDef, but simply reflect the end result of the TableDef changes.

VBA Copy code Copy code
Sub OrdinalPositionX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim aintPosition() As Integer
 Dim astrFieldName() As String
 Dim intTemp As Integer
 Dim fldTemp As Field
 Dim rstEmployees As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set tdfEmployees = dbsNorthwind.TableDefs("Employees")

 With tdfEmployees
 ' Display and store original OrdinalPosition data.
 Debug.Print _
 "Original OrdinalPosition data in TableDef."
 ReDim aintPosition(0 To .Fields.Count - 1) As Integer
 ReDim astrFieldName(0 To .Fields.Count - 1) As String
 For intTemp = 0 To .Fields.Count - 1
 aintPosition(intTemp) = _
 .Fields(intTemp).OrdinalPosition
 astrFieldName(intTemp) = .Fields(intTemp).Name
 Debug.Print , aintPosition(intTemp), _
 astrFieldName(intTemp)
 Next intTemp

 ' Change OrdinalPosition data.
 For Each fldTemp In .Fields
 fldTemp.OrdinalPosition = 1
 Next fldTemp

 ' Open new Recordset object to show how the
 ' OrdinalPosition data has affected the record order.
 Debug.Print _
 "OrdinalPosition data from resulting Recordset."
 Set rstEmployees = dbsNorthwind.OpenRecordset( _
 "SELECT * FROM Employees")
 For Each fldTemp In rstEmployees.Fields
 Debug.Print , fldTemp.OrdinalPosition, fldTemp.Name
 Next fldTemp
 rstEmployees.Close

 ' Restore original OrdinalPosition data because this is
 ' a demonstration.
 For intTemp = 0 To .Fields.Count - 1
 .Fields(astrFieldName(intTemp)).OrdinalPosition = _
 aintPosition(intTemp)
 Next intTemp

 End With

 dbsNorthwind.Close

End Sub


ListBox.ThemeFontIndex Property (Access)

 Copy code hover
[image]

ListBox.ThemeFontIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ThemeFontIndex

expression A variable that represents a ListBox object.

Remarks

The ThemeFontIndex property uses one of the values listed in the following table.

Value | Description
0 | Header font
1 (Default) | Detail font

If no theme is applied, the ThemeFontIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Could not repair this database. (Error 3056)

 Copy code hover
[image]

Could not repair this database. (Error 3056)
Send feedback

This database is corrupted or it is not a Microsoft Access database engine database. Restore the corrupted Microsoft Access database engine database from a backup copy or create a new database.


GroupLevel.GroupOn Property (Access)

 Copy code hover
[image]

GroupLevel.GroupOn Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the GroupOn property in a report to specify how to group data in a field or expression by data type. For example, this property lets you group a Date field by month. Read/write Integer.

Syntax

expression .GroupOn

expression A variable that represents a GroupLevel object.

Remarks

The GroupOn property settings available for a field depend on its data type, as the following table shows. For an expression, all of the settings are available. The default setting for all data types is Each Value.

Field data type | Setting | Groups records with | Visual Basic
Text | (Default) Each Value | The same value in the field or expression. | 0
 | Prefix Characters | The same first n number of characters in the field or expression. | 1
Date/Time | (Default) Each Value | The same value in the field or expression. | 0
 | Year | Dates in the same calendar year. | 2
 | Qtr | Dates in the same calendar quarter. | 3
 | Month | Dates in the same month. | 4
 | Week | Dates in the same week. | 5
 | Day | Dates on the same date. | 6
 | Hour | Times in the same hour. | 7
 | Minute | Times in the same minute. | 8
AutoNumber, Currency, Number | (Default) Each Value | The same value in the field or expression. | 0
 | Interval | Values within an interval you specify. | 9

In Visual Basic, you set this property in the Open event procedure of a report.

To set the GroupOn property to a value other than Each Value, you must first set the GroupHeader or GroupFooter property or both to Yes for the selected field or expression.

Example

The following example sets the SortOrder and grouping properties for the first group level in the Products By Category report to create an alphabetical list of products.

VBA Copy code Copy code
Private Sub Report_Open(Cancel As Integer)
    ' Set SortOrder property to ascending order.
    Me.GroupLevel(0).SortOrder = False
    ' Set GroupOn property.
    Me.GroupLevel(0).GroupOn = 1
    ' Set GroupInterval property to 1.
    Me.GroupLevel(0).GroupInterval = 1
    ' Set KeepTogether property to With First Detail.
    Me.GroupLevel(0).KeepTogether = 2
End Sub

See also

Concepts

GroupLevel Object

Other resources

GroupLevel Object Members


Report.FontSize Property (Access)

 Copy code hover
[image]

Report.FontSize Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontSize property to specify the point size for text in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Integer.

Syntax

expression .FontSize

expression A variable that represents a Report object.

Remarks

The FontSize property uses the following settings.

Setting | Description
8 | (Default for all reports and controls except command buttons) The text is 8-point type.
10 | (Default for command buttons) The text is 10-point type.
Other sizes | The text is the indicated size.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set this property only in an event procedure or in a macro specified by the OnPrint event property setting.

In Visual Basic, you set the FontSize property by using a numeric expression equal to the desired size of the font. The setting for the FontSize property can be between 1 and 127, inclusive.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


CustomControl.BorderColor Property (Access)

 Copy code hover
[image]

CustomControl.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Syntax

expression .BorderColor

expression A variable that represents a CustomControl object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


EMailDatabaseObject Macro Action

 Copy code hover
[image]

EMailDatabaseObject Macro Action
Send feedback

You can use the EMailDatabaseObject action to include the specified Microsoft Access datasheet, form, report, module, or data access page in an electronic mail message, where it can be viewed and forwarded.

Note 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.

Settings

The EMailDatabaseObject action has the following arguments.

Action argument | Description
Object Type | 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. If you want to include the active object, select its type with this argument, but leave the Object Name argument blank.
Object Name | 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 EMailDatabaseObject action in a library database, Access looks for the object with this name first in the library database, then in the current database.
Output Format | 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.
To | 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 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.
Cc | 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.
Bcc | 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.
Subject | 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.
Message Text | 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.
Edit Message | 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.
Template File | 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.

Remarks

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 EMailDatabaseObject action to include a database object in a mail message:

  • You can send table, query, and form datasheets. In the included object, all fields in the datasheet look as they do in Access, except fields containing OLE objects. 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, option button, or check box), the output file displays the value -1 (Yes) or 0 (No).

  • For a text box bound to a Hyperlink field, the output file displays the hyperlink 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, the included object always contains the form's Datasheet view.

  • 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 other than Sum) is included in the object.

  • Subreports 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.

To run the EMailDatabaseObject action in a Visual Basic for Applications (VBA) module, use the SendObject method of the DoCmd object.

Link provided by: Community Member Icon Luke Chung, FMS, Inc. | About the Contributors

  • Features and Limits of Using the SendObject Method to Send

About the Contributors

Luke Chung is the founder and president of FMS, Inc., a leading provider of custom database solutions and developer tools.


NavigationControl.BorderColor Property (Access)

 Copy code hover
[image]

NavigationControl.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderColor

expression A variable that represents a NavigationControl object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Could not lock file. (Error 3050)

 Copy code hover
[image]

Could not lock file. (Error 3050)
Send feedback

The operating system will not allow the Microsoft Access database engine to create a lock file (.LDB) in the same directory where the database file resides. You need to have write privileges to the directory that contains the database you are trying to open. This error can also occur if you are trying to use the passive shut down/connection control feature while the database is opened exclusively.


CommandButton.HoverThemeColorIndex Property (Access)

 Copy code hover
[image]

CommandButton.HoverThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HoverThemeColorIndex

expression A variable that represents a CommandButton object.

Remarks

The HoverThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 (Default) | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the HoverThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ComboBox.ThemeFontIndex Property (Access)

 Copy code hover
[image]

ComboBox.ThemeFontIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ThemeFontIndex

expression A variable that represents a ComboBox object.

Remarks

The ThemeFontIndex property uses one of the values listed in the following table.

Value | Description
0 | Header font
1 (Default) | Detail font

If no theme is applied, the ThemeFontIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Form.Tag Property (Access)

 Copy code hover
[image]

Form.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents a Form object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Field.DefaultValue Property (DAO)

 Copy code hover
[image]

Field.DefaultValue Property (DAO)
Send feedback

Sets or returns the default value of a Field object. For a Field object not yet appended to the Fields collection, this property is read/write (Microsoft Access workspaces only).

Syntax

expression .DefaultValue

expression A variable that represents a Field object.

Remarks

The setting or return value is a String data type that can contain a maximum of 255 characters. It can be either text or an expression. If the property setting is an expression, it can't contain user-defined functions, Microsoft Access database engine SQL aggregate functions, or references to queries, forms, or other Field objects.

Note Note

You can also set the DefaultValue property of a Field object on a TableDef object to a special value called "GenUniqueID( )". This causes a random number to be assigned to this field whenever a new record is added or created, thereby giving each record a unique identifier. The field's Type property must be Long.

The availability of the DefaultValue property depends on the object that contains the Fields collection, as shown in the following table.

If the Fields collection belongs to an | Then DefaultValue is
Index object | Not supported
QueryDef object | Read-only
Recordset object | Read-only
Relation object | Not supported
TableDef object | Read/write

When a new record is created, the DefaultValue property setting is automatically entered as the value for the field. You can change the field value by setting its Value property.

The DefaultValue property doesn't apply to AutoNumber and Long Binary fields.

Example

This example uses the DefaultValue property to alert the user of a field's normal value while prompting for input. In addition, it demonstrates how new records will be filled using DefaultValue in the absence of any other input. The DefaultPrompt function is required for this procedure to run.

VBA Copy code Copy code
Sub DefaultValueX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim strOldDefault As String
 Dim rstEmployees As Recordset
 Dim strMessage As String
 Dim strCode As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set tdfEmployees = dbsNorthwind.TableDefs!Employees

 ' Store original DefaultValue information and set the
 ' property to a new value.
 strOldDefault = _
 tdfEmployees.Fields!PostalCode.DefaultValue
 tdfEmployees.Fields!PostalCode.DefaultValue = "98052"

 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", _
 dbOpenDynaset)

 With rstEmployees
 ' Add a new record to the Recordset.
 .AddNew
 !FirstName = "Bruce"
 !LastName = "Oberg"

 ' Get user input. If user enters something, the field
 ' will be filled with that data; otherwise, it will be
 ' filled with the DefaultValue information.
 strMessage = "Enter postal code for " & vbCr & _
 !FirstName & " " & !LastName & ":"
 strCode = DefaultPrompt(strMessage, !PostalCode)
 If strCode <> "" Then !PostalCode = strCode
 .Update

 ' Go to new record and print information.
 .Bookmark = .LastModified
 Debug.Print " FirstName = " & !FirstName
 Debug.Print " LastName = " & !LastName
 Debug.Print " PostalCode = " & !PostalCode

 ' Delete new record because this is a demonstration.
 .Delete
 .Close
 End With

 ' Restore original DefaultValue property because this is a
 ' demonstration.
 tdfEmployees.Fields!PostalCode.DefaultValue = _
 strOldDefault

 dbsNorthwind.Close

End Sub

Function DefaultPrompt(strPrompt As String, _
 fldTemp As Field) As String

 Dim strFullPrompt As String

 ' Ask user for new DefaultValue setting for the specified
 ' Field object.
 strFullPrompt = strPrompt & vbCr & _
 "[Default = " & fldTemp.DefaultValue & _
 ", Cancel - use default]"
 DefaultPrompt = InputBox(strFullPrompt)

End Function


OldConstants Enumeration

 Copy code hover
[image]

OldConstants Enumeration
Send feedback

Published: July 16, 2012

These constants are provided for backward compatibility with Microsoft Access version 2.0.

Name | Value | Description
A_ADD | 0 |
A_ALL | 0 |
A_ANYWHERE | 0 |
A_ATTACH | 2 |
A_COPY | 3 |
A_CURRENT | 1 |
A_CUT | 2 |
A_DELETE | 6 |
A_DELETE_V2 | 7 |
A_DESIGN | 1 |
A_DIALOG | 3 |
A_DOWN | 1 |
A_DRAFT | 3 |
A_EDIT | 1 |
A_EDITMENU | 1 |
A_ENTIRE | 1 |
A_EXIT | 2 |
A_EXPORT | 1 |
A_EXPORTDELIM | 2 |
A_EXPORTFIXED | 3 |
A_EXPORTMERGE | 4 |
A_FILE | 0 |
A_FIRST | 2 |
A_FORM | 2 |
A_FORMATRTF | Rich |
A_FORMATTXT | MS-DOS |
A_FORMATXLS | Microsoft |
A_FORMBAR | 0 |
A_FORMDS | 3 |
A_GOTO | 4 |
A_HIDDEN | 1 |
A_HIGH | 0 |
A_ICON | 2 |
A_IMPORT | 0 |
A_IMPORTDELIM | 0 |
A_IMPORTFIXED | 1 |
A_LAST | 3 |
A_LOW | 2 |
A_MACRO | 4 |
A_MEDIUM | 1 |
A_MENU_VER1X | 11 |
A_MENU_VER20 | 20 |
A_MODULE | 5 |
A_NEW | 0 |
A_NEWREC | 5 |
A_NEXT | 1 |
A_NORMAL | 0 |
A_OBJECT | 14 |
A_OBJECTUPDATE | 3 |
A_OBJECTVERB | 0 |
A_PAGES | 2 |
A_PASTE | 4 |
A_PREVIEW | 2 |
A_PREVIOUS | 0 |
A_PRINTALL | 0 |
A_PROMPT | 0 |
A_QUERY | 1 |
A_READONLY | 2 |
A_RECORDSMENU | 3 |
A_REFRESH | 2 |
A_REPORT | 3 |
A_SAVE | 1 |
A_SAVEFORM | 2 |
A_SAVEFORMAS | 3 |
A_SAVERECORD | 4 |
A_SELECTALLRECORDS | 8 |
A_SELECTALLRECORDS_V2 | 9 |
A_SELECTION | 1 |
A_SELECTRECORD | 7 |
A_SELECTRECORD_V2 | 8 |
A_START | 2 |
A_TABLE | 0 |
A_TOOLBAR_NO | 2 |
A_TOOLBAR_WHERE_APPROP | 1 |
A_TOOLBAR_YES | 0 |
A_UNDO | 0 |
A_UNDOFIELD | 1 |
A_UP | 0 |
ALT_MASK | 4 |
CTRL_MASK | 2 |
DATA_ERRADDED | 2 |
DATA_ERRCONTINUE | 0 |
DATA_ERRDISPLAY | 1 |
DB_APPENDONLY | 8 |
DB_ATTACHEDODBC | 536870912 |
DB_ATTACHEDTABLE | 1073741824 |
DB_ATTACHEXCLUSIVE | 65536 |
DB_ATTACHSAVEPWD | 131072 |
DB_AUTOINCRFIELD | 16 |
DB_BINARY | 9 |
DB_BOOLEAN | 1 |
DB_BYTE | 2 |
DB_CONSISTENT | 32 |
DB_CURRENCY | 5 |
DB_DATE | 8 |
DB_DECRYPT | 4 |
DB_DENYREAD | 2 |
DB_DENYWRITE | 1 |
DB_DESCENDING | 1 |
DB_DOUBLE | 7 |
DB_ENCRYPT | 2 |
DB_FAILONERROR | 128 |
DB_FIXEDFIELD | 1 |
DB_FORWARDONLY | 256 |
DB_FREELOCKS | 1 |
DB_HIDDENOBJECT | 1 |
DB_IGNORENULL | 8 |
DB_INCONSISTENT | 16 |
DB_INTEGER | 3 |
DB_LANG_ARABIC | ;LANGID |
DB_LANG_CYRILLIC | ;LANGID |
DB_LANG_CZECH | ;LANGID |
DB_LANG_DUTCH | ;LANGID |
DB_LANG_GENERAL | ;LANGID |
DB_LANG_GREEK | ;LANGID |
DB_LANG_HEBREW | ;LANGID |
DB_LANG_HUNGARIAN | ;LANGID |
DB_LANG_ICELANDIC | ;LANGID |
DB_LANG_NORDIC | ;LANGID |
DB_LANG_NORWDAN | ;LANGID |
DB_LANG_POLISH | ;LANGID |
DB_LANG_SPANISH | ;LANGID |
DB_LANG_SWEDFIN | ;LANGID |
DB_LANG_TURKISH | ;LANGID |
DB_LONG | 4 |
DB_LONGBINARY | 11 |
DB_MEMO | 12 |
DB_NONULLS | 3 |
DB_OLE | 11 |
DB_OPEN_DYNASET | 2 |
DB_OPEN_SNAPSHOT | 4 |
DB_OPEN_TABLE | 1 |
DB_OPTIONINIPATH | 1 |
DB_PRIMARY | 2 |
DB_PROHIBITNULL | 4 |
DB_QACTION | 240 |
DB_QAPPEND | 64 |
DB_QCROSSTAB | 16 |
DB_QDDL | 96 |
DB_QDELETE | 32 |
DB_QMAKETABLE | 80 |
DB_QSELECT | 0 |
DB_QSETOPERATION | 128 |
DB_QSPTBULK | 144 |
DB_QSQLPASSTHROUGH | 112 |
DB_QUERYDEF | 5 |
DB_QUPDATE | 48 |
DB_READONLY | 4 |
DB_RELATIONDELETECASCADE | 4096 |
DB_RELATIONDONTENFORCE | 2 |
DB_RELATIONINHERITED | 4 |
DB_RELATIONLEFT | 16777216 |
DB_RELATIONRIGHT | 33554432 |
DB_RELATIONUNIQUE | 1 |
DB_RELATIONUPDATECASCADE | 256 |
DB_SEC_CREATE | 1 |
DB_SEC_DBCREATE | 1 |
DB_SEC_DBEXCLUSIVE | 4 |
DB_SEC_DBOPEN | 2 |
DB_SEC_DELETE | 65536 |
DB_SEC_DELETEDATA | 128 |
DB_SEC_FRMRPT_EXECUTE | 256 |
DB_SEC_FRMRPT_READDEF | 4 |
DB_SEC_FRMRPT_WRITEDEF | 65548 |
DB_SEC_FULLACCESS | 1048575 |
DB_SEC_INSERTDATA | 32 |
DB_SEC_MAC_EXECUTE | 8 |
DB_SEC_MAC_READDEF | 10 |
DB_SEC_MAC_WRITEDEF | 65542 |
DB_SEC_MOD_READDEF | 2 |
DB_SEC_MOD_WRITEDEF | 65542 |
DB_SEC_NOACCESS | 0 |
DB_SEC_READDEF | 4 |
DB_SEC_READSEC | 131072 |
DB_SEC_REPLACEDATA | 64 |
DB_SEC_RETRIEVEDATA | 20 |
DB_SEC_WRITEDEF | 65548 |
DB_SEC_WRITEOWNER | 524288 |
DB_SEC_WRITESEC | 262144 |
DB_SINGLE | 6 |
DB_SORTARABIC | 267 |
DB_SORTCYRILLIC | 263 |
DB_SORTCZECH | 264 |
DB_SORTDUTCH | 259 |
DB_SORTGENERAL | 256 |
DB_SORTGREEK | 269 |
DB_SORTHEBREW | 268 |
DB_SORTHUNGARIAN | 265 |
DB_SORTICELANDIC | 262 |
DB_SORTNORWDAN | 261 |
DB_SORTPDXINTL | 4096 |
DB_SORTPDXNOR | 4098 |
DB_SORTPDXSWE | 4097 |
DB_SORTPOLISH | 266 |
DB_SORTSPANISH | 258 |
DB_SORTSWEDFIN | 260 |
DB_SORTTURKISH | 270 |
DB_SORTUNDEFINED | -1 |
DB_SQLPASSTHROUGH | 64 |
DB_SYSTEMOBJECT | -2147483646 |
DB_TABLE | 1 |
DB_TEXT | 10 |
DB_UNIQUE | 1 |
DB_UPDATABLEFIELD | 32 |
DB_VARIABLEFIELD | 2 |
DB_VERSION10 | 1 |
DB_VERSION11 | 8 |
DB_VERSION20 | 16 |
DELETE_CANCEL | 1 |
DELETE_OK | 0 |
DELETE_USER_CANCEL | 2 |
LB_CLOSE | 8 |
LB_END | 9 |
LB_GETCOLUMNCOUNT | 4 |
LB_GETCOLUMNWIDTH | 5 |
LB_GETFORMAT | 7 |
LB_GETROWCOUNT | 3 |
LB_GETVALUE | 6 |
LB_INITIALIZE | 0 |
LB_OPEN | 1 |
LEFT_BUTTON | 1 |
MIDDLE_BUTTON | 4 |
OBJSTATE_DIRTY | 2 |
OBJSTATE_NEW | 4 |
OBJSTATE_OPEN | 1 |
OLE_CHANGED | 0 |
OLE_CLOSED | 2 |
OLE_RELEASE | 5 |
OLE_RENAMED | 3 |
OLE_SAVED | 1 |
RIGHT_BUTTON | 2 |
SHIFT_MASK | 1 |
SYSCMD_ACCESSDIR | 9 |
SYSCMD_ACCESSVER | 7 |
SYSCMD_CLEARHELPTOPIC | 11 |
SYSCMD_CLEARSTATUS | 5 |
SYSCMD_GETOBJECTSTATE | 10 |
SYSCMD_INIFILE | 8 |
SYSCMD_INITMETER | 1 |
SYSCMD_REMOVEMETER | 3 |
SYSCMD_RUNTIME | 6 |
SYSCMD_SETSTATUS | 4 |
SYSCMD_UPDATEMETER | 2 |
V_CURRENCY | 6 |
V_DATE | 7 |
V_DOUBLE | 5 |
V_EMPTY | 0 |
V_INTEGER | 2 |
V_LONG | 3 |
V_NULL | 1 |
V_SINGLE | 4 |
V_STRING | 8 |


SetLocalVar Macro Action

 Copy code hover
[image]

SetLocalVar Macro Action
Send feedback

The SetLocalVar action creates a temporary variable and set it to a specific value.

Setting

The SetLocalVar action has the following arguments.

Argument | Required | Description
Name | Yes | A string that specifies the name of the variable.
Expression | Yes | An expression that will be used to set the value for this temporary variable. Do not precede the expression with the equal sign (=). You can click the Build button to use the Expression Builder to set this argument.

Remarks

Variables created by the SetLocalVar action can be used only in the macro in which they are defined. Use the SetTempVar action to define a variable that can be used in another macro, in an event procedure, or on a form or report.

Once a temporary variable has been created, you can refer to it in an expression. For example, if you created a temporary variable named TotalAmount, you could use the variable as the control source for a text box by using the following syntax.

Copy code Copy code
=[LocalVars]![TotalAmount]
Note Note

In a Data Macro, you do not have to use the LocalVars collection to refer to a variable. For example, if you created a temporary variable in a Data Macro named TotalAmount, you could use the variable as the control source for a text box by using the following syntax
=[TotalAmount]


WSParameters.Count Property (Access)

 Copy code hover
[image]

WSParameters.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Version Information

Version Added: Access 2010

Syntax

expression .Count

expression A variable that represents a WSParameters object.

See also

Concepts

WSParameters Collection

Other resources

WSParameters Object Members


Update Function (Access 2013 custom web app)

 Copy code hover
[image]

Update Function (Access 2013 custom web app)
Send feedback

Returns whether an INSERT or UPDATE operation was attempted on the specified field.

Syntax

Update(Column)

The Update function contains the following arguments.

Argument name | Description
Column | The name of the field to check for an INSERT or UPDATE operation.

Remarks

The Update function returns TRUE regardless of whether an INSERT or UPDATE attempt is successful.


SubForm.TopPadding Property (Access)

 Copy code hover
[image]

SubForm.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the subform and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .TopPadding

expression A variable that represents a SubForm object.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Form.Controls Property (Access)

 Copy code hover
[image]

Form.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Syntax

expression .Controls

expression A variable that represents a Form object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

Form Object

Other resources

Form Object Members


DBEngine Methods (DAO)

 Copy code hover
[image]

DBEngine Methods (DAO)
Send feedback

In this section

  • DBEngine.BeginTrans Method (DAO)

  • DBEngine.CommitTrans Method (DAO)

  • DBEngine.CompactDatabase Method (DAO)

  • DBEngine.CreateDatabase Method (DAO)

  • DBEngine.CreateWorkspace Method (DAO)

  • DBEngine.Idle Method (DAO)

  • DBEngine.OpenConnection Method (DAO)

  • DBEngine.OpenDatabase Method (DAO)

  • DBEngine.RegisterDatabase Method (DAO)

  • DBEngine.Rollback Method (DAO)

  • DBEngine.SetOption Method (DAO)


CursorLocation Property (ADO)

 Copy code hover
[image]

CursorLocation Property (ADO)
Send feedback

Indicates the location of the cursor service.

Settings And Return Values

Sets or returns a Long value that can be set to one of the CursorLocationEnum values.

Remarks

This property allows you to choose between various cursor libraries accessible to the provider. Usually, you can choose between using a client-side cursor library or one that is located on the server.

This property setting affects connections established only after the property has been set. Changing the CursorLocation property has no effect on existing connections.

Cursors returned by the Execute method inherit this setting. Recordset objects will automatically inherit this setting from their associated connections.

This property is read/write on a Connection or a closed Recordset, and read-only on an open Recordset.

Remote Data Service UsageWhen used on a client-side Recordset or Connection object, the CursorLocation property can only be set to adUseClient.


HelpContext, HelpFile Properties (ADO)

 Copy code hover
[image]

HelpContext, HelpFile Properties (ADO)
Send feedback

Indicates the help file and topic associated with an Error object.

Return Values

  • HelpContextID — returns a context ID, as a Long value, for a topic in a Help file.

  • HelpFile — returns a String value that evaluates to a fully resolved path to a Help file.

Remarks

If a Help file is specified in the HelpFile property, the HelpContext property is used to automatically display the Help topic it identifies. If there is no relevant help topic available, the HelpContext property returns zero and the HelpFile property returns a zero-length string ("").


Rectangle.BackThemeColorIndex Property (Access)

 Copy code hover
[image]

Rectangle.BackThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackThemeColorIndex

expression A variable that represents a Rectangle object.

Remarks

The BackThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BackThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Background Color to the Text 2 color by setting the BackThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BackThemeColorIndex=2

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


TableDef.CreateProperty Method (DAO)

 Copy code hover
[image]

TableDef.CreateProperty Method (DAO)
Send feedback

Creates a new user-defined Property object (Microsoft Access workspaces only).

Syntax

expression .CreateProperty(Name, Type, Value, DDL)

expression A variable that represents a TableDef object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Optional | Variant | A String that uniquely names the new Property object. See the Name property for details on valid Property names.
Type | Optional | Variant | A constant that defines the data type of the new Property object. See the Type property for valid data types.
Value | Optional | Variant | A Variant containing the initial property value. See the Value property for details.
DDL | Optional | Variant | A Variant (Boolean subtype) that indicates whether or not the Property is a DDL object. The default is False. If DDL is True, users can't change or delete this Property object unless they have dbSecWriteDef permission.

Return Value

Property

Remarks

You can create a user-defined Property object only in the Properties collection of an object that is persistent.

If you omit one or more of the optional parts when you use CreateProperty, you can use an appropriate assignment statement to set or reset the corresponding property before you append the new object to a collection. After you append the object, you can alter some but not all of its property settings. See the Name, Type, and Value property topics for more details.

If name refers to an object that is already a member of the collection, a run-time error occurs when you use the Append method.

To remove a user-defined Property object from the collection, use the Delete method on the Properties collection. You can't delete built-in properties.

Note Note

If you omit the DDL argument, it defaults to False (non-DDL). Because no corresponding DDL property is exposed, you must delete and re-create a Property object you want to change from DDL to non-DDL.


CheckBox.ColumnWidth Property (Access)

 Copy code hover
[image]

CheckBox.ColumnWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.

Syntax

expression .ColumnWidth

expression A variable that represents a CheckBox object.

Remarks

In Visual Basic , the ColumnWidth property setting is an Integer value that represents the column width in twips. You can specify a width or use one of the following predefined settings.

Setting | Description
0 | Hides the column.
-1 | (Default) Sizes the column to the default width.
Note Note

The ColumnWidth property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

Setting this property to 0, or resizing the field to a zero width in Datasheet view, sets the field's ColumnHidden property to True (-1) and hides the field in Datasheet view.

Setting a field's ColumnHidden property to False (0) restores the field's ColumnWidth property to the value it had before the field was hidden. For example, if the ColumnWidth property was -1 prior to the field being hidden by setting the property to 0, changing the field's ColumnHidden property to False resets the ColumnWidth to -1.

The ColumnWidth property for a field isn't available when the field's ColumnHidden property is set to True.

Example

This example takes effect in Datasheet view of the open Customers form. It sets the row height to 450 twips and sizes the column to fit the size of the visible text.

VBA Copy code Copy code
Forms![Customers].RowHeight = 450
Forms![Customers]![Address].ColumnWidth = -2

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


AccessObject Object (Access)

 Copy code hover
[image]

AccessObject Object (Access)
See also Send feedback

Published: July 16, 2012

An AccessObject object refers to a particular Microsoft Access object.

Remarks

An AccessObject object includes information about one instance of an object. The following table list the types of objects each AccessObject describes, the name of its collection, and what type of information AccessObject contains.

AccessObject | Collection | Contains information about
Database diagram | AllDatabaseDiagrams | Saved database diagrams
Form | AllForms | Saved forms
Function | AllFunctions | Saved functions
Macro | AllMacros | Saved macros
Module | AllModules | Saved modules
Query | AllQueries | Saved queries
Report | AllReports | Saved reports
Stored procedure | AllStoredProcedures | Saved stored procedures
Table | AllTables | Saved tables
View | AllViews | Saved views

Because an AccessObject object corresponds to an existing object, you can't create new AccessObject objects or delete existing ones. To refer to an AccessObject object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

AllForms(0)

AllForms("name")

AllForms![name]

See also

Concepts

Access Object Model Reference

Other resources

AccessObject Object Members


Create Method Example (VC++)

 Copy code hover
[image]

Create Method Example (VC++)
Send feedback

The following code shows how to create a new Microsoft Jet database with the Create method.

Copy code Copy code

// BeginCreateDatabaseCpp
#import "c:\Program Files\Common Files\system\ado\msadox.dll" no_namespace
#import "c:\Program Files\Common Files\system\ado\msado15.dll"

#define TESTHR(x) if FAILED(x) _com_issue_error(x);

#include "iostream.h"
#include "stdio.h"
#include "conio.h"

//Function declarations
void CreateDatabaseX(void);

//------------------------------------------------------------//
//Main Function
//Purpose: Test Driver
//------------------------------------------------------------//
void main()
{
 HRESULT hr = S_OK;

 hr = ::CoInitialize(NULL);
 if(SUCCEEDED(hr))
 {
 CreateDatabaseX();

 //Wait here for the user to see the output
 printf("Press any key to continue...");
 getch();

 ::CoUninitialize();
 }
}

//------------------------------------------------------------//
//CreateDatabaseX
//Purpose: create a new Jet database with the Create method
//------------------------------------------------------------//
void CreateDatabaseX()
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.

 _CatalogPtr m_pCatalog = NULL;

 //Set ActiveConnection of Catalog to this string
 _bstr_t strcnn("Provider='Microsoft.JET.OLEDB.4.0';"
 "Data source = c:\\new.mdb");
 try
 {
 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof (Catalog)));
 m_pCatalog->Create(strcnn);
 printf("Database 'c:\\new.mdb' is created.\n");
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);

 }
 catch(...)
 {
 cout << "Error occured in CreateDatabaseX...."<< endl;
 }

}
// EndCreateDatabaseCpp


Error Properties, Methods, and Events (ADO)

 Copy code hover
[image]

Error Properties, Methods, and Events (ADO)
Send feedback

Properties

Description Property

HelpContext, HelpFile Properties

NativeError Property

Number Property

Source Property (ADO Error)

SQLState Property

Methods

None.

Events

None.


CheckBox.LeftPadding Property (Access)

 Copy code hover
[image]

CheckBox.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the check box and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .LeftPadding

expression A variable that represents a CheckBox object.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Report.GroupLevel Property (Access)

 Copy code hover
[image]

Report.GroupLevel Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the GroupLevel property in Visual Basic to refer to the group level you are grouping or sorting on in a report. Read-only GroupLevel object.

Syntax

expression .GroupLevel(Index)

expression A variable that represents a Report object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Long | The group level, starting with 0. The first field or expression you group on is group level 0, the second is group level 1, and so on.

Remarks

The following sample settings show how you use the GroupLevel property to refer to a group level.

Group level | Refers to
GroupLevel(0) | The first field or expression you sort or group on.
GroupLevel(1) | The second field or expression you sort or group on.
GroupLevel(2) | The third field or expression you sort or group on.

The GroupLevel property setting is an array in which each entry identifies a group level. You can have up to 10 group levels (0 to 9).

Note Note

You can use this property only by using Visual Basic to set the SortOrder , GroupOn , GroupInterval , KeepTogether , and ControlSource properties. You set these properties in the Open event procedure of a report.

In reports, you can group or sort on more than one field or expression. Each field or expression you group or sort on is a group level.

You specify the fields and expressions to sort and group on by using the CreateGroupLevel method.

If a group is already defined for a report (the GroupLevel property is set to 0), then you can use the ControlSource property to change the group level in the report's Open event procedure.

Example

The following code changes the ControlSource property to a value contained in the txtPromptYou text box on the open form named SortForm:

VBA Copy code Copy code
Private Sub Report_Open(Cancel As Integer)
 Me.GroupLevel(0).ControlSource _
 = Forms!SortForm!txtPromptYou
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


Form.DatasheetBorderLineStyle Property (Access)

 Copy code hover
[image]

Form.DatasheetBorderLineStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Byte indicating the line style to use for the border of the specified datasheet. Read/write.

Syntax

expression .DatasheetBorderLineStyle

expression A variable that represents a Form object.

Remarks

Valid values are between zero and eight. Values greater than eight are ignored; negative values or values above 255 cause an error.

Value | Description
0 | Transparent border
1 | Solid
2 | Dashes
3 | Short dashes
4 | Dots
5 | Sparse dots
6 | Dash-dot
7 | Dash-dot-dot
8 | Double solid

Example

This example sets the datasheet border line style on the first open form to short dashes. The form must be set to Datasheet View in order for you to see the change.

VBA Copy code Copy code
Forms(0).DatasheetBorderLineStyle = 3

See also

Concepts

Form Object

Other resources

Form Object Members


CommandButton.PressedShade Property (Access)

 Copy code hover
[image]

CommandButton.PressedShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the PressedColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .PressedShade

expression A variable that represents a CommandButton object.

Remarks

The PressedShade property contains a numeric expression that can be used to darken the theme color in the PressedColor property. The default value of the PressedShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


EmptyCell.Name Property (Access)

 Copy code hover
[image]

EmptyCell.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .Name

expression A variable that represents an EmptyCell object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


OptionGroup.SetFocus Method (Access)

 Copy code hover
[image]

OptionGroup.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Syntax

expression .SetFocus

expression A variable that represents an OptionGroup object.

Return Value

Nothing

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.

Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.

Example

The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:

VBA Copy code Copy code
Forms!Employees!EmployeeID.SetFocus

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


OptionButton.Name Property (Access)

 Copy code hover
[image]

OptionButton.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents an OptionButton object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Destination synchronizer is not configured to support indirect synchronization, and the destination replica is unavailable for direct synchronization. (Error 3516)

 Copy code hover
[image]

Destination synchronizer is not configured to support indirect synchronization, and the destination replica is unavailable for direct synchronization. (Error 3516)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


The directory you queried for a list of replicas is not a managed directory. (Error 3573)

 Copy code hover
[image]

The directory you queried for a list of replicas is not a managed directory. (Error 3573)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


WSParameters Properties (Access)

 Copy code hover
[image]

WSParameters Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Object.
Parent | Returns the parent object for the specified object. Read-only.


Form.OrderByOnLoad Property (Access)

 Copy code hover
[image]

Form.OrderByOnLoad Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the sorting specified by the OrderBy property is applied when the form is loaded. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .OrderByOnLoad

expression A variable that represents a Form object.

See also

Concepts

Form Object

Other resources

Form Object Members


ReturnVar Object (Access)

 Copy code hover
[image]

ReturnVar Object (Access)
Send feedback

Published: July 16, 2012

Represents a variable that was initialized by the SetReturnVar function in a Data Macro.

Version Information

Version Added: Access 2010

Remarks

A ReturnVar object provides a convenient way to use values set in a Data Macro.

Although a ReturnVar object can be used to store information for use in VBA procedures, it does not have the same functionality as a VBA variable.

  • By default, a ReturnVar object remains in memory until the next time that the RunDataMacro method is used.

    Use the Value poperty of the ReturnVar

  • A ReturnVar object can store only text or numeric data. ReturnVar objects cannot store objects.

To refer to a TempVar object in a collection by its ordinal number or by its Name property setting, use the following syntax form:

Copy code Copy code
ReturnVars![name]


Report.Parent Property (Access)

 Copy code hover
[image]

Report.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a Report object.

Remarks

You can use the Parent property to determine which form or report is currently the parent when you have a subform or subreport that has been inserted in multiple forms or reports.

For example, you might insert an OrderDetails subform into both a form and a report. The following example uses the Parent property to refer to the OrderID field, which is present on the main form and report. You can enter this expression in a bound control on the subform.

VBA Copy code Copy code
=Parent!OrderID

See also

Concepts

Report Object

Other resources

Report Object Members


Field2.Attributes Property (DAO)

 Copy code hover
[image]

Field2.Attributes Property (DAO)
Send feedback

Sets or returns a value that indicates one or more characteristics of a Field2 object. Read/write Long.

Syntax

expression .Attributes

expression A variable that represents a Field2 object.

Remarks

The value specifies characteristics of the field represented by the Field2 object and can be a combination of these constants.

Constant | Description
dbAutoIncrField | The field value for new records is automatically incremented to a unique Long integer that can't be changed (in a Microsoft Access workspace, supported only for Microsoft Access database engine database tables).
dbDescending | The field is sorted in descending (Z to A or 100 to 0) order; this option applies only to a Field2 object in a Fields collection of an Index object. If you omit this constant, the field is sorted in ascending (A to Z or 0 to 100) order. This is the default value for Index and TableDef fields (Microsoft Access workspaces only)..
dbFixedField | The field size is fixed (default for Numeric fields).
dbHyperlinkField | The field contains hyperlink information (Memo fields only).
dbSystemField | The field stores replication information for replicas; you can't delete this type of field (Microsoft Access workspaces only).
dbUpdatableField | The field value can be changed.
dbVariableField | The field size is variable (Text fields only).

For an object not yet appended to a collection, this property is read/write. For an appended Field2 object, the availability of the Attributes property depends on the object that contains the Fields collection.

If the Field object belongs to an | Then Attributes is
Index object | Read/write until the TableDef object that the Index object is appended to is appended to a Database object; then the property is read-only.
QueryDef object | Read-only
Recordset object | Read-only
Relation object | Not supported
TableDef object | Read/write

When you set multiple attributes, you can combine them by summing the appropriate constants. Any invalid values are ignored without producing an error.

Example

This example displays the Attributes property for Field2, Relation, and TableDef objects in the Northwind database.

Copy code Copy code
Sub AttributesX()

 Dim dbsNorthwind As Database
 Dim fldLoop As Field2
 Dim relLoop As Relation
 Dim tdfloop As TableDef

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind

 ' Display the attributes of a TableDef object's
 ' fields.
 Debug.Print "Attributes of fields in " & _
 .TableDefs(0).Name & " table:"
 For Each fldLoop In .TableDefs(0).Fields
 Debug.Print " " & fldLoop.Name & " = " & _
 fldLoop.Attributes
 Next fldLoop

 ' Display the attributes of the Northwind database's
 ' relations.
 Debug.Print "Attributes of relations in " & _
 .Name & ":"
 For Each relLoop In .Relations
 Debug.Print " " & relLoop.Name & " = " & _
 relLoop.Attributes
 Next relLoop

 ' Display the attributes of the Northwind database's
 ' tables.
 Debug.Print "Attributes of tables in " & .Name & ":"
 For Each tdfloop In .TableDefs
 Debug.Print " " & tdfloop.Name & " = " & _
 tdfloop.Attributes
 Next tdfloop

 .Close
 End With

End Sub


Field2.Expression Property (DAO)

 Copy code hover
[image]

Field2.Expression Property (DAO)
Send feedback

Gets or sets an expression that represents the formula for a calculated field. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .Expression

expression A variable that represents a Field2 object.

Remarks

In Access 2013, you can create table fields that calculate values. The calculations can include values from fields in the same table as well as built-in Access functions.

The calculation cannot include fields from other tables or queries.

The results of the calculation are read-only.

Example

The following example shows how to create a calculated field. The CreateField method creates a field named FullName. The Expression property is then set to the expression that calculates the value of the field.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Sub CreateCalculatedField()
    Dim dbs As DAO.Database
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field2

    ' get the database
    Set dbs = CurrentDb()

    ' create the table
    Set tdf = dbs.CreateTableDef("tblContactsCalcField")

    ' create the fields: first name, last name
    tdf.Fields.Append tdf.CreateField("FirstName", dbText, 20)
    tdf.Fields.Append tdf.CreateField("LastName", dbText, 20)

    ' create the calculated field: full name
    Set fld = tdf.CreateField("FullName", dbText, 50)
    fld.Expression = "[FirstName] & "" "" & [LastName]"
    tdf.Fields.Append fld

    ' append the table and cleanup
    dbs.TableDefs.Append tdf

Cleanup:
    Set fld = Nothing
    Set tdf = Nothing
    Set dbs = Nothing
End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Form.OnMouseUp Property (Access)

 Copy code hover
[image]

Form.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Syntax

expression .OnMouseUp

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

Form Object

Other resources

Form Object Members


Report.MinMaxButtons Property (Access)

 Copy code hover
[image]

Report.MinMaxButtons Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the MinMaxButtons property to specify whether the Maximize and Minimize buttons will be visible on a report. Read/write Byte.

Syntax

expression .MinMaxButtons

expression A variable that represents a Report object.

Remarks

The MinMaxButtons property uses the following settings.

Setting | Visual Basic | Description
None | 0 | The Maximize and Minimize buttons aren't visible.
Min Enabled | 1 | Only the Minimize button is visible.
Max Enabled | 2 | Only the Maximize button is visible.
Both Enabled | 3 | (Default) Both the Minimize and Maximize buttons are visible.

You can set the MinMaxButtons property only in form Design view.

See also

Concepts

Report Object

Other resources

Report Object Members


OldConstants Enumeration (Access)

 Copy code hover
[image]

OldConstants Enumeration (Access)
Send feedback

Members

Name | Value | Description
A_ADD | 0 |
A_ALL | 0 |
A_ANYWHERE | 0 |
A_ATTACH | 2 |
A_COPY | 3 |
A_CURRENT | 1 |
A_CUT | 2 |
A_DELETE | 6 |
A_DELETE_V2 | 7 |
A_DESIGN | 1 |
A_DIALOG | 3 |
A_DOWN | 1 |
A_DRAFT | 3 |
A_EDIT | 1 |
A_EDITMENU | 1 |
A_ENTIRE | 1 |
A_EXIT | 2 |
A_EXPORT | 1 |
A_EXPORTDELIM | 2 |
A_EXPORTFIXED | 3 |
A_EXPORTMERGE | 4 |
A_FILE | 0 |
A_FIRST | 2 |
A_FORM | 2 |
A_FORMATRTF |  |
A_FORMATTXT |  |
A_FORMATXLS |  |
A_FORMBAR | 0 |
A_FORMDS | 3 |
A_GOTO | 4 |
A_HIDDEN | 1 |
A_HIGH | 0 |
A_ICON | 2 |
A_IMPORT | 0 |
A_IMPORTDELIM | 0 |
A_IMPORTFIXED | 1 |
A_LAST | 3 |
A_LOW | 2 |
A_MACRO | 4 |
A_MEDIUM | 1 |
A_MENU_VER1X | 11 |
A_MENU_VER20 | 20 |
A_MODULE | 5 |
A_NEW | 0 |
A_NEWREC | 5 |
A_NEXT | 1 |
A_NORMAL | 0 |
A_OBJECT | 14 |
A_OBJECTUPDATE | 3 |
A_OBJECTVERB | 0 |
A_PAGES | 2 |
A_PASTE | 4 |
A_PREVIEW | 2 |
A_PREVIOUS | 0 |
A_PRINTALL | 0 |
A_PROMPT | 0 |
A_QUERY | 1 |
A_READONLY | 2 |
A_RECORDSMENU | 3 |
A_REFRESH | 2 |
A_REPORT | 3 |
A_SAVE | 1 |
A_SAVEFORM | 2 |
A_SAVEFORMAS | 3 |
A_SAVERECORD | 4 |
A_SELECTALLRECORDS | 8 |
A_SELECTALLRECORDS_V2 | 9 |
A_SELECTION | 1 |
A_SELECTRECORD | 7 |
A_SELECTRECORD_V2 | 8 |
A_START | 2 |
A_TABLE | 0 |
A_TOOLBAR_NO | 2 |
A_TOOLBAR_WHERE_APPROP | 1 |
A_TOOLBAR_YES | 0 |
A_UNDO | 0 |
A_UNDOFIELD | 1 |
A_UP | 0 |
ALT_MASK | 4 |
CTRL_MASK | 2 |
DATA_ERRADDED | 2 |
DATA_ERRCONTINUE | 0 |
DATA_ERRDISPLAY | 1 |
DB_APPENDONLY | 8 |
DB_ATTACHEDODBC | 536870912 |
DB_ATTACHEDTABLE | 1073741824 |
DB_ATTACHEXCLUSIVE | 65536 |
DB_ATTACHSAVEPWD | 131072 |
DB_AUTOINCRFIELD | 16 |
DB_BINARY | 9 |
DB_BOOLEAN | 1 |
DB_BYTE | 2 |
DB_CONSISTENT | 32 |
DB_CURRENCY | 5 |
DB_DATE | 8 |
DB_DECRYPT | 4 |
DB_DENYREAD | 2 |
DB_DENYWRITE | 1 |
DB_DESCENDING | 1 |
DB_DOUBLE | 7 |
DB_ENCRYPT | 2 |
DB_FAILONERROR | 128 |
DB_FIXEDFIELD | 1 |
DB_FORWARDONLY | 256 |
DB_FREELOCKS | 1 |
DB_HIDDENOBJECT | 1 |
DB_IGNORENULL | 8 |
DB_INCONSISTENT | 16 |
DB_INTEGER | 3 |
DB_LANG_ARABIC |  |
DB_LANG_CYRILLIC |  |
DB_LANG_CZECH |  |
DB_LANG_DUTCH |  |
DB_LANG_GENERAL |  |
DB_LANG_GREEK |  |
DB_LANG_HEBREW |  |
DB_LANG_HUNGARIAN |  |
DB_LANG_ICELANDIC |  |
DB_LANG_NORDIC |  |
DB_LANG_NORWDAN |  |
DB_LANG_POLISH |  |
DB_LANG_SPANISH |  |
DB_LANG_SWEDFIN |  |
DB_LANG_TURKISH |  |
DB_LONG | 4 |
DB_LONGBINARY | 11 |
DB_MEMO | 12 |
DB_NONULLS | 3 |
DB_OLE | 11 |
DB_OPEN_DYNASET | 2 |
DB_OPEN_SNAPSHOT | 4 |
DB_OPEN_TABLE | 1 |
DB_OPTIONINIPATH | 1 |
DB_PRIMARY | 2 |
DB_PROHIBITNULL | 4 |
DB_QACTION | 240 |
DB_QAPPEND | 64 |
DB_QCROSSTAB | 16 |
DB_QDDL | 96 |
DB_QDELETE | 32 |
DB_QMAKETABLE | 80 |
DB_QSELECT | 0 |
DB_QSETOPERATION | 128 |
DB_QSPTBULK | 144 |
DB_QSQLPASSTHROUGH | 112 |
DB_QUERYDEF | 5 |
DB_QUPDATE | 48 |
DB_READONLY | 4 |
DB_RELATIONDELETECASCADE | 4096 |
DB_RELATIONDONTENFORCE | 2 |
DB_RELATIONINHERITED | 4 |
DB_RELATIONLEFT | 16777216 |
DB_RELATIONRIGHT | 33554432 |
DB_RELATIONUNIQUE | 1 |
DB_RELATIONUPDATECASCADE | 256 |
DB_SEC_CREATE | 1 |
DB_SEC_DBCREATE | 1 |
DB_SEC_DBEXCLUSIVE | 4 |
DB_SEC_DBOPEN | 2 |
DB_SEC_DELETE | 65536 |
DB_SEC_DELETEDATA | 128 |
DB_SEC_FRMRPT_EXECUTE | 256 |
DB_SEC_FRMRPT_READDEF | 4 |
DB_SEC_FRMRPT_WRITEDEF | 65548 |
DB_SEC_FULLACCESS | 1048575 |
DB_SEC_INSERTDATA | 32 |
DB_SEC_MAC_EXECUTE | 8 |
DB_SEC_MAC_READDEF | 10 |
DB_SEC_MAC_WRITEDEF | 65542 |
DB_SEC_MOD_READDEF | 2 |
DB_SEC_MOD_WRITEDEF | 65542 |
DB_SEC_NOACCESS | 0 |
DB_SEC_READDEF | 4 |
DB_SEC_READSEC | 131072 |
DB_SEC_REPLACEDATA | 64 |
DB_SEC_RETRIEVEDATA | 20 |
DB_SEC_WRITEDEF | 65548 |
DB_SEC_WRITEOWNER | 524288 |
DB_SEC_WRITESEC | 262144 |
DB_SINGLE | 6 |
DB_SORTARABIC | 267 |
DB_SORTCYRILLIC | 263 |
DB_SORTCZECH | 264 |
DB_SORTDUTCH | 259 |
DB_SORTGENERAL | 256 |
DB_SORTGREEK | 269 |
DB_SORTHEBREW | 268 |
DB_SORTHUNGARIAN | 265 |
DB_SORTICELANDIC | 262 |
DB_SORTNORWDAN | 261 |
DB_SORTPDXINTL | 4096 |
DB_SORTPDXNOR | 4098 |
DB_SORTPDXSWE | 4097 |
DB_SORTPOLISH | 266 |
DB_SORTSPANISH | 258 |
DB_SORTSWEDFIN | 260 |
DB_SORTTURKISH | 270 |
DB_SORTUNDEFINED | -1 |
DB_SQLPASSTHROUGH | 64 |
DB_SYSTEMOBJECT | -2147483646 |
DB_TABLE | 1 |
DB_TEXT | 10 |
DB_UNIQUE | 1 |
DB_UPDATABLEFIELD | 32 |
DB_VARIABLEFIELD | 2 |
DB_VERSION10 | 1 |
DB_VERSION11 | 8 |
DB_VERSION20 | 16 |
DELETE_CANCEL | 1 |
DELETE_OK | 0 |
DELETE_USER_CANCEL | 2 |
LB_CLOSE | 8 |
LB_END | 9 |
LB_GETCOLUMNCOUNT | 4 |
LB_GETCOLUMNWIDTH | 5 |
LB_GETFORMAT | 7 |
LB_GETROWCOUNT | 3 |
LB_GETVALUE | 6 |
LB_INITIALIZE | 0 |
LB_OPEN | 1 |
LEFT_BUTTON | 1 |
MIDDLE_BUTTON | 4 |
OBJSTATE_DIRTY | 2 |
OBJSTATE_NEW | 4 |
OBJSTATE_OPEN | 1 |
OLE_CHANGED | 0 |
OLE_CLOSED | 2 |
OLE_RELEASE | 5 |
OLE_RENAMED | 3 |
OLE_SAVED | 1 |
RIGHT_BUTTON | 2 |
SHIFT_MASK | 1 |
SYSCMD_ACCESSDIR | 9 |
SYSCMD_ACCESSVER | 7 |
SYSCMD_CLEARHELPTOPIC | 11 |
SYSCMD_CLEARSTATUS | 5 |
SYSCMD_GETOBJECTSTATE | 10 |
SYSCMD_INIFILE | 8 |
SYSCMD_INITMETER | 1 |
SYSCMD_REMOVEMETER | 3 |
SYSCMD_RUNTIME | 6 |
SYSCMD_SETSTATUS | 4 |
SYSCMD_UPDATEMETER | 2 |
V_CURRENCY | 6 |
V_DATE | 7 |
V_DOUBLE | 5 |
V_EMPTY | 0 |
V_INTEGER | 2 |
V_LONG | 3 |
V_NULL | 1 |
V_SINGLE | 4 |
V_STRING | 8 |


Data Blocks

 Copy code hover
[image]

Data Blocks
Send feedback

In this section

  • CreateRecord Data Block

  • EditRecord Data Block

  • ForEachRecord Data Block

  • LookupRecord Data Block


WillConnect Event (ADO)

 Copy code hover
[image]

WillConnect Event (ADO)
Send feedback

The WillConnect event is called before a connection starts.

Syntax

WillConnect ConnectionString, UserID, Password, Options, adStatus, pConnection

Parameters

  • ConnectionString

  • A String that contains connection information for the pending connection.

  • UserID

  • A String that contains a user name for the pending connection.

  • Password

  • A String that contains a password for the pending connection.

  • Options

  • A Long value that indicates how the provider should evaluate the ConnectionString. Your only option is adAsyncOpen.

  • adStatus

  • EventStatusEnum

    When this event is called, this parameter is set to adStatusOK by default. It is set to adStatusCantDeny if the event cannot request cancellation of the pending operation.

    Before this event returns, set this parameter to adStatusUnwantedEvent to prevent subsequent notifications. Set this parameter to adStatusCancel to request the connection operation that caused cancellation of this notification.

  • pConnection

  • The Connection object for which this event notification applies. Changes to the parameters of the Connection by the WillConnect event handler will have no effect on the Connection.

Remarks

When WillConnect is called, the ConnectionString, UserID, Password, and Options parameters are set to the values established by the operation that caused this event (the pending connection), and can be changed before the event returns. WillConnect may return a request that the pending connection be canceled.

When this event is canceled, ConnectComplete will be called with its adStatus parameter set to adStatusErrorsOccurred.


WebBrowserControl.OnProgressChange Property (Access)

 Copy code hover
[image]

WebBrowserControl.OnProgressChange Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the value of the On Progress Change box in the property sheet os a Web Browser control. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnProgressChange

expression A variable that represents a WebBrowserControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Form.PivotTableChange Event (Access)

 Copy code hover
[image]

Form.PivotTableChange Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs whenever the specified PivotTable view field, field set, or total is added or deleted.

Syntax

expression .PivotTableChange(Reason)

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Reason | Required | Long | A PivotTableReasonEnum constant that indicates how the PivotTable list changed.

Example

The following example demonstrates the syntax for a subroutine that traps the PivotTableChange event.

VBA Copy code Copy code
Private Sub Form_PivotTableChange(Reason As Long)
 Select Case Reason
 Case OWC.plPivotTableReasonTotalAdded
 MsgBox "A total was added!"
 Case OWC.plPivotTableReasonFieldSetAdded
 MsgBox "A field set was added!"
 Case OWC.plPivotTableReasonFieldAdded
 MsgBox "A field was added!"
 End Select
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Synchronizer could not find any messages to process. (Error 3517)

 Copy code hover
[image]

Synchronizer could not find any messages to process. (Error 3517)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


Invalid index definition. (Error 3285)

 Copy code hover
[image]

Invalid index definition. (Error 3285)
Send feedback

Possible causes:

You are using the same field twice in an index or relationship, which the Microsoft Access database engine does not permit.

You are creating a relationship using fields with data types that do not match. In Microsoft Access database engine databases, you can only relate fields with identical data types or a AutoNumber field with a Number field set to a Long Integer.


BoundObjectFrame.GridlineStyleTop Property (Access)

 Copy code hover
[image]

BoundObjectFrame.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified frame. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleTop

expression A variable that represents a BoundObjectFrame object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


AllMacros Properties (Access)

 Copy code hover
[image]

AllMacros Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


OptionGroup.ColumnHidden Property (Access)

 Copy code hover
[image]

OptionGroup.ColumnHidden Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.

Syntax

expression .ColumnHidden

expression A variable that represents an OptionGroup object.

Remarks

For example, you might want to hide a CustomerAddress field that's too wide so you can view the CustomerName and PhoneNumber fields.

Note Note

The ColumnHidden property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

Hiding a column with the ColumnHidden property in Datasheet view doesn't hide fields from the same column in Form view. Similarly, setting a control's Visible property to False in Form view doesn't hide the corresponding column in Datasheet view.

Note Note

To set or change this property for a table or query by using Visual Basic, you must use a column's Properties collection. For details on using the Properties collection, see Properties .

You can display a field in a query even though the column for the field is hidden in table Datasheet view. You can use values from a hidden column as the criteria for a filter even though the column remains hidden after the filter is applied.

Setting a field's ColumnWidth property to 0, or resizing the field to a zero width in Datasheet view, causes Microsoft Access to set the corresponding ColumnHidden property to True. Unhiding a column restores the ColumnWidthColumnWidth property to the value it had before the field was hidden.

Note Note

The ColumnHidden property is not available in Design view.

Example

The following example hides the ProductID field in Datasheet view of the Products form.

VBA Copy code Copy code
Forms!Products!ProductID.ColumnHidden = -1

The next example also hides the ProductID field in Datasheet view of the Products table.

VBA Copy code Copy code
Public Sub SetColumnHidden()

 Dim dbs As DAO.Database
 Dim fld As DAO.Field
 Dim prp As DAO.Property
 Const conErrPropertyNotFound = 3270

 ' Turn off error trapping.
 On Error Resume Next

 Set dbs = CurrentDb

 ' Set field property.
 Set fld = dbs.TableDefs!Products.Fields!ProductID
 fld.Properties("ColumnHidden") = True

 ' Error may have occurred when value was set.
 If Err.Number <> 0 Then
 If Err.Number <> conErrPropertyNotFound Then
 On Error GoTo 0
 MsgBox "Couldn't set property 'ColumnHidden' " & _
 "on field '" & fld.Name & "'", vbCritical
 Else
 On Error GoTo 0
 Set prp = fld.CreateProperty("ColumnHidden", dbLong, True)
 fld.Properties.Append prp
 End If
 End If

 Set prp = Nothing
 Set fld = Nothing
 Set dbs = Nothing

End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Report.OnMouseDown Property (Access)

 Copy code hover
[image]

Report.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnMouseDown

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the report.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the report's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

See also

Concepts

Report Object

Other resources

Report Object Members


Too many fields defined. (Error 3190)

 Copy code hover
[image]

Too many fields defined. (Error 3190)
Send feedback

You tried to perform an operation that involves more than 255 fields. Reduce the number of fields, and then try the operation again.


ToggleButton.FontWeight Property (Access)

 Copy code hover
[image]

ToggleButton.FontWeight Property (Access)
See also Send feedback

Published: July 16, 2012

Use the FontWeight property to specify the line width that Windows uses to display and print characters in a control. Read/write Integer.

Syntax

expression .FontWeight

expression A variable that represents a ToggleButton object.

Remarks

The FontWeight property uses the following settings.

Setting | Visual Basic
Thin | 100
Extra Light | 200
Light | 300
Normal | 400
Medium | 500
Semi-bold | 600
Bold | 700
Extra Bold | 800
Heavy | 900

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A font's appearance on screen and in print may differ, depending on your computer and printer. For example, a FontWeight property setting of Thin may look identical to Normal on screen but appear lighter when printed.

The FontBold property, which is available only in Visual Basic and macros, can also be used to set the line width for a control's or report's text to bold. The FontBold property gives you a quick way to make text bold; the FontWeight property gives you finer control over the line width setting for text. The following table shows the relationship between these properties' settings.

If | Then
FontBold = False | FontWeight = Normal (400)
FontBold = True | FontWeight = Bold (700)
FontWeight < 700 | FontBold = False
FontWeight > = 700 | FontBold = True

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Report.LostFocus Event (Access)

 Copy code hover
[image]

Report.LostFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The LostFocus event occurs when the specified object loses the focus.

Version Information

Version Added: Access 2007

Syntax

expression .LostFocus

expression A variable that represents a Report object.

Remarks

To run a macro or event procedure when these events occur, set the OnLostFocus property to the name of the macro or to [Event Procedure].

This event occurs when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

See also

Concepts

Report Object

Other resources

Report Object Members


CommandButton.LayoutID Property (Access)

 Copy code hover
[image]

CommandButton.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified button. Read-only Long.

Version Information

Version Added: Access 2007

Syntax

expression .LayoutID

expression A variable that represents a CommandButton object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


TabControl.ForeColor Property (Access)

 Copy code hover
[image]

TabControl.ForeColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ForeColor property to specify the color for text in a control. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ForeColor

expression A variable that represents a TabControl object.

Remarks

You can use this property for controls on forms or reports to make them easy to read or to convey a special meaning. For example, you can change the color of the text in the UnitsInStock control when its value falls below the reorder level.

You can also use this property on reports to create special visual effects when you print with a color printer. When used on a report, this property specifies the printing and drawing color for the Print , Line , and Circle methods.

The ForeColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors for text in controls.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set the Circle property only by using a macro or a Visual Basic event procedure specified in a section's OnPrint event property setting.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Recordset Methods (DAO)

 Copy code hover
[image]

Recordset Methods (DAO)
Send feedback

In this section

  • Recordset.AddNew Method (DAO)

  • Recordset.Cancel Method (DAO)

  • Recordset.CancelUpdate Method (DAO)

  • Recordset.Clone Method (DAO)

  • Recordset.Close Method (DAO)

  • Recordset.CopyQueryDef Method (DAO)

  • Recordset.Delete Method (DAO)

  • Recordset.Edit Method (DAO)

  • Recordset.FillCache Method (DAO)

  • Recordset.FindFirst Method (DAO)

  • Recordset.FindLast Method (DAO)

  • Recordset.FindNext Method (DAO)

  • Recordset.FindPrevious Method (DAO)

  • Recordset.GetRows Method (DAO)

  • Recordset.Move Method (DAO)

  • Recordset.MoveFirst Method (DAO)

  • Recordset.MoveLast Method (DAO)

  • Recordset.MoveNext Method (DAO)

  • Recordset.MovePrevious Method (DAO)

  • Recordset.NextRecordset Method (DAO)

  • Recordset.OpenRecordset Method (DAO)

  • Recordset.Requery Method (DAO)

  • Recordset.Seek Method (DAO)

  • Recordset.Update Method (DAO)


SmartTagActions.Count Property (Access)

 Copy code hover
[image]

SmartTagActions.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents a SmartTagActions object.

See also

Concepts

SmartTagActions Collection

Other resources

SmartTagActions Object Members


Database.Connection Property (DAO)

 Copy code hover
[image]

Database.Connection Property (DAO)
Send feedback

Syntax

expression .Connection

expression A variable that represents a Database object.

Remarks

Use the Connection property to obtain a reference to a Connection object that corresponds to the Database. In DAO, a Connection object and its corresponding Database object are simply two different object variable references to the same object. The Database property of a Connection object and the Connection property of a Database object make it easier to change connections to an ODBC data source through the Microsoft Access database engine to use ODBCDirect.


ORDER BY clause

 Copy code hover
[image]

ORDER BY clause <clause> conflicts with GROUP BY clause. (Error 3094)
Send feedback

This error can occur when you create a select query and specify grouped fields after sorted fields that are not grouped. For example, you created an SQL statement with the specified field out of sequence in the ORDER BY clause. Move the specified field to the left of the ungrouped fields, or remove the specified field from the ORDER BY clause.


CommandButton.InSelection Property (Access)

 Copy code hover
[image]

CommandButton.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents a CommandButton object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


SubForm.BorderWidth Property (Access)

 Copy code hover
[image]

SubForm.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Syntax

expression .BorderWidth

expression A variable that represents a SubForm object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


+ (Add) (Access 2013 custom web app)

 Copy code hover
[image]

+ (Add) (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Adds two numbers. This addition arithmetic operator can also add a number, in days, to a date.

Syntax

expression + expression

expression Any valid expression of any one of the data types in the numeric category except the bit data type. Cannot be used with date or time data types.

Return Value

Returns the data type of the argument with the higher precedence.


The synchronization failed because a design change could not be applied to one of the replicas. (Error 3492)

 Copy code hover
[image]

The synchronization failed because a design change could not be applied to one of the replicas. (Error 3492)
Send feedback

The Microsoft Access database engine attempted to update the database design at one of the replicas. There are several possible reasons why the design could not be updated, including:

  • The object you are trying to update is already open at the replica.

  • You added an enforced relationship to a replica that has a foreign key that references a nonexistent primary key.

For additional information regarding the synchronization failure, look in the MSysSchemaProb table, either at the Design Master or the replica that was the target of the synchronization.


Update and CancelUpdate Methods Example (VB)

 Copy code hover
[image]

Update and CancelUpdate Methods Example (VB)
Send feedback

This example demonstrates the Update method in conjunction with the CancelUpdate method.

Copy code Copy code

'BeginUpdateVB
Public Sub Main()
 On Error GoTo ErrorHandler

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

 ' recordset and connection variables
 Dim rstEmployees As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim strSQLEmployees As String
 ' buffer variables
 Dim strOldFirst As String
 Dim strOldLast As String
 Dim strMessage As String

 ' Open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open recordset to enable changes
 Set rstEmployees = New ADODB.Recordset
 strSQLEmployees = "SELECT fname, lname FROM Employee ORDER BY lname"
 rstEmployees.Open strSQLEmployees, Cnxn, adOpenKeyset, adLockOptimistic, adCmdText

 ' Store original data
 strOldFirst = rstEmployees!fname
 strOldLast = rstEmployees!lname
 ' Change data in edit buffer
 rstEmployees!fname = "Linda"
 rstEmployees!lname = "Kobara"

 ' Show contents of buffer and get user input
 strMessage = "Edit in progress:" & vbCr & _
 " Original data = " & strOldFirst & " " & _
 strOldLast & vbCr & " Data in buffer = " & _
 rstEmployees!fname & " " & rstEmployees!lname & vbCr & vbCr & _
 "Use Update to replace the original data with " & _
 "the buffered data in the Recordset?"

 If MsgBox(strMessage, vbYesNo) = vbYes Then
 rstEmployees.Update
 Else
 rstEmployees.CancelUpdate
 End If

 ' show the resulting data
 MsgBox "Data in recordset = " & rstEmployees!fname & " " & _
 rstEmployees!lname

 ' restore original data because this is a demonstration
 If Not (strOldFirst = rstEmployees!fname And _
 strOldLast = rstEmployees!lname) Then
 rstEmployees!fname = strOldFirst
 rstEmployees!lname = strOldLast
 rstEmployees.Update
 End If

 ' clean up
 rstEmployees.Close
 Cnxn.Close
 Set rstEmployees = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstEmployees Is Nothing Then
 If rstEmployees.State = adStateOpen Then rstEmployees.Close
 End If
 Set rstEmployees = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndUpdateVB

This example demonstrates the Update method in conjunction with the AddNew method.

Copy code Copy code

' BeginUpdate2VB
Public Sub Main()
 On Error GoTo ErrorHandler

 Dim cnn1 As ADODB.Connection
 Dim rstEmployees As ADODB.Recordset
 Dim strEmpID As String
 Dim strOldFirst As String
 Dim strOldLast As String
 Dim strMessage As String
 Dim strCnn As String

 ' Open a connection.
 Set cnn1 = New ADODB.Connection
 strCnn = "Provider=sqloledb;" & _
 "Data Source=MySqlServer;Initial Catalog=Pubs;Integrated Security=SSPI; "
 cnn1.Open strCnn

 ' Open recordset with data from Employees table.
 Set rstEmployees = New ADODB.Recordset
 rstEmployees.CursorType = adOpenKeyset
 rstEmployees.LockType = adLockOptimistic
 rstEmployees.Open "employee", cnn1, , , adCmdTable

 rstEmployees.AddNew
 strEmpID = "B-S55555M"
 rstEmployees!emp_id = strEmpID
 rstEmployees!fname = "Bill"
 rstEmployees!lname = "Sornsin"

 ' Show contents of buffer and get user input.
 strMessage = "AddNew in progress:" & vbCr & _
 "Data in buffer = " & rstEmployees!emp_id & ", " & _
 rstEmployees!fname & " " & rstEmployees!lname & vbCr & vbCr & _
 "Use Update to save buffer to recordset?"

 If MsgBox(strMessage, vbYesNoCancel) = vbYes Then
 rstEmployees.Update
 ' Go to the new record and show the resulting data.
 MsgBox "Data in recordset = " & rstEmployees!emp_id & ", " & _
 rstEmployees!fname & " " & rstEmployees!lname
 Else
 rstEmployees.CancelUpdate
 MsgBox "No new record added."
 End If

 ' Delete new data because this is a demonstration.
 cnn1.Execute "DELETE FROM employee WHERE emp_id = '" & strEmpID & "'"

 ' clean up
 rstEmployees.Close
 cnn1.Close
 Set rstEmployees = Nothing
 Set cnn1 = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstEmployees Is Nothing Then
 If rstEmployees.State = adStateOpen Then rstEmployees.Close
 End If
 Set rstEmployees = Nothing

 If Not cnn1 Is Nothing Then
 If cnn1.State = adStateOpen Then cnn1.Close
 End If
 Set cnn1 = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndUpdate2VB


Chapter 13: RDS Usage and Security (ADO)

 Copy code hover
[image]

Chapter 13: RDS Usage and Security (ADO)
Send feedback

In this section

  • Chapter 13: RDS Usage and Security

  • Configuring RDS

  • Granting Guest Privileges to a Web Server Computer; RDS guest privileges [ADO]

  • Marking Business Objects as Safe for Scripting

  • Registering Business Objects on the Client for Use with DCOM

  • Setting DCOM Stream Marshaling Format

  • Enabling a DLL to Run on DCOM

  • Configuring Virtual Servers on IIS

  • Specifying Threads Per Processor on IIS

  • Securing RDS Applications

  • Configuring DataFactory for Safe or Unrestricted Modes

  • Using Related Technologies with RDS (ADO)

  • DataFactory Customization (ADO)

  • Troubleshooting RDS (ADO)


Connection.Transactions Property (DAO)

 Copy code hover
[image]

Connection.Transactions Property (DAO)
Send feedback

Returns a value that indicates whether an object supports transactions. Read-only Boolean.

Syntax

expression .Transactions

expression A variable that represents a Connection object.


GroupLevel.Parent Property (Access)

 Copy code hover
[image]

GroupLevel.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a GroupLevel object.

See also

Concepts

GroupLevel Object

Other resources

GroupLevel Object Members


SubForm.Left Property (Access)

 Copy code hover
[image]

SubForm.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Syntax

expression .Left

expression A variable that represents a SubForm object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


BeginTrans, CommitTrans, and RollbackTrans Methods Example (VJ++)

 Copy code hover
[image]

BeginTrans, CommitTrans, and RollbackTrans Methods Example (VJ++)
Send feedback

This example changes the book type of all psychology books in the Titles table of the database. After the BeginTrans method starts a transaction that isolates all the changes made to the Titles table, the CommitTrans method saves the changes. You can use the Rollback method to undo changes that you saved using the Update method.

Copy code Copy code

// BeginBeginTransJ
import com.ms.wfc.data.*;
import java.io.*;

public class BeginTransX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 BeginTransX();
 System.exit(0);
 }

 // BeginTransX function
 static void BeginTransX()
 {
 // Define ADO Objects.
 Connection cnConn1 = null;
 Recordset rstTitles = null;

 //Declarations.
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";
 String strTitle;
 String strType;
 BufferedReader in =
 new BufferedReader (new InputStreamReader (System.in));
 String line = null;
 String strMessage="";
 int intChoice = 0;
 int recordDisplaySize = 15;
 int recordCount = 0;

 try
 {
 // Open a connection.

 cnConn1 = new Connection();
 cnConn1.open(strCnn,"","",AdoEnums.CommandType.UNSPECIFIED);

 // Open the Titles table.
 rstTitles = new Recordset ();
 rstTitles.setCursorType(AdoEnums.CursorType.DYNAMIC);
 rstTitles.setLockType(AdoEnums.LockType.PESSIMISTIC);
 rstTitles.open("titles",cnConn1,AdoEnums.CursorType.DYNAMIC ,
 AdoEnums.LockType.PESSIMISTIC ,AdoEnums.CommandType.TABLE );

 rstTitles.moveFirst();
 cnConn1.beginTrans();

 // Loop through recordset and ask user if he/she wants
 // to change the type for a specified title.

 while (!rstTitles.getEOF())
 {
 strType = rstTitles.getField("type").getString().trim();
 if ((rstTitles.getField("type").getString().
 trim()).compareTo("psychology")== 0)
 {
 strTitle = rstTitles.getField("title").getString().trim();
 System.out.println("\nTitle : " + strTitle + "\n\n"
 + "Change type to self help (1 -> Yes / 2 -> No) ?");
 // Change the title for the specified book.
 line = in.readLine().trim();
 intChoice = Integer.parseInt(line);
 if ( intChoice == 1)
 {
 rstTitles.getField("type").setString("self_help");
 rstTitles.update();
 }
 }
 rstTitles.moveNext();
 }

 // Ask if the user wants to commit to all the
 // changes made above.
 System.out.println
 ("\n\nSave all changes (1 -> Yes / 2 -> No) ?");
 line = in.readLine().trim();
 intChoice = Integer.parseInt(line);
 if ( intChoice == 1)
 cnConn1.commitTrans();
 else
 cnConn1.rollbackTrans();

 // Print current data in recordset.
 rstTitles.requery();
 rstTitles.moveFirst();

 while(true)
 {
 strMessage = strMessage +"\n " +
 rstTitles.getField("title").getString()+" - "
 + rstTitles.getField("type").getString() ;

 if ( recordCount == recordDisplaySize)
 {
 System.out.println(strMessage);
 System.out.println("\n\nPress <Enter> key to continue..");
 line = in.readLine();
 strMessage = "";
 recordCount = 0;
 }
 recordCount++;
 rstTitles.moveNext();
 if(rstTitles.getEOF())
 {
 System.out.println(strMessage);
 break;
 }
 }
 System.out.println("\n\nPress <Enter> key to continue..");
 line = in.readLine();

 // Restore original data because this
 // is a demonstration.
 rstTitles.moveFirst();
 while (!rstTitles.getEOF())
 {
 if ((rstTitles.getField("type").getString().
 trim().compareTo("self_help"))== 0)
 {
 rstTitles.getField("type").setString("psychology");
 rstTitles.update();
 }
 rstTitles.moveNext();
 }
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // Check for null pointer for connection object.
 if(rstTitles.getActiveConnection()==null)
 System.out.println("Exception: " + ae.getMessage());

 // As passing a Recordset, check for null pointer first.
 if (rstTitles != null)
 {
 PrintProviderError(rstTitles.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 // System Read requires this catch.
 catch( java.io.IOException je )
 {
 PrintIOError(je);
 }
 finally
 {
 // Cleanup objects before exit.
 if (rstTitles != null)
 if (rstTitles.getState() == 1)
 rstTitles.close();
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 //.PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}

// EndBeginTransJ


OptionButton.OnMouseUp Property (Access)

 Copy code hover
[image]

OptionButton.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Syntax

expression .OnMouseUp

expression A variable that represents an OptionButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Invalid use of '.', '!', or '()'. (Error 2447)

 Copy code hover
[image]

Invalid use of '.', '!', or '()'. (Error 2447)
Send feedback

The expression does not use delimiters correctly. To reference the properties of DAO objects, it is recommended that you use the .propertyname syntax.


NavigationControl.RightPadding Property (Access)

 Copy code hover
[image]

NavigationControl.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .RightPadding

expression A variable that represents a NavigationControl object.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


OptionButton.Application Property (Access)

 Copy code hover
[image]

OptionButton.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents an OptionButton object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


ObjectFrame.ObjectVerbsCount Property (Access)

 Copy code hover
[image]

ObjectFrame.ObjectVerbsCount Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ObjectVerbsCount property in Visual Basic to determine the number of verbs supported by an OLE object. Read-only Long.

Syntax

expression .ObjectVerbsCount

expression A variable that represents an ObjectFrame object.

Remarks

The ObjectVerbsCount property setting is a value that specifies the number of elements in the ObjectVerbs property array.

This property setting isn't available in Design view.

The list of verbs an OLE object supports may vary, depending on the state of the object. To update the list of supported verbs, set the control'sAction property to acOLEFetchVerbs.

Example

The following example returns the verbs supported by the OLE object in the OLE1 control and displays each verb in a message box.

VBA Copy code Copy code
Sub GetVerbList(frm As Form, OLE1 As Control)
 Dim intX As Integer, intNumVerbs As Integer
 Dim strVerbList As String

 ' Update verb list.
 With frm!OLE1
 .Action = acOLEFetchVerbs
 intNumVerbs = .ObjectVerbsCount
 For intX = 0 To intNumVerbs - 1
 strVerbList = strVerbList & .ObjectVerbs(intX) & "; "
 Next intX
 End With

 ' Display verbs in message box.
 MsgBox Left(strVerbList, Len(strVerbList) - 2)
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


ToggleButton.GridlineColor Property (Access)

 Copy code hover
[image]

ToggleButton.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified toggle button. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineColor

expression A variable that represents a ToggleButton object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


MarshalOptions Property Example (VC++)

 Copy code hover
[image]

MarshalOptions Property Example (VC++)
Send feedback

This example uses the MarshalOptions property to specify what rows are sent back to the server — All Rows or only Modified Rows.

Copy code Copy code

// BeginMarshalOptionsCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <stdio.h>
#include <ole2.h>
#include <conio.h>
#include <malloc.h>
#include "MarshalOptionsX.h"

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void MarshalOptionsX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 MarshalOptionsX();

 printf("Press any key to continue...");
 getch();
 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// Marshal Options Function //
// //
///////////////////////////////////////////////////////////

void MarshalOptionsX(void)
{

 // Define string variables
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace
 _RecordsetPtr pRstEmployees = NULL;

 // Define Other Variables
 IADORecordBinding *picRs = NULL; //Interface Pointer declared
 CEmployeeRs emprs; //C++ Class Object
 HRESULT hr = S_OK;
 LPSTR strOldFirst = NULL;
 LPSTR strOldLast = NULL;

 try
 {
 // Open recordset with names from Employee table.
 TESTHR(pRstEmployees.CreateInstance(__uuidof(Recordset)));
 pRstEmployees->CursorType = adOpenKeyset;
 pRstEmployees->LockType = adLockOptimistic;
 pRstEmployees->CursorLocation = adUseClient;
 pRstEmployees->Open("SELECT fname, lname FROM Employee "
 "ORDER BY lname",strCnn,
 adOpenKeyset, adLockOptimistic,adCmdText);

 // Open an IADORecordBinding interface pointer which
 // we'll use for Binding Recordset to a class.
 TESTHR(pRstEmployees->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 // Bind the Recordset to a C++ Class here.
 TESTHR(picRs->BindToRecordset(&emprs));

 // Store Original Data
 strOldFirst = (LPSTR) malloc(sizeof(emprs.m_szemp_fname));
 strOldLast = (LPSTR) malloc(sizeof(emprs.m_szemp_lname));
 // Set the final character of the destination string to NULL.
 strOldFirst[sizeof(emprs.m_szemp_fname)-1] = '\0';
 // The source string will get truncated if its length is
 // longer than the length of the destination string minus one.
 strncpy(strOldFirst,strtok(emprs.m_szemp_fname," "),
 sizeof(emprs.m_szemp_fname)-1);
 // Set the final character of the destination string to NULL.
 strOldLast[sizeof(emprs.m_szemp_lname)-1] = '\0';
 // The source string will get truncated if its length is
 // longer than the length of the destination string minus one.
 strncpy(strOldLast,strtok(emprs.m_szemp_lname," "),
 sizeof(emprs.m_szemp_lname)-1);

 //Change Data in Edit Buffer
 // Set the final character of the destination string to NULL.
 emprs.m_szemp_fname[sizeof(emprs.m_szemp_fname)-1] = '\0';
 // The source string will get truncated if its length is
 // longer than the length of the destination string minus one.
 strncpy(emprs.m_szemp_fname,"Linda",sizeof(emprs.m_szemp_fname)-1);
 // Set the final character of the destination string to NULL.
 emprs.m_szemp_lname[sizeof(emprs.m_szemp_lname)-1] = '\0';
 // The source string will get truncated if its length is
 // longer than the length of the destination string minus one.
 strncpy(emprs.m_szemp_lname,"Kobara",sizeof(emprs.m_szemp_lname)-1);

 // Show contents of buffer and get user input
 printf("Edit in Progress:\n");
 printf("Original Data = %s %s \n",strOldFirst,strOldLast);
 printf("Data in buffer = %s %s \n", emprs.lemp_fnameStatus ==
 adFldOK ? emprs.m_szemp_fname : "<NULL>",
 emprs.lemp_lnameStatus == adFldOK ?
 emprs.m_szemp_lname : "<NULL>");
 printf("Use Update to replace the original data with the "
 "buffered data in the Recordset?\nEnter (y/n) :?");
 char opt1=getch();

 if(toupper(opt1)=='Y')
 {
 printf("\nWould you like to send all the rows in "
 "the recordset back to the server?\nEnter (y/n):");
 char opt2 = getch();
 if(toupper(opt2) == 'Y')
 {
 {
 pRstEmployees->MarshalOptions = adMarshalAll;
 picRs->Update(&emprs);
 }
 }
 else
 {
 printf("\nWould you like to send only modified "
 "rows back to the server?\nEnter (y/n):");
 char opt3=getch();
 if(toupper(opt3) == 'Y')
 {
 pRstEmployees->MarshalOptions =
 adMarshalModifiedOnly;
 picRs->Update(&emprs);
 }
 }
 }
 // Show the resulting data
 printf("\nData In the Recordset = %s %s\n",
 emprs.lemp_fnameStatus == adFldOK ?
 emprs.m_szemp_fname : "<NULL>",
 emprs.lemp_lnameStatus == adFldOK ?
 emprs.m_szemp_lname : "<NULL>");

 // Restore original data because this is a demonstration
 if((strcmp(strOldFirst,emprs.m_szemp_fname)) &&
 (strcmp(strOldLast,emprs.m_szemp_lname)))
 {
 // Set the final character of the destination string to NULL.
 emprs.m_szemp_fname[sizeof(emprs.m_szemp_fname)-1] = '\0';
 // The source string will get truncated if its length is
 // longer than the length of the destination string minus one.
 strncpy(emprs.m_szemp_fname,strOldFirst,
 sizeof(emprs.m_szemp_fname)-1);
 // Set the final character of the destination string to NULL.
 emprs.m_szemp_lname[sizeof(emprs.m_szemp_lname)-1] = '\0';
 // The source string will get truncated if its length is
 // longer than the length of the destination string minus one.
 strncpy(emprs.m_szemp_lname,strOldLast,
 sizeof(emprs.m_szemp_lname)-1);
 picRs->Update(&emprs);
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstEmployees->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 // Deallocate memory
 if (strOldFirst)
 free(strOldFirst);
 if (strOldLast)
 free(strOldLast);

 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (pRstEmployees)
 if (pRstEmployees->State == adStateOpen)
 pRstEmployees->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndMarshalOptionsCpp

MarshalOptionsX.h

Copy code Copy code

// BeginMarshalOptionsH

#include "icrsint.h"

//This Class extracts only fname,lname from employees table
class CEmployeeRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CEmployeeRs)

 //Column fname is the 1st field in the recordset
 ADO_VARIABLE_LENGTH_ENTRY2(1, adVarChar, m_szemp_fname,
 sizeof(m_szemp_fname), lemp_fnameStatus, TRUE)

 //Column lname is the 2nd field in the recordset
 ADO_VARIABLE_LENGTH_ENTRY2(2, adVarChar, m_szemp_lname,
 sizeof(m_szemp_lname), lemp_lnameStatus, TRUE)

END_ADO_BINDING()

public:
 CHAR m_szemp_fname[21];
 ULONG lemp_fnameStatus;
 CHAR m_szemp_lname[31];
 ULONG lemp_lnameStatus;
};
// EndMarshalOptionsH


CommandButton.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

CommandButton.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthLeft

expression A variable that represents a CommandButton object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


AcSharePointListTransferType Enumeration (Access)

 Copy code hover
[image]

AcSharePointListTransferType Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the TransferSharePointList method to specify whether to import or link to a SharePoint list.

Version Information

Version Added: Access 2007

Name | Value | Description
acImportSharePointList | 0 | Import the SharePoint list.
acLinkSharePointList | 1 | Link to the SharePoint list.


TabControl.ForeThemeColorIndex Property (Access)

 Copy code hover
[image]

TabControl.ForeThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ForeThemeColorIndex

expression A variable that represents a TabControl object.

Remarks

The ForeThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the ForeThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Fore Color to the Text 2 color by setting the ForeThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.ForeThemeColorIndex=2

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Recordset2.MovePrevious Method (DAO)

 Copy code hover
[image]

Recordset2.MovePrevious Method (DAO)
Send feedback

Moves to the previous record in a specified Recordset object and make that record the current record.

Syntax

expression .MovePrevious

expression A variable that represents a Recordset2 object.

Remarks

Use the Move methods to move from record to record without applying a condition.

If you edit the current record, be sure you use the Update method to save the changes before you move to another record. If you move to another record without updating, your changes are lost without warning.

When you open a Recordset, the first record is current and the BOF property is False. If the Recordset contains no records, the BOF property is True, and there is no current record.

If you use MovePrevious when the first record is current, the BOF property is True, and there is no current record. If you use MovePrevious again, an error occurs, and BOF remains True.

If recordset refers to a table-type Recordset (Microsoft Access workspaces only), movement follows the current index. You can set the current index by using the Index property. If you don't set the current index, the order of returned records is undefined.

You can't use the MoveFirst, MoveLast, and MovePrevious methods on a forward-only-type Recordset object.

To move the position of the current record in a Recordset object a specific number of records forward or backward, use the Move method.


How to: Programmatically Retrieve Printer Capabilities

 Copy code hover
[image]

How to: Programmatically Retrieve Printer Capabilities
Send feedback

The Printers collection and Printer 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.

VBA Copy code Copy code
' Declaration for the DeviceCapabilities function API call.
Private Declare Function DeviceCapabilities Lib "winspool.drv" _
    Alias "DeviceCapabilitiesA" (ByVal lpsDeviceName As String, _
    ByVal lpPort As String, ByVal iIndex As Long, lpOutput As Any, _
    ByVal lpDevMode As Long) As Long

' DeviceCapabilities function constants.
Private Const DC_PAPERNAMES = 16
Private Const DC_PAPERS = 2
Private Const DC_BINNAMES = 12
Private Const DC_BINS = 6
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.

VBA Copy code Copy code
Sub GetPaperList()
    Dim lngPaperCount As Long
    Dim lngCounter As Long
    Dim hPrinter As Long
    Dim strDeviceName As String
    Dim strDevicePort As String
    Dim strPaperNamesList As String
    Dim strPaperName As String
    Dim intLength As Integer
    Dim strMsg As String
    Dim aintNumPaper() As Integer

    On Error GoTo GetPaperList_Err

    ' Get the name and port of the default printer.
    strDeviceName = Application.Printer.DeviceName
    strDevicePort = Application.Printer.Port

    ' Get the count of paper names supported by the printer.
    lngPaperCount = DeviceCapabilities(lpsDeviceName:=strDeviceName, _
        lpPort:=strDevicePort, _
        iIndex:=DC_PAPERNAMES, _
        lpOutput:=ByVal vbNullString, _
        lpDevMode:=DEFAULT_VALUES)

    ' Re-dimension the array to the count of paper names.
    ReDim aintNumPaper(1 To lngPaperCount)

    ' Pad the variable to accept 64 bytes for each paper name.
    strPaperNamesList = String(64 * lngPaperCount, 0)

    ' Get the string buffer of all paper names supported by the printer.
    lngPaperCount = DeviceCapabilities(lpsDeviceName:=strDeviceName, _
        lpPort:=strDevicePort, _
        iIndex:=DC_PAPERNAMES, _
        lpOutput:=ByVal strPaperNamesList, _
        lpDevMode:=DEFAULT_VALUES)

    ' Get the array of all paper numbers supported by the printer.
    lngPaperCount = DeviceCapabilities(lpsDeviceName:=strDeviceName, _
        lpPort:=strDevicePort, _
        iIndex:=DC_PAPERS, _
        lpOutput:=aintNumPaper(1), _
        lpDevMode:=DEFAULT_VALUES)

    ' List the available paper names.
    strMsg = "Papers available for " & strDeviceName & vbCrLf
    For lngCounter = 1 To lngPaperCount

        ' Parse a paper name from the string buffer.
        strPaperName = Mid(String:=strPaperNamesList, _
            Start:=64 * (lngCounter - 1) + 1, Length:=64)
        intLength = VBA.InStr(Start:=1, String1:=strPaperName, String2:=Chr(0)) - 1
        strPaperName = Left(String:=strPaperName, Length:=intLength)

        ' Add a paper number and name to text string for the message box.
        strMsg = strMsg & vbCrLf & aintNumPaper(lngCounter) _
            & vbTab & strPaperName

    Next lngCounter

    ' Show the paper names in a message box.
    MsgBox Prompt:=strMsg

GetPaperList_End:
    Exit Sub

GetPaperList_Err:
    MsgBox Prompt:=Err.Description, Buttons:=vbCritical & vbOKOnly, _
        Title:="Error Number " & Err.Number & " Occurred"
    Resume GetPaperList_End

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.

VBA Copy code Copy code
Sub GetBinList(strName As String)
' 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.

    Dim lngBinCount As Long
    Dim lngCounter As Long
    Dim hPrinter As Long
    Dim strDeviceName As String
    Dim strDevicePort As String
    Dim strBinNamesList As String
    Dim strBinName As String
    Dim intLength As Integer
    Dim strMsg As String
    Dim aintNumBin() As Integer

    On Error GoTo GetBinList_Err

    ' Get name and port of the default printer.
    strDeviceName = Application.Printers(strName).DeviceName
    strDevicePort = Application.Printers(strName).Port

    ' Get count of paper bin names supported by the printer.
    lngBinCount = DeviceCapabilities(lpsDeviceName:=strDeviceName, _
        lpPort:=strDevicePort, _
        iIndex:=DC_BINNAMES, _
        lpOutput:=ByVal vbNullString, _
        lpDevMode:=DEFAULT_VALUES)

    ' Re-dimension the array to count of paper bins.
    ReDim aintNumBin(1 To lngBinCount)

    ' Pad variable to accept 24 bytes for each bin name.
    strBinNamesList = String(Number:=24 * lngBinCount, Character:=0)

    ' Get string buffer of paper bin names supported by the printer.
    lngBinCount = DeviceCapabilities(lpsDeviceName:=strDeviceName, _
        lpPort:=strDevicePort, _
        iIndex:=DC_BINNAMES, _
        lpOutput:=ByVal strBinNamesList, _
        lpDevMode:=DEFAULT_VALUES)

    ' Get array of paper bin numbers supported by the printer.
    lngBinCount = DeviceCapabilities(lpsDeviceName:=strDeviceName, _
        lpPort:=strDevicePort, _
        iIndex:=DC_BINS, _
        lpOutput:=aintNumBin(1), _
        lpDevMode:=0)

    ' List available paper bin names.
    strMsg = "Paper bins available for " & strDeviceName & vbCrLf
    For lngCounter = 1 To lngBinCount

        ' Parse a paper bin name from string buffer.
        strBinName = Mid(String:=strBinNamesList, _
            Start:=24 * (lngCounter - 1) + 1, _
            Length:=24)
        intLength = VBA.InStr(Start:=1, _
            String1:=strBinName, String2:=Chr(0)) - 1
        strBinName = Left(String:=strBinName, _
                Length:=intLength)

        ' Add bin name and number to text string for message box.
        strMsg = strMsg & vbCrLf & aintNumBin(lngCounter) _
            & vbTab & strBinName

    Next lngCounter

    ' Show paper bin numbers and names in message box.
    MsgBox Prompt:=strMsg

GetBinList_End:
    Exit Sub
GetBinList_Err:
    MsgBox Prompt:=Err.Description, Buttons:=vbCritical & vbOKOnly, _
        Title:="Error Number " & Err.Number & " Occurred"
    Resume GetBinList_End
End Sub


Field.DataUpdatable Property (DAO)

 Copy code hover
[image]

Field.DataUpdatable Property (DAO)
Send feedback

Returns a value that indicates whether the data in the field represented by a Field object is updatable.

Syntax

expression .DataUpdatable

expression A variable that represents a Field object.

Remarks

Use this property to determine whether you can change the Value property setting of a Field object. This property is always False on a Field object whose Attributes property is dbAutoIncrField.

You can use the DataUpdatable property on Field objects that are appended to the Fields collection of QueryDef, Recordset, and Relation objects, but not the Fields collection of Index or TableDef objects.

Example

This example demonstrates the DataUpdatable property using the first field from six different Recordsets. The DataOutput function is required for this procedure to run.

VBA Copy code Copy code
Sub DataUpdatableX()

 Dim dbsNorthwind As Database
 Dim rstNorthwind As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind
 ' Open and print report about a table-type Recordset.
 Set rstNorthwind = .OpenRecordset("Employees")
 DataOutput rstNorthwind

 ' Open and print report about a dynaset-type Recordset.
 Set rstNorthwind = .OpenRecordset("Employees", _
 dbOpenDynaset)
 DataOutput rstNorthwind

 ' Open and print report about a snapshot-type Recordset.
 Set rstNorthwind = .OpenRecordset("Employees", _
 dbOpenSnapshot)
 DataOutput rstNorthwind

 ' Open and print report about a forward-only-type Recordset.
 Set rstNorthwind = .OpenRecordset("Employees", _
 dbOpenForwardOnly)
 DataOutput rstNorthwind

 ' Open and print report about a Recordset based on
 ' a select query.
 Set rstNorthwind = _
 .OpenRecordset("Current Product List")
 DataOutput rstNorthwind

 ' Open and print report about a Recordset based on a
 ' select query that calculates totals.
 Set rstNorthwind = .OpenRecordset("Order Subtotals")
 DataOutput rstNorthwind

 .Close
 End With

End Sub

Function DataOutput(rstTemp As Recordset)

 With rstTemp
 Debug.Print "Recordset: " & .Name & ", ";
 Select Case .Type
 Case dbOpenTable
 Debug.Print "dbOpenTable"
 Case dbOpenDynaset
 Debug.Print "dbOpenDynaset"
 Case dbOpenSnapshot
 Debug.Print "dbOpenSnapshot"
 Case dbOpenForwardOnly
 Debug.Print "dbOpenForwardOnly"
 End Select
 Debug.Print " Field: " & .Fields(0).Name & ", " & _
 "DataUpdatable = " & .Fields(0).DataUpdatable
 Debug.Print
 .Close
 End With

End Function


QueryDefs.Count Property (DAO)

 Copy code hover
[image]

QueryDefs.Count Property (DAO)
Send feedback

Returns the number of objects in the specified collection. Read-only.

Syntax

expression .Count

expression A variable that represents a QueryDefs object.

Remarks

Because members of a collection begin with 0, you should always code loops starting with the 0 member and ending with the value of the Count property minus 1. If you want to loop through the members of a collection without checking the Count property, you can use a For Each...Next command.

The Count property setting is never Null. If its value is 0, there are no objects in the collection.


CommandButton.Left Property (Access)

 Copy code hover
[image]

CommandButton.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Syntax

expression .Left

expression A variable that represents a CommandButton object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


CommandButton.ThemeFontIndex Property (Access)

 Copy code hover
[image]

CommandButton.ThemeFontIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ThemeFontIndex

expression A variable that represents a CommandButton object.

Remarks

The ThemeFontIndex property uses one of the values listed in the following table.

Value | Description
0 | Header font
1 (Default) | Detail font

If no theme is applied, the ThemeFontIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


WebBrowserControl.DocumentComplete Event (Access)

 Copy code hover
[image]

WebBrowserControl.DocumentComplete Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when a document is completely loaded and initialized.

Version Information

Version Added: Access 2010

Syntax

expression .DocumentComplete(pDisp, URL)

expression A variable that represents a WebBrowserControl object.

Parameters

Name | Required/Optional | Data Type | Description
pDisp | Required | Object | pointer to the IDispatch interface of the window or frame in which the document is loaded.
URL | Required | Variant | Contains the URL of the loaded document.

Return Value

nothing

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


TransferSQLDatabase Macro Action

 Copy code hover
[image]

TransferSQLDatabase Macro Action
Send feedback

In an Access project, you can use the TransferSQLDatabase action to transfer a Microsoft SQL Server 7.0 or later database to another SQL Server 7.0 or later database. For more information on transferring a database, see the SQL Server documentation.

Note 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.

Setting

The TransferSQLDatabase action has the following arguments.

Action argument | Description
Server | The name of the SQL Server 7.0 or later database server you are copying to.
Database | The name of the new database that will be created on the destination server.
Use Trusted Connection | Specifes whether or not there is a trusted connection to the SQL Server. If set to Yes, then there is a trusted connection and the Login and Password arguments are not required. If set to No, the Login and Password arguments are required. The default is Yes. When you use a trusted connection, SQL Server security integrates with the Windows operating system security to provide a single log on to the network and the database.
Login | The name of the Login to the destination server.
Password | The password for the Login argument. This password is stored as text in the Access project, but is hidden during the transfer database operation.
Transfer Copy Data | Specifies whether or not to include data in the transfer database operation. When set to Yes, all data is included for all the tables, along with all data structures, extended properties, and database objects. When set to No, no data is included from the tables. Only the table structure and extended properties are created on the destination server, along with all other database objects (except database diagrams). The default is Yes.

Remarks

You cannot perform other operations while the database is being transferred.

The TransferSQLDatabase action, by default, copies data, data definitions, database objects, and extended properties, such as default values, text constraints, and lookup values.

There are requirements for transferring a database:

  • You must be a member of the sysadmin role on the destination server (No special role is required on the source server).

  • The current SQL server connected to the Access project and the destination server you are transferring the database to must be SQL Server version 7.0 or later.

Note Note

Linked servers are not transferred during a database transfer operation.

To run the TransferSQLDatabase action in a Visual Basic for Applications (VBA) module, use the TransferSQLDatabase method of the DoCmd object.


Cannot set multiple NULL, NOT NULL attributes. (Error 3806)

 Copy code hover
[image]

Cannot set multiple NULL, NOT NULL attributes. (Error 3806)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for more information.


NavigationControl.StatusBarText Property (Access)

 Copy code hover
[image]

NavigationControl.StatusBarText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .StatusBarText

expression A variable that represents a NavigationControl object.

Remarks

You set the StatusBarText property by using a string expression up to 255 characters long.

Note Note

The length of the text you can display in the status bar depends on your computer hardware and video display.

You can use the StatusBarText property to provide specific information about a control. For example, when a text box has the focus, a brief instruction can tell the user what kind of data to enter

Note Note

You can also use the ControlTipText property to display a ScreenTip for a control.

If you create a control by dragging a field from the field list, the value in a field's Description property is copied to the StatusBarText property.

Example

The following example sets the status bar text to be displayed when the "Address_TextBox" control in the "Mailing List" form has the focus in Form View.

VBA Copy code Copy code
Forms("Mailing List").Controls("Address_TextBox"). _
 StatusBarText = "Enter the company's mailing address."

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


The history of design changes in the replica does not match the history in the Design Master. (Error 3524)

 Copy code hover
[image]

The history of design changes in the replica does not match the history in the Design Master. (Error 3524)
Send feedback

The Synchronizer is unable to synchronize the two members of the replica set because the history of design (or schema) changes is different for each replica. The discrepancy in design history might be caused by either the existence of two Design Masters or because the Design Master has been restored from a backup made sometime in the past.


The two members of the replica set you are attempting to synchronize are both Design Masters. (Error 3561)

 Copy code hover
[image]

The two members of the replica set you are attempting to synchronize are both Design Masters. (Error 3561)
Send feedback

Delete one of the Design Masters.


Views Collection (ADOX)

 Copy code hover
[image]

Views Collection (ADOX)
Send feedback

Contains all View objects of a catalog.

Remarks

The Append method for a Views collection is unique for ADOX. You can:

  • Add a new view to the collection with the Append method.

The remaining properties and methods are standard to ADO collections. You can:

  • Access a view in the collection with the Item property.

  • Return the number of views contained in the collection with the Count property.

  • Remove a view from the collection with the Delete method.

  • Update the objects in the collection to reflect the current database's schema with the Refresh method.


CheckBox.BorderStyle Property (Access)

 Copy code hover
[image]

CheckBox.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Syntax

expression .BorderStyle

expression A variable that represents a CheckBox object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ListBox.MouseUp Event (Access)

 Copy code hover
[image]

ListBox.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents a ListBox object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was released to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


WebBrowserControl.StatusBarText Property (Access)

 Copy code hover
[image]

WebBrowserControl.StatusBarText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .StatusBarText

expression A variable that represents a WebBrowserControl object.

Remarks

You set the StatusBarText property by using a string expression up to 255 characters long.

Note Note

The length of the text you can display in the status bar depends on your computer hardware and video display.

You can use the StatusBarText property to provide specific information about a control. For example, when a text box has the focus, a brief instruction can tell the user what kind of data to enter

Note Note

You can also use the ControlTipText property to display a ScreenTip for a control.

If you create a control by dragging a field from the field list, the value in a field's Description property is copied to the StatusBarText property.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Indexes.Delete Method (DAO)

 Copy code hover
[image]

Indexes.Delete Method (DAO)
Send feedback

Deletes the specified Index from the Indexes collection.

Syntax

expression .Delete(Name)

expression A variable that represents an Indexes object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Required | String | The name of the index to delete.

Remarks

The Delete method is supported only when the Index object is new and hasn't been appended to the database.


Cannot perform cascading operation. The value entered is prohibited by the validation rule

 Copy code hover
[image]

Cannot perform cascading operation. The value entered is prohibited by the validation rule <rule> set for <name>. (Error 3404)
Send feedback

The cascade operation you are attempting would result in an invalid value in the indicated field, as established by the field's validation rule. Check the values you are attempting to update and fix them so they comply with the validation rule.


Documents Members (DAO)

 Copy code hover
[image]

Documents Members (DAO)
Send feedback

A Documents collection contains all of the Document objects for a specific type of object (Microsoft Access database engine databases only).

Methods

Name | Description
Refresh | Updates the objects in the specified colletion to reflect the database's current schema.

Properties

Name | Description
Count | Returns the number of objects in the specified collection. Read-only.


DefinedSize Property (ADO)

 Copy code hover
[image]

DefinedSize Property (ADO)
Send feedback

Indicates the data capacity of a Field object.

Return Value

Returns a Long value that reflects the defined size of a field as a number of bytes.

Remarks

Use the DefinedSize property to determine the data capacity of a Field object.

The DefinedSize and ActualSize properties are different. For example, consider a Field object with a declared type of adVarChar and a DefinedSize property value of 50, containing a single character. The ActualSize property value it returns is the length in bytes of the single character.


Clone Method Example (VJ++)

 Copy code hover
[image]

Clone Method Example (VJ++)
Send feedback

This example uses the Clone method to create copies of a Recordset and then lets the user position the record pointer of each copy independently.

Copy code Copy code

// BeginCloneJ
import com.ms.wfc.data.*;
import java.io.* ;

public class CloneX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 CloneX();
 System.exit(0);
 }

 // CloneX function

 static void CloneX()
 {
 // Assign SQL statement and connection string to variables.
 String strSQL = "SELECT stor_name FROM Stores "
 + "ORDER BY stor_name";

 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";

 // Define ADO Objects.
 Recordset[] arstStores = null;

 //Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String line = null;
 String strMessage;
 String strFind;
 int intLoop;
 boolean booExit = true;

 try
 {
 // Open recordset as a static cursor type recordset.
 arstStores = new Recordset[3];
 arstStores[0] = new Recordset();
 arstStores[0].setCursorType(AdoEnums.CursorType.STATIC);
 arstStores[0].setLockType(AdoEnums.LockType.BATCHOPTIMISTIC);
 arstStores[0].open(strSQL,strCnn,AdoEnums.CursorType.STATIC,
 AdoEnums.LockType.BATCHOPTIMISTIC,AdoEnums.CommandType.TEXT);

 // Create two clones of the original Recordset.
 arstStores[1] = (Recordset)arstStores[0].clone
 (AdoEnums.LockType.BATCHOPTIMISTIC);
 arstStores[2] = (Recordset)arstStores[0].clone
 (AdoEnums.LockType.BATCHOPTIMISTIC);

 while(booExit)
 {
 // Loop through the array so that on each pass,
 // the user is searching a different copy of the
 // same Recordset.
 for (intLoop = 0; intLoop < 3; intLoop++)
 {
 // Ask for search string while showing where
 // the current record pointer is for each Recordset
 strMessage = "\nRecordsets from stores table:" + "\n"
 + " 1 - Original - Record pointer at "
 + arstStores[0].getField("stor_name").getString()
 + "\n" + " 2 - Clone - Record pointer at "
 + arstStores[1].getField("stor_name").getString()
 + "\n" + " 3 - Clone - Record pointer at "
 + arstStores[2].getField("stor_name").getString()
 + "\n";
 System.out.println(strMessage);
 System.out.println("Enter search string for #"
 + (intLoop+1) + "(Press <Enter> to Exit.)");

 strFind = in.readLine().trim();
 if(strFind.length() == 0)
 {
 booExit = false;
 break;
 }

 // Find the search string; if there's no
 // match, jump to the last record.
 arstStores[intLoop].setFilter("stor_name >= '" +
 strFind + "'");
 if (arstStores[intLoop].getEOF())
 {
 arstStores[intLoop].setFilter
 (new Integer(AdoEnums.FilterGroup.NONE));
 arstStores[intLoop].moveLast();
 }
 }
 }
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a connection, check for null pointer first.
 if (arstStores[0] != null)
 {
 PrintProviderError(arstStores[0].getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (arstStores[0] != null)
 if (arstStores[0].getState() == 1)
 arstStores[0].close();
 if (arstStores[1] != null)
 if (arstStores[1].getState() == 1)
 arstStores[1].close();
 if (arstStores[2] != null)
 if (arstStores[2].getState() == 1)
 arstStores[2].close();
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndCloneJ


INNER JOIN Operation (Microsoft Access SQL)

 Copy code hover
[image]

INNER JOIN Operation (Microsoft Access SQL)
Send feedback

Combines records from two tables whenever there are matching values in a common field.

Syntax

FROM table1 INNER JOIN table2 ON table1.field1 compopr table2.field2

The INNER JOIN operation has these parts:

Part | Description
table1, table2 | The names of the tables from which records are combined.
field1, field2 | The names of the fields that are joined. If they are not numeric, the fields must be of the same data type and contain the same kind of data, but they do not have to have the same name.
compopr | Any relational comparison operator: "=," "<," ">," "<=," ">=," or "<>."

Remarks

You can use an INNER JOIN operation in any FROM clause. This is the most common type of join. Inner joins combine records from two tables whenever there are matching values in a field common to both tables.

You can use INNER JOIN with the Departments and Employees tables to select all the employees in each department. In contrast, to select all departments (even if some have no employees assigned to them) or all employees (even if some are not assigned to a department), you can use a LEFT JOIN or RIGHT JOIN operation to create an outer join.

If you try to join fields containing Memo or OLE Object data, an error occurs.

You can join any two numeric fields of like types. For example, you can join on AutoNumber and Long fields because they are like types. However, you cannot join Single and Double types of fields.

The following example shows how you could join the Categories and Products tables on the CategoryID field:

SQL Copy code Copy code
SELECT CategoryName, ProductName
FROM Categories INNER JOIN Products
ON Categories.CategoryID = Products.CategoryID;

In the preceding example, CategoryID is the joined field, but it is not included in the query output because it is not included in the SELECT statement. To include the joined field, include the field name in the SELECT statement — in this case, Categories.CategoryID.

You can also link several ON clauses in a JOIN statement, using the following syntax:

SELECT fields FROM table1 INNER JOIN table2 ON table1.field1 compopr table2.field1 AND ON table1.field2 compopr table2.field2) OR ON table1.field3 compopr table2.field3)];

You can also nest JOIN statements using the following syntax:

SELECT fields FROM table1 INNER JOIN (table2 INNER JOIN [( ]table3 [INNER JOIN [( ]tablex [INNER JOIN …)] ON table3.field3 compopr tablex.fieldx)] ON table2.field2 compopr table3.field3) ON table1.field1 compopr table2.field2;

A LEFT JOIN or a RIGHT JOIN may be nested inside an INNER JOIN, but an INNER JOIN may not be nested inside a LEFT JOIN or a RIGHT JOIN.

Example

This example creates two equi-joins: one between the Order Details and Orders tables and another between the Orders and Employees tables. This is necessary because the Employees table does not contain sales data, and the Order Details table does not contain employee data. The query produces a list of employees and their total sales.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

VBA Copy code Copy code
Sub InnerJoinX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Create a join between the Order Details and
    ' Orders tables and another between the Orders and
    ' Employees tables. Get a list of employees and
    ' their total sales.
    Set rst = dbs.OpenRecordset("SELECT DISTINCTROW " _
        & "Sum(UnitPrice * Quantity) AS Sales, " _
        & "(FirstName & Chr(32) & LastName) AS Name " _
        & "FROM Employees INNER JOIN(Orders " _
        & "INNER JOIN [Order Details] " _
        & "ON [Order Details].OrderID = " _
        & "Orders.OrderID ) " _
        & "ON Orders.EmployeeID = " _
        & "Employees.EmployeeID " _
        & "GROUP BY (FirstName & Chr(32) & LastName);")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 20

    dbs.Close

End Sub


BoundObjectFrame.OnMouseMove Property (Access)

 Copy code hover
[image]

BoundObjectFrame.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Syntax

expression .OnMouseMove

expression A variable that represents a BoundObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Form.AfterLayout Property (Access)

 Copy code hover
[image]

Form.AfterLayout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the AfterLayout event occurs. Read/write.

Syntax

expression .AfterLayout

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the AfterLayout event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).AfterLayout = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


Access 2013 custom web app reference

 Copy code hover
[image]

Access 2013 custom web app reference
Send feedback

Published: July 16, 2012

In this section

  • Concepts (Access 2013 custom web app)

  • Access SQL and expressions reference (Access 2013 custom web app)

  • Macro function reference (Access 2013 custom web app)


DoCmd.OpenView Method (Access)

 Copy code hover
[image]

DoCmd.OpenView Method (Access)
See also Send feedback

Published: July 16, 2012

The OpenView method carries out the OpenView action in Visual Basic.

Syntax

expression .OpenView(ViewName, View, DataMode)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
ViewName | Required | Variant | A string expression that's the valid name of a view in the current database. If you execute Visual Basic code containing the OpenView method in a library database, Microsoft Access looks for the view with this name first in the library database, then in the current database.
View | Optional | AcView | A AcView constant that specifies the view in which the view will open. The default value is acViewNormal.
DataMode | Optional | AcOpenDataMode | A AcOpenDataMode constant that specifies the data entry mode for the view. The default value is acEdit.

Remarks

In a Microsoft Access project, you can use the OpenView method to open a view in Datasheet view, view Design view, or Print Preview. This action runs the named view when opened in Datasheet view. You can select data entry for the view and restrict the records that the view displays.

If you don't want to display the system messages that normally appear when a view is run (indicating it's a view and showing how many records will be affected), you can use the SetWarnings method to suppress the display of these messages.

Example

The following example opens the Employees view.

VBA Copy code Copy code
DoCmd.OpenView "Employees"

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Page Members (Access)

 Copy code hover
[image]

Page Members (Access)
Send feedback

Published: July 16, 2012

A Page object corresponds to an individual page on a tab control.

Events

Name | Description
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SetTabOrder | Resets the tab order of the controls in the specified Page to their default values.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Caption | Gets or sets the text that appears at the top of the page. Read/write String.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
PageIndex | You can use the PageIndex property to specify or determine the position of a Page object within a Pages collection. The PageIndex property specifies the order in which the pages on a tab control appear. Read/write Integer.
Parent | Returns the parent object for the specified object. Read-only.
Picture | You can use the Picture property to specify a bitmap or other type of graphic to be displayed on the specified control. Read/write String.
PictureData | You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.
PictureType | You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.
Properties | Returns a reference to a control's Properties collection object. Read-only.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


AllFunctions Properties (Access)

 Copy code hover
[image]

AllFunctions Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


Cannot add record(s); join key of table

 Copy code hover
[image]

Cannot add record(s); join key of table <name> not in result set. (Error 3348)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for more information.


Entities Object (Access)

 Copy code hover
[image]

Entities Object (Access)
See also Send feedback

Published: July 16, 2012

Represents the collection of entities defined in a Data Service data connection.

Version Information

Version Added: Access 2010

Remarks

A Data Service data connection may contain one or more entities. Each entity specifies an external content type. Used throughout the functionality and services offered by Business Connectivity Services, external content types are reusable metadata descriptions of connectivity information and data definitions plus the behaviors you want to apply to a certain category of external data. Use the Entities property to return the entities defined for a Data Service data connection.

Use the Item property to return an Entity object.

For more information about external content types, see What Are External Content Types?.

See also

Concepts

Access Object Model Reference

Other resources

Entities Object Members


CommandButton.LabelY Property (Access)

 Copy code hover
[image]

CommandButton.LabelY Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelY

expression A variable that represents a CommandButton object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


CommandButton.MouseDown Event (Access)

 Copy code hover
[image]

CommandButton.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents a CommandButton object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
         Shift As Integer, X As Single, _
         Y As Single)
    If Button = acLeftButton Then
        MsgBox "You pressed the left button."
    End If
    If Button = acRightButton Then
        MsgBox "You pressed the right button."
    End If
    If Button = acMiddleButton Then
        MsgBox "You pressed the middle button."
    End If
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ListBox.Requery Method (Access)

 Copy code hover
[image]

ListBox.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.

Syntax

expression .Requery

expression A variable that represents a ListBox object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts .

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate function.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

Example

The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form:

VBA Copy code Copy code
Public Sub RequeryList()

    Dim ctlCombo As Control

    ' Return Control object pointing to a combo box.
    Set ctlCombo = Forms!Employees!ReportsTo

    ' Requery source of data for list box.
    ctlCombo.Requery

End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Today Function (Access 2013 custom web app)

 Copy code hover
[image]

Today Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the current date value in the time zone defined by the application

Syntax

Today()

Remarks

The Now function is similar but returns the exact time, whereas Today returns the time value 12:00:00 PM for all dates.


The Microsoft Access database engine has already been initialized. (Error 3279)

 Copy code hover
[image]

The Microsoft Access database engine has already been initialized. (Error 3279)
Send feedback

You attempted to initialize the Microsoft Access database engine, but it has already been initialized.


WebBrowserControl.EventProcPrefix Property (Access)

 Copy code hover
[image]

WebBrowserControl.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents a WebBrowserControl object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Could not execute query; could not find linked table. (Error 3184)

 Copy code hover
[image]

Could not execute query; could not find linked table. (Error 3184)
Send feedback

Possible causes:

  • The linked table no longer exists or has been renamed or moved. Link the table and then try to execute the query again.

  • The linked table is on a network drive, and you are not connected to the network. Make sure the network is available, and then try to execute the query again.


DriverPromptEnum Enumeration (DAO)

 Copy code hover
[image]

DriverPromptEnum Enumeration (DAO)
Send feedback

Specifies if and when to prompt the user to establish a connection.

Name | Value | Description
dbDriverComplete | 0 | If the connection string provided includes the DSN keyword, the driver manager uses the string as provided in connect, otherwise it behaves as it does when dbDriverPrompt is specified.
dbDriverCompleteRequired | 3 | (Default) Behaves like dbDriverComplete except the driver disables the controls for any information not required to complete the connection.
dbDriverNoPrompt | 1 | The driver manager uses the connection string provided in connect. If sufficient information is not provided, a trappable error is returned.
dbDriverPrompt | 2 | The driver manager displays the ODBC Data Sources dialog box. The connection string used to establish the connection is constructed from the data source name (DSN) selected and completed by the user via the dialog boxes.


ComboBox.IsVisible Property (Access)

 Copy code hover
[image]

ComboBox.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Syntax

expression .IsVisible

expression A variable that represents a ComboBox object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


FormatConditions.Item Property (Access)

 Copy code hover
[image]

FormatConditions.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only FormatCondition.

Syntax

expression .Item(Index)

expression A variable that represents a FormatConditions object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

FormatConditions Collection

Other resources

FormatConditions Object Members


NavigationControl.OnKeyDown Property (Access)

 Copy code hover
[image]

NavigationControl.OnKeyDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Down box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnKeyDown

expression A variable that represents a NavigationControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyDown event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyDown

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Document Members (DAO)

 Copy code hover
[image]

Document Members (DAO)
Send feedback

A Document object includes information about one instance of an object. The object can be a database, saved table, query, or relationship (Microsoft Access database engine databases only).

Methods

Name | Description
CreateProperty | Creates a new user-defined Property object (Microsoft Access workspaces only).

Properties

Name | Description
Container | Returns the name of the Container object to which a Document object belongs (Microsoft Access workspaces only). .
DateCreated | Returns the date and time that an object was created. Read-only Variant.
LastUpdated | Returns the date and time of the most recent change made to an object. Read-only Variant.
Name | Returns the name of the specified object. Read-only String.
Properties | Returns the Properties collection of the specified object. Read-only.


Recordsets Members (DAO)

 Copy code hover
[image]

Recordsets Members (DAO)
Send feedback

A Recordsets collection contains all open Recordset objects in a Connection or Database object.

Methods

Name | Description
Refresh | Not supported for this object.

Properties

Name | Description
Count | Returns the number of objects in the specified collection. Read-only Integer.


Changes in Access 2013

 Copy code hover
[image]

Changes in Access 2013
Send feedback

Conceptual overview topic

Access 2013 does not include support for Access Data Projects (ADPs). Access 2013 introduces a new application type that enables you to create a web-based Access app. By using this application type, you can create web-based applications that use the power of SQL Server on premise or in the cloud.

Introduction

Access 2013 introduces a new application type that enables you to create a web-based Access app. By using this application type, you can create web-based applications that use the power of SQL Server on premise or in the cloud.

In an Access app on SharePoint Server, when you create a table, a query or a data macro in the Access client in which you are creating tables, views or triggers in a SQL Server database. Using the Access client, you can open your database to other applications that connect to SQL Server. This enables you to share your data or load data from other systems into your Access app.

With Office 365 and Access 2013, you can build applications that reach your users without having to worry about deployment challenges, software installation issues, or operating system compatibilities. Build your app in one location and share it across the web with the power of SQL Azure and SQL Server.

SQL Azure, the cloud version of SQL Server, does not support features that Access Data Projects (ADPs) rely on to operate. To support ADPs on SQL Azure, Access would require significant changes.

For these reasons, Access 2013 does not support ADPs. ADPs have been a great tool for working with SQL Server in an on-premise environment, however much has changed since ADPs were introduced in Access 2000. Users now expect their database to be available wherever they are.

ADP support and the future

ADPs continue to work in earlier versions of Access. You can continue to develop your ADP applications and we will continue to support earlier versions of Access under the standard support lifecycle. We will not update older versions of Access to support new versions of SQL Server or SQL Azure. Therefore, you may encounter issues if you use SQL Server 2012 or later versions with your ADP. ADPs will continue to support SQL 2008 R2 and earlier.

For the future, ADP developers can consider several different possibilities:

  • Convert to an Access app - Using Access 2013, you can import your tables into a new Access app and forms for your application are automatically created for you. You can extend the functionality of the base forms Access creates for you and users can use your application on the web. Although some of the functionality that you use in ADPs may not be available now, expect Microsoft to continue to focus improvements in the product for this application type.

  • Convert to a linked desktop database - Access 2013 continues to support creating desktop databases in the .accdb file format. You can convert your application to the .accdb format, including all of your existing forms and reports, and leave the data in SQL Server. You can link to the SQL Server database using linked tables and your application will continue to operate against the same data.

  • Create a hybrid application - If your application is large and you don't want to convert everything at the same time, you can import your data into an Access app and link to the SQL Server database from an .accdb. This allows you migrate gradually, adding forms and functionality over time to your Access app while maintaining your client application as an .accdb with linked tables to the SQL Server database behind the Access app.

  • Upgrade to the .NET Framework - Your application may be complex enough that to consider moving to a professional development platform such as the .NET Framework. SQL Server is designed to make it easier for you to use your existing database infrastructure you've already created and extend the functionality of your application without having to significantly rewrite your code.

Conclusion

Access 2013 is designed to connect databases with the cloud by building on SharePoint Server and SQL Server technologies and easily work with Office 365. Access 2013 is designed to help you quickly create and share data-driven business apps that help run your business.

Additional resources

  • What's new for Access 2013 developers

  • Microsoft Support Lifecycle

  • Windows Azure SQL Database


Day Function (Access 2013 custom web app)

 Copy code hover
[image]

Day Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns an integer representing the day (day of the month) of the specified date in the Gregorian calendar.

Syntax

Day(Date)

The Day function contains the following argument.

Argument name | Description
Date | An expression that can be resolved to a Date/Time value. The Date argument expression, column expression, user-defined variable or string literal.

Remarks

Day returns the same value as Datepart(day, date).


NavigationControl.BorderTint Property (Access)

 Copy code hover
[image]

NavigationControl.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderTint

expression A variable that represents a NavigationControl object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


OptionGroup.BackShade Property (Access)

 Copy code hover
[image]

OptionGroup.BackShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackShade

expression A variable that represents an OptionGroup object.

Remarks

The BackShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the BackShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens BackColor by 75%.

VBA Copy code Copy code
Me.ctl.BackShade=25

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


ToggleButton.AfterUpdate Event (Access)

 Copy code hover
[image]

ToggleButton.AfterUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The AfterUpdate event occurs after changed data in a control or record is updated.

Syntax

expression .AfterUpdate

expression A variable that represents a ToggleButton object.

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's AfterUpdate event does occur.

To run a macro or event procedure when this event occurs, set the AfterUpdate property to the name of the macro or to [Event Procedure].

This event does not apply to option buttons, check boxes, or toggle buttons in an option group. It applies only to the option group itself.

The AfterUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

AfterUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. AfterUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For bound controls, the OldValue property isn't set to the updated value until after the AfterUpdate event for the form occurs. Even if the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Report.MenuBar Property (Access)

 Copy code hover
[image]

Report.MenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies a custom menu to display for a report. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .MenuBar

expression A variable that represents a Report object.

Remarks

When opening a report in Microsoft Access 2013 that's part of a database that was created in an earlier version of Microsoft Access, the specified menu bar will be displayed differently depending on the current settings of the AllowFullMenus and AllowBuiltInToolbars properties. If the AllowFullMenus and AllowBuiltInToolbars properties are set to False, the specified menu bar will replace the ribbon as the default set of commands available to the user. If the AllowFullMenus or AllowBuiltInToolbars property is set to True, then the specified menu bar is displayed on the ribbon Add-Ins tab.

See also

Concepts

Report Object

Other resources

Report Object Members


Form.PictureAlignment Property (Access)

 Copy code hover
[image]

Form.PictureAlignment Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureAlignment property to specify where a background picture will appear in an image control or on a form or report. Read/write Byte.Read/write.

Syntax

expression .PictureAlignment

expression A variable that represents a Form object.

Remarks

The PictureAlignment property uses the following settings.

Setting | Visual Basic | Description
Top Left | 0 | The picture is displayed in the top-left corner of the image control, Form window, or page of a report.
Top Right | 1 | The picture is displayed in the top-right corner of the image control, Form window, or page of a report.
Center | 2 | (Default) The picture is centered in the image control, Form window, or page of a report.
Bottom Left | 3 | The picture is displayed in the bottom-left corner of the image control, Form window, or page of a report.
Bottom Right | 4 | The picture is displayed in the bottom-right corner of the image control, Form window, or page of a report.
Form Center | 5 | (Forms only) The form's picture is centered horizontally in relation to the width of the form and vertically in relation to the height the entire form.

You can also set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

This property can be set in any view.

The Form Center setting aligns a form's picture in the center of the form itself. All other PictureAlignment property settings align a form's picture in relation to the Form window. If you want to make sure that a form's picture is displayed only on the form or tiled across only the form, set the PictureAlignment property to Form Center.

For reports, the picture appears relative to a full page and not in relation to the size of the actual report. If your report is less than a full page and you want a picture to appear at a location not available through the PictureAlignment property settings, use an image control instead.

When you set the PictureTiling property to Yes, tiling of the picture will begin from the PictureAlignment property setting.

Example

The following example displays the picture "Logo.gif" in the top left corner of the "Purchase Order" report.

VBA Copy code Copy code
With Reports("Purchase Order")
 .Picture = "C:\Picture Files\Logo.gif"
 .PictureAlignment = 0
End With

See also

Concepts

Form Object

Other resources

Form Object Members


NavigationControl.SelectedTab Property (Access)

 Copy code hover
[image]

NavigationControl.SelectedTab Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the active tab of the navigation control. Read-only NavigationButton.

Version Information

Version Added: Access 2010

Syntax

expression .SelectedTab

expression A variable that represents a NavigationControl object.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Field.Attributes Property (DAO)

 Copy code hover
[image]

Field.Attributes Property (DAO)
Send feedback

Sets or returns a value that indicates one or more characteristics of a Field object. Read/write Long.

Syntax

expression .Attributes

expression A variable that represents a Field object.

Remarks

The value specifies characteristics of the field represented by the Field object and can be a combination of these constants.

Constant | Description
dbAutoIncrField | The field value for new records is automatically incremented to a unique Long integer that can't be changed (in a Microsoft Access workspace, supported only for Microsoft Access database engine database tables).
dbDescending | The field is sorted in descending (Z to A or 100 to 0) order; this option applies only to a Field object in a Fields collection of an Index object. If you omit this constant, the field is sorted in ascending (A to Z or 0 to 100) order. This is the default value for Index and TableDef fields (Microsoft Access workspaces only)..
dbFixedField | The field size is fixed (default for Numeric fields).
dbHyperlinkField | The field contains hyperlink information (Memo fields only).
dbSystemField | The field stores replication information for replicas; you can't delete this type of field (Microsoft Access workspace only).
dbUpdatableField | The field value can be changed.
dbVariableField | The field size is variable (Text fields only).

For an object not yet appended to a collection, this property is read/write. For an appended Field object, the availability of the Attributes property depends on the object that contains the Fields collection.

If the Field object belongs to an | Then Attributes is
Index object | Read/write until the TableDef object that the Index object is appended to is appended to a Database object; then the property is read-only.
QueryDef object | Read-only
Recordset object | Read-only
Relation object | Not supported
TableDef object | Read/write

When you set multiple attributes, you can combine them by summing the appropriate constants. Any invalid values are ignored without producing an error.

Example

This example displays the Attributes property for Field, Relation, and TableDef objects in the Northwind database.

Copy code Copy code
Sub AttributesX()

 Dim dbsNorthwind As Database
 Dim fldLoop As Field
 Dim relLoop As Relation
 Dim tdfloop As TableDef

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind

 ' Display the attributes of a TableDef object's
 ' fields.
 Debug.Print "Attributes of fields in " & _
 .TableDefs(0).Name & " table:"
 For Each fldLoop In .TableDefs(0).Fields
 Debug.Print " " & fldLoop.Name & " = " & _
 fldLoop.Attributes
 Next fldLoop

 ' Display the attributes of the Northwind database's
 ' relations.
 Debug.Print "Attributes of relations in " & _
 .Name & ":"
 For Each relLoop In .Relations
 Debug.Print " " & relLoop.Name & " = " & _
 relLoop.Attributes
 Next relLoop

 ' Display the attributes of the Northwind database's
 ' tables.
 Debug.Print "Attributes of tables in " & .Name & ":"
 For Each tdfloop In .TableDefs
 Debug.Print " " & tdfloop.Name & " = " & _
 tdfloop.Attributes
 Next tdfloop

 .Close
 End With

End Sub


DataControl Object Example (VBScript)

 Copy code hover
[image]

DataControl Object Example (VBScript)
Send feedback

The following code shows how to set the RDS.DataControl parameters at design time and bind them to a data-aware control. Cut and paste this code between the <Body> and </Body> tags in a normal HTML document and name it DataControlDesignVBS.asp. ASP script will identify your server.

VBS Copy code Copy code
<!-- BeginDataControlDesignVBS --><%@ Language=VBScript %>
<HTML><HEAD>
<META name="VI60_DefaultClientScript" content=VBScript><META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<title>RDS DataControl</title>
<%' local style sheet used for display%><STYLE>
<!--BODY {
font-family: 'Verdana','Arial','Helvetica',sans-serif;BACKGROUND-COLOR:white;
COLOR:black;}
.thead {background-color: #008080;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.thead2 {background-color: #800000;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.tbody {text-align: center;
background-color: #f7efde;font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;}
--></STYLE>
</HEAD>
<BODY><H2>RDS API Code Examples</H2>
<HR><H3>Remote Data Service</H3>
<TABLE DATASRC=#RDS><TBODY>
<TR><TD><SPAN DATAFLD="FirstName"></SPAN></TD>
<TD><SPAN DATAFLD="LastName"></SPAN></TD></TR>
</TBODY></TABLE>
<!-- Remote Data Service with Parameters set at Design Time -->
<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"ID=RDS>
<PARAM NAME="SQL" VALUE="Select * from Employees for browse"><PARAM NAME="SERVER" VALUE="http://<%=Request.ServerVariables("SERVER_NAME")%>">
<PARAM NAME="CONNECT" VALUE="Provider='sqloledb';Integrated Security='SSPI';Initial Catalog='Northwind'"></OBJECT>
</BODY></HTML>
<!-- EndDataControlDesignVBS -->

The following example shows how to set the necessary parameters of RDS.DataControl at run time. To test this example, cut and paste this code between the <Body> and </Body> tags in a normal HTML document and name it DataControlRuntimeVBS.asp. ASP script will identify your server.

VBS Copy code Copy code
<!-- BeginDataControlRuntimeVBS --><%@ Language=VBScript %>
<html><head>
<meta name="VI60_DefaultClientScript" content=VBScript><meta name="GENERATOR" content="Microsoft Visual Studio 6.0">
<title>Data Control Object Example (VBScript)</title>
<%' local style sheet used for display%><style>
<!--body {
font-family: 'Verdana','Arial','Helvetica',sans-serif;BACKGROUND-COLOR:white;
COLOR:black;}
.thead {background-color: #008080;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.thead2 {background-color: #800000;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.tbody {text-align: center;
background-color: #f7efde;font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;}
--></style>
</head>
<body><h1>Data Control Object Example (VBScript)</h1>
<H2>RDS API Code Examples</H2><HR>
<H3>Remote Data Service Run Time</H3>
<TABLE DATASRC=#RDS><TBODY>
<TR><TD><SPAN DATAFLD="au_lname"></SPAN></TD>
<TD><SPAN DATAFLD="au_fname"></SPAN></TD></TR>
</TBODY></TABLE>
<% ' RDS.DataControl with no parameters set at design time %><OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID=RDS HEIGHT=1 WIDTH=1></OBJECT>
<FORM name="frmInput"><HR>
<Input Size="70" Name="txtServer" Value="http://<%=Request.ServerVariables("SERVER_NAME")%>"><BR><Input Size="100" Name="txtConnect" Value="Provider='sqloledb';Data Source=<%=Request.ServerVariables("SERVER_NAME")%>;Initial Catalog='Pubs';Integrated Security='SSPI';">
<BR><Input Size="70" Name="txtSQL" Value="Select * from Authors">
<HR><INPUT TYPE="BUTTON" NAME="Run" VALUE="Run"><BR>
<H4>Show grid with these values or change them to see data from another ODBC data source on your server</H4></FORM>
<Script Language="VBScript">
' Set parameters of RDS.DataControl at Run TimeSub Run_OnClick
RDS.Server = document.frmInput.txtServer.ValueRDS.Connect = document.frmInput.txtConnect.Value
RDS.SQL = document.frmInput.txtSQL.Value
RDS.Refresh
End Sub
</Script>
</body></html>
<!-- EndDataControlRuntimeVBS -->


Form.OnDblClick Property (Access)

 Copy code hover
[image]

Form.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Syntax

expression .OnDblClick

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_DblClick" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

Form Object

Other resources

Form Object Members


Printer Members (Access)

 Copy code hover
[image]

Printer Members (Access)
Send feedback

Published: July 16, 2012

A Printer object corresponds to a printer available on your system.

Properties

Name | Description
BottomMargin | Along with the TopMargin, RightMargin, and LeftMargin properties, specifies the margins for a printed page. Read/write Long.
ColorMode | Returns or sets an AcPrintColor constant representing whether the specified printer should print output in color or monochrome. Read/write.
ColumnSpacing | Returns or sets a Long representing the vertical space between detail sections in twips. Read/write.
Copies | Returns or sets a Long indicating the number of copies to be printed. Read/write.
DataOnly | True if Microsoft Access prints only the data from a table or query in Datasheet View and not the labels, control borders, gridlines, and display graphics. Read/write Boolean.
DefaultSize | True if the size of the detail section in Design View is used for printing; otherwise, the values of the ItemSizeHeight and ItemSizeWidth properties are used. Read/write Boolean.
DeviceName | Returns a String indicating name of the specified printer device. Read-only.
DriverName | Returns a String indicating the name of the driver used by the specified printer. Read-only.
Duplex | Returns or sets an AcPrintDuplex constant indicating how the specified printer handles duplex printing. Read/write.
ItemLayout | Returns or sets an AcPrintItemLayout constant indicating whether the printer lays columns across, then down, or down, then across. Read/write.
ItemsAcross | Returns or sets a Long indicating the number of columns to print across a page for multiple-column reports or labels. Read/write.
ItemSizeHeight | Returns or sets a Long indicating the height of the detail section of a form or report in twips. Read/write.
ItemSizeWidth | Returns or sets a Long indicating the height of the detail section of a form or report in twips. Read/write.
LeftMargin | Along with the TopMargin, RightMargin, and BottomMargin properties, specifies the margins for a printed page. Read/write Long.
Orientation | Gets or sets an AcPrintOrientation constant that represents the print orientation. Read/write.
PaperBin | Returns or sets an AcPrintPaperBin constant indicating which paper bin the specified printer should use. Read/write.
PaperSize | Returns or sets an AcPrintPaperSize constant indicating the paper size to use when printing. Read/write.
Port | Returns a String indicating the port name of the specified printer. Read-only.
PrintQuality | Returns or sets an AcPrintObjQuality constant indicating the resolution at which the specified printer should print jobs. Read/write.
RightMargin | Along with the TopMargin, LeftMargin, and BottomMargin properties, specifies the margins for a printed page. Read/write Long.
RowSpacing | Returns or sets a Long indicating the horizontal space between detail sections in twips. Read/write.
TopMargin | Along with the LeftMargin, RightMargin, and BottomMargin properties, specifies the margins for a printed page. Read/write Long.


DoCmd.DeleteObject Method (Access)

 Copy code hover
[image]

DoCmd.DeleteObject Method (Access)
See also Send feedback

Published: July 16, 2012

The DeleteObject method carries out the DeleteObject action in Visual Basic.

Syntax

expression .DeleteObject(ObjectType, ObjectName)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
ObjectType | Optional | AcObjectType | A AcObjectType constant that represents the type of object to delete.
ObjectName | Optional | Variant | string expression that's the valid name of an object of the type selected by the objecttype argument. If you run Visual Basic code containing the DeleteObject method in a library database, Microsoft Access looks for the object with this name first in the library database, then in the current database.

Remarks

You can use the DeleteObject method to delete a specified database object.

If you leave the objecttype and objectname arguments blank (the default constant, acDefault, is assumed for objecttype), Microsoft Access deletes the object selected in the Database window. To select an object in the Database window, you can use the SelectObject action or SelectObject method with the In Database Window argument set to Yes (True).

Example

The following example deletes the specified table:

VBA Copy code Copy code
DoCmd.DeleteObject acTable, "Former Employees Table"

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Syntax error (comma). (Error 2432)

 Copy code hover
[image]

Syntax error (comma). (Error 2432)
Send feedback

The expression or statement uses a comma where it does not belong or is missing a comma to separate arguments.


WSParameter Members (Access)

 Copy code hover
[image]

WSParameter Members (Access)
Send feedback

Published: July 16, 2012

Represents a parameter defined for an Operation.

Properties

Name | Description
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Type | Get the data type of the specified parameter. Read-only Integer.


Form.AllowAdditions Property (Access)

 Copy code hover
[image]

Form.AllowAdditions Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllowAdditions property to specify whether a user can add a record when using a form. Read/write Boolean.

Syntax

expression .AllowAdditions

expression A variable that represents a Form object.

Remarks

Set the AllowAdditions property to No to allow users to view or edit existing records but not add new records.

If you want to prevent changes to existing records (make a form read-only), set the AllowAdditions, AllowDeletions , and AllowEdits properties to No. You can also make records read-only by setting the RecordsetType property to Snapshot.

If you want to open a form for data entry only, set the form's DataEntry property to Yes.

When the AllowAdditions property is set to No, the Data Entry command on the Records menu isn't available.

Note Note

When the Data Mode argument of the OpenForm action is used, Microsoft Access will override a number of form property settings. If the Data Mode argument of the OpenForm action is set to Edit, Microsoft Access will open the form with the following property settings:

  • AllowEdits — Yes

  • AllowDeletions — Yes

  • AllowAdditions — Yes

  • DataEntry — No

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Cannot open any more tables. (Error 3014)

 Copy code hover
[image]

Cannot open any more tables. (Error 3014)
Send feedback

You have reached the limit on the number of tables that can be opened at one time. Close one or more tables, and then try the operation again.


ObjectProxy (ADO/WFC Syntax)

 Copy code hover
[image]

ObjectProxy (ADO/WFC Syntax)
Send feedback

An ObjectProxy object represents a server, and is returned by the createObject method of the DataSpace object. The ObjectProxy class has one method, call, which can invoke a method on the server and return an object resulting from that invocation.

package com.ms.wfc.data

Methods

Call Method (ADO/WFC Syntax)

Invokes a method on the server represented by the ObjectProxy. Optionally, method arguments may be passed as an array of objects.

Syntax

Copy code Copy code

public Object ObjectProxy.call( String method )
public Object ObjectProxy.call( String method, Object[] args)

Returns

  • Object

  • An object resulting from invoking the method.

Parameters

  • ObjectProxy

  • An ObjectProxy object that represents the server.

  • method

  • A String, containing the name of the method to invoke on the server.

  • args

  • Optional. An array of objects that are arguments to the method on the server. Java data types are automatically converted to data types suitable for use on the server.


Application Methods (Access)

 Copy code hover
[image]

Application Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
AccessError | You can use the AccessError method to return the descriptive string associated with a Microsoft Access or DAO error.
AddToFavorites | The AddToFavorites method adds a hyperlink address to the Favorites folder.
BuildCriteria | The BuildCriteria method returns a parsed criteria string as it would appear in the query design grid, in Filter By Form or Server Filter By Form mode. For example, you may want to set a form's Filter or ServerFilter property based on varying criteria from the user. You can use the BuildCriteria method to construct the string expression argument for the Filter or ServerFilter property. String.
CloseCurrentDatabase | You can use the CloseCurrentDatabase method to close the current database (either a Microsoft Access database or an Access project (.adp) from another application that has opened a database through Automation.
CodeDb | You can use the CodeDb method in a code module to determine the name of the Database object that refers to the database in which code is currently running. Use the CodeDb method to access Data Access Objects (DAO) that are part of a library database.
ColumnHistory | Gets the history of values that have been stored in a Memo field.
CompactRepair | Compacts and repairs the specified database or Microsoft Access project (.adp) file. Returns a Boolean; True if the process was successful.
ConvertAccessProject | Converts the specified Microsoft Access file from one version to another.
CreateAccessProject | You can use the CreateAccessProject method to create a new Microsoft Access project (.adp) on disk.
CreateAdditionalData | Creates an AdditionalData object that can be used to add additional tables and queries to the parent table that is being exported by the ExportXML method.
CreateControl | The CreateControl method creates a control on a specified open form. For example, suppose you are building a custom wizard that allows users to easily construct a particular form. You can use the CreateControl method in your wizard to add the appropriate controls to the form.
CreateForm | The CreateForm method creates a form and returns a Form object.
CreateGroupLevel | You can use the CreateGroupLevel method to specify a field or expression on which to group or sort data in a report. .
CreateReport | The CreateReport method creates a report and returns a Report object. For example, suppose you are building a custom wizard to create a sales report. You can use the CreateReport method in your wizard to create a new report based on a specified report template.
CreateReportControl | The CreateReportControl method creates a control on a specified open report. For more information, see the CreateControl method.
CurrentDb | The CurrentDb method returns an object variable of type Database that represents the database currently open in the Microsoft Access window.
CurrentUser | You can use the CurrentUser method to return the name of the current user of the database. .
CurrentWebUser | Gets information about the current user of a Web database on Microsoft SharePoint Foundation 2010.
CurrentWebUserGroups | Gets the collection of Microsoft SharePoint Foundation 2010 groups of which the user is a member.
DAvg | You can use the DAvg function to calculate the average of a set of values in a specified set of records (a domain).
DCount | You can use the DCount function to determine the number of records that are in a specified set of records (a domain).
DDEExecute | You can use the DDEExecute statement to send a command from a client application to a server application over an open dynamic data exchange (DDE) channel.
DDEInitiate | You can use the DDEInitiate function to begin a dynamic data exchange (DDE) conversation with another application. The DDEInitiate function opens a DDE channel for transfer of data between a DDE server and client application.
DDEPoke | You can use the DDEPoke statement to supply text data from a client application to a server application over an open dynamic data exchange (DDE) channel.
DDERequest | You can use the DDERequest function over an open dynamic data exchange (DDE) channel to request an item of information from a DDE server application.
DDETerminate | You can use the DDETerminate statement to close a specified dynamic data exchange (DDE) channel.
DDETerminateAll | You can use the DDETerminateAll statement to close all open dynamic data exchange (DDE) channels.
DefaultWorkspaceClone | You can use the DefaultWorkspaceClone method to create a new Workspace object without requiring the user to log on again. For example, if you need to conduct two sets of transactions simultaneously in separate workspaces, you can use the DefaultWorkspaceClone method to create a second Workspace object with the same user name and password without prompting the user for this information again.
DeleteControl | The DeleteControl method deletes a specified control from a form.
DeleteReportControl | The DeleteReportControl method deletes a specified control from a report.
DFirst | You can use the DFirst function to return a random record from a particular field in a table or query when you simply need any value from that field.
DirtyObject | Marks a form or report as dirty.
DLast | You can use the DLast function to return a random record from a particular field in a table or query when you simply need any value from that field. .
DLookup | You can use the DLookup function to get the value of a particular field from a specified set of records (a domain).
DMax | You can use DMax function to determine maximum value in a specified set of records (a domain).
DMin | You can use DMin function to determine minnimum value in a specified set of records (a domain). .
DStDev | Estimates the standard deviation across a population sample in a specified set of records (a domain). .
DStDevP | Estimates the standard deviation across a population in a specified set of records (a domain). .
DSum | You can use the DSum function to calculate the sum of a set of values in a specified set of records (a domain). .
DVar | Estimates the variance across a sample in a specified set of records (a domain).
DVarP | Calculates the variance of a population in a specified set of records (a domain).
Echo | The Echo method specifies whether Microsoft Access repaints the display screen.
EuroConvert | You can use the EuroConvert function to convert a number to euro or from euro to a participating currency. You can also use it to convert a number from one participating currency to another by using the euro as an intermediary (triangulation). The EuroConvert function uses fixed conversion rates established by the European Union.
Eval | You can use the Eval function to evaluate an expression that results in a text string or a numeric value.
ExportNavigationPane | Saves the current configuration of the Navigation Pane to an XML file.
ExportXML | The ExportXML method allows developers to export XML data, schemas, and presentation information from Microsoft SQL Server 2000 Desktop Engine (MSDE 2000), Microsoft SQL Server 6.5 or later, or the Microsoft Access database engine.
FollowHyperlink | The FollowHyperlink method opens the document or Web page specified by a hyperlink address.
GetHiddenAttribute | The GetHiddenAttribute method returns the value of hidden attribute of a Microsoft Access object in the object's Properties dialog box, available by selecting the object in the Database window and clicking Properties on the View menu.
GetOption | The GetOption method returns the current value of an option in the Access Options dialog box, available by clicking the Microsoft Office Button [image] and then clicking Access Options. Variant.
GUIDFromString | The GUIDFromString function converts a string to a GUID, which is an array of type Byte.
HtmlEncode | Converts a string to an HTML-encoded string.
hWndAccessApp | You can use the hWndAccessApp method to determine the handle assigned by Microsoft Windows to the main Microsoft Access window.
HyperlinkPart | The HyperlinkPart method returns information about data stored as a Hyperlink data type. .
ImportNavigationPane | Loads a saved Navigation Pane configuration from disk.
ImportXML | The ImportXML method allows developers to import XML data and/or schema information into Microsoft SQL Server 2000 Desktop Engine (MSDE 2000), Microsoft SQL Server 7.0 or later, or the Microsoft Access database engine.
InstantiateTemplate | Opens a new database and applies the specified template.
IsCurrentWebUserInGroup | Gets whether or not the current user of a Web databse is a member of the specified Microsoft SharePoint Foundation 2010 group.
LoadCustomUI | Loads XML markup that represents a customized ribbon.
LoadFromAXL | Imports the object defined in an Application XML (AXL) file into the database.
LoadPicture | The LoadPicture method loads a graphic into an ActiveX control.
NewAccessProject | You can use the NewAccessProject method to create and open a new Microsoft Access project (.adp) as the current Access project in the Microsoft Access window.
NewCurrentDatabase | Creates a new Microsoft Access database.
Nz | You can use the Nz function to return zero, a zero-length string (" "), or another specified value when a Variant is Null. For example, you can use this function to convert a Null value to another value and prevent it from propagating through an expression.
OpenAccessProject | You can use the OpenAccessProject method to open an existing Microsoft Access project (.adp) as the current Access project in the Microsoft Access window.
OpenCurrentDatabase | You can use the OpenCurrentDatabase method to open an existing Microsoft Access database as the current database.
PlainText | Strips the rich text formatting from a string and returns an unformatted text string.
Quit | The Quit method quits Microsoft Access. You can select one of several options for saving a database object before quitting.
RefreshDatabaseWindow | The RefreshDatabaseWindow method updates the Database window after a database object has been created, deleted, or renamed.
RefreshTitleBar | The RefreshTitleBar method refreshes the Microsoft Access title bar after the AppTitle or AppIcon property has been set in Visual Basic.
Run | You can use the Run method to carry out a specified Microsoft Access or user-defined Function or Sub procedure. Variant.
RunCommand | The RunCommand method runs a built-in command.
SaveAsAXL | Exports the specified object to an Application XML (AXL) file.
SaveAsTemplate | Converts an existing Access database file to a database template (*.accdt) format file.
SetDefaultWorkgroupFile | Sets the default workgroup file to the specified file.
SetHiddenAttribute | The SetHiddenAttribute method sets the hidden attribute of an Access object.
SetOption | The SetOption method sets the current value of an option in the Access Options dialog box.
StringFromGUID | The StringFromGUID function converts a GUID, which is an array of type Byte, to a string.
SysCmd | You can use the SysCmd method to, display a progress meter or optional specified text in the status bar, return information about Microsoft Access and its associated files, or return the state of a specified database object (to indicate whether the object is open, is a new object, or has been changed but not saved). Variant.
TransformXML | Applies an Extensible Stylesheet Language (XSL) stylesheet to an XML data file and writes the resulting XML to an XML data file.


Form.BeforeScreenTip Event (Access)

 Copy code hover
[image]

Form.BeforeScreenTip Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs before a ScreenTip is displayed for an element in a PivotChart view or PivotTable view.

Syntax

expression .BeforeScreenTip(ScreenTipText, SourceObject)

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
ScreenTipText | Required | Object | Set the Value property of this object to the ScreenTip that you want to display. Changing this argument to an empty string effectively hides the ScreenTip.
SourceObject | Required | Object | The object that generates the ScreenTip.

Return Value

nothing

See also

Concepts

Form Object

Other resources

Form Object Members


Cannot append a Field that is already a part of a Fields collection. (Error 3266).

 Copy code hover
[image]

Cannot append a Field that is already a part of a Fields collection. (Error 3266).
Send feedback

A Field object was specified as an argument to an Append operation when it already is a member of an existing Fields collection. Use the Dim statement and CreateField method to declare a new Field object and specify its values, and retry the operation with the new Field object.


AllViews.Count Property (Access)

 Copy code hover
[image]

AllViews.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents an AllViews object.

See also

Concepts

AllViews Collection

Other resources

AllViews Object Members


Report.Caption Property (Access)

 Copy code hover
[image]

Report.Caption Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the title of the report in Print Preview. Read/write String.

Syntax

expression .Caption

expression A variable that represents a Report object.

Remarks

The Caption property is a string expression that can contain up to 2,048 characters. Captions for forms and reports that are too long to display in the title bar are truncated.

See also

Concepts

Report Object

Other resources

Report Object Members


First, Last Functions (Microsoft Access SQL)

 Copy code hover
[image]

First, Last Functions (Microsoft Access SQL)
Send feedback

Published: July 16, 2012

Return a field value from the first or last record in the result set returned by a query.

Syntax

First(expr)

Last(expr)

The expr placeholder represents a string expression identifying the field that contains the data you want to use or an expression that performs a calculation using the data in that field. Operands in expr can include the name of a table field, a constant, or a function (which can be either intrinsic or user-defined but not one of the other SQL aggregate functions).

Remarks

The First and Last functions are analogous to the MoveFirst and MoveLast methods of a DAO Recordset object. They simply return the value of a specified field in the first or last record, respectively, of the result set returned by a query. Because records are usually returned in no particular order (unless the query includes an ORDER BY clause), the records returned by these functions will be arbitrary.

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Record Order

Example

This example uses the Employees table to return the values from the LastName field of the first and last records returned from the table.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

Copy code Copy code
Sub FirstLastX1()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Return the values from the LastName field of the
    ' first and last records returned from the table.
    Set rst = dbs.OpenRecordset("SELECT " _
        & "First(LastName) as First, " _
        & "Last(LastName) as Last FROM Employees;")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 12

    dbs.Close

End Sub

The next example compares using the First and Last functions with simply using the Min and Max functions to find the earliest and latest birth dates of Employees.

Copy code Copy code
Sub FirstLastX2()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Find the earliest and latest birth dates of
    ' Employees.
    Set rst = dbs.OpenRecordset("SELECT " _
        & "First(BirthDate) as FirstBD, " _
        & "Last(BirthDate) as LastBD FROM Employees;")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 12

    Debug.Print

    ' Find the earliest and latest birth dates of
    ' Employees.
    Set rst = dbs.OpenRecordset("SELECT " _
        & "Min(BirthDate) as MinBD," _
        & "Max(BirthDate) as MaxBD FROM Employees;")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 12

    dbs.Close

End Sub

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.


Report.RecordSourceQualifier Property (Access)

 Copy code hover
[image]

Report.RecordSourceQualifier Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating the SQL Server owner name of the record source for the specified report. Read/write.

Syntax

expression .RecordSourceQualifier

expression A variable that represents a Report object.

See also

Concepts

Report Object

Other resources

Report Object Members


Chapter 1: ADO Fundamentals (ADO)

 Copy code hover
[image]

Chapter 1: ADO Fundamentals (ADO)
Send feedback

In this section

  • Chapter 1: ADO Fundamentals

  • What You Can Do With ADO

  • Errors

  • HelloData: A Simple ADO Application (ADO)

  • OLE DB Providers (ADO)


ConnectComplete and Disconnect Events (ADO)

 Copy code hover
[image]

ConnectComplete and Disconnect Events (ADO)
Send feedback

The ConnectComplete event is called after a connection starts. The Disconnect event is called after a connection ends.

Syntax

ConnectComplete pError, adStatus, pConnection

Disconnect adStatus, pConnection

Parameters

  • pError

  • An Error object. It describes the error that occurred if the value of adStatus is adStatusErrorsOccurred; otherwise it is not set.

  • adStatus

  • EventStatusEnum

    When ConnectComplete is called, this parameter is set to adStatusCancel if a WillConnect event has requested cancellation of the pending connection.

    Before either event returns, set this parameter to adStatusUnwantedEvent to prevent subsequent notifications. However, closing and reopening the Connection causes these events to occur again.

  • pConnection

  • The Connection object for which this event applies.


Entities Members (Access)

 Copy code hover
[image]

Entities Members (Access)
Send feedback

Published: July 16, 2012

Represents the collection of entities defined in a Data Service data connection.

Properties

Name | Description
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Object.
Parent | Returns the parent object for the specified object. Read-only.


Query must have at least one destination field. (Error 3066)

 Copy code hover
[image]

Query must have at least one destination field. (Error 3066)
Send feedback

This error occurs if you do not specify any destination field names when you create a query. Select at least one destination field.


Marking Business Objects as Safe for Scripting

 Copy code hover
[image]

Marking Business Objects as Safe for Scripting
Send feedback

To help ensure a secure Internet environment, you need to mark any business objects instantiated with the RDS.DataSpace object's CreateObject method as "safe for scripting." You need to ensure they are marked as such in the License area of the system registry before they can be used in DCOM.

To manually mark your business object as safe for scripting, create a text file with a .reg extension that contains the following text. The following two numbers enable the safe-for-scripting feature:

Copy code Copy code

[HKEY_CLASSES_ROOT\CLSID\<MyActiveXGUID>\Implemented
Categories\{7DD95801-9882-11CF-9FA9-00AA006C42C4}]
[HKEY_CLASSES_ROOT\CLSID\<MyActiveXGUID>\Implemented
Categories\{7DD95802-9882-11CF-9FA9-00AA006C42C4}]

where <MyActiveXGUID> is the hexadecimal GUID number of your business object. Save it and merge it into your registry by using the Registry Editor or double-clicking the .reg file in Windows Explorer.

Business objects created in Microsoft® Visual Basic can be automatically marked as "safe for scripting" with the Package and Deployment Wizard. When the wizard asks you to specify safety settings, select Safe for initialization and Safe for scripting.

On the last step, the Application Setup Wizard creates an .htm and a .cab file. You can then copy these two files to the target computer and double-click the .htm file to load the page and correctly register the server.

Because the business object will be installed in the Windows\System32\Occache directory by default, move it to the Windows\System32 directory and change the HKEY_CLASSES_ROOT\CLSID\<MyActiveXGUID>\InprocServer32 registry key to match the correct path.

Note Note

Business objects marked as safe for scripting or safe for initialization can be instantiated and initialized by anyone over the network. Any custom business object must not be designed and implemented casually. It is imperative that such objects do not present a security threat that hackers can explore to gain access to the sensitive area of the hosting server and inflict damages.


EmptyCell.BackStyle Property (Access)

 Copy code hover
[image]

EmptyCell.BackStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .BackStyle

expression A variable that represents an EmptyCell object.

Remarks

The BackStyle property uses the following settings.

Setting | Visual Basic | Description
Normal | 1 | (Default for all controls except option group) The control has its interior color set by the BackColor property.
Transparent | 0 | (Default for option group) The control is transparent. The color of the form or report behind the control is visible.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

If the Transparent button on the Back Color button palette is selected, the BackStyle property is set to Transparent; otherwise the BackStyle property is set to Normal.

To make a command button invisible, set its Transparent property to Yes.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


Attachment.AddColon Property (Access)

 Copy code hover
[image]

Attachment.AddColon Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.

Syntax

expression .AddColon

expression A variable that represents an Attachment object.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


CheckBox.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

CheckBox.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified check box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthLeft

expression A variable that represents a CheckBox object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Errors Methods (DAO)

 Copy code hover
[image]

Errors Methods (DAO)
Send feedback

In this section

  • Errors.Refresh Method (DAO)


Image Events (Access)

 Copy code hover
[image]

Image Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.


Could not save; currently locked by another user. (Error 3202)

 Copy code hover
[image]

Could not save; currently locked by another user. (Error 3202)
Send feedback

Possible cause:

  • You tried to save a record on a 2K database page that is currently locked by another user. Wait for the other user to finish working with the record, and then try the operation again.


EmptyCell.BottomPadding Property (Access)

 Copy code hover
[image]

EmptyCell.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .BottomPadding

expression A variable that represents an EmptyCell object.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


ReadText Method (ADO)

 Copy code hover
[image]

ReadText Method (ADO)
Send feedback

Reads specified number of characters from a text Stream object.

Syntax

String = Stream.ReadText (NumChars)

Parameters

  • NumChars

  • Optional. A Long value that specifies the number of characters to read from the file, or a StreamReadEnum value. The default value is adReadAll.

Return Value

The ReadText method reads a specified number of characters, an entire line, or the entire stream from a Stream object and returns the resulting string.

Remarks

If NumChar is more than the number of characters left in the stream, only the characters remaining are returned. The string read is not padded to match the length specified by NumChar. If there are no characters left to read, a variant whose value is null is returned. ReadText cannot be used to read backwards.

Note Note

The ReadText method is used with text streams (Type is adTypeText). For binary streams (Type is adTypeBinary), use Read.


FormatConditions Methods (Access)

 Copy code hover
[image]

FormatConditions Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Add | You can use the Add method to add a conditional format as a FormatCondition object to the FormatConditions collection of a combo box or text box control.
Delete | Deletes the specified object.


UPDATE Statement (Microsoft Access SQL)

 Copy code hover
[image]

UPDATE Statement (Microsoft Access SQL)
Send feedback

Creates an update query that changes values in fields in a specified table based on specified criteria.

Syntax

UPDATE table SET newvalue WHERE criteria;

The UPDATE statement has these parts:

Part | Description
table | The name of the table containing the data you want to modify.
newvalue | An expression that determines the value to be inserted into a particular field in the updated records.
criteria | An expression that determines which records will be updated. Only records that satisfy the expression are updated.

Remarks

UPDATE is especially useful when you want to change many records or when the records that you want to change are in multiple tables.

You can change several fields at the same time. The following example increases the Order Amount values by 10 percent and the Freight values by 3 percent for shippers in the United Kingdom:

SQL Copy code Copy code
UPDATE Orders
SET OrderAmount = OrderAmount * 1.1,
Freight = Freight * 1.03
WHERE ShipCountry = 'UK';
Important note Important

  • UPDATE does not generate a result set. Also, after you update records using an update query, you cannot undo the operation. If you want to know which records were updated, first examine the results of a select query that uses the same criteria, and then run the update query.

  • Maintain backup copies of your data at all times. If you update the wrong records, you can retrieve them from your backup copies.

Example

This example changes values in the ReportsTo field to 5 for all employee records that currently have ReportsTo values of 2.

VBA Copy code Copy code
Sub UpdateX()

    Dim dbs As Database
    Dim qdf As QueryDef

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Change values in the ReportsTo field to 5 for all
    ' employee records that currently have ReportsTo
    ' values of 2.
    dbs.Execute "UPDATE Employees " _
        & "SET ReportsTo = 5 " _
        & "WHERE ReportsTo = 2;"

    dbs.Close

End Sub


Subqueries cannot be used in the expression

 Copy code hover
[image]

Subqueries cannot be used in the expression <expression>. (Error 3203)
Send feedback

The specified expression contains a subquery or other expression that functions as a subquery.

Possible cause:

  • You used a SELECT statement that includes an aggregate function that evaluates another aggregate function. This error occurs, for example, if you execute the following statement:

    SQL Copy code Copy code
    TRANSFORM Sum([OrderAmount]) AS Sum1
SELECT Sum([Sum1]) AS Sum2, OrderID, Sum([Sum2]) AS Expr1
FROM Orders
GROUP BY OrderID
PIVOT ShipName;

    The <expression> parameter of the alert would contain the expression Sum([Sum2]) from the SELECT clause, because this references an alias used in the same SELECT statement and acts as a subquery against Sum([Sum1]) .


AcVerticalAnchor Enumeration (Access)

 Copy code hover
[image]

AcVerticalAnchor Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the VerticalAnchor property to specify how a control is anchored vertically within its layout.

Version Information

Version Added: Access 2007

Name | Value | Description
acVerticalAnchorBoth | 2 | The control is stretched vertically across its layout.
acVerticalAnchorBottom | 1 | The control is anchored at the bottom of its layout.
acVerticalAnchorTop | 0 | The control is anchored at the top of its layout.


Shape Append Clause

 Copy code hover
[image]

Shape Append Clause
Send feedback

The shape command APPEND clause appends a column or columns to a Recordset. Often these columns are chapter columns, which refer to a child Recordset.

Syntax

Copy code Copy code

SHAPE [parent-command [[AS] parent-alias]] APPEND column-list

Description

The parts of this clause are as follows:

  • parent-command

  • Zero or one of the following (you may omit the parent-command entirely):

    • A provider command within curly braces ("{}") that returns a Recordset object. The command is issued to the underlying data provider, and its syntax depends on the requirements of that provider. This will typically be the SQL language, although ADO does not require any particular query language.

    • Another shape command embedded in parentheses.

    • The TABLE keyword, followed by the name of a table in the data provider.

  • parent-alias

  • An optional alias that refers to the parent Recordset.

  • column-list

  • One or more of the following:

    • An aggregate column.

    • A calculated column.

    • A new column created with the NEW clause.

    • A chapter column. A chapter column definition is enclosed in parentheses ("()"). See syntax below:

Copy code Copy code

SHAPE [parent-command [[AS] parent-alias]]
 APPEND (child-recordset [ [[AS] child-alias]
 RELATE parent-column TO child-column | PARAMETER param-number, ... ])
 [[AS] chapter-alias]
 [, ... ]

  • child-recordset

    • A provider command within curly braces ("{}") that returns a Recordset object. The command is issued to the underlying data provider, and its syntax depends on the requirements of that provider. This will typically be the SQL language, although ADO does not require any particular query language.

    • Another shape command embedded in parentheses.

    • The name of an existing shaped Recordset.

    • The TABLE keyword, followed by the name of a table in the data provider.

  • child-alias

  • An alias that refers to the child Recordset.

  • parent-column

  • A column in the Recordset returned by the parent-command.

  • child-column

  • A column in the Recordset returned by the child-command.

  • param-number

  • See Operation of Parameterized Commands.

  • chapter-alias

  • An alias that refers to the chapter column appended to the parent.

Note Note

The "parent-column TO child-column" clause is actually a list, where each relation defined is separated by a comma.
Note Note

The clause after the APPEND keyword is actually a list, where each clause is separated by a comma and defines another column to be appended to the parent.

Remarks

When you construct provider commands from user input as part of a SHAPE command, SHAPE will treat the user-supplied a provider command as an opaque string and pass them faithfully to the provider. For example, in the following SHAPE command,

Copy code Copy code

SHAPE {select * from t1} APPEND ({select * from t2} RELATE k1 TO k2)

SHAPE will execute two commands: select * from t1 and (select * from t2 RELATE k1 TO k2). If the user supplies a compound command consisting of multiple provider commands separated by semicolons, SHAPE is not able to discern the difference. So in the following SHAPE command,

Copy code Copy code

SHAPE {select * from t1; drop table t1} APPEND ({select * from t2} RELATE k1 TO k2)

SHAPE executes select * from t1; drop table t1 and (select * from t2 RELATE k1 TO k2), not realizing that drop table t1 is a separate and in this case, dangerous, provider command. Applications must always validate the user input to prevent such potential hacker attacks from happening.

Remarks

When you construct provider commands from user input as part of a SHAPE command, SHAPE will treat the user-supplied a provider command as an opaque string and pass them faithfully to the provider. For example, in the following SHAPE command,

Copy code Copy code

SHAPE {select * from t1} APPEND ({select * from t2} RELATE k1 TO k2)

SHAPE will execute two commands: select * from t1 and (select * from t2 RELATE k1 TO k2). If the user supplies a compound command consisting of multiple provider commands separated by semicolons, SHAPE is not able to discern the difference. So in the following SHAPE command,

Copy code Copy code

SHAPE {select * from t1; drop table t1} APPEND ({select * from t2} RELATE k1 TO k2)

SHAPE executes select * from t1; drop table t1 and (select * from t2 RELATE k1 TO k2), not realizing that drop table t1 is a separate and in this case, dangerous, provider command. Applications must always validate the user input to prevent such potential hacker attacks from happening.


Report.Recordset Property (Access)

 Copy code hover
[image]

Report.Recordset Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets the ADO Recordset or DAO Recordset object representing the record source for the specified object. Read/write Object.

Syntax

expression .Recordset

expression A variable that represents a Report object.

Remarks

The Recordset property returns the recordset object that provides the data being browsed in a form, report, list box control, or combo box control. If a form is based on a query, for example, referring to the Recordset property is the equivalent of cloning a Recordset object by using the same query. However, unlike using the RecordsetClone property, changing which record is current in the recordset returned by the form's Recordset property also sets the current record of the form.

The read/write behavior of the Recordset property is determined by the type of recordset (ADO or DAO) and the type of data (Access or SQL) contained in the recordset identified by the property.

Recordset type | Based on SQL data | Based on data stored by the Access database engine
ADO | Read/Write | Read/Write
DAO | N/A | Read/Write

The following example opens a form, opens a recordset, and then binds the form to the recordset by setting the form's Recordset property to the newly created Recordset object.

VBA Copy code Copy code
Global rstSuppliers As ADODB.Recordset
Sub MakeRW()
    DoCmd.OpenForm "Suppliers"
    Set rstSuppliers = New ADODB.Recordset
    rstSuppliers.CursorLocation = adUseClient
    rstSuppliers.Open "Select * From Suppliers", _
         CurrentProject.Connection, adOpenKeyset, adLockOptimistic
    Set Forms("Suppliers").Recordset = rstSuppliers
End Sub

Use the Recordset property:

  • To use methods with the Recordset object that aren't directly supported on forms. For example, you can use the Recordset property with the ADO Find or DAO Find methods in a custom dialog for finding a record.

  • To wrap a transaction (which can be rolled back) around a set of edits that affect multiple forms.

Changing a form's Recordset property may also change the RecordSource, RecordsetType, and RecordLocks properties. Also, some data-related properties may be overridden, for example, the Filter, FilterOn, OrderBy, and OrderByOn properties.

Calling the Requery method of a form's recordset (for example, Forms(0).Recordset.Requery) can cause the form to become unbound. To refresh the data in a form bound to a recordset, set the RecordSource property of the form to itself (Forms(0).RecordSource = Forms(0).RecordSource).

  • To bind multiple forms to a common data set. This allows synchronization of multiple forms. For example,

VBA Copy code Copy code
   Set Me.Recordset = Forms!Form1.Recordset

When a form is bound to a recordset, an error occurs if you use the Filter by Form command.

Example

The following example uses the Recordset property to create a new copy of the Recordset object from the current form and then prints the names of the fields in the Debug window.

VBA Copy code Copy code
Sub Print_Field_Names()
    Dim rst As DAO.Recordset, intI As Integer
    Dim fld As Field

    Set rst = Me.Recordset
    For Each fld in rst.Fields
        ' Print field names.
        Debug.Print fld.Name
    Next
End Sub

The next example uses the Recordset property and the Recordset object to synchronize a recordset with the form's current record. When a company name is selected from a combo box, the FindFirst method is used to locate the record for that company, causing the form to display the found record.

VBA Copy code Copy code
Sub SupplierID_AfterUpdate()
    Dim rst As DAO.Recordset
    Dim strSearchName As String

    Set rst = Me.Recordset
    strSearchName = CStr(Me!SupplierID)
    rst.FindFirst "SupplierID = " & strSearchName
    If rst.NoMatch Then
        MsgBox "Record not found"
    End If
    rst.Close
End Sub

The following code helps to determine what type of recordset is returned by the Recordset property under different conditions.

VBA Copy code Copy code
Sub CheckRSType()
    Dim rs as Object

    Set rs=Forms(0).Recordset
    If TypeOf rs Is DAO.Recordset Then
        MsgBox "DAO Recordset"
    ElseIf TypeOf rs is ADODB.Recordset Then
        MsgBox "ADO Recordset"
    End If
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


ODBC -- data type not supported on server. (Error 3235)

 Copy code hover
[image]

ODBC -- data type not supported on server. (Error 3235)
Send feedback

The ODBC server does not support the same SQL data types as the database engine or your application. The data has not been placed on the server.


AccessObjectProperties.Add Method (Access)

 Copy code hover
[image]

AccessObjectProperties.Add Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the Add method to add a new property as an AccessObjectProperty object to the AccessObjectProperties collection of an AccessObject object.

Syntax

expression .Add(PropertyName, Value)

expression A variable that represents an AccessObjectProperties object.

Parameters

Name | Required/Optional | Data Type | Description
PropertyName | Required | String | A string expression that's the name of the new property.
Value | Required | Variant | A Variant value corresponding to the option setting. The setting of the value argument depends on the possible settings for a particular option. Can be a constant or a string value.

Remarks

You can use the Remove method of the AccessObjectProperties collection to delete an existing property.

See also

Concepts

AccessObjectProperties Collection

Other resources

AccessObjectProperties Object Members


Application.MacroError Property (Access)

 Copy code hover
[image]

Application.MacroError Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a MacroError object that contains information about the latest error to occur in a macro. Read-only.

Version Information

Version Added: Access 2007

Syntax

expression .MacroError

expression A variable that represents an Application object.

See also

Concepts

Application Object

Other resources

Application Object Members


XML Recordset Persistence Scenario
Send feedback

XML Recordset Persistence Scenario

In this scenario, you will create an Active Server Pages (ASP) application that saves the contents of a Recordset object directly to the ASP Response object.

Note Note

This scenario requires that your server have Internet Information Server 5.0 (IIS) or later installed.

The returned Recordset is displayed in Internet Explorer using an RDS.DataControl.

The following steps are necessary to create this scenario:

  1. Set up the application.

  2. Get the data.

  3. Send the data.

  4. Receive and display the data.

Next Step 1: Set Up the Application


Cancel Method (RDS)

 Copy code hover
[image]

Cancel Method (RDS)
Send feedback

Cancels execution of a pending, asynchronous method call.

Syntax

RDS. DataControl.Cancel

Remarks

When you call Cancel, ReadyState is automatically set to adcReadyStateLoaded, and the Recordset will be empty.


Section I: ActiveX Data Objects

 Copy code hover
[image]

Section I: ActiveX Data Objects
Send feedback

This section contains the following chapters:

  • Chapter 1: ADO Fundamentals

  • Chapter 2: Getting Data

  • Chapter 3: Examining Data

  • Chapter 4: Editing Data

  • Chapter 5: Updating and Persisting Data

  • Chapter 6: Error Handling

  • Chapter 7: Handling ADO Events

  • Chapter 8: Understanding Cursors and Locks

  • Chapter 9: Data Shaping

  • Chapter 10: Records and Streams


WebBrowserControl.Height Property (Access)

 Copy code hover
[image]

WebBrowserControl.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .Height

expression A variable that represents a WebBrowserControl object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Form.OnDisconnect Property (Access)

 Copy code hover
[image]

Form.OnDisconnect Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the OnDisconnect event occurs. Read/write.

Syntax

expression .OnDisconnect

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the OnDisconnect event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).OnDisconnect = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


AccessObject Methods (Access)

 Copy code hover
[image]

AccessObject Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
GetDependencyInfo | Returns a DependencyInfo object that represents the database objects that are dependent upon the specified object.
IsDependentUpon | Returns a Boolean value that indicates whether the specified object is dependent upon the database object specified in the ObjectName argument.


ComboBox.Controls Property (Access)

 Copy code hover
[image]

ComboBox.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Syntax

expression .Controls

expression A variable that represents a ComboBox object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Fields Methods (DAO)

 Copy code hover
[image]

Fields Methods (DAO)
Send feedback

In this section

  • Fields.Append Method (DAO)

  • Fields.Delete Method (DAO)

  • Fields.Refresh Method (DAO)


DoCmd.MoveSize Method (Access)

 Copy code hover
[image]

DoCmd.MoveSize Method (Access)
See also Send feedback

Published: July 16, 2012

The MoveSize method carries out the MoveSize action in Visual Basic.

Syntax

expression .MoveSize(Right, Down, Width, Height)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
Right | Optional | Variant | The new horizontal position of the window's upper-left corner, measured from the left edge of its containing window.
Down | Optional | Variant | The new vertical position of the window's upper-left corner, measured from the top edge of its containing window.
Width | Optional | Variant | The window's new width.
Height | Optional | Variant | The window's new height.

Remarks

You can use the MoveSize method to move or resize the active window.

The units for the arguments are twips.

You must include at least one argument for the MoveSize method. If you leave an argument blank, the current setting for the window is used.

Example

The following example moves the active window and changes its height, but leaves its width unchanged:

VBA Copy code Copy code
DoCmd.MoveSize 1440, 2400, , 2000

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


ToggleButton.OnKeyPress Property (Access)

 Copy code hover
[image]

ToggleButton.OnKeyPress Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Press box in the Properties window. Read/write String.

Syntax

expression .OnKeyPress

expression A variable that represents a ToggleButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyPress event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyPress value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Press box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Press box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyPress property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyPress

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


CommandButton.OnExit Property (Access)

 Copy code hover
[image]

CommandButton.OnExit Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnExit

expression A variable that represents a CommandButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Exit event occurs just before a control loses the focus to another control on the same form.

The OnExit value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Exit box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Exit box is blank, the property value is an empty string.

Example

The following example associates the Exit event with the macro "Exit_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnExit = "Exit_Macro"

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ForEachRecord Data Block (Access 2013 custom web app)

 Copy code hover
[image]

ForEachRecord Data Block (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

A ForEachRecord data block repeats a set of statements for each record in a domain.

Note Note

The ForEachRecord data block is available only in Data Macros.

Setting

The ForEachRecord action has the following arguments.

Argument name

Required

Description

In

Yes

A string that identifies the domain of records to operate on. The In argument can contain the name of the table, a select query, or a SQL statement.

Note Note

The specified domain cannot include data stored in a linked table or ODBC data source.

Where Condition

No

A string expression used to restrict the range of data on which the ForEachRecord data block is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria are omitted, the ForEachRecord data block operates on the entire domain specified by the In argument. Any field that is included in criteria must also be a field in In.

Alias

No

A string that provides an alternative name for the domain specified by the In argument. Often used to shorten the table name for subsequent references to prevent possible ambiguous references. If Alias is not specified, the table or query name will be used as the alias.

Remarks

Use the ExitForEachRecord action to exit a ForEachRecord data block immediately.


Field2.LoadFromFile Method (DAO)

 Copy code hover
[image]

Field2.LoadFromFile Method (DAO)
Send feedback

Loads the specified file from disk.

Version Information

Version Added: Access 2007

Syntax

expression .LoadFromFile(FileName)

expression A variable that represents a Field2 object.

Parameters

Name | Required/Optional | Data Type | Description
FileName | Required | String | The fully qualified path of the file to that you want to load.

Example

The following code snippet uses the LoadFromFile method to load an employee's picture from disk.

VBA Copy code Copy code
   '  Instantiate the parent recordset.
   Set rsEmployees = db.OpenRecordset("Employees")

   … Code to move to desired employee

   ' Activate edit mode.
   rsEmployees.Edit

   ' Instantiate the child recordset.
   Set rsPictures = rsEmployees.Fields("Pictures").Value

   ' Add a new attachment.
   rsPictures.AddNew
   rsPictures.Fields("FileData").LoadFromFile "EmpPhoto39392.jpg"
   rsPictures.Update

   ' Update the parent record
   rsEmployees.Update

The following example shows how to add files from a specified folder path to an attachment field.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Public Function LoadAttachments(strPath As String, Optional strPattern As String = "*.*") As Long
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset2
    Dim rsA As DAO.Recordset2
    Dim fld  As DAO.Field2
    Dim strFile As String

    'Get the database, recordset, and attachment field
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("tblAttachments")
    Set fld = rst("Attachments")

    'Navigate through the table
    Do While Not rst.EOF

        'Get the recordset for the Attachments field
        Set rsA = fld.Value

        'Load all attachments in the specified directory
        strFile = Dir(strPath & "\*.*")

        rst.Edit
        Do While Len(strFile) > 0
            'Add a new attachment that matches the pattern.
            'Pass "" to match all files.
            If strFile Like strPattern Then
                rsA.AddNew
                rsA("FileData").LoadFromFile strPath & "\" & strFile
                rsA.Update

                'Increment the number of files added
                LoadAttachments = LoadAttachments + 1
            End If
            strFile = Dir
        Loop
        rsA.Close

        rst.Update
        'Next record
        rst.MoveNext
    Loop

    rst.Close
    dbs.Close

    Set fld = Nothing
    Set rsA = Nothing
    Set rst = Nothing
    Set dbs = Nothing
End Function

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Rectangle.ControlType Property (Access)

 Copy code hover
[image]

Rectangle.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Syntax

expression .ControlType

expression A variable that represents a Rectangle object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


Bound Control

 Copy code hover
[image]

Bound Control
Send feedback

Published: July 16, 2012

A bound control is a control on a form or report that gets its contents from a field in the underlying table, query, or SQL statement. (The control's ControlSource property is set to a field name in the table, query, or SQL statement.) For example, a text box that displays an employee's last name is bound to the LastName field in the Employees table.


BoundObjectFrame.AutoLabel Property (Access)

 Copy code hover
[image]

BoundObjectFrame.AutoLabel Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.

Syntax

expression .AutoLabel

expression A variable that represents a BoundObjectFrame object.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


CheckBox.ColumnHidden Property (Access)

 Copy code hover
[image]

CheckBox.ColumnHidden Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.

Syntax

expression .ColumnHidden

expression A variable that represents a CheckBox object.

Remarks

For example, you might want to hide a CustomerAddress field that's too wide so you can view the CustomerName and PhoneNumber fields.

Note Note

The ColumnHidden property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

Hiding a column with the ColumnHidden property in Datasheet view doesn't hide fields from the same column in Form view. Similarly, setting a control's Visible property to False in Form view doesn't hide the corresponding column in Datasheet view.

Note Note

To set or change this property for a table or query by using Visual Basic, you must use a column's Properties collection. For details on using the Properties collection, see Properties .

You can display a field in a query even though the column for the field is hidden in table Datasheet view. You can use values from a hidden column as the criteria for a filter even though the column remains hidden after the filter is applied.

Setting a field's ColumnWidth property to 0, or resizing the field to a zero width in Datasheet view, causes Microsoft Access to set the corresponding ColumnHidden property to True. Unhiding a column restores the ColumnWidthColumnWidth property to the value it had before the field was hidden.

Note Note

The ColumnHidden property is not available in Design view.

Example

The following example hides the ProductID field in Datasheet view of the Products form.

VBA Copy code Copy code
Forms!Products!ProductID.ColumnHidden = -1

The next example also hides the ProductID field in Datasheet view of the Products table.

VBA Copy code Copy code
Public Sub SetColumnHidden()

 Dim dbs As DAO.Database
 Dim fld As DAO.Field
 Dim prp As DAO.Property
 Const conErrPropertyNotFound = 3270

 ' Turn off error trapping.
 On Error Resume Next

 Set dbs = CurrentDb

 ' Set field property.
 Set fld = dbs.TableDefs!Products.Fields!ProductID
 fld.Properties("ColumnHidden") = True

 ' Error may have occurred when value was set.
 If Err.Number <> 0 Then
 If Err.Number <> conErrPropertyNotFound Then
 On Error GoTo 0
 MsgBox "Couldn't set property 'ColumnHidden' " & _
 "on field '" & fld.Name & "'", vbCritical
 Else
 On Error GoTo 0
 Set prp = fld.CreateProperty("ColumnHidden", dbLong, True)
 fld.Properties.Append prp
 End If
 End If

 Set prp = Nothing
 Set fld = Nothing
 Set dbs = Nothing

End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ToggleButton.PressedForeShade Property (Access)

 Copy code hover
[image]

ToggleButton.PressedForeShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .PressedForeShade

expression A variable that represents a ToggleButton object.

Remarks

The PressedForeShade property contains a numeric expression that can be used to darken the theme color in the PressedForeColor property. The default value of the PressedForeShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


CommandButton.HoverShade Property (Access)

 Copy code hover
[image]

CommandButton.HoverShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the HoverColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .HoverShade

expression A variable that represents a CommandButton object.

Remarks

The HoverShade property contains a numeric expression that can be used to darken the theme color in the HoverColor property. The default value of the HoverShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


CommandButton.Requery Method (Access)

 Copy code hover
[image]

CommandButton.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.

Syntax

expression .Requery

expression A variable that represents a CommandButton object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts .

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate function.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

Example

The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form:

VBA Copy code Copy code
Public Sub RequeryList()

    Dim ctlCombo As Control

    ' Return Control object pointing to a combo box.
    Set ctlCombo = Forms!Employees!ReportsTo

    ' Requery source of data for list box.
    ctlCombo.Requery

End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Not a valid account name or password. (Error 3029)

 Copy code hover
[image]

Not a valid account name or password. (Error 3029)
Send feedback

You entered an invalid account (user) name or password.

User names

User names can be from 1 to 20 characters long and can include alphabetic characters, accented characters, numbers, spaces, and symbols, with the following exceptions:

  • The characters " / \ [ ] | < > + = ; , : ? *

  • Leading spaces

  • Control characters

User names are not case-sensitive.

Passwords

Passwords can be any combination of 14 or fewer characters; passwords cannot contain control characters. Passwords are case-sensitive.


OptionButton.KeyDown Event (Access)

 Copy code hover
[image]

OptionButton.KeyDown Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyDown(KeyCode, Shift)

expression A variable that represents an OptionButton object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyDown property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyDown event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyDown event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyDown event occurs when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

Example

The following example determines whether you have pressed the SHIFT, CTRL, or ALT key.

To try the example, add the following event procedure to a form containing a text box named KeyHandler.

VBA Copy code Copy code
Private Sub KeyHandler_KeyDown(KeyCode As Integer, _
     Shift As Integer)
    Dim intShiftDown As Integer, intAltDown As Integer
    Dim intCtrlDown As Integer

    ' Use bit masks to determine which key was pressed.
    intShiftDown = (Shift And acShiftMask) > 0
    intAltDown = (Shift And acAltMask) > 0
    intCtrlDown = (Shift And acCtrlMask) > 0
    ' Display message telling user which key was pressed.
    If intShiftDown Then MsgBox "You pressed the SHIFT key."
    If intAltDown Then MsgBox "You pressed the ALT key."
    If intCtrlDown Then MsgBox "You pressed the CTRL key."
End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Data type conversion error. (Error 3421)

 Copy code hover
[image]

Data type conversion error. (Error 3421)
Send feedback

The Microsoft Access database engine was unable to convert data into the type required by a method or property. This problem typically occurs if you use an argument of one type when a method or property expects another type.


WebBrowserControl.Undo Method (Access)

 Copy code hover
[image]

WebBrowserControl.Undo Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the Undo method to reset a control or form when its value has been changed.

Version Information

Version Added: Access 2010

Syntax

expression .Undo

expression A variable that represents a WebBrowserControl object.

Remarks

For example, you can use the Undo method to clear a change to a record that contains an invalid entry.

If the Undo method is applied to a form, all changes to the current record are lost. If the Undo method is applied to a control, only the control itself is affected.

This method must be applied before the form or control is updated. You may want to include this method in a form's BeforeUpdate event or in a control's Change event.

The Undo method offers an alternative to using the SendKeys statement to send the value of the ESC key in an event procedure.

Example

The following example shows how you can use the Undo method within a control's Change event procedure to force a field named LastName to reset to its original value, if it changed.

VBA Copy code Copy code
Private Sub LastName_Change()
 Me!LastName.Undo
End Sub

The next example uses the Undo method to reset all changes to a form before the form is updated.

VBA Copy code Copy code
Private Sub Form_BeforeUpdate(Cancel As Integer)
 Me.Undo
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


SubForm Properties (Access)

 Copy code hover
[image]

SubForm Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the subform and its bottom gridline. Read/write Integer.
CanGrow | Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the control contains. Read/write Boolean.
CanShrink | Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the section or control contains. Read/write Boolean.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FilterOnEmptyMaster | Gets or sets whether all records are displayed when the subform's master field is Null. Read/write Boolean.
Form | You can use the Form property to refer to a form or to refer to the form associated with a subformcontrol. Read-only Form.
GridlineColor | Gets or sets the color of the gridline for the specified subform. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified subform. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified subform. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified subform. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified subform. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified subform. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified subform. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified subform. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified subform. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the subform is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified subform. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified subform. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the subform and its left gridline. Read/write Integer.
LinkChildFields | You can use the LinkChildFields property (along with the LinkMasterFields property) together to specify how Microsoft Access links records in a form or report to records in a subform, subreport, or embedded object, such as a chart. If these properties are set, Microsoft Access automatically updates the related record in the subform when you change to a new record in a main form. Read/write String.
LinkMasterFields | You can use the LinkMasterFields property (along with the LinkChildFields property) together to specify how Microsoft Access links records in a form or report to records in a subform, subreport, or embedded object, such as a chart. If these properties are set, Microsoft Access automatically updates the related record in the subform when you change to a new record in a main form. Read/write String.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
Report | You can use the Report property to refer to a report or to refer to the report associated with a subreport control. Read-only Report.
RightPadding | Gets or sets the amount of space (in inches) between the subform and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
SourceObject | You can use the SourceObject property to identify the form or report that is the source of the subform or subreport on a form or report. Read/write String.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the subform and its top gridline. Read/write Integer.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified subform is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


BeginTrans, CommitTrans, and RollbackTrans Methods (ADO)

 Copy code hover
[image]

BeginTrans, CommitTrans, and RollbackTrans Methods (ADO)
Send feedback

These transaction methods manage transaction processing within a Connection object as follows:

  • BeginTrans — Begins a new transaction.

  • CommitTrans — Saves any changes and ends the current transaction. It may also start a new transaction.

  • RollbackTrans — Cancels any changes made during the current transaction and ends the transaction. It may also start a new transaction.

Syntax

level = object.BeginTrans()

object.BeginTrans

object.CommitTrans

object.RollbackTrans

Return Value

BeginTrans can be called as a function that returns a Long variable indicating the nesting level of the transaction.

Parameters

  • object

  • A Connection object.

Connection

Use these methods with a Connection object when you want to save or cancel a series of changes made to the source data as a single unit. For example, to transfer money between accounts, you subtract an amount from one and add the same amount to the other. If either update fails, the accounts no longer balance. Making these changes within an open transaction ensures that either all or none of the changes go through.

Note Note

Not all providers support transactions. Verify that the provider-defined property "Transaction DDL" appears in the Connection object's Properties collection, indicating that the provider supports transactions. If the provider does not support transactions, calling one of these methods will return an error.

After you call the BeginTrans method, the provider will no longer instantaneously commit changes you make until you call CommitTrans or RollbackTrans to end the transaction.

For providers that support nested transactions, calling the BeginTrans method within an open transaction starts a new, nested transaction. The return value indicates the level of nesting: a return value of "1" indicates you have opened a top-level transaction (that is, the transaction is not nested within another transaction), "2" indicates that you have opened a second-level transaction (a transaction nested within a top-level transaction), and so forth. Calling CommitTrans or RollbackTrans affects only the most recently opened transaction; you must close or roll back the current transaction before you can resolve any higher-level transactions.

Calling the CommitTrans method saves changes made within an open transaction on the connection and ends the transaction. Calling the RollbackTrans method reverses any changes made within an open transaction and ends the transaction. Calling either method when there is no open transaction generates an error.

Depending on the Connection object's Attributes property, calling either the CommitTrans or RollbackTrans methods may automatically start a new transaction. If the Attributes property is set to adXactCommitRetaining, the provider automatically starts a new transaction after a CommitTrans call. If the Attributes property is set to adXactAbortRetaining, the provider automatically starts a new transaction after a RollbackTrans call.

Remote Data Service

The BeginTrans, CommitTrans, and RollbackTrans methods are not available on a client-side Connection object.


Syntax error. (Error 2433)

 Copy code hover
[image]

Syntax error. (Error 2433)
Send feedback

The wording or punctuation of the command is not correct. It may be missing an operator or you may have specified an operator that does not exist.


Image.Width Property (Access)

 Copy code hover
[image]

Image.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents an Image object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

Image Object

Other resources

Image Object Members


Form.LostFocus Event (Access)

 Copy code hover
[image]

Form.LostFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The LostFocus event occurs when the specified object loses the focus.

Syntax

expression .LostFocus

expression A variable that represents a Form object.

Remarks

To run a macro or event procedure when these events occur, set the OnLostFocus property to the name of the macro or to [Event Procedure].

This events occurs when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The LostFocus event differs from the Exit event in that the LostFocus event occurs every time a control loses the focus. The Exit event occurs only before a control loses the focus to another control on the same form. The LostFocus event occurs after the Exit event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


AllReports Properties (Access)

 Copy code hover
[image]

AllReports Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


CheckBox.EventProcPrefix Property (Access)

 Copy code hover
[image]

CheckBox.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents a CheckBox object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ObjectFrame.Exit Event (Access)

 Copy code hover
[image]

ObjectFrame.Exit Event (Access)
See also Send feedback

Published: July 16, 2012

The Exit event occurs just before a control loses the focus to another control on the same form or report.

Syntax

expression .Exit(Cancel)

expression A variable that represents an ObjectFrame object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | Set to True to cancel the event.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when this event occurs, set the OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Exit event occurs before the LostFocus event.

Unlike the LostFocus event, the Exit event does not occur when a form loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Recordset (ADO for Visual C++ Syntax)

 Copy code hover
[image]

Recordset (ADO for Visual C++ Syntax)
Send feedback

Methods

            AddNew(VARIANT FieldList, VARIANT Values)

Cancel(void)

CancelBatch(AffectEnum AffectRecords)

CancelUpdate(void)

Clone(LockTypeEnum LockType, _ADORecordset **ppvObject)

Close(void)

CompareBookmarks(VARIANT Bookmark1, VARIANT Bookmark2,

                     CompareEnum *pCompare)

Delete(AffectEnum AffectRecords)

Find(BSTR Criteria, LONG SkipRecords, SearchDirectionEnum SearchDirection,

      VARIANT Start)

GetRows(long Rows, VARIANT Start, VARIANT Fields, VARIANT *pvar)

GetString(StringFormatEnum StringFormat, long NumRows, BSTR ColumnDelimeter,

            BSTR RowDelimeter, BSTR NullExpr, BSTR *pRetString)

Move(long NumRecords, VARIANT Start)

MoveFirst(void)

MoveLast(void)

MoveNext(void)

MovePrevious(void)

NextRecordset(VARIANT *RecordsAffected, _ADORecordset **ppiRs)

Open(VARIANT Source, VARIANT ActiveConnection, CursorTypeEnum CursorType,

         LockTypeEnum LockType, LONG Options)

Requery(LONG Options)

Resync(AffectEnum AffectRecords, ResyncEnum ResyncValues)

Save(BSTR FileName, PersistFormatEnum PersistFormat)

Supports(CursorOptionEnum CursorOptions, VARIANT_BOOL *pb)

Update(VARIANT Fields, VARIANT Values)

UpdateBatch(AffectEnum AffectRecords)

Properties

            get_AbsolutePage(PositionEnum *pl)

put_AbsolutePage(PositionEnum Page)

get_AbsolutePosition(PositionEnum *pl)

put_AbsolutePosition(PositionEnum Position)

get_ActiveCommand(IDispatch **ppCmd)

get_ActiveConnection(VARIANT *pvar)

put_ActiveConnection(VARIANT vConn)

putref_ActiveConnection(IDispatch *pconn)

get_BOF(VARIANT_BOOL *pb)

get_Bookmark(VARIANT *pvBookmark)

put_Bookmark(VARIANT vBookmark)

get_CacheSize(long *pl)

put_CacheSize(long CacheSize)

get_CursorLocation(CursorLocationEnum *plCursorLoc)

put_CursorLocation(CursorLocationEnum lCursorLoc)

get_CursorType(CursorTypeEnum *plCursorType)

put_CursorType(CursorTypeEnum lCursorType)

get_DataMember(BSTR *pbstrDataMember)

put_DataMember(BSTR bstrDataMember)

get_DataSource(IUnknown **ppunkDataSource)

putref_DataSource(IUnknown *punkDataSource)

get_EditMode(EditModeEnum *pl)

get_EOF(VARIANT_BOOL *pb)

get_Filter(VARIANT *Criteria)

put_Filter(VARIANT Criteria)

get_LockType(LockTypeEnum *plLockType)

put_LockType(LockTypeEnum lLockType)

get_MarshalOptions(MarshalOptionsEnum *peMarshal)

put_MarshalOptions(MarshalOptionsEnum eMarshal)

get_MaxRecords(long *plMaxRecords)

put_MaxRecords(long lMaxRecords)

get_PageCount(long *pl)

get_PageSize(long *pl)

put_PageSize(long PageSize)

get_RecordCount(long *pl)

get_Sort(BSTR *Criteria)

put_Sort(BSTR Criteria)

get_Source(VARIANT *pvSource)

put_Source(BSTR bstrConn)

putref_Source(IDispatch *pcmd)

get_State(LONG *plObjState)

get_Status(long *pl)

get_StayInSync(VARIANT_BOOL *pbStayInSync)

put_StayInSync(VARIANT_BOOL bStayInSync)

get_Fields(ADOFields **ppvObject)

Events

EndOfRecordset(VARIANT_BOOL *fMoreData, EventStatusEnum *adStatus, _ADORecordset *pRecordset) FetchComplete(ADOError *pError, EventStatusEnum *adStatus, _ADORecordset *pRecordset) FetchProgress(long Progress, long MaxProgress, EventStatusEnum *adStatus, _ADORecordset *pRecordset) FieldChangeComplete(LONG cFields, VARIANT Fields, ADOError *pError, EventStatusEnum *adStatus, _ADORecordset *pRecordset) MoveComplete(EventReasonEnum adReason, ADOError *pError, EventStatusEnum *adStatus, _ADORecordset *pRecordset) RecordChangeComplete(EventReasonEnum adReason, LONG cRecords, ADOError *pError, EventStatusEnum *adStatus, _ADORecordset *pRecordset) RecordsetChangeComplete(EventReasonEnum adReason, ADOError *pError, EventStatusEnum *adStatus, _ADORecordset *pRecordset) WillChangeField(LONG cFields, VARIANT Fields, EventStatusEnum *adStatus, _ADORecordset *pRecordset) WillChangeRecord(EventReasonEnum adReason, LONG cRecords, EventStatusEnum *adStatus, _ADORecordset *pRecordset) WillChangeRecordset(EventReasonEnum adReason, EventStatusEnum *adStatus, _ADORecordset *pRecordset) WillMove(EventReasonEnum adReason, EventStatusEnum *adStatus, _ADORecordset *pRecordset)


NavigationButton.MouseDown Event (Access)

 Copy code hover
[image]

NavigationButton.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Version Information

Version Added: Access 2010

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents a NavigationButton object.

Parameters

Name | Required/Optional | Data Type | Description
Button | Required | Integer |
Shift | Required | Integer |
X | Required | Single |
Y | Required | Single |

Return Value

nothing

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
 Shift As Integer, X As Single, _
 Y As Single)
 If Button = acLeftButton Then
 MsgBox "You pressed the left button."
 End If
 If Button = acRightButton Then
 MsgBox "You pressed the right button."
 End If
 If Button = acMiddleButton Then
 MsgBox "You pressed the middle button."
 End If
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


SmartTag.XML Property (Access)

 Copy code hover
[image]

SmartTag.XML Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a String that represents the related XML code for a smart tag. Read-only.

Syntax

expression .XML

expression A variable that represents a SmartTag object.

See also

Concepts

SmartTag Object

Other resources

SmartTag Object Members


Creating and Executing a Simple Command

 Copy code hover
[image]

Creating and Executing a Simple Command
Send feedback

Though not a typical usage of the Command object, the following code shows the basic method of using the Command object to execute a command against a data source. In this case, it is a row-returning command, so it returns the results of the command execution into a Recordset object.

Copy code Copy code

 'BeginBasicCmd
 On Error GoTo ErrHandler:

 Dim objConn As New ADODB.Connection
 Dim objCmd As New ADODB.Command
 Dim objRs As New ADODB.Recordset

 objCmd.CommandText = "SELECT OrderID, OrderDate, " & _
 "RequiredDate, ShippedDate " & _
 "FROM Orders " & _
 "WHERE CustomerID = 'ALFKI' " & _
 "ORDER BY OrderID"
 objCmd.CommandType = adCmdText

 ' Connect to the data source.
 Set objConn = GetNewConnection
 objCmd.ActiveConnection = objConn

 ' Execute once and display...
 Set objRs = objCmd.Execute

 Debug.Print "ALFKI"
 Do While Not objRs.EOF
 Debug.Print vbTab & objRs(0) & vbTab & objRs(1) & vbTab & _
 objRs(2) & vbTab & objRs(3)
 objRs.MoveNext
 Loop

 'clean up
 objRs.Close
 objConn.Close
 Set objRs = Nothing
 Set objConn = Nothing
 Set objCmd = Nothing
 Exit Sub

ErrHandler:
 'clean up
 If objRs.State = adStateOpen Then
 objRs.Close
 End If

 If objConn.State = adStateOpen Then
 objConn.Close
 End If

 Set objRs = Nothing
 Set objConn = Nothing
 Set objCmd = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
'EndBasicCmd

The command to be executed is specified with the CommandText property.

Note Note

Several examples in this section call a utility function, GetNewConnection, to establish a connection with the data provider. To avoid redundancy, it is listed only once, here:
Copy code Copy code

'BeginNewConnection
Private Function GetNewConnection() As ADODB.Connection
 Dim oCn As New ADODB.Connection
 Dim sCnStr As String

 sCnStr = "Provider='SQLOLEDB';Data Source='MySqlServer';" & _
 "Integrated Security='SSPI';Database='Northwind';"
 oCn.Open sCnStr

 If oCn.State = adStateOpen Then
 Set GetNewConnection = oCn
 End If

End Function
'EndNewConnection


Field will not fit in record. (Error 3016)

 Copy code hover
[image]

Field will not fit in record. (Error 3016)
Send feedback

You tried to import or paste a field that is too large. Consider breaking the field into smaller pieces and then importing or pasting the data to multiple fields or changing the data type of the field.

Records are limited to just under 2K in size, excluding Memo and OLE Object fields.


CommandTypeEnum

 Copy code hover
[image]

CommandTypeEnum
Send feedback

Specifies how a command argument should be interpreted.

Constant | Value | Description
adCmdUnspecified | -1 | Does not specify the command type argument.
adCmdText | 1 | Evaluates CommandText as a textual definition of a command or stored procedure call.
adCmdTable | 2 | Evaluates CommandText as a table name whose columns are all returned by an internally generated SQL query.
adCmdStoredProc | 4 | Evaluates CommandText as a stored procedure name.
adCmdUnknown | 8 | Default. Indicates that the type of command in the CommandText property is not known.
adCmdFile | 256 | Evaluates CommandText as the file name of a persistently stored Recordset. Used with Recordset. Open or Requery only.
adCmdTableDirect | 512 | Evaluates CommandText as a table name whose columns are all returned. Used with Recordset.Open or Requery only. To use the Seek method, the Recordset must be opened with adCmdTableDirect. This value cannot be combined with the ExecuteOptionEnum value adAsyncExecute.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.CommandType.UNSPECIFIED

AdoEnums.CommandType.TEXT

AdoEnums.CommandType.TABLE

AdoEnums.CommandType.STOREDPROC

AdoEnums.CommandType.UNKNOWN

AdoEnums.CommandType.FILE

AdoEnums.CommandType.TABLEDIRECT


ToggleButton.GridlineTint Property (Access)

 Copy code hover
[image]

ToggleButton.GridlineTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineTint

expression A variable that represents a ToggleButton object.

Remarks

The GridlineTint property contains a numeric expression that can be used to lighten the theme color in the GridlineColor property. The default value of the GridlineTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


DependencyInfo.UnsupportedObjects Property (Access)

 Copy code hover
[image]

DependencyInfo.UnsupportedObjects Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a DependencyObjects collection that contains objects that cannot be searched for dependency. Read-only.

Syntax

expression .UnsupportedObjects

expression A variable that represents a DependencyInfo object.

Remarks

The DependencyObjects collection returned by this property contains a collection of AccessObject objects.

See also

Concepts

DependencyInfo Object

Other resources

DependencyInfo Object Members


NavigationButton.LabelY Property (Access)

 Copy code hover
[image]

NavigationButton.LabelY Property (Access)
See also Send feedback

Published: July 16, 2012

Version Information

Version Added: Access 2010

Syntax

expression .LabelY

expression A variable that represents a NavigationButton object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


SetField Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

SetField Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

The SetField action can be used to assign a value to a field.

Note Note

The SetField action is available only in Data Macros.

Setting

The SetField action has the arguments listed in the following table.

Argument name | Description
Name | A string that identifies the field.
Value | An expression that specifies the value to assign to the field.

Remarks

The SetField action cannot be used outside of a CreateRecord or EditRecord data block.


OptionButton.GridlineStyleRight Property (Access)

 Copy code hover
[image]

OptionButton.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified option button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleRight

expression A variable that represents an OptionButton object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Groups Collection (ADOX)

 Copy code hover
[image]

Groups Collection (ADOX)
Send feedback

Contains all stored Group objects of a catalog or user.

Remarks

The Groups collection of a Catalog represents all of the catalog's group accounts. The Groups collection for a User represents only the group to which the user belongs.

The Append method for a Groups collection is unique for ADOX. You can:

  • Add a new security group to the collection with the Append method.

The remaining properties and methods are standard to ADO collections. You can:

  • Access a group in the collection with the Item property.

  • Return the number of groups contained in the collection with the Count property.

  • Remove a group from the collection with the Delete method.

  • Update the objects in the collection to reflect the current database's schema with the Refresh method.

Note Note

Before appending a Group object to the Groups collection of a User object, a Group object with the same Name as the one to be appended must already exist in the Groups collection of the Catalog.


ListBox.ReadingOrder Property (Access)

 Copy code hover
[image]

ListBox.ReadingOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.

Syntax

expression .ReadingOrder

expression A variable that represents a ListBox object.

Remarks

The ReadingOrder property uses the following settings.

Setting | Visual Basic | Description
Context | 0 | Reading order is determined by the language of the first character entered. If a right-to-left language character is entered first, reading order is right to left. If a left-to-right language character is entered first, reading order is left to right.
Left-to-Right | 1 | Sets the reading order to left to right.
Right-to-Left | 2 | Sets the reading order to right to left.

In a combo box or list box, the ReadingOrder property determines reading order behavior for both the text box and list box components of the control.

Example

The following example sets the reading order to right to left for the "Address" text box on the "International Shipping" form.

VBA Copy code Copy code
Forms("International Shipping").Controls("Address").ReadingOrder = 2

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


NavigationButton.LeftPadding Property (Access)

 Copy code hover
[image]

NavigationButton.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .LeftPadding

expression A variable that represents a NavigationButton object.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Connection.Close Method (DAO)

 Copy code hover
[image]

Connection.Close Method (DAO)
Send feedback

Closes an open Connection.

Syntax

expression .Close

expression A variable that represents a Connection object.

Remarks

If the Recordset object is already closed when you use Close, a run-time error occurs.

If you try to close a Connection object while it has any open Recordset objects, the Recordset objects will be closed and any pending updates or edits will be canceled. Similarly, if you try to close a Workspace object while it has any open Connection objects, those Connection objects will be closed, which will close their Recordset objects.

An alternative to the Close method is to set the value of an object variable to Nothing (Set dbsTemp = Nothing).


Recordset2.Restartable Property (DAO)

 Copy code hover
[image]

Recordset2.Restartable Property (DAO)
Send feedback

Returns a value that indicates whether a Recordset object supports the Requery method, which re-executes the query on which the Recordset object is based.

Syntax

expression .Restartable

expression A variable that represents a Recordset2 object.

Remarks

Table-type Recordset objects always return False.

Check the Restartable property before using the Requery method on a Recordset object. If the object's Restartable property is set to False, use the OpenRecordset method on the underlying QueryDef object to re-execute the query.

Example

This example demonstrates the Restartable property with different Recordset objects.

VBA Copy code Copy code
Sub RestartableX()

   Dim dbsNorthwind As Database
   Dim rstTemp As Recordset2

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   With dbsNorthwind
      ' Open a table-type Recordset and print its
      ' Restartable property.
      Set rstTemp = .OpenRecordset("Employees", dbOpenTable)
      Debug.Print _
         "Table-type recordset from Employees table"
      Debug.Print "  Restartable = " & rstTemp.Restartable
      rstTemp.Close

      ' Open a Recordset from an SQL statement and print its
      ' Restartable property.
      Set rstTemp = _
         .OpenRecordset("SELECT * FROM Employees")
      Debug.Print "Recordset based on SQL statement"
      Debug.Print "  Restartable = " & rstTemp.Restartable
      rstTemp.Close

      ' Open a Recordset from a saved QueryDef object and
      ' print its Restartable property.
      Set rstTemp = .OpenRecordset("Current Product List")
      Debug.Print _
         "Recordset based on permanent QueryDef (" & _
         rstTemp.Name & ")"
      Debug.Print "  Restartable = " & rstTemp.Restartable
      rstTemp.Close

      .Close
   End With

End Sub


Prepared Property Example (VC++)

 Copy code hover
[image]

Prepared Property Example (VC++)
Send feedback

This example demonstrates the Prepared property by opening two Command objects — one prepared and one not prepared.

Copy code Copy code

// BeginPreparedCpp
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>
#include <winbase.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void PreparedX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 PreparedX();

 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// PreparedX Function //
// //
///////////////////////////////////////////////////////////

void PreparedX(void)
{
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _ConnectionPtr pConnection =NULL;
 _CommandPtr pCmd1 =NULL;
 _CommandPtr pCmd2 =NULL;

 // Define string variables.
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 //Define Other Variables
 HRESULT hr = S_OK;

 try
 {
 // Open a connection.
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
 pConnection->Open (strCnn, "", "", adConnectUnspecified);

 _bstr_t strCmd ("SELECT title,type FROM titles ORDER BY type");

 // Create two command objects for the same
 // command - one prepared and one not prepared.
 TESTHR(pCmd1.CreateInstance(__uuidof(Command)));
 pCmd1->ActiveConnection = pConnection;
 pCmd1->CommandText = strCmd;

 TESTHR(pCmd2.CreateInstance(__uuidof(Command)));
 pCmd2->ActiveConnection = pConnection;
 pCmd2->CommandText = strCmd;
 pCmd2->PutPrepared(true);

 // Set a timer,then execute the unprepared command 20 times.
 DWORD sngStart=GetTickCount();

 for(int intLoop=1;intLoop<=20;intLoop++)
 {
 pCmd1->Execute(NULL,NULL,adCmdText);
 }
 DWORD sngEnd=GetTickCount();

 float sngNotPrepared = (float)(sngEnd - sngStart)/(float)1000;

 // Reset the timer,then execute the prepared command 20 times
 sngStart=GetTickCount();
 for(intLoop=1;intLoop<=20;intLoop++)
 {
 pCmd2->Execute(NULL,NULL,adCmdText);
 }
 sngEnd=GetTickCount();

 float sngPrepared = (float)(sngEnd - sngStart)/(float)1000;

 // Display performance results
 printf("\n\nPerformance Results:");
 printf("\n\nNot Prepared: %6.3f seconds",sngNotPrepared);
 printf("\n\nPrepared: %6.3f seconds\n\n",sngPrepared);
 }
 catch (_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Connection.
 PrintProviderError(pConnection);
 PrintComError(e);
 }

 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////
void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;

 // Collection ranges from 0 to nCount -1.
 for(long i = 0;i < nCount;i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,
 pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////
void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print COM errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndPreparedCpp


Connections.Count Property (DAO)

 Copy code hover
[image]

Connections.Count Property (DAO)
Send feedback

Returns the number of Connection objects in the Connections collection.

Syntax

expression .Count

expression A variable that represents a Connections object.

Remarks

Because members of a collection begin with 0, you should always code loops starting with the 0 member and ending with the value of the Count property minus 1. If you want to loop through the members of a collection without checking the Count property, you can use a For Each...Next command.

The Count property setting is never Null. If its value is 0, there are no objects in the collection.


Appendix B: ADO Errors (ADO)

 Copy code hover
[image]

Appendix B: ADO Errors (ADO)
Send feedback

In this section

  • Appendix B: ADO Errors

  • ADO Error Codes

  • DataControl Error Codes

  • Internet Explorer Error Codes

  • Internet Information Services Error Codes


Workspace.Close Method (DAO)

 Copy code hover
[image]

Workspace.Close Method (DAO)
Send feedback

Closes an open Workspace.

Syntax

expression .Close

expression A variable that represents a Workspace object.

Remarks

If the Workspace object is already closed when you use Close, a run-time error occurs.

An alternative to the Close method is to set the value of an object variable to Nothing (Set dbsTemp = Nothing).


Field2.ComplexType Property (DAO)

 Copy code hover
[image]

Field2.ComplexType Property (DAO)
Send feedback

Returns a ComplexType object that represents a multi-valued field. Read-only.

Version Information

Version Added: Access 2007

Syntax

expression .ComplexType

expression A variable that represents a Field2 object.


SubForm.Enter Event (Access)

 Copy code hover
[image]

SubForm.Enter Event (Access)
See also Send feedback

Published: July 16, 2012

The Enter event occurs before a control actually receives the focus from a control on the same form or report.

Syntax

expression .Enter

expression A variable that represents a SubForm object.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when these events occur, set the OnEnter or OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Enter event occurs before the GotFocus event. The Exit event occurs before the LostFocus event.

Unlike the GotFocus and LostFocus events, the Enter and Exit events don't occur when a form receives or loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


NumericScale and Precision Properties Example (VJ++)

 Copy code hover
[image]

NumericScale and Precision Properties Example (VJ++)
Send feedback

This example uses the NumericScale and Precision properties to display the numeric scale and precision of fields in the Discounts table of the Pubs database.

Copy code Copy code

// BeginNumericScaleJ
import com.ms.wfc.data.*;
import java.io.* ;

public class NumericScaleX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 NumericScaleX();
 System.exit(0);
 }

 // NumericScaleX function

 static void NumericScaleX()
 {

 // Define ADO Objects.
 Recordset rstDiscounts = null;
 Field fldTemp = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";
 int intLoop;

 try
 {
 rstDiscounts = new Recordset();

 // Open recordset.
 rstDiscounts.open("Discounts", strCnn,
 AdoEnums.CursorType.FORWARDONLY,
 AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TABLE);

 // Display numeric scale and precision of
 // numeric and small integer fields.
 for ( intLoop=0; intLoop <
 rstDiscounts.getFields().getCount();intLoop++)
 {
 fldTemp = rstDiscounts.getFields().getItem(intLoop);
 if((fldTemp.getType()== AdoEnums.DataType.NUMERIC) |
 (fldTemp.getType()== AdoEnums.DataType.SMALLINT))
 {
 System.out.println("\nField: "
 + fldTemp.getName());
 System.out.println("\nNumeric scale: "
 + fldTemp.getNumericScale());
 System.out.println("\nPrecision: "
 + fldTemp.getPrecision());
 System.out.println("\n\nPress <Enter> to continue..");
 in.readLine();
 }
 }

 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstDiscounts != null)
 {
 PrintProviderError(rstDiscounts.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }

 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstDiscounts != null)
 if (rstDiscounts.getState() == 1)
 rstDiscounts.close();
 }

 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndNumericScaleJ


Image.BackThemeColorIndex Property (Access)

 Copy code hover
[image]

Image.BackThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackThemeColorIndex

expression A variable that represents an Image object.

Remarks

The BackThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BackThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Background Color to the Text 2 color by setting the BackThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BackThemeColorIndex=2

See also

Concepts

Image Object

Other resources

Image Object Members


TextBox.ForeThemeColorIndex Property (Access)

 Copy code hover
[image]

TextBox.ForeThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ForeThemeColorIndex

expression A variable that represents a TextBox object.

Remarks

The ForeThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the ForeThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following example sets the Fore Color to the Text 2 color by setting the ForeThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.ForeThemeColorIndex=2

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


QueryDefs.Append Method (DAO)

 Copy code hover
[image]

QueryDefs.Append Method (DAO)
Send feedback

Adds a new QueryDef to the QueryDefs collection.

Syntax

expression .Append(Object)

expression A variable that represents a QueryDefs object.

Parameters

Name | Required/Optional | Data Type | Description
Object | Required | Object | An object variable that represents the field being appended to the collection.

Remarks

The appended object becomes a persistent object, stored on disk, until you delete it by using the Delete method.

The addition of a new object occurs immediately, but you should use the Refresh method on any other collections that may be affected by changes to the database structure.

If the object you're appending isn't complete (such as when you haven't appended any Field objects to a Fields collection of an Index object before it's appended to an Indexes collection) or if the properties set in one or more subordinate objects are incorrect, using the Append method causes an error. For example, if you haven't specified a field type and then try to append the Field object to the Fields collection in a TableDef object, using the Append method triggers a run-time error.


AllQueries Object (Access)

 Copy code hover
[image]

AllQueries Object (Access)
See also Send feedback

Published: July 16, 2012

The AllQueries collection contains an AccessObject for each query in the CurrentData or CodeData object.

Remarks

The CurrentData or CodeData object has an AllQueries collection containing AccessObject objects that describe instances of all queries specified by CurrentData or CodeData. For example, you can enumerate the AllQueries collection in Visual Basic to set or return the values of properties of individual AccessObject objects in the collection.

You can refer to an individual AccessObject object in the AllQueries collection either by referring to the object by name, or by referring to its index within the collection. If you want to refer to a specific object in the AllQueries collection, it's better to refer to the query by name because a query's collection index may change.

The AllQueries collection is indexed beginning with zero. If you refer to a query by its index, the first query is AllQueries(0), the second query is AllQueries(1), and so on.

Note Note

  • The AllQueries collection only contains AccessObject objects within a Microsoft Access database. A Microsoft Access project (.adp) does not contain any macros, see the AllViews collection.

  • To list all open queries in the database, use the IsLoaded property of each AccessObject object in the AllQueries collection. You can then use the Name property of each individual AccessObject object to return the name of a query

  • You can't add or delete an AccessObject object from the AllQueries collection.

Example

The following example prints the name of each open AccessObject object in the AllQueries collection.

VBA Copy code Copy code
Sub AllQueries()
    Dim obj As AccessObject, dbs As Object
    Set dbs = Application.CurrentData
    ' Search for open AccessObject objects in AllQueries collection.
    For Each obj In dbs.AllQueries
        If obj.IsLoaded = True Then
            ' Print name of obj.
            Debug.Print obj.Name
        End If
    Next obj
End Sub

See also

Concepts

Access Object Model Reference

Other resources

AllQueries Object Members


AcHyperlinkPart Enumeration (Access)

 Copy code hover
[image]

AcHyperlinkPart Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the the information you want returned by the HyperlinkPart method.

Name | Value | Description
acAddress | 2 | The address part of a Hyperlink field.
acDisplayedValue | 0 | The underlined text displayed in a hyperlink.
acDisplayText | 1 | The displaytext part of a Hyperlink field.
acFullAddress | 5 | The address and subaddress parts of a Hyperlink field, delimited by a "#" character.
acScreenTip | 4 | The tooltip part of a Hyperlink field.
acSubAddress | 3 | The subaddress part of a Hyperlink field.


How to: Close a Report Automatically If It Does Not Contain Any Records

 Copy code hover
[image]

How to: Close a Report Automatically If It Does Not Contain Any Records
Send feedback

The following example shows how to use the NoData 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.

VBA Copy code Copy code
Private Sub Report_NoData (Cancel As Integer)

    ' Display message to user.
    MsgBox "There are no records to report", vbExclamation, "No Records"

    ' Close the report.
    Cancel = True

End Sub


Could not update; currently locked by another session on this machine. (Error 3188)

 Copy code hover
[image]

Could not update; currently locked by another session on this machine. (Error 3188)
Send feedback

You tried to update information that is currently locked by another session. Wait for the other session to finish or close the other session, and then try the operation again.


Printer.Duplex Property (Access)

 Copy code hover
[image]

Printer.Duplex Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets an AcPrintDuplex constant indicating how the specified printer handles duplex printing. Read/write.

Syntax

expression .Duplex

expression A variable that represents a Printer object.

Example

The following example sets a variety of printer settings for the form specified in the strFormname argument of the procedure.

VBA Copy code Copy code
Sub SetPrinter(strFormname As String)

 DoCmd.OpenForm FormName:=strFormname, view:=acDesign, _
 datamode:=acFormEdit, windowmode:=acHidden

 With Forms(form1).Printer

 .TopMargin = 1440
 .BottomMargin = 1440
 .LeftMargin = 1440
 .RightMargin = 1440

 .ColumnSpacing = 360
 .RowSpacing = 360

 .ColorMode = acPRCMColor
 .DataOnly = False
 .DefaultSize = False
 .ItemSizeHeight = 2880
 .ItemSizeWidth = 2880
 .ItemLayout = acPRVerticalColumnLayout
 .ItemsAcross = 6

 .Copies = 1
 .Orientation = acPRORLandscape
 .Duplex = acPRDPVertical
 .PaperBin = acPRBNAuto
 .PaperSize = acPRPSLetter
 .PrintQuality = acPRPQMedium

 End With

 DoCmd.Close objecttype:=acForm, objectname:=strFormname, _
 Save:=acSaveYes

End Sub

See also

Concepts

Printer Object

Other resources

Printer Object Members


QueryDef.Updatable Property (DAO)

 Copy code hover
[image]

QueryDef.Updatable Property (DAO)
Send feedback

Returns a value that indicates whether you can change a DAO object. Read-only Boolean.

Syntax

expression .Updatable

expression A variable that represents a QueryDef object.

Remarks

The Updatable property of a QueryDef object is set to True if the query definition can be updated, even if the resulting Recordset object isn't updatable.


Form.MouseDown Event (Access)

 Copy code hover
[image]

Form.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents a Form object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
         Shift As Integer, X As Single, _
         Y As Single)
    If Button = acLeftButton Then
        MsgBox "You pressed the left button."
    End If
    If Button = acRightButton Then
        MsgBox "You pressed the right button."
    End If
    If Button = acMiddleButton Then
        MsgBox "You pressed the middle button."
    End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


NavigationButton.OnPush Property (Access)

 Copy code hover
[image]

NavigationButton.OnPush Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window of a command button. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnPush

expression A variable that represents a NavigationButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

Although the name of this property is OnPush, setting this property actually sets the value of the On Click box.

The OnPush value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the command button's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example prints the value of the OnPush property in the Immediate window for the "OK" button on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnPush

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Fields Collection Properties, Methods, and Events

 Copy code hover
[image]

Fields Collection Properties, Methods, and Events
Send feedback

Properties

Count Property

Item Property

Methods

Append Method

CancelUpdate Method

Delete Method (ADO Fields Collection)

Refresh Method

Resync Method

Update Method

Events

None.


Label.FontSize Property (Access)

 Copy code hover
[image]

Label.FontSize Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontSize property to specify the point size for text in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Integer.

Syntax

expression .FontSize

expression A variable that represents a Label object.

Remarks

The FontSize property uses the following settings.

Setting | Description
8 | (Default for all reports and controls except command buttons) The text is 8-point type.
10 | (Default for command buttons) The text is 10-point type.
Other sizes | The text is the indicated size.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set this property only in an event procedure or in a macro specified by the OnPrint event property setting.

In Visual Basic, you set the FontSize property by using a numeric expression equal to the desired size of the font. The setting for the FontSize property can be between 1 and 127, inclusive.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

Label Object

Other resources

Label Object Members


ComboBox.Format Property (Access)

 Copy code hover
[image]

ComboBox.Format Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Format property to customize the way numbers, dates, times, and text are displayed and printed. Read/write String.

Syntax

expression .Format

expression A variable that represents a ComboBox object.

Remarks

You can use one of the predefined formats or you can create a custom format by using formatting symbols.

The Format property uses different settings for different data types. For information about settings for a specific data type, see one of the following topics:

  • Date/Time Data Type

  • Number and Currency Data Types

  • Text and Memo Data Types

  • Yes/No Data Type

In Visual Basic, enter a string expression that corresponds to one of the predefined formats or enter a custom format.

The Format property affects only how data is displayed. It doesn't affect how data is stored.

Microsoft Access provides predefined formats for Date/Time, Number and Currency, Text and Memo, and Yes/No data types. The predefined formats depend on the country/region specified by double-clicking Regional Options in Windows Control Panel. Microsoft Access displays formats appropriate for the country/region selected. For example, with English (United States) selected on the General tab, 1234.56 in the Currency format appears as $1,234.56, but when English (British) is selected on the General tab, the number appears as £1,234.56.

If you set a field's Format property in table Design view, Microsoft Access uses that format to display data in datasheets. It also applies the field's Format property to new controls on forms and reports.

You can use the following symbols in custom formats for any data type.

Symbol | Meaning
(space) | Display spaces as literal characters.
"ABC" | Display anything inside quotation marks as literal characters.
! | Force left alignment instead of right alignment.
* | Fill available space with the next character.
\ | Display the next character as a literal character. You can also display literal characters by placing quotation marks around them.
[color] | Display the formatted data in the color specified between the brackets. Available colors: Black, Blue, Green, Cyan, Red, Magenta, Yellow, White.

You can't mix custom formatting symbols for the Number and Currency data types with Date/Time, Yes/No, or Text and Memo formatting symbols.

When you have defined an input mask and set the Format property for the same data, the Format property takes precedence when the data is displayed and the input mask is ignored. For example, if you create a Password input mask in table Design view and also set the Format property for the same field, either in the table or in a control on a form, the Password input mask is ignored and the data is displayed according to the Format property.

Example

The following three examples set the Format property by using a predefined format:

VBA Copy code Copy code
Me!Date.Format = "Medium Date"

Me!Time.Format = "Long Time"

Me!Registered.Format = "Yes/No"

The next example sets the Format property by using a custom format. This format displays a date as: Jan 2006.

VBA Copy code Copy code
Forms!Employees!HireDate.Format = "mmm yyyy"

The following example demonstrates a Visual Basic function that formats numeric data by using the Currency format and formats text data entirely in capital letters. The function is called from the OnLostFocus event of an unbound control named TaxRefund.

VBA Copy code Copy code
Function FormatValue() As Integer
    Dim varEnteredValue As Variant

    varEnteredValue = Forms!Survey!TaxRefund.Value
    If IsNumeric(varEnteredValue) = True Then
        Forms!Survey!TaxRefund.Format = "Currency"
    Else
        Forms!Survey!TaxRefund.Format = ">"
    End If
End Function

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ListBox.FontName Property (Access)

 Copy code hover
[image]

ListBox.FontName Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontName property to specify the font for text in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write String.

Syntax

expression .FontName

expression A variable that represents a ListBox object.

Remarks

The FontName property setting is the name of the font that the text is displayed in.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set this property only in an event procedure or in a macro specified by the OnPrint event property setting.

Font availability depends on your system and printer. If you select a font that your system can't display or that isn't installed, Windows substitutes a similar font.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


BoundObjectFrame.TabStop Property (Access)

 Copy code hover
[image]

BoundObjectFrame.TabStop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.

Syntax

expression .TabStop

expression A variable that represents a BoundObjectFrame object.

Remarks

This property doesn't apply to toggle button controls when they appear in an option group. It applies only to the option group itself.

The TabStop property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) You can move the focus to the control by pressing the TAB key.
No | False | You can't move the focus to the control by pressing the TAB key.

When you create a control on a form, Microsoft Access automatically assigns the control a position in the form's tab order. Each new control is placed last in the tab order. If you want to prevent a control from being available when you tab through the controls in a form, set the control's TabStop property to No.

In Form view, hidden or disabled controls remain in the tab order but are skipped when you move through the controls by pressing TAB, even if their TabStop properties are set to Yes.

As long as a control's Enabled property is set to Yes, you can click the control or use an access key to select it, regardless of its TabStop property setting. For example, you can set the TabStop property of a command button to No to prevent users from selecting the button by pressing TAB. However, they can still click the command button to choose it.

Example

The following example disables the ability to move the focus to the "City" text box on the "Suppliers" form by using the TAB key.

VBA Copy code Copy code
Forms("Suppliers").Controls("City").TabStop = False

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


NavigationControl.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

NavigationControl.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified list box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleBottom

expression A variable that represents a NavigationControl object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Reports Members (Access)

 Copy code hover
[image]

Reports Members (Access)
Send feedback

Published: July 16, 2012

The Reports collection contains all of the currently open reports in a Microsoft Access database.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Report.
Parent | Returns the parent object for the specified object. Read-only.


Image.PictureTiling Property (Access)

 Copy code hover
[image]

Image.PictureTiling Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureTiling property to specify whether a background picture is tiled across the entire image control, Form window, form, or page of a report. Read/write Boolean.

Syntax

expression .PictureTiling

expression A variable that represents an Image object.

Remarks

The PictureTiling property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The picture is tiled.
No | False | (Default) The picture isn't tiled.

You can also set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

You can create interesting effects by placing a picture on a form or report and setting the PictureTiling property to Yes. The alignment of the tiled images is affected by the PictureAlignment property setting. For example, if the PictureTiling property is set to Top Left, tiling begins at the top left of the image control, Form window, or page of a report.

If the PictureAlignment property is set to Form Center and the PictureTiling property is set to Yes, the background picture of a form will be tiled across the form, not across the Form window.

See also

Concepts

Image Object

Other resources

Image Object Members


Recordset.Sort Property (DAO)

 Copy code hover
[image]

Recordset.Sort Property (DAO)
Send feedback

Sets or returns the sort order for records in a Recordset object (Microsoft Access workspaces only).

Syntax

expression .Sort

expression A variable that represents a Recordset object.

Remarks

You can use the Sort property with dynaset- and snapshot-type Recordset objects.

When you set this property for an object, sorting occurs when a subsequent Recordset object is created from that object. The Sort property setting overrides any sort order specified for a QueryDef object.

The default sort order is ascending (A to Z or 0 to 100).

The Sort property doesn't apply to table- or forward-only-type Recordset objects. To sort a table-type Recordset object, use the Index property.

Note Note

In many cases, it's faster to open a new Recordset object by using an SQL statement that includes the sorting criteria.

Example

This example demonstrates the Sort property by changing its value and creating a new Recordset. The SortOutput function is required for this procedure to run.

VBA Copy code Copy code
Sub SortX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset
 Dim rstSortEmployees As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", _
 dbOpenDynaset)

 With rstEmployees
 SortOutput "Original Recordset:", rstEmployees
 .Sort = "LastName, FirstName"
 ' Print report showing Sort property and record order.
 SortOutput _
 "Recordset after changing Sort property:", _
 rstEmployees
 ' Open new Recordset from current one.
 Set rstSortEmployees = .OpenRecordset
 ' Print report showing Sort property and record order.
 SortOutput "New Recordset:", rstSortEmployees
 rstSortEmployees.Close
 .Close
 End With

 dbsNorthwind.Close

End Sub

Function SortOutput(strTemp As String, _
 rstTemp As Recordset)

 With rstTemp
 Debug.Print strTemp
 Debug.Print " Sort = " & _
 IIf(.Sort <> "", .Sort, "[Empty]")
 .MoveFirst

 ' Enumerate Recordset.
 Do While Not .EOF
 Debug.Print " " & !LastName & _
 ", " & !FirstName
 .MoveNext
 Loop

 End With

End Function

When you know the data you want to select, it's usually more efficient to create a Recordset with an SQL statement. This example shows how you can create just one Recordset and obtain the same results as in the preceding example.

VBA Copy code Copy code
Sub SortX2()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 ' Open a Recordset from an SQL statement that specifies a
 ' sort order.
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("SELECT * " & _
 "FROM Employees ORDER BY LastName, FirstName", _
 dbOpenDynaset)

 dbsNorthwind.Close

End Sub


Recordset2.Type Property (DAO)

 Copy code hover
[image]

Recordset2.Type Property (DAO)
Send feedback

Sets or returns a value that indicates the operational type or data type of an object. Read-only Integer.

Syntax

expression .Type

expression A variable that represents a Recordset2 object.

Remarks

For a Recordset object, the possible settings and return values are as follows.

Constant

Recordset type

dbOpenTable

Table (Microsoft Access workspaces only)

dbOpenDynamic

Dynamic (ODBCDirect workspaces only)

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

dbOpenDynaset

Dynaset

dbOpenSnapshot

Snapshot

dbOpenForwardOnly

Forward-only


ReplicaTypeEnum Enumeration (DAO)

 Copy code hover
[image]

ReplicaTypeEnum Enumeration (DAO)
Send feedback

Used with the MakeReplica method to specify the type of replica to create.

Name | Value | Description
dbRepMakePartial | 1 | Creates a partial replica.
dbRepMakeReadOnly | 2 | Makes replicable elements of new database read-only.


AcPrintColor Enumeration (Access)

 Copy code hover
[image]

AcPrintColor Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the ColorMode property to specify whether the printer should print output in color or monochrome.

Name | Value | Description
acPRCMColor | 2 | The printer should print in color.
acPRCMMonochrome | 1 | The printer should print in monochrome.


ToggleButton.PressedForeThemeColorIndex Property (Access)

 Copy code hover
[image]

ToggleButton.PressedForeThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedForeColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .PressedForeThemeColorIndex

expression A variable that represents a ToggleButton object.

Remarks

The PressedForeThemeColorIndex uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 (Default) | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the PressedForeThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


SetTempVar Macro Action

 Copy code hover
[image]

SetTempVar Macro Action
Send feedback

You can use the SetTempVar action to create a temporary variable and set it to a specific value. The variable can then be used as a condition or argument in subsequent actions, or you can use the variable in another macro, in an event procedure, or on a form or report.

Setting

The SetTempVar action has the following arguments.

Action argument | Description
Name | Enter the name of the temporary variable.
Expression | Enter an expression that will be used to set the value for this temporary variable. Do not precede the expression with the equal (=) sign. You can click the Build button [image] to use the Expression Builder to set this argument.

Remarks

  • You can have up to 255 temporary variables defined at one time. If you do not remove a temporary variable, it will remain in memory until you close the database. It is a good practice to remove temporary variables when you are finished using them. To remove a single temporary variable, use the RemoveTempVar action and set its argument to the name of the temporary variable that you want to remove. If you have more than one temporary variable and you want to remove them all at once, use the RemoveAllTempVars action.

  • Temporary variables are global. Once a temporary variable has been created, you can refer to it in an event procedure, a Visual Basic for Applications (VBA) module, a query, or an expression. For example, if you created a temporary variable named MyVar, you could use the variable as the control source for a text box by using the following syntax:

    Copy code Copy code
    =[TempVars]![MyVar]
    Note Note

    In macros, queries and event procedures, you do not need to precede the expression with an equal sign.

    You can also refer to temporary variables in any add-ins or referenced databases.

  • To run the SetTempVar action in a VBA module, use the Add method of the TempVars object.

Example

The following macro demonstrates how to create a temporary variable by using the SetTempVar action, then using the temporary variable in a condition and a message box, and then removing the temporary variable.

Condition | Action | Arguments
 | SetTempVar | Name: MyVarExpression: InputBox("Enter a non-zero number.")
[TempVars]![MyVar]<>0 | MessageBox | Message: ="You entered " & [TempVars]![MyVar] & "."Beep: Yes Type: Information
 | RemoveTempVar | Name: MyVar


ObjectFrame.BackThemeColorIndex Property (Access)

 Copy code hover
[image]

ObjectFrame.BackThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackThemeColorIndex

expression A variable that represents an ObjectFrame object.

Remarks

The BackThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BackThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Background Color to the Text 2 color by setting the BackThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BackThemeColorIndex=2

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


TextBox.LeftMargin Property (Access)

 Copy code hover
[image]

TextBox.LeftMargin Property (Access)
See also Send feedback

Published: July 16, 2012

Along with the TopMargin, RightMargin, and BottomMargin properties. specifies the location of information displayed within a text box control. Read/write Integer. .

Syntax

expression .LeftMargin

expression A variable that represents a TextBox object.

Remarks

A control's displayed information location is measured from the control's left, top, right, or bottom border to the left, top, right, or bottom edge of the displayed information. Setting the LeftMargin or TopMargin property to 0 places the displayed information's edge at the very left or top of the control. To use a unit of measurement different from the setting in the regional settings of Windows, specify the unit (for example, cm or in).

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ComboBox.DefaultValue Property (Access)

 Copy code hover
[image]

ComboBox.DefaultValue Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.

Syntax

expression .DefaultValue

expression A variable that represents a ComboBox object.

Remarks

The DefaultValue property applies to all table fields except those fields with the data type of AutoNumber or OLE Object.

The DefaultValue property specifies text or an expression that's automatically entered in a control or field when a new record is created. For example, if you set the DefaultValue property for a text box control to =Now(), the control displays the current date and time. The maximum length for a DefaultValue property setting is 255 characters.

In Visual Basic, use a string expression to set the value of this property. For example, the following code sets the DefaultValue property for a text box control named PaymentMethod to "Cash"

VBA Copy code Copy code
Forms!frmInvoice!PaymentMethod.DefaultValue = """Cash"""
Note Note

To set this property for a field by using Visual Basic, use the ADO DefaultValue property or the DAO DefaultValue property.

The DefaultValue property is applied only when you add a new record. If you change the DefaultValue property, the change isn't automatically applied to existing records.

If you set the DefaultValue property for a form control that's bound to a field that also has a DefaultValue property setting defined in the table, the control setting overrides the table setting.

If you create a control by dragging a field from the field list, the field's DefaultValue property setting, as defined in the table, is applied to the control on the form although the control's DefaultValue property setting will remain blank.

One control can provide the default value for another control. For example, if you set the DefaultValue property for a control to the following expression, the control's default value is set to the DefaultValue property setting for the txtShipTo control.

VBA Copy code Copy code
=Forms!frmInvoice!txtShipTo

If the controls are on the same form, the control that's the source of the default value must appear earlier in the tab order than the control containing the expression.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Provider Errors

 Copy code hover
[image]

Provider Errors
Send feedback

When a provider error occurs, a run-time error of -2147467259 is returned. When you receive this error, check the active Connection object's Errors collection, which will contain one or more errors describing what happened.

The ADO Errors Collection

Because a particular ADO operation can produce multiple provider errors, ADO exposes a collection of error objects through the Connection object. This collection contains no objects if an operation concludes successfully and contains one or more Error objects if something went wrong and the provider raised one or more errors. Examine each individual error object in order to determine the exact cause of the error.

Once you have finished handling any errors that have occurred, you can clear the collection by calling the Clear method. It is particularly important to explicitly clear the Errors collection before you call the Resync, UpdateBatch, or CancelBatch method on a Recordset object, the Open method on a Connection object, or set the Filter property on a Recordset object. By clearing the collection explicitly, you can be certain that any Error objects in the collection are not left over from a previous operation.

Some operations can generate warnings as well as errors. Warnings are also represented by Error objects in the Errors collection. When a provider adds a warning to the collection, it does not generate a run-time error. Check the Count property of the Errors collection to determine if a warning was produced by a particular operation. If the count is one or greater, an Error object has been added to the collection. Once you have determined that the Errors collection contains errors or warnings, you can iterate through the collection and retrieve information about each of the Error objects it contains. The following short Visual Basic example demonstrates this:

Copy code Copy code

' BeginErrorHandlingVB02
Private Function DeleteCustomer(ByVal CompanyName As String) As Long
 On Error GoTo DeleteCustomerError

 rst.Find "CompanyName='" & CompanyName & "'"

DeleteCustomerError:

 Dim objError As ADODB.Error
 Dim strError As String

 If cnn.Errors.Count > 0 Then
 For Each objError In cnn.Errors
 strError = strError & "Error #" & objError.Number & _
 " " & objError.Description & vbCrLf & _
 "NativeError: " & objError.NativeError & vbCrLf & _
 "SQLState: " & objError.SQLState & vbCrLf & _
 "Reported by: " & objError.Source & vbCrLf & _
 "Help file: " & objError.HelpFile & vbCrLf & _
 "Help Context ID: " & objError.HelpContext
 Next
 MsgBox strError
 End If
End Function
' EndErrorHandlingVB02

The error-handling routine includes a For Each loop that examines each object in the Errors collection. In this example, it simply accumulates a message for display. In a working program, you would write code to perform an appropriate task for each error, such as closing all open files and shutting down the program in an orderly fashion.

The Error Object

By examining an Error object you can determine what error occurred, and more importantly, what application or what object caused the error. The Error object has the following properties:

Property name | Description
Description | A text description of the error that occurred.
HelpContext, HelpFile | Refers to the help topic and help file that contain a description of the error that occurred.
NativeError | The provider-specific error number.
Number | A Long Integer that represents the number (listed in the ErrorValueEnum) of the error that occurred.
Source | Indicates the name of the object or application that generated an error.
SQLState | A five-character error code that the provider returns during the process of a SQL statement.

The ADO Error object is quite similar to the standard Visual Basic Err object. Its properties describe the error that occurred. In addition to the number of the error, you also receive two related pieces of information. The NativeError property contains an error number specific to the provider you are using. In the previous example, the provider is the Microsoft OLE DB Provider for SQL Server, so NativeError will contain errors specific to SQL Server. The SQLState property has a five-letter code that describes an error in a SQL statement.

Event-Related Errors

The Error object is also used when event-related errors occur. You can determine if an error occurred in the process that raised an ADO event by checking the Error object passed as an event parameter.

If the operation that causes an event is concluded successfully, the adStatus parameter of the event handler will be set to adStatusOK. On the other hand, if the operation that raised the event was unsuccessful, the adStatus parameter is set to adStatusErrorsOccurred. In that case, the pError parameter will contain an Error object that describes the error.


CheckBox.GridlineStyleRight Property (Access)

 Copy code hover
[image]

CheckBox.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified check box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleRight

expression A variable that represents a CheckBox object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Recordset2.Bookmarkable Property (DAO)

 Copy code hover
[image]

Recordset2.Bookmarkable Property (DAO)
Send feedback

Returns a value that indicates whether a Recordset object supports bookmarks, which you can set by using the Bookmark property.

Syntax

expression .Bookmarkable

expression A variable that represents a Recordset2 object.

Remarks

Check the Bookmarkable property setting of a Recordset object before you attempt to set or check the Bookmark property.

For Recordset objects based entirely on Microsoft Access database engine tables, the value of the Bookmarkable property is True, and you can use bookmarks. Other database products may not support bookmarks, however. For example, you can't use bookmarks in any Recordset object based on a linked Paradox table that has no primary key.

Example

This example uses the Bookmark and Bookmarkable properties to let the user flag a record in a recordset and return to it later.

Copy code Copy code
Sub BookmarkX()

 Dim dbsNorthwind As Database
 Dim rstCategories As Recordset2
 Dim strMessage As String
 Dim intCommand As Integer
 Dim varBookmark As Variant

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstCategories = _
 dbsNorthwind.OpenRecordset("Categories", _
 dbOpenSnapshot)

 With rstCategories

 If .Bookmarkable = False Then
 Debug.Print "Recordset is not Bookmarkable!"
 Else
 ' Populate Recordset.
 .MoveLast
 .MoveFirst

 Do While True
 ' Show information about current record and get
 ' user input.
 strMessage = "Category: " & !CategoryName & _
 " (record " & (.AbsolutePosition + 1) & _
 " of " & .RecordCount & ")" & vbCr & _
 "Enter command:" & vbCr & _
 "[1 - next / 2 - previous /" & vbCr & _
 "3 - set bookmark / 4 - go to bookmark]"
 intCommand = Val(InputBox(strMessage))

 Select Case intCommand
 ' Move forward or backward, trapping for BOF
 ' or EOF.
 Case 1
 .MoveNext
 If .EOF Then .MoveLast
 Case 2
 .MovePrevious
 If .BOF Then .MoveFirst

 ' Store the bookmark of the current record.
 Case 3
 varBookmark = .Bookmark

 ' Go to the record indicated by the stored
 ' bookmark.
 Case 4
 If IsEmpty(varBookmark) Then
 MsgBox "No Bookmark set!"
 Else
 .Bookmark = varBookmark
 End If

 Case Else
 Exit Do
 End Select

 Loop

 End If

 .Close
 End With

 dbsNorthwind.Close

End Sub


Section Members (Access)

 Copy code hover
[image]

Section Members (Access)
Send feedback

Published: July 16, 2012

A form section is part of a form such as a header, footer, or detail section.

Events

Name | Description
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.
Paint | Occurs when the specified section is redrawn.

Methods

Name | Description
SetTabOrder | Resets the tab order of the controls in the specified Section to their default values.

Properties

Name | Description
AlternateBackColor | Gets or sets the background color to display on alternate rows of the specified section. Read/write Long.
AlternateBackShade | Gets or sets the shade applied to the theme color in the AlternateBackColor property of the section. Read/write Single.
AlternateBackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the AlternateBackColor property of the section. Read/write Long.
AlternateBackTint | Gets or sets the tint applied to the theme color in the AlternateBackColor property of the section. Read/write Single.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoHeight | Gets or sets whether a section's height is adjusted automatically when controls are resized. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
CanGrow | Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the control contains. Read/write Boolean.
CanShrink | Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the section or control contains. Read/write Boolean.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's sections you want displayed on screen and in print. Read/write Byte.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
ForceNewPage | You can use the ForceNewPage property to specify whether form sections detail, footer) or report sections (header, detail, footer) print on a separate page, rather than on the current page. Read/write Byte.
HasContinued | You can use the HasContinued property to determine if part of the current section begins on the previous page. Read/write Boolean.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
KeepTogether | You can use the KeepTogether property for a section to print a form or report section all on one page. For example, you might have a group of related information that you don't want printed across two pages. The KeepTogether property applies only to form and report sections (except page headers and page footers). Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
NewRowOrCol | You can use the NewRowOrCol property to specify whether a section and its associated data is printed in a new row or column within a multiple-column report or multiple-column form. Read/write Byte.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnFormat | Sets or returns the value of the On Format box in the Properties window of a report section. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnPaint | Sets or returns the value of the On Paint box in the Properties window of a form or report. Read/write String.
OnPrint | Sets or returns the value of the On Print box in the Properties window of a report section. Read/write String.
OnRetreat | Sets or returns the value of the On Retreat box in the Properties window of a report section. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
RepeatSection | You can use the RepeatSection property to specify whether a group header is repeated on the next page or column when a group spans more than one page or column. Read/write Boolean.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
WillContinue | Determines if the current section will continue on the following page. Read/write Boolean.


AcSplitFormPrinting Enumeration (Access)

 Copy code hover
[image]

AcSplitFormPrinting Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the SplitFormPrinting property to specify what to print when a form is in Split Form view.

Version Information

Version Added: Access 2007

Name | Value | Description
acFormOnly | 0 | The contents of the form are printed.
acGridOnly | 1 | The contents of the datasheet are printed.


Command (Visual C++ Syntax Index with #import)

 Copy code hover
[image]

Command (Visual C++ Syntax Index with #import)
Send feedback

Methods

Copy code Copy code

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthadocancel_HV10294125.xml( );

_RecordsetPtr Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcmdexecute_HV10294344.xml( VARIANT * RecordsAffected, VARIANT
 * Parameters, long Options );

_ParameterPtr Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcreateparam_HV10294243.xml( _bstr_t Name, enum
 DataTypeEnum Type, enum ParameterDirectionEnum Direction, long Size,
 const _variant_t & Value =vtMissing);

Properties

Copy code Copy code

_ConnectionPtr GetActiveConnection( );
void PutRefActiveConnection( struct _Connection * ppvObject );
void PutActiveConnection( const _variant_t & ppvObject );
__declspec(property(get=GetActiveConnection,put=PutRefActiveConnection))
 _ConnectionPtr Invalid DDUE based on source, error:link not allowed in code, link filename:mdproactivecon_HV10293988.xml;

_bstr_t GetCommandText( );
void PutCommandText( _bstr_t pbstr );
__declspec(property(get=GetCommandText,put=PutCommandText)) _bstr_t
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocommandtext_HV10294195.xml;

long GetCommandTimeout( );
void PutCommandTimeout( long pl );
__declspec(property(get=GetCommandTimeout,put=PutCommandTimeout)) long
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocommandtimeout_HV10294196.xml;

void PutCommandType( enum CommandTypeEnum plCmdType );
enum CommandTypeEnum GetCommandType( );
__declspec(property(get=GetCommandType,put=PutCommandType)) enum
 CommandTypeEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocommandtype_HV10294197.xml;

VARIANT_BOOL GetPrepared( );
void PutPrepared( VARIANT_BOOL pfPrepared );
__declspec(property(get=GetPrepared,put=PutPrepared)) VARIANT_BOOL
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdproprepared_HV10294617.xml;

ParametersPtr GetParameters( );
__declspec(property(get=GetParameters)) ParametersPtr
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdcolparameters_HV10294594.xml;

_bstr_t GetName( );
void PutName( _bstr_t pbstrName );
__declspec(property(get=GetName,put=PutName)) _bstr_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdproname_HV10294535.xml;

long GetState( );
__declspec(property(get=GetState)) long Invalid DDUE based on source, error:link not allowed in code, link filename:mdprostate_HV10294804.xml;


LEFT JOIN, RIGHT JOIN Operations (Microsoft Access SQL)

 Copy code hover
[image]

LEFT JOIN, RIGHT JOIN Operations (Microsoft Access SQL)
Send feedback

Combines source-table records when used in any FROM clause.

Syntax

FROM table1 [ LEFT | RIGHT ] JOIN table2 ON table1.field1 compopr table2.field2

The LEFT JOIN and RIGHT JOIN operations have these parts:

Part | Description
table1, table2 | The names of the tables from which records are combined.
field1, field2 | The names of the fields that are joined. The fields must be of the same data type and contain the same kind of data, but they do not need to have the same name.
compopr | Any relational comparison operator: "=," "<," ">," "<=," ">=," or "<>."

Remarks

Use a LEFT JOIN operation to create a left outer join. Left outer joins include all of the records from the first (left) of two tables, even if there are no matching values for records in the second (right) table.

Use a RIGHT JOIN operation to create a right outer join. Right outer joins include all of the records from the second (right) of two tables, even if there are no matching values for records in the first (left) table.

For example, you could use LEFT JOIN with the Departments (left) and Employees (right) tables to select all departments, including those that have no employees assigned to them. To select all employees, including those who are not assigned to a department, you would use RIGHT JOIN.

The following example shows how you could join the Categories and Products tables on the CategoryID field. The query produces a list of all categories, including those that contain no products:

SQL Copy code Copy code
SELECT CategoryName,
ProductName
FROM Categories LEFT JOIN Products
ON Categories.CategoryID = Products.CategoryID;

In this example, CategoryID is the joined field, but it is not included in the query results because it is not included in the SELECT statement. To include the joined field, enter the field name in the SELECT statement — in this case, Categories.CategoryID.

Note Note

  • To create a query that includes only records in which the data in the joined fields is the same, use an INNER JOIN operation.

  • A LEFT JOIN or a RIGHT JOIN can be nested inside an INNER JOIN, but an INNER JOIN cannot be nested inside a LEFT JOIN or a RIGHT JOIN. See the discussion of nesting in the INNER JOIN topic to see how to nest joins within other joins.

  • You can link multiple ON clauses. See the discussion of clause linking in the INNER JOIN topic to see how this is done.

  • If you try to join fields containing Memo or OLE Object data, an error occurs.

Example

This example assumes the existence of hypothetical Department Name and Department ID fields in an Employees table. Note that these fields do not actually exist in the Northwind database Employees table.

This example selects all departments, including those without employees.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

VBA Copy code Copy code
Sub LeftRightJoinX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Select all departments, including those
    ' without employees.
    Set rst = dbs.OpenRecordset _
        ("SELECT [Department Name], " _
        & "FirstName & Chr(32) & LastName AS Name " _
        & "FROM Departments LEFT JOIN Employees " _
        & "ON Departments.[Department ID] = " _
        & "Employees.[Department ID] " _
        & "ORDER BY [Department Name];")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 20

    dbs.Close

End Sub


Parameter (ADO for Visual C++ Syntax)

 Copy code hover
[image]

Parameter (ADO for Visual C++ Syntax)
Send feedback

Methods

AppendChunk(VARIANT Val)

Properties

            get_Attributes(LONG *plParmAttribs)

put_Attributes(LONG lParmAttribs)

get_Direction(ParameterDirectionEnum *plParmDirection)

put_Direction(ParameterDirectionEnum lParmDirection)

get_Name(BSTR *pbstr)

put_Name(BSTR bstr)

get_NumericScale(BYTE *pbScale)

put_NumericScale(BYTE bScale)

get_Precision(BYTE *pbPrecision)

put_Precision(BYTE bPrecision)

get_Size(long *pl)

put_Size(long l)

get_Type(DataTypeEnum *psDataType)

put_Type(DataTypeEnum sDataType)

get_Value(VARIANT *pvar)

put_Value(VARIANT val)


Report.MouseWheel Event (Access)

 Copy code hover
[image]

Report.MouseWheel Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when the user rolls the mouse wheel in Report view or Layout view.

Version Information

Version Added: Access 2007

Syntax

expression .MouseWheel(Page, Count)

expression A variable that represents a Report object.

Parameters

Name | Required/Optional | Data Type | Description
Page | Required | Boolean | True if the page was changed.
Count | Required | Long | The number of lines by which the view was scrolled with the mouse wheel.

See also

Concepts

Report Object

Other resources

Report Object Members


Attachment.GotFocus Event (Access)

 Copy code hover
[image]

Attachment.GotFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The GotFocus event occurs when the specified object receives the focus.

Version Information

Version Added: Access 2007

Syntax

expression .GotFocus

expression A variable that represents an Attachment object.

Return Value

nothing

Remarks

The GotFocus event applies only to forms and controls on a form, not controls on a report.

To run a macro or event procedure when these events occur, set the OnGotFocus property to the name of the macro or to [Event Procedure].

These events occur when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The GotFocus event differs from the Enter event in that the GotFocus event occurs every time a control receives the focus. For example, suppose the user clicks a check box on a form, then clicks a report, and finally clicks the check box on the form to bring it to the foreground. The GotFocus event occurs both times the check box receives the focus. In contrast, the Enter event occurs only the first time the user clicks the check box. The GotFocus event occurs after the Enter event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control to which you moved.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform to which the focus moved)

ß

GotFocus (for the control on the subform to which the focus moved)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


OptionButton.BeforeUpdate Event (Access)

 Copy code hover
[image]

OptionButton.BeforeUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The BeforeUpdate event occurs before changed data in a control or record is updated.

Syntax

expression .BeforeUpdate(Cancel)

expression A variable that represents an OptionButton object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the BeforeUpdate event occurs. Setting the Cancel argument to True (-1) cancels the BeforeUpdate event.

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's BeforeUpdate event does occur.

To run a macro or event procedure when this event occurs, set the BeforeUpdate property to the name of the macro or to [Event Procedure].

This event does not apply to option buttons, check boxes, or toggle buttons in an option group. It applies only to the option group itself.

The BeforeUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB. When the focus leaves the record or if the user clicks Save Record on the Records menu, the entire record is updated, and the data is saved in the database.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

BeforeUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. BeforeUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For forms, you can use the BeforeUpdate event to cancel updating of a record before moving to another record.

If the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

You often use the BeforeUpdate event to validate data, especially when you perform complex validations, such as those that:

  • Involve conditions for more than one value on a form.

  • Display different error messages for different data entered.

  • Can be overridden by the user.

  • Contain references to controls on other forms or contain user-defined functions.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

A run-time error will occur if you attempt to modify the data contained in the control that fired the BeforeUpdate event in the event's procedure.

Example

The following example shows how you can use a BeforeUpdate event procedure to check whether a product name has already been entered in the database. After the user types a product name in the ProductName box, the value is compared to the ProductName field in the Products table. If there is a matching value in the Products table, a message is displayed that informs the user that the product has already been entered.

To try the example, add the following event procedure to a form named Products that contains a text box called ProductName.

VBA Copy code Copy code
Private Sub ProductName_BeforeUpdate(Cancel As Integer)
 If(Not IsNull(DLookup("[ProductName]", _
 "Products", "[ProductName] ='" _
 & Me!ProductName & "'"))) Then
 MsgBox "Product has already been entered in the database."
 Cancel = True
 Me!ProductName.Undo
 End If
End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Foreign key violation. (Error 3719)

 Copy code hover
[image]

Foreign key violation. (Error 3719)
Send feedback

This foreign key violation results from an invalid primary key record that was involved in a replication conflict. Either create a new primary key record that satisfies the referential integrity constraint and then resubmit your update, modify the foreign key value in this conflict record to match a valid primary key value and then resubmit this conflict record, or delete this conflict record.


Error in evaluating the Boolean filter expression for table

 Copy code hover
[image]

Error in evaluating the Boolean filter expression for table <name>. (Error 3657)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for more information.


TextBox.AllowAutoCorrect Property (Access)

 Copy code hover
[image]

TextBox.AllowAutoCorrect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllowAutoCorrect property to specify whetherthe specified control will automatically correct entries made by the user. Read/write Boolean.

Syntax

expression .AllowAutoCorrect

expression A variable that represents a TextBox object.

Remarks

The AllowAutoCorrect property uses the following settings.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ComboBox.OnClick Property (Access)

 Copy code hover
[image]

ComboBox.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Syntax

expression .OnClick

expression A variable that represents a ComboBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when one of the following things occurs:

  • The user presses and releases the left mouse button over combo box.

  • The user commits a change to the value of the combo box. In this case, the Click event fires after the AfterUpdate event and before the Exit event.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


PageBreak.Tag Property (Access)

 Copy code hover
[image]

PageBreak.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents a PageBreak object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

PageBreak Object

Other resources

PageBreak Object Members


DoCmd.TransferSharePointList Method (Access)

 Copy code hover
[image]

DoCmd.TransferSharePointList Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the TransferSharePointList method to import or link data from a SharePoint Foundation site.

Version Information

Version Added: Access 2007

Syntax

expression .TransferSharePointList(TransferType, SiteAddress, ListID, ViewID, TableName, GetLookupDisplayValues)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
TransferType | Required | AcSharePointListTransferType | An AcSharePointListTransferType constant that specifies the type of transfer to make.
SiteAddress | Required | Variant | The full path of the SharePoint site.
ListID | Required | Variant | The name or GUID of the list to be transferred.
ViewID | Optional | Variant | The GUID of the view for the list you want to use. Leave this argument blank to transfer all rows and columns in the list.
TableName | Optional | Variant | The name you want displayed for the table or linked table in Access.
GetLookupDisplayValues | Optional | Variant | Specifies whether to transfer display values for Lookup fields instead of the ID used to perform the lookup.

Remarks

This method has the same effect as clicking SharePoint List in the Import group on the External Data tab. The arguments for the action correspond to the choices you make in the Get External Data Wizard.

If you specify a nonexistent list or view, no error occurs, and no data is transferred.

A GUID is a unique hexadecimal identifier for a list or a view. A GUID must be entered in the following format, where each "F" is a hexadecimal number (0 through 9 or A through F).

VBA Copy code Copy code

{FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF}

You can obtain the GUID for a list or view from the SharePoint site by using the following procedure:

  1. Open the list in SharePoint Foundation.

  2. If the view you want is not displayed, click the View drop-down arrow and then select the view you want.

  3. Click the View drop-down arrow and then select Modify this View.The address in the browser's address bar contains the GUIDs for both the list and the view. The GUID for the list follows List= , and the GUID for the view follows View= . However, in the address, each { (left brace) character is represented by the string %7B , each - (hyphen) character is represented by the string %2D , and each } (right brace) character is represented by the string %7D . For example: http://MySite12/_layouts/ViewEdit.aspx?List=%7B2A82A404%2D5529%2D47DC%2DAE13%2DAC1D9BC0A84F%7D&View=%7B357B4FE6%2D44CF%2D4275%2DB91F%2D46558301579B%7D Before you can use the GUIDs from the address as arguments in this macro action, you must replace each %7B string with the { character, replace each %2D string with the - character, and replace each %7D string with the } character. Do not include the & (ampersand) character that follows the %7D string in the list GUID.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Section.Controls Property (Access)

 Copy code hover
[image]

Section.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Syntax

expression .Controls

expression A variable that represents a Section object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

Section Object

Other resources

Section Object Members


ODBC Specification Conformance Error

 Copy code hover
[image]

ODBC Specification Conformance Error <message>. Report this error to the developer of your application. (Error 3299)
Send feedback

This error can be caused by any of a number of problems with your ODBC driver. Write down the error number indicated in the message and report it to the developer of the application, who can then report it to the driver vendor.


ComboBox.Height Property (Access)

 Copy code hover
[image]

ComboBox.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Syntax

expression .Height

expression A variable that represents a ComboBox object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


PageCount Property (ADO)

 Copy code hover
[image]

PageCount Property (ADO)
Send feedback

Indicates how many pages of data the Recordset object contains.

Return Value

Returns a Long value that indicates the number of pages in the Recordset.

Remarks

Use the PageCount property to determine how many pages of data are in the Recordset object. Pages are groups of records whose size equals the PageSize property setting. Even if the last page is incomplete because there are fewer records than the PageSize value, it counts as an additional page in the PageCount value. If the Recordset object does not support this property, the value will be -1 to indicate that the PageCount is indeterminable.

See the PageSize and AbsolutePage properties for more on page functionality.


Working with Recordsets

 Copy code hover
[image]

Working with Recordsets
Send feedback

The Recordset object has built-in features that make it possible for you to rearrange the order of the data in the result set, to search for a specific record based on criteria that you supply, and even to optimize those search operations using indexes. Whether these features are available for use depends on the provider and in some cases — such as that of the Index property — the structure of the data source itself.

Arranging Data

Often, the most efficient way to order the data in your Recordset is by specifying an ORDER BY clause in the SQL command used to return results to it. However, you might need to change the order of the data in a Recordset that has already been created. You can use the Sort property to establish the order in which rows of a Recordset are traversed. Furthermore, the Filter property determines which rows are accessible when traversing rows.

The Sort property sets or returns a String value that indicates the field names in the Recordset on which to sort. Each name is separated by a comma and is optionally followed by a space and the keyword ASC (which sorts the field in ascending order) or DESC (which sorts the field in descending order). By default, if no keyword is specified, the field is sorted in ascending order.

The sort operation is efficient because data is not physically rearranged but is simply accessed in the order specified by an index.

The Sort property requires the CursorLocation property to be set to adUseClient. A temporary index will be created for each field specified in the Sort property if an index does not already exist.

Setting the Sort property to an empty string will reset the rows to their original order and delete temporary indexes. Existing indexes will not be deleted.

Suppose a Recordset contains three fields named firstName, middleInitial, and lastName. Set the Sort property to the string "", which will order the Recordset by last name in descending order and then by first name in ascending order. The middle initial is ignored.

No field referenced in a sort criteria string can be named "ASC" or "DESC" because those names conflict with the keywords ASC and DESC. Give a field with a conflicting name an alias by using the AS keyword in the query that returns the Recordset.

For more details about Recordset filtering, see Filtering the Results later in this topic.

Finding a Specific Record

ADO provides the Find and Seek methods for locating a particular record in a Recordset. The Find method is supported by a variety of providers but is limited to a single search criterion. The Seek method supports searching on multiple criteria, but is not supported by many providers.

Indexes on fields can greatly enhance the performance of the Recordset object's Find method and Sort and Filter properties. You can create an internal index for a Field object by setting its dynamic Optimize property. This dynamic property is added to the Field object's Properties collection when you set the CursorLocation property to adUseClient. Remember that this index is internal to ADO — you cannot gain access to it or use it for any other purpose. Also, this index is distinct from the Recordset object's Index property.

The Find method quickly locates a value within a column (field) of a Recordset. You can often improve the speed of the Find method's operation on a column by using the Optimize property to create an index on it.

The Find method limits your search to the contents of one field. The Seek method requires that you have an index and has other limitations as well. If you need to search on multiple fields that aren't the basis of an index, or if your provider does not support indexes, you can limit your results using the Filter property of the Recordset object.

Find

The Find method searches a Recordset for the row that satisfies a specified criterion. Optionally, the direction of the search, starting row, and offset from the starting row may be specified. If the criterion is met, the current row position is set on the found record; otherwise, the position is set to the end (or start) of the Recordset, depending on search direction.

Only a single-column name may be specified for the criterion. In other words, this method does not support multi-column searches.

The comparison operator for the criterion may be ">" (greater than), "<" (less than), "=" (equal), ">=" (greater than or equal), "<=" (less than or equal), "<>" (not equal), or "LIKE" (pattern matching).

The criterion value may be a string, floating-point number, or date. String values are delimited with single quotes or "#" (number sign) marks (for example, "state = 'WA'" or "state = #WA#"). Date values are delimited with "#" (number sign) marks (for example, "start_date > #7/22/97#").

If the comparison operator is "like", the string value may contain an asterisk (*) to find one or more occurrences of any character or substring. For example, "state like 'M*'" matches Maine and Massachusetts. You can also use leading and trailing asterisks to find a substring contained within the values. For example, "state like '*as*'" matches Alaska, Arkansas, and Massachusetts.

Asterisks can be used only at the end of a criteria string or together at both the beginning and end of a criteria string, as shown above. You cannot use the asterisk as a leading wildcard ('*str') or embedded wildcard ('s*r'). This will cause an error.

Seek and Index

Use the Seek method in conjunction with the Index property if the underlying provider supports indexes on the Recordset object. Use the Supports (adSeek) method to determine whether the underlying provider supports Seek, and the Supports(adIndex) method to determine whether the provider supports indexes. (For example, the OLE DB Provider for Microsoft Jet supports Seek and Index.)

If Seek does not find the desired row, no error occurs, and the row is positioned at the end of the Recordset. Set the Index property to the desired index before executing this method.

This method is supported only with server-side cursors. Seek is not supported when the Recordset object's CursorLocation property value is adUseClient.

This method can be used only when the Recordset object has been opened with a CommandTypeEnum value of adCmdTableDirect.

Filtering the Results

The Find method limits your search to the contents of one field. The Seek method requires that you have an index and has other limitations as well. If you need to search on multiple fields that are not the basis of an index or if your provider does not support indexes, you can limit your results using the Filter property of the Recordset object.

Use the Filter property to selectively screen out records in a Recordset object. The filtered Recordset becomes the current cursor, which means that records that do not satisfy the Filter criteria are not available in the Recordset until the Filter is removed. Other properties that return values based on the current cursor are affected, such as AbsolutePosition, AbsolutePage, RecordCount, and PageCount. This is because setting the Filter property to a specific value will move the current record to the first record that satisfies the new value.

The Filter property takes a variant argument. This value represents one of three methods for using the Filter property: a criteria string, a FilterGroupEnum constant, or an array of bookmarks. For more information, see Filtering with a Criteria String, Filtering with a Constant, and Filtering with Bookmarks later in this topic.

Note Note

When you know the data you want to select, it is usually more efficient to open a Recordset with a SQL statement that effectively filters the result set, rather than relying on the Filter property.

To remove a filter from a Recordset, use the adFilterNone constant. Setting the Filter property to a zero-length string ("") has the same effect as using the adFilterNone constant.

Filtering with a Criteria String

The criteria string is made up of clauses in the form FieldName Operator Value (for example, "LastName = 'Smith'"). You can create compound clauses by concatenating individual clauses with AND (for example, "LastName = 'Smith' AND FirstName = 'John'") and OR (for example, ). You can create compound clauses by concatenating individual clauses with AND (for example, "LastName = 'Smith' AND FirstName = 'John'") and OR (for example, "LastName = 'Smith' OR LastName = 'Jones'"). Use the following guidelines for criteria strings:

  • FieldName must be a valid field name from the Recordset. If the field name contains spaces, you must enclose the name in square brackets.

  • Operator must be one of the following: <, >, <=, >=, <>, =, or LIKE.

  • Value is the value with which you will compare the field values (for example, 'Smith', #8/24/95#, 12.345, or $50.00). Use single quotation marks (') with strings and pound signs (#) with dates. For numbers, you can use decimal points, dollar signs, and scientific notation. If Operator is LIKE, Value can use wildcards. Only the asterisk (*) and percent sign (%) wildcards are allowed, and they must be the last character in the string. Value cannot be null.

    Note Note

    To include single quotation marks (') in the filter Value, use two single quotation marks to represent one. For example, to filter on O'Malley, the criteria string should be "col1 = 'O''Malley'". To include single quotation marks at both the beginning and the end of the filter value, enclose the string in pound signs (#). For example, to filter on '1', the criteria string should be "col1 = #'1'#".

There is no precedence between AND and OR. Clauses can be grouped within parentheses. However, you cannot group clauses joined by an OR and then join the group to another clause with an AND, like this:

Copy code Copy code

(LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John'

Instead, you would construct this filter as:

Copy code Copy code

(LastName = 'Smith' AND FirstName = 'John') OR (LastName = 'Jones' AND FirstName = 'John')

In a LIKE clause, you can use a wildcard at the beginning and end of the pattern (for example, LastName Like '*mit*') or only at the end of the pattern (for example, ) or only at the end of the pattern (for example, LastName Like 'Smit*').

Filtering with a Constant

The following constants are available for filtering Recordsets.

Constant | Description
adFilterAffectedRecords | Filters for viewing only records effected by the last Delete, Resync, UpdateBatch, or CancelBatch call.
adFilterConflictingRecords | Filters for viewing the records that failed the last batch update.
adFilterFetchedRecords | Filters for viewing the records in the current cache — that is, the results of the last call to retrieve records from the database.
adFilterNone | Removes the current filter and restores all records for viewing.
adFilterPendingRecords | Filters for viewing only records that have changed but have not yet been sent to the server. Applicable only for batch update mode.

The filter constants make it easier to resolve individual record conflicts during batch update mode by allowing you to view, for example, only those records that were effected during the last UpdateBatch method call, as shown in the following example:

Copy code Copy code

'BeginDeleteGroup
    'add some bogus records
    With objRs1
        For i = 0 To 8
            .AddNew
            .Fields("CompanyName") = "Shipper Number " & i + 1
            .Fields("Phone") = "(425) 555-000" & (i + 1)
            .Update
        Next i

    're-connect & update
        .ActiveConnection = GetNewConnection
        .UpdateBatch

    'filter on newly added records
        .Filter = adFilterAffectedRecords
        Debug.Print "Deleting the " & .RecordCount & _
                    " records you just added."

    'delete the newly added bogus records
        .Delete adAffectGroup
        .Filter = adFilterNone
        Debug.Print .RecordCount & " records remain."

        .Close
    End With
'EndDeleteGroup

Filtering with Bookmarks

Finally, you can pass a variant array of bookmarks to the Filter property. The resulting cursor will contain only those records whose bookmark was passed in to the property. The following code example creates an array of bookmarks from the records in a Recordset which have a "B" in the ProductName field. It then passes the array to the Filter property and displays information about the resulting filtered Recordset.

Copy code Copy code

'BeginFilterBkmk
    Dim vBkmkArray() As Variant
    Dim i As Integer

    'Recordset created using "SELECT * FROM Products" as command.
    'So, we will check to see if ProductName has a capital B, and
    'if so, add to the array.
    i = 0
    Do While Not objRs.EOF
        If InStr(1, objRs("ProductName"), "B") Then
            ReDim Preserve vBkmkArray(i)
            vBkmkArray(i) = objRs.Bookmark
            i = i + 1
            Debug.Print objRs("ProductName")
        End If
        objRs.MoveNext
    Loop

    'Filter using the array of bookmarks.
    objRs.Filter = vBkmkArray

    objRs.MoveFirst
    Do While Not objRs.EOF
        Debug.Print objRs("ProductName")
        objRs.MoveNext
    Loop
    'EndFilterBkmk

Creating a Clone of a Recordset

Use the Clone method to create multiple, duplicate Recordset objects, particularly if you want to maintain more than one current record in a given set of records. Using the Clone method is more efficient than creating and opening a new Recordset object with the same definition as the original.

The current record of a newly created clone is originally set to the first record. The current record pointer in a cloned Recordset is not synchronized with the original or vice versa. You can navigate independently in each Recordset.

Changes you make to one Recordset object are visible in all of its clones regardless of cursor type. However, after you execute Requery on the original Recordset, the clones will no longer be synchronized to the original.

Closing the original Recordset does not close its copies, nor does closing a copy close the original or any of the other copies.

You can clone a Recordset object only if it supports bookmarks. Bookmark values are interchangeable; that is, a bookmark reference from one Recordset object refers to the same record in any of its clones.


BoundObjectFrame.OLEType Property (Access)

 Copy code hover
[image]

BoundObjectFrame.OLEType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OLEType property to determine if a control contains an OLE object, and, if so, whether the object is linked or embedded. Read/write Byte.

Syntax

expression .OLEType

expression A variable that represents a BoundObjectFrame object.

Remarks

The OLEType property uses the following settings.

Setting | Constant | Description
Linked | acOLELinked | The control contains a linked object. All the object's data is managed by the application that created it.
Embedded | acOLEEmbedded | The control contains an embedded object. All the object's data is managed by Microsoft Access.
None | acOLENone | The control doesn't contain an OLE object.

When creating an OLE object, use the OLETypeAllowed property to determine what type of object a control can contain.

Example

The following example illustrates how to display the Insert Object dialog box and how to display an error message if the Cancel button in the Insert Object dialog box is clicked.

VBA Copy code Copy code
Sub InsertObject_Click()
 Dim conUserCancelled As Integer

 ' Error message returned when user cancels.
 conUserCancelled = 2001
 On Error GoTo ButtonErr
 If OLE1.OLEType = acOLENone Then
 ' No OLE object created.
 ' Display Insert Object dialog box.
 OLE1.Action = acOLEInsertObjDlg
 End If
 Exit Sub

ButtonErr:
 If Err = conUserCancelled Then ' Display message.
 MsgBox "You clicked the Cancel button; " _
 & "no object was created."
 End If
 Resume Next
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


CustomControl.Custom Property (Access)

 Copy code hover
[image]

CustomControl.Custom Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String representing the custom properties dialog box for an ActiveX control. Read/write.

Syntax

expression .Custom

expression A variable that represents a CustomControl object.

Remarks

Not all ActiveX controls provide a custom properties dialog box. To see whether a control provides this custom properties dialog box, look for the Custom property in the Microsoft Access property sheet for this control. If the list of properties contains the name Custom, then the control provides the custom properties dialog box.

After you click the Custom property box in the Microsoft Access property sheet, click the Build button to the right of the property box to display the control's custom properties dialog box, often presented as a tabbed dialog box. Choose the tab that contains the interface for setting the properties that you want to set.

After you make changes on one tab, you can often apply those changes immediately by clicking the Apply button (if provided). You can click other tabs to set other properties as needed. To approve all changes made in the custom properties dialog box, click the OK button. To return to the Microsoft Access property sheet without changing any property settings, click the Cancel button.

You can also view the custom properties dialog box by clicking the Properties subcommand of the ActiveX control Object command (for example, Calendar Control Object) on the Edit menu, or by clicking this same subcommand on the shortcut menu for the ActiveX control. In addition, some properties in the Microsoft Access property sheet for the ActiveX control, like the GridFontColor property of the Calendar control, have a Build button to the right of the property box. When you click the Build button, the custom properties dialog box is displayed, with the appropriate tab selected (for example, Colors).

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


CustomControl.GridlineWidthTop Property (Access)

 Copy code hover
[image]

CustomControl.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthTop

expression A variable that represents a CustomControl object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


BeginTransComplete, CommitTransComplete, and RollbackTransComplete Events (ADO)

 Copy code hover
[image]

BeginTransComplete, CommitTransComplete, and RollbackTransComplete Events (ADO)
Send feedback

These events will be called after the associated operation on the Connection object finishes executing.

  • BeginTransComplete is called after the BeginTrans operation.

  • CommitTransComplete is called after the CommitTrans operation.

  • RollbackTransComplete is called after the RollbackTrans operation.

Syntax

BeginTransComplete TransactionLevel, pError, adStatus, pConnection

CommitTransComplete pError, adStatus, pConnection

RollbackTransComplete pError, adStatus, pConnection

Parameters

  • TransactionLevel

  • A Long value that contains the new transaction level of the BeginTrans that caused this event.

  • pError

  • An Error object. It describes the error that occurred if the value of EventStatusEnum is adStatusErrorsOccurred; otherwise it is not set.

  • adStatus

  • EventStatusEnum

    These events can prevent subsequent notifications by setting this parameter to adStatusUnwantedEvent before the event returns.

  • pConnection

  • The Connection object for which this event occurred.

Remarks

In Visual C++, multiple Connections can share the same event handling method. The method uses the returned Connection object to determine which object caused the event.

If the Attributes property is set to adXactCommitRetaining or adXactAbortRetaining, a new transaction starts after committing or rolling back a transaction. Use the BeginTransComplete event to ignore all but the first transaction start event.


Relation Methods (DAO)

 Copy code hover
[image]

Relation Methods (DAO)
Send feedback

In this section

  • Relation.CreateField Method (DAO)


UPDATESECURITY (Microsoft Access SQL reserved word)

 Copy code hover
[image]

UPDATESECURITY (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The UPDATESECURITY keyword is used in these contexts:

GRANT Statement

REVOKE Statement


PageBreak.Parent Property (Access)

 Copy code hover
[image]

PageBreak.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a PageBreak object.

See also

Concepts

PageBreak Object

Other resources

PageBreak Object Members


Format Property - Text and Memo Data Types

 Copy code hover
[image]

Format Property - Text and Memo Data Types
Send feedback

Published: July 16, 2012

You can use special symbols in the setting for the Format property to create custom formats for Text and Memo fields.

Setting

You can create custom text and memo formats by using the following symbols.

Symbol | Description
@ | Text character (either a character or a space) is required.
& | Text character is not required.
< | Force all characters to lowercase.
> | Force all characters to uppercase.

Custom formats for Text and Memo fields can have up to two sections. Each section contains the format specification for different data in a field.

Section | Description
First | Format for fields with text.
Second | Format for fields with zero-length strings and Null values.

For example, if you have a text box control in which you want the word "None" to appear when there is no string in the field, you could type the custom format @;"None" as the control's Format property setting. The @ symbol causes the text from the field to be displayed; the second section causes the word "None" to appear when there is a zero-length string or Null value in the field.

Note Note

You can use the Format function to return one value for a zero-length string and another for a Null value, and you can similarly use the Format property to automatically format fields in table Datasheet view or controls on a form or report.

Example

The following are examples of text and memo custom formats.

Setting | Data | Display
@@@-@@-@@@@ | 465043799 | 465-04-3799
@@@@@@@@@ | 465-04-3799 465043799 | 465-04-3799 465043799
> | davolio DAVOLIO Davolio | DAVOLIO DAVOLIO DAVOLIO
< | davolio DAVOLIO Davolio | davolio davolio davolio
@;"Unknown" | Null value | Unknown
 | Zero-length string | Unknown
 | Any text | Same text as entered is displayed


ODBC -- linked table definition has changed. (Error 3247)

 Copy code hover
[image]

ODBC -- linked table definition has changed. (Error 3247)
Send feedback

The definition or structure of a linked table changed since you created the link. Delete the link, and then relink the table.


Recordset2.EOF Property (DAO)

 Copy code hover
[image]

Recordset2.EOF Property (DAO)
Send feedback

Returns a value that indicates whether the current record position is after the last record in a Recordset object. Read-only Boolean.

Syntax

expression .EOF

expression A variable that represents a Recordset2 object.

Remarks

You can use the BOF and EOF properties to determine whether a Recordset object contains records or whether you've gone beyond the limits of a Recordset object when you move from record to record.

The location of the current record pointer determines the BOF and EOF return values.

If either the BOF or EOF property is True, there is no current record.

If you open a Recordset object containing no records, the BOF and EOF properties are set to True, and the Recordset object's RecordCount property setting is 0. When you open a Recordset object that contains at least one record, the first record is the current record and the BOF and EOF properties are False; they remain False until you move beyond the beginning or end of the Recordset object by using the MovePrevious or MoveNext method, respectively. When you move beyond the beginning or end of the Recordset, there is no current record or no record exists.

If you delete the last remaining record in the Recordset object, the BOF and EOF properties may remain False until you attempt to reposition the current record.

If you use the MoveLast method on a Recordset object containing records, the last record becomes the current record; if you then use the MoveNext method, the current record becomes invalid and the EOF property is set to True. Conversely, if you use the MoveFirst method on a Recordset object containing records, the first record becomes the current record; if you then use the MovePrevious method, there is no current record and the BOF property is set to True.

Typically, when you work with all the records in a Recordset object, your code will loop through the records by using the MoveNext method until the EOF property is set to True.

If you use the MoveNext method while the EOF property is set to True or the MovePrevious method while the BOF property is set to True, an error occurs.

This table shows which Move methods are allowed with different combinations of the BOF and EOF properties.

 | MoveFirst, MoveLast | MovePrevious, Move < 0 | Move 0 | MoveNext, Move > 0
BOF=True, EOF=False | Allowed | Error | Error | Allowed
BOF=False, EOF=True | Allowed | Allowed | Error | Error
Both True | Error | Error | Error | Error
Both False | Allowed | Allowed | Allowed | Allowed

Allowing a Move method doesn't mean that the method will successfully locate a record. It merely indicates that an attempt to perform the specified Move method is allowed and won't generate an error. The state of the BOF and EOF properties may change as a result of the attempted Move.

An OpenRecordset method internally invokes a MoveFirst method. Therefore, using an OpenRecordset method on an empty set of records sets the BOF and EOF properties to True. (See the following table for the behavior of a failed MoveFirst method.)

All Move methods that successfully locate a record will set both BOF and EOF to False.

In a Microsoft Access workspace, if you add a record to an empty Recordset, BOF will become False, but EOF will remain True, indicating that the current position is at the end of Recordset.

Any Delete method, even if it removes the only remaining record from a Recordset, won't change the setting of the BOF or EOF property.

The following table shows how Move methods that don't locate a record affect the BOF and EOF property settings.

 | BOF | EOF
MoveFirst, MoveLast | True | True
Move 0 | No change | No change
MovePrevious, Move < 0 | True | No change
MoveNext, Move > 0 | No change | True


Could not find a valid transport for this Synchronizer. (Error 3509)

 Copy code hover
[image]

Could not find a valid transport for this Synchronizer. (Error 3509)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


Field Methods (DAO)

 Copy code hover
[image]

Field Methods (DAO)
Send feedback

In this section

  • Field.AppendChunk Method (DAO)

  • Field.CreateProperty Method (DAO)

  • Field.GetChunk Method (DAO)


ToggleButton.BackThemeColorIndex Property (Access)

 Copy code hover
[image]

ToggleButton.BackThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackThemeColorIndex

expression A variable that represents a ToggleButton object.

Remarks

The BackThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BackThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Background Color to the Text 2 color by setting the BackThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BackThemeColorIndex=2

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Issuing Commands to the Underlying Data Provider

 Copy code hover
[image]

Issuing Commands to the Underlying Data Provider
Send feedback

Any command that does not begin with SHAPE is passed through to the data provider. This is equivalent to issuing a shape command in the form "SHAPE {provider command}". These commands do not have to produce a Recordset. For instance, "SHAPE {DROP TABLE MyTable} is a perfectly valid shape command, assuming the data provider supports DROP TABLE.

This capability allows both normal provider commands and shape commands to share the same connection and transaction.


NavigationButton.Shape Property (Access)

 Copy code hover
[image]

NavigationButton.Shape Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets the shape of the specifiednavigation button. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .Shape

expression A variable that represents a NavigationButton object.

Remarks

The Shape property uses the following settings.

Setting | Description
0 (Default) | Rectangle
1 | Rounded Rectangle
2 | Snip Single Corner Rectangle
3 | Snip Same Side Corner Rectangle
4 | Snip Diagonal Corner Rectangle
5 | Snip and Round Single Corner Rectangle
6 | Round Single Corner Rectangle
7 | Round Same Side Corner Rectangle
8 | Round Diagonal Corner Rectangle
9 | Oval

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Use Default Paper Size Property

 Copy code hover
[image]

Use Default Paper Size Property
Send feedback

Published: July 16, 2012

You can use the Use Default Paper Size property to specify whether or not the default paper size of the current printer is used when you print a form or report.

Setting

The Use Default Paper Size property uses the following settings.

Setting | Description
Yes | Use the default paper size of the current printer when printing the form or report.
No | (Default) Use the paper size specified when the form or report was designed when printing the form or report.

Remarks

By default, when you print a form or report, Access uses the paper size that was specified when the form or report was designed. This can cause problems when the form or report is printed on a printer that uses a different default paper size. For example, you might design a form or report while connected to a printer that has a default paper size of A4. An error might occur when you print the form or report on a printer that has a default paper size of Letter. Setting the Use Default Paper Size property to Yes prevents this problem from occurring.


TextBox.SpecialEffect Property (Access)

 Copy code hover
[image]

TextBox.SpecialEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.

Syntax

expression .SpecialEffect

expression A variable that represents a TextBox object.

Remarks

The SpecialEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | 0 | The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised | 1 | The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken | 2 | The object has a shadow on the top and left and a highlight on the bottom and right.
Etched | 3 | The object has a sunken line surrounding the control.
Shadowed | 4 | The object has a shadow below and to the right of the control.
Chiseled | 5 | The object has a sunken line below the control.

The SpecialEffect property setting affects related property settings for the BorderStyle , BorderColor , and BorderWidth properties. For example, if the SpecialEffect property is set to Raised, the settings for the BorderStyle, BorderColor, and BorderWidth properties are ignored. In addition, changing or setting the BorderStyle, BorderColor, and BorderWidth properties may cause Microsoft Access to change the SpecialEffect property setting to Flat.

Note Note

When you set the SpecialEffect property of a text box to Shadowed, the vertical height of the text display area is reduced. You can adjust the Height property of the text box to increase the size of the text display area.

Example

The following example sets the appearance of the text box "OrganizationName1" on the "Mailing List" form to raised.

VBA Copy code Copy code
Forms("Mailing List").Controls("OrganizationName1").SpecialEffect = 1

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Bound Object Frame Control

 Copy code hover
[image]

Bound Object Frame Control
Send feedback

Published: July 16, 2012

A bound object frame control displays a picture, chart, or any OLE object stored in a table in a Microsoft Access database. For example, if you store pictures of your employees in a table in Microsoft Access, you can use a bound object frame to display these pictures on a form or report.

Remarks

This control type allows you to create or edit the object from within the form or report by using the OLE server.

A bound object frame is bound to a field in an underlying table.

The field in the underlying table to which the bound object frame is bound must be of the OLE Object data type.

The object in a bound object frame is different for each record. The bound object frame can display linked or embedded objects. If you want to display objects not stored in an underlying table, use an unbound object frame or an image control .


Workspace.OpenConnection Method (DAO)

 Copy code hover
[image]

Workspace.OpenConnection Method (DAO)
Send feedback

Syntax

expression .OpenConnection(Name, Options, ReadOnly, Connect)

expression A variable that represents a Workspace object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Required | String | A string expression. See the discussion under Remarks.
Options | Optional | Variant | sets various options for the connection, as specified in Remarks. Based on this value, the ODBC driver manager prompts the user for connection information such as data source name (DSN), user name, and password.
ReadOnly | Optional | Variant | True if the connection is to be opened for read-only access and False if the connection is to be opened for read/write access (default).
Connect | Optional | Variant | An ODBC connection string. See the Connect property for the specific elements and syntax of this string. A prepended "ODBC;" is required.

Return Value

Connection

Remarks

Use the OpenConnection method to establish a connection to an ODBC data source from an ODBCDirect workspace. The OpenConnection method is similar but not equivalent to OpenDatabase. The main difference is that OpenConnection is available only in an ODBCDirect workspace.

If you specify a registered ODBC data source name (DSN) in the connect argument, then the name argument can be any valid string, and will also provide the Name property for the Connection object. If a valid DSN is not included in the connect argument, then name must refer to a valid ODBC DSN, which will also be the Name property. If neither name nor connect contains a valid DSN, the ODBC driver manager can be set (via the options argument) to prompt the user for the required connection information. The DSN supplied through the prompt then provides the Name property.

The options argument determines if and when to prompt the user to establish the connection, and whether or not to open the connection asynchronously. You can use one of the following constants.

Constant | Description
dbDriverNoPrompt | The ODBC Driver Manager uses the connection string provided in dbname and connect. If you don't provide sufficient information, a run-time error occurs.
dbDriverPrompt | The ODBC Driver Manager displays the ODBC Data Sources dialog box, which displays any relevant information supplied in dbname or connect. The connection string is made up of the DSN that the user selects via the dialog boxes, or, if the user doesn't specify a DSN, the default DSN is used.
dbDriverComplete | Default. If the connect argument includes all the necessary information to complete a connection, the ODBC Driver Manager uses the string in connect. Otherwise it behaves as it does when you specify dbDriverPrompt.
dbDriverCompleteRequired | This option behaves like dbDriverComplete except the ODBC driver disables the prompts for any information not required to complete the connection.
dbRunAsync | Execute the method asynchronously. This constant may be used with any of the other options constants.

OpenConnection returns a Connection object which contains information about the connection. The Connection object is similar to a Database object. The principal difference is that a Database object usually represents a database, although it can be used to represent a connection to an ODBC data source from a Microsoft Access workspace.

Example

This example uses the OpenConnection method with different parameters to open three different Connection objects.

VBA Copy code Copy code
Sub OpenConnectionX()

 Dim wrkODBC As Workspace
 Dim conPubs As Connection
 Dim conPubs2 As Connection
 Dim conPubs3 As Connection
 Dim conLoop As Connection

 ' Create ODBCDirect Workspace object.
 Set wrkODBC = CreateWorkspace("NewODBCWorkspace", _
 "admin", "", dbUseODBC)

 ' Open Connection object using supplied information in
 ' the connect string. If this information were
 ' insufficient, you could trap for an error rather than
 ' go to an ODBC Driver Manager dialog box.
 MsgBox "Opening Connection1..."

 ' Note: The DSN referenced below must be set to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conPubs = wrkODBC.OpenConnection("Connection1", _
 dbDriverNoPrompt, , _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 ' Open read-only Connection object based on information
 ' you enter in the ODBC Driver Manager dialog box.
 MsgBox "Opening Connection2..."
 Set conPubs2 = wrkODBC.OpenConnection("Connection2", _
 dbDriverPrompt, True, "ODBC;DSN=Publishers;")

 ' Open read-only Connection object by entering only the
 ' missing information in the ODBC Driver Manager dialog
 ' box.
 MsgBox "Opening Connection3..."
 Set conPubs3 = wrkODBC.OpenConnection("Connection3", _
 dbDriverCompleteRequired, True, _
 "ODBC;DATABASE=pubs;DSN=Publishers;")

 ' Enumerate the Connections collection.
 For Each conLoop In wrkODBC.Connections
 Debug.Print "Connection properties for " & _
 conLoop.Name & ":"

 With conLoop
 ' Print property values by explicitly calling each
 ' Property object; the Connection object does not
 ' support a Properties collection.
 Debug.Print " Connect = " & .Connect
 ' Property actually returns a Database object.
 Debug.Print " Database[.Name] = " & _
 .Database.Name
 Debug.Print " Name = " & .Name
 Debug.Print " QueryTimeout = " & .QueryTimeout
 Debug.Print " RecordsAffected = " & _
 .RecordsAffected
 Debug.Print " StillExecuting = " & _
 .StillExecuting
 Debug.Print " Transactions = " & .Transactions
 Debug.Print " Updatable = " & .Updatable
 End With

 Next conLoop

 conPubs.Close
 conPubs2.Close
 conPubs3.Close
 wrkODBC.Close

End Sub

This example demonstrates the Connection object and Connections collection by opening a Microsoft Access Database object and two ODBCDirect Connection objects and listing the properties available to each object.

VBA Copy code Copy code
Sub ConnectionObjectX()

 Dim wrkAcc as Workspace
 Dim dbsNorthwind As Database
 Dim wrkODBC As Workspace
 Dim conPubs As Connection
 Dim conPubs2 As Connection
 Dim conLoop As Connection
 Dim prpLoop As Property

 ' Open Microsoft Access Database object.
 Set wrkAcc = CreateWorkspace("NewWorkspace", _
 "admin", "", dbUseJet)
 Set dbsNorthwind = wrkAcc.OpenDatabase("Northwind.mdb")

 ' Create ODBCDirect Workspace object and open Connection
 ' objects.
 Set wrkODBC = CreateWorkspace("NewODBCWorkspace", _
 "admin", "", dbUseODBC)

 ' Note: The DSNs referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conPubs = wrkODBC.OpenConnection("Connection1", , , _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 Set conPubs2 = wrkODBC.OpenConnection("Connection2", , _
 True, "ODBC;DATABASE=pubs;DSN=Publishers")

 Debug.Print "Database properties:"

 With dbsNorthwind
 ' Enumerate Properties collection of Database object.
 For Each prpLoop In .Properties
 On Error Resume Next
 Debug.Print " " & prpLoop.Name & " = " & _
 prpLoop.Value
 On Error GoTo 0
 Next prpLoop
 End With

 ' Enumerate the Connections collection.
 For Each conLoop In wrkODBC.Connections
 Debug.Print "Connection properties for " & _
 conLoop.Name & ":"

 With conLoop
 ' Print property values by explicitly calling each
 ' Property object; the Connection object does not
 ' support a Properties collection.
 Debug.Print " Connect = " & .Connect
 ' Property actually returns a Database object.
 Debug.Print " Database[.Name] = " & _
 .Database.Name
 Debug.Print " Name = " & .Name
 Debug.Print " QueryTimeout = " & .QueryTimeout
 Debug.Print " RecordsAffected = " & _
 .RecordsAffected
 Debug.Print " StillExecuting = " & _
 .StillExecuting
 Debug.Print " Transactions = " & .Transactions
 Debug.Print " Updatable = " & .Updatable
 End With

 Next conLoop

 dbsNorthwind.Close
 conPubs.Close
 conPubs2.Close
 wrkAcc.Close
 wrkODBC.Close

End Sub


Visual Basic

 Copy code hover
[image]

Visual Basic
Send feedback

In order to handle ADO events in Microsoft Visual Basic, you must declare a module-level variable using the WithEvents keyword. The variable can be declared only as part of a class module and must be declared at the module level. This is not as restrictive as it seems, however, because Visual Basic Form objects are also classes. The simplest way to handle ADO events is to declare a variable using WithEvents. The following example handles the ConnectComplete event for a Connection object:

Copy code Copy code

' BeginEventExampleVB02
Dim WithEvents connEvent As Connection
Attribute connEvent.VB_VarHelpID = -1
Dim strMsg As String

Private Sub Form_Load()
 On Error GoTo ErrHandler:

 Dim strConn As String

 ' Create a new object with event
 ' handling enabled.
 strConn = "Provider='sqloledb';" & _
 "Data Source='MySqlServer';" & _
 "Initial Catalog='Northwind';" & _
 "Integrated Security='SSPI';"
 Set connEvent = New ADODB.Connection
 connEvent.Open strConn

 Exit Sub

ErrHandler:
 MsgBox strMsg
End Sub

Private Sub connEvent_ConnectComplete(ByVal pError As ADODB.Error, _
 adStatus As ADODB.EventStatusEnum, _
 ByVal pConnection As ADODB.Connection)

 If adStatus = adStatusErrorsOccurred Then
 If Not pError Is Nothing Then
 Select Case pError.Number
 Case adErrOperationCancelled
 ' The operation was cancelled in the
 ' Will event. Notify the user and exit.
 strMsg = "I'm sorry you can't connect right now." & vbCrLf
 strMsg = strMsg & " Click OK to exit."
 Unload Me
 Case Else
 strMsg = "Error " & Format(pError.Number) & vbCrLf
 strMsg = strMsg & pError.Description
 strMsg = strMsg & " Click OK to exit."
 Unload Me
 End Select
 Else
 strMsg = "Error occured. Click OK to exit."
 Unload Me
 End If
 End If
 'frmWait.btnOK.Enabled = True
End Sub
' EndEventExampleVB02

The Connection object is declared at the Form level using the WithEvents keyword to enable event handling. The Form_Load event handler actually creates the object by assigning a new Connection object to connEvent and then opens the connection. Of course, a real application would do more processing in the Form_Load event handler than is shown here.


TableDefs Methods (DAO)

 Copy code hover
[image]

TableDefs Methods (DAO)
Send feedback

In this section

  • TableDefs.Append Method (DAO)

  • TableDefs.Delete Method (DAO)

  • TableDefs.Refresh Method (DAO)


Page.Top Property (Access)

 Copy code hover
[image]

Page.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Syntax

expression .Top

expression A variable that represents a Page object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

Page Object

Other resources

Page Object Members


Entity Properties (Access)

 Copy code hover
[image]

Entity Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Operations | Gets the collection of operations defined for the specified Entity. Read-only Operations.
Parent | Returns the parent object for the specified object. Read-only.


AdditionalData.Count Property (Access)

 Copy code hover
[image]

AdditionalData.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents an AdditionalData object.

See also

Concepts

AdditionalData Object

Other resources

AdditionalData Object Members


Attachment.StatusBarText Property (Access)

 Copy code hover
[image]

Attachment.StatusBarText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .StatusBarText

expression A variable that represents an Attachment object.

Remarks

The StatusBarText property applies only to controls on a form, not controls on a report.

You set the StatusBarText property by using a string expression up to 255 characters long.

Note Note

The length of the text you can display in the status bar depends on your computer hardware and video display.

You can use the StatusBarText property to provide specific information about a control. For example, when a text box has the focus, a brief instruction can tell the user what kind of data to enter.

Note Note

You can also use the ControlTipText property to display a ScreenTip for a control.

If you create a control by dragging a field from the field list, the value in a field's Description property is copied to the StatusBarText property.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Recordset.BatchCollisionCount Property (DAO)

 Copy code hover
[image]

Recordset.BatchCollisionCount Property (DAO)
Send feedback

Syntax

expression .BatchCollisionCount

expression A variable that represents a Recordset object.

Remarks

This property indicates how many records encountered collisions or otherwise failed to update during the last batch update attempt. The value of this property corresponds to the number of bookmarks in the BatchCollisions property.

If you set the working Recordset object's Bookmark property to bookmark values in the BatchCollisions array, you can move to each record that failed to complete the most recent batch Update operation.

After the collision records are corrected, a batch-mode Update method can be called again. At this point DAO attempts another batch update, and the BatchCollisions property again reflects the set of records that failed the second attempt. Any records that succeeded in the previous attempt are not sent in the current attempt, because they now have a RecordStatus property of dbRecordUnmodified. This process can continue as long as collisions occur, or until you abandon the updates and close the result set.

Example

This example uses the BatchCollisionCount property and the Update method to demonstrate batch updating where any collisions are resolved by forcing the batch update.

Copy code Copy code
Sub BatchX()

 Dim wrkMain As Workspace
 Dim conMain As Connection
 Dim rstTemp As Recordset
 Dim intLoop As Integer
 Dim strPrompt As String

 Set wrkMain = CreateWorkspace("ODBCWorkspace", _
 "admin", "", dbUseODBC)
 ' This DefaultCursorDriver setting is required for
 ' batch updating.
 wrkMain.DefaultCursorDriver = dbUseClientBatchCursor

 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conMain = wrkMain.OpenConnection("Publishers", _
 dbDriverNoPrompt, False, _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 ' The following locking argument is required for
 ' batch updating. It is also required that a table
 ' with a primary key is used.
 Set rstTemp = conMain.OpenRecordset( _
 "SELECT * FROM roysched", dbOpenDynaset, 0, _
 dbOptimisticBatch)

 With rstTemp
 ' Modify data in local recordset.
 Do While Not .EOF
 .Edit
 If !royalty <= 20 Then
 !royalty = !royalty - 4
 Else
 !royalty = !royalty + 2
 End If
 .Update
 .MoveNext
 Loop

 ' Attempt a batch update.
 .Update dbUpdateBatch

 ' If there are collisions, give the user the option
 ' of forcing the changes or resolving them
 ' individually.
 If .BatchCollisionCount > 0 Then
 strPrompt = "There are collisions. " & vbCr & _
 "Do you want the program to force " & _
 vbCr & "an update using the local data?"
 If MsgBox(strPrompt, vbYesNo) = vbYes Then _
 .Update dbUpdateBatch, True
 End If

 .Close
 End With

 conMain.Close
 wrkMain.Close

End Sub


CodeProject Properties (Access)

 Copy code hover
[image]

CodeProject Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
AccessConnection | You can use the AccessConnection property to return a reference to the current Microsoft ActiveX Data Objects (ADO) Connection object and its related properties. Read-only Connection.
AllForms | You can use the AllForms property to reference the AllForms collection and its related properties. Read-only AllForms object.
AllMacros | You can use the AllMacros property to reference the AllMacros collection and its related properties. Read-only AllMacros object.
AllModules | You can use the AllModules property to reference the AllModules collection and its related properties. Read-only AllModules object.
AllReports | You can use the AllReports property to reference the AllReports collection and its related properties. Read-only AllReports object.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BaseConnectionString | You can use the BaseConnectionString property to return the base connection string for the specified object. Read-only String.
Connection | You can use the Connection property to return a reference to the current ActiveX Data Objects (ADO) Connection object and its related properties. Read-only Connection.
FileFormat | Returns an AcFileFormat constant indicating the Microsoft Access version format of the specified project. Read-only.
FullName | Sets or returns the full path (including file name) of a specific object. Read-only String.
ImportExportSpecifications | Returns a ImportExportSpecifications collection that represents the collection of saved import or export operations for the specified object. Read-only.
IsConnected | You can use the IsConnected property to determine if the CodeProject object is currently connected. Read-only Boolean.
IsTrusted | Gets whether or not macros and Visual Basic for Applications (VBA) code have been enabled in the current project. Read-only Boolean.
IsWeb | Gets whether the database is a Web database. Read-only Boolean.
Name | You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.
Parent | Returns the parent object for the specified object. Read-only.
Path | You can use the Path property to determine the location where data is stored for a Microsoft Access project (.adp) or Microsoft Access database. Read-only String.
ProjectType | You can use the ProjectType property to determine the type of project that is currently open. Read-only AcProjectType.
Properties | Returns a reference to a CodeProject object's AccessObjectProperties collection. Read-only.
RemovePersonalInformation | Returns or sets a Boolean indicating whether personal information about the user is stored in the specified project. True if personal information is removed. Read-write.
Resources | Gets the SharedResources collection for the specified object. Read-only SharedResources.
WebSite | Gets the Uniform Resource Locator (URL) of the Web site to which the database has been published. Read-only String.


Report.PaletteSource Property (Access)

 Copy code hover
[image]

Report.PaletteSource Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PaletteSource property to specify the palette for a report. Read/write String.

Syntax

expression .PaletteSource

expression A variable that represents a Report object.

Remarks

Enter the path and file name of one of the following file types:

  • .dib (device-independent bitmap file)

  • .pal (Windows palette file)

  • .ico (Windows icon file)

  • .bmp (Windows bitmap file)

  • .wmf or .emf file, or other graphics file for which you have a graphics filter

The default setting is (Default), which specifies the palette included with Microsoft Access. If you change this setting by entering a path and file name, the property setting displays (Custom).

For a report, you can set the PaletteSource property only in report Design view. The property setting is unavailable in other views.

Windows can have only one color palette active at a time. Microsoft Access allows you to have multiple graphics on a form, each using a different color palette. The PaletteSource and PaintPalette properties let you specify which color palette a form uses when displaying graphics.

When you set the PaletteSource property for a form or report, Microsoft Access automatically updates its PaintPalette property. Conversely, when you set a form's or report's PaintPalette property, the PaletteSource property is also updated. For example, when you specify a custom palette with the PaintPalette property, the PaletteSource property setting changes to (Custom). The PaintPalette property (which is available only in a macro or Visual Basic) is used to set the palette for the form or report. The PaletteSource property gives you a way to set the palette for the form or report in the property sheet by using an existing graphics file.

Example

The following example sets the PaintPalette property of the Seascape form to the ObjectPalette property of the Ocean control on the DisplayPictures form. (Ocean can be a bound object frame, command button, chart, toggle button, or unbound object frame.)

VBA Copy code Copy code
Forms!Seascape.PaintPalette = _
 Forms!DisplayPictures!Ocean.ObjectPalette

The ObjectPalette and PaintPalette properties are useful for programmatically altering the color palette in use by an open form at run time. A common use of these properties is to set the current form's PaintPalette property to the palette of a graphic displayed in a control that has the focus.

For example, you can have a form with an ocean picture, showing many shades of blue, and a sunset picture, showing many shades of red. Since Windows only allows one color palette active at a time, one picture will look much better than the other. The following example uses a control's Enter event for setting the form's PaintPalette property to the control's ObjectPalette property so the graphic that has the focus will have an optimal appearance.

VBA Copy code Copy code
Sub OceanPicture_Enter()
 Me.PaintPalette = Me!OceanPicture.ObjectPalette
End Sub

Sub SunsetPicture_Enter()
 Me.PaintPalette = Me!SunsetPicture.ObjectPalette
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


BETWEEN (Access 2013 custom web app)

 Copy code hover
[image]

BETWEEN (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Specifies a range to test.

Syntax

test_expression [ NOT ] BETWEEN begin_expression AND end_expression

The Between operator contains the following arguments.

Argument | Required | Description
test_expression | Yes | The expression to test for in the range defined by begin_expression and end_expression. Must be the same data type as both begin_expression and end_expression.
NOT | No | Specifies that the result of the predicate be negated.
begin_expression | Yes | A valid expression. Must be the same data type as both test_expression and end_expression.
end_expression | Yes | A valid expression. Must be the same data type as both test_expression and begin_expression.
AND | Yes | Indicates test_expression should be within the range indicated by begin_expression and end_expression.

Result Type

Boolean

Remarks

BETWEEN returns TRUE if the value of test_expression is greater than or equal to the value of begin_expression and less than or equal to the value of end_expression.

NOT BETWEEN returns TRUE if the value of test_expression is less than the value of begin_expression or greater than the value of end_expression.

To specify an exclusive range, use the greater than (>) and less than operators (<).


Handler Property Example (VC++)

 Copy code hover
[image]

Handler Property Example (VC++)
Send feedback

This example demonstrates the RDS DataControl object Handler property. (See DataFactory Customization for more details.)

Assume the following sections in the parameter file, Msdfmap.ini, located on the server:

Copy code Copy code

[connect AuthorDataBase]
Access=ReadWrite
Connect="DSN=Pubs"
[sql AuthorById]
SQL="SELECT * FROM Authors WHERE au_id = ?"

Your code looks like the following. The command assigned to the SQL property will match the AuthorById identifier and will retrieve a row for author Michael O'Leary. Although the Connect property in your code specifies the Northwind data source, that data source will be overwritten by the Msdfmap.ini connect section. The DataControl object Recordset property is assigned to a disconnected Recordset object purely as a coding convenience.

Copy code Copy code
// BeginHandlerCpp#import "c:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")#import "C:\Program Files\Common Files\System\MSADC\msadco.dll"
#include <ole2.h>#include <stdio.h>
#include <conio.h>// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};void HandlerX(void);
void PrintProviderError(_ConnectionPtr pConnection);void PrintComError(_com_error &e);
//////////////////////////////////////////////////////////// //
// Main Function //// //
//////////////////////////////////////////////////////////void main()
{HRESULT hr = S_OK;
hr = ::CoInitialize(NULL);if (SUCCEEDED(hr))
{HandlerX();
printf("Press any key to continue...");getch();
::CoUninitialize();}
}//////////////////////////////////////////////////////////
// //// HandlerX Function //
// ////////////////////////////////////////////////////////////
void HandlerX(void){
HRESULT hr = S_OK;// Define ADO object pointers.
// Initialize pointers on define.// These are in the ADODB:: namespace.
_RecordsetPtr pRst = NULL;//Define RDS object pointers.
RDS::IBindMgrPtr dc;try
{TESTHR(hr = dc.CreateInstance(__uuidof(RDS::DataControl)));
dc->Handler = "MSDFMAP.Handler";dc->Server = "http://MyServer";
dc->Connect = "Data Source=AuthorDatabase";dc->SQL = "AuthorById('267-41-2394')";
// Retrieve the record.dc->Refresh();
// Use another Recordset as a convenience.pRst = dc->GetRecordset();
printf("Author is %s %s",(LPSTR) (_bstr_t) pRst->Fields->GetItem("au_fname")->Value,\(LPSTR) (_bstr_t) pRst->Fields->GetItem("au_lname")->Value);
pRst->Close();} // End Try statement.
catch (_com_error &e){
PrintProviderError(pRst->GetActiveConnection());PrintComError(e);
}}
//////////////////////////////////////////////////////////// //
// PrintProviderError Function //// //
//////////////////////////////////////////////////////////void PrintProviderError(_ConnectionPtr pConnection)
{// Print Provider Errors from Connection object.
// pErr is a record object in the Connection's Error collection.ErrorPtr pErr = NULL;
long nCount = 0;long i = 0;
if( (pConnection->Errors->Count) > 0){
nCount = pConnection->Errors->Count;// Collection ranges from 0 to nCount -1.
for(i = 0; i < nCount; i++){
pErr = pConnection->Errors->GetItem(i);printf("\t Error number: %x\t%s", pErr->Number, pErr->Description);
}}
}//////////////////////////////////////////////////////////
//// PrintComError Function //
// ////////////////////////////////////////////////////////////
void PrintComError(_com_error &e){
_bstr_t bstrSource(e.Source());_bstr_t bstrDescription(e.Description());
// Print Com errors.printf("Error\n");
printf("\tCode = %08lx\n", e.Error());printf("\tCode meaning = %s\n", e.ErrorMessage());
printf("\tSource = %s\n", (LPCSTR) bstrSource);printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}// EndHandlerCpp


CreateRecord Data Block (Access 2013 custom web app)

 Copy code hover
[image]

CreateRecord Data Block (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

You can use the CreateRecord data block to create a new record in the specified table.

Note Note

The CreateRecord data block is available only in Data Macros.

Setting

The CreateRecord data block has the following arguments.

The CreateRecord data block has the following arguments.

Argument name | Required | Description
Create a Record In | Yes | The name of the table to create the new record in.
Alias | No | A string that identifies the record. You can use the record's alias to identify

Remarks

The record created by CreateRecord automatically becomes the current record.

After CreateRecord statement, you can insert a block of commands that will execute before the new record is committed. The following actions are available in a CreateRecord data block.

CancelRecordChange Macro Action

Comment Macro Statement

Group Macro Statement

If...Then...Else Macro Statement

SetField Macro Action

SetLocalVar Macro Action

After the CreateRecord action creates a record, use the SetField action to specify a value of a field in the new record.

You can use an If...Then...Else statement to perform operations based on a condition.

To cancel the creation of a record, use the CancelRecordChange action. This prevents the changes from being committed and exits the CreateRecord data block.

Once the new record is committed, you can use the LastCreateRecordIdentity local variable to work with the record. For example, use the following syntax to refer to the AssignedTo field of the most recently created record.

Copy code Copy code
[LastCreateRecordIdentity].[AssignedTo]


ImportExportSpecifications Object (Access)

 Copy code hover
[image]

ImportExportSpecifications Object (Access)
See also Send feedback

Published: July 16, 2012

Represents the collection of available ImportExportSpecification objects.

Version Information

Version Added: Access 2007

Remarks

Use the Add method to create a new ImportExportSpecification object.

Use the ImportExportSpecification property of the CodeProject or CurrentProject object to return the ImportExportSpecifications collection.

See also

Concepts

Access Object Model Reference

Other resources

ImportExportSpecifications Object Members


Operators (Access 2013 custom web app)

 Copy code hover
[image]

Operators (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • Arithmetic Operators (Access 2013 custom web app)

  • Comparison Operators (Access 2013 custom web app)

  • Logical Operators (Access 2013 custom web app)

  • String Operators (Access 2013 custom web app)


What is a Lock?

 Copy code hover
[image]

What is a Lock?
Send feedback

Locking is the process by which a DBMS restricts access to a row in a multi-user environment. When a row or column is exclusively locked, other users are not permitted to access the locked data until the lock is released. This ensures that two users cannot simultaneously update the same column in a row.

Locks can be very expensive from a resource perspective and should be used only when required to preserve data integrity. In a database where hundreds or thousands of users could be trying to access a record every second — such as a database connected to the Internet — unnecessary locking could quickly result in slower performance in your application.

You can control how the data source and the ADO cursor library manage concurrency by choosing the appropriate locking option.

Set the LockType property before opening a Recordset to specify what type of locking the provider should use when opening it. Read the property to return the type of locking in use on an open Recordset object.

Providers might not support all lock types. If a provider cannot support the requested LockType setting, it will substitute another type of locking. To determine the actual locking functionality available in a Recordset object, use the Supports method with adUpdate and adUpdateBatch.

The adLockPessimistic setting is not supported if the CursorLocation property is set to adUseClient. If an unsupported value is set, no error will result; the closest supported LockType will be used instead.

The LockType property is read/write when the Recordset is closed, and read-only when it is open.


NavigationControl.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

NavigationControl.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents a NavigationControl object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.BorderThemeColorIndex=2

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Parse Function (Access 2013 custom web app)

 Copy code hover
[image]

Parse Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Parses a text value and returns its value in a given type using the culture of the application.

Syntax

Parse(TextExpression, DataType )

The Parse function contains the following arguments.

Argument name | Description
TextExpression | A text expression representing the formatted value to parse into the specified data type.
DataType | Literal value representing the data type requested for the result.

Remarks

Use Parse only for converting from string to date/time and number types. For general type conversions, use the Convert function. Keep in mind that there is a certain performance overhead in parsing the string value.


TextBox.Tag Property (Access)

 Copy code hover
[image]

TextBox.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents a TextBox object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ComboBox.HorizontalAnchor Property (Access)

 Copy code hover
[image]

ComboBox.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the combo box is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .HorizontalAnchor

expression A variable that represents a ComboBox object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


OptionGroup.BackThemeColorIndex Property (Access)

 Copy code hover
[image]

OptionGroup.BackThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackThemeColorIndex

expression A variable that represents an OptionGroup object.

Remarks

The BackThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BackThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Background Color to the Text 2 color by setting the BackThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BackThemeColorIndex=2

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Attachment.AfterUpdate Event (Access)

 Copy code hover
[image]

Attachment.AfterUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .AfterUpdate

expression An expression that returns an Attachment object.

Remarks

The AfterUpdate event applies only to controls on a form, not controls on a report.

To run a macro or event procedure when this event occurs, set the AfterUpdate property to the name of the macro or to [Event Procedure].

The AfterUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB.

AfterUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. AfterUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


AllModules.Item Property (Access)

 Copy code hover
[image]

AllModules.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.

Syntax

expression .Item(var)

expression A variable that represents an AllModules object.

Parameters

Name | Required/Optional | Data Type | Description
var | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

AllModules Collection

Other resources

AllModules Object Members


CommandButton Members (Access)

 Copy code hover
[image]

CommandButton Members (Access)
Send feedback

Published: July 16, 2012

This object corresponds to a command button. A command button on a form can start an action or a set of actions. For example, you could create a command button that opens another form. To make a command button do something, you write a macro or event procedure and attach it to the button's OnClick property.

Events

Name | Description
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
Alignment | Gets or sets how the specified button's caption and picture are aligned. Read/write Byte.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
AutoRepeat | You can use the AutoRepeat property to specify whether an event procedure or macro runs repeatedly while a command button on a form remains pressed in. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
Bevel | Gets or sets the bevel effect applied to the specified object. Read/write Long.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the button and its bottom gridline. Read/write Integer.
Cancel | You can use the Cancel property to specify whether a command button is also the Cancel button on a form. Read/write Boolean.
Caption | Gets or sets the text that appears in the control. Read/write String.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
CursorOnHover | Gets or sets the type of mouse cursor displayed when the user rests the pointer on a button. Read/write AcCursorOnHover.
Default | You can use the Default property to specify whether a command button is the default button on a form. Read/write Boolean.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontName | You can use the FontName property to specify the font for text in the following situations:
FontSize | You can use the FontSize property to specify the point size for text in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
FontWeight | You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
ForeShade | Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
ForeThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.
ForeTint | Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
Glow | Gets or sets the Glow effect applied to the specified object. Read/write Long.
Gradient | Gets or sets the gradient fill applied to the specified object. Read/write Long.
GridlineColor | Gets or sets the color of the gridline for the specified command button. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified button. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified button. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified button. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified button. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified button. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified button. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified button. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified button. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the button is anchored horizontally within its layout. Read/write.
HoverColor | Gets or sets the color displayed on the control when the user rests the mouse cursor over it. Read/write Long.
HoverForeColor | Gets or sets the color of the text displayed on the control when the user rests the mouse cursor over it. Read/write Long.
HoverForeShade | Gets or sets the shade applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.
HoverForeThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverForeColor property of the specified object. Read/write Long.
HoverForeTint | Gets or sets the tint applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.
HoverShade | Gets or sets the shade that is applied to the theme color in the HoverColor property of the specified object. Read/write Single.
HoverThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverColor property of the specified object. Read/write Long.
HoverTint | Gets or sets the tint applied to the theme color in the HoverColor property of the specified object. Read/write Single.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
HyperlinkAddress | You can use the HyperlinkAddress property to specify or determine the path to an object, document, Web page or other destination for a hyperlink associated with a the specified control. Read/write String.
HyperlinkSubAddress | You can use the HyperlinkSubAddress property to specify or determine a location within the target document specified by the HyperlinkAddress property. Read/write String.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified button. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified button. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the button and its left gridline. Read/write Integer.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
ObjectPalette | The ObjectPalette property specifies the palette in the application used to create A bitmap or other graphic that is loaded into the specified control by using the Picture property. Read/write Variant.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnPush | Sets or returns the value of the On Click box in the Properties window of a command button. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Picture | You can use the Picture property to specify a bitmap or other type of graphic to be displayed on the specified control. Read/write String.
PictureCaptionArrangement | Gets or sets how the specified button's caption is arranged in relation to its picture. Read/write AcPictureCaptionArrangement.
PictureData | You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.
PictureType | You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.
PressedColor | Gets or sets the color displayed on the control when the user clicks it. Read/write Long.
PressedForeColor | Gets or sets the color of the text displayed on the control when the user clicks it. Read/write Long.
PressedForeShade | Gets or sets the shade applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.
PressedForeThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedForeColor property of the specified object. Read/write Long.
PressedForeTint | Gets or sets the tint applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.
PressedShade | Gets or sets the shade that is applied to the theme color in the PressedColor property of the specified object. Read/write Single.
PressedThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedColor property of the specified object. Read/write Long.
PressedTint | Gets or sets the tint applied to the theme color in the PressedColor property of the specified object. Read/write Single.
Properties | Returns a reference to a control's Properties collection object. Read-only.
QuickStyle | Gets or sets the Quick Style that is applied to the specified object. Read/write Long.
QuickStyleMask | Gets or sets modifications to the Quick Style that is applied to the specified object. Read/write Long.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
RightPadding | Gets or sets the amount of space (in inches) between the button and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
Shadow | Gets or sets the Shadow effect applied to the specified object. Read/write Long.
Shape | Returns or sets the shape of the specified button. Read/write Long.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SoftEdges | Gets or sets the Soft Edges effect applied to the specified object. Read/write Long.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
ThemeFontIndex | Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the button and its top gridline. Read/write Integer.
Transparent | You can use the Transparent property to specify whether a command button is solid or transparent. Read/write Boolean.
UseTheme | Gets or sets whether the specified object will utilize formatting styles defined in Office Document Themes. Read/write Boolean.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified button is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


ORDER BY Clause (Microsoft Access SQL)

 Copy code hover
[image]

ORDER BY Clause (Microsoft Access SQL)
Send feedback

Published: July 16, 2012

Sorts a query's resulting records on a specified field or fields in ascending or descending order.

Syntax

SELECT fieldlist FROM table WHERE selectcriteria [ORDER BY field1 [ASC | DESC ][, field2 [ASC | DESC ]][, …]]]

A SELECT statement containing an ORDER BY clause has these parts:

Part | Description
fieldlist | The name of the field or fields to be retrieved along with any field-name aliases, SQL aggregate functions, selection predicates (ALL, DISTINCT, DISTINCTROW, or TOP), or other SELECT statement options.
table | The name of the table from which records are retrieved. For more information, see the FROM clause.
selectcriteria | Selection criteria. If the statement includes a WHERE clause, the Microsoft Access database engine orders values after applying the WHERE conditions to the records.
field1, field2 | The names of the fields on which to sort records.

Remarks

ORDER BY is optional. However, if you want your data displayed in sorted order, then you must use ORDER BY.

The default sort order is ascending (A to Z, 0 to 9). Both of the following examples sort employee names in last name order:

SQL Copy code Copy code
SELECT LastName, FirstName
FROM Employees
ORDER BY LastName;
SELECT LastName, FirstName
FROM Employees
ORDER BY LastName ASC;

To sort in descending order (Z to A, 9 to 0), add the DESC reserved word to the end of each field you want to sort in descending order. The following example selects salaries and sorts them in descending order:

SQL Copy code Copy code
SELECT LastName, Salary
FROM Employees
ORDER BY Salary DESC, LastName;

If you specify a field containing Memo or OLE Object data in the ORDER BY clause, an error occurs. The Microsoft Jet database engine does not sort on fields of these types.

ORDER BY is usually the last item in an SQL statement.

You can include additional fields in the ORDER BY clause. Records are sorted first by the first field listed after ORDER BY. Records that have equal values in that field are then sorted by the value in the second field listed, and so on.

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Record Order

Example

The SQL statement shown in the following example uses the ORDER BY clause to sort records by last name in descending order (Z-A).

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

VBA Copy code Copy code
Sub OrderByX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Select the last name and first name values from
    ' the Employees table, and sort them in descending
    ' order.
    Set rst = dbs.OpenRecordset("SELECT LastName, " _
        & "FirstName FROM Employees " _
        & "ORDER BY LastName DESC;")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print recordset contents.
    EnumFields rst, 12

    dbs.Close

End Sub

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.


AccessObject.FullName Property (Access)

 Copy code hover
[image]

AccessObject.FullName Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the full path (including file name) of a specific object. Read/write String.

Syntax

expression .FullName

expression A variable that represents an AccessObject object.

See also

Concepts

AccessObject Object

Other resources

AccessObject Object Members


AllModules.Application Property (Access)

 Copy code hover
[image]

AllModules.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents an AllModules object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

AllModules Collection

Other resources

AllModules Object Members


TabControl.ForeTint Property (Access)

 Copy code hover
[image]

TabControl.ForeTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .ForeTint

expression A variable that represents a TabControl object.

Remarks

The ForeTint property contains a numeric expression that can be used to lighten the theme color in the ForeColor property. The default value of the ForeTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens ForeColor by 75%.

VBA Copy code Copy code
Me.ctl.ForeTint=25

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


How to: Apply a Custom Ribbon When Starting Access

 Copy code hover
[image]

How to: Apply a Custom Ribbon When Starting Access
Send feedback

The ribbon uses text-based, declarative XML markup that simplifies creating and customizing the ribbon. With a few lines of XML, you can create just the right interface for the user. Access provides tremendous flexibility in customizing the ribbon UI. For example, customization markup can be stored in a table, embedded in a VBA procedure, stored in another Access database, or linked to from an Excel worksheet. This topic describes how to apply customized ribbons when opening a database.

Making the Ribbon Customization XML Available

Storing Ribbon Extensibility XML in a Table

One method that you can use to make ribbon customizations available is to store them in a table. If you store the customizations in a table named USysRibbons, the customizations can be implemented without using macros or VBA code.

USysRibbons is a user-created system table. The table must be created using specific column names in order for the ribbon customizations to be implemented. The following table lists the settings to use when creating the USysRibbons table.

Column Name | Data Type | Description
RibbonName | Text | Contains the name of the custom ribbon to be associated with this customization.
RibbonXML | Memo | Contains the Ribbon Extensibility XML (RibbonX) that defines the ribbon customization.

Loading Ribbon Extensibility XML Programmatically

You can use the LoadCustomUI method to load ribbon customizations programmatically. Typically, to create and make the ribbon available to the application, you first create a module in the database with a procedure that calls the LoadCustomUI method, passing in the name of the ribbon and the XML customization markup.

The XML markup can come from a Recordset object created from a table, from a source external to the database such as an XML file that you parse into a string, or from XML markup embedded directly inside the procedure. You can make different ribbons using multiple calls to the LoadCustomUI method, passing in different XML markup as long as the name of each ribbon and the id attribute of the tabs that make up the ribbon are unique.

After the procedure is complete, you then create an AutoExec macro that calls the procedure by using the RunCode action. That way, when the application is started, the LoadCustomUI method is automatically executed and all of the custom ribbons are made available to the application.

Applying Customized Ribbons When Access Starts

To apply a custom UI so that it is available when the application starts, use the following procedure:

  1. Follow the process described previously to make the customized ribbons available to the application.

  2. Close and then restart the application.

  3. Click the Microsoft Office Button [image] and then click Access Options.

  4. Click the Current Database option and then, in the Ribbon and Toolbar Options section, click the Ribbon Name list and select a ribbon.

  5. Now close and restart the application. The UI you selected is displayed.

Note Note

For more information about the ribbon UI in other Office applications, see Overview of the Office Fluent Ribbon.


TabControl.HoverThemeColorIndex Property (Access)

 Copy code hover
[image]

TabControl.HoverThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HoverThemeColorIndex

expression A variable that represents a TabControl object.

Remarks

The HoverThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 (Default) | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the HoverThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


CustomControl.Controls Property (Access)

 Copy code hover
[image]

CustomControl.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Syntax

expression .Controls

expression A variable that represents a CustomControl object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


ComboBox.ItemData Property (Access)

 Copy code hover
[image]

ComboBox.ItemData Property (Access)
See also Send feedback

Published: July 16, 2012

The ItemData property returns the data in the bound column for the specified row in a combo box. Read-only Variant.

Syntax

expression .ItemData(Index)

expression A variable that represents a ComboBox object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Long | The row in the combo box or list box containing the data you want to return. Rows in combo and list boxes are indexed starting with zero. For example, to return the item in the sixth row of a combo box, you'd specify 5 for the rowindex argument.

Remarks

The ItemData property enables you to iterate through the list of entries in a combo box or list box. For example, suppose you wanted to iterate through all of the items in a list box to search for a particular entry. You can use the ListCount property to determine the number of rows in the list box, and then use the ItemData property to return the data for the bound column in each row.

You can also use the ItemData property to return data only from selected rows in a list box. You can iterate through the ItemsSelected collection to determine which row or rows in the list box have been selected, and use the ItemData property to return the data in those rows. You must set the MultiSelect property of the list box to Simple or Extended to enable the user to select more than one row at a time.

You can use the Column property to return data from a specified row and column, even if the specified column isn't the bound column.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Attachment.SizeToFit Method (Access)

 Copy code hover
[image]

Attachment.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Version Information

Version Added: Access 2007

Syntax

expression .SizeToFit

expression A variable that represents an Attachment object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Append Method (ADOX Tables)

 Copy code hover
[image]

Append Method (ADOX Tables)
Send feedback

Adds a new Table object to the Tables collection.

Syntax

Tables.Append Table

Parameters

  • Table

  • A Variant value that contains a reference to the Table to append or the name of the table to create and append.

Remarks

An error will occur if the provider does not support creating tables.


Report.Printer Property (Access)

 Copy code hover
[image]

Report.Printer Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Printer object representing the default printer on the current system. Read/write.

Syntax

expression .Printer

expression A variable that represents a Report object.

Example

The following example makes the first printer in the Printers collection the default printer for the system, and then reports its name, driver information, and port information.

VBA Copy code Copy code
Dim prtDefault As Printer

Set Application.Printer = Application.Printers(0)

Set prtDefault = Application.Printer

With prtDefault
 MsgBox "Device name: " & .DeviceName & vbCr _
 & "Driver name: " & .DriverName & vbCr _
 & "Port: " & .Port
End With

See also

Concepts

Report Object

Other resources

Report Object Members


Form.NewRecord Property (Access)

 Copy code hover
[image]

Form.NewRecord Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the NewRecord property to determine whether the current record is a new record. Read-only Integer.

Syntax

expression .NewRecord

expression A variable that represents a Form object.

Remarks

Note Note

The NewRecord property is read-only in Form view and Datasheet view. It isn't available in Design view.

When a user has moved to a new record, the NewRecord property setting will be True whether the user has started to edit the record or not.

Example

The following example shows how to use the NewRecord property to determine if the current record is a new record. The NewRecordMark procedure sets the current record to the variable intnewrec. If the record is new, a message is displayed notifying the user of this. You could run this procedure when the Current event for a form occurs.

VBA Copy code Copy code
Sub NewRecordMark(frm As Form)
 Dim intnewrec As Integer

 intnewrec = frm.NewRecord
 If intnewrec = True Then
 MsgBox "You're in a new record." _
 & "@Do you want to add new data?" _
 & "@If not, move to an existing record."
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


NavigationControl.Value Property (Access)

 Copy code hover
[image]

NavigationControl.Value Property (Access)
See also Send feedback

Published: July 16, 2012

Determines or specifies the text in the text box. Read/write Variant.

Version Information

Version Added: Access 2010

Syntax

expression .Value

expression A variable that represents a NavigationControl object.

Remarks

The Text property returns the formatted string. The Text property may be different than the Value property for a text box control. The Text property is the current contents of the control. The Value property is the saved value of the text box control. The Text property is always current while the control has the focus.

The Value property returns or sets a control's default property, which is the property that is assumed when you don't explicitly specify a property name.

Note Note

The Value property is not the same as the DefaultValue property, which specifies the value that a property is assigned when a new record is created.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


ObjectFrame Properties (Access)

 Copy code hover
[image]

ObjectFrame Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Action | You can use the Action property in Visual Basic to specify the operation to perform on an OLE object. Read/write Integer.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoActivate | You can use the AutoActivate property to specify how the user can activate an OLE object. Read/write Integer.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the object frame and its bottom gridline. Read/write Integer.
Class | You can use the Class property to specify or determine the class name of an embeddedOLE object. Read/write String.
ColumnCount | You can use the ColumnCount property to specify the number of columns displayed in a list box or in the list box portion of a combo box, or sent to OLE objects in a chart control or unbound object frame . Read/write Integer.
ColumnHeads | You can use the ColumnHeads property to display a single row of column headings for list boxes, combo boxes, and OLE objects that accept column headings. You can also use this property to create a label for each entry in a chart control . What is actually displayed as the first-row column heading depends on the object's RowSourceType property setting. Read/write Boolean.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayType | You can use the DisplayType property to specify whether Microsoft Access displays an OLE object's content or an icon. Read/write Boolean.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
GridlineColor | Gets or sets the color of the gridline for the specified object frame. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified frame. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified frame. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified frame. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified frame. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified frame. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified frame. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified frame. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified frame. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the object frame is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Item | The Item property returns or sets a specific member of a collection. Read/write String.
Layout | Returns the type of layout for the specified object frame. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified object frame. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the object frame and its left gridline. Read/write Integer.
LinkChildFields | You can use the LinkChildFields property (along with the LinkMasterFields property) together to specify how Microsoft Access links records in a form or report to records in a subform, subreport, or embedded object, such as a chart. If these properties are set, Microsoft Access automatically updates the related record in the subform when you change to a new record in a main form. Read/write String.
LinkMasterFields | You can use the LinkMasterFields property (along with the LinkChildFields property) together to specify how Microsoft Access links records in a form or report to records in a subform, subreport, or embedded object, such as a chart. If these properties are set, Microsoft Access automatically updates the related record in the subform when you change to a new record in a main form. Read/write String.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Object | You can use the Object property in Visual Basic to return a reference to the ActiveX object that is associated with a linked or embedded OLE object in a control. By using this reference, you can access the properties or invoke the methods of the OLE object. Read-only Object.
ObjectPalette | The ObjectPalette property specifies the palette in the application used to create an OLE object. Read/write Variant.
ObjectVerbs | You can use the ObjectVerbs property in Visual Basic to determine the list of verbs an OLE object supports. Read-only String.
ObjectVerbsCount | You can use the ObjectVerbsCount property in Visual Basic to determine the number of verbs supported by an OLE object. Read-only Long.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OLEClass | You can use the OLEClass property to obtain a description of the kind of OLE object contained in a chart control or an unbound object frame. Read-only String.
OLEType | You can use the OLEType property to determine if a control contains an OLE object, and, if so, whether the object is linked or embedded. Read/write Byte.
OLETypeAllowed | You can use the OLETypeAllowed property to specify the type of OLE object a control can contain. Read/write Byte.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnUpdated | Sets or returns the value of the On Updated box in the Properties window of a form or report. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
RightPadding | Gets or sets the amount of space (in inches) between the object frame and its right gridline. Read/write Integer.
RowSource | You can use the RowSource property (along with the RowSourceType property) to tell Microsoft Access how to provide data tothe specified object. Read/write String.
RowSourceType | You can use the RowSourceType property (along with the RowSource property) to tell Microsoft Access how to provide data tothe specified object. Read/write String.
Scaling | Controls how the contents of an object frame control are displayed. Read/write Byte.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SizeMode | You can use the SizeMode property to specify how to size a picture or other object in a bound object frame, an unbound object frame, or an image control.
SourceDoc | You can use the SourceDoc property to specify the file to create a link to or to embed when you create a linked object or embedded object by using the Action property in Visual Basic. Read/write String.
SourceItem | You can use the SourceItem property to specify the data within a file to be linked when you create a linked OLE object. Read/write String.
SourceObject | You can use this property for linked unbound object frames to determine the complete path and file name of the file that contains the data linked to the object frame. Read-only String.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the object frame and its top gridline. Read/write Integer.
UpdateMethod | This property has been deprecated. Use the UpdateOptions property to specify how a linkedOLE object is updated.
UpdateOptions | You can use the UpdateOptions property to specify how a linkedOLE object is updated. Read/write Integer.
VarOleObject | Gets a pointer to an IOLEObject that represents the memory address of an OLE object. Read-only Variant.
Verb | You can use the Verb property to specify the operation to perform when an OLE object is activated, which is permitted when the control'sAction property is set to acOLEActivate. Read/write Long.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified object frame is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


ComboBox.RemoveItem Method (Access)

 Copy code hover
[image]

ComboBox.RemoveItem Method (Access)
See also Send feedback

Published: July 16, 2012

Removes an item from the list of values displayed by the specified combo box control.

Syntax

expression .RemoveItem(Index)

expression A variable that represents a ComboBox object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | The item to be removed from the list, expressed as either an item number or the list item text.

Remarks

This method is only valid for list box or combo box controls on forms. Also, the RowSourceType property of the control must be set to "Value List".

List item numbers start from zero. If the value of the Index argument doesn't correspond to an existing item number or the text of an existing item, an error occurs.

Use the AddItem method to add items to the list of values.

Example

This example removes the specified item from the list in a list box control. For the function to work, you must pass it a ListBox object representing a list box control on a form and a Variant value representing the item to be removed.

VBA Copy code Copy code
Function RemoveListItem(ctrlListBox As ListBox, _
 ByVal varItem As Variant) As Boolean

 ' Trap for errors.
 On Error GoTo ERROR_HANDLER

 ' Remove the list box item and set the return value
 ' to True, indicating success.
 ctrlListBox.RemoveItem Index:=varItem
 RemoveListItem = True

 ' Reset the error trap and exit the function.
 On Error GoTo 0
 Exit Function

' Return False if an error occurs.
ERROR_HANDLER:
 RemoveListItem = False

End Function

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Appendix D: ADO Samples (ADO)

 Copy code hover
[image]

Appendix D: ADO Samples (ADO)
Send feedback

In this section

  • Appendix D: ADO Samples


Module.ReplaceLine Method (Access)

 Copy code hover
[image]

Module.ReplaceLine Method (Access)
See also Send feedback

Published: July 16, 2012

The ReplaceLine method replaces a specified line in a standard module or a class module.

Syntax

expression .ReplaceLine(Line, String)

expression A variable that represents a Module object.

Parameters

Name | Required/Optional | Data Type | Description
Line | Required | Long | The number of the line to be replaced.
String | Required | String | The text that is to replace the existing line.

Return Value

Nothing

Remarks

Lines in a module are numbered beginning with one. To determine the number of lines in a module, use the CountOfLines property.

See also

Concepts

Module Object

Other resources

Module Object Members


Report.Line Method (Access)

 Copy code hover
[image]

Report.Line Method (Access)
See also Send feedback

Published: July 16, 2012

The Line method draws lines and rectangles on a Report object when the Print event occurs.

Syntax

expression.Line(Step(x1, y1) - Step(x2, y2), color, BF)

expression Required. An expression that returns one of the objects in the Applies To list.

Parameters

Step A keyword that indicates the starting point coordinates are relative to the current graphics position given by the current settings for the CurrentX and CurrentY properties of the object argument.

object x1, y1Single values indicating the coordinates of the starting point for the line or rectangle. The Scale properties (ScaleMode, ScaleLeft, ScaleTop, ScaleHeight, and ScaleWidth) of the Report object specified by the object argument determine the unit of measure used. If this argument is omitted, the line begins at the position indicated by the CurrentX and CyrrentY properties.

color A Long value indicating the RGB (red-green-blue) color used to draw the line. If this argument is omitted, the value of the ForeColor property is used. You can also use the RGB function or QBColor function to specify the color.

B An option that creates a rectangle by using the coordinates as opposite corners of the rectangle.

F F cannot be used without B. If the B option is used, the F option specifies that the rectangle is filled with the same color used to draw the rectangle. If B is used without F, the rectangle is filled with the color specified by the current settings of the FillColor and BackStyle properties. The default value for the BackStyle property is Normal for rectangles and lines.

Remarks

You can use this method only in an event procedure or a macro specified by the OnPrint or OnFormat event property for a report section, or the OnPage event property for a report.

To connect two drawing lines, make sure that one line begins at the end point of the previous line.

The width of the line drawn depends on the DrawWidthproperty setting. The way a line or rectangle is drawn on the background depends on the settings of the DrawMode and DrawStyle properties.

When you apply the Line method, the CurrentX and CurrentY properties are set to the end point specified by the x2 and y2 arguments.

Example

The following example uses the Line method to draw a red rectangle five pixels inside the edge of a report named EmployeeReport. The RGB function is used to make the line red.

To try this example in Microsoft Access, create a new report named EmployeeReport. Paste the following code in the declarations section of the report's module, then switch to Print Preview.

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    ' Call the Drawline procedure
    DrawLine
End Sub

Sub DrawLine()
    Dim rpt As Report, lngColor As Long
    Dim sngTop As Single, sngLeft As Single
    Dim sngWidth As Single, sngHeight As Single

    Set rpt = Reports!EmployeeReport
    ' Set scale to pixels.
    rpt.ScaleMode = 3
    ' Top inside edge.
    sngTop = rpt.ScaleTop + 5
    ' Left inside edge.
    sngLeft = rpt.ScaleLeft + 5
    ' Width inside edge.
    sngWidth = rpt.ScaleWidth - 10
    ' Height inside edge.
    sngHeight = rpt.ScaleHeight - 10
    ' Make color red.
    lngColor = RGB(255,0,0)
    ' Draw line as a box.
    rpt.Line(sngTop, sngLeft) - (sngWidth, sngHeight), lngColor, B
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


Parameter has no default value. (Error 3747)

 Copy code hover
[image]

Parameter has no default value. (Error 3747)
Send feedback

This error occurs when using procedures. It occurs when a default value is trying to be utilized and the parameter does not have a defined default value. To prevent this error message, define a default value on the procedure, or pass in a value to the parameter.


An internet function has timed out. (Error 3742)

 Copy code hover
[image]

An internet function has timed out. (Error 3742)
Send feedback

The internet operation has timed out before completing. Increase the timeout values in the registry.


ShowToolbar Macro Action

 Copy code hover
[image]

ShowToolbar Macro Action
Send feedback

You can use the ShowToolbar action to display or hide a group of commands on the Add-Ins tab.

Note Note

The ShowToolbar action does not affect shortcut menus.
Note 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.

Setting

The ShowToolbar action has the following arguments.

Action argument | Description
Toolbar Name | The name of the command group on the Add-Ins tab you want to display or hide. The Toolbar Name box in the Action Arguments section of the Macro Builder Pane shows all the available groups that can be affected by this action. This is a required argument. If you run a macro containing the ShowToolbar action in a library database, Access first looks for the group with this name in the library database, and then in the current database.
Show | Specifies whether to display or hide the group and in which views to display or hide it. The default is Yes (show the group at all times). You can select Yes to display the group at all times, Where Appropriate to display the group only when the appropriate form or report is active, or No to hide the group at all times.

Remarks

You can use this action in a macro with conditional expressions to display or hide a group depending on certain conditions.

If you want to show a particular group on just one form or report, you can set the OnActivate property of the form or report to the name of a macro that contains a ShowToolbar action to show the group. Then set the OnDeactivate property of the form or report to the name of a macro that contains a ShowToolbar action to hide the group.

The built-in toolbars are not available to display or hide by using this action if you set the AllowBuiltInToolbars property to False (0) in a Visual Basic for Applications (VBA) module, or if you set the Allow Built-in Toolbars option to False in VBA by using the SetOption method.

To run the ShowToolbar action in a VBA module, use the ShowToolbar method of the DoCmd object.


Form.DatasheetColumnHeaderUnderlineStyle Property (Access)

 Copy code hover
[image]

Form.DatasheetColumnHeaderUnderlineStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Byte indicating the line style to use for the bottom edge of the column headers on the specified datasheet. Read/write.

Syntax

expression .DatasheetColumnHeaderUnderlineStyle

expression A variable that represents a Form object.

Remarks

Valid values are between zero and eight. Values greater than eight are ignored; negative values or values above 255 cause an error.

Value | Description
0 | Transparent border
1 | Solid
2 | Dashes
3 | Short dashes
4 | Dots
5 | Sparse dots
6 | Dash-dot
7 | Dash-dot-dot
8 | Double solid

Example

This example sets the column header underline style for the first open form to sparse dots. The form must be set to Datasheet View in order for you to see the change.

VBA Copy code Copy code
Forms(0).DatasheetColumnHeaderUnderlineStyle = 5

See also

Concepts

Form Object

Other resources

Form Object Members


The ADO Family of Libraries

 Copy code hover
[image]

The ADO Family of Libraries
Send feedback

Three major libraries make up the ADO family: ADO (including RDS), ADO MD, and ADOX.

ADO

ADO enables your client applications to access and manipulate data from a database server through an OLE DB provider. The primary benefits of ADO are ease of use, high speed, low memory overhead, and a small disk footprint. ADO supports key features for building client/server and Web-based applications.

ADO also features Remote Data Service (RDS), by which you can move data from a server to a client application or Web page, manipulate the data on the client, and return updates to the server in a single round trip.

ADO MD

Microsoft ActiveX Data Objects (Multidimensional) (ADO MD) provides easy access to multidimensional data from languages such as Microsoft Visual Basic, Microsoft Visual C++, and Microsoft Visual J++. ADO MD extends ADO to include objects specific to multidimensional data, such as the CubeDef and Cellset objects. With ADO MD you can browse multidimensional schema, query a cube, and retrieve the results.

Like ADO, ADO MD uses an underlying OLE DB provider to gain access to data. To work with ADO MD, the provider must be a multidimensional data provider (MDP) as defined by the OLE DB for OLAP specification. MDPs present data in multidimensional views as opposed to tabular data providers (TDPs) that present data in tabular views. Refer to the documentation for your OLE DB for OLAP provider for more detailed information about the specific syntax and behaviors supported by your provider.

ADOX

Microsoft ActiveX Data Objects Extensions for Data Definition Language and Security (ADOX) is an extension to the ADO objects and programming model. ADOX includes objects for schema creation and modification as well as security. Because it is an object-based approach to schema manipulation, you can write code that will work against various data sources regardless of differences in their native syntaxes.

ADOX is a companion library to the core ADO objects. It exposes additional objects for creating, modifying, and deleting schema objects, such as tables and procedures. It also includes security objects to maintain users and groups, and to grant and revoke permissions on objects.


NavigationButton.Transparent Property (Access)

 Copy code hover
[image]

NavigationButton.Transparent Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Transparent property to specify whether a command button is solid or transparent. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .Transparent

expression A variable that represents a NavigationButton object.

Remarks

Use the BackStyle property to make other controls solid or transparent.

You can use this property to place a transparent command button over another control. For example, you could place several transparent buttons over a picture displayed in an image control and run various macros or Visual Basic event procedures depending on which part of the picture the user clicks.

Note Note

To hide and disable a button, use the Visible property. To disable a button without hiding it, use the Enabled property. To hide a button only when a form or report is printed, use the DisplayWhen property.

Example

The following example makes the command button "Preview" on the "Purchase Orders" form transparent.

VBA Copy code Copy code
Forms.Item("Purchase Orders").Controls.Item("Preview"). _
 Transparent = True

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


AcNewDatabaseFormat Enumeration (Access)

 Copy code hover
[image]

AcNewDatabaseFormat Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the NewCurrentDatabase method to specify the database format of the newly created database.

Version Information

Version Added: Access 2007

Name | Value | Description
acNewDatabaseFormatAccess12 | 12 | Create a database in the Microsoft Access 2013 (.accdb) file format.
acNewDatabaseFormatAccess2000 | 9 | Create a database in the Microsoft Access 2000 (.mdb) file format.
acNewDatabaseFormatAccess2002 | 10 | Create a database in the Microsoft Access 2002-2003 (.mdb) file format.
acNewDatabaseFormatUserDefault | 0 | Create a database in the default file format.


EXECUTE Statement (Microsoft Access SQL)

 Copy code hover
[image]

EXECUTE Statement (Microsoft Access SQL)
Send feedback

Used to invoke the execution of a procedure.

Syntax

EXECUTE procedure [param1[, param2[, …]]

The EXECUTE statement has these parts:

Part | Description
procedure | The name of the procedure that is to be executed.
param1, param2, … | Values for the parameters defined by the procedure.

Example

This example names the query CategoryList.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

VBA Copy code Copy code
Sub ProcedureX()

    Dim dbs As Database, rst As Recordset
    Dim qdf As QueryDef, strSql As String

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    strSql = "PROCEDURE CategoryList; " _
        & "SELECT DISTINCTROW CategoryName, " _
        & "CategoryID FROM Categories " _
        & "ORDER BY CategoryName;"

    ' Create a named QueryDef based on the SQL
    ' statement.
    Set qdf = dbs.CreateQueryDef("NewQry", strSql)

    ' Create a temporary snapshot-type Recordset.
    Set rst = qdf.OpenRecordset(dbOpenSnapshot)

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 15

    ' Delete the QueryDef because this is a
    ' demonstration.
    dbs.QueryDefs.Delete "NewQry"

    dbs.Close

End Sub


Alternatives: Using SQL Statements

 Copy code hover
[image]

Alternatives: Using SQL Statements
Send feedback

ADO also allows using commands as alternatives to its built-in properties and methods for editing data. Depending upon your provider, all operations mentioned in this chapter could also be accomplished by passing commands to your data source. For example, SQL UPDATE statements can be used to modify data without using the Value property of a Field. SQL INSERT statements can be used to add new records to a data source, rather than the ADO method AddNew. For more information about SQL or the data-manipulation language of your provider, see the documentation of your data source.

For example, you can pass a SQL string containing a DELETE statement to a database, as shown in the following code:

Copy code Copy code

'BeginSQLDelete
strSQL = "DELETE FROM Shippers WHERE ShipperID = " & intId
objConn.Execute strSQL, , adCmdText + adExecuteNoRecords
'EndSQLDelete


Section Object (Access)

 Copy code hover
[image]

Section Object (Access)
See also Send feedback

Published: July 16, 2012

A form section is part of a form such as a header, footer, or detail section.

Remarks

You can set section properties which are attributes of a form that affect the appearance or behavior of that section. For example, you can set the CanGrow property to specify whether the section will increase vertically to print all the data the section contains. Section properties are set in form Design view.

See also

Concepts

Access Object Model Reference

Other resources

Section Object Members


Relation Members (DAO)

 Copy code hover
[image]

Relation Members (DAO)
Send feedback

A Relation object represents a relationship between fields in tables or queries (Microsoft Access database engine databases only).

Methods

Name | Description
CreateField | Creates a new Field object (Microsoft Access workspaces only).

Properties

Name | Description
Attributes | Sets or returns a value that indicates one or more characteristics of a Relation object. Read/write Long.
Fields | Returns a Fields collection that represents all stored Field objects for the specified object. Read-only.
ForeignTable | Sets or returns the name of the foreign table in a relationship (Microsoft Access workspaces only). .
Name | Returns or sets the name of the specified object. Read/write String if the object has not been appended to a collection. Read-only String if the object has been appended to a collection.
PartialReplica | Sets or returns a value on a Relation object indicating whether that relation should be considered when populating a partial replica from a full replica. (Microsoft Access database engine databases only). Read/write Boolean.
Properties | Returns the Properties collection of the specified object. Read-only.
Table | Indicates the name of a Relation object's primary table. This should be equal to the Name property setting of a TableDef or QueryDef object (Microsoft Access workspaces only).


ToggleButton.ColumnHidden Property (Access)

 Copy code hover
[image]

ToggleButton.ColumnHidden Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.

Syntax

expression .ColumnHidden

expression A variable that represents a ToggleButton object.

Remarks

For example, you might want to hide a CustomerAddress field that's too wide so you can view the CustomerName and PhoneNumber fields.

Note Note

The ColumnHidden property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

Hiding a column with the ColumnHidden property in Datasheet view doesn't hide fields from the same column in Form view. Similarly, setting a control's Visible property to False in Form view doesn't hide the corresponding column in Datasheet view.

Note Note

To set or change this property for a table or query by using Visual Basic, you must use a column's Properties collection. For details on using the Properties collection, see Properties .

You can display a field in a query even though the column for the field is hidden in table Datasheet view. You can use values from a hidden column as the criteria for a filter even though the column remains hidden after the filter is applied.

Setting a field's ColumnWidth property to 0, or resizing the field to a zero width in Datasheet view, causes Microsoft Access to set the corresponding ColumnHidden property to True. Unhiding a column restores the ColumnWidthColumnWidth property to the value it had before the field was hidden.

Note Note

The ColumnHidden property is not available in Design view.

Example

The following example hides the ProductID field in Datasheet view of the Products form.

VBA Copy code Copy code
Forms!Products!ProductID.ColumnHidden = -1

The next example also hides the ProductID field in Datasheet view of the Products table.

VBA Copy code Copy code
Public Sub SetColumnHidden()

 Dim dbs As DAO.Database
 Dim fld As DAO.Field
 Dim prp As DAO.Property
 Const conErrPropertyNotFound = 3270

 ' Turn off error trapping.
 On Error Resume Next

 Set dbs = CurrentDb

 ' Set field property.
 Set fld = dbs.TableDefs!Products.Fields!ProductID
 fld.Properties("ColumnHidden") = True

 ' Error may have occurred when value was set.
 If Err.Number <> 0 Then
 If Err.Number <> conErrPropertyNotFound Then
 On Error GoTo 0
 MsgBox "Couldn't set property 'ColumnHidden' " & _
 "on field '" & fld.Name & "'", vbCritical
 Else
 On Error GoTo 0
 Set prp = fld.CreateProperty("ColumnHidden", dbLong, True)
 fld.Properties.Append prp
 End If
 End If

 Set prp = Nothing
 Set fld = Nothing
 Set dbs = Nothing

End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Step 5: DataControl is Made Usable (RDS Tutorial)

 Copy code hover
[image]

Step 5: DataControl is Made Usable (RDS Tutorial)
Send feedback

The returned Recordset object is available for use. You can examine, navigate, or edit it as you would any other Recordset. What you can do with the Recordset depends on your environment. Visual Basic and Visual C++ have visual controls that can use a Recordset directly or indirectly with the aid of an enabling data control.

For example, if you are displaying a Web page in Microsoft Internet Explorer, you might want to display the Recordset object data in a visual control. Visual controls on a Web page cannot access a Recordset object directly. However, they can access the Recordset object through the RDS.DataControl. The RDS.DataControl becomes usable by a visual control when its SourceRecordset property is set to the Recordset object.

The visual control object must have its DATASRC parameter set to the RDS.DataControl, and its DATAFLD property set to a Recordset object field (column).

In this tutorial, set the SourceRecordset property:

Copy code Copy code

Sub RDSTutorial5()
 Dim DS as New RDS.DataSpace
 Dim RS as ADODB.Recordset
 Dim DC as New RDS.DataControl
 Dim DF as Object
 Set DF = DS.CreateObject("RDSServer.DataFactory", "http://yourServer")
 Set RS = DF.Query ("DSN=Pubs", "SELECT * FROM Authors")
 DC.SourceRecordset = RS ' Visual controls can now bind to DC.
...


Initializing the Lotus Driver

 Copy code hover
[image]

Initializing the Lotus Driver
Send feedback

When you install the Lotus database driver, the Setup program writes a set of default values to the Microsoft® Windows® Registry in the Engines and ISAM Formats subkeys. You should not modify these settings directly; use the setup program for your application to add, remove, or change these settings. The following sections describe initialization and ISAM Format settings for the Lotus database driver.

Lotus Initialization Settings

The Access Connectivity Engine\Engines\Lotus folder includes initialization settings for the Acelts.dll driver, used for external access to Lotus spreadsheets. Typical settings for the entries under this heading are shown in the following example.

Copy code Copy code
win32=<path>\ACELTS.DLL

TypeGuessRows=8

ImportMixedTypes=Text

AppendBlankRows=4

FirstRowHasNames=Yes

The Microsoft Access database engine uses the Lotus folder entries as follows.

Entry | Description
win32 | The location of msltus40.dll. The full path is determined at the time of installation. Values are of type REG_SZ.
TypeGuessRows | The number of rows to be checked for the data type. The data type is determined based on the most frequently found data type in the selection. If there is a tie, the data type is determined in the following order: Number, Currency, Date, Text, Long Text. If data is encountered that does not match the data type guessed for the column, it is returned as a Null value. On import, if a column has mixed data types, the entire column will be converted according to the ImportMixedTypes setting. The default number of rows to be checked is 8. Values are of type REG_DWORD.
ImportMixedTypes | Can be set to MajorityType or Text. If set to MajorityType, columns of mixed data types will be cast to the predominate data type on import. If set to Text, columns of mixed data types will be cast to Text on import. The default is Text. Values are of type REG_SZ.
AppendBlankRows | The number of blank rows to be appended to the end of a WK1 worksheet before new data is added. For example, if AppendBlankRows is set to 4, the Microsoft Access database engine will append 4 blank rows to the end of the worksheet before appending rows that contain data. Integer values for this setting can range from 0 to 16; the default is 01 (one additional row appended). Values are of type REG_DWORD.
FirstRowHasNames | A binary value that indicates whether the first row of the table contains column names. A value of 01 indicates that, during import, column names are taken from the first row. A value of 00 indicates no column names in the first row; column names appear as F1, F2, F3, and so on. The default is 01. Values are of type REG_BINARY.

Lotus ISAM Formats

The Access Connectivity Engine\ISAM Formats\Lotus WK1 folder contains the following entries.

Entry name | Type | Value
Engine | REG_SZ | Lotus
ExportFilter | REG_SZ | Lotus 1-2-3 WK1 (*.wk1)
ImportFilter | REG_SZ | Lotus 1-2-3 (*.wk* )
CanLink | REG_BINARY | 00
OneTablePerFile | REG_BINARY | 00
IsamType | REG_DWORD | 1
IndexDialog | REG_BINARY | 00
CreateDBOnExport | REG_BINARY | 01
ResultTextImport | REG_SZ | Import data from the external file into the current database. Changing data in the current database will not change data in the external file.
ResultTextExport | REG_SZ | Export data from the current database into a Lotus 1-2-3 Version 2 file. This process will overwrite the data if exported to an existing file.
SupportsLongNames | REG_BINARY | 01

The Access Connectivity Engine\ISAM Formats\Lotus WK3 folder contains the following entries.

Entry name | Type | Value
Engine | REG_SZ | Lotus
ExportFilter | REG_SZ | Lotus 1-2-3 WK3 (*.wk3)
CanLink | REG_BINARY | 00
OneTablePerFile | REG_BINARY | 00
IsamType | REG_DWORD | 1
IndexDialog | REG_BINARY | 00
CreateDBOnExport | REG_BINARY | 01
ResultTextExport | REG_SZ | Export data from the current database into a Lotus 1-2-3 Version 3 file. This process will overwrite the data if exported to an existing file.
SupportsLongNames | REG_BINARY | 01

The Access Connectivity Engine\ISAM Formats\Lotus WK4 folder contains the following entries.

Entry name | Type | Value
Engine | REG_SZ | Lotus
CanLink | REG_BINARY | 00
OneTablePerFile | REG_BINARY | 00
IsamType | REG_DWORD | 1
IndexDialog | REG_BINARY | 00
CreateDBOnExport | REG_BINARY | 01
SupportsLongNames | REG_BINARY | 01

The Access Connectivity Engine\ISAM Formats\Lotus WJ2 folder contains the following entries.

Entry name | Type | Value
Engine | REG_SZ | Lotus
ExportFilter | REG_SZ | Lotus 1-2-3 WJ2 (*.wj2)
ImportFilter | REG_SZ | Lotus 1-2-3/DOS (*.wj* )
CanLink | REG_BINARY | 00
OneTablePerFile | REG_BINARY | 00
IsamType | REG_DWORD | 1
IndexDialog | REG_BINARY | 00
CreateDBOnExport | REG_BINARY | 01
ResultTextExport | REG_SZ | Export data from the current database into a Lotus 1-2-3 Version 2 file. This process will overwrite the data if exported to an existing file.
SupportsLongNames | REG_BINARY | 01

The Access Connectivity Engine\ISAM Formats\Lotus WJ3 folder contains the following entries.

Entry name | Type | Value
Engine | REG_SZ | Lotus
CanLink | REG_BINARY | 00
OneTablePerFile | REG_BINARY | 00
IsamType | REG_DWORD | 1
IndexDialog | REG_BINARY | 00
CreateDBOnExport | REG_BINARY | 01
SupportsLongNames | REG_BINARY | 01
Note Note

When you change Windows Registry settings, you must exit and then restart the database engine for the new settings to take effect.


Page.DblClick Event (Access)

 Copy code hover
[image]

Page.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Syntax

expression .DblClick(Cancel)

expression A variable that represents a Page object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the DblClick event occurs. Setting the Cancel argument to True (-1) cancels the DblClick event.

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

Page Object

Other resources

Page Object Members


OptionGroup.ControlSource Property (Access)

 Copy code hover
[image]

OptionGroup.ControlSource Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.

Syntax

expression .ControlSource

expression A variable that represents an OptionGroup object.

Remarks

The ControlSource property uses the following settings.

Setting | Description
A field name | The control is bound to a field in a table, query, or SQL statement. Data from the field is displayed in the control. Changes to the data inside the control change the corresponding data in the field. (To make the control read-only, set the Locked property to Yes.) If you click a control bound to a field that has a Hyperlink data type, you jump to the destination specified in the hyperlink address.
An expression | The control displays data generated by an expression. This data can be changed by the user but isn't saved in the database.

For reports, the ControlSource property applies only to report group levels.

Forms and reports act as "windows" into your database. You specify the primary source of data for a form or report by setting its RecordSource property to a table, query, or SQL statement. You can then set the ControlSource property to a field in the source of data or to an expression. If the ControlSource property setting is an expression, the value displayed is read-only and not saved in the database. For example, you can use the following settings.

Sample setting | Description
LastName | For a control, data from the LastName field is displayed in the control. For a report group level, Microsoft Access groups the data on last name.
=Date( ) + 7 | For a control, this expression displays a date seven days from today in the control.
=DatePart("q",ShippedDate) | For a control, this expression displays the quarter of the shipped date. For a report group level, Microsoft Access groups the data on the quarter of the shipped date.

Example

The following example sets the ControlSource property for a text box named AddressPart to a field named City:

VBA Copy code Copy code
Forms!Customers!AddressPart.ControlSource = "City"

The next example sets the ControlSource property for a text box named Expected to the expression =Date() + 7

VBA Copy code Copy code
Me!Expected.ControlSource = "=Date() + 7"

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


NativeError Property (ADO)

 Copy code hover
[image]

NativeError Property (ADO)
Send feedback

Indicates the provider-specific error code for a given Error object.

Return Value

Returns a Long value that indicates the error code.

Remarks

Use the NativeError property to retrieve the database-specific error information for a particular Error object. For example, when using the Microsoft ODBC Provider for OLE DB with a Microsoft SQL Server database, native error codes that originate from SQL Server pass through ODBC and the ODBC Provider to the ADO NativeError property.


Property specified already exists. (Error 3311)

 Copy code hover
[image]

Property specified already exists. (Error 3311)
Send feedback

You tried to append a new Property object to a collection that contains a property of the same name. Check to see whether you have misspelled the new Property object's Name property, or refer to the Help topic for the existing property of the same name to see whether you need to create a new Property object.


Report.OnKeyPress Property (Access)

 Copy code hover
[image]

Report.OnKeyPress Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Press box in the Properties window. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnKeyPress

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyPress event occurs when a user presses a key while a report or control has the focus. This event also occurs if you send a keystroke to a report or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyPress value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Press box in the report's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Press box is blank, the property value is an empty string.

See also

Concepts

Report Object

Other resources

Report Object Members


OptionGroup.VerticalAnchor Property (Access)

 Copy code hover
[image]

OptionGroup.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified option group is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .VerticalAnchor

expression A variable that represents an OptionGroup object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


None of the import field names match fields in the appended table. (Error 3243)

 Copy code hover
[image]

None of the import field names match fields in the appended table. (Error 3243)
Send feedback

At least one field name in the import table and the appended table must match.


Report.PageHeader Property (Access)

 Copy code hover
[image]

Report.PageHeader Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PageHeader property to specify whether a report's page header is printed on the same page as a report header. Read/write Byte.

Syntax

expression .PageHeader

expression A variable that represents a Report object.

Remarks

The PageHeader property use the following settings.

Setting | Visual Basic | Description
All Pages | 0 | (Default) The page header is printed on all pages of a report.
Not With Rpt Hdr | 1 | The page header isn't printed on the same page as the report header.
Not With Rpt Ftr | 2 | The page header isn't printed on the same page as the report footer. Microsoft Access prints the report footer on a new page.
Not With Rpt Hdr/Ftr | 3 | The page header isn't printed on a page that has either a report header or a report footer. Microsoft Access prints the report footer on a new page.

You can set the PageHeader property only in report Design view.

Microsoft Access normally prints report page headers on every page in a report, including the first and last.

Note Note

When forms are printed, page headers are always printed on all pages.

Example

The following example sets the PageHeader property for a report to Not With Rpt Hdr. To run this example, type the following line in the Debug window for a report named Report1.

VBA Copy code Copy code
Reports!Report1.PageHeader = 1

See also

Concepts

Report Object

Other resources

Report Object Members


MacroError.MacroName Property (Access)

 Copy code hover
[image]

MacroError.MacroName Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the name of the macro that was running when an error occurred. Read-only String.

Version Information

Version Added: Access 2007

Syntax

expression .MacroName

expression A variable that represents a MacroError object.

Remarks

When an error occurs in a macro, information about the error is stored in the MacroError object. If you have not used the OnError action to suppress error messages, the macro stops and the error information is displayed in a standard error message. However, if you have used the OnError action to suppress error messages, you may want to use the information stored in the MacroError object in a condition or a custom error message.

After an error has been handled, the information in the MacroError object is out of date, so it is a good idea to clear the object using the ClearMacroError action. This resets the error number in the MacroError object back to zero, and clears any other information about the error that is stored in the object, such as the error description, macro name, action name, condition, and arguments. This way, you can inspect the MacroError object again later to see if another error has occurred.

See also

Concepts

MacroError Object

Other resources

MacroError Object Members


TableDef.RefreshLink Method (DAO)

 Copy code hover
[image]

TableDef.RefreshLink Method (DAO)
Send feedback

Updates the connection information for a linked table (Microsoft Access workspaces only).

Syntax

expression .RefreshLink

expression A variable that represents a TableDef object.

Remarks

To change the connection information for a linked table, reset the Connect property of the corresponding TableDef object and then use the RefreshLink method to update the information. Using RefreshLink method doesn't change the linked table's properties and Relation objects.

For this connection information to exist in all collections associated with the TableDef object that represents the linked table, you must use the Refresh method on each collection.

Example

This example uses the RefreshLink method to refresh the data in a linked table after its connection has been changed from one data source to another. The RefreshLinkOutput procedure is required for this procedure to run.

VBA Copy code Copy code
Sub RefreshLinkX()

 Dim dbsCurrent As Database
 Dim tdfLinked As TableDef

 ' Open a database to which a linked table can be
 ' appended.
 Set dbsCurrent = OpenDatabase("DB1.mdb")

 ' Create a linked table that points to a Microsoft
 ' SQL Server database.
 Set tdfLinked = _
 dbsCurrent.CreateTableDef("AuthorsTable")

 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 tdfLinked.Connect = _
 "ODBC;DATABASE=pubs;DSN=Publishers"
 tdfLinked.SourceTableName = "authors"
 dbsCurrent.TableDefs.Append tdfLinked

 ' Display contents of linked table.
 Debug.Print _
 "Data from linked table connected to first source:"
 RefreshLinkOutput dbsCurrent

 ' Change connection information for linked table and
 ' refresh the connection in order to make the new data
 ' available.

 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 tdfLinked.Connect = _
 "ODBC;DATABASE=pubs;DSN=NewPublishers"
 tdfLinked.RefreshLink

 ' Display contents of linked table.
 Debug.Print _
 "Data from linked table connected to second source:"
 RefreshLinkOutput dbsCurrent

 ' Delete linked table because this is a demonstration.
 dbsCurrent.TableDefs.Delete tdfLinked.Name

 dbsCurrent.Close

End Sub

Sub RefreshLinkOutput(dbsTemp As Database)

 Dim rstRemote As Recordset
 Dim intCount As Integer

 ' Open linked table.
 Set rstRemote = _
 dbsTemp.OpenRecordset("AuthorsTable")

 intCount = 0

 ' Enumerate Recordset object, but stop at 50 records.
 With rstRemote
 Do While Not .EOF And intCount < 50
 Debug.Print , .Fields(0), .Fields(1)
 intCount = intCount + 1
 .MoveNext
 Loop
 If Not .EOF Then Debug.Print , "[more records]"
 .Close
 End With

End Sub


WebBrowserControl.OnKeyPress Property (Access)

 Copy code hover
[image]

WebBrowserControl.OnKeyPress Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Press box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnKeyPress

expression A variable that represents a WebBrowserControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyPress event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyPress value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Press box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Press box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyPress property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyPress

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


NavigationButton.Properties Property (Access)

 Copy code hover
[image]

NavigationButton.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Properties

expression A variable that represents a NavigationButton object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


WillExecute Event (ADO)

 Copy code hover
[image]

WillExecute Event (ADO)
Send feedback

The WillExecute event is called just before a pending command executes on a connection.

Syntax

WillExecute Source, CursorType, LockType, Options, adStatus, pCommand, pRecordset, pConnection

Parameters

  • Source

  • A String that contains an SQL command or a stored procedure name.

  • CursorType

  • A CursorTypeEnum that contains the type of cursor for the Recordset that will be opened. With this parameter, you can change the cursor to any type during a Recordset Open operation. CursorType will be ignored for any other operation.

  • LockType

  • A LockTypeEnum that contains the lock type for the Recordset that will be opened. With this parameter, you can change the lock to any type during a Recordset Open operation. LockType will be ignored for any other operation.

  • Options

  • A Long value that indicates options that can be used to execute the command or open the Recordset.

  • adStatus

  • EventStatusEnum

    Before this event returns, set this parameter to adStatusUnwantedEvent to prevent subsequent notifications, or adStatusCancel to request cancellation of the operation that caused this event.

  • pCommand

  • The Command object for which this event notification applies.

  • pRecordset

  • The Recordset object for which this event notification applies.

  • pConnection

  • The Connection object for which this event notification applies.

Remarks

A WillExecute event may occur due to a Connection. Execute, Command. Execute, or Recordset. Open method The pConnection parameter should always contain a valid reference to a Connection object. If the event is due to Connection.Execute, the pRecordset and pCommand parameters are set to Nothing. If the event is due to Recordset.Open, the pRecordset parameter will reference the Recordset object and the pCommand parameter is set to Nothing. If the event is due to Command.Execute, the pCommand parameter will reference the Command object and the pRecordset parameter is set to Nothing.

WillExecute allows you to examine and modify the pending execution parameters. This event may return a request that the pending command be canceled.


ToggleButton.HelpContextId Property (Access)

 Copy code hover
[image]

ToggleButton.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Syntax

expression .HelpContextId

expression A variable that represents a ToggleButton object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


LineSeparator Property (ADO)

 Copy code hover
[image]

LineSeparator Property (ADO)
Send feedback

Indicates the binary character to be used as the line separator in text Stream objects.

Settings and Return Values

Sets or returns a LineSeparatorsEnum value that indicates the line separator character used in the Stream. The default value is adCRLF.

Remarks

LineSeparator is used to interpret lines when reading the content of a text Stream. Lines can be skipped with the SkipLine method.

LineSeparator is used only with text Stream objects (Type is adTypeText). This property is ignored if Type is adTypeBinary.


Attachment.OnKeyPress Property (Access)

 Copy code hover
[image]

Attachment.OnKeyPress Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Press box in the Properties window. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnKeyPress

expression A variable that represents an Attachment object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyPress event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyPress value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Press box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Press box is blank, the property value is an empty string.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


CheckBox Properties (Access)

 Copy code hover
[image]

CheckBox Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the check box and its bottom gridline. Read/write Integer.
ColumnHidden | You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.
ColumnOrder | You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.
ColumnWidth | You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DefaultValue | Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
GridlineColor | Gets or sets the color of the gridline for the specified check box. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified check box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified check box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified check box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified check box. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified check box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified check box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified check box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified check box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HideDuplicates | You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the check box is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified check box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified check box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the check box and its left gridline. Read/write Integer.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OptionValue | Each control in an option group has a numeric value that you can set with the OptionValue property. Read/write Long.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
RightPadding | Gets or sets the amount of space (in inches) between the check box and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the check box and its top gridline. Read/write Integer.
TripleState | You can use the TripleState property to specify how the specified control will display Null values. Read/write Boolean.
ValidationRule | You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.
ValidationText | Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.
Value | Determines or specifies whether or not the specifed check box is checked. Read /write Variant.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified check box is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


Parameter Query

 Copy code hover
[image]

Parameter Query
Send feedback

Published: July 16, 2012

A parameter query, which is a type of select query, extends the flexibility of another query by prompting you to enter certain criteria each time the query is run. A parameter query is not, strictly speaking, a separate kind of query; rather, it extends the flexibility of other queries.


TableDef.ValidationText Property (DAO)

 Copy code hover
[image]

TableDef.ValidationText Property (DAO)
Send feedback

Sets or returns a value that specifies the text of the message that your application displays if the value of a Field object doesn't satisfy the validation rule specified by the ValidationRule property setting (Microsoft Access workspaces only). Read/write String.

Syntax

expression .ValidationText

expression A variable that represents a TableDef object.

Remarks

For a TableDef object, this property setting is read-only for a linked table and read/write for a base table.


FormatConditions.Parent Property (Access)

 Copy code hover
[image]

FormatConditions.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a FormatConditions object.

See also

Concepts

FormatConditions Collection

Other resources

FormatConditions Object Members


Object Properties

 Copy code hover
[image]

Object Properties
Send feedback

Published: July 16, 2012

The Object properties provide general information about objects contained in the Navigation Pane.

Note Note

The Object properties are available for all objects in a Microsoft Access database and only for forms, macros, modules, and reports in an Access project (.adp).

Setting

You can view the Object properties, and set the Description or Attributes properties, in the following ways:

  • Click an object in the Database window. On the Database Tools tab, in the Show/Hide group, click Property Sheet.

  • Right-click an object in the Database window, and then click Properties on the shortcut menu.

You can also specify or determine the Object properties in an Access database by using Visual Basic . The Object properties of an Access project (.adp) are not available using Visual Basic.

Note Note

You can only enter or edit the Description and Attributes properties. The other Object properties are set by Microsoft Access and are read-only.

Remarks

The objects for which you can display properties in the Database window are tables, queries, forms, reports, macros, and modules. Each class of objects in the database is represented by a separate DAO Document object within the DAO Containers collection. For example, the Containers collection contains a Document object that represents all the forms in the database.

The following Object properties are available from the Database window.

Property | Description
Name | This is the name of the object and contains the setting from the object's Name property.
Type | This is the object's type. Microsoft Access object types are Form, Macro, Module, Query, Report, and Table.
Description | This is the object's description and is the same as the setting for the object's Description property. You can also set the object's Description property in the object's property sheet.
Created | This is the date that the object was created. For tables and queries, this property is the same as the DateCreated property.
Modified | This is the date that the object was last modified. For tables and queries, this property is the same as the LastUpdated property.
Owner | This is the owner of the object. For more information, see the Owner property.
Attributes | This property specifies whether the object is hidden or visible and whether the object can be replicated in a database replica. If you set the Hidden attribute to True (by selecting the Hidden check box), the object won't appear in the Database window. To display hidden objects in the Navigation Pane, click the Microsoft Office Button [image] and then click Access Options. Click the Current Database category, and then click Navigation Options. Click Show Hidden Objects and then click OK. The icons for hidden objects will be dimmed in the Database window. You can then turn the Hidden attribute off, making the objects visible in the Database window.

Example

The following example uses the PrintObjectProperties subroutine to print the values of an object's Object properties to the Debug window. The subroutine requires the object type and object name as arguments.

Copy code Copy code
Dim strObjectType As String
Dim strObjectName As String
Dim strMsg As String

strMsg = "Enter object type (e.g., Forms, Scripts, " _
 & "Modules, Reports, Tables)."
' Get object type.
strObjectType = InputBox(strMsg)
strMsg = "Enter the name of a form, macro, module, " _
 & "query, report, or table."
' Get object name from user.
strObjectName = InputBox(strMsg)
' Pass object type and object name to
' PrintObjectProperties subroutine.
PrintObjectProperties strObjectType, strObjectName

Sub PrintObjectProperties(strObjectType As String, strObjectName _
 As String)
Dim dbs As Database, ctr As Container, doc As Document
Dim intI As Integer
Dim strTabChar As String
Dim prp As DAO.Property

Set dbs = CurrentDb
strTabChar = vbTab
' Set Container object variable.
Set ctr = dbs.Containers(strObjectType)
' Set Document object variable.
Set doc = ctr.Documents(strObjectName)
doc.Properties.Refresh
' Print the object name to Debug window.
Debug.Print doc.Name
' Print each Object property to Debug window.
For Each prp in doc.Properties
 Debug.Print strTabChar & prp.Name & " = " & prp.Value
Next
End Sub


Too many client tasks. (Error 3053)

 Copy code hover
[image]

Too many client tasks. (Error 3053)
Send feedback

You have too many copies of Microsoft Visual Basic or Visual Basic applications running at the same time. Close one or more instances.


Image.RightPadding Property (Access)

 Copy code hover
[image]

Image.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the image control and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .RightPadding

expression A variable that represents an Image object.

See also

Concepts

Image Object

Other resources

Image Object Members


Count Property Example (VB)

 Copy code hover
[image]

Count Property Example (VB)
Send feedback

This example demonstrates the Count property with two collections in the Employee database. The property obtains the number of objects in each collection, and sets the upper limit for loops that enumerate these collections. Another way to enumerate these collections without using the Count property would be to use statements.

Copy code Copy code

'BeginCountVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 ' recordset and connection variables
 Dim rstEmployees As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strSQLEmployees As String
 Dim strCnxn As String

 Dim intLoop As Integer

 ' Open a connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Northwind';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open recordset with data from Employee table
 Set rstEmployees = New ADODB.Recordset
 strSQLEmployees = "Employees"
 'rstEmployees.Open strSQLEmployee, Cnxn, , , adCmdTable
 rstEmployees.Open strSQLEmployees, Cnxn, adOpenForwardOnly, adLockReadOnly, adCmdTable
 'the above two lines opening the recordset are identical as
 'the default values for CursorType and LockType arguments match those specified

 ' Print information about Fields collection
 Debug.Print rstEmployees.Fields.Count & " Fields in Employee"

 For intLoop = 0 To rstEmployees.Fields.Count - 1
 Debug.Print " " & rstEmployees.Fields(intLoop).Name
 Next intLoop

 ' Print information about Properties collection
 Debug.Print rstEmployees.Properties.Count & " Properties in Employee"

 For intLoop = 0 To rstEmployees.Properties.Count - 1
 Debug.Print " " & rstEmployees.Properties(intLoop).Name
 Next intLoop

 ' clean up
 rstEmployees.Close
 Cnxn.Close
 Set rstEmployees = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstEmployees Is Nothing Then
 If rstEmployees.State = adStateOpen Then rstEmployees.Close
 End If
 Set rstEmployees = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndCountVB


BoundObjectFrame.Visible Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents a BoundObjectFrame object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


NavigationButton.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

NavigationButton.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthLeft

expression A variable that represents a NavigationButton object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


The filters defining a partial replica are out of synch with each other. (Error 3570)

 Copy code hover
[image]

The filters defining a partial replica are out of synch with each other. (Error 3570)
Send feedback

You have changed the filters in the partial replica since the last time you populated your partial replica. You must repopulate the partial replica by either running the Partial Replica Wizard, or by using the PopulatePartial Method in VBA code.


Could not find network path or user name. (Error 3171)

 Copy code hover
[image]

Could not find network path or user name. (Error 3171)
Send feedback

One or more entries in the \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Access Connectivity Engine\Engines\Paradox key of the Microsoft Windows Registry is invalid. Correct the invalid entries, and then try the operation again.


Rectangle.MouseDown Event (Access)

 Copy code hover
[image]

Rectangle.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents a Rectangle object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
         Shift As Integer, X As Single, _
         Y As Single)
    If Button = acLeftButton Then
        MsgBox "You pressed the left button."
    End If
    If Button = acRightButton Then
        MsgBox "You pressed the right button."
    End If
    If Button = acMiddleButton Then
        MsgBox "You pressed the middle button."
    End If
End Sub

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


AllViews Properties (Access)

 Copy code hover
[image]

AllViews Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


DimensionCount Property (ADO MD)

 Copy code hover
[image]

DimensionCount Property (ADO MD)
Send feedback

Indicates the number of dimensions on an axis.

Return Values

Returns a Long integer, and is read-only.


Synchronizer cannot find the record of a specific synchronization in the MSysExchangeLog table. (Error 3522)

 Copy code hover
[image]

Synchronizer cannot find the record of a specific synchronization in the MSysExchangeLog table. (Error 3522)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


Application.AutoCorrect Property (Access)

 Copy code hover
[image]

Application.AutoCorrect Property (Access)
See also Send feedback

Published: July 16, 2012

Returns an AutoCorrect object that represents the AutoCorrect settings for Microsoft Access. Read-only.

Syntax

expression .AutoCorrect

expression A variable that represents an Application object.

See also

Concepts

Application Object

Other resources

Application Object Members


Rectangle Events (Access)

 Copy code hover
[image]

Rectangle Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.


AcColorIndex Enumeration (Access)

 Copy code hover
[image]

AcColorIndex Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the color to apply.

Name | Value | Description
acColorIndexAqua | 14 | Aqua color.
acColorIndexBlack | 0 | Black color.
acColorIndexBlue | 12 | Blue color.
acColorIndexBrightGreen | 10 | Bright green color.
acColorIndexDarkBlue | 4 | Dark blue color.
acColorIndexFuschia | 13 | Fuchsia color.
acColorIndexGray | 7 | Gray color.
acColorIndexGreen | 2 | Green color.
acColorIndexMaroon | 1 | Maroon color.
acColorIndexOlive | 3 | Olive color.
acColorIndexRed | 9 | Red color.
acColorIndexSilver | 8 | Silver color.
acColorIndexTeal | 6 | Teal color.
acColorIndexViolet | 5 | Violet color.
acColorIndexWhite | 15 | White color.
acColorIndexYellow | 11 | Yellow color.


Property.Inherited Property (DAO)

 Copy code hover
[image]

Property.Inherited Property (DAO)
Send feedback

Returns a value that indicates whether a Property object is inherited from an underlying object.

Syntax

expression .Inherited

expression A variable that represents a Property object.

Remarks

For built-in Property objects that represent predefined properties, the only possible return value is False.

You can use the Inherited property to determine whether a user-defined Property was created for the object it applies to, or whether the Property was inherited from another object. For example, suppose you create a new Property for a QueryDef object and then open a Recordset object from the QueryDef object. This new Property will be part of the Recordset object's Properties collection, and its Inherited property will be set to True because the property was created for the QueryDef object, not the Recordset object.

Example

This example use the Inherited property to determine if a user-defined Property object was created for a Recordset object or for some underlying object.

VBA Copy code Copy code
Sub InheritedX()

 Dim dbsNorthwind As Database
 Dim tdfTest As TableDef
 Dim rstTest As Recordset
 Dim prpNew As Property
 Dim prpLoop As Property

 ' Create a new property for a saved TableDef object, then
 ' open a recordset from that TableDef object.
 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set tdfTest = dbsNorthwind.TableDefs(0)
 Set prpNew = tdfTest.CreateProperty("NewProperty", _
 dbBoolean, True)
 tdfTest.Properties.Append prpNew
 Set rstTest = tdfTest.OpenRecordset(dbOpenForwardOnly)

 ' Show Name and Inherited property of the new Property
 ' object in the TableDef.
 Debug.Print "NewProperty of " & tdfTest.Name & _
 " TableDef:"
 Debug.Print " Inherited = " & _
 tdfTest.Properties("NewProperty").Inherited

 ' Show Name and Inherited property of the new Property
 ' object in the Recordset.
 Debug.Print "NewProperty of " & rstTest.Name & _
 " Recordset:"
 Debug.Print " Inherited = " & _
 rstTest.Properties("NewProperty").Inherited

 ' Delete new TableDef because this is a demonstration.
 tdfTest.Properties.Delete prpNew.Name
 dbsNorthwind.Close

End Sub


WebBrowserControl.Application Property (Access)

 Copy code hover
[image]

WebBrowserControl.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Version Information

Version Added: Access 2010

Syntax

expression .Application

expression A variable that represents a WebBrowserControl object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Field2.OriginalValue Property (DAO)

 Copy code hover
[image]

Field2.OriginalValue Property (DAO)
Send feedback

Syntax

expression .OriginalValue

expression A variable that represents a Field2 object.

Remarks

During an optimistic batch update, a collision may occur where a second client modifies the same field and record in between the time the first client retrieves the data and the first client's update attempt. The OriginalValue property contains the value of the field at the time the last batch Update began. If this value does not match the value actually in the database when the batch Update attempts to write to the database, a collision occurs. When this happens, the new value in the database will be accessible through the VisibleValue property.


Connect Property (RDS)

 Copy code hover
[image]

Connect Property (RDS)
Send feedback

Indicates the database name from which the query and update operations are run.

You can set the Connect property at design time in the RDS.DataControl object's OBJECT tags, or at run time in scripting code (for instance, VBScript).

Syntax

Design time: <PARAM NAME="Connect" VALUE="ConnectionString">

Run time: DataControl.Connect = "ConnectionString"

Parameters

  • ConnectionString

  • A valid connection string. For more general information about connection strings, see the ConnectionString property or your provider documentation.

    Note Note

    Specifying MS Remote as the provider for the RDS.DataControl would create a four-tier scenario. Scenarios greater than three tiers have not been tested and should not be needed.

  • DataControl

  • An object variable that represents an RDS.DataControl object.


Cannot delete from a Prevent Deletes Replica. (Error 3754)

 Copy code hover
[image]

Cannot delete from a Prevent Deletes Replica. (Error 3754)
Send feedback

A Prevent Deletes replica is a replica designed to prevent users from deleting records. If a delete is desired it must be executed at a replica that allows deletes.


Page.Requery Method (Access)

 Copy code hover
[image]

Page.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.

Syntax

expression .Requery

expression A variable that represents a Page object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts .

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate function.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

Example

The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form:

VBA Copy code Copy code
Public Sub RequeryList()

    Dim ctlCombo As Control

    ' Return Control object pointing to a combo box.
    Set ctlCombo = Forms!Employees!ReportsTo

    ' Requery source of data for list box.
    ctlCombo.Requery

End Sub

See also

Concepts

Page Object

Other resources

Page Object Members


TabControl.HoverForeColor Property (Access)

 Copy code hover
[image]

TabControl.HoverForeColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the text displayed on the control when the user rests the mouse cursor over it. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HoverForeColor

expression A variable that represents a TabControl object.

Remarks

The HoverForeColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


CodeProject.IsTrusted Property (Access)

 Copy code hover
[image]

CodeProject.IsTrusted Property (Access)
See also Send feedback

Published: July 16, 2012

Gets whether or not macros and Visual Basic for Applications (VBA) code have been enabled in the current project. Read-only Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .IsTrusted

expression A variable that represents a CodeProject object.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


RDS API Reference

 Copy code hover
[image]

RDS API Reference
Send feedback

This section of the ADO documentation contains topics for each RDS object, property, method, and event. For more information, search for a specific topic in the index or refer to the following topics:

  • RDS Objects

  • RDS Properties

  • RDS Methods

  • RDS Events


Catalog ActiveConnection Property Example (VB)

 Copy code hover
[image]

Catalog ActiveConnection Property Example (VB)
Send feedback

Setting the ActiveConnection property to a valid, open connection "opens" the catalog. From an open catalog, you can access the schema objects contained within that catalog.

Copy code Copy code

' BeginOpenConnectionVB
Sub OpenConnection()
 On Error GoTo OpenConnectionError

 Dim cnn As New ADODB.Connection
 Dim cat As New ADOX.Catalog

 cnn.Open "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source= 'c:\Program Files\Microsoft Office\" & _
 "Office\Samples\Northwind.mdb';"
 Set cat.ActiveConnection = cnn
 Debug.Print cat.Tables(0).Type

 'Clean up
 cnn.Close
 Set cat = Nothing
 Set cnn = Nothing
 Exit Sub

OpenConnectionError:

 Set cat = Nothing

 If Not cnn Is Nothing Then
 If cnn.State = adStateOpen Then cnn.Close
 End If
 Set cnn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndOpenConnectionVB

Setting the ActiveConnection property to a valid connection string also "opens" the catalog.

Copy code Copy code
                      ' BeginOpenConnection2VB
Sub Main()
 On Error GoTo OpenConnectionWithStringError
 Dim cat As New ADOX.Catalog

 cat.ActiveConnection = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\Microsoft Office\" & _
 "Office\Samples\Northwind.mdb';"
 Debug.Print cat.Tables(0).Type

 'Clean up
 Set cat.ActiveConnection = Nothing
 Exit Sub

OpenConnectionWithStringError:
 Set cat = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndOpenConnection2VB


Could not create; no modify design permission for table or query

 Copy code hover
[image]

Could not create; no modify design permission for table or query <name>. (Error 3111)
Send feedback

You tried to create the specified table or query, but you do not have the required modify design permission. To change your permission assignments, see your system administrator or the query's creator.


A problem occurred in your database. Correct the problem by repairing and compacting the database. (Error 3428)

 Copy code hover
[image]

A problem occurred in your database. Correct the problem by repairing and compacting the database. (Error 3428)
Send feedback

The database you are attempting to use has an unspecified problem and, as a result, it is marked as corrupt.

To correct the problem

  1. Close the database.

  2. Repair the database with the RepairDatabase method.

  3. Compact the database with the CompactDatabase method.

Important note Important

All steps are required.


ObjectFrame.ObjectPalette Property (Access)

 Copy code hover
[image]

ObjectFrame.ObjectPalette Property (Access)
See also Send feedback

Published: July 16, 2012

The ObjectPalette property specifies the palette in the application used to create an OLE object. Read/write Variant.

Syntax

expression .ObjectPalette

expression A variable that represents an ObjectFrame object.

Remarks

Microsoft Access sets the value of the ObjectPalette property to a String data type containing the palette information. You can use this setting to set the value of the PaintPalette property for a form or report.

If the application associated with the OLE object doesn't have an associated palette, the ObjectPalette property is set to an zero-length string.

The ObjectPalette property is read-only in Form Design view, Form view, and Report Design view. This property setting is unavailable in other views.

The setting of the ObjectPalette property makes the palette of the application associated with the OLE object contained in a control available to the PaintPalette property of a form or report. For example, to make the palette used in Microsoft Graph available when you're designing a form in Microsoft Access, you set the form's PaintPalette property to the ObjectPalette value of an existing chart control.

Note Note

Windows can have only one color palette active at a time. Microsoft Access allows you to have multiple graphics on a form, each using a different color palette. The PaintPalette and PaletteSource properties let you specify which color palette a form should use when displaying graphics.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


CustomControl.SizeToFit Method (Access)

 Copy code hover
[image]

CustomControl.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents a CustomControl object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


CommandButton.PressedThemeColorIndex Property (Access)

 Copy code hover
[image]

CommandButton.PressedThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .PressedThemeColorIndex

expression A variable that represents a CommandButton object.

Remarks

The PressedThemeColorIndex uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 (Default) | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the PressedThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Control.GridlineWidthRight Property (Access)

 Copy code hover
[image]

Control.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified control. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthRight

expression A variable that represents a Control object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Control Object

Other resources

Control Object Members


SmartTag.SmartTagActions Property (Access)

 Copy code hover
[image]

SmartTag.SmartTagActions Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a SmartTagActions collection that represents the actions available for a specific smart tag. Read-only.

Syntax

expression .SmartTagActions

expression A variable that represents a SmartTag object.

Remarks

Smart tag actions are processes that are programmed into smart tags that allow users to perform certain functions related to the smart tag. For example, one action for a smart tag might be to access a Web site, while another action inserts contact information from Microsoft Outlook, while yet another action displays a map and driving directions.

See also

Concepts

SmartTag Object

Other resources

SmartTag Object Members


Form.MinMaxButtons Property (Access)

 Copy code hover
[image]

Form.MinMaxButtons Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the MinMaxButtons property to specify whether the Maximize and Minimize buttons will be visible on a form. Read/write Byte.

Syntax

expression .MinMaxButtons

expression A variable that represents a Form object.

Remarks

The MinMaxButtons property uses the following settings.

Setting | Visual Basic | Description
None | 0 | The Maximize and Minimize buttons aren't visible.
Min Enabled | 1 | Only the Minimize button is visible.
Max Enabled | 2 | Only the Maximize button is visible.
Both Enabled | 3 | (Default) Both the Minimize and Maximize buttons are visible.

You can set the MinMaxButtons property only in form Design view.

Clicking a form's Maximize button enlarges the form so it fills the Microsoft Access window. Clicking a form's Minimize button reduces the form to a short title bar at the bottom of the Microsoft Access window.

To display the Maximize and Minimize buttons on a form, you must set the form's BorderStyle property to Thin or Sizable and the ControlBox property to Yes. If you set the BorderStyle property to None or Dialog, or if you set the ControlBox property to No, the form won't have Maximize or Minimize buttons, regardless of the MinMaxButtons property setting.

Even when the MinMaxButtons property is set to None, a form always has Maximize and Minimize buttons in Design view.

If a form's MinMaxButtons property is set to None, the Maximize and Minimize commands aren't available on the form's Control menu.

Example

The following example returns the value of the MinMaxButtons property for the "Order Entry" form.

VBA Copy code Copy code
Dim b As Byte
b = Forms("Order Entry").MinMaxButtons

See also

Concepts

Form Object

Other resources

Form Object Members


Floor Function (Access 2013 custom web app)

 Copy code hover
[image]

Floor Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the largest integer less than or equal to the specified numeric expression.

Syntax

Floor(NumericExpression)

The Floor function contains the following argument.

Argument name | Description
NumericExpression | A numeric expression.


Dimension Object (ADO MD)

 Copy code hover
[image]

Dimension Object (ADO MD)
Send feedback

Represents one of the dimensions of a multidimensional cube, containing one or more hierarchies of members.

Remarks

With the collections and properties of a Dimension object, you can do the following:

  • Identify the Dimension with the Name and UniqueName properties.

  • Return a meaningful string that describes the Dimension with the Description property.

  • Return the Hierarchy objects that make up the Dimension with the Hierarchies collection.

  • Use the standard ADO Properties collection to obtain additional information about the Dimension object.

The Properties collection contains provider-supplied properties. The following table lists properties that might be available. The actual property list may differ depending upon the implementation of the provider. See the documentation for your provider for a more complete list of available properties.

Name | Description
CatalogName | The name of the catalog to which this cube belongs.
CubeName | The name of the cube.
DefaultHierarchy | The unique name of the default hierarchy.
Description | A meaningful description of the cube.
DimensionCaption | A label or caption associated with the dimension.
DimensionCardinality | The number of members in the dimension.
DimensionGUID | The GUID of the dimension.
DimensionName | The name of the dimension.
DimensionOrdinal | The ordinal number of the dimension among the group of dimensions that form the cube.
DimensionType | The dimension type.
DimensionUniqueName | The unambiguous name of the dimension.
SchemaName | The name of the schema to which this cube belongs.


Section.Properties Property (Access)

 Copy code hover
[image]

Section.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a Section object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

Section Object

Other resources

Section Object Members


BeginTrans, CommitTrans, and RollbackTrans Methods Example (VB)

 Copy code hover
[image]

BeginTrans, CommitTrans, and RollbackTrans Methods Example (VB)
Send feedback

This example changes the book type of all psychology books in the Titles table of the database. After the BeginTrans method starts a transaction that isolates all the changes made to the Titles table, the CommitTrans method saves the changes. You can use the RollbackTrans method to undo changes that you saved using the Update method.

Copy code Copy code

'BeginBeginTransVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 'recordset and connection variables
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim rstTitles As ADODB.Recordset
 Dim strSQLTitles As String
 'record variables
 Dim strTitle As String
 Dim strMessage As String

 ' Open connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Set Cnxn = New ADODB.Connection
 Cnxn.Open strCnxn

 ' Open recordset dynamic to allow for changes
 Set rstTitles = New ADODB.Recordset
 strSQLTitles = "Titles"
 rstTitles.Open strSQLTitles, Cnxn, adOpenDynamic, adLockPessimistic, adCmdTable

 Cnxn.BeginTrans

 ' Loop through recordset and prompt user
 ' to change the type for a specified title

 rstTitles.MoveFirst

 Do Until rstTitles.EOF
 If Trim(rstTitles!Type) = "psychology" Then
 strTitle = rstTitles!Title
 strMessage = "Title: " & strTitle & vbCr & _
 "Change type to self help?"

 ' If yes, change type for the specified title
 If MsgBox(strMessage, vbYesNo) = vbYes Then
 rstTitles!Type = "self_help"
 rstTitles.Update
 End If
 End If
 rstTitles.MoveNext
 Loop

 ' Prompt user to commit all changes made
 If MsgBox("Save all changes?", vbYesNo) = vbYes Then
 Cnxn.CommitTrans
 Else
 Cnxn.RollbackTrans
 End If

 ' Print recordset
 rstTitles.Requery
 rstTitles.MoveFirst
 Do While Not rstTitles.EOF
 Debug.Print rstTitles!Title & " - " & rstTitles!Type
 rstTitles.MoveNext
 Loop

 ' Restore original data as this is a demo
 rstTitles.MoveFirst

 Do Until rstTitles.EOF
 If Trim(rstTitles!Type) = "self_help" Then
 rstTitles!Type = "psychology"
 rstTitles.Update
 End If
 rstTitles.MoveNext
 Loop

 ' clean up
 rstTitles.Close
 Cnxn.Close
 Set rstTitles = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstTitles Is Nothing Then
 If rstTitles.State = adStateOpen Then rstTitles.Close
 End If
 Set rstTitles = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub

'EndBeginTransVB


JOIN operation

 Copy code hover
[image]

JOIN operation <operation> refers to a field that is not in one of the joined tables. (Error 3082)
Send feedback

You tried to execute an SQL statement that contains an invalid join. This error occurs when you try to create a join on a field that is not in one of the joined tables. The following example produces this error.

SQL Copy code Copy code
SELECT Authors.FirstName, Titles.ISBN
FROM Authors, Titles, AuthorTitles,
Authors INNER JOIN Titles ON Authors.ID = AuthorTitles.ISBN;

The error occurs because the join involves the Authors and Titles tables, but the joined fields are in the Authors and AuthorTitles tables.


Image.ControlTipText Property (Access)

 Copy code hover
[image]

Image.ControlTipText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.

Syntax

expression .ControlTipText

expression A variable that represents an Image object.

Remarks

You set the ControlTipText property by using a string expression up to 255 characters long.

For controls on forms, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

You can set the ControlTipText property in any view.

The ControlTipText property provides an easy way to provide helpful information about controls on a form.

There are other ways to provide information about a form or a control on a form. You can use the StatusBarText property to display information in the status bar about a control. To provide more extensive help for a form or control, use the HelpFile and HelpContextID properties.

See also

Concepts

Image Object

Other resources

Image Object Members


The data being exported does not match the format described in the Schema.ini file. (Error 3438)

 Copy code hover
[image]

The data being exported does not match the format described in the Schema.ini file. (Error 3438)
Send feedback

Make sure the data being exported matches the format described in the Schema.ini file.


Image.Hyperlink Property (Access)

 Copy code hover
[image]

Image.Hyperlink Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.

Syntax

expression .Hyperlink

expression A variable that represents an Image object.

Example

The CreateHyperlink procedure in the following example sets the hyperlink properties for a command button, label, or image control to the address and subaddress values passed to the procedure. The address setting is an optional argument, because a hyperlink to an object in the current database uses only the subaddress setting, To try this example, create a form with two text box controls (txtAddress and txtSubAddress) and a command button (cmdFollowLink) and paste the following into the Declarations section of the form's module:

VBA Copy code Copy code
Private Sub cmdFollowLink_Click()
 CreateHyperlink Me!cmdFollowLink, Me!txtSubAddress, _
 Me!txtAddress
End Sub

Sub CreateHyperlink(ctlSelected As Control, _
 strSubAddress As String, Optional strAddress As String)
 Dim hlk As Hyperlink
 Select Case ctlSelected.ControlType
 Case acLabel, acImage, acCommandButton
 Set hlk = ctlSelected.Hyperlink
 With hlk
 If Not IsMissing(strAddress) Then
 .Address = strAddress
 Else
 .Address = ""
 End If
 .SubAddress = strSubAddress
 .Follow
 .Address = ""
 .SubAddress = ""
 End With
 Case Else
 MsgBox "The control '" & ctlSelected.Name _
 & "' does not support hyperlinks."
 End Select
End Sub

See also

Concepts

Image Object

Other resources

Image Object Members


Workspace Members (DAO)

 Copy code hover
[image]

Workspace Members (DAO)
Send feedback

A Workspace object defines a named session for a user. It contains open databases and provides mechanisms for simultaneous transactions and, in Microsoft Access workspaces, secure workgroup support.

Methods

Name

Description

BeginTrans

Begins a new transaction. Read/write Database.

Close

Closes an open Workspace.

CommitTrans

Ends the current transaction and saves the changes.

CreateDatabase

Creates a new Database object, saves the database to disk, and returns an opened Database object (Microsoft Access workspaces only).

OpenConnection

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Opens a Connection object on an ODBC data source (ODBCDirect workspaces only).

OpenDatabase

Opens a specified database in a Workspace object and returns a reference to the Database object that represents it.

Rollback

Ends the current transaction and restores the databases in the Workspace object to the state they were in when the current transaction began.

Properties

Name

Description

Connections

Returns a Connections collection that represents the current connections in the specified Workspace. Read-only.

Databases

Returns a Databases collection that represents the open databases in the specified Workspace. Read-only.

DefaultCursorDriver

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Sets or returns the type of cursor driver used on the connection created by the OpenConnection or OpenDatabase methods (ODBCDirect workspaces only).

IsolateODBCTrans

Sets or returns a value that indicates whether multiple transactiond that involve the same Microsoft Access database engine-connected ODBC data source are isolated (Microsoft Access workspaces only).

LoginTimeout

Sets or returns the number of seconds before an error occurs when you attempt to log on to an ODBC database.

Name

Returns or sets the name of the specified object. Read/write String if the object has not been appended to a collection. Read-only String if the object has been appended to a collection.

Properties

Returns the Properties collection of the specified object. Read-only.

Type

Sets or returns a value that indicates the operational type or data type of an object. Read-only Integer.


Cannot perform cascading operation. It would result in two updates to field

 Copy code hover
[image]

Cannot perform cascading operation. It would result in two updates to field <name> in table <name>. (Error 3400)
Send feedback

The cascade operation you are attempting cannot be completed because it would result in two separate updates to the indicated field. Check the values you are attempting to update, and fix them so that either:

  • The field is updated only one time.

  • If the field is updated more than once, the result of each update to the field is the same.


Sharing violation while attempting to open log file

 Copy code hover
[image]

Sharing violation while attempting to open log file <name> in Deny Write mode. (Error 3475)
Send feedback

Close the log file in all other applications.


Report.DefaultControl Property (Access)

 Copy code hover
[image]

Report.DefaultControl Property (Access)
See also Send feedback

Published: July 16, 2012

The DefaultControl property returns a Control object with which you can set the default properties for a particular type of control on a particular report. Read-only.

Syntax

expression .DefaultControl(ControlType)

expression A variable that represents a Report object.

Parameters

Name | Required/Optional | Data Type | Description
ControlType | Required | Long | An AcControlType constant that indicates the type of control for which default property settings are to be set.

Remarks

The DefaultControl property enables you to set a control's default properties from code. Once you have set the default properties for a particular type of control, each subsequently created control of that type will have the same default values.

For example, if you set the FontSize property of the default command button to 12, each new command button will have a font size of 12 points.

Not all of a control's properties are available as default properties. The default properties available for a control depend on the type of control.

The DefaultControl property returns a Control object of the type specified by the controltype argument. This Control object doesn't represent an actual control on a form, but rather a default control that is a template for all subsequently created controls of that type. You set the default control properties for the Control object returned by the DefaultControl property in the same manner that you would set properties for an individual control on a form.

The DefaultControl property can be used only in form Design view or report Design view. If you try to apply this property to a form or report that is not in Design view, a run-time error will result.

If you try to set a property that can't be set as a default property with the DefaultControl property, a run-time error will result. To determine which properties can be default properties, list the Properties collection of the Control object returned by the DefaultControl property.

Example

The following example creates a new form and uses the DefaultControl property to return a Control object representing the default command button. The procedure sets some of the default properties for the command button, then creates a new command button on the form.

VBA Copy code Copy code
Sub SetDefaultProperties()
 Dim frm As Form, ctlDefault As Control, ctlNew As Control

 ' Create new form.
 Set frm = CreateForm
 ' Return Control object representing default command button.
 Set ctlDefault = frm.DefaultControl(acCommandButton)
 ' Set some default properties.
 With ctlDefault
 .FontWeight = 700
 .FontSize = 12
 .Width = 3000
 .Height = 1000
 End With
 ' Create new command button.
 Set ctlNew = CreateControl(frm.Name, acCommandButton, , , , 500, 500)
 ' Set control's caption.
 ctlNew.caption = "New Command Button"
 ' Restore form.
 DoCmd.Restore
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


Module.CreateEventProc Method (Access)

 Copy code hover
[image]

Module.CreateEventProc Method (Access)
See also Send feedback

Published: July 16, 2012

The CreateEventProc method creates an event procedure in a class module.

Syntax

expression .CreateEventProc(EventName, ObjectName)

expression A variable that represents a Module object.

Parameters

Name | Required/Optional | Data Type | Description
EventName | Required | String | The name of an event.
ObjectName | Required | String | An object that has the event specified by the eventname argument. If the event procedure is being added to a Form, the word "Form" should be specified for this argument. If the event procedure is being added to a Report, the word "Report" should be specified for this argument. If the event procedure is being added to a Control, the name of the control should be specified for this argument.

Return Value

Long

Remarks

The value returned by the CreateEventProc method indicates the line number of the first line of the event procedure.

The CreateEventProc method creates a code stub for an event procedure for the specified object. For example, you can use this method to create a Click event procedure for a command button on a form. Microsoft Access creates the Click event procedure in the module associated with the form that contains the command button.

Once you've created the event procedure code stub by using the CreateEventProc method, you can add lines of code to the procedure by using other methods of the Module object. For example, you can use the InsertLines method to insert a line of code.

Example

The following example creates a new form, adds a command button, and creates a Click event procedure for the command button:

VBA Copy code Copy code
Function ClickEventProc() As Boolean
 Dim frm As Form, ctl As Control, mdl As Module
 Dim lngReturn As Long

 On Error GoTo Error_ClickEventProc
 ' Create new form.
 Set frm = CreateForm
 ' Create command button on form.
 Set ctl = CreateControl(frm.Name, acCommandButton, , , , _
 1000, 1000)
 ctl.Caption = "Click here"
 ' Return reference to form module.
 Set mdl = frm.Module
 ' Add event procedure.
 lngReturn = mdl.CreateEventProc("Click", ctl.Name)
 ' Insert text into body of procedure.
 mdl.InsertLines lngReturn + 1, vbTab & "MsgBox ""Way cool!"""
 ClickEventProc = True

Exit_ClickEventProc:
 Exit Function

Error_ClickEventProc:
 MsgBox Err & " :" & Err.Description
 ClickEventProc = False
 Resume Exit_ClickEventProc
End Function

See also

Concepts

Module Object

Other resources

Module Object Members


Read, ReadText, Write, and WriteText Methods Example (VB)

 Copy code hover
[image]

Read, ReadText, Write, and WriteText Methods Example (VB)
Send feedback

This example demonstrates how to read the contents of a text box into both a text Stream and a binary Stream. Other properties and methods shown include Position, Size, Charset, and SetEOS.

Copy code Copy code

'BeginReadVB
Private Sub cmdRead_Click()
 On Error GoTo ErrorHandler

 'Declare variables
 Dim objStream As Stream
 Dim varA As Variant
 Dim bytA() As Byte
 Dim i As Integer
 Dim strBytes As String

 'Instantiate and Open Stream
 Set objStream = New Stream
 objStream.Open

 'Write the text content of a textbox to the stream
 If Text1.Text = "" Then
 Err.Raise 1, , "The text field is blank."
 End If
 objStream.WriteText Text1.Text

 'Display the text contents and size of the stream
 objStream.Position = 0
 Debug.Print "Default text:"
 Debug.Print objStream.ReadText
 Debug.Print objStream.Size

 'Switch character set and display
 objStream.Position = 0
 objStream.Charset = "Windows-1252"
 Debug.Print "New Charset text:"
 Debug.Print objStream.ReadText
 Debug.Print objStream.Size

 'Switch to a binary stream and display
 objStream.Position = 0
 objStream.Type = adTypeBinary
 Debug.Print "Binary:"
 Debug.Print objStream.Read
 Debug.Print objStream.Size

 'Load an array of bytes with the text box text
 ReDim bytA(Len(Text1.Text))
 For i = 1 To Len(Text1.Text)
 bytA(i - 1) = CByte(Asc(Mid(Text1.Text, i, 1)))
 Next

 'Write the buffer to the binary stream and display
 objStream.Position = 0
 objStream.Write bytA()
 objStream.SetEOS
 objStream.Position = 0
 Debug.Print "Binary after Write:"
 Debug.Print objStream.Read
 Debug.Print objStream.Size

 'Switch back to a text stream and display
 Debug.Print "Translated back:"
 objStream.Position = 0
 objStream.Type = adTypeText
 Debug.Print objStream.ReadText
 Debug.Print objStream.Size

 ' clean up
 objStream.Close
 Set objStream = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not objStream Is Nothing Then
 If objStream.State = adStateOpen Then objStream.Close
 End If
 Set objStream = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndReadVB


ComplexType Object Reference (DAO)

 Copy code hover
[image]

ComplexType Object Reference (DAO)
Send feedback

In this section

  • ComplexType Object (DAO)

  • ComplexType Members (DAO)

  • ComplexType Properties (DAO)


Form.Unload Event (Access)

 Copy code hover
[image]

Form.Unload Event (Access)
See also Send feedback

Published: July 16, 2012

The Unload event occurs after a form is closed but before it's removed from the screen. When the form is reloaded, Microsoft Access redisplays the form and reinitializes the contents of all its controls.

Syntax

expression .Unload(Cancel, )

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | Set to True to cancel the Unload event.

Remarks

To run a macro or event procedure when these events occur, set the OnUnload property to the name of the macro or to [Event Procedure].

The Unload event is caused by user actions such as:

  • Closing the form.

  • Running the Close action in a macro.

  • Quitting an application by right-clicking the application's taskbar button and then clicking Close.

  • Quitting Windows while an application is running.

By running a macro or an event procedure when a form's Unload event occurs, you can verify that the form should be unloaded or specify actions that should take place when the form is unloaded. You can also open another form or display a dialog box requesting the user's name to make a log entry indicating who used the form.

When you close a form, the following events occur in this order:

Unload → Deactivate → Close

The Unload event occurs before the Close event. The Unload event can be canceled, but the Close event can't.

Note Note

When you create macros or event procedures for events related to the Unload event, such as Deactivate and LostFocus, be sure that they don't conflict (for example, make sure you don't cause something to happen in one macro or procedure that is canceled in another) and that they don't cause cascading events.

Example

This example prompts the user to verify that the form should close.

To try the example, add the following event procedure to a form. In Form view, close the form to display the dialog box, and then click Yes or No.

VBA Copy code Copy code
Private Sub Form_Unload(Cancel As Integer)
 If MsgBox("Close form?", vbYesNo) = vbYes Then
 Exit Sub
 Else
 Cancel = True
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


TextBox.RightMargin Property (Access)

 Copy code hover
[image]

TextBox.RightMargin Property (Access)
See also Send feedback

Published: July 16, 2012

Along with the TopMargin, Left Margin, and BottomMargin properties, specifies the location of information displayed within text box control. Read/write Integer.

Syntax

expression .RightMargin

expression A variable that represents a TextBox object.

Remarks

A control's displayed information location is measured from the control's left, top, right, or bottom border to the left, top, right, or bottom edge of the displayed information. To use a unit of measurement different from the setting in the regional settings of Windows, specify the unit (for example, cm or in).

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


CustomControl.Cancel Property (Access)

 Copy code hover
[image]

CustomControl.Cancel Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Cancel property to specify whether a command button is also the Cancel button on a form. Read/write Boolean.

Syntax

expression .Cancel

expression A variable that represents a CustomControl object.

Remarks

The Cancel property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The command button is the Cancel button.
No | False | (Default) The command button isn't the Cancel button.

Setting the Cancel property to Yes makes the command button the Cancel button in the form. However, you must still write the macro or Visual Basic event procedure that performs whatever action or actions you want the Cancel button to carry out (for example, closing the form without saving any changes to it). Set the command button's OnClick event property to the name of the macro or event procedure.

When a command button's Cancel property setting is Yes and the Form window is active, the user can choose the command button by pressing ESC, by pressing ENTER when the command button has the focus, or by clicking the command button.

Note Note

If a text box has the focus when the user presses ESC, any changes made to the data in the text box will be lost, and the original data will be restored.

When the Cancel property is set to Yes for one command button on a form, it is automatically set to No for all other command buttons on the form.

For a form that supports irreversible operations, such as deletions, it's a good idea to make the Cancel button the default command button. To do this, set both the Cancel property and the Default property to Yes.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


How to: Work with Form and Report Printer Settings

 Copy code hover
[image]

How to: Work with Form and Report Printer Settings
Send feedback

The Printer objects associated with Form and Report objects support the same properties and programming techniques as the Application 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:

  • 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 method before closing the form or report, or specify acSaveYes for the Save argument when using the Close method to close the form or report.

Note 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:

VBA Copy code Copy code
                      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.

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.

VBA Copy code Copy code
For Each obj In CurrentProject.AllReports
    DoCmd.OpenReport ReportName:=obj.Name, View:=acViewDesign
    If Not Reports(obj.Name).UseDefaultPrinter Then
        Reports(obj.Name).UseDefaultPrinter = True
        DoCmd.Save ObjectType:=acReport, ObjectName:=obj.Name
    End If
    DoCmd.Close
Next obj

Preserving 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.

VBA Copy code Copy code
Sub RestoreReportPrinter()
    Dim rpt As Report
    Dim prtOld As Printer
    Dim prtNew As Printer

    ' Open the Invoice report in Print Preview.
    DoCmd.OpenReport ReportName:="Invoice", View:=acViewPreview

    ' Initialize rpt variable.
    Set rpt = Reports!Invoice

    ' Save the report's current printer settings
    ' in the prtOld variable.
    Set prtOld = rpt.Printer

    ' Load the report's current printer settings
    ' into the prtNew variable.
    Set prtNew = rpt.Printer

    ' Change the report's Orientation property.
    prtNew.Orientation = acPRORLandscape

    ' Change other Printer properties, and then print
    ' or perform other operations here.

    ' If you comment out the following line of code,
    ' and a user interactively closes the report preview
    ' any changes made to properties of the report's Printer
    ' object are saved when the report is closed.
    Set rpt.Printer = prtOld

    ' Close report without saving.
    DoCmd.Close ObjectType:=acReport, ObjectName:="Invoice", Save:=acSaveNo

End Sub


Cannot perform join, group, sort, or indexed restriction. A value being searched or sorted on is too long. (Error 3393)

 Copy code hover
[image]

Cannot perform join, group, sort, or indexed restriction. A value being searched or sorted on is too long. (Error 3393)
Send feedback

The maximum combined length of fields used to join, group, or sort is 255 bytes. Reduce the number of fields in your join, group, or sort, or use shorter data types and field sizes for the fields.


Recordset.UpdateOptions Property (DAO)

 Copy code hover
[image]

Recordset.UpdateOptions Property (DAO)
Send feedback

Syntax

expression .UpdateOptions

expression A variable that represents a Recordset object.

Remarks

When a batch-mode Update is executed, DAO and the client batch cursor library create a series of SQL UPDATE statements to make the needed changes. An SQL WHERE clause is created for each update to isolate the records that are marked as changed by the RecordStatus property. Because some remote servers use triggers or other ways to enforce referential integrity, is it often important to limit the fields being updated to just those affected by the change. To do this, set the UpdateOptions property to one of the constants dbCriteriaKey, dbCriteriaModValues, dbCriteriaAllCols, or dbCriteriaTimeStamp. This way, only the absolute minimum amount of trigger code is executed. As a result, the update operation is executed more quickly, and with fewer potential errors.

You can also concatenate either of the constants dbCriteriaDeleteInsert or dbCriteriaUpdate to determine whether to use a set of SQL DELETE and INSERT statements or an SQL UPDATE statement for each update when sending batched modifications back to the server. In the former case, two separate operations are required to update the record. In some cases, especially where the remote system implements DELETE, INSERT, and UPDATE triggers, choosing the correct UpdateOptions property setting can significantly impact performance.

If you don't specify any constants, dbCriteriaUpdate and dbCriteriaKey will be used.

Newly added records will always generate INSERT statements and deleted records will always generate DELETE statements, so this property only applies to how the cursor library updates modified records.

Example

This example uses the BatchSize and UpdateOptions properties to control aspects of any batch updating for the specified Recordset object.

VBA Copy code Copy code
Sub BatchSizeX()

 Dim wrkMain As Workspace
 Dim conMain As Connection
 Dim rstTemp As Recordset

 Set wrkMain = CreateWorkspace("ODBCWorkspace", _
 "admin", "", dbUseODBC)
 ' This DefaultCursorDriver setting is required for
 ' batch updating.
 wrkMain.DefaultCursorDriver = dbUseClientBatchCursor

 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conMain = wrkMain.OpenConnection("Publishers", _
 dbDriverNoPrompt, False, _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 ' The following locking argument is required for
 ' batch updating.
 Set rstTemp = conMain.OpenRecordset( _
 "SELECT * FROM roysched", dbOpenDynaset, 0, _
 dbOptimisticBatch)

 With rstTemp
 ' Increase the number of statements sent to the server
 ' during a single batch update, thereby reducing the
 ' number of times an update would have to access the
 ' server.
 .BatchSize = 25

 ' Change the UpdateOptions property so that the WHERE
 ' clause of any batched statements going to the server
 ' will include any updated columns in addition to the
 ' key column(s). Also, any modifications to records
 ' will be made by deleting the original record
 ' and adding a modified version rather than just
 ' modifying the original record.
 .UpdateOptions = dbCriteriaModValues + _
 dbCriteriaDeleteInsert

 ' Engage in batch updating using the new settings
 ' above.
 ' ...

 .Close
 End With

 conMain.Close
 wrkMain.Close

End Sub


Label.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

Label.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified label. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleBottom

expression A variable that represents a Label object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

Label Object

Other resources

Label Object Members


NavigationButton.HoverColor Property (Access)

 Copy code hover
[image]

NavigationButton.HoverColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color displayed on the control when the user rests the mouse cursor over it. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HoverColor

expression A variable that represents a NavigationButton object.

Remarks

The HoverColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Image.Properties Property (Access)

 Copy code hover
[image]

Image.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents an Image object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

Image Object

Other resources

Image Object Members


Append Method (ADOX Keys)

 Copy code hover
[image]

Append Method (ADOX Keys)
Send feedback

Adds a new Key object to the Keys collection.

Syntax

Keys.Append Key [,KeyType] [,Column] [,RelatedTable] [,RelatedColumn]

Parameters

  • Key

  • The Key object to append or the name of the key to create and append.

  • KeyType

  • Optional. A Long value that specifies the type of key. The Key parameter corresponds to the Type property of a Key object.

  • Column

  • Optional. A String value that specifies the name of the column to be indexed. The Columns parameter corresponds to the value of the Name property of a Column object.

  • RelatedTable

  • Optional. A String value that specifies the name of the related table. The RelatedTable parameter corresponds to the value of the Name property of a Table object.

  • RelatedColumn

  • Optional. A String value that specifies the name of the related column for a foreign key. The RelatedColumn parameter corresponds to the value of the Name property of a Column object.

Remarks

The Columns parameter can take either the name of a column or an array of column names.


Line.OldBorderStyle Property (Access)

 Copy code hover
[image]

Line.OldBorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.

Syntax

expression .OldBorderStyle

expression A variable that represents a Line object.

Remarks

The OldBorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines
Note Note

  • If the OldBorderStyle property is set to None or Dialog, the form doesn't have Maximize or Minimize buttons, regardless of its MinMaxButtons property setting.

  • If the OldBorderStyle property is set to None, the form doesn't have a Control menu, regardless of its ControlBox property setting.

  • The OldBorderStyle property setting doesn't affect the display of the scroll bars, navigation buttons, the record number box, or record selectors.

Example

The following example demonstrates the effect of changing a control's BorderStyle property, while leaving the OldBorderStyle unaffected. The example concludes with setting the BorderStyle property to its original unedited value.

VBA Copy code Copy code
With Forms("Order Entry").Controls("Zip Code") .BorderStyle = 3 ' Short dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 3, 1.

    .BorderStyle = 2 ' Dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 2, 1

    .BorderStyle = .OldBorderStyle ' Solid (default) border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 1, 1
End With

See also

Concepts

Line Object

Other resources

Line Object Members


Type Property (ADO)

 Copy code hover
[image]

Type Property (ADO)
Send feedback

Indicates the operational type or data type of a Parameter, Field, or Property object.

Settings and Return Values

Sets or returns a DataTypeEnum value.

Remarks

For Parameter objects, the Type property is read/write. For new Field objects that have been appended to the Fields collection of a Record, Type is read/write only after the Value property for the Field has been specified and the data provider has successfully added the new Field by calling the Update method of the Fields collection.

For all other objects, the Type property is read-only.


Invalid SQL syntax - expected CONSTRAINT name. (Error 3721)

 Copy code hover
[image]

Invalid SQL syntax - expected CONSTRAINT name. (Error 3721)
Send feedback

When defining referential integrity from a SQL DDL statement it is necessary to name a constraint when using the CONSTRAINT keyword. If a constraint name is not desired, then do not use the CONSTRAINT keyword. An example of this error would be: CREATE TABLE Customers (CLstNm TEXT(50), CFrstNm TEXT(25), CONSTRAINT PRIMARY KEY (CFrstNm, CLstNm));.

To prevent the error, include a name after the CONSTRAINT keyword:

CREATE TABLE Customers (CLstNm TEXT(50), CFrstNm TEXT(25), CONSTRAINT pkCustomers PRIMARY KEY (CFrstNm, CLstNm));.

or do not use the CONSTRAINT keyword:

CREATE TABLE Customers (CLstNm TEXT(50), CFrstNm TEXT(25), PRIMARY KEY (CFrstNm, CLstNm));.


QueryDef.Connect Property (DAO)

 Copy code hover
[image]

QueryDef.Connect Property (DAO)
Send feedback

Sets or returns a value that provides information about the source of database used in a pass-through query. Read-only String.

Syntax

expression .Connect

expression A variable that represents a QueryDef object.

Remarks

The Connect property setting is a String composed of a database type specifier and zero or more parameters separated by semicolons. The Connect property passes additional information to ODBC and certain ISAM drivers as needed.

To perform an SQL pass-through query on a table linked to your Microsoft Access database file, you must first set the Connect property of the linked table's database to a valid ODBC connection string.

The path as shown in the following table is the full path for the directory containing the database files and must be preceded by the identifier DATABASE=. In some cases (as with Microsoft Excel and Microsoft Access database engine databases), you should include a specific file name in the database path argument.

The following table shows possible database types and their corresponding database specifiers and paths for the Connect property setting.

Database type | Specifier | Example
Microsoft Access Database | [database]; | drive:\path\filename
dBASE III | dBASE III; | drive:\path
dBASE IV | dBASE IV; | drive:\path
dBASE 5 | dBASE 5.0; | drive:\path
Paradox 3.x | Paradox 3.x; | drive:\path
Paradox 4.x | Paradox 4.x; | drive:\path
Paradox 5.x | Paradox 5.x; | drive:\path
Microsoft Excel 3.0 | Excel 3.0; | drive:\path\filename.xls
Microsoft Excel 4.0 | Excel 4.0; | drive:\path\filename.xls
Microsoft Excel 5.0 or Microsoft Excel 95 | Excel 5.0; | drive:\path\filename.xls
Microsoft Excel 97 | Excel 8.0; | drive:\path\filename.xls
Lotus 1-2-3 WKS and WK1 | Lotus WK1; | drive:\path\filename.wk1
Lotus 1-2-3 WK3 | Lotus WK3; | drive:\path\filename.wk3
Lotus 1-2-3 WK4 | Lotus WK4; | drive:\path\filename.wk4
HTML Import | HTML Import; | drive:\path\filename
HTML Export | HTML Export; | drive:\path
Text | Text; | drive:\path
ODBC | ODBC; DATABASE=database; UID=user; PWD=password; DSN= datasourcename; [LOGINTIMEOUT=seconds;] | None
Microsoft Exchange | Exchange 4.0; MAPILEVEL=folderpath; [TABLETYPE={ 0 | 1 }];[PROFILE=profile;] [PWD=password;] [DATABASE=database;] | drive:\path\filename

If the specifier is only "ODBC;", the ODBC driver displays a dialog box listing all registered ODBC data source names so that the user can select a database.

If a password is required but not provided in the Connect property setting, a login dialog box is displayed the first time a table is accessed by the ODBC driver and again if the connection is closed and reopened.

For data in Microsoft Exchange, the required MAPILEVEL key should be set to a fully-resolved folder path (for example, "Mailbox - Pat SmithIAlpha/Today"). The path does not include the name of the folder that will be opened as a table; that folder's name should instead be specified as the name argument to the CreateTable method. The TABLETYPE key should be set to "0" to open a folder (default) or "1" to open an address book. The PROFILE key defaults to the profile currently in use.

On a QueryDef object in a Microsoft Access workspace, you can use the Connect property with the ReturnsRecords property to create an ODBC SQL pass-through query. The databasetype of the connection string is "ODBC;", and the remainder of the string contains information specific to the ODBC driver used to access the remote data. For more information, see the documentation for the specific driver.

Note Note

  • You must set the Connect property before you set the ReturnsRecords property.

  • You must have access permissions to the computer that contains the database server you're trying to access.


Form.DataChange Property (Access)

 Copy code hover
[image]

Form.DataChange Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the DataChange event occurs. Read/write.

Syntax

expression .DataChange

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the DataChange event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).DataChange = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


DoCmd.CopyDatabaseFile Method (Access)

 Copy code hover
[image]

DoCmd.CopyDatabaseFile Method (Access)
See also Send feedback

Published: July 16, 2012

Copies the database connected to the current project to a Microsoft SQL Server database file for export.

Syntax

expression .CopyDatabaseFile(DatabaseFileName, OverwriteExistingFile, DisconnectAllUsers)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
DatabaseFileName | Required | Variant | The name of the file (and path) to which the current database is copied. If no path is specified, the current directory is used.
OverwriteExistingFile | Optional | Variant | Determines whether Microsoft Access overwrites the file specified by DatabaseFileName. True to overwrite the existing file. If the file doesn't already exist, this argument is ignored
DisconnectAllUsers | Optional | Variant | Determines whether Access disconnects any users connected to the current database in order to make the copy. True to disconnect other users before copying the database file.

Remarks

The file name of the copy must have an .mdf extension in order to be recognized as a SQL Server database file.

The method fails and an error occurs if any of the following occurs:

  • DisconnectAllUsers is True but Access is unable to log off other users.

  • The method cancels a save operation by any open design sessions.

  • The destination file exists but OverwriteExistingFile was not set to True.

  • The destination file exists, but is in use by another application.

  • Access could not reconnect the original .mdf file.

  • The current user for the Access project doesn't have system administrator privileges for the database server.

Example

This example copies the database connected to the current project to a SQL Server database file. If the file exists already, Access overwrites it, and any other users connected to the database are disconnected before the copy is made.

VBA Copy code Copy code
DoCmd.CopySQLDatabaseFile _
 DatabaseFileName:="C:\Export\Sales.mdf", _
 OverwriteExistingFile:=True, _
 DisconnectAllUsers:=True

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Workspace.DefaultCursorDriver Property (DAO)

 Copy code hover
[image]

Workspace.DefaultCursorDriver Property (DAO)
Send feedback

Syntax

expression .DefaultCursorDriver

expression A variable that represents a Workspace object.

Remarks

The setting or return value can be set to one of the CursorDriverEnum constants.

This property setting only affects connections established after the property has been set. Changing the DefaultCursorDriver property has no effect on existing connections.

Example

This example uses the NextRecordset method to view the data from a compound SELECT query. The DefaultCursorDriver property must be set to dbUseODBCCursor when executing such queries. The NextRecordset method will return True even if some or all of the SELECT statements return zero records; it will return False only after all the individual SQL clauses have been checked.

VBA Copy code Copy code
Sub NextRecordsetX()

 Dim wrkODBC As Workspace
 Dim conPubs As Connection
 Dim rstTemp As Recordset
 Dim intCount As Integer
 Dim booNext As Boolean

 ' Create ODBCDirect Workspace object and open Connection
 ' object. The DefaultCursorDriver setting is required
 ' when using compound SQL statements.
 Set wrkODBC = CreateWorkspace("", _
 "admin", "", dbUseODBC)
 wrkODBC.DefaultCursorDriver = dbUseODBCCursor

 ' Note: The DSN referenced below must be set to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conPubs = wrkODBC.OpenConnection("Publishers", , , _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 ' Construct compound SELECT statement.
 Set rstTemp = conPubs.OpenRecordset("SELECT * " & _
 "FROM authors; " & _
 "SELECT * FROM stores; " & _
 "SELECT * FROM jobs")

 ' Try printing results from each of the three SELECT
 ' statements.
 booNext = True
 intCount = 1
 With rstTemp
 Do While booNext
 Debug.Print "Contents of recordset #" & intCount
 Do While Not .EOF
 Debug.Print , .Fields(0), .Fields(1)
 .MoveNext
 Loop
 booNext = .NextRecordset
 Debug.Print " rstTemp.NextRecordset = " & _
 booNext
 intCount = intCount + 1
 Loop
 End With

 rstTemp.Close
 conPubs.Close
 wrkODBC.Close

End Sub

Another way to accomplish the same task would be to create a prepared statement containing the compound SQL statement. The CacheSize property of the QueryDef object must be set to 1, and the Recordset object must be forward-only and read-only.

VBA Copy code Copy code
Sub NextRecordsetX2()

 Dim wrkODBC As Workspace
 Dim conPubs As Connection
 Dim qdfTemp As QueryDef
 Dim rstTemp As Recordset
 Dim intCount As Integer
 Dim booNext As Boolean

 ' Create ODBCDirect Workspace object and open Connection
 ' object. The DefaultCursorDriver setting is required
 ' when using compound SQL statements.
 Set wrkODBC = CreateWorkspace("", _
 "admin", "", dbUseODBC)
 wrkODBC.DefaultCursorDriver = dbUseODBCCursor

 ' Note: The DSN referenced below must be set to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conPubs = wrkODBC.OpenConnection("Publishers", , , _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 ' Create a temporary stored procedure with a compound
 ' SELECT statement.
 Set qdfTemp = conPubs.CreateQueryDef("", _
 "SELECT * FROM authors; " & _
 "SELECT * FROM stores; " & _
 "SELECT * FROM jobs")
 ' Set CacheSize and open Recordset object with arguments
 ' that will allow access to multiple recordsets.
 qdfTemp.CacheSize = 1
 Set rstTemp = qdfTemp.OpenRecordset(dbOpenForwardOnly, _
 dbReadOnly)

 ' Try printing results from each of the three SELECT
 ' statements.
 booNext = True
 intCount = 1
 With rstTemp
 Do While booNext
 Debug.Print "Contents of recordset #" & intCount
 Do While Not .EOF
 Debug.Print , .Fields(0), .Fields(1)
 .MoveNext
 Loop
 booNext = .NextRecordset
 Debug.Print " rstTemp.NextRecordset = " & _
 booNext
 intCount = intCount + 1
 Loop
 End With

 rstTemp.Close
 qdfTemp.Close
 conPubs.Close
 wrkODBC.Close

End Sub

This example uses the RecordStatus and DefaultCursorDriver properties to show how changes to a local Recordset are tracked during batch updating. The RecordStatusOutput function is required for this procedure to run.

VBA Copy code Copy code
Sub RecordStatusX()

 Dim wrkMain As Workspace
 Dim conMain As Connection
 Dim rstTemp As Recordset

 Set wrkMain = CreateWorkspace("ODBCWorkspace", _
 "admin", "", dbUseODBC)
 ' This DefaultCursorDriver setting is required for
 ' batch updating.
 wrkMain.DefaultCursorDriver = dbUseClientBatchCursor

 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conMain = wrkMain.OpenConnection("Publishers", _
 dbDriverNoPrompt, False, _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 ' The following locking argument is required for
 ' batch updating.
 Set rstTemp = conMain.OpenRecordset( _
 "SELECT * FROM authors", dbOpenDynaset, 0, _
 dbOptimisticBatch)

 With rstTemp
 .MoveFirst
 Debug.Print "Original record: " & !au_lname
 Debug.Print , RecordStatusOutput2(.RecordStatus)

 .Edit
 !au_lname = "Bowen"
 .Update
 Debug.Print "Edited record: " & !au_lname
 Debug.Print , RecordStatusOutput2(.RecordStatus)

 .AddNew
 !au_lname = "NewName"
 .Update
 Debug.Print "New record: " & !au_lname
 Debug.Print , RecordStatusOutput2(.RecordStatus)

 .Delete
 Debug.Print "Deleted record: " & !au_lname
 Debug.Print , RecordStatusOutput2(.RecordStatus)

 ' Close the local recordset without updating the
 ' data on the server.
 .Close
 End With

 conMain.Close
 wrkMain.Close

End Sub

Function RecordStatusOutput(lngTemp As Long) As String

 Dim strTemp As String

 strTemp = ""

 ' Construct an output string based on the RecordStatus
 ' value.
If lngTemp = dbRecordUnmodified Then _
 strTemp = "[dbRecordUnmodified]"
 If lngTemp = dbRecordModified Then _
 strTemp = "[dbRecordModified]"
 If lngTemp = dbRecordNew Then _
 strTemp = "[dbRecordNew]"
 If lngTemp = dbRecordDeleted Then _
 strTemp = "[dbRecordDeleted]"
 If lngTemp = dbRecordDBDeleted Then _
 strTemp = "[dbRecordDBDeleted]"

 RecordStatusOutput = strTemp

End Function


Section III: ADO (Multidimensional) (ADO MD)

 Copy code hover
[image]

Section III: ADO (Multidimensional) (ADO MD)
Send feedback

This section contains the following chapter:

  • Chapter 14: ADO MD Fundamentals


Cannot open replication system table

 Copy code hover
[image]

Cannot open replication system table <name> because the table is already in use. (Error 3581)
Send feedback

The system table needed to complete this operation is already in use. Wait a few minutes and try your operation again.


Save and Open Methods Example (VJ++)

 Copy code hover
[image]

Save and Open Methods Example (VJ++)
Send feedback

These three examples demonstrate how the Save and Open methods can be used together.

Assume you are going on a business trip and want to take along a table from a database. Before you go, you access the data as a Recordset and save it in a transportable form. When you arrive at your destination, you access the Recordset as a local, disconnected Recordset. You make changes to the Recordset, then save it again, along with your changes. Finally, when you return home, you connect to the database again and update it with the changes you made on the road.

Copy code Copy code

// BeginSaveJ
import com.ms.wfc.data.*;
import java.io.* ;

public class SaveX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 SaveX1();
 SaveX2();
 SaveX3();
 System.exit(0);
 }

 // First, access and save the Authors table.

 // SaveX1 function

 static void SaveX1()
 {
 // Define ADO Objects.
 Recordset rstAuthors = null;

 // Declarations.
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';" +
 "Initial Catalog='Pubs';Integrated Security='SSPI';";
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));
 File file;

 try
 {
 rstAuthors = new Recordset();
 rstAuthors.setCursorLocation(AdoEnums.CursorLocation.CLIENT);
 rstAuthors.open("SELECT * FROM Authors",
 strCnn,
 AdoEnums.CursorType.DYNAMIC,
 AdoEnums.LockType.OPTIMISTIC,
 AdoEnums.CommandType.TEXT);

 // For the sake of illustration, save the recordset to a
 //diskette in XML format.
 file = new File("c:\\Pubs.xml");
 if(!file.exists())
 rstAuthors.save("c:\\Pubs.xml",AdoEnums.PersistFormat.XML);
 else
 {
 System.out.println("\nFile already exists.");
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 System.exit(0);
 }
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstAuthors != null)
 {
 PrintProviderError(rstAuthors.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstAuthors != null)
 if (rstAuthors.getState() == 1)
 rstAuthors.close();
 }
 }

 // At this point, you have arrived at your destination. You will
 // access the Authors table as a local, disconnected Recordset.
 // Don't forget you must have the MSPersist provider on the machine
 // you are using in order to access the saved file, a:\Pubs.xml.

 // SaveX2 function

 static void SaveX2()
 {
 // Define ADO Objects.
 Recordset rstAuthors = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));

 try
 {
 rstAuthors = new Recordset();

 // For sake of illustration, we specify all parameters.
 rstAuthors.open("c:\\Pubs.xml",
 "Provider=MSPersist;",
 AdoEnums.CursorType.FORWARDONLY,
 AdoEnums.LockType.BATCHOPTIMISTIC,
 AdoEnums.CommandType.FILE);

 // Now you have a local, disconnected recordset.
 // Edit it as you desire.
 // (In this example, the change makes no difference).
 rstAuthors.find("au_lname = 'Carson'");
 if(rstAuthors.getEOF())
 {
 System.out.println("Name not found.");
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 return;
 }
 rstAuthors.getField("city").setString("Berkeley");
 rstAuthors.update();

 // Save changes in ADTG format this time, for illustration.
 // Note that previous version on the diskette, as a:\Pubs.xml.
 rstAuthors.save("c:\\Pubs.adtg",AdoEnums.PersistFormat.ADTG);

 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstAuthors != null)
 {
 PrintProviderError(rstAuthors.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstAuthors != null)
 if (rstAuthors.getState() == 1)
 rstAuthors.close();
 }
 }

 // Finally, update the database with your changes.

 // SaveX3 function

 static void SaveX3()
 {
 // Define ADO Objects.
 Connection cnConn1 = null;
 Recordset rstAuthors = null;

 // Declarations.
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';" +
 "Initial Catalog='Pubs';Integrated Security='SSPI';";

 try
 {
 // If there is no ActiveConnection, you can open with defaults.
 rstAuthors = new Recordset();
 rstAuthors.open("c:\\Pubs.adtg");

 // Connect to the database, associate the Recordset with
 // connection, then update the database table with the changed
 // Recordset.
 cnConn1 = new Connection();
 cnConn1.open(strCnn);
 rstAuthors.setActiveConnection(cnConn1);
 rstAuthors.updateBatch();
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstAuthors != null)
 {
 PrintProviderError(rstAuthors.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstAuthors != null)
 if (rstAuthors.getState() == 1)
 rstAuthors.close();
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndSaveJ


CheckBox.BottomPadding Property (Access)

 Copy code hover
[image]

CheckBox.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the check box and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .BottomPadding

expression A variable that represents a CheckBox object.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


CheckBox.Click Event (Access)

 Copy code hover
[image]

CheckBox.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Syntax

expression .Click

expression A variable that represents a CheckBox object.

Remarks

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

Example

In the following example, the Click event procedure is attached to the ReadOnly check box. The event procedure sets the Enabled and Locked properties of another control on the form, the Amount text box. When the check box is clicked, the event procedure checks whether the check box is being selected or cleared and then sets the text box's properties to enable or disable editing accordingly.

To try the example, add the following event procedure to a form that contains a check box called ReadOnly and a text box named Amount.

VBA Copy code Copy code
Private Sub ReadOnly_Click()
 With Me!Amount
 If Me!ReadOnly = True Then ' If checked.
 .Enabled = False ' Disable editing.
 .Locked = True
 Else ' If cleared.
 .Enabled = True ' Enable editing.
 .Locked = False
 End If
 End With
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


AcFormatBarLimits Enumeration (Access)

 Copy code hover
[image]

AcFormatBarLimits Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies how the threshhold values for a Data Bar is determined.

Version Information

Version Added: Access 2010

Name | Value | Description
acAutomatic | 0 | For the shortest bar, the lowest value is used. For the highest bar, the highest value is used.
acNumber | 1 | A number is used.
acPercent | 2 | A percentage is used.


Form.AllowFormView Property (Access)

 Copy code hover
[image]

Form.AllowFormView Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Boolean indicating whether the specified form may be viewed in Form View. True if Form View is allowed. Read/write.

Syntax

expression .AllowFormView

expression A variable that represents a Form object.

Remarks

Use the AllowDatasheetView , AllowFormView, AllowPivotChartView , or AllowPivotTableView properties to control which views are allowed for a form.

Example

The following example makes Form View valid for the specified form and then opens the form in Form View.

VBA Copy code Copy code
Forms(0).AllowFormView = True
DoCmd.OpenForm FormName:=Forms(0).Name, View:=acNormal

See also

Concepts

Form Object

Other resources

Form Object Members


Report.Deactivate Event (Access)

 Copy code hover
[image]

Report.Deactivate Event (Access)
See also Send feedback

Published: July 16, 2012

The Deactivate event occurs when a report loses the focus to a Table, Query, Form, Report, Macro, or Module window, or to the Database window.

Syntax

expression .Deactivate

expression A variable that represents a Report object.

See also

Concepts

Report Object

Other resources

Report Object Members


Field.Size Property (DAO)

 Copy code hover
[image]

Field.Size Property (DAO)
Send feedback

Sets or returns a value that indicates the maximum size, in bytes, of a Field object.

Syntax

expression .Size

expression A variable that represents a Field object.

Remarks

For an object not yet appended to the Fields collection, this property is read/write.

For fields (other than Memo type fields) that contain character data, the Size property indicates the maximum number of characters that the field can hold. For numeric fields, the Size property indicates how many bytes of storage are required.

Use of the Size property depends on the object that contains the Fields collection to which the Field object is appended, as shown in the following table.

Object appended to | Usage
Index | Not supported
QueryDef | Read-only
Recordset | Read-only
Relation | Not supported
TableDef | Read-only

When you create a Field object with a data type other than Text, the Type property setting automatically determines the Size property setting; you don't need to set it. For a Field object with the Text data type, however, you can set Size to any integer up to the maximum text size (255 for Microsoft Access databases). If you do not set the size, the field will be as large as the database allows.

For Long Binary and Memo Field objects, Size is always set to 0. Use the FieldSize property of the Field object to determine the size of the data in a specific record. The maximum size of a Long Binary or Memo field is limited only by your system resources or the maximum size that the database allows.

Example

This example demonstrates the Size property by enumerating the names and sizes of the Field objects in the Employees table.

VBA Copy code Copy code
Sub SizeX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim fldNew As Field
 Dim fldLoop As Field

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set tdfEmployees = dbsNorthwind.TableDefs!Employees

 With tdfEmployees

 ' Create and append a new Field object to the
 ' Employees table.
 Set fldNew = .CreateField("FaxPhone")
 fldNew.Type = dbText
 fldNew.Size = 20
 .Fields.Append fldNew

 Debug.Print "TableDef: " & .Name
 Debug.Print " Field.Name - Field.Type - Field.Size"

 ' Enumerate Fields collection; print field names,
 ' types, and sizes.
 For Each fldLoop In .Fields
 Debug.Print " " & fldLoop.Name & " - " & _
 fldLoop.Type & " - " & fldLoop.Size
 Next fldLoop

 ' Delete new field because this is a demonstration.
 .Fields.Delete fldNew.Name

 End With

 dbsNorthwind.Close

End Sub


Append Method (ADOX Indexes)

 Copy code hover
[image]

Append Method (ADOX Indexes)
Send feedback

Adds a new Index object to the Indexes collection.

Syntax

Indexes.Append Index [,Columns]

Parameters

  • Index

  • The Index object to append or the name of the index to create and append.

  • Columns

  • Optional. A Variant value that specifies the name(s) of the column(s) to be indexed. The Columns parameter corresponds to the value(s) of the Name property of a Column object or objects.

Remarks

The Columns parameter can take either the name of a column or an array of column names.

An error will occur if the provider does not support creating indexes.


Section.AlternateBackThemeColorIndex Property (Access)

 Copy code hover
[image]

Section.AlternateBackThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the AlternateBackColor property of the section. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .AlternateBackThemeColorIndex

expression A variable that represents a Section object.

Remarks

The AlternateBackThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 (Default) | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the AlternateBackThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

Section Object

Other resources

Section Object Members


Field Properties (DAO)

 Copy code hover
[image]

Field Properties (DAO)
Send feedback

In this section

  • Field.AllowZeroLength Property (DAO)

  • Field.Attributes Property (DAO)

  • Field.CollatingOrder Property (DAO)

  • Field.DataUpdatable Property (DAO)

  • Field.DefaultValue Property (DAO)

  • Field.ForeignName Property (DAO)

  • Field.Name Property (DAO)

  • Field.OrdinalPosition Property (DAO)

  • Field.OriginalValue Property (DAO)

  • Field.Properties Property (DAO)

  • Field.Required Property (DAO)

  • Field.FieldSize Property (DAO)

  • Field.SourceField Property (DAO)

  • Field.Size Property (DAO)

  • Field.SourceTable Property (DAO)

  • Field.Type Property (DAO)

  • Field.ValidateOnSet Property (DAO)

  • Field.ValidationRule Property (DAO)

  • Field.ValidationText Property (DAO)

  • Field.Value Property (DAO)

  • Field.VisibleValue Property (DAO)


Securing RDS Applications

 Copy code hover
[image]

Securing RDS Applications
Send feedback

Microsoft Internet Explorer Security Issues

With new security enhancements added to Microsoft® Internet Explorer, some ADO and RDS objects are restricted to running only in a "safe" mode environment. This requires that you are aware of these issues, including different zones, security levels, restrictive behavior, unsafe operations, and customized security settings.

For more information about these issues, see ADO and RDS Security Issues in Microsoft Internet Explorer under ActiveX Data Objects (ADO) Technical Articles.

Security and Your Web Server

If you use the RDSServer.DataFactory object on your Internet Web server, remember that doing so creates a potential security risk. External users who obtain valid data source name (DSN), user ID, and password information could write pages to send any query to that data source. If you want more restricted access to a data source, one option is to unregister and delete the RDSServer.DataFactory object (msadcf.dll), and instead use custom business objects with hard-coded queries.

For more information on the security implications of using the RDSServer.DataFactory object, see the Microsoft Security Bulletin MS99-025 on the Microsoft Security Web site at http://www.microsoft.com/security/default.asp.

Client Impersonation and Security

If the Password Authentication property for your IIS Web server is set to Windows NT Challenge/Response authentication (for Windows NT 4.0) or to Integrated Windows authentication (for Windows 2000), then business objects are invoked under the client's security context. This is a new feature in RDS 1.5 that allows Client Impersonation over HTTP. When working in this mode, the logon to the Web server (IIS) is not anonymous but uses the user ID and password that the client computer is running under. If the ODBC DSNs are set up to use Trusted Connection, then access to databases, such as SQL Server, also happens under the client's security context. But this only works if the database is on the same computer as the IIS; the client credentials cannot be carried over to yet another computer.

For example, a client, John Doe, with userid="JohnD" and password="secret" is logged on to a client computer. He runs a browser-based application that needs to access the RDSServer.DataFactory object to create a Recordset by executing an SQL query on the "MyServer" computer running IIS. MyServer, a system running Windows NT Server 4.0, is set up to use Windows NT Challenge/Response authentication, its ODBC DSN has "Use Trusted Connection" selected, and the server also contains the SQL Server data source. When a request is received on the Web server, it asks the client for the user ID and password. Thus, the request is logged on MyServer as coming from "JohnD"/"Secret" instead of IUSER_MyServer (which is the default when Anonymous Password Authentication is on). Similarly, when logging on to SQL Server, "JohnD"/"Secret" is used.

Consequently, the IIS Windows NT Challenge/Response authentication mode allows HTML pages to be created without the user being explicitly prompted for the user ID and password information needed to log on to the database. If the IIS Basic Authentication were being used, then this also would be required.

Password Authentication

RDS can communicate with an IIS Web server running in any one of the three Password Authentication modes: Anonymous, Basic, or NT Challenge/Response authentication (called Integrated Windows authentication in Windows 2000). These settings define how a Web server controls access through it, such as requiring that a client computer have explicit access privileges on the NT Web server.


TextBox Methods (Access)

 Copy code hover
[image]

TextBox Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.
Undo | You can use the Undo method to reset a control or form when its value has been changed.


CheckBox.AddColon Property (Access)

 Copy code hover
[image]

CheckBox.AddColon Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.

Syntax

expression .AddColon

expression A variable that represents a CheckBox object.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


How to: Determine When a Shelled Process Ends

 Copy code hover
[image]

How to: Determine When a Shelled Process Ends
Send feedback

When you run the Shell function in a Microsoft Visual Basic for Applications (VBA) procedure, it starts an executable program asynchronously and returns control to the procedure. This shelled program continues to run independently of your procedure until you close it.

If your procedure needs to wait for the shelled process to end, you can use the Windows API to poll the status of the application, but this is not very efficient. This topic explains a more efficient method.

The Windows API has integrated functionality that enables your application to wait until a shelled process has completed. To use these functions, you need to have a handle to the shelled process. To accomplish this, use the CreateProcess function instead of the Shell function to begin your shelled program.

Creating the Shelled Process

To create an addressable process, use the CreateProcess function to start your shelled application. The CreateProcess function gives your program the process handle of the shelled process via one of its passed parameters.

Waiting for the Shelled Process to End

After you use the CreateProcess function to get a process handle, you can pass that handle to the WaitForSingleObject function. This causes your VBA procedure to suspend execution until the shelled process ends.

The following steps are necessary to build a VBA procedure that uses the CreateProcess function to run the Windows Notepad application. This code shows how to use the Windows API CreateProcess and WaitForSingleObject functions to wait until a shelled process ends before resuming execution.

The syntax of the CreateProcess function is complex, so in the example code, it is encapsulated into a function called ExecCmd. ExecCmd takes one parameter, the command line of the application to execute.

Create a standard module and paste the following lines in the Declarations section:

VBA Copy code Copy code
Option Explicit

Private Type STARTUPINFO
 cb As Long
 lpReserved As String
 lpDesktop As String
 lpTitle As String
 dwX As Long
 dwY As Long
 dwXSize As Long
 dwYSize As Long
 dwXCountChars As Long
 dwYCountChars As Long
 dwFillAttribute As Long
 dwFlags As Long
 wShowWindow As Integer
 cbReserved2 As Integer
 lpReserved2 As Long
 hStdInput As Long
 hStdOutput As Long
 hStdError As Long
End Type

Private Type PROCESS_INFORMATION
 hProcess As Long
 hThread As Long
 dwProcessID As Long
 dwThreadID As Long
End Type

Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
 hHandle As Long, ByVal dwMilliseconds As Long) As Long

Private Declare Function CreateProcessA Lib "kernel32" (ByVal _
 lpApplicationName As Long, ByVal lpCommandLine As String, ByVal _
 lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
 ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
 ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, _
 lpStartupInfo As STARTUPINFO, lpProcessInformation As _
 PROCESS_INFORMATION) As Long

Private Declare Function CloseHandle Lib "kernel32" (ByVal _
 hObject As Long) As Long

Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const INFINITE = -1&

Paste the following code into the module:

VBA Copy code Copy code
Public Sub ExecCmd(cmdline As String)
 Dim proc As PROCESS_INFORMATION
 Dim start As STARTUPINFO
 Dim ReturnValue As Integer

 ' Initialize the STARTUPINFO structure:
 start.cb = Len(start)

 ' Start the shelled application:
 ReturnValue = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, _
 NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)

 ' Wait for the shelled application to finish:
 Do
 ReturnValue = WaitForSingleObject(proc.hProcess, 0)
 DoEvents
 Loop Until ReturnValue <> 258

 ReturnValue = CloseHandle(proc.hProcess)
End Sub

Sub Testing()
 ExecCmd "NOTEPAD.EXE"
 MsgBox "Process Finished"
End Sub

Type Testing in the Immediate window. Notepad will start. After you close Notepad, a message box will notify you that the process has completed.


NavigationButton.RightPadding Property (Access)

 Copy code hover
[image]

NavigationButton.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .RightPadding

expression A variable that represents a NavigationButton object.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


TableDef Methods (DAO)

 Copy code hover
[image]

TableDef Methods (DAO)
Send feedback

In this section

  • TableDef.CreateField Method (DAO)

  • TableDef.CreateIndex Method (DAO)

  • TableDef.CreateProperty Method (DAO)

  • TableDef.OpenRecordset Method (DAO)

  • TableDef.RefreshLink Method (DAO)


BoundObjectFrame.ControlType Property (Access)

 Copy code hover
[image]

BoundObjectFrame.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Syntax

expression .ControlType

expression A variable that represents a BoundObjectFrame object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


How to: Return a Random Record from a DAO Recordset

 Copy code hover
[image]

How to: Return a Random Record from a DAO Recordset
Send feedback

Microsoft Access does not have a built-in mechanism for returning a random record from a set of records. This topic describes a sample user-defined function that you can use to return a random record.

VBA Copy code Copy code
Function FindRandom (RecordSetName As String, Fieldname As String)

 Dim MyDB As Database
 Dim MyRS As Recordset
 Dim SpecificRecord As Long, i As Long, NumOfRecords As Long

 Set MyDB = CurrentDB()
 Set MyRS = MyDB.OpenRecordset(RecordSetName, dbOpenDynaset)
 On Error GoTo NoRecords
 MyRS.MoveLast
 NumOfRecords = MyRS.RecordCount
 SpecificRecord = Int(NumOfRecords * Rnd)
 If SpecificRecord = NumOfRecords Then
 SpecificRecord = SpecificRecord - 1
 End If
 MyRS.MoveFirst
 For i = 1 To SpecificRecord
 MyRS.MoveNext
 Next i
 FindRandom = MyRS(Fieldname)
 Exit Function

NoRecords:
 If Err = 3021 Then
 MsgBox "There Are No Records In The Dynaset", 16, "Error"
 Else
 MsgBox "Error - " & Err & Chr$(13) & Chr$(10) & Error, _
 16, "Error"
 End If
 FindRandom = "No Records"
 Exit Function

End Function


Invalid SQL Syntax: expected token: DEFAULT (Error 3722)

 Copy code hover
[image]

Invalid SQL Syntax: expected token: DEFAULT (Error 3722)
Send feedback

This error occurs when using the ALTER TABLE ALTER COLUMN syntax. It occurs if one of the following keywords, USER, NULL, or literal, are used without being followed by the keyword DEFAULT.


Object

 Copy code hover
[image]

Object <name> is not a stored procedure. (Error 3750)
Send feedback

This error occurs when using the EXECUTE keyword and either passing a name of a procedure or view that does not exist in the database or passing the name of a base table.


Item Property Example (VC++)

 Copy code hover
[image]

Item Property Example (VC++)
Send feedback

This example demonstrates how the Item property accesses members of a collection. The example opens the Authors table of the Pubs database with a parameterized command.

The parameter in the command issued against the database is accessed from the Command object's Parameters collection by index and name. Then the fields of the returned Recordset are accessed from that object's Fields collection by index and name.

Copy code Copy code

// BeginItemCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void ItemX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 ItemX();

 //Wait here for the user to see the output
 printf("Press any key to continue...");
 getch();
 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// ItemX Function //
// //
//////////////////////////////////////////////////////////

void ItemX(void)
{
 HRESULT hr = S_OK;

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _ConnectionPtr pConnection = NULL;
 _RecordsetPtr pRst = NULL;
 _CommandPtr pCmd = NULL;
 _ParameterPtr pPrm = NULL;
 FieldPtr pFld = NULL;

 // Other Variables.
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");
 _variant_t Column[9];
 _variant_t vIndex;

 try
 {
 // Open connection.
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));

 TESTHR(pRst.CreateInstance(__uuidof(Recordset)));

 TESTHR(pCmd.CreateInstance(__uuidof(Command)));

 //Set the array with the authors table field (column) names
 Column[0] = "au_id";
 Column[1] = "au_lname";
 Column[2] = "au_fname";
 Column[3] = "phone";
 Column[4] = "address";
 Column[5] = "city";
 Column[6] = "state";
 Column[7] = "zip";
 Column[8] = "contract";

 _bstr_t strText("SELECT * FROM authors WHERE state = ?");
 pCmd->CommandText = strText;

 pPrm = pCmd->CreateParameter("ItemXparm", adChar, adParamInput,
 2, "CA");
 pCmd->Parameters->Append(pPrm);

 pConnection->Open(strCnn, "", "", adConnectUnspecified);
 pCmd->ActiveConnection = pConnection;

 // Connection and CommandType are omitted because
 // a Command object is provided.
 _variant_t Conn;
 Conn.vt = VT_ERROR;
 Conn.scode = DISP_E_PARAMNOTFOUND;

 pRst->Open((_variant_t((IDispatch *) pCmd)),Conn,adOpenStatic,
 adLockReadOnly, -1);

 printf("The Parameters collection accessed by index...\n");

 vIndex = (short) 0;
 pPrm = pCmd->Parameters->GetItem(&vIndex);
 printf("Parameter name = '%s', value = '%s'\n",
 (LPCSTR)pPrm->Name, (LPSTR)(_bstr_t)pPrm->Value);

 printf("\nThe Parameters collection accessed by name...\n");
 pPrm = pCmd->Parameters->Item["ItemXparm"];
 printf("Parameter name = '%s', value = '%s'\n",
 (LPCSTR)pPrm->Name, (LPSTR)(_bstr_t)pPrm->Value);

 printf("\nThe Fields collection accessed by index...\n");
 pRst->MoveFirst();
 long limit = 0;
 limit = ((pRst->Fields->Count) - 1);
 int intLineCnt = 8;
 for (short iIndex = 0; iIndex <= limit; iIndex++)
 {
 vIndex = iIndex;
 intLineCnt++;
 if (intLineCnt%15 == 0)
 {
 printf("\nPress any key to continue...\n");
 getch();
 }
 pFld = pRst->Fields->GetItem(&vIndex);
 printf("Field %d : Name = '%s', ", iIndex,
 (LPCSTR)pFld->GetName());
 _variant_t FldVal = pFld->GetValue();

 // Because Value is the default property of a
 // Property object,the use of the actual keyword
 // here is optional.
 switch(FldVal.vt)
 {
 case (VT_BOOL):
 if(FldVal.boolVal)
 {
 printf("Value = 'True'");
 }
 else
 {
 printf("Value = 'False'");
 }
 printf("\n");
 break;
 case (VT_BSTR):
 printf("Value = '%s'",
 (LPCSTR)(_bstr_t)FldVal.bstrVal);
 printf("\n");
 break;
 case (VT_I4):
 printf("Value = '%s'",(LPCSTR)FldVal.iVal);
 printf("\n");
 break;
 case (VT_EMPTY):
 printf("Value = '%s'",(LPCSTR)FldVal.lVal);
 printf("\n");
 break;
 default:
 break;
 }
 }

 printf("\nThe Fields collection accessed by name...\n");
 pRst->MoveFirst();
 for (iIndex = 0; iIndex <= 8; iIndex++)
 {
 intLineCnt++;
 if (intLineCnt%15 == 0)
 {
 printf("\nPress any key to continue...\n");
 getch();
 }
 pFld = pRst->Fields->GetItem(Column[iIndex]);
 printf("Field name = '%s', ",(LPCSTR)pFld->GetName());
 _variant_t FldVal = pFld->GetValue();

 // Because Value is the default property of a
 // Property object,the use of the actual keyword
 // here is optional.
 switch(FldVal.vt)
 {
 case (VT_BOOL):
 if(FldVal.boolVal)
 {
 printf("Value = 'True'");
 }
 else
 {
 printf("Value = 'False'");
 }
 printf("\n");
 break;
 case (VT_BSTR):
 printf("Value = '%s'",
 (LPCSTR)(_bstr_t)FldVal.bstrVal);
 printf("\n");
 break;
 case (VT_I4):
 printf("Value = '%s'",(LPCSTR)FldVal.iVal);
 printf("\n");
 break;
 case (VT_EMPTY):
 printf("Value = '%s'",(LPCSTR)FldVal.lVal);
 printf("\n");
 break;
 default:
 break;
 }
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 PrintProviderError(pConnection);
 PrintComError(e);
 }

 // Clean up objects before exit.
 if (pRst)
 if (pRst->State == adStateOpen)
 pRst->Close();
 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

//////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
//////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,
 pErr->Description);
 }
 }
}

//////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
//////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndItemCpp


BoundObjectFrame.BackShade Property (Access)

 Copy code hover
[image]

BoundObjectFrame.BackShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackShade

expression A variable that represents a BoundObjectFrame object.

Remarks

The BackShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the BackShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackShade=25

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


SubForm.RightPadding Property (Access)

 Copy code hover
[image]

SubForm.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the subform and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .RightPadding

expression A variable that represents a SubForm object.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


CommandButton.Controls Property (Access)

 Copy code hover
[image]

CommandButton.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Syntax

expression .Controls

expression A variable that represents a CommandButton object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ComboBox.Top Property (Access)

 Copy code hover
[image]

ComboBox.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Syntax

expression .Top

expression A variable that represents a ComboBox object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ADO MD Methods

 Copy code hover
[image]

ADO MD Methods
Send feedback
Close | Closes an open cellset.
Open | Retrieves the results of a multidimensional query and returns the results to a cellset.


TextBox.StatusBarText Property (Access)

 Copy code hover
[image]

TextBox.StatusBarText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.

Syntax

expression .StatusBarText

expression A variable that represents a TextBox object.

Remarks

You set the StatusBarText property by using a string expression up to 255 characters long.

Note Note

The length of the text you can display in the status bar depends on your computer hardware and video display.

You can use the StatusBarText property to provide specific information about a control. For example, when a text box has the focus, a brief instruction can tell the user what kind of data to enter

Note Note

You can also use the ControlTipText property to display a ScreenTip for a control.

If you create a control by dragging a field from the field list, the value in a field's Description property is copied to the StatusBarText property.

Example

The following example sets the status bar text to be displayed when the "Address_TextBox" control in the "Mailing List" form has the focus in Form View.

VBA Copy code Copy code
Forms("Mailing List").Controls("Address_TextBox"). _
 StatusBarText = "Enter the company's mailing address."

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Attachment.TopPadding Property (Access)

 Copy code hover
[image]

Attachment.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the attachment and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .TopPadding

expression A variable that represents an Attachment object.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Chapter 11: RDS Fundamentals (ADO)

 Copy code hover
[image]

Chapter 11: RDS Fundamentals (ADO)
Send feedback

In this section

  • Chapter 11: RDS Fundamentals

  • Solutions for Remote Data Access

  • Basic RDS Programming Model

  • RDS Programming Model in Detail

  • RDS Programming Model with Objects

  • RDS Object Model Summary

  • RDS Scenario


Report.Picture Property (Access)

 Copy code hover
[image]

Report.Picture Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Picture property to specify a bitmap or other type of graphic to be used as a background picture on a report. Read/write String.

Syntax

expression .Picture

expression A variable that represents a Report object.

Remarks

The Picture property contains (bitmap) or the path and file name of a bitmap or other type of graphic to be displayed.

The default setting is (none). After the graphic is loaded into the object, the property setting is (bitmap) or the path and file name of the graphic. If you delete (bitmap) or the path and file name of the graphic from the property setting, the picture is deleted from the object and the property setting is again (none).

If the PictureType property is set to Embedded, the graphic is stored with the object.

You can create custom bitmaps by using Microsoft Paintbrush or another application that creates bitmap files. A bitmap file must have a .bmp, .ico, or .dib extension. You can also use graphics files in the .wmf or .emf formats, or any other graphic file type for which you have a graphics filter. Forms, reports, and image controls support all graphics. Command buttons and toggle buttons only support bitmaps.

See also

Concepts

Report Object

Other resources

Report Object Members


Recordset.AddNew Method (DAO)

 Copy code hover
[image]

Recordset.AddNew Method (DAO)
Send feedback

Creates a new record for an updatable Recordset object.

Syntax

expression .AddNew

expression A variable that represents a Recordset object.

Remarks

Use the AddNew method to create and add a new record in the Recordset object named by recordset. This method sets the fields to default values, and if no default values are specified, it sets the fields to Null (the default values specified for a table-type Recordset).

After you modify the new record, use the Update method to save the changes and add the record to the Recordset. No changes occur in the database until you use the Update method.

Note Note

If you issue an AddNew and then perform any operation that moves to another record, but without using Update, your changes are lost without warning. In addition, if you close the Recordset or end the procedure that declares the Recordset or its Database object, the new record is discarded without warning.

Note Note

When you use AddNew in a Microsoft Access workspace and the database engine has to create a new page to hold the current record, page locking is pessimistic. If the new record fits in an existing page, page locking is optimistic.

If you haven't moved to the last record of your Recordset, records added to base tables by other processes may be included if they are positioned beyond the current record. If you add a record to your own Recordset, however, the record is visible in the Recordset and included in the underlying table where it becomes visible to any new Recordset objects.

The position of the new record depends on the type of Recordset:

  • In a dynaset-type Recordset object, records are inserted at the end of the Recordset, regardless of any sorting or ordering rules that were in effect when the Recordset was opened.

  • In a table-type Recordset object whose Index property has been set, records are returned in their proper place in the sort order. If you haven't set the Index property, new records are returned at the end of the Recordset.

The record that was current before you used AddNew remains current. If you want to make the new record current, you can set the Bookmark property to the bookmark identified by the LastModified property setting.

Note Note

To add, edit, or delete a record, there must be a unique index on the record in the underlying data source. If not, a "Permission denied" error will occur on the AddNew, Delete, or Edit method call in a Microsoft Access workspace.

Example

This example uses the AddNew method to create a new record with the specified name. The AddName function is required for this procedure to run.

Copy code Copy code
Sub AddNewX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset
 Dim strFirstName As String
 Dim strLastName As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", dbOpenDynaset)

 ' Get data from the user.
 strFirstName = Trim(InputBox( _
 "Enter first name:"))
 strLastName = Trim(InputBox( _
 "Enter last name:"))

 ' Proceed only if the user actually entered something
 ' for both the first and last names.
 If strFirstName <> "" and strLastName <> "" Then

 ' Call the function that adds the record.
 AddName rstEmployees, strFirstName, strLastName

 ' Show the newly added data.
 With rstEmployees
 Debug.Print "New record: " & !FirstName & _
 " " & !LastName
 ' Delete new record because this is a demonstration.
 .Delete
 End With

 Else
 Debug.Print _
 "You must input a string for first and last name!"
 End If

 rstEmployees.Close
 dbsNorthwind.Close

End Sub

Function AddName(rstTemp As Recordset, _
 strFirst As String, strLast As String)

 ' Adds a new record to a Recordset using the data passed
 ' by the calling procedure. The new record is then made
 ' the current record.
 With rstTemp
 .AddNew
 !FirstName = strFirst
 !LastName = strLast
 .Update
 .Bookmark = .LastModified
 End With

End Function


Form.OnKeyUp Property (Access)

 Copy code hover
[image]

Form.OnKeyUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Up box in the Properties window. Read/write String.

Syntax

expression .OnKeyUp

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyUp event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyUp

See also

Concepts

Form Object

Other resources

Form Object Members


If...Then...Else Macro Block (Access 2013 custom web app)

 Copy code hover
[image]

If...Then...Else Macro Block (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

You can use the If macro block to conditionally execute a group of actions, depending on the value of an expression.

Syntax

VBA Copy code Copy code
If expression Then
 Insert macro actions here ...
Else If expression
 Insert macro actions here ...
Else
 Insert macro actions here ...
End If

Setting

For both If and Else If, the following arguments are required.

Action argument | Description
Expression | The condition that you wish to test. It must be an expression that evaluates to True or False.

Remarks

When you select the If macro block, a textbox appears so that you can enter an expression that represents the condition you wish to test. In addition, a combo box appears where you can insert a macro action, below which the text "End If" automatically displays. The If and the End If bracket an area in which you can enter a group, or block, of actions. The block executes only if the expression that you enter is True.

To evaluate a different expression when the first expression is false, you can click Add Else If to insert an optional Else If block. You must enter an expression that evaluates to True or False. In this case, the block executes only if the expression is True and the first expression is False.

You can add as many Else If blocks as you like to an If block.

You can click Add Else to insert an optional Else block. In this case, the actions that you insert below the Else form the Else block, which executes only when the actions above do not. You can add a single Else block to an If block.

In the following code example, the macro actions in the first block execute if the value of [Status] is greater than 0. If the value of [Status] is not greater than 0, the expression that follows the Else If is evaluated. The macro actions in the Else If block execute if the value of [Status] is equal to 0. Finally, if neither the first block nor the second block execute, the actions in the Else block execute.

VBA Copy code Copy code
If [Status] > 0 Then
 Insert macro actions here ...
Else If [Status] = 0
 Insert macro actions here ...
Else
 Insert macro actions here ...
End If

You can nest If blocks. You should consider nesting an If block within an If block if you want to evaluate a second expression when the first expression is True. In the following code example, the inner If block only executes when the value of [Status] is both greater than 0 and greater than 100.


AcFilterType Enumeration (Access)

 Copy code hover
[image]

AcFilterType Enumeration (Access)
Send feedback

Published: July 16, 2012

Not supported in Microsoft Access 2013.

Name | Value | Description
acFilterNormal | 0 |
acServerFilter | 1 |


Report.OnApplyFilter Property (Access)

 Copy code hover
[image]

Report.OnApplyFilter Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Apply Filter box in the Properties window of a report. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnApplyFilter

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The ApplyFilter event occurs when a filter is applied or removed.

The OnApplyFilter value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Apply Filter box in the report's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Apply Filter box is blank, the property value is an empty string.

Example

The following example associates the OnApplyFilterproperty for the "Catalog" report to the event "Report_ApplyFilter".

VBA Copy code Copy code
Reports("Catalog").OnApplyFilter = "[Event Procedure]"

See also

Concepts

Report Object

Other resources

Report Object Members


 Copy code hover
[image]

<Error> in table-level validation expression. (Error 3320)
Send feedback

An error occurred in a table-level validation rule expression or its default value expression. This could be a syntax error or some other kind of error.


NavigationControl.VerticalAnchor Property (Access)

 Copy code hover
[image]

NavigationControl.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified text box is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2010

Syntax

expression .VerticalAnchor

expression A variable that represents a NavigationControl object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


TabControl.FontSize Property (Access)

 Copy code hover
[image]

TabControl.FontSize Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontSize property to specify the point size for text in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Integer.

Syntax

expression .FontSize

expression A variable that represents a TabControl object.

Remarks

The FontSize property uses the following settings.

Setting | Description
8 | (Default for all reports and controls except command buttons) The text is 8-point type.
10 | (Default for command buttons) The text is 10-point type.
Other sizes | The text is the indicated size.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set this property only in an event procedure or in a macro specified by the OnPrint event property setting.

In Visual Basic, you set the FontSize property by using a numeric expression equal to the desired size of the font. The setting for the FontSize property can be between 1 and 127, inclusive.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


NavigationControl.OnDblClick Property (Access)

 Copy code hover
[image]

NavigationControl.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnDblClick

expression A variable that represents a NavigationControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_DblClick" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Error Object (ADO) Reference

 Copy code hover
[image]

Error Object (ADO) Reference
Send feedback

In this section

  • Error Object (ADO)

  • Error Properties, Methods, and Events (ADO)


Record Object (ADO) Reference

 Copy code hover
[image]

Record Object (ADO) Reference
Send feedback

In this section

  • Record Object (ADO)

  • Record Properties, Methods, and Events (ADO)


Label.OnDblClick Property (Access)

 Copy code hover
[image]

Label.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Syntax

expression .OnDblClick

expression A variable that represents a Label object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_DblClick" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

Label Object

Other resources

Label Object Members


Calling a Stored Procedure with a Command

 Copy code hover
[image]

Calling a Stored Procedure with a Command
Send feedback

You can also use a command when calling a stored procedure. The following code calls a stored procedure in the Northwind sample database, called CustOrdersOrders, which is defined as follows:

Copy code Copy code

CREATE PROCEDURE CustOrdersOrders @CustomerID nchar(5) AS
SELECT OrderID, OrderDate, RequiredDate, ShippedDate
FROM Orders
WHERE CustomerID = @CustomerID
ORDER BY OrderID

This stored procedure is similar to the command used in Command Object Parameters, in that it takes a customer ID parameter and returns information about that customer's orders. The code below uses this stored procedure as the source for an ADO Recordset.

Using the stored procedure allows you to access another capability of ADO: the Parameters collection Refresh method. By using this method, ADO can automatically fill in all information about the parameters required by the command at run time. There is a performance penalty in using this technique, because ADO must query the data source for the information about the parameters.

Other important differences exist between the code below and the code in Command Object Parameters, where the parameters were entered manually. First, this code does not set the Prepared property to True because it is a SQL Server stored procedure and is precompiled by definition. Second, the CommandType property of the Command object changed to adCmdStoredProc in the second example to inform ADO that the command was a stored procedure.

Copy code Copy code

'BeginAutoParamCmd
 On Error GoTo ErrHandler:

 Dim objConn As New ADODB.Connection
 Dim objCmd As New ADODB.Command
 Dim objParm1 As New ADODB.Parameter
 Dim objRs As New ADODB.Recordset

 ' Set CommandText equal to the stored procedure name.
 objCmd.CommandText = "CustOrdersOrders"
 objCmd.CommandType = adCmdStoredProc

 ' Connect to the data source.
 Set objConn = GetNewConnection
 objCmd.ActiveConnection = objConn

 ' Automatically fill in parameter info from stored procedure.
 objCmd.Parameters.Refresh

 ' Set the param value.
 objCmd(1) = "ALFKI"

 ' Execute once and display...
 Set objRs = objCmd.Execute

 Debug.Print objParm1.Value
 Do While Not objRs.EOF
 Debug.Print vbTab & objRs(0) & vbTab & objRs(1) & vbTab & _
 objRs(2) & vbTab & objRs(3)
 objRs.MoveNext
 Loop

 ' ...then set new param value, re-execute command, and display.
 objCmd(1) = "CACTU"
 Set objRs = objCmd.Execute

 Debug.Print objParm1.Value
 Do While Not objRs.EOF
 Debug.Print vbTab & objRs(0) & vbTab & objRs(1) & vbTab & _
 objRs(2) & vbTab & objRs(3)
 objRs.MoveNext
 Loop

 'clean up
 objRs.Close
 objConn.Close
 Set objRs = Nothing
 Set objConn = Nothing
 Set objCmd = Nothing
 Set objParm1 = Nothing
 Exit Sub

ErrHandler:
 'clean up
 If objRs.State = adStateOpen Then
 objRs.Close
 End If

 If objConn.State = adStateOpen Then
 objConn.Close
 End If

 Set objRs = Nothing
 Set objConn = Nothing
 Set objCmd = Nothing
 Set objParm1 = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
'EndAutoParamCmd


Parameters Methods (DAO)

 Copy code hover
[image]

Parameters Methods (DAO)
Send feedback

In this section

  • Parameters.Refresh Method (DAO)


Application.BrokenReference Property (Access)

 Copy code hover
[image]

Application.BrokenReference Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a Boolean indicating whether the current database has any broken references to databases or type libraries. True if there are any broken references. Read-only.

Syntax

expression .BrokenReference

expression A variable that represents an Application object.

Remarks

To test the validity of a specific reference, use the IsBroken property of the Reference object.

Example

This example checks to see if there are any broken references in the current database and reports the results to the user.

VBA Copy code Copy code
' Looping variable.
Dim refLoop As Reference
' Output variable.
Dim strReport As String

' Test whether there are broken references.
If Application.BrokenReference = True Then
 strReport = "The following references are broken:" & vbCr

 ' Test validity of each reference.
 For Each refLoop In Application.References
 If refLoop.IsBroken = True Then
 strReport = strReport & " " & refLoop.Name & vbCr
 End If
 Next refLoop
Else
 strReport = "All references in the current database are valid."
End If

' Display results.
MsgBox strReport

See also

Concepts

Application Object

Other resources

Application Object Members


ActualSize Property (ADO)

 Copy code hover
[image]

ActualSize Property (ADO)
Send feedback

Indicates the actual length of a field's value.

Settings and Return Values

Returns a Long value. Some providers may allow this property to be set to reserve space for BLOB data, in which case the default value is 0.

Remarks

Use the ActualSize property to return the actual length of a Field object's value. For all fields, the ActualSize property is read-only. If ADO cannot determine the length of the Field object's value, the ActualSize property returns adUnknown.

The ActualSize and DefinedSize properties are different, as shown in the following example. A Field object with a declared type of adVarChar and a maximum length of 50 characters returns a DefinedSize property value of 50, but the ActualSize property value it returns is the length of the data stored in the field for the current record. Fields with a DefinedSize greater than 255 bytes are treated as variable length columns.


Label.BottomPadding Property (Access)

 Copy code hover
[image]

Label.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the label and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .BottomPadding

expression A variable that represents a Label object.

See also

Concepts

Label Object

Other resources

Label Object Members


Form.HelpContextId Property (Access)

 Copy code hover
[image]

Form.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Syntax

expression .HelpContextId

expression A variable that represents a Form object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

Form Object

Other resources

Form Object Members


Property setting cannot be larger than 2K. (Error 3309)

 Copy code hover
[image]

Property setting cannot be larger than 2K. (Error 3309)
Send feedback

You are trying to set a property value of an object to a size greater than the largest permissible size of 2K. Shorten the length of the property value.


BoundObjectFrame.EventProcPrefix Property (Access)

 Copy code hover
[image]

BoundObjectFrame.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents a BoundObjectFrame object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


NavigationControl.FormatConditions Property (Access)

 Copy code hover
[image]

NavigationControl.FormatConditions Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FormatConditions property to return a read-only reference to the FormatConditions collection and its related properties.

Version Information

Version Added: Access 2010

Syntax

expression .FormatConditions

expression A variable that represents a NavigationControl object.

Example

The following example sets format properties for an existing conditional format for the "Textbox1" control.

VBA Copy code Copy code
With forms("forms1").Controls("Textbox1").FormatConditions(1)
 .BackColor = RGB(255,255,255)
 .FontBold = True
 .ForeColor = RGB(255,0,0)
End With

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


SmartTags.Application Property (Access)

 Copy code hover
[image]

SmartTags.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a SmartTags object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

SmartTags Collection

Other resources

SmartTags Object Members


Workspace Methods (DAO)

 Copy code hover
[image]

Workspace Methods (DAO)
Send feedback

In this section

  • Workspace.BeginTrans Method (DAO)

  • Workspace.Close Method (DAO)

  • Workspace.CommitTrans Method (DAO)

  • Workspace.CreateDatabase Method (DAO)

  • Workspace.OpenConnection Method (DAO)

  • Workspace.OpenDatabase Method (DAO)

  • Workspace.Rollback Method (DAO)


DoCmd.SetOrderBy Method (Access)

 Copy code hover
[image]

DoCmd.SetOrderBy Method (Access)
See also Send feedback

Published: July 16, 2012

Use the SetOrderBy method to apply a sort to the active datasheet, form, report, or table.

Version Information

Version Added: Access 2010

Syntax

expression .SetOrderBy(OrderBy, ControlName)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
OrderBy | Required | Variant | A string expression that includes the name of the field or fields on which to sort records and the optional ASC or DESC keywords.
ControlName | Optional | Variant | If provided and the active object is a form or report, the name of the control that corresponds to the subform or subreport that will be sorted. If empty and the active object is a form or report, the parent form or report is sorted.

Remarks

When you run this method, the sort is applied to the table, form, report or datasheet (for example, query result) that is active and has the focus.

The Order By argument is the name of the field or fields on which you want to sort records. When you use more than one field name, separate the names with a comma (,). The OrderBy property of the active object is used to save the ordering value and apply it at a later time. OrderBy values are saved with the objects in which they are created. They are automatically loaded when the object is opened, but they are not automatically applied.

When you set the Order By argument by entering one or more field names and then run the method, the records are sorted by default in ascending order.

To sort records in descending order, type DESC at the end of the Order By argument expression. For example, to sort customer records in descending order by contact name, set the Order By argument to "ContactName DESC". To sort names by LastName descending, and FirstName ascending, set the Order By argument to "LastName DESC, FirstName ASC"

Example

The following code example sorts the active datasheet, form, report or table by LastName descending and FirstName ascending.

VBA Copy code Copy code
DoCmd.SetOrderBy "LastName DESC, FirstName ASC"

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Controlling Transactions

 Copy code hover
[image]

Controlling Transactions
Send feedback

A transaction delimits the beginning and end of a series of data access operations that transpire across a connection. Subject to the transactional capabilities of your data source, the Connection object also allows you to create and manage transactions. For example, using the Microsoft OLE DB Provider for SQL Server to access a database on Microsoft SQL Server 2000, you can create multiple nested transactions for the commands you execute.

ADO ensures that changes to a data source resulting from operations in a transaction occur successfully together or not at all.

If you cancel the transaction, or if one of its operations fails, the ultimate result will be as if none of the operations in the transaction occurred. The data source will remain as it was before the transaction began.

The ADO object model does not explicitly include transactions, but represents them with a set of Connection object methods (BeginTrans, CommitTrans, and RollbackTrans).

For more information about transactions, see Chapter 5: Updating and Persisting Data.


Provider and DefaultDatabase Properties Example (VC++)

 Copy code hover
[image]

Provider and DefaultDatabase Properties Example (VC++)
Send feedback

This example demonstrates the Provider property by opening three Connection objects using different providers. It also uses the DefaultDatabase property to set the default database for the Microsoft ODBC Provider.

Copy code Copy code

// BeginProviderCpp
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void ProviderX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////
// //
// Main Function //
// //
///////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 ProviderX();

 ::CoUninitialize();
}

/////////////////////////////////
// //
// ProviderX Function //
// //
/////////////////////////////////

void ProviderX(void)
{
 HRESULT hr = S_OK;

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _ConnectionPtr pConnection1 = NULL;
 _ConnectionPtr pConnection2 = NULL;
 _ConnectionPtr pConnection3 = NULL;

 try
 {
 // Open a Connection using the Microsoft ODBC provider.
 TESTHR(pConnection1.CreateInstance(__uuidof(Connection)));
 pConnection1->ConnectionString = "driver={SQL Server};"
 "server='MySqlServer';user id='MyUserId';password='MyPassword';";
 pConnection1->Open("","","",adConnectUnspecified);
 pConnection1->DefaultDatabase = "pubs";

 // Display the provider
 printf("\n\nConnection1 provider: %s \n\n",
 (LPCSTR)pConnection1->Provider);

 // Open a connection using the OLE DB Provider for Microsoft Jet.
 TESTHR(pConnection2.CreateInstance(__uuidof(Connection)));
 pConnection2->Provider = "Microsoft.Jet.OLEDB.4.0";

 char *sConn = "c:\\Program Files\\Microsoft Office\\Office\\"
 "Samples\\Northwind.mdb";

 pConnection2->Open(sConn,"admin","",NULL);

 // Display the provider
 printf("Connection2 provider: %s \n\n",(LPCSTR)pConnection2->
 Provider);

 // Open a Connection using the Microsoft SQL Server provider.
 TESTHR(pConnection3.CreateInstance(__uuidof(Connection)));
 pConnection3->Provider = "sqloledb";
 pConnection3->Open("Data Source='MySqlServer';Initial Catalog='pubs';",
 "MyUserId","MyPassword",NULL);

 // Display the provider.
 printf("Connection3 provider: %s\n\n",(LPCSTR)pConnection3->
 Provider);
 }

 catch (_com_error &e)
 {
 // Notify the user of errors if any.
 PrintProviderError(pConnection1);
 if(pConnection2) PrintProviderError(pConnection2);
 if(pConnection3) PrintProviderError(pConnection3);
 PrintComError(e);
 }

 if (pConnection1)
 if (pConnection1->State == adStateOpen)
 pConnection1->Close();
 if (pConnection2)
 if (pConnection2->State == adStateOpen)
 pConnection2->Close();
 if (pConnection3)
 if (pConnection3->State == adStateOpen)
 pConnection3->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////
void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;

 // Collection ranges from 0 to nCount -1.
 for(long i = 0;i < nCount;i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////
void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print COM errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndProviderCpp


The Access database is wrong or missing for this SQL/Jet replica set. (Error 3778)

 Copy code hover
[image]

The Access database is wrong or missing for this SQL/Jet replica set. (Error 3778)
Send feedback

The Microsoft Access database specified is wrong or missing because:

  • The data source path supplied in the link server on the SQL Server points to an invalid replica for this publication. The replica may have been replaced, damaged, or not created properly.

  • The hub row is missing or is not valid.

  • The database specified is not replicable.

The solution is to re-initailize your Jet Subscriber using the Re-Initialize tools on the SQL Server.


ComboBox.Application Property (Access)

 Copy code hover
[image]

ComboBox.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a ComboBox object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Recordset.Move Method (DAO)

 Copy code hover
[image]

Recordset.Move Method (DAO)
Send feedback

Moves the position of the current record in a Recordset object.

Syntax

expression .Move(Rows, StartBookmark)

expression A variable that represents a Recordset object.

Parameters

Name | Required/Optional | Data Type | Description
Rows | Required | Long | The number of rows the position will move. If rows is greater than 0, the position is moved forward (toward the end of the file). If rows is less than 0, the position is moved backward (toward the beginning of the file).
StartBookmark | Optional | Variant | A value identifying a bookmark. If you specify startbookmark, the move begins relative to this bookmark. Otherwise, Move begins from the current record.

Remarks

If you use Move to position the current record pointer before the first record, the current record pointer moves to the beginning of the file. If the Recordset contains no records and its BOF property is True, using this method to move backward causes an error.

If you use Move to position the current record pointer after the last record, the current record pointer position moves to the end of the file. If the Recordset contains no records and its EOF property is True, then using this method to move forward causes an error.

If either the BOF or EOF property is True and you attempt to use the Move method without a valid bookmark, a run-time error occurs.

Note Note

  • When you use Move on a forward-only-type Recordset object, the rows argument must be a positive integer and bookmarks aren't allowed. This means you can only move forward.

  • To make the first, last, next, or previous record in a Recordset the current record, use either the MoveFirst, MoveLast, MoveNext, or MovePrevious method.

  • Using Move with rows equal to 0 is an easy way to retrieve the underlying data for the current record. This is useful if you want to make sure that the current record has the most recent data from the base tables. It will also cancel any pending Edit or AddNew calls.

Example

This example uses the Move method to position the record pointer based on user input.

VBA Copy code Copy code
Sub MoveX()

   Dim dbsNorthwind As Database
   Dim rstSuppliers As Recordset
   Dim varBookmark As Variant
   Dim strCommand As String
   Dim lngMove As Long

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   Set rstSuppliers = _
      dbsNorthwind.OpenRecordset("SELECT CompanyName, " & _
      "City, Country FROM Suppliers ORDER BY CompanyName", _
      dbOpenDynaset)

   With rstSuppliers
      ' Populate recordset.
      .MoveLast
      .MoveFirst

      Do While True
         ' Display information about current record and ask
         ' how many records to move.
         strCommand = InputBox( _
            "Record " & (.AbsolutePosition + 1) & " of " & _
            .RecordCount & vbCr & "Company: " & _
            !CompanyName & vbCr & "Location: " & !City & _
            ", " & !Country & vbCr & vbCr & _
            "Enter number of records to Move " & _
            "(positive or negative).")

         If strCommand = "" Then Exit Do

         ' Store bookmark in case the Move doesn't work.
         varBookmark = .Bookmark

         ' Move method requires parameter of data type Long.
         lngMove = CLng(strCommand)
         .Move lngMove

         ' Trap for BOF or EOF.
         If .BOF Then
            MsgBox "Too far backward! " & _
               "Returning to current record."
            .Bookmark = varBookmark
         End If
         If .EOF Then
            MsgBox "Too far forward! " & _
               "Returning to current record."
            .Bookmark = varBookmark
         End If
      Loop
      .Close
   End With

   dbsNorthwind.Close

End Sub


ADO Error Reference

 Copy code hover
[image]

ADO Error Reference
Send feedback

The ErrorValueEnum constant describes the ADO error values. For a complete listing of these enumerated constants, including values, see Appendix B: ADO Errors. This section will examine some of the more interesting errors and explain some specific situations that can raise them, or solutions to fix the problem. Both the ErrorValueEnum constant and the short positive decimal number are listed.

Number | ErrorValueEnum constant | Description/Possible causes
3000 | adErrProviderFailed | Provider failed to perform the requested operation.
3001 | adErrInvalidArgument | Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another. This error is often caused by a typographical error in an SQL SELECT statement. For example, a misspelled field name or table name can generate this error. This error can also occur when a field or table named in a SELECT statement does not exist in the data store.
3002 | adErrOpeningFile | File could not be opened. A misspelled file name was specified, or a file has been moved, renamed, or deleted. Over a network, the drive might be temporarily unavailable or network traffic might be preventing a connection.
3003 | adErrReadFile | File could not be read. The name of the file is specified incorrectly, the file might have been moved or deleted, or the file might have become corrupted.
3004 | adErrWriteFile | Write to file failed. You might have closed a file and then tried to write to it, or the file might be corrupted. If the file is located on a network drive, transient network conditions might prevent writing to a network drive.
3021 | adErrNoCurrentRecord | Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. An attempt was made to update records by using Find or Seek to move the record pointer to the desired record. If the record is not found, EOF will be True. This error can also occur after a failed AddNew or Delete because there is no current record when these methods fail.
3219 | adErrIllegalOperation | Operation is not allowed in this context.
3220 | adErrCantChangeProvider | Supplied provider is different from the one already in use.
3246 | adErrInTransaction | Connection object cannot be explicitly closed while in a transaction. A Recordset or Connection object that is currently participating in a transaction cannot be closed. Call either RollbackTrans or CommitTrans before closing the object.
3251 | adErrFeatureNotAvailable | The object or provider is not capable of performing the requested operation. Some operations depend on a particular provider version.
3265 | adErrItemNotFound | Item cannot be found in the collection corresponding to the requested name or ordinal. An incorrect field or table name has been specified.
3367 | adErrObjectInCollection | Object is already in collection. Cannot append. An object cannot be added to the same collection twice.
3420 | adErrObjectNotSet | Object is no longer valid.
3421 | adErrDataConversion | Application uses a value of the wrong type for the current operation. You might have supplied a string to an operation that expects a stream, for example.
3704 | adErrObjectClosed | Operation is not allowed when the object is closed. The Connection or Recordset has been closed. For example, some other routine might have closed a global object. You can prevent this error by checking the State property before you attempt an operation.
3705 | adErrObjectOpen | Operation is not allowed when the object is open. An object that is open cannot be opened. Fields cannot be appended to an open Recordset.
3706 | adErrProviderNotFound | Provider cannot be found. It may not be properly installed. The name of the provider might be incorrectly specified, the specified provider might not be installed on the computer where your code is being executed, or the installation might have become corrupted.
3707 | adErrBoundToCommand | The ActiveConnection property of a Recordset object, which has a Command object as its source, cannot be changed. The application attempted to assign a new Connection object to a Recordset that has a Command object as its source.
3708 | adErrInvalidParamInfo | Parameter object is improperly defined. Inconsistent or incomplete information was provided.
3709 | adErrInvalidConnection | The connection cannot be used to perform this operation. It is either closed or invalid in this context.
3710 | adErrNotReentrant | Operation cannot be performed while processing event. An operation cannot be performed within an event handler that causes the event to fire again. For example, navigation methods should not be called from within a WillMove event handler.
3711 | adErrStillExecuting | Operation cannot be performed while executing asynchronously.
3712 | adErrOperationCancelled | Operation has been canceled by the user. The application has called the CancelUpdate or CancelBatch method and the current operation has been canceled.
3713 | adErrStillConnecting | Operation cannot be performed while connecting asynchronously.
3714 | adErrInvalidTransaction | Coordinating transaction is invalid or has not started.
3715 | adErrNotExecuting | Operation cannot be performed while not executing.
3716 | adErrUnsafeOperation | Safety settings on this computer prohibit accessing a data source on another domain.
3717 | adWrnSecurityDialog | For internal use only. Don't use. (Entry was included for the sake of completeness. This error should not appear in your code.)
3718 | adWrnSecurityDialogHeader | For internal use only. Don't use. (Entry included for the sake of completeness. This error should not appear in your code.)
3719 | adErrIntegrityViolation | Data value conflicts with the integrity constraints of the field. A new value for a Field would cause a duplicate key. A value that forms one side of a relationship between two records might not be updatable.
3720 | adErrPermissionDenied | Insufficient permission prevents writing to the field. The user named in the connection string does not have the proper permissions to write to a Field.
3721 | adErrDataOverflow | Data value is too large to be represented by the field data type. A numeric value that is too large for the intended field was assigned. For example, a long integer value was assigned to a short integer field.
3722 | adErrSchemaViolation | Data value conflicts with the data type or constraints of the field. The data store has validation constraints that differ from the Field value.
3723 | adErrSignMismatch | Conversion failed because the data value was signed and the field data type used by the provider was unsigned.
3724 | adErrCantConvertvalue | Data value cannot be converted for reasons other than sign mismatch or data overflow. For example, conversion would have truncated data.
3725 | adErrCantCreate | Data value cannot be set or retrieved because the field data type was unknown, or the provider had insufficient resources to perform the operation.
3726 | adErrColumnNotOnThisRow | Record does not contain this field. An incorrect field name was specified or a field not in the Fields collection of the current record was referenced.
3727 | adErrURLDoesNotExist | Either the source URL or the parent of the destination URL does not exist. There is a typographical error in either the source or destination URL. You might have http://mysite/photo/myphoto.jpg when you should actually have http://mysite/photos/myphoto.jpg instead. The typographical error in the parent URL (in this case, photo instead of photos) has caused the error.
3728 | adErrTreePermissionDenied | Permissions are insufficient to access tree or subtree. The user named in the connection string does not have the appropriate permissions.
3729 | adErrInvalidURL | URL contains invalid characters. Make sure the URL is typed correctly. The URL follows the scheme registered to the current provider (for example, Internet Publishing Provider is registered for http).
3730 | adErrResourceLocked | Object represented by the specified URL is locked by one or more other processes. Wait until the process has finished and attempt the operation again. The object you are trying to access has been locked by another user or by another process in your application. This is most likely to arise in a multi-user environment.
3731 | adErrResourceExists | Copy operation cannot be performed. Object named by destination URL already exists. Specify adCopyOverwrite to replace the object. If you do not specify adCopyOverwrite when copying the files in a directory, the copy fails when you try to copy an item that already exists in the destination location.
3732 | adErrCannotComplete | The server cannot complete the operation. This might be because the server is busy with other operations or it might be low on resources.
3733 | adErrVolumeNotFound | Provider cannot locate the storage device indicated by the URL. Make sure the URL is typed correctly. The URL of the storage device might be incorrect, but this error can occur for other reasons. The device might be offline or a large volume of network traffic might prevent the connection from being made.
3734 | adErrOutOfSpace | Operation cannot be performed. Provider cannot obtain enough storage space. There might not be enough RAM or hard-drive space for temporary files on the server.
3735 | adErrResourceOutOfScope | Source or destination URL is outside the scope of the current record.
3736 | adErrUnavailable | Operation failed to complete and the status is unavailable. The field may be unavailable or the operation was not attempted. Another user might have changed or deleted the field you are trying to access.
3737 | adErrURLNamedRowDoesNotExist | Record named by this URL does not exist. While attempting to open a file using a Record object, either the file name or the path to the file was misspelled.
3738 | adErrDelResOutOfScope | The URL of the object to be deleted is outside the scope of the current record.
3747 | adErrCatalogNotSet | Operation requires a valid ParentCatalog.
3748 | adErrCantChangeConnection | Connection was denied. The new connection you requested has different characteristics than the one already in use.
3749 | adErrFieldsUpdateFailed | Fields update failed. For further information, examine the Status property of individual field objects. This error can occur in two situations: when changing a Field object's value in the process of changing or adding a record to the database; and when changing the properties of the Field object itself. The Record or Recordset update failed due to a problem with one of the fields in the current record. Enumerate the Fields collection and check the Status property of each field to determine the cause of the problem.
3750 | adErrDenyNotSupported | Provider does not support sharing restrictions. An attempt was made to restrict file sharing and your provider does not support the concept.
3751 | adErrDenyTypeNotSupported | Provider does not support the requested kind of sharing restriction. An attempt was made to establish a particular type of file-sharing restriction that is not supported by your provider. See the provider's documentation to determine what file-sharing restrictions are supported.


TabControl.Click Event (Access)

 Copy code hover
[image]

TabControl.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Syntax

expression .Click

expression A variable that represents a TabControl object.

Remarks

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


OptionGroup.Application Property (Access)

 Copy code hover
[image]

OptionGroup.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents an OptionGroup object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Control.SetFocus Method (Access)

 Copy code hover
[image]

Control.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Syntax

expression .SetFocus

expression A variable that represents a Control object.

Return Value

Nothing

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.

Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.

Example

The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:

VBA Copy code Copy code
Forms!Employees!EmployeeID.SetFocus

See also

Concepts

Control Object

Other resources

Control Object Members


NavigationButton.Controls Property (Access)

 Copy code hover
[image]

NavigationButton.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Version Information

Version Added: Access 2010

Syntax

expression .Controls

expression A variable that represents a NavigationButton object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Report.RecordLocks Property (Access)

 Copy code hover
[image]

Report.RecordLocks Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the RecordLocks property to determine how records are locked and what happens when two users try to edit the same record at the same time. Read/write.

Syntax

expression .RecordLocks

expression A variable that represents a Report object.

Remarks

When you edit a record, Microsoft Access can automatically lock that record to prevent other users from changing it before you are finished. For reports, the RecordLocks property specifies whether records in the underlying table or query are locked while a report is previewed or printed.

The RecordLocks property only applies to forms, reports, or queries in a Microsoft Access database.

The RecordLocks property uses the following settings.

Setting | Visual Basic | Description
No Locks | 0 | (Default) In reports, records aren't locked while the report is previewed or printed. In queries, records aren't locked while the query is run.
All Records | 1 | All records in the underlying table or query are locked while the report is previewed or printed, or while the query is run. Although users can read the records, the report has finished printing, or the query has finished running.
Edited Record | 2 | (Forms and queries only)
Note Note

Changing the RecordLocks property of an open form or report causes an automatic recreation of the recordset.

You can use the No Locks setting for forms if only one person uses the underlying tables or queries or makes all the changes to the data.

In a multiuser database, you can use the No Locks setting if you want to use optimistic locking and warn users attempting to edit the same record on a form. You can use the Edited Record setting if you want to prevent two or more users editing data at the same time.

You can use the All Records setting when you need to ensure that no changes are made to data after you start to preview or print a report or run an append, delete, make-table, or update query.

See also

Concepts

Report Object

Other resources

Report Object Members


CheckBox.BorderColor Property (Access)

 Copy code hover
[image]

CheckBox.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Syntax

expression .BorderColor

expression A variable that represents a CheckBox object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ToggleButton.BackTint Property (Access)

 Copy code hover
[image]

ToggleButton.BackTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackTint

expression A variable that represents a ToggleButton object.

Remarks

The BackTint property contains a numeric expression that can be used to lighten the theme color in the BackColor property. The default value of the BackTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code lightens the BackColor by 75%.

VBA Copy code Copy code
Me.ctl.BackTint=25

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Failure to replicate database; cannot determine whether the database is open in exclusive mode. (Error 3578)

 Copy code hover
[image]

Failure to replicate database; cannot determine whether the database is open in exclusive mode. (Error 3578)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


SubForm Events (Access)

 Copy code hover
[image]

SubForm Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.


ExitForEachRecord Macro Action

 Copy code hover
[image]

ExitForEachRecord Macro Action
Send feedback

Use the ExitForEachRecord action to immediately exit a ForEachRecord data block.

Note Note

The ExitForEachRecord action is available only in Data Macros.


Application.NewFileTaskPane Property (Access)

 Copy code hover
[image]

Application.NewFileTaskPane Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a NewFile object that represents a document listed on the New File task pane. Read-only NewFile object.

Syntax

expression .NewFileTaskPane

expression A variable that represents an Application object.

Example

This example creates a file list item on the New File task pane in the New from existing file section.

VBA Copy code Copy code
Dim nftpTemp As Office.NewFile

Set nftpTemp = Application.NewFileTaskPane

nftpTemp.Add FileName:="C:\Sales_Quarterly.mdb", _
 Section:=msoNewfromExistingFile, DisplayName:="Quarterly Sales", _
 Action:=msoCreateNewFile

See also

Concepts

Application Object

Other resources

Application Object Members


Page.PageIndex Property (Access)

 Copy code hover
[image]

Page.PageIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PageIndex property to specify or determine the position of a Page object within a Pages collection. The PageIndex property specifies the order in which the pages on a tab control appear. Read/write Integer.

Syntax

expression .PageIndex

expression A variable that represents a Page object.

Remarks

The PageIndex property setting is an Integer value between 0 and the Pages collection Count property setting minus 1.

The PageIndex property can be set in any view.

Changing the value of the PageIndex property changes the location of a Page object in the Pages collection and visually changes the order of pages on a tab control.

Example

The following example moves the page named "Notes" on the tab control named "Information" on the "Order Entry" form to the first page.

VBA Copy code Copy code
Forms("Order Entry").Controls("Information").Pages("Notes").PageIndex = 0

See also

Concepts

Page Object

Other resources

Page Object Members


Cannot retrieve the full path information for a member of the replica set. (Error 3499)

 Copy code hover
[image]

Cannot retrieve the full path information for a member of the replica set. (Error 3499)
Send feedback

This is an unexpected warning. Please contact Microsoft Product Support Services for further information.


Report.OnKeyDown Property (Access)

 Copy code hover
[image]

Report.OnKeyDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Down box in the Properties window. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnKeyDown

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyDown event occurs when a user presses a key while a report or control has the focus. This event also occurs if you send a keystroke to a report or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Down box in the report's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Down box is blank, the property value is an empty string.

See also

Concepts

Report Object

Other resources

Report Object Members


SetObjectOwner method [ADOX]

 Copy code hover
[image]

SetObjectOwner method [ADOX]
Send feedback

Specifies the owner of an object in a Catalog.

Parameters

  • ObjectName

  • A String value that specifies the name of the object for which to specify the owner.

  • ObjectType

  • A Long value which can be one of the ObjectTypeEnum constants that specifies the owner type.

  • OwnerName

  • A String value that specifies the Name of the User or Group to own the object.

  • ObjectTypeId

  • Optional. A Variant value that specifies the GUID for a provider object type not defined by the OLE DB specification. This parameter is required if ObjectType is set to adPermObjProviderSpecific; otherwise, it is not used.

Remarks

An error will occur if the provider does not support specifying object owners.


The replica is not a partial replica. (Error 3478)

 Copy code hover
[image]

The replica is not a partial replica. (Error 3478)
Send feedback

You are attempting to get information about the filter or some other aspect of a partial replica. However, the replica you are querying is not a partial replica. Use the Replication Manager to view the replica's property sheet and confirm that the replica is not a partial replica.


Cannot perform cascading operation:

 Copy code hover
[image]

Cannot perform cascading operation: <validation text>. (Error 3403)
Send feedback

The cascade operation you are attempting would result in invalid data. Check the values you are attempting to update and fix them so they comply with the validation rules.


ListBox.IMEHold Property (Access)

 Copy code hover
[image]

ListBox.IMEHold Property (Access)
See also Send feedback

Published: July 16, 2012

Language-specific information You can use the IMEHold/Hold KanjiConversionMode property to show whether the Kanji Conversion Mode is maintained when the control loses the focus. Read/write Boolean.

Syntax

expression .IMEHold

expression A variable that represents a ListBox object.

Remarks

The IMEHold/Hold KanjiConversionMode property uses the following settings.

Setting | Description
True | Maintains the Kanji Conversion Mode set in the last control.
False | Does not maintain the Kanji Conversion Mode set in the last control (default).

By setting the IMEMode/KanjiConversionMode property, you can designate whether or not the Kanji Conversion Mode is maintained when the control loses the focus. If this property is set to Yes, the Kanji Conversion Mode setting is maintained when the control loses the focus and once that control regains the focus, the Kanji Conversion Mode setting for that control is restored. If this property is set to No (default setting), the Kanji Conversion Mode will be set by the IMEMode/KanjiConversionMode property for that control.

Note Note

To set the Kanji Conversion Mode when the focus shifts to the control, set the IMEMode/KanjiConversionMode property.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Database.TableDefs Property (DAO)

 Copy code hover
[image]

Database.TableDefs Property (DAO)
Send feedback

Returns a TableDefs collection that contains all of the TableDef objects stored in the specified database. Read-only.

Syntax

expression .TableDefs

expression A variable that represents a Database object.


Label.BackShade Property (Access)

 Copy code hover
[image]

Label.BackShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackShade

expression A variable that represents a Label object.

Remarks

The BackShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the BackShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackShade=25

See also

Concepts

Label Object

Other resources

Label Object Members


Image.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

Image.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified image control. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthLeft

expression A variable that represents an Image object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Image Object

Other resources

Image Object Members


Not a valid alias name. (Error 3068)

 Copy code hover
[image]

Not a valid alias name. (Error 3068)
Send feedback

The alias you entered does not follow standard naming conventions. Enter a new name, and then try the operation again.


Container Object (DAO)

 Copy code hover
[image]

Container Object (DAO)
Send feedback

A Container object groups similar types of Document objects together.

Remarks

Each Database object has a Containers collection consisting of built-in Container objects. Applications can define their own document types and corresponding containers (Microsoft Access database engine databases only); however, these objects may not always be supported through DAO.

Some of these Container objects are defined by the Microsoft Access database engine while others may be defined by other applications. The following table lists the name of each Container object defined by the Microsoft Access database engine and what type of information it contains.

Container name | Contains information about
Databases | Saved databases
Tables | Saved tables and queries
Relations | Saved relationships

Note Note

Don't confuse the Container objects listed in the preceding table with the collections of the same name. The Databases Container object refers to all saved database objects, but the Databases collection refers only to database objects that are open in a particular workspace.

Each Container object has a Documents collection containing Document objects that describe instances of built-in objects of the type specified by the Container. You typically use a Container object as an intermediate link to the information in the Document object. You can also use the Containers collection to set security for all Document objects of a given type.

With an existing Container object, you can:

  • Use the Name property to return the predefined name of the Container object.

  • Use the Owner property to set or return the owner of the Container object. To set the Owner property, you must have write permission for the Container object, and you must set the property to the name of an existing User or Group object.

  • Use the Permissions and UserName properties to set access permissions for the Container object; any Document object created in the Documents collection of a Container object inherits these access permission settings.

Because Container objects are built-in, you can't create new Container objects or delete existing ones.

To refer to a Container object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

  • Containers(0)

  • Containers("name")

  • Containers![name]

Example

This example enumerates the Containers collection of the Northwind database and the Properties collection of each Container object in the collection.

VBA Copy code Copy code
Sub ContainerObjectX()

 Dim dbsNorthwind As Database
 Dim ctrLoop As Container
 Dim prpLoop As Property

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind

 ' Enumerate Containers collection.
 For Each ctrLoop In .Containers
 Debug.Print "Properties of " & ctrLoop.Name _
 & " container"

 ' Enumerate Properties collection of each
 ' Container object.
 For Each prpLoop In ctrLoop.Properties
 Debug.Print " " & prpLoop.Name _
 & " = " prpLoop
 Next prpLoop

 Next ctrLoop

 .Close
 End With

End Sub


Microsoft OLE DB Persistence Provider (ADO Service Provider)

 Copy code hover
[image]

Microsoft OLE DB Persistence Provider (ADO Service Provider)
Send feedback

The Microsoft OLE DB Persistence Provider enables you to save a Recordset object into a file, and later restore that Recordset object from the file. Schema information, data, and pending changes are preserved.

You can save the Recordset in either the proprietary Advanced Data Table Gram (ADTG) format, or the open Extensible Markup Language (XML) format.

Provider Keyword

To invoke this provider, specify the following keyword and value in the connection string.

Copy code Copy code

"Provider=MSPersist"

Errors

The following errors issued by this provider can be detected in your application.

Constant | Description
E_BADSTREAM | The file opened does not have a valid format (that is, the format is not ADTG or XML).
E_CANTPERSISTROWSET | The Recordset object saved has characteristics that prevent it from being stored.

Remarks

The Microsoft OLE DB Persistence Provider exposes no dynamic properties.

Currently, only parameterized hierarchical Recordset objects cannot be saved.

For more information about persistently storing Recordset objects, see Recordset Persistence.

When a stream is used to open a Recordset, there should be no parameters specified other than the Source parameter of the Open method.


Attachment.BackShade Property (Access)

 Copy code hover
[image]

Attachment.BackShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackShade

expression A variable that represents an Attachment object.

Remarks

The BackShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the BackShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackShade=25

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


ObjectFrame.SourceDoc Property (Access)

 Copy code hover
[image]

ObjectFrame.SourceDoc Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SourceDoc property to specify the file to create a link to or to embed when you create a linked object or embedded object by using the Action property in Visual Basic. Read/write String.

Syntax

expression .SourceDoc

expression A variable that represents an ObjectFrame object.

Remarks

For an embedded object, enter the full path and file name for the file you want to use as a template and set the Action property to acOLECreateEmbed.

For a linked object, enter the full path and file name of the file to create a link to and set the Action property to acOLECreateLink.

While this property appears in the property sheet, it takes effect only after the Action property is set in a macro or by using Visual Basic.

You can use the SourceDoc property to specify the file to create a link to and the control's SourceItem property to specify the data within that file. If you want to create a link to the entire object, leave the SourceItem property blank.

When a linked unbound object is created, the control's SourceItem property setting is concatenated with its SourceItem property setting. In Form view, Datasheet view, and Print Preview, the control's SourceItem property setting is a zero-length string (" "), and its SourceDoc property setting is the full path to the linked file, followed by an exclamation point (!) or a backslash (\) and the SourceItem property setting, as in the following example:

VBA Copy code Copy code
"C:\Work\Qtr1\Revenue.xls!R1C1:R30C15"

Example

The following example creates a linked OLE object using an unbound object frame named OLE1 and sizes the control to display the object's entire contents when the user clicks a command button.

VBA Copy code Copy code
Sub Command1_Click
 OLE1.Class = "Excel.Sheet" ' Set class name.
 ' Specify type of object.
 OLE1.OLETypeAllowed = acOLELinked
 ' Specify source file.
 OLE1.SourceDoc = "C:\Excel\Oletext.xls"
 ' Specify data to create link to.
 OLE1.SourceItem = "R1C1:R5C5"
 ' Create linked object.
 OLE1.Action = acOLECreateLink
 ' Adjust control size.
 OLE1.SizeMode = acOLESizeZoom
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Form.NavigationButtons Property (Access)

 Copy code hover
[image]

Form.NavigationButtons Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the NavigationButtons property to specify whether navigation buttons and a record number box are displayed on a form. Read/write Boolean.

Syntax

expression .NavigationButtons

expression A variable that represents a Form object.

Remarks

The default value is True.

Navigation buttons provide an efficient way to move to the first, previous, next, last, or blank (new) record. The record number box displays the number of the current record. The total number of records is displayed next to the navigation buttons. You can enter a number in the record number box to move to a particular record.

If you remove the navigation buttons from a form and want to create your owns means of navigation for the form, you can create custom navigation buttons and add them to the form.

Example

The following example returns the value of the Navigation Buttons property for the "Order Entry" form.

VBA Copy code Copy code
Dim b As Boolean
b = Forms("Order Entry").NavigationButtons

See also

Concepts

Form Object

Other resources

Form Object Members


NavigationButton.FontWeight Property (Access)

 Copy code hover
[image]

NavigationButton.FontWeight Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.

Syntax

expression .FontWeight

expression A variable that represents a NavigationButton object.

Remarks

The DatasheetFontWeight property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

These properties are only available in Visual Basic within a Microsoft Access database.

In Visual Basic, the DatasheetFontWeight property setting uses the following Integer values.

Setting | Description
100 | Thin
200 | Extra Light
300 | Light
400 | (Default) Normal
500 | Medium
600 | Semi-bold
700 | Bold
800 | Extra Bold
900 | Heavy

The following table contains the properties that don't exist in the DAO Properties collection of until you set them by using the Formatting (Datasheet) toolbar or you can add them in an Access database by using the CreateProperty method and append it to the DAO Properties collection.

DatasheetFontItalic * | DatasheetForeColor *
DatasheetFontHeight * | DatasheetBackColor
DatasheetFontName * | DatasheetGridlinesColor
DatasheetFontUnderline * | DatasheetGridlinesBehavior
DatasheetFontWeight * | DatasheetCellsEffect
Note Note

When you add or set any property listed with an asterisk, Microsoft Access automatically adds all the properties listed with an asterisk to the Properties collection of the database.

Example

The following example sets the font to MS Serif, the font size to 10 points, and the font weight to medium (500) in Datasheet view of the Products table.

VBA Copy code Copy code

Sub SetDatasheetFont

   Dim dbs As Object, objProducts As Object
   Set dbs = CurrentDb
   Const DB_Text As Long = 10
   Const DB_Integer As Long = 3
   Set objProducts = dbs!Products

   SetTableProperty objProducts, "DatasheetFontName", DB_Text, "MS Serif"
   SetTableProperty objProducts, "DatasheetFontHeight", DB_Integer, 10
   SetTableProperty objProducts, "DatasheetFontWeight", DB_Integer, 500

End Sub

Sub SetTableProperty(objTableObj As Object, strPropertyName As String, _
        intPropertyType As Integer, varPropertyValue As Variant)
    ' Set Microsoft Access-defined table property without causing
    ' nonrecoverable run-time error.
    Const conErrPropertyNotFound = 3270
    Dim prpProperty As Variant
    On Error Resume Next                ' Don't trap errors.
    objTableObj.Properties(strPropertyName) = varPropertyValue
    If Err <> 0 Then                    ' Error occurred when value set.
        If Err <> conErrPropertyNotFound Then
            On Error GoTo 0
            MsgBox "Couldn't set property '" & strPropertyName _
                & "' on table '" & objTableObj.Name & "'", 48, "SetTableProperty"
        Else
            On Error GoTo 0
            Set prpProperty = objTableObj.CreateProperty(strPropertyName, _
                intPropertyType, varPropertyValue)
            objTableObj.Properties.Append prpProperty
        End If
    End If
    objTableObj.Properties.Refresh
End Sub

The next example makes the same changes as the preceding example in Datasheet view of the open Products form.

VBA Copy code Copy code
Forms!Products.DatasheetFontName = "MS Serif"
Forms!Products.DatasheetFontHeight = 10
Forms!Products.DatasheetFontWeight = 500

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


ToggleButton.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

ToggleButton.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified toggle button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthLeft

expression A variable that represents a ToggleButton object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


ToggleButton.SoftEdges Property (Access)

 Copy code hover
[image]

ToggleButton.SoftEdges Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the Soft Edges effect applied to the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .SoftEdges

expression A variable that represents a ToggleButton object.

Remarks

The SoftEdges property uses one of the values listed in the following table.

Value | Effect
0 (Default) | No Soft Edges
1 | 1 Point
2 | 2.5 Points
3 | 5 Points
4 | 10 Points
5 | 25 Points
6 | 50 Points

To see the available shadow effects and apply a shadow through the user interface, first open the form or report in Layout view or Design view by right-clicking the form or report in the Navigation Pane, and then clicking the view you want. Then, click the object to which you want to apply a soft edge effect. Next, on the Format tab, in the Control Formatting group, click Shape Effects, then click Soft Edges and choose a soft edge effect. Notice that the shadow effects are indexed from top to bottom.

This property is not surfaced in the property sheet.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


OptionButton.GridlineColor Property (Access)

 Copy code hover
[image]

OptionButton.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified option button. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineColor

expression A variable that represents an OptionButton object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


How to: Set Form, Report, and Control Properties in Code

 Copy code hover
[image]

How to: Set Form, Report, and Control Properties in Code
Send feedback

Form , Report , and Control objects are Microsoft 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

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

Copy code Copy code
Forms!Customers.Visible = True

You can also set a property of a form or report from within the object's module by using the object's Me property. Code that uses the Me property executes faster than code that uses a fully qualified object name. For example, to set the RecordSource property of the Customers form to an SQL statement that returns all records with a CompanyName field entry beginning with "A" from within the Customers form module, use the following line of code:

Copy code Copy code
Me.RecordSource = "SELECT * FROM Customers " _
    & "WHERE CompanyName Like 'A*'"

To set a property of a control

Refer to the control in the Controls 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:

Copy code Copy code
' Faster method.
Me!CustomerID.Visible = True
Copy code Copy code
' Slower method.
Forms!Customers.Controls!CustomerID.Visible = True

The fastest way to set a property of a control is from within an object's module by using the object's Me property. For example, you can use the following code to toggle the Visible property of a text box called CustomerID on the Customers form:

Copy code Copy code
With Me!CustomerID
    .Visible = Not .Visible
End With

To 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:

Copy code Copy code
Forms!Customers.Section(3).Visible = False
Copy code Copy code
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:

    • 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.

    • 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.


Unique Property (ADOX)

 Copy code hover
[image]

Unique Property (ADOX)
Send feedback

Indicates whether the index keys must be unique.

Settings and Return Values

Sets and returns a Boolean value.

Remarks

The default value is False.

This property is read-only on Index objects already appended to a collection.


ListBox Methods (Access)

 Copy code hover
[image]

ListBox Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
AddItem | Adds a new item to the list of values displayed by the specified list box control.
Move | Moves the specified object to the coordinates specified by the argument values.
RemoveItem | Removes an item from the list of values displayed by the specified list box control.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.
Undo | You can use the Undo method to reset a control or form when its value has been changed.


OptionButton.OptionValue Property (Access)

 Copy code hover
[image]

OptionButton.OptionValue Property (Access)
See also Send feedback

Published: July 16, 2012

Each control in an option group has a numeric value that you can set with the OptionValue property. Read/write Long.

Syntax

expression .OptionValue

expression A variable that represents an OptionButton object.

Remarks

When the control is selected, the number is assigned to the option group. If the option group is bound to a field, the value of the selected control's OptionValue property is stored in the field.

For example, this Region option group is bound to the Region field in a table. The Europe button has an OptionValue property setting of 1, the Asia button has a setting of 2, and the Africa button has a setting of 3. When one of these buttons is selected, the Region option group value will be the same as the OptionValue property setting for the selected control. In this case, because the Region option group is bound to the Region field, the value of this field in the table also equals 2.

The OptionValue property applies only to the check box, option button, and toggle button controls in an option group.

Unless you change the OptionValue property yourself, the first control you place in an option group has a value of 1, the second control has a value of 2, and so on.

The OptionValue property is only available when the control is placed inside an option group control. When a check box, a toggle button, or an option button isn't in an option group, the control has no OptionValue property. Instead, each such control has a ControlSource property, and the value of each control will be either True if selected or False if not selected.

Example

The following example sets the OptionValue property for three option buttons in the "Ship Method Group" option group when a form opens. When an option button is selected in the option group, a message displays indicating the shipper's assigned ID number.

VBA Copy code Copy code
Private Sub Form_Open(Cancel As Integer)

 Me.Controls("ABC Couriers").OptionValue = 15876
 Me.Controls("Speedy Delivery").OptionValue = 742
 Me.Controls("Lightning Express").OptionValue = 1256

End Sub

Private Sub Ship_Method_Group_Click()

 MsgBox "The ID for the selected shipper is " & Me.Controls("Ship Method Group").Value

End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


ADO Enumerated Constants Reference

 Copy code hover
[image]

ADO Enumerated Constants Reference
Send feedback

In this section

  • ADO Enumerated Constants

  • ADCPROP_ASYNCTHREADPRIORITY_ENUM

  • ADCPROP_AUTORECALC_ENUM

  • ADCPROP_UPDATECRITERIA_ENUM

  • ADCPROP_UPDATERESYNC_ENUM

  • AffectEnum

  • BookmarkEnum

  • CommandTypeEnum

  • CompareEnum

  • ConnectModeEnum

  • ConnectOptionEnum

  • ConnectPromptEnum

  • CopyRecordOptionsEnum

  • CursorLocationEnum

  • CursorOptionEnum

  • CursorTypeEnum

  • DataTypeEnum

  • EditModeEnum

  • ErrorValueEnum

  • EventReasonEnum

  • EventStatusEnum

  • ExecuteOptionEnum

  • FieldAttributeEnum

  • FieldEnum

  • FieldStatusEnum

  • FilterGroupEnum

  • GetRowsOptionEnum

  • IsolationLevelEnum

  • LineSeparatorsEnum

  • LockTypeEnum

  • MarshalOptionsEnum

  • MoveRecordOptionsEnum

  • ObjectStateEnum

  • ObjectTypeEnum

  • ParameterAttributesEnum

  • ParameterDirectionEnum

  • PersistFormatEnum

  • PositionEnum

  • PropertyAttributesEnum

  • RecordCreateOptionsEnum

  • RecordOpenOptionsEnum

  • RecordStatusEnum

  • RecordTypeEnum

  • ResyncEnum

  • SaveOptionsEnum

  • SchemaEnum

  • SearchDirectionEnum

  • SeekEnum

  • StreamOpenOptionsEnum

  • StreamReadEnum

  • StreamTypeEnum

  • StreamWriteEnum

  • StringFormatEnum

  • XactAttributeEnum


Cannot delete a built-in property. (Error 3384)

 Copy code hover
[image]

Cannot delete a built-in property. (Error 3384)
Send feedback

You are trying to delete a Property object defined by the Microsoft Access database engine.

You can delete only user-defined (including application-defined) properties for which you have permission to modify the design, or ones for which this permission is not required.


Recovered replicable data. (Error 3711)

 Copy code hover
[image]

Recovered replicable data. (Error 3711)
Send feedback

When a replica is recovered, any new records that existed in the corrupted replica are added to the conflict table of the recovered replica. This ensures that the data can be reviewed before it is reinserted.


Attachment.GridlineShade Property (Access)

 Copy code hover
[image]

Attachment.GridlineShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineShade

expression A variable that represents an Attachment object.

Remarks

The GridlineShade property contains a numeric expression that can be used to darken the theme color in the GridlineColor property. The default value of the GridlineShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


OptionButton.GridlineWidthRight Property (Access)

 Copy code hover
[image]

OptionButton.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified option button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthRight

expression A variable that represents an OptionButton object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


AllTables Properties (Access)

 Copy code hover
[image]

AllTables Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


Image.BorderShade Property (Access)

 Copy code hover
[image]

Image.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents an Image object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

Image Object

Other resources

Image Object Members


VBScript ADO Programming

 Copy code hover
[image]

VBScript ADO Programming
Send feedback

Creating an ADO Project

Microsoft Visual Basic, Scripting Edition does not support type libraries, so you do not need to reference ADO in your project. Consequently, no associated features such as command line completion are supported. Also, by default, ADO enumerated constants are not defined in VBScript.

However, ADO provides you with two include files containing the following definitions to be used with VBScript:

  • For server-side scripting use Adovbs.inc, which is installed in the c:\Program Files\Common Files\System\ado\ folder by default.

  • For client-side scripting use Adcvbs.inc, which is installed in the c:\Program Files\Common Files\System\msdac\ folder by default.

You can either copy and paste constant definitions from these files into your ASP pages, or, if you are doing server-side scripting, copy Adovbs.inc file to a folder on your Web site and referencing it from your ASP page like this:

Copy code Copy code

<!--#include File="adovbs.inc"-->

Creating ADO Objects in VBScript

You cannot use the Dim statement to assign objects to a specific type in VBScript. Also, VBScript does not support the New syntax used with the Dim statement in Visual Basic for Applications. You must instead use the CreateObject function call:

Copy code Copy code

Dim Rs1
Set Rs1 = Server.CreateObject( "ADODB.Recordset" )

VBScript Examples

The following code is a generic example of VBScript server-side programming in an Active Server Page (ASP) file:

Copy code Copy code

<%  @LANGUAGE="VBSCRIPT" %>
<%  Option Explicit %>
<!--#include File="adovbs.inc"-->
<HTML>
    <BODY BGCOLOR="White" topmargin="10" leftmargin="10">

    <!-- Your ASP Code goes here -->
<%
Dim Source
Dim Connect
Dim Rs1

Source = "SELECT * FROM Authors"
Connect = "Provider=sqloledb;Data Source=srv;" & _
    "Initial Catalog=Pubs;Integrated Security=SSPI;"

Set Rs1 = Server.CreateObject( "ADODB.Recordset" )
Rs1.Open Source, Connect, adOpenForwardOnly
Response.Write("Success!")
%>
    </BODY>
</HTML>

More specific VBScript examples are included with the ADO documentation. For more information, see ADO Code Examples in Microsoft Visual Basic Scripting Edition.

Differences Between VBScript and Visual Basic

Using ADO with VBScript is similar to using ADO with Visual Basic in many ways, including how syntax is used. However, some significant differences exist:

  • VBScript supports only the Variant data type, which can hold different types of data. You can store the data you need in a Variant data type, and the data will function appropriately due to casting performed by VBScript. It recognizes the type required by ADO, and converts the value in the Variant accordingly.

  • You cannot use on error goto <label> within VBScript.

  • VBScript supports some of the built-in Visual Basic functions such as Msgbox, Date, and IsNumeric. However, because VBScript is a subset of Visual Basic, not all built-in functions are supported. For example, VBScript does not support the Format function and the file I/O functions.


Modules.Application Property (Access)

 Copy code hover
[image]

Modules.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a Modules object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

Modules Collection

Other resources

Modules Object Members


AcFormOpenDataMode Enumeration (Access)

 Copy code hover
[image]

AcFormOpenDataMode Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the data entry mode of a form.

Name | Value | Description
acFormAdd | 0 | The user can add new records but can't edit existing records.
acFormEdit | 1 | The user can edit existing records and add new records.
acFormPropertySettings | -1 | The user can only change the form's properties.
acFormReadOnly | 2 | The user can only view records.


Index.DistinctCount Property (DAO)

 Copy code hover
[image]

Index.DistinctCount Property (DAO)
Send feedback

Returns a value that indicates the number of unique values for the Index object that are included in the associated table (Microsoft Access workspaces only).

Syntax

expression .DistinctCount

expression A variable that represents an Index object.

Remarks

Check the DistinctCount property to determine the number of unique values, or keys, in an index. Any key is counted only once, even though there may be multiple occurrences of that value if the index permits duplicate values. This information is useful in applications that attempt to optimize data access by evaluating index information. The number of unique values is also known as the cardinality of an Index object.

The DistinctCount property won't always reflect the actual number of keys at a particular time. For example, a change caused by a rolled back transaction won't be reflected immediately in the DistinctCount property. The DistinctCount property value also may not reflect the deletion of records with unique keys. The number will be accurate immediately after you use the CreateIndex method.

Example

This example uses the DistinctCount property to show how you can determine the number of unique values in an Index object. However, this value is only accurate immediately after creating the Index. It will remain accurate if no keys change, or if new keys are added and no old keys are deleted; otherwise, it will not be reliable. (If this procedure is run several times, you can see the effect on the DistinctCount property values of the existing Index objects.)

VBA Copy code Copy code
Sub DistinctCountX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim idxCountry As Index
 Dim idxLoop As Index
 Dim rstEmployees As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set tdfEmployees = dbsNorthwind!Employees

 With tdfEmployees
 ' Create and append new Index object to the Employees
 ' table.
 Set idxCountry = .CreateIndex("CountryIndex")
 idxCountry.Fields.Append _
 idxCountry.CreateField("Country")
 .Indexes.Append idxCountry

 ' The collection must be refreshed for the new
 ' DistinctCount data to be available.
 .Indexes.Refresh

 ' Enumerate Indexes collection to show the current
 ' DistinctCount values.
 Debug.Print "Indexes before adding new record"
 For Each idxLoop In .Indexes
 Debug.Print " DistinctCount = " & _
 idxLoop.DistinctCount & ", Name = " & _
 idxLoop.Name
 Next idxLoop

 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees")

 ' Add a new record to the Employees table.
 With rstEmployees
 .AddNew
 !FirstName = "April"
 !LastName = "LaMonte"
 !Country = "Canada"
 .Update
 End With

 ' Enumerate Indexes collection to show the modified
 ' DistinctCount values.
 Debug.Print "Indexes after adding new record and " & _
 "refreshing Indexes"
 .Indexes.Refresh
 For Each idxLoop In .Indexes
 Debug.Print " DistinctCount = " & _
 idxLoop.DistinctCount & ", Name = " & _
 idxLoop.Name
 Next idxLoop

 ' Delete new record because this is a demonstration.
 With rstEmployees
 .Bookmark = .LastModified
 .Delete
 .Close
 End With

 ' Delete new Indexes because this is a demonstration.
 .Indexes.Delete idxCountry.Name
 End With

 dbsNorthwind.Close

End Sub


Field2.SourceTable Property (DAO)

 Copy code hover
[image]

Field2.SourceTable Property (DAO)
Send feedback

Returns a value that indicates the name of the table that is the original source of the data for a Field2 object. Read-only String.

Syntax

expression .SourceTable

expression A variable that represents a Field2 object.

Remarks

For a Field2 object, use of the SourceField and SourceTable properties depends on the object that contains the Fields collection that the Field2 object is appended to, as shown in the following table.

Object appended to | Usage
Index | Not supported
QueryDef | Read-only
Recordset | Read-only
Relation | Not supported
TableDef | Read-only

These properties indicate the original field and table names associated with a Field2 object. For example, you could use these properties to determine the original source of the data in a query field whose name is unrelated to the name of the field in the underlying table.

Note Note

The SourceTable property will not return a meaningful table name if used on a Field2 object in the Fields collection of a table-type Recordset object.


TabControl.HoverTint Property (Access)

 Copy code hover
[image]

TabControl.HoverTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the HoverColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .HoverTint

expression A variable that represents a TabControl object.

Remarks

The HoverTint property contains a numeric expression that can be used to lighten the theme color in the HoverColor property. The default value of the HoverTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


DisplayControl Property

 Copy code hover
[image]

DisplayControl Property
Send feedback

Published: July 16, 2012

You can use the DisplayControl property in table Design view to specify the default control you want to use for displaying a field.

Setting

You can set the DisplayControl property in the table's property sheet in table Design view by clicking the Lookup tab in the Field Properties section.

This property contains a drop-down list of the available controls for the selected field. For fields with a Text or Number data type, this property can be set to Text Box, List Box, or Combo Box. For fields with a Yes/No data type, this property can be set to Check Box, Text Box, or Combo Box.

Remarks

When you select a control for this property, any additional properties needed to configure the control are also displayed on the Lookup tab.

Setting this property and any related control type properties will affect the field display in both Datasheet view and Form view. The field is displayed by using the control and control property settings set in table Design view. If a field had its DisplayControl property set in table Design view and you drag it from the field list in form Design view, Microsoft Access copies the appropriate properties to the control's property sheet.


Pages.Remove Method (Access)

 Copy code hover
[image]

Pages.Remove Method (Access)
See also Send feedback

Published: July 16, 2012

The Remove method removes a Page object from the Pages collection of a tab control.

Syntax

expression .Remove(Item)

expression A variable that represents a Pages object.

Parameters

Name | Required/Optional | Data Type | Description
Item | Optional | Variant | An integer that specifies the index of the Page object to be removed. The index of the Page object corresponds to the value of the PageIndex property for that Page object. If you omit this argument, the last Page object in the collection is removed.

Remarks

The Pages collection is indexed beginning with zero. The leftmost page in the tab control has an index of 0, the page immediately to the right of the leftmost page has an index of 1, and so on.

You can remove a Page object from the Pages collection of a tab control only when the form is in Design view.

Example

The following example removes pages from a tab control:

VBA Copy code Copy code
Function RemovePage() As Boolean
 Dim frm As Form
 Dim tbc As TabControl, pge As Page

 On Error GoTo Error_RemovePage
 Set frm = Forms!Form1
 Set tbc = frm!TabCtl0
 tbc.Pages.Remove
 RemovePage = True

Exit_RemovePage:
 Exit Function

Error_RemovePage:
 MsgBox Err & ": " & Err.Description
 RemovePage = False
 Resume Exit_RemovePage
End Function

See also

Concepts

Pages Collection

Other resources

Pages Object Members


Macro Commands

 Copy code hover
[image]

Macro Commands
Send feedback

In this section

  • CancelEvent Macro Action

  • Echo Macro Action

  • OpenVisualBasicModule Macro Action

  • RemoveAllTempVars Macro Action

  • RemoveTempVar Macro Action

  • RunCode Macro Action

  • RunDataMacro Macro Action

  • RunMacro Macro Action

  • RunMenuCommand Macro Action

  • SetTempVar Macro Action

  • SingleStep Macro Action

  • StartNewWorkflow Macro Action

  • StopAllMacros Macro Action

  • StopMacro Macro Action

  • WorkflowTasks Macro Action


You tried to execute a query that does not include the specified expression

 Copy code hover
[image]

You tried to execute a query that does not include the specified expression <name> as part of an aggregate function. (Error 3122)
Send feedback

You tried to execute a query that does not include the specified expression as part of an aggregate function or grouping.

Possible cause:

  • You did not enter an aggregate function in the TRANSFORM statement.


Cannot execute a select query. (Error 3065)

 Copy code hover
[image]

Cannot execute a select query. (Error 3065)
Send feedback

You tried to use the Execute method with a select query. The Execute method is valid only with action queries. Select queries contain a SELECT statement and can return records; action queries do not.


AllReports.Item Property (Access)

 Copy code hover
[image]

AllReports.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.

Syntax

expression .Item(var)

expression A variable that represents an AllReports object.

Parameters

Name | Required/Optional | Data Type | Description
var | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

AllReports Collection

Other resources

AllReports Object Members


+ (String Concatenation Operator) (Access 2013 custom web app)

 Copy code hover
[image]

+ (String Concatenation Operator) (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

The plus sign (+) is the string concatenation operator that enables string concatenation. All other string manipulation is handled by using string functions such as Substring.

Syntax

TextExpression+TextExpression

TextExpression Any valid text expression.


Set Properties of ActiveX Data Objects in Visual Basic

 Copy code hover
[image]

Set Properties of ActiveX Data Objects in Visual Basic
Send feedback

Published: July 16, 2012

ActiveX Data Objects (ADO) enable you to manipulate the structure of your database and the data it contains from Visual Basic. Many ADO objects correspond to objects that you see in your database — for example, a Table object corresponds to a Microsoft Access table. A Field object corresponds to a field in a table.

Most of the properties you can set for ADO objects are ADO properties. These properties are defined by the Microsoft Access database engine and are set the same way in any application that includes the Access database engine. Some properties that you can set for ADO objects are defined by Microsoft Access, and aren't automatically recognized by the Access database engine. How you set properties for ADO objects depends on whether a property is defined by the Access database engine or by Microsoft Access.

Setting ADO Properties for ADO Objects

To set a property that's defined by the Access database engine, refer to the object in the ADO hierarchy. The easiest and fastest way to do this is to create object variables that represent the different objects you need to work with, and refer to the object variables in subsequent steps in your code. For example, the following code creates a new TableDef object and sets its Name property:

Copy code Copy code
Dim tbl As New ADOX.Table
Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
tbl.Name = "Contacts"

Setting Microsoft Access Properties for ADO Objects

When you set a property that's defined by Microsoft Access, but applies to a ADO object, the Access database engine doesn't automatically recognize the property as a valid property. The first time you set the property, you must create the property and append it to the Properties collection of the object to which it applies. Once the property is in the Properties collection, it can be set in the same manner as any ADO property.

If the property is set for the first time in the user interface, it's automatically added to the Properties collection, and you can set it normally.

When writing procedures to set properties defined by Microsoft Access, you should include error-handling code to verify that the property you are setting already exists in the Properties collection. See the Help topic about the Add method or the individual property topic for more information.

Keep in mind that when you create the property, you must correctly specify its Type property before you append it to the Properties collection. You can determine the Type property based on the information in the Settings section of the Help topic for the individual property. The following table provides some guidelines for determining the setting of the Type property.

If the property setting is | Then the Type property setting should be
A string | adLongVarWChar or adVarWChar
True/False | adBoolean
An integer | adInteger

The following table lists some Microsoft Access-defined properties that apply to ADO objects.

ADO object | Microsoft Access-defined properties
Connection | AppTitle, AppIcon, StartupShowDBWindow, StartupShowStatusBar, AllowShortcutMenus, AllowFullMenus, AllowBuiltInToolbars, AllowToolbarChanges, AllowBreakIntoCode, AllowSpecialKeys, Replicable, ReplicationConflictFunction
Table | DatasheetBackColor, DatasheetCellsEffect, DatasheetFontHeight, DatasheetFontItalic, DatasheetFontName, DatasheetFontUnderline, DatasheetFontWeight, DatasheetForeColor, DatasheetGridlinesBehavior, DatasheetGridlinesColor, Description, FrozenColumns, RowHeight, ShowGrid
QueryDef | DatasheetBackColor, DatasheetCellsEffect, DatasheetFontHeight, DatasheetFontItalic, DatasheetFontName, DatasheetFontUnderline, DatasheetFontWeight, DatasheetForeColor, DatasheetGridlinesBehavior, DatasheetGridlinesColor, Description, FailOnError, FrozenColumns, LogMessages, MaxRecords, RecordLocks, RowHeight, ShowGrid, UseTransaction
Field | Caption, ColumnHidden, ColumnOrder, ColumnWidth, DecimalPlaces, Description, Format, InputMask


Internet Publishing Scenario

 Copy code hover
[image]

Internet Publishing Scenario
Send feedback

This code example demonstrates how to use ADO with the Microsoft OLE DB Provider for Internet Publishing. In this scenario, you will create a Visual Basic application that uses Recordset, Record, and Stream objects to display the contents of resources published with the Internet Publishing Provider.

The following steps are necessary to create this scenario:

  • Step 1: Set Up the Visual Basic Project

  • Step 2: Initialize the Main List Box

  • Step 3: Populate the Fields List Box

  • Step 4: Populate the Details Text Box


Form.Orientation Property (Access)

 Copy code hover
[image]

Form.Orientation Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Orientation property to specify or determine the view orientation. Read/write Byte.

Syntax

expression .Orientation

expression A variable that represents a Form object.

Remarks

The Orientation property uses the following settings.

Setting | Visual Basic | Description
Left-to-Right | 0 | Sets the view orientation to left to right.
Right-to-Left | 1 | Sets the view orientation to right to left.

See also

Concepts

Form Object

Other resources

Form Object Members


Workspace Object Reference (DAO)

 Copy code hover
[image]

Workspace Object Reference (DAO)
Send feedback

In this section

  • Workspace Object (DAO)

  • Workspace Members (DAO)

  • Workspace Properties (DAO)

  • Workspace Methods (DAO)


WebBrowserControl.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

WebBrowserControl.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleLeft

expression A variable that represents a WebBrowserControl object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


TextBox.Locked Property (Access)

 Copy code hover
[image]

TextBox.Locked Property (Access)
See also Send feedback

Published: July 16, 2012

The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.

Syntax

expression .Locked

expression A variable that represents a TextBox object.

Remarks

The default setting of the Locked property is True. This setting allows editing, adding, and deleting data.

Use the Locked property to protect data in a field by making it read-only. For example, you might want a control to only display information without allowing editing, or you might want to lock a control until a specific condition is met.

Example

The following example toggles the Enabled property of a command button and the Enabled and Locked properties of a control, depending on the type of employee displayed in the current record. If the employee is a manager, then the SalaryDetails button is enabled and the PersonalInfo control is unlocked and enabled.

VBA Copy code Copy code
Sub Form_Current()
 If Me!EmployeeType = "Manager" Then
 Me!SalaryDetails.Enabled = True
 Me!PersonalInfo.Enabled = True
 Me!PersonalInfo.Locked = False
 Else
 Me!SalaryDetails.Enabled = False
 Me!PersonalInfo.Enabled = False
 Me!PersonalInfo.Locked = True
 End If
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Data Manipulation Language

 Copy code hover
[image]

Data Manipulation Language
Send feedback

In this section

  • DELETE Statement (Microsoft Access SQL)

  • EXECUTE Statement (Microsoft Access SQL)

  • INNER JOIN Operation (Microsoft Access SQL)

  • INSERT INTO Statement (Microsoft Access SQL)

  • LEFT JOIN, RIGHT JOIN Operations (Microsoft Access SQL)

  • PARAMETERS Declaration (Microsoft Access SQL)

  • PROCEDURE Clause (Microsoft Access SQL)

  • SELECT Statement (Microsoft Access SQL)

  • SELECT.INTO Statement (Microsoft Access SQL)

  • SQL Subqueries (Microsoft Access SQL)

  • TRANSACTION Statement (Microsoft Access SQL)

  • TRANSFORM Statement (Microsoft Access SQL)

  • UNION Operation (Microsoft Access SQL)

  • UPDATE Statement (Microsoft Access SQL)

  • WITH OWNERACCESS OPTION Declaration (Microsoft Access SQL)


Recordset2.AddNew Method (DAO)

 Copy code hover
[image]

Recordset2.AddNew Method (DAO)
Send feedback

Creates a new record for an updatable Recordset2 object.

Syntax

expression .AddNew

expression A variable that represents a Recordset2 object.

Remarks

Use the AddNew method to create and add a new record in the Recordset2 object named by recordset. This method sets the fields to default values, and if no default values are specified, it sets the fields to Null (the default values specified for a table-type Recordset2).

After you modify the new record, use the Update method to save the changes and add the record to the Recordset2. No changes occur in the database until you use the Update method.

Note Note

If you issue an AddNew and then perform any operation that moves to another record, but without using Update, your changes are lost without warning. In addition, if you close the Recordset2 or end the procedure that declares the Recordset2 or its Database object, the new record is discarded without warning.

Note Note

When you use AddNew in a Microsoft Access workspace and the database engine has to create a new page to hold the current record, page locking is pessimistic. If the new record fits in an existing page, page locking is optimistic.

If you haven't moved to the last record of your Recordset2, records added to base tables by other processes may be included if they are positioned beyond the current record. If you add a record to your own Recordset2, however, the record is visible in the Recordset2 and included in the underlying table where it becomes visible to any new Recordset2 objects.

The position of the new record depends on the type of Recordset2:

  • In a dynaset-type Recordset2 object, records are inserted at the end of the Recordset, regardless of any sorting or ordering rules that were in effect when the Recordset was opened.

  • In a table-type Recordset2 object whose Index property has been set, records are returned in their proper place in the sort order. If you haven't set the Index property, new records are returned at the end of the Recordset.

The record that was current before you used AddNew remains current. If you want to make the new record current, you can set the Bookmark property to the bookmark identified by the LastModified property setting.

Note Note

To add, edit, or delete a record, there must be a unique index on the record in the underlying data source. If not, a "Permission denied" error will occur on the AddNew, Delete, or Edit method call in a Microsoft Access workspace.

Example

This example uses the AddNew method to create a new record with the specified name. The AddName function is required for this procedure to run.

Copy code Copy code
Sub AddNewX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset2
 Dim strFirstName As String
 Dim strLastName As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", dbOpenDynaset)

 ' Get data from the user.
 strFirstName = Trim(InputBox( _
 "Enter first name:"))
 strLastName = Trim(InputBox( _
 "Enter last name:"))

 ' Proceed only if the user actually entered something
 ' for both the first and last names.
 If strFirstName <> "" and strLastName <> "" Then

 ' Call the function that adds the record.
 AddName rstEmployees, strFirstName, strLastName

 ' Show the newly added data.
 With rstEmployees
 Debug.Print "New record: " & !FirstName & _
 " " & !LastName
 ' Delete new record because this is a demonstration.
 .Delete
 End With

 Else
 Debug.Print _
 "You must input a string for first and last name!"
 End If

 rstEmployees.Close
 dbsNorthwind.Close

End Sub

Function AddName(rstTemp As Recordset2, _
 strFirst As String, strLast As String)

 ' Adds a new record to a recordset using the data passed
 ' by the calling procedure. The new record is then made
 ' the current record.
 With rstTemp
 .AddNew
 !FirstName = strFirst
 !LastName = strLast
 .Update
 .Bookmark = .LastModified
 End With

End Function


CommandButton Object (Access)

 Copy code hover
[image]

CommandButton Object (Access)
See also Send feedback

Published: July 16, 2012

This object corresponds to a command button. A command button on a form can start an action or a set of actions. For example, you could create a command button that opens another form. To make a command button do something, you write a macro or event procedure and attach it to the button's OnClick property.

Remarks

Control: | Tool:

You can display text on a command button by setting its Caption property, or you can display a picture by setting its Picture property.

Note Note

You can create over 30 different types of command buttons with the Command Button Wizard. When you use the Command Button Wizard, Microsoft Access creates the button and the event procedure for you.

See also

Concepts

Access Object Model Reference

Other resources

CommandButton Object Members


Could not read the record; currently locked by another user. (Error 3624)

 Copy code hover
[image]

Could not read the record; currently locked by another user. (Error 3624)
Send feedback

You tried to read a record on a 2K database page that is currently locked by another user. Wait for the other user to finish working with the record, and then try the operation again.


Insufficient memory to complete operation. (Error 3584)

 Copy code hover
[image]

Insufficient memory to complete operation. (Error 3584)
Send feedback

Your computer ran out of memory while trying to replicate the database. Close other applications on the computer and try the operation again.


CheckBox.ValidationText Property (Access)

 Copy code hover
[image]

CheckBox.ValidationText Property (Access)
See also Send feedback

Published: July 16, 2012

Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.

Syntax

expression .ValidationText

expression A variable that represents a CheckBox object.

Remarks

Enter an expression for the ValidationRule property setting and text for the ValidationText property setting. The maximum length for the ValidationRule property setting is 2048 characters. The maximum length for the ValidationText property setting is 255 characters.

For controls, you can set the ValidationRule property to any valid expression. For field and record validation rules, the expression can't contain user-defined functions, domain aggregate or aggregate functions, the Eval function, or CurrentUser method, or references to forms, queries, or tables. In addition, field validation rules can't contain references to other fields. For records, expressions can include references to fields in that table.

For table fields and records, you can also set these properties in Visual Basic by using the DAO ValidationRule property.

Note Note

The ValidationRule and ValidationText properties don't apply to check box, option button, or toggle buttoncontrols when they are in an option group. They apply only to the option group itself.

Microsoft Access automatically validates values based on a field's data type; for example, Microsoft Access doesn't allow text in a numeric field. You can set rules that are more specific by using the ValidationRule property.

If you set the ValidationRule property but not the ValidationText property, Microsoft Access displays a standard error message when the validation rule is violated. If you set the ValidationText property, the text you enter is displayed as the error message.

For example, when a record is added for a new employee, you can enter a ValidationRule property requiring that the value in the employee's StartDate field fall between the company's founding date and the current date. If the date entered isn't in this range, you can display the ValidationText property message: "Start date is incorrect."

If you create a control by dragging a field from the field list, the field's validation rule remains in effect, although it isn't displayed in the control's ValidationRule property box in the property sheet. This is because a field's validation rule is inherited by a control bound to that field.

Control, field, and record validation rules are applied as follows:

  • Validation rules you set for fields and controls are applied when you edit the data and the focus leaves the field or control.

  • Validation rules for records are applied when you move to another record.

  • If you create validation rules for both a field and a control bound to the field, both validation rules are applied when you edit data and the focus leaves the control.

The following table contains expression examples for the ValidationRule and ValidationText properties.

ValidationRule property | ValidationText property
<> 0 | Entry must be a nonzero value.
> 1000 Or Is Null | Entry must be blank or greater than 1000.
Like "A????" | Entry must be 5 characters and begin with the letter "A".
>= #1/1/96# And <#1/1/97# | Entry must be a date in 1996.
DLookup("CustomerID", "Customers", "CustomerID = Forms!Customers!CustomerID") Is Null | Entry must be a unique CustomerID (domain aggregate functions are allowed only for form-level validation).

If you create a validation rule for a field, Microsoft Access doesn't normally allow a Null value to be stored in the field. If you want to allow a Null value, add "Is Null" to the validation rule, as in "<> 8 Or Is Null" and make sure the Required property is set to No.

You can't set field or record validation rules for tables created outside Microsoft Access (for example, dBASE, Paradox, or SQL Server). For these kinds of tables, you can create validation rules for controls only.

Example

The following example creates a validation rule for a field that allows only values over 65 to be entered. If a number less than 65 is entered, a message is displayed. The properties are set by using the SetFieldValidation function.

VBA Copy code Copy code
Dim strTblName As String, strFldName As String
Dim strValidRule As String
Dim strValidText As String, intX As Integer

strTblName = "Customers"
strFldName = "Age"
strValidRule = ">= 65"
strValidText = "Enter a number greater than or equal to 65."
intX = SetFieldValidation(strTblName, strFldName, _
 strValidRule, strValidText)

Function SetFieldValidation(strTblName As String, _
 strFldName As String, strValidRule As String, _
 strValidText As String) As Integer

 Dim dbs As Database, tdf As TableDef, fld As Field

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 Set fld = tdf.Fields(strFldName)
 fld.ValidationRule = strValidRule
 fld.ValidationText = strValidText
End Function

The next example uses the SetTableValidation function to set record-level validation to ensure that the value in the EndDate field comes after the value in the StartDate field.

VBA Copy code Copy code
Dim strTblName As String, strValidRule As String
Dim strValidText As String
Dim intX As Integer

strTblName = "Employees"
strValidRule = "EndDate > StartDate"
strValidText = "Enter an EndDate that is later than the StartDate."
intX = SetTableValidation(strTblName, strValidRule, strValidText)

Function SetTableValidation(strTblName As String, _
 strValidRule As String, strValidText As String) _
 As Integer

 Dim dbs As Database, tdf As TableDef

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 tdf.ValidationRule = strValidRule
 tdf.ValidationText = strValidText
End Function

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Form.UniqueTable Property (Access)

 Copy code hover
[image]

Form.UniqueTable Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies the table to be updateable when A form is bound to a multiple table view or stored procedure within a Microsoft Access project (.adp).

Syntax

expression .UniqueTable

expression A variable that represents a Form object.

Remarks

The UniqueTable property identifies the "most many" table of a join.

See also

Concepts

Form Object

Other resources

Form Object Members


CurrentProject.Path Property (Access)

 Copy code hover
[image]

CurrentProject.Path Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Path property to determine the location where data is stored for a Microsoft Access project (.adp) or Microsoft Access database. Read-only String.

Syntax

expression .Path

expression A variable that represents a CurrentProject object.

Remarks

You can use the Path property to determine the location of information stored through the CurrentProject or CodeProject objects of a project or database.

Example

The following example displays a message indicating the disk location of the current Access project or database.

VBA Copy code Copy code
MsgBox "The current database is located at " & Application.CurrentProject.Path & "."

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


NavigationButton.ControlTipText Property (Access)

 Copy code hover
[image]

NavigationButton.ControlTipText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .ControlTipText

expression A variable that represents a NavigationButton object.

Remarks

You set the ControlTipText property by using a string expression up to 255 characters long.

For controls on forms, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

You can set the ControlTipText property in any view.

The ControlTipText property provides an easy way to provide helpful information about controls on a form.

There are other ways to provide information about a form or a control on a form. You can use the StatusBarText property to display information in the status bar about a control. To provide more extensive help for a form or control, use the HelpFile and HelpContextID properties.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


TabControl.BorderColor Property (Access)

 Copy code hover
[image]

TabControl.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderColor

expression A variable that represents a TabControl object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Close Method (ADO)

 Copy code hover
[image]

Close Method (ADO)
Send feedback

Closes an open object and any dependent objects.

Syntax

object.Close

Remarks

Use the Close method to close a Connection, a Record, a Recordset, or a Stream object to free any associated system resources. Closing an object does not remove it from memory; you can change its property settings and open it again later. To completely eliminate an object from memory, set the object variable to Nothing (in Visual Basic) after closing the object.

Connection

Using the Close method to close a Connection object also closes any active Recordset objects associated with the connection. A Command object associated with the Connection object you are closing will persist, but it will no longer be associated with a Connection object; that is, its ActiveConnection property will be set to Nothing. Also, the Command object's Parameters collection will be cleared of any provider-defined parameters.

You can later call the Open method to re-establish the connection to the same, or another, data source. While the Connection object is closed, calling any methods that require an open connection to the data source generates an error.

Closing a Connection object while there are open Recordset objects on the connection rolls back any pending changes in all of the Recordset objects. Explicitly closing a Connection object (calling the Close method) while a transaction is in progress generates an error. If a Connection object falls out of scope while a transaction is in progress, ADO automatically rolls back the transaction.

Recordset, Record, Stream

Using the Close method to close a Recordset, Record, or Stream object releases the associated data and any exclusive access you may have had to the data through this particular object. You can later call the Open method to reopen the object with the same, or modified, attributes.

While a Recordset object is closed, calling any methods that require a live cursor generates an error.

If an edit is in progress while in immediate update mode, calling the Close method generates an error; instead, call the Update or CancelUpdate method first. If you close the Recordset object while in batch update mode, all changes since the last UpdateBatch call are lost.

If you use the Clone method to create copies of an open Recordset object, closing the original or a clone does not affect any of the other copies.


Form.OnInsert Property (Access)

 Copy code hover
[image]

Form.OnInsert Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the Before Insert box in the Properties window of a form. Read/write String.

Syntax

expression .OnInsert

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

Although the name of this property is OnInsert, setting this property actually sets the value of the Before Insert box.

The BeforeInsert event occurs when the user types the first character in a new record, but before the record is actually created.

The OnInsert value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the Before Insert box in the form's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the Before Insert box is blank, the property value is an empty string.

Example

The following example prints the value of the OnInsert property in the Immediate window for the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").OnInsert

See also

Concepts

Form Object

Other resources

Form Object Members


Event Properties

 Copy code hover
[image]

Event Properties
Send feedback

Published: July 16, 2012

Event properties cause a macro or the associated Visual Basic event procedure to run when a particular event occurs. For example, if you enter the name of a macro in a command button's OnClick property, that macro runs when the command button is clicked.

Setting

To run a macro, enter the name of the macro. You can choose an existing macro in the list. If the macro is in a macro group, it will be listed under the macro group name, as macrogroupname.macroname.

To run the event procedure associated with the event, select [Event Procedure] in the list.

Note Note

Although using an event procedure is the recommended method for running Visual Basic code in response to an event, you can also run a user-defined function when an event occurs. To run a user-defined function, place an equal sign (=) before the function name and parentheses after it, as in =functionname( ).

You can set event properties in the property sheet for an object, in a macro , or by using Visual Basic. Note that you can't set any event properties while you're formatting or printing a form or report.

Tip Tip

You can use builders to help you set an event property. To use them, click the Build button [image] to the right of the property box, or right-click the property box and then click Build on the shortcut menu. In the Choose Builder dialog box, select:

  • The Macro Builder to create and specify a macro for this event property. You can also use the Macro Builder to edit a macro already specified by the property.

  • The Code Builder to create and specify an event procedure for this event property. You can also use the Code Builder to edit an event procedure already specified by the property.

  • In a Microsoft Access database, the Expression Builder to choose and specify a user-defined function for this event property.

In Visual Basic, set the property to a string expression.

To run this | Use this syntax | Example
Macro | "macroname" |
Event procedure | "[Event Procedure]" |
User-defined function | "=functionname( )" |

Example

The following example shows how you can use the value entered in the Country control to determine which of two different macros to run when you click the Print Country Report button.

Copy code Copy code
Private Sub Country_AfterUpdate()
    If Country = "Canada" Then
        [Print Country Report].OnClick = "PrintCanadaReport"
    ElseIf Country = "USA" Then
        [Print Country Report].OnClick = "PrintUSAReport"
    End If
End Sub


Form.Requery Method (Access)

 Copy code hover
[image]

Form.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified form by requerying the source of data for the form.

Syntax

expression .Requery

expression A variable that represents a Form object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts .

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate function.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

Example

The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form:

VBA Copy code Copy code
Public Sub RequeryList()

    Dim ctlCombo As Control

    ' Return Control object pointing to a combo box.
    Set ctlCombo = Forms!Employees!ReportsTo

    ' Requery source of data for list box.
    ctlCombo.Requery

End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Hierarchy Object (ADO MD)

 Copy code hover
[image]

Hierarchy Object (ADO MD)
Send feedback

Represents one way in which the members of a dimension can be aggregated or "rolled up." A dimension can be aggregated along one or more hierarchies.

Remarks

With the collections and properties of a Hierarchy object, you can do the following:

  • Identify the Hierarchy with the Name and UniqueName properties.

  • Return a meaningful string that describes the Hierarchy with the Description property.

  • Return the Level objects that make up the Hierarchy with the Levels collection.

  • Use the standard ADO Properties collection to obtain additional information about the Hierarchy object.

The Properties collection contains provider-supplied properties. The following table lists properties that might be available. The actual property list may differ depending upon the implementation of the provider. See the documentation for your provider for a more complete list of available properties.

Name | Description
AllMember | The member at the highest level of rollup in the hierarchy.
CatalogName | The name of the catalog to which this cube belongs.
CubeName | The name of the cube.
DefaultMember | The unique name of the default member for this hierarchy.
Description | A meaningful description of the hierarchy.
DimensionType | The type of dimension to which this hierarchy belongs.
DimensionUniqueName | The unambiguous name of the dimension.
HierarchyCaption | A label or caption associated with the hierarchy.
HierarchyCardinality | The number of members in the hierarchy.
HierarchyGUID | The GUID of the hierarchy.
HierarchyName | The name of the hierarchy.
HierarchyUniqueName | The unambiguous name of the hierarchy.
SchemaName | The name of the schema to which this cube belongs.


Property.Value Property (DAO)

 Copy code hover
[image]

Property.Value Property (DAO)
Send feedback

Sets or returns the value of an object. Read/write Variant.

Syntax

expression .Value

expression A variable that represents a Property object.

Remarks

The setting or return value is a Variant data type that evaluates to a value appropriate for the data type, as specified by the Type property of an object.

Generally, the Value property is used to retrieve and alter data in Recordset objects.

The Value property is the default property of the Field, Parameter, and Property objects. Therefore, you can set or return the value of one of these objects by referring to them directly instead of specifying the Value property.

Trying to set or return the Value property in an inappropriate context (for example, the Value property of a Field object in the Fields collection of a TableDef object) will cause a trappable error.

Note Note

When reading decimal values from a Microsoft SQL Server database, they will be formatted using scientific notation through a Microsoft Access workspace, but will appear as normal decimal values through an ODBCDirect workspace.


Application.DeleteReportControl Method (Access)

 Copy code hover
[image]

Application.DeleteReportControl Method (Access)
See also Send feedback

Published: July 16, 2012

The DeleteReportControl method deletes a specified control from a report.

Syntax

expression .DeleteReportControl(ReportName, ControlName)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
ReportName | Required | String | The name of the report containing the control you want to delete.
ControlName | Required | String | The name of the control you want to delete.

Return Value

Nothing

Remarks

The DeleteReportControl method is available only in form Design view or report Design view, respectively.

Note Note

If you are building a wizard that deletes a control from a form or report, your wizard must open the form or report in Design view before it can delete the control.

Example

The following example creates a form with a command button and displays a message that asks if the user wants to delete the command button. If the user clicks Yes, the command button is deleted.

VBA Copy code Copy code
Sub DeleteCommandButton()
 Dim frm As Form, ctlNew As Control
 Dim strMsg As String, intResponse As Integer, _
 intDialog As Integer

 ' Create new form and get pointer to it.
 Set frm = CreateForm
 ' Create new command button.
 Set ctlNew = CreateControl(frm.Name, acCommandButton)
 ' Restore form.
 DoCmd.Restore
 ' Set caption.
 ctlNew.Caption = "New Command Button"
 ' Size control.
 ctlNew.SizeToFit
 ' Prompt user to delete control.
 strMsg = "About to delete " & ctlNew.Name &". Continue?"
 ' Define buttons to be displayed in dialog box.
 intDialog = vbYesNo + vbCritical + vbDefaultButton2
 intResponse = MsgBox(strMsg, intDialog)
 If intResponse = vbYes Then
 ' Delete control.
 DeleteControl frm.Name, ctlNew.Name
 End If
End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


OpenVisualBasicModule Macro Action

 Copy code hover
[image]

OpenVisualBasicModule Macro Action
Send feedback

You can use the OpenVisualBasicModule action to open a specified Visual Basic for Applications (VBA) module at a specified procedure. This can be a Sub procedure, a Function procedure, or an event procedure.

Note 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.

Setting

The OpenVisualBasicModule action has the following arguments.

Action argument | Description
Module Name | The name of the module you want to open. You can leave this argument blank if you want to search all the standard modules in the database for a procedure and open the appropriate module at that procedure. If you run a macro containing the OpenVisualBasicModule action in a library database, Microsoft Access first looks for the module with this name in the library database, and then in the current database.
Procedure Name | The name of the procedure you want to open the module to. If you leave this argument blank, the module opens to the Declarations section.
Note Note

You must enter a valid name in either the Module Name or Procedure Name argument.

Remarks

You can use this action to open an event procedure by specifying the Module Name argument and the Procedure Name argument. For example, to open the Click event procedure of the PrintInvoice button on the form Orders, set the Module Name argument to Form.Orders and set the Procedure Name argument to PrintInvoice_Click. To view the event procedure for a form or report, the form or report must be open.

Similarly, to open a procedure in a class module, you must specify the module name, although the class module does not have to open.

To open a private procedure, the module containing it must be open.

This action has the same effect as right-clicking a module in the Navigation Pane and then clicking Design View. This action also enables you to specify a procedure name and to search the standard modules in a database for procedures.

Tip Tip

You can select a module in the Navigation Pane and drag it to a macro action row. This automatically creates an OpenVisualBasicModule action that opens the module to the Declarations section.

To run the OpenVisualBasicModule action in a VBA module, use the OpenModule method of the DoCmd object.


You cannot modify the replication system object

 Copy code hover
[image]

You cannot modify the replication system object <name>. (Error 3665)
Send feedback

You are trying to execute an invalid operation, such as deleting a system table, renaming a system table, or deleting a replication system column, on an internal replication system object.


The database you are attempting to open is already in use by another application. (Error 3576)

 Copy code hover
[image]

The database you are attempting to open is already in use by another application. (Error 3576)
Send feedback

If you are attempting to open the database in exclusive mode, it is possible that another application already has the database open. If you are attempting to open the database in shared mode, it is possible that another application has the database open in exclusive mode. Close the other applications using the database and try your request again.


Form.DataChange Event (Access)

 Copy code hover
[image]

Form.DataChange Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when certain properties are changed or when certain methods are executed in the specified PivotTable view.

Syntax

expression .DataChange(Reason, )

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Reason | Required | Long | A PivotDataReasonEnum constant that indicates the reason that this event was triggered.

Return Value

nothing

Example

The following example demonstrates the syntax for a subroutine that traps the DataChange event.

VBA Copy code Copy code
Private Sub Form_DataChange(Reason As Long)
 If Reason = OWC.plDataReasonDisplayCellColorChange Then
 MsgBox "The cell display color was changed."
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


DoCmd.NavigateTo Method (Access)

 Copy code hover
[image]

DoCmd.NavigateTo Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the NavigateTo method to control the display of database objects in the Navigation Pane. .

Version Information

Version Added: Access 2007

Syntax

expression .NavigateTo(Category, Group)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
Category | Optional | Variant | The category by which you want the Navigation Pane to display objects.
Group | Optional | Variant | Determines which objects in the category appear in the Navigation Pane. If you leave the this argument blank, the Navigation Pane will display all database objects grouped by the criteria you specify in the Category argument. Examples of valid Group arguments for the various Category arguments are shown in the following table.

Remarks

For example, you can change how the database objects are categorized, and you can filter the objects so that only certain ones are displayed.

This action is similar to selecting categories and groups from the title bar of the Navigation Pane.

Valid Group arguments depend on which Category argument is used. If you enter an invalid Group argument, an error message appears.

The following table contains examples of valid Group arguments for each Category argument.

Category argument | Example Group arguments
Object Type | Tables; Forms; Queries; Pages; Macros; Modules
Tables and Views | Names of specific tables in your database
Modified Date | Today; Yesterday; Last Month; Older
Created Date | Today; Yesterday; Last Month; Older
Custom Category | Names of groups you have created for the specified custom category
Note Note

To navigate to the top level of a category (for example, All Tables, All Access Objects, or All Dates), you must leave the Group argument blank. For example, when the Category argument is Object Type, entering All Access Objects as a Group argument results in an error.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


ListBox.ControlTipText Property (Access)

 Copy code hover
[image]

ListBox.ControlTipText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.

Syntax

expression .ControlTipText

expression A variable that represents a ListBox object.

Remarks

You set the ControlTipText property by using a string expression up to 255 characters long.

For controls on forms, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

You can set the ControlTipText property in any view.

The ControlTipText property provides an easy way to provide helpful information about controls on a form.

There are other ways to provide information about a form or a control on a form. You can use the StatusBarText property to display information in the status bar about a control. To provide more extensive help for a form or control, use the HelpFile and HelpContextID properties.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


TextBox.AutoTab Property (Access)

 Copy code hover
[image]

TextBox.AutoTab Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AutoTab property to specify whether an automatic tab occurs when the last character permitted by a text box control's input mask is entered. An automatic tab moves the focus to the next control in the form's tab order. Read/write Boolean.

Syntax

expression .AutoTab

expression A variable that represents a TextBox object.

Remarks

The AutoTab property uses the following settings.

Setting | Visual Basic | Description
Yes | True | Generates a tab when the last allowable character in a text box is entered.
No | False | (Default) Doesn't generate a tab when the last allowable character in a text box is entered.

You can also set the default for this property by setting a control's DefaultControl property in Visual Basic.

You can also create an input mask for a text box control bound to a field by setting the InputMask property for the field in the form's underlying table or query. If the field is dragged to a form from the field list, the field's input mask is inherited by the text box control.

You could use the AutoTab property if you have a text box on a form for which you usually enter the maximum number of characters for each record. After you have entered the maximum number of characters, focus automatically moves to the next control in the tab order. For example, you could use this property for a CategoryType field that must always be five characters long.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Operation Methods (Access)

 Copy code hover
[image]

Operation Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Execute | Executes the specified operation.


Between operator without And. (Error 2430)

 Copy code hover
[image]

Between operator without And. (Error 2430)
Send feedback

When using the Between operator to test whether a value of an expression lies within a specified range of values, specify the upper and lower limits of the range separated with the reserved word And. For example, to test for a range of A to C, you could use the following code:

SQL Copy code Copy code
WHERE fldName Between "A" And "C"


Cannot perform cascading operation. It would result in a duplicate key in table

 Copy code hover
[image]

Cannot perform cascading operation. It would result in a duplicate key in table <name>. (Error 3399)
Send feedback

The cascade operation you are attempting would result in a duplicate key in the indicated table, which is set up to not allow duplicate primary keys. Check the values you are attempting to update and fix them so they do not result in duplicate keys.


ComboBox.Text Property (Access)

 Copy code hover
[image]

ComboBox.Text Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Text property to set or return the text contained in the text box portion of a combo box. Read/write String.

Syntax

expression .Text

expression A variable that represents a ComboBox object.

Remarks

You can set the Text property to the text you want to display in the control. You can also use the Text property to read the text currently in the control.

Note Note

To set or return a control's Text property, the control must have the focus, or an error occurs. To move the focus to a control, you can use the SetFocus method or GoToControl action.

While the control has the focus, the Text property contains the text data currently in the control; the Value property contains the last saved data for the control. When you move the focus to another control, the control's data is updated, and the Value property is set to this new value. The Text property setting is then unavailable until the control gets the focus again. If you use the Save Record command on the Records menu to save the data in the control without moving the focus, the Text property and Value property settings will be the same.

Example

The following example uses the Text property to enable a Next button named btnNext whenever the user enters text into a text box named txtName. Anytime the text box is empty, the Next button is disabled.

VBA Copy code Copy code
Sub txtName_Change()
 btnNext.Enabled = Len(Me!txtName.Text & "")<>0
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


CommandButton.AutoRepeat Property (Access)

 Copy code hover
[image]

CommandButton.AutoRepeat Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AutoRepeat property to specify whether an event procedure or macro runs repeatedly while a command button on a form remains pressed in. Read/write Boolean.

Syntax

expression .AutoRepeat

expression A variable that represents a CommandButton object.

Remarks

The default value is False.

The initial repeat of the event procedure or macro occurs 0.5 seconds after it first runs. Subsequent repeats occur either 0.25 seconds apart or the duration of the event procedure or macro, whichever is longer.

If the code attached to the command button causes the current record to change, the AutoRepeat property has no effect.

If the code attached to the command button causes changes to another control on a form, use the DoEvents function to ensure proper screen updating.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Parameters Members (DAO)

 Copy code hover
[image]

Parameters Members (DAO)
Send feedback

A Parameters collection contains all the Parameter objects of a QueryDef object.

Methods

Name | Description
Refresh | Updates the objects in the specified colletion to reflect the database's current schema.

Properties

Name | Description
Count | Returns the number of objects in the specified collection. Read-only.


Recordset2.FillCache Method (DAO)

 Copy code hover
[image]

Recordset2.FillCache Method (DAO)
Send feedback

Fills all or a part of a local cache for a Recordset object that contains data from a Microsoft Access database engine-connected ODBC data source (Microsoft Access database engine-connected ODBC databases only).

Syntax

expression .FillCache(Rows, StartBookmark)

expression A variable that represents a Recordset2 object.

Parameters

Name | Required/Optional | Data Type | Description
Rows | Optional | Variant | A Variant (Integer subtype) that specifies the number of rows to store in the cache. If you omit this argument, the value is determined by the CacheSize property setting.
StartBookmark | Optional | Variant | A Variant (String subtype) that specifies a bookmark. The cache is filled starting from the record indicated by this bookmark. If you omit this argument, the cache is filled starting from the record indicated by the CacheStart property.

Remarks

Caching improves the performance of an application that retrieves data from a remote server. A cache is space in local memory that holds the data most recently retrieved from the server; this assumes that the data will probably be requested again while the application is running. When a user requests data, the Microsoft Access database engine checks the cache for the data first rather than retrieving it from the server, which takes more time. The cache doesn't save data that doesn't come from an ODBC data source.

Rather than waiting for the cache to be filled with records as they are retrieved, you can use the FillCache method to explicitly fill the cache at any time. This is a faster way to fill the cache because FillCache retrieves several records at once instead of one at a time. For example, while you view each screenful of records, your application uses FillCache to retrieve the next screenful of records for viewing.

Any Microsoft Access database engine-connected ODBC data source that you access with Recordset objects can have a local cache. To create the cache, open a Recordset object from the remote data source, and then set the CacheSize and CacheStart properties of the Recordset.

If rows and startbookmark create a range of records that is partially or entirely outside the range of records specified by the CacheSize and CacheStart properties, the portion of the recordset outside this range is ignored and will not be loaded into the cache.

If FillCache requests more records than the number remaining in the remote data source, the Microsoft Access database engine retrieves only the remaining records, and no error occurs.

Note Note

  • Records retrieved from the cache don't reflect concurrent changes that other users made to the source data.

  • FillCache only retrieves records not already cached. To force an update of all the cached data, set the CacheSize property of the Recordset to 0, reset it to the size of the cache you originally requested, and then use FillCache.

Example

This example uses the CreateTableDef and FillCache methods and the CacheSize, CacheStart and SourceTableName properties to enumerate the records in a linked table twice. Then it enumerates the records twice with a 50-record cache. The example then displays the performance statistics for the uncached and cached runs through the linked table.

VBA Copy code Copy code
Sub ClientServerX3()

   Dim dbsCurrent As Database
   Dim tdfRoyalties As TableDef
   Dim rstRemote As Recordset2
   Dim sngStart As Single
   Dim sngEnd As Single
   Dim sngNoCache As Single
   Dim sngCache As Single
   Dim intLoop As Integer
   Dim strTemp As String
   Dim intRecords As Integer

   ' Open a database to which a linked table can be
   ' appended.
   Set dbsCurrent = OpenDatabase("DB1.mdb")

   ' Create a linked table that connects to a Microsoft SQL
   ' Server database.
   Set tdfRoyalties = _
      dbsCurrent.CreateTableDef("Royalties")
   ' Note: The DSN referenced below must be set to
   '       use Microsoft Windows NT Authentication Mode to
   '       authorize user access to the Microsoft SQL Server.
   tdfRoyalties.Connect = _
      "ODBC;DATABASE=pubs;DSN=Publishers"
   tdfRoyalties.SourceTableName = "roysched"
   dbsCurrent.TableDefs.Append tdfRoyalties
   Set rstRemote = _
      dbsCurrent.OpenRecordset("Royalties")

   With rstRemote
      ' Enumerate the Recordset object twice and record
      ' the elapsed time.
      sngStart = Timer

      For intLoop = 1 To 2
         .MoveFirst
         Do While Not .EOF
            ' Execute a simple operation for the
            ' performance test.
            strTemp = !title_id
            .MoveNext
         Loop
      Next intLoop

      sngEnd = Timer
      sngNoCache = sngEnd - sngStart

      ' Cache the first 50 records.
      .MoveFirst
      .CacheSize = 50
      .FillCache
      sngStart = Timer

      ' Enumerate the Recordset object twice and record
      ' the elapsed time.
      For intLoop = 1 To 2
         intRecords = 0
         .MoveFirst
         Do While Not .EOF
            ' Execute a simple operation for the
            ' performance test.
            strTemp = !title_id
            ' Count the records. If the end of the
            ' cache is reached, reset the cache to the
            ' next 50 records.
            intRecords = intRecords + 1
            .MoveNext
            If intRecords Mod 50 = 0 Then
               .CacheStart = .Bookmark
               .FillCache
            End If
         Loop
      Next intLoop

      sngEnd = Timer
      sngCache = sngEnd - sngStart

      ' Display performance results.
      MsgBox "Caching Performance Results:" & vbCr & _
         "  No cache: " & Format(sngNoCache, _
         "##0.000") & " seconds" & vbCr & _
         "  50-record cache: " & Format(sngCache, _
         "##0.000") & " seconds"
      .Close
   End With

   ' Delete linked table because this is a demonstration.
   dbsCurrent.TableDefs.Delete tdfRoyalties.Name
   dbsCurrent.Close

End Sub


Chapter 11: RDS Fundamentals

 Copy code hover
[image]

Chapter 11: RDS Fundamentals
Send feedback

This section contains a series of topics that you can read in a prescribed order. The following topics are included:

  • Solutions for Remote Data Access

  • Basic RDS Programming Model

  • RDS Programming Model in Detail

  • RDS Programming Model with Objects

  • The RDS Object Model Summary

This section also contains the RDS tutorial which demonstrate how to access and update a data source, and a series of topics about Using RDS, which discusses more advanced RDS topics.


Report.OrderByOnLoad Property (Access)

 Copy code hover
[image]

Report.OrderByOnLoad Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the sorting specified by the OrderBy property is applied when the report is loaded. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .OrderByOnLoad

expression A variable that represents a Report object.

See also

Concepts

Report Object

Other resources

Report Object Members


EditMode Property (ADO)

 Copy code hover
[image]

EditMode Property (ADO)
Send feedback

Indicates the editing status of the current record.

Return Value

Returns an EditModeEnum value.

Remarks

ADO maintains an editing buffer associated with the current record. This property indicates whether changes have been made to this buffer, or whether a new record has been created. Use the EditMode property to determine the editing status of the current record. You can test for pending changes if an editing process has been interrupted and determine whether you need to use the Update or CancelUpdate method.

See the AddNew method for a more detailed description of the EditMode property under different editing conditions.

When a call to Delete does not successfully delete the record or records in the data source (due to referential integrity violations, for example), the Recordset will remain in edit mode (EditMode = adEditInProgress). This means that CancelUpdate must be called before moving off the current record (with Move, NextRecordset, or Close, for example).

Note Note

EditMode can return a valid value only if there is a current record. EditMode will return an error if BOF or EOF is true, or if the current record has been deleted.


PrimaryKey Property (ADOX)

 Copy code hover
[image]

PrimaryKey Property (ADOX)
Send feedback

Indicates whether the index represents the primary key on the table.

Settings and Return Values

Sets and returns a Boolean value.

Remarks

The default value is False.

This property is read-only on Index objects already appended to a collection.


Cellset Object (ADO MD)

 Copy code hover
[image]

Cellset Object (ADO MD)
Send feedback

Represents the results of a multidimensional query. It is a collection of cells selected from cubes or other cellsets.

Remarks

Data within a Cellset is retrieved using direct, array-like access. You can "drill down" to a specific member to obtain data about that member. For example, the following code returns the caption of the first member in the first position on the first axis of a cellset named cst:

Copy code Copy code
cst.Axes(0).Positions(0).Members(0).Caption

There is no notion of a current cell within a cellset. Instead, the Item property retrieves a specific Cell object from the cellset. The arguments of the Item property determine which cell is retrieved. You can specify the unique ordinal value of a cell. You can also retrieve cells by using their position numbers along each axis of the cellset. For more information about retrieving cells, see the Item property.

With the collections, methods, and properties of a Cellset object, you can do the following:

  • Associate an open connection with a Cellset object by setting its ActiveConnection property.

  • Execute and retrieve the results of a multidimensional query with the Open method.

  • Retrieve a Cell from the Cellset with the Item property.

  • Return the Axis objects that define the Cellset with the Axes collection.

  • Retrieve information about the dimensions used to filter the data in the Cellset with the FilterAxis property.

  • Return or specify the query used to define the Cellset with the Source property.

  • Return the current state of the Cellset (open, closed, executing, or connecting) with the State property.

  • Close an open Cellset with the Close method.

  • Retrieve provider-specific information about the Cellset with the standard ADO Properties collection.


EmptyCell.ControlType Property (Access)

 Copy code hover
[image]

EmptyCell.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .ControlType

expression A variable that represents an EmptyCell object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


SubForm.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

SubForm.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified subform. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthLeft

expression A variable that represents a SubForm object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


ListBox.EventProcPrefix Property (Access)

 Copy code hover
[image]

ListBox.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents a ListBox object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Persisting Hierarchical Recordsets

 Copy code hover
[image]

Persisting Hierarchical Recordsets
Send feedback

You can save a hierarchical Recordset to a file in either ADTG or XML format by calling the Save method. However, two limitations apply when saving hierarchical Recordsets in XML format: You cannot save in XML if the hierarchical Recordset contains pending updates, and you cannot save a parameterized hierarchical Recordset.

For more information about the Data Shaping provider, see Microsoft Data Shaping Service for OLE DB (ADO) and The Data Shaping Service for OLE DB(OLE DB).


Syntax error in WHERE clause. (Error 3145)

 Copy code hover
[image]

Syntax error in WHERE clause. (Error 3145)
Send feedback

You entered an SQL statement that has an invalid WHERE clause.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


QueryDef.RecordsAffected Property (DAO)

 Copy code hover
[image]

QueryDef.RecordsAffected Property (DAO)
Send feedback

Returns the number of records affected by the most recently invoked Execute method.

Syntax

expression .RecordsAffected

expression A variable that represents a QueryDef object.

Remarks

When you use the Execute method to run an action query from a QueryDef object, the RecordsAffected property will contain the number of records deleted, updated, or inserted.

Example

This example uses the RecordsAffected property with action queries executed from a Database object and from a QueryDef object. The RecordsAffectedOutput function is required for this procedure to run.

VBA Copy code Copy code
Sub RecordsAffectedX()

 Dim dbsNorthwind As Database
 Dim qdfTemp As QueryDef
 Dim strSQLChange As String
 Dim strSQLRestore As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind
 ' Print report of contents of the Employees
 ' table.
 Debug.Print _
 "Number of records in Employees table: " & _
 .TableDefs!Employees.RecordCount
 RecordsAffectedOutput dbsNorthwind

 ' Define and execute an action query.
 strSQLChange = "UPDATE Employees " & _
 "SET Country = 'United States' " & _
 "WHERE Country = 'USA'"
 .Execute strSQLChange

 ' Print report of contents of the Employees
 ' table.
 Debug.Print _
 "RecordsAffected after executing query " & _
 "from Database: " & .RecordsAffected
 RecordsAffectedOutput dbsNorthwind

 ' Define and run another action query.
 strSQLRestore = "UPDATE Employees " & _
 "SET Country = 'USA' " & _
 "WHERE Country = 'United States'"
 Set qdfTemp = .CreateQueryDef("", strSQLRestore)
 qdfTemp.Execute

 ' Print report of contents of the Employees
 ' table.
 Debug.Print _
 "RecordsAffected after executing query " & _
 "from QueryDef: " & qdfTemp.RecordsAffected
 RecordsAffectedOutput dbsNorthwind

 .Close

 End With

End Sub

Function RecordsAffectedOutput(dbsNorthwind As Database)

 Dim rstEmployees As Recordset

 ' Open a Recordset object from the Employees table.
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees")

 With rstEmployees
 ' Enumerate Recordset.
 .MoveFirst
 Do While Not .EOF
 Debug.Print " " & !LastName & ", " & !Country
 .MoveNext
 Loop
 .Close
 End With

End Function


Fields Collection (ADO)

 Copy code hover
[image]

Fields Collection (ADO)
Send feedback

Contains all the Field objects of a Recordset or Record object.

Remarks

A Recordset object has a Fields collection made up of Field objects. Each Field object corresponds to a column in the Recordset. You can populate the Fields collection before opening the Recordset by calling the Refresh method on the collection.

Note Note

See the Field object topic for a more detailed explanation of how to use Field objects.

The Fields collection has an Append method, which provisionally creates and adds a Field object to the collection, and an Update method, which finalizes any additions or deletions.

A Record object has two special fields that can be indexed with FieldEnum constants. One constant accesses a field containing the default stream for the Record, and the other accesses a field containing the absolute URL string for the Record.

Certain providers (for example, the Microsoft OLE DB Provider for Internet Publishing) may populate the Fields collection with a subset of available fields for the Record or Recordset. Other fields will not be added to the collection until they are first referenced by name or indexed by your code.

If you attempt to reference a nonexistent field by name, a new Field object will be appended to the Fields collection with a Status of adFieldPendingInsert. When you call Update, ADO will create a new field in your data source if allowed by your provider.


Image.MouseUp Event (Access)

 Copy code hover
[image]

Image.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents an Image object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was released to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

Image Object

Other resources

Image Object Members


AllTables Members (Access)

 Copy code hover
[image]

AllTables Members (Access)
Send feedback

Published: July 16, 2012

The AllTables collection contains an AccessObject for each table in the CurrentData or CodeData object.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


BoundObjectFrame.SpecialEffect Property (Access)

 Copy code hover
[image]

BoundObjectFrame.SpecialEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.

Syntax

expression .SpecialEffect

expression A variable that represents a BoundObjectFrame object.

Remarks

The SpecialEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | 0 | The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised | 1 | The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken | 2 | The object has a shadow on the top and left and a highlight on the bottom and right.
Etched | 3 | The object has a sunken line surrounding the control.
Shadowed | 4 | The object has a shadow below and to the right of the control.
Chiseled | 5 | The object has a sunken line below the control.

The SpecialEffect property setting affects related property settings for the BorderStyle , BorderColor , and BorderWidth properties. For example, if the SpecialEffect property is set to Raised, the settings for the BorderStyle, BorderColor, and BorderWidth properties are ignored. In addition, changing or setting the BorderStyle, BorderColor, and BorderWidth properties may cause Microsoft Access to change the SpecialEffect property setting to Flat.

Example

The following example sets the appearance of the text box "OrganizationName1" on the "Mailing List" form to raised.

VBA Copy code Copy code
Forms("Mailing List").Controls("OrganizationName1").SpecialEffect = 1

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


SmartTag.Name Property (Access)

 Copy code hover
[image]

SmartTag.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.

Syntax

expression .Name

expression A variable that represents a SmartTag object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

SmartTag Object

Other resources

SmartTag Object Members


Form.Name Property (Access)

 Copy code hover
[image]

Form.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a Form object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

Form Object

Other resources

Form Object Members


The width of a Unicode text column must be an even number of bytes. (Error 3702)

 Copy code hover
[image]

The width of a Unicode text column must be an even number of bytes. (Error 3702)
Send feedback

The database stores data using the Unicode character set, in which each character is a word (two-byte) value. Columns for text must be declared to be an even number of bytes wide so that the columns can hold an exact number of Unicode characters.

  • If this error message appears during database creation, the program that is attempting to create an incorrect database should be corrected.

  • If this error message appears during normal run time, it is probable that the database has become corrupted and needs to be compacted or repaired.


AdditionalData.Add Method (Access)

 Copy code hover
[image]

AdditionalData.Add Method (Access)
See also Send feedback

Published: July 16, 2012

Adds an add table or query that will be included when the ExportXML method is called.

Syntax

expression .Add(var)

expression A variable that represents an AdditionalData object.

Parameters

Name | Required/Optional | Data Type | Description
var | Required | String | The name of the table or query to add.

Return Value

AdditionalData

See also

Concepts

AdditionalData Object

Other resources

AdditionalData Object Members


ObjectFrame.Application Property (Access)

 Copy code hover
[image]

ObjectFrame.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents an ObjectFrame object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


SELECTSECURITY (Microsoft Access SQL reserved word)

 Copy code hover
[image]

SELECTSECURITY (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The SELECTSECURITY keyword is used in these contexts:

GRANT Statement

REVOKE Statement


ObjectFrame.UpdateOptions Property (Access)

 Copy code hover
[image]

ObjectFrame.UpdateOptions Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the UpdateOptions property to specify how a linkedOLE object is updated. Read/write Integer.

Syntax

expression .UpdateOptions

expression A variable that represents an ObjectFrame object.

Remarks

The UpdateOptions property uses the following settings.

Setting | Visual Basic | Description
Automatic | acOLEUpdateAutomatic | (Default) Updates the object each time the linked data changes.
Manual | acOLEUpdateManual | Updates the object only when the control's Action property is set to acOLEUpdate or the link is updated with the OLE/DDE Links command on the Edit menu.

Normally, the object is updated automatically whenever the linked data changes, but you can tell Microsoft Access to update the data only when it receives a specific instruction to do so. For example, if other users or applications can access or change linked spreadsheet data on a form, you can use this property to specify that the linked data only be updated when the database is opened in single-user mode.

When the UpdateOptions property is set to Manual, updates don't occur based on the setting of the Refresh interval box on the Advanced tab of the Options dialog box, available by clicking Options on the Tools menu.

Note Note

When an object's data is changed, the Updated event occurs.

Example

The following example sets the UpdateOptions property for an unbound object frame named OLE1 to update manually, and then uses the Action property to force an update of the OLE object in the control.

VBA Copy code Copy code
OLE1.UpdateOptions = acOLEUpdateManual
OLE1.Action = acOLEUpdate

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


SELECT.INTO Statement (Microsoft Access SQL)

 Copy code hover
[image]

SELECT.INTO Statement (Microsoft Access SQL)
Send feedback

Creates a make-table query.

Syntax

SELECT field1[, field2[, …]] INTO newtable [IN externaldatabase] FROM source

The SELECT…INTO statement has these parts:

Part | Description
field1, field2 | The name of the fields to be copied into the new table.
newtable | The name of the table to be created. It must conform to standard naming conventions. If newtable is the same as the name of an existing table, a trappable error occurs.
externaldatabase | The path to an external database. For a description of the path, see the IN clause.
source | The name of the existing table from which records are selected. This can be single or multiple tables or a query.

Remarks

You can use make-table queries to archive records, make backup copies of your tables, or make copies to export to another database or to use as a basis for reports that display data for a particular time period. For example, you could produce a Monthly Sales by Region report by running the same make-table query each month.

Note Note

  • You may want to define a primary key for the new table. When you create the table, the fields in the new table inherit the data type and field size of each field in the query's underlying tables, but no other field or table properties are transferred.

  • To add data to an existing table, use the INSERT INTO statement instead to create an append query.

  • To find out which records will be selected before you run the make-table query, first examine the results of a SELECT statement that uses the same selection criteria.

Example

This example selects all records in the Employees table and copies them into a new table named Emp Backup.

VBA Copy code Copy code
Sub SelectIntoX()

    Dim dbs As Database
    Dim qdf As QueryDef

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Select all records in the Employees table
    ' and copy them into a new table, Emp Backup.
    dbs.Execute "SELECT Employees.* INTO " _
        & "[Emp Backup] FROM Employees;"

    ' Delete the table because this is a demonstration.
    dbs.Execute "DROP TABLE [Emp Backup];"

    dbs.Close

End Sub


Form.DataSetChange Property (Access)

 Copy code hover
[image]

Form.DataSetChange Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the DataSetChange event occurs. Read/write.

Syntax

expression .DataSetChange

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the DataSetChange event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).DataSetChange = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


Sort Property Example (VJ++)

 Copy code hover
[image]

Sort Property Example (VJ++)
Send feedback

This example uses the Recordset object's Sort property to reorder the rows of a Recordset derived from the Authors table of the Pubs database. A secondary utility routine prints each row.

Copy code Copy code

// BeginSortJ
import com.ms.wfc.data.*;
import java.io.* ;

public class SortX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 SortX();
 System.exit(0);
 }

 // SortX function

 static void SortX()
 {
 // Define ADO Objects.
 Connection cnConn1 = null;
 Recordset rstAuthors = null;

 // Declarations.
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';" +
 "Initial Catalog='Pubs';Integrated Security='SSPI';";

 try
 {
 cnConn1 = new Connection();
 cnConn1.open(strCnn);
 rstAuthors = new Recordset();
 rstAuthors.setCursorLocation(AdoEnums.CursorLocation.CLIENT);
 rstAuthors.open("SELECT * FROM Authors",
 cnConn1,
 AdoEnums.CursorType.STATIC,
 AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TEXT);
 SortXprint("Initial Order",rstAuthors);

 rstAuthors.setSort("au_lname ASC, au_fname ASC");
 SortXprint("Last Name Ascending",rstAuthors);

 rstAuthors.setSort("au_lname DESC, au_fname ASC");
 SortXprint("Last Name Descending",rstAuthors);
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstAuthors != null)
 {
 PrintProviderError(rstAuthors.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstAuthors != null)
 if (rstAuthors.getState() == 1)
 rstAuthors.close();
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 }

 }

 // SortXprint function

 static void SortXprint(String strTitle,Recordset rstp)
 {
 // Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 int intDisplaysize = 15;
 int intCount = 1;
 try
 {
 System.out.println("---------------" +
 strTitle +
 "---------------");
 System.out.println("First Name Last Name" + "\n" +
 "-------------------------" +
 "-------------------------");
 rstp.moveFirst();
 while(!rstp.getEOF())
 {
 System.out.println(rstp.getField("au_fname").getString() +
 " " +
 rstp.getField("au_lname").getString());
 if(intCount % intDisplaysize == 0)
 {
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 intCount = 0;
 }
 intCount++;
 rstp.moveNext();
 }
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstp != null)
 {
 PrintProviderError(rstp.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }
 }
 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndSortJ


Rectangle.SizeToFit Method (Access)

 Copy code hover
[image]

Rectangle.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents a Rectangle object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


ODBC -- Cannot lock all records. (Error 3254)

 Copy code hover
[image]

ODBC -- Cannot lock all records. (Error 3254)
Send feedback

Using an ODBC connection, you tried to lock all of the records in an ODBC database.


Invalid use of Is operator. (Error 2443)

 Copy code hover
[image]

Invalid use of Is operator. (Error 2443)
Send feedback

The Is operator is used to determine if an expression is Null. You can use the Is operator in an expression only with NULL or NOT NULL.


ObjectFrame.Left Property (Access)

 Copy code hover
[image]

ObjectFrame.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Syntax

expression .Left

expression A variable that represents an ObjectFrame object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


ADO Objects and Interfaces Reference

 Copy code hover
[image]

ADO Objects and Interfaces Reference
Send feedback

In this section

  • ADO Objects and Interfaces

  • ADORecordConstruction Interface (ADO)

  • ADORecordsetConstruction Interface (ADO)

  • Command Object (ADO) Reference

  • Connection Object (ADO) Reference

  • Error Object (ADO) Reference

  • Field Object (ADO) Reference

  • Parameter Object (ADO) Reference

  • Property Object (ADO) Reference

  • Record Object (ADO) Reference

  • Recordset Object (ADO) Reference

  • Stream Object (ADO) Reference


Image.SpecialEffect Property (Access)

 Copy code hover
[image]

Image.SpecialEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.

Syntax

expression .SpecialEffect

expression A variable that represents an Image object.

Remarks

The SpecialEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | 0 | The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised | 1 | The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken | 2 | The object has a shadow on the top and left and a highlight on the bottom and right.
Etched | 3 | The object has a sunken line surrounding the control.
Shadowed | 4 | The object has a shadow below and to the right of the control.
Chiseled | 5 | The object has a sunken line below the control.

The SpecialEffect property setting affects related property settings for the BorderStyle , BorderColor , and BorderWidth properties. For example, if the SpecialEffect property is set to Raised, the settings for the BorderStyle, BorderColor, and BorderWidth properties are ignored. In addition, changing or setting the BorderStyle, BorderColor, and BorderWidth properties may cause Microsoft Access to change the SpecialEffect property setting to Flat.

Example

The following example sets the appearance of the text box "OrganizationName1" on the "Mailing List" form to raised.

VBA Copy code Copy code
Forms("Mailing List").Controls("OrganizationName1").SpecialEffect = 1

See also

Concepts

Image Object

Other resources

Image Object Members


Invalid Memo or OLE Object in subquery

 Copy code hover
[image]

Invalid Memo or OLE Object in subquery <name>. (Error 3342)
Send feedback

A subquery cannot return a Memo or OLE Object, and it cannot be compared to a Memo or OLE Object in an expression.


Data Import/Export

 Copy code hover
[image]

Data Import/Export
Send feedback

In this section

  • RunSavedImportExport Macro Action

  • EMailDatabaseObject Macro Action

  • ExportWithFormatting Macro Action

  • ImportExportData Macro Action

  • ImportExportSpreadsheet Macro Action

  • ImportExportText Macro Action

  • ImportSharePointList Macro Action


Attachment.AttachmentCount Property (Access)

 Copy code hover
[image]

Attachment.AttachmentCount Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the number of documents attached to the specified Attachment control. Read-only Long.

Version Information

Version Added: Access 2007

Syntax

expression .AttachmentCount

expression A variable that represents an Attachment object.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


SELECTSCHEMA (Microsoft Access SQL reserved word)

 Copy code hover
[image]

SELECTSCHEMA (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The SELECTSCHEMA keyword is used in these contexts:

GRANT Statement

REVOKE Statement


BOF, EOF, and Bookmark Properties Example (VB)

 Copy code hover
[image]

BOF, EOF, and Bookmark Properties Example (VB)
Send feedback

This example uses the BOF and EOF properties to display a message if a user tries to move past the first or last record of a Recordset. It uses the Bookmark property to let the user flag a record in a Recordset and return to it later.

Copy code Copy code

'BeginBOFVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 'recordset and connection variables
 Dim Cnxn As ADODB.Connection
 Dim rstPublishers As ADODB.Recordset
 Dim strCnxn As String
 Dim strSQLPubs As String
 'record variables
 Dim strMessage As String
 Dim intCommand As Integer
 Dim varBookmark As Variant

 ' open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open recordset and use client cursor
 ' to enable AbsolutePosition property
 Set rstPublishers = New ADODB.Recordset
 strSQLPubs = "SELECT pub_id, pub_name FROM publishers ORDER BY pub_name"
 rstPublishers.Open strSQLPubs, strCnxn, adUseClient, adOpenStatic, adCmdText

 rstPublishers.MoveFirst
 Do Until rstPublishers.EOF
 ' Display information about current record
 ' and get user input
 strMessage = "Publisher: " & rstPublishers!pub_name & _
 vbCr & "(record " & rstPublishers.AbsolutePosition & _
 " of " & rstPublishers.RecordCount & ")" & vbCr & vbCr & _
 "Enter command:" & vbCr & _
 "[1 - next / 2 - previous /" & vbCr & _
 "3 - set bookmark / 4 - go to bookmark]"
 intCommand = Val(InputBox(strMessage))

 ' Check user input
 Select Case intCommand
 Case 1
 ' Move forward trapping for EOF
 rstPublishers.MoveNext
 If rstPublishers.EOF Then
 MsgBox "Moving past the last record." & _
 vbCr & "Try again."
 rstPublishers.MoveLast
 End If
 Case 2
 ' Move backward trapping for BOF
 rstPublishers.MovePrevious
 If rstPublishers.BOF Then
 MsgBox "Moving past the first record." & _
 vbCr & "Try again."
 rstPublishers.MoveFirst
 End If
 Case 3
 ' Store the bookmark of the current record
 varBookmark = rstPublishers.Bookmark
 Case 4
 ' Go to the record indicated by the stored bookmark
 If IsEmpty(varBookmark) Then
 MsgBox "No Bookmark set!"
 Else
 rstPublishers.Bookmark = varBookmark
 End If
 Case Else
 Exit Do
 End Select
 Loop

 ' clean up
 rstPublishers.Close
 Cnxn.Close
 Set rstPublishers = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstPublishers Is Nothing Then
 If rstPublishers.State = adStateOpen Then rstPublishers.Close
 End If
 Set rstPublishers = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndBOFVB

This example uses the Bookmark and Filter properties to create a limited view of the Recordset. Only records referenced by the array of bookmarks are accessible.

Copy code Copy code

'BeginBOF2VB
Public Sub Main()
 On Error GoTo ErrorHandler

 'recordset and connection variables
 Dim rs As New ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strSQL As String
 Dim strCnxn As String

 Dim bmk(10)

 ' open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 'open the recordset client-side
 Set rs = New ADODB.Recordset
 strSQL = "Select * from Authors"
 rs.Open strSQL, Cnxn, adUseClient, adLockReadOnly, adCmdText
 Debug.Print "Number of records before filtering: ", rs.RecordCount

 Dim ii As Integer
 ii = 0

 If rs.EOF <> True And ii < 11 Then
 Do
 If Not (rs.EOF <> True And ii < 11) Then Exit Do
 bmk(ii) = rs.Bookmark
 ii = ii + 1
 rs.Move 2
 Loop Until rs.EOF
 End If

 rs.Filter = bmk
 Debug.Print "Number of records after filtering: ", rs.RecordCount

 rs.MoveFirst
 If rs.EOF <> True Then
 Do
 Debug.Print rs.AbsolutePosition, rs("au_lname")
 rs.MoveNext
 Loop Until rs.EOF
 End If

 ' clean up
 rs.Close
 Cnxn.Close
 Set rs = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rs Is Nothing Then
 If rs.State = adStateOpen Then rs.Close
 End If
 Set rs = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndBOF2VB


OptionGroup.AfterUpdate Property (Access)

 Copy code hover
[image]

OptionGroup.AfterUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.

Syntax

expression .AfterUpdate

expression A variable that represents an OptionGroup object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the AfterUpdate event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the AfterUpdate event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).AfterUpdate = "[Event Procedure]"

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


ObjectFrame.DisplayType Property (Access)

 Copy code hover
[image]

ObjectFrame.DisplayType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayType property to specify whether Microsoft Access displays an OLE object's content or an icon. Read/write Boolean.

Syntax

expression .DisplayType

expression A variable that represents an ObjectFrame object.

Remarks

For example, if the OLE object is a Microsoft Word document and you set this property to Content, the control displays the Word document; if you set this property to Icon, the control displays the Microsoft Word icon.

The DisplayType property uses the following settings.

Setting | Visual Basic | Description
Content | acOLEDisplayContent | (Default) When the control contains an OLE object, the control displays the object's data, such as a document or spreadsheet.
Icon | acOLEDisplayIcon | When the control contains an OLE object, the control displays the object's icon.

The DisplayType property determines the default setting of the Display As Icon check box in the Paste Special dialog box, available by clicking Paste Special on the Edit menu, and the Insert Object dialog box, displayed when inserting an unbound object frame. When you display these dialog boxes in Form view, Datasheet view, or Design view, the Display As Icon check box is automatically selected if the DisplayType property is set to Icon. For example, you will see these boxes selected when using Visual Basic to set the control's Action property to acOLEInsertObjDlg or acOLEPasteSpecialDlg.

The DisplayType property setting has no effect on the state of the Display As Icon check box in the Object dialog box when you insert an object into an unbound object frame. When you paste an object from the Clipboard, the Display As Icon check box reflects the state of the object on the Clipboard.

Changing the DisplayType property of a bound object frame doesn't affect the display of existing objects in the control. However, it will affect new objects that you add to the control by using the Object command on the Insert menu.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


SubForm.Locked Property (Access)

 Copy code hover
[image]

SubForm.Locked Property (Access)
See also Send feedback

Published: July 16, 2012

The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.

Syntax

expression .Locked

expression A variable that represents a SubForm object.

Remarks

The default setting of the Locked property is True. This setting allows editing, adding, and deleting data.

Use the Locked property to protect data in a field by making it read-only. For example, you might want a control to only display information without allowing editing, or you might want to lock a control until a specific condition is met.

Example

The following example toggles the Enabled property of a command button and the Enabled and Locked properties of a control, depending on the type of employee displayed in the current record. If the employee is a manager, then the SalaryDetails button is enabled and the PersonalInfo control is unlocked and enabled.

VBA Copy code Copy code
Sub Form_Current()
 If Me!EmployeeType = "Manager" Then
 Me!SalaryDetails.Enabled = True
 Me!PersonalInfo.Enabled = True
 Me!PersonalInfo.Locked = False
 Else
 Me!SalaryDetails.Enabled = False
 Me!PersonalInfo.Enabled = False
 Me!PersonalInfo.Locked = True
 End If
End Sub

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


CustomControl.BorderTint Property (Access)

 Copy code hover
[image]

CustomControl.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderTint

expression A variable that represents a CustomControl object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Form.OnUndo Property (Access)

 Copy code hover
[image]

Form.OnUndo Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the Undo event occurs. Read/write..

Syntax

expression .OnUndo

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the Undo event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the Undo event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).OnUndo = "[Event Procedure]"

The following example specifies that when the Undo event occurs in any text box on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Dim ctlLoop As Control

For Each ctlLoop In Forms(0).Controls
 If ctlLoop.Type = acTextBox Then
 ctlLoop.OnUndo = "[Event Procedure]"
 End If
Next ctlLoop

See also

Concepts

Form Object

Other resources

Form Object Members


MaxRecords Property

 Copy code hover
[image]

MaxRecords Property
Send feedback

Published: July 16, 2012

Specifies the maximum number of records that will be returned by:

  • A query that returns data from an ODBC database to an Microsoft Access database .

  • A view that returns data from a SQL database to an Access project (.adp).

Setting

The MaxRecords property setting is a Long Integer value representing the number of records that will be returned.

In a Microsoft Access database, you can set this property by using the query's property sheet or Visual Basic .

Remarks

When you set this property in Visual Basic you use the ADO MaxRecords property.

Records are returned in the order specified by the query's ORDER BY clause.

You can use the MaxRecords property in situations where limited system resources might prohibit a large number of returned records.


Modules.Parent Property (Access)

 Copy code hover
[image]

Modules.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a Modules object.

See also

Concepts

Modules Collection

Other resources

Modules Object Members


CubeDefs Collection (ADO MD)

 Copy code hover
[image]

CubeDefs Collection (ADO MD)
Send feedback

Contains the CubeDef objects that represent a cube from a multidimensional catalog.

Remarks

CubeDefs is a standard ADO collection. With the properties and methods of a collection, you can do the following:

  • Obtain the number of objects in the collection with the Count property.

  • Return an object from the collection with the default Item property.

  • Update the objects in the collection from the provider with the Refresh method.


Record(s) cannot be edited; no update permission on

 Copy code hover
[image]

Record(s) cannot be edited; no update permission on <name>. (Error 3108)
Send feedback

You must have update data permission for the specified table or query to replace data in it. To change your permission assignments, see your workgroup administrator or the table or query's creator.


Text functions (Access 2013 custom web app)

 Copy code hover
[image]

Text functions (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • CharIndex Function (Access 2013 custom web app)

  • Concat Function (Access 2013 custom web app)

  • Left Function (Access 2013 custom web app)

  • Len Function (Access 2013 custom web app)

  • Lower Function (Access 2013 custom web app)

  • LTrim Function (Access 2013 custom web app)

  • Replace Function (Access 2013 custom web app)

  • Replicate Function (Access 2013 custom web app)

  • Right Function (Access 2013 custom web app)

  • RTrim Function (Access 2013 custom web app)

  • Stuff Function (Access 2013 custom web app)

  • SubString Function (Access 2013 custom web app)

  • Upper Function (Access 2013 custom web app)


Label.OnMouseMove Property (Access)

 Copy code hover
[image]

Label.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Syntax

expression .OnMouseMove

expression A variable that represents a Label object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

Label Object

Other resources

Label Object Members


Visual C++

 Copy code hover
[image]

Visual C++
Send feedback

This is a schematic description of how to instantiate ADO events in Microsoft Visual C++. See ADO Events Model Example (VC++) for a complete description.

Create classes derived from the ConnectionEventsVt and RecordsetEventsVt interfaces found in the file adoint.h.

Copy code Copy code

// BeginEventExampleVC01
class CConnEvent : public ConnectionEventsVt
{
 public:
 STDMETHODIMP InfoMessage(
 ADOError *pError,
 EventStatusEnum *adStatus,
 _ADOConnection *pConnection);
...
}

class CRstEvent : public RecordsetEventsVt
{
 public:
 STDMETHODIMP WillChangeField(
 LONG cFields,
 VARIANT Fields,
 EventStatusEnum *adStatus,
 _ADORecordset *pRecordset);
...
}
// EndEventExampleVC01

Implement each of the event-handler methods in both classes. It is sufficient that each method merely return an HRESULT of S_OK. However, when you make it known that your event handlers are available, they will be called continuously by default. Instead, you might want to request no further notification after the first time by setting adStatus to adStatusUnwantedEvent.

Copy code Copy code

// BeginEventExampleVC02
STDMETHODIMP CConnEvent::ConnectComplete(
 ADOError *pError,
 EventStatusEnum *adStatus,
 _ADOConnection *pConnection)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 }

// EndEventExampleVC02

The event classes inherit from IUnknown, so you must also implement the QueryInterface, AddRef, and Release methods. Also implement class constructors and destructors. Choose the Visual C++ tools with which you are most comfortable to simplify this part of the task.

Make it known that your event handlers are available by issuing QueryInterface on the Recordset and Connection objects for the IConnectionPointContainer and IConnectionPoint interfaces. Then issue IConnectionPoint::Advise for each class.

For example, assume you are using a Boolean function that returns True if it successfully informs a Recordset object that you have event handlers available.

Copy code Copy code

// BeginEventExampleVC03
HRESULT hr;
DWORD dwEvtClass;
IConnectionPointContainer *pCPC = NULL;
IConnectionPoint *pCP = NULL;
CRstEvent *pRStEvent = NULL;
...
_RecordsetPtr pRs;
pRs.CreateInstance(__uuidof(Recordset));
pRStEvent = new CRstEvent;
if (pRStEvent == NULL) return FALSE;
...
hr = pRs->QueryInterface(IID_IConnectionPointContainer, (LPVOID *)&pCPC);
if (FAILED(hr)) return FALSE;
hr = pCPC->FindConnectionPoint(RecordsetEvents, &pCP);
pCPC->Release(); // Always Release now, even before checking.
if (FAILED(hr)) return FALSE;
hr = pCP->Advise(pRstEvent, &dwEvtClass); //Turn on event support.
pCP->Release();
if (FAILED(hr)) return FALSE;
...
return TRUE;
...
// EndEventExampleVC03

At this point, events for the RecordsetEvent family are enabled and your methods will be called as Recordset events occur.

Later, when you want to make your event handlers unavailable, get the connection point again and issue the IConnectionPoint::Unadvise method.

Copy code Copy code

// BeginEventExampleVC04
...
hr = pCP->Unadvise(dwEvtClass); //Turn off event support.
pCP->Release();
if (FAILED(hr)) return FALSE;
...
// EndEventExampleVC04

You must release interfaces and destroy class objects as appropriate.

The following code shows a complete example of a Recordset Event sink class.

Copy code Copy code

// BeginEventExampleVC05
#include <adoint.h>

class CADORecordsetEvents : public RecordsetEventsVt
{
public :

 ULONG m_ulRefCount;
 CADORecordsetEvents():m_ulRefCount(1){}

 STDMETHOD(QueryInterface)(REFIID iid, LPVOID * ppvObject)
 {
 if (IsEqualIID(__uuidof(IUnknown), iid) ||
 IsEqualIID(__uuidof(RecordsetEventsVt), iid))
 {
 *ppvObject = this;
 return S_OK;
 }
 else
 return E_NOINTERFACE;
 }

 STDMETHOD_(ULONG, AddRef)()
 {
 return m_ulRefCount++;
 }

 STDMETHOD_(ULONG, Release)()
 {
 if (--m_ulRefCount == 0)
 {
 delete this;
 return 0;
 }
 else
 return m_ulRefCount;
 }

 STDMETHOD(WillChangeField)(
 LONG cFields,
 VARIANT Fields,
 EventStatusEnum *adStatus,
 _ADORecordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 }

 STDMETHOD(FieldChangeComplete)(
 LONG cFields,
 VARIANT Fields,
 ADOError *pError,
 EventStatusEnum *adStatus,
 _ADORecordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 }

 STDMETHOD(WillChangeRecord)(
 EventReasonEnum adReason,
 LONG cRecords,
 EventStatusEnum *adStatus,
 _ADORecordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 }

 STDMETHOD(RecordChangeComplete)(
 EventReasonEnum adReason,
 LONG cRecords,
 ADOError *pError,
 EventStatusEnum *adStatus,
 _ADORecordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 }

 STDMETHOD(WillChangeRecordset)(
 EventReasonEnum adReason,
 EventStatusEnum *adStatus,
 _ADORecordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 }

 STDMETHOD(RecordsetChangeComplete)(
 EventReasonEnum adReason,
 ADOError *pError,
 EventStatusEnum *adStatus,
 _ADORecordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 }

 STDMETHOD(WillMove)(
 EventReasonEnum adReason,
 EventStatusEnum *adStatus,
 _ADORecordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 }

 STDMETHOD(MoveComplete)(
 EventReasonEnum adReason,
 ADOError *pError,
 EventStatusEnum *adStatus,
 _ADORecordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 }

 STDMETHOD(EndOfRecordset)(
 VARIANT_BOOL *fMoreData,
 EventStatusEnum *adStatus,
 _ADORecordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 }

 STDMETHOD(FetchProgress)(
 long Progress,
 long MaxProgress,
 EventStatusEnum *adStatus,
 _ADORecordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 }

 STDMETHOD(FetchComplete)(
 ADOError *pError,
 EventStatusEnum *adStatus,
 _ADORecordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 }

};
// EndEventExampleVC05


ComboBox.Parent Property (Access)

 Copy code hover
[image]

ComboBox.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a ComboBox object.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Description Property (ADO)

 Copy code hover
[image]

Description Property (ADO)
Send feedback

Describes an Error object.

Return Value

Returns a String value that contains a description of the error.

Remarks

Use the Description property to obtain a short description of the error. Display this property to alert the user to an error that you cannot or do not want to handle. The string will come from either ADO or a provider.

Providers are responsible for passing specific error text to ADO. ADO adds an Error object to the Errors collection for each provider error or warning it receives. Enumerate the Errors collection to trace the errors that the provider passes.


Attributes Property Example (VC++)

 Copy code hover
[image]

Attributes Property Example (VC++)
Send feedback

This example demonstrates the Attributes property of a Column. Setting it to adColNullable allows the user to set the value of a Recordset Field to an empty string. In this situation, the user can distinguish between a record where data is not known and a record where the data does not apply.

Copy code Copy code

// BeginAttributesCpp
#import "c:\Program Files\Common Files\system\ado\msado15.dll"
#import "c:\Program Files\Common Files\system\ado\msadox.dll" no_namespace

#include "iostream.h"
#include "stdio.h"
#include "conio.h"
#include "ADOXAttributesX.h"

//Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void AttributesX(void);
inline char* mygets(char* strDest, int n)
{
 char strExBuff[10];
 char* pstrRet = fgets(strDest, n, stdin);

 if (pstrRet == NULL)
 return NULL;

 if (!strrchr(strDest, '\n'))
 // Exhaust the input buffer.
 do
 {
 fgets(strExBuff, sizeof(strExBuff), stdin);
 }while (!strrchr(strExBuff, '\n'));
 else
 // Replace '\n' with '\0'
 strDest[strrchr(strDest, '\n') - strDest] = '\0';

 return pstrRet;
}

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 AttributesX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// AttributesX Function //
// //
//////////////////////////////////////////////////////////
void AttributesX(void)
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.
 _CatalogPtr m_pCatalog = NULL;
 _ColumnPtr m_pColumn = NULL;
 _TablePtr m_pTable = NULL;

 // Define ADODB object pointers
 ADODB::_ConnectionPtr m_pCnn = NULL;
 ADODB::_RecordsetPtr m_pRstEmployees = NULL;

 IADORecordBinding *picRs = NULL; // Interface Pointer Declared
 CEmployeeRs emprs; // C++ Class Object

 // Define string variables.
 _bstr_t strcnn("Provider='Microsoft.JET.OLEDB.4.0';"
 "Data Source= 'c:\\Program Files\\Microsoft Office\\"
 "Office\\Samples\\Northwind.mdb';");

 try
 {
 // Connect the catalog.
 TESTHR(hr = m_pCnn.CreateInstance(__uuidof (ADODB::Connection)));
 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof (Catalog)));
 TESTHR(hr = m_pColumn.CreateInstance(__uuidof(Column)));
 TESTHR(hr = m_pRstEmployees.CreateInstance(__uuidof(ADODB::Recordset)));

 m_pCnn->Open(strcnn,"","",NULL);
 m_pCatalog->PutActiveConnection(
 _variant_t((IDispatch *) m_pCnn));
 m_pTable= m_pCatalog->Tables->GetItem("Employees");

 // Create a new Field object and append it to the Fields
 // collection of the Employees table.
 m_pColumn->Name = "FaxPhone";
 m_pColumn->Type = adVarWChar;
 m_pColumn->DefinedSize = 24;
 m_pColumn->Attributes = adColNullable;

 m_pCatalog->Tables->GetItem("Employees")->Columns->
 Append(m_pColumn->Name, adVarWChar, 24);
 //Append("FaxPhone",adVarWChar,24);

 // Open the Employees table for updating as a Recordset.
 m_pRstEmployees->Open("Employees",
 _variant_t((IDispatch *) m_pCnn),
 ADODB::adOpenKeyset,ADODB::adLockOptimistic,
 ADODB::adCmdTable);

 // Get user input.
 printf("Enter fax number for : %s %s\n",(LPSTR) (_bstr_t)
 m_pRstEmployees->Fields->GetItem("LastName")->Value,
 (LPSTR) (_bstr_t) m_pRstEmployees->Fields->
 GetItem("FirstName")->Value);
 printf("[? - unknown, X - has no fax] : \n");
 char strInput[10];
 mygets(strInput, 10);
 char* strTemp = strtok(strInput," \t");
 _variant_t vNull;
 vNull.vt = VT_BSTR;
 vNull.bstrVal = NULL;
 if(strTemp!=NULL)
 {
 if(strcmp(strTemp,"?") == 0)
 {
 m_pRstEmployees->Fields->GetItem("FaxPhone")->
 PutValue(vNull);
 }
 else if( (strcmp(strTemp,"X") == 0) | (strcmp(strTemp,"x") == 0) )
 {
 m_pRstEmployees->Fields->GetItem("FaxPhone")->
 PutValue("");
 }
 else
 {
 m_pRstEmployees->Fields->GetItem("FaxPhone")->
 PutValue(strTemp);
 }
 m_pRstEmployees->Update();

 // Open an IADORecordBinding interface pointer which
 // we will use for binding Recordset to a class
 TESTHR(hr = m_pRstEmployees->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 // Bind the Recordset to a C++ class here
 TESTHR(hr = picRs->BindToRecordset(&emprs));

 // Print report.
 printf("\nName - Fax number\n");
 printf("%s %s ",emprs.lemp_LastNameStatus == adFldOK ?
 emprs.m_szemp_LastName : "<NULL>",
 emprs.lemp_FirstNameStatus == adFldOK ?
 emprs.m_szemp_FirstName : "<NULL>");

 if (emprs.lemp_FaxphoneStatus == adFldNull)
 printf("- [Unknown]\n");
 else if (strcmp((LPSTR)emprs.m_szemp_Faxphone,"") == 0)
 printf("- [Has no fax]\n");
 else
 printf("- %s\n",emprs.m_szemp_Faxphone);

 }

 // Delete new field because this is a demonstration.
 //m_pTable->Columns->Delete(m_pColumn->Name);
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }
 catch(...)
 {
 cout << "Error occured in AttributesX...."<< endl;
 }

 if (m_pRstEmployees)
 if (m_pRstEmployees->State == 1)
 m_pRstEmployees->Close();

 // Delete new field because this is a demonstration.
 if (m_pTable != NULL)
 m_pTable->Columns->Delete(m_pColumn->Name);

 if (m_pCnn)
 if (m_pCnn->State == 1)
 m_pCnn->Close();

 // Release the IADORecordset Interface here
 if(picRs)
 picRs->Release();

}
// EndAttributesCpp

ADOXAttributesX.h

Copy code Copy code
                      // BeginAttributesH
#include "icrsint.h"

//This class extracts LastName, FirstName, FaxPhone from Employees table

class CEmployeeRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CEmployeeRs)

 // Column LastName is the 2nd field in the table
 ADO_VARIABLE_LENGTH_ENTRY2(2,adVarChar,m_szemp_LastName,
 sizeof(m_szemp_LastName),lemp_LastNameStatus,TRUE)

 // Column FirstName is the 17th field in the table
 ADO_VARIABLE_LENGTH_ENTRY2(17,adVarChar,m_szemp_FirstName,
 sizeof(m_szemp_FirstName),lemp_FirstNameStatus,TRUE)

 // Column FaxPhone is the 18th field in the table
 ADO_VARIABLE_LENGTH_ENTRY2(18,adVarChar,m_szemp_Faxphone,
 sizeof(m_szemp_Faxphone),lemp_FaxphoneStatus,TRUE)

END_ADO_BINDING()

public:
 CHAR m_szemp_LastName[21];
 ULONG lemp_LastNameStatus;
 CHAR m_szemp_FirstName[11];
 ULONG lemp_FirstNameStatus;
 CHAR m_szemp_Faxphone[25];
 ULONG lemp_FaxphoneStatus;
};
// EndAttributesH


Name Property (ADO MD)

 Copy code hover
[image]

Name Property (ADO MD)
Send feedback

Indicates the name of an object.

Return Values

Returns a String and is read-only.

Remarks

You can retrieve the Name property of an object by an ordinal reference, after which you can refer to the object directly by name. For example, if cdf.CubeDefs(0).Name yields "Bobs Video Store", you can refer to this CubeDef as cdf.CubeDefs("Bobs Video Store").


ToggleButton.Top Property (Access)

 Copy code hover
[image]

ToggleButton.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Syntax

expression .Top

expression A variable that represents a ToggleButton object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Recordset.ValidationText Property (DAO)

 Copy code hover
[image]

Recordset.ValidationText Property (DAO)
Send feedback

Sets or returns a value that specifies the text of the message that your application displays if the value of a Field object doesn't satisfy the validation rule specified by the ValidationRule property setting (Microsoft Access workspaces only). Read-only String.

Syntax

expression .ValidationText

expression A variable that represents a Recordset object.


Prerequisites (ADO Introduction)

 Copy code hover
[image]

Prerequisites (ADO Introduction)
Send feedback

The ADO Programmer's Guide will prove useful to developers with a wide variety of backgrounds. At a minimum, readers should have an intermediate level of experience in developing applications with Microsoft Visual Basic, because most of the examples in the guide are written in this language. Other examples are written in Microsoft Visual C++; Java; Visual Basic, Scripting Edition (VBScript); and Microsoft JScript.

Because ADO is used for accessing data from a variety of sources, readers might also need some understanding of fundamental relational database management system concepts, online analytical processing (OLAP) concepts, and basic familiarity with the Internet and Internet protocols.

ADO is a part of the Microsoft Data Access (UDA) strategy. (For more information about UDA, see "The Role of ADO in Microsoft Data Access," later in this chapter.) As such, it interoperates with the OLE DB technology. OLE DB is based on the Microsoft Component Object Model (COM). Therefore, familiarity with COM can also be useful for understanding some of the more advanced concepts in ADO.


CommandButton.PressedForeThemeColorIndex Property (Access)

 Copy code hover
[image]

CommandButton.PressedForeThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedForeColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .PressedForeThemeColorIndex

expression A variable that represents a CommandButton object.

Remarks

The PressedForeThemeColorIndex uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 (Default) | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the PressedForeThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Could not use

 Copy code hover
[image]

Could not use <name>; file already in use. (Error 3045)
Send feedback

The specified file is currently being used by another user or session. Wait for the other user or session to finish working with the file, and then try the operation again.


Cannot have Memo or OLE Object fields in aggregate argument

 Copy code hover
[image]

Cannot have Memo or OLE Object fields in aggregate argument <statement>. (Error 3115)
Send feedback

You cannot include Memo or OLE Object fields in an aggregate function.


TabControl.OnMouseMove Property (Access)

 Copy code hover
[image]

TabControl.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Syntax

expression .OnMouseMove

expression A variable that represents a TabControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Databases Methods (DAO)

 Copy code hover
[image]

Databases Methods (DAO)
Send feedback

In this section

  • Databases.Refresh Method (DAO)


EmptyCell.Parent Property (Access)

 Copy code hover
[image]

EmptyCell.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Parent

expression A variable that represents an EmptyCell object.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


TabControl.MouseUp Event (Access)

 Copy code hover
[image]

TabControl.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents a TabControl object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was released to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


ADO Code Examples in Microsoft JScript

 Copy code hover
[image]

ADO Code Examples in Microsoft JScript
Send feedback

Use the following code examples to learn how to use the ADO methods, properties, and events when writing in JScript.

Note Note

Paste the entire code example, from beginning to end, into your code editor. The example may not run correctly if partial examples are used or if paragraph formatting is lost.

Methods

  • AddNew Method Example

  • Append and CreateParameter Methods Example

  • Execute, Requery, and Clear Methods Example

  • Find Method Example

  • GetRows Method Example

Properties

  • AbsolutePage, PageCount, and PageSize Properties Example

  • AbsolutePosition and CursorLocation Properties Example

  • ActiveCommand Property Example

  • ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction Properties Example

  • ActualSize and DefinedSize Properties Example

  • CacheSize Property Example

  • Filter and RecordCount Properties Example


Provider Support for ADOX

 Copy code hover
[image]

Provider Support for ADOX
Send feedback

Certain features of ADOX are unsupported, depending upon your OLE DB data provider. ADOX is fully supported with the OLE DB Provider for Microsoft Jet. The unsupported features with the Microsoft OLE DB Provider for SQL Server, the Microsoft OLE DB Provider for ODBC, or the Microsoft OLE DB Provider for Oracle are listed below. ADOX is not supported by any other Microsoft OLE DB providers.

Microsoft OLE DB Provider for SQL Server

Object or Collection | Usage Restriction
Catalog object | The Create method is not supported.
Tables collection | Properties are read/write prior to object creation, and read-only when referencing an existing object.
Views collection | Views is not supported.
Procedures collection | The Append and Delete methods are not supported.
Procedure object | The Command property is not supported.
Keys collection | The Append and Delete methods are not supported.
Users collection | Users is not supported.
Groups collection | Groups is not supported.

Microsoft OLE DB Provider for ODBC

Object or Collection | Usage Restriction
Catalog object | The Create method is not supported.
Tables collection | The Append and Delete methods are not supported. Properties are read/write prior to object creation, and read-only when referencing an existing object.
Procedures collection | The Append and Delete methods are not supported.
Procedure object | The Command property is not supported.
Indexes collection | The Append and Delete methods are not supported.
Keys collection | The Append and Delete methods are not supported.
Users collection | Users is not supported.
Groups collection | Groups is not supported.

Microsoft OLE DB Provider for Oracle

Object or Collection | Usage Restriction
Catalog object | The Create method is not supported.
Tables collection | The Append and Delete methods are not supported. Properties are read/write prior to object creation, and read-only when referencing an existing object.
Views collection | The Append and Delete methods are not supported.
View object | The Command property is not supported.
Procedures object | The Append and Delete methods are not supported.
Procedure object | The Command property is not supported.
Indexes collection | The Append and Delete methods are not supported.
Keys collection | The Append and Delete methods are not supported.
Users collection | Users is not supported.
Groups collection | Groups is not supported.


MoveFirst, MoveLast, MoveNext, and MovePrevious Methods (RDS)

 Copy code hover
[image]

MoveFirst, MoveLast, MoveNext, and MovePrevious Methods (RDS)
Send feedback

Moves to the first, last, next, or previous record in a specified Recordset object.

Syntax

DataControl.Recordset.{ MoveFirst | MoveLast | MoveNext | MovePrevious}

Parameters

  • DataControl

  • An object variable that represents an RDS.DataControl object.

Remarks

You can use the Move methods with the RDS.DataControl object to navigate through the data records in the data-bound controls on a Web page. For example, suppose you display a Recordset in a grid by binding to an RDS.DataControl object. You can then include First, Last, Next, and Previous buttons that users can click to move to the first, last, next, or previous record in the displayed Recordset. You do this by calling the MoveFirst, MoveLast, MoveNext, and MovePrevious methods of the RDS.DataControl object in the onClick procedures for the First, Last, Next, and Previous buttons, respectively. The Address Book example shows how to do this.


PageBreak Members (Access)

 Copy code hover
[image]

PageBreak Members (Access)
Send feedback

Published: July 16, 2012

This object corresponds to a page break control. The page break control marks the start of a new screen or printed page on a form or report.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
Visible | Returns or sets whether the object is visible. Read/write Boolean.


ToggleButton Properties (Access)

 Copy code hover
[image]

ToggleButton Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
Bevel | Gets or sets the bevel effect applied to the specified object. Read/write Long.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the toggle button and its bottom gridline. Read/write Integer.
Caption | Gets or sets the text that appears in the control. Read/write String.
ColumnHidden | You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.
ColumnOrder | You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.
ColumnWidth | You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DefaultValue | Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontName | You can use the FontName property to specify the font for text in the following situations:
FontSize | You can use the FontSize property to specify the point size for text in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
FontWeight | Use the FontWeight property to specify the line width that Windows uses to display and print characters in a control. Read/write Integer.
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
ForeShade | Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
ForeThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.
ForeTint | Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
Glow | Gets or sets the Glow effect applied to the specified object. Read/write Long.
Gradient | Gets or sets the gradient fill applied to the specified object. Read/write Long.
GridlineColor | Gets or sets the color of the gridline for the specified toggle button. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified toggle button. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified toggle button. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified toggle button. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified toggle button. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified toggle button. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified toggle button. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified toggle button. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified toggle button. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HideDuplicates | You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the toggle button is anchored horizontally within its layout. Read/write.
HoverColor | Gets or sets the color displayed on the control when the user rests the mouse cursor over it. Read/write Long.
HoverForeColor | Gets or sets the color of the text displayed on the control when the user rests the mouse cursor over it. Read/write Long.
HoverForeShade | Gets or sets the shade applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.
HoverForeThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverForeColor property of the specified object. Read/write Long.
HoverForeTint | Gets or sets the tint applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.
HoverShade | Gets or sets the shade that is applied to the theme color in the HoverColor property of the specified object. Read/write Single.
HoverThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverColor property of the specified object. Read/write Long.
HoverTint | Gets or sets the tint applied to the theme color in the HoverColor property of the specified object. Read/write Single.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified toggle button. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified toggle button. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the toggle button and its left gridline. Read/write Integer.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
ObjectPalette | The ObjectPalette property specifies the palette in the application used to create A bitmap or other graphic that is loaded into the specified control by using the Picture property. Read/write Variant.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OptionValue | Each control in an option group has a numeric value that you can set with the OptionValue property. Read/write Long.
Parent | Returns the parent object for the specified object. Read-only.
Picture | You can use the Picture property to specify a bitmap or other type of graphic to be displayed on the specified control. Read/write String.
PictureData | You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.
PictureType | You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.
PressedColor | Gets or sets the color displayed on the control when the user clicks it. Read/write Long.
PressedForeColor | Gets or sets the color of the text displayed on the control when the user clicks it. Read/write Long.
PressedForeShade | Gets or sets the shade applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.
PressedForeThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedForeColor property of the specified object. Read/write Long.
PressedForeTint | Gets or sets the tint applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.
PressedShade | Gets or sets the shade that is applied to the theme color in the PressedColor property of the specified object. Read/write Single.
PressedThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedColor property of the specified object. Read/write Long.
PressedTint | Gets or sets the tint applied to the theme color in the PressedColor property of the specified object. Read/write Single.
Properties | Returns a reference to a control's Properties collection object. Read-only.
QuickStyle | Gets or sets the Quick Style that is applied to the specified object. Read/write Long.
QuickStyleMask | Gets or sets modifications to the Quick Style that is applied to the specified object. Read/write Long.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
RightPadding | Gets or sets the amount of space (in inches) between the toggle button and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
Shadow | Gets or sets the Shadow effect applied to the specified object. Read/write Long.
Shape | Returns or sets the shape of the specified toggle button. Read/write Long.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SoftEdges | Gets or sets the Soft Edges effect applied to the specified object. Read/write Long.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
ThemeFontIndex | Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the toggle button and its top gridline. Read/write Integer.
TripleState | You can use the TripleState property to specify how the specified control will display Null values. Read/write Boolean.
UseTheme | Gets or sets whether the specified object will utilize formatting styles defined in Office Document Themes. Read/write Boolean.
ValidationRule | You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.
ValidationText | Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.
Value | Determines or specifies whether or not the specified toggle button control is selected. Read/write Variant.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified toggle button is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


Form.DatasheetFontItalic Property (Access)

 Copy code hover
[image]

Form.DatasheetFontItalic Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DatasheetFontItalic property to specify an italicized appearance for field names and data in Datasheet view. Read/write Boolean.

Syntax

expression .DatasheetFontItalic

expression A variable that represents a Form object.

Remarks

The DatasheetFontItalic property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

This property is only available in Visual Basic within a Microsoft Access database.

The following table contains the properties that don't exist in the DAO Properties collection of until you set them by using the Formatting (Datasheet) toolbar or you can add them in an Access database by using the CreateProperty method and append it to the DAO Properties collection.

DatasheetFontItalic * | DatasheetForeColor *
DatasheetFontHeight * | DatasheetBackColor
DatasheetFontName * | DatasheetGridlinesColor
DatasheetFontUnderline * | DatasheetGridlinesBehavior
DatasheetFontWeight * | DatasheetCellsEffect
Note Note

When you add or set any property listed with an asterisk, Microsoft Access automatically adds all the properties listed with an asterisk to the Properties collection of the database.

Example

The following example displays the data and field names in Datasheet view of the Products form as italic and underlined.

VBA Copy code Copy code
Forms![Products].DatasheetFontItalic = True
Forms![Products].DatasheetFontUnderline = True

The next example displays the data and field names in Datasheet view of the Products table as italic and underlined.

To set the DatasheetFontItalic and DatasheetFontUnderline properties, the example uses the SetTableProperty procedure, which is in the database's standard module.

VBA Copy code Copy code
Dim dbs As Object, objProducts As Object
Const DB_Boolean As Long = 1
Set dbs = CurrentDb
Set objProducts = dbs![Products]
SetTableProperty objProducts, "DatasheetFontItalic", DB_Boolean, True
SetTableProperty objProducts, "DatasheetFontUnderline", DB_Boolean, True

Sub SetTableProperty(objTableObj As Object, strPropertyName As String, _
 intPropertyType As Integer, varPropertyValue As Variant)
 ' Set Microsoft Access-defined table property without causing
 ' nonrecoverable run-time error.
 Const conErrPropertyNotFound = 3270
 Dim prpProperty As Variant
 On Error Resume Next ' Don't trap errors.
 objTableObj.Properties(strPropertyName) = varPropertyValue
 If Err <> 0 Then ' Error occurred when value set.
 If Err <> conErrPropertyNotFound Then
 On Error GoTo 0
 MsgBox "Couldn't set property '" & strPropertyName _
 & "' on table '" & objTableObj.Name & "'", 48, "SetTableProperty"
 Else
 On Error GoTo 0
 Set prpProperty = objTableObj.CreateProperty(strPropertyName, _
 intPropertyType, varPropertyValue)
 objTableObj.Properties.Append prpProperty
 End If
 End If
 objTableObj.Properties.Refresh
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


..And Operator

 Copy code hover
[image]

..And Operator
Send feedback

Published: July 16, 2012

Determines whether the value of an expression falls within a specified range of values. You can use this operator within SQL statements.

Syntax

expr [Not] Between value1 And value2

The Between…And operator syntax has these parts:

Part | Description
expr | Expression identifying the field that contains the data you want to evaluate.
value1, value2 | Expressions against which you want to evaluate expr.

Remarks

If the value of expr is between value1 and value2 (inclusive), the Between…And operator returns True; otherwise, it returns False. You can include the Not logical operator to evaluate the opposite condition (that is, whether expr lies outside the range defined by value1 and value2).

You might use Between…And to determine whether the value of a field falls within a specified numeric range. The following example determines whether an order was shipped to a location within a range of postal codes. If the postal code is between 98101 and 98199, the IIf function returns "Local". Otherwise, it returns "Nonlocal".

SQL Copy code Copy code
SELECT IIf(PostalCode Between 98101 And 98199, "Local", "Nonlocal")
FROM Publishers;

If expr, value1, or value2 is Null, Between…And returns a Null value.

Because wildcard characters, such as *, are treated as literals, you cannot use them with the Between…And operator. For example, you cannot use 980* and 989* to find all postal codes that start with 980 to 989. Instead, you have two alternatives for accomplishing this. You can add an expression to the query that takes the left three characters of the text field and use Between…And on those characters. Or you can pad the high and low values with extra characters — in this case, 98000 to 98999, or 98000 to 98999 - 9999 if using extended postal codes. (You must omit the - 0000 from the low values because otherwise 98000 is dropped if some postal codes have extended sections and others do not.)

Example

This example lists the name and contact of every customer who placed an order in the second quarter of 1995.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

Copy code Copy code
Sub SubQueryX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' List the name and contact of every customer
    ' who placed an order in the second quarter of
    ' 1995.

    Set rst = dbs.OpenRecordset("SELECT ContactName," _
        & " CompanyName, ContactTitle, Phone" _
        & " FROM Customers" _
        & " WHERE CustomerID" _
        & " IN (SELECT CustomerID FROM Orders" _
        & " WHERE OrderDate Between #04/1/95#" _
        & " And #07/1/95#);")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 25

    dbs.Close

End Sub


Image.GridlineWidthTop Property (Access)

 Copy code hover
[image]

Image.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified image control. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthTop

expression A variable that represents an Image object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Image Object

Other resources

Image Object Members


Invalid SQL Syntax: only one update rule and/or one delete rule allowed (Error 3727)

 Copy code hover
[image]

Invalid SQL Syntax: only one update rule and/or one delete rule allowed (Error 3727)
Send feedback

This error occurs when defining referential integrity through SQL DDL. This occurs when NULL or DEFAULT is not used after the SET keyword.


Prepared Property (ADO)

 Copy code hover
[image]

Prepared Property (ADO)
Send feedback

Indicates whether to save a compiled version of a command before execution.

Settings and Return Values

Sets or returns a Boolean value that, if set to True, indicates that the command should be prepared.

Remarks

Use the Prepared property to have the provider save a prepared (or compiled) version of the query specified in the CommandText property before a Command object's first execution. This may slow a command's first execution, but once the provider compiles a command, the provider will use the compiled version of the command for any subsequent executions, which will result in improved performance.

If the property is False, the provider will execute the Command object directly without creating a compiled version.

If the provider does not support command preparation, it may return an error as soon as this property is set to True. If it does not return an error, it simply ignores the request to prepare the command and sets the Prepared property to False.


TextBox.GridlineShade Property (Access)

 Copy code hover
[image]

TextBox.GridlineShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineShade

expression A variable that represents an TextBox object.

Remarks

The GridlineShade property contains a numeric expression that can be used to darken the theme color in the GridlineColor property. The default value of the GridlineShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


OptionButton.SpecialEffect Property (Access)

 Copy code hover
[image]

OptionButton.SpecialEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.

Syntax

expression .SpecialEffect

expression A variable that represents an OptionButton object.

Remarks

The SpecialEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | 0 | The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised | 1 | The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken | 2 | The object has a shadow on the top and left and a highlight on the bottom and right.
Etched | 3 | The object has a sunken line surrounding the control.
Shadowed | 4 | The object has a shadow below and to the right of the control.
Chiseled | 5 | The object has a sunken line below the control.

The SpecialEffect property setting affects related property settings for the BorderStyle , BorderColor , and BorderWidth properties. For example, if the SpecialEffect property is set to Raised, the settings for the BorderStyle, BorderColor, and BorderWidth properties are ignored. In addition, changing or setting the BorderStyle, BorderColor, and BorderWidth properties may cause Microsoft Access to change the SpecialEffect property setting to Flat.

Example

The following example sets the appearance of the text box "OrganizationName1" on the "Mailing List" form to raised.

VBA Copy code Copy code
Forms("Mailing List").Controls("OrganizationName1").SpecialEffect = 1

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


SortDirection Property (RDS)

 Copy code hover
[image]

SortDirection Property (RDS)
Send feedback

Indicates whether a sort order is ascending or descending.

Syntax

DataControl.SortDirection = value

Parameters

  • DataControl

  • An object variable that represents an RDS.DataControl object.

  • Value

  • A Boolean value that, when set to True, indicates the sort direction is ascending. False indicates descending order.

Remarks

The SortColumn, SortDirection, FilterValue, FilterCriterion, and FilterColumn properties provide sorting and filtering functionality on the client-side cache. The sorting functionality orders records by values from one column. The filtering functionality displays a subset of records based on find criteria, while the full Recordset is maintained in the cache. The Reset method will execute the criteria and replace the current Recordset with an updatable Recordset.


AllModules Members (Access)

 Copy code hover
[image]

AllModules Members (Access)
Send feedback

Published: July 16, 2012

The AllModules collection contains an AccessObject of each module in the CurrentProject or CodeProject object.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


WebBrowserControl.Dirty Event (Access)

 Copy code hover
[image]

WebBrowserControl.Dirty Event (Access)
See also Send feedback

Published: July 16, 2012

The Dirty event occurs when the contents of the specified control changes.

Version Information

Version Added: Access 2010

Syntax

expression .Dirty(Cancel, )

expression A variable that represents a WebBrowserControl object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer |

Return Value

nothing

Remarks

Examples of this event include entering a character directly in the text box or combo box or changing the control's Text property setting by using a macro or Visual Basic.

  • Modifying a record within a form by using a macro or Visual Basic doesn't trigger this event. You must type the data directly into the record or set the control's Text property.

  • This event applies only to bound forms, not an unbound form or report.

To run a macro or event procedure when this event occurs, set the OnDirty property to the name of the macro or to [Event Procedure].

By running a macro or event procedure when a Dirty event occurs, you can determine if the record can be changed. You can also display a message and ask for edit permission.

Changing the data in a record by using the keyboard causes keyboard events to occur in addition to control events like the Dirty event. For example, if you move to a new record and type an ANSI character in a text box in the record, the following events occur in this order:

KeyDown > KeyPress > BeforeInsert > Dirty > KeyUp

The BeforeUpdate and AfterUpdate events for a record occur after you have entered the new or changed data in the record and moved to another record (or clicked Save Record on the Records menu), and therefore after the Dirty event for the record.

Canceling the Dirty event will cause the changes to the current record to be rolled back. It is equivalent to pressing the ESC key.

Example

The following example enables the btnUndo button when data is changed. The UndoEdits( ) subroutine is called from the Dirty event of text box controls. Clicking the enabled btnUndo button restores the original value of the control by using the OldValue property.

VBA Copy code Copy code
Private Sub Form_Dirty()
 If Me.Dirty Then
 Me!btnUndo.Enabled = True ' Enable button.
 Else
 Me!btnUndo.Enabled = False ' Disable button.
 End If
End Sub

Sub btnUndo_Click()
 Dim ctlC As Control
 ' For each control.
 For Each ctlC in Me.Controls
 If ctlC.ControlType = acTextBox Then
 ' Restore Old Value.
 ctlC.Value = ctlC.OldValue
 End If
 Next ctlC
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Image.HorizontalAnchor Property (Access)

 Copy code hover
[image]

Image.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the image is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .HorizontalAnchor

expression A variable that represents an Image object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

Image Object

Other resources

Image Object Members


LoadFromFile Method (ADO)

 Copy code hover
[image]

LoadFromFile Method (ADO)
Send feedback

Loads the contents of an existing file into a Stream.

Syntax

Stream.LoadFromFile FileName

Parameter

  • FileName

  • A String value that contains the name of a file to be loaded into the Stream. FileName can contain any valid path and name in UNC format. If the specified file does not exist, a run-time error occurs.

Remarks

This method may be used to load the contents of a local file into a Stream object. This may be used to upload the contents of a local file to a server.

The Stream object must be already open before calling LoadFromFile. This method does not change the binding of the Stream object; it will still be bound to the object specified by the URL or Record with which the Stream was originally opened.

LoadFromFile overwrites the current contents of the Stream object with data read from the file. Any existing bytes in the Stream are overwritten by the contents of the file. Any previously existing and remaining bytes following the EOS created by LoadFromFile, are truncated.

After a call to LoadFromFile, the current position is set to the beginning of the Stream (Position is 0).

Because 2 bytes may be added to the beginning of the stream for encoding, the size of the stream may not exactly match the size of the file from which it was loaded.


AccessObject.GetDependencyInfo Method (Access)

 Copy code hover
[image]

AccessObject.GetDependencyInfo Method (Access)
See also Send feedback

Published: July 16, 2012

Returns a DependencyInfo object that represents the database objects that are dependent upon the specified object.

Syntax

expression .GetDependencyInfo

expression A variable that represents an AccessObject object.

Return Value

DependencyInfo

Remarks

This method will return a run-time error if any of the following conditions are true:

  • The Track name AutoCorrect info setting (Tools menu, Options dialog box, General tab) is disabled. You can use the following code to enable the Track name AutoCorrect info setting and update the dependency information for all of the objects in the database:

    Application.SetOption "Track Name AutoCorrect Info", 1

  • You have insufficient permissions to check the dependency information for the specified AccessObject object.

  • This method is being called from an Access project (.adp).

Access does not search Visual Basic for Applications (VBA) code, macros, or data access pages for dependencies.

See also

Concepts

AccessObject Object

Other resources

AccessObject Object Members


Application.Assistance Property (Access)

 Copy code hover
[image]

Application.Assistance Property (Access)
See also Send feedback

Published: July 16, 2012

Returns an IAssistance object that represents the Microsoft Office Help Viewer. Read-only.

Version Information

Version Added: Access 2007

Syntax

expression .Assistance

expression A variable that represents an Application object.

Remarks

The IAssistance object allows developers to show custom help and help that is installed with Office in the Office Help Viewer.

See also

Concepts

Application Object

Other resources

Application Object Members


NavigationButton.PressedColor Property (Access)

 Copy code hover
[image]

NavigationButton.PressedColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color displayed on the control when the user clicks it. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .PressedColor

expression A variable that represents a NavigationButton object.

Remarks

The PressedColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


The fixed-width specification

 Copy code hover
[image]

The fixed-width specification <name> contains no column widths. (Error 3443)
Send feedback

The fixed-width parameter specified in the text file specification for the Text ISAM is invalid does not specify a column width. The specification can be set in a number of ways:

  • From Microsoft Access, these values are set in the Link Text Wizard.


Encountered unexpected end of file. (Error 3179)

 Copy code hover
[image]

Encountered unexpected end of file. (Error 3179)
Send feedback

You tried to import a file that contains an end-of-file marker in an unexpected position.

Possible causes:

  • The import file is corrupted. Restore a backup copy of the import file, and then try the operation again.

  • The import/export specifications you are using do not match the data in the import file. Edit the import/export specifications, and then try the operation again.


TabControl.OnMouseDown Property (Access)

 Copy code hover
[image]

TabControl.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Syntax

expression .OnMouseDown

expression A variable that represents a TabControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Recordset2.Edit Method (DAO)

 Copy code hover
[image]

Recordset2.Edit Method (DAO)
Send feedback

Copies the current record from an updatable Recordset object to the copy buffer for subsequent editing.

Syntax

expression .Edit

expression A variable that represents a Recordset2 object.

Remarks

Once you use the Edit method, changes made to the current record's fields are copied to the copy buffer. After you make the desired changes to the record, use the Update method to save your changes.

The current record remains current after you use Edit.

Note Note

If you edit a record and then perform any operation that moves to another record, but without first using Update, your changes are lost without warning. In addition, if you close recordset or end the procedure which declares the Recordset or the parent Database or Connection object, your edited record is discarded without warning.

Using Edit produces an error if:

  • There is no current record.

  • The Connection, Database, or Recordset object was opened as read-only.

  • No fields in the record are updatable.

  • The Database or Recordset was opened for exclusive use by another user (Microsoft Access workspace).

  • Another user has locked the page containing your record (Microsoft Access workspace).

In a Microsoft Access workspace, when the Recordset object's LockEdits property setting is True (pessimistically locked) in a multiuser environment, the record remains locked from the time Edit is used until the update is complete. If the LockEdits property setting is False (optimistically locked), the record is locked and compared with the pre-edited record just before it's updated in the database. If the record has changed since you used the Edit method, the Update operation fails with a run-time error if you use OpenRecordset without specifying dbSeeChanges. By default, Microsoft Access database engine-connected ODBC and installable ISAM databases always use optimistic locking.

Note Note

To add, edit, or delete a record, there must be a unique index on the record in the underlying data source. If not, a "Permission denied" error will occur on the AddNew, Delete, or Edit method call in a Microsoft Access workspace.

Example

This example uses the Edit method to replace the current data with the specified name. The EditName procedure is required for this procedure to run.

VBA Copy code Copy code
Sub EditX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset2
 Dim strOldFirst As String
 Dim strOldLast As String
 Dim strFirstName As String
 Dim strLastName As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", _
 dbOpenDynaset)

 ' Store original data.
 strOldFirst = rstEmployees!FirstName
 strOldLast = rstEmployees!LastName

 ' Get new data for record.
 strFirstName = Trim(InputBox( _
 "Enter first name:"))
 strLastName = Trim(InputBox( _
 "Enter last name:"))

 ' Proceed if the user entered something for both fields.
 If strFirstName <> "" and strLastName <> "" Then
 ' Update record with new data.
 EditName rstEmployees, strFirstName, strLastName

 With rstEmployees
 ' Show old and new data.
 Debug.Print "Old data: " & strOldFirst & _
 " " & strOldLast
 Debug.Print "New data: " & !FirstName & _
 " " & !LastName
 ' Restore original data because this is a
 ' demonstration.
 .Edit
 !FirstName = strOldFirst
 !LastName = strOldLast
 .Update
 End With

 Else
 Debug.Print _
 "You must input a string for first and last name!"
 End If

 rstEmployees.Close
 dbsNorthwind.Close

End Sub

Sub EditName(rstTemp As Recordset2, _
 strFirst As String, strLast As String)

 ' Make changes to record and set the bookmark to keep
 ' the same record current.
 With rstTemp
 .Edit
 !FirstName = strFirst
 !LastName = strLast
 .Update
 .Bookmark = .LastModified
 End With

End Sub


Cannot group on fields selected with '*'

 Copy code hover
[image]

Cannot group on fields selected with '*' <table name>. (Error 3120)
Send feedback

You tried to execute a SELECT statement that groups or totals all fields in a single table, selected with an asterisk ( * ). This error occurs, for example, if you enter the following SQL statement:

SQL Copy code Copy code
SELECT Orders.* FROM Orders GROUP BY ShipVia;


Dimensions Collection (ADO MD Reference)

 Copy code hover
[image]

Dimensions Collection (ADO MD Reference)
Send feedback

In this section

  • Dimensions Collection (ADO MD)

  • Dimensions Collection Properties, Methods, and Events (ADO MD)


Using the Microsoft SDK for Java

 Copy code hover
[image]

Using the Microsoft SDK for Java
Send feedback

The Microsoft SDK for Java is the developer kit for the Microsoft Internet Explorer environment. Tools, information, and samples are provided to help you develop Java programs and applets based on JDK 1.1 and the Microsoft Win32 virtual machine (Microsoft VM). The Microsoft SDK for Java is not tied to Microsoft Visual J++.

The Jactivex.exe utility generates classes from a type library but can only be invoked on the command line. This feature is not integrated with the Visual J++ development environment. Unlike the classes generated by the Java Type Library Wizard, you can step into the class wrappers created by the SDK. This is useful for debugging how your code uses the ADO wrapper classes.

This mechanism reads the ADO type library and generates classes that you can instantiate within your application. It generates those classes in the following location: \<windows directory>\Java\trustlib\msado15.

Creating an ADO application in Java using the Microsoft SDK for Java is fundamentally identical, from the perspective of source code, to using the Java Type Library Wizard. For sample code, see ADO Java Class Wrappers. The only real difference is in how you generate the wrapper classes in the first place, as demonstrated in the steps below.

To create an ADO project with the Microsoft SDK for Java

  1. Run the following from a command prompt. You need to set the path to include the Microsoft SDK for Java Bin directory, or run the command from that location. Typically, the Microsoft SDK for Java is installed in the same location as Visual Studio. This is a single command statement.

    Copy code Copy code

\<path to DevStudio>\<path to Java SDK>\bin\JactiveX.exe /javatlb "C:\program files\common files\system\ado\msado15.dll"

  2. Run the following command to compile the generated classes. The /g:t switch turns on generation of debug symbols so that you can trace into the .Java symbols. Remove it for release builds.

    Copy code Copy code

jvc /g:t c:\<windows>\Java\trustlib\msado15\*.Java

  3. To use these files, open your project in Visual J++. From the Project menu, choose Add To Project. Select Files, and add all of the .JAVA files generated in the trustlib\msado15 directory to your project.


EmptyCell.Height Property (Access)

 Copy code hover
[image]

EmptyCell.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .Height

expression A variable that represents an EmptyCell object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


TabControl.VerticalAnchor Property (Access)

 Copy code hover
[image]

TabControl.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified tab control is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .VerticalAnchor

expression A variable that represents a TabControl object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


BoundObjectFrame.LayoutID Property (Access)

 Copy code hover
[image]

BoundObjectFrame.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified object frame. Read-only Long.

Version Information

Version Added: Access 2007

Syntax

expression .LayoutID

expression A variable that represents a BoundObjectFrame object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Unable to load Jet SQL Server Reconciler - MSRPJT40.dll. (Error 3775)

 Copy code hover
[image]

Unable to load Jet SQL Server Reconciler - MSRPJT40.dll. (Error 3775)
Send feedback

You are trying to execute an operation between a Microsoft Jet Subscriber and an SQL Publication. The file msrpjt40.dll cannot be found on the specified path or is not registered.


NavigationControl.KeyUp Event (Access)

 Copy code hover
[image]

NavigationControl.KeyUp Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Version Information

Version Added: Access 2010

Syntax

expression .KeyUp(KeyCode, Shift)

expression A variable that represents a NavigationControl object.

Parameters

Name | Required/Optional | Data Type | Description
KeyCode | Required | Integer |
Shift | Required | Integer |

Return Value

nothing

Remarks

To run a macro or event procedure when these events occur, set the OnKeyUp property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyUp event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyUp event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


The text file specification

 Copy code hover
[image]

The text file specification <name> does not exist. You cannot import, export, or link using the specification. (Error 3625)
Send feedback

Microsoft Access tried to import/export/link to a text file using a specification table name that does not exist in the MSysIMEXSpecs table of the database. Re-create the link using a valid specification table.


DataFactory Customization (ADO)

 Copy code hover
[image]

DataFactory Customization (ADO)
Send feedback

In this section

  • DataFactory Customization

  • Understanding the Customization File

  • Customization File Connect Section

  • Customization File SQL Section

  • Customization File UserList Section

  • Customization File Logs Section


ActiveCommand Property Example (VC++)

 Copy code hover
[image]

ActiveCommand Property Example (VC++)
Send feedback

This example demonstrates the ActiveCommand property.

A subroutine is given a Recordset object whose ActiveCommand property is used to display the command text and parameter that created the Recordset.

Copy code Copy code

// BeginActiveCommandCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>
#include "ActiveCommandX.h"

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void ActiveCommandX(void);
void ActiveCommandXprint(_RecordsetPtr pRst);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);
inline char* mygets(char* strDest, int n)
{
 char strExBuff[10];
 char* pstrRet = fgets(strDest, n, stdin);

 if (pstrRet == NULL)
 return NULL;

 if (!strrchr(strDest, '\n'))
 // Exhaust the input buffer.
 do
 {
 fgets(strExBuff, sizeof(strExBuff), stdin);
 }while (!strrchr(strExBuff, '\n'));
 else
 // Replace '\n' with '\0'
 strDest[strrchr(strDest, '\n') - strDest] = '\0';

 return pstrRet;
}

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 ActiveCommandX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// ActiveCommandX Function //
// //
//////////////////////////////////////////////////////////

void ActiveCommandX(void)
{

 HRESULT hr = S_OK;

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _ConnectionPtr pConnection = NULL;
 _CommandPtr pCmd = NULL;
 _RecordsetPtr pRstAuthors = NULL;

 //Definitions of other variables
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");
 _bstr_t strPrompt;
 _bstr_t strName;
 CHAR strcharName[50];

 try
 {
 // Open connection.
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));

 TESTHR(pRstAuthors.CreateInstance(__uuidof(Recordset)));

 TESTHR(pCmd.CreateInstance(__uuidof(Command)));

 printf ("ActiveCommandX Example\n\n");
 strPrompt = "Enter an author's name (e.g., Ringer): ";
 printf(strPrompt);
 mygets(strcharName, 50);
 char *tempStr = strtok(strcharName, " \t");
 strName = tempStr;

 pCmd->CommandText = "SELECT * FROM authors WHERE au_lname = ?";
 pCmd->Parameters->Append(pCmd->CreateParameter("LastName", adChar, adParamInput, 20, strName));

 pConnection->Open (strCnn, "", "", adConnectUnspecified);

 pCmd->PutActiveConnection(_variant_t((IDispatch*)pConnection));

 pRstAuthors = pCmd->Execute(NULL,NULL,adCmdText);

 ActiveCommandXprint(pRstAuthors);

 } // End Try statement.
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 PrintProviderError(pConnection);
 PrintComError(e);
 }

 // Clean up objects before exit.
 if (pRstAuthors)
 if (pRstAuthors->State == adStateOpen)
 pRstAuthors->Close();
 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

//////////////////////////////////////////////////////////
// //
// ActiveCommandXprint Function //
// //
//////////////////////////////////////////////////////////

void ActiveCommandXprint(_RecordsetPtr pRst = NULL)
{
 // Varible Declaraion & initialization
 IADORecordBinding *picRs = NULL; //Interface Pointer declared.
 CAuthorsRs autrs; //C++ class object
 _bstr_t strName;

 //Open an IADORecordBinding interface pointer which
 //we'll use for Binding Recordset to a class
 TESTHR(pRst->QueryInterface(__uuidof(IADORecordBinding),(LPVOID*)&picRs));

 //Bind the Recordset to a C++ Class here
 TESTHR(picRs->BindToRecordset(&autrs));

 strName = ((_CommandPtr)pRst->GetActiveCommand())->GetParameters()->GetItem("LastName")->Value;
 printf("Command text = '%s'\n", (LPCSTR)((_CommandPtr)pRst->GetActiveCommand())->CommandText);
 printf("Parameter = '%s'\n", (LPCSTR)strName);

 if (pRst->BOF)
 printf("Name = '%s'not found.", (LPCSTR)strName);
 else
 {
 printf ("Name = '%s %s' author ID = '%s'",
 autrs.lau_fnameStatus == adFldOK ? autrs.m_au_fname : "<NULL>",
 autrs.lau_lnameStatus == adFldOK ? autrs.m_au_lname : "<NULL>",
 autrs.lau_idStatus == adFldOK ? autrs.m_au_id : "<NULL>");
 }

 //Release IADORecordset Interface
 if (picRs)
 picRs->Release();

}

//////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
//////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;
 long nCount = 0;
 long i = 0;

 if( (pConnection->Errors->Count) > 0)
 {
 nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s\n", pErr->Number, (LPCSTR)pErr->Description);
 }
 }
}

//////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
//////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);

}
// EndActiveCommandCpp

ActiveCommandX.h
// BeginActiveCommandH
#include "icrsint.h"

// This Class extracts id, fname, lname from authors table.

class CAuthorsRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CAuthorsRs)

 // Column au_id is the 1st field in the recordset
 ADO_VARIABLE_LENGTH_ENTRY2(1, adVarChar, m_au_id,
 sizeof(m_au_id), lau_idStatus, TRUE)

 // Column au_fname is the 2nd field in the recordset
 ADO_VARIABLE_LENGTH_ENTRY2(2, adVarChar, m_au_fname,
 sizeof(m_au_fname), lau_fnameStatus, TRUE)

 // Column au_lname is the 3rd field in the recordset
 ADO_VARIABLE_LENGTH_ENTRY2(3, adVarChar, m_au_lname,
 sizeof(m_au_lname), lau_lnameStatus, TRUE)

END_ADO_BINDING()

public:

 char m_au_id[21];
 ULONG lau_idStatus;
 char m_au_fname[41];
 ULONG lau_fnameStatus;
 char m_au_lname[41];
 ULONG lau_lnameStatus;

};
// EndActiveCommandH


Report.FormatCount Property (Access)

 Copy code hover
[image]

Report.FormatCount Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FormatCount property to determine the number of times the OnFormat property has been evaluated for the current section on a report. Read/write Integer.

Syntax

expression .FormatCount

expression A variable that represents a Report object.

Remarks

You can use this property only in an event procedure specified by a section's OnFormat property setting.

This property isn't available in report Design view.

Microsoft Access increments the FormatCount property each time the OnFormat property setting is evaluated for the current section. As the next section is formatted, Microsoft Access resets the FormatCount property to 1.

Under some circumstances, Microsoft Access formats a section more than once. For example, you might design a report in which the KeepTogether property for the detail section is set to Yes. When Microsoft Access reaches the bottom of a page, it formats the current detail section once to see if it will fit. If it doesn't fit, Microsoft Access moves to the next page and formats the detail section again. In this case, the setting for the FormatCount property for the detail section is 2 because it was formatted twice before it was printed.

You can use the FormatCount property to ensure that an operation that affects formatting gets executed only once for a section.

Example

In the following example, the DLookup function is evaluated only when the FormatCount property is set to 1:

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Const conBold = 700
 Const conNormal = 400
 If FormatCount = 1 Then
 If DLookup("CompanyName", _
 "Customers", "CustomerID = Reports!" _
 & "[Customer Labels]!CustomerID") _
 Like "B*" Then
 CompanyNameLine.FontWeight = conBold
 Else
 CompanyNameLine.FontWeight = conNormal
 End If
 End If
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


ListBox.ShowOnlyRowSourceValues Property (Access)

 Copy code hover
[image]

ListBox.ShowOnlyRowSourceValues Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the list box can display values that aren't specified by the RowSource property. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .ShowOnlyRowSourceValues

expression A variable that represents a ListBox object.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


AllStoredProcedures Members (Access)

 Copy code hover
[image]

AllStoredProcedures Members (Access)
Send feedback

Published: July 16, 2012

The AllStoredProcedures collection contains an AccessObject for each stored procedure in the CurrentData or CodeData object.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


Form.BeforeDelConfirm Event (Access)

 Copy code hover
[image]

Form.BeforeDelConfirm Event (Access)
See also Send feedback

Published: July 16, 2012

The BeforeDelConfirm event occurs after the user deletes to the buffer one or more records, but before Microsoft Access displays a dialog box asking the user to confirm the deletions.

Syntax

expression .BeforeDelConfirm(Cancel, Response)

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the BeforeDelConfirm event occurs. Setting the Cancel argument to True cancels the BeforeDelConfirm event and prevents the Delete Confirm dialog box from being displayed. If the event is canceled, the original records are restored, but the AfterDelConfirm event still occurs. If Cancel is set to True, the Response argument is ignored. If Cancel is set to False (0), which it is by default, the value in the Response argument is used by Microsoft Access to determine the type of response to the delete event.
Response | Required | Integer | An intrinsic constant that determines whether Microsoft Access displays the Delete Confirm dialog box asking if the record should be deleted. acDataErrContinue continues without displaying the Delete Confirm dialog box. Setting the Cancel argument to False and the Response argument to acDataErrContinue enables Microsoft Access to delete records without prompting the user. acDataErrDisplay displays the Delete Confirm dialog box. The default value is acDataErrDisplay.

Remarks

To run a macro or event procedure when these events occur, set the BeforeDelConfirm property to the name of the macro or to [Event Procedure].

After a record is deleted, it's stored in a temporary buffer. In a Microsoft Access database , the BeforeDelConfirm event occurs after the Delete event (or if you've deleted more than one record, after all the records are deleted, with a Delete event occurring for each record), but before the Delete Confirm dialog box is displayed. Canceling the BeforeDelConfirm event restores the record or records from the buffer and prevents the Delete Confirm dialog box from being displayed.

In a Microsoft Access database, the AfterDelConfirm event occurs after a record or records are actually deleted or after a deletion or deletions are canceled. If the BeforeDelConfirm event isn't canceled, the AfterDelConfirm event occurs after the Delete Confirm dialog box is displayed. The AfterDelConfirm event occurs even if the BeforeDelConfirm event is canceled.

If you cancel the Delete event, the BeforeDelConfirm event does not occur and the Delete Confirm dialog box isn't displayed.

In a Microsoft Access project (.adp), the BeforeDelConfirm event occurs before the Delete event. In order to avoid opening unnecessary transactions on Microsoft SQL Server, Access prompts you to confirm the deletion before opening the transaction. If you confirm the deletion, Access opens a transaction on Microsoft SQL Server, issues the DELETE statement to delete the record or records, and fires the form's Delete event. If you click No when prompted to confirm the deletion, Microsoft Access does not open a transaction on Microsoft SQL Server to delete the record and does not fire the form's Delete event.

Note Note

The BeforeDelConfirm event does not occur and the Delete Confirm dialog box isn't displayed if you clear the Record Changes check box under Confirm on the Editing tab of the Access Options dialog box.

By running a macro or an event procedure when the Delete event occurs, you can prevent a record from being deleted or allow a record to be deleted only under certain conditions. You can also use a Delete event to display a dialog box asking whether the user wants to delete a record before it's deleted.

After you delete the record, the focus moves to the next record following the deleted record, and the Current event for that record occurs, followed by the Enter and GotFocus events for the first control in that record.

The BeforeDelConfirm event then occurs, just before Microsoft Access displays the Delete Confirm dialog box asking you to confirm the deletion. After you respond to the dialog box by confirming or canceling the deletion, the AfterDelConfirm event occurs.

You can delete one or more records at a time. The Delete event occurs after each record is deleted. This enables you to access the data in each record before it's actually deleted, and selectively confirm or cancel each deletion in the Delete macro or event procedure. When you delete more than one record, the Current event for the record following the last deleted record and the Enter and GotFocus events for the first control in this record don't occur until all the records are deleted. In other words, a Delete event occurs for each selected record, but no other events occur until all the selected records are deleted. The BeforeDelConfirm event does not occur until all the selected records are deleted.

Example

The following example shows how you can use the BeforeDelConfirm event procedure to suppress the Delete Confirm dialog box and display a custom dialog box when a record is deleted. It also shows how you can use the AfterDelConfirm event procedure to display a message indicating whether the deletion progressed in the usual way or whether it was canceled in Visual Basic or by the user.

VBA Copy code Copy code
Private Sub Form_BeforeDelConfirm(Cancel As Integer, _
 Response As Integer)
 ' Suppress default Delete Confirm dialog box.
 Response = acDataErrContinue
 ' Display custom dialog box.
 If MsgBox("Delete this record?", vbOKCancel) = vbCancel Then
 Cancel = True
 End If
End Sub

Private Sub Form_AfterDelConfirm(Status As Integer)
 Select Case Status
 Case acDeleteOK
 MsgBox "Deletion occurred normally."
 Case acDeleteCancel
 MsgBox "Programmer canceled the deletion."
 Case acDeleteUserCancel
 MsgBox "User canceled the deletion."
 End Select
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


AcSendObjectType Enumeration (Access)

 Copy code hover
[image]

AcSendObjectType Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the SendObject method to specify the type of object to send.

Name | Value | Description
acSendForm | 2 | Send a Form.
acSendModule | 5 | Send a Module.
acSendNoObject | -1 | (Default) Don't send a database object.
acSendQuery | 1 | Send a Query.
acSendReport | 3 | Send a Report.
acSendTable | 0 | Send a Table.


ComboBox.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

ComboBox.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified combo box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleBottom

expression A variable that represents a ComboBox object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Section.BackShade Property (Access)

 Copy code hover
[image]

Section.BackShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackShade

expression A variable that represents a Section object.

Remarks

The BackShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the BackShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BackColor property of the section by 75%.

VBA Copy code Copy code
Me.FormHeader.BackShade=25

See also

Concepts

Section Object

Other resources

Section Object Members


TextBox.BackShade Property (Access)

 Copy code hover
[image]

TextBox.BackShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackShade

expression A variable that represents a TextBox object.

Remarks

The BackShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the BackShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens BackColor by 75%.

VBA Copy code Copy code
Me.ctl.BackShade=25

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ToggleButton.RightPadding Property (Access)

 Copy code hover
[image]

ToggleButton.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the toggle button and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .RightPadding

expression A variable that represents a ToggleButton object.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Undefined function

 Copy code hover
[image]

Undefined function <name> in expression. (Error 3085)
Send feedback

You entered an SQL expression that includes a Function procedure name that cannot be recognized. Make sure the function exists, that it can be used in SQL expressions, or check the expression to make sure you entered the name correctly.


DependencyInfo Properties (Access)

 Copy code hover
[image]

DependencyInfo Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Dependants | Returns a DependencyObjects collection that represents the objects that depend upon the specified AccessObject object. Read-only.
Dependencies | Returns a DependencyObjects collection that represents the objects that the specified AccessObject object depends upon. Read-only.
InsufficientPermissions | Returns a DependencyObjects collection that contains a collection of objects to which you don't have sufficient permissions to check for dependencies. Read-only.
OutOfDateObjects | Returns a DependencyObjects collection that represents the AccessObject objects for which the dependency information is outdated. Read-only.
Parent | Returns the parent object for the specified object. Read-only.
UnsupportedObjects | Returns a DependencyObjects collection that contains objects that cannot be searched for dependency. Read-only.


The specified fields are not uniquely indexed in table

 Copy code hover
[image]

The specified fields are not uniquely indexed in table <name>. (Error 3374)
Send feedback

The specified fields in the referenced table of a CONSTRAINT clause are not uniquely indexed.


Customization File Connect Section

 Copy code hover
[image]

Customization File Connect Section
Send feedback

The default behavior of the handler is to deny all connections. The connect section specifies exceptions to that behavior. For example, if all the connect sections were absent or empty, then by default no connections could be made.

The connect section can contain:

  • A default access entry that specifies the default read and write operations allowed on this connection. If there is no default access entry in the section, the section will be ignored.

  • A new connection string that replaces the client connection string.

Syntax

A default access entry is of the form:

Copy code Copy code
                      Access=accessRight

A replacement connection string entry is of the form:

Copy code Copy code
                      Connect=connectionString

Part

Description

Connect

A literal string that indicates this is a connection string entry.

connectionString

A string that replaces the whole client connection string.

Access

A literal string that indicates this is an access entry.

accessRight

One of the following access rights:

  • NoAccess — User cannot access the data source.

  • ReadOnly — User can read the data source.

  • ReadWrite — User can read or write to the data source.

If you want to allow any connection (in effect, disabling the default handler behavior), set the access entry in the connect default section to , and delete or comment out any other connect identifier section.


Modules Properties (Access)

 Copy code hover
[image]

Modules Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Module.
Parent | Returns the parent object for the specified object. Read-only.


CurrentProject.OpenConnection Method (Access)

 Copy code hover
[image]

CurrentProject.OpenConnection Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the OpenConnection method to open an ADO connection to an existing Microsoft Access project (.adp) or Access database as the current Access project or database in the Microsoft Access window.

Syntax

expression .OpenConnection(BaseConnectionString, UserID, Password)

expression A variable that represents a CurrentProject object.

Parameters

Name | Required/Optional | Data Type | Description
BaseConnectionString | Optional | Variant | A string expression that is the base connection string of the database.
UserID | Optional | Variant | A string expression that is the name of the existing Access project, including the path name and the file name extension. If your network supports it, you can also specify a network path in the following form: \\Server\Share\Folder\Filename.adp
Password | Optional | Variant | If you don't supply the filename extension, .adp is appended to the filename. You can use this method or the OpenCurrentDatabase method to open .adp files.

Remarks

The OpenConnection method is similar to the Open method of an ADO Connection object. This method establishes the physical connection to the data source. After this method successfully completes, the connection is live, the Connection and BaseConnectionString properties are set, and the Database window or data access page should be repopulated with data from the new connection. All parameters of this method are optional. If no base connection string is supplied, then the connection is re-established using the previous base connection string (but the user must call CloseConnection before calling OpenConnection again). In the case of an Access project, the BaseConnectionString property can only specify the SQL Server OLE DB Provider.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


Report.Click Event (Access)

 Copy code hover
[image]

Report.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over a report.

Version Information

Version Added: Access 2007

Syntax

expression .Click

expression A variable that represents a Report object.

Remarks

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

On a report, this event occurs when the user clicks a blank area of the report.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

Report Object

Other resources

Report Object Members


Reports Object (Access)

 Copy code hover
[image]

Reports Object (Access)
See also Send feedback

Published: July 16, 2012

The Reports collection contains all of the currently open reports in a Microsoft Access database.

Remarks

You can use the Reports collection in Visual Basic or in an expression to refer to reports that are currently open. For example, you can enumerate the Reports collection to set or return the values of properties of individual reports in the collection.

You can refer to an individual Report object in the Reports collection either by referring to the report by name, or by referring to its index within the collection.

The Reports collection is indexed beginning with zero. If you refer to a report by its index, the first report is Reports(0), the second report is Reports(1), and so on. If you opened Report1 and then opened Report2, Report2 would be referenced in the Reports collection by its index as Reports(1). If you then closed Report1, Report2 would be referenced in the Reports collection by its index as Reports(0).

Note Note

To list all reports in the database, whether open or closed, enumerate the AllReports collection of the CurrentProject object. You can then use the Name property of each individual AccessObject object to return the name of a report.

You can't add or delete a Report object from the Reports collection.

See also

Concepts

Access Object Model Reference

Other resources

Reports Object Members


Report.FilterOnLoad Property (Access)

 Copy code hover
[image]

Report.FilterOnLoad Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the filter specified by the Filter property is applied when the report is loaded. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .FilterOnLoad

expression A variable that represents a Report object.

See also

Concepts

Report Object

Other resources

Report Object Members


Cannot create database because the locale is invalid. (Error 3424)

 Copy code hover
[image]

Cannot create database because the locale is invalid. (Error 3424)
Send feedback

An invalid locale parameter was specified. Make sure you are using a valid Data Access Objects (DAO) constant to specify the locale parameter.


Using Wildcard Characters in String Comparisons

 Copy code hover
[image]

Using Wildcard Characters in String Comparisons
Send feedback

Built-in pattern matching provides a versatile tool for making string comparisons. The following table shows the wildcard characters you can use with the Like operator and the number of digits or strings they match.

Character(s) in pattern | Matches in expression
? or _ (underscore) | Any single character
* or % | Zero or more characters
# | Any single digit (0 - 9)
[charlist] | Any single character in charlist
[!charlist] | Any single character not in charlist

You can use a group of one or more characters (charlist) enclosed in brackets ([ ]) to match any single character in expression, and charlist can include almost any characters in the ANSI character set, including digits. You can use the special characters opening bracket ([ ), question mark (?), number sign (#), and asterisk (*) to match themselves directly only if enclosed in brackets. You cannot use the closing bracket ( ]) within a group to match itself, but you can use it outside a group as an individual character.

In addition to a simple list of characters enclosed in brackets, charlist can specify a range of characters by using a hyphen (-) to separate the upper and lower bounds of the range. For example, using [A-Z] in pattern results in a match if the corresponding character position in expression contains any of the uppercase letters in the range A through Z. You can include multiple ranges within the brackets without delimiting the ranges. For example, [a-zA-Z0-9] matches any alphanumeric character.

It is important to note that the ANSI SQL wildcards (%) and (_) are only available with Microsoft® Jet version 4.X and the Microsoft OLE DB Provider for Jet. They will be treated as literals if used through Microsoft Access or DAO.

Other important rules for pattern matching include the following:

  • An exclamation mark (!) at the beginning of charlist means that a match is made if any character except those in charlist are found in expression. When used outside brackets, the exclamation mark matches itself.

  • You can use the hyphen (-) either at the beginning (after an exclamation mark if one is used) or at the end of charlist to match itself. In any other location, the hyphen identifies a range of ANSI characters.

  • When you specify a range of characters, the characters must appear in ascending sort order (A-Z or 0-100). [A-Z] is a valid pattern, but [Z-A] is not.

  • The character sequence [ ] is ignored; it is considered to be a zero-length string ("").


ObjectFrame.DisplayWhen Property (Access)

 Copy code hover
[image]

ObjectFrame.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Syntax

expression .DisplayWhen

expression A variable that represents an ObjectFrame object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


NavigationButton.AddColon Property (Access)

 Copy code hover
[image]

NavigationButton.AddColon Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether a colon (:) follows the text in labels for new controls. Read/write Boolean.

Syntax

expression .AddColon

expression A variable that represents a NavigationButton object.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


ComboBox.BackTint Property (Access)

 Copy code hover
[image]

ComboBox.BackTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackTint

expression A variable that represents a ComboBox object.

Remarks

The BackTint property contains a numeric expression that can be used to lighten the theme color in the BackColor property. The default value of the BackTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackTint=25

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Report.FontUnderline Property (Access)

 Copy code hover
[image]

Report.FontUnderline Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontUnderline property to specify whether text is underlined in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Integer.

Syntax

expression .FontUnderline

expression A variable that represents a Report object.

Remarks

The FontUnderline property uses the following settings.

Setting | Description
True | The text is underlined.
False | (Default) The text isn't underlined.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

Report Object

Other resources

Report Object Members


Disk I/O error at destination dropbox folder. (Error 3558)

 Copy code hover
[image]

Disk I/O error at destination dropbox folder. (Error 3558)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


DoCmd.GoToPage Method (Access)

 Copy code hover
[image]

DoCmd.GoToPage Method (Access)
See also Send feedback

Published: July 16, 2012

Carries out the GoToPage action in Visual Basic. .

Syntax

expression .GoToPage(PageNumber, Right, Down)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
PageNumber | Required | Variant | A numeric expression that's a valid page number for the active form. If you leave this argument blank, the focus stays on the current page. You can use the right and down arguments to display the part of the page you want to see.
Right | Optional | Variant | A numeric expression that's a valid horizontal offset for the page.
Down | Optional | Variant | A numeric expression that's a valid vertical offset for the page.

Return Value

Nothing

Remarks

The units for the right and down arguments are expressed in twips.

If you specify the right and down arguments and leave the pagenumber argument blank, you must include the pagenumber argument's comma. If you don't specify the right and down arguments, don't use a comma following the pagenumber argument.

The GoToPage method of the DoCmd object was added to provide backwards compatibility for running the GoToPage action in Visual Basic code in Microsoft Access 95. It's recommended that you use the existing GoToPage method of the Form object instead.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


CustomControl.BottomPadding Property (Access)

 Copy code hover
[image]

CustomControl.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .BottomPadding

expression A variable that represents a CustomControl object.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Exceptions table could not be created on import/export. (Error 3618)

 Copy code hover
[image]

Exceptions table could not be created on import/export. (Error 3618)
Send feedback

A problem was encountered while importing or exporting to an external file. The import/export driver could not create an error table in the Microsoft Access database to report the problem.


Concat Function (Access 2013 custom web app)

 Copy code hover
[image]

Concat Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns a string that is the result of combining two or more string values.

Syntax

Concat(Value1, Value2, …[ValueN])

The Concat function contains the following arguments.

Argument Name | Description
Value | A string value to concatenate to the other values.

Remarks

Concat takes a variable number of string arguments and concatenates them into a single string. A minimum of two string arguments are required; otherwise, an error is raised.

All arguments are implicitly converted to string data types and then concatenated.

Example

The following expression can be used to display the full name of a person where the table contains FirstName, MiddleInitial, and LastName fields. If the MiddleInitial field is blank, then only the FirstName and LastName fields are combined to display the full name,

Copy code Copy code
IIf([MiddleInitial] Is Null,Concat([FirstName]," ",[LastName]),Concat([FirstName]," ",[MiddleInitial]," ",[LastName]))


TabControl.GridlineTint Property (Access)

 Copy code hover
[image]

TabControl.GridlineTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineTint

expression A variable that represents a TabControl object.

Remarks

The GridlineTint property contains a numeric expression that can be used to lighten the theme color in the GridlineColor property. The default value of the GridlineTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Could not open table 'MSysGroups' in the workgroup information file. (Error 3174)

 Copy code hover
[image]

Could not open table 'MSysGroups' in the workgroup information file. (Error 3174)
Send feedback

This operation requires the System.mdw file, which contains the security and option settings for Microsoft Access database tables.


Echo Macro Action

 Copy code hover
[image]

Echo Macro Action
Send feedback

You can use the Echo action to specify whether echo is turned on. For example, you can use this action to hide or show the results of a macro while it runs.

Setting

Note 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 Echo action has the following arguments.

Action argument | Description
Echo On | Click Yes (turn echo on) or No (turn echo off) in the Echo On box in the Action Arguments section of the Macro Builder pane. The default is Yes.
Status Bar Text | The text to display in the status bar when echo is turned off. For example, when echo is turned off, the status bar can display "The macro is running."

When runs a macro, screen updating often shows information not essential to the functioning of the macro. When you set the Echo On argument to No, the macro runs without updating the screen. When the macro finishes, Access automatically turns echo back on and repaints the window. The No setting for the Echo On argument doesn't affect the functionality of the macro or its results.

The Echo action doesn't suppress the display of modal dialog boxes, such as error messages, or pop-up forms, such as property sheets. You can use dialog boxes and pop-up forms to gather or display information, even if echo is turned off. To suppress all message or dialog boxes except error message boxes and dialog boxes that require the user to enter information, use the SetWarnings action.

You can run the Echo action more than once in a macro. This allows you to change the status bar text while the macro runs.

If you turn echo off, you can use the DisplayHourglassPointer action to change the mouse pointer into an hourglass icon (or whatever mouse pointer icon you've set for "Busy") to provide a visual indication that the macro is running.

To run the Echo action in a Visual Basic for Applications (VBA) module, use the Echo method of the DoCmd object.

Examples

Set the value of a control by using a macro

The following macro opens the Add Products form from a button on the Suppliers form. It shows the use of the Echo, CloseWindow, OpenForm, SetValue, and GoToControl actions. The SetValue action sets the Supplier ID control on the Products form to the current supplier on the Suppliers form. The GoToControl action then moves the focus to the Category ID field, where you can begin to enter data for the new product. This macro should be attached to the Add Products button on the Suppliers form.

Action | Arguments: Setting | Comment
Echo | Echo On: No | Stop screen updating while the macro is running.
CloseWindow | Object Type: FormObject Name: Product List Save: No | Close the Product List form.
OpenForm | Form Name: Products View: FormData Mode: AddWindow Mode: Normal | Open the Products form.
SetValue | Item: [Forms]![Products]![SupplierID] Expression: SupplierID | Set the Supplier ID control to the current supplier on the Suppliers form.
GoToControl | Control Name: CategoryID | Go to the Category ID control.

Synchronize forms by using a macro

The following macro opens the Product List form in the lower-right corner of the Suppliers form, displaying the current supplier's products. It shows the use of the Echo, MessageBox, GoToControl, StopMacro, OpenForm, and MoveAndSizeWindow actions. It also shows the use of a conditional expression with the MessageBox, GoToControl, and StopMacro actions. This macro should be attached to the Review Products button on the Suppliers form.

Condition | Action | Arguments: Setting | Comment
 | Echo | Echo On: No | Stop screen updating while the macro is running.
IsNull([Supplier ID]) | MessageBox | Message: Move to the supplier record whose products you want to see, then click the Review Products button again. Beep: YesType: NoneTitle: Select a Supplier | If there is no current supplier on the Suppliers form, display a message.
... | GoToControl | Control Name: CompanyName | Move focus to the CompanyName control.
... | StopMacro |  | Stop the macro.
 | OpenForm | Form Name: Product List View: DatasheetFilter Name: Where Condition: [Supplier ID] = [Forms]![Suppliers]![SupplierID] Data Mode: Read OnlyWindow Mode: Normal | Open the Product List form and show the current supplier's products.
 | MoveAndSizeWindow | Right: 0.7799" Down: 1.8" | Position the Product List form in the lower right of the Suppliers form.


Parameter Members (DAO)

 Copy code hover
[image]

Parameter Members (DAO)
Send feedback

A Parameter object represents a value supplied to a query. The parameter is associated with a QueryDef object created from a parameter query.

Properties

Name

Description

Direction

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Sets or returns a value that indicates whether a Parameter object represents an input parameter, an output parameter, both, or the return value from the procedure (ODBCDirect workspaces only).

Name

Returns the name of the specified object. Read-only String.

Properties

Returns the Properties collection of the specified object. Read-only.

Type

Sets or returns a value that indicates the operational type or data type of an object. Read/write Integer.

Value

Sets or returns the value of an object. Read/write Variant.


Attachment.Properties Property (Access)

 Copy code hover
[image]

Attachment.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Version Information

Version Added: Access 2007

Syntax

expression .Properties

expression A variable that represents an Attachment object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


ObjectFrame.Class Property (Access)

 Copy code hover
[image]

ObjectFrame.Class Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Class property to specify or determine the class name of an embeddedOLE object. Read/write String.

Syntax

expression .Class

expression A variable that represents an ObjectFrame object.

Remarks

The Class property setting is a string expression supplied by you or Microsoft Access when you create or paste an OLE object.

A class name defines the type of OLE object. For example, Microsoft Excel supports several types of OLE objects, including worksheets and charts. Their class names are "Excel.Sheet" and "Excel.Chart" respectively.

Note Note

To determine the class name of an OLE object, see the documentation for the application supplying the object.

The Class property setting is updated when you copy an object from the Clipboard. For example, if you paste a Microsoft Excel chart from the Clipboard into an OLE object that previously contained a Microsoft Excel worksheet, the Class property setting changes from "Excel.Sheet" to "Excel.Chart". You can paste an object from the Clipboard by using Visual Basic to set the control's Action property to acOLEPaste or acOLEPasteSpecialDlg.

Note Note

The OLEClass property and the Class property are similar but not identical. The OLEClass property setting is a general description of the OLE object whereas the Class property setting is the name used to refer to the OLE object in Visual Basic. Examples of OLEClass property settings are Microsoft Excel Chart, Microsoft Word Document, and Paintbrush Picture.

Example

The following example creates a linked OLE object using an unbound object frame named OLE1 and sizes the control to display the object's entire contents when the user clicks a command button.

VBA Copy code Copy code
Sub Command1_Click
 OLE1.Class = "Excel.Sheet" ' Set class name.
 ' Specify type of object.
 OLE1.OLETypeAllowed = acOLELinked
 ' Specify source file.
 OLE1.SourceDoc = "C:\Excel\Oletext.xls"
 ' Specify data to create link to.
 OLE1.SourceItem = "R1C1:R5C5"
 ' Create linked object.
 OLE1.Action = acOLECreateLink
 ' Adjust control size.
 OLE1.SizeMode = acOLESizeZoom
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


BoundObjectFrame.LeftPadding Property (Access)

 Copy code hover
[image]

BoundObjectFrame.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the object frame and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .LeftPadding

expression A variable that represents a BoundObjectFrame object.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Image.GridlineStyleRight Property (Access)

 Copy code hover
[image]

Image.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified image control. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleRight

expression A variable that represents an Image object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

Image Object

Other resources

Image Object Members


CommandButton.OnPush Property (Access)

 Copy code hover
[image]

CommandButton.OnPush Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window of a command button. Read/write String.

Syntax

expression .OnPush

expression A variable that represents a CommandButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

Although the name of this property is OnPush, setting this property actually sets the value of the On Click box.

The OnPush value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the command button's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example prints the value of the OnPush property in the Immediate window for the "OK" button on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnPush

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


The table

 Copy code hover
[image]

The table <name> is already opened exclusively by another user, or it is already open through the user interface and cannot be manipulated programmatically. (Error 3008)
Send feedback

You tried to use a table that is currently open for exclusive access by another user, or you tried to programmatically manipulate a table that is open through the user interface. Address the appropriate condition, and then try the operation again.


ConnectionString, ConnectionTimeout, and State Properties Example (VC++)

 Copy code hover
[image]

ConnectionString, ConnectionTimeout, and State Properties Example (VC++)
Send feedback

This example demonstrates different ways of using the ConnectionString property to open a Connection object. It also uses the ConnectionTimeout property to set a connection timeout period, and the State property to check the state of the connections. The GetState function is required for this procedure to run.

Copy code Copy code

// BeingConnectionStringCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void ConnectionStringX();
_bstr_t GetState(int intState);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 ConnectionStringX();

 //Wait here for user to see the output..
 printf("\nPress any key to continue...");
 getch();

 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// ConnectionStringX Function //
// //
///////////////////////////////////////////////////////////

void ConnectionStringX()
{
 // Define Connection object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace
 _ConnectionPtr pConnection1 = NULL;
 _ConnectionPtr pConnection2 = NULL;
 _ConnectionPtr pConnection3 = NULL;
 _ConnectionPtr pConnection4 = NULL;

 //Define Other Variables
 HRESULT hr = S_OK;

 try
 {
 // Open a connection using OLE DB syntax.
 TESTHR(pConnection1.CreateInstance(__uuidof(Connection)));
 pConnection1->ConnectionString =
 "Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='Pubs';Integrated Security='SSPI';";
 pConnection1->ConnectionTimeout = 30;
 pConnection1->Open("","","",adConnectUnspecified);
 printf("cnn1 state: %s\n",
 (LPCTSTR)GetState(pConnection1->State));

 // Open a connection using a DSN and ODBC tags.
 // It is assumed that you have create DSN 'Pubs' with a user name as
 // 'MyUserId' and password as 'MyPassword'.
 TESTHR(pConnection2.CreateInstance(__uuidof(Connection)));
 pConnection2->ConnectionString = "DSN=Pubs;UID=MyUserId;PWD=MyPassword;";
 pConnection2->Open("","","",adConnectUnspecified);
 printf("cnn2 state: %s\n",
 (LPCTSTR)GetState(pConnection2->State));

 // Open a connection using a DSN and OLE DB tags.
 TESTHR(pConnection3.CreateInstance(__uuidof(Connection)));
 pConnection3->ConnectionString = "Data Source=Pubs;";
 pConnection3->Open("","","",adConnectUnspecified);
 printf("cnn3 state: %s\n",
 (LPCTSTR)GetState(pConnection3->State));

 // Open a connection using a DSN and individual
 // arguments instead of a connection string.
 // It is assumed that you have create DSN 'Pubs' with a user name as
 // 'MyUserId' and password as 'MyPassword'.
 TESTHR(pConnection4.CreateInstance(__uuidof(Connection)));
 pConnection4->Open("Pubs","MyUserId","MyPassword",adConnectUnspecified);
 printf("cnn4 state: %s\n",
 (LPCTSTR)GetState(pConnection4->State));
 }
 catch(_com_error &e)
 {
 // Notify user of any errors.
 // Pass a connection pointer accessed from the Connection.
 PrintProviderError(pConnection1);
 if(pConnection2)
 PrintProviderError(pConnection2);
 if(pConnection3)
 PrintProviderError(pConnection3);
 if(pConnection4)
 PrintProviderError(pConnection4);
 PrintComError(e);
 }

 //Cleanup objects before exit.
 if (pConnection1)
 if (pConnection1->State == adStateOpen)
 pConnection1->Close();
 if (pConnection2)
 if (pConnection2->State == adStateOpen)
 pConnection2->Close();
 if (pConnection3)
 if (pConnection3->State == adStateOpen)
 pConnection3->Close();
 if (pConnection4)
 if (pConnection4->State == adStateOpen)
 pConnection4->Close();
}

///////////////////////////////////////////////////////////
// //
// GetState Function //
// //
///////////////////////////////////////////////////////////

_bstr_t GetState(int intState)
{
 _bstr_t strState;
 switch(intState)
 {
 case adStateClosed:
 strState = "adStateClosed";
 break;
 case adStateOpen:
 strState = "adStateOpen";
 break;
 default:
 ;
 }
 return strState;
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;

 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n", pErr->Number,
 (LPCSTR)pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndConnectionStringCpp


Cannot initialize Synchronizer because there are too many applications running. (Error 3538)

 Copy code hover
[image]

Cannot initialize Synchronizer because there are too many applications running. (Error 3538)
Send feedback

There are not enough system resources available to run all the open applications and to start the Synchronizer. Shut down one or more applications and try again.


OptionButton.Layout Property (Access)

 Copy code hover
[image]

OptionButton.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified option button. Read-only AcLayoutType.

Version Information

Version Added: Access 2007

Syntax

expression .Layout

expression A variable that represents an OptionButton object.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Working with Other Applications (Access)

 Copy code hover
[image]

Working with Other Applications (Access)
Send feedback

In this section

  • Automation with Microsoft Access

  • Use Microsoft Access as a DDE Server

  • Using ActiveX Data Objects


Selected collating sequence not supported by the operating system. (Error 3228)

 Copy code hover
[image]

Selected collating sequence not supported by the operating system. (Error 3228)
Send feedback

There is an invalid CollatingSequence setting in the Paradox key of the Microsoft Windows Registry.

To fix the CollatingSequence setting

  1. Exit your application.

  2. Start the Registry Editor, navigate to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Access Connectivity Engine\Engines\Paradox key, and select the CollatingSequence value.

  3. On the Edit menu, click Modify.

  4. Specify either ascii or International in the Value data box.

  5. Restart your application, and then try the operation again.


AcRecord Enumeration (Access)

 Copy code hover
[image]

AcRecord Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the GoToRecord method to specify which record to make the current record.

Name | Value | Description
acFirst | 2 | Make the first record the current record.
acGoTo | 4 | Make the specified record the current record.
acLast | 3 | Make the last record the current record.
acNewRec | 5 | Make a new record the current record.
acNext | 1 | Make the next record the current record.
acPrevious | 0 | Make the previous record the current record.


DependencyObjects.Application Property (Access)

 Copy code hover
[image]

DependencyObjects.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a DependencyObjects object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

DependencyObjects Collection

Other resources

DependencyObjects Object Members


Automation with Microsoft Access

 Copy code hover
[image]

Automation with Microsoft Access
Send feedback

Microsoft Access is a COM component that supports Automation, formerly called OLE Automation. Microsoft Access supports Automation in two ways. From Microsoft Access, you can work with objects supplied by another component. Microsoft Access also supplies its objects to other COM components.

You can use the New keyword or the CreateObject method to create a new instance of a component. You can use the GetObject method to assign a variable to an existing instance of a component.

In Microsoft Access, you can set a reference to a component's type library to improve performance when you work with that component through Automation. Microsoft Access also includes the Object Browser, a tool that enables you to view objects in another component's type library, as well as their methods and properties.

The Microsoft Access type library provides information about Microsoft Access objects to other components. You can set a reference to the Microsoft Access type library from a component and view its objects in the Object Browser.

To work with Microsoft Access objects through Automation, you must create an instance of the Microsoft Access Application object. For example, suppose you want to display data from Microsoft Excel in a Microsoft Access form or report. To launch Microsoft Access from Microsoft Excel, you can use the New keyword to create an instance of the Microsoft Access Application object. You can also use the CreateObject method to create a new instance of the Microsoft Access Application object, or you can use the GetObject method to point an object variable to an existing instance of Microsoft Access. Check your component's documentation to determine which syntax it supports.

Once you've launched an instance of Microsoft Access, if you want to control any Microsoft Access objects, you must open a database or project (.adp) in the Microsoft Access window by using either the OpenCurrentDatabase or the NewCurrentDatabase method for a database or by using the OpenAccessProject or the NewAccessProject method for a project.

If you've opened Microsoft Access only as a means of using the Data Access Objects provided by Microsoft DAO, then you don't need to open a database in the Microsoft Access window. You can use the DBEngine property of the Microsoft Access Application object to access objects in the Microsoft Office 12.0 Access Database Engine Object Library object library during an Automation operation.


NavigationControl.TabStop Property (Access)

 Copy code hover
[image]

NavigationControl.TabStop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .TabStop

expression A variable that represents a NavigationControl object.

Remarks

This property doesn't apply to toggle button controls when they appear in an option group. It applies only to the option group itself.

The TabStop property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) You can move the focus to the control by pressing the TAB key.
No | False | You can't move the focus to the control by pressing the TAB key.

When you create a control on a form, Microsoft Access automatically assigns the control a position in the form's tab order. Each new control is placed last in the tab order. If you want to prevent a control from being available when you tab through the controls in a form, set the control's TabStop property to No.

In Form view, hidden or disabled controls remain in the tab order but are skipped when you move through the controls by pressing TAB, even if their TabStop properties are set to Yes.

As long as a control's Enabled property is set to Yes, you can click the control or use an access key to select it, regardless of its TabStop property setting. For example, you can set the TabStop property of a command button to No to prevent users from selecting the button by pressing TAB. However, they can still click the command button to choose it.

Example

The following example disables the ability to move the focus to the "City" text box on the "Suppliers" form by using the TAB key.

VBA Copy code Copy code
Forms("Suppliers").Controls("City").TabStop = False

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


CommandButton.Height Property (Access)

 Copy code hover
[image]

CommandButton.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Syntax

expression .Height

expression A variable that represents a CommandButton object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


TextBox.Vertical Property (Access)

 Copy code hover
[image]

TextBox.Vertical Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Vertical property to set a form control for vertical display and editing or set a report control for vertical display and printing. Read/write Boolean.

Syntax

expression .Vertical

expression A variable that represents a TextBox object.

Remarks

The Vertical property uses the following settings:

Setting | Visual Basic | Description
Yes | True | Displays, edits, and prints vertical text.
No | False | (Default) Does not display, edit, or print vertical text.

You can specify how vertical text will be displayed, edited, or printed in the control by setting the Vertical property. If set to Yes, the starting point for inputting text is the upper right corner of the control (the ending point is the lower left corner of the control). If using full pitch characters, the display and print directions are the same as the control for horizontal text. If using half pitch characters, it shifts 90 degrees to the right. The cursor is also rotated 90 degrees to the right in a vertical text control.

Note Note

Text selection using key combinations is different for vertical text control and horizontal text control. Key combinations and their effect on range selection are described below.

Key combination | Selected range
Shift+Up | Vertical: One character before the cursor. Horizontal: One line before the cursor.
Shift+Down | Vertical: One character after the cursor. Horizontal: One line after the cursor.
Shift+Right | Vertical: One line after the cursor. Horizontal: One character before the cursor.
Shift+Left | Vertical: One line before the cursor. Horizontal: One character after the cursor.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Image.GridlineTint Property (Access)

 Copy code hover
[image]

Image.GridlineTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineTint

expression A variable that represents an Image object.

Remarks

The GridlineTint property contains a numeric expression that can be used to lighten the theme color in the GridlineColor property. The default value of the GridlineTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

Image Object

Other resources

Image Object Members


Report.CurrentY Property (Access)

 Copy code hover
[image]

Report.CurrentY Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the CurrentY property (along with the CurrentX property) to specify the horizontal and vertical coordinates for the starting position of the next printing and drawing method on a report. Read/write Single.

Syntax

expression .CurrentY

expression A variable that represents a Report object.

Remarks

For example, you can use these properties to determine where the center point of a circle is drawn on a report section.

The coordinates are measured from the upper-left corner of the report section that contains the reference to the CurrentX or CurrentY property. The CurrentX property setting is 0 at the section's left edge, and the CurrentY property setting is 0 at its top edge.

You can set the CurrentX and CurrentY properties in an event procedure specified by the OnPrint property setting of a report section.

Use the ScaleMode property to define the unit of measure, such as points, pixels, characters, inches, millimeters, or centimeters, that the coordinates will be based on.

When you use the following graphics methods, the CurrentX and CurrentY property settings are changed as indicated.

Method | Sets CurrentX, CurrentY properties to
Circle | The center of the object.
Line | The end point of the line (the x2, y2 coordinates).
Print | The next print position.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


ToggleButton.HoverThemeColorIndex Property (Access)

 Copy code hover
[image]

ToggleButton.HoverThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HoverThemeColorIndex

expression A variable that represents a ToggleButton object.

Remarks

The HoverThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 (Default) | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the HoverThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


How to: Detect User Idle Time or Inactivity

 Copy code hover
[image]

How to: Detect User Idle Time or Inactivity
Send feedback

This topic shows how to create a procedure that will run if your Microsoft Access application does not detect any user input for a specified period of time. It involves creating a hidden form, DetectIdleTime, which keeps track of idle time.

Follow these steps to create the DetectIdleTime form.

  1. Create a blank form that is not based on any table or query and name it DetectIdleTime.

  2. Set the following form properties:

    Note Note

    The TimerInterval setting indicates how often (in milliseconds) the application checks for user inactivity. A setting of 1000 equals 1 second.

    Property

    Value

    OnTimer

    [Event Procedure]

    TimerInterval

    1000

  3. Enter the following code for the OnTimer property event procedure:

    Copy code Copy code
          Sub Form_Timer()
         ' IDLEMINUTES determines how much idle time to wait for before
         ' running the IdleTimeDetected subroutine.
         Const IDLEMINUTES = 5

         Static PrevControlName As String
         Static PrevFormName As String
         Static ExpiredTime

         Dim ActiveFormName As String
         Dim ActiveControlName As String
         Dim ExpiredMinutes

         On Error Resume Next

         ' Get the active form and control name.

         ActiveFormName = Screen.ActiveForm.Name
         If Err Then
            ActiveFormName = "No Active Form"
            Err = 0
         End If

         ActiveControlName = Screen.ActiveControl.Name
            If Err Then
            ActiveControlName = "No Active Control"
            Err = 0
         End If

         ' Record the current active names and reset ExpiredTime if:
         '    1. They have not been recorded yet (code is running
         '       for the first time).
         '    2. The previous names are different than the current ones
         '       (the user has done something different during the timer
         '        interval).
         If (PrevControlName = "") Or (PrevFormName = "") _
           Or (ActiveFormName <> PrevFormName) _
           Or (ActiveControlName <> PrevControlName) Then
            PrevControlName = ActiveControlName
            PrevFormName = ActiveFormName
            ExpiredTime = 0
         Else
            ' ...otherwise the user was idle during the time interval, so
            ' increment the total expired time.
            ExpiredTime = ExpiredTime + Me.TimerInterval
         End If

         ' Does the total expired time exceed the IDLEMINUTES?
         ExpiredMinutes = (ExpiredTime / 1000) / 60
         If ExpiredMinutes >= IDLEMINUTES Then
            ' ...if so, then reset the expired time to zero...
            ExpiredTime = 0
            ' ...and call the IdleTimeDetected subroutine.
            IdleTimeDetected ExpiredMinutes
         End If
      End Sub

  4. Create the following procedure in the form module:

    Copy code Copy code
          Sub IdleTimeDetected(ExpiredMinutes)
         Dim Msg As String
         Msg = "No user activity detected in the last "
         Msg = Msg & ExpiredMinutes & " minute(s)!"
         MsgBox Msg, 48
      End Sub

To hide the DetectIdleTime form as it opens, set the WindowMode argument of the OpenForm method to acHidden.


Form.BeforeQuery Property (Access)

 Copy code hover
[image]

Form.BeforeQuery Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the BeforeQuery event occurs. Read/write.

Syntax

expression .BeforeQuery

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the BeforeQuery event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0)

See also

Concepts

Form Object

Other resources

Form Object Members


The database

 Copy code hover
[image]

The database <database name> is already in use by another person or process. When the database is available, try the operation again. (Error 3196)
Send feedback

The specified database is currently being used exclusively by another user or session. Wait for the other user or session to finish working with the database, and then try the operation again.


Label.ControlTipText Property (Access)

 Copy code hover
[image]

Label.ControlTipText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.

Syntax

expression .ControlTipText

expression A variable that represents a Label object.

Remarks

You set the ControlTipText property by using a string expression up to 255 characters long.

For controls on forms, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

You can set the ControlTipText property in any view.

The ControlTipText property provides an easy way to provide helpful information about controls on a form.

There are other ways to provide information about a form or a control on a form. You can use the StatusBarText property to display information in the status bar about a control. To provide more extensive help for a form or control, use the HelpFile and HelpContextID properties.

See also

Concepts

Label Object

Other resources

Label Object Members


ADO Glossary

 Copy code hover
[image]

ADO Glossary
Send feedback

A B C D E-I K-M N-O P R S T-W

A

absolute URL

A fully qualified URL that specifies the location of a resource that resides on the Internet or an intranet. See also URL and relative URL.

ActiveX control

Self-registering, in-process COM component that often has a visual element either at design time or run time. ActiveX controls also have the ability to communicate with an Active Document container, such as Microsoft Internet Explorer.

ADISAPI (Advanced Data Internet Server Application Programming Interface)

An ISAPI DLL that provides parsing, Automation control, Recordset marshaling, and MIME packaging. The ADISAPI component works through the API provided by Internet Information Services (IIS). See also ISAPI.

aggregate function

In a query, a function such as COUNT, AVG, or STDEV that calculates a value using all the rows in a column of a table. In writing expressions and in programming, you can use SQL aggregate functions (including the three listed above) and domain aggregate functions to determine various statistics.

alias

An alternate name you give to a column or expression in an SQL SELECT statement, often shorter or more meaningful. For example, BobSales is the alias in the following SELECT statement: "Select wr-Sales as BobSales from SalesDB". An alias can be used to dynamically assign columns to control bindings on the DataControl object.

apartment threading

A COM threading model where all calls to an object occur on one thread. In apartment threading, COM synchronizes and marshals calls. See also COM.

asynchronous operation

An operation that returns control to the calling program without waiting for the operation to complete. Before the operation is complete, code execution continues. See also synchronous operation.

Return to top

B

binding entry

A mapping between a field in a table and a variable. In the ADO Visual C++ extensions, Recordset fields are mapped to C/C++ variables.

bitmask

A numeric value intended for a bit-by-bit value comparison with other numeric values, typically to flag options in parameter or return values. Usually this comparison is done with bitwise logical operators, such as And and Or in Visual Basic, & and | in C++.

For example, the ADO FieldAttributeEnum values can be used as bitmasks to determine the attributes of a field. Suppose you wanted to determine if a field was updateable. You could test for this with the following expression in Visual Basic:

If the result is TRUE, then the field is updateable.

bookmark

A marker that uniquely identifies a row within a set of rows so that a user can quickly navigate to it.

business object

An object that performs a defined set of operations, such as data validation or business rule logic. Business objects usually reside on the middle tier.

business rule

The combination of validation edits, logon verifications, database lookups, policies, and algorithmic transformations that constitute an enterprise's way of doing business. Also known as business logic.

Return to top

C

calculated expression

An expression that is not constant, but whose value depends upon other values. To be evaluated, a calculated expression must obtain and compute values from other sources, typically in other fields or rows.

chapter

A reference to a range of rows from a data source. In ADO, a chapter is typically a reference to another Recordset.

Chapter columns make it possible to define a parent-child relationship where the parent is the Recordset containing the chapter column and the child is the Recordset represented by the chapter.

chapter-alias

An alias that refers to the column appended to the parent.

character set

A mapping of a set of characters to their numeric values. For example, Unicode is a 16-bit character set capable of encoding all known characters and used as a worldwide character-encoding standard.

child

The dependent side of a hierarchical relationship. A child is a node in a hierarchical structure that has another node above it (closer to the root). See also child-alias, parent-child relationship, parent.

child-alias

An alias that refers to the child. See also alias, child.

CLSID (class identifier)

A universally unique identifier (UUID) that identifies a COM component. Each COM component has its CLSID in the Windows Registry so that it can be loaded by other applications. See also ProgID, COM.

client tier

A logical layer of a distributed system that typically presents data to and processes input from the user, sometimes referred to as the front end. Usually, the client tier requests data from a server based on input, and then formats and displays the result. See also middle tier, data source tier, distributed application.

COM (Component Object Model)

A binary standard that enables objects to interoperate in a networked environment regardless of the language in which they were developed or on which computers they reside. COM-based technologies include ActiveX Controls, Automation, and object linking and embedding (OLE). COM allows an object to expose its functionality to other components and to host applications. It defines both how the object exposes itself and how this exposure works across processes and across networks. COM also defines the object's life cycle.

COM component

Binary file — such as .dll, .ocx, and some .exe files — that supports the COM standard for providing objects. Such a file contains code for one or more class factories, COM classes, registry-entry mechanisms, loading code, and so on.

comparison operator

An operator that compares two expressions and returns a Boolean value.

A criteria parameter that may be expressed as ">" (greater than), "<" (less than), "=" (equal), ">=" (greater than or equal), "<=" (less than or equal), "<>" (not equal), or "like" (pattern matching).

component

An object that encapsulates both data and code, and provides a well-specified set of publicly available services.

compound file

An implementation of COM structured storage for files. A compound file stores separate objects in a single, structured file consisting of two main elements: storage objects and stream objects. Together, they function like a file system within a file. For more information, see Compound Files in the Microsoft Platform SDK.

A number of individual files bound together in one physical file. Each individual file in a compound file can be accessed as if it were a single physical file.

constant

A numeric or string value that does not change. Named ADO enumerations (enumerated constants) can be used in your code instead of actual values, for example, adUseClient is a constant whose value is 3. (Const adUseClient = 3). See also enumeration.

cursor

A database element that controls record navigation, updateability of data, and the visibility of changes made to the database by other users.

Return to top

D

data binding

The process of associating the objects or controls of an application to a data source. A control associated with a data source is called a data-bound control.

The contents of a data-bound control are associated with values from a database. For example, a grid control that is bound to a Recordset object can be updated when the rows in the Recordset are updated. When new values are retrieved by the Recordset, new values are displayed in the grid.

data provider

Software that exposes data to an ADO application either directly or via a service provider. See also service provider.

data shaping

A technique which makes use of a formalized syntax (called Shape language) to define a specialized Recordset object (called a shaped Recordset) that contains not just data, but also references to other Recordset objects and/or computed values based on those other Recordset objects.

data source tier

A logical layer of a distributed system that represents a computer running a DBMS, such as an SQL Server database. See also client tier, middle tier, distributed application.

DCOM

A wire protocol that enables COM components to communicate directly with each other across a network. See also COM, component.

DDL (Data Definition Language)

Those statements in SQL that define, as opposed to manipulate, data. The schema of a database is created or modified with DDL. For example, CREATE TABLE, CREATE INDEX, GRANT, and REVOKE are SQL DDL statements.

default stream

A text or binary stream (represented by a Stream object) that is associated with Record or Recordset objects when using certain OLE DB providers, such as the Microsoft OLE DB Provider for Internet Publishing. The default stream typically contains the contents of a file such as the HTML code for the root of a Web site.

distributed application

A program written so that the processing can be divided across multiple computers over a network. Typically, a distributed application is divided into presentation, business logic, and data store layers, or tiers. See also client tier, middle tier, data source tier.

disconnected Recordset

A Recordset object in a client cache that no longer has a live connection to the server. If the original data source needs to be accessed again for some reason, such as updating data, the connection must be re-established. However, the collections, properties, and methods of a disconnected Recordset can still be accessed.

DLL (dynamic-link library)

A file that contains one or more functions that are compiled, linked, and stored separately from the processes that use them. The operating system maps the DLLs into the address space of the calling process when the process is starting, or while it is running.

DML (Data Manipulation Language)

Those statements in SQL that manipulate, as opposed to define, data. The values in a database are selected and modified with DML. For example, INSERT, UPDATE, DELETE, and SELECT are SQL DML statements.

document source provider

A special class of providers that manage folders and documents. When a document is represented by a Record object, or a folder of documents is represented by a Recordset object, the document source provider populates those objects with a unique set of fields that describe characteristics of the document, instead of the actual document itself. See also resource record.

DSN (data source name)

The collection of information used to connect your application to a particular ODBC database. The ODBC Driver Manager uses this information to create a connection to the database. A DSN can be stored in a file (a file DSN) or in the Windows Registry (a machine DSN).

dynamic property

A property specific to a data provider or the cursor service. The Properties collection of an object is populated with these automatically ("dynamically"). An object has no dynamic properties until it is connected to a data source through a particular data provider. See also data provider, cursor.

Return to top

E-I

enumeration

A list of named constants. Enumerated values need not be unique. However the name of each value must be unique within the scope where the enumeration is defined. In ADO, enumerations are used for numeric parameter and return values, to add meaning to ADO code and to shield the developer from the numeric values (which may change from version to version). For example, to open a static Recordset, use the adOpenStatic enumerated value:

Also referred to as enumerated constant. See also constant.

event

An action recognized by an object, for which you can write code to respond. Events can be generated by command execution, transaction completion, recordset navigation, and data updates, among other actions. See also event handler.

event handler

An event handler is the code that is executed when an event occurs. See also event.

handler

A routine that manages a common and relatively simple condition or operation, such as error recovery or data management.

hierarchical Recordset

A Recordset that contains another Recordset. See also data shaping, chapter.

For more information, see Accessing Rows in a Hierarchical Recordset

hierarchy

In general, a hierarchy is a ranked structure with a top level and subordinate levels. In ADO, hierarchical Recordsets are used to represent the parent-child relationship between a record and a chapter. Also in ADO, Record and Stream objects can be used to access hierarchical tree structures such as a folder and documents. ADO MD also includes Hierarchy objects to represent a relationship between the levels of a dimension in an OLAP cube. See also hierarchical Recordsets, parent-child relationship, chapter, tree.

ISAPI (Internet Server Application Programming Interface)

A set of functions for Internet servers, such as a Windows NT Server/Windows 2000 Server running Microsoft Internet Information Services (IIS).

Return to top

K-M

key

A column or columns in a table that uniquely identify a row; often used to index a table.

marshaling

The process of packaging, sending, and unpackaging interface method parameters across thread or process boundaries.

middle tier

The logical layer in a distributed system between a user interface or Web client and the database. This is typically where business objects are instantiated. The middle tier is a collection of business rules and functions that generate and operate upon receiving information. They accomplish this through business rules, which can change frequently, and are thus encapsulated into components that are physically separate from the application logic itself. Also known as application server tier. See also distributed application, client tier, data source tier.

MIME (Multi-purpose Internet Mail Extension)

An Internet protocol originally developed to allow exchange of electronic mail messages with rich content across heterogeneous network, machine, and e-mail environments. In practice, MIME has also been adopted and extended by non-mail applications.

MIME is a standard that allows binary data to be published and read on the Internet. The header of a file with binary data contains the MIME type of the data; this informs client programs (Web browsers and mail packages, for instance) that they will need to handle the data in a different way than they handle straight text. For example, the header of a Web document containing a JPEG graphic contains the MIME type specific to the JPEG file format. This allows a browser to display the file with its JPEG viewer, if one is present.

Return to top

N-O

node

An element in a hierarchical tree structure. A node may be the root, or the child of another node. A node can also be the parent of multiple children. See also hierarchy, tree, root, child, parent.

object variable

A variable that contains a reference to an object. For example, objCustomObject is a variable that points to an object of type CustomObject:

is a variable that points to an object of type CustomObject:

Set objCustomObject = CreateObject(adodb.Recordset)

ODBC (Open Database Connectivity)

A standard programming language interface used to connect to a variety of data sources. This is usually accessed through Control Panel, where data source names (DSNs) can be assigned to use specific ODBC drivers.

OLE DB

A set of interfaces that expose data from a variety of sources using COM. OLE DB interfaces provide applications with uniform access to data stored in diverse information sources. These interfaces support the amount of DBMS functionality appropriate to the data source, enabling it to share its data. See also COM.

optimistic locking

A type of locking in which the data page containing one or more records, including the record being edited, is unavailable to other users only while the record is being updated by the Update method, but is available before and after the call to Update.

Optimistic locking is used when the Recordset object is opened with the LockType parameter or property set to adLockOptimistic or adLockBatchOptimistic. See also pessimistic locking.

ordinal value

The numeric location of an item within an order. In an ADO collection, the ordinal value of the first item is zero (0). The next item is one (1), and so on.

Return to top

P

parameterized command

A query or command that allows you to set parameter values before the command is executed. For example, a SQL string can be parameterized by embedding parameter markers in the SQL string (designated by the '?' character). The application then specifies values for each parameter and executes the command.

parent

The controlling side of a hierarchical relationship. In a hierarchical structure, a parent has one or more child nodes directly beneath it in the hierarchy. See also parent-alias, parent-child relationship, child.

parent-alias

An alias that refers to the parent. See also alias, parent.

parent-child relationship

A relationship in a hierarchical structure in which the parent is one level higher and directly associated with one or more children. A child is one level lower and must have one parent. See also parent, child.

persist

To save data in a permanent state, such as saving a Recordset to a file.

pessimistic locking

A type of locking in which the page containing one or more records, including the record being edited, is unavailable to other users to ensure that an update will be made. Pessimistic locking behavior is defined by the OLE DB provider. Typically, records are locked upon editing and remain unavailable until the Update method has completed.

Pessimistic locking is enabled when the Recordset object is opened with the LockType parameter or property set to adLockPessimistic. See also optimistic locking.

pooling

A performance optimization based on using collections of pre-allocated resources, such as objects or database connections. It is more efficient to draw an existing resource from the pool than to create a new resource.

ProgID (programmatic identifier)

A unique name mapped to the Windows registry by a COM application. The ProgID for an ADO Connection is "ADODB.Connection". See also CLSID, COM.

proxy

An interface-specific object that provides the parameter marshaling and communication required for a client to call an application object that is running in a different execution environment, such as on a different thread or in another process. The proxy is located with the client and communicates with a corresponding stub that is located with the application object that is being called. See also stub.

Return to top

R

relative URL

A partially qualified URL that specifies a resource on the Internet or an intranet whose location is relative to a starting point specified by an absolute URL or equivalent ADO Connection object. In effect, the concatenated absolute and relative URLs consitute a complete URL. See also URL and absolute URL.

remote data source

A data source that exists on a another computer, rather than on the local system (where the client application runs).

resource record

A record from a document source provider that contains fields for the definition and description of a folder or document. The document itself is not contained in the resource record but typically can be accessed by the default stream or a field in the resource record containing a URL. See also document source provider, default stream, URL.

root

The top level in a hierarchical tree structure. The root node has no parents, but may have children. See also hierarchy, tree, parent, child.

rowset

A set of rows from a data source, all having the same field schema. A rowset can represent all or some fields from a table. A rowset can also represent a virtual table, created by a query or a join of two or more tables. In ADO, rowsets are represented by Recordset objects.

Return to top

S

schema

A description of a database to the database management system (DBMS), typically generated using the data definition language provided by the DBMS. A schema defines attributes of the database, such as tables, columns, and properties.

scope

The range of reference for an object or variable or a range of records in a view or table. For example, local variables can be referenced only within the procedure in which they were defined. Public variables are accessible from anywhere in the application. Objects, such as the current database, are in scope if they are in the defined search path. Record ranges can be specified with a Scope clause in many commands.

service provider

Software that encapsulates a service by producing and consuming data, augmenting features in your ADO applications. It is a provider that does not directly expose data, rather it provides a service, such as query processing. The service provider may process data provided by a data provider. See also data provider.

shaped Recordset

A Recordset whose columns have been specifically defined to contain not just data, but also references (called chapters) to other Recordset objects and/or computed values based on other Recordset objects.

sibling

Any two or more nodes in a hierarchical structure that are on the same level in the hierarchy. The root node in a hierarchy has no siblings.

stored procedure

A precompiled collection of code such as SQL statements and optional control-of-flow statements stored under a name and processed as a unit. Stored procedures are stored within a database; they can be executed with one call from an application and allow user-declared variables, conditional execution, and other powerful programming features.

stub

An interface-specific object that provides the parameter marshaling and communication required for an application object to receive calls from a client that is running in a different execution environment, such as on a different thread or in another process. The stub is located with the application object and communicates with a corresponding proxy that is located with the client that calls it. See also proxy.

sub-node

See child.

synchronous operation

An operation initiated by code that completes before the next operation may start. See also asynchronous operation.

Return to top

T-W

tree

A structure representing a hierarchical relationship between elements (nodes). There is one node at the top level of a tree (the root). Underneath the root, there can be multiple children. Each child may in turn be the parent of other children, thus branching like a tree. A folder containing documents and other folders is a typical example of a tree structure. See also hierarchy, node, root, child, parent.

URL (Uniform Resource Locator)

Specifies the location of a resource residing on the Internet or an intranet. A complete URL consists of a scheme (such as FTP, HTTP, mailto, file, and so on), followed by a colon, a server name, and the full path of a resource (such as a document, graphic, or other file). Some examples of URLs are:

http://www.domain.com/default.html
ftp://ftp.server.somewhere/ftp.file

ftp://ftp.server.somewhere/ftp.file
file://Server/Share/File.doc

See also absolute URL and relative URL.

Web server

A computer that provides Web services and pages to intranet and Internet users.

Return to top


In operator without (). (Error 2429)

 Copy code hover
[image]

In operator without (). (Error 2429)
Send feedback

When coding an SQL statement that includes the In operator, you must surround the list of items to test with parentheses. For example, to see if a value is one of a set of values, you could use the following code in the WHERE clause of an SQL query:

SQL Copy code Copy code
WHERE Region In ('TX', 'CA', 'WA')

This code tests to see if the Region field contains any of the above abbreviations, which represent Texas, California, and Washington.


Database.Version Property (DAO)

 Copy code hover
[image]

Database.Version Property (DAO)
Send feedback

In a Microsoft Access workspace, returns the vesion of the Microsoft Jet or Microsoft Access database engine that created the database. Read-only String.

Syntax

expression .Version

expression A variable that represents a Database object.

Remarks

The return value is a String that evaluates to a version number, formatted as follows.

  • Microsoft Access workspace represents the version number in the form "major.minor". For example, "3.0". The product version number consists of the version number (3), a period, and the release number (0).

The following table shows which version of the database engine was included with various versions of Microsoft products.

Database Engine | Version (year released) | Microsoft Access | Microsoft Visual Basic | Microsoft Excel | Microsoft Visual C++
Microsoft Jet | 1.0 (1992) | 1.0 | N/A | N/A | N/A
Microsoft Jet | 1.1 (1993) | 1.1 | 3.0 | N/A | N/A
Microsoft Jet | 2.0 (1994) | 2.0 | N/A | N/A | N/A
Microsoft Jet | 2.5 (1995) | N/A | 4.0 (16-bit) | N/A | N/A
Microsoft Jet | 3.0 (1995) | '95 (7.0) | 4.0 (32-bit) | '95 (7.0) | 4.x
Microsoft Jet | 3.5 (1996) | '97 (8.0) | 5.0 | '97 (8.0) | 5.0
Microsoft Jet | 4.0 (2000) | 2000 (9.0) |  | 2000 (9.0) |
Microsoft Access database engine | 12.0 (2007) | 2007 |  |  |


ADO Collections Reference

 Copy code hover
[image]

ADO Collections Reference
Send feedback

In this section

  • ADO Collections

  • Errors Collection (ADO) Reference

  • Fields Collection (ADO) Reference

  • Parameters Collection (ADO) Reference

  • Properties Collection (ADO) Reference


SubmitChanges Method Example (VBScript)

 Copy code hover
[image]

SubmitChanges Method Example (VBScript)
Send feedback

The following code fragment shows how to use the SubmitChanges method with an RDS.DataControl object.

To test this example, cut and paste this code into a normal ASP document and name it SubmitChangesCtrlVBS.asp. ASP script will identify your server.

VBS Copy code Copy code
<!-- BeginCancelUpdateVBS --><%@Language=VBScript%>
<%'Option Explicit%><% 'use the following META tag instead of adovbs.inc%>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" --><HTML>
<HEAD><META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE></HEAD>
<BODY><CENTER>
<H1>Remote Data Service</H1><H2>SubmitChanges and CancelUpdate Methods</H2>
<% ' to integrate/test this code replace the Server property value and' the Data Source value in the Connect property with appropriate values%>
<HR><OBJECT ID=RDS classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" HEIGHT=1 WIDTH=1></OBJECT>
<SCRIPT Language="VBScript">
'set RDS properties for control just created
RDS.Server = "http://<%=Request.ServerVariables("SERVER_NAME")%>"RDS.SQL = "Select * from Employees"
RDS.Connect = "Provider='sqloledb';Integrated Security='SSPI';Initial Catalog='Northwind';"RDS.Refresh
</SCRIPT>
<TABLE DATASRC=#RDS><THEAD>
<TR ID="ColHeaders"><TH>ID</TH>
<TH>FName</TH><TH>LName</TH>
<TH>Title</TH><TH>Hire Date</TH>
<TH>Birth Date</TH><TH>Extension</TH>
<TH>Home Phone</TH></TR>
</THEAD><TBODY>
<TR><TD> <INPUT DATAFLD="EmployeeID" size=4> </TD>
<TD> <INPUT DATAFLD="FirstName" size=10> </TD><TD> <INPUT DATAFLD="LastName" size=10> </TD>
<TD> <INPUT DATAFLD="Title" size=10> </TD><TD> <INPUT DATAFLD="HireDate" size=10> </TD>
<TD> <INPUT DATAFLD="BirthDate" size=10> </TD><TD> <INPUT DATAFLD="Extension" size=10> </TD>
<TD> <INPUT DATAFLD="HomePhone" size=8> </TD></TR>
</TBODY></TABLE>
<HR><INPUT TYPE=button NAME="SubmitChange" VALUE="Submit Changes">
<INPUT TYPE=button NAME="CancelChange" VALUE="Cancel Update"><BR>
<H4>Alter a current entry on the grid. Move off that Row. <BR>Submit the Changes to your DBMS or cancel the updates. </H4>
</CENTER><SCRIPT Language="VBScript">
Sub SubmitChange_OnClick
msgbox "Changes will be made"RDS.SubmitChanges
RDS.Refresh
End Sub
Sub CancelChange_OnClick
msgbox "Changes will be cancelled"RDS.CancelUpdate
RDS.Refresh
End Sub-->
</SCRIPT>

</BODY></HTML>
<!-- EndCancelUpdateVBS -->


Shape Commands in General (ADO)

 Copy code hover
[image]

Shape Commands in General (ADO)
Send feedback

In this section

  • Shape Commands in General

  • Aggregate Functions, the CALC Function, and the NEW Keyword

  • Issuing Commands to the Underlying Data Provider


Disk or network error. (Error 3043)

 Copy code hover
[image]

Disk or network error. (Error 3043)
Send feedback

An internal disk or drive failure prevents reading from or writing to the disk.

Possible causes:

  • You tried to use a network drive, and the network is temporarily busy, or you are no longer connected to the network. Check the network connection, and then try the operation again.

  • The disk or drive has failed.


ActiveCommand Property (ADO)

 Copy code hover
[image]

ActiveCommand Property (ADO)
Send feedback

Indicates the Command object that created the associated Recordset object.

Return Value

Returns a Variant that contains a Command object. Default is a null object reference.

Remarks

The ActiveCommand property is read-only.

If a Command object was not used to create the current Recordset, then a Null object reference is returned.

Use this property to find the associated Command object when you are given only the resulting Recordset object.


Error Trapping

 Copy code hover
[image]

Error Trapping
Send feedback

You can use the On Error GoTo statement to trap errors and direct procedure flow to the location of error-handling statements within a procedure. For example, the following statement directs the flow to the label line:

Copy code Copy code
On Error GoTo ErrorHandler

Be sure to give each error handler label in a procedure a unique name that will not conflict with any other element in the procedure, and make sure you append a colon to the name. Within the procedure, place the Exit Sub or Exit Function statement in front of the error handler label so that the procedure doesn't run the error-checking code if no error occurs.

Copy code Copy code
Sub CausesAnError()
    ' Direct procedure flow.
    On Error GoTo ErrorHandler
    ' Raise division by zero error.
    Err.Raise 11
    Exit Sub

ErrorHandler:
    ' Display error information.
    MsgBox "Error number " & Err.Number & ": " & Err.Description
    ' Resume with statement following occurrence of error.
    Resume Next
End Sub

The Raise method of the Err object generates the specified error. The Number property of the Err object returns the number corresponding to the most recent run-time error; the Description property returns the corresponding message text for a given error.

Note Note

  • In versions 1.x and 2.0 of Microsoft Access, you might have used the Error statement to generate the error, the Err function to return the error number, and the Error function to return a description of the error. Existing error-handling code that relies on the Error statement and the Error function will continue to work. However, it's better to use the Err object and its properties and methods when writing new code.

  • Versions 1.x and 2.0 of Microsoft Access returned only one error for all Automation, (formerly called OLE Automation) errors. The COM component application that generated the error now returns the same error information that you would receive if you were working in that application. You may need to rewrite existing error-handling code to handle new Automation errors properly.

  • If you wish to return the descriptive string associated with a Microsoft Access error or a Data Access Objects (DAO) error, but the error has not actually occurred in your code, you can use the AccessError method to return the string.


CompareBookmarks Method Example (VC++)

 Copy code hover
[image]

CompareBookmarks Method Example (VC++)
Send feedback

This example demonstrates the CompareBookmarks method. The relative value of bookmarks is seldom needed unless a particular bookmark is somehow special.

Designate a random row of a Recordset derived from the Authors table as the target of a search. Then display the position of each row relative to that target.

Copy code Copy code

// BeginCompareBookmarksCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>
#include <time.h>
#include <stdlib.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void CompareBookMarksX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 CompareBookMarksX();

 printf("Press any key to continue...");
 getch();
 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// CompareBookMarksX Function //
// //
//////////////////////////////////////////////////////////

void CompareBookMarksX(void)
{
 HRESULT hr = S_OK;

 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstAuthors = NULL;
 _variant_t vTarget;
 _bstr_t strAns;
 _bstr_t strTitle;
 strTitle = "CompareBookmarks Example";
 try
 {
 TESTHR(pRstAuthors.CreateInstance(__uuidof(Recordset)));

 pRstAuthors->Open("SELECT * FROM authors ORDER BY au_id", strCnn,
 adOpenStatic, adLockReadOnly, adCmdText);

 long count = pRstAuthors->RecordCount;
 printf("Rows in the Recordset = %d\n", count);
 if (count == 0)
 exit(1); //Exit if an empty recordset

 srand( (unsigned)time( NULL ) ); //Randomize

 count = int(rand() % (count-1)); //Get position between 1 and count-1
 if(!count) {count++;};

 printf("Randomly chosen row position = %d\n", count);

 _variant_t vtBookMark = (short)adBookmarkFirst;

 pRstAuthors->Move(count,vtBookMark); //Move row to random position

 vTarget = pRstAuthors->Bookmark; //Remember the mystery row.
 count = 0;
 long intLineCnt = 3;
 pRstAuthors->MoveFirst();

 while (!(pRstAuthors->EndOfFile)) //Loop through recordset
 {
 intLineCnt++;
 if (intLineCnt%20 == 0)
 {
 printf("\nPress any key to continue...\n");
 getch();
 }
 long result = pRstAuthors->CompareBookmarks(
 pRstAuthors->Bookmark, vTarget);

 if (result == adCompareNotEqual)
 printf("Row %d: Bookmarks are not equal. %d\n", count, result);
 else if (result == adCompareNotComparable)
 printf("Row %d: Bookmarks are not comparable.\n", count);
 else
 {
 switch(result)
 {
 case adCompareLessThan:
 strAns = "less than";
 break;
 case adCompareEqual:
 strAns = "equal to";
 break;
 case adCompareGreaterThan:
 strAns = "greater than";
 break;
 default:
 strAns = "in error comparing to";
 break;
 }
 printf ("Row position %d is %s the target.\n",
 count,(LPCSTR)strAns);
 }
 count++;
 pRstAuthors->MoveNext();
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstAuthors->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 if (pRstAuthors)
 if (pRstAuthors->State == adStateOpen)
 pRstAuthors->Close();
}

//////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
//////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n", pErr->Number,
 pErr->Description);
 }
 }
}

//////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
//////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndCompareBookmarksCpp


Reference.FullPath Property (Access)

 Copy code hover
[image]

Reference.FullPath Property (Access)
See also Send feedback

Published: July 16, 2012

The FullPath property returns a string containing the path and file name of the referenced type library.

Syntax

expression .FullPath

expression A variable that represents a Reference object.

Remarks

If the IsBroken property setting of a Reference object is True, reading the FullPath property generates an error.

Example

The following example prints the value of the FullPath, GUID, IsBroken, Major, and Minor properties for each Reference object in the References collection:

VBA Copy code Copy code
Sub ReferenceProperties()
 Dim ref As Reference

 ' Enumerate through References collection.
 For Each ref In References
 ' Check IsBroken property.
 If ref.IsBroken = False Then
 Debug.Print "Name: ", ref.Name
 Debug.Print "FullPath: ", ref.FullPath
 Debug.Print "Version: ", ref.Major & "." & ref.Minor
 Else
 Debug.Print "GUIDs of broken references:"
 Debug.Print ref.GUID
 EndIf
 Next ref
End Sub

See also

Concepts

Reference Object

Other resources

Reference Object Members


UniqueValues Property

 Copy code hover
[image]

UniqueValues Property
Send feedback

Published: July 16, 2012

You can use the UniqueValues property when you want to omit records that contain duplicate data in the fields displayed in Datasheet view. For example, if a query's output includes more than one field, the combination of values from all fields must be unique for a given record to be included in the results.

Note Note

The UniqueValues property applies only to append and make-table action queries and select queries.

Setting

The UniqueValues property uses the following settings.

Setting | Description
Yes | Displays only the records in which the values of all fields displayed in Datasheet view are unique.
No | (Default) Displays all records.

You can set the UniqueValues property in the query's property sheet or in SQL view of the Query window.

Note Note

You can set this property when you create a new query by using an SQL statement. The DISTINCT predicate corresponds to the UniqueValues property setting. The DISTINCTROW predicate corresponds to the UniqueValues property setting.

Remarks

When you set the UniqueValues property to Yes, the results of the query aren't updatable and won't reflect subsequent changes made by other users.

The UniqueValues and UniqueRecords properties are related in that only one of them can be set to Yes at a time. When you set the UniqueValues property to Yes, for example, Microsoft Access automatically sets the UniqueRecords property to No. You can, however, set both of them to No. When both properties are set to No, all records are returned.

If you want to count the number of instances of a value in a field, create a totals query.

Example

The SELECT statement in this example returns a list of the countries/regions in which there are customers. Because there may be many customers in each country/region, many records could have the same country/region in the Customers table. However, each country/region is represented only once in the query results.

This example uses the Customers table, which contains the following data.

Country/Region | Company name
Brazil | Familia Arquibaldo
Brazil | Gourmet Lanchonetes
Brazil | Hanari Carnes
France | Du monde entier
France | Folies gourmandes
Germany | Frankenversand
Ireland | Hungry Owl All-Night Grocers

This SQL statement returns the countries/regions in the following table:

Copy code Copy code
SELECT DISTINCT Customers.Country
FROM Customers;

Countries/Regions returned

Brazil

France

Germany

Ireland


DBEngine.DefaultUser Property (DAO)

 Copy code hover
[image]

DBEngine.DefaultUser Property (DAO)
Send feedback

Sets the user name used to create the default Workspace when it is initialized. Read/write String.

Syntax

expression .DefaultUser

expression An expression that returns a DBEngine object.

Remarks

The setting for DefaultUser is a String data type. It can be 1-20 characters long in Microsoft Access workspaces and it can include alphabetic characters, accented characters, numbers, spaces, and symbols except for: " (quotation marks), / (forward slash), \ (backslash), [ ] (brackets), : (colon), | (pipe), < (less-than sign), > (greater-than sign), + (plus sign), = (equal sign), ; (semicolon), , ( comma), ? (question mark), * (asterisk), leading spaces, and control characters (ASCII 00 to ASCII 31).

Note Note

Use strong passwords that combine upper- and lowercase letters, numbers, and symbols. Weak passwords don't mix these elements. Strong password: Y6dh!et5. Weak password: House27. Use a strong password that you can remember so that you don't have to write it down.

By default, the DefaultUser property is set to "admin" and the DefaultPassword property is set to a zero-length string ("").

User names aren't usually case-sensitive; however, if you're re-creating a user account that was deleted or created in a different workgroup, the user name must be an exact case-sensitive match of the original name. Passwords are case-sensitive.

Typically, you use the CreateWorkspace method to create a Workspace object with a given user name and password. However, for backward compatibility with earlier versions and for convenience when you don't implement a secured database, the Microsoft Access database engine automatically creates a default Workspace object when needed if one isn't already open. In this case, the DefaultUser and DefaultPassword property values define the user and password for the default Workspace object.

For this property to take effect, you should set it before calling any DAO methods.


Access Forms How Do I...

 Copy code hover
[image]

Access Forms How Do I...
Send feedback

This page links to help on widely used form-related tasks. To view other categories of popular tasks covered in Help, see How Do I... in Access.

User Input

  • How to: Add a Value to a Bound Combo Box

    • Describes how to add a use the NotInList event to add a new value to a bound combo box.

  • How to: Determine Whether The Current Record is a New Record In a Form

    • Illustrates how to use the NewRecord property to determine if the current record is a new record.

  • How to: Display a Custom Dialog Box When the User Deletes a Record

    • Describes how to use the BeforeDelConfirm event procedure to display a custom dialog box when the user deletes a record.

  • How to: Perform Simple Data Validation Checks When Editing a Record in a Form

    • Describes how to use the BeforeUpdate event of a form or a control to perform validation checks on data entered into a form or control.

  • How to: Prompt a User Before Saving a Record

    • Describes how to ask a user for confirmation before saving a record.

  • How to: Use Numeric Criteria from a Control on a Form

    • Describes how to specify numeric criteria coming from a control on a form.

  • How to: Use Textual Criteria from a Control on a Form

    • Describes how to specify textual criteria coming from a control on a form.

  • How to: Use User Input to Build Filter Criteria

    • Describes how to build criteria based on user input.

Controls

  • How to: Add "(All)" to a Combo Box or List Box

    • Describes how to add an (All) entry at the top of a combo box.

  • How to: Allow Users to Add Items to an Unbound Combo Box

    • Describes how to use the NotInList event to add a new value to an unbound combo box.

  • How to: Assign a Control a Value From a Table

    • Describes how to use the DLookup function to display the value of a field that is not in the record source for your form or report.

  • How to: Call Procedures in a Subform or Subreport

    • Describes how to call a procedure that is stored in a subform or subreport form the main form or report.

  • How to: Hide a Subform if the Main Form Contains No Records

    • Describes how to hide a subform when its main form contains no records.

  • How to: Prevent the Accidental Erasure of Data When Moving Between Controls on a Form

    • Describes how to avoid erasing data accidentally when moving between controls.

  • How to: Refer to Tab Control Objects in VBA

    • Describes how to use tab controls on a form.

  • How to: Set Form, Report, and Control Properties in Code

    • Describes how to set properties of forms, reports, and controls.

Design

  • How to: Apply a Custom Ribbon to a Form or Report

    • Describes how to display a custom ribbon when a particular form or report is opened.

  • How to: Bind a Form to an ADO Recordset

    • Describes how to set a form's Recordset property to an open ADO Recordset object.

  • How to: Create a DAO Recordset From a Form

    • Describes how to create a Recordset object based on an Access form.

  • How to: Create Multiple Instances of a Form

    • Illustrates how to open multiple copies of the same form.

  • How to: Synchronize a DAO Recordset's Record with a Form's Current Record

    • Describes how to synchronize a recordset's record with the form's current record.

  • How to: Synchronize Two Combo Boxes on a Form

    • Describes how to limit the choices in a combo box when selecting an item in another combo box.

  • How to: Use Date and Time Criteria from a Control on a Form

    • Describes how to change the criteria argument for an operation based on a user's decision.

Events

  • How to: Apply a Filter When Opening a Form or Report

    • Describes several techniques for filtering a form or report as it opens.

  • How to: Cancel an Event

    • Lists the events that can be canceled programmatically.

  • How to: Cancel the Deletion of a Record by Using Custom Criteria

    • Illustrates how to prevent the deletion of a record based on custom criteria.

  • How to: Change the Filter or Sort Order of a Form or Report

    • Describes how to change the filter or sort order of a form or report in response to users' actions.

  • How to: Disable PAGE UP and PAGE DOWN Keys in a Form

    • Illustrates how to use a form's KeyDown event to disable the use of the PAGE UP and PAGE DOWN keys in the form.

  • How to: Prompt a User Before Closing a Form

    • Describes how to ask a user for confirmation before closing a form.

  • How to: Suspend Code Execution Until a Pop-Up Form is Closed

    • Describes how to use the OpenForm method to suspend code until a pop-up form is closed.

Printing

  • How to: Programmatically Retrieve Printer Capabilities

    • Describes how to use the Microsoft Windows API to determine a printer's capabilities.

  • How to: Retrieve a List of Installed Printers

    • Describes how to use the Printers collection to determine the installed printers.

  • How to: Work with Form and Report Printer Settings

    • Describes how to set or retrieve printer settings for a specific form or report.

  • How Do I... in Access


Group Macro Statement

 Copy code hover
[image]

Group Macro Statement
Send feedback

The Group statement enables you to specify a block of actions within a macro that you can expand or collapse.

Setting

The Group action has the following arguments.

Argument | Required | Description
Description | No | A string that appears as the title of a group when it is collapsed.

Remarks

The Group statment does not define a region of a macro that can be executed separately. Use the Submacro statment to define a set of actions to be executed separately in the Macro Designer window.


Join expression not supported. (Error 3296)

 Copy code hover
[image]

Join expression not supported. (Error 3296)
Send feedback

Possible causes:

  • Your SQL statement contains multiple joins in which the results of the query can differ, depending on the order in which the joins are performed. You may want to create a separate query to perform the first join, and then include that query in your SQL statement.

  • The ON statement in your JOIN operation is incomplete or contains too many tables. You may want to put your ON expression in a WHERE clause.


AppendChunk and GetChunk Methods Example (VB)

 Copy code hover
[image]

AppendChunk and GetChunk Methods Example (VB)
Send feedback

This example uses the AppendChunk and GetChunk methods to fill an image field with data from another record.

Copy code Copy code

'BeginAppendChunkVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 'recordset and connection variables
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim rstPubInfo As ADODB.Recordset
 Dim strSQLPubInfo As String
 'record variables
 Dim strPubID As String
 Dim strPRInfo As String
 Dim lngOffset As Long
 Dim lngLogoSize As Long
 Dim varLogo As Variant
 Dim varChunk As Variant
 Dim strMsg As String

 Const conChunkSize = 100

 ' Open a connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open the pub_info table with a cursor that allows updates
 Set rstPubInfo = New ADODB.Recordset
 strSQLPubInfo = "pub_info"
 rstPubInfo.Open strSQLPubInfo, Cnxn, adOpenKeyset, adLockOptimistic, adCmdTable

 ' Prompt for a logo to copy
 strMsg = "Available logos are : " & vbCr & vbCr
 Do While Not rstPubInfo.EOF
 strMsg = strMsg & rstPubInfo!pub_id & vbCr & _
 Left(rstPubInfo!pr_info, InStr(rstPubInfo!pr_info, ",") - 1) & _
 vbCr & vbCr
 rstPubInfo.MoveNext
 Loop

 strMsg = strMsg & "Enter the ID of a logo to copy:"
 strPubID = InputBox(strMsg)

 ' Copy the logo to a variable in chunks
 rstPubInfo.Filter = "pub_id = '" & strPubID & "'"
 lngLogoSize = rstPubInfo!logo.ActualSize
 Do While lngOffset < lngLogoSize
 varChunk = rstPubInfo!logo.GetChunk(conChunkSize)
 varLogo = varLogo & varChunk
 lngOffset = lngOffset + conChunkSize
 Loop

 ' Get data from the user
 strPubID = Trim(InputBox("Enter a new pub ID" & _
 " [must be > 9899 & < 9999]:"))

 strPRInfo = Trim(InputBox("Enter descriptive text:"))

 ' Add the new publisher to the publishers table to avoid
 ' getting an error due to foreign key constraint
 Cnxn.Execute "INSERT publishers(pub_id, pub_name) VALUES('" & _
 strPubID & "','Your Test Publisher')"

 ' Add a new record, copying the logo in chunks
 rstPubInfo.AddNew
 rstPubInfo!pub_id = strPubID
 rstPubInfo!pr_info = strPRInfo

 lngOffset = 0 ' Reset offset
 Do While lngOffset < lngLogoSize
 varChunk = LeftB(RightB(varLogo, lngLogoSize - lngOffset), _
 conChunkSize)
 rstPubInfo!logo.AppendChunk varChunk
 lngOffset = lngOffset + conChunkSize
 Loop
 rstPubInfo.Update

 ' Show the newly added data
 MsgBox "New record: " & rstPubInfo!pub_id & vbCr & _
 "Description: " & rstPubInfo!pr_info & vbCr & _
 "Logo size: " & rstPubInfo!logo.ActualSize

 ' Delete new records because this is a demo
 rstPubInfo.Requery
 Cnxn.Execute "DELETE FROM pub_info " & _
 "WHERE pub_id = '" & strPubID & "'"

 Cnxn.Execute "DELETE FROM publishers " & _
 "WHERE pub_id = '" & strPubID & "'"

 ' clean up
 rstPubInfo.Close
 Cnxn.Close
 Set rstPubInfo = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstPubInfo Is Nothing Then
 If rstPubInfo.State = adStateOpen Then rstPubInfo.Close
 End If
 Set rstPubInfo = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndAppendChunkVB


Form.AllowPivotTableView Property (Access)

 Copy code hover
[image]

Form.AllowPivotTableView Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Boolean indicating whether the specified form may be viewed in PivotTable View. True if PivotTable View is allowed. Read/write.

Syntax

expression .AllowPivotTableView

expression A variable that represents a Form object.

Remarks

Use the AllowDatasheetView , AllowFormView , AllowPivotChartView, or AllowPivotTableView properties to control which views are allowed for a form.

Example

The following example makes PivotTable View valid for the specified form and then opens the form in PivotTable View.

VBA Copy code Copy code
Forms(0).AllowPivotTableView = True
DoCmd.OpenForm FormName:=Forms(0).Name, View:=acFormPivotTable

See also

Concepts

Form Object

Other resources

Form Object Members


OptionGroup.BorderShade Property (Access)

 Copy code hover
[image]

OptionGroup.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents an OptionGroup object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens BorderColor by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Hyperlink.AddToFavorites Method (Access)

 Copy code hover
[image]

Hyperlink.AddToFavorites Method (Access)
See also Send feedback

Published: July 16, 2012

The AddToFavorites method adds a hyperlink address to the Favorites folder.

Syntax

expression .AddToFavorites

expression A variable that represents a Hyperlink object.

Return Value

Nothing

Remarks

When applied to a Control object, the AddToFavorites method adds the hyperlink address contained in a control to the Favorites folder.

Example

The following example sets the HyperlinkAddress property of a command button. When the user clicks the command button, the address is added to the Favorites folder by using the AddToFavorites method.

To try this example, create a new form and add a command button named Command0. Paste the following code into the form's module. Switch to Form view and click the command button.

VBA Copy code Copy code
Private Sub Form_Load()
 Me!Command0.HyperlinkAddress = "http://www.microsoft.com/"
End SubPrivate Sub Command0_Click()
 Me!Command0.Hyperlink.AddToFavorites
End Sub

See also

Concepts

Hyperlink Object

Other resources

Hyperlink Object Members


StayInSync Property Example (VC++)

 Copy code hover
[image]

StayInSync Property Example (VC++)
Send feedback

This example demonstrates how the StayInSync property facilitates accessing rows in a hierarchical Recordset.

The outer loop displays each author's first and last name, state, and identification. The appended Recordset for each row is retrieved from the Fields collection and automatically assigned to rstTitleAuthor by the StayInSync property whenever the parent Recordset moves to a new row. The inner loop displays four fields from each row in the appended recordset.

Copy code Copy code

// BeginStayInSyncCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void StayInSyncX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 StayInSyncX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// StayInSyncX Function //
// //
//////////////////////////////////////////////////////////
void StayInSyncX(void)
{
 HRESULT hr = S_OK;

 // Define string variables.
 _bstr_t strCnn("Provider='MSDataShape';"
 "Data Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _ConnectionPtr pConnection = NULL;
 _RecordsetPtr pRst = NULL;
 _RecordsetPtr pRstTitleAuthor = NULL;

 try
 {
 TESTHR(pRstTitleAuthor.CreateInstance(__uuidof(Recordset)));

 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));

 TESTHR(pRst.CreateInstance(__uuidof(Recordset)));

 // Open connection.
 pConnection->Open (strCnn, "", "", adConnectUnspecified);
 pRst->PutStayInSync(true);

 // Open recordset with names from Author & titleauthor table.
 pRst->Open("SHAPE {select * from authors} "
 "APPEND ({select * from titleauthor}"
 "RELATE au_id TO au_id) AS chapTitleAuthor",
 _variant_t((IDispatch*)pConnection,true),
 adOpenStatic, adLockReadOnly, adCmdText);

 pRstTitleAuthor = pRst->GetFields()->GetItem("chapTitleAuthor")->
 Value;
 int intLineCnt=0;
 while(!(pRst->EndOfFile))
 {
 printf("\n%s %s %s %s\n", (LPCSTR)(_bstr_t)pRst->
 Fields->GetItem("au_fname")->Value,
 (LPCSTR)(_bstr_t)pRst->Fields->GetItem("au_lname")->Value,
 (LPCSTR)(_bstr_t)pRst->Fields->GetItem("state")->Value,
 (LPCSTR)(_bstr_t)pRst->Fields->GetItem("au_id")->Value);
 intLineCnt++;

 if (intLineCnt%15 == 0)
 {
 printf("\nPress any key to continue...\n");
 getch();
 }

 _variant_t vIndex;
 while(!(pRstTitleAuthor->EndOfFile))
 {
 vIndex = (short) 0;
 printf("%s ",(LPCSTR)(_bstr_t)pRstTitleAuthor->
 Fields->Item[&vIndex]->Value);
 vIndex = (short) 1;
 printf("%s ",(LPCSTR)(_bstr_t)pRstTitleAuthor->
 Fields->Item[&vIndex]->Value);
 vIndex = (short) 2;
 printf("%s ",(LPCSTR)(_bstr_t)pRstTitleAuthor->
 Fields->Item[&vIndex]->Value);
 vIndex = (short) 3;
 printf("%s\n",(LPCSTR)(_bstr_t)pRstTitleAuthor->
 Fields->Item[&vIndex]->Value);
 intLineCnt++;

 if (intLineCnt%15 == 0)
 {
 printf("\nPress any key to continue...\n");
 getch();
 }
 pRstTitleAuthor->MoveNext();
 }
 pRst->MoveNext();
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 PrintProviderError(pConnection);
 PrintComError(e);
 }

 // Clean up objects before exit.
 if (pRst)
 if (pRst->State == adStateOpen)
 pRst->Close();
 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

//////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
//////////////////////////////////////////////////////////
void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

//////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
//////////////////////////////////////////////////////////
void PrintComError(_com_error &e)
{

 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);

}
// EndStayInSyncCpp


Line.SpecialEffect Property (Access)

 Copy code hover
[image]

Line.SpecialEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.

Syntax

expression .SpecialEffect

expression A variable that represents a Line object.

Remarks

The SpecialEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | 0 | The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised | 1 | The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken | 2 | The object has a shadow on the top and left and a highlight on the bottom and right.
Etched | 3 | The object has a sunken line surrounding the control.
Shadowed | 4 | The object has a shadow below and to the right of the control.
Chiseled | 5 | The object has a sunken line below the control.

The SpecialEffect property setting affects related property settings for the BorderStyle , BorderColor , and BorderWidth properties. For example, if the SpecialEffect property is set to Raised, the settings for the BorderStyle, BorderColor, and BorderWidth properties are ignored. In addition, changing or setting the BorderStyle, BorderColor, and BorderWidth properties may cause Microsoft Access to change the SpecialEffect property setting to Flat.

Example

The following example sets the appearance of the text box "OrganizationName1" on the "Mailing List" form to raised.

VBA Copy code Copy code
Forms("Mailing List").Controls("OrganizationName1").SpecialEffect = 1

See also

Concepts

Line Object

Other resources

Line Object Members


ObjectFrame.Action Property (Access)

 Copy code hover
[image]

ObjectFrame.Action Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Action property in Visual Basic to specify the operation to perform on an OLE object. Read/write Integer.

Syntax

expression .Action

expression A variable that represents an ObjectFrame object.

Remarks

The Action property uses the following settings.

Constant | Description
acOLECreateEmbed (0) | Creates an embedded object. To use this setting, you must first set the control'sOLETypeAllowed property to acOLEEmbedded or acOLEEither. Set the Class property to the type of OLE object you want to create. You can use the SourceDoc property to use an existing file as a template.
acOLECreateLink (1) | Creates a linked OLE object from the contents of a file. To use this setting, you must first set the control's OLETypeAllowed and SourceDoc properties. Set the OLETypeAllowed property to acOLELinked or acOLEEither. The SourceDoc property specifies the file used to create the OLE object. You can also set the control's SourceItem property (for example, to specify a row-and-column range if the object you're creating is a Microsoft Excel worksheet). When you create an OLE object by using this setting, the control displays a metafile graphic image of the file specified by the control's SourceDoc property. If you save the OLE object, only the link information, such as the name of the application that supplied the object and the name of the linked file, is saved because the control contains an image of the data but no source data.
acOLECopy (4) | Copies the object to the Clipboard. When you copy an OLE object to the Clipboard, all the data and link information associated with the object is placed on the Clipboard as well. You can copy both linked and embedded objects onto the Clipboard.
acOLEPaste (5) | Pastes data from the Clipboard to the control. If the paste operation is successful, the control's OLEType property is set to acOLELinked or acOLEEmbedded. If the paste operation isn't successful, the OLEType property is set to acOLENone.
acOLEUpdate (6) | Retrieves the current data from the application that supplied the object and displays that data as a metafile graphic in the control.
acOLEActivate (7) | Opens an OLE object for an operation, such as editing. To use this setting, you must first set the control's Verb property. The Verb property specifies the operation to perform when the OLE object is activated.
acOLEClose (9) | Closes an OLE object and ends the connection with the application that supplied the object. This setting applies to embedded objects only. Using this setting is equivalent to clicking Close on the object's Control menu.
acOLEDelete (10) | Deletes the specified OLE object and frees the associated memory. This setting enables you to explicitly delete an OLE object. Objects are automatically deleted when a form is closed or when the object is updated to a new object. You can't use the Action property to delete a bound OLE object from its underlying table or query.
acOLEInsertObjDlg (14) | Displays the Insert Object dialog box. In Form view or Datasheet view, you display this dialog box to enable the user to create a new object or to link or embed an existing object. You can use the control's OLETypeAllowed property to determine the type of object the user can create (with the constant acOLELinked, acOLEEmbedded, or acOLEEither) by using this dialog box.
acOLEPasteSpecialDlg (15) | Displays the Paste Special dialog box. In Form view or Datasheet view, you display this dialog box to enable the user to paste an object from the Clipboard. The dialog box provides several options, including pasting either a linked or embedded object. You can use the control's OLETypeAllowed property to determine the type of object that can be pasted (with the constant acOLELinked, acOLEEmbedded, or acOLEEither) by using this dialog box.
acOLEFetchVerbs (17) | Updates the list of verbs an OLE object supports. To display the list of verbs, use the ObjectVerbs and ObjectVerbsCount properties.

The Action property isn't available in Design view but can be read or set in other views.

When a control's Enabled property is set to No or its Locked property is set to Yes, you can't use some Action property settings. The following table indicates which settings are allowed or not allowed under these conditions.

Setting | Enabled = No | Locked = Yes
acOLECreateEmbed (0) | Not allowed | Not allowed
acOLECreateLink (1) | Not allowed | Not allowed
acOLECopy (4) | Allowed | Allowed
acOLEPaste (5) | Not allowed | Not allowed
acOLEUpdate (6) | Not allowed | Not allowed
acOLEActivate (7) | Allowed | Allowed
acOLEClose (9) | Not allowed | Allowed
acOLEDelete (10) | Not allowed | Not allowed
acOLEInsertObjDlg (14) | Not allowed | Not allowed
acOLEPasteSpecialDlg (15) | Not allowed | Not allowed
acOLEFetchVerbs (17) | Not allowed | Allowed

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


WebBrowserControl.HorizontalAnchor Property (Access)

 Copy code hover
[image]

WebBrowserControl.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the text box is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2010

Syntax

expression .HorizontalAnchor

expression A variable that represents a WebBrowserControl object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Move Method Example (VBScript)

 Copy code hover
[image]

Move Method Example (VBScript)
Send feedback

This example uses the Move method to position the record pointer, based on user input.

Use the following example in an Active Server Page (ASP).

Use Find to locate the file Adovbs.inc and place it in the directory you plan to use. Cut and paste the following code to Notepad or another text editor, and save it as MoveVBS.asp. You can view the result in any browser.

Try entering a letter or noninteger to see the error handling work.

VBS Copy code Copy code

<!-- BeginMoveVBS -->
<%@ Language=VBScript %>
<%' use this meta tag instead of adovbs.inc%>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->
<HTML>
<HEAD>
<TITLE>ADO Move Methods</TITLE>
<STYLE>
<!--
BODY {
   font-family: "MS SANS SERIF",sans-serif;
    }
.thead1 {
   background-color: #008080;
   font-family: 'Arial Narrow','Arial',sans-serif;
   font-size: x-small;
   color: white;
   }
.tbody {
   text-align: center;
   background-color: #f7efde;
   font-family: 'Arial Narrow','Arial',sans-serif;
   font-size: x-small;
    }
-->
</STYLE>
</HEAD>
<BODY>
<H3>ADO Move Methods</H3>
<% ' to integrate/test this code replace the
   ' Data Source value in the Connection string%>
<%
    ' connection and recordset variables
    Dim Cnxn, strCnxn
    Dim rsCustomers, strSQLCustomers

    ' open connection
    Set Cnxn = Server.CreateObject("ADODB.Connection")
    strCnxn = "Provider='sqloledb';Data Source=" & _
            Request.ServerVariables("SERVER_NAME") & ";" & _
            "Integrated Security='SSPI';Initial Catalog='Northwind';"

    Cnxn.Open strCnxn

     ' create and open Recordset using object refs
    Set rsCustomers = Server.CreateObject("ADODB.Recordset")
    strSQLCustomers = "Customers"

    rsCustomers.ActiveConnection = Cnxn
    rsCustomers.CursorLocation = adUseClient
    rsCustomers.CursorType = adOpenKeyset
    rsCustomers.LockType = adLockOptimistic
    rsCustomers.Source = strSQLCustomers
    rsCustomers.Open

    'Check number of user moves this session and increment by entry
    Session("Clicks") = Session("Clicks") + Request.Form("MoveAmount")
    Clicks = Session("Clicks")
    ' Move to last known recordset position plus amount passed
    rsCustomers.Move CInt(Clicks)

    'Error Handling
    If rsCustomers.EOF Then
        Session("Clicks") = rsCustomers.RecordCount
        Response.Write "This is the Last Record"
        rsCustomers.MoveLast
    ElseIf rsCustomers.BOF Then
        Session("Clicks") = 1
        rsCustomers.MoveFirst
        Response.Write "This is the First Record"
    End If
    %>

    <H3>Current Record Number is <BR>
    <%
    If Session("Clicks") = 0 Then Session("Clicks") = 1
    Response.Write(Session("Clicks") )%> of <%=rsCustomers.RecordCount%></H3>
    <HR>

    <TABLE COLSPAN=8 CELLPADDING=5 BORDER=0>

    <!-- BEGIN column header row for Customer Table-->

    <TR CLASS=thead1>
       <TD>Company Name</TD>
       <TD>Contact Name</TD>
       <TD>City</TD>
    </TR>
        <% 'display%>
        <TR CLASS=tbody>
          <TD> <%= rsCustomers("CompanyName")%> </TD>
          <TD> <%= rsCustomers("ContactName")%></TD>
          <TD> <%= rsCustomers("City")%> </TD>
        </TR>
    </TABLE>

    <HR>
    <Input Type=Button Name=cmdDown  Value="&lt;  ">
    <Input Type=Button Name=cmdUp Value=" &gt;">
    <H5>Click Direction Arrows for Previous or Next Record
    <BR> <BR>

    <FORM Method = Post Action="MoveVbs.asp" Name=Form>
    <TABLE>
        <TR>
           <TD><Input Type="Button" Name=Move Value="Move Amount "></TD>
           <TD></TD>
           <TD><Input Type="Text" Size="4" Name="MoveAmount" Value=0></TD>
        <TR>
    </TABLE>
    Click Move Amount to use Move Method<br>
    Enter Number of Records to Move + or - </H5>    </FORM>
</BODY>

<Script Language = "VBScript">

Sub Move_OnClick
   ' Make sure move value entered is an integer
   If IsNumeric(Document.Form.MoveAmount.Value)Then
      Document.Form.MoveAmount.Value = CInt(Document.Form.MoveAmount.Value)
      Document.Form.Submit
   Else
      MsgBox "You Must Enter a Number", ,"ADO-ASP Example"
      Document.Form.MoveAmount.Value = 0
   End If
End Sub

Sub cmdDown_OnClick
   Document.Form.MoveAmount.Value = -1
   Document.Form.Submit
End Sub

Sub cmdUp_OnClick
   Document.Form.MoveAmount.Value = 1
   Document.Form.Submit
End Sub
</Script>

<%
    ' clean up
    If rsCustomers.State = adStateOpen then
        rsCustomers.Close
    End If
    If Cnxn.State = adStateOpen then
        Cnxn.Close
    End If
%>
</HTML>
<!-- EndMoveVBS -->


Errors

 Copy code hover
[image]

Errors
Send feedback

Any operation involving ADO objects can generate one or more provider errors. As each error occurs, one or more Error objects are placed in the Errors collection of the Connection object. For details about handling warnings and errors in your ADO application, see Chapter 6: Error Handling.

Application errors can be raised by a separate mechanism. For example, in Visual Basic, the Err object will contain application-level errors.


CacheSize Property (ADO)

 Copy code hover
[image]

CacheSize Property (ADO)
Send feedback

Indicates the number of records from a Recordset object that are cached locally in memory.

Settings and Return Values

Sets or returns a Long value that must be greater than 0. Default is 1.

Remarks

Use the CacheSize property to control how many records to retrieve at one time into local memory from the provider. For example, if the CacheSize is 10, after first opening the Recordset object, the provider retrieves the first 10 records into local memory. As you move through the Recordset object, the provider returns the data from the local memory buffer. As soon as you move past the last record in the cache, the provider retrieves the next 10 records from the data source into the cache.

Note Note

CacheSize is based on the Maximum Open Rows provider-specific property (in the Properties collection of the Recordset object). You cannot set CacheSize to a value greater than Maximum Open Rows. To modify the number of rows which can be opened by the provider, set Maximum Open Rows.

The value of CacheSize can be adjusted during the life of the Recordset object, but changing this value only affects the number of records in the cache after subsequent retrievals from the data source. Changing the property value alone will not change the current contents of the cache.

If there are fewer records to retrieve than CacheSize specifies, the provider returns the remaining records and no error occurs.

A CacheSize setting of zero is not allowed and returns an error.

Records retrieved from the cache don't reflect concurrent changes that other users made to the source data. To force an update of all the cached data, use the Resync method.

If CacheSize is set to a value greater than one, the navigation methods (Move, MoveFirst, MoveLast, MoveNext, and MovePrevious) may result in navigation to a deleted record, if deletion occurs after the records were retrieved. After the initial fetch, subsequent deletions will not be reflected in your data cache until you attempt to access a data value from a deleted row. However, setting CacheSize to one eliminates this issue since deleted rows cannot be fetched.


NavigationControl.Change Event (Access)

 Copy code hover
[image]

NavigationControl.Change Event (Access)
See also Send feedback

Published: July 16, 2012

The Change event occurs when the contents of the specified control changes.

Version Information

Version Added: Access 2010

Syntax

expression .Change

expression A variable that represents a NavigationControl object.

Return Value

nothing

Remarks

Examples of this event include entering a character directly in the text box or combo box or changing the control's Text property setting by using a macro or Visual Basic.

Note Note

Setting the value of a control by using a macro or Visual Basic doesn't trigger this event for the control. You must type the data directly into the control, or set the control's Text property.

To run a macro or event procedure when this event occurs, set the OnChange property to the name of the macro or to [Event Procedure].

By running a macro or event procedure when a Change event occurs, you can coordinate data display among controls. You can also display data or a formula in one control and the results in another control.

The Change event doesn't occur when a value changes in a calculated control.

Note Note

A Change event can cause a cascading event. This occurs when a macro or event procedure that runs in response to the control's Change event alters the control's contents — for example, by changing a property setting that determines the control's value, such as the Text property for a text box. To prevent a cascading event:

  • If possible, avoid attaching a Change macro or event procedure to a control that alters the control's contents.

  • Avoid creating two or more controls having Change events that affect each other — for example, two text boxes that update each other.

Changing the data in a text box or combo box by using the keyboard causes keyboard events to occur in addition to control events like the Change event. For example, if you move to a new record and type an ANSI character in a text box in the record, the following events occur in this order:

KeyDown → KeyPress → BeforeInsert → Change → KeyUp

The BeforeUpdate and AfterUpdate events for the text box or combo box control occur after you have entered the new or changed data in the control and moved to another control (or clicked Save Record on the Records menu), and therefore after all of the Change events for the control.

In combo boxes for which the LimitToList property is set to Yes, the NotInList event occurs after you enter a value that isn't in the list and attempt to move to another control or save the record. It occurs after all the Change events for the combo box. In this case, the BeforeUpdate and AfterUpdate events for the combo box don't occur, because Microsoft Access doesn't accept a value that is not in the list.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Connection.Cancel Method (DAO)

 Copy code hover
[image]

Connection.Cancel Method (DAO)
Send feedback

Syntax

expression .Cancel

expression A variable that represents a Connection object.

Remarks

Use the Cancel method to terminate execution of an asynchronous Execute or OpenConnection method call (that is, the method was invoked with the dbRunAsync option). Cancel will return a run-time error if dbRunAsync was not used in the method you're trying to terminate.

An error will occur if, following a Cancel method call, you try to reference the object that would have been created by an asynchronous OpenConnection call (that is, the Connection object from which you called the Cancel method).

Example

This example uses the StillExecuting property and the Cancel method to asynchronously open a Connection object.

VBA Copy code Copy code
Sub CancelConnectionX()

 Dim wrkMain As Workspace
 Dim conMain As Connection
 Dim sngTime As Single

 Set wrkMain = CreateWorkspace("ODBCWorkspace", _
 "admin", "", dbUseODBC)
 ' Open the connection asynchronously.

 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conMain = wrkMain.OpenConnection("Publishers", _
 dbDriverNoPrompt + dbRunAsync, False, _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 sngTime = Timer

 ' Wait five seconds.
 Do While Timer - sngTime < 5
 Loop

 ' If the connection has not been made, ask the user
 ' if she wants to keep waiting. If she does not, cancel
 ' the connection and exit the procedure.
 Do While conMain.StillExecuting

 If MsgBox("No connection yet--keep waiting?", _
 vbYesNo) = vbNo Then
 conMain.Cancel
 MsgBox "Connection cancelled!"
 wrkMain.Close
 Exit Sub
 End If

 Loop

 With conMain
 ' Use the Connection object conMain.
 .Close
 End With

 wrkMain.Close

End Sub


FormatCondition.Operator Property (Access)

 Copy code hover
[image]

FormatCondition.Operator Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Operator property to return the operator value for the conditional format or data validation of a FormatCondition object. Read-only AcFormatConditionOperator.

Syntax

expression .Operator

expression A variable that represents a FormatCondition object.

Remarks

The Operator property's intrinsic constants are used in conjunction with the Expression1 and Expression2 properties and the Add method of the FormatConditions object for conditional formatting and data validation.

See also

Concepts

FormatCondition Object

Other resources

FormatCondition Object Members


DataFactory Customization

 Copy code hover
[image]

DataFactory Customization
Send feedback

Remote Data Service (RDS) provides a way to easily perform data access in a three-tier client/server system. A client data control specifies connection and command string parameters to perform a query on a remote data source, or connection string and Recordset object parameters to perform an update.

The parameters are passed to a server program, which performs the data-access operation on the remote data source. RDS provides a default server program called the RDSServer.DataFactory object. The RDSServer.DataFactory object returns any Recordset object produced by a query to the client.

However, the RDSServer.DataFactory is limited to performing queries and updates. It cannot perform any validation or processing on the connection or command strings.

With ADO, you can specify that the DataFactory work in conjunction with another type of server program called a handler. The handler can modify client connection and command strings before they are used to access the data source. In addition, the handler can enforce access rights, which govern the ability of the client to read and write data to the data source.

The parameters the handler uses to modify client parameters and access rights are specified in sections of a customization file.

See the following topics for more information about customizing the DataFactory object:

  • Understanding the Customization File

  • Customization File Connect Section

  • Customization File SQL Section

  • Customization File UserList Section

  • Customization File Logs Section

  • Required Client Settings

  • Writing Your Own Customized Handler


You cannot add a second Replication ID AutoNumber field to a table. (Error 3486)

 Copy code hover
[image]

You cannot add a second Replication ID AutoNumber field to a table. (Error 3486)
Send feedback

The table you are attempting to change already has one field that uses the Replication ID AutoNumber (or GUID) data type. If you are attempting to create a second Replication ID field to serve as a foreign key, use the Number data type instead of the AutoNumber data type.


Form.Click Event (Access)

 Copy code hover
[image]

Form.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Syntax

expression .Click

expression A variable that represents a Form object.

Remarks

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

On a form, this event occurs when the user clicks a blank area or record selector on the form.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

Form Object

Other resources

Form Object Members


CustomControl.BorderShade Property (Access)

 Copy code hover
[image]

CustomControl.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents a CustomControl object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Report.AllowReportView Property (Access)

 Copy code hover
[image]

Report.AllowReportView Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the user is allowed to enter Report view while using the specified report. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .AllowReportView

expression A variable that represents a Report object.

See also

Concepts

Report Object

Other resources

Report Object Members


SharedResources.Application Property (Access)

 Copy code hover
[image]

SharedResources.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Version Information

Version Added: Access 2010

Syntax

expression .Application

expression A variable that represents a SharedResources object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

SharedResources Collection

Other resources

SharedResources Object Members


Page.StatusBarText Property (Access)

 Copy code hover
[image]

Page.StatusBarText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.

Syntax

expression .StatusBarText

expression A variable that represents a Page object.

Remarks

You set the StatusBarText property by using a string expression up to 255 characters long.

Note Note

The length of the text you can display in the status bar depends on your computer hardware and video display.

You can use the StatusBarText property to provide specific information about a control. For example, when a text box has the focus, a brief instruction can tell the user what kind of data to enter

Note Note

You can also use the ControlTipText property to display a ScreenTip for a control.

If you create a control by dragging a field from the field list, the value in a field's Description property is copied to the StatusBarText property.

Example

The following example sets the status bar text to be displayed when the "Address_TextBox" control in the "Mailing List" form has the focus in Form View.

VBA Copy code Copy code
Forms("Mailing List").Controls("Address_TextBox"). _
 StatusBarText = "Enter the company's mailing address."

See also

Concepts

Page Object

Other resources

Page Object Members


WebBrowserControl.OnKeyDown Property (Access)

 Copy code hover
[image]

WebBrowserControl.OnKeyDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Down box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnKeyDown

expression A variable that represents a WebBrowserControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyDown event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyDown

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Field.Properties Property (DAO)

 Copy code hover
[image]

Field.Properties Property (DAO)
Send feedback

Returns the Properties collection of the specified object. Read-only.

Syntax

expression .Properties

expression A variable that represents a Field object.


CurrentProject.FullName Property (Access)

 Copy code hover
[image]

CurrentProject.FullName Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the full path (including file name) of a specific object. Read-only String.

Syntax

expression .FullName

expression A variable that represents a CurrentProject object.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


How do I... (Access 2013 developer reference)

 Copy code hover
[image]

How do I... (Access 2013 developer reference)
Send feedback

This topic links to programming tasks (how-to and walkthrough topics) for common Access scenarios.

"How Do I ..." is your gateway to key task-based topics about programming and application development using Access 2010. The essential categories for what you can do with Access are listed in this topic. The links provide pointers to important, procedure-based Help topics.

Data Access

  • Structured Query Language (SQL) | Data Access Objects (DAO) | ActiveX Data Objects (ADO) | XML | more...

Forms

  • User Input | Controls | Design | Events | Printing | more...

Reports

  • Design | Controls | Printing | Events | more...

User Interface

  • Ribbon | Miscellaneous | more...

Miscellaneous

  • Date/Time | Criteria Expressions | Windows API | Maintenance | more...


Attachment.BeforeUpdate Property (Access)

 Copy code hover
[image]

Attachment.BeforeUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .BeforeUpdate

expression A variable that represents an Attachment object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro; "[Event Procedure]" which indicates the event procedure associated with the BeforeUpdate event for the specified object; or "=functionname()" where functionname is the name of a user-defined function.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


RecordOpenOptionsEnum

 Copy code hover
[image]

RecordOpenOptionsEnum
Send feedback

Specifies options for opening a Record. These values may be combined by using OR.

Constant | Value | Description
adDelayFetchFields | 0x8000 | Indicates to the provider that the fields associated with the Record need not be retrieved initially, but can be retrieved at the first attempt to access the field. The default behavior, indicated by the absence of this flag, is to retrieve all the Record object fields.
adDelayFetchStream | 0x4000 | Indicates to the provider that the default stream associated with the Record need not be retrieved initially. The default behavior, indicated by the absence of this flag, is to retrieve the default stream associated with the Record object.
adOpenAsync | 0x1000 | Indicates that the Record object is opened in asynchronous mode.
adOpenExecuteCommand | 0x10000 | Indicates that the Source string contains command text that should be executed. This value is equivalent to the adCmdText option on Recordset.Open.
adOpenRecordUnspecified | -1 | Default. Indicates no options are specified.
adOpenOutput | 0x800000 | Indicates that if the source points to a node that contains an executable script (such as an .ASP page), then the opened Record will contain the results of the executed script. This value is only valid with non-collection records.

ADO/WFC Equivalent

These constants do not have ADO/WFC equivalents.


OptionButton.BorderStyle Property (Access)

 Copy code hover
[image]

OptionButton.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Syntax

expression .BorderStyle

expression A variable that represents an OptionButton object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


CodeData.AllDatabaseDiagrams Property (Access)

 Copy code hover
[image]

CodeData.AllDatabaseDiagrams Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllDatabaseDiagrams property to reference the AllDatabaseDiagrams collection and its related properties. Read-only AllDatabaseDiagrams object.

Syntax

expression .AllDatabaseDiagrams

expression A variable that represents a CodeData object.

See also

Concepts

CodeData Object

Other resources

CodeData Object Members


How to: Create and Delete Tables and Indexes Using Access SQL

 Copy code hover
[image]

How to: Create and Delete Tables and Indexes Using Access SQL
Send feedback

Creating and Deleting Tables

Tables are the primary building blocks of a relational database. A table contains rows (or records) of data, and each row is organized into a finite number of columns (or fields). To build a new table in Access by using Access SQL, you must name the table, name the fields, and define the type of data that the fields will contain. Use the CREATE TABLE statement to define the table in SQL. Suppose that you are building an invoicing database. The first step is to build the initial customers table.

VBA Copy code Copy code
CREATE TABLE tblCustomers
    (CustomerID INTEGER,
    [Last Name] TEXT(50),
    [First Name] TEXT(50),
    Phone TEXT(10),
    Email TEXT(50))

Be aware of the following issues when creating and deleting tables:

  • If a field name includes a space or some other nonalphanumeric character, you must enclose that field name within square brackets ([ ]).

  • If you do not declare a length for text fields, they will default to 255 characters. For consistency and code readability, you should always define your field lengths.

You can declare a field to be NOT NULL, which means that null values cannot be inserted into that particular field; a value is always required. A null value should not be confused with an empty string or a value of 0; it is simply the database representation of an unknown value.

VBA Copy code Copy code
CREATE TABLE tblCustomers
    (CustomerID INTEGER NOT NULL,
    [Last Name] TEXT(50) NOT NULL,
    [First Name] TEXT(50) NOT NULL,
    Phone TEXT(10),
    Email TEXT(50))

To remove a table from the database, use the DROP TABLE statement.

VBA Copy code Copy code
DROP TABLE tblCustomers

Working with Indexes

An index is an external data structure used to sort or arrange pointers to data in a table. When you apply an index to a table, you are specifying a certain arrangement of the data so that it can be accessed more quickly. However, if you apply too many indexes to a table, you may slow down the performance because there is extra overhead involved in maintaining the index, and because an index can cause locking issues when used in a multiuser environment. Used in the correct context, an index can greatly improve the performance of an application.

To build an index on a table, you must name the index, name the table to build the index on, name the field or fields within the table to use, and name the options you want to use. You use the CREATE INDEX statement to build the index. For example, you could build an index on the customers table in the invoicing database mentioned earlier by using the following code:

VBA Copy code Copy code
CREATE INDEX idxCustomerID
    ON tblCustomers (CustomerID)

Indexed fields can be sorted in one of two ways: ascending (ASC) or descending (DESC). The default order is ascending, and it does not have to be declared. If you use ascending order, the data will be sorted from 1 to 100. If you specify descending order, the data will be sorted from 100 to 1. You should declare the sort order with each field in the index.

VBA Copy code Copy code
CREATE INDEX idxCustomerID
    ON tblCustomers (CustomerID DESC)

There are four main options that you can use with an index: PRIMARY, DISALLOW NULL, IGNORE NULL, and UNIQUE. The PRIMARY option designates the index as the primary key for the table. You can have only one primary key index per table, although the primary key index can be declared with more than one field. Use the WITH keyword to declare the index options.

VBA Copy code Copy code
CREATE INDEX idxCustomerID
    ON tblCustomers (CustomerID)
    WITH PRIMARY

To create a primary key index on more than one field, include all of the field names in the field list.

VBA Copy code Copy code
CREATE INDEX idxCustomerName
    ON tblCustomers ([Last Name], [First Name])
    WITH PRIMARY

The DISALLOW NULL option prevents insertion of null data in the field. (This is similar to the NOT NULL declaration used in the CREATE TABLE statement.)

VBA Copy code Copy code
CREATE INDEX idxCustomerEmail
    ON tblCustomers (Email)
    WITH DISALLOW NULL

The IGNORE NULL option causes null data in the table to be ignored for the index. That means that any record that has a null value in the declared field will not be used (or counted) in the index.

VBA Copy code Copy code
CREATE INDEX idxCustomerLastName
    ON tblCustomers ([Last Name])
    WITH IGNORE NULL

In addition to the PRIMARY, DISALLOW NULL, and IGNORE NULL options, you can also declare the index as UNIQUE, which means that only unique, non-repeating values can be inserted in the indexed field.

VBA Copy code Copy code
CREATE UNIQUE INDEX idxCustomerPhone
    ON tblCustomers (Phone)

To remove an index from a table, use the DROP INDEX statement.

VBA Copy code Copy code
DROP INDEX idxName
    ON tblCustomers

Creating and Deleting Tables

Tables are the primary building blocks of a relational database. A table contains rows (or records) of data, and each row is organized into a finite number of columns (or fields). To build a new table in Access by using Access SQL, you must name the table, name the fields, and define the type of data that the fields will contain. Use the CREATE TABLE statement to define the table in SQL. Suppose that you are building an invoicing database. The first step is to build the initial customers table.

VBA Copy code Copy code
CREATE TABLE tblCustomers
    (CustomerID INTEGER,
    [Last Name] TEXT(50),
    [First Name] TEXT(50),
    Phone TEXT(10),
    Email TEXT(50))

Be aware of the following issues when creating and deleting tables:

  • If a field name includes a space or some other nonalphanumeric character, you must enclose that field name within square brackets ([ ]).

  • If you do not declare a length for text fields, they will default to 255 characters. For consistency and code readability, you should always define your field lengths.

You can declare a field to be NOT NULL, which means that null values cannot be inserted into that particular field; a value is always required. A null value should not be confused with an empty string or a value of 0; it is simply the database representation of an unknown value.

VBA Copy code Copy code
CREATE TABLE tblCustomers
    (CustomerID INTEGER NOT NULL,
    [Last Name] TEXT(50) NOT NULL,
    [First Name] TEXT(50) NOT NULL,
    Phone TEXT(10),
    Email TEXT(50))

To remove a table from the database, use the DROP TABLE statement.

VBA Copy code Copy code
DROP TABLE tblCustomers

Working with Indexes

An index is an external data structure used to sort or arrange pointers to data in a table. When you apply an index to a table, you are specifying a certain arrangement of the data so that it can be accessed more quickly. However, if you apply too many indexes to a table, you may slow down the performance because there is extra overhead involved in maintaining the index, and because an index can cause locking issues when used in a multiuser environment. Used in the correct context, an index can greatly improve the performance of an application.

To build an index on a table, you must name the index, name the table to build the index on, name the field or fields within the table to use, and name the options you want to use. You use the CREATE INDEX statement to build the index. For example, you could build an index on the customers table in the invoicing database mentioned earlier by using the following code:

VBA Copy code Copy code
CREATE INDEX idxCustomerID
    ON tblCustomers (CustomerID)

Indexed fields can be sorted in one of two ways: ascending (ASC) or descending (DESC). The default order is ascending, and it does not have to be declared. If you use ascending order, the data will be sorted from 1 to 100. If you specify descending order, the data will be sorted from 100 to 1. You should declare the sort order with each field in the index.

VBA Copy code Copy code
CREATE INDEX idxCustomerID
    ON tblCustomers (CustomerID DESC)

There are four main options that you can use with an index: PRIMARY, DISALLOW NULL, IGNORE NULL, and UNIQUE. The PRIMARY option designates the index as the primary key for the table. You can have only one primary key index per table, although the primary key index can be declared with more than one field. Use the WITH keyword to declare the index options.

VBA Copy code Copy code
CREATE INDEX idxCustomerID
    ON tblCustomers (CustomerID)
    WITH PRIMARY

To create a primary key index on more than one field, include all of the field names in the field list.

VBA Copy code Copy code
CREATE INDEX idxCustomerName
    ON tblCustomers ([Last Name], [First Name])
    WITH PRIMARY

The DISALLOW NULL option prevents insertion of null data in the field. (This is similar to the NOT NULL declaration used in the CREATE TABLE statement.)

VBA Copy code Copy code
CREATE INDEX idxCustomerEmail
    ON tblCustomers (Email)
    WITH DISALLOW NULL

The IGNORE NULL option causes null data in the table to be ignored for the index. That means that any record that has a null value in the declared field will not be used (or counted) in the index.

VBA Copy code Copy code
CREATE INDEX idxCustomerLastName
    ON tblCustomers ([Last Name])
    WITH IGNORE NULL

In addition to the PRIMARY, DISALLOW NULL, and IGNORE NULL options, you can also declare the index as UNIQUE, which means that only unique, non-repeating values can be inserted in the indexed field.

VBA Copy code Copy code
CREATE UNIQUE INDEX idxCustomerPhone
    ON tblCustomers (Phone)

To remove an index from a table, use the DROP INDEX statement.

VBA Copy code Copy code
DROP INDEX idxName
    ON tblCustomers


AND (Access 2013 custom web app)

 Copy code hover
[image]

AND (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Combines two Boolean expressions and returns TRUE when both expressions are TRUE.

Syntax

boolean_expression AND boolean_expression

Return Value

Returns TRUE when both expressions are TRUE.

Remarks

When more than one logical operator is used in a statement, the AND operators are evaluated first. You can change the order of evaluation by using parentheses.


Document Properties (DAO)

 Copy code hover
[image]

Document Properties (DAO)
Send feedback

In this section

  • Document.Container Property (DAO)

  • Document.DateCreated Property (DAO)

  • Document.LastUpdated Property (DAO)

  • Document.Name Property (DAO)

  • Document.Properties Property (DAO)


The value specified is not a ReplicaID for any member in the replica set. (Error 3488)

 Copy code hover
[image]

The value specified is not a ReplicaID for any member in the replica set. (Error 3488)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


IdleEnum Enumeration (DAO)

 Copy code hover
[image]

IdleEnum Enumeration (DAO)
Send feedback

Insert introduction here.

Section Heading

Insert section body here.

Subsection Heading

Insert subsection body here.


Form.Caption Property (Access)

 Copy code hover
[image]

Form.Caption Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the text that appears in the title bar in Form view. Read/write String.

Syntax

expression .Caption

expression A variable that represents a Form object.

Remarks

The Caption property is a string expression that can contain up to 2,048 characters. Captions for forms and reports that are too long to display in the title bar are truncated.

If you don't set a caption for a form, button, or label, Microsoft Access will assign the object a unique name based on the object, such as "Form1".

You can use the Caption property to assign an access key to a label or command button. In the caption, include an ampersand (&) immediately preceding the character you want to use as an access key. The character will be underlined. You can press ALT plus the underlined character to move the focus to that control on a form.

Include two ampersands (&&) in the setting for a caption if you want to display an ampersand itself in the caption text. For example, to display "Save & Exit", you should type Save && Exit in the Caption property box.

See also

Concepts

Form Object

Other resources

Form Object Members


CommandButton.GridlineShade Property (Access)

 Copy code hover
[image]

CommandButton.GridlineShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineShade

expression A variable that represents a CommandButton object.

Remarks

The GridlineShade property contains a numeric expression that can be used to darken the theme color in the GridlineColor property. The default value of the GridlineShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


The database engine does not recognize either the field

 Copy code hover
[image]

The database engine does not recognize either the field <name> in a validation expression, or the default value in the table <name>. (Error 3344)
Send feedback

Your expression refers to a field incorrectly, or to a field that does not exist. Check to make sure the field name is valid and spelled correctly.


TextBox.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

TextBox.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents a TextBox object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.BorderThemeColorIndex=2

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Invalid partner synchronizer. (Error 3741)

 Copy code hover
[image]

Invalid partner synchronizer. (Error 3741)
Send feedback

The synchronizer specified is not valid for this replica set or is not the hub synchronizer for a Local or Anonymous replica. You can only synchronize a Local or Anonymous replica with the Global hub replica that created it.


OptionButton.OnDblClick Property (Access)

 Copy code hover
[image]

OptionButton.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Syntax

expression .OnDblClick

expression A variable that represents an OptionButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_DblClick" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Determining Edit Mode

 Copy code hover
[image]

Determining Edit Mode
Send feedback

ADO maintains an editing buffer associated with the current record. The EditMode property indicates whether changes have been made to this buffer or whether a new record has been created. Use EditMode to determine the editing status of the current record. You can test for pending changes if an editing process has been interrupted and determine whether you need to use the Update or CancelUpdate method.

EditMode returns one of the EditModeEnum constants, which are listed in the following table.

Constant | Description
adEditNone | Indicates that no editing operation is in progress.
adEditInProgress | Indicates that data in the current record has been modified but not saved.
adEditAdd | Indicates that the AddNew method has been called, and the current record in the copy buffer is a new record that has not been saved to the database.
adEditDelete | Indicates that the current record has been deleted.

EditMode can return a valid value only if there is a current record. EditMode will return an error if BOF or EOF is True or if the current record has been deleted.


Printers.Application Property (Access)

 Copy code hover
[image]

Printers.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a Printers object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

Printers Collection

Other resources

Printers Object Members


DROP USER or GROUP Statement (Microsoft Access SQL)

 Copy code hover
[image]

DROP USER or GROUP Statement (Microsoft Access SQL)
Send feedback

Deletes one or more existing users or groups, or removes one or more existing users from an existing group.

Syntax

Delete one or more users or remove one or more users from a group:

DROP USER user[, user, …] [FROM group]

Delete one or more groups:

DROP GROUP group[, group, …]

The DROP USER or GROUP statement has these parts:

Part | Description
user | The name of a user to be removed from the workgroup information file.
group | The name of a group to be removed from the workgroup information file.

Remarks

If the FROM keyword is used in the DROP USER statement, then each of the users listed in the statement will be removed from the group specified following the FROM keyword. However, the users themselves will not be deleted.

The DROP GROUP statement will delete the specified group(s). The users who are members of the group(s) will not be affected, but they will no longer be members of the deleted group(s).


Report.ApplyFilter Event (Access)

 Copy code hover
[image]

Report.ApplyFilter Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when a filter is applied to a report.

Version Information

Version Added: Access 2007

Syntax

expression .ApplyFilter(Cancel, ApplyType)

expression A variable that represents a Report object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the ApplyFilter event occurs. Setting the Cancel argument to True cancels the ApplyFilter event and the filter is not applied to the report.
ApplyType | Required | Integer | Returns the type of filter that was applied.

Remarks

To run a macro or event procedure when this event occurs, set the OnApplyFilter property to the name of the macro or to [Event Procedure].

You can use the ApplyFilter event to:

  • Make sure the filter that is being applied is correct. For example, you may want to be sure that any filter applied to an Orders report includes criteria restricting the OrderDate field. To do this, check the report's Filter or ServerFilter property value to make sure this criteria is included in the WHERE clause expression.

  • Change the display of the report before the filter is applied. For example, when you apply a certain filter, you may want to disable or hide some fields that aren't appropriate for the records displayed by this filter.

  • Undo or change actions you took when the Filter event occurred. For example, you can disable or hide some controls on the report when the user is creating the filter, because you don't want these controls to be included in the filter criteria. You can then enable or show these controls after the filter is applied.

The actions in the ApplyFilter macro or event procedure occur before the filter is applied or removed, or after the Advanced Filter/Sort window is closed, but before the report is redisplayed. The criteria you've entered in the newly created filter are available to the ApplyFilter macro or event procedure as the setting of the Filter or ServerFilter property.

The ApplyFilter event does not occur when the user does one of the following:

  • Applies or removes a filter by using the ApplyFilter, OpenReport, or ShowAllRecords actions in a macro, or their corresponding methods of the DoCmd object in Visual Basic.

  • Uses the Close action or the Close method of the DoCmd object to close the Advanced Filter/Sort window.

  • Sets the Filter or ServerFilter property or FilterOn property in a macro or Visual Basic (although you can set these properties in an ApplyFilter macro or event procedure).

See also

Concepts

Report Object

Other resources

Report Object Members


DependencyInfo Object (Access)

 Copy code hover
[image]

DependencyInfo Object (Access)
See also Send feedback

Published: July 16, 2012

Represents the dependency information for an AccessObject object.

Remarks

To return the dependency information for an AccessObject object, use the GetDependencyInfo method of the AccessObject object.

See also

Concepts

Access Object Model Reference

Other resources

DependencyInfo Object Members


Relation Object (DAO)

 Copy code hover
[image]

Relation Object (DAO)
Send feedback

A Relation object represents a relationship between fields in tables or queries (Microsoft Access database engine databases only).

Remarks

You can use the Relation object to create new relationships and examine existing relationships in your database.

Using a Relation object and its properties, you can:

  • Specify an enforced relationship between fields in base tables (but not a relationship that involves a query or a linked table).

  • Establish unenforced relationships between any type of table or query— native or linked.

  • Use the Name property to refer to the relationship between the fields in the referenced primary table and the referencing foreign table.

  • Use the Attributes property to determine whether the relationship between fields in the table is one-to-one or one-to-many and how to enforce referential integrity.

  • Use the Attributes property to determine whether the Microsoft Access database engine can perform cascading update and cascading delete operations on primary and foreign tables.

  • Use the Attributes property to determine whether the relationship between fields in the table is left join or right join.

  • Use the Name property of all Field objects in the Fields collection of a Relation object to set or return the names of the fields in the primary key of the referenced table, or the ForeignName property settings of the Field objects to set or return the names of the fields in the foreign key of the referencing table.

If you make changes that violate the relationships established for the database, a trappable error occurs. If you request cascading update or cascading delete operations, the Microsoft Access database engine also modifies the primary key or foreign key tables to enforce the relationships you establish.

For example, the Northwind database contains a relationship between an Orders table and a Customers table. The CustomerID field of the Customers table is the primary key, and the CustomerID field of the Orders table is the foreign key. For the Microsoft Access database engine to accept a new record in the Orders table, it searches the Customers table for a match on the CustomerID field of the Orders table. If the Microsoft Access database engine doesn't find a match, it doesn't accept the new record, and a trappable error occurs.

When you enforce referential integrity, a unique index must already exist for the key field of the referenced table. The Microsoft Access database engine automatically creates an index with the Foreign property set to act as the foreign key in the referencing table.

To create a new Relation object, use the CreateRelation method. To refer to a Relation object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

Relations(0)

Relations("name")

Relations![name]

Example

This example shows how an existing Relation object can control data entry. The procedure attempts to add a record with a deliberately incorrect CategoryID; this triggers the error-handling routine.

VBA Copy code Copy code
Sub RelationX()

 Dim dbsNorthwind As Database
 Dim rstProducts As Recordset
 Dim prpLoop As Property
 Dim fldLoop As Field
 Dim errLoop As Error

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstProducts = dbsNorthwind.OpenRecordset("Products")

 ' Print a report showing all the different parts of
 ' the relation and where each part is stored.
 With dbsNorthwind.Relations!CategoriesProducts
 Debug.Print "Properties of " & .Name & " Relation"
 Debug.Print " Table = " & .Table
 Debug.Print " ForeignTable = " & .ForeignTable
 Debug.Print "Fields of " & .Name & " Relation"
 With .Fields!CategoryID
 Debug.Print " " & .Name
 Debug.Print " Name = " & .Name
 Debug.Print " ForeignName = " & .ForeignName
 End With
 End With

 ' Attempt to add a record that violates the relation.
 With rstProducts
 .AddNew
 !ProductName = "Trygve's Lutefisk"
 !CategoryID = 10
 On Error GoTo Err_Relation
 .Update
 On Error GoTo 0
 .Close
 End With

 dbsNorthwind.Close

 Exit Sub

Err_Relation:

 ' Notify user of any errors that result from
 ' the invalid data.
 If DBEngine.Errors.Count > 0 Then
 For Each errLoop In DBEngine.Errors
 MsgBox "Error number: " & errLoop.Number & _
 vbCr & errLoop.Description
 Next errLoop
 End If

 Resume Next

End Sub

This example uses the CreateRelation method to create a Relation between the Employees TableDef and a new TableDef called Departments. This example also demonstrates how creating a new Relation will also create any necessary Indexes in the foreign table (the DepartmentsEmployees Index in the Employees table).

VBA Copy code Copy code
Sub CreateRelationX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim tdfNew As TableDef
 Dim idxNew As Index
 Dim relNew As Relation
 Dim idxLoop As Index

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind
 ' Add new field to Employees table.
 Set tdfEmployees = .TableDefs!Employees
 tdfEmployees.Fields.Append _
 tdfEmployees.CreateField("DeptID", dbInteger, 2)

 ' Create new Departments table.
 Set tdfNew = .CreateTableDef("Departments")

 With tdfNew
 ' Create and append Field objects to Fields
 ' collection of the new TableDef object.
 .Fields.Append .CreateField("DeptID", dbInteger, 2)
 .Fields.Append .CreateField("DeptName", dbText, 20)

 ' Create Index object for Departments table.
 Set idxNew = .CreateIndex("DeptIDIndex")
 ' Create and append Field object to Fields
 ' collection of the new Index object.
 idxNew.Fields.Append idxNew.CreateField("DeptID")
 ' The index in the primary table must be Unique in
 ' order to be part of a Relation.
 idxNew.Unique = True
 .Indexes.Append idxNew
 End With

 .TableDefs.Append tdfNew

 ' Create EmployeesDepartments Relation object, using
 ' the names of the two tables in the relation.
 Set relNew = .CreateRelation("EmployeesDepartments", _
 tdfNew.Name, tdfEmployees.Name, _
 dbRelationUpdateCascade)

 ' Create Field object for the Fields collection of the
 ' new Relation object. Set the Name and ForeignName
 ' properties based on the fields to be used for the
 ' relation.
 relNew.Fields.Append relNew.CreateField("DeptID")
 relNew.Fields!DeptID.ForeignName = "DeptID"
 .Relations.Append relNew

 ' Print report.
 Debug.Print "Properties of " & relNew.Name & _
 " Relation"
 Debug.Print " Table = " & relNew.Table
 Debug.Print " ForeignTable = " & _
 relNew.ForeignTable
 Debug.Print "Fields of " & relNew.Name & " Relation"

 With relNew.Fields!DeptID
 Debug.Print " " & .Name
 Debug.Print " Name = " & .Name
 Debug.Print " ForeignName = " & .ForeignName
 End With

 Debug.Print "Indexes in " & tdfEmployees.Name & _
 " TableDef"
 For Each idxLoop In tdfEmployees.Indexes
 Debug.Print " " & idxLoop.Name & _
 ", Foreign = " & idxLoop.Foreign
 Next idxLoop

 ' Delete new objects because this is a demonstration.
 .Relations.Delete relNew.Name
 .TableDefs.Delete tdfNew.Name
 tdfEmployees.Fields.Delete "DeptID"
 .Close
 End With

End Sub


SmartTagProperties.Add Method (Access)

 Copy code hover
[image]

SmartTagProperties.Add Method (Access)
See also Send feedback

Published: July 16, 2012

Adds a custom property to a smart tag.

Syntax

expression .Add(Name, Value)

expression A variable that represents a SmartTagProperties object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Required | String | The name to be used for the custom property.
Value | Required | Variant | The value of the custom property.

Return Value

SmartTagProperty

See also

Concepts

SmartTagProperties Collection

Other resources

SmartTagProperties Object Members


Syntax error in field definition. (Error 3292)

 Copy code hover
[image]

Syntax error in field definition. (Error 3292)
Send feedback

A syntax error occurred in the field definition of a CREATE TABLE or ALTER TABLE statement.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


Combo Box Control

 Copy code hover
[image]

Combo Box Control
Send feedback

Published: July 16, 2012

The combo box control combines the features of a text box and a list box. Use a combo box when you want the option of either typing a value or selecting a value from a predefined list.

Remarks

In Form view, Microsoft Access doesn't display the list until you click the combo box's arrow.

If you have Control Wizards on before you select the combo box tool, you can create a combo box with a wizard. To turn Control Wizards on or off, click the Control Wizards button in the toolbox.

The setting of the LimitToList property determines whether you can enter values that aren't in the list.

The list can be single- or multiple-column, and the columns can appear with or without headings.


Indexes Collection Properties, Methods, and Events (ADOX)

 Copy code hover
[image]

Indexes Collection Properties, Methods, and Events (ADOX)
Send feedback

Properties

Count Property

Item Property

Methods

Append Method (Indexes)

Delete Method (Collections)

Refresh Method

Events

None.


Image.GridlineWidthRight Property (Access)

 Copy code hover
[image]

Image.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified image control. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthRight

expression A variable that represents an Image object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Image Object

Other resources

Image Object Members


Error.Description Property (DAO)

 Copy code hover
[image]

Error.Description Property (DAO)
Send feedback

Returns a descriptive string associated with an error. This is the default property for the Error object.

Syntax

expression .Description

expression A variable that represents an Error object.

Remarks

The Description property comprises a short description of the error. Use this property to alert the user about an error that you cannot or do not want to handle.

Example

This example forces an error, traps it, and displays the Description, Number, Source, HelpContext, and HelpFile properties of the resulting Error object.

VBA Copy code Copy code
Sub DescriptionX()

 Dim dbsTest As Database

 On Error GoTo ErrorHandler

 ' Intentionally trigger an error.
 Set dbsTest = OpenDatabase("NoDatabase")

 Exit Sub

ErrorHandler:
 Dim strError As String
 Dim errLoop As Error

 ' Enumerate Errors collection and display properties of
 ' each Error object.
 For Each errLoop In Errors
 With errLoop
 strError = _
 "Error #" & .Number & vbCr
 strError = strError & _
 " " & .Description & vbCr
 strError = strError & _
 " (Source: " & .Source & ")" & vbCr
 strError = strError & _
 "Press F1 to see topic " & .HelpContext & vbCr
 strError = strError & _
 " in the file " & .HelpFile & "."
 End With
 MsgBox strError
 Next

 Resume Next

End Sub


Determining What is Supported

 Copy code hover
[image]

Determining What is Supported
Send feedback

The Supports method is used to determine whether a specified Recordset object supports a particular type of functionality. It has the following syntax:

Copy code Copy code
                      boolean = recordset.Supports( CursorOptions )

Supports returns a Boolean value that indicates whether all of the features identified by the CursorOptions argument are supported by the provider. You can use the Supports method to determine what types of functionality a Recordset object supports. If the Recordset object supports the features whose corresponding constants are in CursorOptions, the Supports method returns True. Otherwise, it returns False.

Using the Supports method, you can check for the ability of the Recordset object to add new records, use bookmarks, use the Find method, use scrolling, use the Index property, and to perform batch updates. For a complete list of constants and their meanings, see CursorOptionEnum.

Although the Supports method may return True for a given functionality, it does not guarantee that the provider can make the feature available under all circumstances. The Supports method simply returns whether the provider can support the specified functionality, assuming certain conditions are met. For example, the Supports method may indicate that a Recordset object supports updates, even though the cursor is based on a multiple table join — some columns of which are not updateable.


Learn about language-specific information (Access)

 Copy code hover
[image]

Learn about language-specific information (Access)
Send feedback

Published: July 16, 2012

Language-specific Help topics apply only if the language-specific feature is available.


ObjectFrame.OnExit Property (Access)

 Copy code hover
[image]

ObjectFrame.OnExit Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnExit

expression A variable that represents an ObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Exit event occurs just before a control loses the focus to another control on the same form.

The OnExit value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Exit box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Exit box is blank, the property value is an empty string.

Example

The following example associates the Exit event with the macro "Exit_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnExit = "Exit_Macro"

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


AutoCorrect.DisplayAutoCorrectOptions Property (Access)

 Copy code hover
[image]

AutoCorrect.DisplayAutoCorrectOptions Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Boolean value that specifies whether the AutoCorrect Options button is displayed for the specified control. The default value is True. Read/write.

Syntax

expression .DisplayAutoCorrectOptions

expression A variable that represents an AutoCorrect object.

See also

Concepts

AutoCorrect Object

Other resources

AutoCorrect Object Members


Recordset.NoMatch Property (DAO)

 Copy code hover
[image]

Recordset.NoMatch Property (DAO)
Send feedback

Indicates whether a particular record was found by using the Seek method or one of the Find methods (Microsoft Access workspaces only).

Syntax

expression .NoMatch

expression A variable that represents a Recordset object.

Remarks

When you open or create a Recordset object, its NoMatch property is set to False.

To locate a record, use the Seek method on a table-type Recordset object or one of the Find methods on a dynaset- or snapshot-type Recordset object. Check the NoMatch property setting to see whether the record was found.

If the Seek or Find method is unsuccessful and the NoMatch property is True, the current record will no longer be valid. Be sure to obtain the current record's bookmark before using the Seek method or a Find method if you'll need to return to that record.

Note Note

Using any of the Move methods on a Recordset object won't affect its NoMatch property setting.

Example

This example uses the NoMatch property to determine whether a Seek and a FindFirst were successful, and if not, to give appropriate feedback. The SeekMatch and FindMatch procedures are required for this procedure to run.

VBA Copy code Copy code
Sub NoMatchX()

   Dim dbsNorthwind As Database
   Dim rstProducts As Recordset
   Dim rstCustomers As Recordset
   Dim strMessage As String
   Dim strSeek As String
   Dim strCountry As String
   Dim varBookmark As Variant

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   ' Default is dbOpenTable; required if Index property will
   ' be used.
   Set rstProducts = dbsNorthwind.OpenRecordset("Products")

   With rstProducts
      .Index = "PrimaryKey"

      Do While True
         ' Show current record information; ask user for
         ' input.
         strMessage = "NoMatch with Seek method" & vbCr & _
            "Product ID: " & !ProductID & vbCr & _
            "Product Name: " & !ProductName & vbCr & _
            "NoMatch = " & .NoMatch & vbCr & vbCr & _
            "Enter a product ID."
         strSeek = InputBox(strMessage)
         If strSeek = "" Then Exit Do

         ' Call procedure that seeks for a record based on
         ' the ID number supplied by the user.
         SeekMatch rstProducts, Val(strSeek)
      Loop

      .Close
   End With

   Set rstCustomers = dbsNorthwind.OpenRecordset( _
      "SELECT CompanyName, Country FROM Customers " & _
      "ORDER BY CompanyName", dbOpenSnapshot)

   With rstCustomers

      Do While True
         ' Show current record information; ask user for
         ' input.
         strMessage = "NoMatch with FindFirst method" & _
            vbCr & "Customer Name: " & !CompanyName & _
            vbCr & "Country: " & !Country & vbCr & _
            "NoMatch = " & .NoMatch & vbCr & vbCr & _
            "Enter country on which to search."
         strCountry = Trim(InputBox(strMessage))
         If strCountry = "" Then Exit Do

         ' Call procedure that finds a record based on
         ' the country name supplied by the user.
         FindMatch rstCustomers, _
            "Country = '" & strCountry & "'"
      Loop

      .Close
   End With

   dbsNorthwind.Close

End Sub

Sub SeekMatch(rstTemp As Recordset, _
   intSeek As Integer)

   Dim varBookmark As Variant
   Dim strMessage As String

   With rstTemp
      ' Store current record location.
      varBookmark = .Bookmark
      .Seek "=", intSeek

      ' If Seek method fails, notify user and return to the
      ' last current record.
      If .NoMatch Then
         strMessage = _
            "Not found! Returning to current record." & _
            vbCr & vbCr & "NoMatch = " & .NoMatch
         MsgBox strMessage
         .Bookmark = varBookmark
      End If

   End With

End Sub

Sub FindMatch(rstTemp As Recordset, _
   strFind As String)

   Dim varBookmark As Variant
   Dim strMessage As String

   With rstTemp
      ' Store current record location.
      varBookmark = .Bookmark
      .FindFirst strFind

      ' If Find method fails, notify user and return to the
      ' last current record.
      If .NoMatch Then
         strMessage = _
            "Not found! Returning to current record." & _
            vbCr & vbCr & "NoMatch = " & .NoMatch
         MsgBox strMessage
         .Bookmark = varBookmark
      End If

   End With

End Sub

The following example shows how to use the Seek method to find a record in a linked table.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Sub TestSeek()
    ' Get the path to the external database that contains
    ' the tblCustomers table we're going to search.
    Dim strMyExternalDatabase
    Dim dbs    As DAO.Database
    Dim dbsExt As DAO.Database
    Dim rst    As DAO.Recordset
    Dim tdf    As DAO.TableDef

    Set dbs = CurrentDb()
    Set tdf = dbs.TableDefs("tblCustomers")
    strMyExternalDatabase = Mid(tdf.Connect, 11)

    'Open the database that contains the table that is linked
    Set dbsExt = OpenDatabase(strMyExternalDatabase)

    'Open a table-type recordset against the external table
    Set rst = dbsExt.OpenRecordset("tblCustomers", dbOpenTable)

    'Specify which index to search on
    rst.Index = "PrimaryKey"

    'Specify the criteria
    rst.Seek "=", 123

    'Check the result
    If rst.NoMatch Then
        MsgBox "Record not found."
    Else
        MsgBox "Customer name: " & rst!CustName
    End If

    rst.Close
    dbs.Close
    dbsExt.Close
    Set rst = Nothing
    Set tdf = Nothing
    Set dbs = Nothing

End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Parameters.Refresh Method (DAO)

 Copy code hover
[image]

Parameters.Refresh Method (DAO)
Send feedback

Updates the objects in the specified colletion to reflect the database's current schema.

Syntax

expression .Refresh

expression A variable that represents a Parameters object.

Remarks

Use the Refresh method in multiuser environments in which other users may change the database. You may also need to use it on any collections that are indirectly affected by changes to the database. For example, if you change a Users collection, you may need to refresh a Groups collection before using the Groups collection.

A collection is filled with objects the first time it's referred to and won't automatically reflect subsequent changes other users make. If it's likely that another user has changed a collection, use the Refresh method on the collection immediately before carrying out any task in your application that assumes the presence or absence of a particular object in the collection. This will ensure that the collection is as up-to-date as possible. On the other hand, using Refresh can unnecessarily slow performance.


Application.CurrentData Property (Access)

 Copy code hover
[image]

Application.CurrentData Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the CurrentData property to access the CurrentData object and its related collections. Read-only CurrentData object.

Syntax

expression .CurrentData

expression A variable that represents an Application object.

Remarks

Use the CurrentData property to refer to one of the following current database collections together with one of its properties or methods.

AllTables | AllQueries
AllViews | AllStoredProcedures
AllDatabaseDiagrams |

See also

Concepts

Application Object

Other resources

Application Object Members


Properties.Append Method (DAO)

 Copy code hover
[image]

Properties.Append Method (DAO)
Send feedback

Adds a new Property to the Properties collection.

Syntax

expression .Append(Object)

expression A variable that represents a Properties object.

Parameters

Name | Required/Optional | Data Type | Description
Object | Required | Object | An object variable that represents the field being appended to the collection.

Remarks

The appended object becomes a persistent object, stored on disk, until you delete it by using the Delete method.

The addition of a new object occurs immediately, but you should use the Refresh method on any other collections that may be affected by changes to the database structure.

If the object you're appending isn't complete (such as when you haven't appended any Field objects to a Fields collection of an Index object before it's appended to an Indexes collection) or if the properties set in one or more subordinate objects are incorrect, using the Append method causes an error. For example, if you haven't specified a field type and then try to append the Field object to the Fields collection in a TableDef object, using the Append method triggers a run-time error.


ComboBox.Exit Event (Access)

 Copy code hover
[image]

ComboBox.Exit Event (Access)
See also Send feedback

Published: July 16, 2012

The Exit event occurs just before a control loses the focus to another control on the same form or report.

Syntax

expression .Exit(Cancel)

expression A variable that represents a ComboBox object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the Exit event occurs. Setting the Cancel argument to True (-1) cancels the Exit event.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when this event occurs, set the OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Exit event occurs before the LostFocus event.

Unlike the LostFocus event, the Exit event does not occur when a form loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Label.Caption Property (Access)

 Copy code hover
[image]

Label.Caption Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the text that appears in the control. Read/write String.

Syntax

expression .Caption

expression A variable that represents a Label object.

Remarks

The Caption property is a string expression that can contain up to 2,048 characters.

If you don't specify a caption for a table field, the field's FieldName property setting will be used as the caption of a label attached to a control or as the column heading in Datasheet view. If you don't specify the caption for a query field, the caption for the underlying table field will be used. If you don't set a caption for a form, button, or label, Microsoft Access will assign the object a unique name based on the object, such as "Form1".

If you create a control by dragging a field from the field list and haven't specified a Caption property setting for the field, the field's FieldName property setting will be copied to the control's Name property box and will also appear in the label of the control created.

Note Note

The text of the Caption property for a label or command button control is the hyperlink display text when the HyperlinkAddress or HyperlinkSubAddress property is set for the control.

You can use the Caption property to assign an access key to a label or command button. In the caption, include an ampersand (&) immediately preceding the character you want to use as an access key. The character will be underlined. You can press ALT plus the underlined character to move the focus to that control on a form.

Include two ampersands (&&) in the setting for a caption if you want to display an ampersand itself in the caption text. For example, to display "Save & Exit", you should type Save && Exit in the Caption property box.

See also

Concepts

Label Object

Other resources

Label Object Members


ObjectFrame.OnLostFocus Property (Access)

 Copy code hover
[image]

ObjectFrame.OnLostFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnLostFocus

expression A variable that represents an ObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The LostFocus event occurs when the object loses the focus.

The OnLostFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Lost Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Lost Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnLostFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnLostFocus

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


OptionGroup.OnExit Property (Access)

 Copy code hover
[image]

OptionGroup.OnExit Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnExit

expression A variable that represents an OptionGroup object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Exit event occurs just before a control loses the focus to another control on the same form.

The OnExit value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Exit box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Exit box is blank, the property value is an empty string.

Example

The following example associates the Exit event with the macro "Exit_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnExit = "Exit_Macro"

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Report.ForeColor Property (Access)

 Copy code hover
[image]

Report.ForeColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ForeColor property to specify the color for text in a control. Read/write Long.

Syntax

expression .ForeColor

expression A variable that represents a Report object.

Remarks

You can use this property for controls on forms or reports to make them easy to read or to convey a special meaning. For example, you can change the color of the text in the UnitsInStock control when its value falls below the reorder level.

You can also use this property on reports to create special visual effects when you print with a color printer. When used on a report, this property specifies the printing and drawing color for the Print , Line , and Circle methods.

The ForeColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors for text in controls.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set the Circle property only by using a macro or a Visual Basic event procedure specified in a section's OnPrint event property setting.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


CheckBox.Enabled Property (Access)

 Copy code hover
[image]

CheckBox.Enabled Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.

Syntax

expression .Enabled

expression A variable that represents a CheckBox object.

Remarks

The Enabled property setting is a value that indicates whether the conditional format is enabled or disabled. True enables the conditional format. False disables the conditional format. The default is True.

When the Enabled property is True, the conditional format can be displayed in the Conditional Formatting dialog box.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


CompareBookmarks Method Example (VB)

 Copy code hover
[image]

CompareBookmarks Method Example (VB)
Send feedback

This example demonstrates the CompareBookmarks method. The relative value of bookmarks is seldom needed unless a particular bookmark is somehow special.

Designate a random row of a Recordset derived from the Authors table as the target of a search. Then display the position of each row relative to that target.

Copy code Copy code

'BeginCompareBookmarksVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 ' recordset and connection variables
 Dim rstAuthors As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strSQLAuthors As String
 Dim strCnxn As String

 ' comparison variables
 Dim count As Integer
 Dim target As Variant
 Dim result As Long
 Dim strAnswer As String
 Dim strTitle As String
 strTitle = "CompareBookmarks Example"

 ' Open a connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open recordset as a static cursor type recordset
 Set rstAuthors = New ADODB.Recordset
 strSQLAuthors = "SELECT * FROM Authors"
 rstAuthors.Open strSQLAuthors, Cnxn, adOpenStatic, adLockReadOnly, adCmdText

 count = rstAuthors.RecordCount
 Debug.Print "Rows in the Recordset = "; count

 ' Exit if an empty recordset
 If count = 0 Then Exit Sub

 ' Get position between 0 and count -1
 Randomize
 count = (Int(count * Rnd))
 Debug.Print "Randomly chosen row position = "; count
 ' Move row to random position
 rstAuthors.Move count, adBookmarkFirst
 ' Remember the mystery row
 target = rstAuthors.Bookmark

 count = 0
 rstAuthors.MoveFirst
 ' Loop through recordset
 Do Until rstAuthors.EOF
 result = rstAuthors.CompareBookmarks(rstAuthors.Bookmark, target)

 If result = adCompareNotEqual Then
 Debug.Print "Row "; count; ": Bookmarks are not equal."
 ElseIf result = adCompareNotComparable Then
 Debug.Print "Row "; count; ": Bookmarks are not comparable."
 Else
 Select Case result
 Case adCompareLessThan
 strAnswer = "less than"
 Case adCompareEqual
 strAnswer = "equal to"
 Case adCompareGreaterThan
 strAnswer = "greater than"
 Case Else
 strAnswer = "in error comparing to"
 End Select
 'show the results row-by-row
 Debug.Print "Row position " & count & " is " & strAnswer & " the target."
 End If

 count = count + 1
 rstAuthors.MoveNext
 Loop

 ' clean up
 rstAuthors.Close
 Cnxn.Close
 Set rstAuthors = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstAuthors Is Nothing Then
 If rstAuthors.State = adStateOpen Then rstAuthors.Close
 End If
 Set rstAuthors = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If

End Sub
'EndCompareBookmarksVB


BoundObjectFrame.Left Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Syntax

expression .Left

expression A variable that represents a BoundObjectFrame object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Cannot have aggregate function in JOIN operation

 Copy code hover
[image]

Cannot have aggregate function in JOIN operation <operation>. (Error 3099)
Send feedback

You cannot use an aggregate function in the JOIN operation of an SQL statement.


Section.BackColor Property (Access)

 Copy code hover
[image]

Section.BackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the interior color of the specified object. Read/write Long.

Syntax

expression .BackColor

expression A variable that represents a Section object.

Remarks

The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

To use the BackColor property, the BackStyle property, if available, must be set to Normal.

Example

The following example uses the RGB function to set the , BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

Section Object

Other resources

Section Object Members


Application.ConvertAccessProject Method (Access)

 Copy code hover
[image]

Application.ConvertAccessProject Method (Access)
See also Send feedback

Published: July 16, 2012

Converts the specified Microsoft Access file from one version to another.

Syntax

expression .ConvertAccessProject(SourceFilename, DestinationFilename, DestinationFileFormat)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
SourceFilename | Required | String | The name of the Access file to convert. If a path isn't specified, Access looks for the file in the current directory.
DestinationFilename | Required | String | e name of the file where Access saves the converted file. If a path isn't specified, Access saves the file in the current directory.
DestinationFileFormat | Required | AcFileFormat | An AcFileFormat constant that specifies the format of the converted file.

Return Value

Nothing

Remarks

The file specified by DestinationFilename cannot already exist, or an error occurs.

Example

The following example converts the specified Access 97 file to an Access 2000 file in the same directory.

VBA Copy code Copy code
Application.ConvertAccessProject _
 SourceFilename:="C:\My Documents\Sales-Access97.mdb", _
 DestinationFilename:="C:\My Documents\Sales-Access2000.mdb", _
 DestinationFileFormat:=acFileFormatAccess2000

See also

Concepts

Application Object

Other resources

Application Object Members


WebBrowserControl.ReadyState Property (Access)

 Copy code hover
[image]

WebBrowserControl.ReadyState Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the status of the specified Web Browser control. Read-only AcWebBrowserState.

Version Information

Version Added: Access 2010

Syntax

expression .ReadyState

expression A variable that represents a WebBrowserControl object.

Remarks

When the Web Browser control does not contain a document, the value of this property is acUninitialized. Other values indicate the control state when it navigates to a new document.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Application.ExportNavigationPane Method (Access)

 Copy code hover
[image]

Application.ExportNavigationPane Method (Access)
See also Send feedback

Published: July 16, 2012

Saves the current configuration of the Navigation Pane to an XML file.

Version Information

Version Added: Access 2007

Syntax

expression .ExportNavigationPane(Path)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Path | Required | String | The path and name of the XML file that you want to save the configuration of the Navigation Pane to.

See also

Concepts

Application Object

Other resources

Application Object Members


How to: Calculate Fields in Domain Aggregate Functions

 Copy code hover
[image]

How to: Calculate Fields in Domain Aggregate Functions
Send feedback

You can use the string expression argument (the expr argument) in a domain aggregate function to perform a calculation on values in a field. For example, you can calculate a percentage (such as a surcharge or sales tax) by dividing a field value by a number.

The following table provides examples of calculations on fields from an Orders table and an Order Details table.

Calculation | Example
Add a number to a field | "[Freight] + 5"
Subtract a number from a field | "[Freight] - 5"
Multiply a field by a number | "[Freight] * 2"
Divide a field by a number | "[Freight] / 2"
Add one field to another | "[UnitsInStock] + [UnitsOnOrder]"
Subtract one field from another | "[ReorderLevel] - [UnitsInStock]"

You would most likely use a domain aggregate function in a macro or module, in a calculated control on a form or report, or in a criteria expression in a query.

For example, you can calculate the average discount amount for all orders in an Order Details table. Multiply the Unit Price and Discount fields to determine the discount for each order, then calculate the average. Enter the following example in a procedure in a module.

Copy code Copy code
Dim dblX As Double
dblX = DAvg("[UnitPrice] * [Discount]", "[Order Details]")


Report.KeyPreview Property (Access)

 Copy code hover
[image]

Report.KeyPreview Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the KeyPreview property to specify whether the report-level keyboard event procedures are invoked before a control's keyboard event procedures. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .KeyPreview

expression A variable that represents a Report object.

Remarks

The KeyPreview property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The report receives keyboard events first, and then the active control receives keyboard events.
No | False | (Default) Only the active control receives keyboard events.

You can set the KeyPreview property in any view.

You can use the KeyPreview property to create a keyboard-handling procedure for a report. For example, when an application uses function keys, setting the KeyPreview property to True allows you to process keystrokes at the report level rather than writing code for each control that might receive keystroke events.

To handle keyboard events only at the report level and prevent controls from receiving keyboard events, set the KeyAscii argument to 0 in the report's KeyPress event procedure, and set the KeyCode argument to 0 in the report's KeyDown and KeyUp event procedures.

If a report has no visible or enabled controls, it automatically receives all keyboard events.

Example

In the following example, the KeyPreview property is set to True in the report's Load event procedure. This causes the report to receive keyboard events before they are received by any control. The report's KeyDown event then checks the KeyCode argument value to determine if the F2, F3, or F4 keys were pressed.

VBA Copy code Copy code
Private Sub Report_Load()
 Me.KeyPreview = True
End Sub

Private Sub Report_KeyDown(KeyCode As Integer, Shift As Integer)
 Select Case KeyCode
 Case vbKeyF2
 ' Process F2 key events.
 Case vbKeyF3
 ' Process F3 key events.
 Case vbKeyF4
 ' Process F4 key events.
 Case Else
 End Select
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


How to: Create a User-Defined Property

 Copy code hover
[image]

How to: Create a User-Defined Property
Send feedback

The following example attempts to set the value of a user-defined property. If the property does not exist, it uses the CreateProperty method to create and set the value of the new property.

VBA Copy code Copy code
Sub CreatePropertyX()

   Dim dbsNorthwind As Database
   Dim prpLoop As Property

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   ' Set the Archive property to True.
   SetProperty dbsNorthwind, "Archive", True

   With dbsNorthwind
      Debug.Print "Properties of " & .Name

      ' Enumerate Properties collection of the Northwind
      ' database.
      For Each prpLoop In .Properties
         If prpLoop <> "" Then Debug.Print "  " & _
            prpLoop.Name & " = " & prpLoop
      Next prpLoop

      ' Delete the new property because this is a
      ' demonstration.
      .Properties.Delete "Archive"

      .Close
   End With

End Sub

Sub SetProperty(dbsTemp As Database, strName As String, _
   booTemp As Boolean)

   Dim prpNew As Property
   Dim errLoop As Error

   ' Attempt to set the specified property.
   On Error GoTo Err_Property
   dbsTemp.Properties("strName") = booTemp
   On Error GoTo 0

   Exit Sub

Err_Property:

   ' Error 3270 means that the property was not found.
   If DBEngine.Errors(0).Number = 3270 Then
      ' Create property, set its value, and append it to the
      ' Properties collection.
      Set prpNew = dbsTemp.CreateProperty(strName, _
         dbBoolean, booTemp)
      dbsTemp.Properties.Append prpNew
      Resume Next
   Else
      ' If different error has occurred, display message.
      For Each errLoop In DBEngine.Errors
         MsgBox "Error number: " & errLoop.Number & vbCr & _
            errLoop.Description
      Next errLoop
      End
   End If

End Sub


Printer.Copies Property (Access)

 Copy code hover
[image]

Printer.Copies Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Long indicating the number of copies to be printed. Read/write.

Syntax

expression .Copies

expression A variable that represents a Printer object.

Example

The following example sets a variety of printer settings for the form specified in the strFormname argument of the procedure.

VBA Copy code Copy code
Sub SetPrinter(strFormname As String)

 DoCmd.OpenForm FormName:=strFormname, view:=acDesign, _
 datamode:=acFormEdit, windowmode:=acHidden

 With Forms(form1).Printer

 .TopMargin = 1440
 .BottomMargin = 1440
 .LeftMargin = 1440
 .RightMargin = 1440

 .ColumnSpacing = 360
 .RowSpacing = 360

 .ColorMode = acPRCMColor
 .DataOnly = False
 .DefaultSize = False
 .ItemSizeHeight = 2880
 .ItemSizeWidth = 2880
 .ItemLayout = acPRVerticalColumnLayout
 .ItemsAcross = 6

  .Copies = 1
 .Orientation = acPRORLandscape
 .Duplex = acPRDPVertical
 .PaperBin = acPRBNAuto
 .PaperSize = acPRPSLetter
 .PrintQuality = acPRPQMedium

 End With

 DoCmd.Close objecttype:=acForm, objectname:=strFormname, _
 Save:=acSaveYes

End Sub

See also

Concepts

Printer Object

Other resources

Printer Object Members


The GUID could not be created. (Error 3553)

 Copy code hover
[image]

The GUID could not be created. (Error 3553)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


UpdateBatch and CancelBatch Methods Example (VC++)

 Copy code hover
[image]

UpdateBatch and CancelBatch Methods Example (VC++)
Send feedback

This example demonstrates the UpdateBatch method in conjunction with the CancelBatch method.

Copy code Copy code

// BeginUpdateBatchCpp
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>
#include "UpdateBatchX.h"

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void UpdateBatchX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 UpdateBatchX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// UpdateBatchX Function //
// //
//////////////////////////////////////////////////////////
void UpdateBatchX(void)
{
 HRESULT hr = S_OK;

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstTitles = NULL;

 // Define string variables.
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 IADORecordBinding *picRs = NULL; // Interface Pointer Declared
 CTitleRs titlers; // C++ Class Object

 try
 {
 // Open titles table.
 TESTHR(pRstTitles.CreateInstance(__uuidof(Recordset)));
 pRstTitles->CursorType = adOpenKeyset;
 pRstTitles->LockType = adLockBatchOptimistic;
 pRstTitles->Open ("titles", strCnn,
 adOpenKeyset, adLockBatchOptimistic, adCmdTable);

 // Open IADORecordBinding interface pointer for binding
 // Recordset to a class
 TESTHR(pRstTitles->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 // Binding the Recordset to a C++ Class
 TESTHR(picRs->BindToRecordset(&titlers));
 pRstTitles->MoveFirst();

 // Loop through recordset and ask user if she wants,
 // to change the type for a specified title.
 while (!(pRstTitles->EndOfFile))
 {
 // Compare type with psychology
 if (!strcmp( (char *)strtok(titlers.m_szt_Type," "),
 "psychology" ))
 {
 printf("\n\nTitle: %s \nChange type to self_help?(y/n):",
 titlers.m_szt_Title);
 char chKey;
 chKey = getch();
 if(toupper(chKey) == 'Y')
 {
 // Change type to self_help.
 pRstTitles->Fields->GetItem("type")->Value =
 (_bstr_t)("self_help");
 }
 }
 pRstTitles->MoveNext();
 }

 // Ask the user if she wants to commit to all the
 // changes made above.
 printf("\n\nSave all changes?");
 char chKey;
 chKey = getch();
 if(toupper(chKey) == 'Y')
 {
 pRstTitles->UpdateBatch(adAffectAll);
 }
 else
 {
 pRstTitles->CancelBatch(adAffectAll);
 }

 // Print current data in recordset.
 pRstTitles->Requery(adOptionUnspecified);

 // Open IADORecordBinding interface pointer for Binding Recordset to a class
 TESTHR(pRstTitles->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 // ReBinding the Recordset to a C++ Class.
 TESTHR(picRs->BindToRecordset(&titlers));

 // Move to the first record of the title table
 pRstTitles->MoveFirst();

 //Clear the screen for the next display.
 system("cls");

 while (!pRstTitles->EndOfFile)
 {
 printf("%s - %s\n",
 titlers.lt_TitleStatus == adFldOK ?
 titlers.m_szt_Title :"<NULL>",
 titlers.lt_TypeStatus == adFldOK ?
 titlers.m_szt_Type :"<NULL>");
 pRstTitles->MoveNext();
 }

 pRstTitles->MoveFirst();

 // Restore original data because this is demonstration.
 while (!(pRstTitles->EndOfFile))
 {
 // Compare type with psychology
 if(!strcmp( (char *)strtok(titlers.m_szt_Type," "),
 "self_help" ))
 {
 // Change type to psychology.
 pRstTitles->Fields->GetItem("type")->Value =
 (_bstr_t)("psychology");
 }
 pRstTitles->MoveNext();
 }
 }
 catch (_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstTitles->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 if (pRstTitles)
 if (pRstTitles->State == adStateOpen)
 {
 pRstTitles->UpdateBatch(adAffectAll);
 pRstTitles->Close();
 }
}

//////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
//////////////////////////////////////////////////////////
void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

//////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
//////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndUpdateBatchCpp

UpdateBatchX.h

Copy code Copy code

// BeginUpdateBatchH
#include "icrsint.h"

//This class extracts titles and type from Titles table
class CTitleRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CTitleRs)
 // Column title is the 2nd field in the table
 ADO_VARIABLE_LENGTH_ENTRY2(2,adVarChar,m_szt_Title,
 sizeof(m_szt_Title),lt_TitleStatus,FALSE)
 // Column type is the 3rd field in the table
 ADO_VARIABLE_LENGTH_ENTRY2(3,adVarChar,m_szt_Type,
 sizeof(m_szt_Type),lt_TypeStatus,TRUE)
END_ADO_BINDING()

public:
 CHAR m_szt_Title[81];
 ULONG lt_TitleStatus;
 CHAR m_szt_Type[13];
 ULONG lt_TypeStatus;
};
// EndUpdateBatchH


OptionGroup.Move Method (Access)

 Copy code hover
[image]

OptionGroup.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents an OptionGroup object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Form.AfterDelConfirm Event (Access)

 Copy code hover
[image]

Form.AfterDelConfirm Event (Access)
See also Send feedback

Published: July 16, 2012

The AfterDelConfirm event occurs after the user confirms the deletions and the records are actually deleted or when the deletions are canceled.

Syntax

expression .AfterDelConfirm(Status)

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Status | Required | Integer | An intrinsic constant that indicates whether a record has been deleted. acDeleteOK indicates the deletion was successful. acDeleteCancel indicates the deletion was canceled in Visual Basic. acDeleteUserCancel indicates the deletion was canceled by the user.

Remarks

To run a macro or event procedure when these events occur, set the AfterDelConfirm property to the name of the macro or to [Event Procedure].

After a record is deleted, it's stored in a temporary buffer.

In a Microsoft Access database, the AfterDelConfirm event occurs after a record or records are actually deleted or after a deletion or deletions are canceled. If the BeforeDelConfirm event isn't canceled, the AfterDelConfirm event occurs after the Delete Confirm dialog box is displayed. The AfterDelConfirm event occurs even if the BeforeDelConfirm event is canceled. The AfterDelConfirm event procedure returns status information about the deletion. For example, you can use a macro or event procedure associated with the AfterDelConfirm event to recalculate totals affected by the deletion of records.

In a Microsoft Access project (.adp), the AfterDelConfirm event occurs before a record or records are actually deleted. In order to avoid opening unnecessary transactions on Microsoft SQL Server, Access prompts you to confirm the deletion before opening the transaction. If you confirm the deletion, Access opens a transaction on Microsoft SQL Server, issues the DELETE statement to delete the record or records, and fires the form's Delete event. If you click No when prompted to confirm the deletion, Microsoft Access does not open a transaction on Microsoft SQL Server to delete the record and does not fire the form's Delete event.

If you cancel the Delete event, the AfterDelConfirm event does not occur and the Delete Confirm dialog box isn't displayed.

Note Note

The AfterDelConfirm event does not occur and the Delete Confirm dialog box isn't displayed if you clear the Record Changes check box under Confirm on the Editing tab of the Access Options dialog box.

By running a macro or an event procedure when the Delete event occurs, you can prevent a record from being deleted or allow a record to be deleted only under certain conditions. You can also use a Delete event to display a dialog box asking whether the user wants to delete a record before it's deleted.

After you delete the record, the focus moves to the next record following the deleted record, and the Current event for that record occurs, followed by the Enter and GotFocus events for the first control in that record.

The BeforeDelConfirm event then occurs, just before Microsoft Access displays the Delete Confirm dialog box asking you to confirm the deletion. After you respond to the dialog box by confirming or canceling the deletion, the AfterDelConfirm event occurs.

You can delete one or more records at a time. The Delete event occurs after each record is deleted. This enables you to access the data in each record before it's actually deleted, and selectively confirm or cancel each deletion in the Delete macro or event procedure. When you delete more than one record, the Current event for the record following the last deleted record and the Enter and GotFocus events for the first control in this record don't occur until all the records are deleted. In other words, a Delete event occurs for each selected record, but no other events occur until all the selected records are deleted. The AfterDelConfirm event also does not occur until all the selected records are deleted.

Example

The following example shows how you can use the BeforeDelConfirm event procedure to suppress the Delete Confirm dialog box and display a custom dialog box when a record is deleted. It also shows how you can use the AfterDelConfirm event procedure to display a message indicating whether the deletion progressed in the usual way or whether it was canceled in Visual Basic or by the user.

VBA Copy code Copy code
Private Sub Form_BeforeDelConfirm(Cancel As Integer, _
 Response As Integer)
 ' Suppress default Delete Confirm dialog box.
 Response = acDataErrContinue
 ' Display custom dialog box.
 If MsgBox("Delete this record?", vbOKCancel) = vbCancel Then
 Cancel = True
 End If
End Sub

Private Sub Form_AfterDelConfirm(Status As Integer)
 Select Case Status
 Case acDeleteOK
 MsgBox "Deletion occurred normally."
 Case acDeleteCancel
 MsgBox "Programmer canceled the deletion."
 Case acDeleteUserCancel
 MsgBox "User canceled the deletion."
 End Select
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


DBEngine.OpenDatabase Method (DAO)

 Copy code hover
[image]

DBEngine.OpenDatabase Method (DAO)
Send feedback

Opens a specified database and returns a reference to the Database object that represents it.

Syntax

expression .OpenDatabase(Name, Options, ReadOnly, Connect)

expression A variable that represents a DBEngine object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Required | String | the name of an existing Microsoft Access database file, or the data source name (DSN) of an ODBC data source. See the Name property for more information about setting this value.
Options | Optional | Variant | Sets various options for the database, as specified in Remarks.
ReadOnly | Optional | Variant | True if you want to open the database with read-only access, or False (default) if you want to open the database with read/write access.
Connect | Optional | Variant | Specifies various connection information, including passwords.

Return Value

Database

Remarks

You can use the following values for the options argument.

Setting | Description
True | Opens the database in exclusive mode.
False | (Default) Opens the database in shared mode.

When you open a database, it is automatically added to the Databases collection.

Some considerations apply when you use dbname:

  • If it refers to a database that is already open for access by another user, an error occurs.

  • If it doesn't refer to an existing database or valid ODBC data source name, an error occurs.

  • If it's a zero-length string ("") and connect is "ODBC;" , a dialog box listing all registered ODBC data source names is displayed so the user can select a database.

To close a database, and thus remove the Database object from the Databases collection, use the Close method on the object.

Note Note

When you access a Microsoft Access database engine-connected ODBC data source, you can improve your application's performance by opening a Database object connected to the ODBC data source, rather than by linking individual TableDef objects to specific tables in the ODBC data source.


GRANT Statement (Microsoft Access SQL)

 Copy code hover
[image]

GRANT Statement (Microsoft Access SQL)
Send feedback

Grants specific privileges to an existing user or group.

Syntax

GRANT {privilege[, privilege, …]} ON{TABLE table | OBJECT object|

CONTAINER container } TO {authorizationname[, authorizationname, …]}

The GRANT statement has these parts:

Part | Description
privilege | The privilege or privileges to be granted. Privileges are specified using the following keywords: SELECT, DELETE, INSERT, UPDATE, DROP, SELECTSECURITY, UPDATESECURITY, DBPASSWORD, UPDATEIDENTITY, CREATE, SELECTSCHEMA, SCHEMA and UPDATEOWNER.
tablename | Any valid table name.
object | This can encompass any non-table object. A stored query (view or procedure) is one example.
container | The name of a valid container.
authorizationname | A user or group name.


TextBox.Move Method (Access)

 Copy code hover
[image]

TextBox.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a TextBox object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Invalid path for destination dropbox folder. (Error 3556)

 Copy code hover
[image]

Invalid path for destination dropbox folder. (Error 3556)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


Recordset.Clone Method (DAO)

 Copy code hover
[image]

Recordset.Clone Method (DAO)
Send feedback

Creates a duplicate Recordset object that refers to the original Recordset object.

Syntax

expression .Clone

expression A variable that represents a Recordset object.

Return Value

Recordset

Remarks

Use the Clone method to create multiple, duplicate Recordset objects. Each Recordset can have its own current record. Using Clone by itself doesn't change the data in the objects or in their underlying structures. When you use the Clone method, you can share bookmarks between two or more Recordset objects because their bookmarks are interchangeable.

You can use the Clone method when you want to perform an operation on a Recordset that requires multiple current records. This is faster and more efficient than opening a second Recordset. When you create a Recordset with the Clone method, it initially lacks a current record. To make a record current before you use the Recordset clone, you must set the Bookmark property or use one of the Move methods, one of the Find methods, or the Seek method.

Using the Close method on either the original or duplicate object doesn't affect the other object. For example, using Close on the original Recordset doesn't close the clone.

Note Note

  • Closing a clone recordset within a pending transaction will cause an implicit Rollback operation.

  • When you clone a table-type Recordset object in a Microsoft Access workspace, the Index property setting is not cloned on the new copy of the recordset. You must copy the Index property setting manually.

Example

This example uses the Clone method to create copies of a Recordset and then lets the user position the record pointer of each copy independently.

VBA Copy code Copy code
Sub CloneX()

   Dim dbsNorthwind As Database
   Dim arstProducts(1 To 3) As Recordset
   Dim intLoop As Integer
   Dim strMessage As String
   Dim strFind As String

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   ' If the following SQL statement will be used often,
   ' creating a permanent QueryDef will result in better
   ' performance.
   Set arstProducts(1) = dbsNorthwind.OpenRecordset( _
      "SELECT ProductName FROM Products " & _
      "ORDER BY ProductName", dbOpenSnapshot)

   ' Create two clones of the original Recordset.
   Set arstProducts(2) = arstProducts(1).Clone
   Set arstProducts(3) = arstProducts(1).Clone

   Do While True

      ' Loop through the array so that on each pass, the
      ' user is searching a different copy of the same
      ' Recordset.
      For intLoop = 1 To 3

         ' Ask for search string while showing where the
         ' current record pointer is for each Recordset.
         strMessage = _
            "Recordsets from Products table:" & vbCr & _
            "  1 - Original - Record pointer at " & _
            arstProducts(1)!ProductName & vbCr & _
            "  2 - Clone - Record pointer at " & _
            arstProducts(2)!ProductName & vbCr & _
            "  3 - Clone - Record pointer at " & _
            arstProducts(3)!ProductName & vbCr & _
            "Enter search string for #" & intLoop & ":"
         strFind = Trim(InputBox(strMessage))
         If strFind = "" Then Exit Do

         ' Find the search string; if there's no match, jump
         ' to the last record.
         With arstProducts(intLoop)
            .FindFirst "ProductName >= '" & strFind & "'"
            If .NoMatch Then .MoveLast
         End With

      Next intLoop

   Loop

   arstProducts(1).Close
   arstProducts(2).Close
   arstProducts(3).Close
   dbsNorthwind.Close

End Sub


ListBox.TabIndex Property (Access)

 Copy code hover
[image]

ListBox.TabIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.

Syntax

expression .TabIndex

expression A variable that represents a ListBox object.

Remarks

You can set the TabIndex property to an integer representing the position of the control within the tab order of the form. Valid settings are 0 for the first tab position, up to the total number of controls minus 1 for the last tab position. For example, if a form has three controls that each have a TabIndex property, valid TabIndex property settings are 0, 1, and 2.

Setting the TabIndex property to an integer less than 0 produces an error.

By default, Microsoft Access assigns a tab order to controls in the order that you create them on a form. Each new control is placed last in the tab order. If you change the setting of a control's TabIndex property to adjust the tab order, Microsoft Access automatically renumbers the TabIndex property setting of other controls to reflect insertions and deletions.

In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the TAB key.

Changing the tab order of other controls on the form doesn't affect what happens when you press a control's access key. For example, if you've created an access key for the label of a text box, the focus will move to the text box whenever you press the label's access key — even if you change the TabIndex property setting for the text box.

If you press an access key for a control such as a label that doesn't have a TabIndex property (and thus isn't in the tab order), the focus moves to the next control in the tab order that can receive the focus.

Example

The following example reverses the tab order of a command button and a text box. Because TextBox1 was created first, it has a TabIndex property setting of 0 and Command1 has a setting of 1.

VBA Copy code Copy code
Sub Form_Click()
 Me!Command1.TabIndex = 0
 Me!TextBox1.TabIndex = 1
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


MacroError.Description Property (Access)

 Copy code hover
[image]

MacroError.Description Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the text that represents the current error message. Read-only String.

Version Information

Version Added: Access 2007

Syntax

expression .Description

expression A variable that represents a MacroError object.

Remarks

When an error occurs in a macro, information about the error is stored in the MacroError object. If you have not used the OnError action to suppress error messages, the macro stops and the error information is displayed in a standard error message. However, if you have used the OnError action to suppress error messages, you may want to use the information stored in the MacroError object in a condition or a custom error message.

After an error has been handled, the information in the MacroError object is out of date, so it is a good idea to clear the object using the ClearMacroError action. This resets the error number in the MacroError object back to zero, and clears any other information about the error that is stored in the object, such as the error description, macro name, action name, condition, and arguments. This way, you can inspect the MacroError object again later to see if another error has occurred.

See also

Concepts

MacroError Object

Other resources

MacroError Object Members


Scoping and Object-Naming Compatibility

 Copy code hover
[image]

Scoping and Object-Naming Compatibility
Send feedback

Visual Basic scoping rules affect the names you choose for your objects, modules, and procedures.

Modules and Other Objects with the Same Name

When you name a module, avoid prefacing module names with "Form_" or "Report_". Naming a module in this way could conflict with existing code you've written behind forms and reports.

If you have a module in an application created with version 1.x or 2.0 of Microsoft Access that doesn't follow these naming rules, Microsoft Access generates an error when you try to convert your application. For example, a module named Form_Orders in a Microsoft Access version 1.x or 2.0 database would generate an error and you would be asked to rename the module before attempting to convert it.

Modules and Procedures with the Same Name

Although it is not suggested, you can have a procedure with the same name as a module. To call that procedure from an expression anywhere in your application, you must use a fully qualified name for the procedure, including both the module name and the procedure name, as in the following example:

Copy code Copy code
IsLoaded.IsLoaded("Orders")
Note Note

This will not work with the Runcode action in macros. Accessing procedures with the same name as a module is not possible with macros.

Procedures and Controls with the Same Name

If you call a procedure from a form, and that procedure has the same name as a control on the form, you must fully qualify the procedure call with the name of the module in which it resides. For example, if you want to call a procedure named PrintInvoice that resides in a standard module named Utilities, and there's also a button on the same form named PrintInvoice, use the fully qualified name when you call the procedure from your form or form module.

Controls with Similar Names

You can't have a control with a name that differs from an existing control's name by only a space or a symbol. For example, if you have a control named [Last_Name], you can't have a control named [Last Name] or [Last+Name].

Modules with the Same Names as Type Libraries

You can't save a module with the same name as a type library. If you try to save a module with the name "ADO", "Access", "DAO" or "VBA", you'll get an error stating that the name conflicts with an existing module, project, or object library. Similarly, if you've set a reference to another type library, such as the Microsoft Excel type library, you can't save a module with the name "Excel".

Fields with the Same Names as Methods

If a field in the table has the same name as an ActiveX Data Objects (ADO) method on an ADO Recordset object, or a Data Access Object (DAO) method on a DAO Recordset object, you can't refer to the corresponding field in the recordset with the . (dot) syntax. You must use the ! (exclamation point) syntax, or Microsoft Access will generate an error. The following example shows how to refer to a field called AddNew in a recordset opened on a table called Contacts:

Copy code Copy code
Dim rst As New ADODB.Recordset
rst.Open "Contacts",CurrentProject.Connection, _
 adOpenKeySet,adLockOptimistic
Debug.Print rst!AddNew

Copy code Copy code
Dim dbs As Database, rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Contacts")
Debug.Print rst!AddNew

Modules with the Same Names as Visual Basic Functions

If you save a module with the same name as an intrinsic Visual Basic function, Microsoft Access will generate an error when you try to run that function. For example, if you save a module named MsgBox, and then try to run a procedure that calls the MsgBox function, Microsoft Access generates the error "Expected variable or procedure, not module."

Modules with the Same Names as Objects

If a database created with a previous version of Microsoft Access includes a module that has the same name as a Microsoft Access object, an ADO object, or a DAO object, you may encounter compilation errors when you convert your database. For example, a module named "Form" or "Database" may generate a compilation error. To avoid these errors, rename the module.

Naming Fields Used in Expressions or Bound to Controls on Forms and Reports

When you create a field in a table that will be bound to a control on a report or used in an expression in the ControlSource property of a control or a report, avoid assigning the field a name that's the same name as a method of the Application object. To see a list of methods of the Application object, click Object Browser on the View menu while in module Design view. Click Access in the Project/Library box, click Application in the Classes box, and view the methods of the Application object in the Members Of box.

When you create a field in a table that will be bound to a control on a form or report, avoid assigning the field any of the following names: AddRef, GetIDsOfNames, GetTypeInfo, GetTypeInfoCount, Invoke, QueryInterface, or Release.

Identifiers with Same Names as Visual Basic Keywords

The version of Visual Basic that's used by Microsoft Access 97 (and later) contains some new Visual Basic keywords, so you can no longer use these keywords as identifiers. These keywords are: AddressOf, Assert, Decimal, DefDec, Enum, Event, Friend, Implements, RaiseEvent, and WithEvents. When you convert a database developed with a prior version of Microsoft Access, existing identifiers that are the same as a new Visual Basic keyword will cause a compile error. To correct this problem, rename the identifiers.

Project Names the Same as Microsoft Access Objects

A project name is the string that is the name of your Microsoft Access application. In prior versions of Microsoft Access, the project name was the name of the database. Beginning in Microsoft Access 2000, the project name is specified by the ProjectName property setting and its default setting is the name of the database. If you convert a database with a name that is the same as a class of objects, for example, "application," "form," or "report," Microsoft Access will append an underscore character to the database name to create a project name that does not conflict with existing objects.


NavigationControl.GotFocus Event (Access)

 Copy code hover
[image]

NavigationControl.GotFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The GotFocus event occurs when the specified object receives the focus.

Version Information

Version Added: Access 2010

Syntax

expression .GotFocus

expression A variable that represents a NavigationControl object.

Return Value

nothing

Remarks

To run a macro or event procedure when these events occur, set the OnGotFocus property to the name of the macro or to [Event Procedure].

These events occur when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The GotFocus event differs from the Enter event in that the GotFocus event occurs every time a control receives the focus. For example, suppose the user clicks a check box on a form, then clicks a report, and finally clicks the check box on the form to bring it to the foreground. The GotFocus event occurs both times the check box receives the focus. In contrast, the Enter event occurs only the first time the user clicks the check box. The GotFocus event occurs after the Enter event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Index Properties (DAO)

 Copy code hover
[image]

Index Properties (DAO)
Send feedback

In this section

  • Index.Clustered Property (DAO)

  • Index.DistinctCount Property (DAO)

  • Index.Fields Property (DAO)

  • Index.Foreign Property (DAO)

  • Index.IgnoreNulls Property (DAO)

  • Index.Name Property (DAO)

  • Index.Primary Property (DAO)

  • Index.Properties Property (DAO)

  • Index.Required Property (DAO)

  • Index.Unique Property (DAO)


Line.Height Property (Access)

 Copy code hover
[image]

Line.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Syntax

expression .Height

expression A variable that represents a Line object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

Line Object

Other resources

Line Object Members


Direction Property (ADO)

 Copy code hover
[image]

Direction Property (ADO)
Send feedback

Indicates whether the Parameter represents an input parameter, an output parameter, an input and an output parameter, or if the parameter is the return value from a stored procedure.

Settings and Return Values

Sets or returns a ParameterDirectionEnum value.

Remarks

Use the Direction property to specify how a parameter is passed to or from a procedure. The Direction property is read/write; this allows you to work with providers that don't return this information or to set this information when you don't want ADO to make an extra call to the provider to retrieve parameter information.

Not all providers can determine the direction of parameters in their stored procedures. In these cases, you must set the Direction property before you execute the query.


Reference.Kind Property (Access)

 Copy code hover
[image]

Reference.Kind Property (Access)
See also Send feedback

Published: July 16, 2012

The Kind property indicates the type of reference that a Reference object represents. Read-only vbext_RefKind.

Syntax

expression .Kind

expression A variable that represents a Reference object.

Remarks

The Kind property returns the following values:

Value | Description
vbext_rk_Project | The Reference object represents a reference to a Visual Basic project.
vbext_rk_TypeLib | The Reference object represents a reference to a file that contains a type library.

See also

Concepts

Reference Object

Other resources

Reference Object Members


UPDATEOWNER (Microsoft Access SQL reserved word)

 Copy code hover
[image]

UPDATEOWNER (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The UPDATEOWNER keyword is used in these contexts:

GRANT Statement

REVOKE Statement


Format Property - Yes/No Data Type

 Copy code hover
[image]

Format Property - Yes/No Data Type
Send feedback

Published: July 16, 2012

You can set the Format property to the Yes/No, True/False, or On/Off predefined formats or to a custom format for the Yes/No data type.

Setting

Microsoft Access uses a check box control as the default control for the Yes/No data type. Predefined and custom formats are ignored when a check box control is used. Therefore, these formats apply only to data that is displayed in a text box control.

Predefined Formats

Yes, True, and On are equivalent, as are No, False, and Off. If you specify one predefined format and then enter an equivalent value, the predefined format of equivalent value will be displayed. For example, if you enter True or On in a text box control with its Format property set to Yes/No, the value is automatically converted to Yes.

Custom Formats

The Yes/No data type can use custom formats containing up to three sections.

Section | Description
First | This section has no effect on the Yes/No data type. However, a semicolon (;) is required as a placeholder.
Second | The text to display in place of Yes, True, or On values.
Third | The text to display in place of No, False, or Off values.

Example

The following example shows a custom yes/no format for a text box control. The control displays the word "Always" in blue text for Yes, True, or On, and the word "Never" in red text for No, False, or Off.

Copy code Copy code
;"Always"[Blue];"Never"[Red]


AllDatabaseDiagrams.Parent Property (Access)

 Copy code hover
[image]

AllDatabaseDiagrams.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents an AllDatabaseDiagrams object.

See also

Concepts

AllDatabaseDiagrams Collection

Other resources

AllDatabaseDiagrams Object Members


NumericScale Property (ADO)

 Copy code hover
[image]

NumericScale Property (ADO)
Send feedback

Indicates the scale of numeric values in a Parameter or Field object.

Settings and Return Values

Sets or returns a Byte value that indicates the number of decimal places to which numeric values will be resolved.

Remarks

Use the NumericScale property to determine how many digits to the right of the decimal point will be used to represent values for a numeric Parameter or Field object.

For Parameter objects, the NumericScale property is read/write.

For a Field object, NumericScale is normally read-only. However, for new Field objects that have been appended to the Fields collection of a Record, NumericScale is read/write only after the Value property for the Field has been specified and the data provider has successfully added the new Field by calling the Update method of the Fields collection.


Controls Properties (Access)

 Copy code hover
[image]

Controls Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Object.
Parent | Returns the parent object for the specified object. Read-only.


Cannot access the FoxPro 3.0 bound DBF file

 Copy code hover
[image]

Cannot access the FoxPro 3.0 bound DBF file <filename>. (Error 3623)
Send feedback

You tried to access Microsoft FoxPro Version 3.0 bound .dbf file. Bound files are accessible only through the FoxPro database container they are bound to.


SmartTagActions.Application Property (Access)

 Copy code hover
[image]

SmartTagActions.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a SmartTagActions object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

SmartTagActions Collection

Other resources

SmartTagActions Object Members


TextBox.SelStart Property (Access)

 Copy code hover
[image]

TextBox.SelStart Property (Access)
See also Send feedback

Published: July 16, 2012

The SelStart property specifies or determines the starting point of the selected text or the position of the insertion point if no text is selected. Read/write Integer.

Syntax

expression .SelStart

expression A variable that represents a TextBox object.

Remarks

The SelStart property uses an Integer in the range 0 to the total number of characters in the text box portion of a combo box.

To set or return this property for a control, the control must have the focus. To move the focus to a control, use the SetFocus method.

Changing the SelStart property cancels the selection, places an insertion point in the text, and sets the SelLength property to 0.

Example

The following example uses two event procedures to search for text specified by a user. The text to search is set in the form's Load event procedure. The Click event procedure for the Find button (which the user clicks to start the search) prompts the user for the text to search for and selects the text in the text box if the search is successful.

VBA Copy code Copy code
Private Sub Form_Load()

 Dim ctlTextToSearch As Control
 Set ctlTextToSearch = Forms!Form1!Textbox1

 ' SetFocus to text box.
 ctlTextToSearch.SetFocus
 ctlTextToSearch.Text = "This company places large orders twice " & _
 "a year for garlic, oregano, chilies and cumin."
 Set ctlTextToSearch = Nothing

End Sub

Public Sub Find_Click()

 Dim strSearch As String
 Dim intWhere As Integer
 Dim ctlTextToSearch As Control

 ' Get search string from user.
 With Me!Textbox1
 strSearch = InputBox("Enter text to find:")

 ' Find string in text.
 intWhere = InStr(.Value, strSearch)
 If intWhere Then
 ' If found.
 .SetFocus
 .SelStart = intWhere - 1
 .SelLength = Len(strSearch)
 Else
 ' Notify user.
 MsgBox "String not found."
 End If
 End With

End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Attachment.Top Property (Access)

 Copy code hover
[image]

Attachment.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Version Information

Version Added: Access 2007

Syntax

expression .Top

expression A variable that represents an Attachment object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Catalog Properties, Methods, and Events (ADO MD)

 Copy code hover
[image]

Catalog Properties, Methods, and Events (ADO MD)
Send feedback

Properties/Collections

ActiveConnection Property

CubeDefs Collection

Name Property

Methods

None.

Events

None.


ObjectFrame.StatusBarText Property (Access)

 Copy code hover
[image]

ObjectFrame.StatusBarText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.

Syntax

expression .StatusBarText

expression A variable that represents an ObjectFrame object.

Remarks

You set the StatusBarText property by using a string expression up to 255 characters long.

Note Note

The length of the text you can display in the status bar depends on your computer hardware and video display.

You can use the StatusBarText property to provide specific information about a control. For example, when a text box has the focus, a brief instruction can tell the user what kind of data to enter

Note Note

You can also use the ControlTipText property to display a ScreenTip for a control.

If you create a control by dragging a field from the field list, the value in a field's Description property is copied to the StatusBarText property.

Example

The following example sets the status bar text to be displayed when the "Address_TextBox" control in the "Mailing List" form has the focus in Form View.

VBA Copy code Copy code
Forms("Mailing List").Controls("Address_TextBox"). _
 StatusBarText = "Enter the company's mailing address."

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Invalid DataCodePage option in initialization setting. (Error 3337)

 Copy code hover
[image]

Invalid DataCodePage option in initialization setting. (Error 3337)
Send feedback

The DataCodePage setting for the external data source you are attempting to use is not valid. This setting is in the corresponding HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Access Connectivity Engine\Engines\<external data source ISAM> in the Microsoft Windows Registry.

Valid settings are:

  • OEM — Data is stored as OEM data; OemToAnsi and AnsiToOem conversions are done.

  • ANSI — Data is stored as ANSI data; OemToAnsi and AnsiToOem conversions are not done.


FilterCriterion Property (RDS)

 Copy code hover
[image]

FilterCriterion Property (RDS)
Send feedback

Indicates the evaluation operator to use in the filter value.

Syntax

DataControl.FilterCriterion = String

Parameters

  • DataControl

  • An object variable that represents an RDS.DataControl object.

  • String

  • A String value that specifies the evaluation operator of the FilterValue to the records. Can be any one of the following: <, <=, >, >=, =, or <>.

Remarks

The SortColumn, SortDirection, FilterValue, FilterCriterion, and FilterColumn properties provide sorting and filtering functionality on the client-side cache. The sorting functionality orders records by values from one column. The filtering functionality displays a subset of records based on find criteria, while the full Recordset is maintained in the cache. The Reset method will execute the criteria and replace the current Recordset with an updatable Recordset.

The "!=" operator is not valid for FilterCriterion; instead, use "<>".

If both the filter and sort properties are set and you call the Reset method, the rowset is first filtered and then it is sorted. For ascending sorts, the null values are at the top; for descending sorts, null values are at the bottom (ascending is default behavior).


The Limits of a Recordset

 Copy code hover
[image]

The Limits of a Recordset
Send feedback

Use the BOF and EOF properties to determine whether a Recordset object contains records or whether you've gone beyond the limits of a Recordset object when you move from record to record. Think of BOF and EOF as "phantom" records that are positioned at the beginning and end of the Recordset. Building on the sample Recordset from Examining Data, it would now look like this:

ProductID | ProductName | UnitPrice
BOF |  |
7 | Uncle Bob's Organic Dried Pears | 30.0000
14 | Tofu | 23.2500
28 | Rssle Sauerkraut | 45.6000
51 | Manjimup Dried Apples | 53.0000
74 | Longlife Tofu | 10.0000
EOF |  |

The BOF property returns True (-1) if the current record position is before the first record and False (0) if the current record position is on or after the first record.

The EOF property returns True if the current record position is after the last record and False if the current record position is on or before the last record.

If either the BOF or EOF property is True, there is no current record, as shown in the following code:

Copy code Copy code

If oRs.BOF And oRs.EOF Then
 ' Command returned no records.
End If

If you open a Recordset object containing no records, the BOF and EOF properties are both set to True and the value of the Recordset object's RecordCount property setting depends on the cursor type. -1 will be returned for dynamic cursors (CursorType = adOpenDynamic) and 0 will be returned for other cursors.

When you open a Recordset object that contains at least one record, the first record is the current record and the BOF and EOF properties are False.

If you delete the last remaining record in the Recordset object, the cursor is left in an indeterminate state. The BOF and EOF properties may remain False until you attempt to reposition the current record, depending upon the provider.


You attempted to delete or get information about a partial filter that does not exist in MsysFilters. (Error 3505)

 Copy code hover
[image]

You attempted to delete or get information about a partial filter that does not exist in MsysFilters. (Error 3505)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


TabControl.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

TabControl.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents a TabControl object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.BorderThemeColorIndex=2

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


CommandButton.OnMouseDown Property (Access)

 Copy code hover
[image]

CommandButton.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Syntax

expression .OnMouseDown

expression A variable that represents a CommandButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


DataSpace (ADO/WFC Syntax)

 Copy code hover
[image]

DataSpace (ADO/WFC Syntax)
Send feedback

The createObject method of the DataSpace class specifies both a business object to process client application requests (progid) and the communications protocol and server (connection). createObject returns an ObjectProxy object that represents the server.

package com.ms.wfc.data

Constructor

Copy code Copy code

public DataSpace()

Methods

Copy code Copy code

public static ObjectProxyDataSpace.Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcreateobj_HV10294242.xml(String
 progid, String connection)

Properties

Copy code Copy code

public static int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprointernettimeout_HV10294450.xml()
public static void setInternetTimeout(int plInetTimeout)


The VBA file failed to initialize when called. Try reinstalling the application that returned the error. (Error 3447)

 Copy code hover
[image]

The VBA file failed to initialize when called. Try reinstalling the application that returned the error. (Error 3447)
Send feedback

The Microsoft Access database engine VBA file did not initialize when it was called. Try reinstalling the application that returned the error.


AcCloseSave Enumeration (Access)

 Copy code hover
[image]

AcCloseSave Enumeration (Access)
Send feedback

Published: July 16, 2012

Used by the Close method to specify whether or not to save an object upon closing.

Name

Value

Description

acSaveNo

2

The specified object is not saved.

acSavePrompt

0

The user is asked whether or not they want to save the object.

Note Note

This value is ignored if you are closing a Visual Basic module. The module will be closed, but changes to the module will not be saved.

acSaveYes

1

The specified object is saved.


Cannot use internal report query. (Error 3083)

 Copy code hover
[image]

Cannot use internal report query. (Error 3083)
Send feedback

You tried to use an SQL statement that includes an explicit reference to a disallowed internal report query. Remove the invalid reference and then try the operation again.


OptionButton.ReadingOrder Property (Access)

 Copy code hover
[image]

OptionButton.ReadingOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.

Syntax

expression .ReadingOrder

expression A variable that represents an OptionButton object.

Remarks

The ReadingOrder property uses the following settings.

Setting | Visual Basic | Description
Context | 0 | Reading order is determined by the language of the first character entered. If a right-to-left language character is entered first, reading order is right to left. If a left-to-right language character is entered first, reading order is left to right.
Left-to-Right | 1 | Sets the reading order to left to right.
Right-to-Left | 2 | Sets the reading order to right to left.

Example

The following example sets the reading order to right to left for the "Address" text box on the "International Shipping" form.

VBA Copy code Copy code
Forms("International Shipping").Controls("Address").ReadingOrder = 2

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


SubForm.HorizontalAnchor Property (Access)

 Copy code hover
[image]

SubForm.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the subform is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .HorizontalAnchor

expression A variable that represents a SubForm object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Report.Timer Event (Access)

 Copy code hover
[image]

Report.Timer Event (Access)
See also Send feedback

Published: July 16, 2012

The Timer event occurs for a report at regular intervals as specified by the report's TimerInterval property.

Version Information

Version Added: Access 2007

Syntax

expression .Timer

expression A variable that represents a Report object.

Remarks

To run a macro or event procedure when this event occurs, set the OnTimer property to the name of the macro or to [Event Procedure].

By running a macro or event procedure when a Timer event occurs, you can control what Microsoft Access does at every timer interval. For example, you might want to requery underlying records or repaint the screen at specified intervals.

The TimerInterval property setting of the report specifies the interval, in milliseconds, between Timer events. The interval can be between 0 and 2,147,483,647 milliseconds. Setting the TimerInterval property to 0 prevents the Timer event from occurring.

See also

Concepts

Report Object

Other resources

Report Object Members


How to: Mark a Position in a DAO Recordset

 Copy code hover
[image]

How to: Mark a Position in a DAO Recordset
Send feedback

A bookmark is a system-generated Byte array that uniquely identifies each record. The DAO Bookmark property of a Recordset object changes each time you move to a new record. To identify a record, move to that record and then assign the value of the DAO Bookmark property to a variable of type Variant. To return to the record, set the DAO Bookmark property to the value of the variable.

The following code example shows how to find the product that makes the most and least revenue per category by using a bookmark to save the current record position. By using a bookmark, you can perform other operations on the Recordset object, and then return to the saved record position.

VBA Copy code Copy code
Sub GetProductStats()

Dim dbsNorthwind As DAO.Database
Dim rstProducts As DAO.Recordset
Dim rstCategories As DAO.Recordset
Dim varFirstMark As Variant
Dim varHighMark As Variant
Dim varLowMark As Variant
Dim curHighRev As Currency
Dim curLowRev As Currency
Dim strSQL As String
Dim strCriteria As String
Dim strMessage As String

On Error GoTo ErrorHandler

   Set dbsNorthwind = CurrentDb

   strSQL = "SELECT * FROM Products WHERE UnitsOnOrder >= 40 " & _
            "ORDER BY CategoryID, UnitsOnOrder DESC"
   Set rstProducts = dbsNorthwind.OpenRecordset(strSQL, dbOpenSnapshot)
   If rstProducts.EOF Then Exit Sub

   StrSQL = "SELECT CategoryID, CategoryName FROM Categories " & _
            "ORDER BY CategoryID"
   Set rstCategories = dbsNorthwind.OpenRecordset(strSQL, dbOpenSnapshot)

   ' For each category find the product generating the least revenue
   ' and the product generating the most revenue.
   Do Until rstCategories.EOF

      strCriteria = "CategoryID = " & rstCategories![CategoryID]
      rstProducts.FindFirst strCriteria
      curHighRev = rstProducts![UnitPrice] * rstProducts![UnitsOnOrder]

      If Not rstProducts.NoMatch Then

         ' Set bookmarks at the first record containing the CategoryID.
         varFirstMark = rstProducts.Bookmark
         varHighMark = varFirstMark
         varLowMark = varFirstMark

         ' Find the product generating the most revenue.
         Do While rstProducts![CategoryID] = rstCategories![CategoryID]
            If rstProducts![UnitPrice] * rstProducts![UnitsOnOrder] > _
            curHighRev Then
               curHighRev = rstProducts![UnitPrice] * _
                            rstProducts![UnitsOnOrder]
               varHighMark = rstProducts.Bookmark
            End If
            rstProducts.MoveNext
         Loop

         ' Move to the first record containing the CategoryID.
         rstProducts.Bookmark = varFirstMark
         curLowRev = rstProducts![UnitPrice] * rstProducts![UnitsOnOrder]

         ' Find the product generating the least revenue.
         Do While rstProducts![CategoryID] = rstCategories![CategoryID]
            If rstProducts![UnitPrice] * rstProducts![UnitsOnOrder] < _
            curLowRev Then
               curLowRev = rstProducts![UnitPrice] * _
                           rstProducts![UnitsOnOrder]
               varLowMark = rstProducts.Bookmark
            End If
            rstProducts.MoveNext
         Loop

      End If

      ' Set high and low bookmarks to build the message string.
      strMessage = "CATEGORY:  " & rstCategories!CategoryName & _
                   vbCrLf & vbCrLf
      rstProducts.Bookmark = varHighMark
      strMessage = strMessage & "HIGH: $" & curHighRev & "  " & _
                   rstProducts!ProductName & vbCrLf
      rstProducts.Bookmark = varLowMark
      strMessage = strMessage & "LOW:  $" & curLowRev & "  " & _
                   rstProducts!ProductName
      MsgBox strMessage, , "Product Statistics"
      rstCategories.MoveNext
   Loop

   rstProducts.Close
   rstCategories.Close
   dbsNorthwind.Close

   Set rstProducts = Nothing
   Set rstCategories = Nothing
   Set dbsNorthwind = Nothing

Exit Sub

ErrorHandler:
   MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Sub

A bookmark is useful if a method fails because the current record position is undefined.

The LastModified property of the Recordset object provides a good illustration of how to use a bookmark. The LastModified property returns the bookmark of the last record in the Recordset to be added or modified. To use it, set the DAO Bookmark property equal to the LastModified property, as follows.

VBA Copy code Copy code
rstCustomers.Bookmark = rstCustomers.LastModified

This moves the current record position to the last record that was added or modified. This is particularly useful when adding new records, because after you add a new record, the current record is the one you were on before you added the record. With the LastModified property, you can move to the newly added record if that is what your application expects.

When you close a Recordset object, any bookmarks you saved become invalid. You cannot use a bookmark from one Recordset in another Recordset, even if both Recordset objects are based on the same underlying table or query. However, you can use a bookmark on the clone of a Recordset, as shown in the following example.

VBA Copy code Copy code
Dim dbsNorthwind As DAO.Database
Dim rstOriginal As DAO.Recordset
Dim rstDuplicate As DAO.Recordset
Dim varBookMark As Variant

   Set dbsNorthwind = CurrentDb

   ' Create the first Recordset.
   Set rstOriginal = dbsNorthwind.OpenRecordset("Orders", dbOpenDynaset)

   ' Save the current record position.
   varBookMark = rstOriginal.Bookmark

   ' Create a duplicate Recordset.
   Set rstDuplicate = rstOriginal.Clone()

   ' Go to the same record.
   rstDuplicate.Bookmark = varBookMark

   rstOriginal.Close

You can also use the DAO Bookmark property on the Recordset object underlying a form. With this property, your code can mark which record is currently displayed on the form, and then change the record that is being displayed. For example, on a form containing employee information, you may want to include a button that a user can click to show the record for an employee's supervisor.

Note Note

Dynasets based on certain linked tables, such as Paradox tables that have no primary key, do not support bookmarks, nor do forward-only-type Recordset objects. You can determine whether a given Recordset object supports bookmarks by checking the value of the Bookmarkable property.


OptionButton.Controls Property (Access)

 Copy code hover
[image]

OptionButton.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Syntax

expression .Controls

expression A variable that represents an OptionButton object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Parameters Collection (DAO)

 Copy code hover
[image]

Parameters Collection (DAO)
Send feedback

A Parameters collection contains all the Parameter objects of a QueryDef object.

Remarks

The Parameters collection provides information only about existing parameters. You can't append objects to or delete objects from the Parameters collection.

Example

This example demonstrates Parameter objects and the Parameters collection by creating a temporary QueryDef and retrieving data based on changes made to the QueryDef object's Parameters. The ParametersChange procedure is required for this procedure to run.

VBA Copy code Copy code
Sub ParameterX()

   Dim dbsNorthwind As Database
   Dim qdfReport As QueryDef
   Dim prmBegin As Parameter
   Dim prmEnd As Parameter

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   ' Create temporary QueryDef object with two
   ' parameters.
   Set qdfReport = dbsNorthwind.CreateQueryDef("", _
      "PARAMETERS dteBegin DateTime, dteEnd DateTime; " & _
      "SELECT EmployeeID, COUNT(OrderID) AS NumOrders " & _
      "FROM Orders WHERE ShippedDate BETWEEN " & _
      "[dteBegin] AND [dteEnd] GROUP BY EmployeeID " & _
      "ORDER BY EmployeeID")
   Set prmBegin = qdfReport.Parameters!dteBegin
   Set prmEnd = qdfReport.Parameters!dteEnd

   ' Print report using specified parameter values.
   ParametersChange qdfReport, prmBegin, #1/1/95#, _
      prmEnd, #6/30/95#
   ParametersChange qdfReport, prmBegin, #7/1/95#, _
      prmEnd, #12/31/95#

   dbsNorthwind.Close

End Sub

Sub ParametersChange(qdfTemp As QueryDef, _
   prmFirst As Parameter, dteFirst As Date, _
   prmLast As Parameter, dteLast As Date)
   ' Report function for ParameterX.

   Dim rstTemp As Recordset
   Dim fldLoop As Field

   ' Set parameter values and open recordset from
   ' temporary QueryDef object.
   prmFirst = dteFirst
   prmLast = dteLast
   Set rstTemp = _
      qdfTemp.OpenRecordset(dbOpenForwardOnly)
   Debug.Print "Period " & dteFirst & " to " & dteLast

   ' Enumerate recordset.
   Do While Not rstTemp.EOF

      ' Enumerate Fields collection of recordset.
      For Each fldLoop In rstTemp.Fields
         Debug.Print " - " & fldLoop.Name & " = " & fldLoop;
      Next fldLoop

      Debug.Print
      rstTemp.MoveNext
   Loop

   rstTemp.Close

End Sub

The following example shows how to create a parameter query. A query named myQuery is created with two parameters, named Param1 and Param2. To do this, the SQL property of the query is set to a Structured Query Language (SQL) statement that defines the parameters.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Sub CreateQueryWithParameters()

    Dim dbs As DAO.Database
    Dim qdf As DAO.QueryDef
    Dim strSQL As String

    Set dbs = CurrentDb
    Set qdf = dbs.CreateQueryDef("myQuery")
    Application.RefreshDatabaseWindow

    strSQL = "PARAMETERS Param1 TEXT, Param2 INT; "
    strSQL = strSQL & "SELECT * FROM [Table1] "
    strSQL = strSQL & "WHERE [Field1] = [Param1] AND [Field2] = [Param2];"
    qdf.SQL = strSQL

    qdf.Close
    Set qdf = Nothing
    Set dbs = Nothing

End Sub

The following example shows how to execute a parameter query. The Parameters collection is used to set the Organization parameter of the myActionQuery query before the query is executed.

VBA Copy code Copy code
Public Sub ExecParameterQuery()

    Dim dbs As DAO.Database
    Dim qdf As DAO.QueryDef

    Set dbs = CurrentDb
    Set qdf = dbs.QueryDefs("myActionQuery")

    'Set the value of the QueryDef's parameter
    qdf.Parameters("Organization").Value = "Microsoft"

    'Execute the query
    qdf.Execute dbFailOnError

    'Clean up
    qdf.Close
    Set qdf = Nothing
    Set dbs = Nothing

End Sub

The following example shows how to open a Recordset that is based on a parameter query.

VBA Copy code Copy code
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset

Set dbs = CurrentDb

'Get the parameter query
Set qfd = dbs.QueryDefs("qryMyParameterQuery")

'Supply the parameter value
qdf.Parameters("EnterStartDate") = Date
qdf.Parameters("EnterEndDate") = Date + 7

'Open a Recordset based on the parameter query
Set rst = qdf.OpenRecordset()

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Replica has not been synchronized within the replica set retention period. (Error 3743)

 Copy code hover
[image]

Replica has not been synchronized within the replica set retention period. (Error 3743)
Send feedback

If the retention period expires for a replica, you cannot synchronize changes between the expired replica and the other replicas in the replica set. If a replica does not synchronize with another replica in the set within the retention period, the next time you attempt to synchronize the replica it gets removed from the replica set. The retention period is established when the database is initially made replicable. If you replicate the database by using Replication Manager, Data Access Objects (DAO), or ActiveX Data Objects (ADO), the default retention period is 60 days. If you replicate the database by using Microsoft Access or Briefcase, the default retention period is 1000 days.


NavigationButton.FontName Property (Access)

 Copy code hover
[image]

NavigationButton.FontName Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontName property to specify the font for text in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .FontName

expression A variable that represents a NavigationButton object.

Remarks

The FontName property setting is the name of the font that the text is displayed in.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set this property only in an event procedure or in a macro specified by the OnPrint event property setting.

Font availability depends on your system and printer. If you select a font that your system can't display or that isn't installed, Windows substitutes a similar font.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Application.DSum Method (Access)

 Copy code hover
[image]

Application.DSum Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the DSum function to calculate the sum of a set of values in a specified set of records (a domain). .

Syntax

expression .DSum(Expr, Domain, Criteria)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Expr | Required | String | An expression that identifies the numeric field whose values you want to total. It can be a string expression identifying a field in a table or query, or it can be an expression that performs a calculation on data in that field . In expr, you can include the name of a field in a table, a control on a form, a constant, or a function. If expr includes a function, it can be either built-in or user-defined, but not another domain aggregate or SQL aggregate function.
Domain | Required | String | A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter.
Criteria | Optional | Variant | An optional string expression used to restrict the range of data on which the DSum function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the DSum function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain; otherwise, the DSum function returns a Null.

Return Value

Variant

Remarks

For example, you could use the DSum function in a calculated field expression in a query to calculate the total sales made by a particular employee over a period of time. Or you could use the DSum function in a calculated control to display a running sum of sales for a particular product.

If no record satisfies the criteria argument or if domain contains no records, the DSum function returns a Null.

Whether you use the DSum function in a macro, module, query expression, or calculated control, you must construct the criteria argument carefully to ensure that it will be evaluated correctly.

You can use the DSum function to specify criteria in the Criteria row of a query, in a calculated field in a query expression, or in the Update To row of an update query.

Note Note

You can use either the DSum or Sum function in a calculated field expression in a totals query. If you use the DSum function, values are calculated before data is grouped. If you use the Sum function, the data is grouped before values in the field expression are evaluated.

You may want to use the DSum function when you need to display the sum of a set of values from a field that is not in the record source for your form or report. For example, suppose you have a form that displays information about a particular product. You could use the DSum function to maintain a running total of sales of that product in a calculated control.

If you need to maintain a running total in a control on a report, you can use the RunningSum property of that control if the field on which it is based is included in the record source for the report. Use the DSum function to maintain a running sum on a form.

Example

The following example totals the values from the Freight field for orders shipped to the United Kingdom. The domain is an Orders table. The criteria argument restricts the resulting set of records to those for which ShipCountry equals UK.

VBA Copy code Copy code
Dim curX As Currency
curX = DSum("[Freight]", "Orders", "[ShipCountry] = 'UK'")

The next example calculates a total by using two separate criteria. Note that single quotation marks (') and number signs (#) are included in the string expression, so that when the strings are concatenated, the string literal will be enclosed in single quotation marks, and the date will be enclosed in number signs.

VBA Copy code Copy code
Dim curX As Currency
curX = DSum("[Freight]", "Orders", _
    "[ShipCountry] = 'UK' AND [ShippedDate] > #1-1-95#")

The following examples show how to use various types of criteria with the DSum function.

Sample code provided by: Community Member Icon The UtterAccess community | About the Contributors

Copy code Copy code
    ' ***************************
    ' Typical Use
    ' Numerical values. Replace "number" with the number to use.
    variable = DSum("[FieldName]", "TableName", "[Criteria] = number")

    ' Strings.
    ' Numerical values. Replace "string" with the string to use.
    variable = DSum("[FieldName]", "TableName", "[Criteria]= 'string'")

    ' Dates. Replace "date" with the string to use.
    variable = DSum("[FieldName]", "TableName", "[Criteria]= #date#")
    ' ***************************

    ' ***************************
    ' Referring to a control on a form
    ' Numerical values
    variable = DSum("[FieldName]", "TableName", "[Criteria] = " & Forms!FormName!ControlName)

    ' Strings
    variable = DSum("[FieldName]", "TableName", "[Criteria] = '" & Forms!FormName!ControlName & "'")

    ' Dates
    variable = DSum("[FieldName]", "TableName", "[Criteria] = #" & Forms!FormName!ControlName & "#")
    ' ***************************

    ' ***************************
    ' Combinations
    ' Multiple types of criteria
    variable = DSum("[FieldName]", "TableName", "[Criteria1] = " & Forms![FormName]![Control1] _
             & " AND [Criteria2] = '" & Forms![FormName]![Control2] & "'" _
            & " AND [Criteria3] =#" & Forms![FormName]![Control3] & "#")

    ' Use two fields from a single record.
    variable = DSum("[LastName] & ', ' & [FirstName]", "tblPeople", "[PrimaryKey] = 7")

    ' Expressions
    variable = DSum("[Field1] + [Field2]", "tableName", "[PrimaryKey] = 7")

    ' Control Structures
    variable = DSum("IIf([LastName] Like 'Smith', 'True', 'False')", "tableName", "[PrimaryKey] = 7")
    ' ***************************

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Application Object

Other resources

Application Object Members


Table Object (ADOX)

 Copy code hover
[image]

Table Object (ADOX)
Send feedback

Represents a database table including columns, indexes, and keys.

Remarks

The following code creates a new Table:

Copy code Copy code
Dim obj As New Table

With the properties and collections of a Table object, you can:

  • Identify the table with the Name property.

  • Determine the type of table with the Type property.

  • Access the database columns of the table with the Columns collection.

  • Access the indexes of the table with the Indexes collection.

  • Access the keys of the table with the Keys collection.

  • Specify the Catalog that owns the table with the ParentCatalog property.

  • Return date information with the DateCreated and DateModified properties.

  • Access provider-specific table properties with the Properties collection.

Note Note

Your data provider may not support all properties of Table objects. An error will occur if you have set a value for a property that the provider does not support. For new Table objects, the error will occur when the object is appended to the collection. For existing objects, the error will occur when setting the property.

When creating Table objects, the existence of an appropriate default value for an optional property does not guarantee that your provider supports the property. For more information about which properties your provider supports, see your provider documentation.


NavigationButton.GridlineStyleTop Property (Access)

 Copy code hover
[image]

NavigationButton.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleTop

expression A variable that represents a NavigationButton object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Form.WindowHeight Property (Access)

 Copy code hover
[image]

Form.WindowHeight Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the height of a form in twips. Read-only Integer.

Syntax

expression .WindowHeight

expression A variable that represents a Form object.

Remarks

The WindowHeight property is measured from the upper-left corner of the form to its lower-left corner.

See also

Concepts

Form Object

Other resources

Form Object Members


ListBox.OldValue Property (Access)

 Copy code hover
[image]

ListBox.OldValue Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.

Syntax

expression .OldValue

expression A variable that represents a ListBox object.

Remarks

The OldValue property contains the unedited data from a bound control and is read-only in all views.

Microsoft Access uses the OldValue property to store the original value of a bound control. When you edit a bound control on a form, your changes aren't saved until you move to another record. The OldValue property contains the unedited version of the underlying data.

You can provide your own undo capability by assigning the OldValue property setting to a control. The following example shows how you can undo any changes to text box controls on a form:

VBA Copy code Copy code
Private Sub btnUndo_Click()

 Dim ctlTextbox As Control

 For Each ctlTextbox in Me.Controls
 If ctlTextbox.ControlType = acTextBox Then
 ctlTextbox.Value = ctl.OldValue
 End If
 Next ctlTextbox

End Sub

If the control hasn't been edited, this code has no effect. When you move to another record, the record source is updated, so the current value and the OldValue property will be the same.

The OldValue property setting has the same data type as the field to which the control is bound.

Example

The following example checks to determine if new data entered in a field is within 10 percent of the value of the original data. If the change is greater than 10 percent, the OldValue property is used to restore the original value. This procedure could be called from the BeforeUpdate event of the control that contains data you want to validate.

VBA Copy code Copy code
Public Sub Validate_Field()

 Dim curNewValue As Currency
 Dim curOriginalValue As Currency
 Dim curChange As Currency
 Dim strMsg As String

 curNewValue = Forms!Products!UnitPrice
 curOriginalValue = Forms!Products!UnitPrice.OldValue
 curChange = Abs(curNewValue - curOriginalValue)

 If curChange > (curOriginalValue * .1) Then
 strMsg = "Change is more than 10% of original unit price. " _
 & "Restoring original unit price."
 MsgBox strMsg, vbExclamation, "Invalid change."
 Forms!Products!UnitPrice = curOriginalValue
 End If

End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Syntax error in partial filter expression on table

 Copy code hover
[image]

Syntax error in partial filter expression on table <name>. (Error 3586)
Send feedback

Make sure you are using the correct syntax in the expression.


SubForm.LeftPadding Property (Access)

 Copy code hover
[image]

SubForm.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the subform and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .LeftPadding

expression A variable that represents a SubForm object.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


OptionGroup.SizeToFit Method (Access)

 Copy code hover
[image]

OptionGroup.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents an OptionGroup object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


ObjectFrame.Height Property (Access)

 Copy code hover
[image]

ObjectFrame.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Syntax

expression .Height

expression A variable that represents an ObjectFrame object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Attachment.SetFocus Method (Access)

 Copy code hover
[image]

Attachment.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Version Information

Version Added: Access 2007

Syntax

expression .SetFocus

expression A variable that represents an Attachment object.

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

Other properties can be set only when a control does not have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a questionnaire form, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Recordset.BatchCollisions Property (DAO)

 Copy code hover
[image]

Recordset.BatchCollisions Property (DAO)
Send feedback

Syntax

expression .BatchCollisions

expression A variable that represents a Recordset object.

Remarks

This property contains an array of bookmarks to rows that encountered a collision during the last attempted batch Update call. The BatchCollisionCount property indicates the number of elements in the array.

If you set the working Recordset object's Bookmark property to bookmark values in the BatchCollisions array, you can move to each record that failed to complete the most recent batch-mode Update operation.

After the collision records are corrected, you can call the batch mode Update method again. At this point DAO attempts another batch update, and the BatchCollisions property again reflects the set of records that failed the second attempt. Any records that succeeded in the previous attempt are not sent in the current attempt, as they now have a RecordStatus property of dbRecordUnmodified. This process can continue as long as collisions occur, or until you abandon the updates and close the result set.

This array is re-created each time you execute a batch-mode Update method.


BoundObjectFrame.Height Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Syntax

expression .Height

expression A variable that represents a BoundObjectFrame object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


ExecuteOptions and FetchOptions Properties Example (VBScript)

 Copy code hover
[image]

ExecuteOptions and FetchOptions Properties Example (VBScript)
Send feedback

The following code shows how to set the ExecuteOptions and FetchOptions properties at design time. If left unset, ExecuteOptions defaults to adcExecSync. This setting indicates that when the RDS.Refresh method is called, it will be executed on the current calling thread — that is, synchronously. Cut and paste the following code to Notepad or another text editor and save it as ExecuteOptionsDesignVBS.asp.

VBS Copy code Copy code
<!-- BeginExecuteOptionsDesignVBS --><%@ Language=VBScript %>
<html><head>
<meta name="VI60_DefaultClientScript" content=VBScript><meta name="GENERATOR" content="Microsoft Visual Studio 6.0">
<title>Design-time ExecuteOptions and FetchOptions Properties Example</title><style>
<!--body {
font-family: 'Verdana','Arial','Helvetica',sans-serif;BACKGROUND-COLOR:white;
COLOR:black;}
.thead {background-color: #008080;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.thead2 {background-color: #800000;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.tbody {text-align: center;
background-color: #f7efde;font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;}
--></style>
</head>
<body><h2>Design-time <br> ExecuteOptions and FetchOptions Properties Example</h2>
<OBJECT CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID=RDS height=1 width=1><PARAM NAME="SQL" VALUE="SELECT FirstName, LastName FROM Employees ORDER BY LastName">
<PARAM NAME="Connect" VALUE="Provider='sqloledb';Data Source=<%=Request.ServerVariables("SERVER_NAME")%>;Integrated Security='SSPI';Initial Catalog='Northwind'"><PARAM NAME="Server" VALUE="http://<%=Request.ServerVariables("SERVER_NAME")%>">
<PARAM NAME="ExecuteOptions" VALUE="1"><PARAM NAME="FetchOptions" VALUE="3">
</OBJECT>
<TABLE DATASRC=#RDS><TBODY>
<TR class="thead2"><TH>First Name</TH>
<TH>Last Name</TH></TR>
<TR class="tbody"><TD><SPAN DATAFLD="FirstName"></SPAN></TD>
<TD><SPAN DATAFLD="LastName"></SPAN></TD></TR>
</TBODY></TABLE>
</body></html>
<!-- EndExecuteOptionsDesignVBS -->

The following example shows how to set the ExecuteOptions and FetchOptions properties at run time in VBScript code. See the Refresh method for a working example of these properties. Cut and paste the following code to Notepad or another text editor and save it as ExecuteOptionsRuntimeVBS.asp.

VBS Copy code Copy code
<!-- BeginExecuteOptionsRuntimeVBS --><%@ Language=VBScript %>
<html><head>
<meta name="VI60_DefaultClientScript" content=VBScript><meta name="GENERATOR" content="Microsoft Visual Studio 6.0">
<title>Run-time ExecuteOptions and FetchOptions Properties Example</title><style>
<!--body {
font-family: 'Verdana','Arial','Helvetica',sans-serif;BACKGROUND-COLOR:white;
COLOR:black;}
.thead {background-color: #008080;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.thead2 {background-color: #800000;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.tbody {text-align: center;
background-color: #f7efde;font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;}
--></style>
</head>
<body><h2>Run-time <br> ExecuteOptions and FetchOptions Properties Example</h2>
<OBJECT CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID=RDS height=1 width=1><PARAM NAME="SQL" VALUE="SELECT FirstName, LastName FROM Employees ORDER BY LastName">
<PARAM NAME="Connect" VALUE="Provider='sqloledb';Data Source=<%=Request.ServerVariables("SERVER_NAME")%>;Integrated Security='SSPI';Initial Catalog='Northwind'"><PARAM NAME="Server" VALUE="http://<%=Request.ServerVariables("SERVER_NAME")%>">
</OBJECT>
<TABLE DATASRC=#RDS><TBODY>
<TR class="thead2"><TH>First Name</TH>
<TH>Last Name</TH></TR>
<TR class="tbody"><TD><SPAN DATAFLD="FirstName"></SPAN></TD>
<TD><SPAN DATAFLD="LastName"></SPAN></TD></TR>
</TBODY></TABLE>
<Script Language="VBScript">Const adcExecSync = 1
Const adcFetchAsynch = 3
Sub ExecuteHow' set RDS properties at run-time
RDS1.ExecuteOptions = adcExecSyncRDS1.FetchOptions = adcFetchAsynch
RDS.RefreshEnd Sub
</Script></body>
</html><!-- EndExecuteOptionsRuntimeVBS -->


ToggleButton.OnClick Property (Access)

 Copy code hover
[image]

ToggleButton.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Syntax

expression .OnClick

expression A variable that represents a ToggleButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


TextBox.Properties Property (Access)

 Copy code hover
[image]

TextBox.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a TextBox object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


CustomControl.Application Property (Access)

 Copy code hover
[image]

CustomControl.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a CustomControl object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Local or Anonymous replicas must synch only to their designated hub replica. (Error 3738)

 Copy code hover
[image]

Local or Anonymous replicas must synch only to their designated hub replica. (Error 3738)
Send feedback

The source replica is a Local or Anonymous replica; you are trying to exchange to the wrong hub replica. You can only synchronize a Local or Anonymous replica with the Global replica that created it.


FormatConditions Properties (Access)

 Copy code hover
[image]

FormatConditions Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only FormatCondition.
Parent | Returns the parent object for the specified object. Read-only.


ListBox.ColumnHidden Property (Access)

 Copy code hover
[image]

ListBox.ColumnHidden Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.

Syntax

expression .ColumnHidden

expression A variable that represents a ListBox object.

Remarks

For example, you might want to hide a CustomerAddress field that's too wide so you can view the CustomerName and PhoneNumber fields.

Note Note

The ColumnHidden property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

Hiding a column with the ColumnHidden property in Datasheet view doesn't hide fields from the same column in Form view. Similarly, setting a control's Visible property to False in Form view doesn't hide the corresponding column in Datasheet view.

Note Note

To set or change this property for a table or query by using Visual Basic, you must use a column's Properties collection. For details on using the Properties collection, see Properties .

You can display a field in a query even though the column for the field is hidden in table Datasheet view. You can use values from a hidden column as the criteria for a filter even though the column remains hidden after the filter is applied.

Setting a field's ColumnWidth property to 0, or resizing the field to a zero width in Datasheet view, causes Microsoft Access to set the corresponding ColumnHidden property to True. Unhiding a column restores the ColumnWidthColumnWidth property to the value it had before the field was hidden.

Note Note

The ColumnHidden property is not available in Design view.

Example

The following example hides the ProductID field in Datasheet view of the Products form.

VBA Copy code Copy code
Forms!Products!ProductID.ColumnHidden = -1

The next example also hides the ProductID field in Datasheet view of the Products table.

VBA Copy code Copy code
Public Sub SetColumnHidden()

 Dim dbs As DAO.Database
 Dim fld As DAO.Field
 Dim prp As DAO.Property
 Const conErrPropertyNotFound = 3270

 ' Turn off error trapping.
 On Error Resume Next

 Set dbs = CurrentDb

 ' Set field property.
 Set fld = dbs.TableDefs!Products.Fields!ProductID
 fld.Properties("ColumnHidden") = True

 ' Error may have occurred when value was set.
 If Err.Number <> 0 Then
 If Err.Number <> conErrPropertyNotFound Then
 On Error GoTo 0
 MsgBox "Couldn't set property 'ColumnHidden' " & _
 "on field '" & fld.Name & "'", vbCritical
 Else
 On Error GoTo 0
 Set prp = fld.CreateProperty("ColumnHidden", dbLong, True)
 fld.Properties.Append prp
 End If
 End If

 Set prp = Nothing
 Set fld = Nothing
 Set dbs = Nothing

End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Page Events (Access)

 Copy code hover
[image]

Page Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.


NavigationButton.FontSize Property (Access)

 Copy code hover
[image]

NavigationButton.FontSize Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontSize property to specify the point size for text in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .FontSize

expression A variable that represents a NavigationButton object.

Remarks

The FontSize property uses the following settings.

Setting | Description
8 | (Default for all reports and controls except command buttons) The text is 8-point type.
10 | (Default for command buttons) The text is 10-point type.
Other sizes | The text is the indicated size.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set this property only in an event procedure or in a macro specified by the OnPrint event property setting.

In Visual Basic, you set the FontSize property by using a numeric expression equal to the desired size of the font. The setting for the FontSize property can be between 1 and 127, inclusive.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Module.InsertLines Method (Access)

 Copy code hover
[image]

Module.InsertLines Method (Access)
See also Send feedback

Published: July 16, 2012

The InsertLines method inserts a line or group of lines of code in a standard module or a class module.

Syntax

expression .InsertLines(Line, String)

expression A variable that represents a Module object.

Parameters

Name | Required/Optional | Data Type | Description
Line | Required | Long | The number of the line at which to begin inserting.
String | Required | String | The text to be inserted into the module.

Return Value

Nothing

Remarks

To add multiple lines, include the intrinsic constant vbCrLf at the desired line breaks within the string that makes up the string argument. This constant forces a carriage return and line feed.

When you use the InsertLines method, any existing code at the line specified by the line argument moves down.

Lines in a module are numbered beginning with one. To determine the number of lines in a module, use the CountOfLines property.

Example

The following example creates a new form, adds a command button, and creates a Click event procedure for the command button:

VBA Copy code Copy code
Function ClickEventProc() As Boolean
 Dim frm As Form, ctl As Control, mdl As Module
 Dim lngReturn As Long

 On Error GoTo Error_ClickEventProc
 ' Create new form.
 Set frm = CreateForm
 ' Create command button on form.
 Set ctl = CreateControl(frm.Name, acCommandButton, , , , _
 1000, 1000)
 ctl.Caption = "Click here"
 ' Return reference to form module.
 Set mdl = frm.Module
 ' Add event procedure.
 lngReturn = mdl.CreateEventProc("Click", ctl.Name)
 ' Insert text into body of procedure.
 mdl.InsertLines lngReturn + 1, vbTab & "MsgBox ""Way cool!"""
 ClickEventProc = True

Exit_ClickEventProc:
 Exit Function

Error_ClickEventProc:
 MsgBox Err & " :" & Err.Description
 ClickEventProc = False
 Resume Exit_ClickEventProc
End Function

See also

Concepts

Module Object

Other resources

Module Object Members


ComboBox.FontUnderline Property (Access)

 Copy code hover
[image]

ComboBox.FontUnderline Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontUnderline property to specify whether text is underlined in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontUnderline

expression A variable that represents a ComboBox object.

Remarks

The FontUnderline property uses the following settings.

Setting | Description
True | The text is underlined.
False | (Default) The text isn't underlined.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


TextBox.OnClick Property (Access)

 Copy code hover
[image]

TextBox.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Syntax

expression .OnClick

expression A variable that represents a TextBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ObjectFrame.MouseDown Event (Access)

 Copy code hover
[image]

ObjectFrame.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents an ObjectFrame object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
         Shift As Integer, X As Single, _
         Y As Single)
    If Button = acLeftButton Then
        MsgBox "You pressed the left button."
    End If
    If Button = acRightButton Then
        MsgBox "You pressed the right button."
    End If
    If Button = acMiddleButton Then
        MsgBox "You pressed the middle button."
    End If
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


CustomControl.Requery Method (Access)

 Copy code hover
[image]

CustomControl.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.

Syntax

expression .Requery

expression A variable that represents a CustomControl object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts .

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate function.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

Example

The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form:

VBA Copy code Copy code
Public Sub RequeryList()

    Dim ctlCombo As Control

    ' Return Control object pointing to a combo box.
    Set ctlCombo = Forms!Employees!ReportsTo

    ' Requery source of data for list box.
    ctlCombo.Requery

End Sub

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Report.WindowWidth Property (Access)

 Copy code hover
[image]

Report.WindowWidth Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the width of a report in twips. Read-only Integer.

Syntax

expression .WindowWidth

expression A variable that represents a Report object.

Remarks

The WindowWidth property is measured from the upper-left corner of the report to its upper-right corner.

See also

Concepts

Report Object

Other resources

Report Object Members


Field2.OrdinalPosition Property (DAO)

 Copy code hover
[image]

Field2.OrdinalPosition Property (DAO)
Send feedback

Sets or returns the relative position of a Field2 object within a Fields collection. .

Syntax

expression .OrdinalPosition

expression A variable that represents a Field2 object.

Remarks

For an object not yet appended to the Fields collection, this property is read/write.

The default is 0.

The availability of the OrdinalPosition property depends on the object that contains the Fields collection, as shown in the following table.

If the Fields collection belongs to a | Then OrdinalPosition is
Index object | Not supported
QueryDef object | Read-only
Recordset object | Read-only
Relation object | Not supported
TableDef object | Read/write

Generally, the ordinal position of an object that you append to a collection depends on the order in which you append the object. The first appended object is in the first position (0), the second appended object is in the second position (1), and so on. The last appended object is in ordinal position count - 1, where count is the number of objects in the collection as specified by the Count property setting.

You can use the OrdinalPosition property to specify an ordinal position for new Field2 objects that differs from the order in which you append those objects to a collection. This enables you to specify a field order for your tables, queries, and recordsets when you use them in an application. For example, the order in which fields are returned in a SELECT * query is determined by the current OrdinalPosition property values.

You can permanently reset the order in which fields are returned in recordsets by setting the OrdinalPosition property to any positive integer.

Two or more Field2 objects in the same collection can have the same OrdinalPosition property value, in which case they will be ordered alphabetically. For example, if you have a field named Age set to 4 and you set a second field named Weight to 4, Weight is returned after Age.

You can specify a number that is greater than the number of fields minus 1. The field will be returned in an order relative to the largest number. For example, if you set a field's OrdinalPosition property to 20 (and there are only 5 fields) and you've set the OrdinalPosition property for two other fields to 10 and 30, respectively, the field set to 20 is returned between the fields set to 10 and 30.

Note Note

Even if the Fields collection of a TableDef has not been refreshed, the field order in a Recordset opened from the TableDef will reflect the OrdinalPosition data of the TableDef object. A table-type Recordset will have the same OrdinalPosition data as the underlying table, but any other type of Recordset will have new OrdinalPosition data (starting with 0) that follow the order determined by the OrdinalPosition data of the TableDef.

Example

This example changes the OrdinalPosition property values in the Employees TableDef in order to control the Field2 order in a resulting Recordset. By setting the OrdinalPosition of all the Fields to 1, any resulting Recordset will order the Fields alphabetically. Note that the OrdinalPosition values in the Recordset don't match the values in the TableDef, but simply reflect the end result of the TableDef changes.

VBA Copy code Copy code
Sub OrdinalPositionX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim aintPosition() As Integer
 Dim astrFieldName() As String
 Dim intTemp As Integer
 Dim fldTemp As Field2
 Dim rstEmployees As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set tdfEmployees = dbsNorthwind.TableDefs("Employees")

 With tdfEmployees
 ' Display and store original OrdinalPosition data.
 Debug.Print _
 "Original OrdinalPosition data in TableDef."
 ReDim aintPosition(0 To .Fields.Count - 1) As Integer
 ReDim astrFieldName(0 To .Fields.Count - 1) As String
 For intTemp = 0 To .Fields.Count - 1
 aintPosition(intTemp) = _
 .Fields(intTemp).OrdinalPosition
 astrFieldName(intTemp) = .Fields(intTemp).Name
 Debug.Print , aintPosition(intTemp), _
 astrFieldName(intTemp)
 Next intTemp

 ' Change OrdinalPosition data.
 For Each fldTemp In .Fields
 fldTemp.OrdinalPosition = 1
 Next fldTemp

 ' Open new Recordset object to show how the
 ' OrdinalPosition data has affected the record order.
 Debug.Print _
 "OrdinalPosition data from resulting Recordset."
 Set rstEmployees = dbsNorthwind.OpenRecordset( _
 "SELECT * FROM Employees")
 For Each fldTemp In rstEmployees.Fields
 Debug.Print , fldTemp.OrdinalPosition, fldTemp.Name
 Next fldTemp
 rstEmployees.Close

 ' Restore original OrdinalPosition data because this is
 ' a demonstration.
 For intTemp = 0 To .Fields.Count - 1
 .Fields(astrFieldName(intTemp)).OrdinalPosition = _
 aintPosition(intTemp)
 Next intTemp

 End With

 dbsNorthwind.Close

End Sub


At most one record can be returned by this subquery. (Error 3354)

 Copy code hover
[image]

At most one record can be returned by this subquery. (Error 3354)
Send feedback

A subquery of this kind cannot return more than one record. Revise the SELECT statement of the subquery to request only one record.


DoCmd.SetParameter Method (Access)

 Copy code hover
[image]

DoCmd.SetParameter Method (Access)
See also Send feedback

Published: July 16, 2012

Use the SetParameter method to create a parameter for use by the BrowseTo , OpenForm, OpenQuery, OpenReport, or RunDataMacro methods.

Version Information

Version Added: Access 2010

Syntax

expression .SetParameter(Name, Expression)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Required | Variant | The name of the parameter. The name must match the name of the parameter expected by the BrowseTo, OpenForm, OpenQuery, OpenReport, or RunDataMacro method.
Expression | Required | Variant | An expression that evaluates to a value to assign to the parameter.

Remarks

You must create as many calls to the SetParameter method as are necessary to create the parameters you need.

Each call to SetParameter adds or updates a single parameter in an internal parameters collection. The parameters collection is passed to the BrowseTo, OpenForm, OpenQuery, OpenReport, or RunDataMacro method. When the method is run the parameters collection supplies the needed parameters. When the method is finished the parameters collection is cleared.

Because each of the methods that accepts parameters clears the parameters collection when it completes, you must ensure that your calls to SetParameter immediately precede the call to the method that employs them.

Example

The following code example creates two parameters for use by the AddComment data macro. The two parameters are named prmComment and prmRelatedID, respectively. The value of the txtComment textbox is stored in the prmComment parameter. The value of the txtId textbox is stored in the prmRelatedID parameter.

VBA Copy code Copy code
Private Sub cmdAddComment_Click()
DoCmd.SetParameter "prmComment", Me.txtComment
DoCmd.SetParameter "prmRelatedID", Me.txtId
DoCmd.RunDataMacro "Comments.AddComment"
End Sub

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Synchronizer could not find a replica from the correct set to complete the synchronization. (Error 3547)

 Copy code hover
[image]

Synchronizer could not find a replica from the correct set to complete the synchronization. (Error 3547)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


OptionButton.MouseUp Event (Access)

 Copy code hover
[image]

OptionButton.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents an OptionButton object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was released to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Report.PicturePalette Property (Access)

 Copy code hover
[image]

Report.PicturePalette Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PicturePalette property to specify a palette to be used by a report. Read/write Variant.

Syntax

expression .PicturePalette

expression A variable that represents a Report object.

See also

Concepts

Report Object

Other resources

Report Object Members


AcTextTransferType Enumeration (Access)

 Copy code hover
[image]

AcTextTransferType Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the TranferText method to specify the type of transfer you want to make.

Name | Value | Description
acExportDelim | 2 | Export Delimited
acExportFixed | 3 | Export Fixed Width
acExportHTML | 8 | Export HTML
acExportMerge | 4 | Export Microsot Word Merge
acImportDelim | 0 | Import Delimited
acImportFixed | 1 | Import Fixed Width
acImportHTML | 7 | Import HTML
acLinkDelim | 5 | Link Delimited
acLinkFixed | 6 | Link Fixed Width
acLinkHTML | 9 | Link HTML


The Microsoft Access database engine could not find the object

 Copy code hover
[image]

The Microsoft Access database engine could not find the object <name>. Make sure the object exists and that you spell its name and the path name correctly. (Error 3011)
Send feedback

Possible causes:

  • The specified object does not exist.

  • You misspelled the object name. Check for missing underscores ( _ ) or other punctuation, and make sure you did not enter leading spaces.

  • If you are trying to open a Btrieve table, the paths indicated in the data definition file File.ddf may be incorrect. Be sure your data (.dat) files are in the correct directories.


Label.VerticalAnchor Property (Access)

 Copy code hover
[image]

Label.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified label is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .VerticalAnchor

expression A variable that represents a Label object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

Label Object

Other resources

Label Object Members


RDS API Reference Topics

 Copy code hover
[image]

RDS API Reference Topics
Send feedback

In this section

  • RDS API Reference

  • RDS Objects (Access)

  • RDS Properties (Access)

  • RDS Methods (Access)

  • RDS Events (Access)


InternetTimeout Property Example (VC++)

 Copy code hover
[image]

InternetTimeout Property Example (VC++)
Send feedback

This example demonstrates the InternetTimeout property, which exists on the DataControl and DataSpace objects. In this case, the InternetTimeout property is demonstrated on the DataControl object and the timeout is set to 20 seconds.

C++ Copy code Copy code
// BeginInternetTimeoutCpp#import "c:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")#import "C:\Program Files\Common Files\System\MSADC\msadco.dll"
#include <ole2.h>#include <stdio.h>
#include <conio.h>
// Function declarationsinline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void InternetTimeOutX(void);void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);
//////////////////////////////////////////////////////////// //
// Main Function //// //
//////////////////////////////////////////////////////////
void main(){
if(FAILED(::CoInitialize(NULL)))return;
InternetTimeOutX();
::CoUninitialize();}
//////////////////////////////////////////////////////////// //
// InternetTimeOutX Function //// //
//////////////////////////////////////////////////////////
void InternetTimeOutX(void){
HRESULT hr = S_OK;
// Define ADO object pointers.// Initialize pointers on define.
// These are in the ADODB:: namespace._RecordsetPtr pRst = NULL;
//Define RDS object pointersRDS::IBindMgrPtr dc ;
try{
TESTHR(dc.CreateInstance(__uuidof(RDS::DataControl)));dc->Server = "http://MyServer";
dc->Connect = "Data Source='AuthorDatabase'";dc->SQL = "SELECT * FROM Authors";
// Wait at least 20 seconds.dc->InternetTimeout = 20000;
dc->Refresh();
// Use another Recordset as a conveniencepRst = dc->GetRecordset();
while(!(pRst->EndOfFile)){
printf("%s %s",(LPSTR) (_bstr_t) pRst->Fields->GetItem("au_fname")->Value,
(LPSTR) (_bstr_t) pRst->Fields->GetItem("au_lname")->Value);
pRst->MoveNext();}
pRst->Close();}
catch (_com_error &e){
PrintProviderError(pRst->GetActiveConnection());PrintComError(e);
}}
//////////////////////////////////////////////////////////// //
// PrintProviderError Function //// //
//////////////////////////////////////////////////////////
void PrintProviderError(_ConnectionPtr pConnection){
// Print Provider Errors from Connection object.// pErr is a record object in the Connection's Error collection.
ErrorPtr pErr = NULL;
if( (pConnection->Errors->Count) > 0){
long nCount = pConnection->Errors->Count;// Collection ranges from 0 to nCount -1.
for(long i = 0; i < nCount; i++){
pErr = pConnection->Errors->GetItem(i);printf("\t Error number: %x\t%s", pErr->Number,
pErr->Description);}
}}
//////////////////////////////////////////////////////////// //
// PrintComError Function //// //
//////////////////////////////////////////////////////////
void PrintComError(_com_error &e){
_bstr_t bstrSource(e.Source());_bstr_t bstrDescription(e.Description());
// Print Com errors.printf("Error\n");
printf("\tCode = %08lx\n", e.Error());printf("\tCode meaning = %s\n", e.ErrorMessage());
printf("\tSource = %s\n", (LPCSTR) bstrSource);printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}// EndInternetTimeoutCpp


NavigationControl.TopPadding Property (Access)

 Copy code hover
[image]

NavigationControl.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .TopPadding

expression A variable that represents a NavigationControl object.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Attachment.OnKeyUp Property (Access)

 Copy code hover
[image]

Attachment.OnKeyUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Up box in the Properties window. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnKeyUp

expression A variable that represents an Attachment object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyUp event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Up box is blank, the property value is an empty string.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Label.ThemeFontIndex Property (Access)

 Copy code hover
[image]

Label.ThemeFontIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ThemeFontIndex

expression A variable that represents a Label object.

Remarks

The ThemeFontIndex property uses one of the values listed in the following table.

Value | Description
0 | Header font
1 (Default) | Detail font

If no theme is applied, the ThemeFontIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

Label Object

Other resources

Label Object Members


IN (Access 2013 custom web app)

 Copy code hover
[image]

IN (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Determines whether a specified value matches any value in a list.

Syntax

expression IN(expression [ ,...n ])

expression Is any valid expression. Both expressions must have implicitly convertible data types. The conversion depends on the rules of data type precedence.

Return Type

Boolean


How to: Create a Shortcut Menu for a Form, Form Control, or Report

 Copy code hover
[image]

How to: Create a Shortcut Menu for a Form, Form Control, or Report
Send feedback

Sample code provided by: Community Member Icon Edwin Blancovitch, Advanced Developers.net | About the Contributors

When you're designing a form or report, you may want to provide a method for a user to easily use a command that applies only to the current context. One way to do this is to create a custom shortcut menu and apply it to a form report, or control. The shortcut menu appears when the user right-clicks the object to which the shortcut menu is applied.

In earlier versions of Access, you could use the Customize dialog box to create custom shortcut menus. In Microsoft Access 2010, you must use Visual Basic for Applications (VBA) code to create a shortcut menu. This article describes you how to create a shortcut menu using VBA.

To create an shortcut menu, you first have to create aCommandBar object. The CommandBar object represents the shortcut menu. Then, you use the Add method to create CommandBarControl objects. Each time that you create a CommandBarControl object, a command is added to the shortcut menu.

The following example creates a shortcut menu named SimpleShortcutMenu that contains two commands, Remove Filter/Sort and Filter by Selection.

Note Note

To use the following examples, you must set a reference to the Microsoft Office 14.0 Object Library. See Set References to Type Libraries for more information about how to set references.
VBA Copy code Copy code

Sub CreateSimpleShortcutMenu()
    Dim cmbShortcutMenu As Office.CommandBar

    ' Create a shortcut menu named "SimpleShortcutMenu.
    Set cmbShortcutMenu = CommandBars.Add("SimpleShortcutMenu", msoBarPopup, False, True)

    ' Add the Remove Filter/Sort command.
    cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=605

    ' Add the Filter By Selection command.
    cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=640

    Set cmbShortcutMenu = Nothing

End Sub

Once you've run the code, the shortcut menu is ssaved as part of the database. You don't have to run the same code to re-create the shortcut menu every time that you open the database.

To assign the shortcut menu to a form, form control, or report, set the Shortcut Menu property of the object to Yes and set the Shortcut Menu Bar property of the object to the name of the shortcut menu. For this example, set the Shortcut Menu Bar property toSimpleShortcutMenu.

The following example creates a shortcut menu named cmdFormFiltering that contains commands that are useful to use with Continuous forms. In this example, the BeginGroup property is used on several controls to group controls visually.

VBA Copy code Copy code

Sub CreateShortcutMenuWithGroups()
    Dim cmbRightClick As Office.CommandBar

 ' Create the shortcut menu.
    Set cmbRightClick = CommandBars.Add("cmdFormFiltering", msoBarPopup, False, True)

    With cmbRightClick
        ' Add the Find command.
        .Controls.Add msoControlButton, 141, , , True

        ' Start a new grouping and add the Sort Ascending command.
        .Controls.Add(msoControlButton, 210, , , True).BeginGroup = True

        ' Add the Sort Descending command.
        .Controls.Add msoControlButton, 211, , , True

        ' Start a new grouping and add the Remove Filer/Sort command.
        .Controls.Add(msoControlButton, 605, , , True).BeginGroup = True

        ' Add the Filter by Selection command.
        .Controls.Add msoControlButton, 640, , , True

        ' Add the Filter Excluding Selection command.
        .Controls.Add msoControlButton, 3017, , , True

        ' Add the Between... command.
        .Controls.Add msoControlButton, 10062, , , True
    End With

Set cmbRightClick = Nothing
End Sub

The following example creates a shortcut menu named cmdReportRightClick that contains commands that are useful to use with a report. This example shows how to change the Caption property of each control as they're added to the shortcut menu.

VBA Copy code Copy code

Sub CreateReportShortcutMenu()
    Dim cmbRightClick As Office.CommandBar
    Dim cmbControl As Office.CommandBarControl

   ' Create the shortcut menu.
    Set cmbRightClick = CommandBars.Add("cmdReportRightClick", msoBarPopup, False, True)

    With cmbRightClick

        ' Add the Print command.
        Set cmbControl = .Controls.Add(msoControlButton, 2521, , , True)
        ' Change the caption displayed for the control.
        cmbControl.Caption = "Quick Print"

        ' Add the Print command.
        Set cmbControl = .Controls.Add(msoControlButton, 15948, , , True)
        ' Change the caption displayed for the control.
        cmbControl.Caption = "Select Pages"

        ' Add the Page Setup... command.
        Set cmbControl = .Controls.Add(msoControlButton, 247, , , True)
        ' Change the caption displayed for the control.
        cmbControl.Caption = "Page Setup"

        ' Add the Mail Recipient (as Attachment)... command.
        Set cmbControl = .Controls.Add(msoControlButton, 2188, , , True)
        ' Start a new group.
        cmbControl.BeginGroup = True
        ' Change the caption displayed for the control.
        cmbControl.Caption = "Email Report as an Attachment"

        ' Add the PDF or XPS command.
        Set cmbControl = .Controls.Add(msoControlButton, 12499, , , True)
        ' Change the caption displayed for the control.
        cmbControl.Caption = "Save as PDF/XPS"

        ' Add the Close command.
        Set cmbControl = .Controls.Add(msoControlButton, 923, , , True)
        ' Start a new group.
        cmbControl.BeginGroup = True
        ' Change the caption displayed for the control.
        cmbControl.Caption = "Close Report"
    End With

    Set cmbControl = Nothing
    Set cmbRightClick = Nothing
End Sub

About the Contributors

Edwin Blancovitch is president of Advanced Developers.net, creators of Easy Payroll, a software package to manage your human resources, payroll, scheduling, time and attendance needs.


ComboBox.FontItalic Property (Access)

 Copy code hover
[image]

ComboBox.FontItalic Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontItalic property to specify whether text is italic in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontItalic

expression A variable that represents a ComboBox object.

Remarks

The FontItalic property uses the following settings.

Setting | Description
True | The text is italic.
False | (Default) The text isn't italic.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


TextBox.GridlineStyleTop Property (Access)

 Copy code hover
[image]

TextBox.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified text box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleTop

expression A variable that represents a TextBox object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


The Significance of Cursor Location

 Copy code hover
[image]

The Significance of Cursor Location
Send feedback

Every cursor uses temporary resources to hold its data. These resources can be memory, a disk paging file, temporary disk files, or even temporary storage in the database. The cursor is called a client-side cursor when these resources are located on the client computer. The cursor is called a server-side cursor when these resources are located on the server.

Client-Side Cursors

In ADO, call for a client-side cursor by using the adUseClient CursorLocationEnum. With a non-keyset client-side cursor, the server sends the entire result set across the network to the client computer. The client computer provides and manages the temporary resources needed by the cursor and result set. The client-side application can browse through the entire result set to determine which rows it requires.

Static and keyset-driven client-side cursors may place a significant load on your workstation if they include too many rows. While all of the cursor libraries are capable of building cursors with thousands of rows, applications designed to fetch such large rowsets may perform poorly. There are exceptions, of course. For some applications, a large client-side cursor might be perfectly appropriate and performance might not be an issue.

One obvious benefit of the client-side cursor is quick response. After the result set has been downloaded to the client computer, browsing through the rows is very fast. Your application is generally more scalable with client-side cursors because the cursor's resource requirements are placed on each separate client and not on the server.

Server-Side Cursors

In ADO, call for a server-side cursor by using the adUseServer CursorLocationEnum. With a server-side cursor, the server manages the result set using resources provided by the server computer. The server-side cursor returns only the requested data over the network. This type of cursor can sometimes provide better performance than the client-side cursor, especially in situations where excessive network traffic is a problem.

However, it is important to point out that a server-side cursor is — at least temporarily — consuming precious server resources for every active client. You must plan accordingly to ensure that your server hardware is capable of managing all of the server-side cursors requested by active clients. Also, a server-side cursor can be slow because it provides only single row access — there is no batch cursor available.

Server-side cursors are useful when inserting, updating, or deleting records. With server-side cursors, you can have multiple active statements on the same connection.


Field2.Type Property (DAO)

 Copy code hover
[image]

Field2.Type Property (DAO)
Send feedback

Sets or returns a value that indicates the operational type or data type of an object. Read/write Integer.

Syntax

expression .Type

expression A variable that represents a Field2 object.

Remarks

The setting or return value is a constant that indicates an operational or data type. For a Field2 object, this property is read/write until the object is appended to a collection or to another object, after which it's read-only.

For a Field2 object, the possible settings and return values are described in the following table.

Constant | Description
dbBigInt | Big Integer
dbBinary | Binary
dbBoolean | Boolean
dbByte | Byte
dbChar | Char
dbCurrency | Currency
dbDate | Date/Time
dbDecimal | Decimal
dbDouble | Double
dbFloat | Float
dbGUID | GUID
dbInteger | Integer
dbLong | Long
dbLongBinary | Long Binary (OLE Object)
dbMemo | Memo
dbNumeric | Numeric
dbSingle | Single
dbText | Text
dbTime | Time
dbTimeStamp | Time Stamp
dbVarBinary | VarBinary

When you append a new Field2, Parameter, or Property object to the collection of an Index, QueryDef, Recordset, or TableDef object, an error occurs if the underlying database doesn't support the data type specified for the new object.


CheckBox.BorderTint Property (Access)

 Copy code hover
[image]

CheckBox.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderTint

expression A variable that represents a CheckBox object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the proerty sheet.

Example

The following code example lightens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


OptionGroup.OnClick Property (Access)

 Copy code hover
[image]

OptionGroup.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Syntax

expression .OnClick

expression A variable that represents an OptionGroup object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


WebServices Members (Access)

 Copy code hover
[image]

WebServices Members (Access)
Send feedback

Published: July 16, 2012

Represents the collection of Data Services data connections installed in the database.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Object.
Parent | Returns the parent object for the specified object. Read-only.


Module.DeleteLines Method (Access)

 Copy code hover
[image]

Module.DeleteLines Method (Access)
See also Send feedback

Published: July 16, 2012

The DeleteLines method deletes lines from a standard module or a class module.

Syntax

expression .DeleteLines(StartLine, Count)

expression A variable that represents a Module object.

Parameters

Name | Required/Optional | Data Type | Description
StartLine | Required | Long | The number of the line from which to begin deleting.
Count | Required | Long | The number of lines to delete.

Return Value

Nothing

Remarks

Lines in a module are numbered beginning with one. To determine the number of lines in a module, use the CountOfLines property.

To replace one line with another line, use the ReplaceLine method.

Example

The following example deletes a specified line from a module.

VBA Copy code Copy code
Function DeleteWholeLine(strModuleName, strText As String) _
 As Boolean
 Dim mdl As Module, lngNumLines As Long
 Dim lngSLine As Long, lngSCol As Long
 Dim lngELine As Long, lngECol As Long
 Dim strTemp As String

 On Error GoTo Error_DeleteWholeLine
 DoCmd.OpenModule strModuleName
 Set mdl = Modules(strModuleName)

 If mdl.Find(strText, lngSLine, lngSCol, lngELine, lngECol) Then
 lngNumLines = Abs(lngELine - lngSLine) + 1
 strTemp = LTrim$(mdl.Lines(lngSLine, lngNumLines))
 strTemp = RTrim$(strTemp)
 If strTemp = strText Then
 mdl.DeleteLines lngSLine, lngNumLines
 Else
 MsgBox "Line contains text in addition to '" _
 & strText & "'."
 End If
 Else
 MsgBox "Text '" & strText & "' not found."
 End If
 DeleteWholeLine = True

Exit_DeleteWholeLine:
 Exit Function

Error_DeleteWholeLine:
 MsgBox Err & " :" & Err.Description
 DeleteWholeLine = False
 Resume Exit_DeleteWholeLine
End Function

You could call this function from a procedure such as the following, which searches the module Module1 for a constant declaration and deletes it.

VBA Copy code Copy code
Sub DeletePiConst()
 If DeleteWholeLine("Module1", "Const conPi = 3.14") Then
 Debug.Print "Constant declaration deleted successfully."
 Else
 Debug.Print "Constant declaration not deleted."
 End If
End Sub

See also

Concepts

Module Object

Other resources

Module Object Members


NavigationControl.OldBorderStyle Property (Access)

 Copy code hover
[image]

NavigationControl.OldBorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .OldBorderStyle

expression A variable that represents a NavigationControl object.

Remarks

The OldBorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines
Note Note

  • If the OldBorderStyle property is set to None or Dialog, the form doesn't have Maximize or Minimize buttons, regardless of its MinMaxButtons property setting.

  • If the OldBorderStyle property is set to None, the form doesn't have a Control menu, regardless of its ControlBox property setting.

  • The OldBorderStyle property setting doesn't affect the display of the scroll bars, navigation buttons, the record number box, or record selectors.

Example

The following example demonstrates the effect of changing a control's BorderStyle property, while leaving the OldBorderStyle unaffected. The example concludes with setting the BorderStyle property to its original unedited value.

VBA Copy code Copy code
With Forms("Order Entry").Controls("Zip Code") .BorderStyle = 3 ' Short dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 3, 1.

    .BorderStyle = 2 ' Dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 2, 1

    .BorderStyle = .OldBorderStyle ' Solid (default) border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 1, 1
End With

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


AccessObject.IsWeb Property (Access)

 Copy code hover
[image]

AccessObject.IsWeb Property (Access)
See also Send feedback

Published: July 16, 2012

Gets whether the specified object is a Web object. Read-only Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .IsWeb

expression A variable that represents an AccessObject object.

Remarks

The IsWeb property contains True if the object is a Web object.

See also

Concepts

AccessObject Object

Other resources

AccessObject Object Members


FindNextRecord Macro Action

 Copy code hover
[image]

FindNextRecord Macro Action
Send feedback

You can use the FindNextRecord action to find the next record that meets the criteria specified by the previous FindRecord action or the value in the Find and Replace dialog box (on the Home tab, click Find). You can use the FindNextRecord action to search repeatedly for records. For example, you can move successively through all the records for a specific customer.

Setting

The FindNextRecord action doesn't have any arguments. The FindNextRecord action finds the next record that meets the criteria set either by the FindRecord action or in the Find and Replace dialog box. The arguments for the FindRecord action are shared with the options in the Find and Replace dialog box.

To set the search criteria, use the FindRecord action. Typically, you enter a FindRecord action in a macro and then use the FindNextRecord action to find succeeding records that meet the same criteria. To search for records only when a certain condition is met, you can enter a conditional expression in the Condition column of the action row for the FindNextRecord action.

Remarks

This action has the same effect as using the Find Next button in the Find and Replace dialog box.

Note Note

Although the FindRecord action corresponds to the Find command on the Home tab for tables, queries, and forms, it doesn't correspond to the Find command on the Edit menu in the Code window. You can't use the FindRecord action or FindNextRecord action to search for text in modules.
Tip Tip

If you've set the Only Current Field argument of the FindRecord action to Yes, you may need to use the GoToControl action to move the focus to the control containing the data you're searching for before you use the FindNextRecord action.

If the currently selected text is the same as the search text at the time the FindNextRecord macro action is carried out, the search begins immediately following the selection, in the same field as the selection, and in the same record. Otherwise, the search begins at the start of the current record. This enables you to find multiple instances of the same search criteria that might appear in a single record.

However, note that if you use a command button to run a macro containing the FindNextRecord action, the first instance of the search criteria will be found repeatedly. This behavior occurs because clicking the command button removes the focus from the field containing the matching value. The FindNextRecord action will then begin searching from the start of the record. To avoid this problem, run the macro by using a technique that doesn't change the focus, such as a custom toolbar button or a key combination defined in an AutoKeys macro. Alternatively, set the focus in the macro to the field containing the search criteria before you carry out the FindNextRecord action.

The same behavior also occurs if you use a command button to run a macro containing the FindRecord action with the Find First argument set to No.

To run the FindNextRecord action in a Visual Basic for Applications module, use the FindNext method of the DoCmd object.


There is no index on the GUID column. (Error 3550)

 Copy code hover
[image]

There is no index on the GUID column. (Error 3550)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


IIf Function (Access 2013 custom web app)

 Copy code hover
[image]

IIf Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Checks whether a condition is met, and returns one value if TRUE of another on if it is FALSE.

Syntax

IIf(Condition, TrueValue, FalseValue)

The IIf function contains the following arguments.

Argument name | Description
Condition | The expression that you want to evaluate.
TrueValue | Value or expression returned if Condition is True.
FalseValue | Value or expression returned if Condition is False.

Example

The following expression can be used to display the full name of a person where the table contains FirstName, MiddleInitial, and LastName fields. If the MiddleInitial field is blank, then only the FirstName and LastName fields are combined to display the full name,

Copy code Copy code
IIf([MiddleInitial] Is Null,Concat([FirstName]," ",[LastName]),Concat([FirstName]," ",[MiddleInitial]," ",[LastName]))


OptionButton.GridlineThemeColorIndex Property (Access)

 Copy code hover
[image]

OptionButton.GridlineThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineThemeColorIndex

expression A variable that represents an OptionButton object.

Remarks

The GridlineThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 (Default) | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the GridlineThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Adding Data to a Recordset (ADO)

 Copy code hover
[image]

Adding Data to a Recordset (ADO)
Send feedback

In this section

  • Adding Data to a Recordset


BoundObjectFrame.Enabled Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Enabled Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.

Syntax

expression .Enabled

expression A variable that represents a BoundObjectFrame object.

Remarks

The Enabled property setting is a value that indicates whether the conditional format is enabled or disabled. True enables the conditional format. False disables the conditional format. The default is True.

When the Enabled property is True, the conditional format can be displayed in the Conditional Formatting dialog box.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Field2 Properties (DAO)

 Copy code hover
[image]

Field2 Properties (DAO)
Send feedback

In this section

  • Field2.AllowZeroLength Property (DAO)

  • Field2.AppendOnly Property (DAO)

  • Field2.Attributes Property (DAO)

  • Field2.CollatingOrder Property (DAO)

  • Field2.ComplexType Property (DAO)

  • Field2.DataUpdatable Property (DAO)

  • Field2.DefaultValue Property (DAO)

  • Field2.Expression Property (DAO)

  • Field2.FieldSize Property (DAO)

  • Field2.ForeignName Property (DAO)

  • Field2.IsComplex Property (DAO)

  • Field2.Name Property (DAO)

  • Field2.OrdinalPosition Property (DAO)

  • Field2.OriginalValue Property (DAO)

  • Field2.Properties Property (DAO)

  • Field2.Required Property (DAO)

  • Field2.Size Property (DAO)

  • Field2.SourceField Property (DAO)

  • Field2.SourceTable Property (DAO)

  • Field2.Type Property (DAO)

  • Field2.ValidateOnSet Property (DAO)

  • Field2.ValidationRule Property (DAO)

  • Field2.ValidationText Property (DAO)

  • Field2.Value Property (DAO)

  • Field2.VisibleValue Property (DAO)


Connection.Connect Property (DAO)

 Copy code hover
[image]

Connection.Connect Property (DAO)
Send feedback

Sets or returns a value that provides information about the source of an open connection. Read/write String.

Syntax

expression .Connect

expression A variable that represents a Connection object.

Remarks

The Connect property setting is a String composed of a database type specifier and zero or more parameters separated by semicolons. The Connect property passes additional information to ODBC and certain ISAM drivers as needed.

To perform an SQL pass-through query on a table linked to your Microsoft Access database file, you must first set the Connect property of the linked table's database to a valid ODBC connection string.

For a TableDef object that represents a linked table, the Connect property setting consists of one or two parts (a database type specifier and a path to the database), each of which ends with a semicolon.

The path as shown in the following table is the full path for the directory containing the database files and must be preceded by the identifier DATABASE=. In some cases (as with Microsoft Excel and Microsoft Access database engine databases), you should include a specific file name in the database path argument.

The following table shows possible database types and their corresponding database specifiers and paths for the Connect property setting.

Database type | Specifier | Example
Microsoft Access Database | [database]; | drive:\path\filename
dBASE III | dBASE III; | drive:\path
dBASE IV | dBASE IV; | drive:\path
dBASE 5 | dBASE 5.0; | drive:\path
Paradox 3.x | Paradox 3.x; | drive:\path
Paradox 4.x | Paradox 4.x; | drive:\path
Paradox 5.x | Paradox 5.x; | drive:\path
Microsoft Excel 3.0 | Excel 3.0; | drive:\path\filename.xls
Microsoft Excel 4.0 | Excel 4.0; | drive:\path\filename.xls
Microsoft Excel 5.0 or Microsoft Excel 95 | Excel 5.0; | drive:\path\filename.xls
Microsoft Excel 97 | Excel 8.0; | drive:\path\filename.xls
Lotus 1-2-3 WKS and WK1 | Lotus WK1; | drive:\path\filename.wk1
Lotus 1-2-3 WK3 | Lotus WK3; | drive:\path\filename.wk3
Lotus 1-2-3 WK4 | Lotus WK4; | drive:\path\filename.wk4
HTML Import | HTML Import; | drive:\path\filename
HTML Export | HTML Export; | drive:\path
Text | Text; | drive:\path
ODBC | ODBC; DATABASE=database; UID=user; PWD=password; DSN= datasourcename; [LOGINTIMEOUT=seconds;] | None
Microsoft Exchange | Exchange 4.0; MAPILEVEL=folderpath; [TABLETYPE={ 0 | 1 }];[PROFILE=profile;] [PWD=password;] [DATABASE=database;] | drive:\path\filename

If the specifier is only "ODBC;", the ODBC driver displays a dialog box listing all registered ODBC data source names so that the user can select a database.

If a password is required but not provided in the Connect property setting, a login dialog box is displayed the first time a table is accessed by the ODBC driver and again if the connection is closed and reopened.

For data in Microsoft Exchange, the required MAPILEVEL key should be set to a fully-resolved folder path (for example, "Mailbox - Pat SmithIAlpha/Today"). The path does not include the name of the folder that will be opened as a table; that folder's name should instead be specified as the name argument to the CreateTable method. The TABLETYPE key should be set to "0" to open a folder (default) or "1" to open an address book. The PROFILE key defaults to the profile currently in use.

For base tables in a Micorosoft Access database, the Connect property setting is a zero-length string ("").

You can set the Connect property for a Database object by providing a source argument to the OpenDatabase method. You can check the setting to determine the type, path, user ID, password, or ODBC data source of the database.

On a QueryDef object in a Microsoft Access workspace, you can use the Connect property with the ReturnsRecords property to create an ODBC SQL pass-through query. The databasetype of the connection string is "ODBC;", and the remainder of the string contains information specific to the ODBC driver used to access the remote data. For more information, see the documentation for the specific driver.

Note Note

  • You must set the Connect property before you set the ReturnsRecords property.

  • You must have access permissions to the computer that contains the database server you're trying to access.


TabControl Events (Access)

 Copy code hover
[image]

TabControl Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
Change | The Change event occurs when when you move from one page to another page.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.


CommandButton.Move Method (Access)

 Copy code hover
[image]

CommandButton.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a CommandButton object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Recordset2 Methods (DAO)

 Copy code hover
[image]

Recordset2 Methods (DAO)
Send feedback

In this section

  • Recordset2.AddNew Method (DAO)

  • Recordset2.Cancel Method (DAO)

  • Recordset2.CancelUpdate Method (DAO)

  • Recordset2.Clone Method (DAO)

  • Recordset2.Close Method (DAO)

  • Recordset2.CopyQueryDef Method (DAO)

  • Recordset2.Delete Method (DAO)

  • Recordset2.Edit Method (DAO)

  • Recordset2.FillCache Method (DAO)

  • Recordset2.FindFirst Method (DAO)

  • Recordset2.FindLast Method (DAO)

  • Recordset2.FindNext Method (DAO)

  • Recordset2.FindPrevious Method (DAO)

  • Recordset2.GetRows Method (DAO)

  • Recordset2.Move Method (DAO)

  • Recordset2.MoveFirst Method (DAO)

  • Recordset2.MoveLast Method (DAO)

  • Recordset2.MoveNext Method (DAO)

  • Recordset2.MovePrevious Method (DAO)

  • Recordset2.NextRecordset Method (DAO)

  • Recordset2.OpenRecordset Method (DAO)

  • Recordset2.Requery Method (DAO)

  • Recordset2.Seek Method (DAO)

  • Recordset2.Update Method (DAO)


SetProperty Macro Action

 Copy code hover
[image]

SetProperty Macro Action
Send feedback

You can use the SetProperty action to set a property for a control on a form or a report.

Setting

The SetProperty action has the following arguments.

Action argument | Description
Control Name | Type the name of the field or control for which you want to set the property value. Use only the control name, not the full syntax. Leave this argument blank to set the property for the current form or report.
Property | Select the property that you want to set. See the Remarks section in this article for a list of the properties that can be set by using this action.
Value | Type the value that the property is to be set to. For properties whose values are either Yes or No, use -1 for Yes and 0 for No.

Remarks

  • You can use the SetProperty action to set the following properties of a control: Enabled, Visible, Locked, Left, Top, Width, Height, Fore Color, Back Color, or Caption.

  • If you enter an invalid value for the Value argument, no error occurs, but Access might change the property to a different value, depending on how it interprets the argument.

  • You can use the SetProperty action in a stand-alone macro only if you precede it with an action that selects the form or report containing the control for which you are setting the property. If the form or report is not open, you can use the OpenForm or OpenReport action to open and select it. If the form or report is already open, you can use the SelectObject action to select it. You can then use the SetProperty action to set the property. Selecting the object is not necessary if you use the SetProperty action in a macro which is embedded in a control on the same form or report as the control for which you are setting the property.

  • To run the SetProperty action in a VBA module, use the SetProperty method of the DoCmd object.

Example

The following example shows how to use the SetProperty action to toggle the visibility of the MyTextBox text box.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

Copy code Copy code
Submacro: TestVisible
    SetProperty
        Control Name Text40
        Property Visible
        Value =Not[Text40].[Visible]
End Submacro

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


NavigationButton.DisplayWhen Property (Access)

 Copy code hover
[image]

NavigationButton.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .DisplayWhen

expression A variable that represents a NavigationButton object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


ToggleButton.AfterUpdate Property (Access)

 Copy code hover
[image]

ToggleButton.AfterUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.

Syntax

expression .AfterUpdate

expression A variable that represents a ToggleButton object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the AfterUpdate event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the AfterUpdate event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).AfterUpdate = "[Event Procedure]"

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


ListBox.Enter Event (Access)

 Copy code hover
[image]

ListBox.Enter Event (Access)
See also Send feedback

Published: July 16, 2012

The Enter event occurs before a control actually receives the focus from a control on the same form or report.

Syntax

expression .Enter

expression A variable that represents a ListBox object.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when these events occur, set the OnEnter or OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Enter event occurs before the GotFocus event. The Exit event occurs before the LostFocus event.

Unlike the GotFocus and LostFocus events, the Enter and Exit events don't occur when a form receives or loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Printer.ColumnSpacing Property (Access)

 Copy code hover
[image]

Printer.ColumnSpacing Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Long representing the vertical space between detail sections in twips. Read/write.

Syntax

expression .ColumnSpacing

expression A variable that represents a Printer object.

Example

The following example sets a variety of printer settings for the form specified in the strFormname argument of the procedure.

VBA Copy code Copy code
Sub SetPrinter(strFormname As String)

 DoCmd.OpenForm FormName:=strFormname, view:=acDesign, _
 datamode:=acFormEdit, windowmode:=acHidden

 With Forms(form1).Printer

 .TopMargin = 1440
 .BottomMargin = 1440
 .LeftMargin = 1440
 .RightMargin = 1440

  .ColumnSpacing = 360
 .RowSpacing = 360

 .ColorMode = acPRCMColor
 .DataOnly = False
 .DefaultSize = False
 .ItemSizeHeight = 2880
 .ItemSizeWidth = 2880
 .ItemLayout = acPRVerticalColumnLayout
 .ItemsAcross = 6

 .Copies = 1
 .Orientation = acPRORLandscape
 .Duplex = acPRDPVertical
 .PaperBin = acPRBNAuto
 .PaperSize = acPRPSLetter
 .PrintQuality = acPRPQMedium

 End With

 DoCmd.Close objecttype:=acForm, objectname:=strFormname, _
 Save:=acSaveYes

End Sub

See also

Concepts

Printer Object

Other resources

Printer Object Members


FormatConditions Members (Access)

 Copy code hover
[image]

FormatConditions Members (Access)
Send feedback

Published: July 16, 2012

The FormatConditions collection represents the collection of conditional formats for a combo box or text box control. Each format is represented by a FormatCondition object.

Methods

Name | Description
Add | You can use the Add method to add a conditional format as a FormatCondition object to the FormatConditions collection of a combo box or text box control.
Delete | Deletes the specified object.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only FormatCondition.
Parent | Returns the parent object for the specified object. Read-only.


Object

 Copy code hover
[image]

Object <name> already exists. (Error 3012)
Send feedback

You tried to create an object with a name that already exists in this database. Choose a different name, and then try the operation again.


Schema Section
Send feedback

Schema Section

The schema section is required. As the previous example shows, ADO writes out detailed metadata about each column to preserve the semantics of the data values as much as possible for updating. However, to load in the XML, ADO only requires the names of the columns and the rowset to which they belong. Here is an example of a minimal schema:

Copy code Copy code

<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
    xmlns:rs="urn:schemas-microsoft-com:rowset"
    xmlns:z="#RowsetSchema">
  <s:Schema id="RowsetSchema">
    <s:ElementType name="row" content="eltOnly">
      <s:AttributeType name="ShipperID"/>
      <s:AttributeType name="CompanyName"/>
      <s:AttributeType name="Phone"/>
      <s:Extends type="rs:rowbase"/>
    </s:ElementType>
  </s:Schema>
  <rs:data>
...
  </rs:data>
</xml>

In the case above, ADO will treat the data as variable length strings because no type information is included in the schema.

Creating Aliases for Column Names

The rs:name attribute allows you to create an alias for a column name so that a friendly name may appear in the column information exposed by the rowset and a shorter name may be used in the data section. For example, the schema above could be modified to map ShipperID to s1, CompanyName to s2, and Phone to s3 as follows:

Copy code Copy code

<s:Schema id="RowsetSchema">
<s:ElementType name="row" content="eltOnly" rs:updatable="true">
<s:AttributeType name="s1" rs:name="ShipperID" rs:number="1" ...>
...
</s:AttributeType>
<s:AttributeType name="s2" rs:name="CompanyName" rs:number="2" ...>
...
</s:AttributeType>
<s:AttributeType name="s3" rs:name="Phone" rs:number="3" ...>
...
</s:AttributeType>
...
</s:ElementType>
</s:Schema>

Then, in the data section, the row would use the name attribute (not rs:name) to refer to that column:

Copy code Copy code

"<row s1="1" s2="Speedy Express" s3="(503) 555-9831"/>

Creating aliases for column names is required whenever a column name is not a legal attribute or tag name in XML. For example, "Last Name" must have an alias because names with embedded spaces are illegal attributes. The following line won't be correctly handled by the XML parser, so you must create an alias to some other name that does not have an embedded space:

Copy code Copy code

<row last name="Jones"/>

Whatever value you use for the name attribute must be used consistently in each place that the column is referenced in both the schema and data sections of the XML document. The following example shows the consistent use of s1:

Copy code Copy code

<s:Schema id="RowsetSchema">
  <s:ElementType name="row" content="eltOnly">
    <s:attribute type="s1"/>
    <s:attribute type="CompanyName"/>
    <s:attribute type="s3"/>
    <s:extends type="rs:rowbase"/>
  </s:ElementType>
  <s:AttributeType name="s1" rs:name="ShipperID" rs:number="1"
    rs:maydefer="true" rs:writeunknown="true">
    <s:datatype dt:type="i4" dt:maxLength="4" rs:precision="10"
      rs:fixedlength="true" rs:maybenull="true"/>
  </s:AttributeType>
</s:Schema>
<rs:data>
  <z:row s1="1" CompanyName="Speedy Express" s3="(503) 555-9831"/>
</rs:data>

Similarly, because there is no alias defined for CompanyName above, CompanyName must be used consistently throughout the document.

Data Types

You can apply a data type to a column with the dt:type attribute. You can specify a data type in two ways: either specify the dt:type attribute directly on the column definition itself or use the s:datatype construct as a nested element of the column definition. For example,

Copy code Copy code

<s:AttributeType name="Phone" >
  <s:datatype dt:type="string"/>
</s:AttributeType>

is equivalent to

Copy code Copy code

<s:AttributeType name="Phone" dt:type="string"/>

If you omit the dt:type attribute entirely from the row definition, by default, the column's type will be a variable length string.

If you have more type information than simply the type name (for example, dt:maxLength), it makes it more readable to use the s:datatype child element. This is merely a convention, however, and not a requirement.

The following examples show further how to include type information in your schema:

Copy code Copy code

<!-- 1. String with no max length -->
<s:AttributeType name="title_id"/>
<! — or -->
<s:AttributeType name="title_id" dt:type="string"/>

<! — 2. Fixed length string with max length of 6 -->
<s:AttributeType name="title_id">
    <s:datatype dt:type="string" dt:maxLength="6" rs:fixedlength="true" />
</s:AttributeType>

<! — 3. Variable length string with max length of 6 -->
<s:AttributeType name="title_id">
    <s:datatype dt:type="string" dt:maxLength="6" />
</s:AttributeType>

<! — 4. Integer -->
<s:AttributeType name="title_id" dt:type="int"/>

There is a subtle use of the rs:fixedlength attribute in the second example. A column with the rs:fixedlength attribute set to true means that the data must have the length defined in the schema. In this case, a legal value for title_id is "123456," as is "123 ." However, "123" would not be valid because its length is 3, not 6. See the OLE DB Programmer's Guide for a more complete description of the fixedlength property.

Handling Nulls

Null values are handled by the rs:maybenull attribute. If this attribute is set to true, the contents of the column may contain a null value. Furthermore, if the column is not found in a row of data, the user reading the data back from the rowset will get a null status from IRowset::GetData(). Consider the following column definitions from the Shippers table:

Copy code Copy code

<s:AttributeType name="ShipperID">
  <s:datatype dt:type="int" dt:maxLength="4"/>
</s:AttributeType>
<s:AttributeType name="CompanyName">
  <s:datatype dt:type="string" dt:maxLength="40" rs:maybenull="true"/>
</s:AttributeType>

The definition allows CompanyName to be null, but ShipperID cannot contain a null value. If the data section contained the following row, the Persistence Provider would set the status of the data for the CompanyName column to the OLE DB status constant DBSTATUS_S_ISNULL:

Copy code Copy code

<z:row ShipperID="1"/>

If the row was entirely empty, as follows, the Persistence Provider would return an OLE DB status of DBSTATUS_E_UNAVAILABLE for ShipperID and DBSTATUS_S_ISNULL for CompanyName.

Copy code Copy code

<z:row/>

Note that a zero-length string is not the same as null.

Copy code Copy code

<z:row ShipperID="1" CompanyName=""/>

For the preceding row, the Persistence Provider will return an OLE DB status of DBSTATUS_S_OK for both columns. The CompanyName in this case is simply "" (a zero-length string).

For further information about the OLE DB constructs available for use within the schema of an XML document for OLE DB, see the definition of "urn:schemas-microsoft-com:rowset" and the OLE DB Programmer's Guide.


RunMacro Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

RunMacro Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

You can use the RunMacro action to run a user interface (UI) macro.

Setting

The RunMacro action has the following arguments.

Action argument | Description
Macro Name | The name of the UI macro to run.

Remarks

When you run a UI macro containing the RunMacro action, and it reaches the RunMacro action, Access runs the called UI macro. When the called UI macro has finished, Access returns to the original UI macro and runs the next action.


Application.LoadCustomUI Method (Access)

 Copy code hover
[image]

Application.LoadCustomUI Method (Access)
See also Send feedback

Published: July 16, 2012

Loads XML markup that represents a customized ribbon.

Version Information

Version Added: Access 2007

Syntax

expression .LoadCustomUI(CustomUIName, CustomUIXML)

expression An expression that returns a Application object.

Parameters

Name | Required/Optional | Data Type | Description
CustomUIName | Required | String | The name that will be used to identify the customized ribbon.
CustomUIXML | Required | String | The XML markup code that defines the customized ribbon.

Remarks

To create and make the ribbon available to Access, you first create a module in the database with a procedure that calls the LoadCustomUI method, passing in the name of the ribbon and the XML customization markup. The XML markup can come from a Recordset object created from a table, from a source external to the database (such as an XML file that you must parse into a String), or from XML markup embedded directly inside of the procedure.

You can make different ribbons available by using multiple calls to the LoadCustomUI method, passing in different XML markup, as long as the name of each ribbon and the id attribute of the tabs that make up the ribbon are unique.

After the procedure is complete, you then create an AutoExec macro that calls the procedure by using the RunCode action. That way, when the application is started, the LoadCustomUI method is automatically executed and all of the custom ribbons are made available to the application

Example

The following code example creates a Recordset from any table that contains the word "Ribbons" in its name. Then it calls the LoadCustomUI method to load the ribbons in order to make them available to the database. Finally, it closes the recordset and the reference to the Database object.

VBA Copy code Copy code
Function LoadRibbons()
Dim i As Integer
Dim db As DAO.Database
Set db = Application.CurrentDb

For i = 0 To (db.TableDefs.Count - 1)
 If (InStr(1, db.TableDefs(i).Name, "Ribbons")) Then
 Dim rs As DAO.Recordset
 Set rs = CurrentDb.OpenRecordset(db.TableDefs(i).Name)
 rs.MoveFirst

 While Not rs.EOF
 Application.LoadCustomUI rs("RibbonName").Value, rs("RibbonXml").Value

 rs.MoveNext
 Wend

 rs.Close
 Set rs = Nothing
 End If
Next i

db.Close
Set db = Nothing
End Function

See also

Concepts

Application Object

Other resources

Application Object Members


ToggleButton.OnExit Property (Access)

 Copy code hover
[image]

ToggleButton.OnExit Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnExit

expression A variable that represents a ToggleButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Exit event occurs just before a control loses the focus to another control on the same form.

The OnExit value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Exit box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Exit box is blank, the property value is an empty string.

Example

The following example associates the Exit event with the macro "Exit_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnExit = "Exit_Macro"

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Cellset Example (VB)

 Copy code hover
[image]

Cellset Example (VB)
Send feedback

This Visual Basic project demonstrates the basics of using ADO MD to access cube data. It displays member captions for column and row headers, then displays formatted values of specific cells within the cellset.

Copy code Copy code

Sub cmdCellSettoDebugWindow_Click()
 On Error GoTo Error_cmdCellSettoDebugWindow_Click

 Dim cat As New ADOMD.Catalog
 Dim cst As New ADOMD.CellSet
 Dim strServer As String
 Dim strSource As String
 Dim strColumnHeader As String
 Dim strRowText As String
 Dim i As Integer
 Dim j As Integer
 Dim k As Integer

 Screen.MousePointer = vbHourglass

 '*-----------------------------------------------------------------------
 '* Set Server to Local Host
 '*-----------------------------------------------------------------------
 strServer = "localhost"

 '*-----------------------------------------------------------------------
 '* Set MDX query string Source
 '*-----------------------------------------------------------------------
 strSource = "SELECT {[Measures].members} ON COLUMNS," & _
 "NON EMPTY [Store].[Store City].members ON ROWS FROM Sales"

 '*-----------------------------------------------------------------------
 '* Set Active Connection
 '*-----------------------------------------------------------------------
 cat.ActiveConnection = "Data Source=" & strServer & ";Provider=msolap;"

 '*-----------------------------------------------------------------------
 '* Set Cell Set source to MDX query string
 '*-----------------------------------------------------------------------
 cst.Source = strSource

 '*-----------------------------------------------------------------------
 '* Set Cell Sets active connection to current connection
 '*-----------------------------------------------------------------------
 Set cst.ActiveConnection = cat.ActiveConnection

 '*-----------------------------------------------------------------------
 '* Open Cell Set
 '*-----------------------------------------------------------------------
 cst.Open

 '*-----------------------------------------------------------------------
 '* Allow space for Row Header Text
 '*-----------------------------------------------------------------------
 strColumnHeader = vbTab & vbTab & vbTab & vbTab & vbTab & vbTab

 '*-----------------------------------------------------------------------
 '* Loop through Column Headers
 '*-----------------------------------------------------------------------
 For i = 0 To cst.Axes(0).Positions.Count - 1
 strColumnHeader = strColumnHeader & _
 cst.Axes(0).Positions(i).Members(0).Caption & vbTab & _
 vbTab & vbTab & vbTab
 Next
 Debug.Print vbTab & strColumnHeader & vbCrLf

 '*-----------------------------------------------------------------------
 '* Loop through Row Headers and Provide data for each row
 '*-----------------------------------------------------------------------
 strRowText = ""
 For j = 0 To cst.Axes(1).Positions.Count - 1
 strRowText = strRowText & _
 cst.Axes(1).Positions(j).Members(0).Caption & vbTab & _
 vbTab & vbTab & vbTab
 For k = 0 To cst.Axes(0).Positions.Count - 1
 strRowText = strRowText & cst(k, j).FormattedValue & _
 vbTab & vbTab & vbTab & vbTab
 Next
 Debug.Print strRowText & vbCrLf
 strRowText = ""
 Next

 Screen.MousePointer = vbDefault

 Exit Sub

Error_cmdCellSettoDebugWindow_Click:
 Beep
 Screen.MousePointer = vbDefault
 Set cat = Nothing
 Set cst = Nothing
 MsgBox "The Following Error has occurred:" & vbCrLf & _
 Err.Description, vbCritical, " Error!"
 Exit Sub
End Sub


DataTypeEnum Enumeration (DAO)

 Copy code hover
[image]

DataTypeEnum Enumeration (DAO)
Send feedback

Specifies the operational data type of an object.

Name

Value

Description

dbAttachment

101

Attachment data

dbBigInt

16

Big Integer data

dbBinary

9

Binary data

dbBoolean

1

Boolean (True/False) data

dbByte

2

Byte (8-bit) data

dbChar

18

Text data (fixed width)

dbComplexByte

102

Multi-valued byte data

dbComplexDecimal

108

Multi-value decimal data

dbComplexDouble

106

Multi-value double-precision floating-point data

dbComplexGUID

107

Multi-value GUID data

dbComplexInteger

103

Multi-value integer data

dbComplexLong

104

Multi-value long integer data

dbComplexSingle

105

Multi-value single-precision floating-point data

dbComplexText

109

Multi-value Text data (variable width)

dbCurrency

5

Currency data

dbDate

8

Date value data

dbDecimal

20

Decimal data (ODBCDirect only)

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

dbDouble

7

Double-precision floating-point data

dbFloat

21

Floating-point data (ODBCDirect only)

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

dbGUID

15

GUID data

dbInteger

3

Integer data

dbLong

4

Long Integer data

dbLongBinary

11

Binary data (bitmap)

dbMemo

12

Memo data (extended text)

dbNumeric

19

Numeric data (ODBCDirect only)

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

dbSingle

6

Single-precision floating-point data

dbText

10

Text data (variable width)

dbTime

22

Data in time format (ODBCDirect only)

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

dbTimeStamp

23

Data in time and date format (ODBCDirect only)

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

dbVarBinary

17

Variable Binary data (ODBCDirect only)

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.


Reshape Name Property--Dynamic (ADO)

 Copy code hover
[image]

Reshape Name Property--Dynamic (ADO)
Send feedback

Specifies a name for the Recordset object.

Return Values

Returns a String value that is the name of the Recordset.

Remarks

Names persist for the duration of the connection or until the Recordset is closed.

The Reshape Name property is primarily intended for use with the re-shaping feature of the Microsoft Data Shaping Service for OLE DB service provider. Names must be unique in order to participate in re-shaping.

This property is read-only, but can be set indirectly when a Recordset is created. For example, if a clause of a SHAPE command creates a Recordset and gives it an alias name with the "AS" keyword, then the alias is assigned to the Reshape Name property. If no alias is declared then the reshape name property is assigned a unique name generated by the data shaping service. If the alias name is the same as the name of an existing Recordset, neither Recordset be reshaped until one of them is released. The default behavior can be changed by setting the "Unique Reshape Names" (See "Microsoft Data shaping service for OLE DB") property on the ADO connection to TRUE. This give the data shaping service permission to change user assigend names if necessary to insure uniqueness.

Use the Reshape Name property when you want to refer to a Recordset in a SHAPE command, or when you don't know its name because it was generated by Data Shaping Service. In that case, you could generate a SHAPE command by concatenating the command around the string returned by the Reshape Name property.

Reshape Name is a dynamic property appended to the Recordset object's Properties collection when the CursorLocation property is set to adUseClient.


How to: Use Aggregate Functions to Work with Values in Access SQL

 Copy code hover
[image]

How to: Use Aggregate Functions to Work with Values in Access SQL
Send feedback

Aggregate functions are used to calculate statistical and summary information from data in tables. These functions are used in SELECT statements, and all of them take fields or expressions as arguments.

To count the number of records in a result set, use the Count function. Using an asterisk with the Count function causes Null values to be counted as well.

VBA Copy code Copy code
SELECT Count(*) AS [Number of Invoices]
    FROM tblInvoices

To count only non-Null values, use the Count function with a field name.

VBA Copy code Copy code
SELECT Count(Amount) AS
    [Number of Valid Invoice Amounts]
    FROM tblInvoices

To find the average value for a column or expression of numeric data, use the Avg function.

VBA Copy code Copy code
SELECT Avg(Amount) AS [Average Invoice Amount]
    FROM tblInvoices

To find the total of the values in a column or expression of numeric data, use the Sum function.

VBA Copy code Copy code
SELECT Sum(Amount) AS [Total Invoice Amount]
    FROM tblInvoices

To find the minimum value for a column or expression, use the Min function.

VBA Copy code Copy code
SELECT Min(Amount) AS [Minimum Invoice Amount]
    FROM tblInvoices

To find the maximum value for a column or expression, use the Max function.

VBA Copy code Copy code
SELECT Max(Amount) AS [Maximum Invoice Amount]
    FROM tblInvoices

To find the first value in a column or expression, use the First function.

VBA Copy code Copy code
SELECT First(Amount) AS [First Invoice Amount]
    FROM tblInvoices

To find the last value in a column or expression, use the Last function.

VBA Copy code Copy code
SELECT Last(Amount) AS [Last Invoice Amount]
    FROM tblInvoices


Recordset.GetRows Method (DAO)

 Copy code hover
[image]

Recordset.GetRows Method (DAO)
Send feedback

Retrieves multiple rows from a Recordset object.

Syntax

expression .GetRows(NumRows)

expression A variable that represents a Recordset object.

Parameters

Name | Required/Optional | Data Type | Description
NumRows | Optional | Variant | The number of rows to retrieve.

Return Value

Variant

Remarks

Use the GetRows method to copy records from a Recordset. GetRows returns a two-dimensional array. The first subscript identifies the field and the second identifies the row number. For example, intField represents the field, and intRecord identifies the row number:

avarRecords(intField, intRecord)

To get the first field value in the second row returned, use code like the following:

field1 = avarRecords(0,1)

To get the second field value in the first row, use code like the following:

field2 = avarRecords(1,0)

The avarRecords variable automatically becomes a two-dimensional array when GetRows returns data.

If you request more rows than are available, then GetRows returns only the number of available rows. You can use the Visual Basic for Applications UBound function to determine how many rows GetRows actually retrieved, because the array is sized to fit the number of returned rows. For example, if you returned the results into a Variant called varA, you could use the following code to determine how many rows were actually returned:

numReturned = UBound(varA,2) + 1

You need to use "+ 1" because the first row returned is in the 0 element of the array. The number of rows that you can retrieve is constrained by the amount of available memory. You shouldn't use GetRows to retrieve an entire table into an array if it is large.

Because GetRows returns all fields of the Recordset into the array, including Memo and Long Binary fields, you might want to use a query that restricts the fields returned.

After you call GetRows, the current record is positioned at the next unread row. That is, GetRows has the same effect on the current record as Move numrows.

If you are trying to retrieve all the rows by using multiple GetRows calls, use the EOF property to be sure that you're at the end of the Recordset. GetRows returns less than the number requested if it's at the end of the Recordset, or if it can't retrieve a row in the range requested. For example, if you're trying to retrieve 10 records, but you can't retrieve the fifth record, GetRows returns four records and makes the fifth record the current record. This will not generate a run-time error. This might occur if another user deletes a record in a dynaset-type Recordset. See the example for a demonstration of how to handle this.

Example

This example uses the GetRows method to retrieve a specified number of rows from a Recordset and to fill an array with the resulting data. The GetRows method will return fewer than the desired number of rows in two cases: either if EOF has been reached, or if GetRows tried to retrieve a record that was deleted by another user. The function returns False only if the second case occurs. The GetRowsOK function is required for this procedure to run.

VBA Copy code Copy code
Sub GetRowsX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset
 Dim strMessage As String
 Dim intRows As Integer
 Dim avarRecords As Variant
 Dim intRecord As Integer

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = dbsNorthwind.OpenRecordset( _
 "SELECT FirstName, LastName, Title " & _
 "FROM Employees ORDER BY LastName", dbOpenSnapshot)

 With rstEmployees
 Do While True
 ' Get user input for number of rows.
 strMessage = "Enter number of rows to retrieve."
 intRows = Val(InputBox(strMessage))

 If intRows <= 0 Then Exit Do

 ' If GetRowsOK is successful, print the results,
 ' noting if the end of the file was reached.
 If GetRowsOK(rstEmployees, intRows, _
 avarRecords) Then
 If intRows > UBound(avarRecords, 2) + 1 Then
 Debug.Print "(Not enough records in " & _
 "Recordset to retrieve " & intRows & _
 " rows.)"
 End If
 Debug.Print UBound(avarRecords, 2) + 1 & _
 " records found."

 ' Print the retrieved data.
 For intRecord = 0 To UBound(avarRecords, 2)
 Debug.Print " " & _
 avarRecords(0, intRecord) & " " & _
 avarRecords(1, intRecord) & ", " & _
 avarRecords(2, intRecord)
 Next intRecord
 Else
 ' Assuming the GetRows error was due to data
 ' changes by another user, use Requery to
 ' refresh the Recordset and start over.
 If .Restartable Then
 If MsgBox("GetRows failed--retry?", _
 vbYesNo) = vbYes Then
 .Requery
 Else
 Debug.Print "GetRows failed!"
 Exit Do
 End If
 Else
 Debug.Print "GetRows failed! " & _
 "Recordset not Restartable!"
 Exit Do
 End If
 End If

 ' Because using GetRows leaves the current record
 ' pointer at the last record accessed, move the
 ' pointer back to the beginning of the Recordset
 ' before looping back for another search.
 .MoveFirst
 Loop
 End With

 rstEmployees.Close
 dbsNorthwind.Close

End Sub

Function GetRowsOK(rstTemp As Recordset, _
 intNumber As Integer, avarData As Variant) As Boolean

 ' Store results of GetRows method in array.
 avarData = rstTemp.GetRows(intNumber)
 ' Return False only if fewer than the desired number of
 ' rows were returned, but not because the end of the
 ' Recordset was reached.
 If intNumber > UBound(avarData, 2) + 1 And _
 Not rstTemp.EOF Then
 GetRowsOK = False
 Else
 GetRowsOK = True
 End If

End Function


Visual C++ Extensions Header

 Copy code hover
[image]

Visual C++ Extensions Header
Send feedback

The following header, icrsint.h, details the interface that allow clients to retrieve fields from a Recordset into variables defined in a class derived from CADORecordBinding. You must specify an ADO binding macro for each field you intend to access.

Copy code Copy code

#ifndef _ICRSINT_H_
#define _ICRSINT_H_

#include <olectl.h>
#include <stddef.h>

// forwards
class CADORecordBinding;

#define classoffset(base, derived) ((DWORD)(static_cast<base*>((derived*)8))-8)

enum ADOFieldStatusEnum
{
 adFldOK = 0,
 adFldBadAccessor = 1,
 adFldCantConvertValue = 2,
 adFldNull = 3,
 adFldTruncated = 4,
 adFldSignMismatch = 5,
 adFldDataOverFlow = 6,
 adFldCantCreate = 7,
 adFldUnavailable = 8,
 adFldPermissionDenied = 9,
 adFldIntegrityViolation = 10,
 adFldSchemaViolation = 11,
 adFldBadStatus = 12,
 adFldDefault = 13
};

typedef struct stADO_BINDING_ENTRY
{
 ULONG ulOrdinal;
 WORD wDataType;
 BYTE bPrecision;
 BYTE bScale;
 ULONG ulSize;
 ULONG ulBufferOffset;
 ULONG ulStatusOffset;
 ULONG ulLengthOffset;
 ULONG ulADORecordBindingOffSet;
 BOOL fModify;
} ADO_BINDING_ENTRY;

#define BEGIN_ADO_BINDING(cls) public: typedef cls ADORowClass; const ADO_BINDING_ENTRY* STDMETHODCALLTYPE GetADOBindingEntries() { static const ADO_BINDING_ENTRY rgADOBindingEntries[] = {

//
// Fixed length non-numeric data
//
#define ADO_FIXED_LENGTH_ENTRY(Ordinal, DataType, Buffer, Status, Modify) {Ordinal, DataType, 0, 0, 0, offsetof(ADORowClass, Buffer), offsetof(ADORowClass, Status), 0, classoffset(CADORecordBinding, ADORowClass), Modify},

#define ADO_FIXED_LENGTH_ENTRY2(Ordinal, DataType, Buffer, Modify) {Ordinal, DataType, 0, 0, 0, offsetof(ADORowClass, Buffer), 0, 0, classoffset(CADORecordBinding, ADORowClass), Modify},

//
// Numeric data
//
#define ADO_NUMERIC_ENTRY(Ordinal, DataType, Buffer, Precision, Scale, Status, Modify) {Ordinal, DataType, Precision, Scale, 0, offsetof(ADORowClass, Buffer), offsetof(ADORowClass, Status), 0, classoffset(CADORecordBinding, ADORowClass), Modify},

#define ADO_NUMERIC_ENTRY2(Ordinal, DataType, Buffer, Precision, Scale, Modify) {Ordinal, DataType, Precision, Scale, 0, offsetof(ADORowClass, Buffer), 0, 0, classoffset(CADORecordBinding, ADORowClass), Modify},

//
// Variable length data
//
#define ADO_VARIABLE_LENGTH_ENTRY(Ordinal, DataType, Buffer, Size, Status, Length, Modify) {Ordinal, DataType, 0, 0, Size, offsetof(ADORowClass, Buffer), offsetof(ADORowClass, Status), offsetof(ADORowClass, Length), classoffset(CADORecordBinding, ADORowClass), Modify},

#define ADO_VARIABLE_LENGTH_ENTRY2(Ordinal, DataType, Buffer, Size, Status, Modify) {Ordinal, DataType, 0, 0, Size, offsetof(ADORowClass, Buffer), offsetof(ADORowClass, Status), 0, classoffset(CADORecordBinding, ADORowClass), Modify},

#define ADO_VARIABLE_LENGTH_ENTRY3(Ordinal, DataType, Buffer, Size, Length, Modify) {Ordinal, DataType, 0, 0, Size, offsetof(ADORowClass, Buffer), 0, offsetof(ADORowClass, Length), classoffset(CADORecordBinding, ADORowClass), Modify},

#define ADO_VARIABLE_LENGTH_ENTRY4(Ordinal, DataType, Buffer, Size, Modify) {Ordinal, DataType, 0, 0, Size, offsetof(ADORowClass, Buffer), 0, 0, classoffset(CADORecordBinding, ADORowClass), Modify},

#define END_ADO_BINDING() {0, adEmpty, 0, 0, 0, 0, 0, 0, 0, FALSE}}; return rgADOBindingEntries;}

//
// Interface that the client 'record' class needs to support. The ADO Binding entries
// provide the implementation for this interface.
//
class CADORecordBinding
{
public:
 STDMETHOD_(const ADO_BINDING_ENTRY*, GetADOBindingEntries) (VOID) PURE;
};

//
// Interface that allows a client to fetch a record of data into class data members.
//
struct __declspec(uuid("00000544-0000-0010-8000-00aa006d2ea4")) IADORecordBinding;
DECLARE_INTERFACE_(IADORecordBinding, IUnknown)
{
public:
 STDMETHOD(BindToRecordset) (CADORecordBinding *pAdoRecordBinding) PURE;
 STDMETHOD(AddNew) (CADORecordBinding *pAdoRecordBinding) PURE;
 STDMETHOD(Update) (CADORecordBinding *pAdoRecordBinding) PURE;
};

#endif // !_ICRSINT_H_


OptionGroup.Top Property (Access)

 Copy code hover
[image]

OptionGroup.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Syntax

expression .Top

expression A variable that represents an OptionGroup object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Rectangle.Section Property (Access)

 Copy code hover
[image]

Rectangle.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Syntax

expression .Section

expression A variable that represents a Rectangle object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


Printer.LeftMargin Property (Access)

 Copy code hover
[image]

Printer.LeftMargin Property (Access)
See also Send feedback

Published: July 16, 2012

Along with the TopMargin, RightMargin, and BottomMargin properties, specifies the margins for a printed page. Read/write Long.

Syntax

expression .LeftMargin

expression A variable that represents a Printer object.

See also

Concepts

Printer Object

Other resources

Printer Object Members


Printers.Parent Property (Access)

 Copy code hover
[image]

Printers.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a Printers object.

See also

Concepts

Printers Collection

Other resources

Printers Object Members


SubForm.Move Method (Access)

 Copy code hover
[image]

SubForm.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a SubForm object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Indexes.Append Method (DAO)

 Copy code hover
[image]

Indexes.Append Method (DAO)
Send feedback

Adds a new Index to the Indexes collection.

Syntax

expression .Append(Object)

expression A variable that represents an Indexes object.

Parameters

Name | Required/Optional | Data Type | Description
Object | Required | Object | An object variable that represents the item being appended to the collection.

Remarks

The appended object becomes a persistent object, stored on disk, until you delete it by using the Delete method.

The addition of a new object occurs immediately, but you should use the Refresh method on any other collections that may be affected by changes to the database structure.

If the object you're appending isn't complete (such as when you haven't appended any Field objects to a Fields collection of an Index object before it's appended to an Indexes collection) or if the properties set in one or more subordinate objects are incorrect, using the Append method causes an error. For example, if you haven't specified a field type and then try to append the Field object to the Fields collection in a TableDef object, using the Append method triggers a run-time error.


Clustered Property (ADOX)

 Copy code hover
[image]

Clustered Property (ADOX)
Send feedback

Indicates whether the index is clustered.

Settings and Return Values

Sets and returns a Boolean value.

Remarks

The default value is False.

This property is read-only on Index objects already appended to a collection.


GetRows Method Example (VJ++)

 Copy code hover
[image]

GetRows Method Example (VJ++)
Send feedback

This example uses the GetRows method to retrieve a specified number of rows from a Recordset and to fill an array with the resulting data. The GetRows method will return less than the desired number of rows in two cases: either if EOF has been reached, or if GetRows tried to retrieve a record that was deleted by another user. The function returns False only if the second case occurs. The GetRowsOK function is required for this procedure to run.

Copy code Copy code

// BeginGetRowsJ
// The WFC class includes the ADO objects.

import com.ms.wfc.data.*;
import java.io.* ;
import com.ms.com.*;

public class GetRowsX
{
 // The main entry point for the application.

 static Variant avarRecords = null;

 public static void main (String[] args)
 {
 GetRowsX();
 System.exit(0);
 }

 // GetRowsX function

 static void GetRowsX()
 {

 // Define ADO Objects.
 Recordset rstEmployees = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String line = null;
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";

 int intRows;
 int intRecord;
 int intUBound;
 int intDisplaysize = 15;

 try
 {
 // Open recordset with names and hire dates from Employees table.
 rstEmployees = new Recordset();
 rstEmployees.open("SELECT fName, lName, hire_date " +
 "FROM Employee ORDER BY lName", strCnn,
 AdoEnums.CursorType.FORWARDONLY,
 AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TEXT);

 while(true)
 {
 // Get user input for number of rows.
 System.out.println(
 "\nEnter number of rows to retrieve. (<= 0 to Exit)");
 line = in.readLine().trim();

 // Convert string entry to int.
 intRows = Integer.parseInt(line);

 // Exit the application if intRows is negative or zero.
 if(intRows <= 0)
 break;

 // If GetRowsOK is successful, print the results,
 // noting if the end of the file was reached.
 if(GetRowsOK(rstEmployees,intRows))
 {
 SafeArray sa = avarRecords.toSafeArray();
 intUBound = sa.getUBound(2);
 if ( intRows > (intUBound + 1))
 System.out.println("\n(Not enough records in " +
 "Recordset to retrieve " + intRows + " rows.)");
 System.out.println("\n" + (intUBound+ 1) +
 " records found.\n");

 // Print the retrieved data.

 for ( intRecord = sa.getLBound();
 intRecord <= intUBound; intRecord++)
 {

 System.out.println(
 " " + sa.getString(0, intRecord) + " " +
 sa.getString(1, intRecord) + ", " +
 sa.getString(2, intRecord));
 if ( ((intRecord +1) % intDisplaysize) == 0)
 {
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 }

 }
 }
 else
 {
 // Assuming the GetRows error was due to data
 // changes by another user, use Requery to
 // refresh the Recordset and start over.
 System.out.println("\nGetRows failed--retry? (Y/N)");
 if(in.readLine().trim().toUpperCase().equals("Y"))
 rstEmployees.requery();
 else
 {
 System.out.println("GetRows failed!");
 break;
 }
 }

 // Because using GetRows leaves the current
 // record pointer at the last record accessed,
 // move the pointer back to the beginning of the
 // Recordset before looping back for another search.
 rstEmployees.moveFirst();
 }

 // Cleanup objects before exit.
 rstEmployees.close();

 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstEmployees != null)
 {
 PrintProviderError(rstEmployees.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 // Display Error that the application has attempted to convert
 // a string of inappropriate format to one of the numeric types.
 catch(java.lang.NumberFormatException ne)
 {
 System.out.println(
 "Exception: Must specify an Integer value." );
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstEmployees != null)
 if (rstEmployees.getState() == 1)
 rstEmployees.close();
 }

 }

 // GetRowsOK Function

 static boolean GetRowsOK(Recordset rstTemp,int intNumber)
 {
 // Store results of GetRows method in array.
 avarRecords = rstTemp.getRows(intNumber);

 // Return False only if fewer than the desired
 // number of rows were returned, but not because the
 // end of the Recordset was reached.
 if ( intNumber > (avarRecords.toSafeArray().getUBound(2)+ 1)
 && !(rstTemp.getEOF()))
 return false;
 else
 return true;

 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndGetRowsJ


CheckBox.HideDuplicates Property (Access)

 Copy code hover
[image]

CheckBox.HideDuplicates Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.

Syntax

expression .HideDuplicates

expression A variable that represents a CheckBox object.

Remarks

The HideDuplicates property applies only to controls (check box, combo box, list box, option button, option group, text box, toggle button) on a report.

The HideDuplicates property uses the following settings.

Setting | Description
True | If the value of a control or the data it contains is the same as in the preceding record, the control is hidden.
False | (Default) The control is visible regardless of the value in the preceding record.

The DefaultValue property doesn't apply to check box, option button, or toggle buttoncontrols when they are in an option group. It does however apply to the option group itself.

You can set the HideDuplicates property only in report Design view.

You can use the HideDuplicates property to create a grouped report by using only the detail section rather than a group header and the detail section.

Example

The following example returns the HideDuplicates property setting for the CategoryName text box and assigns the value to the intCurVal variable.

VBA Copy code Copy code
Dim intCurVal As Integer
intCurVal = Me!CategoryName.HideDuplicates

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


SubForm Object (Access)

 Copy code hover
[image]

SubForm Object (Access)
See also Send feedback

Published: July 16, 2012

This object corresponds to a subform control. The subform control embeds a form in a form.

Remarks

Control: | Tool:
Note Note

For example, you can use a form with a subform to present one-to-many relationships, such as one product category with the items that fall into that category. In this case, the main form can display the category ID, name, and description; the subform can display the available products in that category.

Instead of creating the main form, and then adding the subform control to it, you can simultaneously create the main form and subform with a wizard . You can also create a subform by dragging an existing form or report from the Database window to the main form.

Links provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Create a Subform with Alternating Color Rows

  • Referring To Properties And Controls On Subforms

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Access Object Model Reference

Other resources

SubForm Object Members


The two replicas you are attempting to synchronize are from different replica sets. (Error 3545)

 Copy code hover
[image]

The two replicas you are attempting to synchronize are from different replica sets. (Error 3545)
Send feedback

Replicas from different replica sets cannot be synchronized. Make sure you have selected the proper replica for synchronization.


Printer Properties (Access)

 Copy code hover
[image]

Printer Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
BottomMargin | Along with the TopMargin, RightMargin, and LeftMargin properties, specifies the margins for a printed page. Read/write Long.
ColorMode | Returns or sets an AcPrintColor constant representing whether the specified printer should print output in color or monochrome. Read/write.
ColumnSpacing | Returns or sets a Long representing the vertical space between detail sections in twips. Read/write.
Copies | Returns or sets a Long indicating the number of copies to be printed. Read/write.
DataOnly | True if Microsoft Access prints only the data from a table or query in Datasheet View and not the labels, control borders, gridlines, and display graphics. Read/write Boolean.
DefaultSize | True if the size of the detail section in Design View is used for printing; otherwise, the values of the ItemSizeHeight and ItemSizeWidth properties are used. Read/write Boolean.
DeviceName | Returns a String indicating name of the specified printer device. Read-only.
DriverName | Returns a String indicating the name of the driver used by the specified printer. Read-only.
Duplex | Returns or sets an AcPrintDuplex constant indicating how the specified printer handles duplex printing. Read/write.
ItemLayout | Returns or sets an AcPrintItemLayout constant indicating whether the printer lays columns across, then down, or down, then across. Read/write.
ItemsAcross | Returns or sets a Long indicating the number of columns to print across a page for multiple-column reports or labels. Read/write.
ItemSizeHeight | Returns or sets a Long indicating the height of the detail section of a form or report in twips. Read/write.
ItemSizeWidth | Returns or sets a Long indicating the height of the detail section of a form or report in twips. Read/write.
LeftMargin | Along with the TopMargin, RightMargin, and BottomMargin properties, specifies the margins for a printed page. Read/write Long.
Orientation | Gets or sets an AcPrintOrientation constant that represents the print orientation. Read/write.
PaperBin | Returns or sets an AcPrintPaperBin constant indicating which paper bin the specified printer should use. Read/write.
PaperSize | Returns or sets an AcPrintPaperSize constant indicating the paper size to use when printing. Read/write.
Port | Returns a String indicating the port name of the specified printer. Read-only.
PrintQuality | Returns or sets an AcPrintObjQuality constant indicating the resolution at which the specified printer should print jobs. Read/write.
RightMargin | Along with the TopMargin, LeftMargin, and BottomMargin properties, specifies the margins for a printed page. Read/write Long.
RowSpacing | Returns or sets a Long indicating the horizontal space between detail sections in twips. Read/write.
TopMargin | Along with the LeftMargin, RightMargin, and BottomMargin properties, specifies the margins for a printed page. Read/write Long.


RDS Scenario

 Copy code hover
[image]

RDS Scenario
Send feedback

In this section

  • System Requirements for the Address Book Application

  • Running the Address Book Sample Application

  • Address Book Data-Binding Object

  • Address Book Command Buttons

  • Address Book Navigation Buttons


OptionGroup.HorizontalAnchor Property (Access)

 Copy code hover
[image]

OptionGroup.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the option group is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .HorizontalAnchor

expression A variable that represents an OptionGroup object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Immediate Mode

 Copy code hover
[image]

Immediate Mode
Send feedback

Immediate mode is in effect when the LockType property is set to adLockOptimistic or adLockPessimistic. In immediate mode, changes to a record are propagated to the data source as soon as you declare the work on a row complete by calling the Update method.

Calling Update

If you move from the record you are adding or editing before calling the Update method, ADO will automatically call Update to save the changes. You must call the CancelUpdate method before navigation if you want to cancel any changes made to the current record or discard a newly added record.

The current record remains current after you call the Update method.

CancelUpdate

Use the CancelUpdate method to cancel any changes made to the current row or to discard a newly added row. You cannot cancel changes to the current row or a new row after you call the Update method, unless the changes are either part of a transaction that you can roll back with the RollbackTrans method or part of a batch update. In the case of a batch update, you can cancel the Update with the CancelUpdate or CancelBatch method.

If you are adding a new row when you call the CancelUpdate method, the current row becomes the row that was current before the AddNew call.

If you have not changed the current row or added a new row, calling the CancelUpdate method generates an error.


CheckBox.Top Property (Access)

 Copy code hover
[image]

CheckBox.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Syntax

expression .Top

expression A variable that represents a CheckBox object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


BoundObjectFrame.MouseMove Event (Access)

 Copy code hover
[image]

BoundObjectFrame.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents a BoundObjectFrame object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


CustomControl.LostFocus Event (Access)

 Copy code hover
[image]

CustomControl.LostFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The LostFocus event occurs when the specified object loses the focus.

Syntax

expression .LostFocus

expression A variable that represents a CustomControl object.

Remarks

To run a macro or event procedure when these events occur, set the OnLostFocus property to the name of the macro or to [Event Procedure].

This events occurs when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The LostFocus event differs from the Exit event in that the LostFocus event occurs every time a control loses the focus. The Exit event occurs only before a control loses the focus to another control on the same form. The LostFocus event occurs after the Exit event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Operation not supported on a table that contains data. (Error 3282)

 Copy code hover
[image]

Operation not supported on a table that contains data. (Error 3282)
Send feedback

You cannot add a field or create an index on a linked table that contains data. Once a table is populated with data, you cannot change the table design or indexes. Create a new table with the altered design and transfer the data to it using an action query.


Field (ADO/WFC Syntax)

 Copy code hover
[image]

Field (ADO/WFC Syntax)
Send feedback

package com.ms.wfc.data

Methods

Copy code Copy code

public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthappchunk_HV10294090.xml(byte[] bytes)
public void appendChunk(char[] chars)
public void appendChunk(String chars)
public byte[] getByteChunk(int len)
public char[] getCharChunk(int len)
public String getStringChunk(int len)

Properties

Copy code Copy code

public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdproactualsize_HV10293998.xml()
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdproattributes_HV10294098.xml()
public void setAttributes(int pl)
public com.ms.com.IUnknown getDataFormat()
public void setDataFormat(com.ms.com.IUnknown format)

(For more information, see the Microsoft Visual J++ WFC Reference documentation for the com.ms.wfc.data.IDataFormat interface.)

Copy code Copy code

public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprodefinedsize_HV10294289.xml()
public void setDefinedSize(int pl)
public String Invalid DDUE based on source, error:link not allowed in code, link filename:mdproname_HV10294535.xml()
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdpronumericscale_HV10294551.xml()
public void setNumericScale(byte pbNumericScale)
public Variant Invalid DDUE based on source, error:link not allowed in code, link filename:mdprooriginalvalue_HV10294583.xml()
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdproprecision_HV10294615.xml()
public void setPrecision(byte pbPrecision)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprotype_HV10294866.xml()
public void setType(int pDataType)
public Variant Invalid DDUE based on source, error:link not allowed in code, link filename:mdprounderlyingvalue_HV10294879.xml()
public Variant Invalid DDUE based on source, error:link not allowed in code, link filename:mdprovalue_HV10294920.xml()
public void setValue(Variant value)
public AdoProperties Invalid DDUE based on source, error:link not allowed in code, link filename:mdcolproperties_HV10294633.xml()

Field Accessor Methods

The Value property of a Field object gets or sets the content of that object. The content is represented as a VARIANT, a type of object that can be assigned a value and any of several data types.

ADO/WFC implements the Value property with the getValue method, which returns a VARIANT object; and the setValue method, which takes a VARIANT as an argument. VARIANTs are highly efficient in certain languages, such as Microsoft Visual Basic. However, you can attain better performance in Microsoft Visual J++ by using native Java data types.

In addition to the Value property, ADO/WFC provides accessor methods that use Java data types to get and set the content of Field objects. Most of these methods have names of the form get DataType or set DataType.

There are two noteworthy exceptions: One of the getObject methods returns an object coerced into a specified class. There is no getNull property; instead, there is an isNull property that returns a Boolean value indicating whether the field is null.

Copy code Copy code

public native boolean getBoolean();
public void setBoolean(boolean v)
public native byte getByte();
public void setByte(byte v)
public native byte[] getBytes();
public void setBytes(byte[] v)
public native double getDouble();
public void setDouble(double v)
public native float getFloat();
public void setFloat(float v)
public native int getInt();
public void setInt(int v)
public native long getLong();
public void setLong(long v)
public native short getShort();
public void setShort(short v)
public native String getString();
public void setString(String v)
public native boolean isNull();
public void setNull()
public Object getObject()
public Object getObject(Class c)
public void setObject(Object value)


CommandButton.Layout Property (Access)

 Copy code hover
[image]

CommandButton.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified button. Read-only AcLayoutType.

Version Information

Version Added: Access 2007

Syntax

expression .Layout

expression A variable that represents a CommandButton object.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Attachment.MouseMove Event (Access)

 Copy code hover
[image]

Attachment.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents an Attachment object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


MoveFirst, MoveLast, MoveNext, and MovePrevious Methods Example (VB)

 Copy code hover
[image]

MoveFirst, MoveLast, MoveNext, and MovePrevious Methods Example (VB)
Send feedback

This example uses the MoveFirst, MoveLast, MoveNext, and MovePrevious methods to move the record pointer of a Recordset based on the supplied command. The MoveAny procedure is required for this procedure to run.

Copy code Copy code

'BeginMoveFirstVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 ' connection and recordset variables
 Dim rstAuthors As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim strSQLAuthors
 ' record variables
 Dim strMessage As String
 Dim intCommand As Integer

 ' Open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open recordset from Authors table
 Set rstAuthors = New ADODB.Recordset
 rstAuthors.CursorLocation = adUseClient
 ' Use client cursor to enable AbsolutePosition property
 strSQLAuthors = "Authors"
 rstAuthors.Open strSQLAuthors, Cnxn, adOpenStatic, adLockReadOnly, adCmdTable

 ' Show current record information and get user's method choice
 Do
 strMessage = "Name: " & rstAuthors!au_fname & " " & _
 rstAuthors!au_lname & vbCr & "Record " & _
 rstAuthors.AbsolutePosition & " of " & _
 rstAuthors.RecordCount & vbCr & vbCr & _
 "[1 - MoveFirst, 2 - MoveLast, " & vbCr & _
 "3 - MoveNext, 4 - MovePrevious]"
 intCommand = Val(Left(InputBox(strMessage), 1))

 ' for exiting the loop
 If intCommand < 1 Or intCommand > 4 Then
 MsgBox "You either entered a non-number or canceled the input box. Exit the application."
 Exit Do
 End If

 ' Use specified method while trapping for BOF and EOF
 Select Case intCommand
 Case 1
 rstAuthors.MoveFirst
 Case 2
 rstAuthors.MoveLast
 Case 3
 rstAuthors.MoveNext
 If rstAuthors.EOF Then
 MsgBox "Already at end of recordset!"
 rstAuthors.MoveLast
 End If
 Case 4
 rstAuthors.MovePrevious
 If rstAuthors.BOF Then
 MsgBox "Already at beginning of recordset!"
 rstAuthors.MoveFirst
 End If
 End Select
 Loop

 ' clean up
 rstAuthors.Close
 Cnxn.Close
 Set rstAuthors = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstAuthors Is Nothing Then
 If rstAuthors.State = adStateOpen Then rstAuthors.Close
 End If
 Set rstAuthors = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub

'EndMoveFirstVB


Command Properties, Methods, and Events (ADO)

 Copy code hover
[image]

Command Properties, Methods, and Events (ADO)
Send feedback

Properties/Collections

ActiveConnection Property

CommandText Property

CommandTimeout Property

CommandType Property

Name Property

Parameters Collection

Prepared Property

Properties Collection

State Property

Methods

Cancel Method

CreateParameter Method

Execute Method (ADO Command)

Events

None.


SubForm.Enabled Property (Access)

 Copy code hover
[image]

SubForm.Enabled Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.

Syntax

expression .Enabled

expression A variable that represents a SubForm object.

Remarks

The Enabled property setting is a value that indicates whether the conditional format is enabled or disabled. True enables the conditional format. False disables the conditional format. The default is True.

When the Enabled property is True, the conditional format can be displayed in the Conditional Formatting dialog box.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Delete Method (ADO Recordset)

 Copy code hover
[image]

Delete Method (ADO Recordset)
Send feedback

Deletes the current record or a group of records.

Syntax

recordset.Delete AffectRecords

Parameters

  • AffectRecords

  • An AffectEnum value that determines how many records the Delete method will affect. The default value is adAffectCurrent.

Note Note

adAffectAll and adAffectAllChapters are not valid arguments to Delete.

Remarks

Using the Delete method marks the current record or a group of records in a Recordset object for deletion. If the Recordset object doesn't allow record deletion, an error occurs. If you are in immediate update mode, deletions occur in the database immediately. If a record cannot be successfully deleted (due to database integrity violations, for example), the record will remain in edit mode after the call to Update. This means that you must cancel the update with CancelUpdate before moving off the current record (for example, with Close, Move, or NextRecordset).

If you are in batch update mode, the records are marked for deletion from the cache and the actual deletion happens when you call the UpdateBatch method. (Use the Filter property to view the deleted records.)

Retrieving field values from the deleted record generates an error. After deleting the current record, the deleted record remains current until you move to a different record. Once you move away from the deleted record, it is no longer accessible.

If you nest deletions in a transaction, you can recover deleted records with the RollbackTrans method. If you are in batch update mode, you can cancel a pending deletion or group of pending deletions with the CancelBatch method.

If the attempt to delete records fails because of a conflict with the underlying data (for example, a record has already been deleted by another user), the provider returns warnings to the Errors collection but does not halt program execution. A run-time error occurs only if there are conflicts on all the requested records.

If the Unique Table dynamic property is set, and the Recordset is the result of executing a JOIN operation on multiple tables, then the Delete method will only delete rows from the table named in the Unique Table property.


Containers Object Reference (DAO)

 Copy code hover
[image]

Containers Object Reference (DAO)
Send feedback

In this section

  • Containers Collection (DAO)

  • Containers Members (DAO)

  • Containers Properties (DAO)

  • Containers Methods (DAO)


Documents Object Reference (DAO)

 Copy code hover
[image]

Documents Object Reference (DAO)
Send feedback

In this section

  • Documents Collection (DAO)

  • Documents Members (DAO)

  • Documents Properties (DAO)

  • Documents Methods (DAO)


OptionButton.Enter Event (Access)

 Copy code hover
[image]

OptionButton.Enter Event (Access)
See also Send feedback

Published: July 16, 2012

The Enter event occurs before a control actually receives the focus from a control on the same form or report.

Syntax

expression .Enter

expression A variable that represents an OptionButton object.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when these events occur, set the OnEnter or OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Enter event occurs before the GotFocus event. The Exit event occurs before the LostFocus event.

Unlike the GotFocus and LostFocus events, the Enter and Exit events don't occur when a form receives or loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Label.RightPadding Property (Access)

 Copy code hover
[image]

Label.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the label and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .RightPadding

expression A variable that represents a Label object.

See also

Concepts

Label Object

Other resources

Label Object Members


NavigationControl.OnGotFocus Property (Access)

 Copy code hover
[image]

NavigationControl.OnGotFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnGotFocus

expression A variable that represents a NavigationControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The GotFocus event occurs when the object receives the focus.

The OnGotFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Got Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Got Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnGotFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnGotFocus

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


TabControl Properties (Access)

 Copy code hover
[image]

TabControl Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BottomPadding | Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontName | You can use the FontName property to specify the font for text in the following situations:
FontSize | You can use the FontSize property to specify the point size for text in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
FontWeight | You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
ForeShade | Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
ForeThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.
ForeTint | Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
Gradient | Gets or sets the gradient fill applied to the specified object. Read/write Long.
GridlineColor | Gets or sets the color of the gridline for the specified list box. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified list box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified text box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified text box. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified text box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified text box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified text box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the tab control is anchored horizontally within its layout. Read/write.
HoverColor | Gets or sets the color displayed on the control when the user rests the mouse cursor over it. Read/write Long.
HoverForeColor | Gets or sets the color of the text displayed on the control when the user rests the mouse cursor over it. Read/write Long.
HoverForeShade | Gets or sets the shade applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.
HoverForeThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverForeColor property of the specified object. Read/write Long.
HoverForeTint | Gets or sets the tint applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.
HoverShade | Gets or sets the shade that is applied to the theme color in the HoverColor property of the specified object. Read/write Single.
HoverThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverColor property of the specified object. Read/write Long.
HoverTint | Gets or sets the tint applied to the theme color in the HoverColor property of the specified object. Read/write Single.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Layout | Returns the type of layout for the specified text box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified text box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.
MultiRow | You can use the MultiRow property to specify or determine whether a tab control can display more than one row of tabs. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnChange | Sets or returns the value of the On Change box in the Properties window of one of the objects in the Applies To list. Read/write String.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
Pages | Returns a Pages collection that represents the pages in the specified TabControl object. Read-only.
Parent | Returns the parent object for the specified object. Read-only.
PressedColor | Gets or sets the color displayed on the control when the user clicks it. Read/write Long.
PressedForeColor | Gets or sets the color of the text displayed on the control when the user clicks it. Read/write Long.
PressedForeShade | Gets or sets the shade applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.
PressedForeThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedForeColor property of the specified object. Read/write Long.
PressedForeTint | Gets or sets the tint applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.
PressedShade | Gets or sets the shade that is applied to the theme color in the PressedColor property of the specified object. Read/write Single.
PressedThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedColor property of the specified object. Read/write Long.
PressedTint | Gets or sets the tint applied to the theme color in the PressedColor property of the specified object. Read/write Single.
Properties | Returns a reference to a control's Properties collection object. Read-only.
RightPadding | Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
Shape | Returns or sets the shape of the specified tab control. Read/write Long.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
Style | You can use the Style property to specify or determine the appearance of tabs on a tab control. Read/write Byte.
TabFixedHeight | You can use the TabFixedHeight property to specify or determine the height of the tabs on a tab control. Read/write Integer.
TabFixedWidth | You can use the TabFixedWidth property to specify or determine the width of the tabs on a tab control. Read/write Integer.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
ThemeFontIndex | Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.
UseTheme | Gets or sets whether the specified object will utilize formatting styles defined in Office Document Themes. Read/write Boolean.
Value | Determines or specifies the selected Page object. Read/write Variant.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified tab control is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


Form.KeyPress Event (Access)

 Copy code hover
[image]

Form.KeyPress Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyPress(KeyAscii)

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
KeyAscii | Required | Integer | Returns a numeric ANSI key code. The KeyAscii argument is passed by reference; changing it sends a different character to the object. Setting the KeyAscii argument to 0 cancels the keystroke so that the object doesn't recognize that a key was pressed.

Remarks

To run a macro or event procedure when this event occurs, set the OnKeyPress property to the name of the macro or to [Event Procedure].

The object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down an ANSI key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

A KeyPress event can involve any printable keyboard character, the CTRL key combined with a character from the standard alphabet or a special character, and the ENTER or BACKSPACE key. You can use the KeyDown and KeyUp event procedures to handle any keystroke not recognized by the KeyPress event, such as function keys, navigation keys, and any combinations of these with keyboard modifiers (ALT, SHIFT, or CTRL keys). Unlike the KeyDown and KeyUp events, the KeyPress event doesn't indicate the physical state of the keyboard; instead, it indicates the ANSI character that corresponds to the pressed key or key combinations.

KeyPress interprets the uppercase and lowercase of each character as separate key codes and, therefore, as two separate characters.

Note Note

The BACKSPACE key is part of the ANSI character set, but the DEL key isn't. If you delete a character in a control by using the BACKSPACE key, you cause a KeyPress event; if you use the DEL key, you don't.

The KeyDown and KeyPress events occur when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

For example, if you go to a new record and type a character in the first control in the record, the following events occur:

Current (for the new record)

ß

Enter (for the first control in the new record)

ß

GotFocus (for the control)

ß

KeyDown (for the control)

ß

KeyPress (for the control)

ß

BeforeInsert (for the new record in the form)

ß

Change (for the control if it's a text box or combo box)

ß

KeyUp (for the control)

Example

The following example converts text entered in a text box to uppercase as the text is typed in, one character at a time.

To try the example, add the following event procedure to a form that contains a text box named ShipRegion.

VBA Copy code Copy code
Private Sub ShipRegion_KeyPress(KeyAscii As Integer)
 Dim strCharacter As String

 ' Convert ANSI value to character string.
 strCharacter = Chr(KeyAscii)
 ' Convert character to upper case, then to ANSI value.
 KeyAscii = Asc(UCase(strCharacter))
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Recordset.FindPrevious Method (DAO)

 Copy code hover
[image]

Recordset.FindPrevious Method (DAO)
Send feedback

Locates the previous record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only). .

Syntax

expression .FindPrevious(Criteria)

expression A variable that represents a Recordset object.

Parameters

Name | Required/Optional | Data Type | Description
Criteria | Required | String | A String used to locate the record. It is like the WHERE clause in an SQL statement, but without the word WHERE.

Remarks

If you want to include all the records in your search — not just those that meet a specific condition — use the Move methods to move from record to record. To locate a record in a table-type Recordset, use the Seek method.

If a record matching the criteria isn't located, the current record pointer is unknown, and the NoMatch property is set to True. If recordset contains more than one record that satisfies the criteria, FindFirst locates the first occurrence, FindNext locates the next occurrence, and so on.

Each of the Find methods begins its search from the location and in the direction specified in the following table.

Find method | Begins searching at | Search direction
FindFirst | Beginning of recordset | End of recordset
FindLast | End of recordset | Beginning of recordset
FindNext | Current record | End of recordset
FindPrevious | Current record | Beginning of recordset

Using one of the Find methods isn't the same as using a Move method, however, which simply makes the first, last, next, or previous record current without specifying a condition. You can follow a Find operation with a Move operation.

Always check the value of the NoMatch property to determine whether the Find operation has succeeded. If the search succeeds, NoMatch is False. If it fails, NoMatch is True and the current record isn't defined. In this case, you must position the current record pointer back to a valid record.

Using the Find methods with Microsoft Access database engine-connected ODBC-accessed recordsets can be inefficient. You may find that rephrasing your criteria to locate a specific record is faster, especially when working with large recordsets.

When working with Microsoft Access database engine-connected ODBC databases and large dynaset-type Recordset objects, you might discover that using the Find methods or using the Sort or Filter property is slow. To improve performance, use SQL queries with customized ORDER BY or WHERE clauses, parameter queries, or QueryDef objects that retrieve specific indexed records.

You should use the U.S. date format (month-day-year) when you search for fields containing dates, even if you're not using the U.S. version of the Microsoft Access database engine; otherwise, the data may not be found. Use the Visual Basic Format function to convert the date. For example:

VBA Copy code Copy code
rstEmployees.FindFirst "HireDate > #" _
    & Format(mydate, 'm-d-yy' ) & "#"

If criteria is composed of a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strSQL = "PRICE > " & lngPrice, and lngPrice = 125,50), an error occurs when you try to call the method. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and Microsoft Access SQL only accepts U.S. decimal characters.

Note Note

  • For best performance, the criteria should be in either the form "field = value" where field is an indexed field in the underlying base table, or "field LIKE prefix" where field is an indexed field in the underlying base table and prefix is a prefix search string (for example, "ART*" ).

  • In general, for equivalent types of searches, the Seek method provides better performance than the Find methods. This assumes that table-type Recordset objects alone can satisfy your needs.


ListBox.LeftPadding Property (Access)

 Copy code hover
[image]

ListBox.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the list box and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .LeftPadding

expression A variable that represents a ListBox object.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


ObjectFrame.Move Method (Access)

 Copy code hover
[image]

ObjectFrame.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents an ObjectFrame object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Pages Members (Access)

 Copy code hover
[image]

Pages Members (Access)
Send feedback

Published: July 16, 2012

The Pages collection contains all Page objects in a tab control.

Methods

Name | Description
Add | The Add method adds a new Pageobject to the Pages collection of a tab control.
Remove | The Remove method removes a Page object from the Pages collection of a tab control.

Properties

Name | Description
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Page.


NavigationButton.BottomPadding Property (Access)

 Copy code hover
[image]

NavigationButton.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .BottomPadding

expression A variable that represents a NavigationButton object.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


SetPermissions Method (ADOX)

 Copy code hover
[image]

SetPermissions Method (ADOX)
Send feedback

Specifies the permissions for a group or user on an object.

Syntax

GroupOrUser.SetPermissions Name, ObjectType, Action, Rights [,Inherit] [,ObjectTypeId]

Parameters

  • Name

  • A String value that specifies the name of the object for which to set permissions.

  • ObjectType

  • A Long value which can be one of the ObjectTypeEnum constants, that specifies the type of the object for which to get permissions.

  • Action

  • A Long value which can be one of the ActionEnum constants that specifies the type of action to perform when setting permissions.

  • Rights

  • A Long value which can be a bitmask of one or more of the RightsEnum constants, that indicates the rights to set.

  • Inherit

  • Optional. A Long value which can be one of the InheritTypeEnum constants, that specifies how objects will inherit these permissions. The default value is adInheritNone.

  • ObjectTypeId

  • Optional. A Variant value that specifies the GUID for a provider object type not defined by the OLE DB specification. This parameter is required if ObjectType is set to adPermObjProviderSpecific; otherwise, it is not used.

Remarks

An error will occur if the provider does not support setting access rights for groups or users.

Note Note

When calling SetPermissions, setting Actions to adAccessRevoke overrides any settings of the Rights parameter. Do not set Actions to adAccessRevoke if you want the rights specified in the Rights parameter to take effect.


TabControl.PressedColor Property (Access)

 Copy code hover
[image]

TabControl.PressedColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color displayed on the control when the user clicks it. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .PressedColor

expression A variable that represents a TabControl object.

Remarks

The PressedColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


ComboBox.BackColor Property (Access)

 Copy code hover
[image]

ComboBox.BackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the interior color of the specified object. Read/write Long.

Syntax

expression .BackColor

expression A variable that represents a ComboBox object.

Remarks

The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

To use the BackColor property, the BackStyle property, if available, must be set to Normal.

Example

The following example uses the RGB function to set the , BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


CheckBox Object (Access)

 Copy code hover
[image]

CheckBox Object (Access)
See also Send feedback

Published: July 16, 2012

This object corresponds to a check box on a form or report. This check box is a stand-alone control that displays a Yes/No value from an underlying record source.

Remarks

Control: | Tool:

When you select or clear a check box that's bound to a Yes/No field, Microsoft Access displays the value in the underlying table according to the field's Format property (Yes/No, True/False, or On/Off).

You can also use check boxes in an option group to display values to choose from.

See also

Concepts

Access Object Model Reference

Other resources

CheckBox Object Members


EmptyCell.GridlineShade Property (Access)

 Copy code hover
[image]

EmptyCell.GridlineShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineShade

expression A variable that represents an EmptyCell object.

Remarks

The GridlineShade property contains a numeric expression that can be used to darken the theme color in the GridlineColor property. The default value of the GridlineShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


Module.ProcOfLine Property (Access)

 Copy code hover
[image]

Module.ProcOfLine Property (Access)
See also Send feedback

Published: July 16, 2012

The ProcOfLine property returns the name of the procedure that contains a specified line in a standard module or a class module. Read-only string.

Syntax

expression .ProcOfLine(Line, pprockind)

expression A variable that represents a Module object.

Parameters

Name | Required/Optional | Data Type | Description
Line | Required | Long | The number of a line in the module.
pprockind | Required | vbext_ProcKind | The type of procedure. See the Remarks section for the possible settings.

Remarks

The ProcKind argument can be one of the following vbext_ProcKind constants:

Constant | Description
vbext_pk_Get | A Property Get procedure.
vbext_pk_Let | A Property Let procedure.
vbext_pk_Proc | A Sub or Function procedure.
vbext_pk_Set | A Property Set procedure.

For any given line number, the ProcOfLine property returns the name of the procedure that contains that line. Since comments and compilation constants immediately preceding a procedure definition are considered part of that procedure, the ProcOfLine property may return the name of a procedure for a line that isn't within the body of the procedure. The ProcStartLine property indicates the line on which a procedure begins; the ProcBodyLine property indicates the line on which the procedure definition begins (the body of the procedure).

Note that the pprockind argument indicates whether the line belongs to a Sub or Function procedure, a Property Get procedure, a Property Let procedure, or a Property Set procedure. To determine what type of procedure a line is in, pass a variable of type Long to the ProcOfLine property, then check the value of that variable.

Note Note

The ProcBodyLine property treats Sub and Function procedures similarly, but distinguishes between each type of Property procedure.

Example

The following function procedure lists the names of all procedures in a specified module:

VBA Copy code Copy code
Public Function AllProcs(ByVal strModuleName As String)

 Dim mdl As Module
 Dim lngCount As Long
 Dim lngCountDecl As Long
 Dim lngI As Long
 Dim strProcName As String
 Dim astrProcNames() As String
 Dim intI As Integer
 Dim strMsg As String
 Dim lngR As Long

 ' Open specified Module object.
 DoCmd.OpenModule strModuleName

 ' Return reference to Module object.
 Set mdl = Modules(strModuleName)

 ' Count lines in module.
 lngCount = mdl.CountOfLines

 ' Count lines in Declaration section in module.
 lngCountDecl = mdl.CountOfDeclarationLines

 ' Determine name of first procedure.
 strProcName = mdl.ProcOfLine(lngCountDecl + 1, lngR)

 ' Initialize counter variable.
 intI = 0

 ' Redimension array.
 ReDim Preserve astrProcNames(intI)

 ' Store name of first procedure in array.
 astrProcNames(intI) = strProcName

 ' Determine procedure name for each line after declarations.
 For lngI = lngCountDecl + 1 To lngCount
 ' Compare procedure name with ProcOfLine property value.
 If strProcName <> mdl.ProcOfLine(lngI, lngR) Then
 ' Increment counter.
 intI = intI + 1
 strProcName = mdl.ProcOfLine(lngI, lngR)
 ReDim Preserve astrProcNames(intI)
 ' Assign unique procedure names to array.
 astrProcNames(intI) = strProcName
 End If
 Next lngI

 strMsg = "Procedures in module '" & strModuleName & "': " & vbCrLf & vbCrLf
 For intI = 0 To UBound(astrProcNames)
 strMsg = strMsg & astrProcNames(intI) & vbCrLf
 Next intI

 ' Message box listing all procedures in module.
 MsgBox strMsg
End Function

See also

Concepts

Module Object

Other resources

Module Object Members


DoCmd.LockNavigationPane Method (Access)

 Copy code hover
[image]

DoCmd.LockNavigationPane Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the LockNavigationPane action to prevent users from deleting database objects that are displayed in the Navigation Pane.

Version Information

Version Added: Access 2007

Syntax

expression .LockNavigationPane(Lock)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
Lock | Required | Variant | Set to True to lock the Navigation Pane.

Remarks

Locking the Navigation Pane prevents the user from deleting database objects or cutting database objects to the clipboard. It does not prevent the user from performing any of the following operations:

  • Copying database objects to the clipboard

  • Pasting database objects from the clipboard

  • Displaying or hiding the Navigation Pane

  • Selecting different Navigation Pane organization schemes

  • Showing or hiding sections of the Navigation Pane

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


OpenQuery Macro Action

 Copy code hover
[image]

OpenQuery Macro Action
Send feedback

You can use the OpenQuery action to open a select or crosstab query in Datasheet view, Design view, or Print Preview. This action runs an action query. You can also select a data entry mode for the query.

Note Note

This action is only available in the Access database environment (.mdb or .accdb). See the OpenView, OpenStoredProcedure, or OpenFunction actions if you are using the Access project environment (.adp).

Setting

The OpenQuery action has the following arguments.

Action argument | Description
Query Name | The name of the query to open. The Query Name box in the Action Arguments section of the Macro Builder pane shows all queries in the current database. This is a required argument.If you run a macro containing the OpenQuery action in a library database, Microsoft Access first looks for the query with this name in the library database, and then in the current database.
View | The view in which the query will open. Click Datasheet, Design, Print Preview, PivotTable, or PivotChart in the View box. The default is Datasheet.
Data Mode | The data entry mode for the query. This applies only to queries opened in Datasheet view. Click Add (the user can add new records but can't edit existing records), Edit (the user can edit existing records and add new records), or Read Only (the user can only view records). The default is Edit.

Remarks

If you use Datasheet for the View argument, Access displays the result set if the query is a select, crosstab, union, or pass-through query whose ReturnsRecords property is set to Yes; and it runs the query if it is an action, data-definition, or pass-through query whose ReturnsRecords property is set to No.

The OpenQuery action is similar to double-clicking the query in the Navigation Pane, or right-clicking the query in the Navigation Pane and selecting a view. With this action you can select additional options.

Tips

  • You can drag a query from the Navigation Pane to a macro action row. This automatically creates an OpenQuery action that opens the query in Datasheet view. Switching to Design view while the query is open removes the Data Mode argument setting for the query. This setting isn't in effect even if the user returns to Datasheet view.

  • If you don't want to display the system messages that normally appear when an action query is run (indicating it is an action query and showing how many records will be affected), you can use the SetWarnings action to suppress the display of these messages.

To run the OpenQuery action in a Visual Basic for Applications (VBA) module, use the OpenQuery method of the DoCmd object.


DELETE Statement (Microsoft Access SQL)

 Copy code hover
[image]

DELETE Statement (Microsoft Access SQL)
Send feedback

Creates a delete query that removes records from one or more of the tables listed in the FROM clause that satisfy the WHERE clause.

Syntax

DELETE [table.*] FROM table WHERE criteria

The DELETE statement has these parts:

Part | Description
table | The optional name of the table from which records are deleted.
table | The name of the table from which records are deleted.
criteria | An expression that determines which records to delete.

Remarks

DELETE is especially useful when you want to delete many records.

To drop an entire table from the database, you can use the Execute method with a DROP statement. If you delete the table, however, the structure is lost. In contrast, when you use DELETE, only the data is deleted; the table structure and all of the table properties, such as field attributes and indexes, remain intact.

You can use DELETE to remove records from tables that are in a one-to-many relationship with other tables. Cascade delete operations cause the records in tables that are on the many side of the relationship to be deleted when the corresponding record in the one side of the relationship is deleted in the query. For example, in the relationship between the Customers and Orders tables, the Customers table is on the one side and the Orders table is on the many side of the relationship. Deleting a record from Customers results in the corresponding Orders records being deleted if the cascade delete option is specified.

A delete query deletes entire records, not just data in specific fields. If you want to delete values in a specific field, create an update query that changes the values to Null.

Important note Important

  • After you remove records using a delete query, you cannot undo the operation. If you want to know which records were deleted, first examine the results of a select query that uses the same criteria, and then run the delete query.

  • Maintain backup copies of your data at all times. If you delete the wrong records, you can retrieve them from your backup copies.

Example

This example deletes all records for employees whose title is Trainee. When the FROM clause includes only one table, you do not have to list the table name in the DELETE statement.

VBA Copy code Copy code
Sub DeleteX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Delete employee records where title is Trainee.
    dbs.Execute "DELETE * FROM " _
        & "Employees WHERE Title = 'Trainee';"

    dbs.Close

End Sub


Image.PictureData Property (Access)

 Copy code hover
[image]

Image.PictureData Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.

Syntax

expression .PictureData

expression A variable that represents an Image object.

Remarks

The PictureData property setting is the PictureData property of another control, form, or report.

You can use this property to display different background pictures in a form, depending on actions taken by the user. For example, you might open a Customers form using a different background picture depending on whether the form is opened for data entry or for browsing.

You can also use the PictureData property together with the Timer event and the TimerInterval property to perform simple animation on a form.

Example

The following example uses three image controls to animate a butterfly image across a form. The Hidden1 image control contains a picture of a butterfly with its wings up and the Hidden2 image control contains a picture of the same butterfly with its wings down. Both image controls have their Visible property set to False. The TimerInterval property is set to 200. Each time the Timer event occurs, the picture in the image control Visible1 is changed by using the PictureData property of the hidden image controls, and the visible image control is moved 200 twips to the right. The visible image control is moved back to the left side of the form when its Left property value is greater than the width of the form stored in the public variable gfrmWidth. The value of gfrmWidth is set to Me.Width in the form's open event.

VBA Copy code Copy code
Private Sub Form_Timer()

 Static intPic As Integer

 Select Case intPic
 Case Is = 1
 Me!Visible1.PictureData = Me!Hidden1.PictureData
 Case Is = 2
 Me!Visible1.PictureData = Me!Hidden2.PictureData
 Case Else
 End Select

 If intPic = 2 Then intPic = 0
 intPic = intPic + 1
 If (Me!Visible1.Left > gfrmWidth) Then Me!Visible1.Left = 0
 Me!Visible1.Left = Me!Visible1.Left + 200

End Sub

See also

Concepts

Image Object

Other resources

Image Object Members


Application.SetDefaultWorkgroupFile Method (Access)

 Copy code hover
[image]

Application.SetDefaultWorkgroupFile Method (Access)
See also Send feedback

Published: July 16, 2012

Sets the default workgroup file to the specified file.

Syntax

expression .SetDefaultWorkgroupFile(Path)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Path | Required | String | The full path and file name of the workgroup file to use as the default.

Return Value

Nothing

Remarks

If the file specified by Path does not exist, an error occurs.

Example

The following example sets the default workgroup file to the file system.mdw in the directory C:\Documents and Settings\Wendy Vasse\Application Data\Microsoft\Access.

VBA Copy code Copy code
Application.SetDefaultWorkgroupFile _
 Path:="C:\Documents and Settings\Wendy Vasse\" _
 & "Application Data\Microsoft\Access\system.mdw"

See also

Concepts

Application Object

Other resources

Application Object Members


OptionButton.OnMouseDown Property (Access)

 Copy code hover
[image]

OptionButton.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Syntax

expression .OnMouseDown

expression A variable that represents an OptionButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


ComboBox.OldBorderStyle Property (Access)

 Copy code hover
[image]

ComboBox.OldBorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.

Syntax

expression .OldBorderStyle

expression A variable that represents a ComboBox object.

Remarks

The OldBorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines
Note Note

  • If the OldBorderStyle property is set to None or Dialog, the form doesn't have Maximize or Minimize buttons, regardless of its MinMaxButtons property setting.

  • If the OldBorderStyle property is set to None, the form doesn't have a Control menu, regardless of its ControlBox property setting.

  • The OldBorderStyle property setting doesn't affect the display of the scroll bars, navigation buttons, the record number box, or record selectors.

Example

The following example demonstrates the effect of changing a control's BorderStyle property, while leaving the OldBorderStyle unaffected. The example concludes with setting the BorderStyle property to its original unedited value.

VBA Copy code Copy code
With Forms("Order Entry").Controls("Zip Code") .BorderStyle = 3 ' Short dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 3, 1.

    .BorderStyle = 2 ' Dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 2, 1

    .BorderStyle = .OldBorderStyle ' Solid (default) border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 1, 1
End With

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Command Object (ADO)

 Copy code hover
[image]

Command Object (ADO)
Send feedback

Defines a specific command that you intend to execute against a data source.

Remarks

Use a Command object to query a database and return records in a Recordset object, to execute a bulk operation, or to manipulate the structure of a database. Depending on the functionality of the provider, some Command collections, methods, or properties may generate an error when referenced.

With the collections, methods, and properties of a Command object, you can do the following:

  • Define the executable text of the command (for example, an SQL statement) with the CommandText property.

  • Define parameterized queries or stored-procedure arguments with Parameter objects and the Parameters collection.

  • Execute a command and return a Recordset object if appropriate with the Execute method.

  • Specify the type of command with the CommandType property prior to execution to optimize performance.

  • Control whether the provider saves a prepared (or compiled) version of the command prior to execution with the Prepared property.

  • Set the number of seconds that a provider will wait for a command to execute with the CommandTimeout property.

  • Associate an open connection with a Command object by setting its ActiveConnection property.

  • Set the Name property to identify the Command object as a method on the associated Connection object.

  • Pass a Command object to the Source property of a Recordset in order to obtain data.

  • Access provider-specific attributes with the Properties collection.

Note Note

To execute a query without using a Command object, pass a query string to the Execute method of a Connection object or to the Open method of a Recordset object. However, a Command object is required when you want to persist the command text and re-execute it, or use query parameters.

To create a Command object independently of a previously defined Connection object, set its ActiveConnection property to a valid connection string. ADO still creates a Connection object, but it doesn't assign that object to an object variable. However, if you are associating multiple Command objects with the same connection, you should explicitly create and open a Connection object; this assigns the Connection object to an object variable. If you do not set the Command object's ActiveConnection property to this object variable, ADO creates a new Connection object for each Command object, even if you use the same connection string.

To execute a Command, simply call it by its Name property on the associated Connection object. The Command must have its ActiveConnection property set to the Connection object. If the Command has parameters, pass their values as arguments to the method.

If two or more Command objects are executed on the same connection and either Command object is a stored procedure with output parameters, an error occurs. To execute each Command object, use separate connections or disconnect all other Command objects from the connection.

The Parameters collection is the default member of the Command object. As a result, the following two code statements are equivalent.


BoundObjectFrame.SizeToFit Method (Access)

 Copy code hover
[image]

BoundObjectFrame.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents a BoundObjectFrame object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


SortOrderEnum

 Copy code hover
[image]

SortOrderEnum
Send feedback

Specifies the sort sequence for an indexed column.

Constant | Value | Description
adSortAscending | 1 | Default. The sort sequence for the column is ascending.
adSortDescending | 2 | The sort sequence for the column is descending.


GroupLevel.KeepTogether Property (Access)

 Copy code hover
[image]

GroupLevel.KeepTogether Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the KeepTogether property for a group in a report to keep parts of a group — including the group header, detail section, and group footer — together on the same page. For example, you might want a group header to always be printed on the same page with the first detail section. Read/write Byte.

Syntax

expression .KeepTogether

expression A variable that represents a GroupLevel object.

Remarks

The KeepTogether property for a group uses the following settings.

Setting | Visual Basic | Description
No | 0 | (Default) Prints the group without keeping the group header, detail section, and group footer on the same page.
Whole Group | 1 | Prints the group header, detail section, and group footer on the same page.
With First Detail | 2 | Prints the group header on a page only if it can also print the first detail record.

In Visual Basic, you set the KeepTogether property for a group in report Design view or the Open event procedure of a report by using the GroupLevel property.

To set the KeepTogether property for a group to a value other than No, you must set the GroupHeader or GroupFooter property or both to Yes for the selected field or expression.

A group includes the group header, detail section, and group footer. If you set the KeepTogether property for a group to Whole Group and the group is too large to fit on one page, Microsoft Access will ignore the setting for that group. Similarly, if you set this property to With First Detail and either the group header or detail record is too large to fit on one page, the setting will be ignored.

If the KeepTogether property for a section is set to No and the KeepTogether property for a group is set to Whole Group or With First Detail, the KeepTogether property setting for the section is ignored.

See also

Concepts

GroupLevel Object

Other resources

GroupLevel Object Members


Form.Undo Method (Access)

 Copy code hover
[image]

Form.Undo Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the Undo method to reset a control or form when its value has been changed.

Syntax

expression .Undo

expression A variable that represents a Form object.

Remarks

For example, you can use the Undo method to clear a change to a record that contains an invalid entry.

If the Undo method is applied to a form, all changes to the current record are lost. If the Undo method is applied to a control, only the control itself is affected.

This method must be applied before the form or control is updated. You may want to include this method in a form's BeforeUpdate event or in a control's Change event.

The Undo method offers an alternative to using the SendKeys statement to send the value of the ESC key in an event procedure.

Example

The following example shows how you can use the Undo method within a control's Change event procedure to force a field named LastName to reset to its original value, if it changed.

VBA Copy code Copy code
Private Sub LastName_Change()
 Me!LastName.Undo
End Sub

The next example uses the Undo method to reset all changes to a form before the form is updated.

VBA Copy code Copy code
Private Sub Form_BeforeUpdate(Cancel As Integer)
 Me.Undo
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


OptionGroup.Name Property (Access)

 Copy code hover
[image]

OptionGroup.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents an OptionGroup object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Relationship

 Copy code hover
[image]

Relationship <name> is unenforced. (Error 3659)
Send feedback

You attempted to apply a filter in a partial replica on a table where a relationship that is not enforced exists. Enforce the relationship at the Design Master, and then re-attempt to apply the filter and re-populate the partial replica.


ToggleButton.Section Property (Access)

 Copy code hover
[image]

ToggleButton.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Syntax

expression .Section

expression A variable that represents a ToggleButton object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Connections Collection (DAO)

 Copy code hover
[image]

Connections Collection (DAO)
Send feedback
Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

A Connections collection contains the current Connection objects of a Workspace object. (ODBCDirect workspaces only).

Remarks

When you open a Connection object, it is automatically appended to the Connections collection of the Workspace. When you close a Connection object with the Close method, it is removed from the Connections collection. You should close all open Recordset objects within the Connection before closing it.

At the same time you open a Connection object, a corresponding Database object is created and appended to the Databases collection in the same Workspace, and vice versa. Similarly, when you close the Connection, the corresponding Database is deleted from the Databases collection, and so on.

The Name property setting of a Connection is a string that specifies the path of the database file. To refer to a Connection object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

  • Connections(0)

  • Connections("name")

  • Connections![name]

Note Note

You can open the same data source more than once, creating duplicate names in the Connections collection. You should assign Connection objects to object variables and refer to them by variable name.

Example

This example demonstrates the Connection object and Connections collection by opening a Database object and two ODBCDirect Connection objects and listing the properties available to each object.

VBA Copy code Copy code
Sub ConnectionObjectX()

   Dim wrkAcc as Workspace
   Dim dbsNorthwind As Database
   Dim wrkODBC As Workspace
   Dim conPubs As Connection
   Dim conPubs2 As Connection
   Dim conLoop As Connection
   Dim prpLoop As Property

   ' Open a Database object.
   Set wrkAcc = CreateWorkspace("NewWorkspace", _
      "admin", "", dbUseJet)
   Set dbsNorthwind = wrkAcc.OpenDatabase("Northwind.mdb")

   ' Create ODBCDirect Workspace object and open Connection
   ' objects.
   Set wrkODBC = CreateWorkspace("NewODBCWorkspace", _
      "admin", "", dbUseODBC)

   ' Note: The DSNs referenced below must be configured to
   '       use Microsoft Windows NT Authentication Mode to
   '       authorize user access to the Microsoft SQL Server.
   Set conPubs = wrkODBC.OpenConnection("Connection1", , , _
      "ODBC;DATABASE=pubs;DSN=Publishers")

   Set conPubs2 = wrkODBC.OpenConnection("Connection2", , _
      True, "ODBC;DATABASE=pubs;DSN=Publishers")

   Debug.Print "Database properties:"

   With dbsNorthwind
      ' Enumerate Properties collection of Database object.
      For Each prpLoop In .Properties
         On Error Resume Next
         Debug.Print "  " & prpLoop.Name & " = " & _
            prpLoop.Value
         On Error GoTo 0
      Next prpLoop
   End With

   ' Enumerate the Connections collection.
   For Each conLoop In wrkODBC.Connections
      Debug.Print "Connection properties for " & _
         conLoop.Name & ":"

      With conLoop
         ' Print property values by explicitly calling each
         ' Property object; the Connection object does not
         ' support a Properties collection.
         Debug.Print "  Connect = " & .Connect
         ' Property actually returns a Database object.
         Debug.Print "  Database[.Name] = " & _
            .Database.Name
         Debug.Print "  Name = " & .Name
         Debug.Print "  QueryTimeout = " & .QueryTimeout
         Debug.Print "  RecordsAffected = " & _
            .RecordsAffected
         Debug.Print "  StillExecuting = " & _
            .StillExecuting
         Debug.Print "  Transactions = " & .Transactions
         Debug.Print "  Updatable = " & .Updatable
      End With

   Next conLoop

   dbsNorthwind.Close
   conPubs.Close
   conPubs2.Close
   wrkAcc.Close
   wrkODBC.Close

End Sub

This example uses the OpenConnection method with different parameters to open three different Connection objects.

VBA Copy code Copy code
Sub OpenConnectionX()

   Dim wrkODBC As Workspace
   Dim conPubs As Connection
   Dim conPubs2 As Connection
   Dim conPubs3 As Connection
   Dim conLoop As Connection

   ' Create ODBCDirect Workspace object.
   Set wrkODBC = CreateWorkspace("NewODBCWorkspace", _
      "admin", "", dbUseODBC)

   ' Open Connection object using supplied information in
   ' the connect string. If this information were
   ' insufficient, you could trap for an error rather than
   ' go to an ODBC Driver Manager dialog box.
   MsgBox "Opening Connection1..."

    ' Note: The DSN referenced below must be set to
    '       use Microsoft Windows NT Authentication Mode to
    '       authorize user access to the Microsoft SQL Server.
    Set conPubs = wrkODBC.OpenConnection("Connection1", _
       dbDriverNoPrompt, , _
       "ODBC;DATABASE=pubs;DSN=Publishers")

   ' Open read-only Connection object based on information
   ' you enter in the ODBC Driver Manager dialog box.
   MsgBox "Opening Connection2..."
   Set conPubs2 = wrkODBC.OpenConnection("Connection2", _
      dbDriverPrompt, True, "ODBC;DSN=Publishers;")

   ' Open read-only Connection object by entering only the
   ' missing information in the ODBC Driver Manager dialog
   ' box.
   MsgBox "Opening Connection3..."
   Set conPubs3 = wrkODBC.OpenConnection("Connection3", _
      dbDriverCompleteRequired, True, _
      "ODBC;DATABASE=pubs;DSN=Publishers;")

   ' Enumerate the Connections collection.
   For Each conLoop In wrkODBC.Connections
      Debug.Print "Connection properties for " & _
         conLoop.Name & ":"

      With conLoop
         ' Print property values by explicitly calling each
         ' Property object; the Connection object does not
         ' support a Properties collection.
         Debug.Print "  Connect = " & .Connect
         ' Property actually returns a Database object.
         Debug.Print "  Database[.Name] = " & _
            .Database.Name
         Debug.Print "  Name = " & .Name
         Debug.Print "  QueryTimeout = " & .QueryTimeout
         Debug.Print "  RecordsAffected = " & _
            .RecordsAffected
         Debug.Print "  StillExecuting = " & _
            .StillExecuting
         Debug.Print "  Transactions = " & .Transactions
         Debug.Print "  Updatable = " & .Updatable
      End With

   Next conLoop

   conPubs.Close
   conPubs2.Close
   conPubs3.Close
   wrkODBC.Close

End Sub


Navigating Through the Data

 Copy code hover
[image]

Navigating Through the Data
Send feedback

Now that you have executed a command against the data source and determined that the result set contains data, you can move through the results by using the navigation methods and properties provided by the Recordset object. The following topics describe how to use these methods and properties on the sample Recordset:

  • Jumping to a Record

  • More Ways to Move in a Recordset

  • Using Bookmarks

  • Using Pages

  • Recordset Positioning


How to: Use Date and Time Criteria from a Control on a Form

 Copy code hover
[image]

How to: Use Date and Time Criteria from a Control on a Form
Send feedback

If you want to change the criteria argument for an operation based on a user's decision, you can specify that the criteria come from a control on a form. For example, you could specify that the criteria argument comes from a list box containing order dates from an Orders table.

To specify date and time criteria that come from a control on a form, you include in the criteria argument an expression that references the control on the form. This expression should be separate from the string expression, so that Microsoft Access will evaluate the control expression first and concatenate it with the rest of the string expression before performing the appropriate operation.

In addition to enclosing the entire string expression in double quotation marks ("), you must also ensure that the date or time criteria within the string expression are enclosed in number signs (#). The number signs must be included in the strings flanking the expression that references the control on the form.

Note Note

The number signs indicate to Microsoft Access that the criteria argument contains a date or time within a string.

The following examples set a form's Filter or ServerFilter property based on criteria that come from a control named HireDate that is on the form. Note the placement of the number signs.

Copy code Copy code
Forms!Employees.Filter = "[HireDate] >= #" _
 &     Forms!Employees!HireDate & "#"
Forms!Employees.FilterOn = True

- or -

Copy code Copy code
Forms!Employees.ServerFilter = "[HireDate] >= #" _
 &     Forms!Employees!HireDate & "#"
Forms!Employees.FilterOn = True

If the current value of the HireDate control is 5-1-92, the Filter or ServerFilter property will have the following criteria argument:

Copy code Copy code
"[HireDate] >= #5-1-92#"

To troubleshoot an expression in the criteria argument, break the expression into smaller components and test each one individually in the Immediate window. When all of the components are working correctly, put them back together one at a time until the complete expression works correctly.

You can also include a variable representing a date or time in the criteria argument. The variable should be separate from the string expression, so that Microsoft Access will evaluate the variable first and then concatenate it with the rest of the string expression. The date or time criteria must be enclosed in number signs.

The following example shows how to construct a criteria argument that includes a variable representing a date or time:

Copy code Copy code
Dim datHireDate As Date
datHireDate = #5-1-92#
Forms!Employees.Filter = "[HireDate] >= #" _
 &     datHireDate & "#"


Internet Server Error: Access Denied

 Copy code hover
[image]

Internet Server Error: Access Denied
Send feedback

If you get this error, it usually means that Microsoft Internet Information Services (IIS) returned the following status:

HTTP_STATUS_DENIED 401

Make sure the directories accessed by IIS have proper permissions. RDS can communicate with an IIS Web server running in any one of the three Password Authentication modes: Anonymous, Basic, or NT Challenge/Response (called Integrated Windows authentication in Windows 2000). Also, the Web server must have permissions to the data source computer if it is a Windows NT/Windows 2000 computer.


Syntax error in ORDER BY clause. (Error 3138)

 Copy code hover
[image]

Syntax error in ORDER BY clause. (Error 3138)
Send feedback

You entered an SQL statement that has an invalid ORDER BY clause.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


Illegal column-level constraint. (Error 3789)

 Copy code hover
[image]

Illegal column-level constraint. (Error 3789)
Send feedback

This error occurs when using the CREATE TABLE or ALTER TABLE ALTER COLUMN syntax. While ANSI SQL allows for creating CHECK constraints as part of the table definition, the Microsoft Access database engine requires that the user create the CHECK constraint separate from the COLUMN definition. This can be accomplished by issuing the CHECK keyword after a comma. For example, the following syntax will work because the CHECK constraint is defined separately from the column and follows a comma:

CREATE TABLE Orders (OrderId IDENTITY (100,10) CONSTRAINT pkOrders PRIMARY KEY, CustId LONG CONSTRAINT fkCustomersCustId REFERENCES Customers (CustId), Balance DOUBLE, CONSTRAINT CustomerExceededCreditLimit CHECK (CustId IN (SELECT CustId FROM Customers C WHERE C.CustId = Orders.CustId AND C.CreditLimit >= (SELECT SUM(Balance)FROM Orders O WHERE O.CustId = Orders.CustId))));.


TableDef.Name Property (DAO)

 Copy code hover
[image]

TableDef.Name Property (DAO)
Send feedback

Returns or sets the name of the specified object. Read/write String.

Syntax

expression .Name

expression A variable that represents a TableDef object.

Remarks

The maximum length for the name of a TableDef object is 64 characters.


SetField Macro Action

 Copy code hover
[image]

SetField Macro Action
Send feedback

The SetField action can be used to assign a value to a field.

Note Note

The SetField action is available only in Data Macros.

Setting

The SetField action has the arguments listed in the following table.

Argument | Description
Name | A string that identifies the field.
Value | An expression that specifies the value to assign to the field.

Remarks

The SetField action cannot be used outside of an CreateRecord or EditRecord data block.


FilterValue Property (RDS)

 Copy code hover
[image]

FilterValue Property (RDS)
Send feedback

Indicates the value with which to filter records.

Syntax

DataControl.FilterValue = String

Parameters

  • DataControl

  • An object variable that represents an RDS.DataControl object.

  • String

  • A String value that represents a data value with which to filter records (for example, 'Programmer' or 125 ).

Remarks

The SortColumn, SortDirection, FilterValue, FilterCriterion, and FilterColumn properties provide sorting and filtering functionality on the client-side cache. The sorting functionality orders records by values from one column. The filtering functionality displays a subset of records based on find criteria, while the full Recordset is maintained in the cache. The Reset method will execute the criteria and replace the current Recordset with an updatable Recordset.

Null values result in a type mismatch error.


SubForm.BorderShade Property (Access)

 Copy code hover
[image]

SubForm.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents a SubForm object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens BorderColor by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


EmptyCell.BackThemeColorIndex Property (Access)

 Copy code hover
[image]

EmptyCell.BackThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackThemeColorIndex

expression A variable that represents an EmptyCell object.

Remarks

The BackThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BackThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Background Color to the Text 2 color by setting the BackThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BackThemeColorIndex=2

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


Children Property (ADO MD)

 Copy code hover
[image]

Children Property (ADO MD)
Send feedback

Returns a Members collection for which the current Member is the parent in the hierarchy.

Return Values

Returns a Members collection and is read-only.

Remarks

The Children property contains a Members collection for which the current Member is the hierarchical parent. Leaf level Member objects have no child members in the Members collection. This property is only supported on Member objects belonging to a Level object. An error occurs when this property is referenced from Member objects belonging to a Position object.


InternetTimeout Property (RDS)

 Copy code hover
[image]

InternetTimeout Property (RDS)
Send feedback

Indicates the number of milliseconds to wait before a request times out.

Settings and Return Values

Sets or returns a Long value that represents the number of milliseconds before a request will time out.

Remarks

This property applies only to requests sent with the HTTP or HTTPS protocols.

Requests in a three-tier environment can take several minutes to execute. Use this property to specify additional time for long-running requests.


UniqueName Property (ADO MD)

 Copy code hover
[image]

UniqueName Property (ADO MD)
Send feedback

Indicates an unambiguous name for the current object.

Return Values

Returns a String and is read-only.


BoundObjectFrame.OnGotFocus Property (Access)

 Copy code hover
[image]

BoundObjectFrame.OnGotFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnGotFocus

expression A variable that represents a BoundObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The GotFocus event occurs when the object receives the focus.

The OnGotFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Got Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Got Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnGotFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnGotFocus

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Index (Definition)

 Copy code hover
[image]

Index (Definition)
Send feedback

Published: July 16, 2012

An index is a Microsoft Access feature that speeds up searching and sorting in a table. You can create an index for a field in the Indexes window of table Design view, or by setting the field's Indexed property to Yes.

Note Note

The primary key of a table is automatically indexed, and fields for which the data type is Memo or OLE Object can't be indexed.


TextBox.FontUnderline Property (Access)

 Copy code hover
[image]

TextBox.FontUnderline Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontUnderline property to specify whether text is underlined in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontUnderline

expression A variable that represents a TextBox object.

Remarks

The FontUnderline property uses the following settings.

Setting | Description
True | The text is underlined.
False | (Default) The text isn't underlined.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


User interface commands (Access 2013 custom web app)

 Copy code hover
[image]

User interface commands (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • ChangeView Macro Action (Access 2013 custom web app)

  • ClosePopup Macro Action (Access 2013 custom web app)

  • MessageBox Macro Action (Access 2013 custom web app)

  • OpenPopup Macro Action (Access 2013 custom web app)


AcPrintObjQuality Enumeration (Access)

 Copy code hover
[image]

AcPrintObjQuality Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the PrintQuality property to specify the resolution at which the specified printer should print jobs.

Name | Value | Description
acPRPQDraft | -1 | The printer prints in draft quality.
acPRPQHigh | -4 | The printer prints in high quality.
acPRPQLow | -2 | The printer prints in low quality.
acPRPQMedium | -3 | The printer prints in medium quality.


Member Properties, Methods, and Events (ADO MD)

 Copy code hover
[image]

Member Properties, Methods, and Events (ADO MD)
Send feedback

Properties/Collections

Caption Property

ChildCount Property

Children Property

Description Property

DrilledDown Property

LevelDepth Property

LevelName Property

Name Property

Parent Property

ParentSameAsPrev Property

Properties Collection

Type Property

UniqueName Property

Methods

None.

Events

None.


ToggleButton.HoverForeShade Property (Access)

 Copy code hover
[image]

ToggleButton.HoverForeShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .HoverForeShade

expression A variable that represents a ToggleButton object.

Remarks

The HoverForeShade property contains a numeric expression that can be used to darken the theme color in the HoverForeColor property. The default value of the HoverForeShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


WHERE Clause (Microsoft Access SQL)

 Copy code hover
[image]

WHERE Clause (Microsoft Access SQL)
Send feedback

Published: July 16, 2012

Specifies which records from the tables listed in the FROM clause are affected by a SELECT, UPDATE, or DELETE statement.

Syntax

SELECT fieldlist FROM tableexpression WHERE criteria

A SELECT statement containing a WHERE clause has these parts:

Part | Description
fieldlist | The name of the field or fields to be retrieved along with any field-name aliases, selection predicates (ALL, DISTINCT, DISTINCTROW, or TOP), or other SELECT statement options.
tableexpression | The name of the table or tables from which data is retrieved.
criteria | An expression that records must satisfy to be included in the query results.

Remarks

The Microsoft Access database engine selects the records that meet the conditions listed in the WHERE clause. If you do not specify a WHERE clause, your query returns all rows from the table. If you specify more than one table in your query and you have not included a WHERE clause or a JOIN clause, your query generates a Cartesian product of the tables.

WHERE is optional, but when included, follows FROM. For example, you can select all employees in the sales department (WHERE Dept = 'Sales' ) or all customers between the ages of 18 and 30 () or all customers between the ages of 18 and 30 (WHERE Age Between 18 And 30 ).

If you do not use a JOIN clause to perform SQL join operations on multiple tables, the resulting Recordset object will not be updatable.

WHERE is similar to HAVING. WHERE determines which records are selected. Similarly, once records are grouped with GROUP BY, HAVING determines which records are displayed.

Use the WHERE clause to eliminate records you do not want grouped by a GROUP BY clause.

Use various expressions to determine which records the SQL statement returns. For example, the following SQL statement selects all employees whose salaries are more than $21,000:

SQL Copy code Copy code
SELECT LastName, Salary
FROM Employees
WHERE Salary > 21000;

A WHERE clause can contain up to 40 expressions linked by logical operators, such as And and Or.

When you enter a field name that contains a space or punctuation, surround the name with brackets ([ ]). For example, a customer information table might include information about specific customers:

SQL Copy code Copy code
SELECT [Customer's Favorite Restaurant]

When you specify the criteria argument, date literals must be in U.S. format, even if you are not using the U.S. version of the Microsoft® Jet database engine. For example, May 10, 1996, is written 10/5/96 in the United Kingdom and 5/10/96 in the United States. Be sure to enclose your date literals with the number sign (#) as shown in the following examples.

To find records dated May 10, 1996 in a United Kingdom database, you must use the following SQL statement:

SQL Copy code Copy code
SELECT *
FROM Orders
WHERE ShippedDate = #5/10/96#;

You can also use the DateValue function which is aware of the international settings established by Microsoft Windows®. For example, use this code for the United States:

SQL Copy code Copy code
SELECT *
FROM Orders
WHERE ShippedDate = DateValue('5/10/96');

And use this code for the United Kingdom:

SQL Copy code Copy code
SELECT *
FROM Orders
WHERE ShippedDate = DateValue('10/5/96');
Note Note

If the column referenced in the criteria string is of type GUID, the criteria expression uses a slightly different syntax:

Copy code Copy code
WHERE ReplicaID = {GUID {12345678-90AB-CDEF-1234-567890ABCDEF}}

Be sure to include the nested braces and hyphens as shown.

Example

The following example assumes the existence of a hypothetical Salary field in an Employees table. Note that this field does not actually exist in the Northwind database Employees table.

This example selects the LastName and FirstName fields of each record in which the last name is King.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

VBA Copy code Copy code
Sub WhereX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Select records from the Employees table where the
    ' last name is King.
    Set rst = dbs.OpenRecordset("SELECT LastName, " _
        & "FirstName FROM Employees " _
        & "WHERE LastName = 'King';")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset.
    EnumFields rst, 12

    dbs.Close

End Sub


AllMacros.Count Property (Access)

 Copy code hover
[image]

AllMacros.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents an AllMacros object.

See also

Concepts

AllMacros Collection

Other resources

AllMacros Object Members


Cannot populate the replica or change the replica's filter because the replica has conflicts or data errors. (Error 3636)

 Copy code hover
[image]

Cannot populate the replica or change the replica's filter because the replica has conflicts or data errors. (Error 3636)
Send feedback

You are attempting to change a partial replica's filter or populate a partial replica, and that replica has conflicts or data errors. You need to resolve the conflicts or errors before proceeding. This prevents inadvertent loss of conflict information and ensures that errors are corrected properly.


AccessObject.DateCreated Property (Access)

 Copy code hover
[image]

AccessObject.DateCreated Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a Date indicating the date and time when the design of the specified object was last modified. Read-only.

Syntax

expression .DateCreated

expression A variable that represents an AccessObject object.

Example

The following example lists all the reports in the current database and when their designs were created and modified.

VBA Copy code Copy code
Dim acobjLoop As AccessObject

For Each acobjLoop In CurrentProject.AllReports
 With acobjLoop
 Debug.Print .Name & " - Created " & .DateCreated _
 & " - Modified " & .DateModified
 End With
Next acobjLoop

See also

Concepts

AccessObject Object

Other resources

AccessObject Object Members


The specified row length is shorter than the sum of the column lengths. (Error 3646)

 Copy code hover
[image]

The specified row length is shorter than the sum of the column lengths. (Error 3646)
Send feedback

The row length parameter did not specify enough space for the column binding.


LAST (Microsoft Access SQL reserved word)

 Copy code hover
[image]

LAST (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The LAST keyword is used in these contexts:

First, Last Functions


Database Members (DAO)

 Copy code hover
[image]

Database Members (DAO)
Send feedback

A Database object represents an open database.

Methods

Name | Description
Close | Closes an open Database.
CreateProperty | Creates a new user-defined Property object (Microsoft Access workspaces only). .
CreateQueryDef | Creates a new QueryDef object.
CreateRelation | Creates a new Relation object (Microsoft Access workspaces only). .
CreateTableDef | Creates a new TableDef object (Microsoft Access workspaces only). .
Execute | Runs an action query or executes an SQL statement on the specified object.
MakeReplica | Makes a new replica from another database replica (Microsoft Access workspaces only).
NewPassword | Changes the password of an existing Microsoft Access database engine database (Microsoft Access workspaces only).
OpenRecordset | Creates a new Recordset object and appends it to the Recordsets collection.
PopulatePartial | Synchronizes any changes in a partial replica with the full replica, clears all records in the partial replica, and then repopulates the partial replica based on the current replica filters. (Microsoft Access database engine databases only.).
Synchronize | Synchronizes two replicas. (Microsoft Access workspaces only).

Properties

Name

Description

CollatingOrder

Returns a value that specifies the sequence of the sort order in text for string comparison or sorting (Microsoft Access workspaces only). Read-only Long.

Connect

Sets or returns a value that provides information about the source an open database. Read/write String.

Connection

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Returns the Connection object that corresponds to the database (ODBCDirect workspaces only).

Containers

Returns a Containers collection that represents all of the Container objects in the specifed database. Read-only.

DesignMasterID

Sets or returns a 16-byte value that uniquely identifies the Design Master in a replica set (Microsoft Access workspaces only).

Name

Returns the name of the specified object. Read-only String.

Properties

Returns the Properties collection of the specified object. Read-only.

QueryDefs

Returns a QueryDefs collection that contains all of the QueryDef objects of the specified database. Read-only.

QueryTimeout

Sets or returns a value that specifies the number of seconds to wait before a timeout error occurs when a query is executed on an ODBC data source.

RecordsAffected

Returns the number of records affected by the most recently invoked Execute method.

Recordsets

Returns a Recordsets collection that contains all of the open recordsets in the for the specified database. Read-only.

Relations

Returns a Relations collection that contains all of the stored Relation objects for the specified database. Read-only.

ReplicaID

Returns a 16-byte value that uniquely identifies a database replica (Microsoft Access workspaces only).

TableDefs

Returns a TableDefs collection that contains all of the TableDef objects stored in the specified database. Read-only.

Transactions

Returns a value that indicates whether an object supports transactions. Read-only Boolean.

Updatable

Returns a value that indicates whether you can change a DAO object. Read-only Boolean.

Version

In a Microsoft Access workspace, returns the vesion of the Microsoft Jet or Microsoft Access database engine that created the database. Read-only String.


Hyperlink.Address Property (Access)

 Copy code hover
[image]

Hyperlink.Address Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Address property to specify or determine the path to an object, document, Web page or other destination for a Hyperlink object associated with a command button, image control, or label control. Read/write String.

Syntax

expression .Address

expression A variable that represents a Hyperlink object.

Remarks

When you set the Address property, you automatically specify the HyperlinkAddress property for the control associated with the hyperlink.

For more information about hyperlink addresses and their format, see the HyperlinkAddress and HyperlinkSubAddress property topics.

See also

Concepts

Hyperlink Object

Other resources

Hyperlink Object Members


Illegal reference in query. (Error 3451)

 Copy code hover
[image]

Illegal reference in query. (Error 3451)
Send feedback

This error occurs when parameters are defined with unrecognized data types.


NavigationControl.Controls Property (Access)

 Copy code hover
[image]

NavigationControl.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Version Information

Version Added: Access 2010

Syntax

expression .Controls

expression A variable that represents a NavigationControl object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Database

 Copy code hover
[image]

Database <name> is exclusively locked. (Error 3006)
Send feedback

You tried to use a database that is currently open for exclusive access by another user. Wait for the other user to finish working with the database, and then try the operation again.


RefreshRecord Macro Action

 Copy code hover
[image]

RefreshRecord Macro Action
Send feedback

You can use the RefreshRecord action to update the underlying record source for the active form or datasheet to reflect changes made to the records in the current set.

Remarks

the RefreshRecord action shows only changes made to records in the current set. Because the RefreshRecord action does not actually requery the database, the current set will not include records that have been added or exclude records that have been deleted since the database was last requeried; Nor will it exclude records that no longer satisfy the criteria of the query or filter. To requery the database, use the Requery method. When the record source for a form is requeried, the current set of records will accurately reflect all data in the record source.

The behavior of this macro action depends on whether you are calling it in a client database or a web database.

Client database

In a client database, you can use the RefreshRecord action to update the underlying record source for the active form or datasheet to reflect changes made to the data in the current set. Changes include those made by the current user or by other users in a multiuser environment. It is equivalent to the Refresh method.

The RefreshRecord macro action does the following in a client database:

  1. Updates the record source for the active form or datasheet to reflect the changes made to rows in the current set. For ODBC linked tables, retrieves changes to records in the current set from the data source.

  2. Updates the current set to reflect the changes. If a row in the record source has been deleted, it is changed to show #Deleted.

  3. Refreshes the active or datasheet to display any changed records and any #Deleted records, in the current set.

  4. Requeries any subforms and subreports on the active form or datasheet.

Web database

In a web database, you can use the RefreshRecord action to update the underlying record source for the active form or datasheet to reflect changes made to the records in the current set. Changes include those made by the current user or other users.

The RefreshRecord macro action does the following in a web database:

  1. Retrieves changes from the server for any base tables in the current set. For ODBC linked tables, retrieves changes to records in the current set from the data source.

  2. Updates the current set to reflect the changes. If a row in the current set has been deleted, it is changed to show #Deleted.

  3. Refreshes the active form or datasheet to display any changed records and any #Deleted records, in the current set.

  4. Requeries any subforms and subreports on the active form or datasheet.


ToggleButton.AutoLabel Property (Access)

 Copy code hover
[image]

ToggleButton.AutoLabel Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.

Syntax

expression .AutoLabel

expression A variable that represents a ToggleButton object.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


CheckBox.SetFocus Method (Access)

 Copy code hover
[image]

CheckBox.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Syntax

expression .SetFocus

expression A variable that represents a CheckBox object.

Return Value

Nothing

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.

Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.

Example

The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:

VBA Copy code Copy code
Forms!Employees!EmployeeID.SetFocus

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


TextBox.IsHyperlink Property (Access)

 Copy code hover
[image]

TextBox.IsHyperlink Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsHyperlink property to specify or determine if the data contained in a text box is a hyperlink. Read/write Boolean.

Syntax

expression .IsHyperlink

expression A variable that represents a TextBox object.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ComboBox.Visible Property (Access)

 Copy code hover
[image]

ComboBox.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents a ComboBox object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ImportExportSpecifications.Item Property (Access)

 Copy code hover
[image]

ImportExportSpecifications.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only ImportExportSpecification.

Version Information

Version Added: Access 2007

Syntax

expression .Item(Index)

expression A variable that represents an ImportExportSpecifications object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection.

See also

Concepts

ImportExportSpecifications Collection

Other resources

ImportExportSpecifications Object Members


BOF, EOF, and Bookmark Properties Example (VJ++)

 Copy code hover
[image]

BOF, EOF, and Bookmark Properties Example (VJ++)
Send feedback

This example uses the BOF and EOF properties to display a message if a user tries to move past the first or last record of a Recordset. It uses the Bookmark property to let the user flag a record in a Recordset and return to it later.

Copy code Copy code

// BeginBOFEOFJ
import com.ms.wfc.data.*;
import java.io.*;
import com.ms.com.*;

public class BOFEOFBookmark
{
 Variant varBookmark;
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));
 String line = null;

 // The main entry point for the application.

 public static void main (String[] args)
 {
 BOFEOFBookmark b1 = new BOFEOFBookmark ();
 b1.BOFX();
 b1.BOFX2();
 System.exit(0);
 try
 {
 b1.finalize();
 }
 catch(Throwable te)
 {
 System.out.println("Exception: " + te.getMessage());
 }
 }

 // The main entry point for the application.

 public void BOFX()
 {
 // Declarations.
 Recordset rstPublishers = null;
 String strCnn;
 String strMessage;
 int intCommand = 0;

 strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";
 try
 {
 // Open a recordset with data from Publishers table.
 rstPublishers = new Recordset();
 rstPublishers.setCursorType(AdoEnums.CursorType.STATIC );
 rstPublishers.setCursorLocation(
 AdoEnums.CursorLocation.CLIENT);

 // Use client cursor to enable AbsolutePosition property.

 rstPublishers.open(new String(
 "SELECT pub_id,pub_name FROM Publishers ORDER BY pub_name"),
 strCnn, AdoEnums.CursorType.STATIC ,
 AdoEnums.LockType.BATCHOPTIMISTIC,
 AdoEnums.CommandType.TEXT );
 rstPublishers.moveFirst();

 //Display information about current record and get user input.
 while ( true)
 {
 strMessage = "\nPublisher :" +
 rstPublishers.getField("pub_name").getString() + "\n"
 + " (Record " + rstPublishers.getAbsolutePosition()
 + " of " + rstPublishers.getRecordCount() + ")" + "\n\n"
 + "Enter command : " + "\n"
 + "[1 - next / 2 - previous /" + "\n"
 + "3 - set bookmark / 4 - go to bookmark] / 5 - quit]" ;
 System.out.println (strMessage);
 line = in.readLine();
 //No entry exits loop.
 if (line.length() == 0)
 break;
 //convert string entry to int.
 intCommand = Integer.parseInt(line);
 //out of range entry exits loop.
 if ((intCommand < 1) || (intCommand > 4)) break ;

 //Call method based on user's validated selection.
 MoveAny(intCommand, rstPublishers);
 }
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstPublishers != null)
 {
 PrintProviderError(rstPublishers.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // This catch is required if input string cannot be converted to
 // Integer data type. "TCS[VSD]"

 catch ( java.lang.NumberFormatException ne)
 {
 System.out.println("\nException: Integer Input required." );
 }

 // System Read requires this catch.
 catch( java.io.IOException je )
 {
 PrintIOError(je);
 }
 finally
 {
 // Cleanup objects before exit.
 if (rstPublishers != null)
 if (rstPublishers.getState() == 1)
 rstPublishers.close();
 }
 }

 // MoveAny Function

 public void MoveAny(int intChoice, Recordset rsTemp)
 {
 // Move Forward or backword per selection from user,
 // trapping for BOF and EOF.
 try
 {
 switch(intChoice)
 {
 case 1: // Equals char of 1.
 rsTemp.moveNext();
 if (rsTemp.getEOF())
 {
 System.out.println (
 "\nMoving past the last record \nTry again." );
 rsTemp.moveLast();
 }
 break;
 case 2: // Equals char of 2.
 rsTemp.movePrevious();
 if (rsTemp.getBOF())
 {
 System.out.println (
 "\nMoving past the first record \nTry again." );
 rsTemp.moveFirst();
 }
 break;
 case 3: // Equals char of 3.
 // Store the bookmark of the current record.
 varBookmark = (Variant)rsTemp.getBookmark();
 break;
 case 4: // Equals char of 4.
 // Go to the record indicated by the stored bookmark.
 if (varBookmark == null)
 System.out.println ("\nNo bookmark set!");
 else
 rsTemp.setBookmark((Object)varBookmark);
 break;
 default:
 break;
 }
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rsTemp != null)
 {
 PrintProviderError(rsTemp.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 //.PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }

 ////////////////////////////////////////////
 // BOFX2() Function. //
 ////////////////////////////////////////////

 public void BOFX2()
 {
 Recordset rs = null ;

 try
 {
 // Declarations.
 rs = new Recordset();
 Variant[] arrbmk = new Variant[11];
 rs.setCursorLocation( AdoEnums.CursorLocation.CLIENT);
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";
 rs.setActiveConnection (strCnn);
 // Open recorset with data from authors table.
 rs.open((new String("SELECT * FROM authors")),strCnn,AdoEnums.CursorType.STATIC ,AdoEnums.LockType.BATCHOPTIMISTIC,AdoEnums.CommandType.TEXT );
 System.out.println ("\nNumber of records before filtering : " + rs.getRecordCount() );
 int ii = 0;

 // Create array of bookmarks.
 while (rs.getEOF() != true && ii < 11)
 {
 arrbmk[ii] = (Variant)rs.getBookmark();
 ii++;
 rs.move (2);
 }

 // set Filter to recordset.
 Variant bmk=new Variant();
 bmk.putVariantArray(arrbmk);
 rs.setFilter(bmk);
 System.out.println ("\nNumber of records after filtering : " + rs.getRecordCount() );

 // Dislay the records after filtering.
 rs.moveFirst();
 while (!rs.getEOF())
 {
 System.out.println ("\t" +rs.getAbsolutePosition() + " " +rs.getField("au_lname").getString());
 rs.moveNext();
 }
 rs.close();
 System.out.println ("\n\nPress <Enter> key to continue.");
 in.readLine();

 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rs != null)
 {
 PrintProviderError(rs.getActiveConnection());
 System.out.println("Exception: " + ae.getMessage());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 // System Read requires this catch.
 catch( java.io.IOException je )
 {
 PrintIOError(je);
 }
 }
}

// EndBOFEOFJ


Level Properties, Methods, and Events (ADO MD)

 Copy code hover
[image]

Level Properties, Methods, and Events (ADO MD)
Send feedback

Properties/Collections

Caption Property

Depth Property

Description Property

Members Collection

Name Property

Properties Collection

UniqueName Property

Methods

None.

Events

None.


IndexNulls Property Example (VB)

 Copy code hover
[image]

IndexNulls Property Example (VB)
Send feedback

This example demonstrates the IndexNulls property of an Index. The code creates a new index and sets the value of IndexNulls based on user input (from a list box named List1). Then, the Index is appended to the Employees Table in the Northwind Catalog. The new Index is applied to a Recordset based on the Employees table, and the Recordset is opened. A new record is added to the Employees table, with a Null value in the indexed field. Whether this new record is displayed depends on the setting of the IndexNulls property.

Copy code Copy code
                      ' IndexNullsVB
Sub Main()
 On Error GoTo IndexNullsXError

 Dim cnn As New ADODB.Connection
 Dim catNorthwind As New ADOX.Catalog
 Dim idxNew As New ADOX.Index
 Dim rstEmployees As New ADODB.Recordset
 Dim varBookmark As Variant

 ' Connect the catalog.
 cnn.Open "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\" & _
 "Microsoft Office\Office\Samples\Northwind.mdb';"

 Set catNorthwind.ActiveConnection = cnn

 ' Append Country column to new index
 idxNew.Columns.Append "Country"
 idxNew.Name = "NewIndex"

 Dim Response
 Response = MsgBox("Allow 'Null' index? Otherwise ignore 'Null' index.", vbYesNo)
 '"Allow 'Null' index? Otherwise ignore 'Null' index."
 ', vbYesNo + vbCritical + vbDefaultButton2,,,,
 If Response = vbYes Then ' User chose Yes.
 idxNew.IndexNulls = adIndexNullsAllow
 Else ' User chose No.
 idxNew.IndexNulls = adIndexNullsIgnore
 End If

 'Append new index to Employees table
 catNorthwind.Tables("Employees").Indexes.Append idxNew

 rstEmployees.Index = idxNew.Name
 rstEmployees.Open "Employees", cnn, adOpenKeyset, _
 adLockOptimistic, adCmdTableDirect

 With rstEmployees
 ' Add a new record to the Employees table.
 .AddNew
 !FirstName = "Gary"
 !LastName = "Haarsager"
 .Update

 ' Bookmark the newly added record
 varBookmark = .Bookmark

 ' Use the new index to set the order of the records.
 .MoveFirst

 Debug.Print "Index = " & .Index & _
 ", IndexNulls = " & idxNew.IndexNulls
 Debug.Print " Country - Name"

 ' Enumerate the Recordset. The value of the
 ' IndexNulls property will determine if the newly
 ' added record appears in the output.
 Do While Not .EOF
 Debug.Print " " & _
 IIf(IsNull(!Country), "[Null]", !Country) & _
 " - " & !FirstName & " " & !LastName
 .MoveNext
 Loop

 ' Delete new record because this is a demonstration.
 .Bookmark = varBookmark
 .Delete

 .Close
 End With

 'Clean up
 Set rstEmployees = Nothing
 catNorthwind.Tables("Employees").Indexes.Delete idxNew.Name
 cnn.Close
 Set cnn = Nothing
 Set catNorthwind = Nothing
 Set idxNew = Nothing
 Exit Sub

IndexNullsXError:

 If Not rstEmployees Is Nothing Then
 If rstEmployees.State = adStateOpen Then rstEmployees.Close
 End If
 Set rstEmployees = Nothing

 ' Delete new Index because this is a demonstration.
 If Not catNorthwind Is Nothing Then
 catNorthwind.Tables("Employees").Indexes.Delete idxNew.Name
 End If

 If Not cnn Is Nothing Then
 If cnn.State = adStateOpen Then cnn.Close
 End If
 Set cnn = Nothing

 Set catNorthwind = Nothing
 Set idxNew = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If

End Sub
' EndIndexNullsVB


Field.OriginalValue Property (DAO)

 Copy code hover
[image]

Field.OriginalValue Property (DAO)
Send feedback

Syntax

expression .OriginalValue

expression A variable that represents a Field object.

Remarks

During an optimistic batch update, a collision may occur where a second client modifies the same field and record in between the time the first client retrieves the data and the first client's update attempt. The OriginalValue property contains the value of the field at the time the last batch Update began. If this value does not match the value actually in the database when the batch Update attempts to write to the database, a collision occurs. When this happens, the new value in the database will be accessible through the VisibleValue property.


Pages Methods (Access)

 Copy code hover
[image]

Pages Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Add | The Add method adds a new Pageobject to the Pages collection of a tab control.
Remove | The Remove method removes a Page object from the Pages collection of a tab control.


Database objects (Access 2013 custom web app)

 Copy code hover
[image]

Database objects (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • GoToControl Macro Action (Access 2013 custom web app)

  • GoToRecord Macro Action (Access 2013 custom web app)

  • SetProperty Macro Action (Access 2013 custom web app)


UpdateBatch Method (ADO)

 Copy code hover
[image]

UpdateBatch Method (ADO)
Send feedback

Writes all pending batch updates to disk.

Syntax

recordset.UpdateBatch AffectRecords

Parameters

  • AffectRecords

  • Optional. An AffectEnum value that indicates how many records the UpdateBatch method will affect.

Remarks

Use the UpdateBatch method when modifying a Recordset object in batch update mode to transmit all changes made in a Recordset object to the underlying database.

If the Recordset object supports batch updating, you can cache multiple changes to one or more records locally until you call the UpdateBatch method. If you are editing the current record or adding a new record when you call the UpdateBatch method, ADO will automatically call the Update method to save any pending changes to the current record before transmitting the batched changes to the provider. You should use batch updating with either a keyset or static cursor only.

Note Note

Specifying adAffectGroup as the value for this parameter will result in an error when there are no visible records in the current Recordset (such as a filter for which no records match).

If the attempt to transmit changes fails for any or all records because of a conflict with the underlying data (for example, a record has already been deleted by another user), the provider returns warnings to the Errors collection and a run-time error occurs. Use the Filter property (adFilterAffectedRecords) and the Status property to locate records with conflicts.

To cancel all pending batch updates, use the CancelBatch method.

If the Unique Table and Update Resync dynamic properties are set, and the Recordset is the result of executing a JOIN operation on multiple tables, then the execution of the UpdateBatch method is implicitly followed by the Resync method depending on the settings of the Update Resync property.

The order in which the individual updates of a batch are performed on the data source is not necessarily the same as the order in which they were performed on the local Recordset. Update order is dependent upon the provider. Take this into account when coding updates that are related to one another, such as foreign key constraints on an insert or update.


EmptyCell.Left Property (Access)

 Copy code hover
[image]

EmptyCell.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .Left

expression A variable that represents an EmptyCell object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


Query support unavailable. (Error 3389)

 Copy code hover
[image]

Query support unavailable. (Error 3389)
Send feedback

You attempted to establish referential integrity on a Relation object of a QueryDef object, which is not supported.

Change the Attributes property setting of the Relation object to dbRelationDontEnforce.


Invalid dropbox path

 Copy code hover
[image]

Invalid dropbox path <name>. (Error 3476)
Send feedback

Make sure the dropbox path is correct.


References Events (Access)

 Copy code hover
[image]

References Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
ItemAdded | The ItemAdded event occurs when a reference is added to the project from Visual Basic.
ItemRemoved | The ItemRemoved event occurs when a reference is removed from the project.


AcFormatConditionType Enumeration (Access)

 Copy code hover
[image]

AcFormatConditionType Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the type of conditional formatting to apply to a control.

Name | Value | Description
acDataBar | 3 | The conditional format is displayed as a data bar.
acExpression | 1 | The conditional format is based on an expression.
acFieldHasFocus | 2 | The conditional format is based on the value of the control that has focus on a form.
acFieldValue | 0 | The conditional format is based on values in the selected control.


VBScript

 Copy code hover
[image]

VBScript
Send feedback

Microsoft Visual Basic Scripting Edition does not support ADO events.


CodeProject Object (Access)

 Copy code hover
[image]

CodeProject Object (Access)
See also Send feedback

Published: July 16, 2012

The CodeProject object refers to the project for the code database of a Microsoft Access project (.adp) or Access database.

Remarks

The CodeProject object has several collections that contain specific AccessObject objects within the code database. The following table lists the name of each collection defined by Access project and the types of objects it contains.

Collections | Object type
AllForms | All forms
AllReports | All reports
AllMacros | All macros
AllModules | All modules
Note Note

The collections in the preceding table contain all of the respective objects in the database regardless if they are opened or closed.

For example, an AccessObject object representing a form is a member of the AllForms collection, which is a collection of AccessObject objects within the current database. Within the AllForms collection, individual members of the collection are indexed beginning with zero. You can refer to an individual AccessObject object in the AllForms collection either by referring to the form by name, or by referring to its index within the collection. If you want to refer to a specific object in the AllForms collection, it's better to refer to it by name because a item's collection index may change. If the object name includes a space, the name must be surrounded by brackets ([ ]).

Syntax | Example
AllForms!formname | AllForms!OrderForm
AllForms![form name] | AllForms![Order Form]
AllForms("formname") | AllForms("OrderForm")
AllForms(formname) | AllForms(0)

See also

Concepts

Access Object Model Reference

Other resources

CodeProject Object Members


Form.AllowLayoutView Property (Access)

 Copy code hover
[image]

Form.AllowLayoutView Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the specified form can be used in Layout View. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .AllowLayoutView

expression A variable that represents a Form object.

See also

Concepts

Form Object

Other resources

Form Object Members


The VBA file is missing. Try reinstalling the application that returned the error. (Error 3446)

 Copy code hover
[image]

The VBA file is missing. Try reinstalling the application that returned the error. (Error 3446)
Send feedback

The Microsoft Access database engine VBA file could not be found.


= (Equals) (Access 2013 custom web app)

 Copy code hover
[image]

= (Equals) (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Compares the equality of two expressions.

Syntax

expression = expression

expression Is any valid expression. If the expressions are not of the same data type, the data type for one expression must be implicitly convertible to the data type of the other. The conversion depends on the rules of data type precedence.

Return Type

Boolean

Remarks

When you compare two NULL expressions, the result is TRUE.

Comparing NULL to a non-NULL value always results in FALSE.


Form.SplitFormSplitterBarSave Property (Access)

 Copy code hover
[image]

Form.SplitFormSplitterBarSave Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the location of the splitter bar is saved when a form that's displayed in Split Form mode is closed. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .SplitFormSplitterBarSave

expression A variable that represents a Form object.

See also

Concepts

Form Object

Other resources

Form Object Members


Choose Function (Access 2013 custom web app)

 Copy code hover
[image]

Choose Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the item at the specified index from a list of values.

Syntax

Choose (IndexNumber, Value [,Value_n ])

The Choose function contains the following arguments.

Argument name | Description
IndexNumber | An integer expression that represents a 1-based index into the list of the items following it.
Value | List of values of any data type.

Remarks

If the provided IndexNumber is not an integer, then the value is implicitly converted to an integer.

If the index value exceeds the bounds of the array of values, then Choose returns NULL.


Chapter 9: Data Shaping (ADO)

 Copy code hover
[image]

Chapter 9: Data Shaping (ADO)
Send feedback

In this section

  • Chapter 9: Data Shaping

  • Required Providers for Data Shaping

  • Shape Compute Clause

  • Fabricating Hierarchical Recordsets

  • Accessing Rows in a Hierarchical Recordset

  • Formal Shape Grammar

  • Visual Basic for Applications functions

  • Shape Append Clause (ADO)

  • Data Shaping Summary (ADO)

  • Shape Commands in General (ADO)


Like Operator (Microsoft Access SQL)

 Copy code hover
[image]

Like Operator (Microsoft Access SQL)
Send feedback

Published: July 16, 2012

Compares a string expression to a pattern in an SQL expression.

Syntax

expression Like "pattern"

The Like operator syntax has these parts:

Part | Description
expression | SQL expression used in a WHERE clause.
pattern | String or character string literal against which expression is compared.

Remarks

You can use the Like operator to find values in a field that match the pattern you specify. For pattern, you can specify the complete value (for example, Like "Smith" ), or you can use wildcard characters to find a range of values (for example, ), or you can use wildcard characters to find a range of values (for example, Like "Sm*") .

In an expression, you can use the Like operator to compare a field value to a string expression. For example, if you enter Like "C*" in an SQL query, the query returns all field values beginning with the letter C. In a parameter query, you can prompt the user for a pattern to search for.

The following example returns data that begins with the letter P followed by any letter between A and F and three digits:

SQL Copy code Copy code
Like "P[A-F]###"

The following table shows how you can use Like to test expressions for different patterns.

Kind of match | Pattern | Match (returns True) | No match (returns False)
Multiple characters | a*a | aa, aBa, aBBBa | aBC
 | *ab* | abc, AABB, Xab | aZb, bac
Special character | a[*]a | a*a | aaa
Multiple characters | ab* | abcdefg, abc | cab, aab
Single character | a?a | aaa, a3a, aBa | aBBBa
Single digit | a#a | a0a, a1a, a2a | aaa, a10a
Range of characters | [a-z] | f, p, j | 2, &
Outside a range | [!a-z] | 9, &, % | b, a
Not a digit | [!0-9] | A, a, &, ~ | 0, 1, 9
Combined | a[!b-m]# | An9, az0, a99 | abc, aj0

Example

This example returns a list of employees whose names begin with the letters A through D.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

VBA Copy code Copy code
Sub LikeX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Return a list of employees whose names begin with
    ' the letters A through D.
    Set rst = dbs.OpenRecordset("SELECT LastName," _
        & " FirstName FROM Employees" _
        & " WHERE LastName Like '[A-D]*';")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 15

    dbs.Close

End Sub


ADCPROP_UPDATECRITERIA_ENUM

 Copy code hover
[image]

ADCPROP_UPDATECRITERIA_ENUM
Send feedback

Specifies which fields can be used to detect conflicts during an optimistic update of a row of the data source with a Recordset object.

Use these constants with the Recordset "Update Criteria" dynamic property, which is referenced in the ADO Dynamic Property Index and documented in the Microsoft Cursor Service for OLE DB documentation.

Constant | Value | Description
adCriteriaAllCols | 1 | Detects conflicts if any column of the data source row has been changed.
adCriteriaKey | 0 | Detects conflicts if the key column of the data source row has been changed, which means that the row has been deleted.
adCriteriaTimeStamp | 3 | Detects conflicts if the timestamp of the data source row has been changed, which means the row has been accessed after the Recordset was obtained.
adCriteriaUpdCols | 2 | Detects conflicts if any of the columns of the data source row that correspond to updated fields of the Recordset have been changed.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.AdcPropUpdateCriteria.ALLCOLS

AdoEnums.AdcPropUpdateCriteria.KEY

AdoEnums.AdcPropUpdateCriteria.TIMESTAMP

AdoEnums.AdcPropUpdateCriteria.UPDCOLS


SharedResources.Item Property (Access)

 Copy code hover
[image]

SharedResources.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only Object.

Version Information

Version Added: Access 2010

Syntax

expression .Item(Index)

expression A variable that represents a SharedResources object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Long |

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

SharedResources Collection

Other resources

SharedResources Object Members


ToggleButton.Name Property (Access)

 Copy code hover
[image]

ToggleButton.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a ToggleButton object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


ToggleButton.KeyDown Event (Access)

 Copy code hover
[image]

ToggleButton.KeyDown Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyDown(KeyCode, Shift)

expression A variable that represents a ToggleButton object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyDown property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyDown event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyDown event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyDown event occurs when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

Example

The following example determines whether you have pressed the SHIFT, CTRL, or ALT key.

To try the example, add the following event procedure to a form containing a text box named KeyHandler.

VBA Copy code Copy code
Private Sub KeyHandler_KeyDown(KeyCode As Integer, _
     Shift As Integer)
    Dim intShiftDown As Integer, intAltDown As Integer
    Dim intCtrlDown As Integer

    ' Use bit masks to determine which key was pressed.
    intShiftDown = (Shift And acShiftMask) > 0
    intAltDown = (Shift And acAltMask) > 0
    intCtrlDown = (Shift And acCtrlMask) > 0
    ' Display message telling user which key was pressed.
    If intShiftDown Then MsgBox "You pressed the SHIFT key."
    If intAltDown Then MsgBox "You pressed the ALT key."
    If intCtrlDown Then MsgBox "You pressed the CTRL key."
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


TabControl Methods (Access)

 Copy code hover
[image]

TabControl Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.


CommandButton.Shadow Property (Access)

 Copy code hover
[image]

CommandButton.Shadow Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the Shadow effect applied to the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .Shadow

expression A variable that represents a CommandButton object.

Remarks

The Shadow property uses one of the values listed in the following table.

Value | Effect
0 Default) | None
1 | Offset Diagonal Bottom Right
2 | Offset Bottom
3 | Offset Diagonal Bottom Left
4 | Offset Right
5 | Offset Center
6 | Offset Left
7 | Offset Diagonal Top Right
8 | Offset Top
9 | Offset Diagonal Top Left
10 | Inside Diagonal Top Left
11 | Inside Top
12 | Inside Diagonal Top Right
13 | Inside Left
14 | Inside Center
15 | Inside Right
16 | Inside Diagonal Bottom Left
17 | Inside Bottom
18 | Inside Diagonal Bottom Right
19 | Perspective Diagonal Upper Left
20 | Perspective Diagonal Upper Right
21 | Below
22 | Perspective Diagonal Lower Left
23 | Perspective Diagonal Lower Right

To see the available shadow effects and apply a shadow through the user interface, first open the form or report in Layout view or Design view by right-clicking the form or report in the Navigation Pane, and then clicking the view you want. Then, click the object to which you want to apply a shadow effect. Next, on the Format tab, in the Control Formatting group, click Shape Effects, then click Shadow and choose a shadow effect. Notice that the shadow effects are indexed from left to right, and then top to bottom. So the first item, under No Shadow, has the value 0. Then, under Outer, the first row contains shadow effects with values from 1 to 3. The second row from 4 to 6, and so on.

This property is not surfaced in the property sheet.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


CheckBox.VerticalAnchor Property (Access)

 Copy code hover
[image]

CheckBox.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified check box is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .VerticalAnchor

expression A variable that represents a CheckBox object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Indexes Append Method Example (VB)

 Copy code hover
[image]

Indexes Append Method Example (VB)
Send feedback

The following code demonstrates how to create a new index. The index is on two columns in the table.

Copy code Copy code

' BeginCreateIndexVB
Sub Main()
 On Error GoTo CreateIndexError

 Dim tbl As New Table
 Dim idx As New ADOX.Index
 Dim cat As New ADOX.Catalog

 'Open the catalog.
 ' Open the Catalog.
 cat.ActiveConnection = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\Microsoft Office\" & _
 "Office\Samples\Northwind.mdb';"

 ' Define the table and append it to the catalog
 tbl.Name = "MyTable"
 tbl.Columns.Append "Column1", adInteger
 tbl.Columns.Append "Column2", adInteger
 tbl.Columns.Append "Column3", adVarWChar, 50
 cat.Tables.Append tbl
 Debug.Print "Table 'MyTable' is added."

 ' Define a multi-column index
 idx.Name = "multicolidx"
 idx.Columns.Append "Column1"
 idx.Columns.Append "Column2"

 ' Append the index to the table
 tbl.Indexes.Append idx
 Debug.Print "The index is appended to table 'MyTable'."

 'Delete the table as this is a demonstration
 cat.Tables.Delete tbl.Name
 Debug.Print "Table 'MyTable' is deleted."

 'Clean up
 Set cat.ActiveConnection = Nothing
 Set cat = Nothing
 Set tbl = Nothing
 Set idx = Nothing
 Exit Sub

CreateIndexError:
 Set cat = Nothing
 Set tbl = Nothing
 Set idx = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndCreateIndexVB


Attachment.OnMouseDown Property (Access)

 Copy code hover
[image]

Attachment.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnMouseDown

expression A variable that represents an Attachment object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Properties.Refresh Method (DAO)

 Copy code hover
[image]

Properties.Refresh Method (DAO)
Send feedback

Updates the objects in the specified colletion to reflect the database's current schema.

Syntax

expression .Refresh

expression A variable that represents a Properties object.

Remarks

Use the Refresh method in multiuser environments in which other users may change the database. You may also need to use it on any collections that are indirectly affected by changes to the database. For example, if you change a Users collection, you may need to refresh a Groups collection before using the Groups collection.

A collection is filled with objects the first time it's referred to and won't automatically reflect subsequent changes other users make. If it's likely that another user has changed a collection, use the Refresh method on the collection immediately before carrying out any task in your application that assumes the presence or absence of a particular object in the collection. This will ensure that the collection is as up-to-date as possible. On the other hand, using Refresh can unnecessarily slow performance.


Members Collection Properties, Methods, and Events (ADO MD)

 Copy code hover
[image]

Members Collection Properties, Methods, and Events (ADO MD)
Send feedback

Properties

Count Property

Item Property

Methods

Refresh Method

Events

None.


Operation of Parameterized Commands

 Copy code hover
[image]

Operation of Parameterized Commands
Send feedback

If you are working with a large child Recordset, especially compared to the size of the parent Recordset, but need to access only a few child chapters, you might find it more efficient to use a parameterized command.

A non-parameterized command retrieves both the entire parent and child Recordsets, appends a chapter column to the parent, and then assigns a reference to the related child chapter for each parent row.

A parameterized command retrieves the entire parent Recordset, but retrieves only the chapter Recordset when the chapter column is accessed. This difference in retrieval strategy can yield significant performance benefits.

For example, you can specify the following:

Copy code Copy code

SHAPE {SELECT * FROM customer}
 APPEND ({SELECT * FROM orders WHERE cust_id = ?}
 RELATE cust_id TO PARAMETER 0)

The parent and child tables have a column name in common, cust_id. The child-command has a "?" placeholder, to which the RELATE clause refers (that is, "...PARAMETER 0").

Note Note

The PARAMETER clause pertains solely to the shape command syntax. It is not associated with either the ADO Parameter object or the Parameters collection.

When the parameterized shape command is executed, the following occurs:

  1. The parent-command is executed and returns a parent Recordset from the Customers table.

  2. A chapter column is appended to the parent Recordset.

  3. When the chapter column of a parent row is accessed, the child-command is executed using the value of the customer.cust_id as the value of the parameter.

  4. All rows in the data provider rowset created in step 3 are used to populate the child Recordset. In this example, that is all the rows in the Orders table in which the cust_id equals the value of customer.cust_id. By default, the child Recordsets will be cached on the client until all references to the parent Recordset are released. To change this behavior, set the Recordset dynamic property Cache Child Rows to False.

  5. A reference to the retrieved child rows (that is, the chapter of the child Recordset) is placed in the chapter column of the current row of the parent Recordset.

  6. Steps 3-5 are repeated when the chapter column of another row is accessed.

The Cache Child Rows dynamic property is set to True by default. The caching behavior varies depending upon the parameter values of the query. In a query with a single parameter, the child Recordset for a given parameter value will be cached between requests for a child with that value. The following code demonstrates this:

Copy code Copy code

...
SCmd = "SHAPE {select * from customer} " & _
 "APPEND({select * from orders where cust_id = ?} " & _
 "RELATE cust_id TO PARAMETER 0) AS chpCustOrder"
Rst1.Open sCmd, Cnn1
Set RstChild = Rst1("chpCustOrder").Value
Rst1.MoveNext ' Next cust_id passed to Param 0, & new rs fetched
 ' into RstChild.
Rst1.MovePrevious ' RstChild now holds cached rs, saving round trip.
...

In a query with two or more parameters, a cached child is used only if all the parameter values match the cached values.

Parameterized Commands and Complex Parent Child Relations

In addition to using parameterized commands to improve performance of an equi-join type hierarchy, parameterized commands can be used to support more complex parent-child relationships. For example, consider a Little League database with two tables: one consisting of the teams (team_id, team_name) and the other of games (date, home_team, visiting_team).

Using a non-parameterized hierarchy, there is no way to relate the teams and games tables in such a way that the child Recordset for each team contains its complete schedule. You can create chapters that contain the home schedule or the road schedule, but not both. This is because the RELATE clause limits you to parent-child relationships of the form (pc1=cc1) AND (pc2=pc2). So, if your command included "RELATE team_id TO home_team, team_id TO visiting_team", you would get only games where a team was playing itself. What you want is "(team_id=home_team) OR (team_id=visiting_team)", but the Shape provider does not support the OR clause.

To obtain the desired result, you can use a parameterized command. For example:

Copy code Copy code

SHAPE {SELECT * FROM teams}
APPEND ({SELECT * FROM games WHERE home_team = ? OR visiting_team = ?}
 RELATE team_id TO PARAMETER 0,
 team_id TO PARAMETER 1)

This example exploits the greater flexibility of the SQL WHERE clause to get the result you need.


DeleteRecord Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

DeleteRecord Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

You can use the DeleteRecord action to delete a record.

Setting

The DeleteRecord action doesn't contain any arguments when used in a user interface (UI) macro.


View an ActiveX Control's About Box

 Copy code hover
[image]

View an ActiveX Control's About Box
Send feedback

To view an About box showing version and copyright information for an ActiveX control, click the About property box in the Microsoft Access property sheet. Then click the Build button to the right of the property box.


Report.OnFilter Property (Access)

 Copy code hover
[image]

Report.OnFilter Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Filter box in the Properties window of a report. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnFilter

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Filter event occurs when a report is opened and its records are displayed.

The OnFilter value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Filter box in the report's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Filter box is blank, the property value is an empty string.

Example

The following example associates the Filter property for the "Catalog" report to the event "Report_Filter".

VBA Copy code Copy code
Reports("Catalog").OnFilter = "[Event Procedure]"

See also

Concepts

Report Object

Other resources

Report Object Members


TabControl.LeftPadding Property (Access)

 Copy code hover
[image]

TabControl.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .LeftPadding

expression A variable that represents a TabControl object.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


QueryDef.Fields Property (DAO)

 Copy code hover
[image]

QueryDef.Fields Property (DAO)
Send feedback

Returns a Fields collection that represents all stored Field objects for the specified object. Read-only.

Syntax

expression .Fields

expression A variable that represents a QueryDef object.


Form.HelpFile Property (Access)

 Copy code hover
[image]

Form.HelpFile Property (Access)
See also Send feedback

Published: July 16, 2012

The name of a help file associated with a form. Read/write String.

Syntax

expression .HelpFile

expression A variable that represents a Form object.

Example

This example adds a custom command bar with a combo box that tracks stock data. The example also specifies the Help topic to be displayed for the combo box when the user presses SHIFT+F1.

VBA Copy code Copy code
Set myBar = CommandBars _
 .Add(Name:="Custom", Position:=msoBarTop, _
 Temporary:=True)
With myBar
 .Controls.Add Type:=msoControlComboBox, ID:=1
 .Visible = True
End With
With CommandBars("Custom").Controls(1)
 .AddItem "Get Stock Quote", 1
 .AddItem "View Chart", 2
 .AddItem "View Fundamentals", 3
 .AddItem "View News", 4
 .Caption = "Stock Data"
 .DescriptionText = "View Data For Stock"
 .HelpFile = "C:\corphelp\custom.hlp"
 .HelpContextID = 47
End With

See also

Concepts

Form Object

Other resources

Form Object Members


OptionGroup.MouseMove Event (Access)

 Copy code hover
[image]

OptionGroup.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents an OptionGroup object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Status Property Example (VC++)

 Copy code hover
[image]

Status Property Example (VC++)
Send feedback

This example uses the Status property to display which records have been modified in a batch operation before a batch update has occurred.

Copy code Copy code

// BeginStatusCpp
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>
#include "StatusX.h"

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void StatusX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////

void main()
{
 if(FAILED(CoInitialize(NULL)))
 return;

 StatusX();

 ::CoUninitialize();
}

///////////////////////////////////////////////
// //
// StatusX Function //
// //
///////////////////////////////////////////////
void StatusX(void)
{
 HRESULT hr = S_OK;

 // Define string variables.
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 IADORecordBinding *picRs = NULL; // Interface Pointer Declared
 CTitleRs titlers; // C++ Class Object
 _RecordsetPtr pRstTitles = NULL;
 LPSTR p_TempStr = NULL;

 try
 {
 // Open recordset for batch update
 TESTHR(hr = pRstTitles.CreateInstance(__uuidof(Recordset)));
 pRstTitles->CursorType = adOpenKeyset;
 pRstTitles->LockType = adLockBatchOptimistic;
 pRstTitles->Open ("titles", strCnn,
 adOpenKeyset, adLockBatchOptimistic, adCmdTable);

 // Open an IADORecordBinding interface pointer which
 // we will use for binding Recordset to a class.
 TESTHR(hr = pRstTitles->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 // Bind the Recordset to a C++ class here
 TESTHR(hr = picRs->BindToRecordset(&titlers));

 p_TempStr = (LPSTR) malloc(sizeof(titlers.m_szt_Type));

 // Change the type of psychology titles.
 while(!(pRstTitles->EndOfFile))
 {
 // Set the final character of the destination string to NULL.
 p_TempStr[sizeof(titlers.m_szt_Type)-1] = '\0';
 // The source string will get truncated if its length is
 // longer than the length of the destination string minus one.
 strncpy(p_TempStr,strtok(titlers.m_szt_Type," "),
 sizeof(titlers.m_szt_Type)-1);

 // Compare the type of psychology titles
 if (!strcmp(p_TempStr,"psychology"))
 {
 // Copy "self_help" title field
 pRstTitles->Fields->GetItem("type")->Value =
 (_bstr_t) ("self_help");
 }
 pRstTitles->MoveNext();
 }

 // Display Title ID and status
 pRstTitles->MoveFirst();
 while(!(pRstTitles->EndOfFile))
 {
 if(pRstTitles->Status == adRecModified)
 {
 printf("%s - Modified\n",titlers.lt_Title_idStatus ==
 adFldOK ? titlers.m_szt_Title_id : "<NULL>");
 }
 else
 {
 printf("%s\n",titlers.lt_Title_idStatus == adFldOK ?
 titlers.m_szt_Title_id : "<NULL>");
 }
 pRstTitles->MoveNext();
 }
 }
 catch (_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstTitles->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Deallocate the memory
 if (p_TempStr)
 free(p_TempStr);

 if (pRstTitles)
 if (pRstTitles->State == adStateOpen)
 {
 // Cancel the update because this is a demonstration.
 pRstTitles->CancelBatch(adAffectAll);
 pRstTitles->Close();
 }
}

///////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

///////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////
void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndStatusCpp

StatusX.h

Copy code Copy code

// BeginStatusH
#include "icrsint.h"

//This class extracts title_id and type from titles table.
class CTitleRs : public CADORecordBinding
{
 BEGIN_ADO_BINDING(CTitleRs)
 // Column title_id is the 1st field in the table
 ADO_VARIABLE_LENGTH_ENTRY2(1,adVarChar,m_szt_Title_id,
 sizeof(m_szt_Title_id),lt_Title_idStatus,FALSE)
 // Column type is the 3rd field in the table
 ADO_VARIABLE_LENGTH_ENTRY2(3,adVarChar,m_szt_Type,
 sizeof(m_szt_Type),lt_TypeStatus,TRUE)
END_ADO_BINDING()

public:
 CHAR m_szt_Title_id[7];
 ULONG lt_Title_idStatus;
 CHAR m_szt_Type[13];
 ULONG lt_TypeStatus;
};
// EndStatusH


GetRows Method Example (JScript)

 Copy code hover
[image]

GetRows Method Example (JScript)
Send feedback

This example uses the GetRows method to retrieve all rows of the Custiomers table from a Recordset and to fill an array with the resulting data. The GetRows method will return fewer than the desired number of rows in two cases: either if EOF has been reached, or if GetRows tried to retrieve a record that was deleted by another user. The function returns False only if the second case occurs. Cut and paste the following code to Notepad or another text editor, and save it as GetRowsJS.asp.

Copy code Copy code

<!-- BeginGetRowsJS -->
<%@ LANGUAGE="JScript" %>
<%// use this meta tag instead of adojavas.inc%>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->

<html>

<head>
<title>ADO Recordset.GetRows Example (JScript)</title>
<style>
<!--
BODY {
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 BACKGROUND-COLOR:white;
 COLOR:black;
 }
.thead {
 background-color: #008080;
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 font-size: x-small;
 color: white;
 }
.thead2 {
 background-color: #800000;
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 font-size: x-small;
 color: white;
 }
.tbody {
 text-align: center;
 background-color: #f7efde;
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 font-size: x-small;
 }
-->
</style>
</head>

<body bgcolor="white">

<h1>ADO Recordset.GetRows Example (JScript)</h1>
 <!-- Page text goes here -->
<%
 var Connect = "Provider='sqloledb';Data Source=" + Request.ServerVariables("SERVER_NAME") + ";" +
 "Initial Catalog='Northwind';Integrated Security='SSPI';";
 var mySQL = "select * from customers;";
 var showblank = " ";
 var shownull = "-null-";

 var connTemp = Server.CreateObject("ADODB.Connection");

 try
 {
 connTemp.Open(Connect);
 var rsTemp = Server.CreateObject("ADODB.Recordset");
 rsTemp.ActiveConnection = connTemp;
 rsTemp.CursorLocation = adUseClient;
 rsTemp.CursorType = adOpenKeyset;
 rsTemp.LockType = adLockOptimistic;
 rsTemp.Open(mySQL);

 rsTemp.MoveFirst();

 if (rsTemp.RecordCount == 0)
 {
 Response.Write("No records matched ");
 Response.Write (mySQL & "So cannot make table...");
 connTemp.Close();
 Response.End();
 } else
 {
 Response.Write('<table width="100%" border="2">');
 Response.Write('<tr class="thead2">');

 // Headings On The Table for each Field Name
 for (var i=0; i<rsTemp.Fields.Count; i++)
 {
 fieldObject = rsTemp.fields(i);
 Response.Write('<td width="' + Math.floor(100 / rsTemp.Fields.Count) + '%">' + fieldObject.name + "</td>");
 }

 Response.Write("</tr>");

 // JScript doesn't support multi-dimensional arrays
 // so we'll convert the returned array to a single
 // dimensional JScript array and then display the data.
 tempArray = rsTemp.GetRows();
 recArray = tempArray.toArray();

 var col = 1;
 var maxCols = rsTemp.Fields.Count;

 for (var thisField=0; thisField<recArray.length; thisField++)
 {
 if (col == 1)
 Response.Write('<tr class="tbody">');
 if (recArray[thisField] == null)
 recArray[thisField] = shownull;
 if (recArray[thisField] == "")
 recArray[thisField] = showblank;
 Response.Write("<td>" + recArray[thisField] + "</td>");
 col++
 if (col > maxCols)
 {
 Response.Write("</tr>");
 col = 1;
 }
 }
 Response.Write("</table>");
 }
 }
 catch (e)
 {
 Response.Write(e.message);
 }
 finally
 {
 // clean up
 if (rsTemp.State == adStateOpen)
 rsTemp.Close;
 if (connTemp.State == adStateOpen)
 connTemp.Close;
 rsTemp = null;
 connTemp = null;
 }
%>

</body>

</html>
<!-- EndGetRowsJS -->


Using ADO with Scripting Languages Topics

 Copy code hover
[image]

Using ADO with Scripting Languages Topics
Send feedback

In this section

  • Using ADO with Scripting Languages

  • JScript ADO Programming

  • VBScript ADO Programming


Chapter 2: Getting Data

 Copy code hover
[image]

Chapter 2: Getting Data
Send feedback

The preceding chapter introduced four primary operations involved in creating an ADO application: getting data, examining data, editing data, and updating data. This chapter will focus on the details of the concepts relevant to the first operation: getting data.

Several ADO objects can play a role in this operation. First you connect to the data source using an ADO Connection object (which at times will be created implicitly). Then you pass instructions to the data source about what you want to do using an ADO Command object (which also can be created implicitly). The result of passing a command to a data source and receiving its response usually will be represented in an ADO Recordset object.

To get data, your application must be in communication with a data source, such as a DBMS, a file store, or a comma-delimited text file. This communication represents a connection — the environment necessary for exchanging data.

The ADO object model represents the concept of a connection with the Connection object — the foundation upon which much ADO functionality is built. The purpose of a Connection object is to:

  • Define the information ADO needs to communicate with data sources and create sessions.

  • Define the transactional capabilities of the session.

  • Allow you to create and execute commands against the data source.

  • Provide information about the design of the underlying data source in the form of schema rowsets. For more information about schema rowsets, see OpenSchema Method.


How to: Use Textual Criteria Expressions

 Copy code hover
[image]

How to: Use Textual Criteria Expressions
Send feedback

To specify textual criteria for an operation, you supply a text string as part of the string expression that forms the criteria argument. This text string must be enclosed in single quotation marks (').

Note Note

The single quotation marks indicate to Microsoft Access that the criteria argument contains a string within a string.

Suppose that you are using the ADO Find method to find the first occurrence of a last name in an Employees table. You could construct the criteria argument as in the following example, which moves the current record pointer to the first record in which an employee's last name is Buchanan. Note that the string literal Buchanan is enclosed in single quotation marks and the entire string comprising the criteria argument must also be enclosed in double quotation marks (").

Copy code Copy code
Dim rst As New ADODB.Connection

rst.open "Employees", CurrentProject.Connection,_
     dbOpenDynaset, adlockoptimistic)
rst.Find "[LastName] = 'Buchanan'"


Form Object (Access)

 Copy code hover
[image]

Form Object (Access)
See also Send feedback

Published: July 16, 2012

A Form object refers to a particular Microsoft Access form.

Remarks

A Form object is a member of the Forms collection, which is a collection of all currently open forms. Within the Forms collection, individual forms are indexed beginning with zero. You can refer to an individual Form object in the Forms collection either by referring to the form by name, or by referring to its index within the collection. If you want to refer to a specific form in the Forms collection, it's better to refer to the form by name because a form's collection index may change. If the form name includes a space, the name must be surrounded by brackets ([ ]).

Syntax | Example
AllForms!formname | AllForms!OrderForm
AllForms![form name] | AllForms![Order Form]
AllForms("formname") | AllForms("OrderForm")
AllForms(formname) | AllForms(0)

Each Form object has a Controls collection, which contains all controls on the form. You can refer to a control on a form either by implicitly or explicitly referring to the Controls collection. Your code will be faster if you refer to the Controls collection implicitly. The following examples show two of the ways you might refer to a control named NewData on the form called OrderForm:

VBA Copy code Copy code
' Implicit reference.
Forms!OrderForm!NewData
VBA Copy code Copy code
' Explicit reference.
Forms!OrderForm.Controls!NewData

The next two examples show how you might refer to a control named NewData on a subform ctlSubForm contained in the form called OrderForm:

VBA Copy code Copy code
Forms!OrderForm.ctlSubForm.Form!Controls.NewData
VBA Copy code Copy code
Forms!OrderForm.ctlSubForm!NewData

Links provided by: Community Member Icon Luke Chung, FMS, Inc. | About the Contributors

  • Microsoft Access Form Tips and Avoiding Common Mistakes

  • Microsoft Office Access 2007 Form Design Tips

Links provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Display Pictures on a Form

  • Display Related Data

  • Opening a Detail Form to Related Information

  • Forms: Populate Controls/Text Boxes Based on Combobox Selection

  • Referring To Properties And Controls On Subforms

Example

The following example shows how to use TextBox controls to supply date criteria for a query.

UtterAccess members can download a database that contains this example from here.

Sample code provided by: Community Member Icon The UtterAccess community | About the Contributors

VBA Copy code Copy code
Private Sub cmdSearch_Click()

   Dim db As DAO.Database
   Dim qd As QueryDef
   Dim vWhere As Variant

   Set db = CurrentDb()

   On Error Resume Next
   db.QueryDefs.Delete "Query1"
   On Error GoTo 0

   vWhere = Null

   vWhere = vWhere & " AND [PayeeID]=" + Me.cboPayeeID

   If Nz(Me.txtEndDate, "") <> "" And Nz(Me.txtStartDate, "") <> "" Then
      vWhere = vWhere & " AND [RefundProcessed] Between #" & _
      Me.txtStartDate & "# AND #" & Me.txtEndDate & "#"
   Else
      If Nz(Me.txtEndDate, "") = "" And Nz(Me.txtStartDate, "") <> "" Then
         vWhere = vWhere & " AND [RefundProcessed]>=#" _
                  + Me.txtStartDate & "#"
      Else
         If Nz(Me.txtEndDate, "") <> "" And Nz(Me.txtStartDate, "") = "" Then
            vWhere = vWhere & " AND [RefundProcessed] <=#" _
                     + Me.txtEndDate & "#"
      End If
     End If
   End If

   If Nz(vWhere, "") = "" Then
      MsgBox "There are no search criteria selected." & vbCrLf & vbCrLf & _
             "Search Cancelled.", vbInformation, "Search Canceled."
   Else
      Set qd = db.CreateQueryDef("Query1", "SELECT * FROM tblRefundData" & _
               " WHERE " & Mid(vWhere, 6))
      db.Close
      Set db = Nothing

      DoCmd.OpenQuery "Query1", acViewNormal, acReadOnly
   End If
End Sub

The following example shows how to use the BeforeUpdate event of a form to require that a value be entered into one control when another control also has data.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Private Sub Form_BeforeUpdate(Cancel As Integer)
If (IsNull(Me.FieldOne)) Or (Me.FieldOne.Value =  "") Then
    ' No action required
Else
    If (IsNull(Me.FieldTwo)) or (Me.FieldTwo.Value = "") Then
        MsgBox "You must provide data for field 'FieldTwo', " & _
            "if a value is entered in FieldOne", _
            vbOKOnly, "Required Field"
        Me.FieldTwo.SetFocus
        Cancel = True
        Exit Sub
    End If
End If

End Sub

The following example shows how to use the OpenArgs property to prevent a form from being opened from the Navigation Pane.

VBA Copy code Copy code
Private Sub Form_Open(Cancel As Integer)

If Me.OpenArgs() <> "Valid User" Then
    MsgBox "You are not authorized to use this form!", _
        vbExclamation + vbOKOnly, "Invalid Access"
    Cancel = True
End If
End Sub

The following example shows how to use the WhereCondition argument of the OpenForm method to filter the records displayed on a form as it is opened.

VBA Copy code Copy code
Private Sub cmdShowOrders_Click()
If Not Me.NewRecord Then
    DoCmd.OpenForm "frmOrder", _
        WhereCondition:="CustomerID=" & Me.txtCustomerID
End If
End Sub

About the Contributors

Luke Chung is the founder and president of FMS, Inc., a leading provider of custom database solutions and developer tools.

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.

See also

Concepts

Access Object Model Reference

Other resources

Form Object Members


ODBC -- could not create table. (Error 3232)

 Copy code hover
[image]

ODBC -- could not create table. (Error 3232)
Send feedback

You tried to export a table to an ODBC database and the table could not be created. This error can occur if the ODBC database is read-only, or you do not have permission to create a table in that database. Resolve the read-only condition, or see your system administrator or the person who created the database to obtain the necessary permissions.


ObjectFrame.GridlineWidthTop Property (Access)

 Copy code hover
[image]

ObjectFrame.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified frame. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthTop

expression A variable that represents an ObjectFrame object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Set Startup Properties from Visual Basic

 Copy code hover
[image]

Set Startup Properties from Visual Basic
Send feedback

In a Microsoft Access database, startup properties are properties of a Database object. A Database object is a DAO object supplied by the Microsoft Access database engine, but startup properties are defined by Microsoft Access, so they aren't automatically recognized by the Access database engine. If a startup property hasn't been set previously, you must create it and add it to the Properties collection of the Database object.

In a Microsoft Access project (.adp), startup properties are properties of a CurrentProject object and like the Database object in an Access database, startup properties aren't automatically recognized by the Access database engine. If a startup property hasn't been set previously, you must create it and add it to the AccessObjectProperties collection of the CurrentProject object.

When you set startup properties from Visual Basic, you should include error-handling code to verify that the property exists in the Properties or AccessObjectProperties collection. For more information about setting properties defined by Microsoft Access, see Set Properties of Data Access Objects in Visual Basic or Set Properties of ActiveX Data Objects in Visual Basic .

The names of the startup properties differ from the text that appears in the Startup dialog box. The following table provides the name of each startup property as it's used in Visual Basic code.

Text in Startup dialog box | Property name
Application Title | AppTitle
Application Icon | AppIcon
Display Form/Page | StartupForm
Display Database Window | StartupShowDBWindow
Display Status Bar | StartupShowStatusBar
Menu Bar | StartupMenuBar
Shortcut Menu Bar | StartupShortcutMenuBar
Allow Full Menus | AllowFullMenus
Allow Default Shortcut Menus | AllowShortcutMenus
Allow Built-In Toolbars | AllowBuiltInToolbars
Allow Toolbar/Menu Changes | AllowToolbarChanges
Allow Viewing Code After Error | AllowBreakIntoCode
Use Access Special Keys | AllowSpecialKeys


ParameterDirectionEnum

 Copy code hover
[image]

ParameterDirectionEnum
Send feedback

Specifies whether the Parameter represents an input parameter, an output parameter, both an input and an output parameter, or the return value from a stored procedure.

Constant | Value | Description
adParamInput | 1 | Default. Indicates that the parameter represents an input parameter.
adParamInputOutput | 3 | Indicates that the parameter represents both an input and output parameter.
adParamOutput | 2 | Indicates that the parameter represents an output parameter.
adParamReturnValue | 4 | Indicates that the parameter represents a return value.
adParamUnknown | 0 | Indicates that the parameter direction is unknown.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.ParameterDirection.INPUT

AdoEnums.ParameterDirection.INPUTOUTPUT

AdoEnums.ParameterDirection.OUTPUT

AdoEnums.ParameterDirection.RETURNVALUE

AdoEnums.ParameterDirection.UNKNOWN


Indexes Properties (DAO)

 Copy code hover
[image]

Indexes Properties (DAO)
Send feedback

In this section

  • Indexes.Count Property (DAO)


TextBox.FontSize Property (Access)

 Copy code hover
[image]

TextBox.FontSize Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontSize property to specify the point size for text in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Integer.

Syntax

expression .FontSize

expression A variable that represents a TextBox object.

Remarks

The FontSize property uses the following settings.

Setting | Description
8 | (Default for all reports and controls except command buttons) The text is 8-point type.
10 | (Default for command buttons) The text is 10-point type.
Other sizes | The text is the indicated size.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set this property only in an event procedure or in a macro specified by the OnPrint event property setting.

In Visual Basic, you set the FontSize property by using a numeric expression equal to the desired size of the font. The setting for the FontSize property can be between 1 and 127, inclusive.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


SmartTagAction Members (Access)

 Copy code hover
[image]

SmartTagAction Members (Access)
Send feedback

Published: July 16, 2012

Represents a single action for a smart tag.

Methods

Name | Description
Execute | The Execute method performs the specified smart tag action.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Name | You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.
Parent | Returns the parent object for the specified object. Read-only.


CurrentProject.AllMacros Property (Access)

 Copy code hover
[image]

CurrentProject.AllMacros Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllMacros property to reference the AllMacros collection and its related properties. Read-only AllMacros object.

Syntax

expression .AllMacros

expression A variable that represents a CurrentProject object.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


Calculate Fields in Domain Aggregate Functions

 Copy code hover
[image]

Calculate Fields in Domain Aggregate Functions
Send feedback

You can use the string expression argument (the expr argument) in a domain aggregate function to perform a calculation on values in a field. For example, you can calculate a percentage (such as a surcharge or sales tax) by dividing a field value by a number.

The following table provides examples of calculations on fields from an Orders table and an Order Details table.

Calculation | Example
Add a number to a field | "[Freight] + 5"
Subtract a number from a field | "[Freight] - 5"
Multiply a field by a number | "[Freight] * 2"
Divide a field by a number | "[Freight] / 2"
Add one field to another | "[UnitsInStock] + [UnitsOnOrder]"
Subtract one field from another | "[ReorderLevel] - [UnitsInStock]"

You would most likely use a domain aggregate function in a macro or module, in a calculated control on a form or report, or in a criteria expression in a query.

For example, you can calculate the average discount amount for all orders in an Order Details table. Multiply the Unit Price and Discount fields to determine the discount for each order, then calculate the average. Enter the following example in a procedure in a module.

Copy code Copy code
Dim dblX As Double
dblX = DAvg("[UnitPrice] * [Discount]", "[Order Details]")


ComboBox.MouseMove Event (Access)

 Copy code hover
[image]

ComboBox.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents a ComboBox object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Chapter 3: Examining Data

 Copy code hover
[image]

Chapter 3: Examining Data
Send feedback

Chapter 2 explained how to retrieve data from a data source as a Recordset object. This chapter will discuss the Recordset in more detail, including how to navigate through the Recordset and view its data.

Recordsets have methods and properties designed to make it easy to move through them and examine their contents. Depending on the functionality supported by the provider, some Recordset methods or properties might not be available. To continue exploring the Recordset object, consider a Recordset that would be returned from the Northwind sample database on Microsoft SQL Server 2000, using the following code:

Copy code Copy code

'BeginRsTour
Public Sub RecordsetTour()
 On Error GoTo ErrHandler:

 Dim objRs As New ADODB.Recordset
 Dim strSQL As String

 strSQL = "SELECT ProductID, ProductName, UnitPrice FROM Products " & _
 "WHERE CategoryID = 7" '7 = Produce

 objRs.Open strSQL, strConnStr, adOpenForwardOnly, _
 adLockReadOnly, adCmdText

 'Clean up
 objRs.Close
 Set objRs = Nothing
 Exit Sub

ErrHandler:
 If Not objRs Is Nothing Then
 If objRs.State = adStateOpen Then objRs.Close
 Set objRs = Nothing
 End If

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndRsTour

This SQL query returns a Recordset with five rows (records) and three columns (fields). The values for each row are shown in the following table.

FIELD 0 Name = ProductID | FIELD 1 Name = ProductName | FIELD 2 Name = UnitPrice
7 | Uncle Bob's Organic Dried Pears | 30.0000
14 | Tofu | 23.2500
28 | Rssle Sauerkraut | 45.6000
51 | Manjimup Dried Apples | 53.0000
74 | Longlife Tofu | 10.0000

The next section will explain how to locate the current position of the cursor in this sample Recordset.


CodeProject.AllModules Property (Access)

 Copy code hover
[image]

CodeProject.AllModules Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllModules property to reference the AllModules collection and its related properties. Read-only AllModules object.

Syntax

expression .AllModules

expression A variable that represents a CodeProject object.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


Recordset2.MoveFirst Method (DAO)

 Copy code hover
[image]

Recordset2.MoveFirst Method (DAO)
Send feedback

Moves to the first record in a specified Recordset object and make that record the current record.

Syntax

expression .MoveFirst

expression A variable that represents a Recordset2 object.

Remarks

Use the Move methods to move from record to record without applying a condition.

If you edit the current record, be sure you use the Update method to save the changes before you move to another record. If you move to another record without updating, your changes are lost without warning.

When you open a Recordset, the first record is current and the BOF property is False. If the Recordset contains no records, the BOF property is True, and there is no current record.

If the first or last record is already current when you use MoveFirst or MoveLast, the current record doesn't change.

If recordset refers to a table-type Recordset (Microsoft Access workspaces only), movement follows the current index. You can set the current index by using the Index property. If you don't set the current index, the order of returned records is undefined.

You can't use the MoveFirst, MoveLast, and MovePrevious methods on a forward-only-type Recordset object.

To move the position of the current record in a Recordset object a specific number of records forward or backward, use the Move method.


Right Function (Access 2013 custom web app)

 Copy code hover
[image]

Right Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the right part of a character string with the specified number of characters.

Syntax

Right(TextExpression, Length)

The Right function contains the following arguments.

Argument name | Description
TextExpression | A text expression.
Length | Is a positive integer that specifies how many characters of the TextExpression are returned.


Invalid precision for decimal data type. (Error 3700)

 Copy code hover
[image]

Invalid precision for decimal data type. (Error 3700)
Send feedback

The precision and scale for a DECIMAL data type must be between 0 and 28. For example, the following SQL statement would return this error: CREATE TABLE foo (foo DECIMAL(38,0));


SubForm.LinkChildFields Property (Access)

 Copy code hover
[image]

SubForm.LinkChildFields Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the LinkChildFields property (along with the LinkMasterFields property) together to specify how Microsoft Access links records in a form or report to records in a subform, subreport, or embedded object, such as a chart. If these properties are set, Microsoft Access automatically updates the related record in the subform when you change to a new record in a main form. Read/write String.

Syntax

expression .LinkChildFields

expression A variable that represents a SubForm object.

Remarks

You can set the LinkChildFields and LinkMasterFields properties for the subform, subreport, or embedded object as follows:

  • The LinkChildFields property. Enter the name of one or more linking fields in the subform, subreport, or embedded object.

  • The LinkMasterFields property. Enter the name of one or more linking fields or controls in the main form or report.

You can use the Subform/Subreport Field Linker to set these properties by clicking the Build button to the right of the property box in the property sheet.

The properties can only be set in Design view or during the Open event of a form or report.

The fields or controls you use to set these properties don't need to have the same names, but they must contain the same kind of data and have the same or a compatible data type and field size. For example, an AutoNumber field is compatible with a Number field if the FieldSize property for the Number field is set to Long Integer.

You can use the name of a control (including the name of a calculated control) to set the LinkMasterFields property, but you can't use the name of a control to set the LinkChildFields property. If you want to use a calculated value as the link for a subform, subreport, or embedded object, define a calculated field in the child object's underlying query and set the LinkChildFields property to the field.

When you specify more than one field or control name for these property settings, you must enter the same number of fields or controls for each property setting and separate the names with a semicolon (;).

When you create a subform or subreport by dragging a form or report from the Database window onto another form or report or by using the Form Wizard, Microsoft Access automatically sets the LinkChildFields and LinkMasterFields properties under the following conditions:

  • Both the main form or report and the child object are based on tables, and a relationship between those tables has been defined with the Relationships command. Microsoft Access uses the fields that relate the two tables as the linking fields.

  • The main form or report is based on a table with a primary key, and the subform or subreport is based on a table or query that contains a field with the same name and the same or a compatible data type as the primary key. Microsoft Access uses the primary key from the main object's underlying table and the identically named field from the child object's underlying table or query as the linking fields.

Note Note

The linking fields don't have to be included in the main object or in the child object. As long as they are contained in the objects' underlying tables or queries, you can use the fields to link the objects. When you use a wizard, Microsoft Access automatically includes the linking fields.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


OptionButton.OnClick Property (Access)

 Copy code hover
[image]

OptionButton.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Syntax

expression .OnClick

expression A variable that represents an OptionButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


OptionButton.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

OptionButton.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified option button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleLeft

expression A variable that represents an OptionButton object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Application.Quit Method (Access)

 Copy code hover
[image]

Application.Quit Method (Access)
See also Send feedback

Published: July 16, 2012

The Quit method quits Microsoft Access. You can select one of several options for saving a database object before quitting.

Syntax

expression .Quit(Option)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Options | Optional | AcQuitOption | An AcQuitOption constant that indicates the action to take when quitting Access. The default value is acQuitSaveAll.

See also

Concepts

Application Object

Other resources

Application Object Members


UserDisplayName Function (Access 2013 custom web app)

 Copy code hover
[image]

UserDisplayName Function (Access 2013 custom web app)
Send feedback

Returns the display name of the current user.

Syntax

UserDisplayName()

Remarks

The UserDisplayName function is available only in user interface (UI) macros.


ListBox.LostFocus Event (Access)

 Copy code hover
[image]

ListBox.LostFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The LostFocus event occurs when the specified object loses the focus.

Syntax

expression .LostFocus

expression A variable that represents a ListBox object.

Remarks

To run a macro or event procedure when these events occur, set the OnLostFocus property to the name of the macro or to [Event Procedure].

This events occurs when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The LostFocus event differs from the Exit event in that the LostFocus event occurs every time a control loses the focus. The Exit event occurs only before a control loses the focus to another control on the same form. The LostFocus event occurs after the Exit event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


CustomControl.OnGotFocus Property (Access)

 Copy code hover
[image]

CustomControl.OnGotFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnGotFocus

expression A variable that represents a CustomControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The GotFocus event occurs when the object receives the focus.

The OnGotFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Got Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Got Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnGotFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnGotFocus

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


AcExportXMLSchemaFormat Enumeration (Access)

 Copy code hover
[image]

AcExportXMLSchemaFormat Enumeration (Access)
Send feedback

Published: July 16, 2012

Not supported in Microsoft Access 2013.

Name | Value | Description
acSchemaNone | 0 |
acSchemaXSD | 1 |


BookmarkEnum

 Copy code hover
[image]

BookmarkEnum
Send feedback

Specifies a bookmark indicating where the operation should begin.

Constant | Value | Description
adBookmarkCurrent | 0 | Starts at the current record.
adBookmarkFirst | 1 | Starts at the first record.
adBookmarkLast | 2 | Starts at the last record.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.Bookmark.CURRENT

AdoEnums.Bookmark.FIRST

AdoEnums.Bookmark.LAST


TextBox.BottomPadding Property (Access)

 Copy code hover
[image]

TextBox.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .BottomPadding

expression A variable that represents a TextBox object.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


NavigationButton.MouseMove Event (Access)

 Copy code hover
[image]

NavigationButton.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Version Information

Version Added: Access 2010

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents a NavigationButton object.

Parameters

Name | Required/Optional | Data Type | Description
Button | Required | Integer |
Shift | Required | Integer |
X | Required | Single |
Y | Required | Single |

Return Value

nothing

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MoueMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Handling Errors in Visual C++

 Copy code hover
[image]

Handling Errors in Visual C++
Send feedback

In COM, most operations return an HRESULT return code that indicates whether a function completed successfully. The #import directive generates wrapper code around each "raw" method or property and checks the returned HRESULT. If the HRESULT indicates failure, the wrapper code throws a COM error by calling _com_issue_errorex() with the HRESULT return code as an argument. COM error objects can be caught in a try-catch block. (For efficiency's sake, catch a reference to a _com_error object.)

Remember, these are ADO errors: they result from the ADO operation failing. Errors returned by the underlying provider appear as Error objects in the Connection object's Errors collection.

The #import directive only creates error-handling routines for methods and properties declared in the ADO .dll. However, you can take advantage of this same error-handling mechanism by writing your own error-checking macro or inline function. See the topic Visual C++ Extensions for examples.


Report.DefaultView Property (Access)

 Copy code hover
[image]

Report.DefaultView Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DefaultView property to specify the opening view of a report. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .DefaultView

expression A variable that represents a Report object.

Remarks

The DefaultView property uses the following settings.

Setting | Visual Basic | Description
Print Preview | 0 | Displays the report in Print Preview.
Report View | 1 | (Default) Displays the report in Report view.

See also

Concepts

Report Object

Other resources

Report Object Members


Database.CreateQueryDef Method (DAO)

 Copy code hover
[image]

Database.CreateQueryDef Method (DAO)
Send feedback

Creates a new QueryDef object.

Syntax

expression .CreateQueryDef(Name, SQLText)

expression A variable that represents a Database object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Optional | Variant | A Variant (String subtype) that uniquely names the new QueryDef.
SQLText | Optional | Variant | A Variant (String subtype) that is an SQL statement defining the QueryDef. If you omit this argument, you can define the QueryDef by setting its SQL property before or after you append it to a collection.

Return Value

QueryDef

Remarks

In a Microsoft Access workspace, if you provide anything other than a zero-length string for the name when you create a QueryDef, the resulting QueryDef object is automatically appended to the QueryDefs collection.

If the object specified by name is already a member of the QueryDefs collection, a run-time error occurs. You can create a temporary QueryDef by using a zero-length string for the name argument when you execute the CreateQueryDef method. You can also accomplish this by setting the Name property of a newly created QueryDef to a zero-length string (""). Temporary QueryDef objects are useful if you want to repeatedly use dynamic SQL statements without having to create any new permanent objects in the QueryDefs collection. You can't append a temporary QueryDef to any collection because a zero-length string isn't a valid name for a permanent QueryDef object. You can always set the Name and SQL properties of the newly created QueryDef object and subsequently append the QueryDef to the QueryDefs collection.

To run the SQL statement in a QueryDef object, use the Execute or OpenRecordset method.

Using a QueryDef object is the preferred way to perform SQL pass-through queries with ODBC databases.

To remove a QueryDef object from a QueryDefs collection in a Microsoft Access database engine database, use the Delete method on the collection.

Example

This example uses the CreateQueryDef method to create and execute both a temporary and a permanent QueryDef. The GetrstTemp function is required for this procedure to run.

VBA Copy code Copy code
Sub CreateQueryDefX()

   Dim dbsNorthwind As Database
   Dim qdfTemp As QueryDef
   Dim qdfNew As QueryDef

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   With dbsNorthwind
      ' Create temporary QueryDef.
      Set qdfTemp = .CreateQueryDef("", _
         "SELECT * FROM Employees")
      ' Open Recordset and print report.
      GetrstTemp qdfTemp
      ' Create permanent QueryDef.
      Set qdfNew = .CreateQueryDef("NewQueryDef", _
         "SELECT * FROM Categories")
      ' Open Recordset and print report.
      GetrstTemp qdfNew
      ' Delete new QueryDef because this is a demonstration.
      .QueryDefs.Delete qdfNew.Name
      .Close
   End With

End Sub

Function GetrstTemp(qdfTemp As QueryDef)

   Dim rstTemp As Recordset

   With qdfTemp
      Debug.Print .Name
      Debug.Print "  " & .SQL
      ' Open Recordset from QueryDef.
      Set rstTemp = .OpenRecordset(dbOpenSnapshot)

      With rstTemp
         ' Populate Recordset and print number of records.
         .MoveLast
         Debug.Print "  Number of records = " & _
            .RecordCount
         Debug.Print
         .Close
      End With

   End With

End Function

This example uses the CreateQueryDef and OpenRecordset methods and the SQL property to query the table of titles in the Microsoft SQL Server sample database Pubs and return the title and title identifier of the best-selling book. The example then queries the table of authors and instructs the user to send a bonus check to each author based on his or her royalty share (the total bonus is $1,000 and each author should receive a percentage of that amount).

VBA Copy code Copy code
Sub ClientServerX2()

   Dim dbsCurrent As Database
   Dim qdfBestSellers As QueryDef
   Dim qdfBonusEarners As QueryDef
   Dim rstTopSeller As Recordset
   Dim rstBonusRecipients As Recordset
   Dim strAuthorList As String

   ' Open a database from which QueryDef objects can be
   ' created.
   Set dbsCurrent = OpenDatabase("DB1.mdb")

   ' Create a temporary QueryDef object to retrieve
   ' data from a Microsoft SQL Server database.
   Set qdfBestSellers = dbsCurrent.CreateQueryDef("")
   With qdfBestSellers
      ' Note: The DSN referenced below must be configured to
      '       use Microsoft Windows NT Authentication Mode to
      '       authorize user access to the Microsoft SQL Server.
      .Connect = "ODBC;DATABASE=pubs;DSN=Publishers"
      .SQL = "SELECT title, title_id FROM titles " & _
         "ORDER BY ytd_sales DESC"
      Set rstTopSeller = .OpenRecordset()
      rstTopSeller.MoveFirst
   End With

   ' Create a temporary QueryDef to retrieve data from
   ' a Microsoft SQL Server database based on the results from
   ' the first query.
   Set qdfBonusEarners = dbsCurrent.CreateQueryDef("")
   With qdfBonusEarners
      ' Note: The DSN referenced below must be configured to
      '       use Microsoft Windows NT Authentication Mode to
      '       authorize user access to the Microsoft SQL Server.
      .Connect = "ODBC;DATABASE=pubs;DSN=Publishers"
      .SQL = "SELECT * FROM titleauthor " & _
         "WHERE title_id = '" & _
         rstTopSeller!title_id & "'"
      Set rstBonusRecipients = .OpenRecordset()
   End With

   ' Build the output string.
   With rstBonusRecipients
      Do While Not .EOF
         strAuthorList = strAuthorList & "  " & _
            !au_id & ":  $" & (10 * !royaltyper) & vbCr
         .MoveNext
      Loop
   End With

   ' Display results.
   MsgBox "Please send a check to the following " & _
      "authors in the amounts shown:" & vbCr & _
      strAuthorList & "for outstanding sales of " & _
      rstTopSeller!Title & "."

   rstTopSeller.Close
   dbsCurrent.Close

End Sub

The following example shows how to create a parameter query. A query named myQuery is created with two parameters, named Param1 and Param2. To do this, the SQL property of the query is set to a Structured Query Language (SQL) statement that defines the parameters.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Sub CreateQueryWithParameters()

    Dim dbs As DAO.Database
    Dim qdf As DAO.QueryDef
    Dim strSQL As String

    Set dbs = CurrentDb
    Set qdf = dbs.CreateQueryDef("myQuery")
    Application.RefreshDatabaseWindow

    strSQL = "PARAMETERS Param1 TEXT, Param2 INT; "
    strSQL = strSQL & "SELECT * FROM [Table1] "
    strSQL = strSQL & "WHERE [Field1] = [Param1] AND [Field2] = [Param2];"
    qdf.SQL = strSQL

    qdf.Close
    Set qdf = Nothing
    Set dbs = Nothing

End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


WSParameters.Parent Property (Access)

 Copy code hover
[image]

WSParameters.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Parent

expression A variable that represents a WSParameters object.

See also

Concepts

WSParameters Collection

Other resources

WSParameters Object Members


Invalid partner synchronizer. (Error 3741) (ADO Error)

 Copy code hover
[image]

Invalid partner synchronizer. (Error 3741) (ADO Error)
Send feedback

The synchronizer specified is not valid for this replica set or is not the hub synchronizer for a Local or Anonymous replica. You can only synchronize a Local or Anonymous replica with the Global hub replica that created it.


TabControl.HoverForeThemeColorIndex Property (Access)

 Copy code hover
[image]

TabControl.HoverForeThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverForeColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HoverForeThemeColorIndex

expression A variable that represents a TabControl object.

Remarks

The HoverForeThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 (Default) | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the HoverThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Application.PlainText Method (Access)

 Copy code hover
[image]

Application.PlainText Method (Access)
See also Send feedback

Published: July 16, 2012

Strips the rich text formatting from a string and returns an unformatted text string.

Version Information

Version Added: Access 2007

Syntax

expression .PlainText(RichText, Length)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
RichText | Required | Variant | The rich text string that you want to remove the formatting of.
Length | Optional | Variant | The number of character to return.

Return Value

String

See also

Concepts

Application Object

Other resources

Application Object Members


TextBox.Section Property (Access)

 Copy code hover
[image]

TextBox.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Syntax

expression .Section

expression A variable that represents a TextBox object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


AcSpreadSheetType Enumeration (Access)

 Copy code hover
[image]

AcSpreadSheetType Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the TransferSpreadsheet method to specify the type of spreadsheet to import from, export to, or link to.

Name | Value | Description
acSpreadsheetTypeExcel3 | 0 | Microsoft Excel 3.0 format
acSpreadsheetTypeExcel4 | 6 | Microsoft Excel 4.0 format
acSpreadsheetTypeExcel5 | 5 | Microsoft Excel 5.0 format
acSpreadsheetTypeExcel7 | 5 | Microsoft Excel 95 format
acSpreadsheetTypeExcel8 | 8 | Microsoft Excel 97 format
acSpreadsheetTypeExcel9 | 8 | Microsoft Excel 2000 format
acSpreadsheetTypeLotusWJ2 | 4 | Japanese version only
acSpreadsheetTypeLotusWK1 | 2 | Lotus 1-2-3 WK1 format
acSpreadsheetTypeLotusWK3 | 3 | Lotus 1-2-3 WK3 format
acSpreadsheetTypeLotusWK4 | 7 | Lotus 1-2-3 WK4 format


CustomControl.OldValue Property (Access)

 Copy code hover
[image]

CustomControl.OldValue Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.

Syntax

expression .OldValue

expression A variable that represents a CustomControl object.

Remarks

The OldValue property contains the unedited data from a bound control and is read-only in all views.

Microsoft Access uses the OldValue property to store the original value of a bound control. When you edit a bound control on a form, your changes aren't saved until you move to another record. The OldValue property contains the unedited version of the underlying data.

You can provide your own undo capability by assigning the OldValue property setting to a control. The following example shows how you can undo any changes to text box controls on a form:

VBA Copy code Copy code
Private Sub btnUndo_Click()

 Dim ctlTextbox As Control

 For Each ctlTextbox in Me.Controls
 If ctlTextbox.ControlType = acTextBox Then
 ctlTextbox.Value = ctl.OldValue
 End If
 Next ctlTextbox

End Sub

If the control hasn't been edited, this code has no effect. When you move to another record, the record source is updated, so the current value and the OldValue property will be the same.

The OldValue property setting has the same data type as the field to which the control is bound.

Example

The following example checks to determine if new data entered in a field is within 10 percent of the value of the original data. If the change is greater than 10 percent, the OldValue property is used to restore the original value. This procedure could be called from the BeforeUpdate event of the control that contains data you want to validate.

VBA Copy code Copy code
Public Sub Validate_Field()

 Dim curNewValue As Currency
 Dim curOriginalValue As Currency
 Dim curChange As Currency
 Dim strMsg As String

 curNewValue = Forms!Products!UnitPrice
 curOriginalValue = Forms!Products!UnitPrice.OldValue
 curChange = Abs(curNewValue - curOriginalValue)

 If curChange > (curOriginalValue * .1) Then
 strMsg = "Change is more than 10% of original unit price. " _
 & "Restoring original unit price."
 MsgBox strMsg, vbExclamation, "Invalid change."
 Forms!Products!UnitPrice = curOriginalValue
 End If

End Sub

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


ListBox.BorderTint Property (Access)

 Copy code hover
[image]

ListBox.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderTint

expression A variable that represents a ListBox object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Errors Collection (ADO)

 Copy code hover
[image]

Errors Collection (ADO)
Send feedback

Contains all the Error objects created in response to a single provider-related failure provider.

Remarks

Any operation involving ADO objects can generate one or more provider errors. As each error occurs, one or more Error objects can be placed in the Errors collection of the Connection object. When another ADO operation generates an error, the Errors collection is cleared, and the new set of Error objects can be placed in the Errors collection.

Each Error object represents a specific provider error, not an ADO error. ADO errors are exposed to the run-time exception-handling mechanism. For example, in Microsoft Visual Basic, the occurrence of an ADO-specific error will trigger an onError event and appear in the Err object.

ADO operations that don't generate an error have no effect on the Errors collection. Use the Clear method to manually clear the Errors collection.

The set of Error objects in the Errors collection describes all errors that occurred in response to a single statement. Enumerating the specific errors in the Errors collection enables your error-handling routines to more precisely determine the cause and origin of an error, and take appropriate steps to recover.

Some properties and methods return warnings that appear as Error objects in the Errors collection but do not halt a program's execution. Before you call the Resync, UpdateBatch, or CancelBatch methods on a Recordset object, the Open method on a Connection object, or set the Filter property on a Recordset object, call the Clear method on the Errors collection. That way you can read the Count property of the Errors collection to test for returned warnings.

Note Note

See the Error object topic for a more detailed explanation of the way a single ADO operation can generate multiple errors.


EmptyCell.GridlineStyleRight Property (Access)

 Copy code hover
[image]

EmptyCell.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleRight

expression A variable that represents an EmptyCell object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


Field2.ForeignName Property (DAO)

 Copy code hover
[image]

Field2.ForeignName Property (DAO)
Send feedback

Sets or returns a value that specifies the name of the Field2 object in a foreign table that corresponds to a field in a primary table for a relationship (Microsoft Access workspaces only).

Syntax

expression .ForeignName

expression A variable that represents a Field2 object.

Remarks

If the Relation object isn't appended to the Database, but the Field2 is appended to the Relation object, the ForeignName property is read/write. Once the Relation object is appended to the database, the ForeignName property is read-only.

Only a Field2 object that belongs to the Fields collection of a Relation object can support the ForeignName property.

The Name and ForeignName property settings for a Field2 object specify the names of the corresponding fields in the primary and foreign tables of a relationship. The Table and ForeignTable property settings for a Relation object determine the primary and foreign tables of a relationship.

For example, if you had a list of valid part codes (in a field named PartNo) stored in a ValidParts table, you could establish a relationship with an OrderItem table such that if a part code were entered into the OrderItem table, it would have to already exist in the ValidParts table. If the part code didn't exist in the ValidParts table and you had not set the Attributes property of the Relation object to dbRelationDontEnforce, a trappable error would occur.

In this case, the ValidParts table is the foreign table, so the ForeignTable property of the Relation object would be set to ValidParts and the Table property of the Relation object would be set to OrderItem. The Name and ForeignName properties of the Field2 object in the Relation object's Fields collection would be set to PartNo.

Example

This example shows how the Table, ForeignTable, and ForeignName properties define the terms of a Relation between two tables.

VBA Copy code Copy code
Sub ForeignNameX()

 Dim dbsNorthwind As Database
 Dim relLoop As Relation

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 Debug.Print "Relation"
 Debug.Print " Table - Field"
 Debug.Print " Primary (One) ";
 Debug.Print ".Table - .Fields(0).Name"
 Debug.Print " Foreign (Many) ";
 Debug.Print ".ForeignTable - .Fields(0).ForeignName"

 ' Enumerate the Relations collection of the Northwind
 ' database to report on the property values of
 ' the Relation objects and their Field objects.
 For Each relLoop In dbsNorthwind.Relations
 With relLoop
 Debug.Print
 Debug.Print .Name & " Relation"
 Debug.Print " Table - Field"
 Debug.Print " Primary (One) ";
 Debug.Print .Table & " - " & .Fields(0).Name
 Debug.Print " Foreign (Many) ";
 Debug.Print .ForeignTable & " - " & _
 .Fields(0).ForeignName
 End With
 Next relLoop

 dbsNorthwind.Close

End Sub


ComboBox.ColumnCount Property (Access)

 Copy code hover
[image]

ComboBox.ColumnCount Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnCount property to specify the number of columns displayed in a list box or in the list box portion of a combo box, or sent to OLE objects in a chart control or unbound object frame . Read/write Integer.

Syntax

expression .ColumnCount

expression A variable that represents a ComboBox object.

Remarks

The ColumnCount property holds an integer between 1 and the maximum number of fields in the table, query, or SQL statement, or the maximum number of values in the value list, specified in the RowSource property of the control.

For table fields , you can set this property on the Lookup tab in the Field Properties section of table Design view for fields with the DisplayControl property set to Combo Box or List Box.

For example, if you set the ColumnCount property for a list box on an Employees form to 3, one column can list last names, another can list first names, and the third can list employee ID numbers.

A combo box or list box can have multiple columns. If the control's RowSource property contains the name of a table, query, or SQL statement, a combo box or list box will display the fields from that source, from left to right, up to the number specified by the ColumnCount property.

To display a different combination of fields, create either a new query or a new SQL statement for the RowSource property, specifying the fields and the order you want.

If the RowSource property contains a list of values (the RowSourceType property is set to Value List), the values are put into the rows and columns of the combo box or list box in the order they are listed in the RowSource property. For example, if the RowSource property contains the list "Red; Green; Blue; Yellow" and the ColumnCount property is set to 2, the first row of the combo box or list box list will contain "Red" in the first column and "Green" in the second column. The second row will contain "Blue" in the first column and "Yellow" in the second column.

You can use the ColumnWidths property to set the width of the columns displayed in the control, or to hide columns.

Example

The following example uses the Column property and the ColumnCount property to print the values of a list box selection.

VBA Copy code Copy code
Public Sub Read_ListBox()

    Dim intNumColumns As Integer
    Dim intI As Integer
    Dim frmCust As Form

    Set frmCust = Forms!frmCustomers
    If frmCust!lstCustomerNames.ItemsSelected.Count > 0 Then

        ' Any selection?
        intNumColumns = frmCust!lstCustomerNames.ColumnCount
        Debug.Print "The list box contains "; intNumColumns; _
            IIf(intNumColumns = 1, " column", " columns"); _
             " of data."

        Debug.Print "The current selection contains:"
        For intI = 0 To intNumColumns - 1
            ' Print column data.
            Debug.Print frmCust!lstCustomerNames.Column(intI)
        Next intI
    Else
        Debug.Print "You haven't selected an entry in the " _
            & "list box."
    End If

    Set frmCust = Nothing

End Sub

The following example show how to create a combo box that is bound to one column while displaying another. Setting the ColumnCount property to 2 specifies that the cboDept combo box will display the first two columns of the data source specified by the RowSource property. Setting the BoundColumn property to 1 specifies that the value stored in the first column will be returned when you inspect the value of the combo box.

The ColumnWidths property specifies the width of the two columns. By setting the width of the first column to 0in., the first column is not displayed in the combo box.

Sample code provided by: MVP Contributor Bill Jelen, MrExcel.com | About the Contributors

Copy code Copy code
Private Sub cboDept_Enter()
    With cboDept
        .RowSource = "SELECT * FROM tblDepartments ORDER BY Department"
        .ColumnCount = 2
        .BoundColumn = 1
        .ColumnWidths = "0in.;1in."
    End With
End Sub

About the Contributors

Holy Macro! Books publishes entertaining books for people who use Microsoft Office. See the complete catalog at MrExcel.com.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Report.PopUp Property (Access)

 Copy code hover
[image]

Report.PopUp Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether a report opens as a pop-up window. Read/write Boolean.

Syntax

expression .PopUp

expression A variable that represents a Report object.

Remarks

The PopUp property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The report opens as a pop-up window. It remains on top of all other Microsoft Access windows.
No | False | (Default) The report isn't a pop-up window.

The PopUp property can be set only in Design view.

To specify the type of border you want on a pop-up window, use the BorderStyle property. You typically set the BorderStyle property to Thin for pop-up windows.

Setting the PopUp property to Yes makes the report a pop-up window only when you do one of the following:

  • Open it in Form view from the Database window.

  • Open it in Form view by using a macro or Visual Basic.

  • Switch from Design view to Form view.

See also

Concepts

Report Object

Other resources

Report Object Members


ComboBox.DblClick Event (Access)

 Copy code hover
[image]

ComboBox.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Syntax

expression .DblClick(Cancel)

expression A variable that represents a ComboBox object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the DblClick event occurs. Setting the Cancel argument to True (-1) cancels the DblClick event.

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


GoToRecord Macro Action

 Copy code hover
[image]

GoToRecord Macro Action
Send feedback

You can use the GoToRecord action to make the specified record the current record in an open table, form, or query result set.

Setting

The GoToRecord action has the following arguments.

Action argument

Description

Object Type

The type of object that contains the record you want to make current. Click Table, Query, Form, Server View, Stored Procedure, or Function in the Object Type box in the Action Arguments section of the Macro Builder pane. Leave this argument blank to select the active object.

Object Name

The name of the object that contains the record you want to make the current record. The Object Name box shows all objects in the current database of the type selected by the Object Type argument. If you leave the Object Type argument blank, leave this argument blank also.

Record

The record to make the current record. Click Previous, Next, First, Last, Go To, or New in the Record box. The default is Next.

Offset

An integer or expression that evaluates to an integer. An expression must be preceded by an equal sign (=). This argument specifies the record to make the current record. You can use the Offset argument in two ways:

  • When the Record argument is Next or Previous, Microsoft Office Access 2007 moves the number of records forward or backward specified in the Offset argument.

  • When the Record argument is Go To, Access moves to the record with the number equal to the Offset argument. The record number is shown in the record number box at the bottom of the window.

Note Note

If you use the First, Last, or New setting for the Record argument, Access ignores the Offset argument. If you enter an Offset argument that is too large, Access displays an error message. You can't enter negative numbers for the Offset argument.

  • When the Record argument is Next or Previous, Microsoft Office Access 2007 moves the number of records forward or backward specified in the Offset argument.

  • When the Record argument is Go To, Access moves to the record with the number equal to the Offset argument. The record number is shown in the record number box at the bottom of the window.

Remarks

If the focus is in a particular control in a record, this action leaves it in the same control for the new record.

You can use the New setting for the Record argument to move to the blank record at the end of a form or table so you can enter new data.

This action is similar to clicking the arrow below the Find button on the Home tab and then clicking Go To. The First, Last, Next, Previous, and New Record subcommands of the Go To command have the same effect on the selected object as the First, Last, Next, Previous, and New settings for the Record argument. You can also move to records by using the navigation buttons at the bottom of the window.

You can use the GoToRecord action to make a record on a hidden form the current record if you specify the hidden form in the Object Type and Object Name arguments.

To run the GoToRecord action in a Visual Basic for Applications (VBA) module, use the GoToRecord method of the DoCmd object.


Image.Left Property (Access)

 Copy code hover
[image]

Image.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Syntax

expression .Left

expression A variable that represents an Image object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

Image Object

Other resources

Image Object Members


Form Methods (Access)

 Copy code hover
[image]

Form Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
GoToPage | The GoToPage method moves the focus to the first control on a specified page in the active form.
Move | Moves the specified object to the coordinates specified by the argument values.
Recalc | The Recalc method immediately updates all calculated controls on a form.
Refresh | The Refresh method immediately updates the records in the underlying record source for a specified form or datasheet to reflect changes made to the data by you and other users in a multiuser environment.
Repaint | The Repaint method completes any pending screen updates for a specified form. When performed on a form, the Repaint method also completes any pending recalculations of the form's controls.
Requery | The Requery method updates the data underlying a specified form by requerying the source of data for the form.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
Undo | You can use the Undo method to reset a control or form when its value has been changed.


ReturnVars Properties (Access)

 Copy code hover
[image]

ReturnVars Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | Gets the number of ReturnVar objects in the ReturnVars collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only ReturnVar.
Parent | Returns the parent object for the specified object. Read-only Object.


Chapter 5: Updating and Persisting Data

 Copy code hover
[image]

Chapter 5: Updating and Persisting Data
Send feedback

The preceding chapters have discussed how to use ADO to get to data in a data source, how to move around in the data, and even how to edit the data. Of course, if the goal of your application is to allow users to make changes to the data, you will need to understand how to save those changes. You can either persist the Recordset changes to a file using the Save method, or you can send the changes back to the data source for storage using the Update or UpdateBatch methods.

In the preceding chapters, you changed the data in several rows of the Recordset. ADO supports two basic notions relating to the addition, deletion, and modification of rows of data.

The first notion is that changes aren't immediately made to the Recordset; instead, they are made to an internal copy buffer. If you decide you don't want the changes, the modifications in the copy buffer are discarded. If you decide to keep the changes, the changes in the copy buffer are applied to the Recordset.

The second notion is that changes are either propagated to the data source as soon as you declare the work on a row complete (that is, immediate mode), or all changes to a set of rows are collected until you declare the work for the set complete (that is, batch mode). The LockType property determines when the changes are made to the underlying data source. adLockOptimistic or adLockPessimistic specifies immediate mode, while adLockBatchOptimistic specifies batch mode. The CursorLocation property can affect which LockType settings are available. For instance, the adLockPessimistic setting is not supported if the CursorLocation property is set to adUseClient.

In immediate mode, each invocation of the Update method propagates the changes to the data source. In batch mode, each invocation of Update or movement of the current row position saves the changes to the copy buffer, but only the UpdateBatch method propagates the changes to the data source.


ToggleButton.Width Property (Access)

 Copy code hover
[image]

ToggleButton.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents a ToggleButton object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


OptionGroup.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

OptionGroup.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents an OptionGroup object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.BorderThemeColorIndex=2

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Operation Object (Access)

 Copy code hover
[image]

Operation Object (Access)
See also Send feedback

Published: July 16, 2012

Represents an operation defined for an Entity.

Version Information

Version Added: Access 2010

Remarks

Use the WSParameters property to return the parameters defined for the specified operation.

Use the Execute method to execute the operation.

See also

Concepts

Access Object Model Reference

Other resources

Operation Object Members


OptionButton.OldBorderStyle Property (Access)

 Copy code hover
[image]

OptionButton.OldBorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.

Syntax

expression .OldBorderStyle

expression A variable that represents an OptionButton object.

Remarks

The OldBorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines
Note Note

  • If the OldBorderStyle property is set to None or Dialog, the form doesn't have Maximize or Minimize buttons, regardless of its MinMaxButtons property setting.

  • If the OldBorderStyle property is set to None, the form doesn't have a Control menu, regardless of its ControlBox property setting.

  • The OldBorderStyle property setting doesn't affect the display of the scroll bars, navigation buttons, the record number box, or record selectors.

Example

The following example demonstrates the effect of changing a control's BorderStyle property, while leaving the OldBorderStyle unaffected. The example concludes with setting the BorderStyle property to its original unedited value.

VBA Copy code Copy code
With Forms("Order Entry").Controls("Zip Code") .BorderStyle = 3 ' Short dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 3, 1.

    .BorderStyle = 2 ' Dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 2, 1

    .BorderStyle = .OldBorderStyle ' Solid (default) border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 1, 1
End With

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Append and CreateParameter Methods Example (JScript)

 Copy code hover
[image]

Append and CreateParameter Methods Example (JScript)
Send feedback

This example uses the Append and CreateParameter methods to execute a stored procedure with an input parameter. Cut and paste the following code to Notepad or another text editor, and save it as AppendJS.asp.

Copy code Copy code

<!-- BeginAppendJS -->
<%@LANGUAGE="JScript" %>
<%// use this meta tag instead of adojavas.inc%>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->

<html>
<head>
 <title>Append and CreateParameter Methods Example (JScript)</title>
<style>
<!--
body {
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 BACKGROUND-COLOR:white;
 COLOR:black;
 }
-->
</style>
</head>

<body>
<h1>Append and CreateParameter Methods Example (JScript)</h1>
<%
 // verify user-input
 var iRoyalty = parseInt(Request.Form("RoyaltyValue"));
 if (iRoyalty > -1)
 {

 // connection, recordset and command variables
 var strCnxn = "Provider='sqloledb';Data Source=" + Request.ServerVariables("SERVER_NAME") + ";" +
 "Initial Catalog='pubs';Integrated Security='SSPI';";
 var Cnxn = Server.CreateObject("ADODB.Connection");
 var cmdByRoyalty = Server.CreateObject("ADODB.Command");
 var rsByRoyalty = Server.CreateObject("ADODB.Recordset");
 var rsAuthor = Server.CreateObject("ADODB.Recordset");
 // display variables
 var strMessage;

 try
 {
 // open connection and set cursor location
 Cnxn.Open(strCnxn);
 Cnxn.CursorLocation = adUseClient;

 // command object initial parameters
 cmdByRoyalty.CommandText = "byroyalty";
 cmdByRoyalty.CommandType = adCmdStoredProc;

 // create the new parameter and append to
 // the Command object's parameters collection
 var prmByRoyalty = cmdByRoyalty.CreateParameter("percentage", adInteger, adParamInput);
 cmdByRoyalty.Parameters.Append(prmByRoyalty);
 prmByRoyalty.Value = iRoyalty;

 cmdByRoyalty.ActiveConnection = Cnxn;

 // execute command
 rsByRoyalty = cmdByRoyalty.Execute();

 // display results
 rsAuthor.Open("Authors", Cnxn);

 while (!rsByRoyalty.EOF)
 {
 rsAuthor.Filter = "au_id='" + rsByRoyalty.Fields("au_id") + "'";

 // start new line
 strMessage = "<P>";

 // recordset data
 strMessage += rsAuthor.Fields("au_fname") + " ";
 strMessage += rsAuthor.Fields("au_lname") + " ";

 // end the line
 strMessage += "</P>";

 // show result
 Response.Write(strMessage);

 // et next record
 rsByRoyalty.MoveNext;
 }
 }
 catch (e)
 {
 Response.Write(e.message);
 }
 finally
 {
 // clean up
 if (rsByRoyalty.State == adStateOpen)
 rsByRoyalty.Close;
 if (rsAuthor.State == adStateOpen)
 rsAuthor.Close;
 if (Cnxn.State == adStateOpen)
 Cnxn.Close;
 rsByRoyalty = null;
 rsAuthor = null;
 Cnxn = null;
 }
 }
%>

<hr>

<form method="POST" action="AppendJS.asp" id=form1 name=form1>
 <p align="left">Enter royalty percentage to find (e.g., 40): <input type="text" name="RoyaltyValue" size="5"></p>
 <p align="left"><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
&nbsp;

</body>

</html>
<!-- EndAppendJS -->


Invalid bracketing of name

 Copy code hover
[image]

Invalid bracketing of name <name>. (Error 3126)
Send feedback

The specified name either cannot have brackets around it or the brackets are mismatched. Check your entry to make sure the brackets are properly matched, and then try the operation again.


Report.Moveable Property (Access)

 Copy code hover
[image]

Report.Moveable Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Boolean indicating whether the specified report can be moved by the user; True if it can be moved. Read/write.

Syntax

expression .Moveable

expression A variable that represents a Report object.

Remarks

You can use the Move method to programmatically move a form or report regardless of the value of the Moveable property.

Example

The following example determines whether or not the first form in the current project can be moved.

VBA Copy code Copy code
If Forms(0).Moveable Then
 MsgBox "You may move the form."
Else
 MsgBox "The form cannot be moved."
End If

See also

Concepts

Report Object

Other resources

Report Object Members


TextBox.OnKeyUp Property (Access)

 Copy code hover
[image]

TextBox.OnKeyUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Up box in the Properties window. Read/write String.

Syntax

expression .OnKeyUp

expression A variable that represents a TextBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyUp event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyUp

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


CommandButton.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

CommandButton.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleBottom

expression A variable that represents a CommandButton object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


SmartTagAction Object (Access)

 Copy code hover
[image]

SmartTagAction Object (Access)
See also Send feedback

Published: July 16, 2012

Represents a single action for a smart tag.

Remarks

Smart tag actions are processes that are programmed into smart tags that allow users to perform certain functions related to the smart tag. For example, one action for a smart tag might be to access a Web site, while another action inserts contact information from Microsoft Outlook, while yet another action displays a map and driving directions.

To perform an action represented by a SmartTagAction object, use the Execute method.

To return the parent control of the SmartTag object, use the Parent property.

See also

Concepts

Access Object Model Reference

Other resources

SmartTagAction Object Members


Rectangle.Width Property (Access)

 Copy code hover
[image]

Rectangle.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents a Rectangle object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


ObjectFrame.Click Event (Access)

 Copy code hover
[image]

ObjectFrame.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Syntax

expression .Click

expression A variable that represents an ObjectFrame object.

Remarks

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


AccessObject Members (Access)

 Copy code hover
[image]

AccessObject Members (Access)
Send feedback

Published: July 16, 2012

An AccessObject object refers to a particular Microsoft Access object.

Methods

Name | Description
GetDependencyInfo | Returns a DependencyInfo object that represents the database objects that are dependent upon the specified object.
IsDependentUpon | Returns a Boolean value that indicates whether the specified object is dependent upon the database object specified in the ObjectName argument.

Properties

Name | Description
CurrentView | Returns the current view for the specified Microsoft Access object. Read-only AcCurrentView.
DateCreated | Returns a Date indicating the date and time when the design of the specified object was last modified. Read-only.
DateModified | Returns a Date indicating the date and time when the design of the specified object was last modified. Read-only.
FullName | Sets or returns the full path (including file name) of a specific object. Read/write String.
IsLoaded | You can use the IsLoaded property to determine if an AccessObject is currently loaded. Read-only Boolean.
IsWeb | Gets whether the specified object is a Web object. Read-only Boolean.
Name | You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a AccessObject object's AccessObjectProperties collection. Read-only.
Type | Returns the value of an AccessObject object type. Read-only AcObjectType.


Chapter 13: RDS Usage and Security

 Copy code hover
[image]

Chapter 13: RDS Usage and Security
Send feedback

Use the information in this chapter to set up your server and use RDS quickly. This chapter includes specific configuration steps that you might need to take when implementing RDS, describes some of the key relationships between RDS and other technologies, and helps identify solutions to problems that you might encounter when setting up an RDS solution.

This section contains information about:

  • Configuring RDS

  • Using Related Technologies with RDS

  • DataFactory Customization

  • Troubleshooting RDS


JOIN (Microsoft Access SQL reserved word)

 Copy code hover
[image]

JOIN (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The JOIN keyword is used in these contexts:

INNER JOIN Operation

LEFT JOIN, RIGHT JOIN Operations


ADO Methods Reference

 Copy code hover
[image]

ADO Methods Reference
Send feedback

In this section

  • ADO Methods

  • AddNew Method (ADO)

  • Append Method (ADO)

  • AppendChunk Method (ADO)

  • BeginTrans, CommitTrans, and RollbackTrans Methods (ADO)

  • Cancel Method (ADO)

  • CancelBatch Method (ADO)

  • CancelUpdate Method (ADO)

  • Clear Method (ADO)

  • Clone Method (ADO)

  • Close Method (ADO)

  • CompareBookmarks Method (ADO)

  • CopyRecord Method (ADO)

  • CopyTo Method (ADO)

  • CreateParameter Method (ADO)

  • Delete Method (ADO Fields Collection)

  • Delete Method (ADO Parameters Collection)

  • Delete Method (ADO Recordset)

  • DeleteRecord Method (ADO)

  • Find Method (ADO)

  • Flush Method (ADO)

  • GetChildren Method (ADO)

  • GetChunk Method (ADO)

  • GetRows Method (ADO)

  • GetString Method (ADO)

  • LoadFromFile Method (ADO)

  • Move Method (ADO)

  • MoveFirst, MoveLast, MoveNext, and MovePrevious Methods (ADO)

  • MoveRecord Method (ADO)

  • NextRecordset Method (ADO)

  • Open Method (ADO Connection)

  • Open Method (ADO Record)

  • Open Method (ADO Recordset)

  • Open Method (ADO Stream)

  • OpenSchema Method (ADO)

  • Read Method (ADO)

  • ReadText Method (ADO)

  • Refresh Method (ADO)

  • Requery Method (ADO)

  • Resync Method (ADO)

  • Save Method (ADO)

  • SaveToFile Method (ADO)

  • Seek Method (ADO)

  • SetEOS Method (ADO)

  • SkipLine Method (ADO)

  • Stat Method (ADO)

  • Supports Method (ADO)

  • Update Method (ADO)

  • UpdateBatch Method (ADO)

  • Write Method (ADO)

  • WriteText Method (ADO)


AcPrintRange Enumeration (Access)

 Copy code hover
[image]

AcPrintRange Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the PrintOut method to specify the range to print.

Name | Value | Description
acPages | 2 | A specific range of pages will be printed. Use the PageFrom and PageTo arguments to specify the range of pages to print.
acPrintAll | 0 | Prints all of the object.
acSelection | 1 | Prints the selected part of the object.


Printer.RowSpacing Property (Access)

 Copy code hover
[image]

Printer.RowSpacing Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Long indicating the horizontal space between detail sections in twips. Read/write.

Syntax

expression .RowSpacing

expression A variable that represents a Printer object.

Example

The following example sets a variety of printer settings for the form specified in the strFormname argument of the procedure.

VBA Copy code Copy code
Sub SetPrinter(strFormname As String)

 DoCmd.OpenForm FormName:=strFormname, view:=acDesign, _
 datamode:=acFormEdit, windowmode:=acHidden

 With Forms(form1).Printer

 .TopMargin = 1440
 .BottomMargin = 1440
 .LeftMargin = 1440
 .RightMargin = 1440

 .ColumnSpacing = 360
  .RowSpacing = 360

 .ColorMode = acPRCMColor
 .DataOnly = False
 .DefaultSize = False
 .ItemSizeHeight = 2880
 .ItemSizeWidth = 2880
 .ItemLayout = acPRVerticalColumnLayout
 .ItemsAcross = 6

 .Copies = 1
 .Orientation = acPRORLandscape
 .Duplex = acPRDPVertical
 .PaperBin = acPRBNAuto
 .PaperSize = acPRPSLetter
 .PrintQuality = acPRPQMedium

 End With

 DoCmd.Close objecttype:=acForm, objectname:=strFormname, _
 Save:=acSaveYes

End Sub

See also

Concepts

Printer Object

Other resources

Printer Object Members


JScript

 Copy code hover
[image]

JScript
Send feedback

Microsoft JScript does not support ADO events.


ALTER TABLE Statement (Microsoft Access SQL)

 Copy code hover
[image]

ALTER TABLE Statement (Microsoft Access SQL)
Send feedback

Modifies the design of a table after it has been created with the CREATE TABLE statement.

Note Note

The Microsoft Access database engine does not support the use of ALTER TABLE, or any of the data definition language (DDL) statements, with non-Microsoft Access databases. Use the DAO Create methods instead.

Syntax

ALTER TABLE table {ADD {COLUMN field type[(size)] [NOT NULL] [CONSTRAINT index] | ALTER COLUMN field type[(size)] | CONSTRAINT multifieldindex} | DROP {COLUMN field I CONSTRAINT indexname} }

The ALTER TABLE statement has these parts:

Part | Description
table | The name of the table to be altered.
field | The name of the field to be added to or deleted from table. Or, the name of the field to be altered in table.
type | The data type of field.
size | The field size in characters (Text and Binary fields only).
index | The index for field. For more information on how to construct this index see CONSTRAINT Clause.
multifieldindex | The definition of a multiple-field index to be added to table. For more information on how to construct this index see CONSTRAINT Clause.
indexname | The name of the multiple-field index to be removed.

Remarks

Using the ALTER TABLE statement you can alter an existing table in several ways. You can:

  • Use ADD COLUMN to add a new field to the table. You specify the field name, data type, and (for Text and Binary fields) an optional size. For example, the following statement adds a 25-character Text field called Notes to the Employees table:

    SQL Copy code Copy code
    ALTER TABLE Employees ADD COLUMN Notes TEXT(25)

    You can also define an index on that field. For more information on single-field indexes see CONSTRAINT Clause.

    If you specify NOT NULL for a field then new records are required to have valid data in that field.

  • Use ALTER COLUMN to change the data type of an existing field. You specify the field name, the new data type, and an optional size for Text and Binary fields. For example, the following statement changes the data type of a field in the Employees table called ZipCode (originally defined as Integer) to a 10-character Text field:

    SQL Copy code Copy code
    ALTER TABLE Employees ALTER COLUMN ZipCode TEXT(10)

  • Use ADD CONSTRAINT to add a multiple-field index. For more information on multiple-field indexes see CONSTRAINT Clause.

  • Use DROP COLUMN to delete a field. You specify only the name of the field.

  • Use DROP CONSTRAINT to delete a multiple-field index. You specify only the index name following the CONSTRAINT reserved word.

Note Note

  • You cannot add or delete more than one field or index at a time.

  • You can use the CREATE INDEX statement to add a single- or multiple-field index to a table, and you can use ALTER TABLE or the DROP statement to delete an index created with ALTER TABLE or CREATE INDEX.

  • You can use NOT NULL on a single field or within a named CONSTRAINT clause that applies to either a single field or to a multiple-field named CONSTRAINT. However, you can apply the NOT NULL restriction only once to a field. Attempting to apply this restriction more than once restuls in a run-time error.

Example

This example adds a Salary field with the data type Money to the Employees table.

VBA Copy code Copy code
Sub AlterTableX1()

    Dim dbs As Database

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Add the Salary field to the Employees table
    ' and make it a Money data type.
    dbs.Execute "ALTER TABLE Employees " _
        & "ADD COLUMN Salary MONEY;"

    dbs.Close

End Sub

This example changes the Salary field from the data type Money to the data type Char.

VBA Copy code Copy code
Sub AlterTableX2()

    Dim dbs As Database

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Add the Salary field to the Employees table
    ' and make it a Money data type.
    dbs.Execute "ALTER TABLE Employees " _
        & "ALTER COLUMN Salary CHAR(20);"

    dbs.Close

End Sub

This example removes the Salary field from the Employees table.

VBA Copy code Copy code
Sub AlterTableX3()

    Dim dbs As Database

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Delete the Salary field from the Employees table.
    dbs.Execute "ALTER TABLE Employees " _
        & "DROP COLUMN Salary;"

    dbs.Close

End Sub

This example adds a foreign key to the Orders table. The foreign key is based on the EmployeeID field and refers to the EmployeeID field of the Employees table. In this example, you do not have to list the EmployeeID field after the Employees table in the REFERENCES clause because EmployeeID is the primary key of the Employees table.

VBA Copy code Copy code
Sub AlterTableX4()

    Dim dbs As Database

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Add a foreign key to the Orders table.
    dbs.Execute "ALTER TABLE Orders " _
        & "ADD CONSTRAINT OrdersRelationship " _
        & "FOREIGN KEY (EmployeeID) " _
        & "REFERENCES Employees (EmployeeID);"

    dbs.Close

End Sub

This example removes the foreign key from the Orders table.

VBA Copy code Copy code
Sub AlterTableX5()

    Dim dbs As Database

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Remove the OrdersRelationship foreign key from
    ' the Orders table.
    dbs.Execute "ALTER TABLE Orders " _
        & "DROP CONSTRAINT OrdersRelationship;"

    dbs.Close

End Sub


Container Properties (DAO)

 Copy code hover
[image]

Container Properties (DAO)
Send feedback

In this section

  • Container.Documents Property (DAO)

  • Container.Name Property (DAO)

  • Container.Properties Property (DAO)


BoundObjectFrame.OnLostFocus Property (Access)

 Copy code hover
[image]

BoundObjectFrame.OnLostFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnLostFocus

expression A variable that represents a BoundObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The LostFocus event occurs when the object loses the focus.

The OnLostFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Lost Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Lost Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnLostFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnLostFocus

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


SetOrderBy Macro Action

 Copy code hover
[image]

SetOrderBy Macro Action
Send feedback

You can use the SetOrderBy action to specify how you want to sort records in a form, report, table, or query result.

Setting

The SetOrderBy action has the following arguments.

Action argument | Description
Order By | A string expression that includes the name of the field or fields on which to sort records and the optional ASC or DESC keywords.
Control Name | If provided and the active object is a form or report, the name of the control that corresponds to the subform or subreport that will be sorted. If empty and the active object is a form or report, the parent form or report is sorted..

Remarks

When you run this macro action, the sort is applied to the table, form, report or datasheet (query result) that is active and has the focus.

The Order By argument is the name of the field or fields on which you want to sort records. When you use more than one field name, separate the names with a comma (,). The OrderBy property of the active object is used to save the ordering value and apply it at a later time. OrderBy values are saved with the objects in which they are created. They are automatically loaded when the object is opened, but they aren't automatically applied.

When you set the Order By argument by entering one or more field names and then run the macro, the records are sorted by default in ascending order.

To sort records in descending order, type DESC at the end of the Order By argument expression. For example, to sort customer records in descending order by contact name, set the Order By argument to "ContactName DESC". To sort names by LastName descending, and FirstName ascending, set the Order By argument to "LastName DESC, FirstName ASC".


Absolute and Relative URLs

 Copy code hover
[image]

Absolute and Relative URLs
Send feedback

A URL specifies the location of a target stored on a local or networked computer, such as a file, directory, HTML page, image, program, and so on. In this discussion, an absolute URL is of the form:

scheme://server/path/resource

where:

  • scheme

  • Specifies how the resource is to be accessed.

  • server

  • Specifies the name of the computer where the resource is located.

  • path

  • Specifies the sequence of directories leading to the target. If resource is omitted, the target is the last directory in path.

  • resource

  • If included, resource is the target, and is typically the name of a file. It may be a simple file, containing a single binary stream of bytes, or a structured document, containing one or more storages and binary streams of bytes.

An absolute URL contains all the information necessary to locate a resource.

A relative URL locates a resource using an absolute URL as a starting point. In effect, the "complete URL" of the target is specified by concatenating the absolute and relative URLs. A relative URL typically consists only of the path, and optionally, the resource, but no scheme or server.

URL Scheme Registration

If a provider supports URLs, it will register for one or more URL schemes. This means that any URLs using this scheme will automatically invoke the registered provider. For example, the http scheme is registered to the Microsoft OLE DB Provider for Internet Publishing. ADO assumes all URLs prefixed with "http" represent Web folders or files to be used with the Internet Publishing Provider. For information about the schemes registered by your provider, see your provider documentation.

Defining Context with a URL

One function of an open connection, represented by a Connection object, is to restrict subsequent operations to the data source represented by that connection. That is, the connection defines the context for subsequent operations.

With ADO 2.5, an absolute URL may also define a context. For example, when a Record object is opened with an absolute URL, a Connection object is implicitly created to represent the resource specified by the URL.

An absolute URL that defines a context may be specified in the ActiveConnection parameter of the Record object Open method. An absolute URL may also be specified as the value of the new "URL=" keyword in the Connection object Open method ConnectionString parameter, and the Recordset object Open method ActiveConnection parameter.

Context may also be defined with an open Record or Recordset object that represents a directory because these objects already have an implicitly or explicitly declared Connection object that specifies context.

Scoped Operations

The context simultaneously defines a scope — that is, the directory and its subdirectories that may participate in subsequent operations. The Record object has several scoped methods, including CopyRecord, MoveRecord, and DeleteRecord, that operate on a directory and all its subdirectories.

Relative URLs as Command Text

A string specifying a command to be executed on the data source may be specified in the Connection object Execute method CommandText parameter, and the Recordset object Open method Source parameter.

A relative URL may be specified in the CommandText or Source parameter. The relative URL does not actually specify a command (such as an SQL command); it is merely specified in those parameters. In addition, the context of the active connection must be an absolute URL, and the Option parameter must be set to adCmdTableDirect.

For example, a Recordset could be opened on the Readme25.txt file of the Winnt/system32 directory like this:

Copy code Copy code

recordset.Open "system32/Readme25.txt", "URL=http://YourServer/Winnt/",,,adCmdTableDirect

The absolute URL in the connection string specifies the server (YourServer ) and the path () and the path (Winnt ). This URL also defines the context.

The relative URL in the command text uses the absolute URL as a starting point and specifies the remainder of the path (system32 ) and the file to open () and the file to open (Readme25.txt ).

The options field () indicates that the command type is a relative URL.

As another example, the following code will open a Recordset on the contents of the directory:

Copy code Copy code

recordset.Open "", "URL=http://YourServer/Winnt/",,,adCmdTableDirect

OLE DB Provider-Supplied URL Schemes

The leading part of a fully-qualified URL is the scheme used to access the resource identified by the remainder of the URL. Examples are HTTP (HyperText Transfer Protocol) and FTP (File Transfer Protocol).

ADO supports OLE DB providers that recognize their own URL schemes. For example, the Microsoft OLE DB Provider for Internet Publishing , which accesses "published" Windows 2000 files, recognizes the existing HTTP scheme.


ListBox.LabelY Property (Access)

 Copy code hover
[image]

ListBox.LabelY Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelY

expression A variable that represents a ListBox object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


ComboBox.EventProcPrefix Property (Access)

 Copy code hover
[image]

ComboBox.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents a ComboBox object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ComboBox.HideDuplicates Property (Access)

 Copy code hover
[image]

ComboBox.HideDuplicates Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.

Syntax

expression .HideDuplicates

expression A variable that represents a ComboBox object.

Remarks

The HideDuplicates property applies only to controls (check box, combo box, list box, option button, option group, text box, toggle button) on a report.

The HideDuplicates property uses the following settings.

Setting | Description
True | If the value of a control or the data it contains is the same as in the preceding record, the control is hidden.
False | (Default) The control is visible regardless of the value in the preceding record.

You can set the HideDuplicates property only in report Design view.

You can use the HideDuplicates property to create a grouped report by using only the detail section rather than a group header and the detail section.

Example

The following example returns the HideDuplicates property setting for the CategoryName text box and assigns the value to the intCurVal variable.

VBA Copy code Copy code
Dim intCurVal As Integer
intCurVal = Me!CategoryName.HideDuplicates

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


SmartTags Object (Access)

 Copy code hover
[image]

SmartTags Object (Access)
See also Send feedback

Published: July 16, 2012

Represents the collection of smart tags for a control on a form, report, or data access page.

Remarks

To return a single SmartTag object, use the Item method or use SmartTags(Index), where Index represents the number of the smart tag.

Note Note

Unlike the SmartTags collections in Microsoft Excel and Microsoft Word, the SmartTags collection in Microsoft Access is zero-based. Therefore, the code control.SmartTags(0) returns the first smart tag for the specified control.

See also

Concepts

Access Object Model Reference

Other resources

SmartTags Object Members


MaximizeWindow Macro Action

 Copy code hover
[image]

MaximizeWindow Macro Action
Send feedback

If Microsoft Access 2013 is configured to use overlapping windows instead of tabbed documents, you can use the MaximizeWindow action to enlarge the active window so that it fills the Access window. This action will allow you to see as much of the object in the active window as possible.

Note Note

This action can't be applied to code windows in the Visual Basic Editor. For information about how to affect code windows, see the WindowState property topic.

Setting

The MaximizeWindow action doesn't have any arguments.

Remarks

This action has the same effect as clicking the Maximize button in the window's upper-right corner or clicking Maximize on the window's Control menu.

You can use the RestoreWindow action to restore a maximized window to its previous size.

Tips

  • You may need to use the SelectObject action if the window you want to maximize isn't the active window.

  • When you maximize a window in Access, all other windows are also maximized when you open them or switch to them. However, pop-up forms aren't maximized. If you want a form to maintain its size when other windows are maximized, set its PopUp property to Yes.

To run the MaximizeWindow action in a Visual Basic for Applications module, use the Maximize method of the DoCmd object.


ADCPROP_AUTORECALC_ENUM

 Copy code hover
[image]

ADCPROP_AUTORECALC_ENUM
Send feedback

Specifies when the MSDataShape provider re-calculates aggregate and calculated columns in a hierarchical Recordset.

These constants are only used with the MSDataShape provider and the Recordset "Auto Recalc" dynamic property, which is referenced in the ADO Dynamic Property Index and documented in the Microsoft Cursor Service for OLE DB or Microsoft Data Shaping Service for OLE DB documentation.

Constant | Value | Description
adRecalcAlways | 1 | Default. Recalculates whenever the MSDataShape provider determines values that the calculated columns depend upon have changed.
adRecalcUpFront | 0 | Calculates only when initially building the hierarchical Recordset.

ADO/WFC Equivalent

These constants do not have ADO/WFC equivalents.


OptionButton.Value Property (Access)

 Copy code hover
[image]

OptionButton.Value Property (Access)
See also Send feedback

Published: July 16, 2012

Determines or specifies whether or not the specified option button is selected. Read/write Variant.

Syntax

expression .Value

expression A variable that represents an OptionButton object.

Remarks

Set to True to select the option button. The default value is False.

The Value property returns or sets a control's default property, which is the property that is assumed when you don't explicitly specify a property name.

Note Note

The Value property is not the same as the DefaultValue property, which specifies the value that a property is assigned when a new record is created.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


ToggleButton.EventProcPrefix Property (Access)

 Copy code hover
[image]

ToggleButton.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents a ToggleButton object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Form.SplitFormSplitterBar Property (Access)

 Copy code hover
[image]

Form.SplitFormSplitterBar Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the splitter bar is available when the form is displayed in Split Form mode. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .SplitFormSplitterBar

expression A variable that represents a Form object.

See also

Concepts

Form Object

Other resources

Form Object Members


Using ADO with Microsoft Visual C++

 Copy code hover
[image]

Using ADO with Microsoft Visual C++
Send feedback

For information about using ADO with Visual C++, see the following sections:

  • Visual C++ ADO Programming

  • Visual C++ Extensions for ADO

  • ADO for Visual C++ Syntax Index for COM

  • ADO for Visual C++ Syntax Index with #import


Printers Properties (Access)

 Copy code hover
[image]

Printers Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Printer.
Parent | Returns the parent object for the specified object. Read-only.


Initializing the Paradox Database Driver

 Copy code hover
[image]

Initializing the Paradox Database Driver
Send feedback

When you install the Paradox database driver, the Setup program writes a set of default values to the Microsoft® Windows® Registry in the Engines and ISAM Formats subkeys. You should not modify these settings directly (unless necessary); use the setup program for your application to add, remove, or change these settings. The following sections describe initialization and ISAM Format settings for the Paradox database driver.

The Paradox database driver will work in one of two modes, depending upon whether the Borland Database Engine (BDE) is installed. Paradox data is only updateable with the BDE. Without the BDE, the Paradox data can be Read, Exported, or Linked to read-only.

Paradox Initialization Settings

The Access Connectivity Engine\Engines\Paradox folder includes initialization settings for the Acepde.dll driver, used for access to external Paradox data. Typical settings for the entries in this folder are shown in the following example.

Copy code Copy code
win32=<path>\ ACEPDE.DLL

PageTimeout=600

CollatingSequence=ASCII

DataCodePage=OEM

ParadoxUserName=Kimberly

ParadoxNetPath=P:\PDOXDB

The Microsoft Access database engine uses the Paradox folder entries as follows.

Entry

Description

win32

The location of mspbde40.dll. The full path is determined at the time of installation. Values are of type REG_SZ.

PageTimeout

The length of time between when data is placed in an internal cache and when it is invalidated. The value is specified in 100 millisecond units. The default is 600 units or 60 seconds. Values are of type REG_DWORD.

CollatingSequence

This setting is only used if the BDE is not present on the machine. The collating sequence for all Paradox tables created or opened using the Microsoft Access database engine. Possible values are ASCII, International, Norwegian-Danish, and Swedish-Finnish. The CollatingSequence entry must match the collating sequence used when the Paradox table was built. The default is ASCII. Values are of type REG_SZ.

DataCodePage

This setting is only used if the BDE is not present on the machine. An indicator of how text pages are stored. Possible settings are:

  • OEM — OemToAnsi and AnsiToOem conversions done.

  • ANS — OemToAnsi and AnsiToOem conversions not done.

The default is OEM. Values are of type REG_SZ.

ParadoxUserName

The name to be displayed by Paradox if a table is locked by the Paradox ISAM and an interactive user accessing the data from Paradox (rather than the ISAM) attempts to place an incompatible lock. This entry is not added by the setup program. You must create this entry. Values are of type REG_SZ.

Note Note

If you indicate a ParadoxUserName, you must also specify a ParadoxNetPath and a ParadoxNetStyle or you will receive an error when trying to access external Paradox data. Also, if you are accessing a Paradox database in multi-user mode over the network, you will need to add or modify this registry entry manually.

ParadoxNetPath

The full path to the directory containing the PARADOX.NET file (for Paradox 3.x) or the PDOXUSRS.NET file (for Paradox 4.x). This entry is not added by the setup program. You must create this entry. The full ParadoxNetPath (including the drive letter) must be consistent for all users sharing a particular database (directory). Values are of type REG_SZ.

Note Note

If you indicate a ParadoxNetPath, you must also specify a ParadoxUserName and a ParadoxNetStyle or you will receive an error when trying to access external Paradox data. Also, if you are accessing a Paradox database in multi-user mode over the network, you will need to add or modify this registry entry manually.

ParadoxNetStyle

The network access style to use when accessing Paradox data. Possible values are:

  • 3.x

  • 4.x

Note Note

Paradox 3.x users cannot set this to 4.x or the driver will use the wrong locking method. Paradox 5.0 users must use the 4.x ParadoxNetStyle setting to ensure proper locking behavior.

This entry is not added by the setup program. You must create this entry. This entry should correspond to whatever version of Paradox the users in the group are using. It must be consistent for all users sharing a particular database (directory). The default is 4.x. Values are of type REG_SZ.

Note Note

If you indicate a ParadoxNetStyle, you must also specify a ParadoxUserName and a ParadoxNetPath or you will receive an error when trying to access external Paradox data.

Paradox ISAM Formats

The Access Connectivity Engine\ISAM Formats\Paradox 3.X folder contains the following entries.

Entry name | Type | Value
Engine | REG_SZ | Paradox
ExportFilter | REG_SZ | Paradox 3 (*.db)
ImportFilter | REG_SZ | Paradox (*.db)
CanLink | REG_BINARY | 01
OneTablePerFile | REG_BINARY | 01
IsamType | REG_DWORD | 0
IndexDialog | REG_BINARY | 00
CreateDBOnExport | REG_BINARY | 00
ResultTextImport | REG_SZ | Import data from the external file into the current database. Changing data in the current database will not change data in the external file.
ResultTextLink | REG_SZ | Create a table in the current database that is linked to the external file. Changing data in the current database will change data in the external file.
ResultTextExport | REG_SZ | Export data from the current database into a Paradox 3 file. This process will overwrite the data if exported to an existing file.
SupportsLongNames | REG_BINARY | 00

The Access Connectivity Engine\ISAM Formats\Paradox 4.X folder contains the following entries.

Entry name | Type | Value
Engine | REG_SZ | Paradox
ExportFilter | REG_SZ | Paradox 4 (*.db)
CanLink | REG_BINARY | 01
OneTablePerFile | REG_BINARY | 01
IsamType | REG_DWORD | 0
IndexDialog | REG_BINARY | 00
CreateDBOnExport | REG_BINARY | 00
ResultTextExport | REG_SZ | Export data from the current database into a Paradox 4 file. This process will overwrite the data if exported to an existing file.
SupportsLongNames | REG_BINARY | 00

The Access Connectivity Engine\ISAM Formats\Paradox 5.X folder contains the following entries.

Entry name | Type | Value
Engine | REG_SZ | Paradox
ExportFilter | REG_SZ | Paradox 5 (*.db)
CanLink | REG_BINARY | 01
OneTablePerFile | REG_BINARY | 01
IsamType | REG_DWORD | 0
IndexDialog | REG_BINARY | 00
CreateDBOnExport | REG_BINARY | 00
ResultTextExport | REG_SZ | Export data from the current database into a Paradox 5 file. This process will overwrite the data if exported to an existing file.
SupportsLongNames | REG_BINARY | 00

The Access Connectivity Engine\ISAM Formats\Paradox 7.X folder contains the following entries.

Entry name | Type | Value
Engine | REG_SZ | Paradox
ExportFilter | REG_SZ | Paradox 7 (*.db)
CanLink | REG_BINARY | 01
OneTablePerFile | REG_BINARY | 01
IsamType | REG_DWORD | 0
IndexDialog | REG_BINARY | 00
CreateDBOnExport | REG_BINARY | 00
ResultTextExport | REG_SZ | Export data from the current database into a Paradox 7 file. This process will overwrite the data if exported to an existing file.
SupportsLongNames | REG_BINARY | 00
Note Note

When you change Windows Registry settings, you must exit and then restart the database engine for the new settings to take effect.


ObjectFrame.BackTint Property (Access)

 Copy code hover
[image]

ObjectFrame.BackTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackTint

expression A variable that represents an ObjectFrame object.

Remarks

The BackTint property contains a numeric expression that can be used to lighten the theme color in the BackColor property. The default value of the BackTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens BackColor by 75%.

VBA Copy code Copy code
Me.ctl.BackTint=25

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


ListBox.BottomPadding Property (Access)

 Copy code hover
[image]

ListBox.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .BottomPadding

expression A variable that represents a ListBox object.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


The Synchronizer or Replication Manager could not find the system object. (Error 3527)

 Copy code hover
[image]

The Synchronizer or Replication Manager could not find the system object. (Error 3527)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction Properties Example (VJ++)

 Copy code hover
[image]

ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction Properties Example (VJ++)
Send feedback

This example uses the ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction properties to execute a stored procedure.

Copy code Copy code

// BeginActiveConnectionJ
import com.ms.wfc.data.*;
import java.io.*;

public class ActiveConnectionX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 ActiveConnectionX();
 System.exit(0);
 }

 //.ActiveConnectionX function

 static void ActiveConnectionX()
 {
 // Define ADO Objects.
 Connection cnConn1 = null;
 Command cmdByRoyalty = null;
 Parameter prmByRoyalty = null;
 Recordset rstByRoyalty = null;
 Recordset rstAuthors = null;

 //Declarations.
 String strCnn;
 String strAuthorID;
 String strFName;
 String strLName;
 int intRoyalty ;
 BufferedReader in = new BufferedReader
 (new InputStreamReader (System.in));
 String line = null;

 try
 {
 // Open a connection.

 strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";
 cnConn1 = new Connection();
 cnConn1.open(strCnn,"","",AdoEnums.CommandType.UNSPECIFIED);

 // Define a command object for stored procedure.
 cmdByRoyalty = new Command();
 cmdByRoyalty.setActiveConnection(cnConn1);
 cmdByRoyalty.setCommandText("byRoyalty");
 cmdByRoyalty.setCommandType(AdoEnums.CommandType.STOREDPROC);
 cmdByRoyalty.setCommandTimeout(15);

 //Define the stored procedure's input parameter.
 System.out.println ("\nEnter Royalty : ");
 line = in.readLine().trim();
 intRoyalty = Integer.parseInt(line);
 prmByRoyalty = new Parameter ();
 prmByRoyalty.setType(AdoEnums.DataType.INTEGER);
 prmByRoyalty.setSize(3);
 prmByRoyalty.setDirection(AdoEnums.ParameterDirection.INPUT);
 prmByRoyalty.setValue(new Integer(intRoyalty));
 cmdByRoyalty.getParameters().append(prmByRoyalty);

 // Create a recordset by executing the command.

 rstByRoyalty = cmdByRoyalty.execute();

 // Open the Authors table to get author names for display.
 rstAuthors = new Recordset ();
 rstAuthors.open("authors",strCnn,
 AdoEnums.CursorType.FORWARDONLY,
 AdoEnums.LockType.READONLY ,AdoEnums.CommandType.TABLE );

 // Print current data in the recordset,
 // adding author names from Authors table.
 System.out.println("\nAuthors with " + intRoyalty +
 " percent royalty");
 while (!rstByRoyalty.getEOF())
 {
 strAuthorID = rstByRoyalty.getField("au_id").getString();
 rstAuthors.setFilter("au_id ='" + strAuthorID + "'");
 strFName = rstAuthors.getField("au_fname").getString();
 strLName = rstAuthors.getField("au_lname").getString();
 System.out.println("\t" + strAuthorID + ", " + strFName
 + " " + strLName);
 rstByRoyalty.moveNext();
 }
 System.out.println("\n\nPress <Enter> key to continue.");
 line = in.readLine();

 //Cleanup objects before exit.
 rstByRoyalty.close();
 rstAuthors.close();
 cnConn1.close();

 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // Check for null pointer for connection object
 if(rstByRoyalty.getActiveConnection()==null)
 System.out.println("Exception: " + ae.getMessage());
 if(rstAuthors.getActiveConnection()==null)
 System.out.println("Exception: " + ae.getMessage());
 // As passing a Recordset, check for null pointer first.
 if (rstByRoyalty != null)
 {
 PrintProviderError(rstByRoyalty.getActiveConnection());
 }
 if (rstAuthors != null)
 {
 PrintProviderError(rstAuthors.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // This catch is required if input string cannot be converted to
 // Integer data type.
 catch ( java.lang.NumberFormatException ne)
 {
 System.out.println("\nException: Integer Input required.");
 }
 // System Read requires this catch.
 catch( java.io.IOException je )
 {
 PrintIOError(je);
 }
 finally
 {
 // Cleanup objects before exit.
 if (rstByRoyalty != null)
 if (rstByRoyalty.getState() == 1)
 rstByRoyalty.close();
 if (rstAuthors != null)
 if (rstAuthors.getState() == 1)
 rstAuthors.close();
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 //.PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}

// EndActiveConnectionJ


Label.BackThemeColorIndex Property (Access)

 Copy code hover
[image]

Label.BackThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackThemeColorIndex

expression A variable that represents a Label object.

Remarks

The BackThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BackThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Background Color to the Text 2 color by setting the BackThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BackThemeColorIndex=2

See also

Concepts

Label Object

Other resources

Label Object Members


SubForm.Tag Property (Access)

 Copy code hover
[image]

SubForm.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents a SubForm object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


TabControl.PressedForeColor Property (Access)

 Copy code hover
[image]

TabControl.PressedForeColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the text displayed on the control when the user clicks it. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .PressedForeColor

expression A variable that represents a TabControl object.

Remarks

The PressedForeColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


SharedResources.Count Property (Access)

 Copy code hover
[image]

SharedResources.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Version Information

Version Added: Access 2010

Syntax

expression .Count

expression A variable that represents a SharedResources object.

See also

Concepts

SharedResources Collection

Other resources

SharedResources Object Members


Updating JOINed Results: Unique Table
Send feedback

Updating JOINed Results: Unique Table

ADO enables you to closely control modifications to a particular base table in a Recordset that was formed by a JOIN operation on multiple base tables using the Unique Table dynamic property. For details on using Unique Table, refer to the ADO Programmer's Reference topics on the Unique Table and Update Resynch dynamic properties.


Field-Related Error Information

 Copy code hover
[image]

Field-Related Error Information
Send feedback

If an error is directly related to a field — for example, if the data is missing or if it is the wrong type for the field — you can retrieve more information about the cause of the problem by examining the Field object's Status property. This property has been enhanced to provide specific information about the problem. So, for example, when a call to UpdateBatch fails, the cause of the problem can be determined by examining the Status property of the Fields in each of the effected records. The property will contain one of the values in the FieldStatusEnum constant. The following table includes those values that are of particular interest when an error occurs.

Constant | Value | Description
adFieldCantConvertValue | 2 | Indicates that the field cannot be retrieved or stored without loss of data.
adFieldDataOverflow | 6 | Indicates that the data returned from the provider overflowed the data type of the field.
adFieldDefault | 13 | Indicates that the default value for the field was used when setting data.
adFieldIgnore | 15 | Indicates that this field was skipped when setting data values in the source. No value was set by the provider.
adFieldIntegrityViolation | 10 | Indicates that the field cannot be modified because it is a calculated or derived entity.
adFieldIsNull | 3 | Indicates that the provider returned a null value.
adFieldOutOfSpace | 22 | Indicates that the provider is unable to obtain enough storage space to complete a move or copy operation.


Printer.ItemSizeWidth Property (Access)

 Copy code hover
[image]

Printer.ItemSizeWidth Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Long indicating the height of the detail section of a form or report in twips. Read/write.

Syntax

expression .ItemSizeWidth

expression A variable that represents a Printer object.

Remarks

If the DefaultSize property is True, this property is ignored.

Example

The following example sets a variety of printer settings for the form specified in the strFormname argument of the procedure.

VBA Copy code Copy code
Sub SetPrinter(strFormname As String)

 DoCmd.OpenForm FormName:=strFormname, view:=acDesign, _
 datamode:=acFormEdit, windowmode:=acHidden

 With Forms(form1).Printer

 .TopMargin = 1440
 .BottomMargin = 1440
 .LeftMargin = 1440
 .RightMargin = 1440

 .ColumnSpacing = 360
 .RowSpacing = 360

 .ColorMode = acPRCMColor
 .DataOnly = False
 .DefaultSize = False
 .ItemSizeHeight = 2880
  .ItemSizeWidth = 2880
 .ItemLayout = acPRVerticalColumnLayout
 .ItemsAcross = 6

 .Copies = 1
 .Orientation = acPRORLandscape
 .Duplex = acPRDPVertical
 .PaperBin = acPRBNAuto
 .PaperSize = acPRPSLetter
 .PrintQuality = acPRPQMedium

 End With

 DoCmd.Close objecttype:=acForm, objectname:=strFormname, _
 Save:=acSaveYes

End Sub

See also

Concepts

Printer Object

Other resources

Printer Object Members


Control.Controls Property (Access)

 Copy code hover
[image]

Control.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Syntax

expression .Controls

expression A variable that represents a Control object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

Control Object

Other resources

Control Object Members


Adding Multiple Fields

 Copy code hover
[image]

Adding Multiple Fields
Send feedback

Occasionally, it might be more efficient to pass in an array of fields and their corresponding values to the AddNew method, rather than setting Value multiple times for each new field. If FieldList is an array, Values must also be an array with the same number of members; otherwise, an error occurs. The order of field names must match the order of field values in each array. The following code passes an array of fields and an array of values to the AddNew method.

Copy code Copy code

'BeginAddNew2
 Dim avarFldNames As Variant
 Dim avarFldValues As Variant

 avarFldNames = Array("CompanyName", "Phone")
 avarFldValues = Array("Sample Shipper 2", "(931) 555-6334")

 If objRs1.Supports(adAddNew) Then
 objRs1.AddNew avarFldNames, avarFldValues
 End If

 'Re-establish a Connection and update
 Set objRs1.ActiveConnection = GetNewConnection
 objRs1.UpdateBatch
'EndAddNew2


ToggleButton.HoverForeTint Property (Access)

 Copy code hover
[image]

ToggleButton.HoverForeTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .HoverForeTint

expression A variable that represents a ToggleButton object.

Remarks

The HoverForeTint property contains a numeric expression that can be used to lighten the theme color in the HoverForeColor property. The default value of the HoverForeTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


WebBrowserControl.OnUpdated Property (Access)

 Copy code hover
[image]

WebBrowserControl.OnUpdated Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Updated box in the Properties window of a form or report. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnUpdated

expression A variable that represents a WebBrowserControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The OnUpdated value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Updated box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Updated box is blank, the property value is an empty string.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


There is no new data in shared memory for the Synchronizer or Replication Manager to read. (Error 3528)

 Copy code hover
[image]

There is no new data in shared memory for the Synchronizer or Replication Manager to read. (Error 3528)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


DBEngine.LoginTimeout Property (DAO)

 Copy code hover
[image]

DBEngine.LoginTimeout Property (DAO)
Send feedback

Sets or returns the number of seconds before an error occurs when you attempt to log on to an ODBC database.

Syntax

expression .LoginTimeout

expression A variable that represents a DBEngine object.

Remarks

The default LoginTimeout property setting is 20 seconds. When the LoginTimeout property is set to 0, no timeout occurs.

When you're attempting to log on to an ODBC database, such as Microsoft SQL Server, the connection can fail as a result of network errors or because the server isn't running. Rather than waiting for the default 20 seconds to connect, you can specify how long to wait before raising an error. Logging on to the server happens implicitly as part of a number of different events, such as running a query on an external server database.


ConnectPromptEnum

 Copy code hover
[image]

ConnectPromptEnum
Send feedback

Specifies whether a dialog box should be displayed to prompt for missing parameters when opening a connection to a data source.

Constant | Value | Description
adPromptAlways | 1 | Prompts always.
adPromptComplete | 2 | Prompts if more information is required.
adPromptCompleteRequired | 3 | Prompts if more information is required but optional parameters are not allowed.
adPromptNever | 4 | Never prompts.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.ConnectPrompt.ALWAYS

AdoEnums.ConnectPrompt.COMPLETE

AdoEnums.ConnectPrompt.COMPLETEREQUIRED

AdoEnums.ConnectPrompt.NEVER


Step 2: Initialize the Main List Box
Send feedback

Step 2: Initialize the Main List Box

To declare global Record and Recordset objects

  • Insert the following code into the (General) (Declarations) for Form1:

    Copy code Copy code

Option Explicit
Dim grec As Record
Dim grs As Recordset

    This code declares global object references for Record and Recordset objects that will be used later in this scenario.

To connect to a URL and populate lstMain

  • Insert the following code into the Form Load event handler for Form1:

    Copy code Copy code

Private Sub Form_Load()
    Set grec = New Record
    Set grs = New Recordset
    grec.Open "", "URL=http://servername/foldername/", , _
        adOpenIfExists Or adCreateCollection
    Set grs = grec.GetChildren
    While Not grs.EOF
        lstMain.AddItem grs(0)
        grs.MoveNext
    Wend
End Sub

    This code instantiates the global Record and Recordset objects. The Record, grec, is opened with a URL specified as the ActiveConnection. If the URL exists, it is opened; if it does not already exist, it is created. Note that you should replace "http://servername/foldername/" with a valid URL from your environment. The Recordset, grs, is opened on the children of the Record, grec. Then lstMain is populated with the file names of the resources published to the URL.


Image.SizeToFit Method (Access)

 Copy code hover
[image]

Image.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents an Image object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

Image Object

Other resources

Image Object Members


EmptyCell.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

EmptyCell.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .ShortcutMenuBar

expression A variable that represents an EmptyCell object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

Example

The following example sets the "Suppliers_Toolbar" as the custom shortcut menu to display when the user clicks the right mouse button on the "Suppliers" form.

VBA Copy code Copy code
Forms("Suppliers").ShortcutMenuBar = "Suppliers_Toolbar"

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


BoundObjectFrame.HelpContextId Property (Access)

 Copy code hover
[image]

BoundObjectFrame.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Syntax

expression .HelpContextId

expression A variable that represents a BoundObjectFrame object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Recordset.MovePrevious Method (DAO)

 Copy code hover
[image]

Recordset.MovePrevious Method (DAO)
Send feedback

Moves to the previous record in a specified Recordset object and make that record the current record.

Syntax

expression .MovePrevious

expression A variable that represents a Recordset object.

Remarks

Use the Move methods to move from record to record without applying a condition.

If you edit the current record, be sure you use the Update method to save the changes before you move to another record. If you move to another record without updating, your changes are lost without warning.

When you open a Recordset, the first record is current and the BOF property is False. If the Recordset contains no records, the BOF property is True, and there is no current record.

If you use MovePrevious when the first record is current, the BOF property is True, and there is no current record. If you use MovePrevious again, an error occurs, and BOF remains True.

If recordset refers to a table-type Recordset (Microsoft Access workspaces only), movement follows the current index. You can set the current index by using the Index property. If you don't set the current index, the order of returned records is undefined.

You can't use the MoveFirst, MoveLast, and MovePrevious methods on a forward-only-type Recordset object.

To move the position of the current record in a Recordset object a specific number of records forward or backward, use the Move method.


Modules.Item Property (Access)

 Copy code hover
[image]

Modules.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only Module.

Syntax

expression .Item(Index)

expression A variable that represents a Modules object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

Modules Collection

Other resources

Modules Object Members


Report.Painting Property (Access)

 Copy code hover
[image]

Report.Painting Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Painting property to specify whether a report is repainted. Read/write Boolean.

Syntax

expression .Painting

expression A variable that represents a Report object.

Remarks

The Painting property is similar to the Echo action. However, the Painting property prevents repainting of a single report, whereas the Echo action prevents repainting of all open windows in an application.

Setting the Painting property for a report to False also prevents all controls (except subreport controls) on a report from being repainted. To prevent a subreport control from being repainted, you must set the Painting property for the subreport to False. (Note that you set the Painting property for the subreport, not the subreport control.)

The Painting property is automatically set to True whenever the report gets or loses the focus. You can set this property to False while you are working on a report if you don't want to see changes to the report or to its controls. For example, if a form has a set of controls that are automatically resized when the form is resized and you don't want the user to see each individual control move, you can turn Painting off, and then move all of the controls, then turn Painting back on.

Example

The following example uses the Painting property to enable or disable form painting depending on whether the SetPainting variable is set to True or False. If form painting is turned off, Microsoft Access displays the hourglass icon while painting is turned off.

VBA Copy code Copy code
Public Sub EnablePaint(ByRef frmName As Form, _
 ByVal SetPainting As Integer)

 frmName.Painting = SetPainting

 ' Form painting is turned off.
 If SetPainting = False Then
 DoCmd.Hourglass True
 Else
 DoCmd.Hourglass False
 End If

End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


Screen Members (Access)

 Copy code hover
[image]

Screen Members (Access)
Send feedback

Published: July 16, 2012

The Screen object refers to the particular form, report, or control that currently has the focus.

Properties

Name | Description
ActiveControl | You can use the ActiveControl property together with the Screen object to identify or refer to the control that has the focus. Read-only Control object.
ActiveDatasheet | You can use the ActiveDatasheet property together with the Screen object to identify or refer to the datasheet that has the focus. Read-only Form object.
ActiveForm | You can use the ActiveForm property together with the Screen object to identify or refer to the form that has the focus. Read-only Form object.
ActiveReport | You can use the ActiveReport property together with the Screen object to identify or refer to the report that has the focus. Read-only Report object.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
MousePointer | You can use the MousePointer property together with the Screen object to specify or determine the type of mouse pointer currently displayed. Read/write Integer.
Parent | Returns the parent object for the specified object. Read-only.
PreviousControl | You can use the PreviousControl property with the Screen object to return a reference to the control that last received the focus. Read-only.


Report.PageFooter Property (Access)

 Copy code hover
[image]

Report.PageFooter Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PageFooter property to specify whether a report's page footer is printed on the same page as a report footer. Read/write Byte.

Syntax

expression .PageFooter

expression A variable that represents a Report object.

Remarks

The PageFooter property use the following settings.

Setting | Visual Basic | Description
All Pages | 0 | (Default) The page footer is printed on all pages of a report.
Not With Rpt Hdr | 1 | The page footer isn't printed on the same page as the report header.
Not With Rpt Ftr | 2 | The page footer isn't printed on the same page as the report footer. Microsoft Access prints the report footer on a new page.
Not With Rpt Hdr/Ftr | 3 | The page footer isn't printed on a page that has either a report header or a report footer. Microsoft Access prints the report footer on a new page.

You can set the PageFooter property only in report Design view.

Microsoft Access normally prints report page footers on every page in a report, including the first and last.

Note Note

When forms are printed, page footers are always printed on all pages.

Example

The following example sets the PageFooter property for a report to Not With Rpt Hdr. To run this example, type the following line in the Debug window for a report named Report1.

VBA Copy code Copy code
Reports!Report1.PageFooter = 1

See also

Concepts

Report Object

Other resources

Report Object Members


AllMacros.Parent Property (Access)

 Copy code hover
[image]

AllMacros.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents an AllMacros object.

See also

Concepts

AllMacros Collection

Other resources

AllMacros Object Members


Catalog Properties, Methods, and Events (ADOX)

 Copy code hover
[image]

Catalog Properties, Methods, and Events (ADOX)
Send feedback

Properties/Collections

ActiveConnection Property

Groups Collection

Procedures Collection

Tables Collection

Users Collection

Views Collection

Methods

Create Method

GetObjectOwner Method

SetObjectOwner Method

Events

None.


Label.FontWeight Property (Access)

 Copy code hover
[image]

Label.FontWeight Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.

Syntax

expression .FontWeight

expression A variable that represents a Label object.

Remarks

The DatasheetFontWeight property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

These properties are only available in Visual Basic within a Microsoft Access database.

In Visual Basic, the DatasheetFontWeight property setting uses the following Integer values.

Setting | Description
100 | Thin
200 | Extra Light
300 | Light
400 | (Default) Normal
500 | Medium
600 | Semi-bold
700 | Bold
800 | Extra Bold
900 | Heavy

The following table contains the properties that don't exist in the DAO Properties collection of until you set them by using the Formatting (Datasheet) toolbar or you can add them in an Access database by using the CreateProperty method and append it to the DAO Properties collection.

DatasheetFontItalic * | DatasheetForeColor *
DatasheetFontHeight * | DatasheetBackColor
DatasheetFontName * | DatasheetGridlinesColor
DatasheetFontUnderline * | DatasheetGridlinesBehavior
DatasheetFontWeight * | DatasheetCellsEffect
Note Note

When you add or set any property listed with an asterisk, Microsoft Access automatically adds all the properties listed with an asterisk to the Properties collection of the database.

Example

The following example sets the font to MS Serif, the font size to 10 points, and the font weight to medium (500) in Datasheet view of the Products table.

VBA Copy code Copy code

Sub SetDatasheetFont

   Dim dbs As Object, objProducts As Object
   Set dbs = CurrentDb
   Const DB_Text As Long = 10
   Const DB_Integer As Long = 3
   Set objProducts = dbs!Products

   SetTableProperty objProducts, "DatasheetFontName", DB_Text, "MS Serif"
   SetTableProperty objProducts, "DatasheetFontHeight", DB_Integer, 10
   SetTableProperty objProducts, "DatasheetFontWeight", DB_Integer, 500

End Sub

Sub SetTableProperty(objTableObj As Object, strPropertyName As String, _
        intPropertyType As Integer, varPropertyValue As Variant)
    ' Set Microsoft Access-defined table property without causing
    ' nonrecoverable run-time error.
    Const conErrPropertyNotFound = 3270
    Dim prpProperty As Variant
    On Error Resume Next                ' Don't trap errors.
    objTableObj.Properties(strPropertyName) = varPropertyValue
    If Err <> 0 Then                    ' Error occurred when value set.
        If Err <> conErrPropertyNotFound Then
            On Error GoTo 0
            MsgBox "Couldn't set property '" & strPropertyName _
                & "' on table '" & objTableObj.Name & "'", 48, "SetTableProperty"
        Else
            On Error GoTo 0
            Set prpProperty = objTableObj.CreateProperty(strPropertyName, _
                intPropertyType, varPropertyValue)
            objTableObj.Properties.Append prpProperty
        End If
    End If
    objTableObj.Properties.Refresh
End Sub

The next example makes the same changes as the preceding example in Datasheet view of the open Products form.

VBA Copy code Copy code
Forms!Products.DatasheetFontName = "MS Serif"
Forms!Products.DatasheetFontHeight = 10
Forms!Products.DatasheetFontWeight = 500

See also

Concepts

Label Object

Other resources

Label Object Members


NavigationButton.PressedThemeColorIndex Property (Access)

 Copy code hover
[image]

NavigationButton.PressedThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .PressedThemeColorIndex

expression A variable that represents a NavigationButton object.

Remarks

The PressedThemeColorIndex uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 (Default) | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the PressedThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Screen.Parent Property (Access)

 Copy code hover
[image]

Screen.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a Screen object.

See also

Concepts

Screen Object

Other resources

Screen Object Members


WITH OWNERACCESS OPTION Declaration (Microsoft Access SQL)

 Copy code hover
[image]

WITH OWNERACCESS OPTION Declaration (Microsoft Access SQL)
Send feedback

In a multiuser environment with a secure workgroup, use this declaration with a query to give the user who runs the query the same permissions as the query's owner.

Syntax

sqlstatement WITH OWNERACCESS OPTION

Remarks

The WITH OWNERACCESS OPTION declaration is optional.

The following example enables the user to view salary information (even if the user does not otherwise have permission to view the Payroll table), provided that the query's owner does have that permission:

SQL Copy code Copy code
SELECT LastName,
FirstName, Salary
FROM Employees
ORDER BY LastName
WITH OWNERACCESS OPTION;

If a user is otherwise prevented from creating or adding to a table, you can use WITH OWNERACCESS OPTION to enable the user to run a make-table or append query.

If you want to enforce workgroup security settings and users' permissions, do not include the WITH OWNERACCESS OPTION declaration.

This option requires you to have access to the System.mdw file associated with the database. It is useful only in secured multiuser implementations.


ListBox.IMEMode Property (Access)

 Copy code hover
[image]

ListBox.IMEMode Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .IMEMode

expression A variable that represents a ListBox object.

Remarks

The IMEMode property uses the following settings.

Setting | Description | Visual Basic
No Control | Kanji Conversion Mode not set (default). | 0
On | Turns on Kanji Conversion Mode. | 1
Off | Turns off Kanji Conversion Mode. | 2
Disable | Disables Kanji Conversion Mode. | 3
Hiragana | Sets full pitch hiragana | 4
Full pitch Katakana | Sets full pitch katakana. | 5
Half pitch Katakana | Sets half pitch katakana. | 6
Full pitch Alpha/Num | Sets full pitch letters/numbers. | 7
Half pitch Alpha/Num | Sets half pitch letters/numbers. | 8
HangulFull | Sets full pitch hangul. | 9
Hangul | Sets half pitch hangul. | 10

You can specify the Kanji Conversion Mode when the focus shifts to control by setting the IMEMode property. If set to No Control (default) the setting before the focus shifted to that control is used. For any other setting, the Kanji Conversion Mode setting for that control is used. For example, if the IMEMode property is set to Off, the Kanji Conversion Mode is turned off, and if the IMEMode property is set to On, the Kanji Conversion Mode is turned on. The Kanji Conversion Mode automatically changes each time the focus shifts between controls.

Note Note

If set to Disable, the Kanji Conversion Mode settings cannot be changed. If any other setting is used, the Kanji Conversion Mode can be changed, but when the focus changes, the settings are lost. If you want to save the settings before the control loses the focus, set the IMEHold/HoldKanjiConversionMode property.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


SELECT INTO on a remote database tried to produce too many fields. (Error 3185)

 Copy code hover
[image]

SELECT INTO on a remote database tried to produce too many fields. (Error 3185)
Send feedback

The Microsoft Access database engine supports up to 255 fields per table, but the other database supports fewer fields. A SELECT...INTO statement created a table with more fields than the remote database can support. Reduce the number of columns produced by the SELECT INTO statement, and then try the operation again.


ObjectFrame.DblClick Event (Access)

 Copy code hover
[image]

ObjectFrame.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Syntax

expression .DblClick(Cancel)

expression A variable that represents an ObjectFrame object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the DblClick event occurs. Setting the Cancel argument to True (-1) cancels the DblClick event.

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


OptionButton.GridlineTint Property (Access)

 Copy code hover
[image]

OptionButton.GridlineTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineTint

expression A variable that represents an OptionButton object.

Remarks

The GridlineTint property contains a numeric expression that can be used to lighten the theme color in the GridlineColor property. The default value of the GridlineTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


ComboBox.BorderTint Property (Access)

 Copy code hover
[image]

ComboBox.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderTint

expression A variable that represents a ComboBox object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Index.Name Property (DAO)

 Copy code hover
[image]

Index.Name Property (DAO)
Send feedback

Returns or sets the name of the specified object. Read/write String if the object has not been appended to a collection. Read-only String if the object has been appended to a collection.

Syntax

expression .Name

expression A variable that represents an Index object.

Remarks

The maximum length for the name of a Index object is 64 characters.


GetString Method Example (VJ++)

 Copy code hover
[image]

GetString Method Example (VJ++)
Send feedback

This example demonstrates the GetString method.

Assume you are debugging a data access problem and want a quick, simple way of printing the current contents of a small Recordset.

Copy code Copy code

// BeginGetStringJ
// The WFC class includes the ADO objects.
import com.ms.wfc.data.*;
import java.io.* ;

public class GetStringX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 GetStringX ();
 System.exit(0);
 }

 // GetStringX function
 static void GetStringX()
 {
 // Define ADO Objects.
 Connection cnConn1 = null;
 Recordset rstAuthors = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';" +
 "Initial Catalog='Pubs';Integrated Security='SSPI';";
 String strOutput;

 try
 {
 // Get the user input for state.
 System.out.println(
 "Enter a state (CA, IN, KS, MD, MI, OR, TN, UT): ");
 String strState = in.readLine().trim();
 String strQuery =
 "SELECT au_fname, au_lname, address, city FROM Authors " +
 "WHERE state = '" + strState + "'";

 // Open recordset with data from Authors table.
 cnConn1 = new Connection();
 cnConn1.open(strCnn);
 rstAuthors = new Recordset();
 rstAuthors.open(strQuery,
 cnConn1,
 AdoEnums.CursorType.STATIC,
 AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TEXT);

 if (rstAuthors.getRecordCount() > 0)
 {
 // Use all defaults: get all rows, TAB column delimiter,
 // CARRIAGE RETURN
 // row delimiter, empty-string null delimiter.
 strOutput =
 rstAuthors.getString(AdoEnums.StringFormat.CLIPSTRING,
 rstAuthors.getRecordCount(),
 "\t ",
 "\n",
 "").trim();
 System.out.println("\nState = '" + strState + "'" +
 "\n\n" +
 "Name Address City" +
 "\n");
 System.out.println(strOutput);
 }
 else
 System.out.println("\nNo rows found for state = '" +
 strState + "'\n");

 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstAuthors != null)
 {
 PrintProviderError(rstAuthors.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstAuthors != null)
 if (rstAuthors.getState() == 1)
 rstAuthors.close();
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 }

 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndGetStringJ


Save and Open Methods Example (VC++)

 Copy code hover
[image]

Save and Open Methods Example (VC++)
Send feedback

These three examples demonstrate how the Save and Open methods can be used together.

Assume you are going on a business trip and want to take along a table from a database. Before you go, you access the data as a Recordset and save it in a transportable form. When you arrive at your destination, you access the Recordset as a local, disconnected Recordset. You make changes to the Recordset, then save it again. Finally, when you return home, you connect to the database again and update it with the changes you made on the road.

Copy code Copy code

// BeginSaveCpp
#import "c:\Program Files\Common Files\system\ado\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>
#include <io.h>

//Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
bool FileExists(void);
void SaveX1(void);
void SaveX2(void);
void SaveX3(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 //If File exists in the specified directory, then display error
 if (!FileExists())
 {
 SaveX1();
 SaveX2();
 SaveX3();
 }

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// SaveX1 Function //
// //
//////////////////////////////////////////////////////////

//First, access and save the authors table.
void SaveX1()
{
 HRESULT hr = S_OK;

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstAuthors = NULL;

 //Definitions of other variables
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 TESTHR(pRstAuthors.CreateInstance(__uuidof(Recordset)));

 pRstAuthors->Open("SELECT * FROM authors",strCnn,
 adOpenDynamic,adLockBatchOptimistic,adCmdText);

 // For sake of illustration, save the Recordset to a diskette
 // in XML format.
 pRstAuthors->Save("c:\\pubs.xml",adPersistXML);
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstAuthors->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 if (pRstAuthors)
 if (pRstAuthors->State == adStateOpen)
 pRstAuthors->Close();
}

//////////////////////////////////////////////////////////
// //
// SaveX2 Function //
// //
//////////////////////////////////////////////////////////
//At this point, you have arrived at your destination.
//You will access the authors table as a local, disconnected Recordset.
//Don't forget you must have the MSPersist provider on the machine you
//are using in order to access the saved file, c:\pubs.xml.
void SaveX2()
{
 HRESULT hr = S_OK;

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstAuthors = NULL;

 try
 {
 TESTHR(pRstAuthors.CreateInstance(__uuidof(Recordset)));

 //For sake of illustration, we specify all parameters.
 pRstAuthors->Open("c:\\pubs.xml","Provider='MSPersist';",
 adOpenForwardOnly,adLockBatchOptimistic,adCmdFile);

 //Now you have a local, disconnected Recordset.
 //Edit it as you desire.
 //(In this example, the change makes no difference).
 pRstAuthors->Find("au_lname = 'Carson'",NULL,adSearchForward);
 if (pRstAuthors->EndOfFile)
 {
 printf("Name not found ...\n");
 pRstAuthors->Close();
 return;
 }
 pRstAuthors->GetFields()->GetItem("City")->PutValue("Chicago");
 pRstAuthors->Update();

 // Save changes in ADTG format this time, purely for sake of
 // illustration. Note that the previous version is still on the
 // diskette as c:\pubs.xml.
 pRstAuthors->Save("c:\\pubs.adtg",adPersistADTG);
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstAuthors->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 if (pRstAuthors)
 if (pRstAuthors->State == adStateOpen)
 pRstAuthors->Close();
}

//////////////////////////////////////////////////////////
// //
// SaveX3 Function //
// //
//////////////////////////////////////////////////////////
//Finally, you return home. Now update the database with
//your changes.
void SaveX3()
{
 HRESULT hr = S_OK;

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstAuthors = NULL;
 _ConnectionPtr pCnn = NULL;

 //Definitions of other variables
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 TESTHR(pCnn.CreateInstance(__uuidof(Connection)));

 TESTHR(pRstAuthors.CreateInstance(__uuidof(Recordset)));

 //If there is no ActiveConnection, you can open with defaults.
 pRstAuthors->Open("c:\\pubs.adtg","Provider=MSPersist;",
 adOpenForwardOnly,adLockBatchOptimistic,adCmdFile);

 //Connect to the database, associate the Recordset with
 //the connection, then update the database table with the
 //changed Recordset.
 pCnn->Open(strCnn,"","",NULL);

 pRstAuthors->PutActiveConnection(_variant_t((IDispatch *) pCnn));
 pRstAuthors->UpdateBatch(adAffectAll);
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstAuthors->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 if (pRstAuthors)
 if (pRstAuthors->State == adStateOpen)
 pRstAuthors->Close();
 if (pCnn)
 if (pCnn->State == adStateOpen)
 pCnn->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////
void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;

 // Collection ranges from 0 to nCount -1.
 for(long i = 0;i < nCount;i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print COM errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}

bool FileExists()
{
 struct _finddata_t xml_file;
 long hFile;

 if( (hFile = _findfirst("c:\\pubs.xml", &xml_file )) != -1L)
 {
 printf( "File already exists!\n" );
 return(true);
 }
 else
 return (false);
}
// EndSaveCpp


NavigationButton.NavigationTargetName Property (Access)

 Copy code hover
[image]

NavigationButton.NavigationTargetName Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the name of the form or report to be displayed when the user click the specified navigation button. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .NavigationTargetName

expression A variable that represents a NavigationButton object.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


BoundObjectFrame.Top Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Syntax

expression .Top

expression A variable that represents a BoundObjectFrame object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


TextBox.Application Property (Access)

 Copy code hover
[image]

TextBox.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a TextBox object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Relationship must be on the same number of fields with the same data types. (Error 3368)

 Copy code hover
[image]

Relationship must be on the same number of fields with the same data types. (Error 3368)
Send feedback

The CONSTRAINT clause you are using to create a relationship includes a different number of fields for each table or includes fields with different data types. Check the number of fields in the CONSTRAINT clause, check the data types of fields to make sure they match, and try again.


BoundObjectFrame.BackColor Property (Access)

 Copy code hover
[image]

BoundObjectFrame.BackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the interior color of the specified object. Read/write Long.

Syntax

expression .BackColor

expression A variable that represents a BoundObjectFrame object.

Remarks

The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

To use the BackColor property, the BackStyle property, if available, must be set to Normal.

Example

The following example uses the RGB function to set the , BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


NavigationButton.EventProcPrefix Property (Access)

 Copy code hover
[image]

NavigationButton.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .EventProcPrefix

expression A variable that represents a NavigationButton object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


ADO Events

 Copy code hover
[image]

ADO Events
Send feedback
BeginTransComplete | Called after the BeginTrans operation.
CommitTransComplete | Called after the CommitTrans operation.
ConnectComplete | Called after a connection starts.
Disconnect | Called after a connection ends.
EndOfRecordset | Called when there is an attempt to move to a row past the end of the Recordset.
ExecuteComplete | Called after a command has finished executing.
FetchComplete | Called after all the records in a lengthy asynchronous operation have been retrieved into the Recordset.
FetchProgress | Called periodically during a lengthy asynchronous operation to report how many rows have currently been retrieved into the Recordset.
FieldChangeComplete | Called after the value of one or more Field objects has changed.
InfoMessage | Called whenever a warning occurs during a ConnectionEvent operation.
MoveComplete | Called after the current position in the Recordset changes.
RecordChangeComplete | Called after one or more records change.
RecordsetChangeComplete | Called after the Recordset has changed.
RollbackTransComplete | Called after the RollbackTrans operation.
WillChangeField | Called before a pending operation changes the value of one or more Field objects in the Recordset.
WillChangeRecord | Called before one or more records (rows) in the Recordset change.
WillChangeRecordset | Called before a pending operation changes the Recordset.
WillConnect | Called before a connection starts.
WillExecute | Called just before a pending command executes on this connection and affords the user an opportunity to examine and modify the pending execution parameters.
WillMove | The WillMove event is called before a pending operation changes the current position in the Recordset.


Form.OnResize Property (Access)

 Copy code hover
[image]

Form.OnResize Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Resize box in the Properties window of a form. Read/write String.

Syntax

expression .OnResize

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Resize event occurs when a form is opened and whenever the size of a form changes.

The OnResize value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Resize box in the form's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Resize box is blank, the property value is an empty string.

Example

The following example prints the value of the OnResize property in the Immediate window for the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").OnResize

See also

Concepts

Form Object

Other resources

Form Object Members


ToggleButton.Visible Property (Access)

 Copy code hover
[image]

ToggleButton.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents a ToggleButton object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


SubForm.BorderTint Property (Access)

 Copy code hover
[image]

SubForm.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderTint

expression A variable that represents a SubForm object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens BorderColor by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


TabControl.MouseDown Event (Access)

 Copy code hover
[image]

TabControl.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents a TabControl object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
         Shift As Integer, X As Single, _
         Y As Single)
    If Button = acLeftButton Then
        MsgBox "You pressed the left button."
    End If
    If Button = acRightButton Then
        MsgBox "You pressed the right button."
    End If
    If Button = acMiddleButton Then
        MsgBox "You pressed the middle button."
    End If
End Sub

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


SendEmail Macro Action

 Copy code hover
[image]

SendEmail Macro Action
Send feedback

The SendEmail action sends an e-mail message.

Note Note

The SendEmail action is available only in Data Macros.

Setting

The SendEmail action has the following arguments.

Argument | Required | Description
To | Yes | The recipients of the message whose names you want to put on the To line in the message.Separate the recipient names that you specify in this argument (and in the Cc and Bcc arguments) with a semicolon (;).
Cc | No | The message recipients whose names you want to put on the Cc ("carbon copy") line in the message.
Bcc | No | The message recipients whose names you want to put on the Bcc ("blind carbon copy") line in the message.
Subject | No | The subject of the message. This text appears on the Subject line in the message.
Body | No | The text that you want to include in the main body of the mail message. If you leave this argument blank, no additional text is included in the message.

Remarks

The SendEmail action is available only in the After Delete, After Insert, and After Update macro events.

The SendEmail action does not display the message for editing.


ObjectFrame.Enter Event (Access)

 Copy code hover
[image]

ObjectFrame.Enter Event (Access)
See also Send feedback

Published: July 16, 2012

The Enter event occurs before a control actually receives the focus from a control on the same form or report.

Syntax

expression .Enter

expression A variable that represents an ObjectFrame object.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when these events occur, set the OnEnter or OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Enter event occurs before the GotFocus event. The Exit event occurs before the LostFocus event.

Unlike the GotFocus and LostFocus events, the Enter and Exit events don't occur when a form receives or loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Application.CurrentObjectName Property (Access)

 Copy code hover
[image]

Application.CurrentObjectName Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the CurrentObjectName property with the Application object to determine the name of the active database object. The active database object is the object that has the focus or in which code is running. Read-only String.

Syntax

expression .CurrentObjectName

expression A variable that represents an Application object.

Remarks

The CurrentObjectName property is set by Microsoft Access to a string expression containing the name of the active object.

The following conditions determine which object is considered the active object:

  • If the active object is a property sheet, command bar, menu, palette, or field list of an object, the CurrentObjectName property returns the name of the underlying object.

  • If the active object is a pop-up form, the CurrentObjectName property refers to the pop-up form itself, not the form from which it was opened.

  • If the active object is the Database window, the CurrentObjectName property returns the item selected in the Database window.

  • If no object is selected, the CurrentObjectName property returns a zero-length string (" ").

  • If the current state is ambiguous (the active object isn't a table, query, form, report, macro, or module) for example, if a dialog box has the focus the CurrentObjectName property returns the dialog box name.

Example

You can use this property with the SysCmd method to determine the active object and its state (for example, if the object is open, new, or has been changed but not saved).

The following example uses the CurrentObjectType and CurrentObjectName properties with the SysCmd function to determine if the active object is the Products form and if this form is open and has been changed but not saved. If these conditions are true, the form is saved and then closed.

VBA Copy code Copy code
Public Sub CheckProducts()

 Dim intState As Integer
 Dim intCurrentType As Integer
 Dim strCurrentName As String

 intCurrentType = Application.CurrentObjectType
 strCurrentName = Application.CurrentObjectName

 If intCurrentType = acForm And strCurrentName = "Products" Then
 intState = SysCmd(acSysCmdGetObjectState, intCurrentType, _
 strCurrentName)

 ' Products form changed but not saved.
 If intState = acObjStateDirty + acObjStateOpen Then

 ' Close Products form and save changes.
 DoCmd.Close intCurrentType, strCurrentName, acSaveYes
 End If
 End If
End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


ListBox.BackColor Property (Access)

 Copy code hover
[image]

ListBox.BackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the interior color of the specified object. Read/write Long.

Syntax

expression .BackColor

expression A variable that represents a ListBox object.

Remarks

The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

To use the BackColor property, the BackStyle property, if available, must be set to Normal.

Example

The following example uses the RGB function to set the , BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


NavigationButton.CursorOnHover Property (Access)

 Copy code hover
[image]

NavigationButton.CursorOnHover Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the type of mouse cursor displayed when the user rests the pointer on a button. Read/write AcCursorOnHover.

Version Information

Version Added: Access 2010

Syntax

expression .CursorOnHover

expression A variable that represents a NavigationButton object.

Remarks

Setting the CursorOnHover property to acCursorOnHoverHyperlinkHand can be useful when a button's BackStyle property is set to Transparent.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


TextBox.HorizontalAnchor Property (Access)

 Copy code hover
[image]

TextBox.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the text box is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .HorizontalAnchor

expression A variable that represents a TextBox object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ListBox.Tag Property (Access)

 Copy code hover
[image]

ListBox.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents a ListBox object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


CheckBox.GridlineThemeColorIndex Property (Access)

 Copy code hover
[image]

CheckBox.GridlineThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineThemeColorIndex

expression A variable that represents a CheckBox object.

Remarks

The GridlineThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 (Default) | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the GridlineThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ObjectFrame.HelpContextId Property (Access)

 Copy code hover
[image]

ObjectFrame.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Syntax

expression .HelpContextId

expression A variable that represents an ObjectFrame object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Page.Width Property (Access)

 Copy code hover
[image]

Page.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents a Page object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

Page Object

Other resources

Page Object Members


Editing Existing Records

 Copy code hover
[image]

Editing Existing Records
Send feedback

To edit existing records, move to the row you want to edit and change the Value property of the fields you want to change. For more information about the Field object's Value property, see Chapter 3: Examining Data. Depending on your cursor type, you will use Update or UpdateBatch to send changes back to the data source. For more information, see Chapter 5: Updating and Persisting Data.

It is usually more efficient to use a stored procedure with a command object to perform updates, as well as to perform other operations, because a stored procedure does not require the creation of a cursor. For more information about cursors, see Chapter 8: Understanding Cursors and Locks.


NavigationButton.ForeColor Property (Access)

 Copy code hover
[image]

NavigationButton.ForeColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ForeColor property to specify the color for text in a control. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ForeColor

expression A variable that represents a NavigationButton object.

Remarks

You can use this property for controls on forms or reports to make them easy to read or to convey a special meaning. For example, you can change the color of the text in the UnitsInStock control when its value falls below the reorder level.

You can also use this property on reports to create special visual effects when you print with a color printer. When used on a report, this property specifies the printing and drawing color for the Print , Line , and Circle methods.

The ForeColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors for text in controls.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set the Circle property only by using a macro or a Visual Basic event procedure specified in a section's OnPrint event property setting.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


MoveAndSizeWindow Macro Action

 Copy code hover
[image]

MoveAndSizeWindow Macro Action
Send feedback

If you have set your document window options to use overlapping windows instead of tabbed documents, you can use the MoveAndSizeWindow action to move or resize the active window. For information on how to set document window options, see the Remarks section.

Setting

The MoveAndSizeWindow action has the following arguments.

Action argument | Description
Right | The new horizontal position of the window's upper-left corner, measured from the left edge of its containing window. Enter the position in the Right box in the Action Arguments section of the Macro Builder pane.
Down | The new vertical position of the window's upper-left corner, measured from the top edge of its containing window.
Width | The window's new width.
Height | The window's new height.

If you leave an argument blank, Microsoft Access uses the window's current setting.

You must enter a value for at least one argument.

Note Note

Each measurement is in inches or centimeters, depending on the regional settings in Windows Control Panel.

Remarks

To set up an application to use overlapping windows instead of tabbed documents, use the following procedure:

  1. and then click Options

  2. Click Current Database.

  3. In the Application Options section, under Document Window Options, click Overlapping Windows.

  4. Click OK, and then close and reopen the database.

This action is similar to clicking Move or Size on the window's Control menu. With the menu commands, you use the keyboard's arrow keys to move or resize the window. With the MoveAndSizeWindow action, you enter the position and size measurements directly. You can also use the mouse to move and size windows.

You can use this action on any window, in any view.

Tips

  • To move a window without resizing it, enter values for the Right and Down arguments but leave the Width and Height arguments blank.

  • To resize a window without moving it, enter values for the Width and Height arguments but leave the Right and Down arguments blank.

To run the MoveAndSizeWindow action in a Visual Basic for Applications (VBA) module, use the MoveSize method of the DoCmd object.

Example

Synchronize forms by using a macro

The following macro opens a Product List form in the lower-right corner of the Suppliers form, displaying the current supplier's products. It shows the use of the Echo, MessageBox, GoToControl, StopMacro, OpenForm, and MoveAndSizeWindow actions. It also shows the use of a conditional expression with the MessageBox, GoToControl, and StopMacro actions. This macro should be attached to the Review Products button on the Suppliers form.

Condition | Action | Arguments: Setting | Comment
 | Echo | Echo On: No | Stop screen updating while the macro is running.
IsNull([Supplier ID]) | MessageBox | Message: Move to the supplier record whose products you want to see, then click the Review Products button again. Beep: Yes Type: None Title: Select a Supplier | If there is no current supplier on the Suppliers form, display a message.
 | GoToControl | Control Name: CompanyName | Move focus to the CompanyName control.
... | StopMacro |  | Stop the macro.
 | OpenForm | Form Name: Product List View: Datasheet Filter Name: Where Condition: [Supplier ID] = [Forms]![Suppliers]![SupplierID] Data Mode: Read Only Window Mode: Normal | Open the Product List form and show the current supplier's products.
 | MoveAndSizeWindow | Right: 0.7799" Down: 1.8" | Position the Product List form in the lower right of the Suppliers form.


TabControl.EventProcPrefix Property (Access)

 Copy code hover
[image]

TabControl.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents a TabControl object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


ObjectFrame.SourceItem Property (Access)

 Copy code hover
[image]

ObjectFrame.SourceItem Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SourceItem property to specify the data within a file to be linked when you create a linked OLE object. Read/write String.

Syntax

expression .SourceItem

expression A variable that represents an ObjectFrame object.

Remarks

You can set the SourceItem property by specifying data in units recognized by the application supplying the object. For example, when you link to Microsoft Excel, you specify the SourceItem property setting by using a cell or cell-range reference such as R1C1 or R3C4:R9C22 or a named range such as Revenues.

Note Note

To determine the syntax to describe a unit of data for a particular object, see the documentation for the application that was used to create the object.

The control's OLETypeAllowed property must be set to Linked or Either when you use this property. Use the control's SourceDoc property to specify the file to link.

Example

The following example creates a linked OLE object using an unbound object frame named OLE1 and sizes the control to display the object's entire contents when the user clicks a command button.

VBA Copy code Copy code
Sub Command1_Click
 OLE1.Class = "Excel.Sheet" ' Set class name.
 ' Specify type of object.
 OLE1.OLETypeAllowed = acOLELinked
 ' Specify source file.
 OLE1.SourceDoc = "C:\Excel\Oletext.xls"
 ' Specify data to create link to.
 OLE1.SourceItem = "R1C1:R5C5"
 ' Create linked object.
 OLE1.Action = acOLECreateLink
 ' Adjust control size.
 OLE1.SizeMode = acOLESizeZoom
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


ALTER USER or DATABASE Statement (Microsoft Access SQL)

 Copy code hover
[image]

ALTER USER or DATABASE Statement (Microsoft Access SQL)
Send feedback

Changes the password for an existing user or for a database.

Syntax

ALTER DATABASE PASSWORD newpassword oldpassword

ALTER USER user PASSWORD newpassword oldpassword

The ALTER USER or DATABASE statement has these parts:

Part | Description
user | The name of a user to be added to the workgroup information file.
newpassword | The new password to be associated with the specified user or database name.
oldpassword | The existing password to be associated with the specified user or group name.


NavigationControl Methods (Access)

 Copy code hover
[image]

NavigationControl Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.
Undo | You can use the Undo method to reset a control or form when its value has been changed.


ObjectFrame.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

ObjectFrame.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified frame. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthLeft

expression A variable that represents an ObjectFrame object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Page.Controls Property (Access)

 Copy code hover
[image]

Page.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Syntax

expression .Controls

expression A variable that represents a Page object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

Page Object

Other resources

Page Object Members


ToggleButton.Shape Property (Access)

 Copy code hover
[image]

ToggleButton.Shape Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets the shape of the specified toggle button. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .Shape

expression A variable that represents a ToggleButton object.

Remarks

The Shape property uses the following settings.

Setting | Description
0 | Rectangle
1 (Default) | Rounded Rectangle
2 | Snip Single Corner Rectangle
3 | Snip Same Side Corner Rectangle
4 | Snip Diagonal Corner Rectangle
5 | Snip and Round Single Corner Rectangle
6 | Round Single Corner Rectangle
7 | Round Same Side Corner Rectangle
8 | Round Diagonal Corner Rectangle
9 | Oval

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Recordsets Properties (DAO)

 Copy code hover
[image]

Recordsets Properties (DAO)
Send feedback

In this section

  • Recordsets.Count Property (DAO)


SubForm.SizeToFit Method (Access)

 Copy code hover
[image]

SubForm.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents a SubForm object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


ListBox.OnExit Property (Access)

 Copy code hover
[image]

ListBox.OnExit Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnExit

expression A variable that represents a ListBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Exit event occurs just before a control loses the focus to another control on the same form.

The OnExit value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Exit box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Exit box is blank, the property value is an empty string.

Example

The following example associates the Exit event with the macro "Exit_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnExit = "Exit_Macro"

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


ComboBox.HelpContextId Property (Access)

 Copy code hover
[image]

ComboBox.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Syntax

expression .HelpContextId

expression A variable that represents a ComboBox object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


CommandButton.ForeTint Property (Access)

 Copy code hover
[image]

CommandButton.ForeTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .ForeTint

expression A variable that represents a CommandButton object.

Remarks

The ForeTint property contains a numeric expression that can be used to lighten the theme color in the ForeColor property. The default value of the ForeTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the ForeColor property by 75%.

VBA Copy code Copy code
Me.ctl.ForeTint=25

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


OptionButton.DefaultValue Property (Access)

 Copy code hover
[image]

OptionButton.DefaultValue Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.

Syntax

expression .DefaultValue

expression A variable that represents an OptionButton object.

Remarks

The DefaultValue property applies to all table fields except those fields with the data type of AutoNumber or OLE Object.

The DefaultValue property specifies text or an expression that's automatically entered in a control or field when a new record is created. For example, if you set the DefaultValue property for a text box control to =Now(), the control displays the current date and time. The maximum length for a DefaultValue property setting is 255 characters.

The DefaultValue property doesn't apply to check box, option button, or toggle buttoncontrols when they are in an option group. It does however apply to the option group itself.

In Visual Basic, use a string expression to set the value of this property. For example, the following code sets the DefaultValue property for a text box control named PaymentMethod to "Cash"

VBA Copy code Copy code
Forms!frmInvoice!PaymentMethod.DefaultValue = """Cash"""
Note Note

To set this property for a field by using Visual Basic, use the ADO DefaultValue property or the DAO DefaultValue property.

The DefaultValue property is applied only when you add a new record. If you change the DefaultValue property, the change isn't automatically applied to existing records.

If you set the DefaultValue property for a form control that's bound to a field that also has a DefaultValue property setting defined in the table, the control setting overrides the table setting.

If you create a control by dragging a field from the field list, the field's DefaultValue property setting, as defined in the table, is applied to the control on the form although the control's DefaultValue property setting will remain blank.

One control can provide the default value for another control. For example, if you set the DefaultValue property for a control to the following expression, the control's default value is set to the DefaultValue property setting for the txtShipTo control.

VBA Copy code Copy code
=Forms!frmInvoice!txtShipTo

If the controls are on the same form, the control that's the source of the default value must appear earlier in the tab order than the control containing the expression.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Record (Visual C++ Syntax Index with #import)

 Copy code hover
[image]

Record (Visual C++ Syntax Index with #import)
Send feedback

Methods

Copy code Copy code

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthadocancel_HV10294125.xml( );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthclose_HV10294173.xml( );

_bstr_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcopyrecord_HV10294230.xml( _bstr_t Source, _bstr_t Destination,
 _bstr_t UserName, _bstr_t Password, enum CopyRecordOptionsEnum
 Options, VARIANT_BOOL Async );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthdeleterecord_HV10294302.xml( _bstr_t Source, VARIANT_BOOL Async );

_RecordsetPtr Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthgetchildrenmethodado_HV10294390.xml( );

_bstr_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthmoverecord_HV10294532.xml( _bstr_t Source, _bstr_t Destination,
 _bstr_t UserName, _bstr_t Password, enum MoveRecordOptionsEnum
 Options, VARIANT_BOOL Async );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthopenrecord_HV10294565.xml( const _variant_t & Source, const _variant_t
& ActiveConnection, enum ConnectModeEnum Mode, enum
 RecordCreateOptionsEnum CreateOptions, enum RecordOpenOptionsEnum
 Options, _bstr_t UserName, _bstr_t Password );

Properties

Copy code Copy code

_variant_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdproactivecon_HV10293988.xml( );
void PutActiveConnection( _bstr_t pvar );
void PutRefActiveConnection( struct _Connection * pvar );

FieldsPtr GetFields( );
__declspec(property(get=GetFields)) FieldsPtr Invalid DDUE based on source, error:link not allowed in code, link filename:mdcolfields_HV10294366.xml;

enum ConnectModeEnum GetMode( );
void PutMode( enum ConnectModeEnum pMode );
__declspec(property(get=GetMode,put=PutMode)) enum ConnectModeEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdpromode_HV10294518.xml;

_bstr_t GetParentURL( );
__declspec(property(get=GetParentURL)) _bstr_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdproparenturl_HV10294604.xml;

enum RecordTypeEnum GetRecordType( );
__declspec(property(get=GetRecordType)) enum RecordTypeEnum
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdprorecordtypeproperty_HV10294716.xml;

_variant_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdprosourcerecord_HV10294793.xml( );
void PutSource( _bstr_t pvar );
void PutRefSource( IDispatch * pvar );

enum ObjectStateEnum GetState( );
__declspec(property(get=GetState)) enum ObjectStateEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdprostate_HV10294804.xml;


Appendix D: ADO Samples

 Copy code hover
[image]

Appendix D: ADO Samples
Send feedback

The Windows SDK contains several sample applications that demonstrate the use of ADO and RDS code. These samples are intended to help you learn how to use ADO and RDS, but are not intended to be deployed on production servers.

Note Note

Companies, names, and data used in samples are fictitious unless otherwise noted.

To find the ADO samples, navigate to your Windows SDK root folder, such as C:\Program Files\Microsoft SDKs\Windows\v6.0. Then navigate to the Samples\dataaccess\ADO subfolder. To get started with the ADO and RDS sample applications, open default.htm from the ADO and RDS samples folders, respectively. These files describe each available sample application and explain how to configure and run the samples how to browse the sample source code.

The ADO documentation also contains code examples in multiple languages, which are included as topics within this online help. For more information about these examples, see ADO Code Examples.

ADO Code Examples

  • ADO Code Examples in Microsoft Visual Basic

  • ADO Code Examples in Microsoft Visual Basic Scripting Edition

  • ADO Code Examples in Microsoft Visual C++

  • ADO Code Examples in Microsoft Visual J++

  • ADO Code Examples in Microsoft JScript


Ignore Nulls Property

 Copy code hover
[image]

Ignore Nulls Property
Send feedback

Published: July 16, 2012

You can use the IgnoreNulls property to specify that records with Null values in the indexed fields not be included in the index.

Settings

Setting | Visual Basic | Description
Yes | True | Records that contain Null values in the indexed fields aren't included in the index.
No | False | (Default) Records that contain Null values in the indexed fields are included in the index.

You can set this property by using the Indexes window of table Design view or Visual Basic.

To access the Ignore Nulls property of an index by using Visual Basic, use the DAO IgnoreNulls property.

You can define an index for a field to facilitate faster searches for records indexed on that field. If you allow Null entries in the indexed field and expect to have many of them, set the Ignore Nulls property for the index to Yes to reduce the amount of storage space that the index uses.


TextBox.KeyPress Event (Access)

 Copy code hover
[image]

TextBox.KeyPress Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyPress(KeyAscii)

expression A variable that represents a TextBox object.

Parameters

Name | Required/Optional | Data Type | Description
KeyAscii | Required | Integer | Returns a numeric ANSI key code. The KeyAscii argument is passed by reference; changing it sends a different character to the object. Setting the KeyAscii argument to 0 cancels the keystroke so that the object doesn't recognize that a key was pressed.

Remarks

To run a macro or event procedure when this event occurs, set the OnKeyPress property to the name of the macro or to [Event Procedure].

The object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down an ANSI key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

A KeyPress event can involve any printable keyboard character, the CTRL key combined with a character from the standard alphabet or a special character, and the ENTER or BACKSPACE key. You can use the KeyDown and KeyUp event procedures to handle any keystroke not recognized by the KeyPress event, such as function keys, navigation keys, and any combinations of these with keyboard modifiers (ALT, SHIFT, or CTRL keys). Unlike the KeyDown and KeyUp events, the KeyPress event doesn't indicate the physical state of the keyboard; instead, it indicates the ANSI character that corresponds to the pressed key or key combinations.

KeyPress interprets the uppercase and lowercase of each character as separate key codes and, therefore, as two separate characters.

Note Note

The BACKSPACE key is part of the ANSI character set, but the DEL key isn't. If you delete a character in a control by using the BACKSPACE key, you cause a KeyPress event; if you use the DEL key, you don't.

The KeyDown and KeyPress events occur when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

For example, if you go to a new record and type a character in the first control in the record, the following events occur:

Current (for the new record)

ß

Enter (for the first control in the new record)

ß

GotFocus (for the control)

ß

KeyDown (for the control)

ß

KeyPress (for the control)

ß

BeforeInsert (for the new record in the form)

ß

Change (for the control if it's a text box or combo box)

ß

KeyUp (for the control)

Example

The following example converts text entered in a text box to uppercase as the text is typed in, one character at a time.

To try the example, add the following event procedure to a form that contains a text box named ShipRegion.

VBA Copy code Copy code
Private Sub ShipRegion_KeyPress(KeyAscii As Integer)
 Dim strCharacter As String

 ' Convert ANSI value to character string.
 strCharacter = Chr(KeyAscii)
 ' Convert character to upper case, then to ANSI value.
 KeyAscii = Asc(UCase(strCharacter))
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Find Method Example (JScript)

 Copy code hover
[image]

Find Method Example (JScript)
Send feedback

This example uses the Recordset object's Find method to locate and display the companies in the Northwind database whose name begins with the letter G. Cut and paste the following code to Notepad or another text editor, and save it as FindJS.asp.

Copy code Copy code

<!-- BeginFindJS -->
<%@ Language=JavaScript %>
<%// use this meta tag instead of adojavas.inc%>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->

<html>

<head>
<title>ADO Recordset.Find Example</title>
<style>
<!--
BODY {
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 BACKGROUND-COLOR:white;
 COLOR:black;
 }
.thead {
 background-color: #008080;
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 font-size: x-small;
 color: white;
 }
.thead2 {
 background-color: #800000;
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 font-size: x-small;
 color: white;
 }
.tbody {
 text-align: center;
 background-color: #f7efde;
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 font-size: x-small;
 }
-->
</style>
</head>

<body bgcolor="white">

<h1>ADO Recordset.Find Example</h1>
<%
 // connection and recordset variables
 var Cnxn = Server.CreateObject("ADODB.Connection");
 var strCnxn = "Provider='sqloledb';Data Source=" + Request.ServerVariables("SERVER_NAME") + ";" +
 "Initial Catalog='Northwind';Integrated Security='SSPI';";
 var rsCustomers = Server.CreateObject("ADODB.Recordset");
 // display string
 var strMessage;
 var strFind;

 try
 {
 // open connection
 Cnxn.Open(strCnxn);

 //create recordset using object refs
 SQLCustomers = "select * from Customers;";

 rsCustomers.ActiveConnection = Cnxn;
 rsCustomers.CursorLocation = adUseClient;
 rsCustomers.CursorType = adOpenKeyset;
 rsCustomers.LockType = adLockOptimistic;
 rsCustomers.Source = SQLCustomers;

 rsCustomers.Open();
 rsCustomers.MoveFirst();

 //find criteria
 strFind = "CompanyName like 'g%'"
 rsCustomers.Find(strFind);

 if (rsCustomers.EOF) {
 Response.Write("No records matched ");
 Response.Write(SQLCustomers & "So cannot make table...");
 Cnxn.Close();
 Response.End();
 }
 else {
 Response.Write('<table width="100%" border="2">');
 Response.Write('<tr class="thead2">');
 // Put Headings On The Table for each Field Name
 for (thisField = 0; thisField < rsCustomers.Fields.Count; thisField++) {
 fieldObject = rsCustomers.Fields(thisField);
 Response.Write('<th width="' + Math.floor(100 / rsCustomers.Fields.Count) + '%">' + fieldObject.Name + "</th>");
 }
 Response.Write("</tr>");

 while (!rsCustomers.EOF) {
 Response.Write('<tr class="tbody">');
 for(thisField=0; thisField<rsCustomers.Fields.Count; thisField++) {
 fieldObject = rsCustomers.Fields(thisField);
 strField = fieldObject.Value;
 if (strField == null)
 strField = "-Null-";
 if (strField == "")
 strField = "";
 Response.Write("<td>" + strField + "</td>");
 }
 rsCustomers.Find(strFind, 1, adSearchForward)
 Response.Write("</tr>");
 }
 Response.Write("</table>");
 }
 }
 catch (e)
 {
 Response.Write(e.message);
 }
 finally
 {
 // clean up
 if (rsCustomers.State == adStateOpen)
 rsCustomers.Close;
 if (Cnxn.State == adStateOpen)
 Cnxn.Close;
 rsCustomers = null;
 Cnxn = null;
 }
%>

</body>

</html>
<!-- EndFindJS -->


Command Object (ADO) Reference

 Copy code hover
[image]

Command Object (ADO) Reference
Send feedback

In this section

  • Command Object (ADO)

  • Command Properties, Methods, and Events (ADO)


AllTables.Item Property (Access)

 Copy code hover
[image]

AllTables.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.

Syntax

expression .Item(var)

expression A variable that represents an AllTables object.

Parameters

Name | Required/Optional | Data Type | Description
var | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

AllTables Collection

Other resources

AllTables Object Members


Open Method (ADO Recordset)

 Copy code hover
[image]

Open Method (ADO Recordset)
Send feedback

Opens a cursor.

Syntax

recordset.Open Source, ActiveConnection, CursorType, LockType, Options

Parameters

  • Source

  • Optional. A Variant that evaluates to a valid Command object, an SQL statement, a table name, a stored procedure call, a URL, or the name of a file or Stream object containing a persistently stored Recordset.

  • ActiveConnection

  • Optional. Either a Variant that evaluates to a valid Connection object variable name, or a String that contains ConnectionString parameters.

  • CursorType

  • Optional. A CursorTypeEnum value that determines the type of cursor that the provider should use when opening the Recordset. The default value is adOpenForwardOnly.

  • LockType

  • Optional. A LockTypeEnum value that determines what type of locking (concurrency) the provider should use when opening the Recordset. The default value is adLockReadOnly.

  • Options

  • Optional. A Long value that indicates how the provider should evaluate the Source argument if it represents something other than a Command object, or that the Recordset should be restored from a file where it was previously saved. Can be one or more CommandTypeEnum or ExecuteOptionEnum values, which can be combined with a bitwise AND operator.

Note Note

If you open a Recordset from a Stream containing a persisted Recordset, using an ExecuteOptionEnum value of adAsyncFetchNonBlocking will not have an effect; the fetch will be synchronous and blocking.

The ExecuteOpenEnum values of adExecuteNoRecords or adExecuteStream should not be used with Open.

Remarks

The default cursor for an ADO Recordset is a forward-only, read-only cursor located on the server.

Using the Open method on a Recordset object opens a cursor that represents records from a base table, the results of a query, or a previously saved Recordset.

Use the optional Source argument to specify a data source using one of the following: a Command object variable, an SQL statement, a stored procedure, a table name, a URL, or a complete file path name. If Source is a file path name, it can be a full path ("c:\dir\file.rst"), a relative path ("..\file.rst"), or a URL ("http://files/file.rst").

It is not a good idea to use the Source argument of the Open method to perform an action query that doesnt return records because there is no easy way to determine whether the call succeeded. The Recordset returned by such a query will be closed. Call the Execute method of a Command object or the Execute method of a Connection object instead to perform a query that, such as a SQL INSERT statement, that doesnt return records.

The ActiveConnection argument corresponds to the ActiveConnection property and specifies in which connection to open the Recordset object. If you pass a connection definition for this argument, ADO opens a new connection using the specified parameters. After opening the Recordset with a client-side cursor (CursorLocation = adUseClient), you can change the value of this property to send updates to another provider. Or you can set this property to Nothing (in Microsoft Visual Basic) or NULL to disconnect the Recordset from any provider. Changing ActiveConnection for a server-side cursor generates an error, however.

For the other arguments that correspond directly to properties of a Recordset object (Source, CursorType, and LockType), the relationship of the arguments to the properties is as follows:

  • The property is read/write before the Recordset object is opened.

  • The property settings are used unless you pass the corresponding arguments when executing the Open method. If you pass an argument, it overrides the corresponding property setting, and the property setting is updated with the argument value.

  • After you open the Recordset object, these properties become read-only.

Note Note

The ActiveConnection property is read only for Recordset objects whose Source property is set to a valid Command object, even if the Recordset object isn't open.

If you pass a Command object in the Source argument and also pass an ActiveConnection argument, an error occurs. The ActiveConnection property of the Command object must already be set to a valid Connection object or connection string.

If you pass something other than a Command object in the Source argument, you can use the Options argument to optimize evaluation of the Source argument. If the Options argument is not defined, you may experience diminished performance because ADO must make calls to the provider to determine if the argument is an SQL statement, a stored procedure, a URL, or a table name. If you know what Source type you're using, setting the Options argument instructs ADO to jump directly to the relevant code. If the Options argument does not match the Source type, an error occurs.

If you pass a Stream object in the Source argument, you should not pass information into the other arguments. Doing so will generate an error. The ActiveConnection information is not retained when a Recordset is opened from a Stream.

The default for the Options argument is adCmdFile if no connection is associated with the Recordset. This will typically be the case for persistently stored Recordset objects.

If the data source returns no records, the provider sets both the BOF and EOF properties to True, and the current record position is undefined. You can still add new data to this empty Recordset object if the cursor type allows it.

When you have concluded your operations over an open Recordset object, use the Close method to free any associated system resources. Closing an object does not remove it from memory; you can change its property settings and use the Open method to open it again later. To completely eliminate an object from memory, set the object variable to Nothing.

Before the ActiveConnection property is set, call Open with no operands to create an instance of a Recordset created by appending fields to the Recordset Fields collection.

If you have set the CursorLocation property to adUseClient, you can retrieve rows asynchronously in one of two ways. The recommended method is to set Options to adAsyncFetch. Alternatively, you can use the "Asynchronous Rowset Processing" dynamic property in the Properties collection, but related retrieved events can be lost if you do not set the Options parameter to adAsyncFetch.

Note Note

Background fetching in the MS Remote provider is supported only through the Open method's Options parameter.
Note Note

URLs using the http scheme will automatically invoke the Microsoft OLE DB Provider for Internet Publishing. For more information, see Absolute and Relative URLs.


Persisting Records in XML Format (ADO)

 Copy code hover
[image]

Persisting Records in XML Format (ADO)
Send feedback

In this section

  • Persisting Records in XML Format

  • XML Persistence Format

  • Namespaces

  • Schema Section

  • Data Section

  • Hierarchical Recordsets in XML

  • Recordset Dynamic Properties in XML

  • XSLT Transformations

  • Saving to the XML DOM Object

  • XML Security Considerations

  • XML Recordset Persistence Scenario Topics


CustomControl.LayoutID Property (Access)

 Copy code hover
[image]

CustomControl.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified text box. Read-only Long.

Version Information

Version Added: Access 2010

Syntax

expression .LayoutID

expression A variable that represents a CustomControl object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


ConnectionString, ConnectionTimeout, and State Properties Example (VJ++)

 Copy code hover
[image]

ConnectionString, ConnectionTimeout, and State Properties Example (VJ++)
Send feedback

This example demonstrates different ways of using the ConnectionString property to open a Connection object. It also uses the ConnectionTimeout property to set a connection timeout period, and the State property to check the state of the connections. The GetState function is required for this procedure to run.

Copy code Copy code

// BeginConnectionStringJ
import com.ms.wfc.data.*;
import java.io.* ;

public class ConnectionStringX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 ConnectionStringX();
 System.exit(0);
 }

 // ConnectionStringX function

 static void ConnectionStringX()
 {
 // Define ADO Objects.
 Connection cnConn1 = null;
 Connection cnConn2 = null;
 Connection cnConn3 = null;
 Connection cnConn4 = null;

 //Declarations.

 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String line = null;
 String strTemp;

 try
 {
 // Open a connection using OLE DB syntax.
 cnConn1 = new Connection();
 cnConn1.setConnectionString(
 "Provider='sqloledb';Data Source='MySqlServer';" +
 "Initial Catalog='Pubs';Integrated Security='SSPI';");
 cnConn1.setCommandTimeout(30);
 cnConn1.open();
 strTemp = getState(cnConn1.getState());
 System.out.println("CnConn1 state: " + strTemp);

 // Open a connection using a DSN and ODBC tags.
 // It is assumed that you have create DSN 'Pubs' with a user name as
 // 'MyUserId' and password as 'MyPassword'.
 cnConn2 = new Connection();
 cnConn2.setConnectionString("DSN='Pubs';UID='MyUserId';PWD='MyPassword';");
 cnConn2.open();
 strTemp = getState(cnConn2.getState());
 System.out.println("CnConn2 state: " + strTemp);

 // Open a connection using a DSN and OLE DB tags.
 cnConn3 = new Connection();
 cnConn3.setConnectionString
 ("Data Source='Pubs';");
 cnConn3.open();
 strTemp = getState(cnConn3.getState());
 System.out.println("CnConn3 state: " + strTemp);

 // Open a connection using a DSN and individual
 // arguments instead of a connection string.
 // It is assumed that you have create DSN 'Pubs' with a user name as
 // 'MyUserId' and password as 'MyPassword'.
 cnConn4 = new Connection();
 cnConn4.open("Pubs", "MyUserId", "MyPassword");
 strTemp = getState(cnConn4.getState());
 System.out.println("CnConn4 state: " + strTemp);

 System.out.println("\n\nPress <Enter> to continue..");
 in.readLine();

 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 System.out.println("Exception: " + ae.getMessage());

 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 if (cnConn2 != null)
 if (cnConn2.getState() == 1)
 cnConn2.close();
 if (cnConn3 != null)
 if (cnConn3.getState() == 1)
 cnConn3.close();
 if (cnConn4 != null)
 if (cnConn4.getState() == 1)
 cnConn4.close();
 }

 }

 // getState Function

 static String getState(int intState)
 {
 // Returns current state of the connection object.
 String strState=null;

 switch(intState)
 {
 case AdoEnums.ObjectState.CLOSED :
 strState = new String("adStateClosed");
 break;
 case AdoEnums.ObjectState.OPEN :
 strState = new String("adStateOpen");
 break;
 default :
 break;
 }
 return strState;
 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}

// EndConnectionStringJ


Workspaces Collection (DAO)

 Copy code hover
[image]

Workspaces Collection (DAO)
Send feedback

A Workspaces collection contains all active, unhidden Workspace objects of the DBEngine object. (Hidden Workspace objects are not appended to the collection and referenced by the variable to which they are assigned.)

Remarks

Use the Workspace object to manage the current session or to start an additional session.

When you first refer to or use a Workspace object, you automatically create the default workspace, DBEngine.Workspaces(0). The settings of the Name and UserName properties of the default workspace are "#Default Workspace#" and "Admin," respectively. If security is enabled, the UserName property setting is the name of the user who logged on.

You can create new Workspace objects with the CreateWorkspace method. After you create a new Workspace object, you must append it to the Workspaces collection if you need to refer to it from the Workspaces collection. You can, however, use a newly created Workspace object without appending it to the Workspaces collection.

To refer to a Workspace object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

DBEngine.Workspaces(0)

DBEngine.Workspaces("name")

DBEngine.Workspaces![name]

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Example

This example creates a new Microsoft Access Workspace object and appends it to the Workspaces collection. It then enumerates the Workspaces collections and the Properties collection of the Workspace object.

VBA Copy code Copy code
Sub WorkspaceX()

 Dim wrkNewAcc As Workspace
 Dim wrkLoop As Workspace
 Dim prpLoop As Property

 ' Create a new Microsoft Access workspace.
 Set wrkNewAcc = CreateWorkspace("NewAccessWorkspace", _
 "admin", "", dbUseJet)
 Workspaces.Append wrkNewAcc

 ' Enumerate the Workspaces collection.
 For Each wrkLoop In Workspaces
 With wrkLoop
 Debug.Print "Properties of " & .Name
 ' Enumerate the Properties collection of the new
 ' Workspace object.
 For Each prpLoop In .Properties
 On Error Resume Next
 If prpLoop <> "" Then Debug.Print " " & _
 prpLoop.Name & " = " & prpLoop
 On Error GoTo 0
 Next prpLoop
 End With
 Next wrkLoop

 wrkNewAcc.Close
End Sub

This example uses the CreateWorkspace method to create a Microsoft Access workspace. It then lists the properties of theworkspace.

VBA Copy code Copy code
Sub CreateWorkspaceX()

 Dim wrkAcc As Workspace
 Dim wrkLoop As Workspace
 Dim prpLoop As Property

 DefaultType = dbUseJet
 ' Create an unnamed Workspace object of the type
 ' specified by the DefaultType property of DBEngine
 ' (dbUseJet).
 Set wrkAcc = CreateWorkspace("", "admin", "")

 ' Enumerate Workspaces collection.
 Debug.Print "Workspace objects in Workspaces collection:"
 For Each wrkLoop In Workspaces
 Debug.Print " " & wrkLoop.Name
 Next wrkLoop

 With wrkAcc
 ' Enumerate Properties collection of Microsoft Access
 ' workspace.
 Debug.Print _
 "Properties of unnamed Microsoft Access workspace"
 On Error Resume Next
 For Each prpLoop In .Properties
 Debug.Print " " & prpLoop.Name & " = " & prpLoop
 Next prpLoop
 On Error GoTo 0
 End With

 wrkAcc.Close

End Sub


Math functions (Access 2013 custom web app)

 Copy code hover
[image]

Math functions (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • Abs Function (Access 2013 custom web app)

  • Avg Function (Access 2013 custom web app)

  • Ceiling Function (Access 2013 custom web app)

  • Count Function (Access 2013 custom web app)

  • Exp Function (Access 2013 custom web app)

  • Floor Function (Access 2013 custom web app)

  • Log10 Function (Access 2013 custom web app)

  • Log Function (Access 2013 custom web app)

  • Max Function (Access 2013 custom web app)

  • Min Function (Access 2013 custom web app)

  • Pi Function (Access 2013 custom web app)

  • Power Function (Access 2013 custom web app)

  • Rand Function (Access 2013 custom web app)

  • Round Function (Access 2013 custom web app)

  • Sign Function (Access 2013 custom web app)

  • StDev Function (Access 2013 custom web app)

  • Sqrt Function (Access 2013 custom web app)

  • Sum Function (Access 2013 custom web app)

    Var Function (Access 2013 custom web app)


AcModuleType Enumeration (Access)

 Copy code hover
[image]

AcModuleType Enumeration (Access)
Send feedback

Published: July 16, 2012

Returns the type of the specified Visual Basic module.

Name | Value | Description
acClassModule | 1 | The specified module is a class module.
acStandardModule | 0 | The specified module is a standard module.


Label.TextAlign Property (Access)

 Copy code hover
[image]

Label.TextAlign Property (Access)
See also Send feedback

Published: July 16, 2012

The TextAlign property specifies the text alignment in new controls. Read/write Byte.

Syntax

expression .TextAlign

expression A variable that represents a Label object.

Remarks

The TextAlign property uses the following settings.

Setting | Visual Basic | Description
General | 0 | (Default) The text aligns to the left; numbers and dates align to the right.
Left | 1 | The text, numbers, and dates align to the left.
Center | 2 | The text, numbers, and dates are centered.
Right | 3 | The text, numbers, and dates align to the right.
Distribute | 4 | The text, numbers, and dates are evenly distributed.

You can set the default for the TextAlign property by using a control's default control style or the DefaultControl property in Visual Basic.

Example

The following example aligns the text in the "Address" text box on the "Suppliers" form to the right.

VBA Copy code Copy code
Forms("Suppliers").Controls("Address").TextAlign = 3

See also

Concepts

Label Object

Other resources

Label Object Members


NavigationControl.GridlineStyleRight Property (Access)

 Copy code hover
[image]

NavigationControl.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleRight

expression A variable that represents a NavigationControl object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Screen.PreviousControl Property (Access)

 Copy code hover
[image]

Screen.PreviousControl Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PreviousControl property with the Screen object to return a reference to the control that last received the focus. Read-only.

Syntax

expression .PreviousControl

expression A variable that represents a Screen object.

Remarks

The PreviousControl property contains a reference to the control that last had the focus. Once you establish a reference to the control, you can access all the properties and methods of the control.

You can't use the PreviousControl property until more than one control on any form has received the focus after a form is opened. Microsoft Access generates an error if you attempt to use this property when only one control on a form has received the focus.

Example

The following example displays a message if the control that last received the focus wasn't the txtFinalEntry text box.

VBA Copy code Copy code
Public Function ProcessData() As Integer

 ' No previous control error.
 Const conNoPreviousControl = 2483
 Dim ctlPrevious As Control

 On Error GoTo Process_Err

 Set ctlPrevious = Screen.PreviousControl
 If ctlPrevious.Name = "txtFinalEntry" Then
 '
 ' Process Data Here.
 '
 ProcessData = True
 Else
 ' Set focus to txtFinalEntry and display message.
 Me!txtFinalEntry.SetFocus
 MsgBox "Please enter a value here."
 ProcessData = False
 End If

Process_Exit:
 Set ctlPrevious = Nothing
 Exit Function

Process_Err:
 If Err = conNoPreviousControl Then
 Me!txtFinalEntry.SetFocus
 MsgBox "Please enter a value to process.", vbInformation
 ProcessData = False
 End If
 Resume Process_Exit

End Function

See also

Concepts

Screen Object

Other resources

Screen Object Members


Label.EventProcPrefix Property (Access)

 Copy code hover
[image]

Label.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents a Label object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

Label Object

Other resources

Label Object Members


Recordset.Cancel Method (DAO)

 Copy code hover
[image]

Recordset.Cancel Method (DAO)
Send feedback

Syntax

expression .Cancel

expression A variable that represents a Recordset object.

Remarks

Use the Cancel method to terminate execution of an asynchronous Execute or OpenConnection method call (that is, the method was invoked with the dbRunAsync option). Cancel will return a run-time error if dbRunAsync was not used in the method you're trying to terminate.


ComboBox.AfterUpdate Event (Access)

 Copy code hover
[image]

ComboBox.AfterUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The AfterUpdate event occurs after changed data in a control or record is updated.

Syntax

expression .AfterUpdate

expression A variable that represents a ComboBox object.

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's AfterUpdate event does occur.

To run a macro or event procedure when this event occurs, set the AfterUpdate property to the name of the macro or to [Event Procedure].

The AfterUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

AfterUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. AfterUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For bound controls, the OldValue property isn't set to the updated value until after the AfterUpdate event for the form occurs. Even if the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Forms: Populate Controls/Text Boxes Based on Combobox Selection

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


WebBrowserControl.OnBeforeNavigate Property (Access)

 Copy code hover
[image]

WebBrowserControl.OnBeforeNavigate Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the value of the On Before Navigate box in the property sheet os a Web Browser control. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnBeforeNavigate

expression A variable that represents a WebBrowserControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


ToggleButton.HorizontalAnchor Property (Access)

 Copy code hover
[image]

ToggleButton.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the toggle button is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .HorizontalAnchor

expression A variable that represents a ToggleButton object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Log10 Function (Access 2013 custom web app)

 Copy code hover
[image]

Log10 Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the base-10 logarithm of a number.

Syntax

Log10(NumericExpression)

The Log10 function contains the following argument.

Argument name | Description
NumericExpression | The positive number for which you want the base-10 logarithm.

Remarks

The Log function lets you change the base of the logarithm, instead of using the base 10.


Reshaping

 Copy code hover
[image]

Reshaping
Send feedback

A Recordset created by a clause of a shape command may be assigned an alias name (typically with the AS keyword). The alias of a shaped Recordset can be referenced in an entirely different command. That is, you may reuse, or reshape, a previously shaped Recordset in a new shape command. To support this feature, ADO provides a property, Reshape Name.

Reshaping has two main functions. The first is to associate an existing Recordset with a new parent Recordset.

Example

Copy code Copy code

. . .
rs1.Open "SHAPE {select * from Customers} " & _
 "APPEND ({select * from Orders} AS chapOrders " & _
 "RELATE CustomerID to CustomerID)", cn

rs2.Open "SHAPE {select * from Employees} " & _
 "APPEND (chapOrders RELATE EmployeeID to EmployeeID)", cn
. . .

The second function is to enable non-chaptered access to existing child Recordset objects, using the syntax "SHAPE <recordset reshape name>".

Note Note

You cannot append columns to an existing Recordset, reshape a parameterized Recordset or the Recordset objects in any intervening COMPUTE clause, or perform aggregate operations on any Recordset descendant from the Recordset being reshaped. The Recordset being reshaped and the new shape command must both use the same Connection.


Requested row locking, but DB is in page lock mode. (Error 3751)

 Copy code hover
[image]

Requested row locking, but DB is in page lock mode. (Error 3751)
Send feedback

This error occurs when a user specifies that the dataqbase open in row/page locking mode, but another user already has the database opened in page locking only mode.


BoundObjectFrame.OldValue Property (Access)

 Copy code hover
[image]

BoundObjectFrame.OldValue Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.

Syntax

expression .OldValue

expression A variable that represents a BoundObjectFrame object.

Remarks

The OldValue property contains the unedited data from a bound control and is read-only in all views.

Microsoft Access uses the OldValue property to store the original value of a bound control. When you edit a bound control on a form, your changes aren't saved until you move to another record. The OldValue property contains the unedited version of the underlying data.

You can provide your own undo capability by assigning the OldValue property setting to a control. The following example shows how you can undo any changes to text box controls on a form:

VBA Copy code Copy code
Private Sub btnUndo_Click()

 Dim ctlTextbox As Control

 For Each ctlTextbox in Me.Controls
 If ctlTextbox.ControlType = acTextBox Then
 ctlTextbox.Value = ctl.OldValue
 End If
 Next ctlTextbox

End Sub

If the control hasn't been edited, this code has no effect. When you move to another record, the record source is updated, so the current value and the OldValue property will be the same.

The OldValue property setting has the same data type as the field to which the control is bound.

Example

The following example checks to determine if new data entered in a field is within 10 percent of the value of the original data. If the change is greater than 10 percent, the OldValue property is used to restore the original value. This procedure could be called from the BeforeUpdate event of the control that contains data you want to validate.

VBA Copy code Copy code
Public Sub Validate_Field()

 Dim curNewValue As Currency
 Dim curOriginalValue As Currency
 Dim curChange As Currency
 Dim strMsg As String

 curNewValue = Forms!Products!UnitPrice
 curOriginalValue = Forms!Products!UnitPrice.OldValue
 curChange = Abs(curNewValue - curOriginalValue)

 If curChange > (curOriginalValue * .1) Then
 strMsg = "Change is more than 10% of original unit price. " _
 & "Restoring original unit price."
 MsgBox strMsg, vbExclamation, "Invalid change."
 Forms!Products!UnitPrice = curOriginalValue
 End If

End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


NavigationControl.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

NavigationControl.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .ShortcutMenuBar

expression A variable that represents a NavigationControl object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

Example

The following example sets the "Suppliers_Toolbar" as the custom shortcut menu to display when the user clicks the right mouse button on the "Suppliers" form.

VBA Copy code Copy code
Forms("Suppliers").ShortcutMenuBar = "Suppliers_Toolbar"

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Workspace.Type Property (DAO)

 Copy code hover
[image]

Workspace.Type Property (DAO)
Send feedback

Sets or returns a value that indicates the operational type or data type of an object. Read-only Integer.

Syntax

expression .Type

expression A variable that represents a Workspace object.

Remarks

For a Workspace object, the possible settings and return values are as follows.

Constant | Workspace type
dbUseJet | The Workspace is connected to the Microsoft Access database engine.
dbUseODBC | The Workspace is connected to an ODBC data source.


Inspection functions (Access 2013 custom web app)

 Copy code hover
[image]

Inspection functions (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • Try_Convert Function (Access 2013 custom web app)


ToggleButton.ForeColor Property (Access)

 Copy code hover
[image]

ToggleButton.ForeColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ForeColor property to specify the color for text in a control. Read/write Long.

Syntax

expression .ForeColor

expression A variable that represents a ToggleButton object.

Remarks

You can use this property for controls on forms or reports to make them easy to read or to convey a special meaning. For example, you can change the color of the text in the UnitsInStock control when its value falls below the reorder level.

You can also use this property on reports to create special visual effects when you print with a color printer. When used on a report, this property specifies the printing and drawing color for the Print , Line , and Circle methods.

The ForeColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors for text in controls.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set the Circle property only by using a macro or a Visual Basic event procedure specified in a section's OnPrint event property setting.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Controls.Parent Property (Access)

 Copy code hover
[image]

Controls.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a Controls object.

See also

Concepts

Controls Collection

Other resources

Controls Object Members


Form.AfterFinalRender Event (Access)

 Copy code hover
[image]

Form.AfterFinalRender Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs after all elements in the specified PivotChart view have been rendered.

Syntax

expression .AfterFinalRender(drawObject )

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
drawObject | Required | Object | A ChChartDraw object. Use the methods and properties of this object to draw objects on the chart.

Return Value

nothing

Example

The following example demonstrates the syntax for a subroutine that traps the AfterFinalRender event.

VBA Copy code Copy code
Private Sub Form_AfterFinalRender(ByVal drawObject As Object)
 MsgBox "The PivotChart View has fully rendered."
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


NavigationButton.KeyPress Event (Access)

 Copy code hover
[image]

NavigationButton.KeyPress Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Version Information

Version Added: Access 2010

Syntax

expression .KeyPress(KeyAscii, )

expression A variable that represents a NavigationButton object.

Parameters

Name | Required/Optional | Data Type | Description
KeyAscii | Required | Integer |

Return Value

nothing

Remarks

To run a macro or event procedure when this event occurs, set the OnKeyPress property to the name of the macro or to [Event Procedure].

The object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down an ANSI key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

A KeyPress event can involve any printable keyboard character, the CTRL key combined with a character from the standard alphabet or a special character, and the ENTER or BACKSPACE key. You can use the KeyDown and KeyUp event procedures to handle any keystroke not recognized by the KeyPress event, such as function keys, navigation keys, and any combinations of these with keyboard modifiers (ALT, SHIFT, or CTRL keys). Unlike the KeyDown and KeyUp events, the KeyPress event doesn't indicate the physical state of the keyboard; instead, it indicates the ANSI character that corresponds to the pressed key or key combinations.

KeyPress interprets the uppercase and lowercase of each character as separate key codes and, therefore, as two separate characters.

Note Note

The BACKSPACE key is part of the ANSI character set, but the DEL key isn't. If you delete a character in a control by using the BACKSPACE key, you cause a KeyPress event; if you use the DEL key, you don't.

The KeyDown and KeyPress events occur when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

For example, if you go to a new record and type a character in the first control in the record, the following events occur:

Current (for the new record)

ß

Enter (for the first control in the new record)

ß

GotFocus (for the control)

ß

KeyDown (for the control)

ß

KeyPress (for the control)

ß

BeforeInsert (for the new record in the form)

ß

Change (for the control if it's a text box or combo box)

ß

KeyUp (for the control)

Example

The following example converts text entered in a text box to uppercase as the text is typed in, one character at a time.

To try the example, add the following event procedure to a form that contains a text box named ShipRegion.

VBA Copy code Copy code
Private Sub ShipRegion_KeyPress(KeyAscii As Integer)
 Dim strCharacter As String

 ' Convert ANSI value to character string.
 strCharacter = Chr(KeyAscii)
 ' Convert character to upper case, then to ANSI value.
 KeyAscii = Asc(UCase(strCharacter))
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


ActualSize and DefinedSize Properties Example (VC++)

 Copy code hover
[image]

ActualSize and DefinedSize Properties Example (VC++)
Send feedback

This example uses the ActualSize and DefinedSize properties to display the defined size and actual size of a field.

Copy code Copy code

// BeginActualSizeCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include "conio.h"

//Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void ActualSizeX(VOID);
void PrintProviderError(_ConnectionPtr pConnection);

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;
 ActualSizeX();
 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// ActualSizeX Function //
// //
///////////////////////////////////////////////////////////
VOID ActualSizeX(VOID)
{
 HRESULT hr = S_OK;

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstStores = NULL;

 //Define Other variables
 _bstr_t strMessage;
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 //Open a recordset for the stores table.
 TESTHR(pRstStores.CreateInstance(__uuidof(Recordset)));

 //You have to explicitly pass the Cursor type and LockType
 //to the Recordset here.
 hr = pRstStores->Open("stores",
 strCnn,adOpenForwardOnly,adLockReadOnly,adCmdTable);

 //Loop through the recordset displaying the contents
 //of the stor_name field, the field's defined size,
 //and its actual size.

 pRstStores->MoveFirst();

 while(!(pRstStores->EndOfFile))
 {
 strMessage = "Store Name: ";
 strMessage += (_bstr_t)pRstStores->Fields->
 Item["stor_name"]->Value + "\n";
 strMessage += "Defined Size: ";
 strMessage += (_bstr_t)pRstStores->Fields->
 Item["stor_name"]->DefinedSize + "\n";
 strMessage += "Actual Size: ";
 strMessage += (_bstr_t) pRstStores->Fields->
 Item["stor_name"]->ActualSize + "\n";

 printf("%s\n",(LPCSTR)strMessage);
 printf("Press any key to continue...");
 getch();
 //Clear the screen for the next display
 system("cls");
 pRstStores->MoveNext();
 }
 }
 catch(_com_error &e)
 {
 _variant_t vtConnect = pRstStores->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 printf("Error:\n");
 printf("Code = %08lx\n", e.Error());
 printf("Message = %s\n", e.ErrorMessage());
 printf("Source = %s\n", (LPCSTR) e.Source());
 printf("Description = %s\n", (LPCSTR) e.Description());
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 if (pRstStores)
 if (pRstStores->State == adStateOpen)
 pRstStores->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

VOID PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;
 long nCount = 0;
 long i = 0;

 if( (pConnection->Errors->Count) > 0)
 {
 nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,(LPCSTR ) pErr->Description);
 }
 }
}
// EndActualSizeCpp


EmptyCell.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

EmptyCell.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleLeft

expression A variable that represents an EmptyCell object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


NavigationButton.PressedForeColor Property (Access)

 Copy code hover
[image]

NavigationButton.PressedForeColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the text displayed on the control when the user clicks it. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .PressedForeColor

expression A variable that represents a NavigationButton object.

Remarks

The PressedForeColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


TextBox.MouseMove Event (Access)

 Copy code hover
[image]

TextBox.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents a TextBox object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


CheckBox.Visible Property (Access)

 Copy code hover
[image]

CheckBox.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents a CheckBox object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


OptionGroup Members (Access)

 Copy code hover
[image]

OptionGroup Members (Access)
Send feedback

Published: July 16, 2012

An option group on a form or report displays a limited set of alternatives. An option group makes selecting a value easy since you can just click the value you want. Only one option in an option group can be selected at a time.

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.
Undo | You can use the Undo method to reset a control or form when its value has been changed.

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
ColumnHidden | You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.
ColumnOrder | You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.
ColumnWidth | You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DefaultValue | Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HideDuplicates | You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the option group is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
ValidationRule | You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.
ValidationText | Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.
Value | Gets or sets whether or not the specified option button is selected. Read/write Variant.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified option group is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


DoCmd.OpenStoredProcedure Method (Access)

 Copy code hover
[image]

DoCmd.OpenStoredProcedure Method (Access)
See also Send feedback

Published: July 16, 2012

The OpenStoredProcedure method carries out the OpenStoredProcedure action in Visual Basic.

Syntax

expression .OpenStoredProcedure(ProcedureName, View, DataMode)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
ProcedureName | Required | Variant | A string expression that's the valid name of a stored procedure in the current database. If you execute Visual Basic code containing the OpenStoredProcedure method in a library database, Microsoft Access looks for the stored procedure with this name first in the library database, then in the current database.
View | Optional | AcView | A AcView constant that specifies the view in which the stored procedure will open. The default value is acViewNormal.
DataMode | Optional | AcOpenDataMode | A AcOpenDataMode constant that specifies the data entry mode for the stored procedure. The default value is acEdit.

Remarks

In a Microsoft Access project, you can use the OpenStoredProcedure method to open a stored procedure in Datasheet view, stored procedure Design view, or Print Preview. This method runs the named stored procedure when opened in Datasheet view. You can select the data entry mode for the stored procedure and restrict the records that the stored procedure displays.

If you don't want to display the system messages that normally appear when a stored procedure is run (indicating it's a stored procedure and showing how many records will be affected), you can use the SetWarnings method to suppress the display of these messages.

Example

The following example opens the Employees stored procedure in Design view.

VBA Copy code Copy code
DoCmd.OpenStoredProcedure "Employees", 1

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


How to: Calculate Elapsed Time

 Copy code hover
[image]

How to: Calculate Elapsed Time
Send feedback

This topic explains how Microsoft Access stores the Date/Time data type and why you may receive unexpected results when you calculate or compare dates and times.

Storing Date/Time Data

Microsoft Access stores the Date/Time data type as a double-precision, floating-point number (up to 15 decimal places). The integer portion of the double-precision number represents the date; the decimal portion represents the time.

Valid date values range from -647,434 (January 1, 100 A.D.) to 2,958,465 (December 31, 9999 A.D.). A date value of 0 represents December 30, 1899. Microsoft Access stores dates prior to December 30, 1899 as negative numbers.

Valid time values range from .0 (00:00:00) to .99999 (23:59:59). The numeric value represents a fraction of one day. You can convert the numeric value into hours, minutes, and seconds by multiplying the numeric value by 24.

Double Number | Date Portion | Actual Date | Time Portion | Actual Time
1.0 | 1 | December 31,1899 | .0 | 12:00:00 A.M.
2.5 | 2 | January 1, 1900 | .5 | 12:00:00 P.M.
27468.96875 | 27468 | March 15, 1975 | .96875 | 11:15:00 P.M.
33914.125 | 33914 | November 6, 1992 |  |

Calculating Time Data

Because a time value is stored as a fraction of a 24-hour day, you may receive incorrect formatting results when you calculate time intervals greater than 24 hours. To work around this behavior, you can create a user-defined function to ensure that time intervals are formatted correctly.

The following procedure illustrates how to use the Format function to format time intervals. The procedure accepts two time values and prints their the interval between them to the Immediate window in several different formats.

VBA Copy code Copy code
Function ElapsedTime(endTime As Date, startTime As Date)
    Dim strOutput As String
    Dim Interval As Date

    ' Calculate the time interval.
    Interval = endTime - startTime

    ' Format and print the time interval in seconds.
    strOutput = Int(CSng(Interval * 24 * 3600)) & " Seconds"
    Debug.Print strOutput

    ' Format and print the time interval in minutes and seconds.
    strOutput = Int(CSng(Interval * 24 * 60)) & ":" & Format(Interval, "ss") _
        & " Minutes:Seconds"
    Debug.Print strOutput

    ' Format and print the time interval in hours, minutes and seconds.
    strOutput = Int(CSng(Interval * 24)) & ":" & Format(Interval, "nn:ss") _
           & " Hours:Minutes:Seconds"
    Debug.Print strOutput

    ' Format and print the time interval in days, hours, minutes and seconds.
    strOutput = Int(CSng(Interval)) & " days " & Format(Interval, "hh") _
        & " Hours " & Format(Interval, "nn") & " Minutes " & _
        Format(Interval, "ss") & " Seconds"
    Debug.Print strOutput

End Function

Comparing Date Data

Because dates and times are stored together as double-precision numbers, you may receive unexpected results when you compare Date/Time data. For example, if you type the following expression in the Immediate window , you receive a False (0) result even if today's date is 7/11/2006:

VBA Copy code Copy code
? Now()=DateValue("7/11/2006")

The Now function returns a double-precision number representing the current date and time. However, the DateValue function returns an integer number representing the date but not a fractional time value. As a result, Now equals DateValue only when Now returns a time of 00:00:00 (12:00:00 A.M.).

To receive accurate results when you compare date values, use one of the following functions. To test each function, type it in the Immediate window, substitute the current date for 7/11/2006, and then press ENTER:

To return an integer value, use the Date function:

VBA Copy code Copy code
?Date()=DateValue("7/11/2006")

To remove the fractional portion of the Now function, use the Int function:

VBA Copy code Copy code
?Int(Now())=DateValue("7/11/2006")

Comparing Time Data

When you compare time values, you may receive inconsistent results because a time value is stored as the fractional portion of a double-precision, floating-point number. For example, if you type the following expression in the Immediate window, you receive a False (0) result even though the two time values look the same:

VBA Copy code Copy code
var1 = #2:01:00 PM#
var2 = DateAdd("n", 10, var1)
? var2 = #2:11:00 PM#

When Microsoft Access converts a time value to a fraction, the calculated result may not be the exact equivalent of the time value. The small difference caused by the calculation is enough to produce a False (0) result when you compare a stored value to a constant value.

To receive accurate results when you compare time values, use one of the following methods. To test each method, type it in the Immediate window, and then press ENTER:

Add an associated date to the time comparison:

VBA Copy code Copy code
var1 = #7/11/2006 2:00:00 PM#
var2 = DateAdd("n", 10, var1)
? var2 = #7/11/2006 2:10:00 PM#

Convert the time values to String data types before you compare them:

VBA Copy code Copy code
var1 = #2:00:00 PM#
var2 = DateAdd("n", 10, var1)
? CStr(var2) = CStr(#2:10:00 PM#)

Use the DateDiff function to compare precise units such as seconds:

VBA Copy code Copy code
var1 = #2:00:00 PM#
var2 = DateAdd("n", 10, var1)
? DateDiff("s", var2, #2:10:00 PM#) = 0

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Summing elapsed time that could go over 24 hours

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.


NavigationButton.HoverTint Property (Access)

 Copy code hover
[image]

NavigationButton.HoverTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the HoverColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .HoverTint

expression A variable that represents a NavigationButton object.

Remarks

The HoverTint property contains a numeric expression that can be used to lighten the theme color in the HoverColor property. The default value of the HoverTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Index.Primary Property (DAO)

 Copy code hover
[image]

Index.Primary Property (DAO)
Send feedback

Sets or returns a value that indicates whether an Index object represents a primary key index for a table (Microsoft Access workspaces only).

Syntax

expression .Primary

expression A variable that represents an Index object.

Remarks

The Primary property setting is read/write for a new Index object not yet appended to a collection and read-only for an existing Index object in an Indexes collection. If the Index object is appended to the TableDef object but the TableDef object isn't appended to the TableDefs collection, the Index property is read/write.

A primary key index consists of one or more fields that uniquely identify all records in a table in a predefined order. Because the index field must be unique, the Unique property of the Index object is set to True. If the primary key index consists of more than one field, each field can contain duplicate values, but each combination of values from all the indexed fields must be unique. A primary key index consists of a key for the table and usually contains the same fields as the primary key.

Note Note

You don't have to create indexes for tables, but in large, unindexed tables, accessing a specific record can take a long time. The Attributes property of each Field object in the Index object determines the order of records and consequently determines the access techniques to use for that index. When you create a new table in your database, it's a good idea to create an index on one or more fields that uniquely identify each record, and then set the Primary property of the Index object to True.

When you set a primary key for a table, the primary key is automatically defined as the primary key index for the table.

Example

This example uses the Primary property to designate a new Index in a new TableDef as the primary Index for that table. Note that setting the Primary property to True automatically sets Unique and Required properties to True as well.

VBA Copy code Copy code
Sub PrimaryX()

 Dim dbsNorthwind As Database
 Dim tdfNew As TableDef
 Dim idxNew As Index
 Dim idxLoop As Index
 Dim fldLoop As Field
 Dim prpLoop As Property

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 ' Create and append a new TableDef object to the
 ' TableDefs collection of the Northwind database.
 Set tdfNew = dbsNorthwind.CreateTableDef("NewTable")
 tdfNew.Fields.Append tdfNew.CreateField("NumField", _
 dbLong, 20)
 tdfNew.Fields.Append tdfNew.CreateField("TextField", _
 dbText, 20)
 dbsNorthwind.TableDefs.Append tdfNew

 With tdfNew
 ' Create and append a new Index object to the
 ' Indexes collection of the new TableDef object.
 Set idxNew = .CreateIndex("NumIndex")
 idxNew.Fields.Append idxNew.CreateField("NumField")
 idxNew.Primary = True
 .Indexes.Append idxNew
 Set idxNew = .CreateIndex("TextIndex")
 idxNew.Fields.Append idxNew.CreateField("TextField")
 .Indexes.Append idxNew

 Debug.Print .Indexes.Count & " Indexes in " & _
 .Name & " TableDef"

 ' Enumerate Indexes collection.
 For Each idxLoop In .Indexes

 With idxLoop
 Debug.Print " " & .Name

 ' Enumerate Fields collection of each Index
 ' object.
 Debug.Print " Fields"
 For Each fldLoop In .Fields
 Debug.Print " " & fldLoop.Name
 Next fldLoop

 ' Enumerate Properties collection of each
 ' Index object.
 Debug.Print " Properties"
 For Each prpLoop In .Properties
 Debug.Print " " & prpLoop.Name & _
 " = " & IIf(prpLoop = "", "[empty]", _
 prpLoop)
 Next prpLoop
 End With

 Next idxLoop

 End With

 dbsNorthwind.TableDefs.Delete tdfNew.Name
 dbsNorthwind.Close

End Sub


Property not found. (Error 3270)

 Copy code hover
[image]

Property not found. (Error 3270)
Send feedback

The specified property could not be found.

Possible causes:

  • The property does not exist. Check the spelling of the property in your code.

  • If the property is user-defined, it may have been deleted from the collection.

  • You do not have adequate permissions to create a list on the specified Microsoft SharePoint Foundation site.


Attachment.KeyDown Event (Access)

 Copy code hover
[image]

Attachment.KeyDown Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyDown(KeyCode, Shift)

expression A variable that represents an Attachment object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

Note Note

The KeyDown event applies only to forms and controls on a form, not controls on a report.

To run a macro or event procedure when these events occur, set the OnKeyDown property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, and then the KeyUp event occurs.

Although the KeyDown event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyDown event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyDown event occurs when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


TabControl.GridlineWidthTop Property (Access)

 Copy code hover
[image]

TabControl.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthTop

expression A variable that represents a TabControl object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Recordset.LastUpdated Property (DAO)

 Copy code hover
[image]

Recordset.LastUpdated Property (DAO)
Send feedback

Returns the date and time of the most recent change made to a base table. Read-only Variant.

Syntax

expression .LastUpdated

expression A variable that represents a Recordset object.

Remarks

The date and time settings are derived from the computer on which the base table was created or last updated.


Cannot add record(s); primary key for table

 Copy code hover
[image]

Cannot add record(s); primary key for table <name> not in result set. (Error 3347)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for more information.


Cannot enter value into blank field on 'one' side of outer join. (Error 3332)

 Copy code hover
[image]

Cannot enter value into blank field on 'one' side of outer join. (Error 3332)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for more information.


Read Method (ADO)

 Copy code hover
[image]

Read Method (ADO)
Send feedback

Reads a specified number of bytes from a binary Stream object.

Syntax

Variant = Stream.Read (NumBytes )

Parameters

  • NumBytes

  • Optional. A Long value that specifies the number of bytes to read from the file or the StreamReadEnum value adReadAll, which is the default.

Return Value

The Read method reads a specified number of bytes or the entire stream from a Stream object and returns the resulting data as a Variant.

Remarks

If NumBytes is more than the number of bytes left in the Stream, only the bytes remaining are returned. The data read is not padded to match the length specified by NumBytes. If there are no bytes left to read, a variant with a null value is returned. Read cannot be used to read backwards.

Note Note

NumBytes always measures bytes. For text Stream objects (Type is adTypeText), use ReadText.


Recordset2.AbsolutePosition Property (DAO)

 Copy code hover
[image]

Recordset2.AbsolutePosition Property (DAO)
Send feedback

Sets or returns the relative record number of a Recordset2 object's current record.

Syntax

expression .AbsolutePosition

expression A variable that represents a Recordset2 object.

Remarks

You can use the AbsolutePosition property to position the current record pointer to a specific record based on its ordinal position in a dynaset- or snapshot-type Recordset2 object. You can also determine the current record number by checking the AbsolutePosition property setting.

Because the AbsolutePosition property value is zero-based (that is, a setting of 0 refers to the first record in the Recordset2 object), you cannot set it to a value greater than or equal to the number of populated records; doing so causes a trappable error. You can determine the number of populated records in the Recordset2 object by checking the RecordCount property setting. The maximum allowable setting for the AbsolutePosition property is the value of the RecordCount property minus 1.

If there is no current record, as when there are no records in the Recordset2 object, AbsolutePosition returns -1. If the current record is deleted, the AbsolutePosition property value isn't defined, and a trappable error occurs if it's referenced. New records are added to the end of the sequence.

You shouldn't use this property as a surrogate record number. Bookmarks are still the recommended way of retaining and returning to a given position and are the only way to position the current record across all types of Recordset2 objects. In particular, the position of a record changes when one or more records preceding it are deleted. There is also no assurance that a record will have the same absolute position if the Recordset2 object is re-created again because the order of individual records within a Recordset object isn't guaranteed unless it's created with an SQL statement by using an ORDER BY clause.

Note Note

  • Setting the AbsolutePosition property to a value greater than zero on a newly opened but unpopulated Recordset2 object causes a trappable error. Populate the Recordset2 object first with the MoveLast method.

  • The AbsolutePosition property isn't available on forward-only-type Recordset2 objects, or on Recordset2 objects opened from pass-through queries against Microsoft Access database engine-connected ODBC databases.

Example

This example uses the AbsolutePosition property to track the progress of a loop that enumerates all the records of a Recordset2.

Copy code Copy code
Sub AbsolutePositionX()

   Dim dbsNorthwind As Database
   Dim rstEmployees As Recordset2
   Dim strMessage As String

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   ' AbsolutePosition only works with dynasets or snapshots.
   Set rstEmployees = _
      dbsNorthwind.OpenRecordset("Employees", _
      dbOpenSnapshot)

   With rstEmployees
      ' Populate Recordset.
      .MoveLast
      .MoveFirst

      ' Enumerate Recordset.
      Do While Not .EOF
         ' Display current record information. Add 1 to
         ' AbsolutePosition value because it is zero-based.
         strMessage = "Employee: " & !LastName & vbCr & _
            "(record " & (.AbsolutePosition + 1) & _
            " of " & .RecordCount & ")"
         If MsgBox(strMessage, vbOKCancel) = vbCancel _
            Then Exit Do
         .MoveNext
      Loop

      .Close
   End With

   dbsNorthwind.Close

End Sub


Group Object (ADOX)

 Copy code hover
[image]

Group Object (ADOX)
Send feedback

Represents a group account that has access permissions within a secured database.

Remarks

The Groups collection of a Catalog represents all the catalog's group accounts. The Groups collection for a User represents only the group to which the user belongs.

With the properties, collections, and methods of a Group object, you can:

  • Identify the group with the Name property.

  • Determine whether a group has read, write, or delete permissions with the GetPermissions and SetPermissions methods.

  • Access the user accounts that have memberships in the group with the Users collection.

  • Access provider-specific properties with the Properties collection.


ToggleButton.Bevel Property (Access)

 Copy code hover
[image]

ToggleButton.Bevel Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bevel effect applied to the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .Bevel

expression A variable that represents a ToggleButton object.

Remarks

The Bevel property contains a numeric expression that represents the bevel effect applied to the specified object. The default value of the Bevel property is 0, which does not apply a bevel effect.

The Bevel effect values are listed in the following table.

Value | Effect
0 | None
1 | Circle
2 | Relaxed Inset
3 | Cross
4 | Cool Slant
5 | Angle
6 | Soft Round
7 | Convex
8 | Slope
9 | Divot
10 | Riblet
11 | Hard Edge
12 | Art Deco

To see the available bevel effects and apply a bevel through the user interface, first open the form or report in Layout view or Design view by right-clicking the form or report in the Navigation Pane, and then clicking the view you want. Then, click the object to which you want to apply a bevel effect. Next, on the Format tab, in the Control Formatting group, click Shape Effects, then click Bevel and choose a bevel effect. Notice that the bevel effects are indexed from left to right, and then top to bottom. So the first item, under No Bevel, has the value 0. Then, under Bevel, the first row contains bevel effects with values from 1 to 4. The second row from 5 to 8, and the third row from 9 to 12.

This property is not surfaced in the property sheet.

Example

The following code example sets the bevel effect to Cross.

VBA Copy code Copy code
Public Const BevelEffectNone = 0
Public Const BevelEffectCircle = 1
Public Const BevelEffectRelaxedInset = 2
Public Const BevelEffectCross = 3
Public Const BevelEffectCoolSlant = 4
Public Const BevelEffectAngle = 5
Public Const BevelEffectSoftRound = 6
Public Const BevelEffectConvex = 7
Public Const BevelEffectSlope = 8
Public Const BevelEffectDivot = 9
Public Const BevelEffectRiblet = 10
Public Const BevelEffectHardEdge = 11
Public Const BevelEffectArtDeco = 12
Me.ctl.Bevel = BevelEffectCross

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Image.ImageHeight Property (Access)

 Copy code hover
[image]

Image.ImageHeight Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ImageHeight property to determine the height in twips of the picture in an image control. Read/write Long.

Syntax

expression .ImageHeight

expression A variable that represents an Image object.

Remarks

This property is read-only in all views.

You can use the ImageHeight property together with the ImageWidth property to determine the size of a picture in an image control. You could then use this information to change the image control's Height and Width properties to match the size of the picture displayed.

Example

The following example prompts the user to enter the name of a bitmap and then assigns that bitmap to the Picture property of the Image1 image control. The ImageHeight and ImageWidth properties are used to resize the image control to fit the size of the bitmap.

VBA Copy code Copy code
Sub GetNewPicture(frm As Form)
    Dim ctlImage As Control
    Set ctlImage = frm!Image1
    ctlImage.Picture = InputBox("Enter path and " _
        & "file name for new bitmap")
    ctlImage.Height = ctlImage.ImageHeight
    ctlImage.Width = ctlImage.ImageWidth
End Sub

See also

Concepts

Image Object

Other resources

Image Object Members


QueryDef.Properties Property (DAO)

 Copy code hover
[image]

QueryDef.Properties Property (DAO)
Send feedback

Returns the Properties collection of the specified object. Read-only.

Syntax

expression .Properties

expression A variable that represents a QueryDef object.


Report.OpenArgs Property (Access)

 Copy code hover
[image]

Report.OpenArgs Property (Access)
See also Send feedback

Published: July 16, 2012

Determines the string expression specified by the OpenArgs argument of the OpenReport method that opened a Report. Read/write Variant.

Syntax

expression .OpenArgs

expression A variable that represents a Report object.

Remarks

This property is available only by using a macro or by using Visual Basic with the OpenReport method of the DoCmd object. This property setting is read-only in all views.

To use the OpenArgs property, open a report by using the OpenReport method of the DoCmd object and set the OpenArgs argument to the desired string expression. The OpenArgs property setting can then be used in code for the report, such as in an Openevent procedure. You can also refer to the property setting in a macro, such as an Open macro, or an expression, such as an expression that sets the ControlSource property for a control on the form.

See also

Concepts

Report Object

Other resources

Report Object Members


QueryDef.Cancel Method (DAO)

 Copy code hover
[image]

QueryDef.Cancel Method (DAO)
Send feedback

Syntax

expression .Cancel

expression A variable that represents a QueryDef object.

Remarks

Use the Cancel method to terminate execution of an asynchronous Execute or OpenConnection method call (that is, the method was invoked with the dbRunAsync option). Cancel will return a run-time error if dbRunAsync was not used in the method you're trying to terminate.


NavigationControl.Visible Property (Access)

 Copy code hover
[image]

NavigationControl.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .Visible

expression A variable that represents a NavigationControl object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Coalesce Function (Access 2013 custom web app)

 Copy code hover
[image]

Coalesce Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the first expression that is not NULL from a list of arguments.

Syntax

Coalesce (Value, [Value], …,[Value])

The Coalesce function contains the following arguments

Argument name | Description
Value | An expression.

Remarks

If all arguments are NULL, Coalesce returns NULL.

Example

The following expression is used as the validation rule for a table. The expression ensures that entries are made in the First Name, Last Name, Email, Mobile Phone, Work Phone, Home Phone, and Company fields before a record is committed. If any of the listed fields are left blank, the Coalesce function returns Null, which violates the validation rule.

Copy code Copy code
Coalesce([First Name],[Last Name],[Email],[Mobile Phone],[Work Phone],[Home Phone],[Company]) Is Not Null


Index Object (DAO)

 Copy code hover
[image]

Index Object (DAO)
Send feedback

Index objects specify the order of records accessed from database tables and whether or not duplicate records are accepted, providing efficient access to data. For external databases, Index objects describe the indexes established for external tables (Microsoft Access workspaces only).

Remarks

The Microsoft Access database engine uses indexes when it joins tables and creates Recordset objects. Indexes determine the order in which table-type Recordset objects return records, but they don't determine the order in which the Microsoft Access database engine stores records in the base table or the order in which any other type of Recordset object returns records.

With an Index object, you can:

  • Use the Required property to determine whether the Field objects in the index require values that are not Null, and then use the IgnoreNulls property to determine whether the null values have index entries.

  • Use the Primary and Unique properties to determine the ordering and uniqueness of the Index object.

The Microsoft Access database engine maintains all base table indexes automatically. It updates indexes whenever you add, change, or delete records from the base table. Once you create the database, use the CompactDatabase method periodically to bring index statistics up-to-date.

When accessing a table-type Recordset object, you specify the order of records using the object's Index property. Set this property to the Name property setting of an existing Index object in the Indexes collection. This collection is contained by the TableDef object underlying the Recordset object that you're populating.

Note Note

You don't have to create indexes for a table, but for large, unindexed tables, accessing a specific record or processing joins can take a long time. Conversely, having too many indexes can slow down updates to the database as each of the table indexes is amended.

The Attributes property of each Field object in the index determines the order of records returned and consequently determines which access techniques to use for that index.

Each Field object in the Fields collection of an Index object is a component of the index. To define a new Index object, set its properties before you append it to a collection, making the Index object available for subsequent use.

Note Note

You can modify the Name property setting of an existing Index object only if the Updatable property setting of the containing TableDef object is True.

When you set a primary key for a table, the Microsoft Access database engine automatically defines it as the primary index. A primary index consists of one or more fields that uniquely identify all records in a table in a predefined order. Because the primary index field must be unique, the Microsoft Access database engine automatically sets the Unique property of the primary Index object to True. If the primary index consists of more than one field, each field can contain duplicate values, but the combination of values from all the indexed fields must be unique. A primary index consists of a key for the table and is always made up of the same fields as the primary key.

Important note Important

Make sure your data complies with the attributes of your new index. If your index requires unique values, make sure that there are no duplicates in existing data records. If duplicates exist, the Microsoft Access database engine can't create the index; a trappable error results when you attempt to use the Append method on the new index.

When you create a relationship that enforces referential integrity, the Microsoft Access database engine automatically creates an index with the Foreign property, set as the foreign key in the referencing table. After you've established a table relationship, the Microsoft Access database engine prevents additions or changes to the database that violate that relationship. If you set the Attributes property of the Relation object to allow cascading updates and cascading deletes, the Microsoft Access database engine updates or deletes records in related tables automatically.

  1. Use the CreateIndex method on a TableDef object.

  2. Use the CreateField method on the Index object to create a Field object for each field (column) to be included in the Index object.

  3. Set Index properties as needed.

  4. Append the Field object to the Fields collection.

  5. Append the Index object to the Indexes collection.

    Note Note

    The Clustered property is ignored for databases that use the Microsoft Access database engine, which doesn't support clustered indexes.

Example

This example creates a new Index object, appends it to the Indexes collection of the Employees TableDef, and then enumerates the Indexes collection of the TableDef. Finally, it enumerates a Recordset, first using the primary Index, and then using the new Index. The IndexOutput procedure is required for this procedure to run.

VBA Copy code Copy code
Sub IndexObjectX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim idxNew As Index
 Dim idxLoop As Index
 Dim rstEmployees As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set tdfEmployees = dbsNorthwind!Employees

 With tdfEmployees
 ' Create new index, create and append Field
 ' objects to its Fields collection.
 Set idxNew = .CreateIndex("NewIndex")

 With idxNew
 .Fields.Append .CreateField("Country")
 .Fields.Append .CreateField("LastName")
 .Fields.Append .CreateField("FirstName")
 End With

 ' Add new Index object to the Indexes collection
 ' of the Employees table collection.
 .Indexes.Append idxNew
 .Indexes.Refresh

 Debug.Print .Indexes.Count & " Indexes in " & _
 .Name & " TableDef"

 ' Enumerate Indexes collection of Employees
 ' table.
 For Each idxLoop In .Indexes
 Debug.Print " " & idxLoop.Name
 Next idxLoop

 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees")

 ' Print report using old and new indexes.
 IndexOutput rstEmployees, "PrimaryKey"
 IndexOutput rstEmployees, idxNew.Name
 rstEmployees.Close

 ' Delete new Index because this is a
 ' demonstration.
 .Indexes.Delete idxNew.Name
 End With

 dbsNorthwind.Close

End Sub

Sub IndexOutput(rstTemp As Recordset, _
 strIndex As String)
 ' Report function for FieldX.

 With rstTemp
 ' Set the index.
 .Index = strIndex
 .MoveFirst
 Debug.Print "Recordset = " & .Name & _
 ", Index = " & .Index
 Debug.Print " EmployeeID - Country - Name"

 ' Enumerate the recordset using the specified
 ' index.
 Do While Not .EOF
 Debug.Print " " & !EmployeeID & " - " & _
 !Country & " - " & !LastName & ", " & !FirstName
 .MoveNext
 Loop

 End With

End Sub

This example uses the CreateIndex method to create two new Index objects and then appends them to the Indexes collection of the Employees TableDef object. It then enumerates the Indexes collection of the TableDef object, the Fields collection of the new Index objects, and the Properties collection of the new Index objects. The CreateIndexOutput function is required for this procedure to run.

VBA Copy code Copy code
Sub CreateIndexX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim idxCountry As Index
 Dim idxFirstName As Index
 Dim idxLoop As Index

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set tdfEmployees = dbsNorthwind!Employees

 With tdfEmployees
 ' Create first Index object, create and append Field
 ' objects to the Index object, and then append the
 ' Index object to the Indexes collection of the
 ' TableDef.
 Set idxCountry = .CreateIndex("CountryIndex")
 With idxCountry
 .Fields.Append .CreateField("Country")
 .Fields.Append .CreateField("LastName")
 .Fields.Append .CreateField("FirstName")
 End With
 .Indexes.Append idxCountry

 ' Create second Index object, create and append Field
 ' objects to the Index object, and then append the
 ' Index object to the Indexes collection of the
 ' TableDef.
 Set idxFirstName = .CreateIndex
 With idxFirstName
 .Name = "FirstNameIndex"
 .Fields.Append .CreateField("FirstName")
 .Fields.Append .CreateField("LastName")
 End With
 .Indexes.Append idxFirstName

 ' Refresh collection so that you can access new Index
 ' objects.
 .Indexes.Refresh

 Debug.Print .Indexes.Count & " Indexes in " & _
 .Name & " TableDef"

 ' Enumerate Indexes collection.
 For Each idxLoop In .Indexes
 Debug.Print " " & idxLoop.Name
 Next idxLoop

 ' Print report.
 CreateIndexOutput idxCountry
 CreateIndexOutput idxFirstName

 ' Delete new Index objects because this is a
 ' demonstration.
 .Indexes.Delete idxCountry.Name
 .Indexes.Delete idxFirstName.Name
 End With

 dbsNorthwind.Close

End Sub

Function CreateIndexOutput(idxTemp As Index)

 Dim fldLoop As Field
 Dim prpLoop As Property

 With idxTemp
 ' Enumerate Fields collection of Index object.
 Debug.Print "Fields in " & .Name
 For Each fldLoop In .Fields
 Debug.Print " " & fldLoop.Name
 Next fldLoop

 ' Enumerate Properties collection of Index object.
 Debug.Print "Properties of " & .Name
 For Each prpLoop In .Properties
 Debug.Print " " & prpLoop.Name & " - " & _
 IIf(prpLoop = "", "[empty]", prpLoop)
 Next prpLoop
 End With

End Function


ReturnVar Properties (Access)

 Copy code hover
[image]

ReturnVar Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Name | Gets the name of the specified ReturnVar. Read-only String.
Value | Gets the value of the specified ReturnVar. Read-only Variant.


How to: Sort Records in Case-Sensitive ( ASCII) Order

 Copy code hover
[image]

How to: Sort Records in Case-Sensitive ( ASCII) Order
Send feedback

Microsoft Access sorts records in ascending or descending order without regard to case. However, you can use a user-defined function in a query to sort text data by its ASCII character values. This results in a case-sensitive order.

The following table demonstrates how the ascending order in Microsoft Access differs from a case-sensitive order.

Pre-Sort Order | Ascending Order | Case-Sensitive Order
c | A | A
D | a | B
a | B | C
d | b | D
B | C | a
C | c | b
A | D | c
b | d | d

Although the results in the Ascending Order column might at first appear somewhat unpredictable, they are not. In the Ascending Order column, "a" appears before "A," and " B" appears before "b." This occurs because, when evaluated as text values, "A" = "a" and "B" = "b," whether lowercase or uppercase. Access takes into account the original order of the values. In the Pre-Sort Order column, "a" precedes "A" and "B" precedes "b."

When the case-sensitive sort operation is performed, the text values are replaced with their ASCII values. For example, A = 65, a = 97, B = 66, b = 98, and so on.

The following user-defined function can be used to sort data in case-sensitive order.

VBA Copy code Copy code
Function StrToHex(S As Variant) As Variant
 Dim Temp As String, I As Integer

 If VarType(S) <> 8 Then

 StrToHex = S
 Else
 Temp = ""
 For I = 1 To Len(S)
 Temp = Temp & Format(Hex(Asc(Mid(S, I, 1))), "00")
 Next I
 StrToHex = Temp
 End If
End Function

Using the StrToHex Function

The preceding user-defined function, StrToHex, can be called from a query. When you pass the name of the sort field to this function, it will sort the field values in case-sensitive order. The following steps illustrate how to use the function.

  1. Create a query from which you will call this function.

  2. In the Show Table dialog box, click the table that you want to sort, and then click Add.

  3. Drag the fields you want to the grid.

  4. In the first blank column, in the Field row, type Expr1: StrToHex([SortField]).StrToHex is the user-defined function you created earlier. SortField is the name of the field that contains the case-sensitive values.

  5. In the Sort cell, click Ascending or Descending.If you choose ascending order, values beginning with uppercase letters will appear before those that begin with lowercase letters. Applying a descending-order sort does the opposite.

  6. Switch to Datasheet view.Access displays the records, sorted in case-sensitive order.


CommandButton.MouseUp Event (Access)

 Copy code hover
[image]

CommandButton.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents a CommandButton object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was released to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Microsoft OLE DB Provider for Microsoft Active Directory Service

 Copy code hover
[image]

Microsoft OLE DB Provider for Microsoft Active Directory Service
Send feedback

The Microsoft Active Directory Service Interfaces (ADSI) Provider allows ADO to connect to heterogeneous directory services through ADSI. This gives ADO applications read-only access to the Microsoft Windows NT 4.0 and Microsoft Windows 2000 directory services, in addition to any LDAP-compliant directory service and Novell Directory Services. ADSI itself is based on a provider model, so if there is a new provider giving access to another directory, the ADO application will be able to access it seamlessly. The ADSI provider is free-threaded and unicode enabled.

Connection String Parameters

To connect to this provider, set the Provider argument of the ConnectionString property to:

Copy code Copy code

ADSDSOObject

Reading the Provider property will return this string as well.

Typical Connection String

A typical connection string for this provider is:

Copy code Copy code

"Provider=ADSDSOObject;User ID=userName;Password=userPassword;"

The string consists of these keywords:

Keyword | Description
Provider | Specifies the OLE DB Provider for Microsoft Active Directory Service.
User ID | Specifies the user name. If this keyword is omitted, then the current logon is used.
Password | Specifies the user password. If this keyword is omitted, then the current logon is used.

Command Text

A four-part command text string is recognized by the provider in the following syntax:

Copy code Copy code
                      "
                      Root
                      ;
                      Filter
                      ;
                      Attributes[; Scope]"

Value | Description
Root | Indicates the ADsPath object from which to start the search (that is, the root of the search).
Filter | Indicates the search filter in the RFC 1960 format.
Attributes | Indicates a comma-delimited list of attributes to be returned.
Scope | Optional. A String that specifies the scope of the search. Can be one of the following: Base — Search only the base object (root of the search). OneLevel — Search only one level. Subtree — Search the entire subtree.

For example:

Copy code Copy code

"<LDAP://DC=ArcadiaBay,DC=COM>;(objectClass=*);sn, givenName; subtree"

The provider also supports SQL SELECT for command text. For example:

Copy code Copy code

"SELECT title, telephoneNumber From 'LDAP://DC=Microsoft, DC=COM' WHERE
objectClass='user' AND objectCategory='Person'"

The provider does not accept stored procedure calls or simple table names (for example, the CommandType property will always be adCmdText). See the Active Directory Service Interfaces documentation for a more complete description of the command text elements.

Recordset Behavior

The following tables list the features available on a Recordset object opened with this provider. Only the Static cursor type (adOpenStatic) is available.

For more detailed information about Recordset behavior for your provider configuration, run the Supports method and enumerate the Properties collection of the Recordset to determine whether provider-specific dynamic properties are present.

Availability of standard ADO Recordset properties:

Property | Availability
AbsolutePage | read/write
AbsolutePosition | read/write
ActiveConnection | read-only
BOF | read-only
Bookmark | read/write
CacheSize | read/write
CursorLocation | always adUseServer
CursorType | always adOpenStatic
EditMode | always adEditNone
EOF | read-only
Filter | read/write
LockType | read/write
MarshalOptions | not available
MaxRecords | read/write
PageCount | read-only
PageSize | read/write
RecordCount | read-only
Source | read/write
State | read-only
Status | read-only

Availability of standard ADO Recordset methods:

Method | Available?
AddNew | No
Cancel | No
CancelBatch | No
CancelUpdate | No
Clone | Yes
Close | Yes
Delete | No
GetRows | Yes
Move | Yes
MoveFirst | Yes
MoveLast | Yes
MoveNext | Yes
MovePrevious | Yes
NextRecordset | Yes
Open | Yes
Requery | Yes
Resync | Yes
Supports | Yes
Update | No
UpdateBatch | No


Form.DatasheetGridlinesColor Property (Access)

 Copy code hover
[image]

Form.DatasheetGridlinesColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DatasheetGridlinesColor property to specify the color of gridlines in a datasheet. Read/write Long.

Syntax

expression .DatasheetGridlinesColor

expression A variable that represents a Form object.

Remarks

The DatasheetGridlinesColor property applies only to objects in Datasheet view.

This property is only available in Visual Basic within a Microsoft Access database.

You can also use the RGB or QBColor functions to set this property.

This property setting affects the gridline color for the entire datasheet. It's not possible to set the gridline color of individual cells in Datasheet view.

The following table contains the properties that don't exist in the DAO Properties collection of until you set them by using the Formatting (Datasheet) toolbar or you can add them in an Access database by using the CreateProperty method and append it to the DAO Properties collection.

DatasheetFontItalic * | DatasheetForeColor *
DatasheetFontHeight * | DatasheetBackColor
DatasheetFontName * | DatasheetGridlinesColor
DatasheetFontUnderline * | DatasheetGridlinesBehavior
DatasheetFontWeight * | DatasheetCellsEffect
Note Note

When you add or set any property listed with an asterisk, Microsoft Access automatically adds all the properties listed with an asterisk to the Properties collection in the database.

See also

Concepts

Form Object

Other resources

Form Object Members


ListBox.Click Event (Access)

 Copy code hover
[image]

ListBox.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Syntax

expression .Click

expression A variable that represents a ListBox object.

Remarks

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Record(s) cannot be added; no insert permission on

 Copy code hover
[image]

Record(s) cannot be added; no insert permission on <name>. (Error 3107)
Send feedback

You must have insert data permission for the specified table or query to insert data into it. To change your permission assignments, see your system administrator or the table or query's creator.


WebBrowserControl.TabStop Property (Access)

 Copy code hover
[image]

WebBrowserControl.TabStop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .TabStop

expression A variable that represents a WebBrowserControl object.

Remarks

This property doesn't apply to toggle button controls when they appear in an option group. It applies only to the option group itself.

The TabStop property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) You can move the focus to the control by pressing the TAB key.
No | False | You can't move the focus to the control by pressing the TAB key.

When you create a control on a form, Microsoft Access automatically assigns the control a position in the form's tab order. Each new control is placed last in the tab order. If you want to prevent a control from being available when you tab through the controls in a form, set the control's TabStop property to No.

In Form view, hidden or disabled controls remain in the tab order but are skipped when you move through the controls by pressing TAB, even if their TabStop properties are set to Yes.

As long as a control's Enabled property is set to Yes, you can click the control or use an access key to select it, regardless of its TabStop property setting. For example, you can set the TabStop property of a command button to No to prevent users from selecting the button by pressing TAB. However, they can still click the command button to choose it.

Example

The following example disables the ability to move the focus to the "City" text box on the "Suppliers" form by using the TAB key.

VBA Copy code Copy code
Forms("Suppliers").Controls("City").TabStop = False

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


BoundObjectFrame Events (Access)

 Copy code hover
[image]

BoundObjectFrame Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.
Updated | The Updated event occurs when an OLE object's data has been modified.


Replace Function (Access 2013 custom web app)

 Copy code hover
[image]

Replace Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Replaces all occurrences of a specified string value with another string value.

Syntax

Replace(TextExpression, Pattern, Replacement)

The Replace function contains the following arguments.

Argument name | Description
TextExpression | The string expression to be searched.
Pattern | The substring to be found. Pattern cannot be an empty string ("").
Replacement | The replacement string.


ComboBox.NumeralShapes Property (Access)

 Copy code hover
[image]

ComboBox.NumeralShapes Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .NumeralShapes

expression A variable that represents a ComboBox object.

Remarks

The NumeralShapes property uses the following settings.

Setting | Visual Basic | Description
System | 0 | Numeral shapes determined by the Numeral Shapes system setting.
Arabic | 1 | Arabic digit shapes will be used to display and print numerals.
National | 2 | National digit shapes will be used to display and print numerals.
Context | 3 | Numeral shapes determined by Unicode context rules for adjacent text.

Example

The following example changes the NumeralShapes property for the selected control to 0 (numeral shapes will be determined by the Numeral Shapes system setting).

VBA Copy code Copy code
Public Sub ChangeNumeralShapes(ctl As Control)
 ctl.NumeralShapes = 0
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Using ADO with ADO MD

 Copy code hover
[image]

Using ADO with ADO MD
Send feedback

ADO and ADO MD are related but separate object models. ADO provides objects for connecting to data sources, executing commands, retrieving tabular data and schema metadata in a tabular format, and viewing provider error information. ADO MD provides objects for retrieving multidimensional data and viewing multidimensional schema metadata.

When working with an MDP you may choose to use ADO, ADO MD, or both with your application. By referencing both libraries within your project, you will have full access to the functionality provided by your MDP.

It is often useful for consumers to get a flattened, tabular view of a multidimensional dataset. You can do this by using the ADO Recordset object. Specify the source for your Cellset as the Source parameter for the Open method of a Recordset, rather than as the source for an ADO MD Cellset.

It may also be useful to view the schema metadata in a tabular view rather than as a hierarchy of objects. The ADO OpenSchema method on the Connection object allows the user to open a Recordset containing schema information. The QueryType parameter of the OpenSchema method has several SchemaEnum values that relate specifically to MDPs. These values are:

  • adSchemaCubes

  • adSchemaDimensions

  • adSchemaHierarchies

  • adSchemaLevels

  • adSchemaMeasures

  • adSchemaMembers

To use ADO enum values with ADO MD properties or methods, your project must reference both the ADO and ADO MD libraries. For example, you can use the ADO adState enum values with the ADO MD State property. For more information about establishing references to libraries, see the documentation of your development tool.

For more information about the ADO objects and methods, see the ADO API Reference.


Form.PictureType Property (Access)

 Copy code hover
[image]

Form.PictureType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.

Syntax

expression .PictureType

expression A variable that represents a Form object.

Remarks

The PictureType property uses the following settings.

Setting | Description
0 | (Default) The picture is embedded in the object and becomes part of the database file.
1 | The picture is linked to the object. Microsoft Access stores a pointer to the location of the picture on the disk.

This property can be set only in form Design view or report Design view.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

When this property is set to 0, the size of the database increases by the size of the picture file and, with some .wmf files, the size may increase as much as twice the size of the picture file. When this property is set to 1, there is no increase in the size of the database because Microsoft Access only saves a pointer to the picture's location on the disk.

Note Note

If a linked file is moved to another location on the disk, you must re-establish the link by using the object's Picture property.

For embedded pictures, the object's PictureData property stores the individual bits that make up a picture's image. For linked pictures, this property stores the path to the picture's file.

You can modify a linked picture by using a separate application and changes to the picture will appear the next time the object containing that picture is displayed in the database.

Example

The following example links the picture in the "Customer Photo" image control on the "Order Entry" form to the picture on the disk. The picture is not part of the database file.

VBA Copy code Copy code
Forms("Order Entry").Controls("Customer Photo").PictureType = 1

See also

Concepts

Form Object

Other resources

Form Object Members


Cannot make the

 Copy code hover
[image]

Cannot make the <name> table replicable due to too many columns. (Error 3705)
Send feedback

The table cannot be made replicable since replication system columns cannot be added. Adding these columns would exceed the column limit. Reduce the number of columns in the table prior to making it replicable.


Synchronizer could not find any scheduled or on-demand synchronizations to process. (Error 3514)

 Copy code hover
[image]

Synchronizer could not find any scheduled or on-demand synchronizations to process. (Error 3514)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


ImportExportSpecifications Properties (Access)

 Copy code hover
[image]

ImportExportSpecifications Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only ImportExportSpecification.
Parent | Returns the parent object for the specified object. Read-only Object.


Find Method Example (VB)

 Copy code hover
[image]

Find Method Example (VB)
Send feedback

This example uses the Recordset object's Find method to locate and count the number of business titles in the Pubs database. The example assumes the underlying provider does not support similar functionality.

Copy code Copy code

'BeginFindVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 ' connection and recordset variables
 Dim Cnxn As New ADODB.Connection
 Dim rstTitles As New ADODB.Recordset
 Dim strCnxn As String
 Dim strSQLTitles As String

 ' record variables
 Dim mark As Variant
 Dim count As Integer

 ' open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' open recordset with default parameters which are
 ' sufficient to search forward through a Recordset
 Set rstTitles = New ADODB.Recordset
 strSQLTitles = "SELECT title_id FROM titles"
 rstTitles.Open strSQLTitles, Cnxn, adOpenStatic, adLockReadOnly, adCmdText

 count = 0
 rstTitles.Find "title_id LIKE 'BU%'"

 Do While Not rstTitles.EOF
 'continue if last find succeeded
 Debug.Print "Title ID: "; rstTitles!title_id
 'count the last title found
 count = count + 1
 ' note current position
 mark = rstTitles.Bookmark
 rstTitles.Find "title_id LIKE 'BU%'", 1, adSearchForward, mark
 ' above code skips current record to avoid finding the same row repeatedly;
 ' last arg (bookmark) is redundant because Find searches from current position
 Loop

 Debug.Print "The number of business titles is " & count

 ' clean up
 rstTitles.Close
 Cnxn.Close
 Set rstTitles = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstTitles Is Nothing Then
 If rstTitles.State = adStateOpen Then rstTitles.Close
 End If
 Set rstTitles = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndFindVB


Fatal error accessing a local dropbox folder. (Error 3563)

 Copy code hover
[image]

Fatal error accessing a local dropbox folder. (Error 3563)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


CustomControl.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

CustomControl.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthLeft

expression A variable that represents a CustomControl object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


LevelName Property (ADO MD)

 Copy code hover
[image]

LevelName Property (ADO MD)
Send feedback

Indicates the name of the level of a member.

Return Values

Returns a String and is read-only.

Remarks

Use the LevelName property to retrieve the name of the level to which a member belongs. This corresponds to the Name property of a Level object.


Connection Members (DAO)

 Copy code hover
[image]

Connection Members (DAO)
Send feedback
Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.A Connection object represents a connection to an ODBC database (ODBCDirect workspaces only).

Methods

Name

Description

Cancel

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Cancels execution of a pending asynchronous method call (ODBCDirect workspaces only).

Close

Closes an open Connection.

CreateQueryDef

Creates a new QueryDef object.

Execute

Runs an action query or executes an SQL statement on the specified object.

OpenRecordset

Creates a new Recordset object and appends it to the Recordsets collection.

Properties

Name

Description

Connect

Sets or returns a value that provides information about the source of an open connection. Read/write String.

Database

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Returns the Database object that corresponds to this connection (ODBCDirect workspaces only).

Name

Rreturns the name of a Connection.

QueryDefs

Returns a QueryDefs collection that contains all of the QueryDef objects of the specified connection. Read-only.

QueryTimeout

Sets or returns a value that specifies the number of seconds to wait before a timeout error occurs when a query is executed on an ODBC data source.

RecordsAffected

Returns the number of records affected by the most recently invoked Execute method.

Recordsets

Returns a Recordsets collection that contains all of the open recordsets in the for the specified connection. Read-only.

StillExecuting

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Indicates whether or not an asynchronous operation (that is, a method called with the dbRunAsync option) has finished executing (ODBCDirect workspaces only).

Transactions

Returns a value that indicates whether an object supports transactions. Read-only Boolean.

Updatable

Returns a value that indicates whether you can change a DAO object. Read-only Boolean.Read-only.


Could not rename installable ISAM file. (Error 3013)

 Copy code hover
[image]

Could not rename installable ISAM file. (Error 3013)
Send feedback

You tried to rename a Btrieve, dBASE, or Paradox table, but the file that contains that table could not be renamed.

Possible causes:

  • The file has been defined as read-only in the operating system or by your network.

  • In a network environment, you do not have write privileges for the file.


Microsoft Access Constants - Overview

 Copy code hover
[image]

Microsoft Access Constants - Overview
Send feedback

Published: July 16, 2012

General

A constant represents a numeric or string value that doesn't change. You can use constants to improve the readability of your Visual Basic code and to make your code easier to maintain. In addition, the use of intrinsic constants ensures that code will continue to work even if the underlying values that the constants represent are changed in later releases of Microsoft Access.

Microsoft Access supports three types of constants:

  • Symbolic constants, which you create by using the Const statement and use in modules.

  • Intrinsic constants, which are part of Microsoft Access or a referenced library.

  • System-defined constants: True, False, and Null.

Symbolic Constants

Often, you'll use the same values repeatedly in your code, or you'll find that the code depends on certain numbers that have no obvious meaning. In these cases, you can make the code much easier to read and maintain by using symbolic or user-defined constants, which enable you to use a meaningful name in place of a number or string.

Once you have created a constant by using the Const statement, you can't modify it or assign a new value to it. You also can't create a constant that has the same name as an intrinsic constant.

The following examples show some of the ways you can use the Const statement to declare numeric and string constants:

Copy code Copy code
Const conPI = 3.14159265                ' Pi equals this number.
Const conPI2 = conPI * 2                ' A constant used to create another.
Const conVersion = "Version 12.0"        ' Declare a string constant.

Intrinsic Constants

In addition to the constants you declare with the Const statement, Microsoft Access automatically declares a number of intrinsic constants and provides access to the Visual Basic for Applications (VBA) constants, and ActiveX Data Objects (ADO) constants. You can also use constants in other referenced object libraries. For more information on adding references see Set References to Type Libraries.

Any intrinsic constant can be used in a macro or Visual Basic. These constants are available at all times. The specific built-in constants used with a particular function, method, or property are described in the Help topic for that function, method, or property.

Note Note

You can use the Object Browser to view lists of intrinsic constants from all available object libraries.

Intrinsic constants have a two letter prefix identifying the object library that defines the constant. Constants from the Microsoft Access library are prefaced with "ac"; constants from the ADO library are prefaced with "ad"; and constants from the Visual Basic library are prefaced with "vb". For example:

  • acForm

  • adAddNew

  • vbCurrency

Note Note

Because the values represented by the intrinsic constants may change in future versions of Microsoft Access, you should use the constants instead of their actual values. You can, however, display the actual value of a constant by choosing the constant in the Object Browser or by typing ?constantname in the Immediate window.

You can use intrinsic constants wherever you can use symbolic, or user-defined constants, including in expressions. The following example shows how you might use the intrinsic constant vbCurrency to determine whether the variable is a Variant for which the VarType function returns 6 (Currency):

Copy code Copy code
Dim varNum As Variant

If VarType(varNum) = vbCurrency Then
    Debug.Print "varNum contains Currency data."
Else
    Debug.Print "varNum doesn't contain Currency data."
End If

System-Defined Constants

You can use the system-defined constants True, False, and Null anywhere in Microsoft Access. For example, you can use True in the following macro condition expression. The condition is met if the Visible property setting for the Employees form equals True.

Copy code Copy code
Forms!Employees.Visible = True

You can use the constant Null anywhere in Microsoft Access. For example, you can use Null to set the DefaultValue property for a form control by using the following expression:

Copy code Copy code
=Null

General

A constant represents a numeric or string value that doesn't change. You can use constants to improve the readability of your Visual Basic code and to make your code easier to maintain. In addition, the use of intrinsic constants ensures that code will continue to work even if the underlying values that the constants represent are changed in later releases of Microsoft Access.

Microsoft Access supports three types of constants:

  • Symbolic constants, which you create by using the Const statement and use in modules.

  • Intrinsic constants, which are part of Microsoft Access or a referenced library.

  • System-defined constants: True, False, and Null.

Symbolic Constants

Often, you'll use the same values repeatedly in your code, or you'll find that the code depends on certain numbers that have no obvious meaning. In these cases, you can make the code much easier to read and maintain by using symbolic or user-defined constants, which enable you to use a meaningful name in place of a number or string.

Once you have created a constant by using the Const statement, you can't modify it or assign a new value to it. You also can't create a constant that has the same name as an intrinsic constant.

The following examples show some of the ways you can use the Const statement to declare numeric and string constants:

Copy code Copy code
Const conPI = 3.14159265                ' Pi equals this number.
Const conPI2 = conPI * 2                ' A constant used to create another.
Const conVersion = "Version 12.0"        ' Declare a string constant.

Intrinsic Constants

In addition to the constants you declare with the Const statement, Microsoft Access automatically declares a number of intrinsic constants and provides access to the Visual Basic for Applications (VBA) constants, and ActiveX Data Objects (ADO) constants. You can also use constants in other referenced object libraries. For more information on adding references see Set References to Type Libraries.

Any intrinsic constant can be used in a macro or Visual Basic. These constants are available at all times. The specific built-in constants used with a particular function, method, or property are described in the Help topic for that function, method, or property.

Note Note

You can use the Object Browser to view lists of intrinsic constants from all available object libraries.

Intrinsic constants have a two letter prefix identifying the object library that defines the constant. Constants from the Microsoft Access library are prefaced with "ac"; constants from the ADO library are prefaced with "ad"; and constants from the Visual Basic library are prefaced with "vb". For example:

  • acForm

  • adAddNew

  • vbCurrency

Note Note

Because the values represented by the intrinsic constants may change in future versions of Microsoft Access, you should use the constants instead of their actual values. You can, however, display the actual value of a constant by choosing the constant in the Object Browser or by typing ?constantname in the Immediate window.

You can use intrinsic constants wherever you can use symbolic, or user-defined constants, including in expressions. The following example shows how you might use the intrinsic constant vbCurrency to determine whether the variable is a Variant for which the VarType function returns 6 (Currency):

Copy code Copy code
Dim varNum As Variant

If VarType(varNum) = vbCurrency Then
    Debug.Print "varNum contains Currency data."
Else
    Debug.Print "varNum doesn't contain Currency data."
End If

System-Defined Constants

You can use the system-defined constants True, False, and Null anywhere in Microsoft Access. For example, you can use True in the following macro condition expression. The condition is met if the Visible property setting for the Employees form equals True.

Copy code Copy code
Forms!Employees.Visible = True

You can use the constant Null anywhere in Microsoft Access. For example, you can use Null to set the DefaultValue property for a form control by using the following expression:

Copy code Copy code
=Null


TextBox.BackStyle Property (Access)

 Copy code hover
[image]

TextBox.BackStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.

Syntax

expression .BackStyle

expression A variable that represents a TextBox object.

Remarks

The BackStyle property uses the following settings.

Setting | Visual Basic | Description
Normal | 1 | (Default for all controls except option group) The control has its interior color set by the BackColor property.
Transparent | 0 | (Default for option group) The control is transparent. The color of the form or report behind the control is visible.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

If the Transparent button on the Back Color button palette is selected, the BackStyle property is set to Transparent; otherwise the BackStyle property is set to Normal.

To make a command button invisible, set its Transparent property to Yes.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


InternetTimeout Property Example (VB)

 Copy code hover
[image]

InternetTimeout Property Example (VB)
Send feedback

This example demonstrates the InternetTimeout property, which exists on the DataControl and DataSpace objects. This example uses the DataControl object and sets the timeout to 20 seconds.

Visual Basic Copy code Copy code
'BeginInternetTimeoutVB

Public Sub Main()On Error GoTo ErrorHandler
Dim dc As RDS.DataControlDim rst As ADODB.Recordset
Set dc = New RDS.DataControl
dc.Server = "http://MyServer"dc.ExecuteOptions = 1
dc.FetchOptions = 1dc.Connect = "Provider='sqloledb';Data Source='MySqlServer';" & _
"Initial Catalog='Pubs';Integrated Security='SSPI';"dc.SQL = "SELECT * FROM Authors"
' Wait at least 20 secondsdc.InternetTimeout = 200
dc.Refresh' Use another Recordset as a convenience
Set rst = dc.RecordsetDo While Not rst.EOF
Debug.Print rst!au_fname & " " & rst!au_lnamerst.MoveNext
Loop
If rst.State = adStateOpen Then rst.CloseSet rst = Nothing
Set dc = NothingExit Sub
ErrorHandler:' clean up
If Not rst Is Nothing ThenIf rst.State = adStateOpen Then rst.Close
End IfSet rst = Nothing
Set dc = Nothing
If Err <> 0 ThenMsgBox Err.Source & "-->" & Err.Description, , "Error"
End If
End Sub'EndInternetTimeoutVB


Form.AfterInsert Property (Access)

 Copy code hover
[image]

Form.AfterInsert Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the AfterInsert event occurs. Read/write.

Syntax

expression .AfterInsert

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the AfterInsert event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).After Insert = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


AllDatabaseDiagrams.Count Property (Access)

 Copy code hover
[image]

AllDatabaseDiagrams.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents an AllDatabaseDiagrams object.

See also

Concepts

AllDatabaseDiagrams Collection

Other resources

AllDatabaseDiagrams Object Members


ADO Programmer's Reference

 Copy code hover
[image]

ADO Programmer's Reference
Send feedback

This section of the ADO documentation contains reference topics for ADO, RDS, ADO MD, and ADOX.

  • ADO API Reference

  • RDS API Reference

  • ADO MD API Reference

  • ADOX API Reference


ToggleButton.Undo Method (Access)

 Copy code hover
[image]

ToggleButton.Undo Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the Undo method to reset a control or form when its value has been changed.

Syntax

expression .Undo

expression A variable that represents a ToggleButton object.

Remarks

For example, you can use the Undo method to clear a change to a record that contains an invalid entry.

If the Undo method is applied to a form, all changes to the current record are lost. If the Undo method is applied to a control, only the control itself is affected.

This method must be applied before the form or control is updated. You may want to include this method in a form's BeforeUpdate event or in a control's Change event.

The Undo method offers an alternative to using the SendKeys statement to send the value of the ESC key in an event procedure.

Example

The following example shows how you can use the Undo method within a control's Change event procedure to force a field named LastName to reset to its original value, if it changed.

VBA Copy code Copy code
Private Sub LastName_Change()
 Me!LastName.Undo
End Sub

The next example uses the Undo method to reset all changes to a form before the form is updated.

VBA Copy code Copy code
Private Sub Form_BeforeUpdate(Cancel As Integer)
 Me.Undo
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Invalid replica path or name. (Error 3686)

 Copy code hover
[image]

Invalid replica path or name. (Error 3686)
Send feedback

The synchronizer identified by the HTTP address does not manage the database name specified in the URL.


Control.Requery Method (Access)

 Copy code hover
[image]

Control.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.

Syntax

expression .Requery

expression A variable that represents a Control object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts .

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate function.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

Example

The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form:

VBA Copy code Copy code
Public Sub RequeryList()

    Dim ctlCombo As Control

    ' Return Control object pointing to a combo box.
    Set ctlCombo = Forms!Employees!ReportsTo

    ' Requery source of data for list box.
    ctlCombo.Requery

End Sub

See also

Concepts

Control Object

Other resources

Control Object Members


ToggleButton.Shadow Property (Access)

 Copy code hover
[image]

ToggleButton.Shadow Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the Shadow effect applied to the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .Shadow

expression A variable that represents a ToggleButton object.

Remarks

The Shadow property uses one of the values listed in the following table.

Value | Effect
0 Default) | None
1 | Offset Diagonal Bottom Right
2 | Offset Bottom
3 | Offset Diagonal Bottom Left
4 | Offset Right
5 | Offset Center
6 | Offset Left
7 | Offset Diagonal Top Right
8 | Offset Top
9 | Offset Diagonal Top Left
10 | Inside Diagonal Top Left
11 | Inside Top
12 | Inside Diagonal Top Right
13 | Inside Left
14 | Inside Center
15 | Inside Right
16 | Inside Diagonal Bottom Left
17 | Inside Bottom
18 | Inside Diagonal Bottom Right
19 | Perspective Diagonal Upper Left
20 | Perspective Diagonal Upper Right
21 | Below
22 | Perspective Diagonal Lower Left
23 | Perspective Diagonal Lower Right

To see the available shadow effects and apply a shadow through the user interface, first open the form or report in Layout view or Design view by right-clicking the form or report in the Navigation Pane, and then clicking the view you want. Then, click the object to which you want to apply a shadow effect. Next, on the Format tab, in the Control Formatting group, click Shape Effects, then click Shadow and choose a shadow effect. Notice that the shadow effects are indexed from left to right, and then top to bottom. So the first item, under No Shadow, has the value 0. Then, under Outer, the first row contains shadow effects with values from 1 to 3. The second row from 4 to 6, and so on.

This property is not surfaced in the property sheet.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Report.PictureType Property (Access)

 Copy code hover
[image]

Report.PictureType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.

Syntax

expression .PictureType

expression A variable that represents a Report object.

Remarks

The PictureType property uses the following settings.

Setting | Description
0 | (Default) The picture is embedded in the object and becomes part of the database file.
1 | The picture is linked to the object. Microsoft Access stores a pointer to the location of the picture on the disk.

This property can be set only in form Design view or report Design view.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

When this property is set to 0, the size of the database increases by the size of the picture file and, with some .wmf files, the size may increase as much as twice the size of the picture file. When this property is set to 1, there is no increase in the size of the database because Microsoft Access only saves a pointer to the picture's location on the disk.

Note Note

If a linked file is moved to another location on the disk, you must re-establish the link by using the object's Picture property.

For embedded pictures, the object's PictureData property stores the individual bits that make up a picture's image. For linked pictures, this property stores the path to the picture's file.

You can modify a linked picture by using a separate application and changes to the picture will appear the next time the object containing that picture is displayed in the database.

Example

The following example links the picture in the "Customer Photo" image control on the "Order Entry" form to the picture on the disk. The picture is not part of the database file.

VBA Copy code Copy code
Forms("Order Entry").Controls("Customer Photo").PictureType = 1

See also

Concepts

Report Object

Other resources

Report Object Members


Remote Synchronizer is not configured for remote synchronization. (Error 3632)

 Copy code hover
[image]

Remote Synchronizer is not configured for remote synchronization. (Error 3632)
Send feedback

This remote Synchronizer is not configured to perform remote synchronization.


Report.PrtDevNames Property (Access)

 Copy code hover
[image]

Report.PrtDevNames Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PrtDevNames property to set or return information about the printer selected in the Print dialog box for a form or report. Read/write Variant.

Syntax

expression .PrtDevNames

expression A variable that represents a Report object.

Remarks

It is strongly recommended that you consult the Win32 Software Development Kit for complete documentation on the PrtDevMode, PrtDevNames, and PrtMip properties.

The PrtDevNames property is a variable-length structure that mirrors the DEVNAMES structure defined in the Win32 Software Development Kit.

The PrtDevNames property uses the following members.

Member | Description
DriverOffset | Specifies the offset from the beginning of the structure to a Null-terminated string that specifies the file name (without an extension) of the device driver. This string is used to specify which printer is initially displayed in the Print dialog box.
DeviceOffset | Specifies the offset from the beginning of the structure to the Null-terminated string that specifies the name of the device. This string can't be longer than 32 bytes (including the null character) and must be identical to the DeviceName member of the DEVMODE structure.
OutputOffset | Specifies the offset from the beginning of the structure to the Null-terminated string that specifies the MS-DOS device name for the physical output medium (output port); for example, "LPT1:".
Default | Specifies whether the strings specified in the DEVNAMES structure identify the default printer. Before the Print dialog box is displayed, if Default is set to 1 and all of the values in the DEVNAMES structure match the current default printer, the selected printer is set to the default printer. Default is set to 1 if the current default printer has been selected.

Microsoft Access sets the PrtDevNames property when you make selections in the Printer section of the Print dialog box. You can also set the property by using Visual Basic .

Microsoft Access uses the DEVNAMES structure to initialize the Print dialog box. When the user chooses OK to close the dialog box, information about the selected printer is returned by the PrtDevNames property.

See also

Concepts

Report Object

Other resources

Report Object Members


Attachment.Back Method (Access)

 Copy code hover
[image]

Attachment.Back Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the focus to the previous file in the specified Attachment control.

Version Information

Version Added: Access 2007

Syntax

expression .Back

expression A variable that represents an Attachment object.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Using the Java Type Library Wizard

 Copy code hover
[image]

Using the Java Type Library Wizard
Send feedback

The Java Type Library Wizard is a feature of Visual J++ 1.x, integrated into the Tools menu of the development environment. Its purpose is to search a type library and create a Java interface that allows access to COM objects. For Visual J++ 6.0, the Java Type Library Wizard has been replaced with ADO for Windows Foundation Classes.

The Java Type Library Wizard produces similar results as the command-line tools included with the Microsoft SDK for Java. However, you cannot step into the class wrappers that the Wizard generates, unlike the class wrappers generated by the Microsoft SDK for Java.

The Java Type Library Wizard generates the classes in the following location: \<windows directory>\Java\trustlib\msado15. The Summary.txt file, located in the directory where the classes were generated, shows the class definitions it generated.

The Java Type Library Wizard converts enumerated types, found in any given type library, to type INT (integer). It also defines an interface that corresponds to each enumerated type in the type library. You can reference the values of an ADO enumerated type with the following syntax:

Copy code Copy code

msado15.<Enum Name>.<constant Name>

An example of this is shown in the following code fragment for setting the CommandType property of a Command object:

Copy code Copy code

Cmd1.putCommandType( msado15.CommandTypeEnum.adCmdStoredProc );

Alternately, you could inherit from the enumerated type wrapper generated by the Java Type Library Wizard. If so, you could remove "msado15." from the syntax. However, your class would need to inherit from each Java object and enumerated type interface that it references to completely eliminate the need to reference msado15.* in front of all ADO objects and enumerated values.

For more sample code, see ADO Java Class Wrappers.

To run the Java Type Library Wizard from Visual J++ version 1.x

  1. From the Tools menu, select Java Type Library Wizard.

  2. Select "Microsoft ActiveX Data Objects Library" and click OK. This now (re)generates files in the \trustlib directory for ADO (by default at c:\winnt\java\trustlib\msado15). If you used the Microsoft SDK for Java to already generate classes for ADO, they will be replaced with those from the Java Type Library Wizard.

  3. To use these files, open your project in Visual J++. From the Project menu, choose Add To Project. Select Files, and add all of the .JAVA files generated in the \trustlib directory (by default at c:\winnt\java\trustlib\msado15) to your project.


Command Property (ADOX)

 Copy code hover
[image]

Command Property (ADOX)
Send feedback

Specifies an ADO Command object that can be used to create or execute the procedure.

Settings and Return Values

Sets or returns a valid ADO Command object.

Remarks

An error will occur when getting and setting this property if the provider does not support persisting commands.


NavigationControl.InSelection Property (Access)

 Copy code hover
[image]

NavigationControl.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .InSelection

expression A variable that represents a NavigationControl object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Cannot open the log file

 Copy code hover
[image]

Cannot open the log file <name> for writing. (Error 3474)
Send feedback

Make sure you have permission to write to the log file.


AllQueries.Item Property (Access)

 Copy code hover
[image]

AllQueries.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject,.

Syntax

expression .Item(var)

expression A variable that represents an AllQueries object.

Parameters

Name | Required/Optional | Data Type | Description
var | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

AllQueries Collection

Other resources

AllQueries Object Members


Error Object Reference (DAO)

 Copy code hover
[image]

Error Object Reference (DAO)
Send feedback

In this section

  • Error Object (DAO)

  • Error Members (DAO)

  • Error Properties (DAO)


ODBC - insert on a linked table

 Copy code hover
[image]

ODBC - insert on a linked table <table> failed. (Error 3155)
Send feedback

Using an ODBC connection, you tried to insert data into an ODBC database; that insertion could not be completed.

Possible causes:

  • The insertion would have caused a rule violation.

  • The ODBC database is read-only, or you do not have permission to insert data in that database. Resolve the read-only condition, or see your system administrator or the person who created the database to obtain the necessary permissions.

  • The ODBC database is on a network drive, and you are not connected to the network. Make sure the network is available, and then try the operation again.


OptionGroup.BorderStyle Property (Access)

 Copy code hover
[image]

OptionGroup.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Syntax

expression .BorderStyle

expression A variable that represents an OptionGroup object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


CodeProject.WebSite Property (Access)

 Copy code hover
[image]

CodeProject.WebSite Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the Uniform Resource Locator (URL) of the Web site to which the database has been published. Read-only String.

Version Information

Version Added: Access 2010

Syntax

expression .WebSite

expression A variable that represents a CodeProject object.

Remarks

The WebSite property contains a zero-length string if the database has not been published.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


ADOX Methods Reference

 Copy code hover
[image]

ADOX Methods Reference
Send feedback

In this section

  • ADOX Methods

  • Append Method (ADOX Columns)

  • Append Method (ADOX Groups)

  • Append Method (ADOX Indexes)

  • Append Method (ADOX Keys)

  • Append Method (ADOX Procedures)

  • Append Method (ADOX Tables)

  • Append Method (ADOX Users)

  • Append Method (ADOX Views)

  • ChangePassword Method (ADOX)

  • Create Method (ADOX)

  • Delete Method (ADOX Collections)

  • GetObjectOwner Method (ADOX)

  • GetPermissions Method (ADOX)

  • SetPermissions Method (ADOX)


Cannot perform this operation. (Error 3032)

 Copy code hover
[image]

Cannot perform this operation. (Error 3032)
Send feedback

Possible causes:

  • You tried to delete the only user account in the group Admins. The group Admins must have at least one user account. If you want to delete this account, create a new account and add it to the group Admins, or add an existing account to the group Admins, and then delete the account.

  • You tried to put a user in a group to which the user already belongs, by appending either a Group object to a User object's Groups collection that already has a Group object of the same name or a User object to a Group object's Users collection that already has a User object of the same name.


BoundObjectFrame.KeyDown Event (Access)

 Copy code hover
[image]

BoundObjectFrame.KeyDown Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyDown(KeyCode, Shift)

expression A variable that represents a BoundObjectFrame object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyDown property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyDown event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyDown event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyDown event occurs when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

Example

The following example determines whether you have pressed the SHIFT, CTRL, or ALT key.

To try the example, add the following event procedure to a form containing a text box named KeyHandler.

VBA Copy code Copy code
Private Sub KeyHandler_KeyDown(KeyCode As Integer, _
     Shift As Integer)
    Dim intShiftDown As Integer, intAltDown As Integer
    Dim intCtrlDown As Integer

    ' Use bit masks to determine which key was pressed.
    intShiftDown = (Shift And acShiftMask) > 0
    intAltDown = (Shift And acAltMask) > 0
    intCtrlDown = (Shift And acCtrlMask) > 0
    ' Display message telling user which key was pressed.
    If intShiftDown Then MsgBox "You pressed the SHIFT key."
    If intAltDown Then MsgBox "You pressed the ALT key."
    If intCtrlDown Then MsgBox "You pressed the CTRL key."
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


EOS Property (ADO)

 Copy code hover
[image]

EOS Property (ADO)
Send feedback

Indicates whether the current position is at the end of the stream.

Return Values

Returns a Boolean value that indicates whether the current position is at the end of the stream. EOS returns True if there are no more bytes in the stream; it returns False if there are more bytes following the current position.

To set the end of stream position, use the SetEOS method. To determine the current position, use the Position property.


Form.OnDelete Property (Access)

 Copy code hover
[image]

Form.OnDelete Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Delete box in the Properties window of a form. Read/write String.

Syntax

expression .OnDelete

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Delete event occurs when the user performs some action, such as pressing the DELETE key to delete a record, but before the record is actually deleted.

The OnDelete value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Delete box in the form's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Delete box is blank, the property value is an empty string.

Example

The following example associates the Delete event with the "Form_Delete" event for the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").OnDelete = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


Status Property Example (Recordset) (VB)

 Copy code hover
[image]

Status Property Example (Recordset) (VB)
Send feedback

This example uses the Status property to display which records have been modified in a batch operation before a batch update has occurred.

Copy code Copy code

'BeginStatusRecordsetVB
Public Sub Main()
 On Error GoTo ErrorHandler

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

 ' connection and recordset variables
 Dim rstTitles As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim strSQLTitles As String

 ' open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' open recordset for batch update
 Set rstTitles = New ADODB.Recordset
 strSQLTitles = "Titles"
 rstTitles.Open strSQLTitles, Cnxn, adOpenKeyset, adLockBatchOptimistic, adCmdTable

 ' change the type of psychology titles
 Do Until rstTitles.EOF
 If Trim(rstTitles!Type) = "psychology" Then rstTitles!Type = "self_help"
 rstTitles.MoveNext
 Loop

 ' display Title ID and status
 rstTitles.MoveFirst
 Do Until rstTitles.EOF
 If rstTitles.Status = adRecModified Then
 Debug.Print rstTitles!title_id & " - Modified"
 Else
 Debug.Print rstTitles!title_id
 End If
 rstTitles.MoveNext
 Loop

 ' clean up
 rstTitles.Close
 Cnxn.Close
 Set rstTitles = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstTitles Is Nothing Then
 If rstTitles.State = adStateOpen Then
 ' Cancel the update because this is a demonstration
 rstTitles.CancelBatch
 rstTitles.Close
 End If
 End If
 Set rstTitles = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndStatusRecordsetVB


Error Object (ADO)

 Copy code hover
[image]

Error Object (ADO)
Send feedback

Contains details about data access errors that pertain to a single operation involving the provider.

Remarks

Any operation involving ADO objects can generate one or more provider errors. As each error occurs, one or more Error objects are placed in the Errors collection of the Connection object. When another ADO operation generates an error, the Errors collection is cleared, and the new set of Error objects is placed in the Errors collection.

Note Note

Each Error object represents a specific provider error, not an ADO error. ADO errors are exposed to the run-time exception-handling mechanism. For example, in Microsoft Visual Basic, the occurrence of an ADO-specific error will trigger an On Error event and appear in the Error object. For a complete list of ADO errors, see the ErrorValueEnum topic.

You can read an Error object's properties to obtain specific details about each error, including the following:

  • The Description property, which contains the text of the error. This is the default property.

  • The Number property, which contains the Long integer value of the error constant.

  • The Source property, which identifies the object that raised the error. This is particularly useful when you have several Error objects in the Errors collection following a request to a data source.

  • The SQLState and NativeError properties, which provide information from SQL data sources.

When a provider error occurs, it is placed in the Errors collection of the Connection object. ADO supports the return of multiple errors by a single ADO operation to allow for error information specific to the provider. To obtain this rich error information in an error handler, use the appropriate error-trapping features of the language or environment you are working with, then use nested loops to enumerate the properties of each Error object in the Errors collection.

Microsoft Visual Basic and VBScript UsersIf there is no valid Connection object, you will need to retrieve error information from the Error object.

Just as providers do, ADO clears the OLE Error Info object before making a call that could potentially generate a new provider error. However, the Errors collection on the Connection object is cleared and populated only when the provider generates a new error, or when the Clear method is called.

Some properties and methods return warnings that appear as Error objects in the Errors collection but do not halt a program's execution. Before you call the Resync, UpdateBatch, or CancelBatch methods on a Recordset object; the Open method on a Connection object; or set the Filter property on a Recordset object, call the Clear method on the Errors collection. That way, you can read the Count property of the Errors collection to test for returned warnings.


Custom numeric formats for the Format function (Access 2013 custom web app)

 Copy code hover
[image]

Custom numeric formats for the Format function (Access 2013 custom web app)
Send feedback

Learn how to control how a number is displayed by creating a user-defined number format.

Applies to: Access 2013

Introduction

You can change the way a number is displayed by creating a user-defined number format. A user-defined number format can have from one to three sections separated by a semicolon (;). If the Style argument of the Format Function (Access 2013 custom web app) function contains one of the predefined numeric formats, only one section is allowed.

Format Specifications

The following table lists characters you can use to create user-defined number formats.

Format specification

Description

None

Displays the number without formatting.

0 (zero character)

Digit placeholder. Displays a digit or a zero. If the expression has a digit in the position where the zero appears in the format string, displays the digit; otherwise, displays a zero in that position.

If the number has fewer digits than there are zeros (on either side of the decimal) in the format expression, displays leading or trailing zeros. If the number has more digits to the right side of the decimal separator than there are zeros to the right side of the decimal separator in the format expression, rounds the number to as many decimal places as there are zeros. If the number has more digits to the left of the decimal separator than there are zeros to the left of the decimal separator in the format expression, displays the additional digits without modification.

#

Digit placeholder. Displays a digit or nothing. If the expression has a digit in the position where the # character appears in the format string, displays the digit; otherwise, displays nothing in that position.

This symbol works exactly like the 0 digit placeholder, except that leading and trailing zeros aren't displayed if the number has fewer digits than there are # characters on either side of the decimal separator in the format expression.

. (dot character)

Decimal placeholder. The decimal placeholder determines how many digits are displayed to the left and right of the decimal separator. If the format expression contains only # characters to the left of this symbol; numbers smaller than 1 begin with a decimal separator. To display a leading zero displayed with fractional numbers, use zero as the first digit placeholder to the left of the decimal separator. In some locales, a comma is used as the decimal separator. The actual character that is used as a decimal placeholder in the formatted output depends on the number format recognized by the system. Thus, you should use the period as the decimal placeholder in your formats even if you are in a locale that uses a comma as a decimal placeholder. The formatted string will appear in the format correct for the locale.

%

Percent placeholder. Multiplies the expression by 100. The percent character (%) is inserted in the position where it appears in the format string.

, (comma character)

Thousand separator. The thousand separator separates thousands from hundreds in a number that has four or more places to the left of the decimal separator. Standard use of the thousand separator is specified if the format contains a thousand separator enclosed in digit placeholders (0 or #).

A thousand separator immediately to the left of the decimal separator (whether a decimal is specified) or as the rightmost character in the string means "scale the number by dividing it by 1,000, rounding as needed." Numbers smaller than 1,000 but greater or equal to 500 are displayed as 1, and numbers smaller than 500 are displayed as 0. Two adjacent thousand separators in this position scale by a factor of 1 million, and an additional factor of 1,000 for each additional separator.

Multiple separators in any position other than immediately to the left of the decimal separator or the rightmost position in the string are treated only as specifying the use of a thousand separator. In some locales, a period is used as a thousand separator. The actual character that is used as the thousand separator in the formatted output depends on the Number Format recognized by the system. Thus, you should use the comma as the thousand separator in your formats even if you are in a locale that uses a period as a thousand separator. The formatted string will appear in the format correct for the locale.

For example, consider the three following format strings:

"#,0.", which uses the thousands separator to format the number 100 million as the string "100,000,000".

"#0,.", which uses scaling by a factor of one thousand to format the number 100 million as the string "100000".

"#,0,.", which uses the thousands separator and scaling by one thousand to format the number 100 million as the string "100,000".

: (colon character)

Time separator. In some locales, other characters may be used to represent the time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character that is used as the time separator in formatted output is determined by the system settings.

/ (forward slash character)

Date separator. In some locales, other characters may be used to represent the date separator. The date separator separates the day, month, and year when date values are formatted. The actual character that is used as the date separator in formatted output is determined by the system settings.

E- , E+ , e- , e+

Scientific format. If the format expression contains at least one digit placeholder (0 or #) to the left of E-, E+, e-, or e+, the number is displayed in scientific format and E or e is inserted between the number and its exponent. The number of digit placeholders to the left determines the number of digits in the exponent. Use E- or e- to place a minus sign next to negative exponents. Use E+ or e+ to place a minus sign next to negative exponents and a plus sign next to positive exponents. You must also include digit placeholders to the right side of this symbol to achieve correct formatting.

- + $ ( )

Literal characters. These characters are displayed exactly as typed in the format string. To display a character other than one of those listed, precede it with a backslash (\) or enclose it in double quotation marks (" ").

\ (backward slash character)

Displays the next character in the format string. To display a character that has special meaning as a literal character, precede it with a backslash (\). The backslash itself isn't displayed. By using a backslash is the same as enclosing the next character in double quotation marks. To display a backslash, use two backslashes (\\).

Examples of characters that can't be displayed as literal characters are the date-formatting and time-formatting characters (a, c, d, h, m, n, p, q, s, t, w, y, /, and :), the numeric-formatting characters (#, 0, %, E, e, comma, and period), and the string-formatting characters (@, &, <, >, and !).

"ABC"

Displays the string inside the double quotation marks (" "). To include a string in the style argument within code, you must use Chr(34) to enclose the text (34 is the character code for a quotation mark (")).

The following table contains some sample format expressions for numbers. (These examples all assume that your system's locale setting is English-U.S.) The first column contains the format strings for the Format function. The other columns contain the resulting output if the formatted data has the value given in the column headings.

Format (Style) | "5" formatted as | "-5" formatted as | "0.5" formatted as | "0" formatted as
Zero-length string ("") | 5 | -5 | 0.5 | 0
0 | 5 | -5 | 1 | 0
0.00 | 5.00 | -5.00 | 0.50 | 0.00
#,##0 | 5 | -5 | 1 | 0
$#,##0;($#,##0) | $5 | ($5) | $1 | $0
$#,##0.00;($#,##0.00) | $5.00 | ($5.00) | $0.50 | $0.00
0% | 500% | -500% | 50% | 0%
0.00% | 500.00% | -500.00% | 50.00% | 0.00%
0.00E+00 | 5.00E+00 | -5.00E+00 | 5.00E-01 | 0.00E+00
0.00E-00 | 5.00E00 | -5.00E00 | 5.00E-01 | 0.00E00
"$#,##0;;\Z\e\r\o" | $5 | $-5 | $1 | Zero

Remarks

If you include semicolons with nothing between them, the missing section is displayed by using the format of the positive value.

Additional Resources

Format Function (Access 2013 custom web app)

Custom date and time formats for the Format function (Access 2013 custom web app)


ComboBox.AutoLabel Property (Access)

 Copy code hover
[image]

ComboBox.AutoLabel Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.

Syntax

expression .AutoLabel

expression A variable that represents a ComboBox object.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


CopyRecord, CopyTo, and SaveToFile Methods Example (VB)

 Copy code hover
[image]

CopyRecord, CopyTo, and SaveToFile Methods Example (VB)
Send feedback

This example demonstrates how to create copies of a file using Stream or Record objects. One copy is made to a Web folder for Internet publishing. Other properties and methods shown include Stream Type, Open, LoadFromFile, and Record Open.

Copy code Copy code

'BeginCopyRecordVB

'Note:
' This sample requires that "C:\checkmrk.wmf" and
' "http://MyServer/mywmf.wmf" exist.

Option Explicit

Private Sub Form_Load()
 On Error GoTo ErrorHandler

 ' Declare variables
 Dim strPicturePath, strStreamPath, strStream2Path, _
 strRecordPath, strStreamURL, strRecordURL As String
 Dim objStream, objStream2 As Stream
 Dim objRecord As Record
 Dim objField As Field

 ' Instantiate objects
 Set objStream = New Stream
 Set objStream2 = New Stream
 Set objRecord = New Record

 ' Initialize path and URL strings
 strPicturePath = "C:\checkmrk.wmf"
 strStreamPath = "C:\mywmf.wmf"
 strStreamURL = "URL=http://MyServer/mywmf.wmf"
 strStream2Path = "C:\checkmrk2.wmf"
 strRecordPath = "C:\mywmf.wmf"
 strRecordURL = "http://MyServer/mywmf2.wmf"

 ' Load the file into the stream
 objStream.Open
 objStream.Type = adTypeBinary
 objStream.LoadFromFile (strPicturePath)

 ' Save the stream to a new path and filename
 objStream.SaveToFile strStreamPath, adSaveCreateOverWrite

 ' Copy the contents of the first stream to a second stream
 objStream2.Open
 objStream2.Type = adTypeBinary
 objStream.CopyTo objStream2

 ' Save the second stream to a different path
 objStream2.SaveToFile strStream2Path, adSaveCreateOverWrite

 ' Because strStreamPath is a Web Folder, open a Record on the URL
 objRecord.Open "", strStreamURL

 ' Display the Fields of the record
 For Each objField In objRecord.Fields
 Debug.Print objField.Name & ": " & objField.Value
 Next

 ' Copy the record to a new URL
 objRecord.CopyRecord "", strRecordURL, , , adCopyOverWrite

 ' Load each copy of the graphic into Image controls for viewing
 Image1.Picture = LoadPicture(strPicturePath)
 Image2.Picture = LoadPicture(strStreamPath)
 Image3.Picture = LoadPicture(strStream2Path)
 Image4.Picture = LoadPicture(strRecordPath)

 ' clean up
 objStream.Close
 objStream2.Close
 objRecord.Close
 Set objStream = Nothing
 Set objStream2 = Nothing
 Set objRecord = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not objStream Is Nothing Then
 If objStream.State = adStateOpen Then objStream.Close
 End If
 Set objStream = Nothing

 If Not objStream2 Is Nothing Then
 If objStream2.State = adStateOpen Then objStream2.Close
 End If
 Set objStream2 = Nothing

 If Not objRecord Is Nothing Then
 If objRecord.State = adStateOpen Then objRecord.Close
 End If
 Set objRecord = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndCopyRecordVB


FormatCondition Members (Access)

 Copy code hover
[image]

FormatCondition Members (Access)
Send feedback

Published: July 16, 2012

The FormatCondition object represents a conditional format of a combo box or text box control and is a member of the FormatConditions collection.

Methods

Name | Description
Delete | Deletes the specified object.
Modify | You can use the Modify method to change the format conditions of a FormatCondition object in the FormatConditions collection of a combo box or text box control.

Properties

Name | Description
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
Expression1 | You can use the Expression1 property to return the values of a conditional format within a FormatCondition object. Read-only String.
Expression2 | You can use the Expression2 property to return the values of a conditional format within a FormatCondition object. Read-only String.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
LongestBarLimit | Gets or sets how the longest data bar is evaluated for the specified FormatCondition. Read/write AcFormatBarLimits.
LongestBarValue | Gets or sets a numeric expression that specifies the value of the longest bar of a FormatCondition. Read/write String.
Operator | You can use the Operator property to return the operator value for the conditional format or data validation of a FormatCondition object. Read-only AcFormatConditionOperator.
ShortestBarLimit | Gets or sets how the shortest data bar is evaluated for the specified FormatCondition. Read/write AcFormatBarLimits.
ShortestBarValue | Gets or sets a numeric expression that specifies the value of the shortest bar of a FormatCondition. Read/write String.
ShowBarOnly | Gets or sets whether the data bar or the data bar and its value are displayed. Set to True to display only the data bar. Read/write Boolean.
Type | Returns the value of a FormatCondition object type. Read-only AcFormatConditionType.


GetPermissions Method (ADOX)

 Copy code hover
[image]

GetPermissions Method (ADOX)
Send feedback

Returns the permissions for a group or user on an object or object container.

Syntax

ReturnValue = GroupOrUser.GetPermissions(Name, ObjectType [,ObjectTypeId])

Return Value

Returns a Long value that specifies a bitmask containing the permissions that the group or user has on the object. This value can be one or more of the RightsEnum constants.

Parameters

  • Name

  • A Variant value that specifies the name of the object for which to set permissions. Set Name to a null value if you want to get the permissions for the object container.

  • ObjectType

  • A Long value which can be one of the ObjectTypeEnum constants, that specifies the type of the object for which to get permissions.

  • ObjectTypeId

  • Optional. A Variant value that specifies the GUID for a provider object type not defined by the OLE DB specification. This parameter is required if ObjectType is set to adPermObjProviderSpecific; otherwise, it is not used.


Properties Collection (ADO) Reference

 Copy code hover
[image]

Properties Collection (ADO) Reference
Send feedback

In this section

  • Properties Collection (ADO)

  • Properties Collection Properties, Methods, and Events


GroupLevel.GroupInterval Property (Access)

 Copy code hover
[image]

GroupLevel.GroupInterval Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the GroupInterval property with the GroupOn property to specify how records are grouped in a report. Read/write Long.

Syntax

expression .GroupInterval

expression A variable that represents a GroupLevel object.

Remarks

The GroupInterval property specifies an interval value that records are grouped by. This interval differs depending on the data type and GroupOn property setting of the field or expression you're grouping on. For example, you can set the GroupInterval property to 1 if you want to group records by the first character of a Text field, such as ProductName.

The GroupInterval property settings are Long values that depend on the field's data type and its GroupOn property setting. The default GroupInterval setting is 1.

You can set the GroupInterval property only the Open event procedure of a report.

Note Note

To set the GroupInterval property to a value other than its default setting (1), you must first set the GroupHeader or GroupFooter property or both to Yes for the selected field or expression.

Here are examples of GroupInterval property settings for different field data types.

Field data type | GroupOn setting | GroupInterval setting
All | Each value | (Default) Set to 1.
Text | Prefix characters | Set to 3 for grouping by the first three characters in the field (for example, Chai, Chartreuse, and Chang would be grouped together).
Date/Time | Week | Set to 2 to return data in biweekly groups.
Date/Time | Hour | Set to 12 to return data in half-day groups.

Example

The following example sets the SortOrder and grouping properties for the first group level in the Products By Category report to create an alphabetical list of products.

VBA Copy code Copy code
Private Sub Report_Open(Cancel As Integer)
 ' Set SortOrder property to ascending order.
 Me.GroupLevel(0).SortOrder = False
 ' Set GroupOn property.
 Me.GroupLevel(0).GroupOn = 1
 ' Set GroupInterval property to 1.
 Me.GroupLevel(0).GroupInterval = 1
 ' Set KeepTogether property to With First Detail.
 Me.GroupLevel(0).KeepTogether = 2
End Sub

See also

Concepts

GroupLevel Object

Other resources

GroupLevel Object Members


Attachment.DefaultPicture Property (Access)

 Copy code hover
[image]

Attachment.DefaultPicture Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the path and file name of the graphic to be used as a background picture on an attachment control. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .DefaultPicture

expression A variable that represents an Attachment object.

Remarks

The DefaultPicture property contains (bitmap) or the path and file name of a bitmap or other type of graphic to be displayed.

The default setting is (none). After the graphic is loaded into the object, the property setting is (bitmap) or the path and file name of the graphic. If you delete the path and file name of the graphic from the property setting, the picture is deleted from the object and the property setting is again (none).

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


CommandButton.CursorOnHover Property (Access)

 Copy code hover
[image]

CommandButton.CursorOnHover Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the type of mouse cursor displayed when the user rests the pointer on a button. Read/write AcCursorOnHover.

Version Information

Version Added: Access 2007

Syntax

expression .CursorOnHover

expression A variable that represents a CommandButton object.

Remarks

Setting the CursorOnHover property to acCursorOnHoverHyperlinkHand can be useful when a button's BackStyle property is set to Transparent.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


DoCmd.SetFilter Method (Access)

 Copy code hover
[image]

DoCmd.SetFilter Method (Access)
See also Send feedback

Published: July 16, 2012

Use the SetFilter method to apply a filter to the records in the active datasheet, form, report, or table.

Version Information

Version Added: Access 2010

Syntax

expression .SetFilter(FilterName, WhereCondition, ControlName)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
FilterName | Optional | Variant | If provided, the name of a query or of a filter saved as a query. This argument or the WhereCondition argument is required.
WhereCondition | Optional | Variant | If provided, a SQL WHERE clause that restricts the records in the datasheet, form, report, or table.
ControlName | Optional | Variant | If provided, the name of the control that corresponds to the subform or subreport to be filtered. If empty, the current object is filtered.

Remarks

When you run this method, the filter is applied to the table, form, report or datasheet (for example, query result) that is active and has the focus.

The Filter property of the active object is used to save the WhereCondition argument and apply it at a later time. Filters are saved with the objects in which they are created. They are automatically loaded when the object is opened, but they are not automatically applied.

To automatically apply a filter when the object is opened, set the FilterOnLoad property to True.

Example

The following code example filters the active object so that it displays only records that begin with "NWTB".

VBA Copy code Copy code
DoCmd.SetFilter WhereCondition:="[Product Code] Like ""NWTB*"""

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


ToggleButton.Move Method (Access)

 Copy code hover
[image]

ToggleButton.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a ToggleButton object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


ReturnVars Members (Access)

 Copy code hover
[image]

ReturnVars Members (Access)
Send feedback

Published: July 16, 2012

Represents the collection of ReturnVar objects.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | Gets the number of ReturnVar objects in the ReturnVars collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only ReturnVar.
Parent | Returns the parent object for the specified object. Read-only Object.


ODBC - field would be too long; data truncated. (Error 3231)

 Copy code hover
[image]

ODBC - field would be too long; data truncated. (Error 3231)
Send feedback

You tried to perform a task on an ODBC data source that would have resulted in a field that is too long. The data has been truncated to the maximum allowable length.


Application.BuildCriteria Method (Access)

 Copy code hover
[image]

Application.BuildCriteria Method (Access)
See also Send feedback

Published: July 16, 2012

The BuildCriteria method returns a parsed criteria string as it would appear in the query design grid, in Filter By Form or Server Filter By Form mode. For example, you may want to set a form's Filter or ServerFilter property based on varying criteria from the user. You can use the BuildCriteria method to construct the string expression argument for the Filter or ServerFilter property. String.

Syntax

expression .BuildCriteria(Field, FieldType, Expression)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Field | Required | String | The field for which you wish to define criteria.
FieldType | Required | Integer | An intrinsic constant denoting the data type of the field. Can be set to one of the DAO DataTypeEnum values.
Expression | Required | String | A string expression identifying the criteria to be parsed.

Return Value

String

Remarks

The BuildCriteria method enables you to easily construct criteria for a filter based on user input. It parses the expression argument in the same way that the expression would be parsed had it been entered in the query design grid, in Filter By Form or Server Filter By Form mode.

For example, a user creating a query on an Orders table might restrict the result set to orders placed after January 1, 1995, by setting criteria on an OrderDate field. The user might enter an expression such as the following one in the Criteria row beneath the OrderDate field:

>1-1-95

Microsoft Access automatically parses this expression and returns the following expression:

>#1/1/95#

The BuildCriteria method provides the same parsing from Visual Basic code. For example, to return the preceding correctly parsed string, you can supply the following arguments to the BuildCriteria method:

VBA Copy code Copy code
Dim strCriteria As String
strCriteria = BuildCriteria("OrderDate", dbDate, ">1-1-95")

Since you need to supply criteria for the Filter property in correctly parsed form, you can use the BuildCriteria method to construct a correctly parsed string.

You can use the BuildCriteria method to construct a string with multiple criteria if those criteria refer to the same field. For example, you can use the BuildCriteria method with the following arguments to construct a string with multiple criteria relating to the OrderDate field:

VBA Copy code Copy code
strCriteria = BuildCriteria("OrderDate", dbDate, ">1-1-95 and <5-1-95")

This example returns the following criteria string:

OrderDate>#1/1/95# And OrderDate<#5/1/95#

However, if you wish to construct a criteria string that refers to multiple fields, you must create the strings and concatenate them yourself. For example, if you wish to construct criteria for a filter to show records for orders placed after 1-1-95 and for which freight is less than $50, you would need to use the BuildCriteria method twice and concatenate the resulting strings.

Example

The following example prompts the user to enter the first few letters of a product's name and then uses the BuildCriteria method to construct a criteria string based on the user's input. Next, the procedure provides this string as an argument to the Filter property of a Products form. Finally, the FilterOn property is set to apply the filter.

VBA Copy code Copy code
Sub SetFilter()
 Dim frm As Form, strMsg As String
 Dim strInput As String, strFilter As String

 ' Open Products form in Form view.
 DoCmd.OpenForm "Products"
 ' Return Form object variable pointing to Products form.
 Set frm = Forms!Products
 strMsg = "Enter one or more letters of product name " _
 & "followed by an asterisk."
 ' Prompt user for input.
 strInput = InputBox(strMsg)
 ' Build criteria string.
 strFilter = BuildCriteria("ProductName", dbText, strInput)
 ' Set Filter property to apply filter.
 frm.Filter = strFilter
 ' Set FilterOn property; form now shows filtered records.
 frm.FilterOn = True
End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


Section II: Remote Data Service

 Copy code hover
[image]

Section II: Remote Data Service
Send feedback

This section contains the following chapters:

  • Chapter 11: RDS Fundamentals

  • Chapter 12: RDS Tutorial

  • Chapter 13: RDS Usage and Security


QueryDef.StillExecuting Property (DAO)

 Copy code hover
[image]

QueryDef.StillExecuting Property (DAO)
Send feedback

Syntax

expression .StillExecuting

expression A variable that represents a QueryDef object.

Remarks

Use the StillExecuting property to determine if the most recently called asynchronous Execute or OpenConnection method (that is, a method executed with the dbRunAsync option) is complete. While the StillExecuting property is True, any returned object cannot be accessed.

Once the StillExecuting property returns False, following the OpenConnection call that returns the associated Connection object, the object can be referenced. So long as StillExecuting remains True, the object may not be referenced, other than to read the StillExecuting property.

Use the Cancel method to terminate execution of a task in progress.


Image.Requery Method (Access)

 Copy code hover
[image]

Image.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.

Syntax

expression .Requery

expression A variable that represents an Image object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts .

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate function.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

Example

The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form:

VBA Copy code Copy code
Public Sub RequeryList()

    Dim ctlCombo As Control

    ' Return Control object pointing to a combo box.
    Set ctlCombo = Forms!Employees!ReportsTo

    ' Requery source of data for list box.
    ctlCombo.Requery

End Sub

See also

Concepts

Image Object

Other resources

Image Object Members


Understanding the Customization File

 Copy code hover
[image]

Understanding the Customization File
Send feedback

Each section header in the customization file consists of square brackets ([]) containing a type and parameter. The four section types are indicated by the literal strings connect, sql, userlist, or logs. The parameter is the literal string, the default, a user-specified identifier, or nothing.

Therefore, each section is marked with one of the following section headers:

Copy code Copy code

[ connect   default     ]
[ connect   identifier  ]
[ sql       default     ]
[ sql       identifier  ]
[ userlist  identifier  ]
[ logs                  ]

The section headers have the following parts.

Part

Description

connect

A literal string that modifies a connection string.

sql

A literal string that modifies a command string.

userlist

A literal string that modifies the access rights of a specific user.

logs

A literal string that specifies a log file recording operational errors.

default

A literal string that is used if no identifier is specified or found.

identifier

A string that matches a string in the connect or command string.

  • Use this section if the section header contains connect and the identifier string is found in the connection string.

  • Use this section if the section header contains sql and the identifier string is found in the command string.

  • Use this section if the section header contains userlist and the identifier string matches a connect section identifier.

The DataFactory calls the handler, passing client parameters. The handler searches for whole strings in the client parameters that match identifiers in the appropriate section headers. If a match is found, the contents of that section are applied to the client parameter.

A particular section is used under the following circumstances:

  • A connect section is used if the value part of the client connect string keyword, "Data Source=value", matches a connect section identifier.

  • An sql section is used if the client command string contains a string that matches an sql section identifier.

  • A connect or sql section with a default parameter is used if there is no matching identifier.

  • A userlist section is used if the userlist section identifier matches a connect section identifier. If there is a match, the contents of the userlist section are applied to the connection governed by the connect section.

  • If the string in a connection or command string does not match the identifier in any connect or sql section header, and there is no connect or sql section header with a default parameter, then the client string is used without modification.

  • The logs section is used whenever the DataFactory is in operation.


ObjectFrame.GridlineStyleRight Property (Access)

 Copy code hover
[image]

ObjectFrame.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified frame. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleRight

expression A variable that represents an ObjectFrame object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Application.DVarP Method (Access)

 Copy code hover
[image]

Application.DVarP Method (Access)
See also Send feedback

Published: July 16, 2012

Calculates the variance of a population in a specified set of records (a domain).

Syntax

expression .DVarP(Expr, Domain, Criteria)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Expr | Required | String | An expression that identifies the numeric field on which you want to find the variance. It can be a string expression identifying a field from a table or query, or it can be an expression that performs a calculation on data in that field . In expr, you can include the name field in a table, a control on a form, a constant, or a function. If expr includes a function, it can be either built-in or user-defined, but not another domain aggregate or SQL aggregate function. Any field included in expr must be a numeric field.
Domain | Required | String | A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter.
Criteria | Optional | Variant | An optional string expression used to restrict the range of data on which the DVarP function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the DVarP function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain; otherwise the DVarP function returns a Null.

Return Value

Variant

Remarks

If domain refers to fewer than two records or if fewer than two records satisfy criteria, the DVarP functions return a Null, indicating that a variance can't be calculated.

Whether you use the DVarP function in a macro, module, query expression, or calculated control, you must construct the criteria argument carefully to ensure that it will be evaluated correctly.

You can use the DVarP function to specify criteria in the Criteria row of a select query, in a calculated field expression in a query, or in the Update To row of an update query.

Note Note

You can use the DVarP function or the VarP function in a calculated field expression in a totals query. If you use the DVarP function, values are calculated before data is grouped. If you use the VarP function, the data is grouped before values in the field expression are evaluated.

If you simply want to find the standard deviation across all records in domain, use the Var or VarP function.

Example

The following example returns estimates of the variance for a population and a population sample for orders shipped to the United Kingdom. The domain is an Orders table. The criteria argument restricts the resulting set of records to those for which ShipCountry equals UK.

VBA Copy code Copy code
Dim dblX As Double
Dim dblY As Double

' Sample estimate.
dblX = DVar("[Freight]", "Orders", "[ShipCountry] = 'UK'")

' Population estimate.
dblY = DVarP("[Freight]", "Orders", "[ShipCountry] = 'UK'")

The following examples show how to use various types of criteria with the DVarP function.

Sample code provided by: Community Member Icon The UtterAccess community | About the Contributors

Copy code Copy code
    ' ***************************
    ' Typical Use
    ' Numerical values. Replace "number" with the number to use.
    variable = DVarP("[FieldName]", "TableName", "[Criteria] = number")

    ' Strings.
    ' Numerical values. Replace "string" with the string to use.
    variable = DVarP("[FieldName]", "TableName", "[Criteria]= 'string'")

    ' Dates. Replace "date" with the string to use.
    variable = DVarP("[FieldName]", "TableName", "[Criteria]= #date#")
    ' ***************************

    ' ***************************
    ' Referring to a control on a form
    ' Numerical values
    variable = DVarP("[FieldName]", "TableName", "[Criteria] = " & Forms!FormName!ControlName)

    ' Strings
    variable = DVarP("[FieldName]", "TableName", "[Criteria] = '" & Forms!FormName!ControlName & "'")

    ' Dates
    variable = DVarP("[FieldName]", "TableName", "[Criteria] = #" & Forms!FormName!ControlName & "#")
    ' ***************************

    ' ***************************
    ' Combinations
    ' Multiple types of criteria
    variable = DVarP("[FieldName]", "TableName", "[Criteria1] = " & Forms![FormName]![Control1] _
             & " AND [Criteria2] = '" & Forms![FormName]![Control2] & "'" _
            & " AND [Criteria3] =#" & Forms![FormName]![Control3] & "#")

    ' Use two fields from a single record.
    variable = DVarP("[LastName] & ', ' & [FirstName]", "tblPeople", "[PrimaryKey] = 7")

    ' Expressions
    variable = DVarP("[Field1] + [Field2]", "tableName", "[PrimaryKey] = 7")

    ' Control Structures
    variable = DVarP("IIf([LastName] Like 'Smith', 'True', 'False')", "tableName", "[PrimaryKey] = 7")
    ' ***************************

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Application Object

Other resources

Application Object Members


Values for the PaperSize Member

 Copy code hover
[image]

Values for the PaperSize Member
Send feedback

Published: July 16, 2012

Value | Paper size
1 | Letter (8.5 x 11 in.)
2 | Letter Small (8.5 x 11 in.)
3 | Tabloid (11 x 17 in.)
4 | Ledger (17 x 11 in.)
5 | Legal (8.5 x 14 in.)
6 | Statement (5.5 x 8.5 in.)
7 | Executive (7.25 x 10.5 in.)
8 | A3 (297 x 420 mm)
9 | A4 (210 x 297 mm)
10 | A4 Small (210 x 297 mm)
11 | A5 (148 x 210 mm)
12 | B4 (250 x 354 mm)
13 | B5 (182 x 257 mm)
14 | Folio (8.5 x 13 in.)
15 | Quarto (215 x 275 mm)
16 | 11 x 17 in.
18 | Note (8.5 x 11 in.)
19 | Envelope #9 (3.875 x 8.875 in.)
20 | Envelope #10 (4.125 x 9.5 in.)
21 | Envelope #11 (4.5 x 10.375 in.)
22 | Envelope #12 (4.25 x 11 in.)
23 | Envelope #14 (5 x 11.5 in.)
24 | C size sheet (17 x 22 in.)
25 | D size sheet (22 x 34 in.)
26 | E size sheet (34 x 44 in.)
27 | Envelope DL (110 x 220 mm)
28 | Envelope C5 (162 x 229 mm)
29 | Envelope C3 (324 x 458 mm)
30 | Envelope C4 (229 x 324 mm)
31 | Envelope C6 (114 x 162 mm)
32 | Envelope C65 (114 x 229 mm)
33 | Envelope B4 (250 x 353 mm)
34 | Envelope B5 (176 x 250 mm
35 | Envelope B6 (176 x 125 mm)
36 | Envelope (110 x 230 mm)
37 | Envelope Monarch (3.875 x 7.5 in.)
38 | 6-3/4 Envelope (3.625 x 6.5 in.)
39 | US Std Fanfold (14.875 x 11 in.)
40 | German Std Fanfold (8.5 x 12 in.)
41 | German Legal Fanfold (8.5 x 13 in.)
256 | User-defined


Wrong number of arguments used with function. (Error 2439)

 Copy code hover
[image]

Wrong number of arguments used with function. (Error 2439)
Send feedback

You entered an expression that has a function with the wrong number of arguments. Check the function to verify how many arguments it takes, or check the expression to make sure you entered it correctly.


OptionButton.OnKeyUp Property (Access)

 Copy code hover
[image]

OptionButton.OnKeyUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Up box in the Properties window. Read/write String.

Syntax

expression .OnKeyUp

expression A variable that represents an OptionButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyUp event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyUp

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Report.WindowTop Property (Access)

 Copy code hover
[image]

Report.WindowTop Property (Access)
See also Send feedback

Published: July 16, 2012

Returns an Integer indicating the screen position in twips of the top edge of a report relative to the top of the Microsoft Access window. Read-only.

Syntax

expression .WindowTop

expression A variable that represents a Report object.

Remarks

Use the Move method to change the position of a report.

See also

Concepts

Report Object

Other resources

Report Object Members


Not a valid bookmark. (Error 3159)

 Copy code hover
[image]

Not a valid bookmark. (Error 3159)
Send feedback

You tried to set a bookmark to an invalid string.

This error can occur if you set the Bookmark property to a string that is invalid or was not saved from previously reading a Bookmark property. For example, the following code produces this error:

Visual Basic Copy code Copy code
Sub SetBookmark()
    Dim dbs As Database
    Dim rstEmployees As Recordset
    Dim strPlaceholder As String

    Set dbs = OpenDatabase("Northwind.mdb")

    Set rstEmployees = _
        dbs.OpenRecordset _
        ("Employees", dbOpenDynaset)

    strPlaceholder = "1"

    rstEmployees.Bookmark = strPlaceholder    ' Not a valid bookmark.
End Sub


Command and CommandText Properties Example (VC++)

 Copy code hover
[image]

Command and CommandText Properties Example (VC++)
Send feedback

The following code demonstrates how to use the Command property to update the text of a procedure.

Copy code Copy code

// BeginCommandTextCpp
// This sample runs correctly only if procedure 'CustomerById'
// exists. If the procedure doesn't exist, please use
// 'ADOXProceduresAppend.cpp' to creat it.

#import "c:\Program Files\Common Files\system\ado\msadox.dll" no_namespace
#import "c:\Program Files\Common Files\system\ado\msado15.dll"

#include "iostream.h"
#include "stdio.h"
#include "conio.h"

//Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void ProcedureTextX(void);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 ProcedureTextX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// ProcedureTextX Function //
// //
//////////////////////////////////////////////////////////
void ProcedureTextX()
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.
 _CatalogPtr m_pCatalog = NULL;

 // Define ADODB object pointers.
 ADODB::_ConnectionPtr m_pCnn = NULL;
 ADODB::_CommandPtr m_pCommand = NULL;

 try
 {
 //Open the Connection
 TESTHR(hr = m_pCnn.CreateInstance(__uuidof(ADODB::Connection)));
 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof(Catalog)));
 TESTHR(hr = m_pCommand.CreateInstance(__uuidof(ADODB::Command)));
 m_pCnn->Open("Provider='Microsoft.JET.OLEDB.4.0';"
 "data source='c:\\Program Files\\Microsoft Office"
 "\\Office\\Samples\\Northwind.mdb';","","",NULL);

 // Open the catalog
 m_pCatalog->PutActiveConnection(_variant_t((IDispatch *)m_pCnn));

 // Get the Command
 m_pCommand = m_pCatalog->Procedures->GetItem("CustomerById")->GetCommand();

 // Update the CommandText
 m_pCommand->PutCommandText("PARAMETERS [CustId] Text;select "
 "CustomerId, CompanyName, ContactName "
 "from Customers where CustomerId = [CustId]");
 printf("CommandText is updated.\n");

 // Update the Procedure
 m_pCatalog->Procedures->GetItem("CustomerById")->PutCommand(
 _variant_t((IDispatch *)m_pCommand));
 printf("Procedure 'CustomerById' is updated.\n");
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",(LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }
 catch(...)
 {
 cout << "Error occured in ProcedureTextX...."<< endl;
 }
}
// EndCommandTextCpp


ToggleButton.Controls Property (Access)

 Copy code hover
[image]

ToggleButton.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Syntax

expression .Controls

expression A variable that represents a ToggleButton object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Groups Collection (ADOX) Reference

 Copy code hover
[image]

Groups Collection (ADOX) Reference
Send feedback

In this section

  • Groups Collection (ADOX)

  • Groups Collection Properties, Methods, and Events (ADOX)


AccessObjectProperties Members (Access)

 Copy code hover
[image]

AccessObjectProperties Members (Access)
Send feedback

Published: July 16, 2012

The AccessObjectProperties collection contains all of the custom AccessObjectProperty objects of a specific instance of an object. These AccessObjectProperty objects (which are often just called properties) uniquely characterize that instance of the object.

Methods

Name | Description
Add | You can use the Add method to add a new property as an AccessObjectProperty object to the AccessObjectProperties collection of an AccessObject object.
Remove | You can use the Remove method to remove an AccessObjectProperty object from the AccessObjectProperties collection of an AccessObject object.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObjectProperty.
Parent | Returns the parent object for the specified object. Read-only.


CodeProject.ImportExportSpecifications Property (Access)

 Copy code hover
[image]

CodeProject.ImportExportSpecifications Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a ImportExportSpecifications collection that represents the collection of saved import or export operations for the specified object. Read-only.

Version Information

Version Added: Access 2007

Syntax

expression .ImportExportSpecifications

expression A variable that represents a CodeProject object.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


Handline Errors in Visual J++

 Copy code hover
[image]

Handline Errors in Visual J++
Send feedback

Handle ADO errors in your Microsoft Visual J++ applications using a try catch block. Once an error has been thrown, you can iterate through the collection, successively handling each error. The following Visual J++ example shows a console application that deliberately causes an error.

When the catch block is activated, it calls the PrintProviderError function to display the errors. The PrintProviderError function iterates through the Errors collection and sends a line to the standard output device that describes each error in the collection.

Copy code Copy code

// BeginErrorExampleVJ
/**
 * This class can take a variable number of parameters on the command
 * line. Program execution begins with the main() method. The class
 * constructor is not invoked unless an object of type 'Class1'
 * created in the main() method.
 */

import com.ms.wfc.data.*;
import java.io.* ;

public class ErrorExample
{
 /**
 * The main entry point for the application.
 *
 * @param args Array of parameters passed to the application
 * via the command line.
 */
 public static void main (String[] args)
 {
 DescriptionX();
 System.exit(0);
 }

 static void DescriptionX()
 {
 BufferedReader in = new
 BufferedReader(new InputStreamReader(System.in));

 // Define ADO Objects.
 Connection cnConn1 = null;

 try
 {
 // Create an error by trying to
 // Open a database that doesn't exist.
 cnConn1 = new Connection();
 cnConn1.open("nothing");
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.
 PrintProviderError(cnConn1);
 }

 try
 {
 System.out.println("\nPress <Enter> key to continue.");
 in.readLine();
 }
 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }
 }

 // PrintProviderError Function
 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }
 }

 // PrintIOError Function
 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndErrorExampleVJ


Bookmark Property (ADO)

 Copy code hover
[image]

Bookmark Property (ADO)
Send feedback

Indicates a bookmark that uniquely identifies the current record in a Recordset object or sets the current record in a Recordset object to the record identified by a valid bookmark.

Settings and Return Values

Sets or returns a Variant expression that evaluates to a valid bookmark.

Remarks

Use the Bookmark property to save the position of the current record and return to that record at any time. Bookmarks are available only in Recordset objects that support bookmark functionality.

When you open a Recordset object, each of its records has a unique bookmark. To save the bookmark for the current record, assign the value of the Bookmark property to a variable. To quickly return to that record at any time after moving to a different record, set the Recordset object's Bookmark property to the value of that variable.

The user may not be able to view the value of the bookmark. Also, users should not expect bookmarks to be directly comparable — two bookmarks that refer to the same record may have different values.

If you use the Clone method to create a copy of a Recordset object, the Bookmark property settings for the original and the duplicate Recordset objects are identical and you can use them interchangeably. However, you cannot use bookmarks from different Recordset objects interchangeably, even if they were created from the same source or command.

Remote Data Service UsageWhen used on a client-side Recordset object, the Bookmark property is always available.


Module.InsertText Method (Access)

 Copy code hover
[image]

Module.InsertText Method (Access)
See also Send feedback

Published: July 16, 2012

The InsertText method inserts a specified string of text into a standard module or a class module.

Syntax

expression .InsertText(Text)

expression A variable that represents a Module object.

Parameters

Name | Required/Optional | Data Type | Description
Text | Required | String | The text to be inserted into the module.

Return Value

Nothing

Remarks

When you insert a string by using the InsertText method, Microsoft Access places the new text at the end of the module, after all other procedures.

To add multiple lines, include the intrinsic constant vbCrLf at the desired line breaks within the string that makes up the text argument. This constant forces a carriage return and line feed.

To specify at which line the text is inserted, use the InsertLines method. To insert code into the Declarations section of the module, use the InsertLines method rather than the InsertText method.

Note Note

In previous versions of Microsoft Access, the InsertText method was a method of the Application object. You can still use the InsertText method of the Application object, but it's recommended that you use the InsertText method of the Module object instead.

Example

The following example inserts a string of text into a standard module:

VBA Copy code Copy code
Function InsertProc(strModuleName) As Boolean
 Dim mdl As Module, strText As String

 On Error GoTo Error_InsertProc
 ' Open module.
 DoCmd.OpenModule strModuleName
 ' Return reference to Module object.
 Set mdl = Modules(strModuleName)
 ' Initialize string variable.
 strText = "Sub DisplayMessage()" & vbCrLf _
 & vbTab & "MsgBox ""Wild!""" & vbCrLf _
 & "End Sub"
 ' Insert text into module.
 mdl.InsertText strText
 InsertProc = True

Exit_InsertProc:
 Exit Function

Error_InsertProc:
 MsgBox Err & ": " & Err.Description
 InsertProc = False
 Resume Exit_InsertProc
End Function

See also

Concepts

Module Object

Other resources

Module Object Members


Failure creating file. (Error 3436)

 Copy code hover
[image]

Failure creating file. (Error 3436)
Send feedback

An error occurred while attempting to create a Microsoft Excel or text file or Lotus installable ISAM.

Possible causes:

  • Insufficient disk space

  • Network failure


Label Control (Access)

 Copy code hover
[image]

Label Control (Access)
Send feedback

Published: July 16, 2012

Labels on a form or report display descriptive text such as titles, captions, or brief instructions. Labels have certain characteristics:

  • Labels don't display values from fields or expressions.

  • Labels are always unbound.

  • Labels don't change as you move from record to record.

Remarks

A label can be attached to another control. When you create a text box, for example, it has an attached label that displays a caption for that text box. This label appears as a column heading in the Datasheet view of a form.

When you create a label by using the Label tool, the label stands on its own — it isn't attached to any other control. You use stand-alone labels for information such as the title of a form or report, or for other descriptive text. Stand-alone labels don't appear in Datasheet view.


Application.CreateForm Method (Access)

 Copy code hover
[image]

Application.CreateForm Method (Access)
See also Send feedback

Published: July 16, 2012

The CreateForm method creates a form and returns a Form object.

Syntax

expression .CreateForm(Database, FormTemplate)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Database | Optional | Variant | The name of the database that contains the form template you want to use to create a form. If you want the current database, omit this argument. If you want to use an open library database, specify the library database with this argument.
FormTemplate | Optional | Variant | The name of the form you want to use as a template to create a new form.

Return Value

Form

Remarks

You can use the CreateForm method when designing a wizard that creates a new form.

The CreateForm method opens a new, minimized form in form Design view.

If the name you use for the formtemplate argument isn't valid, Visual Basic uses the form template specified by the Form Template setting on the Forms/Reports tab of the Options dialog box.

Example

This example creates a new form in the Northwind sample database based on the Customers form, and sets its RecordSource property to the Customers table. Run this code from the Northwind sample database.

VBA Copy code Copy code
Sub NewForm()
 Dim frm As Form

 ' Create form based on Customers form.
 Set frm = CreateForm( , "Customers")
 DoCmd.Restore
 ' Set RecordSource property to Customers table.
 frm.RecordSource = "Customers"
End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


Page.PictureType Property (Access)

 Copy code hover
[image]

Page.PictureType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.

Syntax

expression .PictureType

expression A variable that represents a Page object.

Remarks

The PictureType property uses the following settings.

Setting | Description
0 | (Default) The picture is embedded in the object and becomes part of the database file.
1 | The picture is linked to the object. Microsoft Access stores a pointer to the location of the picture on the disk.

This property can be set only in form Design view or report Design view.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

When this property is set to 0, the size of the database increases by the size of the picture file and, with some .wmf files, the size may increase as much as twice the size of the picture file. When this property is set to 1, there is no increase in the size of the database because Microsoft Access only saves a pointer to the picture's location on the disk.

Note Note

If a linked file is moved to another location on the disk, you must re-establish the link by using the object's Picture property.

For embedded pictures, the object's PictureData property stores the individual bits that make up a picture's image. For linked pictures, this property stores the path to the picture's file.

You can modify a linked picture by using a separate application and changes to the picture will appear the next time the object containing that picture is displayed in the database.

Example

The following example links the picture in the "Customer Photo" image control on the "Order Entry" form to the picture on the disk. The picture is not part of the database file.

VBA Copy code Copy code
Forms("Order Entry").Controls("Customer Photo").PictureType = 1

See also

Concepts

Page Object

Other resources

Page Object Members


ComboBox.IMEMode Property (Access)

 Copy code hover
[image]

ComboBox.IMEMode Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .IMEMode

expression A variable that represents a ComboBox object.

Remarks

The IMEMode property uses the following settings.

Setting | Description | Visual Basic
No Control | Kanji Conversion Mode not set (default). | 0
On | Turns on Kanji Conversion Mode. | 1
Off | Turns off Kanji Conversion Mode. | 2
Disable | Disables Kanji Conversion Mode. | 3
Hiragana | Sets full pitch hiragana | 4
Full pitch Katakana | Sets full pitch katakana. | 5
Half pitch Katakana | Sets half pitch katakana. | 6
Full pitch Alpha/Num | Sets full pitch letters/numbers. | 7
Half pitch Alpha/Num | Sets half pitch letters/numbers. | 8
HangulFull | Sets full pitch hangul. | 9
Hangul | Sets half pitch hangul. | 10

You can specify the Kanji Conversion Mode when the focus shifts to control by setting the IMEMode property. If set to No Control (default) the setting before the focus shifted to that control is used. For any other setting, the Kanji Conversion Mode setting for that control is used. For example, if the IMEMode property is set to Off, the Kanji Conversion Mode is turned off, and if the IMEMode property is set to On, the Kanji Conversion Mode is turned on. The Kanji Conversion Mode automatically changes each time the focus shifts between controls.

Note Note

If set to Disable, the Kanji Conversion Mode settings cannot be changed. If any other setting is used, the Kanji Conversion Mode can be changed, but when the focus changes, the settings are lost. If you want to save the settings before the control loses the focus, set the IMEHold/HoldKanjiConversionMode property.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ToggleButton.Requery Method (Access)

 Copy code hover
[image]

ToggleButton.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.

Syntax

expression .Requery

expression A variable that represents a ToggleButton object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts .

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate function.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

Example

The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form:

VBA Copy code Copy code
Public Sub RequeryList()

    Dim ctlCombo As Control

    ' Return Control object pointing to a combo box.
    Set ctlCombo = Forms!Employees!ReportsTo

    ' Requery source of data for list box.
    ctlCombo.Requery

End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Visual C++ ADO Programming

 Copy code hover
[image]

Visual C++ ADO Programming
Send feedback

The ADO API Reference describes the functionality of the ADO application programming interface (API) using a syntax similar to Microsoft Visual Basic. Though the intended audience is all users, ADO programmers employ diverse languages such as Visual Basic, Visual C++ (with and without the #import directive), and Visual J++ (with the ADO/WFC class package).

To accommodate this diversity, the ADO for Visual C++ Syntax Indexes provide Visual C++ language-specific syntax with links to common descriptions of functionality, parameters, exceptional behaviors, and so on, in the API Reference.

ADO is implemented with COM (Component Object Model) interfaces. However, it is easier for programmers to work with COM in certain programming languages than others. For example, nearly all the details of using COM are handled implicitly for Visual Basic programmers, whereas Visual C++ programmers must attend to those details themselves.

The following sections summarize details for C and C++ programmers using ADO and the #import directive. It focuses on data types specific to COM (Variant, BSTR, and SafeArray), and error handling (_com_error).

Using the #import Compiler Directive

The #import Visual C++ compiler directive simplifies working with the ADO methods and properties. The directive takes the name of a file containing a type library, such as the ADO .dll (Msado15.dll), and generates header files containing typedef declarations, smart pointers for interfaces, and enumerated constants. Each interface is encapsulated, or wrapped, in a class.

For each operation within a class (that is, a method or property call), there is a declaration to call the operation directly (that is, the "raw" form of the operation), and a declaration to call the raw operation and throw a COM error if the operation fails to execute successfully. If the operation is a property, there is usually a compiler directive that creates an alternative syntax for the operation that has syntax like Visual Basic.

Operations that retrieve the value of a property have names of the form, Get Property. Operations that set the value of a property have names of the form, Put Property. Operations that set the value of a property with a pointer to an ADO object have names of the form, PutRef Property.

You can get or set a property with calls of these forms:

Copy code Copy code

variable = objectPtr->GetProperty(); // get property value
objectPtr->PutProperty(value); // set property value
objectPtr->PutRefProperty(&value); // set property with object pointer

Using Property Directives

The __declspec(property...) compiler directive is a Microsoft-specific C language extension that declares a function used as a property to have an alternative syntax. As a result, you can set or get values of a property in a way similar to Visual Basic. For example, you can set and get a property this way:

Copy code Copy code

objectPtr->property = value; // set property value
variable = objectPtr->property; // get property value

Notice you do not have to code:

Copy code Copy code

objectPtr->PutProperty(value); // set property value
variable = objectPtr->GetProperty; // get property value

The compiler will generate the appropriate Get-, Put-, or PutRef Property call based on what alternative syntax is declared and whether the property is being read or written.

The __declspec(property...) compiler directive can only declare get, put, or get and put alternative syntax for a function. Read-only operations only have a get declaration; write-only operations only have a put declaration; operations that are both read and write have both get and put declarations.

Only two declarations are possible with this directive; however, each property may have three property functions: Get Property, Put Property, and PutRef Property. In that case, only two forms of the property have the alternative syntax.

For example, the Command object ActiveConnection property is declared with an alternative syntax for Get ActiveConnection and PutRef ActiveConnection. The PutRef- syntax is a good choice because in practice, you will typically want to put an open Connection object (that is, a Connection object pointer) in this property. On the other hand, the Recordset object has Get-, Put-, and PutRef ActiveConnection operations, but no alternative syntax.

Collections, the GetItem Method, and the Item Property

ADO defines several collections, including Fields, Parameters, Properties, and Errors. In Visual C++, the GetItem(index) method returns a member of the collection. Index is a Variant, the value of which is either a numerical index of the member in the collection, or a string containing the name of the member.

The __declspec(property...) compiler directive declares the Item property as an alternative syntax to each collection's fundamental GetItem() method. The alternative syntax uses square brackets and looks similar to an array reference. In general, the two forms look like the following:

Copy code Copy code
                      collectionPtr->GetItem(index);
collectionPtr->Item[index];

For example, assign a value to a field of a Recordset object, named rs, derived from the authors table of the pubs database. Use the Item() property to access the third Field of the Recordset object Fields collection (collections are indexed from zero; assume the third field is named au_fname). Then call the Value() method on the Field object to assign a string value.

This can be expressed in Visual Basic in the following four ways (the last two forms are unique to Visual Basic; other languages do not have equivalents):

Copy code Copy code

rs.Fields.Item(2).Value = "value"
rs.Fields.Item("au_fname").Value = "value"
rs(2) = "value"
rs!au_fname = "value"

The equivalent in Visual C++ to the first two forms above is:

Copy code Copy code

rs->Fields->GetItem(long(2))->PutValue("value");
rs->Fields->GetItem("au_fname")->PutValue("value");

-or- (the alternative syntax for the Value property is also shown)

Copy code Copy code

rs->Fields->Item[long(2)]->Value = "value";
rs->Fields->Item["au_fname"]->Value = "value";

COM-Specific Data Types

In general, any Visual Basic data type you find in the ADO API Reference has a Visual C++ equivalent. These include standard data types such as unsigned char for a Visual Basic Byte, short for Integer, and long for Long. Look in the Syntax Indexes to see exactly what is required for the operands of a given method or property.

The exceptions to this rule are the data types specific to COM: Variant, BSTR, and SafeArray.

Variant

A Variant is a structured data type that contains a value member and a data type member. A Variant may contain a wide range of other data types including another Variant, BSTR, Boolean, IDispatch or IUnknown pointer, currency, date, and so on. COM also provides methods that make it easy to convert one data type to another.

The _variant_t class encapsulates and manages the Variant data type.

When the ADO API Reference says a method or property operand takes a value, it usually means the value is passed in a _variant_t.

This rule is explicitly true when the Parameters section in the topics of the ADO API Reference says an operand is a Variant. One exception is when the documentation explicitly says the operand takes a standard data type, such as Long or Byte, or an enumeration. Another exception is when the operand takes a String.

BSTR

A BSTR (Basic STRing) is a structured data type that contains a character string and the string's length. COM provides methods to allocate, manipulate, and free a BSTR.

The _bstr_t class encapsulates and manages the BSTR data type.

When the ADO API Reference says a method or property takes a String value, it means the value is in the form of a _bstr_t.

Casting _variant_t and _bstr_t Classes

Often it is not necessary to explicitly code a _variant_t or _bstr_t in an argument to an operation. If the _variant_t or _bstr_t class has a constructor that matches the data type of the argument, then the compiler will generate the appropriate _variant_t or _bstr_t.

However, if the argument is ambiguous, that is, the argument's data type matches more than one constructor, you must cast the argument with the appropriate data type to invoke the correct constructor.

For example, the declaration for the Recordset::Open method is:

Copy code Copy code

 HRESULT Open (
 const _variant_t & Source,
 const _variant_t & ActiveConnection,
 enum CursorTypeEnum CursorType,
 enum LockTypeEnum LockType,
 long Options );

The ActiveConnection argument takes a reference to a _variant_t, which you may code as a connection string or a pointer to an open Connection object.

The correct _variant_t will be constructed implicitly if you pass a string such as "DSN=pubs;uid=sa;pwd=;", or a pointer such as "(IDispatch *) pConn".

Or you may explicitly code a _variant_t containing a pointer such as "_variant_t((IDispatch *) pConn, true)". The cast, (IDispatch *), resolves the ambiguity with another constructor that takes a pointer to an IUnknown interface.

It is a crucial, though seldom mentioned fact, that ADO is an IDispatch interface. Whenever a pointer to an ADO object must be passed as a Variant, that pointer must be cast as a pointer to an IDispatch interface.

The last case explicitly codes the second boolean argument of the constructor with its optional, default value of true. This argument causes the Variant constructor to call its AddRef() method, which compensates for ADO automatically calling the _variant_t::Release() method when the ADO method or property call completes.

SafeArray

A SafeArray is a structured data type that contains an array of other data types. A SafeArray is called safe because it contains information about the bounds of each array dimension, and limits access to array elements within those bounds.

When the ADO API Reference says a method or property takes or returns an array, it means the method or property takes or returns a SafeArray, not a native C/C++ array.

For example, the second parameter of the Connection object OpenSchema method requires an array of Variant values. Those Variant values must be passed as elements of a SafeArray, and that SafeArray must be set as the value of another Variant. It is that other Variant that is passed as the second argument of OpenSchema.

As further examples, the first argument of the Find method is a Variant whose value is a one-dimensional SafeArray; each of the optional first and second arguments of AddNew is a one-dimensional SafeArray; and the return value of the GetRows method is a Variant whose value is a two-dimensional SafeArray.

Missing and Default Parameters

Visual Basic allows missing parameters in methods. For example, the Recordset object Open method has five parameters, but you can skip intermediate parameters and leave off trailing parameters. A default BSTR or Variant will be substituted depending on the data type of the missing operand.

In C/C++, all operands must be specified. If you want to specify a missing parameter whose data type is a string, specify a _bstr_t containing a null string. If you want to specify a missing parameter whose data type is a Variant, specify a _variant_t with a value of DISP_E_PARAMNOTFOUND and a type of VT_ERROR. Alternatively, specify the equivalent _variant_t constant, vtMissing, which is supplied by the #import directive.

Three methods are exceptions to the typical use of vtMissing. These are the Execute methods of the Connection and Command objects, and the NextRecordset method of the Recordset object. The following are their signatures:

Copy code Copy code

_RecordsetPtr Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcnnexecute_HV10294345.xml( _bstr_t CommandText, VARIANT * RecordsAffected,
 long Options ); // Connection
_RecordsetPtr Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcmdexecute_HV10294344.xml( VARIANT * RecordsAffected, VARIANT * Parameters,
 long Options ); // Command
_RecordsetPtr Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthnextrec_HV10294541.xml( VARIANT * RecordsAffected ); // Recordset

The parameters, RecordsAffected and Parameters, are pointers to a Variant. Parameters is an input parameter which specifies the address of a Variant containing a single parameter, or array of parameters, that will modify the command being executed. RecordsAffected is an output parameter that specifies the address of a Variant, where the number of rows affected by the method is returned.

In the Command object Execute method, indicate that no parameters are specified by setting Parameters to either &vtMissing (which is recommended) or to the null pointer (that is, NULL or zero (0)). If Parameters is set to the null pointer, the method internally substitutes the equivalent of vtMissing, and then completes the operation.

In all the methods, indicate that the number of records affected should not be returned by setting RecordsAffected to the null pointer. In this case, the null pointer is not so much a missing parameter as an indication that the method should discard the number of records affected.

Thus, for these three methods, it is valid to code something such as:

Copy code Copy code

pConnection->Execute("commandText", NULL, adCmdText);
pCommand->Execute(NULL, NULL, adCmdText);
pRecordset->NextRecordset(NULL);

Error Handling

In COM, most operations return an HRESULT return code that indicates whether a function completed successfully. The #import directive generates wrapper code around each "raw" method or property and checks the returned HRESULT. If the HRESULT indicates failure, the wrapper code throws a COM error by calling _com_issue_errorex() with the HRESULT return code as an argument. COM error objects can be caught in a try-catch block. (For efficiency's sake, catch a reference to a _com_error object.)

Remember, these are ADO errors: they result from the ADO operation failing. Errors returned by the underlying provider appear as Error objects in the Connection object Errors collection.

The #import directive creates only error handling routines for methods and properties declared in the ADO .dll. However, you can take advantage of this same error handling mechanism by writing your own error checking macro or inline function. See the topic, Visual C++ Extensions, or the code in the following sections for examples.

Visual C++ Equivalents of Visual Basic Conventions

The following is a summary of several conventions in the ADO documentation, coded in Visual Basic, as well as their equivalents in Visual C++.

Declaring an ADO Object

In Visual Basic, an ADO object variable (in this case for a Recordset object) is declared as follows:

Copy code Copy code

Dim rst As ADODB.Recordset

The clause, "ADODB.Recordset", is the ProgID of the Recordset object as defined in the Registry. A new instance of a Record object is declared as follows:

Copy code Copy code

Dim rst As New ADODB.Recordset

-or-

Copy code Copy code

Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset

In Visual C++, the #import directive generates smart pointer-type declarations for all the ADO objects. For example, a variable that points to a _Recordset object is of type _RecordsetPtr, and is declared as follows:

Copy code Copy code

_RecordsetPtr rs;

A variable that points to a new instance of a _Recordset object is declared as follows:

Copy code Copy code

_RecordsetPtr rs("ADODB.Recordset");

-or-

Copy code Copy code

_RecordsetPtr rs;
rs.CreateInstance("ADODB.Recordset");

-or-

Copy code Copy code

_RecordsetPtr rs;
rs.CreateInstance(__uuidof(_Recordset));

After the CreateInstance method is called, the variable can be used as follows:

Copy code Copy code

rs->Open(...);

Notice that in one case, the "." operator is used as if the variable were an instance of a class (rs.CreateInstance), and in another case, the "->" operator is used as if the variable were a pointer to an interface (rs->Open).

One variable can be used in two ways because the "->" operator is overloaded to allow an instance of a class to behave like a pointer to an interface. A private class member of the instance variable contains a pointer to the _Recordset interface; the "->" operator returns that pointer; and the returned pointer accesses the members of the _Recordset object.

Coding a Missing Parameter

When you need to code a missing String operand in Visual Basic, you merely omit the operand. You must specify the operand in Visual C++. Code a _bstr_t that has an empty string as a value.

Copy code Copy code

_bstr_t strMissing(L"");

Coding a Missing Parameter

When you need to code a missing Variant operand in Visual Basic, you merely omit the operand. You must specify all operands in Visual C++. Code a missing Variant parameter with a _variant_t set to the special value, DISP_E_PARAMNOTFOUND, and type, VT_ERROR. Alternatively, specify vtMissing, which is an equivalent pre-defined constant supplied by the #import directive.

Copy code Copy code

_variant_t vtMissingYours(DISP_E_PARAMNOTFOUND, VT_ERROR);

-or use -

Copy code Copy code

...vtMissing...;

Declaring a Variant

In Visual Basic, a Variant is declared with the Dim statement as follows:

Copy code Copy code

Dim VariableName As Variant

In Visual C++, declare a variable as type _variant_t. A few schematic _variant_t declarations are shown below.

Note Note

These declarations merely give a rough idea of what you would code in your own program. For more information, see the examples below, and the Visual C++ documentation.
Copy code Copy code

_variant_t VariableName(value);
_variant_t VariableName((data type cast) value);
_variant_t VariableName(value, VT_DATATYPE);
_variant_t VariableName(interface * value, bool fAddRef = true);

Using Arrays of Variants

In Visual Basic, arrays of Variants can be coded with the Dim statement, or you may use the Array function, as demonstrated in the following example code:

Copy code Copy code

Public Sub ArrayOfVariants
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim fld As ADODB.Field

cn.Open "DSN=pubs", "sa", ""
rs = cn.OpenSchema(adSchemaColumns, _
 Array(Empty, Empty, "authors", Empty))
For Each fld in rs.Fields
 Debug.Print "Name = "; fld.Name
Next fld
rs.Close
cn.Close
End Sub

The following Visual C++ example demonstrates using a SafeArray used with a _variant_t.

Note Note

The following notes correspond to commented sections in the code example.

  1. Once again, the TESTHR() inline function is defined to take advantage of the existing error-handling mechanism.

  2. You only need a one-dimensional array, so you can use SafeArrayCreateVector, instead of the general purpose SAFEARRAYBOUND declaration and SafeArrayCreate function. The following is what that code would look like using SafeArrayCreate:

    Copy code Copy code

 SAFEARRAYBOUND sabound[1];
 sabound[0].lLbound = 0;
 sabound[0].cElements = 4;
 pSa = SafeArrayCreate(VT_VARIANT, 1, sabound);

  3. The schema identified by the enumerated constant, adSchemaColumns, is associated with four constraint columns: TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, and COLUMN_NAME. Therefore, an array of Variant values with four elements is created. Then a constraint value that corresponds to the third column, TABLE_NAME, is specified. The Recordset that is returned consists of several columns, a subset of which is the constraint columns. The values of the constraint columns for each returned row must be the same as the corresponding constraint values.

  4. Those familiar with SafeArrays may be surprised that SafeArrayDestroy() is not called before the exit. In fact, calling SafeArrayDestroy() in this case will cause a run-time exception. The reason is that the destructor for vtCriteria will call VariantClear() when the _variant_t goes out of scope, which will free the SafeArray. Calling SafeArrayDestroy, without manually clearing the _variant_t, would cause the destructor to try to clear an invalid SafeArray pointer. If SafeArrayDestroy were called, the code would look like this:

    Copy code Copy code

 TESTHR(SafeArrayDestroy(pSa));
 vtCriteria.vt = VT_EMPTY;
 vtCriteria.parray = NULL;

    However, it is much simpler to let the _variant_t manage the SafeArray.

Copy code Copy code

#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")
#include <stdio.h>

// Note 1
inline void TESTHR( HRESULT _hr )
 { if FAILED(_hr) _com_issue_error(_hr); }

void main(void)
{
 CoInitialize(NULL);
 try
 {
 _RecordsetPtr pRs("ADODB.Recordset");
 _ConnectionPtr pCn("ADODB.Connection");
 _variant_t vtTableName("authors"),
 vtCriteria;
 long ix[1];
 SAFEARRAY *pSa = NULL;

 pCn->Open("DSN=pubs;User ID=MyUserId;pwd=MyPassword;Provider=MSDASQL;", "", "",
 adConnectUnspecified);
// Note 2, Note 3
 pSa = SafeArrayCreateVector(VT_VARIANT, 1, 4);
 if (!pSa) _com_issue_error(E_OUTOFMEMORY);

// Specify TABLE_NAME in the third array element (index of 2).

 ix[0] = 2;
 TESTHR(SafeArrayPutElement(pSa, ix, &vtTableName));

// There is no Variant constructor for a SafeArray, so manually set the
// type (SafeArray of Variant) and value (pointer to a SafeArray).

 vtCriteria.vt = VT_ARRAY | VT_VARIANT;
 vtCriteria.parray = pSa;

 pRs = pCn->OpenSchema(adSchemaColumns, vtCriteria, vtMissing);

 long limit = pRs->GetFields()->Count;
 for (long x = 0; x < limit; x++)
 printf("%d: %s\n", x+1,
 ((char*) pRs->GetFields()->Item[x]->Name));
// Note 4
 pRs->Close();
 pCn->Close();
 }
 catch (_com_error &e)
 {
 printf("Error:\n");
 printf("Code = %08lx\n", e.Error());
 printf("Code meaning = %s\n", (char*) e.ErrorMessage());
 printf("Source = %s\n", (char*) e.Source());
 printf("Description = %s\n", (char*) e.Description());
 }
 CoUninitialize();
}

Using Property Get/Put/PutRef

In Visual Basic, the name of a property is not qualified by whether it is retrieved, assigned, or assigned a reference.

Copy code Copy code
Public Sub GetPutPutRef
Dim rs As New ADODB.Recordset
Dim cn As New ADODB.Connection
Dim sz as Integer
cn.Open "Provider=sqloledb;Data Source=yourserver;" & _
 "Initial Catalog=pubs;Integrated Security=SSPI;"
rs.PageSize = 10
sz = rs.PageSize
rs.ActiveConnection = cn
rs.Open "authors",,adOpenStatic
' ...
rs.Close
cn.Close
End Sub

This Visual C++ example demonstrates the Get/Put/PutRef Property.

Note Note

The following notes correspond to commented sections in the code example.

  1. This example uses two forms of a missing string argument: an explicit constant, strMissing, and a string that the compiler will use to create a temporary _bstr_t that will exist for the scope of the Open method.

  2. It isn't necessary to cast the operand of rs->PutRefActiveConnection(cn) to (IDispatch *) because the type of the operand is already (IDispatch *).

    Copy code Copy code

#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")
#include <stdio.h>

void main(void)
{
 CoInitialize(NULL);
 try
 {
 _ConnectionPtr cn("ADODB.Connection");
 _RecordsetPtr rs("ADODB.Recordset");
 _bstr_t strMissing(L"");
 long oldPgSz = 0,
 newPgSz = 5;

// Note 1
 cn->Open("Provider=sqloledb;Data Source=MyServer;"
 "Initial Catalog=pubs;Integrated Security=SSPI;",
 strMissing, "",
 adConnectUnspecified);

 oldPgSz = rs->GetPageSize();
 // -or-
 oldPgSz = rs->PageSize;

 rs->PutPageSize(newPgSz);
 // -or-
 rs->PageSize = newPgSz;

// Note 2
 rs->PutRefActiveConnection( cn );
 rs->Open("authors", vtMissing, adOpenStatic, adLockReadOnly,
 adCmdTable);
 printf("Original pagesize = %d, new pagesize = %d\n", oldPgSz,
 rs->GetPageSize());
 rs->Close();
 cn->Close();
 }
 catch (_com_error &e)
 {
 printf("Description = %s\n", (char*) e.Description());
 }
 ::CoUninitialize();
}

Using GetItem(x) and Item[x]

This Visual Basic example demonstrates the standard and alternative syntax for Item().

Copy code Copy code

Public Sub GetItemItem
Dim rs As New ADODB.Recordset
Dim name as String
rs = rs.Open "authors", "DSN=pubs;", adOpenDynamic, _
 adLockBatchOptimistic, adTable
name = rs(0)
' -or-
name = rs.Fields.Item(0)
rs(0) = "Test"
rs.UpdateBatch
' Restore name
rs(0) = name
rs.UpdateBatch
rs.Close
End Sub

This Visual C++ example demonstrates Item.

Note Note

The following note corresponds to commented sections in the code example.

  1. When the collection is accessed with Item, the index, 2, must be cast to long so an appropriate constructor will be invoked.

    Copy code Copy code

#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")
#include <stdio.h>

void main(void)
{
 CoInitialize(NULL);
 try {
 _RecordsetPtr rs("ADODB.Recordset");
 _variant_t vtFirstName;

 rs->Open("authors",
 "Provider=sqloledb;Data Source=MyServer;"
 "Initial Catalog=pubs;Integrated Security=SSPI;",
 adOpenStatic, adLockOptimistic, adCmdTable);
 rs->MoveFirst();

// Note 1. Get a field.
 vtFirstName = rs->Fields->GetItem((long)2)->GetValue();
 // -or-
 vtFirstName = rs->Fields->Item[(long)2]->Value;

 printf( "First name = '%s'\n", (char*) ((_bstr_t) vtFirstName));

 rs->Fields->GetItem((long)2)->Value = L"TEST";
 rs->Update(vtMissing, vtMissing);

 // Restore name
 rs->Fields->GetItem((long)2)->PutValue(vtFirstName);
 // -or-
 rs->Fields->GetItem((long)2)->Value = vtFirstName;
 rs->Update(vtMissing, vtMissing);
 rs->Close();
 }
 catch (_com_error &e)
 {
 printf("Description = '%s'\n", (char*) e.Description());
 }
 ::CoUninitialize();
}

Casting ADO object pointers with (IDispatch *)

The following Visual C++ example demonstrates using (IDispatch *) to cast ADO object pointers.

Note Note

The following notes correspond to commented sections in the code example.

  1. Specify an open Connection object in an explicitly coded Variant. Cast it with (IDispatch *) so the correct constructor will be invoked. Also, explicitly set the second _variant_t parameter to the default value of true, so the object reference count will be correct when the Recordset::Open operation ends.

  2. The expression, (_bstr_t), is not a cast, but a _variant_t operator that extracts a _bstr_t string from the Variant returned by Value. The expression, (char*), is not a cast, but a _bstr_t operator that extracts a pointer to the encapsulated string in a _bstr_t object. This section of code demonstrates some of the useful behaviors of _variant_t and _bstr_t operators.

    Copy code Copy code

#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <stdio.h>

void main(void)
{
 CoInitialize(NULL);
 try
 {
 _ConnectionPtr pConn("ADODB.Connection");
 _RecordsetPtr pRst("ADODB.Recordset");

 pConn->Open("Provider=sqloledb;Data Source=MyServer;"
 "Initial Catalog=pubs;Integrated Security=SSPI;",
 "", "", adConnectUnspecified);
// Note 1.
 pRst->Open(
 "authors",
 _variant_t((IDispatch *) pConn, true),
 adOpenStatic,
 adLockReadOnly,
 adCmdTable);
 pRst->MoveLast();
// Note 2.
 printf("Last name is '%s %s'\n",
 (char*) ((_bstr_t) pRst->GetFields()->GetItem("au_fname")->GetValue()),
 (char*) ((_bstr_t) pRst->Fields->Item["au_lname"]->Value));

 pRst->Close();
 pConn->Close();
 }
 catch (_com_error &e)
 {
 printf("Description = '%s'\n", (char*) e.Description());
 }
::CoUninitialize();
}


CodeProject.BaseConnectionString Property (Access)

 Copy code hover
[image]

CodeProject.BaseConnectionString Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BaseConnectionString property to return the base connection string for the specified object. Read-only String.

Syntax

expression .BaseConnectionString

expression A variable that represents a CodeProject object.

Remarks

The BaseConnectionString property returns the connection string that was set through the OpenConnection method or by clicking Connection on the File menu. When making a connection, Microsoft Access project modifies the BaseConnectionString property for use with the ADO environment.

Example

The following example displays the BaseConnectionString property setting of the current project:

VBA Copy code Copy code
Public Sub ShowConnectString()

 Dim objCurrent As Object

 Set objCurrent = Application.CurrentProject
 MsgBox "The current base connection is " & objCurrent.BaseConnectionString

End Sub

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


Type Property (Key) (ADOX)

 Copy code hover
[image]

Type Property (Key) (ADOX)
Send feedback

Indicates the type of the key.

Settings and Return Values

Sets or returns a Long value that can be one of the KeyTypeEnum constants. The default value is adKeyPrimary.

Remarks

This property is read-only on Key objects already appended to a collection.


Module.AddFromString Method (Access)

 Copy code hover
[image]

Module.AddFromString Method (Access)
See also Send feedback

Published: July 16, 2012

The AddFromString method adds a string to a Module object. The Module object may represent a standard module or a class module.

Syntax

expression .AddFromString(String)

expression A variable that represents a Module object.

Parameters

Name | Required/Optional | Data Type | Description
String | Required | String | The information that you want to add to the module.

Return Value

Nothing

Remarks

The AddFromString method places the contents of a string after the Declarations section and before the first existing procedure in the module if the module contains other procedures.

In order to add a string to a form or report module, the form or report must be open in form Design view or report Design view. In order to add a string to a standard module or class module, the module must be open.

Example

This example creates a new form and adds a string and the contents of the Functions.txt file to its module. Run the following procedure from a standard module:

VBA Copy code Copy code
Sub AddTextToFormModule()
 Dim frm As Form, mdl As Module

 Set frm = CreateForm
 Set mdl = frm.Module
 mdl.AddFromString "Public intY As Integer"
 mdl.AddFromFile "C:\My Documents\Functions.txt"
End Sub

See also

Concepts

Module Object

Other resources

Module Object Members


ToggleButton.GridlineStyleTop Property (Access)

 Copy code hover
[image]

ToggleButton.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified toggle button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleTop

expression A variable that represents a ToggleButton object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Connection.StillExecuting Property (DAO)

 Copy code hover
[image]

Connection.StillExecuting Property (DAO)
Send feedback

Syntax

expression .StillExecuting

expression A variable that represents a Connection object.

Remarks

Use the StillExecuting property to determine if the most recently called asynchronous Execute or OpenConnection method (that is, a method executed with the dbRunAsync option) is complete. While the StillExecuting property is True, any returned object cannot be accessed.

Once the StillExecuting property returns False, following the OpenConnection call that returns the associated Connection object, the object can be referenced. So long as StillExecuting remains True, the object may not be referenced, other than to read the StillExecuting property.

Use the Cancel method to terminate execution of a task in progress.

Example

This example uses the StillExecuting property and the Cancel method to asynchronously open a Connection object.

VBA Copy code Copy code
Sub CancelConnectionX()

 Dim wrkMain As Workspace
 Dim conMain As Connection
 Dim sngTime As Single

 Set wrkMain = CreateWorkspace("ODBCWorkspace", _
 "admin", "", dbUseODBC)
 ' Open the connection asynchronously.

 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conMain = wrkMain.OpenConnection("Publishers", _
 dbDriverNoPrompt + dbRunAsync, False, _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 sngTime = Timer

 ' Wait five seconds.
 Do While Timer - sngTime < 5
 Loop

 ' If the connection has not been made, ask the user
 ' if she wants to keep waiting. If she does not, cancel
 ' the connection and exit the procedure.
 Do While conMain.StillExecuting

 If MsgBox("No connection yet--keep waiting?", _
 vbYesNo) = vbNo Then
 conMain.Cancel
 MsgBox "Connection cancelled!"
 wrkMain.Close
 Exit Sub
 End If

 Loop

 With conMain
 ' Use the Connection object conMain.
 .Close
 End With

 wrkMain.Close

End Sub


Section.Tag Property (Access)

 Copy code hover
[image]

Section.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents a Section object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

Section Object

Other resources

Section Object Members


Improvements in Compilation Performance

 Copy code hover
[image]

Improvements in Compilation Performance
Send feedback

Microsoft Access includes improvements to module loading and compilation performance to make your code compile and run faster.

Form and Report Modules Created on Demand

When you create a form or report in Microsoft Access 2002 or later, the form or report doesn't automatically have an associated module. When you click Code on the toolbar to view the form's or report's module, the module is created. You can also create the module from Visual Basic by referring to the form's Module property while the form or report is in Design view, or by setting the HasModule property to True.

The setting of the HasModule property indicates whether a form or report currently has an associated module.

Since a form or report module isn't created until you need to add code to it, your project may have fewer modules to compile, resulting in improved compilation performance. Also, forms and reports without modules load more quickly than those with modules.

Compiling on Demand

It's a good idea to explicitly compile the modules in your project by using the commands described above, but it's not necessary. Microsoft Access compiles a module before running a procedure in it if the module hasn't already been compiled.

When a module is loaded for execution, Microsoft Access checks to see whether the module has already been compiled. If not, Microsoft Access compiles the module immediately prior to executing a procedure within it. The process of compiling slows down your code, so code in modules that have been saved in a compiled state will run faster.

Note that in Microsoft Access 95, when you run a procedure in one module, all modules in the potential call tree are loaded, although by default they aren't compiled until a procedure within them is called. Because Microsoft Access 97 (and later versions) load modules on a need-only basis, your code may run faster in many cases.

You can further enhance performance by grouping procedures in modules to reduce unnecessary compilations. Group procedures in modules with other procedures that they call, as opposed to grouping them in modules with unrelated procedures.


The ActiveX Control's Custom Properties Dialog Box

 Copy code hover
[image]

The ActiveX Control's Custom Properties Dialog Box
Send feedback

When setting the properties of an ActiveX control, you may need or prefer to use the control's custom properties dialog box. This custom properties dialog box provides an alternative to the list of properties in the Microsoft Access property sheet for setting ActiveX control properties in Design view.

Note Note

This information only applies to ActiveX controls in a Microsoft Access database environment.

Two Ways to Set Properties

The reason for the custom properties dialog box is that not all applications that use ActiveX controls provide a property sheet like the one in Microsoft Access. The custom properties dialog box provides an interface for setting key control properties regardless of the interface supplied by the hosting application.

For some ActiveX control properties, you can choose either of these two locations to set the property:

  • The Microsoft Access property sheet.

  • The ActiveX control's custom properties dialog box.

In some cases, the custom properties dialog box is the only way to set a property in Design view. This is usually the situation when the interface needed to set a property doesn't work inside the Microsoft Access property sheet. For example, the GridFont property for the Calendar control has a number of arguments; you can't set more than one argument per property in the Microsoft Access property sheet.

Finding the Custom Properties Dialog Box

Not all ActiveX controls provide a custom properties dialog box. To see whether a control provides this custom properties dialog box, look for the Custom property in the Microsoft Access property sheet for this control. If the list of properties contains the name Custom, then the control provides the custom properties dialog box.

Using the Custom Properties Dialog Box

After you click the Custom property box in the Microsoft Access property sheet, click the Build button to the right of the property box to display the control's custom properties dialog box, often presented as a tabbed dialog box. Choose the tab that contains the interface for setting the properties that you want to set.

After you make changes on one tab, you can often apply those changes immediately by clicking the Apply button (if provided). You can click other tabs to set other properties as needed. To approve all changes made in the custom properties dialog box, click the OK button. To return to the Microsoft Access property sheet without changing any property settings, click the Cancel button.

You can also view the custom properties dialog box by clicking the Properties subcommand of the ActiveX control Object command (for example, Calendar Control Object) on the Edit menu, or by clicking this same subcommand on the shortcut menu for the ActiveX control. In addition, some properties in the Microsoft Access property sheet for the ActiveX control, like the GridFontColor property of the Calendar control, have a Build button to the right of the property box. When you click the Build button, the custom properties dialog box is displayed, with the appropriate tab selected (for example, Colors).


TextBox.ForeColor Property (Access)

 Copy code hover
[image]

TextBox.ForeColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ForeColor property to specify the color for text in a control. Read/write Long.

Syntax

expression .ForeColor

expression A variable that represents a TextBox object.

Remarks

You can use this property for controls on forms or reports to make them easy to read or to convey a special meaning. For example, you can change the color of the text in the UnitsInStock control when its value falls below the reorder level.

You can also use this property on reports to create special visual effects when you print with a color printer. When used on a report, this property specifies the printing and drawing color for the Print , Line , and Circle methods.

The ForeColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors for text in controls.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set the Circle property only by using a macro or a Visual Basic event procedure specified in a section's OnPrint event property setting.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


The Synchronizer ID does not match an existing ID in the MSysTranspAddress table. (Error 3504)

 Copy code hover
[image]

The Synchronizer ID does not match an existing ID in the MSysTranspAddress table. (Error 3504)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


Chapter 14: ADO MD Fundamentals

 Copy code hover
[image]

Chapter 14: ADO MD Fundamentals
Send feedback

Microsoft ActiveX Data Objects (Multidimensional) (ADO MD) provides easy access to multidimensional data from languages such as Microsoft Visual Basic, Microsoft Visual C++, and Microsoft Visual J++. ADO MD extends Microsoft ActiveX Data Objects (ADO) to include objects specific to multidimensional data, such as the CubeDef and Cellset objects. With ADO MD you can browse multidimensional schema, query a cube, and retrieve the results.

Like ADO, ADO MD uses an underlying OLE DB provider to gain access to data. To work with ADO MD, the provider must be a multidimensional data provider (MDP) as defined by the OLE DB for OLAP specification. MDPs present data in multidimensional views as opposed to tabular data providers (TDPs) that present data in tabular views. Refer to the documentation for your OLAP OLE DB provider for more detailed information on the specific syntax and behaviors supported by your provider.

This document assumes a working knowledge of the Visual Basic programming language and a general knowledge of ADO and OLAP. For more information, see the ADO Programmer's Guide and the OLE DB for OLAP Programmer's Reference. For more overview information about ADO MD, see the following topics:

  • Overview of Multidimensional Schemas and Data

  • Working with Multidimensional Data

  • Using ADO with ADO MD

  • Programming with ADO MD


ObjectStateEnum

 Copy code hover
[image]

ObjectStateEnum
Send feedback

Specifies whether an object is open or closed, connecting to a data source, executing a command, or retrieving data.

Constant | Value | Description
adStateClosed | 0 | Indicates that the object is closed.
adStateOpen | 1 | Indicates that the object is open.
adStateConnecting | 2 | Indicates that the object is connecting.
adStateExecuting | 4 | Indicates that the object is executing a command.
adStateFetching | 8 | Indicates that the rows of the object are being retrieved.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.ObjectState.CLOSED

AdoEnums.ObjectState.OPEN

AdoEnums.ObjectState.CONNECTING

AdoEnums.ObjectState.EXECUTING

AdoEnums.ObjectState.FETCHING


TableDefs.Delete Method (DAO)

 Copy code hover
[image]

TableDefs.Delete Method (DAO)
Send feedback

Deletes the specified TableDef object from the TableDefs collection.

Syntax

expression .Delete(Name)

expression A variable that represents a TableDefs object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Required | String | The name of the TableDef to delete.

Remarks

The Delete method is supported only when the TableDef object is new and hasn't been appended to the database, or when the Updatable property of the TableDef is set to True.


DoCmd.OpenDataAccessPage Method (Access)

 Copy code hover
[image]

DoCmd.OpenDataAccessPage Method (Access)
See also Send feedback

Published: July 16, 2012

The OpenDataAccessPage method carries out the OpenDataAccessPage action in Visual Basic.

Syntax

expression .OpenDataAccessPage(DataAccessPageName, View)

expression An expression that returns a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
DataAccessPageName | Required | Variant | A string expression that's the valid name of a data access page in the current database. If you execute Visual Basic code containing the OpenDataAccessPage method in a library database, Microsoft Access looks for the form with this name, first in the library database, then in the current database.
View | Optional | AcDataAccessPageView | The view in which to open the data access page. In Microsoft Access 2013, this must be set to acDataAccessPageBrowse.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


CreateObject Method (RDS)

 Copy code hover
[image]

CreateObject Method (RDS)
Send feedback

Creates the proxy for the target business object and returns a pointer to it. The proxy packages and marshals data to the server-side stub for communications with the business object to send requests and data over the Internet. For in-process component objects, no proxies are used, just a pointer to the object is provided.

Syntax

Remote Data Service supports the following protocols: HTTP, HTTPS (HTTP over Secure Socket Layer), DCOM, and in-process.

Protocol | Syntax
HTTP | Set object = DataSpace.CreateObject("ProgId", "http://awebsrvr")
HTTPS | Set object = DataSpace.CreateObject("ProgId", "https://awebsrvr")
DCOM | Set object = DataSpace.CreateObject("ProgId", "computername")
In-process | Set object = DataSpace.CreateObject("ProgId", " ")

Parameters

  • Object

  • An object variable that evaluates to an object that is the type specified in ProgID.

  • DataSpace

  • An object variable that represents an RDS.DataSpace object used to create an instance of the new object.

  • ProgID

  • A String value that contains the programmatic identifier specifying a server-side business object that implements your application's business rules.

  • awebsrvr or computername

  • A String value that represents a URL identifying the Internet Information Services (IIS) Web server where an instance of the server business object is created.

Remarks

The HTTP protocol is the standard Web protocol; HTTPS is a secure Web protocol. Use the DCOM protocol when running a local-area network without HTTP. The in-process protocol is a local dynamic-link library (DLL); it does not use a network.


Date and Time Criteria from a Control on a Form

 Copy code hover
[image]

Date and Time Criteria from a Control on a Form
Send feedback

If you want to change the criteria argument for an operation based on a user's decision, you can specify that the criteria comes from a control on a form. For example, you could specify that the criteria argument comes from a list box containing order dates from an Orders table.

To specify date and time criteria that comes from a control on a form, you include in the criteria argument an expression that references the control on the form. This expression should be separate from the string expression, so that Microsoft Access will evaluate the control expression first and concatenate it with the rest of the string expression before performing the appropriate operation.

In addition to enclosing the entire string expression in double quotation marks ("), you must also ensure that the date or time criteria within the string expression is enclosed in number signs (#). The number signs must be included in the strings flanking the expression that references the control on the form.

Note Note

The number signs indicate to Microsoft Access that the criteria argument contains a date or time within a string.

The following examples set a form's Filter or ServerFilter property based on criteria that comes from a control named HireDate that's on the form. Note the placement of the number signs.

Copy code Copy code
Forms!Employees.Filter = "[HireDate] >= #" _
 & Forms!Employees!HireDate & "#"
Forms!Employees.FilterOn = True

- or -

Copy code Copy code
Forms!Employees.ServerFilter = "[HireDate] >= #" _
 & Forms!Employees!HireDate & "#"
Forms!Employees.FilterOn = True

If the current value of the HireDate control is , the Filter or ServerFilter property will have the following criteria argument:

Copy code Copy code
"[HireDate] >= #5-1-92#"
Tip Tip

To troubleshoot an expression in the criteria argument, break the expression into smaller components and test each individually in the Immediate window. When all of the components are working correctly, put them back together one at a time until the complete expression works correctly.

You can also include a variable representing a date or time in the criteria argument. The variable should be separate from the string expression, so that Microsoft Access will evaluate the variable first and then concatenate it with the rest of the string expression. The date or time criteria must be enclosed in number signs.

The following example shows how to construct a criteria argument that includes a variable representing a date or time:

Copy code Copy code
Dim datHireDate As Date
datHireDate = #5-1-92#
Forms!Employees.Filter = "[HireDate] >= #" _
 & datHireDate & "#"


RDS Programming Model in Detail

 Copy code hover
[image]

RDS Programming Model in Detail
Send feedback

The following are key elements of the RDS programming model:

  • RDS.DataSpace

  • RDSServer.DataFactory

  • RDS.DataControl

  • Event

RDS.DataSpace

Your client application must specify the server and the server program to invoke. In return, your application receives a reference to the server program and can treat the reference as if it were the server program itself.

The RDS object model embodies this functionality with the RDS.DataSpace object.

The server program is specified with a program identifier, or ProgID. The server uses the ProgID and the server machine's registry to locate information about the actual program to initiate.

RDS makes a distinction internally depending on whether the server program is on a remote server across the Internet or an intranet; a server on a local area network; or not on a server at all, but instead on a local dynamic-link library (DLL). This distinction determines how information is exchanged between the client and the server, and makes a tangible difference in the type of reference returned to your client application. However, from your point of view, this distinction has no special meaning. All that matters is that you receive a usable program reference.

RDSServer.DataFactory

RDS provides a default server program that can either perform a SQL query against the data source and return a Recordset object or take a Recordset object and update the data source.

The RDS object model embodies this functionality with the RDSServer.DataFactory object.

In addition, this object has a method for creating an empty Recordset object that you can fill programmatically (CreateRecordset), and another method for converting a Recordset object into a text string to build a Web page (ConvertToString).

With ADO, you can override some of the standard connection and command behavior of the RDSServer.DataFactory with a DataFactory handler and a customization file that contains connection, command, and security parameters.

The server program is sometimes called a business object. You can write your own custom business object that can perform complicated data access, validity checks, and so on. Even when writing a custom business object, you can create an instance of an RDSServer.DataFactory object and use some of its methods to accomplish your own tasks.

RDS.DataControl

RDS provides a means to combine the functionality of the RDS.DataSpace and RDSServer.DataFactory, and also enable visual controls to easily use the Recordset object returned by a query from a data source. RDS attempts, for the most common case, to do as much as possible to automatically gain access to information on a server and display it in a visual control.

The RDS object model embodies this functionality with the RDS.DataControl object.

The RDS.DataControl has two aspects. One aspect pertains to the data source. If you set the command and connection information using the Connect and SQL properties of the RDS.DataControl, it will automatically use the RDS.DataSpace to create a reference to the default RDSServer.DataFactory object. Then the RDSServer.DataFactory will use the Connect property value to connect to the data source, use the SQL property value to obtain a Recordset from the data source, and return the Recordset object to the RDS.DataControl.

The second aspect pertains to the display of returned Recordset information in a visual control. You can associate a visual control with the RDS.DataControl (in a process called binding) and gain access to the information in the associated Recordset object, displaying query results on a Web page in Microsoft® Internet Explorer. Each RDS.DataControl object binds one Recordset object, representing the results of a single query, to one or more visual controls (for example, a text box, combo box, grid control, and so forth). There may be more than one RDS.DataControl object on each page. Each RDS.DataControl object can be connected to a different data source and contain the results of a separate query.

The RDS.DataControl object also has its own methods for navigating, sorting, and filtering the rows of the associated Recordset object. These methods are similar, but not the same as the methods on the ADO Recordset object.

Events

RDS supports two of its own events, which are independent of the ADO event model. The onReadyStateChange event is called whenever the RDS.DataControl ReadyState property changes, thus notifying you when an asynchronous operation has successfully completed, terminated, or experienced an error. The onError event is called whenever an error occurs, even if the error occurs during an asynchronous operation.

Note Note

Microsoft Internet Explorer provides two additional events to RDS — onDataSetChanged (the Recordset is functional but still retrieving rows) and onDataSetComplete (the Recordset has finished retrieving rows).


AddNew Method Example (VC++)

 Copy code hover
[image]

AddNew Method Example (VC++)
Send feedback

This example uses the AddNew method to create a new record with the specified name.

Copy code Copy code

// Note: When adding the record. You need to get the data from the user
// The employee id must be formatted as first,middle and last initial,
// five numbers,then M or F to signify the gender.For example,the
// employee id for Bill A. Sorensen would be "BAS55555M".

// BeginAddNewCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include "conio.h"
#include "AddNewX.h"

//Function declaration
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void AddNewX(VOID);
void PrintProviderError(_ConnectionPtr pConnection);
inline int myscanf(char* strDest, int n)
{
 char strExBuff[10];
 char* pstrRet = fgets(strDest, n, stdin);

 if (pstrRet == NULL)
 return 0;

 if (!strrchr(strDest, '\n'))
 // Exhaust the input buffer.
 do
 {
 fgets(strExBuff, sizeof(strExBuff), stdin);
 }while (!strrchr(strExBuff, '\n'));
 else
 // Replace '\n' with '\0'
 strDest[strrchr(strDest, '\n') - strDest] = '\0';

 return strlen(strDest);
}

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////
void main()
{
 HRESULT hr = S_OK;

 if(FAILED(::CoInitialize(NULL)))
 return;

 if (SUCCEEDED(hr))
 {
 AddNewX();

 //Wait here for the user to see the output
 printf("Press any key to continue...");
 getch();

 ::CoUninitialize();
 }
}

///////////////////////////////////////////////////////////
// //
// AddNewX Function //
// //
///////////////////////////////////////////////////////////
VOID AddNewX(VOID)
{

 // Define ADO object pointers.
 // Initialize pointers on define.
 _RecordsetPtr pRstEmployees = NULL;
 _ConnectionPtr pConnection = NULL;

 //Define Other variables
 IADORecordBinding *picRs = NULL; //Interface Pointer declared.(VC++ Extensions)
 CEmployeeRs emprs; //C++ class object

 HRESULT hr = S_OK;

 //Replace Data Source value with your server name.
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");
 _bstr_t strId;
 _bstr_t strMessage;

 try
 {
 //Open a connection
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
 pConnection->Open(strCnn,"","",adConnectUnspecified);

 //Open employee table
 TESTHR(pRstEmployees.CreateInstance(__uuidof(Recordset)));

 //You have to explicitly pass the Cursor type and LockType to the Recordset here
 pRstEmployees->Open("employee",_variant_t((IDispatch *) pConnection, true),
 adOpenKeyset,adLockOptimistic,adCmdTable);

 //Open an IADORecordBinding interface pointer which we'll use for Binding
 //Recordset to a class
 TESTHR(pRstEmployees->QueryInterface(__uuidof(IADORecordBinding),(LPVOID*)&picRs));

 //Bind the Recordset to a C++ Class here
 TESTHR(picRs->BindToRecordset(&emprs));

 // Get data from the user.The employee id must be formatted as
 // first,middle and last initial,five numbers,then M or F to
 // signify the gender.For example,the employee id for
 // Bill A. Sorensen would be "BAS55555M".

 printf("Enter Employee Id: ");
 myscanf(emprs.m_sz_empid, sizeof(emprs.m_sz_empid));
 strId = emprs.m_sz_empid;
 printf("Enter First Name: ");
 myscanf(emprs.m_sz_fname, sizeof(emprs.m_sz_fname));
 printf("Enter Last Name:");
 myscanf(emprs.m_sz_lname, sizeof(emprs.m_sz_lname));

 //Proceed if the user actually entered some thing
 //for the id, the first and the last name.

 if(strcmp(emprs.m_sz_empid,"") && strcmp(emprs.m_sz_fname,"") &&
 strcmp(emprs.m_sz_lname,""))
 {
 //This adds a new record to the table
 //if (FAILED(hr = picRs->AddNew(&emprs)))
 //_com_issue_error(hr);
 TESTHR(picRs->AddNew(&emprs));

 //Show the newly added data
 printf("New Record: %s %s %s \n", emprs.lemp_empidStatus == adFldOK ? emprs.m_sz_empid : "<NULL>", emprs.lemp_fnameStatus == adFldOK ? emprs.m_sz_fname : "<NULL>", emprs.lemp_lnameStatus == adFldOK ? emprs.m_sz_lname : "<NULL>");
 }
 else
 printf("Please enter an employee id, first name and last name.\n");

 //Delete the new record because this is a demonstration.
 pConnection->Execute("DELETE FROM EMPLOYEE WHERE emp_id = '"+strId+"'",
 NULL,adCmdText);
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _variant_t vtConnect = pRstEmployees->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 printf("Error:\n");
 printf("Code = %08lx\n", e.Error());
 printf("Message = %s\n", e.ErrorMessage());
 printf("Source = %s\n", (LPCSTR) e.Source());
 printf("Description = %s\n", (LPCSTR) e.Description());
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }

 }

 // Clean up objects before exit.
 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (pRstEmployees)
 if (pRstEmployees->State == adStateOpen)
 pRstEmployees->Close();
 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

VOID PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;
 long nCount = 0;
 long i = 0;

 if( (pConnection->Errors->Count) > 0)
 {
 nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\n\t Error number: %x\t%s", pErr->Number, (LPCSTR)pErr->Description);
 }
 }
}
// EndAddNewCpp

AddNewX.h

Copy code Copy code

// BeginAddNewH
#include "icrsint.h"

//This Class extracts empid, fname and lastname

class CEmployeeRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CEmployeeRs)

 //Column empid is the 1st field in the recordset

 ADO_VARIABLE_LENGTH_ENTRY2(1, adVarChar, m_sz_empid,
 sizeof(m_sz_empid), lemp_empidStatus, TRUE)

 ADO_VARIABLE_LENGTH_ENTRY2(2, adVarChar, m_sz_fname,
 sizeof(m_sz_fname), lemp_fnameStatus, TRUE)

 ADO_VARIABLE_LENGTH_ENTRY2(4, adVarChar, m_sz_lname,
 sizeof(m_sz_lname), lemp_lnameStatus, TRUE)

END_ADO_BINDING()

public:

 CHAR m_sz_empid[10];
 ULONG lemp_empidStatus;
 CHAR m_sz_fname[40];
 ULONG lemp_fnameStatus;
 CHAR m_sz_lname[41];
 ULONG lemp_lnameStatus;

};
// EndAddNewH


FilterGroupEnum

 Copy code hover
[image]

FilterGroupEnum
Send feedback

Specifies the group of records to be filtered from a Recordset.

Constant | Value | Description
adFilterAffectedRecords | 2 | Filters for viewing only records affected by the last Delete, Resync, UpdateBatch, or CancelBatch call.
adFilterConflictingRecords | 5 | Filters for viewing the records that failed the last batch update.
adFilterFetchedRecords | 3 | Filters for viewing the records in the current cache — that is, the results of the last call to retrieve records from the database.
adFilterNone | 0 | Removes the current filter and restores all records for viewing.
adFilterPendingRecords | 1 | Filters for viewing only records that have changed but have not yet been sent to the server. Applicable only for batch update mode.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.FilterGroup.AFFECTEDRECORDS

AdoEnums.FilterGroup.CONFLICTINGRECORDS

AdoEnums.FilterGroup.FETCHEDRECORDS

AdoEnums.FilterGroup.NONE

AdoEnums.FilterGroup.PENDINGRECORDS


Events in Access Reports

 Copy code hover
[image]

Events in Access Reports
Send feedback

In this section

  • How to: Close a Report Automatically If It Does Not Contain Any Records

  • How to: Filter a Report Using a Form's Filter


CheckBox.Move Method (Access)

 Copy code hover
[image]

CheckBox.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a CheckBox object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


TextBox.FontBold Property (Access)

 Copy code hover
[image]

TextBox.FontBold Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontBold property to specify whether a font appears in a bold style in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontBold

expression A variable that represents a TextBox object.

Remarks

The FontBold property uses the following settings.

Setting | Description
True | The text is bold.
False | (Default) The text isn't bold.

To use the FontBold property on a report, first create a Printevent procedure that prints the desired text.

A font's appearance on screen and in print may differ, depending on your computer and printer.

The FontWeight property, which is available in the property sheet for controls, can also be used to set the line width for a control's text. The FontBold property gives you a quick way to make text bold; the FontWeight property gives you finer control over the line width setting for text. The following table shows the relationship between these properties' settings.

If | Then
FontBold = False | FontWeight = Normal (400)
FontBold = True | FontWeight = Bold (700)
FontWeight < 700 | FontBold = False
FontWeight > = 700 | FontBold = True

Example

The following Print event procedure prints a report title and the current date in a bold style on a report at the coordinates specified by the CurrentX and CurrentY property settings.

VBA Copy code Copy code
Private Sub ReportHeader0_Print(Cancel As Integer, _
 PrintCount As Integer)
 Dim MyDate

 MyDate = Date
 Me.FontBold = True
 ' Print report title in bold.
 Me.Print("Sales Management Report")
 Me.Print(MyDate)
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


OptionButton.Tag Property (Access)

 Copy code hover
[image]

OptionButton.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents an OptionButton object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


DoCmd.CloseDatabase Method (Access)

 Copy code hover
[image]

DoCmd.CloseDatabase Method (Access)
See also Send feedback

Published: July 16, 2012

Closes the current database.

Version Information

Version Added: Access 2007

Syntax

expression .CloseDatabase

expression A variable that represents a DoCmd object.

Remarks

This method has the same effect as clicking the Microsoft Office Button [image] and then clicking Close Database. If you have any unsaved objects when you use the CloseDatabase method, the dialog boxes that appear are the same as those displayed when you click Close Database.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Form.OnOpen Property (Access)

 Copy code hover
[image]

Form.OnOpen Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Open box in the Properties window of a form or report. Read/write String.

Syntax

expression .OnOpen

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Open event occurs when a form is opened, but before the first record is displayed. For reports, the event occurs before a report is previewed or printed.

The OnOpen value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Open box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Open box is blank, the property value is an empty string.

See also

Concepts

Form Object

Other resources

Form Object Members


RecordCreateOptionsEnum

 Copy code hover
[image]

RecordCreateOptionsEnum
Send feedback

Specifies whether an existing Record should be opened or a new Record created for the Record object Open method. The values can be combined with an AND operator.

Constant | Value | Description
adCreateCollection | 0x2000 | Creates a new Record at the node specified by Source parameter, instead of opening an existing Record. If the source points to an existing node, then a run-time error occurs, unless adCreateCollection is combined with adOpenIfExists or adCreateOverwrite.
adCreateNonCollection | 0 | Creates a new Record of type adSimpleRecord.
adCreateOverwrite | 0x4000000 | Modifies the creation flags adCreateCollection, adCreateNonCollection, and adCreateStructDoc. When OR is used with this value and one of the creation flag values, if the source URL points to an existing node or Record, then the existing Record is overwritten and a new one is created in its place. This value cannot be used together with adOpenIfExists.
adCreateStructDoc | 0x80000000 | Creates a new Record of type adStructDoc, instead of opening an existing Record.
adFailIfNotExists | -1 | Default. Results in a run-time error if Source points to a non-existent node.
adOpenIfExists | 0x2000000 | Modifies the creation flags adCreateCollection, adCreateNonCollection, and adCreateStructDoc. When OR is used with this value and one of the creation flag values, if the source URL points to an existing node or Record object, then the provider must open the existing Record instead of creating a new one. This value cannot be used together with adCreateOverwrite.

ADO/WFC Equivalent

These constants do not have ADO/WFC equivalents.


Operation Properties (Access)

 Copy code hover
[image]

Operation Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
WSParameters | Gets the collection of parameters defined for the specified operation. Read-only WSParameters.


AcObjectType Enumeration (Access)

 Copy code hover
[image]

AcObjectType Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the type of object.

Name | Value | Description
acDatabaseProperties | 11 | Database property
acDefault | -1 |
acDiagram | 8 | Database Diagram (Microsoft Access project)
acForm | 2 | Form
acFunction | 10 | Function
acMacro | 4 | Macro
acModule | 5 | Module
acQuery | 1 | Query
acReport | 3 | Report
acServerView | 7 | Server View
acStoredProcedure | 9 | Stored Procedure (Microsoft Access project)
acTable | 0 | Table
acTableDataMacro | 12 | Data macro


Can not perform this operation because there is no active connection. (Error 3668)

 Copy code hover
[image]

Can not perform this operation because there is no active connection. (Error 3668)
Send feedback

The following operation could not be performed without an open connection on the object. Open a connection and then retry the operation.


Form.PaintPalette Property (Access)

 Copy code hover
[image]

Form.PaintPalette Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PaintPalette property to specify a palette to be used by a form. Read/write Variant.

Syntax

expression .PaintPalette

expression A variable that represents a Form object.

Remarks

You can set the PaintPalette property by using a macro or Visual Basic . The property setting must be a String data type containing the palette information.

You can set the PaintPalette property by assigning the value of the ObjectPalette property to the PaintPalette property in a macro or Visual Basic, by setting the PaletteSource property (in which case Microsoft Access automatically sets the PaintPalette property to this PaletteSource), or by setting the PaintPalette property of one form or report to the PaintPalette property of another form or report.

For a form, you can set the PaintPalette property in form Design view and Form view.

When you set the PaintPalette property, Microsoft Access makes a copy of the palette that you specify and saves it with the form or report. The palette is then available if you modify that form or report.

Changes to the palette you specified when you set the PaintPalette property don't affect the copy of the palette stored with the form or report. If you want to update the copy of the palette stored with the form or report, you must rerun the code or macro that sets the PaintPalette property or reset the PaletteSource property when the form or report is open.

When you set the PaintPalette property for a form or report, Microsoft Access automatically updates its PaletteSource property. Conversely, when you set the PaletteSource property for a form or report, the PaintPalette property is also updated. For example, when you specify a custom palette with the PaintPalette property, the PaletteSource property setting is changed to (Custom). The PaintPalette property (which is available only in a macro or Visual Basic) is used to set the palette for the form or report. The PaletteSource property gives you a way to set the palette for the form or report in the property sheet by using an existing graphics file.

Note Note

Windows can have only one color palette active at a time. Microsoft Access allows you to have multiple graphics on a form, each using a different color palette. The PaintPalette and PaletteSource properties let you specify which color palette a form should use when displaying graphics.

You can use the ObjectPalette property to make the palette of an application associated with an OLE object, bitmap, or other graphic contained in a control on a form or report available to the PaintPalette property. For example, to make the palette used in Microsoft Graph available when you're designing a form in Microsoft Access, you set the form's PaintPalette property to the ObjectPalette value of an existing chart control.

Example

The ObjectPalette and PaintPalette properties are useful for programmatically altering the color palette in use by an open form at run time. A common use of these properties is to set the current form's PaintPalette property to the palette of a graphic displayed in a control that has the focus.

For example, you can have a form with an ocean picture, showing many shades of blue, and a sunset picture, showing many shades of red. Since Windows only allows one color palette active at a time, one picture will look much better than the other. The following example uses a control's Enter event for setting the form's PaintPalette property to the control's ObjectPalette property so the graphic that has the focus will have an optimal appearance.

VBA Copy code Copy code
Sub OceanPicture_Enter()
 Me.PaintPalette = Me!OceanPicture.ObjectPalette
End Sub

Sub SunsetPicture_Enter()
 Me.PaintPalette = Me!SunsetPicture.ObjectPalette
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


BoundObjectFrame.AutoActivate Property (Access)

 Copy code hover
[image]

BoundObjectFrame.AutoActivate Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AutoActivate property to specify how the user can activate an OLE object. Read/write Integer.

Syntax

expression .AutoActivate

expression A variable that represents a BoundObjectFrame object.

Remarks

The AutoActivate property uses the following settings.

Setting | Constant | Description
Manual | acOLEActivateManual (0) | The OLE object isn't activated when it receives the focus or when the user double-clicks the control. You can activate an OLE object only by using Visual Basic to set the control's Action property to acOLEActivate.
GetFocus | acOLEActivateGetFocus (1) | (For unbound object frame and chart controls only) If the control contains an OLE object, the application that supplied the object is activated when the control receives the focus.
Double-Click | acOLEActivateDoubleClick (2) | (Default) If the control contains an OLE object, the application that supplied the object is activated when the user double-clicks the control or presses CTRL+ENTER when the control has the focus.

The AutoActivate property can be set only in Design view.

Some OLE objects can be activated from within the control. When such an object is activated, the object can be edited (or some other operation can be performed) from inside the boundaries of the control. This feature is called in-place activation. If an object supports in-place activation, see the documentation for the application that was used to create the object for information about using this feature.

With Visual Basic, you can determine if a control contains an object by checking the setting of its OLEType property.

Note Note

If you set a control's AutoActivate property to Double-Click and specify a DblClick event for the control, the DblClick event occurs before the object is activated.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


CheckBox.ControlSource Property (Access)

 Copy code hover
[image]

CheckBox.ControlSource Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.

Syntax

expression .ControlSource

expression A variable that represents a CheckBox object.

Remarks

The ControlSource property uses the following settings.

Setting | Description
A field name | The control is bound to a field in a table, query, or SQL statement. Data from the field is displayed in the control. Changes to the data inside the control change the corresponding data in the field. (To make the control read-only, set the Locked property to Yes.) If you click a control bound to a field that has a Hyperlink data type, you jump to the destination specified in the hyperlink address.
An expression | The control displays data generated by an expression. This data can be changed by the user but isn't saved in the database.
Note Note

The ControlSource property doesn't apply to check box, option button, or toggle button controls in an option group. It applies only to the option group itself.

For reports, the ControlSource property applies only to report group levels.

Forms and reports act as "windows" into your database. You specify the primary source of data for a form or report by setting its RecordSource property to a table, query, or SQL statement. You can then set the ControlSource property to a field in the source of data or to an expression. If the ControlSource property setting is an expression, the value displayed is read-only and not saved in the database. For example, you can use the following settings.

Sample setting | Description
LastName | For a control, data from the LastName field is displayed in the control. For a report group level, Microsoft Access groups the data on last name.
=Date( ) + 7 | For a control, this expression displays a date seven days from today in the control.
=DatePart("q",ShippedDate) | For a control, this expression displays the quarter of the shipped date. For a report group level, Microsoft Access groups the data on the quarter of the shipped date.

Example

The following example sets the ControlSource property for a text box named AddressPart to a field named City:

VBA Copy code Copy code
Forms!Customers!AddressPart.ControlSource = "City"

The next example sets the ControlSource property for a text box named Expected to the expression =Date() + 7

VBA Copy code Copy code
Me!Expected.ControlSource = "=Date() + 7"

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Report.Move Method (Access)

 Copy code hover
[image]

Report.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a Report object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

If a report is modal, it is still positioned relative to the Access window, but the values for Left and Top can be negative.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

Report Object

Other resources

Report Object Members


 Copy code hover
[image]

< (Less Than) (Access 2013 custom web app)
Send feedback

Compares two expressions. When you compare non-null expressions, the result is TRUE if the left operand has a value lower than the right operand; otherwise, the result is FALSE.

Syntax

expression < expression

expression Is any valid expression. Both expressions must have implicitly convertible data types. The conversion depends on the rules of data type precedence.

Return Type

Boolean


Reset Method (RDS)

 Copy code hover
[image]

Reset Method (RDS)
Send feedback

Executes the sort or filter on a client-side Recordset based on the specified sort and filter properties.

Syntax

DataControl.Reset(value)

Parameters

  • DataControl

  • An object variable that represents an RDS.DataControl object.

  • value

  • Optional. A Boolean value that is True (default) if you want to filter on the current "filtered" rowset. False indicates that you filter on the original rowset, removing any previous filter options.

Remarks

The SortColumn, SortDirection, FilterValue, FilterCriterion, and FilterColumn properties provide sorting and filtering functionality on the client-side cache. The sorting functionality orders records by values from one column. The filtering functionality displays a subset of records based on a find criteria, while the full Recordset is maintained in the cache. The Reset method will execute the criteria and replace the current Recordset with an updatable Recordset.

If there are changes to the original data that haven't yet been submitted, the Reset method will fail. First, use the SubmitChanges method to save any changes in a read/write Recordset, and then use the Reset method to sort or filter the records.

If you want to perform more than one filter on your rowset, you can use the optional Boolean argument with the Reset method. The following example shows how to do this:


ADO MD Properties Reference

 Copy code hover
[image]

ADO MD Properties Reference
Send feedback

In this section

  • ADO MD Properties

  • ActiveConnection Property (ADO MD)

  • Caption Property (ADO MD)

  • ChildCount Property (ADO MD)

  • Children Property (ADO MD)

  • Depth Property (ADO MD)

  • Description Property (ADO MD)

  • DimensionCount Property (ADO MD)

  • DrilledDown Property (ADO MD)

  • FilterAxis Property (ADO MD)

  • FormattedValue Property (ADO MD)

  • Item Property (ADO MD Cellset)

  • LevelDepth Property (ADO MD)

  • LevelName Property (ADO MD)

  • Name Property (ADO MD)

  • Ordinal Property (ADO MD Cell)

  • Ordinal Property (ADO MD Position)

  • Parent Property (ADO MD)

  • ParentSameAsPrev Property (ADO MD)

  • Source Property (ADO MD)

  • State Property (ADO MD)

  • Type Property (ADO MD)

  • UniqueName Property (ADO MD)

  • Value Property (ADO MD)


Disk I/O error during read. (Error 3040)

 Copy code hover
[image]

Disk I/O error during read. (Error 3040)
Send feedback

The disk could not be read due to an internal disk or drive failure.

Possible causes:

  • You tried to read from a network drive, and the network is temporarily busy, or youyou arere no longer connected to the network. Check the network connection, and then try the operation again.

  • The disk or drive has failed.


Application.DoCmd Property (Access)

 Copy code hover
[image]

Application.DoCmd Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DoCmd property to access the read-only DoCmd object and its related methods. Read-only DoCmd.

Syntax

expression .DoCmd

expression A variable that represents an Application object.

Example

The following example opens a form in Form view and moves to a new record.

VBA Copy code Copy code
Sub ShowNewRecord()
 DoCmd.OpenForm "Employees", acNormal
 DoCmd.GoToRecord , , acNewRec
End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


ToggleButton.ReadingOrder Property (Access)

 Copy code hover
[image]

ToggleButton.ReadingOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.

Syntax

expression .ReadingOrder

expression A variable that represents a ToggleButton object.

Remarks

The ReadingOrder property uses the following settings.

Setting | Visual Basic | Description
Context | 0 | Reading order is determined by the language of the first character entered. If a right-to-left language character is entered first, reading order is right to left. If a left-to-right language character is entered first, reading order is left to right.
Left-to-Right | 1 | Sets the reading order to left to right.
Right-to-Left | 2 | Sets the reading order to right to left.

Example

The following example sets the reading order to right to left for the "Address" text box on the "International Shipping" form.

VBA Copy code Copy code
Forms("International Shipping").Controls("Address").ReadingOrder = 2

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


NavigationControl.MouseUp Event (Access)

 Copy code hover
[image]

NavigationControl.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Version Information

Version Added: Access 2010

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents a NavigationControl object.

Parameters

Name | Required/Optional | Data Type | Description
Button | Required | Integer |
Shift | Required | Integer |
X | Required | Single |
Y | Required | Single |

Return Value

nothing

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


ToggleButton.FontSize Property (Access)

 Copy code hover
[image]

ToggleButton.FontSize Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontSize property to specify the point size for text in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Integer.

Syntax

expression .FontSize

expression A variable that represents a ToggleButton object.

Remarks

The FontSize property uses the following settings.

Setting | Description
8 | (Default for all reports and controls except command buttons) The text is 8-point type.
10 | (Default for command buttons) The text is 10-point type.
Other sizes | The text is the indicated size.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set this property only in an event procedure or in a macro specified by the OnPrint event property setting.

In Visual Basic, you set the FontSize property by using a numeric expression equal to the desired size of the font. The setting for the FontSize property can be between 1 and 127, inclusive.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Chapter 14: ADO MD Fundamentals (ADO)

 Copy code hover
[image]

Chapter 14: ADO MD Fundamentals (ADO)
Send feedback

In this section

  • Chapter 14: ADO MD Fundamentals

  • Overview of Multidimensional Schemas and Data

  • Working with Multidimensional Data

  • Using ADO with ADO MD

  • Programming with ADO MD


BoundObjectFrame.ColumnOrder Property (Access)

 Copy code hover
[image]

BoundObjectFrame.ColumnOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.

Syntax

expression .ColumnOrder

expression A variable that represents a BoundObjectFrame object.

Remarks

To set or change this property for a table or query by using Visual Basic, you must use a column's Properties collection. For details on using the Properties collection, see Properties .

Note Note

The ColumnOrder property isn't available in Design view.

The ColumnOrder property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

In Datasheet view, a field's ColumnOrder property setting is determined by the field's position. For example, the field in the leftmost column in Datasheet view has a ColumnOrder property setting of 1, the next field has a setting of 2, and so on. Changing a field's ColumnOrder property resets the property for that field and every field to the left of its original position in Datasheet view.

In other views, the property setting is 0 unless you explicitly change the order of one or more fields in Datasheet view (either by dragging the fields to new positions or by changing their ColumnOrder property settings). Fields to the right of the moved field's new position will have a property setting of 0 in views other than Datasheet view.

The order of the fields in Datasheet view doesn't affect the order of the fields in table Design view or Form view.

Example

The following example displays the ProductName and QuantityPerUnit fields in the first two columns in Datasheet view of the Products form.

VBA Copy code Copy code
Forms!Products!ProductName.ColumnOrder = 1
Forms!Products!QuantityPerUnit.ColumnOrder = 2

The next example displays the ProductName and QuantityPerUnit fields in the first two columns of the Products table in Datasheet view. To set the ColumnOrder property, the example uses the SetFieldProperty procedure. If this procedure is run while the table is open, changes will not be displayed until it is closed and reopened.

VBA Copy code Copy code
Public Sub SetColumnOrder()

 Dim dbs As DAO.Database
 Dim tdf As DAO.TableDef

 Set dbs = CurrentDb
 Set tdf = dbs!Products

 ' Call the procedure to set the ColumnOrder property.
 SetFieldProperty tdf!ProductName, "ColumnOrder", dbLong, 2
 SetFieldProperty tdf!QuantityPerUnit, "ColumnOrder", dbLong, 3

 Set tdf = Nothing
 Set dbs = Nothing

End Sub

Private Sub SetFieldProperty(ByRef fld As DAO.Field, _
 ByVal strPropertyName As String, _
 ByVal intPropertyType As Integer, _
 ByVal varPropertyValue As Variant)
 ' Set field property without producing nonrecoverable run-time error.

 Const conErrPropertyNotFound = 3270
 Dim prp As Property

 ' Turn off error handling.
 On Error Resume Next

 fld.Properties(strPropertyName) = varPropertyValue

 ' Check for errors in setting the property.
 If Err <> 0 Then
 If Err <> conErrPropertyNotFound Then
 On Error GoTo 0
 MsgBox "Couldn't set property '" & strPropertyName & _
 "' on field '" & fld.Name & "'", vbCritical
 Else
 On Error GoTo 0
 Set prp = fld.CreateProperty(strPropertyName, intPropertyType, _
 varPropertyValue)
 fld.Properties.Append prp
 End If
 End If

 Set prp = Nothing

End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


SmartTags Properties (Access)

 Copy code hover
[image]

SmartTags Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only SmartTag.
Parent | Returns the parent object for the specified object. Read-only.


ImportExportSpecifications.Parent Property (Access)

 Copy code hover
[image]

ImportExportSpecifications.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only Object.

Version Information

Version Added: Access 2007

Syntax

expression .Parent

expression A variable that represents an ImportExportSpecifications object.

See also

Concepts

ImportExportSpecifications Collection

Other resources

ImportExportSpecifications Object Members


References.Count Property (Access)

 Copy code hover
[image]

References.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents a References object.

See also

Concepts

References Collection

Other resources

References Object Members


Initializing the dBASE Database Driver

 Copy code hover
[image]

Initializing the dBASE Database Driver
Send feedback

When you install the dBASE database driver, the Setup program writes a set of default values to the Microsoft® Windows® Registry in the Engines and ISAM Formats subkeys. You should not modify these settings directly; use the setup program for your application to add, remove, or change these settings. The following sections describe initialization and ISAM format settings for the dBASE database driver.

The Paradox database driver will work in one of two modes, depending upon whether the Borland Database Engine (BDE) is installed. Paradox data is only updateable with the BDE. Without the BDE, the Paradox data can be Read, Exported, or Linked to read-only.

dBASE Initialization Settings

The Access Connectivity Engine\Engines\Xbase folder includes initialization settings for the Acexbe.dll driver, used for access to external dBASE data sources. Typical settings for the entries in this folder are shown in the following example.

Copy code Copy code
win32=<path>\Acexbe.dll

NetworkAccess=On

PageTimeout=600

INFPath=C:\DBASE\SYSTEM

CollatingSequence=ASCII

DataCodePage=OEM

Deleted=On

DbcsStr=On

Century=Off

Date=MDY

Mark=47

Exact=Off

The Microsoft Access database engine uses the Xbase folder entries as follows.

Entry

Description

win32

The location of Msxbse35.dll. The full path is determined at the time of installation. Values are of type REG_SZ.

NetworkAccess

A binary indicator for file locking preference. If NetworkAccess is set to 00, tables are opened for exclusive access, regardless of the settings of the OpenDatabase and OpenRecordset methods' exclusive argument. The default value is 01. Values are of type REG_BINARY.

PageTimeout

The length of time between when data is placed in an internal cache and when it is invalidated. The value is specified in 100 millisecond units. The default is 600 units or 60 seconds. Values are of type REG_DWORD.

INFPath

The full path to the .inf file directory. The Microsoft Access database engine first looks for an .inf file in the directory containing the table. If the .inf file is not in the database directory, it looks in the INFPath. If there is no INFPath, it uses whatever index files (.cdx or .mdx) it finds in the database directory. Values are of type REG_SZ. This entry is not written by the installation procedure.

CollatingSequence

This setting is only used if the BDE is not present on the machine. The collating sequence for all dBASE tables created or opened using the Microsoft Access database engine. Possible values are ASCII and International. The default is ASCII. Values are of type REG_SZ.

DataCodePage

This setting is only used if the BDE is not present on the machine. An indicator of how text pages are stored. Possible settings are:

  • OEM — OemToAnsi and AnsiToOem conversions done.

  • ANSI — OemToAnsi and AnsiToOem conversions not done.

The default is OEM. Values are of type REG_SZ.

Deleted

A binary indicator that determines how records marked for deletion are handled by the Microsoft Access database engine. A value of 01 corresponds to the dBASE command SET DELETED ON and indicates never to retrieve or position on a deleted record. A value of 00 corresponds to the dBASE command SET DELETED OFF and indicates to treat a deleted record like any other record. The default is 00. Values are of type REG_BINARY for Windows NT 3.51.

DbcsStr

A binary indicator that determines how the string functions will handle East Asia character set data. A value of 01 corresponds to the dBASE command SET KANJISTRING ON and indicates that strings should be treated as a dbcs character stream. A value of 00 indicates that strings should be treated as a simple byte stream.

Century

A binary indicator for formatting the century component of dates in cases where date-to-string functions are used in index expressions. A value of 01 corresponds to the dBASE command SET CENTURY ON and a value of 00 corresponds to the dBASE command SET CENTURY OFF. The default is 00. Values are of type REG_BINARY.

Date

The date formatting style to use in cases where date-to-string functions are used in index expressions. The possible settings for this entry, which corresponds to the dBASE SET DATE command, are American, ANSI, British, French, DMY, German, Italian, Japan, MDY, USA, and YMD. The default is MDY. Values are of type REG_SZ.

Mark

The decimal value of the ASCII character used to separate date parts. The default depends on the Date setting as follows:

  • "/" (American, MDY)

  • "." (ANSI)

  • "/" (British, French, DMY)

  • "." (German)

  • "-" (Italian)

  • "/" (Japan, YMD)

  • "-" (USA)

A value of 0 specifies that the system should use the separator usually associated with the selected date format. The default is 0. Values are of type REG_DWORD.

Exact

A binary indicator for string comparisons. A value of 01 corresponds to the dBASE command SET EXACT ON. A value of 00 corresponds to the dBASE command SET EXACT OFF. The default is 00. Values are of type REG_BINARY..

dBASE ISAM Formats

The Access Connectivity Engine\ISAM Formats\dBASE III folder contains the following entries.

Entry name | Type | Value
Engine | REG_SZ | Xbase
ExportFilter | REG_SZ | dBASE III (*.dbf)
ImportFilter | REG_SZ | dBASE III (*.dbf)
CanLink | REG_BINARY | 01
OneTablePerFile | REG_BINARY | 01
IsamType | REG_DWORD | 0
IndexDialog | REG_BINARY | 01
IndexFilter | REG_SZ | dBASE Index (*.ndx)
CreateDBOnExport | REG_BINARY | 00
ResultTextImport | REG_SZ | Import data from the external file into the current database. Changing data in the current database will not change data in the external file.
ResultTextLink | REG_SZ | Create a table in the current database that is linked to the external file. Changing data in the current database will change data in the external file.
ResultTextExport | REG_SZ | Export data from the current database into a dBASE III file. This process will overwrite the data if exported to an existing file.
SupportsLongNames | REG_BINARY | 00

The Access Connectivity Engine\ISAM Formats\dBASE IV folder contains the following entries.

Entry name | Type | Value
Engine | REG_SZ | Xbase
ExportFilter | REG_SZ | dBASE IV (*.dbf)
ImportFilter | REG_SZ | dBASE IV (*.dbf)
CanLink | REG_BINARY | 01
OneTablePerFile | REG_BINARY | 01
IsamType | REG_DWORD | 0
IndexDialog | REG_BINARY | 01
IndexFilter | REG_SZ | dBASE Index (*.ndx; *.mdx)
CreateDBOnExport | REG_BINARY | 00
ResultTextImport | REG_SZ | Import data from the external file into the current database. Changing data in the current database will not change data in the external file.
ResultTextLink | REG_SZ | Create a table in the current database that is linked to the external file. Changing data in the current database will change data in the external file.
ResultTextExport | REG_SZ | Export data from the current database into a dBASE IV file. This process will overwrite the data if exported to an existing file.
SupportsLongNames | REG_BINARY | 00

The Access Connectivity Engine\ISAM Formats\dBASE 5.0 folder contains the following entries.

Entry name | Type | Value
Engine | REG_SZ | Xbase
ExportFilter | REG_SZ | dBASE 5 (*.dbf)
ImportFilter | REG_SZ | dBASE 5 (*.dbf)
CanLink | REG_BINARY | 01
OneTablePerFile | REG_BINARY | 01
IsamType | REG_DWORD | 0
IndexDialog | REG_BINARY | 01
IndexFilter | REG_SZ | dBASE Index (*.ndx; *.mdx)
CreateDBOnExport | REG_BINARY | 00
ResultTextImport | REG_SZ | Import data from the external file into the current database. Changing data in the current database will not change data in the external file.
ResultTextLink | REG_SZ | Create a table in the current database that is linked to the external file. Changing data in the current database will change data in the external file.
ResultTextExport | REG_SZ | Export data from the current database into a dBASE 5 file. This process will overwrite the data if exported to an existing file.
SupportsLongNames | REG_BINARY | 00
Note Note

When you change Windows Registry settings, you must exit and then restart the database engine for the new settings to take effect.


Joined table

 Copy code hover
[image]

Joined table <name> not listed in FROM clause. (Error 3080)
Send feedback

Add the specified table name to the FROM clause of the query, and then try the operation again.


Making a Connection

 Copy code hover
[image]

Making a Connection
Send feedback

To connect to a data source, you must specify a connection string, the parameters of which might differ for each provider and data source. For more information, see Creating the Connection String.

ADO most commonly opens a connection by using the Connection object Open method. The syntax for the Open method is shown here:

Copy code Copy code

Dim connection as New ADODB.Connection
connection.Open ConnectionString, UserID, Password, OpenOptions

Alternatively, you can invoke a shortcut technique, Recordset.Open, to open an implicit connection and issue a command over that connection in one operation. Do this by passing in a valid connection string as the ActiveConnection argument to the Open method. Here is the syntax for each method in Visual Basic:

Copy code Copy code

Dim recordset as ADODB.Recordset
Set recordset = New ADODB.Recordset
recordset.Open Source, ActiveConnection, CursorType, LockType, Options
Note Note

When should you use a Connection object vs. the Recordset.Open shortcut? Use the Connection object if you plan to open more than one Recordset, or when executing multiple commands. A connection is still created by ADO implicitly when you use the Recordset.Open shortcut.


Rectangle.Visible Property (Access)

 Copy code hover
[image]

Rectangle.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents a Rectangle object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


ADO MD Collections Reference

 Copy code hover
[image]

ADO MD Collections Reference
Send feedback

In this section

  • ADO MD Collections

  • Axes Collection (ADO MD Reference)

  • CubeDefs Collection (ADO MD Reference)

  • Dimensions Collection (ADO MD Reference)

  • Hierarchies Collection (ADO MD Reference)

  • Levels Collection (ADO MD Reference)

  • Members Collection (ADO MD Reference)

  • Positions Collection (ADO MD Reference)


DBEngine.DefaultPassword Property (DAO)

 Copy code hover
[image]

DBEngine.DefaultPassword Property (DAO)
Send feedback

Sets the password used to create the default Workspace when it is initialized. Read/write String.

Syntax

expression .DefaultPassword

expression A variable that represents a DBEngine object.

Remarks

The setting for DefaultPassword is a String data type that can be up to 20 characters long. It can contain any character except ASCII 0.

Note Note

Use strong passwords that combine upper- and lowercase letters, numbers, and symbols. Weak passwords don't mix these elements. Strong password: Y6dh!et5. Weak password: House27. Use a strong password that you can remember so that you don't have to write it down.

By default, the DefaultUser property is set to "admin" and the DefaultPassword property is set to a zero-length string ("").

Typically, you use the CreateWorkspace method to create a Workspace object with a given user name and password. However, for backward compatibility with earlier versions and for convenience when you don't implement a secured database, the Microsoft Access database engine automatically creates a default Workspace object when needed if one isn't already open. In this case, the DefaultUser and DefaultPassword property values define the user and password for the default Workspace object.

For this property to take effect, you should set it before calling any DAO methods.


Line.Name Property (Access)

 Copy code hover
[image]

Line.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a Line object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

Line Object

Other resources

Line Object Members


Parameter Object (DAO)

 Copy code hover
[image]

Parameter Object (DAO)
Send feedback

A Parameter object represents a value supplied to a query. The parameter is associated with a QueryDef object created from a parameter query.

Remarks

Parameter objects allow you to change the arguments in a frequently run QueryDef object without having to recompile the query.

Using the properties of a Parameter object, you can set a query parameter that can be changed before the query is run. You can:

  • Use the Name property to return the name of a parameter.

  • Use the Value property to set or return the parameter values to be used in the query.

  • Use the Type property to return the data type of the Parameter object.

  • Use the Direction property to set or return whether the parameter is an input parameter, an output parameter, or both.

Example

This example demonstrates Parameter objects and the Parameters collection by creating a temporary QueryDef and retrieving data based on changes made to the QueryDef object's Parameters. The ParametersChange procedure is required for this procedure to run.

VBA Copy code Copy code
Sub ParameterX()

 Dim dbsNorthwind As Database
 Dim qdfReport As QueryDef
 Dim prmBegin As Parameter
 Dim prmEnd As Parameter

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 ' Create temporary QueryDef object with two
 ' parameters.
 Set qdfReport = dbsNorthwind.CreateQueryDef("", _
 "PARAMETERS dteBegin DateTime, dteEnd DateTime; " & _
 "SELECT EmployeeID, COUNT(OrderID) AS NumOrders " & _
 "FROM Orders WHERE ShippedDate BETWEEN " & _
 "[dteBegin] AND [dteEnd] GROUP BY EmployeeID " & _
 "ORDER BY EmployeeID")
 Set prmBegin = qdfReport.Parameters!dteBegin
 Set prmEnd = qdfReport.Parameters!dteEnd

 ' Print report using specified parameter values.
 ParametersChange qdfReport, prmBegin, #1/1/95#, _
 prmEnd, #6/30/95#
 ParametersChange qdfReport, prmBegin, #7/1/95#, _
 prmEnd, #12/31/95#

 dbsNorthwind.Close

End Sub

Sub ParametersChange(qdfTemp As QueryDef, _
 prmFirst As Parameter, dteFirst As Date, _
 prmLast As Parameter, dteLast As Date)
 ' Report function for ParameterX.

 Dim rstTemp As Recordset
 Dim fldLoop As Field

 ' Set parameter values and open recordset from
 ' temporary QueryDef object.
 prmFirst = dteFirst
 prmLast = dteLast
 Set rstTemp = _
 qdfTemp.OpenRecordset(dbOpenForwardOnly)
 Debug.Print "Period " & dteFirst & " to " & dteLast

 ' Enumerate recordset.
 Do While Not rstTemp.EOF

 ' Enumerate Fields collection of recordset.
 For Each fldLoop In rstTemp.Fields
 Debug.Print " - " & fldLoop.Name & " = " & fldLoop;
 Next fldLoop

 Debug.Print
 rstTemp.MoveNext
 Loop

 rstTemp.Close

End Sub


Workspaces.Append Method (DAO)

 Copy code hover
[image]

Workspaces.Append Method (DAO)
Send feedback

Adds a new Workspace to the Workspaces collection.

Syntax

expression .Append(Object)

expression A variable that represents a Workspaces object.

Parameters

Name | Required/Optional | Data Type | Description
Object | Required | Object | An object variable that represents the field being appended to the collection.

Remarks

The appended object becomes a persistent object, stored on disk, until you delete it by using the Delete method.

The addition of a new object occurs immediately, but you should use the Refresh method on any other collections that may be affected by changes to the database structure.

If the object you're appending isn't complete (such as when you haven't appended any Field objects to a Fields collection of an Index object before it's appended to an Indexes collection) or if the properties set in one or more subordinate objects are incorrect, using the Append method causes an error. For example, if you haven't specified a field type and then try to append the Field object to the Fields collection in a TableDef object, using the Append method triggers a run-time error.


Indexes.Count Property (DAO)

 Copy code hover
[image]

Indexes.Count Property (DAO)
Send feedback

Returns the number of objects in the specified collection. Read-only.

Syntax

expression .Count

expression A variable that represents an Indexes object.

Remarks

Because members of a collection begin with 0, you should always code loops starting with the 0 member and ending with the value of the Count property minus 1. If you want to loop through the members of a collection without checking the Count property, you can use a For Each...Next command.

The Count property setting is never Null. If its value is 0, there are no objects in the collection.


AllFunctions.Count Property (Access)

 Copy code hover
[image]

AllFunctions.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents an AllFunctions object.

See also

Concepts

AllFunctions Collection

Other resources

AllFunctions Object Members


NavigationButton.Bevel Property (Access)

 Copy code hover
[image]

NavigationButton.Bevel Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bevel effect applied to the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .Bevel

expression A variable that represents a NavigationButton object.

Remarks

The Bevel property contains a numeric expression that represents the bevel effect applied to the specified object. The default value of the Bevel property is 0, which does not apply a bevel effect.

The Bevel effects are listed in the following table.

Value | Effect
0 | None
1 | Circle
2 | Relaxed Inset
3 | Cross
4 | Cool Slant
5 | Angle
6 | Soft Round
7 | Convex
8 | Slope
9 | Divot
10 | Riblet
11 | Hard Edge
12 | Art Deco

To see the available bevel effects and apply a bevel through the user interface, first open the form or report in Layout view or Design view by right-clicking the form or report in the Navigation Pane, and then clicking the view you want. Then, click the object to which you want to apply a bevel effect. Next, on the Format tab, in the Control Formatting group, click Shape Effects, then click Bevel and choose a bevel effect. Notice that the bevel effects are indexed from left to right, and then top to bottom. So the first item, under No Bevel, has the value 0. Then, under Bevel, the first row contains bevel effects with values from 1 to 4. The second row from 5 to 8, and the third row from 9 to 12.

This property is not surfaced in the property sheet.

Example

The following code example sets the bevel effect to Cross.

VBA Copy code Copy code
Public Const BevelEffectNone = 0
Public Const BevelEffectCircle = 1
Public Const BevelEffectRelaxedInset = 2
Public Const BevelEffectCross = 3
Public Const BevelEffectCoolSlant = 4
Public Const BevelEffectAngle = 5
Public Const BevelEffectSoftRound = 6
Public Const BevelEffectConvex = 7
Public Const BevelEffectSlope = 8
Public Const BevelEffectDivot = 9
Public Const BevelEffectRiblet = 10
Public Const BevelEffectHardEdge = 11
Public Const BevelEffectArtDeco = 12
Me.ctl.Bevel = BevelEffectCross

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Data type mismatch in criteria expression. (Error 3464)

 Copy code hover
[image]

Data type mismatch in criteria expression. (Error 3464)
Send feedback

The criteria expression in a Find method is attempting to compare a field with a value whose data type does not match the field's data type.


SubForm.InSelection Property (Access)

 Copy code hover
[image]

SubForm.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents a SubForm object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Append Method (ADOX Views)

 Copy code hover
[image]

Append Method (ADOX Views)
Send feedback

Creates a new View object and appends it to the Views collection.

Syntax

Views.Append Name, Command

Parameters

  • Name

  • A String value that specifies the name of the view to create.

  • Command

  • An ADO Command object that represents the view to create.

Remarks

Creates a new view in the data source with the name and attributes specified in the Command object.

If the command text that the user specifies represents a procedure rather than a view, the behavior is dependent upon the provider. Append will fail if the provider does not support persisting commands.

Note Note

When using the OLE DB Provider for Microsoft Jet, the Views collection Append method will allow you to specify a Procedure rather than a View in the Command parameter. The Procedure will be added to the data source and will be added to the Views collection. After the Append, if the Procedures and Views collections are refreshed, the Procedure will no longer be in the Views collection and will appear in the Procedures collection.


CheckBox.HelpContextId Property (Access)

 Copy code hover
[image]

CheckBox.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Syntax

expression .HelpContextId

expression A variable that represents a CheckBox object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


The partial filter expression contains an unknown function. (Error 3589)

 Copy code hover
[image]

The partial filter expression contains an unknown function. (Error 3589)
Send feedback

Make sure you are using the correct name of the function. Also, not all functions are valid in filter expressions.


NavigationControl.NumeralShapes Property (Access)

 Copy code hover
[image]

NavigationControl.NumeralShapes Property (Access)
See also Send feedback

Published: July 16, 2012

Version Information

Version Added: Access 2010

Syntax

expression .NumeralShapes

expression A variable that represents a NavigationControl object.

Remarks

The NumeralShapes property uses the following settings.

Setting | Visual Basic | Description
System | 0 | Numeral shapes determined by the Numeral Shapes system setting.
Arabic | 1 | Arabic digit shapes will be used to display and print numerals.
National | 2 | National digit shapes will be used to display and print numerals.
Context | 3 | Numeral shapes determined by Unicode context rules for adjacent text.

Example

The following example changes the NumeralShapes property for the selected control to 0 (numeral shapes will be determined by the Numeral Shapes system setting).

VBA Copy code Copy code
Public Sub ChangeNumeralShapes(ctl As Control)
 ctl.NumeralShapes = 0
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


 Copy code hover
[image]

<Message> in query expression <expression>. (Error 3075)
Send feedback

The expression you typed is not valid for the reason indicated in the message. Make sure you have typed field names and punctuation correctly, and then try the operation again.


SQL property [ADO]

 Copy code hover
[image]

SQL property [ADO]
Send feedback

Indicates the query string used to retrieve the Recordset.

You can set the SQL property at design time in the RDS.DataControl object's OBJECT tags, or at run time in scripting code.

Parameters

  • QueryString

  • A String value that contains a valid SQL data request.

  • DataControl

  • An object variable that represents an RDS.DataControl object.

Remarks

In general, this is an SQL statement (using the dialect of the database server), such as . To ensure that records are matched and updated accurately, an updatable query must contain a field other than a Long Binary field or a computed field.

The SQL property is optional if a custom server-side business objects retrieves the data for the client.


Execute, Requery, and Clear Methods Example (VJ++)

 Copy code hover
[image]

Execute, Requery, and Clear Methods Example (VJ++)
Send feedback

This example demonstrates the Execute method when run from both a Command object and a Connection object. It also uses the Requery method to retrieve current data in a recordset, and the Clear method to clear the contents of the Errors collection. The ExecuteCommand and PrintOutput procedures are required for this procedure to run.

Copy code Copy code

// BeginExecuteJ
// The WFC class includes the ADO objects.
import com.ms.wfc.data.*;
import java.io.*;

public class ExecuteX
{
 // Main Function

 public static void main (String[] args)
 {
 ExecuteX();
 }

 // ExecuteX Function

 static void ExecuteX()
 {
 // Define string variables.
 String strSQLChange = "UPDATE Titles SET Type = "
 + "'self_help' WHERE Type = 'psychology'";
 String strSQLRestore = "UPDATE Titles SET Type = "
 + "'psychology' WHERE Type = 'self_help'";
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";

 // Define ADO objects.
 Connection cnConn1 = null;
 Command cmdChange = null;
 Recordset rsTitles = null;

 try
 {
 // Open connection.
 cnConn1 = new Connection ();
 cnConn1.open(strCnn, "", "", AdoEnums.CommandType.UNSPECIFIED);

 // Create command object.
 cmdChange = new Command();
 cmdChange.setActiveConnection (cnConn1);
 cmdChange.setCommandText (strSQLChange);

 // Open recordset with Titles table.
 rsTitles = new Recordset();
 rsTitles.open("Titles", cnConn1,
 AdoEnums.CursorType.STATIC,
 AdoEnums.LockType.OPTIMISTIC,
 AdoEnums.CommandType.TABLE);

 // Print report of original data.
 System.out.println("\n\n\tData in Titles table "
 + "before executing the query: \n");
 PrintOutput(rsTitles);

 // Clear extraneous errors from the Errors collection.
 cnConn1.getErrors().clear();

 // Call the ExecuteCommand subroutine to
 // execute cmdChange command.
 ExecuteCommand(cmdChange, rsTitles);

 // Print report of new data.
 System.out.println("\n\n\tData in Titles table after "
 + "executing the query: \n");
 PrintOutput(rsTitles);

 // Use the Connection object's execute method to
 // execute SQL statement to restore data.
 cnConn1.execute(strSQLRestore);

 // Print report of restored data.
 System.out.println("\n\n\tData after executing the query "
 + "to restore the original information: \n");
 PrintOutput(rsTitles);
 } // End Try statement.
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rsTitles != null)
 {
 PrintProviderError(rsTitles.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 finally
 {
 // Cleanup objects before exit.
 if (rsTitles != null)
 if (rsTitles.getState() == 1)
 rsTitles.close();
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 }
 }

 // ExecuteCommand Function

 static void ExecuteCommand(Command cmdTemp, Recordset rstTemp)
 {
 try
 {
 // CommandText property already set before function was called.
 cmdTemp.setCommandType(AdoEnums.CommandType.TEXT);
 cmdTemp.execute();

 // Retrieve the current data by requerying the recordset.
 rstTemp.requery(AdoEnums.CommandType.UNKNOWN);
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.
 PrintProviderError(rstTemp.getActiveConnection());
 }
 }

 // PrintOutput Function

 static void PrintOutput(Recordset rstTemp)
 {
 // Declarations.
 BufferedReader in = new
 BufferedReader(new InputStreamReader(System.in));

 // Ensure at top of recordset.
 rstTemp.moveFirst();

 // If EOF is true, then no data and skip print loop.
 if( rstTemp.getEOF() )
 {
 System.out.println("\tRecordset empty\n");
 }
 else
 {
 // Enumerate Recordset and print data from each.
 while( !(rstTemp.getEOF()) )
 {
 // Convert variant string to convertable string type.
 System.out.println("\t"
 + rstTemp.getFields().getItem("Title").getValue() + " "
 + rstTemp.getFields().getItem("Type").getValue() + "\n");
 rstTemp.moveNext();
 }
 }
 try
 {
 System.out.println("\nPress <Enter> key to continue.");
 in.readLine();
 }
 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndExecuteJ


ADO Syntax Indexes

 Copy code hover
[image]

ADO Syntax Indexes
Send feedback

The syntax for calling ADO methods and properties differs depending upon your development environment. The rest of the ADO Language Reference uses the Microsoft Visual Basic programming language to illustrate ADO method and property syntax. However, refer to the sections below for more specific syntax examples based on your programming language and methodology.

  • The ADO for Visual C++ Syntax Index for COM covers ADO properties and methods without using the #import compiler directive with Microsoft Visual C++.

  • The ADO for Visual C++ Syntax Index with #import covers ADO properties and methods when using the #import compiler directive with Microsoft Visual C++.

  • The ADO/WFC Syntax Index covers using the ADO Windows Foundation Classes with Visual J++.


Out-of-date Paradox lock file. (Error 3230)

 Copy code hover
[image]

Out-of-date Paradox lock file. (Error 3230)
Send feedback

You tried to use a Paradox table, but the table's associated lock (.lck) file is outdated. Delete the .lck file and then try the operation again.


FormatCondition.Modify Method (Access)

 Copy code hover
[image]

FormatCondition.Modify Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the Modify method to change the format conditions of a FormatCondition object in the FormatConditions collection of a combo box or text box control.

Syntax

expression .Modify(Type, Operator, Expression1, Expression2)

expression A variable that represents a FormatCondition object.

Parameters

Name

Required/Optional

Data Type

Description

Type

Required

AcFormatConditionType

A AcFormatConditionType constant that specifies the type of condition to be modified.

Operator

Optional

AcFormatConditionOperator

A AcFormatConditionOperator constant that specifies the type of operator to be used.

Note Note

If the type argument is acExpression, the operator argument is ignored. If you leave this argument blank, the default constant (acBetween) is assumed.

Expression1

Optional

Variant

A value or expression associated with the first part of the conditional format. Can be a constant value or a string value.

Expression2

Optional

Variant

A value or expression associated with the second part of the conditional format when the operator argument is acBetween or acNotBetween (otherwise, this argument is ignored). Can be a constant value or a string value.

Return Value

Nothing

See also

Concepts

FormatCondition Object

Other resources

FormatCondition Object Members


Cannot start your application. The workgroup information file is missing or opened exclusively by another user. (Error 3028)

 Copy code hover
[image]

Cannot start your application. The workgroup information file is missing or opened exclusively by another user. (Error 3028)
Send feedback

To ensure referential integrity in databases created by the Microsoft Access database engine, your application must read the database's System.mdw file. Make sure the file is in the location specified in the SystemDB value in the Windows Registry.


How to: Group Records in a Result Set Using Access SQL

 Copy code hover
[image]

How to: Group Records in a Result Set Using Access SQL
Send feedback

Sometimes records in a table are logically related, as in the case of the invoices table. Because one customer can have many invoices, it could be useful to handle all invoices for one customer as a group, in order to find statistical and summary information about the group.

The key to grouping records is that one or more fields in each record must contain the same value for every record in the group. In the case of the invoices table, the CustomerID field value is the same for every invoice a particular customer has.

To create a group of records, use the GROUP BY clause with the name of the field or fields you want to group with.

VBA Copy code Copy code
SELECT CustomerID, Count(*) AS [Number of Invoices],
    Avg(Amount) AS [Average Invoice Amount]
    FROM tblInvoices
    GROUP BY CustomerID

Be aware that the statement will return one record that shows the customer ID, the number of invoices the customer has, and the average invoice amount, for every customer who has an invoice record in the invoices table. Because each customer invoice is handled as a group, you are able to count the number of invoices and then determine the average invoice amount.

You can specify a condition at the group level by using the HAVING clause, which is similar to the WHERE clause. For example, the following query returns only those records for each customer whose average invoice amount is less than 100.

VBA Copy code Copy code
SELECT CustomerID, Count(*) AS [Number of Invoices],
    Avg(Amount) AS [Average Invoice Amount]
    FROM tblInvoices
    GROUP BY CustomerID
    HAVING Avg(Amount) < 100


Database is already replicable. (Error 3784)

 Copy code hover
[image]

Database is already replicable. (Error 3784)
Send feedback

The database is already replicable and cannot be made replicable again. If, in the database there exist local objects you want replicated, from the Design Master make the objects replicable by setting the replicable property to True.


Recordsets Object Reference (DAO)

 Copy code hover
[image]

Recordsets Object Reference (DAO)
Send feedback

In this section

  • Recordsets Collection (DAO)

  • Recordsets Members (DAO)

  • Recordsets Properties (DAO)

  • Recordsets Methods (DAO)


Deleting data in a linked table is not supported by this ISAM. (Error 3617)

 Copy code hover
[image]

Deleting data in a linked table is not supported by this ISAM. (Error 3617)
Send feedback

The installable ISAM you are using does not allow you to delete records in external tables. You can only add new records.


A system error has occurred or your swap file has reached its limit. (Error 3539)

 Copy code hover
[image]

A system error has occurred or your swap file has reached its limit. (Error 3539)
Send feedback

The Synchronizer has made a system call that resulted in an unexpected problem. Shut down, turn off, and then reboot your computer.


Cannot open action query

 Copy code hover
[image]

Cannot open action query <name>. (Error 3064)
Send feedback

You tried to open an action query using the OpenQueryDef method, which is an obsolete method originally valid only with select queries. The preferred method for executing an action query is to use the Execute method of the QueryDef object.


Microsoft ActiveX Data Objects reference

 Copy code hover
[image]

Microsoft ActiveX Data Objects reference
Send feedback

Purpose

Microsoft ActiveX Data Objects (ADO) enable your client applications to access and manipulate data from a database server through an OLE DB provider. Its primary benefits are ease of use, high speed, low memory overhead, and a small disk footprint. ADO supports key features for building client/server and Web-based applications.

RDS

ADO also features Remote Data Service (RDS), by which you can move data from a server to a client application or Web page, manipulate the data on the client, and return updates to the server in a single round trip.

ADO MD

Microsoft ActiveX Data Objects (Multidimensional) (ADO MD) provides easy access to multidimensional data from languages such as Microsoft Visual Basic, Microsoft Visual C++, and Microsoft Visual J++. ADO MD extends Microsoft ActiveX Data Objects (ADO) to include objects specific to multidimensional data, such as the CubeDef and Cellset objects. With ADO MD you can browse multidimensional schema, query a cube, and retrieve the results.

Like ADO, ADO MD uses an underlying OLE DB provider to gain access to data. To work with ADO MD, the provider must be a multidimensional data provider (MDP) as defined by the OLE DB for OLAP specification. MDPs present data in multidimensional views as opposed to tabular data providers (TDPs) that present data in tabular views. Refer to the documentation for your OLAP OLE DB provider for more detailed information on the specific syntax and behaviors supported by your provider.

ADOX

Microsoft ActiveX Data Objects Extensions for Data Definition Language and Security (ADOX) is an extension to the ADO objects and programming model. ADOX includes objects for schema creation and modification, as well as security. Because it is an object-based approach to schema manipulation, you can write code that will work against various data sources regardless of differences in their native syntaxes.

ADOX is a companion library to the core ADO objects. It exposes additional objects for creating, modifying, and deleting schema objects, such as tables and procedures. It also includes security objects to maintain users and groups and to grant and revoke permissions on objects.

Main Components of ADO 2.5

Programmer's Guide

An introduction to using ADO, RDS, ADO MD, and ADOX.

Programmer's Reference

This section of the ADO documentation contains topics for each ADO, RDS, ADO MD, and ADOX object, collection, property, dynamic property, method, event, and enumeration.

Feedback

You can send feedback about ADO documentation or samples directly to the ADO documentation team.


CheckBox.OnMouseDown Property (Access)

 Copy code hover
[image]

CheckBox.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Syntax

expression .OnMouseDown

expression A variable that represents a CheckBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


How to: Use Textual Criteria from a Control on a Form

 Copy code hover
[image]

How to: Use Textual Criteria from a Control on a Form
Send feedback

If you want to change the criteria argument for an operation based on a user's decision, you can specify that the criteria come from a control on a form. For example, you could specify that the criteria argument comes from a list box containing the last names of all employees in an Employees table.

To specify textual criteria coming from a control on a form, you include in the criteria argument an expression that references the control on the form. This expression should be separate from the string expression, so that Microsoft Access will evaluate the control expression first and concatenate it with the rest of the string expression before performing the appropriate operation.

In addition to enclosing the entire string expression in double quotation marks ("), you must also ensure that the textual criteria within the string expression are enclosed in single quotation marks ('). The quotation marks must be included in the strings flanking the expression that references the control on the form.

Note Note

The single quotation marks indicate to Microsoft Access that the criteria argument contains a string within a string.

The following example performs a lookup on an Employees table and returns the region in which an employee lives, based on the employee's last name. The current value of a list box control called LastName on the Employees form determines the criteria. Note the placement of the single quotation marks.

Copy code Copy code
=DLookup("[Region]", "Employees", "[LastName] = '" _
    & Forms!Employees!LastName & "'")

If the current value of the control is King, the following criteria argument is passed to the DLookup function after Microsoft Access evaluates the expression and concatenates the strings:

Copy code Copy code
"[LastName] = 'King'"

Keep in mind that the entire string comprising the criteria argument must also be enclosed in double quotation marks once the strings have been concatenated.

To troubleshoot an expression in the criteria argument, break the expression into smaller components and test each one individually in the Immediate window. When all of the components are working correctly, put them back together one at a time until the complete expression works correctly.

You can also include a variable representing a textual string in the criteria argument. The variable should be separate from the string expression, so that Microsoft Access will evaluate the variable first and then concatenate it with the rest of the string expression. The textual string must be enclosed in single or double quotation marks.

The following example shows how to construct a criteria argument that includes a variable representing a textual string:

Copy code Copy code
Dim strLastName As String
Dim varResult As Variant

strLastName = "King"
varResult = DLookup("[EmployeeID]", "Employees", "[LastName] = '" _
    & strLastName & "'")


SmartTagAction.Name Property (Access)

 Copy code hover
[image]

SmartTagAction.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.

Syntax

expression .Name

expression A variable that represents a SmartTagAction object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

SmartTagAction Object

Other resources

SmartTagAction Object Members


ComboBox.Hyperlink Property (Access)

 Copy code hover
[image]

ComboBox.Hyperlink Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.

Syntax

expression .Hyperlink

expression A variable that represents a ComboBox object.

Example

The CreateHyperlink procedure in the following example sets the hyperlink properties for a command button, label, or image control to the address and subaddress values passed to the procedure. The address setting is an optional argument, because a hyperlink to an object in the current database uses only the subaddress setting, To try this example, create a form with two text box controls (txtAddress and txtSubAddress) and a command button (cmdFollowLink) and paste the following into the Declarations section of the form's module:

VBA Copy code Copy code
Private Sub cmdFollowLink_Click()
 CreateHyperlink Me!cmdFollowLink, Me!txtSubAddress, _
 Me!txtAddress
End Sub

Sub CreateHyperlink(ctlSelected As Control, _
 strSubAddress As String, Optional strAddress As String)
 Dim hlk As Hyperlink
 Select Case ctlSelected.ControlType
 Case acLabel, acImage, acCommandButton
 Set hlk = ctlSelected.Hyperlink
 With hlk
 If Not IsMissing(strAddress) Then
 .Address = strAddress
 Else
 .Address = ""
 End If
 .SubAddress = strSubAddress
 .Follow
 .Address = ""
 .SubAddress = ""
 End With
 Case Else
 MsgBox "The control '" & ctlSelected.Name _
 & "' does not support hyperlinks."
 End Select
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


CurrentProject Methods (Access)

 Copy code hover
[image]

CurrentProject Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
AddSharedImage | Imports the the specified image into the database and adds it to the SharedResources collection.
CloseConnection | You can use the CloseConnection method to close the current connection between the CurrentProject object in a Microsoft Access project (.adp) or Access database and the database specified in the project's base connection string.
OpenConnection | You can use the OpenConnection method to open an ADO connection to an existing Microsoft Access project (.adp) or Access database as the current Access project or database in the Microsoft Access window.
UpdateDependencyInfo | Updates the dependency information for the database.


Field.ValidateOnSet Property (DAO)

 Copy code hover
[image]

Field.ValidateOnSet Property (DAO)
Send feedback

Sets or returns a value that specifies whether or not the value of a Field object is immediately validated when the object's Value property is set (Microsoft Access workspaces only).

Syntax

expression .ValidateOnSet

expression A variable that represents a Field object.

Remarks

Only Field objects in Recordset objects support the ValidateOnSet property as read/write.

Setting the ValidateOnSet property to True can be useful in a situation when a user is entering records that include substantial Memo data. Waiting until the Update call to validate the data can result in unnecessary time spent writing the lengthy Memo data to the database if it turns out that the data was invalid anyway because a validation rule was broken in another field.

Example

This example uses the ValidateOnSet property to demonstrate how one might trap for errors during data entry. The ValidateData function is required for this procedure to run.

VBA Copy code Copy code
Sub ValidateOnSetX()

 Dim dbsNorthwind As Database
 Dim fldDays As Field
 Dim rstEmployees As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 ' Create and append a new Field object to the Fields
 ' collection of the Employees table.
 Set fldDays = _
 dbsNorthwind.TableDefs!Employees.CreateField( _
 "DaysOfVacation", dbInteger, 2)
 fldDays.ValidationRule = "BETWEEN 1 AND 20"
 fldDays.ValidationText = _
 "Number must be between 1 and 20!"
 dbsNorthwind.TableDefs!Employees.Fields.Append fldDays

 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees")

 With rstEmployees

 Do While True
 ' Add new record.
 .AddNew

 ' Get user input for three fields. Verify that the
 ' data do not violate the validation rules for any
 ' of the fields.
 If ValidateData(!FirstName, _
 "Enter first name.") = False Then Exit Do
 If ValidateData(!LastName, _
 "Enter last name.") = False Then Exit Do
 If ValidateData(!DaysOfVacation, _
 "Enter days of vacation.") = False Then Exit Do

 .Update
 .Bookmark = .LastModified
 Debug.Print !FirstName & " " & !LastName & _
 " - " & "DaysOfVacation = " & !DaysOfVacation

 ' Delete new record because this is a demonstration.
 .Delete
 Exit Do
 Loop

 ' Cancel AddNew method if any of the validation rules
 ' were broken.
 If .EditMode <> dbEditNone Then .CancelUpdate
 .Close
 End With

 ' Delete new field because this is a demonstration.
 dbsNorthwind.TableDefs!Employees.Fields.Delete _
 fldDays.Name
 dbsNorthwind.Close

End Sub

Function ValidateData(fldTemp As Field, _
 strMessage As String) As Boolean

 Dim strInput As String
 Dim errLoop As Error

 ValidateData = True
 ' ValidateOnSet is only read/write for Field objects in
 ' Recordset objects.
 fldTemp.ValidateOnSet = True

 Do While True
 strInput = InputBox(strMessage)
 If strInput = "" Then Exit Do
 ' Trap for errors when setting the Field value.
 On Error GoTo Err_Data
 If fldTemp.Type = dbInteger Then
 fldTemp = Val(strInput)
 Else
 fldTemp = strInput
 End If
 On Error GoTo 0
 If Not IsNull(fldTemp) Then Exit Do
 Loop

 If strInput = "" Then ValidateData = False

 Exit Function

Err_Data:

 If DBEngine.Errors.Count > 0 Then
 ' Enumerate the Errors collection. The description
 ' property of the last Error object will be set to
 ' the ValidationText property of the relevant
 ' field.
 For Each errLoop In DBEngine.Errors
 MsgBox "Error number: " & errLoop.Number & _
 vbCr & errLoop.Description
 Next errLoop
 End If

 Resume Next

End Function


Ceiling Function (Access 2013 custom web app)

 Copy code hover
[image]

Ceiling Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the smallest integer greater than, or equal to, the specified numeric expression.

Syntax

Ceiling(NumericExpression)

The Ceiling function contains the following argument.

Argument name | Description
NumericExpression | A numeric expression.


Label.BorderWidth Property (Access)

 Copy code hover
[image]

Label.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Syntax

expression .BorderWidth

expression A variable that represents a Label object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

Label Object

Other resources

Label Object Members


Recordsets Collection (DAO)

 Copy code hover
[image]

Recordsets Collection (DAO)
Send feedback

A Recordsets collection contains all open Recordset objects in a Connection or Database object.

Remarks

When you use DAO objects, you manipulate data almost entirely using Recordset objects.

A new Recordset object is automatically added to the Recordsets collection when you open the Recordset object, and is automatically removed when you close it.

You can create as many Recordset object variables as needed. Different Recordset objects can access the same tables, queries, and fields without conflicting.

To refer to a Recordset object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

Recordsets(0)

Recordsets("name")

Recordsets![name]

Note Note

You can open a Recordset object from the same data source or database more than once, creating duplicate names in the Recordsets collection. You should assign Recordset objects to object variables and refer to them by variable name.

Example

This example demonstrates Recordset objects and the Recordsets collection by opening four different types of Recordsets, enumerating the Recordsets collection of the current Database, and enumerating the Properties collection of each Recordset.

VBA Copy code Copy code
Sub RecordsetX()

 Dim dbsNorthwind As Database
 Dim rstTable As Recordset
 Dim rstDynaset As Recordset
 Dim rstSnapshot As Recordset
 Dim rstForwardOnly As Recordset
 Dim rstLoop As Recordset
 Dim prpLoop As Property

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind

 ' Open one of each type of Recordset object.
 Set rstTable = .OpenRecordset("Categories", _
 dbOpenTable)
 Set rstDynaset = .OpenRecordset("Employees", _
 dbOpenDynaset)
 Set rstSnapshot = .OpenRecordset("Shippers", _
 dbOpenSnapshot)
 Set rstForwardOnly = .OpenRecordset _
 ("Employees", dbOpenForwardOnly)

 Debug.Print "Recordsets in Recordsets " & _
 "collection of dbsNorthwind"

 ' Enumerate Recordsets collection.
 For Each rstLoop In .Recordsets

 With rstLoop
 Debug.Print " " & .Name

 ' Enumerate Properties collection of each
 ' Recordset object. Trap for any
 ' properties whose values are invalid in
 ' this context.
 For Each prpLoop In .Properties
 On Error Resume Next
 If prpLoop <> "" Then Debug.Print _
 " " & prpLoop.Name & _
 " = " & prpLoop
 On Error GoTo 0
 Next prpLoop

 End With

 Next rstLoop

 rstTable.Close
 rstDynaset.Close
 rstSnapshot.Close
 rstForwardOnly.Close

 .Close
 End With

End Sub


NavigationButton.OnMouseDown Property (Access)

 Copy code hover
[image]

NavigationButton.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnMouseDown

expression A variable that represents a NavigationButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


TempVars.Application Property (Access)

 Copy code hover
[image]

TempVars.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a TempVars object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

TempVars Collection

Other resources

TempVars Object Members


Field2.SaveToFile Method (DAO)

 Copy code hover
[image]

Field2.SaveToFile Method (DAO)
Send feedback

Saves an attachment to disk.

Version Information

Version Added: Access 2007

Syntax

expression .SaveToFile(FileName)

expression A variable that represents a Field2 object.

Parameters

Name | Required/Optional | Data Type | Description
FileName | Required | String | The fully qualified path of the file to which you want to save the attachment.

Example

The following code snippet illustrates how to use the SaveToFile method to save all of the attachments for a specific employee to disk.

VBA Copy code Copy code
'  Instantiate the parent recordset.
   Set rsEmployees = db.OpenRecordset("Employees")

   … Code to move to desired employee

   ' Instantiate the child recordset.
   Set rsPictures = rsEmployees.Fields("Pictures").Value

   '  Loop through the attachments.
   While Not rsPictures.EOF

      '  Save current attachment to disk in the "My Documents" folder.
      rsPictures.Fields("FileData").SaveToFile _
                  "C:\Documents and Settings\Username\My Documents"
      rsPictures.MoveNext
   Wend

The following example shows how to save the files stored in an attachment field to the specified folder path.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Public Function SaveAttachments(strPath As String, Optional strPattern As String = "*.*") As Long
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset2
    Dim rsA As DAO.Recordset2
    Dim fld As DAO.Field2
    Dim strFullPath As String

    'Get the database, recordset, and attachment field
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("tblAttachments")
    Set fld = rst("Attachments")

    'Navigate through the table
    Do While Not rst.EOF

        'Get the recordset for the Attachments field
        Set rsA = fld.Value

        'Save all attachments in the field
        Do While Not rsA.EOF
            If rsA("FileName") Like strPattern Then
                strFullPath = strPath & "\" & rsA("FileName")

                'Make sure the file does not exist and save
                If Dir(strFullPath) = "" Then
                    rsA("FileData").SaveToFile strFullPath
                End If

                'Increment the number of files saved
                SaveAttachments = SaveAttachments + 1
            End If

            'Next attachment
            rsA.MoveNext
        Loop
        rsA.Close

        'Next record
        rst.MoveNext
    Loop

    rst.Close
    dbs.Close

    Set fld = Nothing
    Set rsA = Nothing
    Set rst = Nothing
    Set dbs = Nothing
End Function

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction Properties Example (VC++)

 Copy code hover
[image]

ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction Properties Example (VC++)
Send feedback

This example uses the ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction properties to execute a stored procedure.

Copy code Copy code

// BeginActiveConnectionCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#define TESTHR(x) if FAILED(x) _com_issue_error(x)

#include <stdio.h>
#include <ole2.h>
#include "conio.h"
#include "ActiveConnectionX.h"

//Function declaration
void ActiveConnectionX(VOID);
void PrintProviderError(_ConnectionPtr pConnection);

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 ActiveConnectionX();

 //Wait here for user to see the output..
 printf("\n\nPress any key to continue..");
 getch();

 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// ActiveConnectionX Function //
// //
///////////////////////////////////////////////////////////
VOID ActiveConnectionX(VOID)
{
 HRESULT hr = S_OK;

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _ConnectionPtr pConnection = NULL;
 _CommandPtr pCmdByRoyalty = NULL;
 _RecordsetPtr pRstByRoyalty = NULL;
 _RecordsetPtr pRstAuthors = NULL;
 _ParameterPtr pPrmByRoyalty = NULL;

 //Define Other variables
 IADORecordBinding *picRs = NULL; //Interface Pointer declared.(VC++ Extensions) TCS(SPA)
 CEmployeeRs emprs; //C++ class object TCS(SPA)
 _bstr_t strAuthorId;
 int intRoyalty;
 VARIANT vtroyal ;

 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 //Define a command object for a stored procedure.

 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
 hr = pConnection->Open(strCnn,"","",adConnectUnspecified);

 TESTHR(pCmdByRoyalty.CreateInstance(__uuidof(Command)));

 pCmdByRoyalty->ActiveConnection = pConnection;
 pCmdByRoyalty->CommandText = "byRoyalty";
 pCmdByRoyalty->CommandType = adCmdStoredProc;
 pCmdByRoyalty->CommandTimeout = 15;

 //Define stored procedure's input parameter.
 printf("Enter Royalty : ");
 scanf("%d",&intRoyalty);

 //Assign Integer value
 vtroyal.vt = VT_I2;
 vtroyal.iVal = intRoyalty;

 TESTHR(pPrmByRoyalty.CreateInstance(__uuidof(Parameter)));
 pPrmByRoyalty->Type = adInteger;
 pPrmByRoyalty->Size = 3;
 pPrmByRoyalty->Direction = adParamInput;
 pPrmByRoyalty->Value = vtroyal;
 pCmdByRoyalty->Parameters->Append(pPrmByRoyalty);

 //Create a recordset by executing a command.
 pRstByRoyalty = pCmdByRoyalty->Execute(NULL,NULL,adCmdStoredProc);

 //Open the authors table to get author names for display.

 TESTHR(pRstAuthors.CreateInstance(__uuidof(Recordset)));
 hr = pRstAuthors->Open("authors",strCnn,adOpenForwardOnly,adLockReadOnly,adCmdTable);

 //Open an IADORecordBinding interface pointer which we'll use for Binding Recordset to a class
 TESTHR(pRstAuthors->QueryInterface(__uuidof(IADORecordBinding),(LPVOID*)&picRs));

 //Bind the Recordset to a C++ Class here
 TESTHR(picRs->BindToRecordset(&emprs));

 //Print current data in the recordset ,adding author names from author table.
 printf("Authors With %d Percent Royalty",intRoyalty);

 while(!(pRstByRoyalty->EndOfFile))
 {
 strAuthorId = pRstByRoyalty->Fields->Item["au_id"]->Value;
 pRstAuthors->Filter = "au_id = '"+strAuthorId+"'";

 printf("\n\t%s, %s %s",emprs.lau_idStatus == adFldOK ? emprs.m_szau_id : "<NULL>", emprs.lau_fnameStatus == adFldOK ? emprs.m_szau_fname : "<NULL>", emprs.lau_lnameStatus == adFldOK ? emprs.m_szau_lname : "<NULL>");

 pRstByRoyalty->MoveNext();
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 PrintProviderError(pConnection);
 printf("Source : %s \n Description : %s \n",(LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }

 // Clean up objects before exit.
 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (pRstByRoyalty)
 if (pRstByRoyalty->State == adStateOpen)
 pRstByRoyalty->Close();
 if (pRstAuthors)
 if (pRstAuthors->State == adStateOpen)
 pRstAuthors->Close();
 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

VOID PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;
 long nCount = 0;
 long i = 0;

 if( (pConnection->Errors->Count) > 0)
 {
 nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s", pErr->Number,(LPCSTR)pErr->Description);
 }
 }
}

// EndActiveConnectionCpp

ActiveConnectionX.h

Copy code Copy code

// BeginActiveConnectionH
#include "icrsint.h"

//This Class extracts fname,lastname

class CEmployeeRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CEmployeeRs)

 //Column au_id is the 1st field in the recordset
 ADO_VARIABLE_LENGTH_ENTRY2(1, adVarChar, m_szau_id,
 sizeof(m_szau_id), lau_idStatus, TRUE)

 ADO_VARIABLE_LENGTH_ENTRY2(2, adVarChar, m_szau_lname,
 sizeof(m_szau_lname), lau_lnameStatus, TRUE)

 ADO_VARIABLE_LENGTH_ENTRY2(3, adVarChar, m_szau_fname,
 sizeof(m_szau_fname), lau_fnameStatus, TRUE)

END_ADO_BINDING()

public:

 CHAR m_szau_id[20];
 ULONG lau_idStatus;

 CHAR m_szau_fname[40];
 ULONG lau_fnameStatus;

 CHAR m_szau_lname[40];
 ULONG lau_lnameStatus;

};
// EndActiveConnectionH


Connection.CreateQueryDef Method (DAO)

 Copy code hover
[image]

Connection.CreateQueryDef Method (DAO)
Send feedback

Creates a new QueryDef object.

Syntax

expression .CreateQueryDef(Name, SQLText)

expression A variable that represents a Connection object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Optional | Variant | A Variant (String subtype) that uniquely names the new QueryDef.
SQLText | Optional | Variant | A Variant (String subtype) that is an SQL statement defining the QueryDef. If you omit this argument, you can define the QueryDef by setting its SQL property before or after you append it to a collection.

Return Value

QueryDef

Remarks

In a Microsoft Access workspace, if you provide anything other than a zero-length string for the name when you create a QueryDef, the resulting QueryDef object is automatically appended to the QueryDefs collection.

If the object specified by name is already a member of the QueryDefs collection, a run-time error occurs. You can create a temporary QueryDef by using a zero-length string for the name argument when you execute the CreateQueryDef method. You can also accomplish this by setting the Name property of a newly created QueryDef to a zero-length string (""). Temporary QueryDef objects are useful if you want to repeatedly use dynamic SQL statements without having to create any new permanent objects in the QueryDefs collection. You can't append a temporary QueryDef to any collection because a zero-length string isn't a valid name for a permanent QueryDef object. You can always set the Name and SQL properties of the newly created QueryDef object and subsequently append the QueryDef to the QueryDefs collection.

To run the SQL statement in a QueryDef object, use the Execute or OpenRecordset method.

Using a QueryDef object is the preferred way to perform SQL pass-through queries with ODBC databases.

To remove a QueryDef object from a QueryDefs collection in a Microsoft Access database engine database, use the Delete method on the collection.


CheckBox.LabelAlign Property (Access)

 Copy code hover
[image]

CheckBox.LabelAlign Property (Access)
See also Send feedback

Published: July 16, 2012

The property specifies the text alignment within attached labels on new controls. Read/write Byte.

Syntax

expression .LabelAlign

expression A variable that represents a CheckBox object.

Remarks

The LabelAlign property uses the following settings.

Setting | Description
0 | (Default) The label text aligns to the left.
1 | The label text aligns to the left.
2 | The label text is centered.
3 | The label text aligns to the right.
4 | The label text is evenly distributed.

You can set the LabelAlign property by using a control's default control style or the DefaultControl property in Visual Basic.

When created, controls have an attached label (as long as their AutoLabel property is set to Yes). Changes to the LabelAlign default control style setting affect only controls created on the current form or report.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


CheckBox.OldBorderStyle Property (Access)

 Copy code hover
[image]

CheckBox.OldBorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.

Syntax

expression .OldBorderStyle

expression A variable that represents a CheckBox object.

Remarks

The OldBorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines
Note Note

  • If the OldBorderStyle property is set to None or Dialog, the form doesn't have Maximize or Minimize buttons, regardless of its MinMaxButtons property setting.

  • If the OldBorderStyle property is set to None, the form doesn't have a Control menu, regardless of its ControlBox property setting.

  • The OldBorderStyle property setting doesn't affect the display of the scroll bars, navigation buttons, the record number box, or record selectors.

Example

The following example demonstrates the effect of changing a control's BorderStyle property, while leaving the OldBorderStyle unaffected. The example concludes with setting the BorderStyle property to its original unedited value.

VBA Copy code Copy code
With Forms("Order Entry").Controls("Zip Code") .BorderStyle = 3 ' Short dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 3, 1.

    .BorderStyle = 2 ' Dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 2, 1

    .BorderStyle = .OldBorderStyle ' Solid (default) border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 1, 1
End With

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Application.DCount Method (Access)

 Copy code hover
[image]

Application.DCount Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the DCount function to determine the number of records that are in a specified set of records (a domain).

Syntax

expression .DCount(Expr, Domain, Criteria)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Expr | Required | String | An expression that identifies the field for which you want to count records. It can be a string expression identifying a field in a table or query, or it can be an expression that performs a calculation on data in that field. In expr, you can include the name of a field in a table, a control on a form, a constant, or a function. If expr includes a function, it can be either built-in or user-defined, but not another domain aggregate or SQL aggregate function.
Domain | Required | String | A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter.
Criteria | Optional | Variant | An optional string expression used to restrict the range of data on which the DCount function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the DCount function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain; otherwise the DCount function returns a Null.

Return Value

Variant

Remarks

For example, you could use the DCount function in a module to return the number of records in an Orders table that correspond to orders placed on a particular date.

Use the DCount function to count the number of records in a domain when you don't need to know their particular values. Although the expr argument can perform a calculation on a field, the DCount function simply tallies the number of records. The value of any calculation performed by expr is unavailable.

Use the DCount function in a calculated control when you need to specify criteria to restrict the range of data on which the function is performed. For example, to display the number of orders to be shipped to California, set the ControlSource property of a text box to the following expression:

VBA Copy code Copy code
=DCount("[OrderID]", "Orders", "[ShipRegion] = 'CA'")

If you simply want to count all records in domain without specifying any restrictions, use the Count function.

The Count function has been optimized to speed counting of records in queries. Use the Count function in a query expression instead of the DCount function, and set optional criteria to enforce any restrictions on the results. Use the DCount function when you must count records in a domain from within a code module or macro, or in a calculated control.

You can use the DCount function to count the number of records containing a particular field that isn't in the record source on which your form or report is based. For example, you could display the number of orders in the Orders table in a calculated control on a form based on the Products table.

The DCount function doesn't count records that contain Null values in the field referenced by expr unless expr is the asterisk (*) wildcard character. If you use an asterisk, the DCount function calculates the total number of records, including those that contain Null fields. The following example calculates the number of records in an Orders table.

VBA Copy code Copy code
intX = DCount("*", "Orders")

If domain is a table with a primary key, you can also count the total number of records by setting expr to the primary key field, since there will never be a Null in the primary key field.

If expr identifies multiple fields, separate the field names with a concatenation operator, either an ampersand (&) or the addition operator (+). If you use an ampersand to separate the fields, the DCount function returns the number of records containing data in any of the listed fields. If you use the addition operator, the DCount function returns only the number of records containing data in all of the listed fields. The following example demonstrates the effects of each operator when used with a field that contains data in all records (ShipName) and a field that contains no data (ShipRegion).

VBA Copy code Copy code
intW = DCount("[ShipName]", "Orders")
intX = DCount("[ShipRegion]", "Orders")
intY = DCount("[ShipName] + [ShipRegion]", "Orders")
intZ = DCount("[ShipName] & [ShipRegion]", "Orders")
Note Note

The ampersand is the preferred operator for performing string concatenation. You should avoid using the addition operator for anything other than numeric addition, unless you specifically wish to propagate Nulls through an expression.

Example

The following function returns the number of orders shipped to a specified country or region after a specified ship date. The domain is an Orders table.

VBA Copy code Copy code
Public Function OrdersCount(ByVal strCountry As String, _
                            ByVal dteShipDate As Date) As Integer

    OrdersCount = DCount("[ShippedDate]", "Orders", _
                  "[ShipCountry] = '" & strCountry & _
                  "' AND [ShippedDate] > #" & dteShipDate & "#")
End Function

The following examples show how to use various types of criteria with the DCount function.

Sample code provided by: Community Member Icon The UtterAccess community | About the Contributors

Copy code Copy code
    ' ***************************
    ' Typical Use
    ' Numerical values. Replace "number" with the number to use.
    variable = DCount("[FieldName]", "TableName", "[Criteria] = number")

    ' Strings.
    ' Numerical values. Replace "string" with the string to use.
    variable = DCount("[FieldName]", "TableName", "[Criteria]= 'string'")

    ' Dates. Replace "date" with the string to use.
    variable = DCount("[FieldName]", "TableName", "[Criteria]= #date#")
    ' ***************************

    ' ***************************
    ' Referring to a control on a form
    ' Numerical values
    variable = DCount("[FieldName]", "TableName", "[Criteria] = " & Forms!FormName!ControlName)

    ' Strings
    variable = DCount("[FieldName]", "TableName", "[Criteria] = '" & Forms!FormName!ControlName & "'")

    ' Dates
    variable = DCount("[FieldName]", "TableName", "[Criteria] = #" & Forms!FormName!ControlName & "#")
    ' ***************************

    ' ***************************
    ' Combinations
    ' Multiple types of criteria
    variable = DCount("[FieldName]", "TableName", "[Criteria1] = " & Forms![FormName]![Control1] _
             & " AND [Criteria2] = '" & Forms![FormName]![Control2] & "'" _
            & " AND [Criteria3] =#" & Forms![FormName]![Control3] & "#")

    ' Use two fields from a single record.
    variable = DCount("[LastName] & ', ' & [FirstName]", "tblPeople", "[PrimaryKey] = 7")

    ' Expressions
    variable = DCount("[Field1] + [Field2]", "tableName", "[PrimaryKey] = 7")

    ' Control Structures
    variable = DCount("IIf([LastName] Like 'Smith', 'True', 'False')", "tableName", "[PrimaryKey] = 7")
    ' ***************************

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Application Object

Other resources

Application Object Members


Report.OnGotFocus Property (Access)

 Copy code hover
[image]

Report.OnGotFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Got Focus box in the Properties window of the specified report. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnGotFocus

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The GotFocus event occurs when the report receives the focus.

The OnGotFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Got Focus box in the report's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Got Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnGotFocus property in the Immediate window for the button named "OK" on the "Catalog" report.

VBA Copy code Copy code
Debug.Print Reports("Catalog").Controls("OK").OnGotFocus

See also

Concepts

Report Object

Other resources

Report Object Members


Report.OnMouseMove Property (Access)

 Copy code hover
[image]

Report.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnMouseMove

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the report.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the report's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

See also

Concepts

Report Object

Other resources

Report Object Members


ListBox.GridlineShade Property (Access)

 Copy code hover
[image]

ListBox.GridlineShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineShade

expression A variable that represents an ListBox object.

Remarks

The GridlineShade property contains a numeric expression that can be used to darken the theme color in the GridlineColor property. The default value of the GridlineShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


CommandButton.HelpContextId Property (Access)

 Copy code hover
[image]

CommandButton.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Syntax

expression .HelpContextId

expression A variable that represents a CommandButton object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Form.Filter Event (Access)

 Copy code hover
[image]

Form.Filter Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when the user opens a filter window by clicking Filter by Form, Advanced Filter/Sort, or Server Filter By Form.

Syntax

expression .Filter(Cancel, FilterType)

expression A variable that represents a Form object.

Parameters

Name

Required/Optional

Data Type

Description

Cancel

Required

Integer

The setting determines whether to open the filter window. Setting the Cancel argument to True (-1) prevents the filter window from opening. You can also use the CancelEvent method of the DoCmd object to cancel opening the filter window.

FilterType

Required

Integer

The filter window the user is trying to open. The FilterType argument can be one of the following intrinsic constants:

  • acFilterByForm

  • acFilterAdvanced

  • acServerFilterByForm

Remarks

To run a macro or event procedure when this event occurs, set the OnFilter property to the name of the macro or to [Event Procedure].

You can use the Filter event to:

  • Remove any previous filter for the form. To do this, set the Filter or ServerFilter property of the form to a zero-length string (" ") in the Filter macro or event procedure. This is especially useful if you want to make sure extraneous criteria don't appear in the new filter. For example, when you use the Filter By Selection feature, the criteria you use (the selected text in the form) is added to the Filter or ServerFilter property WHERE clause expression, and appears in both the Filter By Form window and the Advanced Filter/Sort window or the Server Filter By Form window. You can remove these old criteria by using the Filter event.

  • Enter default settings for the new filter. To do this, set the Filter or ServerFilter property to include these criteria. For example, you may want all filters for a Products form to display only current products (products for which the Discontinued control in the Products form isn't selected).

  • Use your own custom filter window instead of one of the Microsoft Access filter windows. When the Filter event occurs, you can open your own custom form and use the entries on this form to set the Filter or ServerFilter property and filter the original form. When the user closes this custom form, set the FilterOn or ServerFilterByForm property of the original form to True (-1) to apply the filter. Canceling the Filter event prevents the Microsoft Access filter window from opening.

  • Prevent certain controls on the form from appearing or being used in the Filter By Form or Server Filter By Form window. If you hide or disable a control in the Filter macro or event procedure, the control is hidden or disabled in the Filter By Form or Server Filter By Form window, and can't be used to set filter criteria. You can then use the ApplyFilter event to show or enable this control after the filter is applied, or when the filter is removed from the form.

Example

The following example shows how to disable the TotalDue control on an Orders form when the user tries to create a filter, so that the user can't filter on this field. Any records that have a TotalDue value and meet the other filter criteria will always be shown on the filtered form. This example also forces the user to use the Filter By Form window and not the Advanced Filter/Sort window.

To try this example, add the following event procedure to an Orders form that contains a TotalDue control. Try to create a filter by using the Advanced Filter/Sort window that uses the TotalDue control. Also try creating the same filter by using the Filter By Form window.

VBA Copy code Copy code
Private Sub Form_Filter(Cancel As Integer, FilterType As Integer)
    If FilterType = acFilterByForm Then
        Forms!Orders!TotalDue.Enabled = False
    ElseIf FilterType = acFilterAdvanced Then
        MsgBox "The best way to filter this form is to use the " _
            & "Filter By Form command or toolbar button.", vbOKOnly + vbInformation
        Cancel = True
    End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


CommandButton.BorderColor Property (Access)

 Copy code hover
[image]

CommandButton.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderColor

expression A variable that represents a CommandButton object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ToggleButton.ForeShade Property (Access)

 Copy code hover
[image]

ToggleButton.ForeShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .ForeShade

expression A variable that represents a ToggleButton object.

Remarks

The ForeShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the ForeShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the ForeColor by 75%.

VBA Copy code Copy code
Me.ctl.ForeShade=25

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Report.TimerInterval Property (Access)

 Copy code hover
[image]

Report.TimerInterval Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TimerInterval property to specify the interval, in milliseconds, between Timer events on a report. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .TimerInterval

expression A variable that represents a Report object.

Remarks

The TimerInterval property setting is a Long Integer value between 0 and 2,147,483,647.

You can set this property by using the report's property sheet, a macro, or Visual Basic.

Note Note

When using Visual Basic, you set the TimerInterval property in the report's Load event.

To run Visual Basic code at intervals specified by the TimerInterval property, put the code in the report's Timer event procedure. For example, to requery records every 30 seconds, put the code to requery the records in the report's Timer event procedure, and then set the TimerInterval property to 30000.

Example

The following example shows how to create a flashing button on a form by displaying and hiding an icon on the button. The report's Load event procedure sets the report's TimerInterval property to 1000 so the icon display is toggled once every second.

VBA Copy code Copy code
Sub Report_Load()
 Me.TimerInterval = 1000
End Sub

Sub Report_Timer()
 Static intShowPicture As Integer
 If intShowPicture Then
 ' Show icon.
 Me!btnPicture.Picture = "C:\Icons\Flash.ico"
 Else
 ' Don't show icon.
 Me!btnPicture.Picture = ""
 End If
 intShowPicture = Not intShowPicture
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


Printer.Orientation Property (Access)

 Copy code hover
[image]

Printer.Orientation Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcPrintOrientation constant that represents the print orientation. Read/write.

Syntax

expression .Orientation

expression A variable that represents a Printer object.

See also

Concepts

Printer Object

Other resources

Printer Object Members


Recordset Object (ADO) Reference

 Copy code hover
[image]

Recordset Object (ADO) Reference
Send feedback

In this section

  • Recordset Object (ADO)

  • Recordset Properties, Methods, and Events (ADO)


List Box Control

 Copy code hover
[image]

List Box Control
Send feedback

Published: July 16, 2012

The list box control displays a list of values or alternatives. In many cases, it's quicker and easier to select a value from a list than to remember a value to type. A list of choices also helps ensure that the value that's entered in a field is correct.

The list in a list box consists of rows of data. Rows can have one or more columns, which can appear with or without headings.

Remarks

If a multiple-column list box is bound, Microsoft Access stores the values from one of the columns.

You can use an unbound list box to store a value that you can use with another control. For example, you could use an unbound list box to limit the values in another list box or in a custom dialog box. You could also use an unbound list box to find a record based on the value you select in the list box.

If you don't have room on your form to display a list box, or if you want to be able to type new values as well as select values from a list, use a combo box instead of a list box.


CurrentProject.BaseConnectionString Property (Access)

 Copy code hover
[image]

CurrentProject.BaseConnectionString Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BaseConnectionString property to return the base connection string for the specified object. Read-only String.

Syntax

expression .BaseConnectionString

expression A variable that represents a CurrentProject object.

Remarks

The BaseConnectionString property returns the connection string that was set through the OpenConnection method or by clicking Connection on the File menu. When making a connection, Microsoft Access project modifies the BaseConnectionString property for use with the ADO environment.

Example

The following example displays the BaseConnectionString property setting of the current project:

VBA Copy code Copy code
Public Sub ShowConnectString()

 Dim objCurrent As Object

 Set objCurrent = Application.CurrentProject
 MsgBox "The current base connection is " & objCurrent.BaseConnectionString

End Sub

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


ListBox.StatusBarText Property (Access)

 Copy code hover
[image]

ListBox.StatusBarText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.

Syntax

expression .StatusBarText

expression A variable that represents a ListBox object.

Remarks

You set the StatusBarText property by using a string expression up to 255 characters long.

Note Note

The length of the text you can display in the status bar depends on your computer hardware and video display.

You can use the StatusBarText property to provide specific information about a control. For example, when a text box has the focus, a brief instruction can tell the user what kind of data to enter

Note Note

You can also use the ControlTipText property to display a ScreenTip for a control.

If you create a control by dragging a field from the field list, the value in a field's Description property is copied to the StatusBarText property.

Example

The following example sets the status bar text to be displayed when the "Address_TextBox" control in the "Mailing List" form has the focus in Form View.

VBA Copy code Copy code
Forms("Mailing List").Controls("Address_TextBox"). _
 StatusBarText = "Enter the company's mailing address."

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Unique Property

 Copy code hover
[image]

Unique Property
Send feedback

Published: July 16, 2012

You can use the Unique property to specify that an index enforces uniqueness of the data in the table's key index.

Setting

The Unique property uses the following settings.

Setting | Visual Basic | Description
Yes | True (-1) | The index is a key (unique) index.
No | False (0) | The index is a non-key index.

You can set this property in the Indexes window of table Design view or by using Visual Basic.

Note Note

To access the Unique property of an index by using Visual Basic, use the ADO Unique property.

Remarks

A key index optimizes finding records. It consists of one or more fields that uniquely arrange all records in a table in a predefined order. If the index consists of one field, values in that field must be unique. If the index consists of more than one field, duplicate values can occur in each field, but each combination of values from all the indexed fields must be unique. A non-key index has fields with values that are not necessarily unique.

An index is the primary index for a table if its Primary property is set to Yes. Each table can have only one primary index.


Invalid entry. Cannot perform cascading operation in table

 Copy code hover
[image]

Invalid entry. Cannot perform cascading operation in table <name> because the value entered is too large for field <name>. (Error 3411)
Send feedback

You are trying to save a value to a primary key field that is included in a relationship.

In Microsoft Access, the Cascade Update Related Fields option is selected for the relationship; or, in DAO code, the dbRelationUpdateCascade option is specified for the Relation object's Attributes property. Setting either one of these options will cause your application to attempt to update the matching field in the related table.

To save your changes to this field, the text you enter must be no longer than the field size of the related field that your application is trying to update for you. In this case, the related field has a shorter field size than the field you are updating. To avoid this problem in the future, set the Size property for both of the matching fields to the same value.


DataSpace Properties, Methods, and Events (RDS)

 Copy code hover
[image]

DataSpace Properties, Methods, and Events (RDS)
Send feedback

Properties

InternetTimeout Property (RDS)

Methods

CreateObject Method (RDS)

Events

None.


Size of field

 Copy code hover
[image]

Size of field <name> is too long. (Error 3382)
Send feedback

Text fields in Microsoft FoxPro tables can be no more than 254 characters, and in Microsoft access database engine tables, no more than 255 characters. Redefine the size of the field.


Operations.Item Property (Access)

 Copy code hover
[image]

Operations.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only Object.

Version Information

Version Added: Access 2010

Syntax

expression .Item(Index)

expression A variable that represents an Operations object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant |

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

Operations Collection

Other resources

Operations Object Members


This query is not a properly formed data-definition query. (Error 3357)

 Copy code hover
[image]

This query is not a properly formed data-definition query. (Error 3357)
Send feedback

This query is not a properly formed data-definition query.


Application.HtmlEncode Method (Access)

 Copy code hover
[image]

Application.HtmlEncode Method (Access)
See also Send feedback

Published: July 16, 2012

Converts a string to an HTML-encoded string.

Version Information

Version Added: Access 2007

Syntax

expression .HtmlEncode(PlainText, Length)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
PlainText | Required | Variant | The text string to encode.
Length | Optional | Variant | The number of characters to return.

Return Value

String

See also

Concepts

Application Object

Other resources

Application Object Members


ListBox.GridlineColor Property (Access)

 Copy code hover
[image]

ListBox.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified list box. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineColor

expression A variable that represents a ListBox object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


ListBox.Section Property (Access)

 Copy code hover
[image]

ListBox.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Syntax

expression .Section

expression A variable that represents a ListBox object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Syntax error in HAVING clause. (Error 3133)

 Copy code hover
[image]

Syntax error in HAVING clause. (Error 3133)
Send feedback

You entered an SQL statement that has an invalid HAVING clause.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


Syntax error in query. Incomplete query clause (Error 3450)

 Copy code hover
[image]

Syntax error in query. Incomplete query clause (Error 3450)
Send feedback

This error occurs when trying to save a stored query (view or procedure).


Guidelines for naming fields, controls, and objects

 Copy code hover
[image]

Guidelines for naming fields, controls, and objects
Send feedback

Published: July 16, 2012

Names if fields, controls, and objects in Microsoft Access:

  • Can be up to 64 characters long.

  • Can include any combination of letters, numbers, spaces, and special characters except a period (.), an exclamation point (!), an accent grave (`), and brackets ([ ]).

  • Can't begin with leading spaces.

  • Can't include control characters (ASCII values 0 through 31).

Although you can include spaces in field, control, and object names, most examples in the Access documentation show field and control names without spaces because spaces in names can produce naming conflicts in Visual Basic for Applications in some circumstances.

When you name a field, control, or object, it's a good idea to make sure that the name doesn't duplicate the name of a property or other element used by Access; otherwise, your database can produce unexpected behavior in some circumstances. For example, if you refer to the value of a field that is named Name in a table NameInfo using the syntax NameInfo.Name, Access displays the value of the table's Name property rather than the value of the Name field.

Another way to avoid unexpected results is to always use the ! operator instead of the . (dot) operator to refer to the value of a field, control, or object. For example, the following identifier explicitly refers to the value of the Name field rather than the Name property:

[NameInfo]![Name]

Note Note

The ! operator can be used only in Access desktop databases.


ComboBox.OnNotInList Property (Access)

 Copy code hover
[image]

ComboBox.OnNotInList Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Not in List box in the Properties window of a combo box. Read/write String.

Syntax

expression .OnNotInList

expression A variable that represents a ComboBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The NotInList event occurs when the user enters a value in the text box portion of a combo box that isn't in the combo box list.

The OnNotInList value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Not in List box in the combo box's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Not in List box is blank, the property value is an empty string.

Example

The following example prints the value of the OnNotInList property in the Immediate window for the "State" combo box in the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("State").OnNotInList

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Recordset.Delete Method (DAO)

 Copy code hover
[image]

Recordset.Delete Method (DAO)
Send feedback

Not supported for this object.

Syntax

expression .Delete

expression A variable that represents a Recordset object.


Group Macro Block (Access 2013 custom web app)

 Copy code hover
[image]

Group Macro Block (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

The Group statement enables you to specify a block of actions within a macro that you can expand or collapse.

Setting

The Group action has the following arguments.

Argument | Required | Description
Description | No | A string that appears as the title of a group when it is collapsed.

Remarks

The Group statement does not define a region of a macro that can be executed separately.


NavigationButton.ForeShade Property (Access)

 Copy code hover
[image]

NavigationButton.ForeShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .ForeShade

expression A variable that represents a NavigationButton object.

Remarks

The ForeShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the ForeShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the ForeColor property by 75%.

VBA Copy code Copy code
Me.ctl.ForeShade=25

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


OptionGroup.OnMouseDown Property (Access)

 Copy code hover
[image]

OptionGroup.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Syntax

expression .OnMouseDown

expression A variable that represents an OptionGroup object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Relation.Properties Property (DAO)

 Copy code hover
[image]

Relation.Properties Property (DAO)
Send feedback

Returns the Properties collection of the specified object. Read-only.

Syntax

expression .Properties

expression A variable that represents a Relation object.


Report.WindowHeight Property (Access)

 Copy code hover
[image]

Report.WindowHeight Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the height of a report in twips. Read-only Integer.

Syntax

expression .WindowHeight

expression A variable that represents a Report object.

Remarks

The WindowHeight property is measured from the upper-left corner of the report to its lower-left corner.

See also

Concepts

Report Object

Other resources

Report Object Members


RDS Objects (Access)

 Copy code hover
[image]

RDS Objects (Access)
Send feedback

In this section

  • RDS Objects

  • DataControl Object (RDS) (ADO)

  • DataFactoryObject (RDSServer)

  • DataSpace Object (RDS) (ADO)


The member of the replica set you are attempting to synchronize is currently being used in another synchronization. (Error 3510)

 Copy code hover
[image]

The member of the replica set you are attempting to synchronize is currently being used in another synchronization. (Error 3510)
Send feedback

The Design Master or a replica can be involved in only one synchronization at a time. Although you cannot initiate a second synchronization while the member is locked, you can continue using it. Wait a few minutes and try your synchronization again.


Cancel Method Example (VJ++)

 Copy code hover
[image]

Cancel Method Example (VJ++)
Send feedback

This example uses the Cancel method to cancel a command executing on a Connection object if the connection is busy.

Copy code Copy code

// BeginCancelJ
import com.ms.wfc.data.*;
import java.io.* ;

public class CancelX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 CancelX();
 System.exit(0);
 }

 // CancelX function

 static void CancelX()
 {
 // Define command strings.
 String strCmdChange = "UPDATE titles SET type = 'self_help' "
 + "WHERE type = 'psychology'";
 String strCmdRestore = "UPDATE titles SET type = 'psychology' "
 + "WHERE type = 'self_help'";
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";

 // Define ADO Objects.
 Connection cnConn1 = null;

 //Declarations.
 boolean booChanged = false;
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String line = null;

 try
 {
 // Open a connection.
 cnConn1 = new Connection();
 cnConn1.open(strCnn);

 // Begin a transaction, then execute a command asynchronously.
 cnConn1.beginTrans();
 cnConn1.execute(strCmdChange,
 AdoEnums.ExecuteOption.ASYNCEXECUTE);

 // do something else for a little while - this could be changed.

 for (int intLoop = 0; intLoop < 10; intLoop++)
 {
 System.out.println(intLoop);
 }

 // If the command has NOT completed, cancel the execute
 // and roll back the transaction. Otherwise, commit the
 // transaction.

 if ((cnConn1.getState() & AdoEnums.ObjectState.EXECUTING) > 0)
 {
 cnConn1.cancel();
 cnConn1.rollbackTrans();
 booChanged = false;
 System.out.println("\nUpdate canceled.");
 }
 else
 {
 cnConn1.commitTrans();
 booChanged = true;
 System.out.println("\nUpdate complete.");
 }

 //If the change was made, restore the data
 // because this is a demonstration.

 if(booChanged )
 {
 cnConn1.execute(strCmdRestore);
 System.out.println("\nData restored.");
 }

 System.out.println("\n\nPress <Enter> to continue..");
 in.readLine();
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a connection, check for null pointer first.
 if (cnConn1 != null)
 {
 PrintProviderError(cnConn1);
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }
 finally
 {
 // Cleanup objects before exit.
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}

// EndCancelJ


Positions Collection (ADO MD Reference)

 Copy code hover
[image]

Positions Collection (ADO MD Reference)
Send feedback

In this section

  • Positions Collection (ADO MD)

  • Positions Collection Properties, Methods, and Events (ADO MD)


RDS Returns "Stream Not Read" Error

 Copy code hover
[image]

RDS Returns "Stream Not Read" Error
Send feedback

"The Stream object could not be read because it is empty, or the current position is at the end of the Stream. For non-empty Streams, set the current position with the Position property. To determine if a Stream is empty, check the Size property."

If you get the error above, it may be a result of trying to use a parameterized hierarchical query over http. RDS does not permit you to remote parameterized hierarchies.


MessageBox Macro Action

 Copy code hover
[image]

MessageBox Macro Action
Send feedback

You can use the MessageBox action to display a message box containing a warning or an informational message. For example, you can use the MessageBox action with validation macros. When a control or record fails a validation condition in the macro, a message box can display an error message and provide instructions about the kind of data that should be entered.

Setting

The MessageBox action has the following arguments.

Action argument | Description
Message | The text in the message box. Enter the message text in the Message box in the Action Arguments section of the Macro Builder pane. You can type up to 255 characters or enter an expression (preceded by an equal sign).
Beep | Specifies whether your computer's speaker sounds a beep tone when the message displays. Click Yes (sound the beep tone) or No (don't sound the beep tone). The default is Yes.
Type | The type of message box. Each type has a different icon. Click None, Critical, Warning?, Warning!, or Information. The default is None.
Title | The text displayed in the message box title bar. For example, you can have the title bar display "Customer ID Validation". If you leave this argument blank, "Microsoft Access" is displayed.

Remarks

You can use the MessageBox action to create a formatted error message similar to built-in error messages displayed by Microsoft Access. The MessageBox action permits you to supply a message in three sections for the Message argument. You separate the sections with the "@" character.

The following example displays a formatted message box with a sectioned message. The first section of text in the message is displayed as a bold heading. The second section is displayed as plain text beneath that heading. The third section is displayed as plain text beneath the second section, with a blank line between them.

Type the following string in the Message argument:

Wrong button!@This button doesn't work.@Try another.

You can't run the MessageBox action in a Visual Basic for Applications (VBA) module. Use the MsgBox function instead.

Examples

Synchronize forms by using a macro

The following macro opens a Product List form in the lower-right corner of the Suppliers form, displaying the current supplier's products. It shows the use of the Echo, MessageBox, GoToControl, StopMacro, OpenForm, and MoveAndSizeWindow actions. It also shows the use of a conditional expression with the MessageBox, GoToControl, and StopMacro actions. This macro should be attached to the Review Products button on the Suppliers form.

Condition | Action | Arguments: Setting | Comment
 | Echo | Echo On: No | Stop screen updating while the macro is running.
IsNull([SupplierID]) | MessageBox | Message: Move to the supplier record whose products you want to see, then click the Review Products button again. Beep: Yes Type: None Title: Select a Supplier | If there is no current supplier on the Suppliers form, display a message.
... | GoToControl | Control Name: CompanyName | Move focus to the CompanyName control.
... | StopMacro |  | Stop the macro.
 | OpenForm | Form Name: Product List View: Datasheet Filter Name: Where Condition: [SupplierID] = [Forms]![Suppliers]![SupplierID] Data Mode: Read Only Window Mode: Normal | Open the Product List form and show the current supplier's products.
 | MoveAndSizeWindow | Right: 0.7799" Down: 1.8" | Position the Product List form in the lower right of the Suppliers form.

Validate data by using a macro

The following validation macro checks the postal codes entered in a Suppliers form. It shows the use of the StopMacro, MessageBox, CancelEvent, and GoToControl actions. A conditional expression checks the country/region and postal code entered in a record on the form. If the postal code isn't in the right format for the country/region, the macro displays a message box and cancels saving the record. It then returns you to the PostalCode control, where you can correct the error. This macro should be attached to the BeforeUpdate property of the Suppliers form.

Condition | Action | Arguments: Setting | Comment
IsNull([CountryRegion]) | StopMacro |  | If CountryRegion is Null, the postal code can't be validated.
[CountryRegion] In ("France","Italy","Spain") And Len([PostalCode]) <> 5 | MessageBox | Message: The postal code must be 5 characters. Beep: Yes Type: Information Title: Postal Code Error | If the postal code isn't 5 characters, display a message.
... | CancelEvent |  | Cancel the event.
 | GoToControl | Control Name: PostalCode |
[CountryRegion] In ("Australia","Singapore") And Len([PostalCode]) <> 4 | MessageBox | Message: The postal code must be 4 characters. Beep: Yes Type: Information Title: Postal Code Error | If the postal code isn't 4 characters, display a message.
... | CancelEvent |  | Cancel the event.
 | GoToControl | Control Name: PostalCode |
([CountryRegion] = "Canada") And ([PostalCode] Not Like"[A-Z][0-9][A-Z] [0-9][A-Z][0-9]") | MessageBox | Message: The postal code is not valid. Example of Canadian code: H1J 1C3 Beep: Yes Type: Information Title: Postal Code Error | If the postal code isn't correct for Canada, display a message. (Example of Canadian code: H1J 1C3)
... | CancelEvent |  | Cancel the event.


EmptyCell.InSelection Property (Access)

 Copy code hover
[image]

EmptyCell.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .InSelection

expression A variable that represents an EmptyCell object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


SubForm Members (Access)

 Copy code hover
[image]

SubForm Members (Access)
Send feedback

Published: July 16, 2012

This object corresponds to a subform control. The subform control embeds a form in a form.

Events

Name | Description
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified subform by requerying the source of data for the subform.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the subform and its bottom gridline. Read/write Integer.
CanGrow | Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the control contains. Read/write Boolean.
CanShrink | Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the section or control contains. Read/write Boolean.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FilterOnEmptyMaster | Gets or sets whether all records are displayed when the subform's master field is Null. Read/write Boolean.
Form | You can use the Form property to refer to a form or to refer to the form associated with a subformcontrol. Read-only Form.
GridlineColor | Gets or sets the color of the gridline for the specified subform. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified subform. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified subform. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified subform. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified subform. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified subform. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified subform. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified subform. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified subform. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the subform is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified subform. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified subform. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the subform and its left gridline. Read/write Integer.
LinkChildFields | You can use the LinkChildFields property (along with the LinkMasterFields property) together to specify how Microsoft Access links records in a form or report to records in a subform, subreport, or embedded object, such as a chart. If these properties are set, Microsoft Access automatically updates the related record in the subform when you change to a new record in a main form. Read/write String.
LinkMasterFields | You can use the LinkMasterFields property (along with the LinkChildFields property) together to specify how Microsoft Access links records in a form or report to records in a subform, subreport, or embedded object, such as a chart. If these properties are set, Microsoft Access automatically updates the related record in the subform when you change to a new record in a main form. Read/write String.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
Report | You can use the Report property to refer to a report or to refer to the report associated with a subreport control. Read-only Report.
RightPadding | Gets or sets the amount of space (in inches) between the subform and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
SourceObject | You can use the SourceObject property to identify the form or report that is the source of the subform or subreport on a form or report. Read/write String.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the subform and its top gridline. Read/write Integer.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified subform is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


BoundObjectFrame.OnMouseUp Property (Access)

 Copy code hover
[image]

BoundObjectFrame.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Syntax

expression .OnMouseUp

expression A variable that represents a BoundObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


KeyTypeEnum

 Copy code hover
[image]

KeyTypeEnum
Send feedback

Specifies the type of Key: primary, foreign, or unique.

Constant | Value | Description
adKeyPrimary | 1 | Default. The key is a primary key.
adKeyForeign | 2 | The key is a foreign key.
adKeyUnique | 3 | The key is unique.


SubForm.EventProcPrefix Property (Access)

 Copy code hover
[image]

SubForm.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents a SubForm object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


BoundObjectFrame.BackStyle Property (Access)

 Copy code hover
[image]

BoundObjectFrame.BackStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.

Syntax

expression .BackStyle

expression A variable that represents a BoundObjectFrame object.

Remarks

The BackStyle property uses the following settings.

Setting | Visual Basic | Description
Normal | 1 | (Default for all controls except option group) The control has its interior color set by the BackColor property.
Transparent | 0 | (Default for option group) The control is transparent. The color of the form or report behind the control is visible.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

If the Transparent button on the Back Color button palette is selected, the BackStyle property is set to Transparent; otherwise the BackStyle property is set to Normal.

To make a command button invisible, set its Transparent property to Yes.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


GroupLevel.GroupHeader Property (Access)

 Copy code hover
[image]

GroupLevel.GroupHeader Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the GroupHeader property to create a group header for a selected field or expression in a report. Read/write Boolean.

Syntax

expression .GroupHeader

expression A variable that represents a GroupLevel object.

Remarks

You can use group headers and footers to label or summarize data in a group of records. For example, if you set the GroupHeader property to Yes for the Categories field, each group of products will begin with its category name.

Note Note

You can't set or refer to these properties directly in Visual Basic. To create a group header or footer for a field or expression in Visual Basic, use the CreateGroupLevel method.

To set the grouping properties — GroupOn , GroupInterval , and KeepTogether — to other than their default values, you must first set the GroupHeader or GroupFooter property or both to Yes for the selected field or expression.

See also

Concepts

GroupLevel Object

Other resources

GroupLevel Object Members


Report.OnResize Property (Access)

 Copy code hover
[image]

Report.OnResize Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Resize box in the Properties window of a report. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnResize

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Resize event occurs when a report is opened and whenever the size of a report changes.

The OnResize value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Resize box in the report's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Resize box is blank, the property value is an empty string.

See also

Concepts

Report Object

Other resources

Report Object Members


Line.LineSlant Property (Access)

 Copy code hover
[image]

Line.LineSlant Property (Access)
See also Send feedback

Published: July 16, 2012

You use the LineSlant property to specify whether a line control slants from upper left to lower right or from upper right to lower left. Read/write Boolean.

Syntax

expression .LineSlant

expression A variable that represents a Line object.

Remarks

The LineSlant property uses the following settings.

Setting | Visual Basic | Description
\ | False | (Default) Upper left to lower right
/ | True | Upper right to lower left

Use the LineSlant property to change a line's direction. To position and size the line on your form or report, use the mouse.

Example

The following example slants a line on a form from upper right to lower left.

VBA Copy code Copy code
Forms("Purchase Orders").Controls("Section Separator").LineSlant = True

See also

Concepts

Line Object

Other resources

Line Object Members


Provider and DefaultDatabase Properties Example (VB)

 Copy code hover
[image]

Provider and DefaultDatabase Properties Example (VB)
Send feedback

This example demonstrates the Provider property by opening three Connection objects using different providers. It also uses the DefaultDatabase property to set the default database for the Microsoft ODBC Provider.

Copy code Copy code

'BeginProviderVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection strings

Public Sub Main()
 On Error GoTo ErrorHandler

 Dim Cnxn1 As ADODB.Connection
 Dim Cnxn2 As ADODB.Connection
 Dim Cnxn3 As ADODB.Connection
 Dim strCnxn As String

 ' Open a connection using the Microsoft ODBC provider
 Set Cnxn1 = New ADODB.Connection
 Cnxn1.ConnectionString = "driver={SQL Server};server='MySqlServer';" & _
 "user id='MyUserID';password='MyPassword';"
 Cnxn1.Open strCnxn
 Cnxn1.DefaultDatabase = "Pubs"

 ' Display the provider
 MsgBox "Cnxn1 provider: " & Cnxn1.Provider

 ' Open a connection using the Microsoft Jet provider
 Set Cnxn2 = New ADODB.Connection
 Cnxn2.Provider = "Microsoft.Jet.OLEDB.4.0"
 Cnxn2.Open "C:\Program Files\Microsoft Office\Office\Samples\northwind.mdb", _
 "MyUserID", "MyPassword"

 ' Display the provider.
 MsgBox "Cnxn2 provider: " & Cnxn2.Provider

 ' Open a connection using the Microsoft SQL Server provider
 Set Cnxn3 = New ADODB.Connection
 Cnxn3.Provider = "sqloledb"
 Cnxn3.Open "Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"

 ' Display the provider
 MsgBox "Cnxn3 provider: " & Cnxn3.Provider

 ' clean up
 Cnxn1.Close
 Cnxn2.Close
 Cnxn3.Close
 Set Cnxn1 = Nothing
 Set Cnxn2 = Nothing
 Set Cnxn3 = Nothing
 Exit Sub

ErrorHandler:
 If Not Cnxn1 Is Nothing Then
 If Cnxn1.State = adStateOpen Then Cnxn1.Close
 End If
 Set Cnxn1 = Nothing

 If Not Cnxn2 Is Nothing Then
 If Cnxn2.State = adStateOpen Then Cnxn2.Close
 End If
 Set Cnxn2 = Nothing

 If Not Cnxn3 Is Nothing Then
 If Cnxn3.State = adStateOpen Then Cnxn3.Close
 End If
 Set Cnxn3 = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If

End Sub
'EndProviderVB


Unknown function

 Copy code hover
[image]

Unknown function <name> in validation expression or default value on <name>. (Error 3388)
Send feedback

The function you are referencing is either unknown (because the name is invalid or misspelled) or is a type of function not allowed by the ValidationRule or DefaultValue property. Among the types of functions not allowed are user-defined, SQL aggregate functions.


Attachment.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

Attachment.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified attachment. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleBottom

expression A variable that represents an Attachment object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Recordset.MoveFirst Method (DAO)

 Copy code hover
[image]

Recordset.MoveFirst Method (DAO)
Send feedback

Moves to the first record in a specified Recordset object and make that record the current record.

Syntax

expression .MoveFirst

expression A variable that represents a Recordset object.

Remarks

Use the Move methods to move from record to record without applying a condition.

If you edit the current record, be sure you use the Update method to save the changes before you move to another record. If you move to another record without updating, your changes are lost without warning.

When you open a Recordset, the first record is current and the BOF property is False. If the Recordset contains no records, the BOF property is True, and there is no current record.

If the first or last record is already current when you use MoveFirst or MoveLast, the current record doesn't change.

If recordset refers to a table-type Recordset (Microsoft Access workspaces only), movement follows the current index. You can set the current index by using the Index property. If you don't set the current index, the order of returned records is undefined.

You can't use the MoveFirst, MoveLast, and MovePrevious methods on a forward-only-type Recordset object.

To move the position of the current record in a Recordset object a specific number of records forward or backward, use the Move method.


ToggleButton.BorderStyle Property (Access)

 Copy code hover
[image]

ToggleButton.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .BorderStyle

expression A variable that represents a ToggleButton object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


CharIndex Function (Access 2013 custom web app)

 Copy code hover
[image]

CharIndex Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Searches a text expression for another text expression and returns its starting position if found.

Syntax

CharIndex(TextExpression, WithinText, [Start])

Argument Name | Required | Description
TextExpression | Yes | A text expression that contains the text to be found.
WithinText | Yes | The text expression to be searched.
Start | No | An integer that specifies the location in WithinText to begin the search. If Start is not specified, is a negative number, or is 0, the search starts at the beginning of WithinText.

Remarks

If either TextExpression or WithinText is NULL, CharIndex returns NULL.

If TextExpressionis not found within WithinText, CharIndex returns 0.

The starting position returned is 1-based, not 0-based.


Control Methods (Access)

 Copy code hover
[image]

Control Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Dropdown | You can use the Dropdown method to force the list in the specified combo box to drop down.
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.
Undo | You can use the Undo method to reset a control or form when its value has been changed.


NavigationButton.Layout Property (Access)

 Copy code hover
[image]

NavigationButton.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified text box. Read-only AcLayoutType.

Version Information

Version Added: Access 2010

Syntax

expression .Layout

expression A variable that represents a NavigationButton object.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Control.ItemsSelected Property (Access)

 Copy code hover
[image]

Control.ItemsSelected Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ItemsSelected property to return a read-only reference to the hidden ItemsSelected collection. This hidden collection can be used to access data in the selected rows of a multiselect list box control.

Syntax

expression .ItemsSelected

expression A variable that represents a Control object.

Remarks

The ItemsSelected collection is unlike other collections in that it is a collection of Variants rather than of objects. Each Variant is an integer index referring to a selected row in a list box or combo box.

Use the ItemsSelected collection in conjunction with the Column property or the ItemData property to retrieve data from selected rows in a list box or combo box. You can list the ItemsSelected collection by using the For Each...Next statement.

For example, if you have an Employees list box on a form, you can list the ItemsSelected collection and use the control's ItemData property to return the value of the bound column for each selected row in the list box.

To enable multiple selection of rows in a list box, set the control's MultiSelect property to Simple or Extended.

The ItemsSelected collection has no methods and two properties, the Count and Item properties.

Example

The following example prints the value of the bound column for each selected row in a Names list box on a Contacts form. To try this example, create the list box and set its BoundColumn property as desired and its MultiSelect property to Simple or Extended. Switch to Form view, select several rows in the list box, and run the following code:

VBA Copy code Copy code
Sub BoundData()
 Dim frm As Form, ctl As Control
 Dim varItm As Variant

 Set frm = Forms!Contacts
 Set ctl = frm!Names
 For Each varItm In ctl.ItemsSelected
 Debug.Print ctl.ItemData(varItm)
 Next varItm
End Sub

The next example uses the same list box control, but prints the values of each column for each selected row in the list box, instead of only the values in the bound column.

VBA Copy code Copy code
Sub AllSelectedData()
 Dim frm As Form, ctl As Control
 Dim varItm As Variant, intI As Integer

 Set frm = Forms!Contacts
 Set ctl = frm!Names
 For Each varItm In ctl.ItemsSelected
 For intI = 0 To ctl.ColumnCount - 1
 Debug.Print ctl.Column(intI, varItm)
 Next intI
 Debug.Print
 Next varItm
End Sub

See also

Concepts

Control Object

Other resources

Control Object Members


The object specified cannot be replicated because it is missing a necessary resource. (Error 3489)

 Copy code hover
[image]

The object specified cannot be replicated because it is missing a necessary resource. (Error 3489)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


DoCmd.TransferSpreadsheet Method (Access)

 Copy code hover
[image]

DoCmd.TransferSpreadsheet Method (Access)
See also Send feedback

Published: July 16, 2012

The TransferSpreadsheet method carries out the TransferSpreadsheet action in Visual Basic.

Syntax

expression .TransferSpreadsheet(TransferType, SpreadsheetType, TableName, FileName, HasFieldNames, Range, UseOA)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
TransferType | Optional | AcDataTransferType | The type of transfer you want to make. The default value is acImport.
SpreadsheetType | Optional | AcSpreadSheetType | The type of spreadsheet to import from, export to, or link to.
TableName | Optional | Variant | A string expression that is the name of the Microsoft Office Access table you want to import spreadsheet data into, export spreadsheet data from, or link spreadsheet data to, or the Access select query whose results you want to export to a spreadsheet.
FileName | Optional | Variant | A string expression that's the file name and path of the spreadsheet you want to import from, export to, or link to.
HasFieldNames | Optional | Variant | Use True (-1) to use the first row of the spreadsheet as field names when importing or linking. Use False (0) to treat the first row of the spreadsheet as normal data. If you leave this argument blank, the default (False) is assumed. When you export Access table or select query data to a spreadsheet, the field names are inserted into the first row of the spreadsheet no matter what you enter for this argument.
Range | Optional | Variant | A string expression that's a valid range of cells or the name of a range in the spreadsheet. This argument applies only to importing. Leave this argument blank to import the entire spreadsheet. When you export to a spreadsheet, you must leave this argument blank. If you enter a range, the export will fail.
UseOA | Optional | Variant | This argument is not supported.

Remarks

You can use the TransferSpreadsheet method to import or export data between the current Access database or Access project (.adp) and a spreadsheet file. You can also link the data in a Microsoft Excel spreadsheet to the current Access database. With a linked spreadsheet, you can view and edit the spreadsheet data with Access while still allowing complete access to the data from your Excel spreadsheet program. You can also link to data in a Lotus 1-2-3 spreadsheet file, but this data is read-only in Access.

Note Note

You can also use ActiveX Data Objects (ADO) to create a link by using the ActiveConnection property for the Recordset object.

Example

The following example imports the data from the specified range of the Lotus spreadsheet Newemps.wk3 into the Access Employees table. It uses the first row of the spreadsheet as field names.

VBA Copy code Copy code
DoCmd.TransferSpreadsheet acImport, 3, _
 "Employees","C:\Lotus\Newemps.wk3", True, "A1:G12"

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Page Break Control

 Copy code hover
[image]

Page Break Control
Send feedback

Published: July 16, 2012

The page break control marks the start of a new screen or printed page on a form or report.

Remarks

In a form, a page break is active only when you set the form's DefaultView property to Single Form. Page breaks don't affect a form's datasheet.

In Form view, press the PAGE UP or PAGE DOWN key to move to the previous or next page break.

Position page breaks above or below other controls. Placing a page break on the same line as another control splits that control's data.


DeleteRule Property Example (VB)

 Copy code hover
[image]

DeleteRule Property Example (VB)
Send feedback

This example demonstrates the DeleteRule property of a Key object. The code appends a new Table and then defines a new primary key, setting DeleteRule to adRICascade.

Copy code Copy code

' BeginDeleteRuleVB
Sub Main()
 On Error GoTo DeleteRuleXError

 Dim kyPrimary As New ADOX.Key
 Dim cat As New ADOX.Catalog
 Dim tblNew As New ADOX.Table

 ' Connect the catalog
 cat.ActiveConnection = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "data source='c:\Program Files\" & _
 "Microsoft Office\Office\Samples\Northwind.mdb';"

 ' Name new table
 tblNew.Name = "NewTable"

 ' Append a numeric and a text field to new table.
 tblNew.Columns.Append "NumField", adInteger, 20
 tblNew.Columns.Append "TextField", adVarWChar, 20

 ' Append the new table
 cat.Tables.Append tblNew

 ' Define the Primary key
 kyPrimary.Name = "NumField"
 kyPrimary.Type = adKeyPrimary
 kyPrimary.RelatedTable = "Customers"
 kyPrimary.Columns.Append "NumField"
 kyPrimary.Columns("NumField").RelatedColumn = "CustomerId"
 kyPrimary.DeleteRule = adRICascade

 ' Append the primary key
 cat.Tables("NewTable").Keys.Append kyPrimary
 Debug.Print "The primary key is appended."

 'Delete the table as this is a demonstration.
 cat.Tables.Delete tblNew.Name
 Debug.Print "The primary key is deleted."

 'Clean up
 Set cat.ActiveConnection = Nothing
 Set cat = Nothing
 Set kyPrimary = Nothing
 Set tblNew = Nothing
 Exit Sub

DeleteRuleXError:

 Set cat = Nothing
 Set kyPrimary = Nothing
 Set tblNew = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If

End Sub
' EndDeleteRuleVB


AcNavigationSpan Enumeration (Access)

 Copy code hover
[image]

AcNavigationSpan Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the orientation of navigation buttons.

Version Information

Version Added: Access 2010

Name | Value | Description
acHorizontal | 0 | The navigation buttons are displayed horizontally.
acVertical | 1 | The navigation buttons are displayed vertically.


RDS Object Model Summary

 Copy code hover
[image]

RDS Object Model Summary
Send feedback
Object | Description
RDS.DataSpace | This object contains a method to obtain a server proxy. The proxy may be the default or a custom server program (business object). The server program may be invoked on the Internet, an intranet, a local area network, or be a local dynamic-link library.
RDSServer.DataFactory | This object represents the default server program. It executes the default RDS data retrieval and update behavior.
RDS.DataControl | This object can automatically invoke the RDS.DataSpace and RDSServer.DataFactory objects. Use this object to invoke the default RDS data retrieval or update behavior. This object also provides the means for visual controls to access the returned Recordset object.


ObjectFrame.OnDblClick Property (Access)

 Copy code hover
[image]

ObjectFrame.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Syntax

expression .OnDblClick

expression A variable that represents an ObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_DblClick" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Cannot expand named range. (Error 3434)

 Copy code hover
[image]

Cannot expand named range. (Error 3434)
Send feedback

Cells with values were encountered while attempting to add rows to a Microsoft Excel version 5.0 named range. These cells cannot be overwritten by an append operation.


Application.TempVars Property (Access)

 Copy code hover
[image]

Application.TempVars Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the collection of TempVar objects. Read-only TempVars.

Version Information

Version Added: Access 2007

Syntax

expression .TempVars

expression A variable that represents an Application object.

See also

Concepts

Application Object

Other resources

Application Object Members


PageBreak.Left Property (Access)

 Copy code hover
[image]

PageBreak.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Syntax

expression .Left

expression A variable that represents a PageBreak object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

PageBreak Object

Other resources

PageBreak Object Members


DeleteRule Property Example (VC++)

 Copy code hover
[image]

DeleteRule Property Example (VC++)
Send feedback

This example demonstrates the DeleteRule property of a Key object. The code appends a new Table and then defines a new primary key, setting DeleteRule to adRICascade.

Copy code Copy code

// BeginDeleteRuleCpp
#import "c:\Program Files\Common Files\system\ado\msadox.dll" no_namespace
#import "c:\Program Files\Common Files\system\ado\msado15.dll"

#include "iostream.h"
#include "stdio.h"
#include "conio.h"

//Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void DeleteRuleX(void);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 DeleteRuleX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// DeleteRuleX Function //
// //
//////////////////////////////////////////////////////////
void DeleteRuleX(void)
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.
 _KeyPtr m_pKeyPrimary = NULL;
 _CatalogPtr m_pCatalog = NULL;
 _TablePtr m_pTblNew = NULL;

 // Define string variables.
 _bstr_t strcnn("Provider='Microsoft.JET.OLEDB.4.0';"
 "Data source = 'c:\\Program Files\\Microsoft Office"
 "\\Office\\Samples\\Northwind.mdb';");
 try
 {
 TESTHR(hr = m_pKeyPrimary.CreateInstance(__uuidof(Key)));
 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof (Catalog)));
 TESTHR(hr = m_pTblNew.CreateInstance(__uuidof(Table)));

 // Connect the catalog.
 m_pCatalog->PutActiveConnection(strcnn);

 // Name new table.
 m_pTblNew->Name = "NewTable";

 // Append a numeric and a text field to new table.
 m_pTblNew->Columns->Append("NumField",adInteger,20);
 m_pTblNew->Columns->Append("TextField",adVarWChar,20);

 // Append the new table.
 m_pCatalog->Tables->Append(_variant_t((IDispatch*)m_pTblNew));
 printf("Table 'NewTable' is added.\n");

 // Define the Primary key.
 m_pKeyPrimary->Name = "NumField";
 m_pKeyPrimary->Type = adKeyPrimary;
 m_pKeyPrimary->RelatedTable = "Customers";
 m_pKeyPrimary->Columns->Append("NumField",adInteger,20);
 m_pKeyPrimary->Columns->GetItem("NumField")->RelatedColumn =
 "CustomerId";
 m_pKeyPrimary->DeleteRule = adRICascade;

 //to pass an optional column parameter to Key's Apppend method
 _variant_t vOptional;
 vOptional.vt = VT_ERROR;
 vOptional.scode = DISP_E_PARAMNOTFOUND;

 // Append the primary key.
 m_pCatalog->Tables->GetItem("NewTable")->Keys->Append(
 _variant_t((IDispatch*)m_pKeyPrimary),
 adKeyPrimary,vOptional,L"",L"");

 // Delete the table as this is a demonstration.
 m_pCatalog->Tables->Delete(m_pTblNew->Name);
 printf("Table 'NewTable' is deleted.\n");
 }

 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }

 catch(...)
 {
 cout << "Error occured in include files...."<< endl;
 }
}
// EndDeleteRuleCpp


Form.MouseWheel Property (Access)

 Copy code hover
[image]

Form.MouseWheel Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the MouseWheel event occurs. Read/write.

Syntax

expression .MouseWheel

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the MouseWheel event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).MouseWheel = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


ImportExportSpecification.Name Property (Access)

 Copy code hover
[image]

ImportExportSpecification.Name Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the name of the specified ImportExportSpecification object. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .Name

expression A variable that represents an ImportExportSpecification object.

Remarks

The Name property must be unique within the ImportExportSpecifications collection and cannot exceed 64 characters.

See also

Concepts

ImportExportSpecification Object

Other resources

ImportExportSpecification Object Members


ImportExportText Macro Action

 Copy code hover
[image]

ImportExportText Macro Action
Send feedback

You can use the ImportExportText action to import or export text between the current Microsoft Access database (.mdb or .accdb) or Access project (.adp) and a text file. You can also link the data in a text file to the current Access database. With a linked text file, you can view the text data with Access while still allowing complete access to the data from your word processing program. You can also import from, export to, and link to a table or list in an HTML file (*.html).

Note Note

If you link to data in a text file or an HTML file, the data is read-only in Access.
Note 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.

Setting

The ImportExportText action has the following arguments.

Action argument

Description

Transfer Type

The type of transfer you want to make. You can import data from, export data to, or link to data in delimited or fixed-width text files or HTML files. You can also export data to a Microsoft Word mail merge data file, which you can then use with the Word mail merge feature to create merged documents such as form letters and mailing labels. Select Import Delimited, Import Fixed Width, Import HTML, Export Delimited, Export Fixed Width, Export HTML, Export Word for Windows Merge, Link Delimited, Link Fixed Width, or Link HTML in the Transfer Type box in the Action Arguments section of the Macro Builder pane. The default is Import Delimited.

Note Note

Only Import Delimited, Import Fixed Width, Export Delimited, Export Fixed Width, or Export Word for Windows Merge transfer types are supported in an Access project (.adp).

Specification Name

The specification name for the set of options that determines how a text file is imported or linked. For a fixed-width text file, you must either specify an argument or use a schema.ini file, which must be stored in the same folder as the imported or linked text file.

To create a specification for importing or linking a text file:

  2. In the Get External Data dialog box, enter the path of the source text file in the File name box.

  3. Click the option you want for storing the data (import, append, or link), and click OK.

  4. In the Import Text Wizard dialog box, click Advanced.

  5. Specify the options you want for this specification, then click Save As.

  6. Enter the name you want for the specification, then click OK.

  7. You can manage existing specifications by clicking Specs in the specification dialog box.

  8. Click OK to close the specification dialog box.

You can then type the specification name in this argument whenever you want to import or export the same type of text file. You can import, export, or link delimited text files without typing a specification name for this argument. In this case, Access uses the defaults from the wizard dialog box. Access uses a predetermined format for mail merge data files, so you don't ever need to type a specification name for this argument when you export these types of files. You can use import/export specifications with HTML files, but the only part of the specification that applies is the specification for data type formatting.

Table Name

The name of the Access table to import text data to, export text data from, or link text data to. You can also type the name of the Access query you want to export data from. This is a required argument. If you click Import Delimited, Import Fixed Width, or Import HTML in the Transfer Type box, Access appends the text data to this table if the table already exists. Otherwise, Access creates a new table containing the text data. You can't use an SQL statement to specify data to export when you are using the ImportExportText action. Instead of using an SQL statement, you must first create a query and then specify the name of the query in the Table Name argument.

File Name

The name of the text file to import from, export to, or link to. Include the full path. This is a required argument. Access creates a new text file when you export data from Access. If the file name is the same as the name of an existing text file, Access replaces the existing text file. If you want to import or link a particular table or list in an HTML file, you can use the HTML Table Name argument.

Has Field Names

Specifies whether the first row of the text file contains the names of the fields. If you select Yes, Access uses the names in this row as field names in the Access table when you import or link the text data. If you select No, Access treats the first row as a normal row of data. The default is No. Access ignores this argument for Word for Windows mail merge data files because the first row must contain the field names. When you export an Access table or select query to a delimited or fixed-width text file, Access inserts the field names of your table or select query into the first row of the text file if you've selected Yes for this argument. If you are importing or linking a fixed-width text file and select Yes in this box, the first row containing the field names must use the field delimiter set in the import/export specification to separate the field names. If you are exporting to a fixed-width text file and select Yes for this argument, Access inserts the field names into the first row of the text file with this delimiter.

HTML Table Name

The name of the table or list in the HTML file that you want to import or link. This argument is ignored unless the Transfer Type argument is set to Import HTML or Link HTML. If you leave this argument blank, the first table or list in the HTML file is imported or linked. The table or list name in the HTML file is determined by the text specified by the <CAPTION> tag, if there's a <CAPTION> tag. If there's no <CAPTION> tag, the name is determined by the text specified by the <TITLE> tag. If more than one table or list has the same name, Access distinguishes them by adding a number to the end of each name; for example, Employees1 and Employees2.

Code Page

The name of the character set used with the code page.

Remarks

You can export the data in Access select queries to text files. Access exports the result set of the query, treating it just like a table.

Text data that you append to an existing Access table must be compatible with the table's structure.

  • Each field in the text must be of the same data type as the corresponding field in the table.

  • The fields must be in the same order (unless you set the Has Field Names argument to Yes, in which case the field names in the text must match the field names in the table).

This action is similar to clicking Text File in the Import or Export group on the External Data tab. The arguments of the ImportExportText action reflect the options in the wizard started by the Text File command.

Tip Tip

An import/export specification stores the information Access needs to import, export, or link a text file. You can use stored specifications to import, export, or link text data from or to similar text files. For example, you might receive weekly sales figures in a text file from a mainframe computer. You can create and save a specification for this type of data and then use the specification whenever you add this data to your Access database.
Note Note

If you query or filter a linked text file, the query or filter is case-sensitive.

To run the ImportExportText action in a Visual Basic for Applications (VBA) module, use the TransferText method of the DoCmd object.


You cannot add or change a record because a related record is required in table

 Copy code hover
[image]

You cannot add or change a record because a related record is required in table <name>. (Error 3201)
Send feedback

You tried to perform an operation that would have violated referential integrity rules for related tables. For example, this error occurs if you try to change or insert a record in the "many" table in a one-to-many relationship, and that record does not have a related record in the table on the "one" side.

If you want to add or change the record, first add a record to the "one" table that contains the same value for the matching field.


CancelUpdate Method (RDS)

 Copy code hover
[image]

CancelUpdate Method (RDS)
Send feedback

Cancels any changes made to the current or new row of a Recordset object.

Syntax

DataControl.CancelUpdate

Parameters

  • DataControl

  • An object variable that represents an RDS.DataControl object.

Remarks

The Cursor Service for OLE DB keeps both a copy of the original values and a cache of changes. When you call CancelUpdate, the cache of changes is reset to empty, and any bound controls are refreshed with the original data.


NavigationControl.Width Property (Access)

 Copy code hover
[image]

NavigationControl.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .Width

expression A variable that represents a NavigationControl object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Documents Properties (DAO)

 Copy code hover
[image]

Documents Properties (DAO)
Send feedback

In this section

  • Documents.Count Property (DAO)


NavigationControl Properties (Access)

 Copy code hover
[image]

NavigationControl Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoTab | You can use the AutoTab property to specify whether an automatic tab occurs when the last character permitted by a text box control's input mask is entered. An automatic tab moves the focus to the next control in the form's tab order. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FilterLookup | You can use the FilterLookup property to specify whether values appear in a boundtext box control when using the Filter By Form or Server Filter By Form window. Read/write Byte.
FormatConditions | You can use the FormatConditions property to return a read-only reference to the FormatConditions collection and its related properties.
GridlineColor | Gets or sets the color of the gridline for the specified list box. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified list box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified text box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified text box. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified text box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified text box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified text box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the text box is anchored horizontally within its layout. Read/write.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
KeyboardLanguage |
Layout | Returns the type of layout for the specified text box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified text box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.
LineSpacing | You can use the LineSpacing property to specify or determine the location of information displayed within a label or text box control. Read/write Integer.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
NumeralShapes |
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
RightPadding | Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.
ScrollBarAlign | You can use the ScrollBarAlign to specify or determine the alignment of a vertical scroll bar. Read/write Byte.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
SelectedTab | Gets the active tab of the navigation control. Read-only NavigationButton.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SmartTags | Returns a SmartTags collection that represents the collection of smart tags that have been added to a control. .
Span | Gets or sets the orientation of the navigation buttons. Read/write AcNavigationSpan.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
SubForm | Gets or sets the name of the SubForm object used to display forms. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
Tabs | Gets the collection of navigation buttons for the specified navigation control. Read-only Children.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.
Value | Determines or specifies the text in the text box. Read/write Variant.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified text box is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


Properties.Item Property (Access)

 Copy code hover
[image]

Properties.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only Object.

Syntax

expression .Item(Index)

expression A variable that represents a Properties object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

Properties Collection

Other resources

Properties Members


FindRecord Macro Action

 Copy code hover
[image]

FindRecord Macro Action
Send feedback

You can use the FindRecord action to find the first instance of data that meets the criteria specified by the FindRecord arguments. This data can be in the current record, in a succeeding or prior record, or in the first record. You can find records in the active table datasheet, query datasheet, form datasheet, or form.

Setting

The FindRecord action has the following arguments.

Action argument

Description

Find What

Specifies the data you want to find in the record. Enter the text, number, or date you want to find or type an expression, which is preceded by an equal sign (=), in the Find What box in the Action Arguments section of the Macro Builder pane. You can use wildcard characters. This is a required argument.

Match

Specifies where the data is located in the field. You can specify a search for data in any part of the field (Any Part of Field), for data that fills the entire field (Whole Field), or for data located at the beginning of the field (Start of Field). The default is Whole Field.

Match Case

Specifies whether the search is case-sensitive. Click Yes (conduct a case-sensitive search) or No (search without matching uppercase and lowercase letters exactly). The default is No.

Search

Specifies whether the search proceeds from the current record up to the beginning of the records (Up); down to the end of the records (Down); or down to the end of the records and then from the beginning of the records to the current record, so all records are searched (All). The default is All.

Search As Formatted

Specifies whether the search includes formatted data. Click Yes (Microsoft Office Access 2007 searches for the data as it is formatted and displayed in the field) or No (Access searches for the data as it is stored in the database, which isn't always the same as it's displayed). The default is No. You can use this feature to restrict the search to data in a particular format. For example, click Yes and type 1,234 in the Find What argument to find a value of 1,234 in a field formatted to include commas. Click No if you want to type 1234 to search for the data in this field. To search for dates, click Yes to find a date exactly as it is formatted, such as 08-July-2003. If you click No, enter the date for the Find What argument in the format that is set in the regional settings in Windows Control Panel. This format is shown in the Short date format box found on the Date tab in the regional settings. For example, if the Short date format box is set to M/d/yy, you can enter 7/8/03, and Access will find all entries in a Date field that correspond to July 8, 2003, regardless of how this field is formatted.

Note Note

The Search As Formatted argument takes effect only if the current field is a bound control, the Match argument is set to Whole Field, the Only Current Field argument is set to Yes, and the Match Case argument is set to No.

If you set Match Case to Yes or Only Current Field to No, you must also set Search As Formatted to Yes.

Only Current Field

Specifies whether the search is confined to the current field in each record or includes all fields in each record. Searching in the current field is faster. Click Yes (confine the search to the current field) or No (search in all fields in each record). The default is Yes.

Find First

Specifies whether the search starts at the first record or at the current record. Click Yes (start at the first record) or No (start at the current record). The default is Yes.

Remarks

When a macro runs the FindRecord action, Access searches for the specified data in the records (the order of the search is determined by the setting of the Search argument). When Access finds the specified data, the data is selected in the record.

The FindRecord action is equivalent to clicking Find on the Home tab, and its arguments are the same as the options in the Find and Replace dialog box. If you set the FindRecord arguments in the Macro Builder pane and then run the macro, you will see the corresponding options selected in the Find and Replace dialog box when you click Find.

Access retains the most recent FindRecord arguments during a database session so that you don't need to enter the same criteria repeatedly as you perform subsequent operations with the FindRecord action. If you leave an argument blank, Access uses the most recent setting for the argument, as set either by a previous FindRecord action or in the Find and Replace dialog box.

When you want to find a record by using a macro, use the FindRecord action, not the RunMenuCommand action with its argument set to run the Find command.

Note Note

While the FindRecord action corresponds to the Find command on the Home tab for tables, queries, and forms, it doesn't correspond to the Find command on the Edit menu in the Code window. You can't use the FindRecord action to search for text in modules.

If the currently selected text is the same as the search text at the time the FindRecord action is carried out, the search begins immediately following the selection in the same field as the selection, and in the same record. Otherwise, the search begins at the start of the current record. This enables you to find multiple instances of the same search criteria that might appear in a single record.

However, note that if you use a command button to run a macro containing the FindRecord action, the first instance of the search criteria will be found repeatedly. This behavior occurs because clicking the command button removes the focus from the field containing the matching value. The FindRecord action will then begin searching from the start of the record. To avoid this problem, run the macro by using a technique that doesn't change the focus, such as a custom toolbar button or a key combination defined in an AutoKeys macro, or set the focus in the macro to the field containing the search criteria before you carry out the FindRecord action.

Security note Security Note
Avoid using the SendKeys statement or an AutoKeys macro with sensitive or confidential information. A malicious user could intercept the keystrokes and compromise the security of your computer and data.

The same behavior also occurs if you use a command button to run a macro containing the FindNext action.

To run the FindRecord action in a Visual Basic for Applications (VBA) module, use the FindRecord method of the DoCmd object.

For more complex searches, you may want to use the SearchForRecord macro action.


Date/Time

 Copy code hover
[image]

Date/Time
Send feedback

In this section

  • How to: Calculate Age

  • How to: Calculate and Display Specific Date Values

  • How to: Calculate Elapsed Time

  • How to: Find the Number of Working Days Between Two Dates

  • How to: Format Dates as U.S. Dates Regardless of Regional Settings

  • How to: Specify Date and Time in Criteria Expressions


WebBrowserControl.Change Event (Access)

 Copy code hover
[image]

WebBrowserControl.Change Event (Access)
See also Send feedback

Published: July 16, 2012

The Change event occurs when the contents of the specified control changes.

Version Information

Version Added: Access 2010

Syntax

expression .Change

expression A variable that represents a WebBrowserControl object.

Return Value

nothing

Remarks

Examples of this event include entering a character directly in the text box or combo box or changing the control's Text property setting by using a macro or Visual Basic.

Note Note

Setting the value of a control by using a macro or Visual Basic doesn't trigger this event for the control. You must type the data directly into the control, or set the control's Text property.

To run a macro or event procedure when this event occurs, set the OnChange property to the name of the macro or to [Event Procedure].

By running a macro or event procedure when a Change event occurs, you can coordinate data display among controls. You can also display data or a formula in one control and the results in another control.

The Change event doesn't occur when a value changes in a calculated control.

Note Note

A Change event can cause a cascading event. This occurs when a macro or event procedure that runs in response to the control's Change event alters the control's contents — for example, by changing a property setting that determines the control's value, such as the Text property for a text box. To prevent a cascading event:

  • If possible, avoid attaching a Change macro or event procedure to a control that alters the control's contents.

  • Avoid creating two or more controls having Change events that affect each other — for example, two text boxes that update each other.

Changing the data in a text box or combo box by using the keyboard causes keyboard events to occur in addition to control events like the Change event. For example, if you move to a new record and type an ANSI character in a text box in the record, the following events occur in this order:

KeyDown → KeyPress → BeforeInsert → Change → KeyUp

The BeforeUpdate and AfterUpdate events for the text box or combo box control occur after you have entered the new or changed data in the control and moved to another control (or clicked Save Record on the Records menu), and therefore after all of the Change events for the control.

In combo boxes for which the LimitToList property is set to Yes, the NotInList event occurs after you enter a value that isn't in the list and attempt to move to another control or save the record. It occurs after all the Change events for the combo box. In this case, the BeforeUpdate and AfterUpdate events for the combo box don't occur, because Microsoft Access doesn't accept a value that is not in the list.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Filter/Query/Search

 Copy code hover
[image]

Filter/Query/Search
Send feedback

In this section

  • ApplyFilter Macro Action

  • FindNextRecord Macro Action

  • FindRecord Macro Action

  • OpenQuery Macro Action

  • RefreshRecord Macro Action

  • Requery Macro Action

  • RunSQL Macro Action

  • SearchForRecord Macro Action

  • SetFilter Macro Action

  • SetOrderBy Macro Action

  • ShowAllRecords Macro Action


Method not applicable for this object. (Error 3273)

 Copy code hover
[image]

Method not applicable for this object. (Error 3273)
Send feedback

You tried to use a method on an object that does not support that method. Refer to the Summary topic for the object to see a list of valid methods for that object.


CheckBox.Requery Method (Access)

 Copy code hover
[image]

CheckBox.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.

Syntax

expression .Requery

expression A variable that represents a CheckBox object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts .

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate function.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

Example

The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form:

VBA Copy code Copy code
Public Sub RequeryList()

    Dim ctlCombo As Control

    ' Return Control object pointing to a combo box.
    Set ctlCombo = Forms!Employees!ReportsTo

    ' Requery source of data for list box.
    ctlCombo.Requery

End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Invalid use of '.', '!', or '()'. (Error 2423)

 Copy code hover
[image]

Invalid use of '.', '!', or '()'. (Error 2423)
Send feedback

The expression does not use delimiters correctly. To reference the properties of a DAO object, it is recommended that you use the .propertyname syntax.


BoundObjectFrame.Tag Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents a BoundObjectFrame object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


NavigationButton.Enabled Property (Access)

 Copy code hover
[image]

NavigationButton.Enabled Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .Enabled

expression A variable that represents a NavigationButton object.

Remarks

The Enabled property setting is a value that indicates whether the conditional format is enabled or disabled. True enables the conditional format. False disables the conditional format. The default is True.

When the Enabled property is True, the conditional format can be displayed in the Conditional Formatting dialog box.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


ListBox.OnEnter Property (Access)

 Copy code hover
[image]

ListBox.OnEnter Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnEnter

expression A variable that represents a ListBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Enter event occurs before a control actually receives the focus from a control on the same form.

The OnEnter value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Enter box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Enter box is blank, the property value is an empty string.

Example

The following example associates the Enter event with the macro "Enter_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnEnter = "Enter_Macro"

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Index Properties, Methods, and Events (ADOX)

 Copy code hover
[image]

Index Properties, Methods, and Events (ADOX)
Send feedback

Properties/Collections

Clustered Property

Columns Collection

IndexNulls Property

Name Property

PrimaryKey Property

Properties Collection

Unique Property

Methods

None.

Events

None.


CommandButton.ControlTipText Property (Access)

 Copy code hover
[image]

CommandButton.ControlTipText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.

Syntax

expression .ControlTipText

expression A variable that represents a CommandButton object.

Remarks

You set the ControlTipText property by using a string expression up to 255 characters long.

For controls on forms, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

You can set the ControlTipText property in any view.

The ControlTipText property provides an easy way to provide helpful information about controls on a form.

There are other ways to provide information about a form or a control on a form. You can use the StatusBarText property to display information in the status bar about a control. To provide more extensive help for a form or control, use the HelpFile and HelpContextID properties.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Form Section

 Copy code hover
[image]

Form Section
Send feedback

Published: July 16, 2012

A form section is part of a form such as a header, footer, or detail section.

You can set section properties which are attributes of a form that affect the appearance or behavior of that section. For example, you can set the CanGrow property to specify whether the section will increase vertically to print all the data the section contains. Section properties are set in form Design view.


Form.Timer Event (Access)

 Copy code hover
[image]

Form.Timer Event (Access)
See also Send feedback

Published: July 16, 2012

The Timer event occurs for a form at regular intervals as specified by the form's TimerInterval property.

Syntax

expression .Timer

expression A variable that represents a Form object.

Remarks

To run a macro or event procedure when this event occurs, set the OnTimer property to the name of the macro or to [Event Procedure].

By running a macro or event procedure when a Timer event occurs, you can control what Microsoft Access does at every timer interval. For example, you might want to requery underlying records or repaint the screen at specified intervals.

The TimerInterval property setting of the form specifies the interval, in milliseconds, between Timer events. The interval can be between 0 and 2,147,483,647 milliseconds. Setting the TimerInterval property to 0 prevents the Timer event from occurring.

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Delay Event/Actions for Set Time Interval

Example

The following example demonstrates a digital clock you can display on a form. A label control displays the current time according to your computer's system clock.

To try the example, add the following event procedure to a form that contains a label named Clock. Set the form's TimerInterval property to 1000 milliseconds to update the clock every second.

VBA Copy code Copy code
Private Sub Form_Timer()
    Clock.Caption = Time        ' Update time display.
End Sub

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Form Object

Other resources

Form Object Members


WebBrowserControl.GridlineThemeColorIndex Property (Access)

 Copy code hover
[image]

WebBrowserControl.GridlineThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineThemeColorIndex

expression A variable that represents a WebBrowserControl object.

Remarks

The GridlineThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 (Default) | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the GridlineThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


NavigationControl.BeforeUpdate Event (Access)

 Copy code hover
[image]

NavigationControl.BeforeUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The BeforeUpdate event occurs before changed data in a control or record is updated.

Version Information

Version Added: Access 2010

Syntax

expression .BeforeUpdate(Cancel, )

expression A variable that represents a NavigationControl object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer |

Return Value

nothing

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's BeforeUpdate event does occur.

To run a macro or event procedure when this event occurs, set the BeforeUpdate property to the name of the macro or to [Event Procedure].

This event does not apply to option buttons, check boxes, or toggle buttons in an option group. It applies only to the option group itself.

The BeforeUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB. When the focus leaves the record or if the user clicks Save Record on the Records menu, the entire record is updated, and the data is saved in the database.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

BeforeUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. BeforeUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For forms, you can use the BeforeUpdate event to cancel updating of a record before moving to another record.

If the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

You often use the BeforeUpdate event to validate data, especially when you perform complex validations, such as those that:

  • Involve conditions for more than one value on a form.

  • Display different error messages for different data entered.

  • Can be overridden by the user.

  • Contain references to controls on other forms or contain user-defined functions.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

A run-time error will occur if you attempt to modify the data contained in the control that fired the BeforeUpdate event in the event's procedure.

Example

The following example shows how you can use a BeforeUpdate event procedure to check whether a product name has already been entered in the database. After the user types a product name in the ProductName box, the value is compared to the ProductName field in the Products table. If there is a matching value in the Products table, a message is displayed that informs the user that the product has already been entered.

To try the example, add the following event procedure to a form named Products that contains a text box called ProductName.

VBA Copy code Copy code
Private Sub ProductName_BeforeUpdate(Cancel As Integer)
 If(Not IsNull(DLookup("[ProductName]", _
 "Products", "[ProductName] ='" _
 & Me!ProductName & "'"))) Then
 MsgBox "Product has already been entered in the database."
 Cancel = True
 Me!ProductName.Undo
 End If
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


TextBox.LabelY Property (Access)

 Copy code hover
[image]

TextBox.LabelY Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelY

expression A variable that represents a TextBox object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


TextBox.IMESentenceMode Property (Access)

 Copy code hover
[image]

TextBox.IMESentenceMode Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .IMESentenceMode

expression A variable that represents a TextBox object.

Remarks

The IMESentenceMode property uses the following settings.

Setting | Description | Visual Basic
Normal | (Default) Set IME Sentence Mode to "Normal" mode. | 0
Plural | Set IME Sentence Mode to "Plural" mode. | 1
Speaking | Set IME Sentence Mode to "Speaking" mode. | 2
No Conversion | Doesn't set IME Sentence Mode. | 3

Normal mode

Use this mode when creating a literary Japanese document.

Plural mode

Use this mode when entering name or address data. In this mode, two additional dictionaries are available. The "Biographical/Geographical Dictionary" contains names not covered in the normal dictionary and the "Postal Code Dictionary", useful in creating addresses. (Factory setting.)

Speaking mode

Use this mode when entering data that contains conversational language.

No Conversion

In this mode, inputted characters are settled without conversion.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ComboBox.MouseUp Event (Access)

 Copy code hover
[image]

ComboBox.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents a ComboBox object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was released to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Field

 Copy code hover
[image]

Field <name> cannot be a zero-length string. (Error 3315)
Send feedback

The AllowZeroLength property for this field is set to False, prohibiting the entry of a zero-length string in the field. Enter a different value in the field.


Application.DStDev Method (Access)

 Copy code hover
[image]

Application.DStDev Method (Access)
See also Send feedback

Published: July 16, 2012

Estimates the standard deviation across a population sample in a specified set of records (a domain). .

Syntax

expression .DStDev(Expr, Domain, Criteria)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Expr | Required | String | An expression that identifies the numeric field on which you want to find the standard deviation. It can be a string expression identifying a field from a table or query, or it can be an expression that performs a calculation on data in that field. In expr, you can include the name of a field in a table, a control on a form, a constant, or a function. If expr includes a function, it can be either built-in or user-defined, but not another domain aggregate or SQL aggregate function.
Domain | Required | String | A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter.
Criteria | Optional | Variant | An optional string expression used to restrict the range of data on which the DStDev function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the DStDev function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain; otherwise, the DStDev function will return a Null.

Return Value

Variant

Remarks

For example, you could use the DStDev function in a module to calculate the standard deviation across a set of students' test scores.

If domain refers to fewer than two records or if fewer than two records satisfy criteria, the DStDev function returns a Null, indicating that a standard deviation can't be calculated.

You can use the DStDev function to specify criteria in the Criteria row of a select query. For example, you could create a query on an Orders table and a Products table to display all products for which the freight cost fell above the mean plus the standard deviation for freight cost. The Criteria row beneath the Freight field would contain the following expression:

VBA Copy code Copy code
>(DStDev("[Freight]", "Orders") + DAvg("[Freight]", "Orders"))

You can use the DStDev function in a calculated field expression of a query, or in the Update To row of an update query.

Note Note

You can use the DStDev and DStDevP functions or the StDev and StDevP functions in a calculated field expression of a totals query. If you use the DStDev or DStDevP function, values are calculated before data is grouped. If you use the StDev or StDevP function, the data is grouped before values in the field expression are evaluated.

Use the DStDev function in a calculated control when you need to specify criteria to restrict the range of data on which the function is performed. For example, to display standard deviation for orders to be shipped to California, set the ControlSource property of a text box to the following expression:

VBA Copy code Copy code
=DStDev("[Freight]", "Orders", "[ShipRegion] = 'CA'")

If you simply want to find the standard deviation across all records in domain, use the StDev or StDevP function.

If the data type of the field from which expr is derived is a number, the DStDev function returns a Double data type. If you use the DStDev function in a calculated control, include a data type conversion function in the expression to improve performance.

Example

The following example returns estimates of the standard deviation for a population and a population sample for orders shipped to the United Kingdom. The domain is an Orders table. The criteria argument restricts the resulting set of records to those for which the ShipCountry value is UK.

VBA Copy code Copy code
Dim dblX As Double
Dim dblY As Double

' Sample estimate.
dblX = DStDev("[Freight]", "Orders", "[ShipCountry] = 'UK'")

' Population estimate.
dblY = DStDevP("[Freight]", "Orders", "[ShipCountry] = 'UK'")

The next example calculates the same estimates by using a variable, strCountry, in the criteria argument. Note that single quotation marks (') are included in the string expression, so that when the strings are concatenated, the string literal UK will be enclosed in single quotation marks.

VBA Copy code Copy code
Dim strCountry As String
Dim dblX As Double
Dim dblY As Double

strCountry = "UK"

dblX = DStDev("[Freight]", "Orders", _
    "[ShipCountry] = '" & strCountry & "'")

dblY = DStDevP("[Freight]", "Orders", _
    "[ShipCountry] = '" & strCountry & "'")

The following examples show how to use various types of criteria with the DStDev function.

Sample code provided by: Community Member Icon The UtterAccess community | About the Contributors

Copy code Copy code
    ' ***************************
    ' Typical Use
    ' Numerical values. Replace "number" with the number to use.
    variable = DStDev("[FieldName]", "TableName", "[Criteria] = number")

    ' Strings.
    ' Numerical values. Replace "string" with the string to use.
    variable = DStDev("[FieldName]", "TableName", "[Criteria]= 'string'")

    ' Dates. Replace "date" with the string to use.
    variable = DStDev("[FieldName]", "TableName", "[Criteria]= #date#")
    ' ***************************

    ' ***************************
    ' Referring to a control on a form
    ' Numerical values
    variable = DStDev("[FieldName]", "TableName", "[Criteria] = " & Forms!FormName!ControlName)

    ' Strings
    variable = DStDev("[FieldName]", "TableName", "[Criteria] = '" & Forms!FormName!ControlName & "'")

    ' Dates
    variable = DStDev("[FieldName]", "TableName", "[Criteria] = #" & Forms!FormName!ControlName & "#")
    ' ***************************

    ' ***************************
    ' Combinations
    ' Multiple types of criteria
    variable = DStDev("[FieldName]", "TableName", "[Criteria1] = " & Forms![FormName]![Control1] _
             & " AND [Criteria2] = '" & Forms![FormName]![Control2] & "'" _
            & " AND [Criteria3] =#" & Forms![FormName]![Control3] & "#")

    ' Use two fields from a single record.
    variable = DStDev("[LastName] & ', ' & [FirstName]", "tblPeople", "[PrimaryKey] = 7")

    ' Expressions
    variable = DStDev("[Field1] + [Field2]", "tableName", "[PrimaryKey] = 7")

    ' Control Structures
    variable = DStDev("IIf([LastName] Like 'Smith', 'True', 'False')", "tableName", "[PrimaryKey] = 7")
    ' ***************************

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Application Object

Other resources

Application Object Members


Updating data in a linked table is not supported by this ISAM. (Error 3616)

 Copy code hover
[image]

Updating data in a linked table is not supported by this ISAM. (Error 3616)
Send feedback

The installable ISAM you are using does not allow updates to records in external tables. You can only add new records.


OptionButton.DblClick Event (Access)

 Copy code hover
[image]

OptionButton.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Syntax

expression .DblClick(Cancel)

expression A variable that represents an OptionButton object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the DblClick event occurs. Setting the Cancel argument to True (-1) cancels the DblClick event.

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Type Property Example (Property) (VJ++)

 Copy code hover
[image]

Type Property Example (Property) (VJ++)
Send feedback

This example demonstrates the Type property. It is a model of a utility for listing the names and types of a collection, like Properties, Fields, etc.

We do not need to open the Recordset to access its Properties collection; they come into existence when the Recordset object is instantiated. However, setting the CursorLocation property to adUseClient adds several dynamic properties to the Recordset object's Properties collection, making the example a little more interesting. For sake of illustration, we explicitly use the Item property to access each Property object.

Copy code Copy code

// BegintTypePropertyJ
import com.ms.wfc.data.*;
import java.io.* ;

public class TypePropertyX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 TypePropertyX();
 System.exit(0);
 }

 // TypePropertyX function
 static void TypePropertyX()
 {
 // Define ADO Objects.
 Recordset rst = null;
 AdoProperty prop = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String strCnn = "DSN='Pubs';Provider='MSDASQL';Integrated Security='SSPI';";
 String strMsg;
 int intIndex;
 int intDisplaysize = 15;

 try
 {
 rst = new Recordset();
 rst.setCursorLocation(AdoEnums.CursorLocation.CLIENT);
 for(intIndex = 0;
 intIndex <= rst.getProperties().getCount() - 1;intIndex++)
 {
 prop = rst.getProperties().getItem(intIndex);
 switch(prop.getType())
 {
 case AdoEnums.DataType.BIGINT :
 strMsg = "adBigInt";
 break;
 case AdoEnums.DataType.BINARY :
 strMsg = "adBinary";
 break;
 case AdoEnums.DataType.BOOLEAN :
 strMsg = "adBoolean";
 break;
 case AdoEnums.DataType.BSTR :
 strMsg = "adBSTR";
 break;
 case AdoEnums.DataType.CHAPTER :
 strMsg = "adChapter";
 break;
 case AdoEnums.DataType.CHAR :
 strMsg = "adChar";
 break;
 case AdoEnums.DataType.CURRENCY :
 strMsg = "adCurrency";
 break;
 case AdoEnums.DataType.DATE :
 strMsg = "adDate";
 break;
 case AdoEnums.DataType.DBDATE :
 strMsg = "adDBDate";
 break;
 case AdoEnums.DataType.DBTIME :
 strMsg = "adDBTime";
 break;
 case AdoEnums.DataType.DBTIMESTAMP :
 strMsg = "adDBTimeStamp";
 break;
 case AdoEnums.DataType.DECIMAL :
 strMsg = "adDecimal";
 break;
 case AdoEnums.DataType.DOUBLE :
 strMsg = "adDouble";
 break;
 case AdoEnums.DataType.EMPTY :
 strMsg = "adEmpty";
 break;
 case AdoEnums.DataType.ERROR :
 strMsg = "adError";
 break;
 case AdoEnums.DataType.FILETIME :
 strMsg = "adFileTime";
 break;
 case AdoEnums.DataType.GUID :
 strMsg = "adGUID";
 break;
 case AdoEnums.DataType.IDISPATCH :
 strMsg = "adIDispatch";
 break;
 case AdoEnums.DataType.INTEGER :
 strMsg = "adInteger";
 break;
 case AdoEnums.DataType.IUNKNOWN :
 strMsg = "adIUnknown";
 break;
 case AdoEnums.DataType.LONGVARBINARY :
 strMsg = "adLongVarBinary";
 break;
 case AdoEnums.DataType.LONGVARCHAR :
 strMsg = "adLongVarChar";
 break;
 case AdoEnums.DataType.LONGVARWCHAR :
 strMsg = "adLongVarWChar";
 break;
 case AdoEnums.DataType.NUMERIC :
 strMsg = "adNumeric";
 break;
 case AdoEnums.DataType.PROPVARIANT :
 strMsg = "adPropVariant";
 break;
 case AdoEnums.DataType.SINGLE :
 strMsg = "adSingle";
 break;
 case AdoEnums.DataType.SMALLINT :
 strMsg = "adSmallInt";
 break;
 case AdoEnums.DataType.TINYINT :
 strMsg = "adTinyInt";
 break;
 case AdoEnums.DataType.UNSIGNEDBIGINT :
 strMsg = "adUnsignedBigInt";
 break;
 case AdoEnums.DataType.UNSIGNEDINT :
 strMsg = "adUnsignedInt";
 break;
 case AdoEnums.DataType.UNSIGNEDSMALLINT :
 strMsg = "adUnsignedSmallInt";
 break;
 case AdoEnums.DataType.UNSIGNEDTINYINT :
 strMsg = "adUnsignedTinyInt";
 break;
 case AdoEnums.DataType.USERDEFINED :
 strMsg = "adUserDefined";
 break;
 case AdoEnums.DataType.VARBINARY :
 strMsg = "adVarBinary";
 break;
 case AdoEnums.DataType.VARCHAR :
 strMsg = "adVarChar";
 break;
 case AdoEnums.DataType.VARIANT :
 strMsg = "adVariant";
 break;
 case AdoEnums.DataType.VARNUMERIC :
 strMsg = "adVarNumeric";
 break;
 case AdoEnums.DataType.VARWCHAR :
 strMsg = "adVarWChar";
 break;
 case AdoEnums.DataType.WCHAR :
 strMsg = "adWChar";
 break;
 default:
 strMsg = "*UNKNOWN*";
 break;
 }
 System.out.println("Property " +
 Integer.toString(intIndex) +
 " : " +
 prop.getName() +
 ", Type = " +
 strMsg);
 if(intIndex % intDisplaysize == 0 && intIndex != 0)
 {
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 }
 }

 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rst != null)
 {
 PrintProviderError(rst.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rst != null)
 if (rst.getState() == 1)
 rst.close();
 }
 }

 // PrintProviderError Function
 static void PrintProviderError(Connection cnn1)
 {
 // Print Provider Errors from Connection Object.
 // ErrItem is an item object in the Connections Errors Collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if ( nCount > 0)
 {
 // Collection ranges from 0 to nCount-1.
 for ( i=0;i<nCount; i++)
 {
 ErrItem = cnn1.getErrors().getItem(i);
 System.out.println("\t Error Number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription());
 }
 }
 }
 // PrintIOError Function
 static void PrintIOError(java.io.IOException je)
 {
 System.out.println("Error: \n");
 System.out.println("\t Source: " + je.getClass() + "\n");
 System.out.println("\t Description: "+ je.getMessage() + "\n");
 }
}
// EndTypePropertyJ


NavigationControl.MouseDown Event (Access)

 Copy code hover
[image]

NavigationControl.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Version Information

Version Added: Access 2010

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents a NavigationControl object.

Parameters

Name | Required/Optional | Data Type | Description
Button | Required | Integer |
Shift | Required | Integer |
X | Required | Single |
Y | Required | Single |

Return Value

nothing

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
 Shift As Integer, X As Single, _
 Y As Single)
 If Button = acLeftButton Then
 MsgBox "You pressed the left button."
 End If
 If Button = acRightButton Then
 MsgBox "You pressed the right button."
 End If
 If Button = acMiddleButton Then
 MsgBox "You pressed the middle button."
 End If
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


OpenDiagram Macro Action

 Copy code hover
[image]

OpenDiagram Macro Action
Send feedback

In an Access project, you can use the OpenDiagram action to open a database diagram in Design view.

Note 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.

Setting

The OpenDiagram action has the following argument.

Action argument | Description
Diagram Name | The name of the database diagram to open. The Diagram Name box in the Action Arguments section of the Macro Builder pane shows all database diagrams in the current database. This is a required argument. If you run a macro containing the OpenDiagram action in a library database, Microsoft Access first looks for the diagram with this name in the library database, and then in the current database.

Remarks

This action is similar to double-clicking a database diagram in the Navigation Pane, or right-clicking the database diagram in the Navigation Pane and then clicking Design View.

Tip Tip

You can drag a database diagram from the Navigation Pane to a macro action row. This automatically creates an OpenDiagram action that opens the database diagram in Design view.

To run the OpenDiagram action in a Visual Basic for Applications (VBA) module, use the OpenDiagram method of the DoCmd object.


ListBox.GridlineTint Property (Access)

 Copy code hover
[image]

ListBox.GridlineTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineTint

expression A variable that represents a ListBox object.

Remarks

The GridlineTint property contains a numeric expression that can be used to lighten the theme color in the GridlineColor property. The default value of the GridlineTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


RemoveAllTempVars Macro Action

 Copy code hover
[image]

RemoveAllTempVars Macro Action
Send feedback

You can use the RemoveAllTempVars action to remove any temporary variables that you created by using the SetTempVar action.

Setting

The RemoveAllTempVars action does not have any arguments.

Remarks

  • You can have up to 255 temporary variables defined at one time. If you do not remove a temporary variable, it will remain in memory until you close the database or project. It is a good practice to remove temporary variables when you are finished using them.

  • Access automatically removes all temporary variables when you close the database or project.

  • To remove a single temporary variable, use the RemoveTempVar action and set its argument to the name of the temporary variable you want to remove.

  • To run the RemoveAllTempVars action in a VBA module, use the RemoveAll method of the TempVars object.

Example

The following macro demonstrates how to create a temporary variable, use it in a condition and a message box, and then remove the temporary variable by using the RemoveAllTempVars action.

Condition | Action | Arguments
 | SetTempVar | Name: MyVarExpression: InputBox("Enter a non-zero number.")
[TempVars]![MyVar]<>0 | MessageBox | Message: ="You entered " & [TempVars]![MyVar] & "."Beep: Yes Type: Information
 | RemoveAllTempVars |


WebServices.Item Property (Access)

 Copy code hover
[image]

WebServices.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only Object.

Version Information

Version Added: Access 2010

Syntax

expression .Item(Index)

expression A variable that represents a WebServices object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant |

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

WebServices Collection

Other resources

WebServices Object Members


EmptyCell.BackColor Property (Access)

 Copy code hover
[image]

EmptyCell.BackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the interior color of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackColor

expression A variable that represents an EmptyCell object.

Remarks

The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

To use the BackColor property, the BackStyle property, if available, must be set to Normal.

Example

The following example uses the RGB function to set the , BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


DependencyInfo.Dependencies Property (Access)

 Copy code hover
[image]

DependencyInfo.Dependencies Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a DependencyObjects collection that represents the objects that the specified AccessObject object depends upon. Read-only.

Syntax

expression .Dependencies

expression A variable that represents a DependencyInfo object.

Remarks

To return the collection of objects that depend upon the specified AccessObject object, use the Dependants property of the DependencyInfoobject.

See also

Concepts

DependencyInfo Object

Other resources

DependencyInfo Object Members


ObjectFrame.GotFocus Event (Access)

 Copy code hover
[image]

ObjectFrame.GotFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The GotFocus event occurs when the specified object receives the focus.

Syntax

expression .GotFocus

expression A variable that represents an ObjectFrame object.

Remarks

To run a macro or event procedure when these events occur, set the OnGotFocus property to the name of the macro or to [Event Procedure].

These events occur when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The GotFocus event differs from the Enter event in that the GotFocus event occurs every time a control receives the focus. For example, suppose the user clicks a check box on a form, then clicks a report, and finally clicks the check box on the form to bring it to the foreground. The GotFocus event occurs both times the check box receives the focus. In contrast, the Enter event occurs only the first time the user clicks the check box. The GotFocus event occurs after the Enter event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Cannot perform cascading operation. Since related records exist in table

 Copy code hover
[image]

Cannot perform cascading operation. Since related records exist in table <name>, referential integrity rules would be violated. (Error 3396)
Send feedback

The cascade operation you are attempting violates referential integrity rules with the indicated table. Check the values you are attempting to update or delete, and fix them so they comply with the referential integrity rules.


Control.Properties Property (Access)

 Copy code hover
[image]

Control.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a Control object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

Control Object

Other resources

Control Object Members


SkipLine Method (ADO)

 Copy code hover
[image]

SkipLine Method (ADO)
Send feedback

Skips one entire line when reading a text stream.

Syntax

Stream.SkipLine

Remarks

All characters up to, and including the next line separator, are skipped. By default, the LineSeparator is adCRLF. If you attempt to skip past EOS, the current position will simply remain at EOS.

The SkipLine method is used with text streams (Type is adTypeText).


Invalid SQL syntax - expected token: Database (Error 3785)

 Copy code hover
[image]

Invalid SQL syntax - expected token: Database (Error 3785)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for more information.


SubForm.ControlType Property (Access)

 Copy code hover
[image]

SubForm.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Syntax

expression .ControlType

expression A variable that represents a SubForm object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Control.SizeToFit Method (Access)

 Copy code hover
[image]

Control.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents a Control object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

Control Object

Other resources

Control Object Members


SQL Property Example (VBScript)

 Copy code hover
[image]

SQL Property Example (VBScript)
Send feedback

The following code shows how to set the RDS.DataControl SQL parameter at design time and bind it to a data-aware control using the database called Pubs, which ships with Microsoft® SQL Server™. To test the example, copy the following code into a normal ASP document named SQLDesignVBS.asp on your Web server.

VBS Copy code Copy code
<!-- BeginSQLDesignVBS --><%@ Language=VBScript %>
<html><head>
<meta name="VI60_DefaultClientScript" content=VBScript><meta name="GENERATOR" content="Microsoft Visual Studio 6.0">
<title>SQL Property Example (VBScript)</title><style>
<!--body {
font-family: 'Verdana','Arial','Helvetica',sans-serif;BACKGROUND-COLOR:white;
COLOR:black;}
.thead {background-color: #008080;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.thead2 {background-color: #800000;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.tbody {text-align: center;
background-color: #f7efde;font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;}
--></style>
</head>
<body><h1>SQL Property Example (VBScript)</h1>
<!-- RDS.DataControl --><OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID=RDC HEIGHT=1 WIDTH=1>
<PARAM NAME="SQL" VALUE="Select FirstName, LastName from Employees"><PARAM NAME="SERVER" VALUE="http://<%=Request.ServerVariables("SERVER_NAME")%>">
<PARAM NAME="CONNECT" VALUE="Provider='sqloledb';Initial Catalog='Northwind';Integrated Security='SSPI';"></OBJECT>
<!-- Data Table -->
<TABLE DATASRC=#RDC BORDER=1><TR>
<TD> <SPAN DATAFLD="FirstName"></SPAN> </TD><TD> <SPAN DATAFLD="LastName"></SPAN> </TD>
</TR></TABLE>
</body></html>
<!-- EndSQLDesignVBS -->

The following example shows how to set the necessary parameters of RDS.DataControl at run time. To test this example, cut and paste the following code into a normal ASP document and name it SQLRuntimeVBS.asp. ASP script will identify your server.

VBS Copy code Copy code
<!-- BeginServerRuntimeVBS --><%@ Language=VBScript %>
<html><head>
<meta name="VI60_DefaultClientScript" content=VBScript><meta name="GENERATOR" content="Microsoft Visual Studio 6.0">
<title>Server Property Example (VBScript)</title><style>
<!--body {
font-family: 'Verdana','Arial','Helvetica',sans-serif;BACKGROUND-COLOR:white;
COLOR:black;}
.thead {background-color: #008080;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.thead2 {background-color: #800000;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.tbody {text-align: center;
background-color: #f7efde;font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;}
--></style>
</head>
<body><h1>Server Property Example (VBScript)</h1>
<H2>RDS API Code Examples</H2>
<H3>Remote Data Service Server Property Set at Run Time</H3>
<!-- RDS.DataControl with no parameters set at design time --><OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
ID=RDC HEIGHT=1 WIDTH=1></OBJECT>
<TABLE DATASRC=#RDC><TR>
<TD> <SPAN DATAFLD="FirstName"></SPAN> </TD><TD> <SPAN DATAFLD="LastName"></SPAN> </TD>
<TD> <SPAN DATAFLD="Title"></SPAN> </TD><TD> <SPAN DATAFLD="Type"></SPAN> </TD>
<TD> <SPAN DATAFLD="Email"></SPAN> </TD></TR>
</TABLE>
<HR><Input Size=70 Name="txtServer" Value="HTTP://<%= Request.ServerVariables("SERVER_NAME")%>">
<BR><Input Size=70 Name="txtConnect" Value="Provider='sqloledb';Integrated Security='SSPI';Initial Catalog='Northwind'">
<BR><Input Size=70 Name="txtSQL" Value="Select * from Employees">
<HR><INPUT TYPE=BUTTON NAME="Run" VALUE="Run"><BR>
<Script Language="VBScript"><!--
' Set parameters of RDS.DataControl at Run TimeSub Run_OnClick
RDC.Server = txtServer.ValueRDC.SQL = txtSQL.Value
RDC.Connect = txtConnect.ValueRDC.Refresh
End Sub-->
</Script>
</body></html>
<!-- EndServerRuntimeVBS -->


Views Delete Method Example (VB)

 Copy code hover
[image]

Views Delete Method Example (VB)
Send feedback

The following code shows how to use the Delete method to delete a view from the catalog.

Copy code Copy code

' BeginDeleteViewVB
Sub Main()
 On Error GoTo DeleteViewError

 Dim cat As New ADOX.Catalog

 ' Open the catalog
 cat.ActiveConnection = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\Microsoft Office\" & _
 "Office\Samples\Northwind.mdb';"

 'Delete the View
 cat.Views.Delete "AllCustomers"

 'Clean up
 Set cat.ActiveConnection = Nothing
 Set cat = Nothing
 Exit Sub

DeleteViewError:
 Set cat = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndDeleteViewVB


MaxRecords Property (ADO)

 Copy code hover
[image]

MaxRecords Property (ADO)
Send feedback

Indicates the maximum number of records to return to a Recordset from a query.

Settings and Return Values

Sets or returns a Long value that indicates the maximum number of records to return. Default is zero (no limit).

Remarks

Use the MaxRecords property to limit the number of records that the provider returns from the data source. The default setting of this property is zero, which means the provider returns all requested records.

The MaxRecords property is read/write when the Recordset is closed and read-only when it is open.


Could not find reference. (Error 3199)

 Copy code hover
[image]

Could not find reference. (Error 3199)
Send feedback

You entered a file, table, or field reference that could not be found. Check the spelling and punctuation to make sure you entered the reference correctly, and then try the operation again.


Unexpected error from external database driver

 Copy code hover
[image]

Unexpected error from external database driver <error number>. (Error 3275)
Send feedback

The specified external database driver returned an error. This error can be caused by performing an operation not supported on this type of external database.


ComboBox.StatusBarText Property (Access)

 Copy code hover
[image]

ComboBox.StatusBarText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.

Syntax

expression .StatusBarText

expression A variable that represents a ComboBox object.

Remarks

You set the StatusBarText property by using a string expression up to 255 characters long.

Note Note

The length of the text you can display in the status bar depends on your computer hardware and video display.

You can use the StatusBarText property to provide specific information about a control. For example, when a text box has the focus, a brief instruction can tell the user what kind of data to enter

Note Note

You can also use the ControlTipText property to display a ScreenTip for a control.

If you create a control by dragging a field from the field list, the value in a field's Description property is copied to the StatusBarText property.

Example

The following example sets the status bar text to be displayed when the "Address_TextBox" control in the "Mailing List" form has the focus in Form View.

VBA Copy code Copy code
Forms("Mailing List").Controls("Address_TextBox"). _
 StatusBarText = "Enter the company's mailing address."

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Reports.Count Property (Access)

 Copy code hover
[image]

Reports.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents a Reports object.

See also

Concepts

Reports Collection

Other resources

Reports Object Members


ADO Dynamic Property Index

 Copy code hover
[image]

ADO Dynamic Property Index
Send feedback

Data providers, service providers, and service components can add dynamic properties to the Properties collections of the unopened Connection and Recordset objects. A given provider may also insert additional properties when these objects are opened. Some of these properties are listed in the ADO Dynamic Properties section. More are listed under the specific providers in the Appendix A: Providers section.

The table below is a cross-index of the ADO and OLE DB names for each standard OLE DB provider dynamic property. Your providers may add more properties than listed here. For the specific information about provider-specific dynamic properties, see your provider documentation.

The OLE DB Programmer's Reference refers to an ADO property name by the term, "Description." You can find more information about these standard properties in the OLE DB Programmer's Reference. Search for the OLE DB property name in the Index or see the following topics:

  • Appendix C: OLE DB Properties

  • Supported Properties of the Cursor Service

  • Supported Properties of the Persistence Provider

  • Supported OLE DB Properties of the Remoting Provider

Remarks

Note numbers used in the cross-index:

(1) This property is a Boolean flag indicating whether the named interface should be used. The equivalent OLE DB property name is listed if it exists.

(2) The "Bookmarkable" ADO property is generated internally for backwards compatibility, and is mapped to the OLE DB property, DBPROP_IROWSETLOCATE. This is the same property that corresponds to the ADO property, IRowsetLocate.

(3) The ADO property name, "Hidden Columns", is named differently than the OLE DB property name Description, "Hidden Columns Count."

(4) For hierarchical recordsets, the "Maximum Rows" ADO property gets applied across all children. Depending on the order in which the rows are returned, you might have all, some or no children for each parent or orphaned children in the result set. Therefore, when reshaping hierarchical recordsets, the identifier for every child should be unique. In general, the Microsoft Data Shaping Service for OLE DB (MSDATASHAPE) provider does not allow for distinction between properties that can be inherited from the parent and those that cannot be inherited.

(5) Does not apply.

Connection Dynamic Properties

ADO Property Name | OLE DB Property Name
Active Sessions | DBPROP_ACTIVESESSIONS
Asynchable Abort | DBPROP_ASYNCTXNABORT
Asynchable Commit | DBPROP_ASYNCTNXCOMMIT
Autocommit Isolation Levels | DBPROP_SESS_AUTOCOMMITISOLEVELS
Catalog Location | DBPROP_CATALOGLOCATION
Catalog Term | DBPROP_CATALOGTERM
Column Definition | DBPROP_COLUMNDEFINITION
Connect Timeout | DBPROP_INIT_TIMEOUT
Current Catalog | DBPROP_CURRENTCATALOG
Data Source | DBPROP_INIT_DATASOURCE
Data Source Name | DBPROP_DATASOURCENAME
Data Source Object Threading Model | DBPROP_DSOTHREADMODEL
DBMS Name | DBPROP_DBMSNAME
DBMS Version | DBPROP_DBMSVER
Extended Properties | DBPROP_INIT_PROVIDERSTRING
GROUP BY Support | DBPROP_GROUPBY
Heterogeneous Table Support | DBPROP_HETEROGENEOUSTABLES
Identifier Case Sensitivity | DBPROP_IDENTIFIERCASE
Initial Catalog | DBPROP_INIT_CATALOG
Isolation Levels | DBPROP_SUPPORTEDTXNISOLEVELS
Isolation Retention | DBPROP_SUPPORTEDTXNISORETAIN
Locale Identifier | DBPROP_INIT_LCID
Location | DBPROP_INIT_LOCATION
Maximum Index Size | DBPROP_MAXINDEXSIZE
Maximum Row Size | DBPROP_MAXROWSIZE
Maximum Row Size Includes BLOB | DBPROP_MAXROWSIZEINCLUDESBLOB
Maximum Tables in SELECT | DBPROP_MAXTABLESINSELECT
Mode | DBPROP_INIT_MODE
Multiple Parameter Sets | DBPROP_MULTIPLEPARAMSETS
Multiple Results | DBPROP_MULTIPLERESULTS
Multiple Storage Objects | DBPROP_MULTIPLESTORAGEOBJECTS
Multi-Table Update | DBPROP_MULTITABLEUPDATE
NULL Collation Order | DBPROP_NULLCOLLATION
NULL Concatenation Behavior | DBPROP_CONCATNULLBEHAVIOR
OLE DB Services | DBPROP_INIT_OLEDBSERVICES
OLE DB Version | DBPROP_PROVIDEROLEDBVER
OLE Object Support | DBPROP_OLEOBJECTS
Open Rowset Support | DBPROP_OPENROWSETSUPPORT
ORDER BY Columns in Select List | DBPROP_ORDERBYCOLUMNSINSELECT
Output Parameter Availability | DBPROP_OUTPUTPARAMETERAVAILABILITY
Pass By Ref Accessors | DBPROP_BYREFACCESSORS
Password | DBPROP_AUTH_PASSWORD
Persist Security Info | DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO
Persistent ID Type | DBPROP_PERSISTENTIDTYPE
Prepare Abort Behavior | DBPROP_PREPAREABORTBEHAVIOR
Prepare Commit Behavior | DBPROP_PREPARECOMMITBEHAVIOR
Procedure Term | DBPROP_PROCEDURETERM
Prompt | DBPROP_INIT_PROMPT
Provider Friendly Name | DBPROP_PROVIDERFRIENDLYNAME
Provider Name | DBPROP_PROVIDERFILENAME
Provider Version | DBPROP_PROVIDERVER
Read-Only Data Source | DBPROP_DATASOURCEREADONLY
Rowset Conversions on Command | DBPROP_ROWSETCONVERSIONSONCOMMAND
Schema Term | DBPROP_SCHEMATERM
Schema Usage | DBPROP_SCHEMAUSAGE
SQL Support | DBPROP_SQLSUPPORT
Structured Storage | DBPROP_STRUCTUREDSTORAGE
Subquery Support | DBPROP_SUBQUERIES
Table Term | DBPROP_TABLETERM
Transaction DDL | DBPROP_SUPPORTEDTXNDDL
User ID | DBPROP_AUTH_USERID
User Name | DBPROP_USERNAME
Window Handle | DBPROP_INIT_HWND

Recordset Dynamic Properties

Note that the Dynamic Properties of the Recordset object go out of scope (become unavailable) when the Recordset is closed.

ADO Property Name | OLE DB Property Name
IAccessor | DBPROP_IACCESSOR (1)
IChapteredRowset | (1)
IColumnsInfo | DBPROP_ICOLUMNSINFO (1)
IColumnsRowset | DBPROP_ICOLUMNSROWSET (1)
IConnectionPointContainer | DBPROP_ICONNECTIONPOINTCONTAINER (1)
IConvertType | (1)
ILockBytes | DBPROP_ILOCKBYTES (1)
IRowset | DBPROP_IROWSET (1)
IDBAsynchStatus | DBPROP_IDBASYNCHSTATUS (1)
IParentRowset | (1)
IRowsetChange | DBPROP_IROWSETCHANGE (1)
IRowsetExactScroll | (1)
IRowsetFind | DBPROP_IROWSETFIND (1)
IRowsetIdentity | DBPROP_IROWSETIDENTITY (1)
IRowsetInfo | DBPROP_IROWSETINFO (1)
IRowsetLocate | DBPROP_IROWSETLOCATE (1)
IRowsetRefresh | DBPROP_IROWSETREFRESH (1)
IRowsetResynch | (1)
IRowsetScroll | DBPROP_IROWSETSCROLL (1)
IRowsetUpdate | DBPROP_IROWSETUPDATE (1)
IRowsetView | DBPROP_IROWSETVIEW (1)
IRowsetIndex | DBPROP_IROWSETINDEX (1)
ISequentialStream | DBPROP_ISEQUENTIALSTREAM (1)
IStorage | DBPROP_ISTORAGE (1)
IStream | DBPROP_ISTREAM (1)
ISupportErrorInfo | DBPROP_ISUPPORTERRORINFO (1)
Access Order | DBPROP_ACCESSORDER
Append-Only Rowset | DBPROP_APPENDONLY
Asynchronous Rowset Processing | DBPROP_ROWSET_ASYNCH
Auto Recalc | DBPROP_ADC_AUTORECALC
Background Fetch Size | DBPROP_ASYNCHFETCHSIZE
Background Thread Priority | DBPROP_ASYNCHTHREADPRIORITY
Batch Size | DBPROP_ADC_BATCHSIZE
Blocking Storage Objects | DBPROP_BLOCKINGSTORAGEOBJECTS
Bookmark Type | DBPROP_BOOKMARKTYPE
Bookmarkable | DBPROP_IROWSETLOCATE (2)
Bookmarks Ordered | DBPROP_ORDEREDBOOKMARKS
Cache Child Rows | DBPROP_ADC_CACHECHILDROWS
Cache Deferred Columns | DBPROP_CACHEDEFERRED
Change Inserted Rows | DBPROP_CHANGEINSERTEDROWS
Column Privileges | DBPROP_COLUMNRESTRICT
Column Set Notification | DBPROP_NOTIFYCOLUMNSET
Column Writable | DBPROP_MAYWRITECOLUMN
Command Time Out | DBPROP_COMMANDTIMEOUT
Cursor Engine Version | DBPROP_ADC_CEVER
Defer Column | DBPROP_DEFERRED
Delay Storage Object Updates | DBPROP_DELAYSTORAGEOBJECTS
Fetch Backwards | DBPROP_CANFETCHBACKWARDS
Filter Operations | DBPROP_FILTERCOMPAREOPS
Find Operations | DBPROP_FINDCOMPAREOPS
Hidden Columns (Count) | DBPROP_HIDDENCOLUMNS (3)
Hold Rows | DBPROP_CANHOLDROWS
Immobile Rows | DBPROP_IMMOBILEROWS
Initial Fetch Size | DBPROP_ASYNCHPREFETCHSIZE
Literal Bookmarks | DBPROP_LITERALBOOKMARKS
Literal Row Identity | DBPROP_LITERALIDENTITY
Maintain Change Status | DBPROP_ADC_MAINTAINCHANGESTATUS
Maximum Open Rows | DBPROP_MAXOPENROWS
Maximum Pending Rows | DBPROP_MAXPENDINGROWS
Maximum Rows | DBPROP_MAXROWS (4)
Memory Usage | DBPROP_MEMORYUSAGE
Notification Granularity | DBPROP_NOTIFICATIONGRANULARITY
Notification Phases | DBPROP_NOTIFICATIONPHASES
Objects Transacted | DBPROP_TRANSACTEDOBJECT
Others' Changes Visible | DBPROP_OTHERUPDATEDELETE
Others' Inserts Visible | DBPROP_OTHERINSERT
Own Changes Visible | DBPROP_OWNUPDATEDELETE
Own Inserts Visible | DBPROP_OWNINSERT
Preserve on Abort | DBPROP_ABORTPRESERVE
Preserve on Commit | DBPROP_COMMITPRESERVE
Private1 | (5)
Quick Restart | DBPROP_QUICKRESTART
Reentrant Events | DBPROP_REENTRANTEVENTS
Remove Deleted Rows | DBPROP_REMOVEDELETED
Report Multiple Changes | DBPROP_REPORTMULTIPLECHANGES
Reshape Name | DBPROP_ADC_RESHAPENAME
Resync Command | DBPROP_ADC_CUSTOMRESYNCH
Return Pending Inserts | DBPROP_RETURNPENDINGINSERTS
Row Delete Notification | DBPROP_NOTIFYROWDELETE
Row First Change Notification | DBPROP_NOTIFYROWFIRSTCHANGE
Row Insert Notification | DBPROP_NOTIFYROWINSERT
Row Privileges | DBPROP_ROWRESTRICT
Row Resynchronization Notification | DBPROP_NOTIFYROWRESYNCH
Row Threading Model | DBPROP_ROWTHREADMODEL
Row Undo Change Notification | DBPROP_NOTIFYROWUNDOCHANGE
Row Undo Delete Notification | DBPROP_NOTIFYROWUNDODELETE
Row Undo Insert Notification | DBPROP_NOTIFYROWUNDOINSERT
Row Update Notification | DBPROP_NOTIFYROWUPDATE
Rowset Fetch Position Change Notification | DBPROP_NOTIFYROWSETFETCHPOSITIONCHANGE
Rowset Release Notification | DBPROP_NOTIFYROWSETRELEASE
Scroll Backwards | DBPROP_CANSCROLLBACKWARDS
Server Cursor | DBPROP_SERVERCURSOR
Skip Deleted Bookmarks | DBPROP_BOOKMARKSKIPPED
Strong Row Identity | DBPROP_STRONGIDENTITY
Unique Catalog | DBPROP_ADC_UNIQUECATALOG
Unique Rows | DBPROP_UNIQUEROWS
Unique Schema | DBPROP_ADC_UNIQUESCHEMA
Unique Table | DBPROP_ADC_UNIQUETABLE
Updatability | DBPROP_UPDATABILITY
Update Criteria | DBPROP_ADC_UPDATECRITERIA
Update Resync | DBPROP_ADC_UPDATERESYNC
Use Bookmarks | DBPROP_BOOKMARKS


ToggleButton.GridlineThemeColorIndex Property (Access)

 Copy code hover
[image]

ToggleButton.GridlineThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineThemeColorIndex

expression A variable that represents a ToggleButton object.

Remarks

The GridlineThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 (Default) | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the GridlineThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


WSParameter.Name Property (Access)

 Copy code hover
[image]

WSParameter.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .Name

expression A variable that represents a WSParameter object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

WSParameter Object

Other resources

WSParameter Object Members


Attachment.BeforeUpdate Event (Access)

 Copy code hover
[image]

Attachment.BeforeUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The BeforeUpdate event occurs before changed data in a control or record is updated.

Version Information

Version Added: Access 2007

Syntax

expression .BeforeUpdate(Cancel, )

expression A variable that represents an Attachment object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the BeforeUpdate event occurs. Setting the Cancel argument to True (-1) cancels the BeforeUpdate event.

Return Value

nothing

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's BeforeUpdate event does occur.

The BeforeUpdate event applies only to controls on a form, not controls on a report.

To run a macro or event procedure when this event occurs, set the BeforeUpdate property to the name of the macro or to [Event Procedure].

The BeforeUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB. When the focus leaves the record or if the user clicks Save Record on the Records menu, the entire record is updated, and the data is saved in the database.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occurs immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

BeforeUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. BeforeUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

If the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

You often use the BeforeUpdate event to validate data, especially when you perform complex validations, such as those that:

  • Involve conditions for more than one value on a form.

  • Display different error messages for different data entered.

  • Can be overridden by the user.

  • Contain references to controls on other forms or contain user-defined functions.

A run-time error will occur if you attempt to modify the data contained in the control that fired the BeforeUpdate event in the event's procedure.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


IsolationLevelEnum

 Copy code hover
[image]

IsolationLevelEnum
Send feedback

Specifies the level of transaction isolation for a Connection object.

Constant | Value | Description
adXactUnspecified | -1 | Indicates that the provider is using a different isolation level than specified, but that the level cannot be determined.
adXactChaos | 16 | Indicates that pending changes from more highly isolated transactions cannot be overwritten.
adXactBrowse | 256 | Indicates that from one transaction you can view uncommitted changes in other transactions.
adXactReadUncommitted | 256 | Same as adXactBrowse.
adXactCursorStability | 4096 | Indicates that from one transaction you can view changes in other transactions only after they have been committed.
adXactReadCommitted | 4096 | Same as adXactCursorStability.
adXactRepeatableRead | 65536 | Indicates that from one transaction you cannot see changes made in other transactions, but that requerying can retrieve new Recordset objects.
adXactIsolated | 1048576 | Indicates that transactions are conducted in isolation of other transactions.
adXactSerializable | 1048576 | Same as adXactIsolated.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.IsolationLevel.UNSPECIFIED

AdoEnums.IsolationLevel.CHAOS

AdoEnums.IsolationLevel.BROWSE

AdoEnums.IsolationLevel.READUNCOMMITTED

AdoEnums.IsolationLevel.CURSORSTABILITY

AdoEnums.IsolationLevel.READCOMMITTED

AdoEnums.IsolationLevel.REPEATABLEREAD

AdoEnums.IsolationLevel.ISOLATED

AdoEnums.IsolationLevel.SERIALIZABLE


Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'. (Error 3129)

 Copy code hover
[image]

Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'. (Error 3129)
Send feedback

Your SQL statement could not be recognized because it does not begin with one of the specified reserved words.


CodeData Properties (Access)

 Copy code hover
[image]

CodeData Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
AllDatabaseDiagrams | You can use the AllDatabaseDiagrams property to reference the AllDatabaseDiagrams collection and its related properties. Read-only AllDatabaseDiagrams object.
AllFunctions | You can use the AllFunctions property to reference the AllFunctions collection and its related properties. Read-only AllFunctions object.
AllQueries | You can use the AllQueries property to reference the AllQueries collection and its related properties. Read-only AllQueries object.
AllStoredProcedures | You can use the AllStoredProcedures property to reference the AllStoredProcedures collection and its related properties. Read-only AllStoredProcedures object.
AllTables | You can use the AllTables property to reference the AllTables collection and its related properties. Read-only AllTables object.
AllViews | You can use the AllViews property to reference the AllViews collection and its related properties. Read-only AllViews object.


Report.ControlBox Property (Access)

 Copy code hover
[image]

Report.ControlBox Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether a report has a Control menu in Report view. Read/write Boolean.

Syntax

expression .ControlBox

expression A variable that represents a Report object.

Remarks

The default value is True.

Setting the ControlBox property to False also removes the Minimize, Maximize, and Close buttons on a form.

It can only be set in form Design view.

See also

Concepts

Report Object

Other resources

Report Object Members


Calculating Fields in SQL Functions

 Copy code hover
[image]

Calculating Fields in SQL Functions
Send feedback

Published: July 16, 2012

You can use the string expression argument in an SQL aggregate function to perform a calculation on values in a field. For example, you could calculate a percentage (such as a surcharge or sales tax) by multiplying a field value by a fraction.

The following table provides examples of calculations on fields from the Orders and Order Details tables in the Northwind.mdb database.

Calculation | Example
Add a number to a field | Freight + 5
Subtract a number from a field | Freight - 5
Multiply a field by a number | UnitPrice * 2
Divide a field by a number | Freight / 2
Add one field to another | UnitsInStock + UnitsOnOrder
Subtract one field from another | ReorderLevel - UnitsInStock

The following example calculates the average discount amount of all orders in the Northwind.mdb database. It multiplies the values in the UnitPrice and Discount fields to determine the discount amount of each order and then calculates the average. You can use this expression in an SQL statement in Visual Basic code:

SQL Copy code Copy code
SELECT Avg(UnitPrice * Discount) AS [Average Discount] FROM [Order Details];


OpenFunction Macro Action

 Copy code hover
[image]

OpenFunction Macro Action
Send feedback

In an Access project, you can use the OpenFunction action to open a user-defined function in Datasheet view, inline function Design view, SQL Text Editor view (for a scalar or table user-defined function), or Print Preview. This action runs the user-defined function when opened in Datasheet view. You can also select the data entry mode for the user-defined function and restrict the records that the user-defined function displays.

Note 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.

Setting

The OpenFunction action has the following arguments.

Action argument | Description
Function Name | The name of the user-defined function to open. The Function Name box in the Action Arguments section of the Macro Builder pane shows all user-defined functions in the current database. This is a required argument.If you run a macro containing the Function action in a library database, Microsoft Access first looks for the function with this name in the library database, and then in the current database.
View | The view in which the user-defined function will open. Click Datasheet, Design, Print Preview, PivotTable, or PivotChart in the View box. The default is Datasheet.
Data Mode | The data entry mode for the user-defined function. This applies only to user-defined functions opened in Datasheet view. Click Add (the user can add new records but can't view or edit existing records), Edit (the user can view or edit existing records and add new records), or Read Only (the user can only view records). The default is Edit.

Remarks

This action is similar to double-clicking a user-defined function in the Navigation Pane, or right-clicking the function in the Navigation Pane and selecting a view.

Switching to Design view while the user-defined function is open removes the Data Mode argument setting for the user-defined function. This setting is not in effect, even if the user returns to Datasheet view.

Tips

  • You can select a user-defined function in the Navigation Pane and drag it to a macro action row. This automatically creates an OpenFunction action that opens the user-defined function in Datasheet view.

  • If you don't want to display the system messages that normally appear when a user-defined function is run (indicating it is a user-defined function and showing how many records will be affected), you can use the SetWarning action to suppress the display of these messages.

To run the OpenFunction action in a Visual Basic for Applications (VBA) module, use the OpenFunction method of the DoCmd object.


Section.OnMouseUp Property (Access)

 Copy code hover
[image]

Section.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Syntax

expression .OnMouseUp

expression A variable that represents a Section object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

Section Object

Other resources

Section Object Members


The field

 Copy code hover
[image]

The field <name> cannot contain a Null value because the Required property for this field is set to True. Enter a value in this field. (Error 3314)
Send feedback

The Required property for this field is set to Yes, prohibiting the entry of a Null or zero-length string (" ") in the field. Enter a value in the field.

What Is a Null?

A Null is a value you can enter in a field or use in expressions or queries to indicate missing or unknown data. In Microsoft Visual Basic, the Null keyword indicates a Null value. Some fields, such as primary key fields, cannot contain Null.

What Is the Required Property?

You can use the Required property to specify whether a value is required in a field. If this property is set to Yes, when you enter data in a record, you must enter a value in the field or in any control bound to the field, and the value cannot be Null. For example, you might want to be sure that a LastName control has a value for each record.

Solution

This problem has the following possible solutions:

  • Enter a value in the field named in the error message.

  • Remove the Required property setting from the field.

  • Use the AllowZeroLength property to allow zero-length strings (" ") to be stored in the field.

To remove the required property

  1. In the Navigation Pane, right-click the name of the table that contains the required field, and then click Design View.

  2. Click the Field Name for the field named in the error message.

  3. Under Field Properties, click the General tab.

  4. In the Required property, click No.

  5. To save your changes, click Save on the Quick Access Toolbar, or press CTRL+S.

Setting the AllowZeroLength Property

You can use the Required and AllowZeroLength properties to differentiate between information that does not exist (stored as a zero-length string (" ") in the field) and information that may exist but is unknown (stored as a Null value in the field). If you set the AllowZeroLength property to Yes, a zero-length string will be a valid entry in the field regardless of the Required property setting. If you set Required to Yes and AllowZeroLength to No, you must enter a value in the field, and a zero-length string will not be a valid entry.

The following table shows the results you can expect when you combine the settings of the Required and AllowZeroLength properties.

Required | AllowZeroLength | User's action | Value stored
No | No | Presses ENTER Presses SPACEBAR Enters a zero-length string | Null Null (not allowed)
No | Yes | Presses ENTER Presses SPACEBAR Enters a zero-length string | Null Null Zero-length string
Yes | No | Presses ENTER Presses SPACEBAR Enters a zero-length string | (not allowed) (not allowed) (not allowed)
Yes | Yes | Presses ENTER Presses SPACEBAR Enters a zero-length string | (not allowed) Zero-length string Zero-length string


Charset Property (ADO)

 Copy code hover
[image]

Charset Property (ADO)
Send feedback

Indicates the character set into which the contents of a text Stream should be translated for storage in the Stream objects internal buffer.

Settings and Return Values

Sets or returns a String value that specifies the character set into which the contents of the Stream will be translated. The default value is "Unicode". Allowed values are typical strings passed over the interface as Internet character set strings (for example, "iso-8859-1", "Windows-1252", etc.). For a list of the character set strings that is known by a system, see the subkeys of HKEY_CLASSES_ROOT\MIME\Database\Charset in the Windows Registry.

Remarks

In a text Stream object, text data is stored in the character set specified by the Charset property. The default is Unicode. The Charset property is used for converting data going into the Stream or coming out of the Stream. For example, if the Stream contains ISO-8859-1 data and that data is copied to a BSTR, the Stream object will convert the data to Unicode. The reverse is also true.

For an open Stream, the current Position must be at the beginning of the Stream (0) to be able to set Charset.

Charset is used only with text Stream objects (Type is adTypeText). This property is ignored if Type is adTypeBinary.


Cannot make the database replicable. (Error 3455)

 Copy code hover
[image]

Cannot make the database replicable. (Error 3455)
Send feedback

The Microsoft Access database engine was in the process of making the database replicable. The operation failed because there were insufficient resources. Make sure the total number of fields after replication does not exceed 255 in a single table and the total number of bytes in a record does not exceed 2048.


DoCmd.Restore Method (Access)

 Copy code hover
[image]

DoCmd.Restore Method (Access)
See also Send feedback

Published: July 16, 2012

The Restore method carries out the Restore action in Visual Basic.

Syntax

expression .Restore

expression A variable that represents a DoCmd object.

Remarks

You can use the Restore method to restore a maximized or minimized window to its previous size.

Note Note

This method cannot be applied to module windows in the Visual Basic Editor (VBE). For information about how to affect module windows see the WindowState property topic.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


TabControl.GridlineStyleTop Property (Access)

 Copy code hover
[image]

TabControl.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleTop

expression A variable that represents a TabControl object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


TextBox.OnKeyPress Property (Access)

 Copy code hover
[image]

TextBox.OnKeyPress Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Press box in the Properties window. Read/write String.

Syntax

expression .OnKeyPress

expression A variable that represents a TextBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyPress event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyPress value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Press box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Press box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyPress property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyPress

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Tables Collection Properties, Methods, and Events (ADOX)

 Copy code hover
[image]

Tables Collection Properties, Methods, and Events (ADOX)
Send feedback

Properties

Count Property

Item Property

Methods

Append Method (Tables)

Delete Method (Collections)

Refresh Method

Events

None.


CommandButton.OnDblClick Property (Access)

 Copy code hover
[image]

CommandButton.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Syntax

expression .OnDblClick

expression A variable that represents a CommandButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_DblClick" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ObjectFrame.Requery Method (Access)

 Copy code hover
[image]

ObjectFrame.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.

Syntax

expression .Requery

expression A variable that represents an ObjectFrame object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts .

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate function.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

Example

The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form:

VBA Copy code Copy code
Public Sub RequeryList()

    Dim ctlCombo As Control

    ' Return Control object pointing to a combo box.
    Set ctlCombo = Forms!Employees!ReportsTo

    ' Requery source of data for list box.
    ctlCombo.Requery

End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


TextBox.OnKeyDown Property (Access)

 Copy code hover
[image]

TextBox.OnKeyDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Down box in the Properties window. Read/write String.

Syntax

expression .OnKeyDown

expression A variable that represents a TextBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyDown event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyDown

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Comment Macro Statement

 Copy code hover
[image]

Comment Macro Statement
Send feedback

The Comment statement can be used to provide explanatory remarks in a macro.

Remarks

A Comment may be up to 1000 characters in length. However, by default, only the first line of the comment is displayed.


No country code found in the connection string. (Error 3449)

 Copy code hover
[image]

No country code found in the connection string. (Error 3449)
Send feedback

No country code was found in the connection string.


ComboBox.ValidationText Property (Access)

 Copy code hover
[image]

ComboBox.ValidationText Property (Access)
See also Send feedback

Published: July 16, 2012

Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.

Syntax

expression .ValidationText

expression A variable that represents a ComboBox object.

Remarks

Enter an expression for the ValidationRule property setting and text for the ValidationText property setting. The maximum length for the ValidationRule property setting is 2048 characters. The maximum length for the ValidationText property setting is 255 characters.

For controls, you can set the ValidationRule property to any valid expression. For field and record validation rules, the expression can't contain user-defined functions, domain aggregate or aggregate functions, the Eval function, or CurrentUser method, or references to forms, queries, or tables. In addition, field validation rules can't contain references to other fields. For records, expressions can include references to fields in that table.

For table fields and records, you can also set these properties in Visual Basic by using the DAO ValidationRule property.

Microsoft Access automatically validates values based on a field's data type; for example, Microsoft Access doesn't allow text in a numeric field. You can set rules that are more specific by using the ValidationRule property.

If you set the ValidationRule property but not the ValidationText property, Microsoft Access displays a standard error message when the validation rule is violated. If you set the ValidationText property, the text you enter is displayed as the error message.

For example, when a record is added for a new employee, you can enter a ValidationRule property requiring that the value in the employee's StartDate field fall between the company's founding date and the current date. If the date entered isn't in this range, you can display the ValidationText property message: "Start date is incorrect."

If you create a control by dragging a field from the field list, the field's validation rule remains in effect, although it isn't displayed in the control's ValidationRule property box in the property sheet. This is because a field's validation rule is inherited by a control bound to that field.

Control, field, and record validation rules are applied as follows:

  • Validation rules you set for fields and controls are applied when you edit the data and the focus leaves the field or control.

  • Validation rules for records are applied when you move to another record.

  • If you create validation rules for both a field and a control bound to the field, both validation rules are applied when you edit data and the focus leaves the control.

The following table contains expression examples for the ValidationRule and ValidationText properties.

ValidationRule property | ValidationText property
<> 0 | Entry must be a nonzero value.
> 1000 Or Is Null | Entry must be blank or greater than 1000.
Like "A????" | Entry must be 5 characters and begin with the letter "A".
>= #1/1/96# And <#1/1/97# | Entry must be a date in 1996.
DLookup("CustomerID", "Customers", "CustomerID = Forms!Customers!CustomerID") Is Null | Entry must be a unique CustomerID (domain aggregate functions are allowed only for form-level validation).

If you create a validation rule for a field, Microsoft Access doesn't normally allow a Null value to be stored in the field. If you want to allow a Null value, add "Is Null" to the validation rule, as in "<> 8 Or Is Null" and make sure the Required property is set to No.

You can't set field or record validation rules for tables created outside Microsoft Access (for example, dBASE, Paradox, or SQL Server). For these kinds of tables, you can create validation rules for controls only.

Example

The following example creates a validation rule for a field that allows only values over 65 to be entered. If a number less than 65 is entered, a message is displayed. The properties are set by using the SetFieldValidation function.

VBA Copy code Copy code
Dim strTblName As String, strFldName As String
Dim strValidRule As String
Dim strValidText As String, intX As Integer

strTblName = "Customers"
strFldName = "Age"
strValidRule = ">= 65"
strValidText = "Enter a number greater than or equal to 65."
intX = SetFieldValidation(strTblName, strFldName, _
 strValidRule, strValidText)

Function SetFieldValidation(strTblName As String, _
 strFldName As String, strValidRule As String, _
 strValidText As String) As Integer

 Dim dbs As Database, tdf As TableDef, fld As Field

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 Set fld = tdf.Fields(strFldName)
 fld.ValidationRule = strValidRule
 fld.ValidationText = strValidText
End Function

The next example uses the SetTableValidation function to set record-level validation to ensure that the value in the EndDate field comes after the value in the StartDate field.

VBA Copy code Copy code
Dim strTblName As String, strValidRule As String
Dim strValidText As String
Dim intX As Integer

strTblName = "Employees"
strValidRule = "EndDate > StartDate"
strValidText = "Enter an EndDate that is later than the StartDate."
intX = SetTableValidation(strTblName, strValidRule, strValidText)

Function SetTableValidation(strTblName As String, _
 strValidRule As String, strValidText As String) _
 As Integer

 Dim dbs As Database, tdf As TableDef

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 tdf.ValidationRule = strValidRule
 tdf.ValidationText = strValidText
End Function

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


TRANSACTION Statement (Microsoft Access SQL)

 Copy code hover
[image]

TRANSACTION Statement (Microsoft Access SQL)
Send feedback

Used to initiate and conclude explicit transactions.

Syntax

Initiate a new transaction.

BEGIN TRANSACTION

Conclude a transaction by committing all work performed during the transaction.

COMMIT [TRANSACTION | WORK]

Conclude a transaction by rolling back all work performed during the transaction.

ROLLBACK [TRANSACTION | WORK]

Remarks

Transactions are not started automatically. To start a transaction, you must do so explicitly using BEGIN TRANSACTION.

Transactions can be nested up to five levels deep. To start a nested transaction, use BEGIN TRANSACTION within the context of an existing transaction.

Transactions are not supported for linked tables.


Visual Basic for Applications functions

 Copy code hover
[image]

Visual Basic for Applications functions
Send feedback

The following Visual Basic for Applications functions can be used in data shaping CALC expressions:

Abs | Asc | Atn | CBool | CByte | CCur
CDate | CDbl | Chr | ChrB | ChrW | Chr$
ChrB$ | CInt | CLng | Cos | CSng | CStr
Cvar | CVDate | CVErr | Date | Date$ | DateAdd
DateDiff | DatePart | DateSerial | DateValue | Day | DDB
Error | Error$ | Exp | Fix | Format | Format$
FV | Hex | Hex$ | Hour | IIF | InStr
Int | IPmt | IRR | IsDate | IsEmpty | IsError
IsNull | IsNumeric | IsObject | LCase | LCase$ | Left
LeftB | Left$ | LeftB$ | Len | Log | LTrim
LTrim$ | Mid | Mid$ | Minute | MIRR | Month
Now | NPer | NPV | Oct | Oct$ | Pmt
PPmt | PV | QBColor | Rate | RGB | Right
RightB | Right$ | RightB$ | Rnd | RTrim | RTrim$
Second | Sgn | Sin | SLN | Space | Space$
Sqr | Str | Str$ | StrComp | StrConv | String
String$ | SYD | Tan | Time | Time$ | Timer
TimeSerial | TimeValue | Trim | Trim$ | TypeName | UCase
UCase$ | Val | VarType | Weekday | Year |


ComboBox.ListWidth Property (Access)

 Copy code hover
[image]

ComboBox.ListWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ListWidth property to set the width of the list box portion of a combo box. Read/write String.

Syntax

expression .ListWidth

expression A variable that represents a ComboBox object.

Remarks

The ListWidth property holds a value specifying the width of the list box portion of a combo box in inches or centimeters, depending on the measurement system (U.S. or Metric) selected in the Measurement system box on the Numbers tab of the Regional Options dialog box of Windows Control Panel. To use a unit other than the default, include a measurement indicator, such as cm or in. The default setting (Auto) makes the list box portion of the combo box the same width as the combo box.

The default unit of measurement is twips.

Note Note

Microsoft Access sets the ListWidth property automatically when you select Lookup Wizard as the data type for a field in table Design view.

You can also set the default for this property by using a combo box's default control style or the DefaultControl property in Visual Basic.

The list portion of the combo box can be wider than the combo box but can't be narrower.

If you want to display a multiple-column list, enter a value that will make the list box wide enough to show all the columns. When designing combo boxes, be sure to leave enough space to display your data and for Microsoft Access to insert a vertical scroll bar.

Example

The following example returns the value of the ListWidth property for the "States" combo box on the "Order Entry" form.

VBA Copy code Copy code
Dim str As String
str = Forms("Order Entry").Controls("States").ListWidth

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Label.Height Property (Access)

 Copy code hover
[image]

Label.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Syntax

expression .Height

expression A variable that represents a Label object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

Label Object

Other resources

Label Object Members


CodeProject.AllMacros Property (Access)

 Copy code hover
[image]

CodeProject.AllMacros Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllMacros property to reference the AllMacros collection and its related properties. Read-only AllMacros object.

Syntax

expression .AllMacros

expression A variable that represents a CodeProject object.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


CommandButton.GridlineStyleRight Property (Access)

 Copy code hover
[image]

CommandButton.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleRight

expression A variable that represents a CommandButton object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


CommandButton.PressedForeShade Property (Access)

 Copy code hover
[image]

CommandButton.PressedForeShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .PressedForeShade

expression A variable that represents a CommandButton object.

Remarks

The PressedForeShade property contains a numeric expression that can be used to darken the theme color in the PressedForeColor property. The default value of the PressedForeShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


NavigationButton.BackShade Property (Access)

 Copy code hover
[image]

NavigationButton.BackShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackShade

expression A variable that represents a NavigationButton object.

Remarks

The BackShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the BackShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackShade=25

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


CommandButton.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

CommandButton.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents a CommandButton object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.BorderThemeColorIndex=2

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


BoundObjectFrame.GridlineStyleRight Property (Access)

 Copy code hover
[image]

BoundObjectFrame.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified frame. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleRight

expression A variable that represents a BoundObjectFrame object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


XML Persistence Format
Send feedback

XML Persistence Format

ADO uses UTF-8 encoding for the XML stream it persists.

The ADO XML format is broken into two sections, a schema section followed by the data section. The following is an example XML file for the Shippers table from the Northwind database. Various parts of the XML are discussed following the example.

Copy code Copy code

<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:rs="urn:schemas-microsoft-com:rowset"
xmlns:z="#RowsetSchema">
  <s:Schema id="RowsetSchema">
    <s:ElementType name="row" content="eltOnly" rs:updatable="true">
      <s:AttributeType name="ShipperID" rs:number="1"
        rs:basetable="shippers" rs:basecolumn="ShipperID"
        rs:keycolumn="true">
        <s:datatype dt:type="int" dt:maxLength="4" rs:precision="10"
          rs:fixedlength="true" rs:maybenull="false"/>
      </s:AttributeType>
      <s:AttributeType name="CompanyName" rs:number="2"
        rs:nullable="true" rs:write="true" rs:basetable="shippers"
        rs:basecolumn="CompanyName">
        <s:datatype dt:type="string" dt:maxLength="40" />
      </s:AttributeType>
      <s:AttributeType name="Phone" rs:number="3" rs:nullable="true"
        rs:write="true" rs:basetable="shippers"
        rs:basecolumn="Phone">
        <s:datatype dt:type="string" dt:maxLength="24"/>
      </s:AttributeType>
      <s:extends type="rs:rowbase"/>
    </s:ElementType>
  </s:Schema>

  <rs:data>
    <z:row ShipperID="1" CompanyName="Speedy Express"
      Phone="(503) 555-9831"/>
    <z:row ShipperID="2" CompanyName="United Package"
      Phone="(503) 555-3199"/>
    <z:row ShipperID="3" CompanyName="Federal Shipping"
      Phone="(503) 555-9931"/>
  </rs:data>
</xml>

The schema shows the declarations of namespaces, the schema section, and the data section. The schema section contains definitions for row, ShipperID, CompanyName, and Phone.

Schema definitions conform to the XML-Data specification and are able to be fully validated (though validation will not occur in Internet Explorer 5). You can view this specification at W3C XMLData Note. XML-Data is the only supported schema format for Recordset persistence currently.

The data section has three rows containing information about shippers. For an empty rowset, the data section may be empty, but the <rs:data> tags must be present. With no data, you could write the tag shorthand as simply <rs:data/>. Any tag prefixed with "rs" indicates that it is in the namespace defined by urn:schemas-microsoft-com:rowset. The full definition of this schema is defined in the appendix to this document.

XML Persistence Format

ADO uses UTF-8 encoding for the XML stream it persists.

The ADO XML format is broken into two sections, a schema section followed by the data section. The following is an example XML file for the Shippers table from the Northwind database. Various parts of the XML are discussed following the example.

Copy code Copy code

<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:rs="urn:schemas-microsoft-com:rowset"
xmlns:z="#RowsetSchema">
  <s:Schema id="RowsetSchema">
    <s:ElementType name="row" content="eltOnly" rs:updatable="true">
      <s:AttributeType name="ShipperID" rs:number="1"
        rs:basetable="shippers" rs:basecolumn="ShipperID"
        rs:keycolumn="true">
        <s:datatype dt:type="int" dt:maxLength="4" rs:precision="10"
          rs:fixedlength="true" rs:maybenull="false"/>
      </s:AttributeType>
      <s:AttributeType name="CompanyName" rs:number="2"
        rs:nullable="true" rs:write="true" rs:basetable="shippers"
        rs:basecolumn="CompanyName">
        <s:datatype dt:type="string" dt:maxLength="40" />
      </s:AttributeType>
      <s:AttributeType name="Phone" rs:number="3" rs:nullable="true"
        rs:write="true" rs:basetable="shippers"
        rs:basecolumn="Phone">
        <s:datatype dt:type="string" dt:maxLength="24"/>
      </s:AttributeType>
      <s:extends type="rs:rowbase"/>
    </s:ElementType>
  </s:Schema>

  <rs:data>
    <z:row ShipperID="1" CompanyName="Speedy Express"
      Phone="(503) 555-9831"/>
    <z:row ShipperID="2" CompanyName="United Package"
      Phone="(503) 555-3199"/>
    <z:row ShipperID="3" CompanyName="Federal Shipping"
      Phone="(503) 555-9931"/>
  </rs:data>
</xml>

The schema shows the declarations of namespaces, the schema section, and the data section. The schema section contains definitions for row, ShipperID, CompanyName, and Phone.

Schema definitions conform to the XML-Data specification and are able to be fully validated (though validation will not occur in Internet Explorer 5). You can view this specification at W3C XMLData Note. XML-Data is the only supported schema format for Recordset persistence currently.

The data section has three rows containing information about shippers. For an empty rowset, the data section may be empty, but the <rs:data> tags must be present. With no data, you could write the tag shorthand as simply <rs:data/>. Any tag prefixed with "rs" indicates that it is in the namespace defined by urn:schemas-microsoft-com:rowset. The full definition of this schema is defined in the appendix to this document.


AbsolutePosition Property (ADO)

 Copy code hover
[image]

AbsolutePosition Property (ADO)
Send feedback

Indicates the ordinal position of a Recordset object's current record.

Settings and Return Values

Sets or returns a Long value from 1 to the number of records in the Recordset object (RecordCount), or returns one of the PositionEnum values.

Remarks

In order to set the AbsolutePosition property, ADO requires that the OLE DB provider you are using implement the IRowsetLocate interface.

Accessing the AbsolutePosition property of a Recordset that was opened with either a forward-only or dynamic cursor raises the error adErrFeatureNotAvailable. With other cursor types, the correct position will be returned as long as the provider supports the IRowsetScroll interface. If the provider does not support the IRowsetScroll interface, the property is set to adPosUnknown. See the documentation for your provider to determine whether it supports IRowsetScroll.

Use the AbsolutePosition property to move to a record based on its ordinal position in the Recordset object, or to determine the ordinal position of the current record. The provider must support the appropriate functionality for this property to be available.

Like the AbsolutePage property, AbsolutePosition is 1-based and equals 1 when the current record is the first record in the Recordset. You can obtain the total number of records in the Recordset object from the RecordCount property.

When you set the AbsolutePosition property, even if it is to a record in the current cache, ADO reloads the cache with a new group of records starting with the record you specified. The CacheSize property determines the size of this group.

Note Note

You should not use the AbsolutePosition property as a surrogate record number. The position of a given record changes when you delete a preceding record. There is also no assurance that a given record will have the same AbsolutePosition if the Recordset object is requeried or reopened. Bookmarks are still the recommended way of retaining and returning to a given position and are the only way of positioning across all types of Recordset objects.


Cannot perform cascading operation. It would result in a null key in table

 Copy code hover
[image]

Cannot perform cascading operation. It would result in a null key in table <name>. (Error 3398)
Send feedback

The cascade operation you are attempting would result in a Null value in a primary key field in the indicated table, which has been set up not to allow Null values. Check the values you are attempting to update and fix them so they do not result in Null values.


NavigationControl.Exit Event (Access)

 Copy code hover
[image]

NavigationControl.Exit Event (Access)
See also Send feedback

Published: July 16, 2012

The Exit event occurs just before a control loses the focus to another control on the same form or report.

Version Information

Version Added: Access 2010

Syntax

expression .Exit(Cancel, )

expression A variable that represents a NavigationControl object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer |

Return Value

nothing

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when this event occurs, set the OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Exit event occurs before the LostFocus event.

Unlike the LostFocus event, the Exit event does not occur when a form loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


SetMenuItem Macro Action

 Copy code hover
[image]

SetMenuItem Macro Action
Send feedback

You can use the SetMenuItem action to set the state of menu items (enabled or disabled, selected or unselected) on custom or global menus on the Add-Ins tab.

Note Note

The SetMenuItem action works only with custom and global menus created by using menu macros. The SetMenuItem action is included in Microsoft Access only for compatibility with previous versions. It does not work with the command bar functionality. However, you can use the Enabled and State properties in a Visual Basic for Applications (VBA) module to disable or enable and select or unselect items on shortcut menus or custom or global menus.

Setting

The SetMenuItem action has the following arguments.

Action argument | Description
Menu Index | The index of the menu that contains the command for which you want to set the state. Enter an integer value, starting from 0, for the index of the desired menu in the custom or global menu. Enter the index value in the Menu Index box in the Action Arguments section of the Macro Builder pane. The index is relative to the menu's position in the menu macro for the custom or global menu (the position of this menu's AddMenu action in the menu macro, counting from 0). The menu's display may be somewhat different, because you can use conditional expressions in the menu macro to hide or display custom menu items. This is a required argument. If you select a menu with this argument and leave the Command Index and Subcommand Index arguments blank, you can enable or disable the menu name itself. You cannot, however, select or unselect a menu name (Access ignores the Check and Uncheck settings for the Flag argument for menu names).
Command Index | The index of the command for which you want to set the state. Enter an integer value, starting from 0, for the index of the desired command in the menu selected by the Menu Index argument. The index is relative to the command's position in the macro group that defines the selected menu for the custom or global menu (the position of this command's macro in the macro group, counting from 0). The menu's display may be somewhat different, because you can use conditional expressions in the menu's macro group to hide or display custom menu commands.
Subcommand Index | The index of the subcommand for which you want to set the state. This applies only if the desired command has a submenu. Enter an integer value, starting from 0, for the index of the desired subcommand in the submenu selected by the Command Index argument. The index is relative to the subcommand's position in the macro group that defines the selected submenu for the custom or global menu (the position of this subcommand's macro in the macro group, counting from 0).
Flag | The state you want to set the command or subcommand to. Click Gray (to disable the command — it appears dimmed), Ungray (to enable it), Check (to place a check by the command — typically indicating it has been selected or toggled), or Uncheck (to remove the check). The default is Ungray.

Remarks

The SetMenuItem action works only on a custom or global menu. If the active window does not have a custom or global menu, running a macro containing the SetMenuItem action causes a run-time error.

You can use this action to set the state of menu commands and subcommands, but not subcommands of subcommands.

To run the SetMenuItem action in a Visual Basic for Applications (VBA) module, use the SetMenuItem method of the DoCmd object.


BoundObjectFrame.Object Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Object Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Object property in Visual Basic to return a reference to the ActiveX object that is associated with a linked or embedded OLE object in a control. By using this reference, you can access the properties or invoke the methods of the OLE object. Read-only Object.

Syntax

expression .Object

expression A variable that represents a BoundObjectFrame object.

Remarks

The Object property returns a reference to an ActiveX object. You can use the Set statement to assign this ActiveX object to an object variable. The type of object reference returned depends on which application created the OLE object.

When you embed or link an OLE object in a Microsoft Access form, you can set properties that determine the type of object and the behavior of the container control. However, you can't directly set or read the OLE object's properties or apply its methods, as you can when performing Automation. The Object property returns a reference to an Automation object that represents the linked or embedded OLE object. By using this reference, you can change the OLE object by setting or reading its properties or applying its methods. For example, Microsoft Excel is an COM component that supports Automation. If you've embedded a Microsoft Excel worksheet in a Microsoft Access form, you can use the Object property to set a reference to the Worksheet object associated with that worksheet. You can then use any of the properties and methods of the Worksheet object.

For information on which properties and methods an ActiveX object supports, see the documentation for the application that was used to create the OLE object.

Example

The following example uses the Object property of an unbound object frame named OLE1. Customer name and address information is inserted in an embedded Microsoft Word document formatted as a form letter with placeholders for the name and address information and boilerplate text in the body of the letter. The procedure replaces the placeholder information for each record and prints the form letter. It doesn't save copies of the printed form letter.

VBA Copy code Copy code
Sub PrintFormLetter_Click()
 Dim objWord As Object
 Dim strCustomer As String, strAddress As String
 Dim strCity As String, strRegion As String

 ' Assign object property of control to variable.
 Set objWord = Me!OLE1.Object.Application.Wordbasic
 ' Assign customer address to variables.
 strCustomer = Me!CompanyName
 strAddress = Me!Address
 strCity = Me!City & ", "
 If Not IsNull(Me!Region) Then
 strRegion = Me!Region
 Else
 strRegion = Me!Country
 End If
 ' Activate ActiveX control.
 Me!OLE1.Action = acOLEActivate
 With objWord
 .StartOfDocument
 ' Go to first placeholder.
 .LineDown 2
 ' Highlight placeholder text.
 .EndOfLine 1
 ' Insert customer name.
 .Insert strCustomer
 ' Go to next placeholder.
 .LineDown
 .StartOfLine
 ' Highlight placeholder text.
 .EndOfLine 1
 ' Insert address.
 .Insert strAddress
 ' Go to last placeholder.
 .LineDown
 .StartOfLine
 ' Highlight placeholder text.
 .EndOfLine 1
 ' Insert City and Region.
 .Insert strCity & strRegion
 .FilePrint
 .FileClose
 End With
 Set objWord = Nothing
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Table

 Copy code hover
[image]

Table <name> is exclusively locked by user <name> on machine <name>. (Error 3261)
Send feedback

You tried to use a table that is currently open for exclusive access by the specified user. Wait for the other user to finish working with the table, and then try the operation again.


Attachment.PictureAlignment Property (Access)

 Copy code hover
[image]

Attachment.PictureAlignment Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureAlignment property to specify where a background picture will appear in the Attachment control. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .PictureAlignment

expression A variable that represents an Attachment object.

Remarks

The PictureAlignment property uses the following settings.

Setting | Visual Basic | Description
Top Left | 0 | The picture is displayed in the top-left corner of the control.
Top Right | 1 | The picture is displayed in the top-right corner of the control.
Center | 2 | (Default) The picture is centered in the control.
Bottom Left | 3 | The picture is displayed in the bottom-left corner of the control.
Bottom Right | 4 | The picture is displayed in the bottom-right corner of the control.

You can also set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

This property can be set in any view.

When you set the PictureTiling property to Yes, tiling of the picture will begin from the PictureAlignment property setting.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


SQL Specific Query

 Copy code hover
[image]

SQL Specific Query
Send feedback

Published: July 16, 2012

An SQL specific query is one that can be created only by writing an SQL statement in SQL view. Union, pass-through, and data definition queries are SQL specific queries.

SQL specific query type | Description
Union | An SQL specific select query that combines corresponding fields from two or more tables or queries into one field. For example, a union query of the Customers table and the Suppliers table results in a snapshot that contains all the specified records from both the Customers table and the Suppliers table.
Pass-Through | An SQL specific query that sends commands directly to an SQL database server (such as Microsoft SQL Server). With pass-through queries, you work with the tables on the server instead of linking the tables to your Microsoft Access database.
Data Definition | An SQL specific query that can create or delete an index, or create, alter, or delete a table.


RestoreWindow Macro Action

 Copy code hover
[image]

RestoreWindow Macro Action
Send feedback

You can use the RestoreWindow action to restore a maximized or minimized window to its previous size.

Note Note

This action can't be applied to code windows in the Visual Basic Editor. For information about how to affect code windows, see the WindowState property topic.

Setting

The RestoreWindow action doesn't have any arguments.

Remarks

This action works on the selected object. If an object has been minimized, you can first select it by using the SelectObject action and then restore it to its previous size by using the RestoreWindow action.

You can use the MoveAndSizeWindow action to move or size a window that you have restored.

The RestoreWindow action has the same effect as clicking the Restore button in the window's upper-right corner or clicking the Restore command on the window's Control menu.

To run the RestoreWindow action in a Visual Basic for Applications (VBA) module, use the Restore method of the DoCmd object.


DataType Property

 Copy code hover
[image]

DataType Property
Send feedback

Published: July 16, 2012

You can use the DataType property to specify the type of data stored in a table field. Each field can store data consisting of only a single data type.

Setting

The DataType property uses the following settings.

Setting | Type of data | Size
Text | (Default) Text or combinations of text and numbers, as well as numbers that don't require calculations, such as phone numbers. | Up to 255 characters or the length set by the FieldSize property, whichever is less. Microsoft Access does not reserve space for unused portions of a text field.
Memo | Lengthy text or combinations of text and numbers. | Up to 63,999 characters. (If the Memo field is manipulated through DAO and only text and numbers [not binary data] will be stored in it, then the size of the Memo field is limited by the size of the database.)
Number | Numeric data used in mathematical calculations. For more information on how to set the specific Number type, see the FieldSize property topic. | 1, 2, 4, or 8 bytes (16 bytes if the FieldSize property is set to Replication ID).
Date/Time | Date and time values for the years 100 through 9999. | 8 bytes.
Currency | Currency values and numeric data used in mathematical calculations involving data with one to four decimal places. Accurate to 15 digits on the left side of the decimal separator and to 4 digits on the right side. | 8 bytes.
AutoNumber | A unique sequential (incremented by 1) number or random number assigned by Microsoft Access whenever a new record is added to a table. AutoNumber fields can't be updated. For more information, see the NewValues property topic. | 4 bytes (16 bytes if the FieldSize property is set to Replication ID).
Yes/No | Yes and No values and fields that contain only one of two values (Yes/No, True/False, or On/Off). | 1 bit.
OLE Object | An object (such as a Microsoft Excel spreadsheet, a Microsoft Word document, graphics, sounds, or other binary data) linked to or embedded in a Microsoft Access table. | Up to 1 gigabyte (limited by available disk space)
Hyperlink | Text or combinations of text and numbers stored as text and used as a hyperlink address. A hyperlink address can have up to four parts: text to display — the text that appears in a field or control. address — the path to a file (UNC path) or page (URL). subaddress — a location within the file or page. screentip — the text displayed as a tooltip. | Each part of the parts of a Hyperlink data type can contain up to 2048 characters.
Attachment | Any supported type of file | You can attach images, spreadsheet files, documents, charts, and other types of supported files to the records in your database, much like you attach files to e-mail messages. You can also view and edit attached files, depending on how the database designer sets up the Attachment field. Attachment fields provide greater flexibility than OLE Object fields, and they use storage space more efficiently because they don't create a bitmap image of the original file.
Lookup Wizard | Creates a field that allows you to choose a value from another table or from a list of values by using a list box or combo box. Clicking this option starts the Lookup Wizard, which creates a Lookup field. After you complete the wizard, Microsoft Access sets the data type based on the values selected in the wizard. | The same size as the primary key field used to perform the lookup, typically 4 bytes.

You can set this property only in the upper portion of table Design view.

In Visual Basic , you can use the ADO Type property to set a field's data type before appending it to the Fields collection.

Remarks

Memo, Hyperlink, and OLE Object fields can't be indexed.

Tip Tip

Use the Currency data type for a field requiring many calculations involving data with one to four decimal places. Single and Double data type fields require floating-point calculation. The Currency data type uses a faster fixed-point calculation.

Caution note Caution

Changing a field's data type after you enter data in a table causes a potentially lengthy process of data conversion when you save the table. If the data type in a field conflicts with a changed DataType property setting, you may lose some data.

Set the Format property to specify a predefined display format for Number, Date/Time, Currency, and Yes/No data types.


Printing

 Copy code hover
[image]

Printing
Send feedback

In this section

  • How to: Programmatically Retrieve Printer Capabilities

  • How to: Work with Form and Report Printer Settings


How to: Display a Custom Dialog Box When the User Deletes a Record

 Copy code hover
[image]

How to: Display a Custom Dialog Box When the User Deletes a Record
Send feedback

When you select a record on a form and delete it, Access displays a dialog box asking the user to confirm the deletion of the record. If you want, you can prevent this dialog box from appearing in two ways. You can cancel the BeforeDelConfirm event, in which case the deletion is canceled. Or you can set the Response argument of the BeforeDelConfirm event procedure to acDataErrContinue, in which case the deletion is confirmed.

You can use a BeforeDelConfirm event procedure to display a custom dialog box and handle users' responses. The following example demonstrates how to use a custom dialog box to ask users whether they want to cancel or proceed with the record deletion.

VBA Copy code Copy code
Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)

   Dim strMessage As String
   Dim intResponse As Integer

On Error GoTo ErrorHandler

   ' Display the custom dialog box.
   strMessage = "Would you like to delete the current record?"
   intResponse = MsgBox(strMessage, vbYesNo + vbQuestion, _
               "Continue delete?")

   ' Check the response.
   If intResponse = vbYes Then
      Response = acDataErrContinue
   Else
      Cancel = True
   End If

   Exit Sub

ErrorHandler:
   MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Sub


ImportExportSpecifications.Application Property (Access)

 Copy code hover
[image]

ImportExportSpecifications.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents an ImportExportSpecifications object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

ImportExportSpecifications Collection

Other resources

ImportExportSpecifications Object Members


NavigationControl.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

NavigationControl.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthBottom

expression A variable that represents a NavigationControl object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


NavigationButton.Name Property (Access)

 Copy code hover
[image]

NavigationButton.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .Name

expression A variable that represents a NavigationButton object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Image.ImageWidth Property (Access)

 Copy code hover
[image]

Image.ImageWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ImageWidth property to determine the width in twips of a picture in an image control. Read/write Long.

Syntax

expression .ImageWidth

expression A variable that represents an Image object.

Remarks

This property is read-only in all views.

You can use the ImageWidth property together with the ImageHeight property to determine the size of a picture in an image control. You could then use this information to change the image control's Height and Width properties to match the size of the picture displayed.

Example

The following example prompts the user to enter the name of a bitmap and then assigns that bitmap to the Picture property of the Image1 image control. The ImageHeight and ImageWidth properties are used to resize the image control to fit the size of the bitmap.

See also

Concepts

Image Object

Other resources

Image Object Members


Using Pages

 Copy code hover
[image]

Using Pages
Send feedback

Use the PageCount property to determine how many pages of data are in the Recordset object. Pages are groups of records whose size equals the PageSize property setting. Even if the last page is incomplete because there are fewer records than the PageSize value, it counts as an additional page in the PageCount value. If the Recordset object does not support this property, PageCount will be -1 to indicate that the PageCount is indeterminable.

Use the PageSize property to determine how many records make up a logical page of data. Establishing a page size allows you to use the AbsolutePage property to move to the first record of a particular page. This is useful in Web-server scenarios when you want to allow the user to page through data, viewing a certain number of records at a time.

This property can be set at any time, and its value will be used for calculating the location of the first record of a particular page.

Use the AbsolutePage property to identify the page number on which the current record is located. Again, the provider must support the appropriate functionality for this property to be available.

AbsolutePage is 1-based and equals 1 when the current record is the first record in the Recordset. Set this property to move to the first record of a particular page. Obtain the total number of pages from the PageCount property.


Failed to write to the dropbox folder. (Error 3513)

 Copy code hover
[image]

Failed to write to the dropbox folder. (Error 3513)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


BoundObjectFrame.ObjectVerbsCount Property (Access)

 Copy code hover
[image]

BoundObjectFrame.ObjectVerbsCount Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ObjectVerbsCount property in Visual Basic to determine the number of verbs supported by an OLE object. Read-only Long.

Syntax

expression .ObjectVerbsCount

expression A variable that represents a BoundObjectFrame object.

Remarks

The ObjectVerbsCount property setting is a value that specifies the number of elements in the ObjectVerbs property array.

This property setting isn't available in Design view.

The list of verbs an OLE object supports may vary, depending on the state of the object. To update the list of supported verbs, set the control'sAction property to acOLEFetchVerbs.

Example

The following example returns the verbs supported by the OLE object in the OLE1 control and displays each verb in a message box.

VBA Copy code Copy code
Sub GetVerbList(frm As Form, OLE1 As Control)
 Dim intX As Integer, intNumVerbs As Integer
 Dim strVerbList As String

 ' Update verb list.
 With frm!OLE1
 .Action = acOLEFetchVerbs
 intNumVerbs = .ObjectVerbsCount
 For intX = 0 To intNumVerbs - 1
 strVerbList = strVerbList & .ObjectVerbs(intX) & "; "
 Next intX
 End With

 ' Display verbs in message box.
 MsgBox Left(strVerbList, Len(strVerbList) - 2)
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


DoCmd.Echo Method (Access)

 Copy code hover
[image]

DoCmd.Echo Method (Access)
See also Send feedback

Published: July 16, 2012

Carries out the Echo action in Visual Basic.

Syntax

expression .Echo(EchoOn, StatusBarText)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
EchoOn | Required | Variant | Use True to turn echo on and False to turn it off.
StatusBarText | Optional | Variant | A string expression indicating the text that appears in the status bar.

Remarks

If you leave the StatusBarText argument blank, do not use a comma following the echoon argument.

If you turn echo off in Visual Basic, you must turn it back on or it will remain off, even if the user presses CTRL+BREAK or if Visual Basic encounters a breakpoint. You may want to create a macro that turns echo on and then assign that macro to a key combination or a custom menu command. You could then use the key combination or menu command to turn echo on if it has been turned off in Visual Basic.

The Echo method of the DoCmd object was added to provide backward compatibility for running the Echo action in Visual Basic code in Microsoft Access for Windows 95. It is recommended that you use the existing Echo method of the Application object instead.

Note Note

The Echo method does not affect the visibility of the ribbon or the availability of ribbon commands.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


CursorLocationEnum

 Copy code hover
[image]

CursorLocationEnum
Send feedback

Specifies the location of the cursor service.

Constant | Value | Description
adUseClient | 3 | Uses client-side cursors supplied by a local cursor library. Local cursor services often will allow many features that driver-supplied cursors may not, so using this setting may provide an advantage with respect to features that will be enabled. For backward compatibility, the synonym adUseClientBatch is also supported.
adUseNone | 1 | Does not use cursor services. (This constant is obsolete and appears solely for the sake of backward compatibility.)
adUseServer | 2 | Default. Uses data-provider or driver-supplied cursors. These cursors are sometimes very flexible and allow for additional sensitivity to changes others make to the data source. However, some features of the Microsoft Cursor Service for OLE DB (such as disassociated Recordset objects) cannot be simulated with server-side cursors and these features will be unavailable with this setting.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.CursorLocation.CLIENT

AdoEnums.CursorLocation.NONE

AdoEnums.CursorLocation.SERVER


OptionGroup.BorderWidth Property (Access)

 Copy code hover
[image]

OptionGroup.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Syntax

expression .BorderWidth

expression A variable that represents an OptionGroup object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


ObjectFrame.OnClick Property (Access)

 Copy code hover
[image]

ObjectFrame.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Syntax

expression .OnClick

expression A variable that represents an ObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Recordset2.Sort Property (DAO)

 Copy code hover
[image]

Recordset2.Sort Property (DAO)
Send feedback

Sets or returns the sort order for records in a Recordset object (Microsoft Access workspaces only).

Syntax

expression .Sort

expression A variable that represents a Recordset2 object.

Remarks

You can use the Sort property with dynaset- and snapshot-type Recordset objects.

When you set this property for an object, sorting occurs when a subsequent Recordset object is created from that object. The Sort property setting overrides any sort order specified for a QueryDef object.

The default sort order is ascending (A to Z or 0 to 100).

The Sort property doesn't apply to table- or forward-only-type Recordset objects. To sort a table-type Recordset object, use the Index property.

Note Note

In many cases, it's faster to open a new Recordset object by using an SQL statement that includes the sorting criteria.

Example

This example demonstrates the Sort property by changing its value and creating a new Recordset. The SortOutput function is required for this procedure to run.

VBA Copy code Copy code
Sub SortX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset2
 Dim rstSortEmployees As Recordset2

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", _
 dbOpenDynaset)

 With rstEmployees
 SortOutput "Original Recordset:", rstEmployees
 .Sort = "LastName, FirstName"
 ' Print report showing Sort property and record order.
 SortOutput _
 "Recordset after changing Sort property:", _
 rstEmployees
 ' Open new Recordset from current one.
 Set rstSortEmployees = .OpenRecordset
 ' Print report showing Sort property and record order.
 SortOutput "New Recordset:", rstSortEmployees
 rstSortEmployees.Close
 .Close
 End With

 dbsNorthwind.Close

End Sub

Function SortOutput(strTemp As String, _
 rstTemp As Recordset)

 With rstTemp
 Debug.Print strTemp
 Debug.Print " Sort = " & _
 IIf(.Sort <> "", .Sort, "[Empty]")
 .MoveFirst

 ' Enumerate Recordset.
 Do While Not .EOF
 Debug.Print " " & !LastName & _
 ", " & !FirstName
 .MoveNext
 Loop

 End With

End Function

When you know the data you want to select, it's usually more efficient to create a Recordset with an SQL statement. This example shows how you can create just one Recordset and obtain the same results as in the preceding example.

VBA Copy code Copy code
Sub SortX2()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 ' Open a Recordset from an SQL statement that specifies a
 ' sort order.
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("SELECT * " & _
 "FROM Employees ORDER BY LastName, FirstName", _
 dbOpenDynaset)

 dbsNorthwind.Close

End Sub


Source Property (ADO Recordset)

 Copy code hover
[image]

Source Property (ADO Recordset)
Send feedback

Indicates the data source for a Recordset object.

Settings and Return Values

Sets a String value or Command object reference; returns only a String value that indicates the source of the Recordset.

Remarks

Use the Source property to specify a data source for a Recordset object using one of the following: a Command object variable, an SQL statement, a stored procedure, or a table name.

If you set the Source property to a Command object, the ActiveConnection property of the Recordset object will inherit the value of the ActiveConnection property for the specified Command object. However, reading the Source property does not return a Command object; instead, it returns the CommandText property of the Command object to which you set the Source property.

If the Source property is an SQL statement, a stored procedure, or a table name, you can optimize performance by passing the appropriate Options argument with the Open method call.

The Source property is read/write for closed Recordset objects and read-only for open Recordset objects.


Operation not supported on replicable databases that have not been converted to the current version. (Error 3703)

 Copy code hover
[image]

Operation not supported on replicable databases that have not been converted to the current version. (Error 3703)
Send feedback

This replica was created with a previous version of Microsoft Jet. To execute any replication operations you must first compact/convert your replica set.


TabControl.Move Method (Access)

 Copy code hover
[image]

TabControl.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a TabControl object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


ImportExportSpreadsheet Macro Action

 Copy code hover
[image]

ImportExportSpreadsheet Macro Action
Send feedback

You can use the ImportExportSpreadsheet action to import or export data between the current Access database (.mdb or .accdb) or Access project (.adp) and a spreadsheet file. You can also link the data in a Microsoft Excel spreadsheet to the current Microsoft Access database. With a linked spreadsheet, you can view and edit the spreadsheet data with Access while still allowing complete access to the data from your Excel spreadsheet program. You can also link to data in a Lotus 1-2-3 spreadsheet file, but this data is read-only in Access.

Note 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.

Setting

The TransferSpreadsheet action has the following arguments.

Action argument

Description

Transfer Type

The type of transfer you want to make. Select Import, Export, or Link in the Transfer Type box in the Action Arguments section of the Macro Builder pane. The default is Import.

Note Note

The Link transfer type is not supported for Access projects (.adp).

Spreadsheet Type

The type of spreadsheet to import from, export to, or link to. You can select one of a number of spreadsheet types in the box. The default is Excel Workbook.

Note Note

You can import from and link (read-only) to Lotus .WK4 files, but you can't export Access data to this spreadsheet format. Access also no longer supports importing, exporting, or linking data from Lotus .WKS or Excel version 2.0 spreadsheets with this action. If you want to import from or link to spreadsheet data in Excel version 2.0 or Lotus .WKS format, convert the spreadsheet data to a later version of Excel or Lotus 1-2-3 before importing or linking the data into Access.

Table Name

The name of the Access table to import spreadsheet data to, export spreadsheet data from, or link spreadsheet data to. You can also type the name of the Access select query you want to export data from. This is a required argument. If you select Import in the Transfer Type argument, Access appends the spreadsheet data to this table if the table already exists. Otherwise, Access creates a new table containing the spreadsheet data. In Access, you can't use an SQL statement to specify data to export when you are using the ImportExportSpreadsheet action. Instead of using an SQL statement, you must first create a query and then specify the name of the query in the Table Name argument.

File Name

The name of the spreadsheet file to import from, export to, or link to. Include the full path. This is a required argument. Access creates a new spreadsheet when you export data from Access. If the file name is the same as the name of an existing spreadsheet, Access replaces the existing spreadsheet, unless you're exporting to an Excel version 5.0 or later workbook. In that case, Access copies the exported data to the next available new worksheet in the workbook. If you are importing from or linking to an Excel version 5.0 or later spreadsheet, you can specify a particular worksheet by using the Range argument.

Has Field Names

Specifies whether the first row of the spreadsheet contains the names of the fields. If you select Yes, Access uses the names in this row as field names in the Access table when you import or link the spreadsheet data. If you select No, Access treats the first row as a normal row of data. The default is No. When you export an Access table or select query to a spreadsheet, the field names are inserted into the first row of the spreadsheet no matter what you select in this argument.

Range

The range of cells to import or link. Leave this argument blank to import or link the entire spreadsheet. You can type the name of a range in the spreadsheet or specify the range of cells to import or link, such as A1:E25 (note that the A1..E25 syntax does not work in Access 97 or later). If you are importing from or linking to an Excel version 5.0 or later spreadsheet, you can prefix the range with the name of the worksheet and an exclamation point; for example, Budget!A1:C7.

Note Note

When you export to a spreadsheet, you must leave this argument blank. If you enter a range, the export will fail.

Remarks

You can export the data in Access select queries to spreadsheets. Access exports the result set of the query, treating it just like a table.

Spreadsheet data that you append to an existing Access table must be compatible with the table's structure.

  • Each field in the spreadsheet must be of the same data type as the corresponding field in the table.

  • The fields must be in the same order (unless you set the Has Field Names argument to Yes, in which case the field names in the spreadsheet must match the field names in the table).

This action is similar to clicking the External Data tab and clicking Excel in the Import or Export group, or clicking More in the Import or Export group and clicking Lotus 1-2-3 File. You can use these commands to select a source of data, such as Access or a type of database, spreadsheet, or text file. If you select a spreadsheet, a series of dialog boxes appear, or an Access wizard runs, in which you select the name of the spreadsheet and other options. The arguments of the ImportExportSpreadsheet action reflect the options in these dialog boxes or in the wizards.

Note Note

If you query or filter a linked spreadsheet, the query or filter is case-sensitive.

If you link to an Excel spreadsheet that is open in Edit mode, Access will wait until the Excel spreadsheet is out of Edit mode before completing the link; there's no time-out.

To run the ImportExportSpreadsheet action in a Visual Basic for Applications (VBA) module, use the TransferSpreadsheet method of the DoCmd object.


BoundObjectFrame.OnKeyUp Property (Access)

 Copy code hover
[image]

BoundObjectFrame.OnKeyUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Up box in the Properties window. Read/write String.

Syntax

expression .OnKeyUp

expression A variable that represents a BoundObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyUp event occurs when a user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyUp

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Application.StringFromGUID Method (Access)

 Copy code hover
[image]

Application.StringFromGUID Method (Access)
See also Send feedback

Published: July 16, 2012

The StringFromGUID function converts a GUID, which is an array of type Byte, to a string.

Syntax

expression .StringFromGUID(Guid)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Guid | Required | Variant | An array of Byte data used to uniquely identify an application, component, or item of data to the operating system.

Return Value

Variant

Remarks

The Microsoft Access database engine stores GUIDs as arrays of type Byte. However, Microsoft Access can't return Byte data from a control on a form or report. In order to return the value of a GUID from a control, you must convert it to a string. To convert a GUID to a string, use the StringFromGUID function. To convert a string back to a GUID, use the GUIDFromString function.

For example, you may need to refer to a field that contains a GUID when using database replication. To return the value of a control on a form bound to a field that contains a GUID, use the StringFromGUID function to convert the GUID to a string.

Example

The following example returns the value of the s_GUID control on an Employees form in string form and assigns it to a string variable. The s_GUID control is bound to the s_GUID field, one of the system fields added to each replicated table in a replicated database.

VBA Copy code Copy code
Public Sub StringValueOfGUID()

 Dim ctl As Control
 Dim strGUID As String

 ' Get the GUID.
 Set ctl = Forms!Employees!s_GUID
 Debug.Print TypeName(ctl.Value)

 ' Convert the GUID to a string.
 strGUID = StringFromGUID(ctl.Value)
 Debug.Print TypeName(strGUID)

End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


Report.Close Event (Access)

 Copy code hover
[image]

Report.Close Event (Access)
See also Send feedback

Published: July 16, 2012

The Close event occurs when a report is closed and removed from the screen.

Syntax

expression .Close

expression A variable that represents a Report object.

Remarks

To run a macro or event procedure when this event occurs, set the OnClose property to the name of the macro or to [Event Procedure].

See also

Concepts

Report Object

Other resources

Report Object Members


AllTables Object (Access)

 Copy code hover
[image]

AllTables Object (Access)
See also Send feedback

Published: July 16, 2012

The AllTables collection contains an AccessObject for each table in the CurrentData or CodeData object.

Remarks

The CurrentData or CodeData object has an AllTables collection containing AccessObject objects that describe instances of all tables specified by CurrentData or CodeData. For example, you can enumerate the AllTables collection in Visual Basic to set or return the values of properties of individual AccessObject objects in the collection.

You can refer to an individual AccessObject object in the AllTables collection either by referring to the object by name, or by referring to its index within the collection. If you want to refer to a specific object in the AllTables collection, it's better to refer to the table by name because a table's collection index may change.

The AllTables collection is indexed beginning with zero. If you refer to a table by its index, the first table is AllTables(0), the second table is AllTables(1), and so on.

Note Note

To list all open tables in the database, use the IsLoaded property of each AccessObject object in the AllTables collection. You can then use the Name property of each individual AccessObject object to return the name of a table.

You can't add or delete an AccessObject object from the AllTables collection.

Example

The following example prints the name of each open AccessObject object in the AllTables collection.

VBA Copy code Copy code
Sub AllTables()
 Dim obj As AccessObject, dbs As Object
 Set dbs = Application.CurrentData
 ' Search for open AccessObject objects in AllTables collection.
 For Each obj In dbs.AllTables
 If obj.IsLoaded = True Then
 ' Print name of obj.
 Debug.Print obj.Name
 End If
 Next obj
End Sub

See also

Concepts

Access Object Model Reference

Other resources

AllTables Object Members


Controls.Count Property (Access)

 Copy code hover
[image]

Controls.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents a Controls object.

Example

The following example uses the Count property to control a loop that prints information about all open forms and their controls.

VBA Copy code Copy code
Sub Print_Form_Controls()
 Dim frm As Form, intI As Integer
 Dim intJ As Integer
 Dim intControls As Integer, intForms As Integer
 intForms = Forms.Count ' Number of open forms.
 If intForms > 0 Then
 For intI = 0 To intForms - 1
 Set frm = Forms(intI)
 Debug.Print frm.Name
 intControls = frm.Count
 If intControls > 0 Then
 For intJ = 0 To intControls - 1
 Debug.Print vbTab; frm(intJ).Name
 Next intJ
 Else
 Debug.Print vbTab; "(no controls)"
 End If
 Next intI
 Else
 MsgBox "No open forms.", vbExclamation, "Form Controls"
 End If
End Sub

See also

Concepts

Controls Collection

Other resources

Controls Object Members


How to: Track Design Changes to a Table-Type DAO Recordset

 Copy code hover
[image]

How to: Track Design Changes to a Table-Type DAO Recordset
Send feedback

You may need to determine when the underlying TableDef object of a table-type Recordset was created, or the last time it was modified. The DateCreated and LastUpdated properties, respectively, give you this information. Both properties return the date stamp applied to the table by the machine on which the table resided at the time it was stamped. These properties are updated only when the table's design changes; they are not affected by changes to records in the table.

The following code example shows the DateCreated and LastUpdated properties by adding a new Field to an existing TableDef and by creating a new TableDef. The DateOutput function is required for this procedure to run.

VBA Copy code Copy code
Sub DateCreatedX()

   Dim dbsNorthwind As Database
   Dim tdfEmployees As TableDef
   Dim tdfNewTable As TableDef

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   With dbsNorthwind
      Set tdfEmployees = .TableDefs!Employees

      With tdfEmployees
         ' Print current information about the Employees
         ' table.
         DateOutput "Current properties", tdfEmployees

         ' Create and append a field to the Employees table.
         .Fields.Append .CreateField("NewField", dbDate)

         ' Print new information about the Employees
         ' table.
         DateOutput "After creating a new field", _
            tdfEmployees

         ' Delete new Field because this is a demonstration.
         .Fields.Delete "NewField"
      End With

      ' Create and append a new TableDef object to the
      ' Northwind database.
      Set tdfNewTable = .CreateTableDef("NewTableDef")
      With tdfNewTable
         .Fields.Append .CreateField("NewField", dbDate)
      End With
      .TableDefs.Append tdfNewTable

      ' Print information about the new TableDef object.
      DateOutput "After creating a new table", tdfNewTable

      ' Delete new TableDef object because this is a
      ' demonstration.
      .TableDefs.Delete tdfNewTable.Name
      .Close
   End With

End Sub

Function DateOutput(strTemp As String, _
   tdfTemp As TableDef)

   ' Print DateCreated and LastUpdated information about
   ' specified TableDef object.
   Debug.Print strTemp
   Debug.Print "  TableDef: " & tdfTemp.Name
   Debug.Print "    DateCreated = " & _
      tdfTemp.DateCreated
   Debug.Print "    LastUpdated = " & _
      tdfTemp.LastUpdated
   Debug.Print

End Function


Field2.AppendChunk Method (DAO)

 Copy code hover
[image]

Field2.AppendChunk Method (DAO)
Send feedback

Appends data from a string expression to a Memo or Long Binary Field2 object in a Recordset.

Syntax

expression .AppendChunk(Val)

expression A variable that represents a Field2 object.

Parameters

Name | Required/Optional | Data Type | Description
Val | Required | Variant | A Variant (String subtype) expression or variable containing the data you want to append to the Field2 object.

Remarks

You can use the AppendChunk and GetChunk methods to access subsets of data in a Memo or Long Binary field.

You can also use these methods to conserve string space when you work with Memo and Long Binary fields. Certain operations (copying, for example) involve temporary strings. If string space is limited, you may need to work with chunks of a field instead of the entire field.

If there is no current record when you use AppendChunk, an error occurs.

Note Note

The initial AppendChunk operation (after an Edit or AddNew call) will simply place the data in the field, overwriting any existing data. Subsequent AppendChunk calls within the same Edit or AddNew session will then add to the existing data.

Example

This example uses the AppendChunk and GetChunk methods to fill an OLE object field with data from another record, 32K at a time. In a real application, one might use a procedure like this to copy an employee record (including the employee's photo) from one table to another. In this example, the record is simply being copied back to same table. Note that all the chunk manipulation takes place within a single AddNew-Update sequence.

Copy code Copy code
Sub AppendChunkX()

   Dim dbsNorthwind As Database
   Dim rstEmployees As Recordset
   Dim rstEmployees2 As Recordset

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   ' Open two recordsets from the Employees table.
   Set rstEmployees = _
      dbsNorthwind.OpenRecordset("Employees", _
      dbOpenDynaset)
   Set rstEmployees2 = rstEmployees.Clone

   ' Add a new record to the first Recordset and copy the
   ' data from a record in the second Recordset.
   With rstEmployees
      .AddNew
      !FirstName = rstEmployees2!FirstName
      !LastName = rstEmployees2!LastName
      CopyLargeField rstEmployees2!Photo, !Photo
      .Update

      ' Delete new record because this is a demonstration.
      .Bookmark = .LastModified
      .Delete
      .Close
   End With

   rstEmployees2.Close
   dbsNorthwind.Close

End Sub

Function CopyLargeField(fldSource As Field2, _
   fldDestination As Field2)

   ' Set size of chunk in bytes.
   Const conChunkSize = 32768

   Dim lngOffset As Long
   Dim lngTotalSize As Long
   Dim strChunk As String

   ' Copy the photo from one Recordset to the other in 32K
   ' chunks until the entire field is copied.
   lngTotalSize = fldSource.FieldSize
   Do While lngOffset < lngTotalSize
      strChunk = fldSource.GetChunk(lngOffset, conChunkSize)
      fldDestination.AppendChunk strChunk
      lngOffset = lngOffset + conChunkSize
   Loop

End Function


WebBrowserControl.Tag Property (Access)

 Copy code hover
[image]

WebBrowserControl.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .Tag

expression A variable that represents a WebBrowserControl object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Form.SplitFormPrinting Property (Access)

 Copy code hover
[image]

Form.SplitFormPrinting Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the contents of the form or the datasheet are printed when printing a form displayed in Split Form view. Read/write AcSplitFormPrinting.

Version Information

Version Added: Access 2007

Syntax

expression .SplitFormPrinting

expression A variable that represents a Form object.

See also

Concepts

Form Object

Other resources

Form Object Members


Rectangle.Parent Property (Access)

 Copy code hover
[image]

Rectangle.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a Rectangle object.

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


Form.SubdatasheetExpanded Property (Access)

 Copy code hover
[image]

Form.SubdatasheetExpanded Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SubdatasheetExpanded property to specify or determine the saved state of all subdatasheets within a table or query. Read/write Boolean.

Syntax

expression .SubdatasheetExpanded

expression A variable that represents a Form object.

Remarks

The default value is False.

To set the SubdatasheetExpanded property by using Visual Basic, you must first create the property by using the DAO CreateProperty method.

The SubdatasheetExpanded and SubdatasheetHeight properties take effect on the subform control when the form is in datasheet view.

Example

The following example turns subdatasheet expansion on or off for the "Purchase Orders" form.

To try this example yourself, open a form (containing a subform) in Design view, click the Builder button next to the On Load property box in the form's property window, paste this code into the form's Form_Load event (removing the reference to the "Purchase Orders" form), and then open the form in Datasheet view.

VBA Copy code Copy code
Dim strExpand As String

With Forms("Purchase Orders")

 strExpand = InputBox("Expand subdatasheets? Y/N")

 Select Case strExpand
 Case "Y"
 .SubdatasheetExpanded = True
 Case "N"
 .SubdatasheetExpanded = False
 Case Else
 MsgBox "Can't determine subdatasheet expansion state."
 End Select

End With

See also

Concepts

Form Object

Other resources

Form Object Members


CheckBox.Name Property (Access)

 Copy code hover
[image]

CheckBox.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a CheckBox object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Attachment.OnLostFocus Property (Access)

 Copy code hover
[image]

Attachment.OnLostFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnLostFocus

expression A variable that represents an Attachment object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The LostFocus event occurs when the object loses the focus.

The OnLostFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Lost Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Lost Focus box is blank, the property value is an empty string.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Form.FilterOnLoad Property (Access)

 Copy code hover
[image]

Form.FilterOnLoad Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the filter specified by the Filter property is applied when the form is loaded. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .FilterOnLoad

expression A variable that represents a Form object.

See also

Concepts

Form Object

Other resources

Form Object Members


CreateRecordset Method Example (VBScript)

 Copy code hover
[image]

CreateRecordset Method Example (VBScript)
Send feedback

This code example creates a Recordset on the server side. It has two columns with four rows each. Cut and paste the following code to Notepad or another text editor and save it as CreateRecordsetVBS.asp.

VBS Copy code Copy code
<!-- BeginCreateRecordsetVBS --><%@ Language=VBScript %>
<html><head>
<meta name="VI60_DefaultClientScript" content=VBScript><meta name="GENERATOR" content="Microsoft Visual Studio 6.0">
<title>CreateRecordset Method Example (VBScript)</title><style>
<!--body {
font-family: 'Verdana','Arial','Helvetica',sans-serif;BACKGROUND-COLOR:white;
COLOR:black;}
.thead {background-color: #008080;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.thead2 {background-color: #800000;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.tbody {text-align: center;
background-color: #f7efde;font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;}
--></style>
</head>
<body>
<OBJECT classid=clsid:BD96C556-65A3-11D0-983A-00C04FC29E33 height=1 id=DC1 width=1></OBJECT>
<h1>CreateRecordset Method Example (VBScript)</h1><script language = "vbscript">
' use the RDS.DataControl to create an empty recordset;' takes an array of variants where every element is itself another
' array of variants, one for every column required in the recordset
' the elements of the inner array are the column's' name, type, size, and nullability
Sub GetRS()Dim Record(2)
Dim Field1(3)Dim Field2(3)
Dim Field3(3)
' for each field, specify the name type, size, and nullability
Field1(0) = "Name" ' Column name.Field1(1) = CInt(129) ' Column type.
Field1(2) = CInt(40) ' Column size.Field1(3) = False ' Nullable?
Field2(0) = "Age"Field2 (1) = CInt(3)
Field2 (2) = CInt(-1)Field2 (3) = True
Field3 (0) = "DateOfBirth"Field3 (1) = CInt(7)
Field3 (2) = CInt(-1)Field3 (3) = True
' put all fields into an array of arraysRecord(0) = Field1
Record(1) = Field2Record(2) = Field3
Dim NewRsSet NewRS = DC1.CreateRecordset(Record)
Dim fields(2)fields(0) = Field1(0)
fields(1) = Field2(0)fields(2) = Field3(0)
' Populate the new recordset with data values.Dim fieldVals(2)
' Use AddNew to add the records.fieldVals(0) = "Joe"
fieldVals(1) = 5fieldVals(2) = CDate(#1/5/96#)
NewRS.AddNew fields, fieldVals
fieldVals(0) = "Mary"fieldVals(1) = 6
fieldVals(2) = CDate(#6/5/94#)NewRS.AddNew fields, fieldVals
fieldVals(0) = "Alex"fieldVals(1) = 13
fieldVals(2) = CDate(#1/6/88#)NewRS.AddNew fields, fieldVals
fieldVals(0) = "Susan"fieldVals(1) = 13
fieldVals(2) = CDate(#8/6/87#)NewRS.AddNew fields, fieldVals
NewRS.MoveFirst
' Set the newly created and populated Recordset to' the SourceRecordset property of the
' RDS.DataControl to bind to visual controls
Set DC1.SourceRecordset = NewRSEnd Sub
</script><table datasrc="#DC1" align="center">
<thead><tr id="ColHeaders" class="thead2">
<th>Name</th><th>Age</th>
<th>D.O.B.</th></tr>
</thead><tbody class="tbody">
<tr><td><input datafld="Name" size=15 id=text1 name=text1> </td>
<td><input datafld="Age" size=25 id=text2 name=text2> </td><td><input datafld="DateOfBirth" size=25 id=text3 name=text3> </td>
</tr></tbody>
</table><input type = "button" onclick = "GetRS()" value="Go!">
</body></html>
<!-- EndCreateRecordsetVBS -->


Rectangle.InSelection Property (Access)

 Copy code hover
[image]

Rectangle.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents a Rectangle object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


Format Function (Access 2013 custom web app)

 Copy code hover
[image]

Format Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns a value formatted according to a specified pattern.

Syntax

Format (Expression, Format)

The Format function contains the following arguments.

Argument name | Description
Expression | Expression of a supported data type to format.
Format | A format pattern. The format argument must contain a valid format string, either as a standard format string (for example, "C" or "D"), or as a pattern of custom characters for dates and numeric values (for example, "MMMM dd, yyyy (dddd)").


ListBox.BorderColor Property (Access)

 Copy code hover
[image]

ListBox.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Syntax

expression .BorderColor

expression A variable that represents a ListBox object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Cannot create an index on this MAPI folder/address book. (Error 3788)

 Copy code hover
[image]

Cannot create an index on this MAPI folder/address book. (Error 3788)
Send feedback

Many Microsoft Outlook/Exchange folders and address books are system-wide components that you cannot modify in any way. This error message indicates that you tried to create an index on an object, such as a global address list or a public folder, for which you do not have permissions.


Section.AlternateBackShade Property (Access)

 Copy code hover
[image]

Section.AlternateBackShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the AlternateBackColor property of the section. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .AlternateBackShade

expression A variable that represents a Section object.

Remarks

The AlternateBackShade property contains a numeric expression that can be used to darken the theme color in the AlternateBackColor property. The default value of the AlternateBackShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

Section Object

Other resources

Section Object Members


BoundObjectFrame.OnDblClick Property (Access)

 Copy code hover
[image]

BoundObjectFrame.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Syntax

expression .OnDblClick

expression A variable that represents a BoundObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_DblClick" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


MacroError Object (Access)

 Copy code hover
[image]

MacroError Object (Access)
See also Send feedback

Published: July 16, 2012

Represents the properties of a run-time error that occurs in a macro.

Version Information

Version Added: Access 2007

Remarks

When an error occurs in a macro, information about the error is stored in the MacroError object. If you have not used the OnError action to suppress error messages, the macro stops and the error information is displayed in a standard error message. However, if you have used the OnError action to suppress error messages, you may want to use the information stored in the MacroError object in a condition or a custom error message.

After an error has been handled, the information in the MacroError object is out of date, so it is a good idea to clear the object using the ClearMacroError action. This resets the error number in the MacroError object back to zero, and clears any other information about the error that is stored in the object, such as the error description, macro name, action name, condition, and arguments. This way, you can inspect the MacroError object again later to see if another error has occurred.

The MacroError object contains information about only one error at a time. If more than one error has occurred in a macro, the MacroError object contains information about only the last one.

The MacroError object does not contain information about run-time errors that occur when running Visual Basic for Applications (VBA) code. See Elements of Run-Time Error Handling for more information about handling run-time errors in VBA.

See also

Concepts

Access Object Model Reference

Other resources

MacroError Object Members


Access Developer Extensions

 Copy code hover
[image]

Access Developer Extensions
Send feedback

In this section

  • How to: Create a Database Template Programmatically

  • How to: Create a Deployment Package Programmatically


Attachment.AfterUpdate Property (Access)

 Copy code hover
[image]

Attachment.AfterUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .AfterUpdate

expression An expression that returns an Attachment object.

Remarks

Valid values for this property are "macroname" where macroname is the name of a macro; "[Event Procedure]" which indicates the event procedure associated with the AfterUpdate event for the specified object; or "=functionname()" where functionname is the name of a user-defined function.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


CacheSize Property Example (VB)

 Copy code hover
[image]

CacheSize Property Example (VB)
Send feedback

This example uses the CacheSize property to show the difference in performance for an operation performed with and without a 30-record cache.

Copy code Copy code

'BeginCacheSizeVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 'recordset and connection variables
 Dim rstRoySched As ADODB.Recordset
 Dim strSQLSched As String
 Dim strCnxn As String
 'record variables
 Dim sngStart As Single
 Dim sngEnd As Single
 Dim sngNoCache As Single
 Dim sngCache As Single
 Dim intLoop As Integer
 Dim strTemp As String

 ' Open the connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"

 ' Open the RoySched Table
 Set rstRoySched = New ADODB.Recordset
 strSQLSched = "roysched"
 rstRoySched.Open strSQLSched, strCnxn, , , adCmdTable

 ' Enumerate the Recordset object twice and
 ' record the elapsed time
 sngStart = Timer

 For intLoop = 1 To 2
 rstRoySched.MoveFirst

 If Not rstRoySched.EOF Then
 ' Execute a simple operation for the
 ' performance test
 Do
 strTemp = rstRoySched!title_id
 rstRoySched.MoveNext
 Loop Until rstRoySched.EOF
 End If
 Next intLoop

 sngEnd = Timer
 sngNoCache = sngEnd - sngStart

 ' Cache records in groups of 30 records.
 rstRoySched.MoveFirst
 rstRoySched.CacheSize = 30
 sngStart = Timer

 ' Enumerate the Recordset object twice and record
 ' the elapsed time
 For intLoop = 1 To 2
 rstRoySched.MoveFirst
 Do While Not rstRoySched.EOF
 ' Execute a simple operation for the
 ' performance test
 strTemp = rstRoySched!title_id
 rstRoySched.MoveNext
 Loop
 Next intLoop

 sngEnd = Timer
 sngCache = sngEnd - sngStart

 ' Display performance results.
 MsgBox "Caching Performance Results:" & vbCr & _
 " No cache: " & Format(sngNoCache, "##0.000") & " seconds" & vbCr & _
 " 30-record cache: " & Format(sngCache, "##0.000") & " seconds"

 ' clean up
 rstRoySched.Close
 Set rstRoySched = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstRoySched Is Nothing Then
 If rstRoySched.State = adStateOpen Then rstRoySched.Close
 End If
 Set rstRoySched = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndCacheSizeVB


ComboBox.AllowValueListEdits Property (Access)

 Copy code hover
[image]

ComboBox.AllowValueListEdits Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the Edit List Items command is available when the user right-clicks a combo box. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .AllowValueListEdits

expression A variable that represents a ComboBox object.

Remarks

The AllowValueEditLists property determines whether the the Edit List Items command is available when the user right-clicks a combo box that's bound to a Lookup field.

If the Lookup field is bound to a list of values, then the Edit List Items dialog box is displayed when the user clicks Edit List Items. The user can then add, delete, or edit the items to be displayed in the combo box.

If the Lookup field is bound to a table or query, then the form specified by the ListItemsEditForm property is diplayed when the user clicks Edit List Items. The user can use the form to add, delete, or edit the items to be displayed in the combo box.

The AllowValueEditLists property is not available for combo boxes on a report.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


WebBrowserControl.GridlineWidthTop Property (Access)

 Copy code hover
[image]

WebBrowserControl.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthTop

expression A variable that represents a WebBrowserControl object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Mod (Access 2013 custom web app)

 Copy code hover
[image]

Mod (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the remainder of one number divided by another.

Syntax

dividend Mod divisor

dividend Is the numeric expression to divide.

Divisor Is the numeric expression by which to divide the dividend.


TabControl.TabFixedHeight Property (Access)

 Copy code hover
[image]

TabControl.TabFixedHeight Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabFixedHeight property to specify or determine the height of the tabs on a tab control. Read/write Integer.

Syntax

expression .TabFixedHeight

expression A variable that represents a TabControl object.

Remarks

The TabFixedHeight property setting is a value that represents the height of tabs in the unit of measurement specified in the Regional Options dialog box in Windows Control Panel. If you set this property to zero, the tabs automatically adjust to the height of the tab contents.

You can also set the default for this property by setting a control's DefaultControl property in Visual Basic.

Tthis property uses an Integer value representing the height of the tabs in twips and can be set in any view.

Note Note

To use a unit of measurement different from the setting in the Regional Options dialog box in Windows Control Panel, specify the unit, such as cm or in (for example, 5 cm or 3 in).

You can't change the color of a tab control. If the tabs don't cover the height of the tab control, the area behind the tabs is displayed. If you place a tab control on an object with a different color than the tab control, you should make sure that the tabs cover the control's background area.

Example

The following example sets the height of each tab in the tab control "TabCtl1" on the "Mailing List" form to 500 twips.

VBA Copy code Copy code
Forms("Mailing List").Controls("TabCtl1").TabFixedWidth = 500

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


AcControlType Enumeration (Access)

 Copy code hover
[image]

AcControlType Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the type of control created by the CreateControl and CreateReportControl methods.

Name | Value | Description
acAttachment | 126 | Attachment control.
acBoundObjectFrame | 108 | Bound Object Frame control.
acCheckBox | 106 | Check Box control.
acComboBox | 111 | Combo Box control.
acCommandButton | 104 | Command Button control.
acCustomControl | 119 | ActiveX control.
acEmptyCell | 127 | EmptyCell control.
acImage | 103 | Image control.
acLabel | 100 | Label control.
acLine | 102 | Line control.
acListBox | 110 | List Box control.
acNavigationButton | 130 | Navigation Button control.
acNavigationControl | 129 | Navigation control.
acObjectFrame | 114 | Unbound Object Frame control.
acOptionButton | 105 | Option Button control.
acOptionGroup | 107 | Option Group control.
acPage | 124 | Page control.
acPageBreak | 118 | Page Break control.
acRectangle | 101 | Rectangle control.
acSubform | 112 | Subform control.
acTabCtl | 123 | Tab control.
acTextBox | 109 | Text Box control.
acToggleButton | 122 | Toggle Button control.
acWebBrowser | 128 | Web browser control.


Streams and Persistence

 Copy code hover
[image]

Streams and Persistence
Send feedback

The Recordset object Save method stores, or persists, a Recordset in a file, and the Open method restores the Recordset from that file.

With ADO 2.5, the Save and Open methods can persist a Recordset to a Stream object as well. This feature is especially useful when working with Remote Data Service (RDS) and Active Server Pages (ASP).

For more information about how persistence can be used by itself on ASP pages, see the current ASP documentation.

The following are a few scenarios that show how Stream objects and persistence can be used.

Scenario 1

This scenario simply saves a Recordset to a file and then to a Stream. It then opens the persisted stream into another Recordset.

Copy code Copy code

Dim rs1 As ADODB.Recordset
Dim rs2 As ADODB.Recordset
Dim stm As ADODB.Stream

Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
Set stm = New ADODB.Stream

rs1.Open "SELECT * FROM Customers", "Provider=sqloledb;" & _
 "Data Source=MyServer;Initial Catalog=Northwind;" & _
 "Integrated Security=SSPI;""", adopenStatic, adLockReadOnly, adCmdText
rs1.Save "c:\myfolder\mysubfolder\myrs.xml", adPersistXML
rs1.Save stm, adPersistXML
rs2.Open stm

Scenario 2

This scenario persists a Recordset into a Stream in XML format. It then reads the Stream into a string that you can examine, manipulate, or display.

Copy code Copy code

Dim rs As ADODB.Recordset
Dim stm As ADODB.Stream
Dim strRst As String

Set rs = New ADODB.Recordset
Set stm = New ADODB.Stream

' Open, save, and close the recordset.
rs.Open "SELECT * FROM Customers", "Provider=sqloledb;" & _
 "Data Source=MyServer;Initial Catalog=Northwind;" & _
 "Integrated Security=SSPI;"""
rs.Save stm, adPersistXML
rs.Close
Set rs = nothing

' Put saved Recordset into a string variable.
strRst = stm.ReadText(adReadAll)

' Examine, manipulate, or display the XML data.
...

Scenario 3

This example code shows ASP code persisting a Recordset as XML directly to the Response object:

Copy code Copy code

...
<%
response.ContentType = "text/xml"

' Create and open a Recordset.
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "select * from Customers", "Provider=sqloledb;" & _
 "Data Source=MyServer;Initial Catalog=Northwind;" & _
 "Integrated Security=SSPI;"""

' Save Recordset directly into output stream.
rs.Save Response, adPersistXML

' Close Recordset.
rs.Close
Set rs = nothing
%>
...

Scenario 4

In this scenario, ASP code writes the contents of the Recordset in ADTG format to the client. The Microsoft Cursor Service for OLE DB can use this data to create a disconnected Recordset.

A new property on the RDS DataControl, URL, points to the .asp page that generates the Recordset. This means a Recordset object can be obtained without RDS using the server-side DataFactory object or the user writing a business object. This simplifies the RDS programming model significantly.

Server-side code, named http://server/directory/recordset.asp:

Copy code Copy code

<%
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "select au_fname, au_lname, phone from Authors", ""& _
 "Provider=sqloledb;Data Source=MyServer;" & _
 "Initial Catalog=Pubs;Integrated Security=SSPI;"
response.ContentType = "multipart/mixed"
rs.Save response, adPersistADTG
%>

Client-side code:

Copy code Copy code

<HTML>
<HEAD>
<TITLE>RDS Query Page</TITLE>
</HEAD>
<body>
<CENTER>
<H1>Remote Data Service 2.5</H1>
<TABLE DATASRC="#DC1">
 <TR>
 <TD><SPAN DATAFLD="au_fname"></SPAN></TD>
 <TD><SPAN DATAFLD="au_lname"></SPAN></TD>
 <TD><SPAN DATAFLD="phone"></SPAN></TD>
 </TR>
</TABLE>
<BR>

<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
 ID=DC1 HEIGHT=1 WIDTH = 1>
 <PARAM NAME="URL" VALUE="http://server/directory/recordset.asp">
</OBJECT>

</SCRIPT>
</BODY>
</HTML>

Developers also have the option of using a Recordset object on the client:

Copy code Copy code

...
function GetRs()
 {
 rs = CreateObject("ADODB.Recordset");
 rs.Open "http://server/directory/recordset.asp"
 DC1.SourceRecordset = rs;
 }
...


Report.Activate Event (Access)

 Copy code hover
[image]

Report.Activate Event (Access)
See also Send feedback

Published: July 16, 2012

The Activate event occurs when a report receives the focus and becomes the active window.

Syntax

expression .Activate

expression A variable that represents a Report object.

Return Value

nothing

Remarks

To run a macro or event procedure when these events occur, set the OnActivate, or OnDeactivate property to the name of the macro or to [Event Procedure].

You can make a report or report active by opening it, clicking it or a control on it.

The Activate event can occur only when a report is visible.

The Activate event occurs before the GotFocus event; the Deactivate event occurs after the LostFocus event.

See also

Concepts

Report Object

Other resources

Report Object Members


The query is a DDL query and cannot be used as a row source. (Error 3324)

 Copy code hover
[image]

The query is a DDL query and cannot be used as a row source. (Error 3324)
Send feedback

You tried to run an action query or data-definition query without using the Execute method.


GetRows Method (ADO)

 Copy code hover
[image]

GetRows Method (ADO)
Send feedback

Retrieves multiple records of a Recordset object into an array.

Syntax

array = recordset.GetRows(Rows, Start, Fields )

Return Value

Returns a Variant whose value is a two-dimensional array.

Parameters

  • Rows

  • Optional. A GetRowsOptionEnum value that indicates the number of records to retrieve. The default is adGetRowsRest.

  • Start

  • Optional. A String value or Variant that evaluates to the bookmark for the record from which the GetRows operation should begin. You can also use a BookmarkEnum value.

  • Fields

  • Optional. A Variant that represents a single field name or ordinal position, or an array of field names or ordinal position numbers. ADO returns only the data in these fields.

Remarks

Use the GetRows method to copy records from a Recordset into a two-dimensional array. The first subscript identifies the field and the second identifies the record number. The array variable is automatically dimensioned to the correct size when the GetRows method returns the data.

If you do not specify a value for the Rows argument, the GetRows method automatically retrieves all the records in the Recordset object. If you request more records than are available, GetRows returns only the number of available records.

If the Recordset object supports bookmarks, you can specify at which record the GetRows method should begin retrieving data by passing the value of that record's Bookmark property in the Start argument.

If you want to restrict the fields that the GetRows call returns, you can pass either a single field name/number or an array of field names/numbers in the Fields argument.

After you call GetRows, the next unread record becomes the current record, or the EOF property is set to True if there are no more records.


TextBox.OnDblClick Property (Access)

 Copy code hover
[image]

TextBox.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Syntax

expression .OnDblClick

expression A variable that represents a TextBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_DblClick" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Duplicate output destination

 Copy code hover
[image]

Duplicate output destination <name>. (Error 3063)
Send feedback

You tried to execute a query that contains more than one destination field with the same name.

Possible cause:

  • You created an SQL statement that includes an INSERT INTO, SELECT...INTO, or UPDATE statement that lists the specified field name more than once.

Remove the duplicate fields or alias the destination field names, and try the operation again.


EmptyCell.DisplayWhen Property (Access)

 Copy code hover
[image]

EmptyCell.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .DisplayWhen

expression A variable that represents an EmptyCell object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


AbsolutePosition and CursorLocation Properties Example (VB)

 Copy code hover
[image]

AbsolutePosition and CursorLocation Properties Example (VB)
Send feedback

This example demonstrates how the AbsolutePosition property can track the progress of a loop that enumerates all the records of a Recordset. It uses the CursorLocation property to enable the AbsolutePosition property by setting the cursor to a client cursor.

Copy code Copy code

'BeginAbsolutePositionVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 'recordset and connection variables
 Dim rstEmployees As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim strSQL As String
 'record variables
 Dim strMessage As String

 'Open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open Employee recordset with
 ' Client-side cursor to enable AbsolutePosition property
 Set rstEmployees = New ADODB.Recordset
 strSQL = "employee"
 rstEmployees.Open strSQL, strCnxn, adUseClient, adLockReadOnly, adCmdTable

 ' Enumerate Recordset
 Do While Not rstEmployees.EOF
 ' Display current record information
 strMessage = "Employee: " & rstEmployees!lname & vbCr & _
 "(record " & rstEmployees.AbsolutePosition & _
 " of " & rstEmployees.RecordCount & ")"
 If MsgBox(strMessage, vbOKCancel) = vbCancel Then Exit Do
 rstEmployees.MoveNext
 Loop

 ' clean up
 rstEmployees.Close
 Cnxn.Close
 Set rstEmployees = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstEmployees Is Nothing Then
 If rstEmployees.State = adStateOpen Then rstEmployees.Close
 End If
 Set rstEmployees = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndAbsolutePositionVB


Fields.Count Property (DAO)

 Copy code hover
[image]

Fields.Count Property (DAO)
Send feedback

Returns the number of objects in the specified collection. Read-only Integer.

Syntax

expression .Count

expression A variable that represents a Fields object.

Remarks

Because members of a collection begin with 0, you should always code loops starting with the 0 member and ending with the value of the Count property minus 1. If you want to loop through the members of a collection without checking the Count property, you can use a For Each...Next command.

The Count property setting is never Null. If its value is 0, there are no objects in the collection.


AcPrintOrientation Enumeration (Access)

 Copy code hover
[image]

AcPrintOrientation Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the Orientation property to specify a printer's print orientation.

Name | Value | Description
acPRORLandscape | 2 | Landscape orientation
acPRORPortrait | 1 | Portrait orientation


CustomControl.EventProcPrefix Property (Access)

 Copy code hover
[image]

CustomControl.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents a CustomControl object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


TabControl.Shape Property (Access)

 Copy code hover
[image]

TabControl.Shape Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets the shape of the specified tab control. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .Shape

expression A variable that represents a TabControl object.

Remarks

The Shape property uses the following settings.

Setting | Description
0 | Rectangle
1 | Rounded Rectangle
2 | Snip Single Corner Rectangle
3 | Snip Same Side Corner Rectangle
4 | Snip Diagonal Corner Rectangle
5 (Default) | Snip and Round Single Corner Rectangle
6 | Round Single Corner Rectangle
7 | Round Same Side Corner Rectangle
8 | Round Diagonal Corner Rectangle
9 | Oval

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


ListBox.TabStop Property (Access)

 Copy code hover
[image]

ListBox.TabStop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.

Syntax

expression .TabStop

expression A variable that represents a ListBox object.

Remarks

This property doesn't apply to toggle button controls when they appear in an option group. It applies only to the option group itself.

The TabStop property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) You can move the focus to the control by pressing the TAB key.
No | False | You can't move the focus to the control by pressing the TAB key.

When you create a control on a form, Microsoft Access automatically assigns the control a position in the form's tab order. Each new control is placed last in the tab order. If you want to prevent a control from being available when you tab through the controls in a form, set the control's TabStop property to No.

In Form view, hidden or disabled controls remain in the tab order but are skipped when you move through the controls by pressing TAB, even if their TabStop properties are set to Yes.

As long as a control's Enabled property is set to Yes, you can click the control or use an access key to select it, regardless of its TabStop property setting. For example, you can set the TabStop property of a command button to No to prevent users from selecting the button by pressing TAB. However, they can still click the command button to choose it.

Example

The following example disables the ability to move the focus to the "City" text box on the "Suppliers" form by using the TAB key.

VBA Copy code Copy code
Forms("Suppliers").Controls("City").TabStop = False

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


QueryDefs Object Reference (DAO)

 Copy code hover
[image]

QueryDefs Object Reference (DAO)
Send feedback

In this section

  • QueryDefs Collection (DAO)

  • QueryDefs Members (DAO)

  • QueryDefs Properties (DAO)

  • QueryDefs Methods (DAO)


CustomControl.Left Property (Access)

 Copy code hover
[image]

CustomControl.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Syntax

expression .Left

expression A variable that represents a CustomControl object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Connection.OpenRecordset Method (DAO)

 Copy code hover
[image]

Connection.OpenRecordset Method (DAO)
Send feedback

Creates a new Recordset object and appends it to the Recordsets collection.

Syntax

expression .OpenRecordset(Name, Type, Options, LockEdit)

expression A variable that represents a Connection object.

Parameters

Name

Required/Optional

Data Type

Description

Name

Required

String

The source of the records for the new Recordset. The source can be a table name, a query name, or an SQL statement that returns records. For table-type Recordset objects in Microsoft Access database engine databases, the source can only be a table name.

Type

Optional

Variant

A RecordsetTypeEnum constant that indicates the type of Recordset to open.

Note Note

If you open a Recordset in a Microsoft Access workspace and you don't specify a type, OpenRecordset creates a table-type Recordset, if possible. If you specify a linked table or query, OpenRecordset creates a dynaset-type Recordset.

Options

Optional

Variant

A combination of RecordsetOptionEnum constants that specify characteristics of the new Recordset.

Note Note

The constants dbConsistent and dbInconsistent are mutually exclusive, and using both causes an error. Supplying a lockedits argument when options uses the dbReadOnly constant also causes an error.

LockEdit

Optional

Variant

A LockTypeEnum constant that determines the locking for the Recordset.

Note Note

You can use dbReadOnly in either the options argument or the lockedits argument, but not both. If you use it for both arguments, a run-time error occurs.

Return Value

Recordset

Remarks

Typically, if the user gets this error while updating a record, your code should refresh the contents of the fields and retrieve the newly modified values. If the error occurs while deleting a record, your code could display the new record data to the user and a message indicating that the data has recently changed. At this point, your code can request a confirmation that the user still wants to delete the record.

You should also use the dbSeeChanges constant if you open a Recordset in a Microsoft Access database engine-connected ODBC workspace against a Microsoft SQL Server 6.0 (or later) table that has an IDENTITY column, otherwise an error may result.

Opening more than one Recordset on an ODBC data source may fail because the connection is busy with a prior OpenRecordset call. One way around this is to fully populate the Recordset by using the MoveLast method as soon as the Recordset is opened.

Closing a Recordset with the Close method automatically deletes it from the Recordsets collection.

Note Note

If source refers to an SQL statement composed of a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strSQL = "PRICE > " & lngPrice, and lngPrice = 125,50), an error occurs when you try to open the Recordset. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and SQL only accepts U.S. decimal characters.


Field2 Object (DAO)

 Copy code hover
[image]

Field2 Object (DAO)
Send feedback

A Field2 object represents a column of data with a common data type and a common set of properties.

Remarks

A Field2 object is contains all of the same properties and methods as the Field object. The Field2 object contains several new properties and methods that support multi-valued field types. The new properties and methods are:

  • AppendOnly property

  • ComplexType property

  • IsComplex property

  • LoadFromFile method

  • SaveToFile method

To refer to a Field2 object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

Fields(0)

Fields("name")

Fields![name]

With the same syntax forms, you can also refer to the Value property of a Field2 object that you create and append to a Fields collection. The context of the field reference will determine whether you are referring to the Field2 object or the Value property of the Field object.

Example

The following example shows how to navigate a Recordset that contains a multi-value field.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Sub PrintStudentsAndClasses()
    Dim dbs As DAO.Database
    Dim rsStudents As DAO.Recordset2  'Recordset for students
    Dim rsClasses As DAO.Recordset2  'Recordset for classes
    Dim fld As DAO.Field2

    'open the database
    Set dbs = CurrentDb()

    'get the table of students
    Set rsStudents = dbs.OpenRecordset("tblStudents")

    'loop through the students
    Do While Not rsStudents.EOF

        'get the classes field
        Set fld = rsStudents("Classes")

        'get the classes Recordset
        'make sure the field is a multi-valued field before
        'getting a Recordset object
        If fld.IsComplex Then
            Set rsClasses = fld.Value
        End If

        'access all records in the Recordset
        If Not (rsClasses.BOF And rsClasses.EOF) Then
            rsClasses.MoveLast
            rsClasses.MoveFirst
        End If

        'print the student and number of classes
        Debug.Print rsStudents("FirstName") & " " & rsStudents("LastName"), _
            "Number of classes: " & rsClasses.RecordCount

        'print the classes for this student
        Do While Not rsClasses.EOF
            Debug.Print , rsClasses("Value")
            rsClasses.MoveNext
        Loop

        'close the Classes Recordset
        rsClasses.Close

        'get the next student
        rsStudents.MoveNext

    Loop

    'cleanup
    rsStudents.Close

    Set fld = Nothing
    Set rsStudents = Nothing
    Set dbs = Nothing

End Sub

The following example shows how to navigate the files in an attachment field. The file type and filename of each attachment is printed in the Immediate window.

VBA Copy code Copy code
Sub ListAttachments()
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset2
    Dim rsA As DAO.Recordset2
    Dim fld As DAO.Field2

    'Get the database, recordset, and attachment field
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("tblAttachments")
    Set fld = rst("Attachments")

    'Navigate through the table
    Do While Not rst.EOF

        'Print the first and last name
        Debug.Print rst("FirstName") & " " & rst("LastName")

        'Get the recordset for the Attachments field
        Set rsA = fld.Value

        'Print all attachments in the field
        Do While Not rsA.EOF
            Debug.Print , rsA("FileType"), rsA("FileName")

            'Next attachment
            rsA.MoveNext
        Loop

        rsA.Close

        'Next record
        rst.MoveNext
    Loop

    rst.Close
    dbs.Close

    Set fld = Nothing
    Set rsA = Nothing
    Set rst = Nothing
    Set dbs = Nothing
End Sub

The following example shows how to add files from a specified folder path to an attachment field.

VBA Copy code Copy code
Public Function LoadAttachments(strPath As String, Optional strPattern As String = "*.*") As Long
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset2
    Dim rsA As DAO.Recordset2
    Dim fld  As DAO.Field2
    Dim strFile As String

    'Get the database, recordset, and attachment field
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("tblAttachments")
    Set fld = rst("Attachments")

    'Navigate through the table
    Do While Not rst.EOF

        'Get the recordset for the Attachments field
        Set rsA = fld.Value

        'Load all attachments in the specified directory
        strFile = Dir(strPath & "\*.*")

        rst.Edit
        Do While Len(strFile) > 0
            'Add a new attachment that matches the pattern.
            'Pass "" to match all files.
            If strFile Like strPattern Then
                rsA.AddNew
                rsA("FileData").LoadFromFile strPath & "\" & strFile
                rsA.Update

                'Increment the number of files added
                LoadAttachments = LoadAttachments + 1
            End If
            strFile = Dir
        Loop
        rsA.Close

        rst.Update
        'Next record
        rst.MoveNext
    Loop

    rst.Close
    dbs.Close

    Set fld = Nothing
    Set rsA = Nothing
    Set rst = Nothing
    Set dbs = Nothing
End Function

The following example shows how to save the files stored in an attachment field to the specified folder path.

VBA Copy code Copy code
Public Function SaveAttachments(strPath As String, Optional strPattern As String = "*.*") As Long
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset2
    Dim rsA As DAO.Recordset2
    Dim fld As DAO.Field2
    Dim strFullPath As String

    'Get the database, recordset, and attachment field
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("tblAttachments")
    Set fld = rst("Attachments")

    'Navigate through the table
    Do While Not rst.EOF

        'Get the recordset for the Attachments field
        Set rsA = fld.Value

        'Save all attachments in the field
        Do While Not rsA.EOF
            If rsA("FileName") Like strPattern Then
                strFullPath = strPath & "\" & rsA("FileName")

                'Make sure the file does not exist and save
                If Dir(strFullPath) = "" Then
                    rsA("FileData").SaveToFile strFullPath
                End If

                'Increment the number of files saved
                SaveAttachments = SaveAttachments + 1
            End If

            'Next attachment
            rsA.MoveNext
        Loop
        rsA.Close

        'Next record
        rst.MoveNext
    Loop

    rst.Close
    dbs.Close

    Set fld = Nothing
    Set rsA = Nothing
    Set rst = Nothing
    Set dbs = Nothing
End Function

The following example shows how to delete a file stored in an attachment field.

VBA Copy code Copy code
Function RemoveAttachment(strRemoveFile As String, Optional strFilter As String) As Long
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset2
    Dim rsA As DAO.Recordset2
    Dim fld As DAO.Field2

    'Get the database
    Set dbs = CurrentDb

    'Open the recordset. If the strFilter is supplied, add it to the WHERE
    'clause for the recordset. Otherwise, any files matching strFileName
    'will be deleted
    If Len(strFilter) > 0 Then
        Set rst = dbs.OpenRecordset("SELECT * FROM tblAttachments WHERE " & strFilter)
    Else
        Set rst = dbs.OpenRecordset("tblAttachments")
    End If

    'Get the Attachment field
    Set fld = rst("Attachments")

    'Navigate through the recordset
    Do While Not rst.EOF

        'Get the recordset for the Attachments field
        Set rsA = fld.Value

        'Walk the attachments and look for the file name to remove
        Do While Not rsA.EOF
            If rsA("FileName") Like strRemoveFile Then
                rsA.Delete

                'Increment the number of files removed
                RemoveAttachment = RemoveAttachment + 1
            End If
            rsA.MoveNext
        Loop

        'Cleanup the Attachments recordset
        rsA.Close
        Set rsA = Nothing

        'Next record
        rst.MoveNext
    Loop

    rst.Close
    dbs.Close
    Set fld = Nothing
    Set rst = Nothing
    Set dbs = Nothing
End Function

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Types of Cursors

 Copy code hover
[image]

Types of Cursors
Send feedback

As a general rule, your application should use the simplest cursor that provides the required data access. Each additional cursor characteristic beyond the basics (forward-only, read-only, static, scrolling, unbuffered) has a price — in client memory, network load, or performance. In many cases, the default cursor options generate a more complex cursor than your application actually needs.

Your choice of cursor type depends on how your application uses the result set and also on several design considerations, including the size of the result set, the percentage of the data likely to be used, sensitivity to data changes, and application performance requirements.

At its most basic, your cursor choice depends on whether you need to change or simply view the data:

  • If you just need to scroll through a set of results, but not change data, use a forward-only or static cursor.

  • If you have a large result set and need to select just a few rows, use a keyset cursor.

  • If you want to synchronize a result set with recent adds, changes, and deletes by all concurrent users, use a dynamic cursor.

Although each cursor type seems to be distinct, keep in mind that these cursor types are not so much different varieties as simply the result of overlapping characteristics and options.


ObjectFrame.LayoutID Property (Access)

 Copy code hover
[image]

ObjectFrame.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified object frame. Read-only Long.

Version Information

Version Added: Access 2007

Syntax

expression .LayoutID

expression A variable that represents an ObjectFrame object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


How to: Retrieve Information from the Clipboard

 Copy code hover
[image]

How to: Retrieve Information from the Clipboard
Send feedback

Using the RunCommand Method

You can use the RunCommand method with the acCmdPaste constant to paste the contents of the Clipboard into the active control on a form or report. The following example illustrates how to paste the contents of the Clipboard into a text box named txtNotes.

VBA Copy code Copy code
Private Sub cmdPaste_Click()
   Me!txtNotes.SetFocus
   DoCmd.RunCommand acCmdPaste
End Sub

Using the Windows API

To use API calls to retrieve information from the Clipboard, paste the following code into the Declarations section of a standard module.

VBA Copy code Copy code
Declare Function OpenClipboard Lib "User32" (ByVal hwnd As Long) _
   As Long
Declare Function CloseClipboard Lib "User32" () As Long
Declare Function GetClipboardData Lib "User32" (ByVal wFormat As _
   Long) As Long
Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags&, ByVal _
   dwBytes As Long) As Long
Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) _
   As Long
Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) _
   As Long
Declare Function GlobalSize Lib "kernel32" (ByVal hMem As Long) _
   As Long
Declare Function lstrcpy Lib "kernel32" (ByVal lpString1 As Any, _
   ByVal lpString2 As Any) As Long

Public Const GHND = &H42
Public Const CF_TEXT = 1
Public Const MAXSIZE = 4096

Paste the following code into a standard module.

VBA Copy code Copy code
Function ClipBoard_GetData()
   Dim hClipMemory As Long
   Dim lpClipMemory As Long
   Dim MyString As String
   Dim RetVal As Long

   If OpenClipboard(0&) = 0 Then
      MsgBox "Cannot open Clipboard. Another app. may have it open"
      Exit Function
   End If

   ' Obtain the handle to the global memory
   ' block that is referencing the text.
   hClipMemory = GetClipboardData(CF_TEXT)
   If IsNull(hClipMemory) Then
      MsgBox "Could not allocate memory"
      GoTo OutOfHere
   End If

   ' Lock Clipboard memory so we can reference
   ' the actual data string.
   lpClipMemory = GlobalLock(hClipMemory)

   If Not IsNull(lpClipMemory) Then
      MyString = Space$(MAXSIZE)
      RetVal = lstrcpy(MyString, lpClipMemory)
      RetVal = GlobalUnlock(hClipMemory)

      ' Peel off the null terminating character.
      MyString = Mid(MyString, 1, InStr(1, MyString, Chr$(0), 0) - 1)
   Else
      MsgBox "Could not lock memory to copy string from."
   End If

OutOfHere:

   RetVal = CloseClipboard()
   ClipBoard_GetData = MyString

End Function


Report.OnCurrent Property (Access)

 Copy code hover
[image]

Report.OnCurrent Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Current box in the Properties window of a report. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnCurrent

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Current event occurs when the focus moves to a record, making it the current record, or when the report is refreshed or requeried.

The OnCurrent value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Current box in the report's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Current box is blank, the property value is an empty string.

Example

The following example associates the Current event with the macro "Current_Macro" for the "Catalog" report.

VBA Copy code Copy code
Reports("Catalog").OnDeactivate = "Current_Macro"

See also

Concepts

Report Object

Other resources

Report Object Members


DBEngine.Errors Property (DAO)

 Copy code hover
[image]

DBEngine.Errors Property (DAO)
Send feedback

Returns an Errors collection that contains all of the stored Error objects for the specified object. Read-only.

Syntax

expression .Errors

expression A variable that represents a DBEngine object.


CustomControl.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

CustomControl.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleLeft

expression A variable that represents a CustomControl object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Property Object (ADO) Reference

 Copy code hover
[image]

Property Object (ADO) Reference
Send feedback

In this section

  • Property Object (ADO)

  • Property Properties, Methods, and Events (ADO)


Report.RibbonName Property (Access)

 Copy code hover
[image]

Report.RibbonName Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or set the name of the customized ribbon to be displayed when the specified report is loaded. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .RibbonName

expression A variable that represents a Report object.

Remarks

For more information about how to display a customized ribbon when loading a report, see How to: Apply a Filter When Opening a Form or Report.

See also

Concepts

Report Object

Other resources

Report Object Members


OptionButton.Parent Property (Access)

 Copy code hover
[image]

OptionButton.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents an OptionButton object.

Remarks

The Parent property of a label control is the control the label is linked to. The Parent property for a check box, option button, or toggle button in an option group is the name of the option group control. The Parent property of an option group control is the name of the form.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


OptionButton.GridlineShade Property (Access)

 Copy code hover
[image]

OptionButton.GridlineShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineShade

expression A variable that represents an OptionButton object.

Remarks

The GridlineShade property contains a numeric expression that can be used to darken the theme color in the GridlineColor property. The default value of the GridlineShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Image Methods (Access)

 Copy code hover
[image]

Image Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.


Cannot delete one or more objects:

 Copy code hover
[image]

Cannot delete one or more objects: <name>. (Error 3773)
Send feedback

This error occurs when using the DROP TABLE syntax and specifying a table that does not exist or is opened by another user.


DBEngine.Properties Property (DAO)

 Copy code hover
[image]

DBEngine.Properties Property (DAO)
Send feedback

Returns the Properties collection of the specified object. Read-only.

Syntax

expression .Properties

expression A variable that represents a DBEngine object.


Delete Method Example (VC++)

 Copy code hover
[image]

Delete Method Example (VC++)
Send feedback

This example uses the Delete method to remove a specified record from a Recordset.

Copy code Copy code

// BeginDeleteCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <stdio.h>
#include <ole2.h>
#include <conio.h>
#include "DeleteX.h"

//Function Declarations.
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void DeleteX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);
inline char* mygets(char* strDest, int n)
{
 char strExBuff[10];
 char* pstrRet = fgets(strDest, n, stdin);

 if (pstrRet == NULL)
 return NULL;

 if (!strrchr(strDest, '\n'))
 // Exhaust the input buffer.
 do
 {
 fgets(strExBuff, sizeof(strExBuff), stdin);
 }while (!strrchr(strExBuff, '\n'));
 else
 // Replace '\n' with '\0'
 strDest[strrchr(strDest, '\n') - strDest] = '\0';

 return pstrRet;
}

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 DeleteX();

 // Wait here for the user to see the output
 printf("\n\nPress any key to continue...");
 getch();

 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// DeleteX Function //
// //
///////////////////////////////////////////////////////////

void DeleteX(void)
{

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstRoySched = NULL;

 // Define Other Variables
 IADORecordBinding *picRs = NULL; //Interface Pointer declared.
 CRoySchedRs royschrs; //C++ class object
 HRESULT hr = S_OK;

 char strTitleID[10], strTmpTitleID[10]="";
 long longHiRange;
 int intRoyalty, intLoRange, cnt=0;
 bool blnFound = TRUE;

 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 // Open RoySched table
 TESTHR(pRstRoySched.CreateInstance(__uuidof(Recordset)));

 pRstRoySched->CursorLocation = adUseClient;
 pRstRoySched->CursorType = adOpenStatic;
 pRstRoySched->LockType = adLockBatchOptimistic;

 TESTHR(pRstRoySched->Open("SELECT * FROM roysched WHERE"
 " royalty = 20",strCnn,adOpenStatic,adLockBatchOptimistic,
 adCmdText));

 // Prompt for a record to delete.
 printf("Before delete there are %d titles with 20 percent "
 "royalty :\n", pRstRoySched->RecordCount);

 // Open an IADORecordBinding interface pointer which we'll use
 // for Binding Recordset to a class.
 TESTHR(pRstRoySched->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 // Bind the Recordset to a C++ Class here
 TESTHR(picRs->BindToRecordset(&royschrs));

 while(!(pRstRoySched->EndOfFile))
 {
 printf("%s\n", royschrs.lemp_titleidStatus == adFldOK ?
 royschrs.m_sz_titleid : "<NULL>");
 pRstRoySched->MoveNext();
 }

 printf("\nEnter the ID of a record to delete: ");
 mygets(strTitleID, 10);

 // Converting the title_id to upper case
 for( cnt=0; cnt<10; cnt++)
 {
 if(strTitleID[cnt] != NULL)
 {
 if( IsCharAlpha( strTitleID[cnt]) )
 {
 if( islower( strTitleID[cnt]) )
 strTmpTitleID[cnt] = _toupper(strTitleID[cnt]);
 else
 strTmpTitleID[cnt] = strTitleID[cnt];
 }
 else
 {
 strTmpTitleID[cnt] = strTitleID[cnt];
 }
 }
 }

 // Move to the record and save data so it can be restored.
 pRstRoySched->PutFilter ("title_id = '" +
 (_bstr_t)(LPCSTR)strTmpTitleID + "'");

 if(pRstRoySched->RecordCount != 0)
 {
 intLoRange = royschrs.m_sz_lorange;
 longHiRange = royschrs.m_sz_hirange;
 intRoyalty = royschrs.m_sz_royalty;

 // Delete the record
 pRstRoySched->Delete(adAffectCurrent);
 pRstRoySched->UpdateBatch(adAffectCurrent);
 }
 else
 {
 blnFound = FALSE;
 printf("This Title ID not available");
 }

 // Show the results.
 VARIANT varFilter;
 varFilter.vt = VT_I2;
 varFilter.iVal = adFilterNone;
 pRstRoySched->PutFilter (varFilter);
 pRstRoySched->Requery(-1);

 // Bind the Recordset to a C++ Class here.
 TESTHR(picRs->BindToRecordset(&royschrs));

 printf("\nAfter delete there are %d titles with 20 percent"
 " royalty: ", pRstRoySched->RecordCount);

 while(!(pRstRoySched->EndOfFile))
 {
 printf("\n%s", royschrs.lemp_titleidStatus == adFldOK ?
 royschrs.m_sz_titleid : "<NULL>");
 pRstRoySched->MoveNext();
 }

 // Restore the data because this is a demonstration.
 if(blnFound)
 {
 // Set the final character of the destination string to NULL.
 royschrs.m_sz_titleid[sizeof(royschrs.m_sz_titleid)-1] = '\0';
 // The source string will get truncated if its length is
 // longer than the length of the destination string minus one.
 strncpy(royschrs.m_sz_titleid,strTmpTitleID,sizeof(royschrs.m_sz_titleid)-1);
 royschrs.m_sz_lorange = intLoRange;
 royschrs.m_sz_hirange = longHiRange;
 royschrs.m_sz_royalty = intRoyalty;

 TESTHR(picRs->AddNew(&royschrs));

 pRstRoySched->UpdateBatch(adAffectCurrent);
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstRoySched->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (pRstRoySched)
 if (pRstRoySched->State == adStateOpen)
 pRstRoySched->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndDeleteCpp

DeleteX.h

Copy code Copy code

// BeginDeleteH
#include "icrsint.h"

// This Class extracts titleid, lorange, hirange and royalty
// from the "roysched" table.

class CRoySchedRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CRoySchedRs)

 //Column empid is the 1st field in the recordset

 ADO_VARIABLE_LENGTH_ENTRY2(1, adVarChar, m_sz_titleid,
 sizeof(m_sz_titleid), lemp_titleidStatus, TRUE)

 ADO_VARIABLE_LENGTH_ENTRY2(2, adInteger, m_sz_lorange,
 sizeof(m_sz_lorange), lemp_lorangeStatus, TRUE)

 ADO_VARIABLE_LENGTH_ENTRY2(3, adInteger, m_sz_hirange,
 sizeof(m_sz_hirange), lemp_hirangeStatus, TRUE)

 ADO_VARIABLE_LENGTH_ENTRY2(4, adInteger, m_sz_royalty,
 sizeof(m_sz_royalty), lemp_royaltyStatus, TRUE)

END_ADO_BINDING()

public:

 CHAR m_sz_titleid[10];
 ULONG lemp_titleidStatus;
 ULONG m_sz_lorange;
 ULONG lemp_lorangeStatus;
 ULONG m_sz_hirange;
 ULONG lemp_hirangeStatus;
 ULONG m_sz_royalty;
 ULONG lemp_royaltyStatus;
};
// EndDeleteH


Report.GrpKeepTogether Property (Access)

 Copy code hover
[image]

Report.GrpKeepTogether Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the GrpKeepTogether property to specify whether groups in a multiple column report that have their KeepTogether property for a group set to Whole Group or With First Detail will be kept together by page or by column. Read/write Byte.

Syntax

expression .GrpKeepTogether

expression A variable that represents a Report object.

Remarks

The GrpKeepTogether property uses the following settings.

Setting | Visual Basic | Description
Per Page | 0 | Groups are kept together by page.
Per Column | 1 | (Default) Groups are kept together by column.

This property can be set only in report Design view.

You can use this property to specify whether all the data for a group will appear in the same column. For example, if you have a list of employees by department in a multiple-column format, you can use this property to keep all members of the same department in the same column.

The GrpKeepTogether property setting has no effect if the KeepTogether property for a group is set to No.

See also

Concepts

Report Object

Other resources

Report Object Members


Image.DblClick Event (Access)

 Copy code hover
[image]

Image.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Syntax

expression .DblClick(Cancel)

expression A variable that represents an Image object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the DblClick event occurs. Setting the Cancel argument to True (-1) cancels the DblClick event.

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

Image Object

Other resources

Image Object Members


Hierarchical Recordsets in XML
Send feedback

Hierarchical Recordsets in XML

ADO allows persistence of hierarchical Recordset objects into XML. With hierarchical Recordset objects, the value of a field in the parent Recordset is another Recordset. Such fields are represented as child elements in the XML stream rather than an attribute. The following example demonstrates this case:

Copy code Copy code

Rs.Open "SHAPE {select stor_id, stor_name, state from stores} APPEND ({select stor_id, ord_num, ord_date, qty from sales} AS rsSales RELATE stor_id TO stor_id)", "Provider=MSDataShape;DSN=pubs;UID=MyUserId;PWD=MyPassword;"

The following is the XML format of the persisted Recordset:

Copy code Copy code

<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"     xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"     xmlns:rs="urn:schemas-microsoft-com:rowset"
    xmlns:z="#RowsetSchema">
  <s:Schema id="RowsetSchema">
    <s:ElementType name="row" content="eltOnly" rs:updatable="true">
      <s:AttributeType name="stor_id" rs:number="1"
        rs:writeunknown="true">
        <s:datatype dt:type="string" dt:maxLength="4"
          rs:fixedlength="true" rs:maybenull="false"/>
      </s:AttributeType>
      <s:AttributeType name="stor_name" rs:number="2" rs:nullable="true"
        rs:writeunknown="true">
          <s:datatype dt:type="string" dt:maxLength="40"/>
      </s:AttributeType>
      <s:AttributeType name="state" rs:number="3" rs:nullable="true"
        rs:writeunknown="true">
        <s:datatype dt:type="string" dt:maxLength="2"
          rs:fixedlength="true"/>
      </s:AttributeType>
      <s:ElementType name="rsSales" content="eltOnly"
        rs:updatable="true" rs:relation="010000000100000000000000">
        <s:AttributeType name="stor_id" rs:number="1"
          rs:writeunknown="true">
          <s:datatype dt:type="string" dt:maxLength="4"
            rs:fixedlength="true" rs:maybenull="false"/>
        </s:AttributeType>
        <s:AttributeType name="ord_num" rs:number="2"
          rs:writeunknown="true">
          <s:datatype dt:type="string" dt:maxLength="20"
            rs:maybenull="false"/>
        </s:AttributeType>
        <s:AttributeType name="ord_date" rs:number="3"
          rs:writeunknown="true">
            <s:datatype dt:type="dateTime" dt:maxLength="16"
              rs:scale="3" rs:precision="23" rs:fixedlength="true"
              rs:maybenull="false"/>
        </s:AttributeType>
        <s:AttributeType name="qty" rs:number="4" rs:writeunknown="true">
          <s:datatype dt:type="i2" dt:maxLength="2" rs:precision="5"
            rs:fixedlength="true" rs:maybenull="false"/>
        </s:AttributeType>
        <s:extends type="rs:rowbase"/>
      </s:ElementType>
      <s:extends type="rs:rowbase"/>
    </s:ElementType>
  </s:Schema>
  <rs:data>
    <z:row stor_id="6380" stor_name="Eric the Read Books" state="WA">
      <rsSales stor_id="6380" ord_num="6871"
        ord_date="1994-09-14T00:00:00" qty="5"/>
      <rsSales stor_id="6380" ord_num="722a"
        ord_date="1994-09-13T00:00:00" qty="3"/>
    </z:row>
    <z:row stor_id="7066" stor_name="Barnum's" state="CA">
      <rsSales stor_id="7066" ord_num="A2976"
        ord_date="1993-05-24T00:00:00" qty="50"/>
      <rsSales stor_id="7066" ord_num="QA7442.3"
        ord_date="1994-09-13T00:00:00" qty="75"/>
    </z:row>
    <z:row stor_id="7067" stor_name="News & Brews" state="CA">
      <rsSales stor_id="7067" ord_num="D4482"
        ord_date="1994-09-14T00:00:00" qty="10"/>
      <rsSales stor_id="7067" ord_num="P2121"
        ord_date="1992-06-15T00:00:00" qty="40"/>
      <rsSales stor_id="7067" ord_num="P2121"
        ord_date="1992-06-15T00:00:00" qty="20"/>
      <rsSales stor_id="7067" ord_num="P2121"
        ord_date="1992-06-15T00:00:00" qty="20"/>
    </z:row>
...
  </rs:data>
</xml>

The exact order of the columns in the parent Recordset is not obvious when it is persisted in this manner. Any field in the parent may contain a child Recordset. The Persistence Provider persists out all scalar columns first as attributes and then persists out all child Recordset "columns" as child elements of the parent row. The ordinal position of the field in the parent Recordset can be obtained by looking at the schema definition of the Recordset. Every field has an OLE DB property, rs:number, defined in the Recordset schema namespace that contains the ordinal number for that field.

The names of all fields in the child Recordset are concatenated with the name of the field in the parent Recordset that contains this child. This is to ensure that there are no name collisions in cases where parent and child Recordsets both contain a field that is obtained from two different tables but is named singularly.

When saving hierarchical Recordsets into XML, you should be aware of the following restrictions in ADO:

  • A hierarchical Recordset with pending updates cannot be persisted into XML.

  • A hierarchical Recordset created with a parameterized shape command cannot be persisted (in either XML or ADTG format).

  • ADO currently saves the relationship between the parent and the child Recordsets as a binary large object (BLOB). XML tags to describe this relationship have not yet been defined in the rowset schema namespace.

  • When a hierarchical Recordset is saved, all child Recordsets are saved along with it. If the current Recordset is a child of another Recordset, its parent is not saved. All child Recordsets that form the subtree of the current Recordset are saved.

When a hierarchical Recordset is reopened from its XML-persisted format, you must be aware of the following limitations:

  • If the child record contains records for which there are no corresponding parent records, these rows are not written out in the XML representation of the hierarchical Recordset. Thus, these rows will be lost when the Recordset is reopened from its persisted location.

  • If a child record has references to more than one parent record, then on reopening the Recordset, the child Recordset may contain duplicate records. However, these duplicates will only be visible if the user works directly with the underlying child rowset. If a chapter is used to navigate the child Recordset (that is the only way to navigate through ADO), the duplicates are not visible.


Views Refresh Method Example (VB)

 Copy code hover
[image]

Views Refresh Method Example (VB)
Send feedback

The following code shows how to refresh the Views collection of a Catalog. This is required before View objects from the Catalog can be accessed.

Copy code Copy code

' BeginViewsRefreshVB
Sub Main()
 On Error GoTo ProcedureViewsRefreshError

 Dim cat As New ADOX.Catalog

 ' Open the Catalog
 cat.ActiveConnection = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\" & _
 "Microsoft Office\Office\Samples\Northwind.mdb';"

 ' Refresh the Procedures collection
 cat.Views.Refresh

 'Clean up
 Set cat = Nothing
 Exit Sub

ProcedureViewsRefreshError:

 If Not cat Is Nothing Then
 Set cat = Nothing
 End If

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndViewsRefreshVB


AccessObject Properties (Access)

 Copy code hover
[image]

AccessObject Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
CurrentView | Returns the current view for the specified Microsoft Access object. Read-only AcCurrentView.
DateCreated | Returns a Date indicating the date and time when the design of the specified object was last modified. Read-only.
DateModified | Returns a Date indicating the date and time when the design of the specified object was last modified. Read-only.
FullName | Sets or returns the full path (including file name) of a specific object. Read/write String.
IsLoaded | You can use the IsLoaded property to determine if an AccessObject is currently loaded. Read-only Boolean.
IsWeb | Gets whether the specified object is a Web object. Read-only Boolean.
Name | You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a AccessObject object's AccessObjectProperties collection. Read-only.
Type | Returns the value of an AccessObject object type. Read-only AcObjectType.


TextBox.AfterUpdate Event (Access)

 Copy code hover
[image]

TextBox.AfterUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The AfterUpdate event occurs after changed data in a control or record is updated.

Syntax

expression .AfterUpdate

expression A variable that represents a TextBox object.

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's AfterUpdate event does occur.

To run a macro or event procedure when this event occurs, set the AfterUpdate property to the name of the macro or to [Event Procedure].

The AfterUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

AfterUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. AfterUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For bound controls, the OldValue property isn't set to the updated value until after the AfterUpdate event for the form occurs. Even if the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


GoToPage Macro Action

 Copy code hover
[image]

GoToPage Macro Action
Send feedback

You can use the GoToPage action to move the focus in the active form to the first control on a specified page. You can use this action if you have created a form with page breaks that contains groups of related information. For example, you might have an Employees form with personal information on one page, office information on another page, and sales information on a third page. You can use the GoToPage action to move to the desired page. You can also present multiple pages of information on a single form by using tab controls.

Setting

The GoToPage action has the following arguments.

Action argument | Description
Page Number | The number of the page to which you want to move the focus. Enter the page number in the Page Number box in the Action Arguments section of the Macro Builder pane. If you leave this argument blank, the focus stays on the current page. You can use the Right and Down arguments to display the part of the page you want to see.
Right | The horizontal position of the spot on the page, measured from the left edge of its containing window, that is to appear at the left edge of the window. This is required if you specify a Down argument.
Down | The vertical position of the spot on the page, measured from the top edge of its containing window, that is to appear at the top edge of the window. This is required if you specify a Right argument.
Note Note

The Right and Down arguments are measured in inches or centimeters, depending on the regional settings in Windows Control Panel.

Remarks

You can use this action to select the first control (as defined by the form's tab order) on the specified page. Use the GoToControl action to move to a particular control on the form.

You can use the Right and Down arguments for forms with pages larger than the Microsoft Access 2013 window. Use the Page Number argument to move to the desired page, and then use the Right and Down arguments to display the part of the page you want to see. Access displays the part of the page whose upper-left corner is offset the specified distance from the upper-left corner of the page.

You can't use the GoToPage action in the following cases:

  • To move the focus to a page on a hidden form.

  • To move the focus from one page to another within the tab control.

To run the GoToPage action in a Visual Basic for Applications (VBA) module, use the GoToPage method of the DoCmd object.


Attributes and Name Properties Example (VC++)

 Copy code hover
[image]

Attributes and Name Properties Example (VC++)
Send feedback

This example displays the value of the Attributes property for Connection, Field, and Property objects. It uses the Name property to display the name of each Field and Property object.

Copy code Copy code

// BeginAttributesCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void AttributesX();
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 AttributesX();

 //Wait here for user to see the output..
 printf("\nPress any key to continue...");
 getch();

 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// AttributesX Function //
// //
///////////////////////////////////////////////////////////

void AttributesX()
{
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace
 _RecordsetPtr pRstEmployee = NULL;
 _ConnectionPtr pConnection = NULL;
 FieldsPtr fldLoop = NULL;
 PropertiesPtr proLoop = NULL;

 //Define Other Variables
 HRESULT hr = S_OK;
 _variant_t Index;
 Index.vt = VT_I2;
 int j=0;
 //Open a recordset using a Client Cursor
 //For the Employee Table
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 // open connection and record set
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
 pConnection->Open(strCnn,"","",adConnectUnspecified);

 TESTHR(pRstEmployee.CreateInstance(__uuidof(Recordset)));
 pRstEmployee->Open("Employee", _variant_t((IDispatch *)pConnection,true), adOpenForwardOnly,
 adLockReadOnly, adCmdTable);

 // Display the attributes of Connection.
 printf("Connection attributes: %d \n", pConnection->Attributes);

 // Display the attribute of the employee table's
 //fields
 printf("\nFields attributes:\n");
 fldLoop = pRstEmployee->GetFields();

 for (int i = 0; i < (int)fldLoop->GetCount(); i++)
 {
 Index.iVal=i;
 printf (" %s = %d \n",(LPSTR)fldLoop->GetItem(Index)->GetName(),
 (int)fldLoop->GetItem(Index)->GetAttributes());
 }

 // Display Fields of the Employee table which are NULLBALE
 printf("\nNULLABLE Fields :");

 for (int i1 = 0; i1 < (int)fldLoop->GetCount(); i1++)
 {
 Index.iVal = i1;

 if (fldLoop->GetItem(Index)->GetAttributes() & adFldIsNullable)
 {
 printf ("%s \n", (LPSTR)fldLoop->GetItem(Index)->GetName());
 }
 }

 // Display the attributes of the Employee tables's
 // properties
 printf("\nProperty attributes:\n");
 proLoop = pRstEmployee->GetProperties();

 for (int i2 = 0; i2 < (int)proLoop->GetCount(); i2++)
 {
 j= j+1;
 Index.iVal=i2;
 printf (" %s = %d \n", (LPSTR)(_bstr_t)proLoop->GetItem(Index)->GetName()
 ,(int)proLoop->GetItem(Index)->GetAttributes());

 if (((j % 23) == 0) || ( i2==6))
 {
 printf("\nPress any key to continue...");
 getch();

 //Clear the screen for the next display
 system("cls");
 j=0;
 }

 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.

 PrintProviderError(pConnection);
 PrintComError(e);
 }

 // Clean up objects before exit.
 if (pRstEmployee)
 if (pRstEmployee->State == adStateOpen)
 pRstEmployee->Close();
 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.

 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;
 long nCount = 0;
 long i = 0;

 if( (pConnection->Errors->Count) > 0)
 {
 nCount = pConnection->Errors->Count;

 // Collection ranges from 0 to nCount -1.
 for(i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", (LPCSTR) pErr->Number, (LPCSTR) pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////

VOID PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("\nError\n");
 printf("Code = %08lx\n", e.Error());
 printf("Code meaning = %s\n", e.ErrorMessage());
 printf("Source = %s\n", (LPCSTR) bstrSource);
 printf("Description = %s\n", (LPCSTR) bstrDescription);
}
// EndAttributesCpp

AttributesX.h

Copy code Copy code

// BeginAttributesH
#include "icrsint.h"

//This class extracts LastName, FirstName, FaxPhone from Employees table

class CEmployeeRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CEmployeeRs)

 // Column LastName is the 2nd field in the table
 ADO_VARIABLE_LENGTH_ENTRY2(2,adVarChar,m_szemp_LastName,
 sizeof(m_szemp_LastName),lemp_LastNameStatus,TRUE)

 // Column FirstName is the 17th field in the table
 ADO_VARIABLE_LENGTH_ENTRY2(17,adVarChar,m_szemp_FirstName,
 sizeof(m_szemp_FirstName),lemp_FirstNameStatus,TRUE)

 // Column FaxPhone is the 18th field in the table
 ADO_VARIABLE_LENGTH_ENTRY2(18,adVarChar,m_szemp_Faxphone,
 sizeof(m_szemp_Faxphone),lemp_FaxphoneStatus,TRUE)

END_ADO_BINDING()

public:
 CHAR m_szemp_LastName[21];
 ULONG lemp_LastNameStatus;
 CHAR m_szemp_FirstName[11];
 ULONG lemp_FirstNameStatus;
 CHAR m_szemp_Faxphone[25];
 ULONG lemp_FaxphoneStatus;
};

// EndAttributesH


NavigationControl.Requery Method (Access)

 Copy code hover
[image]

NavigationControl.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.

Version Information

Version Added: Access 2010

Syntax

expression .Requery

expression A variable that represents a NavigationControl object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts .

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate function.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

Example

The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form:

VBA Copy code Copy code
Public Sub RequeryList()

    Dim ctlCombo As Control

    ' Return Control object pointing to a combo box.
    Set ctlCombo = Forms!Employees!ReportsTo

    ' Requery source of data for list box.
    ctlCombo.Requery

End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Axes Collection Properties, Methods, and Events (ADO MD)

 Copy code hover
[image]

Axes Collection Properties, Methods, and Events (ADO MD)
Send feedback

Properties

Count Property

Item Property

Methods

Refresh Method

Events

None.


Recordset2.Index Property (DAO)

 Copy code hover
[image]

Recordset2.Index Property (DAO)
Send feedback

Sets or returns a value that indicates the name of the current Index object in a table-type Recordset object (Microsoft Access workspaces only).

Syntax

expression .Index

expression A variable that represents a Recordset2 object.

Remarks

Records in base tables aren't stored in any particular order. Setting the Index property changes the order of records returned from the database; it doesn't affect the order in which the records are stored.

The specified Index object must already be defined. If you set the Index property to an Index object that doesn't exist or if the Index property isn't set when you use the Seek method, a trappable error occurs.

Examine the Indexes collection of a TableDef object to determine what Index objects are available to table-type Recordset objects created from that TableDef object.

You can create a new index for the table by creating a new Index object, setting its properties, appending it to the Indexes collection of the underlying TableDef object, and then reopening the Recordset object.

Records returned from a table-type Recordset object can be ordered only by the indexes defined for the underlying TableDef object. To sort records in some other order, you can open a dynaset-, snapshot-, or forward-only-type Recordset object by using an SQL statement with an ORDER BY clause.

Note Note

  • You don't have to create indexes for tables. With large, unindexed tables, accessing a specific record or creating a Recordset object can take a long time. On the other hand, creating too many indexes slows down update, append, and delete operations because all indexes are automatically updated.

  • Records read from tables without indexes are returned in no particular sequence.

  • The Attributes property of each Field object in the Index object determines the order of records and consequently determines the access techniques to use for that index.

  • A unique index helps optimize finding records.

  • Indexes don't affect the physical order of a base tableindexes affect only how the records are accessed by the table-type Recordset object when a particular index is chosen or when Recordset is opened.

Example

This example uses the Index property to set different record orders for a table-type Recordset.

VBA Copy code Copy code
Sub IndexPropertyX()

   Dim dbsNorthwind As Database
   Dim tdfEmployees As TableDef
   Dim rstEmployees As Recordset2
   Dim idxLoop As Index

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   Set rstEmployees = _
      dbsNorthwind.OpenRecordset("Employees")
   Set tdfEmployees = dbsNorthwind.TableDefs!Employees

   With rstEmployees

      ' Enumerate Indexes collection of Employees table.
      For Each idxLoop In tdfEmployees.Indexes
         .Index = idxLoop.Name
         Debug.Print "Index = " & .Index
         Debug.Print "  EmployeeID - PostalCode - Name"
         .MoveFirst

         ' Enumerate Recordset to show the order of records.
         Do While Not .EOF
            Debug.Print "    " & !EmployeeID & " - " & _
               !PostalCode & " - " & !FirstName & " " & _
               !LastName
            .MoveNext
         Loop

      Next idxLoop

      .Close
   End With

   dbsNorthwind.Close

End Sub

This example demonstrates the Seek method by allowing the user to search for a product based on an ID number.

VBA Copy code Copy code
Sub SeekX()

   Dim dbsNorthwind As Database
   Dim rstProducts As Recordset2
   Dim intFirst As Integer
   Dim intLast As Integer
   Dim strMessage As String
   Dim strSeek As String
   Dim varBookmark As Variant

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   ' You must open a table-type Recordset to use an index,
   ' and hence the Seek method.
   Set rstProducts = _
      dbsNorthwind.OpenRecordset("Products", dbOpenTable)

   With rstProducts
      ' Set the index.
      .Index = "PrimaryKey"

      ' Get the lowest and highest product IDs.
      .MoveLast
      intLast = !ProductID
      .MoveFirst
      intFirst = !ProductID

      Do While True
         ' Display current record information and ask user
         ' for ID number.
         strMessage = "Product ID: " & !ProductID & vbCr & _
            "Name: " & !ProductName & vbCr & vbCr & _
            "Enter a product ID between " & intFirst & _
            " and " & intLast & "."
         strSeek = InputBox(strMessage)

         If strSeek = "" Then Exit Do

         ' Store current bookmark in case the Seek fails.
         varBookmark = .Bookmark

         .Seek "=", Val(strSeek)

         ' Return to the current record if the Seek fails.
         If .NoMatch Then
            MsgBox "ID not found!"
            .Bookmark = varBookmark
         End If
      Loop

      .Close
   End With

   dbsNorthwind.Close

End Sub


No destination field name in INSERT INTO statement

 Copy code hover
[image]

No destination field name in INSERT INTO statement <statement>. (Error 3352)
Send feedback

The destination field name or names cannot be determined from the expression in the SELECT clause of the INSERT INTO statement.


TextBox.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

TextBox.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Syntax

expression .ShortcutMenuBar

expression A variable that represents a TextBox object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

Example

The following example sets the "Suppliers_Toolbar" as the custom shortcut menu to display when the user clicks the right mouse button on the "Suppliers" form.

VBA Copy code Copy code
Forms("Suppliers").ShortcutMenuBar = "Suppliers_Toolbar"

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Form.Cycle Property (Access)

 Copy code hover
[image]

Form.Cycle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Cycle property to specify what happens when you press the TAB key and the focus is in the last control on a bound form. Read/write Byte.

Syntax

expression .Cycle

expression A variable that represents a Form object.

Remarks

The Cycle property uses the following settings.

Setting | Visual Basic | Description
All Records | 0 | (Default) Pressing the TAB key from the last control on a form moves the focus to the first control in the tab order in the next record.
Current Record | 1 | Pressing the TAB key from the last control on a record moves the focus to the first control in the tab order in the same record.
Current Page | 2 | Pressing the TAB key from the last control on a page moves the focus back to the first control in the tab order on the page.
Note Note

You can set the Cycle property by using the form's property sheet, a macro, or Visual Basic .

You can set the Cycle property in any view.

When you press the TAB key on a form, the focus moves through the controls on the form according to each control's place in the tab order.

You can set the Cycle property to All Records for forms designed for data entry. This allows the user to move to a new record by pressing the TAB key.

Note Note

The Cycle property only controls the TAB key behavior on the form where the property is set. If a subform control is in the tab order, once the subform control receives the focus, the Cycle property setting for the subform determines what happens when you press the TAB key.

To move the focus outside a subform control, press CTRL+TAB.

See also

Concepts

Form Object

Other resources

Form Object Members


Find Method Example (VJ++)

 Copy code hover
[image]

Find Method Example (VJ++)
Send feedback

This example uses the Recordset object's Find method to locate and count the number of business titles in the Pubs database. The example assumes the underlying provider does not support similar functionality.

Copy code Copy code

// BeginFindJ
// The WFC class includes the ADO objects.
import com.ms.wfc.data.*;
import java.io.* ;
import com.ms.com.*;

public class FindX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 FindX();
 System.exit(0);
 }

 // FindX function

 static void FindX()
 {

 // Define ADO Objects.
 Connection cnConn1 = null;
 Recordset rstTitles = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';" +
 "Initial Catalog='Pubs';Integrated Security='SSPI';";
 Variant varMark = null;
 int intCount = 0;

 try
 {
 cnConn1 = new Connection();
 cnConn1.open(strCnn);
 rstTitles = new Recordset();
 rstTitles.open("SELECT title_id FROM titles",
 cnConn1,
 AdoEnums.CursorType.STATIC,
 AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TEXT);

 // The default parameters are sufficient to search forward
 // through a Recordset.
 rstTitles.find("title_id LIKE 'BU%'");

 // Skip current record to avoid finding the same row repeatedly.
 // The bookmark is redundant because Find searches from current
 // position.
 while(!rstTitles.getEOF()) // Continue if last find succeeded.
 {
 System.out.println("Title ID: "
 + rstTitles.getField("title_id").getString());
 intCount++; // Count the last title found.
 varMark = (Variant)rstTitles.getBookmark();
 // Note current position.
 rstTitles.find("title_id LIKE 'BU%'",
 1,
 AdoEnums.SearchDirection.FORWARD,
 varMark);
 }

 System.out.println("\nThe number of business titles is " +
 Integer.toString(intCount));
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstTitles != null)
 {
 PrintProviderError(rstTitles.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstTitles != null)
 if (rstTitles.getState() == 1)
 rstTitles.close();
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 }

 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndFindJ


OriginalValue and UnderlyingValue Properties Example (VJ++)

 Copy code hover
[image]

OriginalValue and UnderlyingValue Properties Example (VJ++)
Send feedback

This example demonstrates the OriginalValue and UnderlyingValue properties by displaying a message if a record's underlying data has changed during a Recordset batch update.

Copy code Copy code

// BeginOriginalValueJ
import com.ms.wfc.data.*;
import java.io.* ;

public class OriginalValueX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 OriginalValueX();
 System.exit(0);
 }

 // OriginalValueX function

 static void OriginalValueX()
 {
 // Define ADO Objects.
 Connection cnConn1 = null;
 Recordset rstTitles = null;
 Field fldType = null;

 // Declarations.
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));

 try
 {
 // Open a connection.
 cnConn1 = new Connection();
 cnConn1.open(strCnn);

 // Open recordset for batch update.
 rstTitles = new Recordset();
 rstTitles.setActiveConnection(cnConn1);
 rstTitles.setCursorType(AdoEnums.CursorType.KEYSET);
 rstTitles.setLockType(AdoEnums.LockType.BATCHOPTIMISTIC);
 rstTitles.open("Titles",cnConn1,
 AdoEnums.CursorType.KEYSET,
 AdoEnums.LockType.BATCHOPTIMISTIC,
 AdoEnums.CommandType.TABLE);

 // Set field object variable for Type field.
 fldType = rstTitles.getField("type");

 // Change the type of psychology titles.
 while(!rstTitles.getEOF())
 {
 if(rstTitles.getField("type").getString().
 trim().equals("psychology"))
 fldType.setString("self_help");
 rstTitles.moveNext();
 }

 // Similate a change by another user by updating
 // data using a command string.
 cnConn1.execute("UPDATE Titles SET type = 'sociology' "
 + "WHERE type = 'psychology'");

 // Check for changes.
 rstTitles.moveFirst();

 while(!rstTitles.getEOF())
 {
 String strOriginalValue =
 fldType.getOriginalValue().toString().trim();
 String strUnderlyingValue =
 fldType.getUnderlyingValue().toString().trim();
 if(!(strOriginalValue.equals(strUnderlyingValue)))
 {
 System.out.println("Data has changed!" + "\n\n");
 System.out.println("\tTitle ID: "
 + rstTitles.getField("title_id").getString().trim() +
 "\n");
 System.out.println("\tCurrent value: "
 + fldType.getString()+ "\n");
 System.out.println("\tOriginal value: "
 + fldType.getOriginalValue().toString()+ "\n");
 System.out.println("\tUnderlying value: "
 + fldType.getUnderlyingValue().toString()+ "\n");
 System.out.println("\n\nPress <Enter> to continue..");
 in.readLine();
 }
 rstTitles.moveNext();
 }
 // Cancel the update because this is a demonstration.

 rstTitles.cancelBatch();

 // Restore original values.
 cnConn1.execute("UPDATE Titles SET type = 'psychology' "
 + "WHERE type = 'sociology'");
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstTitles!= null)
 {
 PrintProviderError(rstTitles.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstTitles != null)
 if (rstTitles.getState() == 1)
 rstTitles.close();
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 }

 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndOriginalValueJ


Rectangle.BackTint Property (Access)

 Copy code hover
[image]

Rectangle.BackTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackTint

expression A variable that represents a Rectangle object.

Remarks

The BackTint property contains a numeric expression that can be used to lighten the theme color in the BackColor property. The default value of the BackTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens BackColor by 75%.

VBA Copy code Copy code
Me.ctl.BackTint=25

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


Parameters Collection, Command Property Example (VC++)

 Copy code hover
[image]

Parameters Collection, Command Property Example (VC++)
Send feedback

The following code demonstrates how to use the Command property with the Command object to retrieve parameter information for the procedure.

Copy code Copy code

// This sample runs correctly only if procedure 'CustomerById'
// exists. If the procedure doesn't exist, please use
// 'ADOXProceduresAppend.cpp' to creat it.

// BeginProcedureParametersCpp
#import "c:\Program Files\Common Files\system\ado\msadox.dll" no_namespace
#import "c:\Program Files\Common Files\system\ado\msado15.dll"

#include "iostream.h"
#include "stdio.h"
#include "conio.h"

//Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void ProcedureParametersX(void);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 ProcedureParametersX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// ProcedureParametersX Function //
// //
//////////////////////////////////////////////////////////
void ProcedureParametersX()
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.
 _CatalogPtr m_pCatalog = NULL;

 //Define ADODB object pointers.
 ADODB::_ConnectionPtr m_pCnn = NULL;
 ADODB::_CommandPtr m_pCommand = NULL;
 ADODB::_ParameterPtr m_pParameter = NULL;

 try
 {
 TESTHR(hr = m_pCnn.CreateInstance(__uuidof(ADODB::Connection)));

 //Open the Connection
 m_pCnn->Open("Provider='Microsoft.JET.OLEDB.4.0';"
 "Data Source='c:\\Program Files\\Microsoft Office\\"
 "Office\\Samples\\Northwind.mdb';","","",NULL);

 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof(Catalog)));

 //Open the catalog
 m_pCatalog->PutActiveConnection(_variant_t((IDispatch *)m_pCnn));

 //Get the command object
 m_pCommand = m_pCatalog->Procedures->GetItem("CustomerById")->
 GetCommand();

 _variant_t vIndex;

 //Retrieve Parameter information
 m_pCommand->Parameters->Refresh();
 for (long lIndex = 0; lIndex < m_pCommand->Parameters->Count;
 lIndex ++)
 {
 vIndex = lIndex;
 m_pParameter = m_pCommand->Parameters->GetItem(vIndex);
 cout << m_pParameter->Name << ":" << m_pParameter->Type <<
 "\n" << endl;
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }

 catch(...)
 {
 cout << "Error occured in ProcedureParametersX...."<< endl;
 }
}
// EndProcedureParametersCpp


Event Parameters

 Copy code hover
[image]

Event Parameters
Send feedback

Every event handler has a status parameter that controls the event handler. For Complete events, this parameter is also used to indicate the success or failure of the operation that generated the event. Most Complete events also have an error parameter to provide information about any error that might have occurred, as well as one or more object parameters that refer to the ADO objects used to perform the operation. For example, the ExecuteComplete event includes object parameters for the Command, Recordset, and Connection objects associated with the event. In the following Microsoft Visual Basic example, you can see the pCommand, pRecordset and pConnection objects which represent the Command, Recordset, and Connection objects used by the Execute method.

Copy code Copy code

Private Sub connEvent_ExecuteComplete(ByVal RecordsAffected As Long, _
 ByVal pError As ADODB.Error, _
 adStatus As ADODB.EventStatusEnum, _
 ByVal pCommand As ADODB.Command, _
 ByVal pRecordset As ADODB.Recordset, _
 ByVal pConnection As ADODB.Connection)

Except for the Error object, the same parameters are passed to the Will events. This gives you the opportunity to examine each of the objects to be used in the pending operation and determine whether the operation should be allowed to complete.

Some event handlers have a Reason parameter, which provides additional information about why the event occurred. For example, the WillMove and MoveComplete events can occur due to any one of the navigation methods (MoveNext, MovePrevious, and so on) being called or as the result of a requery.

Status Parameter

When the event-handler routine is called, the Status parameter is set to one of the following values.

Value | Description
adStatusOK | Passed to both Will and Complete events. This value means that the operation that caused the event completed successfully.
adStatusErrorsOccurred | Passed to Complete events only. This value means that the operation that caused the event was unsuccessful, or a Will event canceled the operation. Check the Error parameter for more details.
adStatusCantDeny | Passed to Will events only. This value means that the operation cannot be canceled by the Will event. It must be performed.

If you determine in your Will event that the operation should continue, leave the Status parameter unchanged. As long as the incoming status parameter was not set to adStatusCantDeny, however, you can cancel the pending operation by changing Status to adStatusCancel. When you do so, the Complete event associated with the operation has its Status parameter set to adStatusErrorsOccurred. The Error object passed to the Complete event will contain the value adErrOperationCancelled.

If you no longer want to process an event, you can set Status to adStatusUnwantedEvent and your application will no longer receive notification of that event. Remember, however, that some events can be raised for more than one reason. In that case, you must specify adStatusUnwantedEvent for each possible reason. For example, in order to stop receiving notification of pending RecordChange events, you must set the Status parameter to adStatusUnwantedEvent for adRsnAddNew, adRsnDelete, adRsnUpdate, adRsnUndoUpdate, adRsnUndoAddNew, adRsnUndoDelete, and adRsnFirstChange as they occur.

Value | Description
adStatusUnwantedEvent | Request that this event handler receive no further notifications.
adStatusCancel | Request cancellation of the operation that is about to occur.

Error Parameter

The Error parameter is a reference to an ADO Error object. When the Status parameter is set to adStatusErrorsOccurred, the Error object contains details about why the operation failed. If the Will event associated with a Complete event has canceled the operation by setting the Status parameter to adStatusCancel, the error object is always set to adErrOperationCancelled.

Object Parameter

Each event receives one or more objects representing the objects that are involved in the operation. For example, the ExecuteComplete event receives a Command object, a Recordset object, and a Connection object.

Reason Parameter

The Reason parameter, adReason, provides additional information about why the event occurred. Events with an adReason parameter may be called several times, even for the same operation, each time for a different reason. For example, the WillChangeRecord event handler is called for operations that are about to do or undo the insertion, deletion, or modification of a record. If you want to process an event only when it occurs for a particular reason, you can use the adReason parameter to filter out the occurrences you are not interested in. For example, if you wanted to process record-change events only when they occur because a record was added, you can do something like this:

Copy code Copy code

' BeginEventExampleVB01
Private Sub rsTest_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
 If adReason = adRsnAddNew Then
 ' Process event
 '...
 Else
 ' Cancel event notification for all
 ' other possible adReason values.
 adStatus = adStatusUnwantedEvent
 End If
End Sub
' EndEventExampleVB01

In this case, notification can potentially occur for each of the other reasons. However, it will occur only once for each reason. After the notification has occurred once for each reason, you will receive notification only for the addition of a new record.

In contrast, you need to set adStatus to adStatusUnwantedEvent only one time to request that an event handler without an adReason parameter stop receiving event notifications.


Image.Tag Property (Access)

 Copy code hover
[image]

Image.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents an Image object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

Image Object

Other resources

Image Object Members


CodeProject.Resources Property (Access)

 Copy code hover
[image]

CodeProject.Resources Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the SharedResources collection for the specified object. Read-only SharedResources.

Version Information

Version Added: Access 2010

Syntax

expression .Resources

expression A variable that represents a CodeProject object.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


ComboBox.ColumnHidden Property (Access)

 Copy code hover
[image]

ComboBox.ColumnHidden Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.

Syntax

expression .ColumnHidden

expression A variable that represents a ComboBox object.

Remarks

For example, you might want to hide a CustomerAddress field that's too wide so you can view the CustomerName and PhoneNumber fields.

Note Note

The ColumnHidden property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

Hiding a column with the ColumnHidden property in Datasheet view doesn't hide fields from the same column in Form view. Similarly, setting a control's Visible property to False in Form view doesn't hide the corresponding column in Datasheet view.

Note Note

To set or change this property for a table or query by using Visual Basic, you must use a column's Properties collection. For details on using the Properties collection, see Properties .

You can display a field in a query even though the column for the field is hidden in table Datasheet view. You can use values from a hidden column as the criteria for a filter even though the column remains hidden after the filter is applied.

Setting a field's ColumnWidth property to 0, or resizing the field to a zero width in Datasheet view, causes Microsoft Access to set the corresponding ColumnHidden property to True. Unhiding a column restores the ColumnWidthColumnWidth property to the value it had before the field was hidden.

Note Note

The ColumnHidden property is not available in Design view.

Example

The following example hides the ProductID field in Datasheet view of the Products form.

VBA Copy code Copy code
Forms!Products!ProductID.ColumnHidden = -1

The next example also hides the ProductID field in Datasheet view of the Products table.

VBA Copy code Copy code
Public Sub SetColumnHidden()

 Dim dbs As DAO.Database
 Dim fld As DAO.Field
 Dim prp As DAO.Property
 Const conErrPropertyNotFound = 3270

 ' Turn off error trapping.
 On Error Resume Next

 Set dbs = CurrentDb

 ' Set field property.
 Set fld = dbs.TableDefs!Products.Fields!ProductID
 fld.Properties("ColumnHidden") = True

 ' Error may have occurred when value was set.
 If Err.Number <> 0 Then
 If Err.Number <> conErrPropertyNotFound Then
 On Error GoTo 0
 MsgBox "Couldn't set property 'ColumnHidden' " & _
 "on field '" & fld.Name & "'", vbCritical
 Else
 On Error GoTo 0
 Set prp = fld.CreateProperty("ColumnHidden", dbLong, True)
 fld.Properties.Append prp
 End If
 End If

 Set prp = Nothing
 Set fld = Nothing
 Set dbs = Nothing

End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


OptionButton.OnKeyDown Property (Access)

 Copy code hover
[image]

OptionButton.OnKeyDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Down box in the Properties window. Read/write String.

Syntax

expression .OnKeyDown

expression A variable that represents an OptionButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyDown event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyDown

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Navigating Through the Data (ADO)

 Copy code hover
[image]

Navigating Through the Data (ADO)
Send feedback

In this section

  • Navigating Through the Data

  • Jumping to a Record

  • More Ways to Move in a Recordset

  • Using Bookmarks

  • Using Pages

  • Recordset Positioning


Chapter 8: Understanding Cursors and Locks (ADO)

 Copy code hover
[image]

Chapter 8: Understanding Cursors and Locks (ADO)
Send feedback

In this section

  • Chapter 8: Understanding Cursors and Locks

  • What is a Cursor?

  • The Significance of Cursor Location

  • The Microsoft Cursor Service for OLE DB

  • Using CacheSize

  • Cursor and Lock Characteristics

  • What is a Lock? (ADO)

  • Types of Cursors (ADO)


Form.BeforeInsert Property (Access)

 Copy code hover
[image]

Form.BeforeInsert Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the BeforeInsert event occurs. Read/write.

Syntax

expression .BeforeInsert

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the BeforeInsert event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).BeforeInsert = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


Cannot open any more tables or queries. (Error 3037)

 Copy code hover
[image]

Cannot open any more tables or queries. (Error 3037)
Send feedback

You have reached the limit on the number of tables and queries that can be opened at one time. Close one or more tables or queries, and then try the operation again.


Report.OnClose Property (Access)

 Copy code hover
[image]

Report.OnClose Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Close box in the Properties window of a form or report. Read/write String.

Syntax

expression .OnClose

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Close event occurs when when a form or report is closed and removed from the screen.

The OnClose value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Close box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Close box is blank, the property value is an empty string.

See also

Concepts

Report Object

Other resources

Report Object Members


SmartTagActions Object (Access)

 Copy code hover
[image]

SmartTagActions Object (Access)
See also Send feedback

Published: July 16, 2012

Represents a collection of actions for an individual smart tag or a type of smart tag.

Remarks

Smart tag actions are processes that are programmed into smart tags; they allow users to perform certain functions related to the smart tag. For example, one action for a smart tag might be to access a Web site, while another action inserts contact information from Microsoft Outlook, while yet another action displays a map and driving directions.

To return the collection of actions related to a smart tag, use the SmartTagActions property of the SmartTag object.

See also

Concepts

Access Object Model Reference

Other resources

SmartTagActions Object Members


PageBreak Properties (Access)

 Copy code hover
[image]

PageBreak Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
Visible | Returns or sets whether the object is visible. Read/write Boolean.


FormatCondition.Delete Method (Access)

 Copy code hover
[image]

FormatCondition.Delete Method (Access)
See also Send feedback

Published: July 16, 2012

Deletes the specified object.

Syntax

expression .Delete

expression A variable that represents a FormatCondition object.

Return Value

Nothing

See also

Concepts

FormatCondition Object

Other resources

FormatCondition Object Members


How to: Allow Users to Add Items to an Unbound Combo Box

 Copy code hover
[image]

How to: Allow Users to Add Items to an Unbound Combo Box
Send feedback

The following example uses the NotInList event to add an item to a combo box.

To try this example, create a combo box called Colors on a form. Set the combo box's LimitToList property to Yes. To populate the combo box, set the combo box's RowSourceType property to Value List, and supply a list of values separated by semicolons as the setting for the RowSource property. For example, you might supply the following values as the setting for this property: Red; Green; Blue.

Next, add the following event procedure to the form. Switch to Form view and enter a new value in the text portion of the combo box.

VBA Copy code Copy code
Private Sub Colors_NotInList(NewData As String, _
        Response As Integer)
    Dim ctl As Control

    ' Return Control object that points to combo box.
    Set ctl = Me!Colors
    ' Prompt user to verify they want to add new value.
    If MsgBox("Value is not in list. Add it?", _
         vbOKCancel) = vbOK Then
        ' Set Response argument to indicate that data
        ' is being added.
        Response = acDataErrAdded
        ' Add string in NewData argument to row source.
        ctl.RowSource = ctl.RowSource & ";" & NewData
    Else
    ' If user chooses Cancel, suppress error message
    ' and undo changes.
        Response = acDataErrContinue
        ctl.Undo
    End If
End Sub
Note Note

This example adds an item to an unbound combo box. When you add an item to a bound combo box, you add a value to a field in the underlying data source. In most cases you cannot simply add one field in a new record. Depending on the structure of data in the table, you probably will need to add one or more fields to fulfill data requirements. For instance, a new record must include values for any fields comprising the primary key. If you need to add items to a bound combo box dynamically, you must prompt the user to enter data for all required fields, save the new record, and then requery the combo box to display the new value.


Report.Modal Property (Access)

 Copy code hover
[image]

Report.Modal Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Modal property to specify whether a report opens as a modal window. When a report opens as a modal window, you must close the window before you can move the focus to another object. Read/write Boolean.

Syntax

expression .Modal

expression A variable that represents a Report object.

Remarks

The Modal property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The form or report opens as a modal window.
No | False | (Default) The form opens as a non-modal window.

When you open a modal window, other windows in Microsoft Access are disabled until you close it (although you can switch to windows in other applications). To disable menus and toolbars in addition to other windows, set both the Modal and PopUp properties to Yes.

See also

Concepts

Report Object

Other resources

Report Object Members


CommandButton.Transparent Property (Access)

 Copy code hover
[image]

CommandButton.Transparent Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Transparent property to specify whether a command button is solid or transparent. Read/write Boolean.

Syntax

expression .Transparent

expression A variable that represents a CommandButton object.

Remarks

Use the BackStyle property to make other controls solid or transparent.

You can use this property to place a transparent command button over another control. For example, you could place several transparent buttons over a picture displayed in an image control and run various macros or Visual Basic event procedures depending on which part of the picture the user clicks.

Note Note

To hide and disable a button, use the Visible property. To disable a button without hiding it, use the Enabled property. To hide a button only when a form or report is printed, use the DisplayWhen property.

Example

The following example makes the command button "Preview" on the "Purchase Orders" form transparent.

VBA Copy code Copy code
Forms.Item("Purchase Orders").Controls.Item("Preview"). _
 Transparent = True

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


AcWebBrowserScrollBars Enumeration (Access)

 Copy code hover
[image]

AcWebBrowserScrollBars Enumeration (Access)
Send feedback

Published: July 16, 2012

Used by the ScrollBars property to specify whether scroll bars are displayed.

Version Information

Version Added: Access 2010

Name | Value | Description
acScrollAuto | 0 | Scroll bars are displayed if the currrent page in the control is too large to be displayed in its entirely.
acScrollNo | 2 | Scroll bars are not displayed.
acScrollYes | 1 | Scroll bars are displayed.


CustomControl.Width Property (Access)

 Copy code hover
[image]

CustomControl.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents a CustomControl object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


NavigationControl.IsVisible Property (Access)

 Copy code hover
[image]

NavigationControl.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .IsVisible

expression A variable that represents a NavigationControl object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


OptionButton Object (Access)

 Copy code hover
[image]

OptionButton Object (Access)
See also Send feedback

Published: July 16, 2012

An option button on a form or report is a stand-alone control used to display a Yes/No value from an underlying record source.

Remarks

When you select or clear an option button that's bound to a Yes/No field, Microsoft Access displays the value in the underlying table according to the field's Format property (Yes/No, True/False, or On/Off).

You can also use option buttons in an option group to display values to choose from.

It's also possible to use an unbound option button in a custom dialog box to accept user input.

See also

Concepts

Access Object Model Reference

Other resources

OptionButton Object Members


Attachment.FileURL Property (Access)

 Copy code hover
[image]

Attachment.FileURL Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Uniform Resource Locator (URL) of the specified attachment. Read-only String.

Version Information

Version Added: Access 2007

Syntax

expression .FileURL(var)

expression A variable that represents an Attachment object.

Parameters

Name | Required/Optional | Data Type | Description
var | Optional | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection.

Remarks

The FileURL property returns an empty string if the table that contains the attachments is not linked to a SharePoint list.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Report.GotFocus Event (Access)

 Copy code hover
[image]

Report.GotFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The GotFocus event occurs when the report receives the focus.

Version Information

Version Added: Access 2007

Syntax

expression .GotFocus

expression A variable that represents a Report object.

Remarks

To run a macro or event procedure when these events occur, set the OnGotFocus property to the name of the macro or to [Event Procedure].

These events occur when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

See also

Concepts

Report Object

Other resources

Report Object Members


URL Property Example (VBScript)

 Copy code hover
[image]

URL Property Example (VBScript)
Send feedback

The following code demonstrates how to set the URL property on the client side to specify an .asp file that in turn handles the submission of changes to the data source.

VBS Copy code Copy code
<!-- BeginURLClientVBS -->
<%@ Language=VBScript %>
<html>
<head>
<meta name="VI60_DefaultClientScript" content=VBScript>
<meta name="GENERATOR" content="Microsoft Visual Studio 6.0">
<title>URL Property Example (VBScript)</title>
<style>
<!--
body {
font-family: 'Verdana','Arial','Helvetica',sans-serif;
BACKGROUND-COLOR:white;
COLOR:black;
}

.thead {
background-color: #008080;
font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;
color: white;
}

.thead2 {
background-color: #800000;
font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;
color: white;
}

.tbody {
text-align: center;
background-color: #f7efde;
font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;
}
-->

</style>
</head>
<body onload=Getdata()>
<h1>URL Property Example (VBScript)</h1>
<OBJECT classid=clsid:BD96C556-65A3-11D0-983A-00C04FC29E33 height=1 id=ADC width=1>
</OBJECT>

<table datasrc="#ADC" align="center">
<thead>
<tr id="ColHeaders" class="thead2">
<th>FirstName</th>
<th>LastName</th>
<th>Extension</th>
</tr>
</thead>
<tbody class="tbody">
<tr>
<td><input datafld="FirstName" size=15> </td>
<td><input datafld="LastName" size=25> </td>
<td><input datafld="Extension" size=15> </td>
</tr>
</tbody>
</table>

<script Language="VBScript">

Sub Getdata()

msgbox "getdata"

ADC.URL = "http://<%=Request.ServerVariables("SERVER_NAME")%>/URLServerVBS.asp"

ADC.Refresh

End Sub
</script>
</body>
</html>
<!-- EndURLClientVBS -->

The server-side code that exists in URLServerVBS.asp submits the updated Recordset to the data source.

VBS Copy code Copy code
<!-- BeginURLServerVBS -->
<%@ Language=VBScript %>
<%
' XML output req's
Response.ContentType = "text/xml"

const adPersistXML = 1

' recordset vars
Dim strSQL, rsEmployees
Dim strCnxn, Cnxn

strCnxn = "Provider='sqloledb';Data Source=" & _
Request.ServerVariables("SERVER_NAME") & ";" & _
"Integrated Security='SSPI';Initial Catalog='Northwind';"

Set Cnxn = Server.CreateObject("ADODB.Connection")

Set rsEmployees = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT FirstName, LastName, Extension FROM Employees"

Cnxn.Open strCnxn

rsEmployees.Open strSQL, Cnxn

' output as XML
rsEmployees.Save Response, adPersistXML

' Clean up
rsEmployees.Close
Cnxn.Close
Set rsEmployees = Nothing
Set Cnxn = Nothing
%>
<!-- EndURLServerVBS -->


CheckBox.RightPadding Property (Access)

 Copy code hover
[image]

CheckBox.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the check box and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .RightPadding

expression A variable that represents a CheckBox object.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Application.Nz Method (Access)

 Copy code hover
[image]

Application.Nz Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the Nz function to return zero, a zero-length string (" "), or another specified value when a Variant is Null. For example, you can use this function to convert a Null value to another value and prevent it from propagating through an expression.

Syntax

expression .Nz(Value, ValueIfNull)

expression A variable that represents an Application object.

Parameters

Name

Required/Optional

Data Type

Description

Value

Required

Variant

A variable of data type Variant.

ValueIfNull

Optional

Variant

Optional (unless used in a query). A Variant that supplies a value to be returned if the variant argument is Null. This argument enables you to return a value other than zero or a zero-length string.

Note Note

If you use the Nz function in an expression in a query without using the valueifnull argument, the results will be a zero-length string in the fields that contain null values.

Return Value

Variant

Remarks

If the value of the variant argument is Null, the Nz function returns the number zero or a zero-length string (always returns a zero-length string when used in a query expression), depending on whether the context indicates the value should be a number or a string. If the optional valueifnull argument is included, then the Nz function will return the value specified by that argument if the variant argument is Null. When used in a query expression, the Nz function should always include the valueifnull argument.

If the value of variant isn't Null, then the Nz function returns the value of variant.

The Nz function is useful for expressions that may include Null values. To force an expression to evaluate to a non-Null value even when it contains a Null value, use the Nz function to return zero, a zero-length string, or a custom return value.

For example, the expression 2 + varX will always return a Null value when the Variant varX is Null. However, 2 + Nz(varX) returns 2.

You can often use the Nz function as an alternative to the IIf function. For example, in the following code, two expressions including the IIf function are necessary to return the desired result. The first expression including the IIf function is used to check the value of a variable and convert it to zero if it is Null.

VBA Copy code Copy code
varTemp = IIf(IsNull(varFreight), 0, varFreight)
varResult = IIf(varTemp > 50, "High", "Low")

In the next example, the Nz function provides the same functionality as the first expression, and the desired result is achieved in one step rather than two.

VBA Copy code Copy code
varResult = IIf(Nz(varFreight) > 50, "High", "Low")

If you supply a value for the optional argument valueifnull, that value will be returned when variant is Null. By including this optional argument, you may be able to avoid the use of an expression containing the IIf function. For example, the following expression uses the IIf function to return a string if the value of varFreight is Null.

VBA Copy code Copy code
varResult = IIf(IsNull(varFreight), "No Freight Charge", varFreight)

In the next example, the optional argument supplied to the Nz function provides the string to be returned if varFreight is Null.

VBA Copy code Copy code
varResult = Nz(varFreight, "No Freight Charge")

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Nulls and Their Behavior

Example

The following example evaluates a control on a form and returns one of two strings based on the control's value. If the value of the control is Null, the procedure uses the Nz function to convert a Null value to a zero-length string.

VBA Copy code Copy code
Public Sub CheckValue()

    Dim frm As Form
    Dim ctl As Control
    Dim varResult As Variant

    ' Return Form object variable pointing to Orders form.
    Set frm = Forms!Orders

    ' Return Control object variable pointing to ShipRegion.
    Set ctl = frm!ShipRegion

    ' Choose result based on value of control.
    varResult = IIf(Nz(ctl.Value) = vbNullString, _
        "No value.", "Value is " & ctl.Value & ".")

    ' Display result.
    MsgBox varResult, vbExclamation

End Sub

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Application Object

Other resources

Application Object Members


NavigationControl.Section Property (Access)

 Copy code hover
[image]

NavigationControl.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .Section

expression A variable that represents a NavigationControl object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Application.DFirst Method (Access)

 Copy code hover
[image]

Application.DFirst Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the DFirst function to return a random record from a particular field in a table or query when you simply need any value from that field.

Syntax

expression .DFirst(Expr, Domain, Criteria)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Expr | Required | String | An expression that identifies the field from which you want to find the first or last value. It can be either a string expression identifying a field in a table or query, or an expression that performs a calculation on data in that field. In expr, you can include the name of a field in a table, a control on a form, a constant, or a function. If expr includes a function, it can be either built-in or user-defined, but not another domain aggregate or SQL aggregate function.
Domain | Required | String | A string expression identifying the set of records that constitutes the domain.
Criteria | Optional | Variant | An optional string expression used to restrict the range of data on which the DFirst function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the wrd WHERE. If criteria is omitted, the DFirst function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain; otherwise, the DFirst function returns a Null.

Return Value

Variant

Remarks

Note Note

If you want to return the first or last record in a set of records (a domain), you should create a query sorted as either ascending or descending and set the TopValues property to 1. From Visual Basic, you can also create an ADO Recordset object and use the MoveFirst or MoveLast method to return the first or last record in a set of records.

Example

The following examples show how to use various types of criteria with the DFirst function.

Sample code provided by: Community Member Icon The UtterAccess community | About the Contributors

Copy code Copy code
    ' ***************************
    ' Typical Use
    ' Numerical values. Replace "number" with the number to use.
    variable = DFirst("[FieldName]", "TableName", "[Criteria] = number")

    ' Strings.
    ' Numerical values. Replace "string" with the string to use.
    variable = DFirst("[FieldName]", "TableName", "[Criteria]= 'string'")

    ' Dates. Replace "date" with the string to use.
    variable = DFirst("[FieldName]", "TableName", "[Criteria]= #date#")
    ' ***************************

    ' ***************************
    ' Referring to a control on a form
    ' Numerical values
    variable = DFirst("[FieldName]", "TableName", "[Criteria] = " & Forms!FormName!ControlName)

    ' Strings
    variable = DFirst("[FieldName]", "TableName", "[Criteria] = '" & Forms!FormName!ControlName & "'")

    ' Dates
    variable = DFirst("[FieldName]", "TableName", "[Criteria] = #" & Forms!FormName!ControlName & "#")
    ' ***************************

    ' ***************************
    ' Combinations
    ' Multiple types of criteria
    variable = DFirst("[FieldName]", "TableName", "[Criteria1] = " & Forms![FormName]![Control1] _
             & " AND [Criteria2] = '" & Forms![FormName]![Control2] & "'" _
            & " AND [Criteria3] =#" & Forms![FormName]![Control3] & "#")

    ' Use two fields from a single record.
    variable = DFirst("[LastName] & ', ' & [FirstName]", "tblPeople", "[PrimaryKey] = 7")

    ' Expressions
    variable = DFirst("[Field1] + [Field2]", "tableName", "[PrimaryKey] = 7")

    ' Control Structures
    variable = DFirst("IIf([LastName] Like 'Smith', 'True', 'False')", "tableName", "[PrimaryKey] = 7")
    ' ***************************

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Application Object

Other resources

Application Object Members


Reference Members (Access)

 Copy code hover
[image]

Reference Members (Access)
Send feedback

Published: July 16, 2012

The Reference object refers to a reference set to another application's or project's type library.

Properties

Name | Description
BuiltIn | The BuiltIn property returns a Boolean value indicating whether a Reference object points to a default reference that's necessary for Microsoft Access to function properly. Read-only Boolean.
Collection | The Collection property returns a reference to the collection that contains an object. Read-only References object.
FullPath | The FullPath property returns a string containing the path and file name of the referenced type library.
Guid | The GUID property of a Reference object returns a GUID that identifies a type library in the Windows Registry. Read-only String.
IsBroken | The IsBroken property returns a Boolean value indicating whether a Reference object points to a valid reference in the Windows Registry. Read-only Boolean.
Kind | The Kind property indicates the type of reference that a Reference object represents. Read-only vbext_RefKind.
Major | The Major property of a Reference object returns a read-only Long value indicating the major version number of an application to which you have set a reference.
Minor | The Minor property of a Reference object returns a Long value indicating the minor version number of the application to which you have set a reference.
Name | You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.


Convert Library Databases and Add-Ins

 Copy code hover
[image]

Convert Library Databases and Add-Ins
Send feedback

Published: July 16, 2012

If you use add-ins or library databases created in versions of Microsoft Access before 2002, you must convert them to Microsoft Access 2002 - 2003 format before you can use them with applications created in Access.

You may also need to make some changes to the objects, macros, and procedures in your library databases and add-ins in order to make sure that they function properly.

Referencing and Loading Library Databases

Before using a library in Microsoft Access 2002 or later, you must establish a reference to the library database from each of your applications that uses it. You establish such a reference by clicking References on the Tools menu while in module Design view. A referenced database must be in Microsoft Access 2002 format.

A library database should contain only Visual Basic code, which you can call from any application that maintains a reference to that library. In versions 1.x and 2.0 of Microsoft Access, you load a library database at startup by creating an entry in the Libraries section of your .ini file. Most of the information that's stored in an .ini file in versions 1.x and 2.0 is stored in the Windows registry in later versions. However, there's no need to create a Windows registry key in order to use a library database.

Circular References Between Libraries

In versions 1.x and 2.0 of Microsoft Access, you can make circular library references. However, these aren't allowed in later versions of Microsoft Access. In other words, once you've created a reference from Library A to Library B, you cannot create a reference from Library B to Library A.


SubForm.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

SubForm.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents a SubForm object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BorderThemeColorIndex=2

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


NavigationControl.Properties Property (Access)

 Copy code hover
[image]

NavigationControl.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Properties

expression A variable that represents a NavigationControl object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


File sharing lock count exceeded. (Error 3052)

 Copy code hover
[image]

File sharing lock count exceeded. (Error 3052)
Send feedback

You have exceeded the maximum number of locks allowed on a recordset. This limit is specified by the MaxLocksPerFile setting in your system registry. The default value is 9500, and can be changed either by editing the registry with Regedit.exe or with the SetOption method.

Some other factors that may cause an application to reach this threshold include the following:

  • amount of available memory

  • size of rows in the recordset

  • network operating system restrictions


ADOX Code Examples in Microsoft Visual Basic

 Copy code hover
[image]

ADOX Code Examples in Microsoft Visual Basic
Send feedback

These topics provide sample code to help you understand how to use ADOX. All code examples are written using Microsoft Visual Basic.

Note Note

Paste the entire code example, from Sub to End Sub, into your code editor. The example may not run correctly if you use partial examples or if paragraph formatting is lost.

Methods

  • Columns and Tables Append Methods, Name Property Example (VB)

  • Connection Close Method, Table Type Property Example (VB)

  • Create Method Example (VB)

  • GetObjectOwner and SetObjectOwner Methods Example (VB)

  • GetPermissions and SetPermissions Methods Example (VB)

  • Groups and Users Append, ChangePassword Methods Example (VB)

  • Indexes Append Method Example (VB)

  • Keys Append Method, Key Type, RelatedColumn, RelatedTable, and UpdateRule Properties Example (VB)

  • Procedures Append Method Example (VB)

  • Procedures Delete Method Example (VB)

  • Procedures Refresh Method Example (VB)

  • Views Append Method Example (VB)

  • Views Delete Method Example (VB)

  • Views Refresh Method Example (VB)

Properties

  • Attributes Property Example (VB)

  • Catalog ActiveConnection Property Example (VB)

  • Clustered Property Example (VB)

  • Command and CommandText Properties Example (VB)

  • Command Property, Parameters Collection Example (VB)

  • CommandText Property, Views Collection Example (VB)

  • DateCreated and DateModified Properties Example (VB)

  • DefinedSize Property Example (VB)

  • DeleteRule Property Example (VB)

  • IndexNulls Property Example (VB)

  • Key Type, RelatedColumn, RelatedTable, and UpdateRule Properties, Keys Append Method Example (VB)

  • Name Property, Columns and Tables Append Methods Example (VB)

  • NumericScale and Precision Properties Example (VB)

  • ParentCatalog Property Example (VB)

  • PrimaryKey and Unique Properties Example (VB)

  • SortOrder Property Example (VB)

  • Table Type Property, Connection Close Method, Example (VB)

Collections

  • Parameters Collection, Command Property Example (VB)

  • Views and Fields Collections Example (VB)

  • Views Collection, CommandText Property Example (VB)


Comparison of Microsoft Access SQL and ANSI SQL

 Copy code hover
[image]

Comparison of Microsoft Access SQL and ANSI SQL
Send feedback

Microsoft Access database engine SQL is generally ANSI-89 Level 1 compliant. However, certain ANSI SQL features are not implemented in Microsoft® Access SQL. Conversely, Microsoft Access SQL includes reserved words and features not supported in ANSI SQL.

Major Differences

  • Microsoft Access SQL and ANSI SQL each have different reserved words and data types. For more information, see Microsoft Access Database Engine SQL Reserved Words and Equivalent ANSI SQL Data Types. Using the Microsoft Access Database Engine OLE DB Provider there are additional reserved words.

  • Between…And

    expr1 [NOT] Between value1 And value2

    In Microsoft Access SQL, value1 can be greater than value2; in ANSI SQL, value1 must be equal to or less than value2.

  • Microsoft Access SQL supports both ANSI SQL wildcard characters and wildcard characters that are specific to the Microsoft Access database engine to use with the Like operator. The use of the ANSI and Microsoft Access database engine wildcard characters is mutually exclusive. You must use one set or the other and cannot mix them. The ANSI SQL wildcards are only available when using the Microsoft Access database engine and the Microsoft Access Database Engine OLE DB Provider. If you try to use the ANSI SQL wildcards through Microsoft Access or DAO, then they will be interpreted as literals. The opposite is true when using the Microsoft Access Database Engine OLE DB Provider.

    Matching character

    Microsoft Access SQL

    ANSI SQL

    Any single character

    ?

    _ (underscore)

    Zero or more characters

    *

    %

  • Microsoft Access SQL is generally less restrictive. For example, it permits grouping and ordering on expressions.

  • Microsoft Access SQL supports more powerful expressions.

Enhanced Features of Microsoft Access SQL

Microsoft Access SQL provides the following enhanced features:

  • The TRANSFORM statement, which provides support for crosstab queries.

  • Additional aggregate functions, such as StDev and VarP.

  • The PARAMETERS declaration for defining parameter queries.

ANSI SQL Features Not Supported in Microsoft Access SQL

Microsoft Access SQL does not support the following ANSI SQL features:

  • DISTINCT aggregate function references. For example, Microsoft Access SQL does not allow SUM(DISTINCT columnname).

  • The LIMIT TO nn ROWS clause used to limit the number of rows returned by a query. You can use only the WHERE clause to limit the scope of a query.


 Copy code hover
[image]

<> (Not Equal To) (Access 2013 custom web app)
Send feedback

Compares two expressions. When you compare non-null expressions, the result is TRUE if the left operand is not equal to the right operand; otherwise, the result is FALSE.

Syntax

expression <> expression

expression Is any valid expression. Both expressions must have implicitly convertible data types. The conversion depends on the rules of data type precedence.

Return Type

Boolean


TextBox.AfterUpdate Property (Access)

 Copy code hover
[image]

TextBox.AfterUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.

Syntax

expression .AfterUpdate

expression A variable that represents a TextBox object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the AfterUpdate event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the AfterUpdate event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).AfterUpdate = "[Event Procedure]"

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


NavigationControl.SizeToFit Method (Access)

 Copy code hover
[image]

NavigationControl.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Version Information

Version Added: Access 2010

Syntax

expression .SizeToFit

expression A variable that represents a NavigationControl object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Rectangle.OnMouseMove Property (Access)

 Copy code hover
[image]

Rectangle.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Syntax

expression .OnMouseMove

expression A variable that represents a Rectangle object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


ObjectFrame.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

ObjectFrame.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified frame. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleBottom

expression A variable that represents an ObjectFrame object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


CommandButton.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

CommandButton.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthBottom

expression A variable that represents a CommandButton object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


TabControl.BackThemeColorIndex Property (Access)

 Copy code hover
[image]

TabControl.BackThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackThemeColorIndex

expression A variable that represents a TabControl object.

Remarks

The BackThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BackThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Background Color to the Text 2 color by setting the BackThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BackThemeColorIndex=2

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


The current field must match the join key

 Copy code hover
[image]

The current field must match the join key <name> in the table that serves as the 'one' side of one-to-many relationship. (Error 3341)
Send feedback

You have tried to enter a value into the join field in the many-only table of an outer join with no corresponding value in the join field of the "one" side table.

The message includes the following instruction: Enter a record in the "one" side table with the desired key value, and then make the entry with the desired join field in the "many-only" table.


Module Methods (Access)

 Copy code hover
[image]

Module Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
AddFromFile | The AddFromFile method adds the contents of a text file to a Module object. The Module object may represent a standard module or a class module.
AddFromString | The AddFromString method adds a string to a Module object. The Module object may represent a standard module or a class module.
CreateEventProc | The CreateEventProc method creates an event procedure in a class module.
DeleteLines | The DeleteLines method deletes lines from a standard module or a class module.
Find | Finds specified text in a standard module or class module.
InsertLines | The InsertLines method inserts a line or group of lines of code in a standard module or a class module.
InsertText | The InsertText method inserts a specified string of text into a standard module or a class module.
ReplaceLine | The ReplaceLine method replaces a specified line in a standard module or a class module.


OptionGroup.LabelAlign Property (Access)

 Copy code hover
[image]

OptionGroup.LabelAlign Property (Access)
See also Send feedback

Published: July 16, 2012

The property specifies the text alignment within attached labels on new controls. Read/write Byte.

Syntax

expression .LabelAlign

expression A variable that represents an OptionGroup object.

Remarks

The LabelAlign property uses the following settings.

Setting | Description
0 | (Default) The label text aligns to the left.
1 | The label text aligns to the left.
2 | The label text is centered.
3 | The label text aligns to the right.
4 | The label text is evenly distributed.

You can set the LabelAlign property by using a control's default control style or the DefaultControl property in Visual Basic.

When created, controls have an attached label (as long as their AutoLabel property is set to Yes). Changes to the LabelAlign default control style setting affect only controls created on the current form or report.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


CheckBox.MouseUp Event (Access)

 Copy code hover
[image]

CheckBox.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents a CheckBox object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was released to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


AcView Enumeration (Access)

 Copy code hover
[image]

AcView Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies an object's view.

Name | Value | Description
acViewDesign | 1 | Design view
acViewLayout | 6 | Layout view
acViewNormal | 0 | (Default) Normal view
acViewPivotChart | 4 | PivotChart view
acViewPivotTable | 3 | PivotTable view
acViewPreview | 2 | Print Preview
acViewReport | 5 | Report view


Attachment.Width Property (Access)

 Copy code hover
[image]

Attachment.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .Width

expression A variable that represents an Attachment object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Catalog Object (ADO MD)

 Copy code hover
[image]

Catalog Object (ADO MD)
Send feedback

Contains multidimensional schema information (that is, cubes and underlying dimensions, hierarchies, levels, and members) specific to a multidimensional data provider (MDP).

Remarks

With the collections and properties of a Catalog object, you can do the following:

  • Open the catalog by setting the ActiveConnection property to a standard ADO Connection object or to a valid connection string.

  • Identify the Catalog with the Name property.

  • Iterate through the cubes in a catalog using the CubeDefs collection.


Field2.DefaultValue Property (DAO)

 Copy code hover
[image]

Field2.DefaultValue Property (DAO)
Send feedback

Sets or returns the default value of a Field2 object. For a Field2 object not yet appended to the Fields collection, this property is read/write (Microsoft Access workspaces only).

Syntax

expression .DefaultValue

expression A variable that represents a Field2 object.

Remarks

The setting or return value is a String data type that can contain a maximum of 255 characters. It can be either text or an expression. If the property setting is an expression, it can't contain user-defined functions, Microsoft Access database engine SQL aggregate functions, or references to queries, forms, or other Field2 objects.

Note Note

You can also set the DefaultValue property of a Field2 object on a TableDef object to a special value called "GenUniqueID( )". This causes a random number to be assigned to this field whenever a new record is added or created, thereby giving each record a unique identifier. The field's Type property must be Long.

The availability of the DefaultValue property depends on the object that contains the Fields collection, as shown in the following table.

If the Fields collection belongs to an | Then DefaultValue is
Index object | Not supported
QueryDef object | Read-only
Recordset object | Read-only
Relation object | Not supported
TableDef object | Read/write

When a new record is created, the DefaultValue property setting is automatically entered as the value for the field. You can change the field value by setting its Value property.

The DefaultValue property doesn't apply to AutoNumber and Long Binary fields.

Example

This example uses the DefaultValue property to alert the user of a field's normal value while prompting for input. In addition, it demonstrates how new records will be filled using DefaultValue in the absence of any other input. The DefaultPrompt function is required for this procedure to run.

VBA Copy code Copy code
Sub DefaultValueX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim strOldDefault As String
 Dim rstEmployees As Recordset
 Dim strMessage As String
 Dim strCode As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set tdfEmployees = dbsNorthwind.TableDefs!Employees

 ' Store original DefaultValue information and set the
 ' property to a new value.
 strOldDefault = _
 tdfEmployees.Fields!PostalCode.DefaultValue
 tdfEmployees.Fields!PostalCode.DefaultValue = "98052"

 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", _
 dbOpenDynaset)

 With rstEmployees
 ' Add a new record to the Recordset.
 .AddNew
 !FirstName = "Bruce"
 !LastName = "Oberg"

 ' Get user input. If user enters something, the field
 ' will be filled with that data; otherwise, it will be
 ' filled with the DefaultValue information.
 strMessage = "Enter postal code for " & vbCr & _
 !FirstName & " " & !LastName & ":"
 strCode = DefaultPrompt(strMessage, !PostalCode)
 If strCode <> "" Then !PostalCode = strCode
 .Update

 ' Go to new record and print information.
 .Bookmark = .LastModified
 Debug.Print " FirstName = " & !FirstName
 Debug.Print " LastName = " & !LastName
 Debug.Print " PostalCode = " & !PostalCode

 ' Delete new record because this is a demonstration.
 .Delete
 .Close
 End With

 ' Restore original DefaultValue property because this is a
 ' demonstration.
 tdfEmployees.Fields!PostalCode.DefaultValue = _
 strOldDefault

 dbsNorthwind.Close

End Sub

Function DefaultPrompt(strPrompt As String, _
 fldTemp As Field2) As String

 Dim strFullPrompt As String

 ' Ask user for new DefaultValue setting for the specified
 ' Field object.
 strFullPrompt = strPrompt & vbCr & _
 "[Default = " & fldTemp.DefaultValue & _
 ", Cancel - use default]"
 DefaultPrompt = InputBox(strFullPrompt)

End Function


Report.Properties Property (Access)

 Copy code hover
[image]

Report.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a Report object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


Index.CreateProperty Method (DAO)

 Copy code hover
[image]

Index.CreateProperty Method (DAO)
Send feedback

Creates a new user-defined Property object (Microsoft Access workspaces only).

Syntax

expression .CreateProperty(Name, Type, Value, DDL)

expression A variable that represents an Index object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Optional | Variant | A String that uniquely names the new Property object. See the Name property for details on valid Property names.
Type | Optional | Variant | A constant that defines the data type of the new Property object. See the Type property for valid data types.
Value | Optional | Variant | A Variant containing the initial property value. See the Value property for details.
DDL | Optional | Variant | A Variant (Boolean subtype) that indicates whether or not the Property is a DDL object. The default is False. If DDL is True, users can't change or delete this Property object unless they have dbSecWriteDef permission.

Return Value

Property

Remarks

You can create a user-defined Property object only in the Properties collection of an object that is persistent.

If you omit one or more of the optional parts when you use CreateProperty, you can use an appropriate assignment statement to set or reset the corresponding property before you append the new object to a collection. After you append the object, you can alter some but not all of its property settings. See the Name, Type, and Value property topics for more details.

If name refers to an object that is already a member of the collection, a run-time error occurs when you use the Append method.

To remove a user-defined Property object from the collection, use the Delete method on the Properties collection. You can't delete built-in properties.

Note Note

If you omit the DDL argument, it defaults to False (non-DDL). Because no corresponding DDL property is exposed, you must delete and re-create a Property object you want to change from DDL to non-DDL.


WebBrowserControl.GotFocus Event (Access)

 Copy code hover
[image]

WebBrowserControl.GotFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The GotFocus event occurs when the specified object receives the focus.

Version Information

Version Added: Access 2010

Syntax

expression .GotFocus

expression A variable that represents a WebBrowserControl object.

Return Value

nothing

Remarks

To run a macro or event procedure when these events occur, set the OnGotFocus property to the name of the macro or to [Event Procedure].

These events occur when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The GotFocus event differs from the Enter event in that the GotFocus event occurs every time a control receives the focus. For example, suppose the user clicks a check box on a form, then clicks a report, and finally clicks the check box on the form to bring it to the foreground. The GotFocus event occurs both times the check box receives the focus. In contrast, the Enter event occurs only the first time the user clicks the check box. The GotFocus event occurs after the Enter event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


GetObjectOwner Method (ADOX)

 Copy code hover
[image]

GetObjectOwner Method (ADOX)
Send feedback

Returns the owner of an object in a Catalog.

Syntax

Owner = Catalog.GetObjectOwner(ObjectName, ObjectType [,ObjectTypeId])

Return Value

Returns a String value that specifies the Name of the User or Group that owns the object.

Parameters

  • ObjectName

  • A String value that specifies the name of the object for which to return the owner.

  • ObjectType

  • A Long value which can be one of the ObjectTypeEnum constants, that specifies the type of the object for which to get the owner.

  • ObjectTypeId

  • Optional. A Variant value that specifies the GUID for a provider object type not defined by the OLE DB specification. This parameter is required if ObjectType is set to adPermObjProviderSpecific; otherwise, it is not used.

Remarks

An error will occur if the provider does not support returning object owners.


Synchronizer has not been set up. (Error 3543)

 Copy code hover
[image]

Synchronizer has not been set up. (Error 3543)
Send feedback

The Synchronizer for your computer has not been set up.

To configure the Synchronizer

  1. Start Replication Manager.

  2. On the Tools menu, click Configure Microsoft Replication Manager.

  3. Follow the instructions in the wizard.

If you are using a third-party application, obtain the Synchronizer Setup disk from the developer supporting your application.


Cannot perform cascading update on the table because it is currently in use by another user. (Error 3412)

 Copy code hover
[image]

Cannot perform cascading update on the table because it is currently in use by another user. (Error 3412)
Send feedback

You are trying to save a value into a primary key field that is included in a relationship.

In Microsoft Access, the Cascade Update Related Fields option is selected for the relationship, or in DAO code, the dbRelationUpdateCascade option is specified for the Relation object's Attributes property. Your application is attempting to update the matching field in the related table.

The matching field cannot be updated because of a locking conflict with another user. To save the record, you must wait until the related table is no longer in use.


Access Miscellaneous How Do I...

 Copy code hover
[image]

Access Miscellaneous How Do I...
Send feedback

This page links to help on widely used miscellaneous tasks. To view other categories of popular tasks covered in Help, see How Do I… in Access.

Date/Time

  • How to: Calculate Age

    • Describes how to calculate the age of a person or thing based on a given date.

  • How to: Calculate and Display Specific Date Values

    • Describes how to create expressions for displaying specific dates and calculating time intervals.

  • How to: Calculate Elapsed Time

    • Describes how to calculate elapsed time.

  • How to: Find the Number of Working Days Between Two Dates

    • Contains a custom function that you can use to determine the number of working days between two dates.

  • How to: Format Dates as U.S. Dates Regardless of Regional Settings

    • Contains a custom function that formats dates in U.S. date format, regardless of the region that you have set in the Regional Settings tool in Control Panel.

  • How to: Specify Date and Time in Criteria Expressions

    • Describes how to specify date or time criteria for an operation.

  • How to: Use Date and Time Criteria from a Control on a Form

    • Describes how to change the criteria argument for an operation based on a user's decision.

Criteria Expressions

  • How to: Calculate Fields in Domain Aggregate Functions

    • Describes how to use the expr argument in a domain aggregate function to perform a calculation on values in a field.

  • How to: Include Quotation Marks in String Expressions

    • Describes how to embed quotation marks in an SQL expression.

  • How to: Sort Records in Case-Sensitive ( ASCII) Order

    • Contains a custom function that can be used to sort records in case-sensitive order.

  • How to: Specify Date and Time in Criteria Expressions

    • Describes how to specify date or time criteria for an operation.

  • How to: Use Multiple Fields in Criteria Expressions

    • Describes how to specify multiple fields in a criteria argument.

  • How to: Use Numeric Criteria from a Control on a Form

    • Describes how to specify numeric criteria coming from a control on a form.

  • How to: Use Numeric Criteria in Expressions

    • Describes how to specify numeric criteria for an operation.

  • How to: Use Textual Criteria Expressions

    • Describes how to specify textual criteria for an operation.

  • How to: Use Textual Criteria from a Control on a Form

    • Describes how to specify textual criteria coming from a control on a form.

  • How to: Use User Input to Build Filter Criteria

    • Describes how to build criteria based on user input.

Windows API

  • How to: Determine When a Shelled Process Ends

    • Describes how to use the Windows API to wait for an external process.

  • How to: Programmatically Retrieve Printer Capabilities

    • Describes how to use the Windows API to determine a printer's capabilities.

  • How to: Retrieve Information from the Clipboard

    • Describes two methods for pasting information form the Clipboard programmatically.

  • How to: Send Information to the Clipboard

    • Describes two methods for copying information to the Clipboard programmatically.

  • How to: Retrieve the Name of the User Logged On To the Network

    • Describes how to use the Windows API to retrieve the name of the user logged on to the computer.

Maintenance

  • How to: Compact and Repair a Database

    • Describes how to compact and repair a database.

  • How to: Recover Tables Deleted from a Database

    • Describes a method for recovering tables that have been deleted.

  • How to: Handle Run-Time Errors in VBA

    • Describes how to trap run-time errors.

  • How Do I... in Access


Equivalent ANSI SQL Data Types

 Copy code hover
[image]

Equivalent ANSI SQL Data Types
Send feedback

The following table lists ANSI SQL data types, their equivalent Microsoft Access database engine SQL data types, and their valid synonyms. It also lists the equivalent Microsoft® SQL Server™ data types.

ANSI SQL data type | Microsoft Access SQL data type | Synonym | Microsoft SQL Server data type
BIT, BIT VARYING | BINARY (See Notes) | VARBINARY, BINARY VARYING BIT VARYING | BINARY, VARBINARY
Not supported | BIT (See Notes) | BOOLEAN, LOGICAL, LOGICAL1, YESNO | BIT
Not supported | TINYINT | INTEGER1, BYTE | TINYINT
Not supported | COUNTER (See Notes) | AUTOINCREMENT | (See Notes)
Not supported | MONEY | CURRENCY | MONEY
DATE, TIME, TIMESTAMP | DATETIME | DATE, TIME (See Notes) | DATETIME
Not supported | UNIQUEIDENTIFIER | GUID | UNIQUEIDENTIFIER
DECIMAL | DECIMAL | NUMERIC, DEC | DECIMAL
REAL | REAL | SINGLE, FLOAT4, IEEESINGLE | REAL
DOUBLE PRECISION, FLOAT | FLOAT | DOUBLE, FLOAT8, IEEEDOUBLE, NUMBER (See Notes) | FLOAT
SMALLINT | SMALLINT | SHORT, INTEGER2 | SMALLINT
INTEGER | INTEGER | LONG, INT, INTEGER4 | INTEGER
INTERVAL | Not supported |  | Not supported
Not supported | IMAGE | LONGBINARY, GENERAL, OLEOBJECT | IMAGE
Not supported | TEXT (See Notes) | LONGTEXT, LONGCHAR, MEMO, NOTE, NTEXT (See Notes) | TEXT
CHARACTER, CHARACTER VARYING, NATIONAL CHARACTER, NATIONAL CHARACTER VARYING | CHAR (See Notes) | TEXT(n), ALPHANUMERIC, CHARACTER, STRING, VARCHAR, CHARACTER VARYING, NCHAR, NATIONAL CHARACTER, NATIONAL CHAR, NATIONAL CHARACTER VARYING, NATIONAL CHAR VARYING (See Notes) | CHAR, VARCHAR, NCHAR, NVARCHAR

Note Note

  • The ANSI SQL BIT data type does not correspond to the Microsoft Access SQL BIT data type. It corresponds to the BINARY data type instead. There is no ANSI SQL equivalent for the Microsoft Access SQL BIT data type.

  • TIMESTAMP is no longer supported as a synonym for DATETIME.

  • NUMERIC is no longer supported as a synonym for FLOAT or DOUBLE. NUMERIC is now used as a synonym for DECIMAL.

  • A LONGTEXT field is always stored in the Unicode representation format.

  • If the data type name TEXT is used without specifying the optional length, for example TEXT(25), a LONGTEXT field is created. This enables CREATE TABLE statements to be written that will yield data types consistent with Microsoft SQL Server.

  • A CHAR field is always stored in the Unicode representation format, which is the equivalent of the ANSI SQL NATIONAL CHAR data type.

  • If the data type name TEXT is used and the optional length is specified, for example TEXT(25), the data type of the field is equivalent to the CHAR data type. This preserves backwards compatibility for most Microsoft Jet applications, while enabling the TEXT data type (without a length specification) to be aligned with Microsoft SQL Server.


ComboBox.SizeToFit Method (Access)

 Copy code hover
[image]

ComboBox.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents a ComboBox object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Databases Properties (DAO)

 Copy code hover
[image]

Databases Properties (DAO)
Send feedback

In this section

  • Databases.Count Property (DAO)


CopyRecord Method (ADO)

 Copy code hover
[image]

CopyRecord Method (ADO)
Send feedback

Copies a entity represented by a Record to another location.

Syntax

Record.CopyRecord (Source, Destination, UserName, Password, Options, Async)

Parameters

  • Source

  • Optional. A String value that contains a URL specifying the entity to be copied (for example, a file or directory). If Source is omitted or specifies an empty string, the file or directory represented by the current Record will be copied.

  • Destination

  • Optional. A String value that contains a URL specifying the location where Source will be copied.

  • UserName

  • Optional. A String value that contains the user ID that, if needed, authorizes access to Destination.

  • Password

  • Optional. A String value that contains the password that, if needed, verifies UserName.

  • Options

  • Optional. A CopyRecordOptionsEnum value that has a default value of adCopyUnspecified. Specifies the behavior of this method.

  • Async

  • Optional. A Boolean value that, when True, specifies that this operation should be asynchronous.

Return Value

A String value that typically returns the value of Destination. However, the exact value returned is provider-dependent.

Remarks

The values of Source and Destination must not be identical; otherwise, a run-time error occurs. At least one of the server, path, or resource names must differ.

All children (for example, subdirectories) of Source are copied recursively, unless adCopyNonRecursive is specified. In a recursive operation, Destination must not be a subdirectory of Source; otherwise, the operation will not complete.

This method fails if Destination identifies an existing entity (for example, a file or directory), unless adCopyOverWrite is specified.

Important note Important

Use the adCopyOverWrite option judiciously. For example, specifying this option when copying a file to a directory will delete the directory and replace it with the file.

Note Note

URLs using the http scheme will automatically invoke the Microsoft OLE DB Provider for Internet Publishing. For more information, see Absolute and Relative URLs.


AllModules Properties (Access)

 Copy code hover
[image]

AllModules Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


Index Object Reference (DAO)

 Copy code hover
[image]

Index Object Reference (DAO)
Send feedback

In this section

  • Index Object (DAO)

  • Index Members (DAO)

  • Index Properties (DAO)

  • Index Methods (DAO)


ComplexType Properties (DAO)

 Copy code hover
[image]

ComplexType Properties (DAO)
Send feedback

In this section

  • ComplexType.Fields Property (DAO)


NumericScale and Precision Properties Example (VB)

 Copy code hover
[image]

NumericScale and Precision Properties Example (VB)
Send feedback

This example demonstrates the NumericScale and Precision properties of the Column object. This code displays their value for the Order Details table of the Northwind database.

Copy code Copy code

' BeginNumericScalePrecVB
Sub Main()
 On Error GoTo NumericScalePrecXError

 Dim cnn As New ADODB.Connection
 Dim cat As New ADOX.Catalog
 Dim tblOD As ADOX.Table
 Dim colLoop As ADOX.Column

 ' Connect the catalog.
 cnn.Open "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "data source='c:\Program Files\" & _
 "Microsoft Office\Office\Samples\Northwind.mdb';"
 Set cat.ActiveConnection = cnn

 ' Retrieve the Order Details table
 Set tblOD = cat.Tables("Order Details")

 ' Display numeric scale and precision of
 ' small integer fields.
 For Each colLoop In tblOD.Columns
 If colLoop.Type = adSmallInt Then
 MsgBox "Column: " & colLoop.Name & vbCr & _
 "Numeric scale: " & _
 colLoop.NumericScale & vbCr & _
 "Precision: " & colLoop.Precision
 End If
 Next colLoop

 'Clean up
 cnn.Close
 Set cat = Nothing
 Set cnn = Nothing
 Exit Sub

NumericScalePrecXError:
 Set cat = Nothing

 If Not cnn Is Nothing Then
 If cnn.State = adStateOpen Then cnn.Close
 End If
 Set cnn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndNumericScalePrecVB


 Copy code hover
[image]

<Database name> is not a valid database name. (Error 3005)
Send feedback

The specified database name does not follow the standard naming conventions for file names. The name may be too long for the buffer that contains the path and file name. Enter a new name, and then try the operation again.


Catalog Object (ADO MD Reference)

 Copy code hover
[image]

Catalog Object (ADO MD Reference)
Send feedback

In this section

  • Catalog Object (ADO MD)

  • Catalog Properties, Methods, and Events (ADO MD)


ToggleButton.OnMouseUp Property (Access)

 Copy code hover
[image]

ToggleButton.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Syntax

expression .OnMouseUp

expression A variable that represents a ToggleButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Attachment.GridlineWidthTop Property (Access)

 Copy code hover
[image]

Attachment.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified attachment. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthTop

expression A variable that represents an Attachment object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


CodeProject Methods (Access)

 Copy code hover
[image]

CodeProject Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
AddSharedImage | Imports the specified image into the database and adds it to the SharedResources collection.
CloseConnection | You can use the CloseConnection method to close the current connection between the CodeProject object in a Microsoft Access project (.adp) or Access database and the database specified in the project's base connection string.
OpenConnection | You can use the OpenConnection method to open an ADO connection to an existing Microsoft Access project (.adp) or Access database as the current Access project or database in the Microsoft Access window.
UpdateDependencyInfo | Updates the dependency information for the database.


ComboBox.OnDblClick Property (Access)

 Copy code hover
[image]

ComboBox.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Syntax

expression .OnDblClick

expression A variable that represents a ComboBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_DblClick" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Operation not supported on a Paradox table with no primary key. (Error 3207)

 Copy code hover
[image]

Operation not supported on a Paradox table with no primary key. (Error 3207)
Send feedback

Run the application that created the table, and add a primary key. Then, try the operation again.


EditModeEnum Enumeration (DAO)

 Copy code hover
[image]

EditModeEnum Enumeration (DAO)
Send feedback

Indicates the state of editing for the current record.

Name | Value | Description
dbEditAdd | 2 | AddNew method invoked.
dbEditInProgress | 1 | Edit method invoked.
dbEditNone | 0 | Edit method invoked.


DBEngine Members (DAO)

 Copy code hover
[image]

DBEngine Members (DAO)
Send feedback

The DBEngine object is the top level object in the DAO object model.

Methods

Name

Description

BeginTrans

Begins a new transaction. Read/write Database.

CommitTrans

Ends the current transaction and saves the changes.

CompactDatabase

Copies and compacts a closed database, and gives you the option of changing its version, collating order, and encryption. (Microsoft Access workspaces only). .

CreateDatabase

Creates a new Database object, saves the database to disk, and returns an opened Database object (Microsoft Access workspaces only). .

CreateWorkspace

Creates a new Workspace object.

Idle

Suspends data processing, enabling the Microsoft Access database engine to complete any pending tasks, such as memory optimization or page timeouts (Microsoft Access workspaces only).

OpenConnection

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Opens a Connection object on an ODBC data source (ODBCDirect workspaces only).

OpenDatabase

Opens a specified database and returns a reference to the Database object that represents it.

RegisterDatabase

Enters connection information for an ODBC data source in the Windows Registry. The ODBC driver needs connection information when the ODBC data source is opened during a session.

Rollback

Ends the current transaction and restores the databases in the Workspace object to the state they were in when the current transaction began.

SetOption

Temporarily overrides values for the Microsoft Access database engine keys in the Windows Registry (Microsoft Access workspaces only).

Properties

Name | Description
DefaultPassword | Sets the password used to create the default Workspace when it is initialized. Read/write String.
DefaultType | Sets or returns a value that indicates what type of workspace will be used by the next Workspace object created.
DefaultUser | Sets the user name used to create the default Workspace when it is initialized. Read/write String.
Errors | Returns an Errors collection that contains all of the stored Error objects for the specified object. Read-only.
IniPath | Sets or returns information about the Windows Registry key that contains values for the Microsoft Access database engine (Microsoft Access workspaces only).
LoginTimeout | Sets or returns the number of seconds before an error occurs when you attempt to log on to an ODBC database.
Properties | Returns the Properties collection of the specified object. Read-only.
Version | Rreturns the version of DAO currently in use. Read-only String.
Workspaces | Returns a Workspaces collection that contains all of the active, unhidden Workspace objects. Read-only.


Index Methods (DAO)

 Copy code hover
[image]

Index Methods (DAO)
Send feedback

In this section

  • Index.CreateField Method (DAO)

  • Index.CreateProperty Method (DAO)


Attachment.GridlineWidthRight Property (Access)

 Copy code hover
[image]

Attachment.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified attachment. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthRight

expression A variable that represents an Attachment object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Report.PrintSection Property (Access)

 Copy code hover
[image]

Report.PrintSection Property (Access)
See also Send feedback

Published: July 16, 2012

The PrintSection property specifies whether a section should be printed. Read/write Boolean.

Syntax

expression .PrintSection

expression A variable that represents a Report object.

Remarks

The PrintSection property uses the following settings.

Setting | Description
True | (Default) The section is printed.
False | The section isn't printed.
Note Note

To set this property, specify a macro or event procedure for a section's OnFormat property.

Microsoft Access sets this property to True before each section's Format event.

Example

The following example does not print the section "PageHeaderSection" of the "Product Summary" report.

VBA Copy code Copy code
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)

 Reports("Product Summary").PrintSection = False

End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


CopyObject Macro Action

 Copy code hover
[image]

CopyObject Macro Action
Send feedback

You can use the CopyObject action to copy the specified database object to a different Access database or to the same database or Access project under a new name. For example, you can copy or back up an existing object in another database or quickly create a similar object with a few changes.

Note 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.

Setting

The CopyObject action has the following arguments.

Action argument

Description

Destination Database

A valid path and file name for the destination database. Enter the path and file name in the Destination Database box in the Action Arguments section of the Macro Builder pane. Leave this argument blank if you want to select the current database.

Note Note

This argument is only available in the Access database environment. When using this action in an Access project environment (.adp), the Destination Database argument must be blank.

If you run a macro containing the CopyObject action in a library database and leave this argument blank, Microsoft Office Access 2007 will copy the object into the library database.

New Name

A new name for the object. When copying to a different database, leave this argument blank to keep the same name.

Source Object Type

The object type you want to copy. Click Table, Query, Form, Report, Macro, Module, Data Access Page, Server View, Diagram, Stored Procedure, or Function. To copy the object selected in the Navigation Pane, leave this argument blank.

Source Object Name

The name of the object to be copied. The Source Object Name box shows all objects in the database of the type selected by the Source Object Type argument. In the Source Object Name box, click the object to copy. If you leave the Source Object Type argument blank, leave this argument blank also. If you run a macro containing the CopyObject action in a library database, Access first looks for the object with this name in the library database, and then in the current database.

Remarks

You must enter a value for either one or both of the Destination Database and New Name arguments for this action.

If you leave the Source Object Type and Source Object Name arguments blank, Access copies the object selected in the Navigation Pane. To select an object in the Navigation Pane, you can use the SelectObject action with the In Navigation Pane argument set to Yes.

The CopyObject action is similar to performing the following steps manually:

  1. Select an object in the Navigation Pane.

  2. On the Home tab, in the Clipboard group, click Copy.

  3. On the same tab, click Paste.The Paste As dialog box appears so that you can give the object a new name. The CopyObject action performs all of these steps automatically.

Note Note

When copying data access pages, the CopyObject action copies only the link to the associated .htm file, not the file itself.

The path and file name of the destination database must exist before the macro runs the CopyObject action. If they don't exist, Access displays an error message.

To run the CopyObject action in a Visual Basic for Applications (VBA) module, use the CopyObject method of the DoCmd object.

You can also manually copy an object selected in the Navigation Pane, or an object that is currently open, by clicking the File tab and then clicking Save As. This command will make a copy of the object in the current database only. In the Save As dialog box, enter the name for the copy, and choose what type of object you want to save it as. If the original object has already been saved and you save it in the current database with a new name, the original version still exists with its old name.

To manually copy an object to a different Access database:

  1. On the External Data tab, in the Export group, click More and then click Access Database.

  2. In the Export - Access Database dialog box, enter the file name of the destination database.-or-Click Browse to display the File Save dialog box, locate the destination database, and then click Save.

  3. In the Export - Access Database dialog box, click OK. The Export dialog box appears.

  4. In the Export dialog box, enter a name for the object in the destination database. Choose any applicable options, such as Export Definition and Data or Definition Only for tables. When you are finished, click OK.


Cancel Method (ADO)

 Copy code hover
[image]

Cancel Method (ADO)
Send feedback

Cancels execution of a pending, asynchronous method call.

Syntax

object.Cancel

Remarks

Use the Cancel method to terminate execution of an asynchronous method call (that is, a method invoked with the adAsyncConnect, adAsyncExecute, or adAsyncFetch option).

The following table shows what task is terminated when you use the Cancel method on a particular type of object.

If object is a | The last asynchronous call to this method is terminated
Command | Execute
Connection | Execute or Open
Record | CopyRecord, DeleteRecord, MoveRecord, or Open
Recordset | Open
Stream | Open


Update/update conflict. (Error 3713)

 Copy code hover
[image]

Update/update conflict. (Error 3713)
Send feedback

This record contains a field value that lost in the conflict with another replica. Either resubmit this conflict record or delete this conflict record.


Count Property Example (VJ++)

 Copy code hover
[image]

Count Property Example (VJ++)
Send feedback

This example demonstrates the Count property with two collections in the Employees database. The property obtains the number of objects in each collection, and sets the upper limit for loops that enumerate these collections. Another way to enumerate these collections without using the Count property would be to use statements.

Copy code Copy code

// BeginCountJ
import com.ms.wfc.data.*;
import java.io.* ;

public class CountX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 CountX();
 System.exit(0);
 }

 // CountX function

 static void CountX()
 {

 // Define ADO Objects.
 Recordset rstEmployees = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String line = null;
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";

 int intLoop;
 int intDisplaySize = 20;
 int recCount=0;

 try
 {
 rstEmployees = new Recordset();

 // Open recordset with data from Employees table.
 rstEmployees.open("employee", strCnn,
 AdoEnums.CursorType.FORWARDONLY,
 AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TABLE);

 // Print information about Fields collection.
 System.out.println(rstEmployees.getFields().getCount() +
 " Fields in Employees");
 for ( intLoop = 0; intLoop <
 rstEmployees.getFields().getCount(); intLoop++)
 {
 System.out.println("\t" +
 rstEmployees.getFields().getItem(intLoop).getName());
 }
 System.out.println("\n\nPress <Enter> to continue..");
 in.readLine();

 // Print information about Properties collection.
 System.out.println(rstEmployees.getProperties().getCount() +
 " Properties in Employees");
 for ( intLoop = 0; intLoop <
 rstEmployees.getProperties().getCount(); intLoop++)
 {
 System.out.println("\t" +
 rstEmployees.getProperties().getItem(intLoop).getName());
 recCount++;
 if ( recCount >= intDisplaySize)
 {
 System.out.println("\n\nPress <Enter> to continue..");
 in.readLine();
 recCount = 0;
 }
 }
 System.out.println("\n\nPress <Enter> to continue..");
 in.readLine();

 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // Check for null pointer for connection object.
 if (rstEmployees.getActiveConnection()==null)
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 else
 {
 // As passing a Recordset, check for null pointer first.
 if (rstEmployees != null)
 {
 PrintProviderError(rstEmployees.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstEmployees != null)
 if (rstEmployees.getState() == 1)
 rstEmployees.close();
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}

// EndCountJ


LookupRecord Data Block

 Copy code hover
[image]

LookupRecord Data Block
Send feedback

A LookupRecord data block performs a set of actions on a specific record.

Note Note

The LookupRecord data block is available only in Data Macros.

Setting

The SetField action has the following arguments.

Argument

Required

Description

In

Yes

A string that identifies the record to operate on. The In argument can contain the name of the table, a select query, or a SQL statement.

Note Note

The specified record cannot include data stored in a linked table or ODBC data source.

Where Condition

No

A string expression used to restrict the range of data on which the LookupRecord data block is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the LookupRecord data block operates on the entire domain specified by the In argument. Any field that is included in criteria must also be a field in In.

Alias

No

A string that provides an alternative name for the record specified by the In argument. Often used to shorten the table name for subsequent references to prevent possible ambiguous references. If Alias is not specified, the table or query name will be used as the alias.

Remarks

If the criteria specified by the In and Where Condition arguments specifies more than one record, then the LookupRecord data block will only operate on the first record.

If no record satisfies Where Condition or if In contains no records, then LookupRecord creates a blank record in which all of the fields contain a Null value.

Example

The following example shows how to use the SetReturnVar action to return a value from a named data macro. A ReturnVar named CurrentServiceRequest is returned to the macro or Visual Basic for Applications (VBA) subroutine that called the named data macro.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

Copy code Copy code
RunDataMacro
    Macro Name tblServiceRequests.dmGetCurrentServiceRequest

Parameters
    prmAssignedTo =[ID]

SetProperty
    Control Name txtCurrentSR
    Property Value
    Value =[ReturnVars]![CurrentServiceRequest]

The following example shows how to use the RaiseError action to cancel the Before Change data macro event. When the AssignedTo field is updated, a LookupRecord data block is used to determine whether the assigned technician is currently assigned to an open service request. If this is true, then the Before Change event is cancelled and the record is not updated.

Copy code Copy code
/* Get the name of the technician  */
Look Up A Record In tblTechnicians
    Where Condition =[tblTechnicians].[ID]=[tblServiceRequests].[AssignedTo]
SetLocalVar
    Name TechName
    Expression [tblTechnicians].[FirstName] & " " & [tblTechnicians].[LastName]
/* End LookUpRecord  */

If Updated("AssignedTo") Then
    Look Up A Record In tblServiceRequests
        Where Condition SR.[AssignedTo]=tblServiceRequests[AssignedTo] And
            SR.[ID]<>tblServiceRequests.[ID] And IsNull(SR.[ActualCompletionDate])
        Alias SR
        RaiseError
            Error Number 1234
            Error Description ="Cannot assign a request to the specified technician: " & [TechName]

End If

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Scaling of decimal value resulted in data truncation. (Error 3758)

 Copy code hover
[image]

Scaling of decimal value resulted in data truncation. (Error 3758)
Send feedback

This error occurs when the data being updated or inserted into a DECIMAL data type does not match the defined scale and precision of the column.


An action query cannot be used as a row source. (Error 3417)

 Copy code hover
[image]

An action query cannot be used as a row source. (Error 3417)
Send feedback

Possible cause:

  • The query being used as a record source is an action query or a data-definition query.


DataFactory Object, Query Method, and CreateObject Method Example (VBScript)

 Copy code hover
[image]

DataFactory Object, Query Method, and CreateObject Method Example (VBScript)
Send feedback

This example creates an RDSServer.DataFactory object using the CreateObject method of the RDS.DataSpace object. To test this example, cut and paste this code between the <Body> and </Body> tags in a normal HTML document and name it DataFactoryVBS.asp. ASP script will identify your server.

VBS Copy code Copy code
<!-- BeginDataFactoryVBS -->
<HTML>
<HEAD>
<!--use the following META tag instead of adovbs.inc-->
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->
<META name="VI60_DefaultClientScript" Content="VBScript">
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>DataFactory Object, Query Method, and
CreateObject Method Example (VBScript)</TITLE>
<style>
<!--
body {
font-family: 'Verdana','Arial','Helvetica',sans-serif;
BACKGROUND-COLOR:white;
COLOR:black;
}

.thead {
background-color: #008080;
font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;
color: white;
}

.thead2 {
background-color: #800000;
font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;
color: white;
}

.tbody {
text-align: center;
background-color: #f7efde;
font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;
}
-->
</style>
</HEAD>
<BODY>
<h1>DataFactory Object, Query Method, and
CreateObject Method Example (VBScript)</h1>

<H2>RDS API Code Examples</H2>

<HR>
<H3>Using Query Method of RDSServer.DataFactory</H3>

<!-- RDS.DataSpace ID RDS1-->
<OBJECT ID="RDS1" WIDTH=1 HEIGHT=1
CLASSID="CLSID:BD96C556-65A3-11D0-983A-00C04FC29E36">
</OBJECT>

<!-- RDS.DataControl with parameters set at run time -->
<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
ID=RDS WIDTH=1 HEIGHT=1>
</OBJECT>

<TABLE DATASRC=#RDS>
<TBODY>
<TR>
<TD><SPAN DATAFLD="FirstName"></SPAN></TD>
<TD><SPAN DATAFLD="LastName"></SPAN></TD>
</TR>
</TBODY>
</TABLE>

<HR>

<INPUT TYPE=BUTTON NAME="Run" VALUE="Run">

<BR>

<H4>Click Run -
The <i>CreateObject</i> Method of the RDS.DataSpace Object Creates
an instance of the RDSServer.DataFactory;
The <i>Query</i> Method of the RDSServer.DataFactory is used
to bring back a Recordset. </H4>

<Script Language="VBScript">

Dim rdsDF
Dim strServer
Dim strCnxn
Dim strSQL

strServer = "http://<%=Request.ServerVariables("SERVER_NAME")%>"

strCnxn = "Provider='sqloledb';Integrated Security='SSPI';Initial Catalog='Northwind';"

strSQL = "Select FirstName, LastName from Employees"

Sub Run_OnClick()

' Create RDSServer.DataFactory Object
Dim rs

' Get Recordset
Set DF = RDS1.CreateObject("RDSServer.DataFactory", strServer)
Set rs = DF.Query(strCnxn, strSQL)

' Set parameters of RDS.DataControl at Run Time
RDS.Server = strServer
RDS.SQL = strSQL
RDS.Connect = strCnxn
RDS.Refresh

End Sub
</Script>
</BODY>
</HTML>
<!-- EndDataFactoryVBS -->


ToggleButton.Parent Property (Access)

 Copy code hover
[image]

ToggleButton.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a ToggleButton object.

Remarks

The Parent property for a check box, option button, or toggle button in an option group is the name of the option group control. The Parent property of an option group control is the name of the form.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


ListBox.ColumnWidth Property (Access)

 Copy code hover
[image]

ListBox.ColumnWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.

Syntax

expression .ColumnWidth

expression A variable that represents a ListBox object.

Remarks

In Visual Basic , the ColumnWidth property setting is an Integer value that represents the column width in twips. You can specify a width or use one of the following predefined settings.

Setting | Description
0 | Hides the column.
-1 | (Default) Sizes the column to the default width.
Note Note

The ColumnWidth property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

Setting this property to 0, or resizing the field to a zero width in Datasheet view, sets the field's ColumnHidden property to True (-1) and hides the field in Datasheet view.

Setting a field's ColumnHidden property to False (0) restores the field's ColumnWidth property to the value it had before the field was hidden. For example, if the ColumnWidth property was -1 prior to the field being hidden by setting the property to 0, changing the field's ColumnHidden property to False resets the ColumnWidth to -1.

The ColumnWidth property for a field isn't available when the field's ColumnHidden property is set to True.

Example

This example takes effect in Datasheet view of the open Customers form. It sets the row height to 450 twips and sizes the column to fit the size of the visible text.

VBA Copy code Copy code
Forms![Customers].RowHeight = 450
Forms![Customers]![Address].ColumnWidth = -2

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


BoundObjectFrame.LabelAlign Property (Access)

 Copy code hover
[image]

BoundObjectFrame.LabelAlign Property (Access)
See also Send feedback

Published: July 16, 2012

The property specifies the text alignment within attached labels on new controls. Read/write Byte.

Syntax

expression .LabelAlign

expression A variable that represents a BoundObjectFrame object.

Remarks

The LabelAlign property uses the following settings.

Setting | Description
0 | (Default) The label text aligns to the left.
1 | The label text aligns to the left.
2 | The label text is centered.
3 | The label text aligns to the right.
4 | The label text is evenly distributed.

You can set the LabelAlign property by using a control's default control style or the DefaultControl property in Visual Basic.

When created, controls have an attached label (as long as their AutoLabel property is set to Yes). Changes to the LabelAlign default control style setting affect only controls created on the current form or report.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Form.SplitFormDatasheet Property (Access)

 Copy code hover
[image]

Form.SplitFormDatasheet Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the user can edit records in the datasheet when a form is displayed in Split Form view. Read/write AcSplitFormDatasheet.

Version Information

Version Added: Access 2007

Syntax

expression .SplitFormDatasheet

expression A variable that represents a Form object.

See also

Concepts

Form Object

Other resources

Form Object Members


DoCmd.ShowAllRecords Method (Access)

 Copy code hover
[image]

DoCmd.ShowAllRecords Method (Access)
See also Send feedback

Published: July 16, 2012

The ShowAllRecords method carries out the ShowAllRecords action in Visual Basic.

Syntax

expression .ShowAllRecords

expression A variable that represents a DoCmd object.

Remarks

You can use the ShowAllRecords action to remove any applied filter from the active table, query result set, or form, and display all records in the table or result set or all records in the form's underlying table or query.

Note Note

This method only applies to tables, queries, and forms within a Microsoft Access database.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


SubForm.GridlineStyleRight Property (Access)

 Copy code hover
[image]

SubForm.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified subform. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleRight

expression A variable that represents a SubForm object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


BoundObjectFrame.RightPadding Property (Access)

 Copy code hover
[image]

BoundObjectFrame.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the object frame and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .RightPadding

expression A variable that represents a BoundObjectFrame object.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Attachment.Controls Property (Access)

 Copy code hover
[image]

Attachment.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Version Information

Version Added: Access 2007

Syntax

expression .Controls

expression A variable that represents an Attachment object.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


ObjectFrame.Locked Property (Access)

 Copy code hover
[image]

ObjectFrame.Locked Property (Access)
See also Send feedback

Published: July 16, 2012

The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.

Syntax

expression .Locked

expression A variable that represents an ObjectFrame object.

Remarks

The default setting of the Locked property is True. This setting allows editing, adding, and deleting data.

Use the Locked property to protect data in a field by making it read-only. For example, you might want a control to only display information without allowing editing, or you might want to lock a control until a specific condition is met.

Example

The following example toggles the Enabled property of a command button and the Enabled and Locked properties of a control, depending on the type of employee displayed in the current record. If the employee is a manager, then the SalaryDetails button is enabled and the PersonalInfo control is unlocked and enabled.

VBA Copy code Copy code
Sub Form_Current()
 If Me!EmployeeType = "Manager" Then
 Me!SalaryDetails.Enabled = True
 Me!PersonalInfo.Enabled = True
 Me!PersonalInfo.Locked = False
 Else
 Me!SalaryDetails.Enabled = False
 Me!PersonalInfo.Enabled = False
 Me!PersonalInfo.Locked = True
 End If
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


ToggleButton.UseTheme Property (Access)

 Copy code hover
[image]

ToggleButton.UseTheme Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the specified object will utilize formatting styles defined in Office Document Themes. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .UseTheme

expression A variable that represents a ToggleButton object.

Remarks

The default value is True.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Missing semicolon (;) at end of SQL statement. (Error 3137)

 Copy code hover
[image]

Missing semicolon (;) at end of SQL statement. (Error 3137)
Send feedback

The SQL statement has additional invalid tokens following an SQL statement. For example, "SELECT col1 FROM table1 garbage" would return this error. "SELECT col1 FROM table1; garbage" would be valid.


Attachment.ColumnHidden Property (Access)

 Copy code hover
[image]

Attachment.ColumnHidden Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .ColumnHidden

expression A variable that represents an Attachment object.

Remarks

Note Note

The ColumnHidden property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

Hiding a column with the ColumnHidden property in Datasheet view doesn't hide fields from the same column in Form view. Similarly, setting a control's Visible property to False in Form view doesn't hide the corresponding column in Datasheet view.

Note Note

The ColumnHidden property is not available in Design view.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Report.DrawMode Property (Access)

 Copy code hover
[image]

Report.DrawMode Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DrawMode property to specify how the pen (the color used in drawing) interacts with existing background colors on a report when the Line , Circle , or Pset method is used to draw on a report when printing. Read/write Integer.

Syntax

expression .DrawMode

expression A variable that represents a Report object.

Remarks

The DrawMode property uses the following settings.

Setting | Description
1 | Black pen color.
2 | The inverse of setting 15 (NotMergePen).
3 | The combination of the colors common to the background color and the inverse of the pen (MaskNotPen).
4 | The inverse of setting 13 (NotCopyPen).
5 | The combination of the colors common to both the pen and the inverse of the display (MaskPenNot).
6 | The inverse of the display color (Invert).
7 | The combination of the colors in the pen and in the display color, but not in both (XorPen).
8 | The inverse of setting 9 (NotMaskPen).
9 | The combination of the colors common to both the pen and the display (MaskPen).
10 | The inverse of setting 7 (NotXorPen).
11 | No operation — the output remains unchanged. In effect, this setting turns drawing off (Nop).
12 | The combination of the display color and the inverse of the pen color (MergeNotPen).
13 | (Default) The color specified by the ForeColor property (CopyPen).
14 | The combination of the pen color and the inverse of the display color (MergePenNot).
15 | The combination of the pen color and the display color (MergePen).
16 | White pen color.

You can set the DrawMode property in an event procedure specified by a section's OnPrint property setting.

Use this property to produce visual effects when drawing on a report. Microsoft Access compares each pixel in the draw pattern to the corresponding pixel in the existing background to determine how the drawing appears on the report. For example, setting 7 uses the Xor operator to combine a draw-pattern pixel with a background pixel.

See also

Concepts

Report Object

Other resources

Report Object Members


NavigationButton.Exit Event (Access)

 Copy code hover
[image]

NavigationButton.Exit Event (Access)
See also Send feedback

Published: July 16, 2012

The Exit event occurs just before a control loses the focus to another control on the same form or report.

Version Information

Version Added: Access 2010

Syntax

expression .Exit(Cancel, )

expression A variable that represents a NavigationButton object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer |

Return Value

nothing

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when this event occurs, set the OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Exit event occurs before the LostFocus event.

Unlike the LostFocus event, the Exit event does not occur when a form loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


ToggleButton Methods (Access)

 Copy code hover
[image]

ToggleButton Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.
Undo | You can use the Undo method to reset a control or form when its value has been changed.


Workspaces.Delete Method (DAO)

 Copy code hover
[image]

Workspaces.Delete Method (DAO)
Send feedback

Deletes the specified Workspace form the Workspaces collection.

Syntax

expression .Delete(Name)

expression A variable that represents a Workspaces object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Required | String | The name of the workspace to delete.


DBEngine.OpenConnection Method (DAO)

 Copy code hover
[image]

DBEngine.OpenConnection Method (DAO)
Send feedback

Syntax

expression .OpenConnection(Name, Options, ReadOnly, Connect)

expression A variable that represents a DBEngine object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Required | String | A string expression. See the discussion under Remarks.
Options | Optional | Variant | sets various options for the connection, as specified in Remarks. Based on this value, the ODBC driver manager prompts the user for connection information such as data source name (DSN), user name, and password.
ReadOnly | Optional | Variant | True if the connection is to be opened for read-only access and False if the connection is to be opened for read/write access (default).
Connect | Optional | Variant | An ODBC connection string. See the Connect property for the specific elements and syntax of this string. A prepended "ODBC;" is required.

Return Value

Connection

Remarks

Use the OpenConnection method to establish a connection to an ODBC data source from an ODBCDirect workspace. The OpenConnection method is similar but not equivalent to OpenDatabase. The main difference is that OpenConnection is available only in an ODBCDirect workspace.

If you specify a registered ODBC data source name (DSN) in the connect argument, then the name argument can be any valid string, and will also provide the Name property for the Connection object. If a valid DSN is not included in the connect argument, then name must refer to a valid ODBC DSN, which will also be the Name property. If neither name nor connect contains a valid DSN, the ODBC driver manager can be set (via the options argument) to prompt the user for the required connection information. The DSN supplied through the prompt then provides the Name property.

The options argument determines if and when to prompt the user to establish the connection, and whether or not to open the connection asynchronously. You can use one of the following constants.

Constant | Description
dbDriverNoPrompt | The ODBC Driver Manager uses the connection string provided in dbname and connect. If you don't provide sufficient information, a run-time error occurs.
dbDriverPrompt | The ODBC Driver Manager displays the ODBC Data Sources dialog box, which displays any relevant information supplied in dbname or connect. The connection string is made up of the DSN that the user selects via the dialog boxes, or, if the user doesn't specify a DSN, the default DSN is used.
dbDriverComplete | Default. If the connect argument includes all the necessary information to complete a connection, the ODBC Driver Manager uses the string in connect. Otherwise it behaves as it does when you specify dbDriverPrompt.
dbDriverCompleteRequired | This option behaves like dbDriverComplete except the ODBC driver disables the prompts for any information not required to complete the connection.
dbRunAsync | Execute the method asynchronously. This constant may be used with any of the other options constants.

OpenConnection returns a Connection object which contains information about the connection. The Connection object is similar to a Database object. The principal difference is that a Database object usually represents a database, although it can be used to represent a connection to an ODBC data source from a Microsoft Access workspace.


CodeData Members (Access)

 Copy code hover
[image]

CodeData Members (Access)
Send feedback

Published: July 16, 2012

The CodeData object refers to objects stored within the code database by the source (server) application.

Properties

Name | Description
AllDatabaseDiagrams | You can use the AllDatabaseDiagrams property to reference the AllDatabaseDiagrams collection and its related properties. Read-only AllDatabaseDiagrams object.
AllFunctions | You can use the AllFunctions property to reference the AllFunctions collection and its related properties. Read-only AllFunctions object.
AllQueries | You can use the AllQueries property to reference the AllQueries collection and its related properties. Read-only AllQueries object.
AllStoredProcedures | You can use the AllStoredProcedures property to reference the AllStoredProcedures collection and its related properties. Read-only AllStoredProcedures object.
AllTables | You can use the AllTables property to reference the AllTables collection and its related properties. Read-only AllTables object.
AllViews | You can use the AllViews property to reference the AllViews collection and its related properties. Read-only AllViews object.


Primary Property

 Copy code hover
[image]

Primary Property
Send feedback

Published: July 16, 2012

You can use the Primary property to specify the primary key field for a table. A primary key field holds data that uniquely identifies each record in a table.

Setting

The Primary property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The selected index is the primary key.
No | False | The selected index isn't the primary key.

You can set the Primary property in three ways:

  • In table Design view, select the field or fields in the order you want for the primary key and then click Primary Key on the toolbar.

  • In the Indexes window, select or enter the name of an index in the Index Name column and set the Primary property to Yes in the Index Properties section.

  • In Visual Basic, to access the Primary property of an index, use the DAO PrimaryKey property.

Remarks

Microsoft Access automatically creates an index on the primary key field of a table and uses it to find records and to create joins between tables. The primary key index requires an entry in each primary key field and allows no duplicates. The order of the fields in a multiple-field primary key determines the default sort order for the table.

If there is no primary key when you save a table's design, Microsoft Access will display a dialog box asking whether you want a primary key to be created. If you click Yes , an AutoNumber data type field will be added to the table (with its NewValues property set to Increment) and set as the primary key. If you click No , no primary key will be created.

A table with no primary key can't be used in a relationship and can be slower to sort and search.


TextBox.BorderStyle Property (Access)

 Copy code hover
[image]

TextBox.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Syntax

expression .BorderStyle

expression A variable that represents a TextBox object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


SharedResource.Delete Method (Access)

 Copy code hover
[image]

SharedResource.Delete Method (Access)
See also Send feedback

Published: July 16, 2012

Deletes the specified object.

Version Information

Version Added: Access 2010

Syntax

expression .Delete

expression A variable that represents a SharedResource object.

See also

Concepts

SharedResource Object

Other resources

SharedResource Object Members


Item Property (ADO)

 Copy code hover
[image]

Item Property (ADO)
Send feedback

Indicates a specific member of a collection, by name or ordinal number.

Syntax

Set object = collection.Item ( Index )

Return Value

Returns an object reference.

Parameters

  • Index

  • A Variant expression that evaluates either to the name or to the ordinal number of an object in a collection.

Remarks

Use the Item property to return a specific object in a collection. If Item cannot find an object in the collection corresponding to the Index argument, an error occurs. Also, some collections don't support named objects; for these collections, you must use ordinal number references.

The Item property is the default property for all collections; therefore, the following syntax forms are interchangeable:

Copy code Copy code
collection.Item (Index)
collection (Index)


Property can be set only when the Field is part of a Recordset object's Fields collection. (Error 3267)

 Copy code hover
[image]

Property can be set only when the Field is part of a Recordset object's Fields collection. (Error 3267)
Send feedback

This property is valid only for Field objects that are part of a Recordset object's Fields collection. See the Field Object, Fields Collection Summary for a list of properties available for different Fields collections.


TextBox.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

TextBox.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthLeft

expression A variable that represents a TextBox object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


RDS Code Examples

 Copy code hover
[image]

RDS Code Examples
Send feedback

Use the following code examples to learn how to use the RDS objects, methods, properties, and events.

Note Note

Paste the entire code example into your code editor. The example may not run correctly if partial examples are used or if paragraph formatting is lost.

  • RDS Code Examples in Microsoft Visual Basic

  • RDS Code Examples in Microsoft Visual Basic Scripting Edition

  • RDS Code Examples in Microsoft Visual C++

  • RDS Code Examples in Microsoft Visual J++


Delete/RI conflict. (Error 3717)

 Copy code hover
[image]

Delete/RI conflict. (Error 3717)
Send feedback

The primary key record has been deleted by another replica, therefore this referencing record has been rejected. Either create a new primary key that satisfies the referential integrity constraint and then resubmit your update, or delete this conflict record.


TabControl.BackColor Property (Access)

 Copy code hover
[image]

TabControl.BackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the interior color of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackColor

expression A variable that represents a TabControl object.

Remarks

The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

To use the BackColor property, the BackStyle property, if available, must be set to Normal.

Example

The following example uses the RGB function to set the , BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Form.NavigationCaption Property (Access)

 Copy code hover
[image]

Form.NavigationCaption Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the text that appears to the left of the form's navigation buttons. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .NavigationCaption

expression A variable that represents a Form object.

Remarks

Although Record: appears to the left of the navigation buttons by default, the NavigationCaption property is blank until it's explicitly specified.

See also

Concepts

Form Object

Other resources

Form Object Members


ConnectOptionEnum

 Copy code hover
[image]

ConnectOptionEnum
Send feedback

Specifies whether the Open method of a Connection object should return after (synchronously) or before (asynchronously) the connection is established.

Constant | Value | Description
adAsyncConnect | 16 | Opens the connection asynchronously. The ConnectComplete event may be used to determine when the connection is available.
adConnectUnspecified | -1 | Default. Opens the connection synchronously.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.ConnectOption.ASYNCCONNECT

AdoEnums.ConnectOption.CONNECTUNSPECIFIED


There are fewer records remaining in the Recordset than you requested. (Error 3641)

 Copy code hover
[image]

There are fewer records remaining in the Recordset than you requested. (Error 3641)
Send feedback

The end of the Recordset has been reached.


Recordset (Visual C++ Syntax Index with #import)

 Copy code hover
[image]

Recordset (Visual C++ Syntax Index with #import)
Send feedback

Methods

Copy code Copy code

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthaddnew_HV10294007.xml( const _variant_t & FieldList = vtMissing,
 const _variant_t & Values =vtMissing);

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthadocancel_HV10294125.xml( );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcancelbatch_HV10294131.xml( enum AffectEnum AffectRecords );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcancelupdate_HV10294132.xml( );

_RecordsetPtr Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthclone_HV10294166.xml( enum LockTypeEnum LockType );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthclose_HV10294173.xml( );

enum CompareEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcomparebookmarks_HV10294199.xml( const _variant_t
 & Bookmark1, const _variant_t & Bookmark2 );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthrstdelete_HV10294295.xml( enum AffectEnum AffectRecords );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthfindmethodado_HV10294381.xml( _bstr_t Criteria, long SkipRecords, enum
 SearchDirectionEnum SearchDirection, const _variant_t & Start =
 vtMissing );

_variant_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthgetrows_HV10294398.xml( long Rows, const _variant_t & Start =
 vtMissing, const _variant_t & Fields = vtMissing );

_bstr_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthgetstringmethod_recordset_ado_HV10294404.xml( enum
 StringFormatEnum StringFormat, long NumRows, _bstr_t
 ColumnDelimeter, _bstr_t RowDelimeter, _bstr_t NullExpr );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthmove_HV10294521.xml( long NumRecords, const _variant_t & Start = vtMissing);

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthmovefirst_HV10294526.xml( );
HRESULT MoveLast( );
HRESULT MoveNext( );
HRESULT MovePrevious( );

_RecordsetPtr Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthnextrec_HV10294541.xml( VARIANT * RecordsAffected );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthrstopen_HV10294566.xml( const _variant_t & Source, const _variant_t &
 ActiveConnection, enum CursorTypeEnum CursorType, enum LockTypeEnum
 LockType, long Options );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthadorequery_HV10294728.xml( long Options );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthupdate_HV10294888.xml( const _variant_t & Fields = vtMissing, const
 _variant_t & Values =vtMissing);

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthupdatebatch_HV10294893.xml( enum AffectEnum AffectRecords );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthadoresync_HV10294735.xml( enum AffectEnum AffectRecords, enum
 ResyncEnum ResyncValues );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthrstsave_HV10294750.xml( const _variant_t & Destination, enum
 PersistFormatEnum PersistFormat );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthseek_HV10294763.xml( const _variant_t & KeyValues, enum SeekEnumSeekOption );

VARIANT_BOOL Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthsupports_HV10294844.xml( enum CursorOptionEnum CursorOptions );

Properties

Copy code Copy code

enum PositionEnum GetAbsolutePage( );
void PutAbsolutePage( enum PositionEnum pl );
__declspec(property(get=GetAbsolutePage,put=PutAbsolutePage)) enum
 PositionEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdproabpage_HV10293970.xml;

enum PositionEnum GetAbsolutePosition( );
void PutAbsolutePosition( enum PositionEnum pl );
__declspec(property(get=GetAbsolutePosition,put=PutAbsolutePosition))
 enum PositionEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdproabpos_HV10293979.xml;

IDispatchPtr GetActiveCommand( );
__declspec(property(get=GetActiveCommand)) IDispatchPtr Invalid DDUE based on source, error:link not allowed in code, link filename:mdproactivecommand_HV10293982.xml;

void Invalid DDUE based on source, error:link not allowed in code, link filename:mdproactivecon_HV10293988.xml( IDispatch * pvar );
void PutActiveConnection( const _variant_t & pvar );
_variant_t GetActiveConnection( );

enum CursorLocationEnum GetCursorLocation( );
void PutCursorLocation( enum CursorLocationEnum plCursorLoc );
__declspec(property(get=GetCursorLocation,put=PutCursorLocation)) enum
 CursorLocationEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocursorlocation_HV10294254.xml;

VARIANT_BOOL GetBOF( );
__declspec(property(get=GetBOF)) VARIANT_BOOL Invalid DDUE based on source, error:link not allowed in code, link filename:mdprobof_HV10294113.xml;

VARIANT_BOOL GetEndOfFile( ); // Actually, GetEOF. Renamed in #import.
__declspec(property(get=GetEndOfFile)) VARIANT_BOOL Invalid DDUE based on source, error:link not allowed in code, link filename:mdprobof_HV10294113.xml;

_variant_t GetBookmark( );
void PutBookmark( const _variant_t & pvBookmark );
__declspec(property(get=GetBookmark,put=PutBookmark)) _variant_t
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdprobookmark_HV10294117.xml;

long GetCacheSize( );
void PutCacheSize( long pl );
__declspec(property(get=GetCacheSize,put=PutCacheSize)) long
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocachesize_HV10294119.xml;

enum CursorTypeEnum GetCursorType( );
void PutCursorType( enum CursorTypeEnum plCursorType );
__declspec(property(get=GetCursorType,put=PutCursorType)) enum
 CursorTypeEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocursortype_HV10294257.xml;

_bstr_t GetDataMember( );
void PutDataMember( _bstr_t pbstrDataMember );
__declspec(property(get=GetDataMember,put=PutDataMember)) _bstr_t
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdprodatamember_HV10294276.xml;

IUnknownPtr GetDataSource( );
void PutRefDataSource( IUnknown * ppunkDataSource );
__declspec(property(get=GetDataSource,put=PutRefDataSource)) IUnknownPtr
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdprodatasource_HV10294277.xml;

enum EditModeEnum GetEditMode( );
__declspec(property(get=GetEditMode)) enum EditModeEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdproeditmode_HV10294326.xml;

FieldsPtr GetFields( );
__declspec(property(get=GetFields)) FieldsPtr Invalid DDUE based on source, error:link not allowed in code, link filename:mdcolfields_HV10294366.xml;

_variant_t GetFilter( );
void PutFilter( const _variant_t & Criteria );
__declspec(property(get=GetFilter,put=PutFilter)) _variant_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdprofilter_HV10294373.xml;

_bstr_t GetIndex( );
void PutIndex( _bstr_t pbstrIndex );
__declspec(property(get=GetIndex,put=PutIndex)) _bstr_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdproindex_HV10294437.xml;

enum LockTypeEnum GetLockType( );
void PutLockType( enum LockTypeEnum plLockType );
__declspec(property(get=GetLockType,put=PutLockType)) enum LockTypeEnum
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdprolocktype_HV10294487.xml;

enum MarshalOptionsEnum GetMarshalOptions( );
void PutMarshalOptions( enum MarshalOptionsEnum peMarshal );
__declspec(property(get=GetMarshalOptions,put=PutMarshalOptions)) enum
 MarshalOptionsEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdpromarshaloptions_HV10294491.xml;

long GetMaxRecords( );
void PutMaxRecords( long plMaxRecords );
__declspec(property(get=GetMaxRecords,put=PutMaxRecords)) long
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdpromaxrecords_HV10294496.xml;

long GetPageCount( );
__declspec(property(get=GetPageCount)) long Invalid DDUE based on source, error:link not allowed in code, link filename:mdpropagecount_HV10294585.xml;

long GetPageSize( );
void PutPageSize( long pl );
__declspec(property(get=GetPageSize,put=PutPageSize)) long Invalid DDUE based on source, error:link not allowed in code, link filename:mdpropagesize_HV10294586.xml;

long GetRecordCount( );
__declspec(property(get=GetRecordCount)) long Invalid DDUE based on source, error:link not allowed in code, link filename:mdprorecordcount_HV10294700.xml;

_bstr_t GetSort( );
void PutSort( _bstr_t Criteria );
__declspec(property(get=GetSort,put=PutSort)) _bstr_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdprosortpropertyado_HV10294782.xml;

void Invalid DDUE based on source, error:link not allowed in code, link filename:mdprorstsource_HV10294794.xml( IDispatch * pvSource );
void PutSource( _bstr_t pvSource );
_variant_t GetSource( );

long GetState( );
__declspec(property(get=GetState)) long Invalid DDUE based on source, error:link not allowed in code, link filename:mdprostate_HV10294804.xml;

long GetStatus( );
__declspec(property(get=GetStatus)) long Invalid DDUE based on source, error:link not allowed in code, link filename:mdprostatus_HV10294810.xml;

VARIANT_BOOL GetStayInSync( );
void PutStayInSync( VARIANT_BOOL pbStayInSync );
__declspec(property(get=GetStayInSync,put=PutStayInSync)) VARIANT_BOOL
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdprostayinsync_HV10294815.xml;


NavigationButton.Section Property (Access)

 Copy code hover
[image]

NavigationButton.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .Section

expression A variable that represents a NavigationButton object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Application.AccessError Method (Access)

 Copy code hover
[image]

Application.AccessError Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the AccessError method to return the descriptive string associated with a Microsoft Access or DAO error.

Syntax

expression .AccessError(ErrorNumber)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
ErrorNumber | Required | Variant | The number of the error for which you wish to return a descriptive string.

Return Value

Variant

Remarks

You can use the AccessError method to return the descriptive string associated with a Microsoft Access or DAO error when the error hasn't actually occurred, but you cannot use it for ADO errors.

You can use the Visual Basic Raise method to raise a Visual Basic error. Once you've raised the error, you can determine its associated descriptive string by reading the Description property of the Err object.

You can't use the Raise method to raise a Microsoft Access or DAO error. However, you can use the AccessError method to return the descriptive string associated with these errors, without having to generate the error.

You can use the AccessError method to return a descriptive string from within a form's Error event.

If the Microsoft Access error has occurred, you can return the descriptive string by using either the AccessError method or the Description property of the Visual Basic Err object.

Example

The following function returns an error string for any valid error number:

Note Note

You must have your error trapping options set to Break on Unhandled Errors for the code to run in the VBA IDE. You can set this option on the General tab of the Options dialog found on the VBA Tools menu.

VBA Copy code Copy code
Function ErrorString(ByVal lngError As Long) As String

 Const conAppError = "Application-defined or " & _
 "object-defined error"

 On Error Resume Next
 Err.Raise lngError

 If Err.Description = conAppError Then
 ErrorString = AccessError(lngError)
 ElseIf Err.Description = vbNullString Then
 MsgBox "No error string associated with this number."
 Else
 ErrorString = Err.Description
 End If

End Function

See also

Concepts

Application Object

Other resources

Application Object Members


Recordset2.ParentRecordset Property (DAO)

 Copy code hover
[image]

Recordset2.ParentRecordset Property (DAO)
Send feedback

Returns the parent Recordset of the specified recordset. Read-only.

Version Information

Version Added: Access 2007

Syntax

expression .ParentRecordset

expression A variable that represents a Recordset2 object.

Remarks

The ParentRecordset property returns Null if the specifed recordset does not represent a multi-valued field.


Record Object (ADO)

 Copy code hover
[image]

Record Object (ADO)
Send feedback

Represents a row from a Recordset or the data provider, or an object returned by a semi-structured data provider, such as a file or directory.

Remarks

A Record object represents one row of data, and has some conceptual similarities with a one-row Recordset. Depending upon the capabilities of your provider, Record objects may be returned directly from your provider instead of a one-row Recordset, for example when an SQL query that selects only one row is executed. Or, a Record object can be obtained directly from a Recordset object. Or, a Record can be returned directly from a provider to semi-structured data, such as the Microsoft Exchange OLE DB provider.

You can view the fields associated with the Record object by way of the Fields collection on the Record object. ADO allows object-valued columns including Recordset, SafeArray, and scalar values in the Fields collection of Record objects.

If the Record object represents a row in a Recordset, then it is possible to return to that original Recordset with the Source property.

The Record object can also be used by semi-structured data providers such as the Microsoft OLE DB Provider for Internet Publishing, to model tree-structured namespaces. Each node in the tree is a Record object with associated columns. The columns can represent the attributes of that node and other relevant information. The Record object can represent both a leaf node and a non-leaf node in the tree structure. Non-leaf nodes have other nodes as their contents while leaf nodes do not have such contents. Leaf nodes typically contain binary streams of data while non-leaf nodes may also have a default binary stream associated with them. Properties on the Record object identify the type of node.

The Record object also represents an alternative way for navigating hierarchically organized data. A Record object may be created to represent the root of a specific sub-tree in a large tree structure and new Record objects may be opened to represent child nodes.

A resource (for example, a file or directory) can be uniquely identified by an absolute URL. A Connection object is implicitly created and set to the Record object when the Record is opened with an absolute URL. A Connection object may explicitly be set to the Record object via the ActiveConnection property. The files and directories accessible via the Connection object define the context in which Record operations may occur.

Data modification and navigation methods on the Record object also accept a relative URL, which locates a resource using an absolute URL or the Connection object context as a starting point.

Note Note

URLs using the http scheme will automatically invoke the Microsoft OLE DB Provider for Internet Publishing. For more information, see Absolute and Relative URLs.

A Connection object is associated with each Record object. Therefore, Record object operations can be part of a transaction by invoking Connection object transaction methods.

The Record object does not support ADO events, and therefore will not respond to notifications.

With the methods and properties of a Record object, you can do the following:

  • Set or return the associated Connection object with the ActiveConnection property.

  • Indicate access permissions with the Mode property.

  • Return the URL of the directory, if any, that contains the resource represented by the Record with the ParentURL property.

  • Indicate the absolute URL, relative URL, or Recordset from which the Record is derived with the Source property.

  • Indicate the current status of the Record with the State property.

  • Indicate the type of Record — simple, collection, or structured document — with the RecordType property.

  • Halt execution of an asynchronous operation with the Cancel method.

  • Disassociate the Record from a data source with the Close method.

  • Copy the file or directory represented by a Record to another location with the CopyRecord method.

  • Delete the file, or directory and subdirectories, represented by a Record with the DeleteRecord method.

  • Open a Recordset containing rows that represent the subdirectories and files of the entity represented by the Record with the GetChildren method.

  • Move (rename) the file, or directory and subdirectories, represented by a Record to another location with the MoveRecord method.

  • Associate the Record with an existing data source, or create a new file or directory with the Open method.


Move Method Example (VJ++)

 Copy code hover
[image]

Move Method Example (VJ++)
Send feedback

This example uses the Move method to position the record pointer based on user input.

Copy code Copy code

// BeginMoveJ
import java.io.*;
import com.ms.wfc.data.*;
import com.ms.com.*;

public class MoveX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 MoveX();
 System.exit(0);
 }
 // MoveX Function

 static void MoveX()
 {
 // Define ADO Objects
 Recordset rstAuthors = null;

 // Declarations
 String line = null;
 Variant varBookmark;
 String strCommand = null;
 int lngMove;
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));

 try
 {
 // Open recordset from Authors table.
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"+
 "Initial Catalog='Pubs';Integrated Security='SSPI';";

 rstAuthors = new Recordset();
 rstAuthors.setCursorType(AdoEnums.CursorType.STATIC);

 // Use client cursor to allow use of
 // Absolute Position property.
 rstAuthors.setCursorLocation(AdoEnums.CursorLocation.CLIENT);
 rstAuthors.open("select au_id,au_fname,au_lname,city,state " +
 "from Authors order by au_lname",
 strCnn,AdoEnums.CursorType.STATIC,
 AdoEnums.CursorLocation.CLIENT, AdoEnums.CommandType.TEXT);

 rstAuthors.moveFirst();

 while(true)
 {
 // Display information about current record and
 // ask how many records to move.
 strCommand = "Record:\t\t"+ rstAuthors.getAbsolutePosition() +
 " of " + rstAuthors.getRecordCount() + "\n" + "\tAuthor:\t\t"
 + rstAuthors.getField("au_fname").getString() +
 " " + rstAuthors.getField("au_lname").getString() +
 "\n" +"\tLocation:\t" +
 rstAuthors.getField("city").getString() +
 ", " +rstAuthors.getField("state").getString()
 +"\n\n"+"\tEnter number of records to move" +
 " (positive or negative).";

 System.out.print("\t"+ strCommand + "\t");
 line =in.readLine();

 // No entry exits program loop.
 if (line.length()== 0)
 break;

 // Converts string entry to int.
 lngMove = Integer.parseInt(line);

 // Store bookmark in case the move goes too far
 // forward or backward.
 varBookmark =(Variant)rstAuthors.getBookmark();

 // Move method requires parameter of data type int.
 rstAuthors.move(lngMove);

 // Trap for BOF and EOF.
 if (rstAuthors.getBOF())
 {
 System.out.println("\tToo far backward! " +
 "Returning to the current record.");
 rstAuthors.setBookmark(varBookmark);
 }
 if (rstAuthors.getEOF())
 {
 System.out.println("\tToo far forward! " +
 "Returning to the current record.");
 rstAuthors.setBookmark(varBookmark);
 }
 }
 System.out.println("\tPress <Enter> to continue..");
 in.readLine();
 }

 catch(AdoException ae)
 {
 // Notify user of any errors that result from ADO.

 // As passing a recordset, check for null pointer.
 if (rstAuthors!=null)
 {
 PrintProviderError(rstAuthors.getActiveConnection());
 }
 else
 {
 System.out.println(" Exception: "+ ae.getMessage());
 }
 }
 // System Read requires this catch.
 catch(java.io.IOException je)
 {
 PrintIOError(je);
 }
 // Required if the user enter non integer value.
 catch(java.lang.NumberFormatException ne)
 {
 System.out.println("\n\nPlease enter integer values!");
 rstAuthors.close();
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstAuthors != null)
 if (rstAuthors.getState() == 1)
 rstAuthors.close();
 }
 }
 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndMoveJ


NavigationButton.Hyperlink Property (Access)

 Copy code hover
[image]

NavigationButton.Hyperlink Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Hyperlink

expression A variable that represents a NavigationButton object.

Example

The CreateHyperlink procedure in the following example sets the hyperlink properties for a command button, label, or image control to the address and subaddress values passed to the procedure. The address setting is an optional argument, because a hyperlink to an object in the current database uses only the subaddress setting, To try this example, create a form with two text box controls (txtAddress and txtSubAddress) and a command button (cmdFollowLink) and paste the following into the Declarations section of the form's module:

VBA Copy code Copy code
Private Sub cmdFollowLink_Click()
 CreateHyperlink Me!cmdFollowLink, Me!txtSubAddress, _
 Me!txtAddress
End Sub

Sub CreateHyperlink(ctlSelected As Control, _
 strSubAddress As String, Optional strAddress As String)
 Dim hlk As Hyperlink
 Select Case ctlSelected.ControlType
 Case acLabel, acImage, acCommandButton
 Set hlk = ctlSelected.Hyperlink
 With hlk
 If Not IsMissing(strAddress) Then
 .Address = strAddress
 Else
 .Address = ""
 End If
 .SubAddress = strSubAddress
 .Follow
 .Address = ""
 .SubAddress = ""
 End With
 Case Else
 MsgBox "The control '" & ctlSelected.Name _
 & "' does not support hyperlinks."
 End Select
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Label.GridlineStyleRight Property (Access)

 Copy code hover
[image]

Label.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified label. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleRight

expression A variable that represents a Label object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

Label Object

Other resources

Label Object Members


Rectangle.Properties Property (Access)

 Copy code hover
[image]

Rectangle.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a Rectangle object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


DoCmd.Beep Method (Access)

 Copy code hover
[image]

DoCmd.Beep Method (Access)
See also Send feedback

Published: July 16, 2012

The Beep method carries out the Beep action in Visual Basic.

Syntax

expression .Beep

expression A variable that represents a DoCmd object.

Remarks

This method has no arguments and can called directly using the syntax DoCmd.Beep.

You can also use the VBA command Interaction.Beep to accomplish the same result.

You can also use the Visual Basic Beep statement to cause your computer to sound a tone through its speaker.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Chapter 4: Editing Data

 Copy code hover
[image]

Chapter 4: Editing Data
Send feedback

The preceding two chapters explained how use ADO to connect to a data source, execute a command, get the results in a Recordset object, and navigate within the Recordset. This chapter focuses on the next fundamental ADO operation: editing data.

This chapter continues to use the sample Recordset introduced in Chapter 3 — with one important change. The following code is used to open the Recordset:

Copy code Copy code

 . . .
'BeginEditIntro
 Dim strSQL As String
 Dim objRs1 As ADODB.Recordset

 strSQL = "SELECT * FROM Shippers"

 Set objRs1 = New ADODB.Recordset

 objRs1.Open strSQL, GetNewConnection, adOpenStatic, _
 adLockBatchOptimistic, adCmdText

 ' Disconnect the Recordset from the Connection object.
 Set objRs1.ActiveConnection = Nothing
'EndEditIntro

 . . .

The important change to the code involves setting the Connection object's CursorLocation property equal to adUseClient in the GetNewConnection function (shown below), which indicates the use of a client cursor. For more information about the differences between client-side and server-side cursors, see Chapter 8: Understanding Cursors and Locks.

The CursorLocation property's adUseClient setting moves the location of the cursor from the data source (the SQL Server, in this case) to the location of the client code (the desktop workstation). This setting forces ADO to invoke the Client Cursor Engine for OLE DB on the client in order to create and manage the cursor.

You might also have noticed that the LockType parameter of the Open method changed to adLockBatchOptimistic. This opens the cursor in batch mode. (The provider caches multiple changes and writes them to the underlying data source only when you call the UpdateBatch method.) Changes made to the Recordset will not be updated in the database until the UpdateBatch method is called.

Finally, the code in this chapter uses a modified version of the GetNewConnection function, introduced in Chapter 2. This version of the function now returns a client-side cursor. The function looks like this:

Copy code Copy code

'BeginNewConnection
Public Function GetNewConnection() As ADODB.Connection
 Dim objConn1 As ADODB.Connection
 Set objConn1 = New ADODB.Connection

 strConnStr = "Provider=SQLOLEDB;Initial Catalog=Northwind;" & _
 "Data Source=MySrvr;Integrated Security=SSPI;"

 objConn1.ConnectionString = strConnStr
 objConn1.CursorLocation = adUseClient
 objConn1.Open

 Set GetNewConnection = objConn1
End Function
'EndNewConnection


ListBox.BackTint Property (Access)

 Copy code hover
[image]

ListBox.BackTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackTint

expression A variable that represents a ListBox object.

Remarks

The BackTint property contains a numeric expression that can be used to lighten the theme color in the BackColor property. The default value of the BackTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackTint=25

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


CurrentData.AllFunctions Property (Access)

 Copy code hover
[image]

CurrentData.AllFunctions Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllFunctions property to reference the AllFunctions collection and its related properties. Read-only AllFunctions object.

Syntax

expression .AllFunctions

expression A variable that represents a CurrentData object.

See also

Concepts

CurrentData Object

Other resources

CurrentData Object Members


CompareBookmarks Method (ADO)

 Copy code hover
[image]

CompareBookmarks Method (ADO)
Send feedback

Compares two bookmarks and returns an indication of their relative values.

Syntax

result = recordset.CompareBookmarks(Bookmark1, Bookmark2)

Return Value

Returns a CompareEnum value that indicates the relative row position of two records represented by their bookmarks.

Parameters

  • Bookmark1

  • The bookmark of the first row.

  • Bookmark2

  • The bookmark of the second row.

Remarks

The bookmarks must apply to the same Recordset object, or a Recordset object and its clone. You cannot reliably compare bookmarks from different Recordset objects, even if they were created from the same source or command. Nor can you compare bookmarks for a Recordset object whose underlying provider does not support comparisons.

A bookmark uniquely identifies a row in a Recordset object. Use the current row's Bookmark property to obtain its bookmark.

Because the data type of a bookmark is provider specific, ADO exposes it as a Variant. For example, SQL Server bookmarks are of type DBTYPE_R8 (Double). ADO would expose this type as a Variant with a subtype of Double.

When comparing bookmarks, ADO does not attempt any type of coercion. The values are simply passed to the provider where the compare occurs. If bookmarks passed to the CompareBookmarks method are stored in variables of differing types, it can generate the type mismatch error, "Arguments are of the wrong type, are out of the acceptable range, or are in conflict with each other."

A bookmark that is not valid or incorrectly formed will cause an error.


ObjectFrame.Updated Event (Access)

 Copy code hover
[image]

ObjectFrame.Updated Event (Access)
See also Send feedback

Published: July 16, 2012

The Updated event occurs when an OLE object's data has been modified.

Syntax

expression .Updated(Code)

expression A variable that represents an ObjectFrame object.

Remarks

To run a macro or event procedure when this event occurs, set the OnUpdated property to the name of the macro or to [Event Procedure].

You can use this event to determine if an object's data has been changed since it was last saved.

The Updated event occurs when the data in an OLE object has been modified. This update can come from the application in which the object was created or from one of the linked copies of this object. As a result, this event is asynchronous with other Microsoft Access control events.

Note Note

The Updated event and the BeforeUpdate and AfterUpdate events for bound and unbound object frames are not related. The Updated event occurs when an OLE object's data is changed, and the BeforeUpdate and AfterUpdate events occur when data is updated. Although not related, all three events usually occur when an OLE object's data is changed. The Updated event generally occurs before the BeforeUpdate and AfterUpdate events; however, this may not happen every time.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


NavigationButton.GridlineShade Property (Access)

 Copy code hover
[image]

NavigationButton.GridlineShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineShade

expression A variable that represents an NavigationButton object.

Remarks

The GridlineShade property contains a numeric expression that can be used to darken the theme color in the GridlineColor property. The default value of the GridlineShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Recordset2.PercentPosition Property (DAO)

 Copy code hover
[image]

Recordset2.PercentPosition Property (DAO)
Send feedback

Sets or returns a value indicating the approximate location of the current record in the Recordset object based on a percentage of the records in the Recordset.

Syntax

expression .PercentPosition

expression A variable that represents a Recordset2 object.

Remarks

To indicate or change the approximate position of the current record in a Recordset object, you can check or set the PercentPosition property. When working with a dynaset- or snapshot-type Recordset object opened directly from a base table, first populate the Recordset object by moving to the last record before you set or check the PercentPosition property. If you use the PercentPosition property before fully populating the Recordset object, the amount of movement is relative to the number of records accessed as indicated by the RecordCount property setting. You can move to the last record by using the MoveLast method.

Note Note

Using the PercentPosition property to move the current record to a specific record in a Recordset object isn't recommended?the Bookmark property is better suited for this task.

Once you set the PercentPosition property to a value, the record at the approximate position corresponding to that value becomes current, and the PercentPosition property is reset to a value that reflects the approximate position of the current record. For example, if your Recordset object contains only five records, and you set its PercentPosition property value to 77, the value returned from the PercentPosition property may be 80, not 77.

The PercentPosition property applies to all types of Recordset objects except for forward-only-type Recordset objects or Recordset objects opened from pass-through queries against remote databases.

You can use the PercentPosition property with a scroll bar on a form or text box to indicate the location of the current record in a Recordset object.

Example

This example uses the PercentPosition property to show the position of the current record pointer relative to the beginning of the Recordset.

VBA Copy code Copy code
Sub PercentPositionX()

 Dim dbsNorthwind As Database
 Dim rstProducts As Recordset2
 Dim strFind As String
 Dim strMessage As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 ' PercentPosition only works with dynasets or snapshots.
 Set rstProducts = dbsNorthwind.OpenRecordset( _
 "SELECT ProductName FROM Products " & _
 "ORDER BY ProductName", dbOpenSnapshot)

 With rstProducts
 ' Populate the Recordset.
 .MoveLast
 .MoveFirst

 Do While True
 ' Show current record information and ask user
 ' for input.
 strMessage = "Product: " & !ProductName & vbCr & _
 "The record pointer is " & _
 Format(.PercentPosition, "##0.0") & _
 "% from the " & vbCr & _
 "beginning of the Recordset." & vbCr & _
 "Please enter a character search string " & _
 "for a product name."
 strFind = Trim(InputBox(strMessage))
 If strFind = "" Then Exit Do

 ' Try to find a record matching the search string.
 .FindFirst "ProductName >= '" & strFind & "'"
 If .NoMatch Then .MoveLast
 Loop

 .Close
 End With

 dbsNorthwind.Close

End Sub


Error (Visual C++ Syntax Index with #import)

 Copy code hover
[image]

Error (Visual C++ Syntax Index with #import)
Send feedback

Properties

Copy code Copy code

_bstr_t GetDescription( );
__declspec(property(get=GetDescription)) _bstr_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdprodescription_HV10294309.xml;

long GetHelpContext( );
__declspec(property(get=GetHelpContext)) long Invalid DDUE based on source, error:link not allowed in code, link filename:mdprohelpcontext_HV10294428.xml;

_bstr_t GetHelpFile( );
__declspec(property(get=GetHelpFile)) _bstr_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdprohelpcontext_HV10294428.xml;

long GetNativeError( );
__declspec(property(get=GetNativeError)) long Invalid DDUE based on source, error:link not allowed in code, link filename:mdpronativeerror_HV10294539.xml;

long GetNumber( );
__declspec(property(get=GetNumber)) long Invalid DDUE based on source, error:link not allowed in code, link filename:mdpronumber_HV10294545.xml;

_bstr_t GetSource( );
__declspec(property(get=GetSource)) _bstr_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdproerrsource_HV10294791.xml;

_bstr_t GetSQLState( );
__declspec(property(get=GetSQLState)) _bstr_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdprosqlstate_HV10294801.xml;


Image.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

Image.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified image. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleLeft

expression A variable that represents an Image object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Image Object

Other resources

Image Object Members


OptionButton.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

OptionButton.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified option button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleBottom

expression A variable that represents an OptionButton object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Document.CreateProperty Method (DAO)

 Copy code hover
[image]

Document.CreateProperty Method (DAO)
Send feedback

Creates a new user-defined Property object (Microsoft Access workspaces only).

Syntax

expression .CreateProperty(Name, Type, Value, DDL)

expression A variable that represents a Document object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Optional | Variant | A String that uniquely names the new Property object. See the Name property for details on valid Property names.
Type | Optional | Variant | A constant that defines the data type of the new Property object. See the Type property for valid data types.
Value | Optional | Variant | A Variant containing the initial property value. See the Value property for details.
DDL | Optional | Variant | A Variant (Boolean subtype) that indicates whether or not the Property is a DDL object. The default is False. If DDL is True, users can't change or delete this Property object unless they have dbSecWriteDef permission.

Return Value

Property

Remarks

You can create a user-defined Property object only in the Properties collection of an object that is persistent.

If you omit one or more of the optional parts when you use CreateProperty, you can use an appropriate assignment statement to set or reset the corresponding property before you append the new object to a collection. After you append the object, you can alter some but not all of its property settings. See the Name, Type, and Value property topics for more details.

If name refers to an object that is already a member of the collection, a run-time error occurs when you use the Append method.

To remove a user-defined Property object from the collection, use the Delete method on the Properties collection. You can't delete built-in properties.

Note Note

If you omit the DDL argument, it defaults to False (non-DDL). Because no corresponding DDL property is exposed, you must delete and re-create a Property object you want to change from DDL to non-DDL.


BoundObjectFrame.Exit Event (Access)

 Copy code hover
[image]

BoundObjectFrame.Exit Event (Access)
See also Send feedback

Published: July 16, 2012

The Exit event occurs just before a control loses the focus to another control on the same form or report.

Syntax

expression .Exit(Cancel )

expression A variable that represents a BoundObjectFrame object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | Set to True to cancel the event.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when this event occurs, set the OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Exit event occurs before the LostFocus event.

Unlike the LostFocus event, the Exit event does not occur when a form loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


ToggleButton.Enabled Property (Access)

 Copy code hover
[image]

ToggleButton.Enabled Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.

Syntax

expression .Enabled

expression A variable that represents a ToggleButton object.

Remarks

The Enabled property setting is a value that indicates whether the conditional format is enabled or disabled. True enables the conditional format. False disables the conditional format. The default is True.

When the Enabled property is True, the conditional format can be displayed in the Conditional Formatting dialog box.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


TempVars.Add Method (Access)

 Copy code hover
[image]

TempVars.Add Method (Access)
See also Send feedback

Published: July 16, 2012

Adds a variable to the TempVars collection.

Version Information

Version Added: Access 2007

Syntax

expression .Add(Name, Value)

expression A variable that represents a TempVars object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Required | String | The name to use for the TempVar.
Value | Required | Variant | The value to store as a TempVar. This value must be a string expression or a numeric expression. Setting this argument to an object data type will result in a run-time error.

See also

Concepts

TempVars Collection

Other resources

TempVars Object Members


ObjectFrame.GridlineShade Property (Access)

 Copy code hover
[image]

ObjectFrame.GridlineShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineShade

expression A variable that represents an ObjectFrame object.

Remarks

The GridlineShade property contains a numeric expression that can be used to darken the theme color in the GridlineColor property. The default value of the GridlineShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Collections (Visual C++ Syntax Index with #import)

 Copy code hover
[image]

Collections (Visual C++ Syntax Index with #import)
Send feedback

It is useful to know that collections inherit certain common methods and properties.

All collections inherit the Count property and Refresh method, and all collections add the Item property. The Errors collection adds the Clear method. The Parameters collection inherits the Append and Delete methods, while the Fields collection adds the Append, Delete, and Update methods.

Properties Collection

Methods

Copy code Copy code

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthadorefresh_HV10294718.xml( );

Properties

Copy code Copy code

long GetCount( );
__declspec(property(get=GetCount)) long Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocount_HV10294234.xml;

PropertyPtr GetItem( const _variant_t & Index );
__declspec(property(get=GetItem)) PropertyPtr Invalid DDUE based on source, error:link not allowed in code, link filename:mdproitem_HV10294463.xml[];

Errors Collection

Methods

Copy code Copy code

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthclear_HV10294165.xml( );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthadorefresh_HV10294718.xml( );

Properties

Copy code Copy code

long GetCount( );
__declspec(property(get=GetCount)) long Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocount_HV10294234.xml;

PropertyPtr GetItem( const _variant_t & Index );
__declspec(property(get=GetItem)) PropertyPtr Invalid DDUE based on source, error:link not allowed in code, link filename:mdproitem_HV10294463.xml[];

Parameters Collection

Methods

Copy code Copy code

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthappend_HV10294078.xml( IDispatch * Object );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcoldelete_HV10294294.xml( const _variant_t & Index );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthadorefresh_HV10294718.xml( );

Properties

Copy code Copy code

long GetCount( );
__declspec(property(get=GetCount)) long Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocount_HV10294234.xml;

PropertyPtr GetItem( const _variant_t & Index );
__declspec(property(get=GetItem)) PropertyPtr Invalid DDUE based on source, error:link not allowed in code, link filename:mdproitem_HV10294463.xml[];

Fields Collection

Methods

Copy code Copy code

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthappend_HV10294078.xml( _bstr_t Name, enum DataTypeEnum Type, long DefinedSize,
 enum FieldAttributeEnum Attrib, const _variant_t & FieldValue =
 vtMissing );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcoldeletefield_HV10294293.xml( const _variant_t & Index );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthadorefresh_HV10294718.xml( );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthupdate_HV10294888.xml( );

Properties

Copy code Copy code

long GetCount( );
__declspec(property(get=GetCount)) long Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocount_HV10294234.xml;

PropertyPtr GetItem( const _variant_t & Index );
__declspec(property(get=GetItem)) PropertyPtr Invalid DDUE based on source, error:link not allowed in code, link filename:mdproitem_HV10294463.xml[];


Report.WindowLeft Property (Access)

 Copy code hover
[image]

Report.WindowLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Returns an Integer indicating the screen position in twips of the left edge of a report relative to the left edge of the Microsoft Access window. Read-only.

Syntax

expression .WindowLeft

expression A variable that represents a Report object.

Remarks

Use the Move method to change the position of a report.

See also

Concepts

Report Object

Other resources

Report Object Members


ObjectFrame.BorderColor Property (Access)

 Copy code hover
[image]

ObjectFrame.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Syntax

expression .BorderColor

expression A variable that represents an ObjectFrame object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


ADO Code Examples in Microsoft Visual Basic Scripting Edition

 Copy code hover
[image]

ADO Code Examples in Microsoft Visual Basic Scripting Edition
Send feedback

Use the following code examples to learn about how to use the ADO methods when writing in Visual Basic Scripting Edition (VBScript).

Note Note

Paste the entire code example, from beginning to end, into your code editor. The example may not run correctly if partial examples are used or if paragraph formatting is lost.

Methods

  • AddNew Method Example

  • Clone Method Example

  • Delete Method Example

  • Execute, Requery, and Clear Methods Example

  • Move Method Example

  • MoveFirst, MoveLast, MoveNext, and MovePrevious Methods Example

  • Open and Close Methods Example


EmptyCell.Move Method (Access)

 Copy code hover
[image]

EmptyCell.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Version Information

Version Added: Access 2010

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents an EmptyCell object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant |
Top | Optional | Variant |
Width | Optional | Variant |
Height | Optional | Variant |

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


TabControl.PressedShade Property (Access)

 Copy code hover
[image]

TabControl.PressedShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the PressedColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .PressedShade

expression A variable that represents a TabControl object.

Remarks

The PressedShade property contains a numeric expression that can be used to darken the theme color in the PressedColor property. The default value of the PressedShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Hyperlink.Follow Method (Access)

 Copy code hover
[image]

Hyperlink.Follow Method (Access)
See also Send feedback

Published: July 16, 2012

The Follow method opens the document or Web page specified by a hyperlink address associated with a control on a form or report.

Syntax

expression .Follow(NewWindow, AddHistory, ExtraInfo, Method, HeaderInfo)

expression A variable that represents a Hyperlink object.

Parameters

Name | Required/Optional | Data Type | Description
NewWindow | Optional | Boolean | True (-1) opens the document in a new window and False (0) opens the document in the current window. The default is False.
AddHistory | Optional | Boolean | True adds the hyperlink to the History folder and False doesn't add the hyperlink to the History folder. The default is True.
ExtraInfo | Optional | Variant | A string or an array of Byte data that specifies additional information for navigating to a hyperlink. For example, this argument may be used to specify a search parameter for an .ASP or .IDC file. In your Web browser, the extrainfo argument may appear after the hyperlink address, separated from the address by a question mark (?). You don't need to include the question mark when you specify the extrainfo argument.
Method | Optional | MsoExtraInfoMethod | A MsoExtraInfoMethod constant that specifies how the extrainfo argument is attached. The default is msoMethodGet.
HeaderInfo | Optional | String | Specifies header information. By default the headerinfo argument is a zero-length string (" ").

Remarks

The Follow method has the same effect as clicking a hyperlink.

You can include the Follow method in an event procedure if you want to open a hyperlink in response to a user action. For example, you may want to open a web page with reference information when a user opens a particular form.

When you use the Follow method, you don't need to know the address specified by a control's HyperlinkAddress property. You only need to know the name of the control that contains the hyperlink. Conversely, when you use the FollowHyperlink method, you need to specify the address for the particular hyperlink you wish to follow.

Example

The following example sets the HyperlinkAddress property of a command button and then opens the hyperlink when the form is loaded.

To try this example, create a form and add a command button named Command0. Paste the following code into the form's module and switch to Form view:

VBA Copy code Copy code
Private Sub Form_Load()
    Dim ctl As CommandButton

    Set ctl = Me!Command0
    With ctl
        .Visible = False
        .HyperlinkAddress = "http://www.microsoft.com/"
        .Hyperlink.Follow
    End With
End Sub

See also

Concepts

Hyperlink Object

Other resources

Hyperlink Object Members


Section.HasContinued Property (Access)

 Copy code hover
[image]

Section.HasContinued Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the HasContinued property to determine if part of the current section begins on the previous page. Read/write Boolean.

Syntax

expression .HasContinued

expression A variable that represents a Section object.

Remarks

The HasContinued property is set by Microsoft Access and is read-only in all views.

Value | Description
True | Part of the current section has been printed on the previous page.
False | Part of the current section hasn't been printed on the previous page.

You can use this property to determine whether to show or hide certain controls depending on the value of the property. For example, you may have a hidden label in a page header containing the text "Continued from previous page". If the value of the HasContinued property is True, you can make the hidden label visible.

See also

Concepts

Section Object

Other resources

Section Object Members


WebBrowserControl.Updated Event (Access)

 Copy code hover
[image]

WebBrowserControl.Updated Event (Access)
See also Send feedback

Published: July 16, 2012

The Updated event occurs when an OLE object's data has been modified.

Version Information

Version Added: Access 2010

Syntax

expression .Updated(Code, )

expression A variable that represents a WebBrowserControl object.

Parameters

Name | Required/Optional | Data Type | Description
Code | Required | Integer |

Return Value

nothing

Remarks

To run a macro or event procedure when this event occurs, set the OnUpdated property to the name of the macro or to [Event Procedure].

You can use this event to determine if an object's data has been changed since it was last saved.

The Updated event occurs when the data in an OLE object has been modified. This update can come from the application in which the object was created or from one of the linked copies of this object. As a result, this event is asynchronous with other Microsoft Access control events.

Note Note

The Updated event and the BeforeUpdate and AfterUpdate events for bound and unbound object frames are not related. The Updated event occurs when an OLE object's data is changed, and the BeforeUpdate and AfterUpdate events occur when data is updated. Although not related, all three events usually occur when an OLE object's data is changed. The Updated event generally occurs before the BeforeUpdate and AfterUpdate events; however, this may not happen every time.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


ListBox.ColumnOrder Property (Access)

 Copy code hover
[image]

ListBox.ColumnOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.

Syntax

expression .ColumnOrder

expression A variable that represents a ListBox object.

Remarks

To set or change this property for a table or query by using Visual Basic, you must use a column's Properties collection. For details on using the Properties collection, see Properties .

Note Note

The ColumnOrder property isn't available in Design view.

The ColumnOrder property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

In Datasheet view, a field's ColumnOrder property setting is determined by the field's position. For example, the field in the leftmost column in Datasheet view has a ColumnOrder property setting of 1, the next field has a setting of 2, and so on. Changing a field's ColumnOrder property resets the property for that field and every field to the left of its original position in Datasheet view.

In other views, the property setting is 0 unless you explicitly change the order of one or more fields in Datasheet view (either by dragging the fields to new positions or by changing their ColumnOrder property settings). Fields to the right of the moved field's new position will have a property setting of 0 in views other than Datasheet view.

The order of the fields in Datasheet view doesn't affect the order of the fields in table Design view or Form view.

Example

The following example displays the ProductName and QuantityPerUnit fields in the first two columns in Datasheet view of the Products form.

VBA Copy code Copy code
Forms!Products!ProductName.ColumnOrder = 1
Forms!Products!QuantityPerUnit.ColumnOrder = 2

The next example displays the ProductName and QuantityPerUnit fields in the first two columns of the Products table in Datasheet view. To set the ColumnOrder property, the example uses the SetFieldProperty procedure. If this procedure is run while the table is open, changes will not be displayed until it is closed and reopened.

VBA Copy code Copy code
Public Sub SetColumnOrder()

 Dim dbs As DAO.Database
 Dim tdf As DAO.TableDef

 Set dbs = CurrentDb
 Set tdf = dbs!Products

 ' Call the procedure to set the ColumnOrder property.
 SetFieldProperty tdf!ProductName, "ColumnOrder", dbLong, 2
 SetFieldProperty tdf!QuantityPerUnit, "ColumnOrder", dbLong, 3

 Set tdf = Nothing
 Set dbs = Nothing

End Sub

Private Sub SetFieldProperty(ByRef fld As DAO.Field, _
 ByVal strPropertyName As String, _
 ByVal intPropertyType As Integer, _
 ByVal varPropertyValue As Variant)
 ' Set field property without producing nonrecoverable run-time error.

 Const conErrPropertyNotFound = 3270
 Dim prp As Property

 ' Turn off error handling.
 On Error Resume Next

 fld.Properties(strPropertyName) = varPropertyValue

 ' Check for errors in setting the property.
 If Err <> 0 Then
 If Err <> conErrPropertyNotFound Then
 On Error GoTo 0
 MsgBox "Couldn't set property '" & strPropertyName & _
 "' on field '" & fld.Name & "'", vbCritical
 Else
 On Error GoTo 0
 Set prp = fld.CreateProperty(strPropertyName, intPropertyType, _
 varPropertyValue)
 fld.Properties.Append prp
 End If
 End If

 Set prp = Nothing

End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


LogMessages Property

 Copy code hover
[image]

LogMessages Property
Send feedback

Published: July 16, 2012

You can use the LogMessages property in an SQL pass-through query to specify whether messages returned from an SQL database are stored in a messages table in the current Microsoft Access database.

Note Note

The LogMessages property applies only to pass-through queries.

Setting

The LogMessages property uses the following settings.

Setting | Visual Basic | Description
Yes | True (-1) | Microsoft Access stores messages returned from the SQL database in a messages table.
No | False (0) | (Default) Microsoft Access doesn't store messages returned from the SQL database.

You can set this property by using the query's property sheet or Visual Basic .

Remarks

The name of the messages table where the returned messages are stored is username - nn, where username is the logon name of the user running the pass-through query, and nn is an integer that increases in increments of 1, starting at 00. For example, if user JoanW sets the LogMessages property to Yes and receives messages from an SQL database, the messages table will be named JoanW - 00. If JoanW receives messages in another Microsoft Access session (and the first table hasn't been deleted), a new table named JoanW - 01 is created.

Note Note

Error messages from SQL Server aren't stored in the messages table.


ComboBox.OnUndo Property (Access)

 Copy code hover
[image]

ComboBox.OnUndo Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the Undo event occurs. Read/write..

Syntax

expression .OnUndo

expression A variable that represents a ComboBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the Undo event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the Undo event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).OnUndo = "[Event Procedure]"

The following example specifies that when the Undo event occurs in any text box on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Dim ctlLoop As Control

For Each ctlLoop In Forms(0).Controls
 If ctlLoop.Type = acTextBox Then
 ctlLoop.OnUndo = "[Event Procedure]"
 End If
Next ctlLoop

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


TextBox.GridlineColor Property (Access)

 Copy code hover
[image]

TextBox.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified text box. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineColor

expression A variable that represents a TextBox object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


CodeProject.CloseConnection Method (Access)

 Copy code hover
[image]

CodeProject.CloseConnection Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the CloseConnection method to close the current connection between the CodeProject object in a Microsoft Access project (.adp) or Access database and the database specified in the project's base connection string.

Syntax

expression .CloseConnection

expression A variable that represents a CodeProject object.

Return Value

Nothing

Remarks

The CloseConnection method closes the current connection of the Access project, database, or data source control, frees the ADO Connection object, and sets the Connection property to Null. The BaseConnectionString property is left unchanged. Users are prevented from calling datasourcecontrol.Connection.Close and must use this method instead.

The CloseConnection method is useful when you have opened a Microsoft Access database from another application through Automation.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


OpenPopup Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

OpenPopup Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Opens the specified view in a popup window.

Syntax

OpenPopup (View, Where=, Order By)

The OpenPopup action contains the following arguments.

Argument name | Description
View | The name of the view to open.
Where= | A valid SQL WHERE clause (without the word WHERE) that restricts the records in the view.
Order By | A string expression that includes the name of the field or fields on which to sort records and the optional ASC or DESC keywords. By default, this argument is blank.

Remarks

The current macro ends once the OpenPopup action is processed.

Any sorting or filtering applied by the user is cleared when the OpenPopup action is called.

The OrderBy argument is the name of the field or fields on which you want to sort records. When you use more than one field name, separate the names with a comma (,).

When you set the OrderBy argument, the records are sorted by default in ascending order.


IsolationLevel and Mode Properties Example (VC++)

 Copy code hover
[image]

IsolationLevel and Mode Properties Example (VC++)
Send feedback

This example uses the Mode property to open an exclusive connection, and the IsolationLevel property to open a transaction that is conducted in isolation of other transactions.

Copy code Copy code

// BeginIsolationLevelCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF","EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>
#include "IsolationLevelX.h"

// Function Declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void IsolationLevelX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

/////////////////////////////////////////////////////////////////
// //
// //
// Main Function //
// //
// //
/////////////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 IsolationLevelX();

 printf("Press any key to continue...");
 getch();
 ::CoUninitialize();
}

/////////////////////////////////////////////////////////////////
// //
// IsolationLevelX() Function //
// //
/////////////////////////////////////////////////////////////////

void IsolationLevelX(void)
{
 // Define ADO ObjectPointers
 // Initialize Pointers on define
 // These are in the ADODB :: namespace
 _RecordsetPtr pRstTitles = NULL;
 _ConnectionPtr pConnection = NULL;

 // Define other Variables
 HRESULT hr = S_OK;
 IADORecordBinding *picRs = NULL; // Interface Pointer Declared
 CTitleRs titlers; // C++ Class Object
 LPSTR p_TempStr = NULL;

 //Assign Connection String to Variable
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 // Open Connection and Titles Table
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
 pConnection->Mode = adModeShareExclusive;
 pConnection->IsolationLevel = adXactIsolated;
 pConnection->Open(strCnn,"","",adConnectUnspecified);

 TESTHR(pRstTitles.CreateInstance(__uuidof(Recordset)));
 pRstTitles->CursorType = adOpenDynamic;
 pRstTitles->LockType = adLockPessimistic;

 pRstTitles->Open("titles",_variant_t((IDispatch*) pConnection,
 true),adOpenDynamic,adLockPessimistic,adCmdTable);

 pConnection->BeginTrans();

 // Display Connection Mode
 if(pConnection->Mode == adModeShareExclusive)
 {
 printf("Connection Mode Is Exclusive");
 }
 else
 {
 printf("Connection Mode Is Not Exclusive");
 }

 // Display Isolation Level
 if(pConnection->IsolationLevel == adXactIsolated)
 {
 printf("\n\nTransaction is Isolated");
 printf("\n\nPress any key to continue...\n\n");
 getch();
 }
 else
 {
 printf("\n\nTransaction is not Isolated");
 printf("\n\nPress any key to continue...\n\n");
 getch();
 }

 // Open an IADORecordBinding interface pointer which
 // we will use for binding Recordset to a class
 TESTHR(pRstTitles->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 // Bind the Recordset to a C++ class here
 TESTHR(picRs->BindToRecordset(&titlers));

 // Change the type of psychology titles.
 p_TempStr = (LPSTR) malloc(sizeof(titlers.m_szau_Type));

 while (!(pRstTitles->EndOfFile))
 {
 // Set the final character of the destination string to NULL.
 p_TempStr[sizeof(titlers.m_szau_Type)-1] = '\0';
 // The source string will get truncated if its length is
 // longer than the length of the destination string minus one.
 strncpy(p_TempStr,strtok(titlers.m_szau_Type," "),sizeof(titlers.m_szau_Type)-1);

 // Compare type with psychology
 if (!strcmp(p_TempStr,"psychology"))
 {
 // Set the final character of the destination string to NULL.
 titlers.m_szau_Type[sizeof(titlers.m_szau_Type)-1] = '\0';
 // Copy "self_help" title field
 // The source string will get truncated if its length is
 // longer than the length of the destination string minus one.
 strncpy(titlers.m_szau_Type,"self_help",sizeof(titlers.m_szau_Type)-1);
 picRs->Update(&titlers);
 }
 pRstTitles->MoveNext();
 }
 // Print current data in recordset.
 pRstTitles->Requery(adOptionUnspecified);

 // Open again IADORecordBinding interface pointer for Binding
 // Recordset to a class.
 TESTHR(pRstTitles->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 // ReBinding the Recordset to a C++ Class
 TESTHR(picRs->BindToRecordset(&titlers));

 // Move to the first record of the title table
 pRstTitles->MoveFirst();

 //Clear the screen for the next display
 system("cls");

 while (!pRstTitles->EndOfFile)
 {
 printf("%s - %s\n",titlers.lau_TitleStatus == adFldOK ?
 titlers.m_szau_Title :"<NULL>",
 titlers.lau_TypeStatus == adFldOK ?
 titlers.m_szau_Type :"<NULL>");
 pRstTitles->MoveNext();
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 PrintProviderError(pConnection);
 PrintComError(e);
 }

 // Clean up objects before exit.
 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (pRstTitles)
 if (pRstTitles->State == adStateOpen)
 pRstTitles->Close();
 if (pConnection)
 if (pConnection->State == adStateOpen)
 {
 // Restore Original Data
 pConnection->RollbackTrans();

 pConnection->Close();
 }

 // Deallocate the memory
 if (p_TempStr)
 free(p_TempStr);
}

/////////////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
/////////////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 //Print Provider Errors from Connection object
 //pErr is a record object in the Connection's Error collection
 ErrorPtr pErr = NULL;

 if((pConnection->Errors->Count)>0)
 {
 long nCount = pConnection->Errors->Count;

 //Collection ranges from 0 to nCount-1
 for(long i = 0;i < nCount;i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error Number :%x \t %s",pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndIsolationLevelCpp

IsolationLevelX.h

Copy code Copy code

// BeginIsolationLevelH

#include "icrsint.h"

//This class extracts titles and type from Title table

class CTitleRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CTitleRs)
 // Column title is the 2nd field in the table
 ADO_VARIABLE_LENGTH_ENTRY2(2,adVarChar,m_szau_Title,
 sizeof(m_szau_Title),lau_TitleStatus,FALSE)
 // Column type is the 3rd field in the table
 ADO_VARIABLE_LENGTH_ENTRY2(3,adVarChar,m_szau_Type,
 sizeof(m_szau_Type),lau_TypeStatus,TRUE)
END_ADO_BINDING()

public:
 CHAR m_szau_Title[81];
 ULONG lau_TitleStatus;
 CHAR m_szau_Type[13];
 ULONG lau_TypeStatus;
};
// EndIsolationLevelH


TableDef.CreateIndex Method (DAO)

 Copy code hover
[image]

TableDef.CreateIndex Method (DAO)
Send feedback

Creates a new Index object (Microsoft Access workspaces only). .

Syntax

expression .CreateIndex(Name)

expression A variable that represents a TableDef object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Optional | Variant | A String that uniquely names the new Index object. See the Name property for details on valid Index names.

Return Value

Index

Remarks

You can use the CreateIndex method to create a new Index object for a TableDef object. If you omit the optional name part when you use CreateIndex, you can use an appropriate assignment statement to set or reset the Name property before you append the new object to a collection. After you append the object, you may or may not be able to set its Name property, depending on the type of object that contains the Indexes collection. See the Name property topic for more details.

If name refers to an object that is already a member of the collection, a run-time error occurs when you use the Append method.

To remove an Index object from a collection, use the Delete method on the collection.

Example

This example uses the CreateIndex method to create two new Index objects and then appends them to the Indexes collection of the Employees TableDef object. It then enumerates the Indexes collection of the TableDef object, the Fields collection of the new Index objects, and the Properties collection of the new Index objects. The CreateIndexOutput function is required for this procedure to run.

VBA Copy code Copy code
Sub CreateIndexX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim idxCountry As Index
 Dim idxFirstName As Index
 Dim idxLoop As Index

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set tdfEmployees = dbsNorthwind!Employees

 With tdfEmployees
 ' Create first Index object, create and append Field
 ' objects to the Index object, and then append the
 ' Index object to the Indexes collection of the
 ' TableDef.
 Set idxCountry = .CreateIndex("CountryIndex")
 With idxCountry
 .Fields.Append .CreateField("Country")
 .Fields.Append .CreateField("LastName")
 .Fields.Append .CreateField("FirstName")
 End With
 .Indexes.Append idxCountry

 ' Create second Index object, create and append Field
 ' objects to the Index object, and then append the
 ' Index object to the Indexes collection of the
 ' TableDef.
 Set idxFirstName = .CreateIndex
 With idxFirstName
 .Name = "FirstNameIndex"
 .Fields.Append .CreateField("FirstName")
 .Fields.Append .CreateField("LastName")
 End With
 .Indexes.Append idxFirstName

 ' Refresh collection so that you can access new Index
 ' objects.
 .Indexes.Refresh

 Debug.Print .Indexes.Count & " Indexes in " & _
 .Name & " TableDef"

 ' Enumerate Indexes collection.
 For Each idxLoop In .Indexes
 Debug.Print " " & idxLoop.Name
 Next idxLoop

 ' Print report.
 CreateIndexOutput idxCountry
 CreateIndexOutput idxFirstName

 ' Delete new Index objects because this is a
 ' demonstration.
 .Indexes.Delete idxCountry.Name
 .Indexes.Delete idxFirstName.Name
 End With

 dbsNorthwind.Close

End Sub

Function CreateIndexOutput(idxTemp As Index)

 Dim fldLoop As Field
 Dim prpLoop As Property

 With idxTemp
 ' Enumerate Fields collection of Index object.
 Debug.Print "Fields in " & .Name
 For Each fldLoop In .Fields
 Debug.Print " " & fldLoop.Name
 Next fldLoop

 ' Enumerate Properties collection of Index object.
 Debug.Print "Properties of " & .Name
 For Each prpLoop In .Properties
 Debug.Print " " & prpLoop.Name & " - " & _
 IIf(prpLoop = "", "[empty]", prpLoop)
 Next prpLoop
 End With

End Function


ComboBox.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

ComboBox.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified combo box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthBottom

expression A variable that represents a ComboBox object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


WebBrowserControl.Controls Property (Access)

 Copy code hover
[image]

WebBrowserControl.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Version Information

Version Added: Access 2010

Syntax

expression .Controls

expression A variable that represents a WebBrowserControl object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


The replication property you are attempting to set or delete is read-only and cannot be changed. (Error 3461)

 Copy code hover
[image]

The replication property you are attempting to set or delete is read-only and cannot be changed. (Error 3461)
Send feedback

Many properties related to replication are for internal use only or are available to the developer on a read-only basis. Review your program code to make sure you are reading rather than changing the property.


The OLE DB Provider for Internet Publishing

 Copy code hover
[image]

The OLE DB Provider for Internet Publishing
Send feedback

The ADO Record and Stream objects can be used with the Microsoft OLE DB Provider for Internet Publishing (Internet Publishing Provider) to access and manipulate resources, such as Web folders or files served by Microsoft FrontPage. With ADO, you can specify the source of a Record, Stream, or Recordset to be a URL. You can then upload, download, move, copy, and delete resources, or directly manipulate resource properties.

For example code using Records and Streams with the Internet Publishing Provider, see the Internet Publishing Scenario.

The Internet Publishing Provider is installed with Microsoft Windows 2000. Earlier versions of the Internet Publishing Provider are also available with Microsoft Office 2000 and Microsoft Internet Explorer 5.0.

There are three ways to connect ADO to the Internet Publishing Provider:

  • Specify "URL=" in the connection string. For example:

    Copy code Copy code

objConn.Open "URL=http://servername"

  • Specify Msdaipp.dso for the Provider keyword of the connection string. For example:

    Copy code Copy code

objConn.Open "provider=MSDAIPP.DSO;data source=http://servername"

  • Specify Msdaipp.dso for the Provider property of the Connection object. For example:

    Copy code Copy code

objConn.Provider = "MSDAIPP.DSO"
objConn.Open "http://servername"

Note Note

If Msdaipp.dso is explicitly specified as the value of the provider, either with the Provider connection string keyword or the Provider property, you cannot use "URL=" in the connection string. If you do, an error will occur. Instead, simply specify the URL as shown above.

For more specific information about the Internet Publishing Provider, see Microsoft OLE DB Provider for Internet Publishing, or the provider documentation provided with the source application with which the OLE DB Provider for Internet Publishing was installed: Windows 2000, Office 2000, or Internet Explorer 5.0.


Form.AfterRender Property (Access)

 Copy code hover
[image]

Form.AfterRender Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the AfterRender event occurs. Read/write.

Syntax

expression .AfterRender

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the AfterRender event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).AfterRender = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


Could not open .inf file. (Error 3165)

 Copy code hover
[image]

Could not open .inf file. (Error 3165)
Send feedback

You tried to link a dBASE table, but the associated .inf file that contains index information about that table could not be opened or created.

Possible causes:

  • There is not enough disk space available to create the .inf file.

  • In a network environment, you do not have write privileges for the network drive.


Label.LineSpacing Property (Access)

 Copy code hover
[image]

Label.LineSpacing Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the LineSpacing property to specify or determine the location of information displayed within a label or text box control. Read/write Integer.

Syntax

expression .LineSpacing

expression A variable that represents a Label object.

Remarks

A control's displayed information location is the distance measured between each line of the displayed information. To use a unit of measurement different from the setting in the Regional Options dialog box in Windows Control Panel, specify the unit, such as cm or in (for example, 3 cm or 2 in).

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

Example

The following example sets the line spacing to 0.25 inches for the text box "PurchaseOrderInformation" on the "Purchase Order Form"

VBA Copy code Copy code
' 0.25 inches = 360/1440 twips.
 Forms("Purchase Orders").Controls("PurchaseOrderDescription").LineSpacing = 360

See also

Concepts

Label Object

Other resources

Label Object Members


Image.PictureType Property (Access)

 Copy code hover
[image]

Image.PictureType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.

Syntax

expression .PictureType

expression A variable that represents an Image object.

Remarks

The PictureType property uses the following settings.

Setting | Description
0 | (Default) The picture is embedded in the object and becomes part of the database file.
1 | The picture is linked to the object. Microsoft Access stores a pointer to the location of the picture on the disk.

This property can be set only in form Design view or report Design view.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

When this property is set to 0, the size of the database increases by the size of the picture file and, with some .wmf files, the size may increase as much as twice the size of the picture file. When this property is set to 1, there is no increase in the size of the database because Microsoft Access only saves a pointer to the picture's location on the disk.

Note Note

If a linked file is moved to another location on the disk, you must re-establish the link by using the object's Picture property.

For embedded pictures, the object's PictureData property stores the individual bits that make up a picture's image. For linked pictures, this property stores the path to the picture's file.

You can modify a linked picture by using a separate application and changes to the picture will appear the next time the object containing that picture is displayed in the database.

Example

The following example links the picture in the "Customer Photo" image control on the "Order Entry" form to the picture on the disk. The picture is not part of the database file.

VBA Copy code Copy code
Forms("Order Entry").Controls("Customer Photo").PictureType = 1

See also

Concepts

Image Object

Other resources

Image Object Members


WebBrowserControl.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

WebBrowserControl.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents a WebBrowserControl object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.BorderThemeColorIndex=2

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


ListBox.IMESentenceMode Property (Access)

 Copy code hover
[image]

ListBox.IMESentenceMode Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .IMESentenceMode

expression A variable that represents a ListBox object.

Remarks

The IMESentenceMode property uses the following settings.

Setting | Description | Visual Basic
Normal | (Default) Set IME Sentence Mode to "Normal" mode. | 0
Plural | Set IME Sentence Mode to "Plural" mode. | 1
Speaking | Set IME Sentence Mode to "Speaking" mode. | 2
No Conversion | Doesn't set IME Sentence Mode. | 3

Normal mode

Use this mode when creating a literary Japanese document.

Plural mode

Use this mode when entering name or address data. In this mode, two additional dictionaries are available. The "Biographical/Geographical Dictionary" contains names not covered in the normal dictionary and the "Postal Code Dictionary", useful in creating addresses. (Factory setting.)

Speaking mode

Use this mode when entering data that contains conversational language.

No Conversion

In this mode, inputted characters are settled without conversion.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Application.CreateGroupLevel Method (Access)

 Copy code hover
[image]

Application.CreateGroupLevel Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the CreateGroupLevel method to specify a field or expression on which to group or sort data in a report. .

Syntax

expression .CreateGroupLevel(ReportName, Expression, Header, Footer)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
ReportName | Required | String | the name of the report that will contain the new group level.
Expression | Required | String | The field or expression to sort or group on.
Header | Required | Integer | Indicates a field or expression will have an associated group header. If the header argument is True (-1), the field or expression will have a group header. If the header argument is False (0), the field or expression won't. You can create a header by setting the argument to True.
Footer | Required | Integer | Indicates a field or expression will have an associated group footer. If the footer argument is True (-1), the field or expression will have a group footer. If the footer argument is False (0), the field or expression won't. You can create a footer by setting the argument to True.

Return Value

Long

Remarks

For example, suppose you are building a custom wizard that provides the user with a choice of fields on which to group data when designing a report. Call the CreateGroupLevel method from your wizard to create the appropriate groups according to the user's choice.

You can use the CreateGroupLevel method when designing a wizard that creates a report with groups or totals. The CreateGroupLevel method groups or sorts data on the specified field or expression and creates a header and/or footer for the group level.

The CreateGroupLevel method is available only in report Design view.

Microsoft Access uses an array, the GroupLevel property array, to keep track of the group levels created for a report. The CreateGroupLevel method adds a new group level to the array, based on the expression argument. The CreateGroupLevel method then returns an index value that represents the new group level's position in the array. The first field or expression you sort or group on is level 0, the second is level 1, and so on. You can have up to ten group levels in a report (0 to 9).

When you specify that either the header or footer argument, or both, is True, the GroupHeader and GroupFooter properties in a report are set to Yes, and a header and/or footer is created for the group level.

Once a header or footer is created, you can set other GroupLevel properties: GroupOn , GroupInterval , and KeepTogether.

Note Note

If your wizard creates group levels in a new or existing report, it must open the report in Design view.

Example

The following example creates a group level on an OrderDate field on a report called OrderReport. The report on which the group level is to be created must be open in Design view. Since the header and footer arguments are set to True (-1), the method creates both the header and footer for the group level. The header and footer are then sized.

VBA Copy code Copy code
Sub CreateGL()
 Dim varGroupLevel As Variant

 ' Create new group level on OrderDate field.
 varGroupLevel = CreateGroupLevel("OrderReport", "OrderDate", _
 True, True)
 ' Set height of header/footer sections.
 Reports!OrderReport.Section(acGroupLevel1Header).Height = 400
 Reports!OrderReport.Section(acGroupLevel1Footer).Height = 400
End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


SmartTags.Add Method (Access)

 Copy code hover
[image]

SmartTags.Add Method (Access)
See also Send feedback

Published: July 16, 2012

Adds a smart tag to a form or control.

Syntax

expression .Add(Name)

expression A variable that represents a SmartTags object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Required | String | The name of the smart tag to add.

Return Value

SmartTag

See also

Concepts

SmartTags Collection

Other resources

SmartTags Object Members


Application.CodeProject Property (Access)

 Copy code hover
[image]

Application.CodeProject Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the CodeProject property to access the CodeProject object and its related collections, properties, and methods. Read-only CodeProject object.

Syntax

expression .CodeProject

expression A variable that represents an Application object.

Remarks

Use the CodeProject property to refer to one of the following code database collections together with one of its properties or methods.

AllForms | AllMacros
AllModules | AccessObjectProperties
AllReports |

See also

Concepts

Application Object

Other resources

Application Object Members


ToggleButton.DisplayWhen Property (Access)

 Copy code hover
[image]

ToggleButton.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Syntax

expression .DisplayWhen

expression A variable that represents a ToggleButton object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Zero-length string is valid only in a Text or Memo field. (Error 3415)

 Copy code hover
[image]

Zero-length string is valid only in a Text or Memo field. (Error 3415)
Send feedback

You are trying to enter a zero-length string in a field that has a data type other than Text or Memo. You may be able to enter a Null value instead.


OptionGroup.Parent Property (Access)

 Copy code hover
[image]

OptionGroup.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents an OptionGroup object.

Remarks

The Parent property for a check box, option button, or toggle button in an option group is the name of the option group control. The Parent property of an option group control is the name of the form.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


AllStoredProcedures.Item Property (Access)

 Copy code hover
[image]

AllStoredProcedures.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.

Syntax

expression .Item(var)

expression A variable that represents an AllStoredProcedures object.

Parameters

Name | Required/Optional | Data Type | Description
var | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

AllStoredProcedures Collection

Other resources

AllStoredProcedures Object Members


The operation you attempted conflicts with an existing operation involving this member of the replica set. (Error 3460)

 Copy code hover
[image]

The operation you attempted conflicts with an existing operation involving this member of the replica set. (Error 3460)
Send feedback

Another user or application is already performing the same operation on this member of the replica set. Retry your action later.


NavigationControl.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

NavigationControl.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthLeft

expression A variable that represents a NavigationControl object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


The number of aliases specified shall be the same as number of output columns (Error 3731)

 Copy code hover
[image]

The number of aliases specified shall be the same as number of output columns (Error 3731)
Send feedback

This error occurs when trying to create a view through SQL DDL. The error occurs when a different number of correlation names or aliases are defined from what is in the SELECT statement. For example, the following syntax would generate this error: CREATE VIEW foo (col1, col2) AS SELECT col1 FROM table1.


AbsolutePage, PageCount, and PageSize Properties Example (VC++)

 Copy code hover
[image]

AbsolutePage, PageCount, and PageSize Properties Example (VC++)
Send feedback

This example uses the AbsolutePage, PageCount, and PageSize properties to display names and hire dates from the Employee table, five records at a time.

Copy code Copy code

// BeginAbsolutePageCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <stdio.h>
#include <ole2.h>
#include "conio.h"
#include "AbsolutepageX.h"

//Function Declarations.
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void AbsolutePageX(void);
void PrintProviderError(_ConnectionPtr pConnection);

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 AbsolutePageX();

 ::CoUninitialize();
}

/////////////////////////////////////////////////////////////
// //
// AbsolutePageX Function //
// //
/////////////////////////////////////////////////////////////

void AbsolutePageX(void)
{

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstEmployees = NULL;

 //Define Other Variables
 //Interface Pointer declared.(VC++ Extensions)
 IADORecordBinding *picRs = NULL;
 CEmployeeRs emprs; //C++ class object
 HRESULT hr = S_OK;
 _bstr_t strMessage;

 //Open a recordset using a Client Cursor
 //For the Employee Table

 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 // Open a recordset.
 TESTHR(hr = pRstEmployees.CreateInstance(__uuidof(Recordset)));

 // Use client cursor to enable Absoluteposition property.
 pRstEmployees->CursorLocation = adUseClient;

 // You have to explicitly pass the default Cursor type
 // and LockType to the Recordset here
 TESTHR(hr = pRstEmployees->Open("employee",
 strCnn,adOpenForwardOnly,adLockReadOnly,adCmdTable));

 //Open an IADORecordBinding interface pointer which we'll use for
 //Binding Recordset to a class
 TESTHR(hr = pRstEmployees->QueryInterface
 (__uuidof(IADORecordBinding), (LPVOID*)&picRs));

 //Bind the Recordset to a C++ Class here
 TESTHR(hr = picRs->BindToRecordset(&emprs));

 //Display Names and hire dates, five records at a time
 pRstEmployees->PageSize = 5;

 int intPageCount = pRstEmployees->PageCount;

 for(int intPage=1;intPage<=intPageCount;intPage++)
 {
 pRstEmployees->put_AbsolutePage((enum PositionEnum)intPage);
 strMessage = "";

 for(int intRecord=1;
 intRecord<=pRstEmployees->PageSize;intRecord++)
 {
 printf("\t%s %s %.10s\n",
 emprs.lau_fnameStatus == adFldOK ?
 emprs.m_szau_fname : "<NULL>",
 emprs.lau_lnameStatus == adFldOK ?
 emprs.m_szau_lname : "<NULL>",
 emprs.lau_hiredateStatus == adFldOK ?
 emprs.m_szau_hiredate : "<NULL>");

 pRstEmployees->MoveNext();

 if(pRstEmployees->EndOfFile)
 break;
 }

 printf("\n Press any key to continue...");getch();

 //Clear the Screen for the next Display
 system("cls");
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _variant_t vtConnect = pRstEmployees->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 printf("Error:\n");
 printf("Code = %08lx\n", e.Error());
 printf("Message = %s\n", e.ErrorMessage());
 printf("Source = %s\n", (LPCSTR) e.Source());
 printf("Description = %s\n", (LPCSTR) e.Description());
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }
 // Clean up objects before exit.
 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (pRstEmployees)
 if (pRstEmployees->State == adStateOpen)
 pRstEmployees->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 printf("Error:\n");
 for(long iError = 0; iError < nCount; iError++)
 {
 pErr = pConnection->Errors->GetItem(iError);
 printf("\t Error number: %x\t%s\n", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}
//EndAbsolutePageCpp

AbsolutePageX.h

Copy code Copy code

// BeginAbsolutePageH
#include "icrsint.h"

//This Class extracts only fname,lastname and hire_date

class CEmployeeRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CEmployeeRs)

 //Column fname is the 2nd field in the table
 ADO_VARIABLE_LENGTH_ENTRY2(2, adVarChar, m_szau_fname,
 sizeof(m_szau_fname), lau_fnameStatus, FALSE)

 ADO_VARIABLE_LENGTH_ENTRY2(4, adVarChar, m_szau_lname,
 sizeof(m_szau_lname), lau_lnameStatus, TRUE)

 ADO_VARIABLE_LENGTH_ENTRY2(8, adVarChar, m_szau_hiredate,
 sizeof(m_szau_hiredate), lau_hiredateStatus, TRUE)

END_ADO_BINDING()

public:
 CHAR m_szau_lname[41];
 ULONG lau_lnameStatus;
 CHAR m_szau_fname[41];
 ULONG lau_fnameStatus;
 CHAR m_szau_hiredate[40];
 ULONG lau_hiredateStatus;

};
// EndAbsolutePageH


ComboBox.LimitToList Property (Access)

 Copy code hover
[image]

ComboBox.LimitToList Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the LimitToList property to limit a combo box's values to the listed items. Read/write Boolean.

Syntax

expression .LimitToList

expression A variable that represents a ComboBox object.

Remarks

The LimitToList property uses the following settings.

Setting | Visual Basic | Description
Yes | True | If the user selects an item from the list in the combo box or enters text that matches a listed item, Microsoft Access accepts it. If the entered text doesn't match a listed item, the text isn't accepted and the user must then retype the entry, select a listed item, press ESC, or click Undo on the Edit menu.
No | False | (Default) Microsoft Access accepts any text that conforms to the ValidationRule property.

For table fields , you can set this property on the Lookup tab of the Field Properties section of table Design view for fields with the DisplayControl property set to Combo Box.

Note Note

Microsoft Access sets the LimitToList property automatically when you select Lookup Wizard as the data type for a field in table Design view.

When the LimitToList property of a bound combo box is set to No, you can enter a value in the combo box that isn't included in the list. Microsoft Access stores the new value in the form's underlying table or query (in the field specified in the combo box's ControlSource property), not the table or query set for the combo box by the RowSource property. To have newly entered values appear in the combo box, you must add the new value to the table or query set in the RowSource property by using a macro or Visual Basic event procedure that runs when the NotInList event occurs.

Setting both the LimitToList property and the AutoExpand property to Yes lets Microsoft Access find matching values from the list as the user enters characters in the text box portion of the combo box, and restricts the entries to only those values.

Note Note

If you set the combo box's BoundColumn property to any column other than the first visible column (or if you set BoundColumn to 0), the LimitToList property is automatically set to Yes.

When the LimitToList property is set to Yes and the user clicks the arrow next to the combo box, Microsoft Access selects matching values in the list as the user enters characters in the text box portion of the combo box, even if the AutoExpand property is set to No. If the user presses ENTER or moves to another control or record, the selected value appears in the combo box.

Combo boxes accept null values when the LimitToList property is set to Yes or True, whether or not the list contains null values. If you want to prevent users from entering a null value in a combo box, set the Required property of the field in the table to which the combo box is bound to Yes.

Link provided by: Community Member Icon Luke Chung, FMS, Inc. | About the Contributors

  • Tips and Techniques for Using and Validating Combo Boxes

Example

The following example limits a given combo box's values to its listed items.

VBA Copy code Copy code
Forms("Order Entry").Controls("States").LimitToList = True

About the Contributors

Luke Chung is the founder and president of FMS, Inc., a leading provider of custom database solutions and developer tools.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Network I/O error. (Error 3566)

 Copy code hover
[image]

Network I/O error. (Error 3566)
Send feedback

The communication between your computer and the network is experiencing a problem. Check to be sure your network is operating properly and that your network cable is tightly connected to your computer. Shut down, turn off, and reboot your computer.


Record(s) cannot be added; no corresponding record on the 'one' side. (Error 3363)

 Copy code hover
[image]

Record(s) cannot be added; no corresponding record on the 'one' side. (Error 3363)
Send feedback

This error occurs when you edit a stored query or view that contains more than one table. This error could occur if you tried to save a row from a view that was a join between a customer (single) and orders (many) table. If you entered information regarding the order only and did not enter information, such as the primary key value, for the customer table this error would be returned.


PrimaryKey and Unique Properties Example (VB)

 Copy code hover
[image]

PrimaryKey and Unique Properties Example (VB)
Send feedback

This example demonstrates the PrimaryKey and Unique properties of an Index. The code creates a new table with two columns. The PrimaryKey and Unique properties are used to make one column the primary key for which duplicate values are not allowed.

Copy code Copy code

' BeginPrimaryKeyVB
Sub Main()
 On Error GoTo PrimaryKeyXError

 Dim catNorthwind As New ADOX.Catalog
 Dim tblNew As New ADOX.Table
 Dim idxNew As New ADOX.Index
 Dim idxLoop As New ADOX.Index
 Dim colLoop As New ADOX.Column

 ' Connect the catalog
 catNorthwind.ActiveConnection = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\" & _
 "Microsoft Office\Office\Samples\Northwind.mdb';"

 ' Name new table
 tblNew.Name = "NewTable"

 ' Append a numeric and a text field to new table.
 tblNew.Columns.Append "NumField", adInteger, 20
 tblNew.Columns.Append "TextField", adVarWChar, 20

 ' Append new Primary Key index on NumField column
 ' to new table
 idxNew.Name = "NumIndex"
 idxNew.Columns.Append "NumField"
 idxNew.PrimaryKey = True
 idxNew.Unique = True
 tblNew.Indexes.Append idxNew

 ' Append an index on Textfield to new table.
 ' Note the different technique: Specifying index and
 ' column name as parameters of the Append method
 tblNew.Indexes.Append "TextIndex", "TextField"

 ' Append the new table
 catNorthwind.Tables.Append tblNew

 With tblNew
 Debug.Print tblNew.Indexes.Count & " Indexes in " & _
 tblNew.Name & " Table"

 ' Enumerate Indexes collection.
 For Each idxLoop In .Indexes
 With idxLoop
 Debug.Print "Index " & .Name
 Debug.Print " Primary key = " & .PrimaryKey
 Debug.Print " Unique = " & .Unique

 ' Enumerate Columns collection of each Index
 ' object.
 Debug.Print " Columns"
 For Each colLoop In .Columns
 Debug.Print " " & colLoop.Name
 Next colLoop
 End With
 Next idxLoop

 End With

 ' Delete new table as this is a demonstration.
 catNorthwind.Tables.Delete tblNew.Name

 'Clean up
 Set catNorthwind.ActiveConnection = Nothing
 Set catNorthwind = Nothing
 Set tblNew = Nothing
 Set idxNew = Nothing
 Set idxLoop = Nothing
 Set colLoop = Nothing
 Exit Sub

PrimaryKeyXError:

 Set catNorthwind = Nothing
 Set tblNew = Nothing
 Set idxNew = Nothing
 Set idxLoop = Nothing
 Set colLoop = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndPrimaryKeyVB


Synchronizer is already running. (Error 3544)

 Copy code hover
[image]

Synchronizer is already running. (Error 3544)
Send feedback

Only one instance of the Synchronizer can operate at a time. Use the currently operating Synchronizer instead of starting a second Synchronizer on this computer.


Label.Parent Property (Access)

 Copy code hover
[image]

Label.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a Label object.

Remarks

The Parent property of a label control is the control the label is linked to.

See also

Concepts

Label Object

Other resources

Label Object Members


CommandButton.BackThemeColorIndex Property (Access)

 Copy code hover
[image]

CommandButton.BackThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackThemeColorIndex

expression A variable that represents a CommandButton object.

Remarks

The BackThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BackThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Background Color to the Text 2 color by setting the BackThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BackThemeColorIndex=2

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


BoundObjectFrame.ObjectVerbs Property (Access)

 Copy code hover
[image]

BoundObjectFrame.ObjectVerbs Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ObjectVerbs property in Visual Basic to determine the list of verbs an OLE object supports. Read-only String.

Syntax

expression .ObjectVerbs(Index)

expression A variable that represents a BoundObjectFrame object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Long | An element in the array of supported verbs. This is a zero-based index, meaning zero (0) represents the first verb in the array, one (1) represents the second verb in the array, and so on.

Remarks

This property setting isn't available in Design view.

You can use the ObjectVerbs property with the ObjectVerbsCount property to display a list of the verbs supported by an OLE object. The ObjectVerbs property uses this list of verbs to determine which operation to perform when an OLE object is activated (when the Action property is set to acOLEActivate).

The Verb property setting is the position of a particular verb in the list of verbs returned by the ObjectVerbs property. For example, 1 specifies the first verb in the list (the Visual Basic command ObjectVerbs(0), or the first verb in the ObjectVerbs property array), 2 specifies the second verb in the list (the Visual Basic command ObjectVerbs(1), or the second verb in the ObjectVerbs property array), and so on.

The first verb in the ObjectVerbs property array, called by the Visual Basic command ObjectVerbs(0), is the default verb. If the Verb property hasn't been set, this verb specifies the operation performed when the OLE object is activated.

The list of verbs an object supports varies, depending on the state of the object. To update the list of verbs an object supports, set the control'sAction property to acOLEFetchVerbs. Be sure to update the list of verbs before presenting it to the user.

Example

The following example returns the verbs supported by the OLE object in the OLE1 control and displays each verb in a message box.

VBA Copy code Copy code
Sub GetVerbList(frm As Form, OLE1 As Control)
 Dim intX As Integer, intNumVerbs As Integer
 Dim strVerbList As String

 ' Update verb list.
 With frm!OLE1
 .Action = acOLEFetchVerbs
 intNumVerbs = .ObjectVerbsCount
 For intX = 0 To intNumVerbs - 1
 strVerbList = strVerbList & .ObjectVerbs(intX) & "; "
 Next intX
 End With

 ' Display verbs in message box.
 MsgBox Left(strVerbList, Len(strVerbList) - 2)
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Form.Hwnd Property (Access)

 Copy code hover
[image]

Form.Hwnd Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the hWnd property to determine the handle (a unique Long Integer value) assigned by Microsoft Windows to the current window. Read/write Long.

Syntax

expression .Hwnd

expression A variable that represents a Form object.

Remarks

You can use this property in Visual Basic when making calls to Windows application programming interface (API) functions or other external routines that require the hWnd property as an argument. Many Windows functions require the hWnd property value of the current window as one of the arguments.

Note Note

Because the value of this property can change while a program is running, don't store the hWnd property value in a public variable.

Example

The following example uses the hWnd property with the Windows API IsZoomed function to determine if a window is maximized.

VBA Copy code Copy code
' Enter on single line in Declarations section of Module window.
Declare Function IsZoomed Lib "user32" (ByVal hWnd As Long) As Long

Sub Form_Activate()
 Dim intWindowHandle As Long
 intWindowHandle = Screen.ActiveForm.hWnd
 If Not IsZoomed(intWindowHandle) Then
 DoCmd.Maximize
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Attachment.CurrentAttachment Property (Access)

 Copy code hover
[image]

Attachment.CurrentAttachment Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the index number of the file that has the focus in the Attachment control. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .CurrentAttachment

expression A variable that represents an Attachment object.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Out of memory during calculation. (Error 2446)

 Copy code hover
[image]

Out of memory during calculation. (Error 2446)
Send feedback

The application does not have enough memory to complete the calculation. Make sure you have enough RAM and an established swap file. You may need to terminate other programs, remove desktop wallpaper bitmaps, or remove unneeded device drivers to recover enough memory.


AllStoredProcedures Object (Access)

 Copy code hover
[image]

AllStoredProcedures Object (Access)
See also Send feedback

Published: July 16, 2012

The AllStoredProcedures collection contains an AccessObject for each stored procedure in the CurrentData or CodeData object.

Remarks

The CurrentData or CodeData object has an AllStoredProcedures collection containing AccessObject objects that describe instances of all stored procedures specified by CurrentData or CodeData. For example, you can enumerate the AllStoredProcedures collection in Visual Basic to set or return the values of properties of individual AccessObject objects in the collection.

You can refer to an individual AccessObject object in the AllStoredProcedures collection either by referring to the object by name, or by referring to its index within the collection. If you want to refer to a specific object in the AllStoredProcedures collection, it's better to refer to the stored procedures by name because a stored procedure's collection index may change.

The AllStoredProcedures collection is indexed beginning with zero. If you refer to a stored procedure by its index, the first stored procedure is AllStoredProcedures(0), the second stored procedure is AllStoredProcedures(1), and so on.

Note Note

  • The AllStoredProcedures collection only contains AccessObject objects within a Microsoft Access project (.adp). A Microsoft Access database does not contain any stored procedures, see the AllMacros collection.

  • To list all open stored procedures in the project, use the IsLoaded property of each AccessObject object in the AllStoredProcedures collection. You can then use the Name property of each individual AccessObject object to return the name of a stored procedure.

  • You can't add or delete an AccessObject object from the AllStoredProcedures collection.

Example

The following example prints the name of each open AccessObject object in the AllProcedures collection.

VBA Copy code Copy code
Sub AllStoredProcedures()
    Dim obj As AccessObject, dbs As Object
    Set dbs = Application.CurrentData
    ' Search for open AccessObject objects in
    ' AllStoredProcedures collection.
    For Each obj In dbs.AllStoredProcedures
        If obj.IsLoaded = True Then
            ' Print name of obj.
            Debug.Print obj.Name
        End If
    Next obj
End Sub

See also

Concepts

Access Object Model Reference

Other resources

AllStoredProcedures Object Members


CheckBox.OnMouseUp Property (Access)

 Copy code hover
[image]

CheckBox.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Syntax

expression .OnMouseUp

expression A variable that represents a CheckBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Image.BackShade Property (Access)

 Copy code hover
[image]

Image.BackShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackShade

expression A variable that represents an Image object.

Remarks

The BackShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the BackShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackShade=25

See also

Concepts

Image Object

Other resources

Image Object Members


How to: Sort Data in a DAO Recordset

 Copy code hover
[image]

How to: Sort Data in a DAO Recordset
Send feedback

Unless you open a table-type Recordset object and set its Index property, you cannot be sure that records will appear in any specific order. However, you usually want to retrieve records in a specific order. For example, you may want to view invoices arranged by increasing invoice number, or retrieve employee records in alphabetical order by their last names. To see records in a specific order, sort them.

To sort data in a Recordset object that is not a table, use an SQL ORDER BY clause in the query that constructs the Recordset. You can specify an SQL string when you create a QueryDef object, when you create a stored query in a database, or when you use the OpenRecordset method.

You can also filter data, which means you restrict the result set returned by a query to records that meet some criteria. With any type of OpenRecordset object, use an SQL WHERE clause in the original query to filter data.

The following code example opens a dynaset-type Recordset object, and uses an SQL statement to retrieve, filter, and sort records.

VBA Copy code Copy code
Dim dbsNorthwind As DAO.Database
Dim rstManagers As DAO.Recordset

Set dbsNorthwind = CurrentDb
Set rstManagers = dbsNorthwind.OpenRecordset("SELECT FirstName, " & _
                  "LastName FROM Employees WHERE Title = " & _
                  "'Sales Manager' ORDER BY LastName")

One limitation of running an SQL query in an OpenRecordset method is that it has to be recompiled every time you run it. If this query is used frequently, you can improve performance by first creating a stored query using the same SQL statement, and then opening a Recordset object against the query, as shown in the following code example.

VBA Copy code Copy code
Dim dbsNorthwind As DAO.Database
Dim rstSalesReps As DAO.Recordset
Dim qdfSalesReps As DAO.QueryDef

Set dbsNorthwind = CurrentDb

Set qdfSalesReps = dbsNorthwind.CreateQueryDef("SalesRepQuery")
qdfSalesReps.SQL = "SELECT * FROM Employees WHERE Title = " & _
                   "'Sales Representative'"

Set rstSalesReps = dbsNorthwind.OpenRecordset("SalesRepQuery")


OptionButton.BorderTint Property (Access)

 Copy code hover
[image]

OptionButton.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Syntax

expression .BorderTint

expression A variable that represents an OptionButton object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens BorderColor by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


TabControl.Enabled Property (Access)

 Copy code hover
[image]

TabControl.Enabled Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.

Syntax

expression .Enabled

expression A variable that represents a TabControl object.

Remarks

The Enabled property setting is a value that indicates whether the conditional format is enabled or disabled. True enables the conditional format. False disables the conditional format. The default is True.

When the Enabled property is True, the conditional format can be displayed in the Conditional Formatting dialog box.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


WebBrowserControl.AfterUpdate Event (Access)

 Copy code hover
[image]

WebBrowserControl.AfterUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The AfterUpdate event occurs after changed data in a control or record is updated.

Syntax

expression .AfterUpdate

expression A variable that represents a WebBrowserControl object.

Return Value

nothing

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's AfterUpdate event does occur.

To run a macro or event procedure when this event occurs, set the AfterUpdate property to the name of the macro or to [Event Procedure].

The AfterUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

AfterUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. AfterUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For bound controls, the OldValue property isn't set to the updated value until after the AfterUpdate event for the form occurs. Even if the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Line.BorderTint Property (Access)

 Copy code hover
[image]

Line.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderTint

expression A variable that represents a Line object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

Line Object

Other resources

Line Object Members


ToggleButton.Application Property (Access)

 Copy code hover
[image]

ToggleButton.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a ToggleButton object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Tables Collection (ADOX) Reference

 Copy code hover
[image]

Tables Collection (ADOX) Reference
Send feedback

In this section

  • Tables Collection (ADOX)

  • Tables Collection Properties, Methods, and Events (ADOX)


Forms.Count Property (Access)

 Copy code hover
[image]

Forms.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents a Forms object.

Example

For example, if you want to determine the number of forms currently open or existing on the database, you would use the following code strings

VBA Copy code Copy code
' Determine the number of open forms.

forms.count

' Determine the number of forms (open or closed)
' in the current database.

currentproject.allforms.count

The following example uses the Count property to control a loop that prints information about all open forms and their controls.

VBA Copy code Copy code
Sub Print_Form_Controls()
 Dim frm As Form, intI As Integer
 Dim intJ As Integer
 Dim intControls As Integer, intForms As Integer
 intForms = Forms.Count ' Number of open forms.
 If intForms > 0 Then
 For intI = 0 To intForms - 1
 Set frm = Forms(intI)
 Debug.Print frm.Name
 intControls = frm.Count
 If intControls > 0 Then
 For intJ = 0 To intControls - 1
 Debug.Print vbTab; frm(intJ).Name
 Next intJ
 Else
 Debug.Print vbTab; "(no controls)"
 End If
 Next intI
 Else
 MsgBox "No open forms.", vbExclamation, "Form Controls"
 End If
End Sub

See also

Concepts

Forms Collection

Other resources

Forms Object Members


Rectangle Properties (Access)

 Copy code hover
[image]

Rectangle Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the rectangle is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified rectangle is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


You cannot set the KeepLocal property for an object that is already replicated. (Error 3457)

 Copy code hover
[image]

You cannot set the KeepLocal property for an object that is already replicated. (Error 3457)
Send feedback

The KeepLocal property cannot be set on a replicated object. Setting a local object's KeepLocal property after the database has been replicated has no effect on the object. If you want to keep an object from being replicated to the other replicas in the set, set the object's Replicable property to "F".


Rectangle.BackShade Property (Access)

 Copy code hover
[image]

Rectangle.BackShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackShade

expression A variable that represents a Rectangle object.

Remarks

The BackShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the BackShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens BackColor by 75%.

VBA Copy code Copy code
Me.ctl.BackShade=25

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


Attachment.TabStop Property (Access)

 Copy code hover
[image]

Attachment.TabStop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control in Form view. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .TabStop

expression A variable that represents an Attachment object.

Remarks

The TabStop property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) You can move the focus to the control by pressing the TAB key.
No | False | You cannot move the focus to the control by pressing the TAB key.

When you create a control on a form, Microsoft Access automatically assigns the control a position in the form's tab order. Each new control is placed last in the tab order. If you want to prevent a control from being available when you tab through the controls in a form, set the control's TabStop property to No.

In Form view, hidden or disabled controls remain in the tab order but are skipped when you move through the controls by pressing TAB, even if their TabStop properties are set to Yes.

As long as a control's Enabled property is set to Yes, you can click the control or use an access key to select it, regardless of its TabStop property setting. For example, you can set the TabStop property of a command button to No to prevent users from selecting the button by pressing TAB. However, they can still click the command button to select it.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


BoundObjectFrame.UpdateOptions Property (Access)

 Copy code hover
[image]

BoundObjectFrame.UpdateOptions Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the UpdateOptions property to specify how a linkedOLE object is updated. Read/write Integer.

Syntax

expression .UpdateOptions

expression A variable that represents a BoundObjectFrame object.

Remarks

The UpdateOptions property uses the following settings.

Setting | Visual Basic | Description
Automatic | acOLEUpdateAutomatic | (Default) Updates the object each time the linked data changes.
Manual | acOLEUpdateManual | Updates the object only when the control's Action property is set to acOLEUpdate or the link is updated with the OLE/DDE Links command on the Edit menu.

Normally, the object is updated automatically whenever the linked data changes, but you can tell Microsoft Access to update the data only when it receives a specific instruction to do so. For example, if other users or applications can access or change linked spreadsheet data on a form, you can use this property to specify that the linked data only be updated when the database is opened in single-user mode.

When the UpdateOptions property is set to Manual, updates don't occur based on the setting of the Refresh interval box on the Advanced tab of the Options dialog box, available by clicking Options on the Tools menu.

Note Note

When an object's data is changed, the Updated event occurs.

Example

The following example sets the UpdateOptions property for an unbound object frame named OLE1 to update manually, and then uses the Action property to force an update of the OLE object in the control.

VBA Copy code Copy code
OLE1.UpdateOptions = acOLEUpdateManual
OLE1.Action = acOLEUpdate

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


USER (Microsoft Access SQL reserved word)

 Copy code hover
[image]

USER (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The USER keyword is used in these contexts:

CREATE USER or GROUP Statement

ADD USER Statement

DROP USER or GROUP Statement

ALTER USER or DATABASE Statement


Failure writing to the Synchronizer log. (Error 3507)

 Copy code hover
[image]

Failure writing to the Synchronizer log. (Error 3507)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


DoCmd.ApplyFilter Method (Access)

 Copy code hover
[image]

DoCmd.ApplyFilter Method (Access)
See also Send feedback

Published: July 16, 2012

The ApplyFilter method carries out the ApplyFilter action in Visual Basic.

Syntax

expression .ApplyFilter(FilterName, WhereCondition, ControlName)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
FilterName | Optional | Variant | A string expression that is the valid name of a filter or query in the current database. When using this method to apply a server filter, the FilterName argument must be blank.
WhereCondition | Optional | Variant | A string expression that is a valid SQL WHERE clause without the word WHERE.
ControlName | Optional | Variant |

Remarks

You can use the ApplyFilter action to apply a filter, a query, or an SQL WHERE clause to a table, form, or report to restrict or sort the records in the table, or the records from the underlying table or query of the form or report. For reports, you can use this action only in a macro specified by the report's OnOpen event property.

You can use this action to apply an SQL WHERE clause only when applying a server filter. A server filter cannot be applied to a stored procedure's record source.

Note Note

You can use the Filter Name argument if you've already defined a filter that provides the appropriate data. You can use the Where Condition argument to enter the restriction criteria directly. If you use both arguments, Microsoft Access applies the WHERE clause to the results of the filter. You must use one or both arguments.

You can apply a filter or query to a form in Form view or Datasheet view.

The filter and WHERE condition you apply become the setting of the form's Filter property or the report's ServerFilter property.

When you save a table or form, Access saves any filter currently defined in that object, but will not apply the filter automatically the next time the object is opened (although it will automatically apply any sort you applied to the object before it was saved). If you want to apply a filter automatically when a form is first opened, specify a macro containing the ApplyFilter action or an event procedure containing the ApplyFilter method of the DoCmd object as the OnOpen event property setting of the form. You can also apply a filter by using the OpenForm or OpenReport action, or their corresponding methods. To apply a filter automatically when a table is first opened, you can open the table by using a macro containing the OpenTable action, followed immediately by the ApplyFilter action.

You must include at least one of the two ApplyFilter method arguments. If you enter a value for both arguments, the WhereCondition argument is applied to the filter.

The maximum length of the WhereCondition argument is 32,768 characters (unlike the Where Condition action argument in the Macro window, whose maximum length is 256 characters).

Example

The following example uses the ApplyFilter method to display only records that contain the name "King" in the LastName field:

VBA Copy code Copy code
DoCmd.ApplyFilter , "LastName = 'King'"

The following example shows how to use the ApplyFilter property to filter the records displayed when a toggle button named tglFilter is clicked.

Sample code provided by: MVP Contributor Bill Jelen, MrExcel.com | About the Contributors

Copy code Copy code
Private Sub tglFilter_Click()
    With tglFilter
        If .Value = True Then
            .Caption = "P/T"
            .StatusBarText = "only full-timers"
            DoCmd.ApplyFilter , "[Hours]=40"
        ElseIf .Value = False Then
            .Caption = "All"
            .StatusBarText = "only part-timers"
            DoCmd.ApplyFilter , "[Hours]<40"
        Else
            .Caption = "F/T"
            .StatusBarText = "all employees"
            DoCmd.ShowAllRecords
            .SetFocus 'to activate the button's statusbar-text
        End If
    End With
End Sub

About the Contributors

Holy Macro! Books publishes entertaining books for people who use Microsoft Office. See the complete catalog at MrExcel.com.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


ListBox.LayoutID Property (Access)

 Copy code hover
[image]

ListBox.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified list box. Read-only Long.

Version Information

Version Added: Access 2007

Syntax

expression .LayoutID

expression A variable that represents a ListBox object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


CustomControl.Name Property (Access)

 Copy code hover
[image]

CustomControl.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a CustomControl object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Min Function (Access 2013 custom web app)

 Copy code hover
[image]

Min Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the minimum value in the expression in a query or table.

Syntax

Min(Expression)

The Min function contains the following argument.

Argument name | Description
Expression | A string expression identifying the field that contains the data you want to evaluate or an expression that performs a calculation using the data in that field. Operands in Expression can include the name of a table field, a constant, or a function (which can be either intrinsic or user-defined but not one of the other SQL aggregate functions).


GetPermissions and SetPermissions Methods Example (VB)

 Copy code hover
[image]

GetPermissions and SetPermissions Methods Example (VB)
Send feedback

This example demonstrates the GetPermissions and SetPermissions methods. The following code gives full access for the Orders table to the Admin user.

Copy code Copy code

' BeginGrantPermissionsVB
Sub GrantPermissions()
 On Error GoTo GrantPermissionsError

 Dim cnn As New ADODB.Connection
 Dim cat As New ADOX.Catalog
 Dim lngPerm As Long

 ' Opens a connection to the northwind database
 ' using the Microsoft Jet 4.0 provider
 cnn.Provider = "Microsoft.Jet.OLEDB.4.0"
 cnn.Open "Data Source='c:\Program Files\" & _
 "Microsoft Office\Office\Samples\Northwind.mdb';" & _
 "jet oledb:system database=" & _
 "'c:\Program Files\Microsoft Office\Office\system.mdw'"

 Set cat.ActiveConnection = cnn

 ' Retrieve original permissions
 lngPerm = cat.Users("admin").GetPermissions("Orders", adPermObjTable)
 Debug.Print "Original permissions: " & Str(lngPerm)

 ' Revoke all permissions
 cat.Users("admin").SetPermissions "Orders", adPermObjTable, _
 adAccessRevoke, adRightFull

 ' Display permissions
 Debug.Print "Revoked permissions: " & _
 Str(cat.Users("admin").GetPermissions("Orders", adPermObjTable))

 ' Give the Admin user full rights on the orders object
 cat.Users("admin").SetPermissions "Orders", adPermObjTable, _
 adAccessSet, adRightFull

 ' Display permissions
 Debug.Print "Full permissions: " & _
 Str(cat.Users("admin").GetPermissions("Orders", adPermObjTable))

 ' Restore original permissions
 cat.Users("admin").SetPermissions "Orders", adPermObjTable, _
 adAccessSet, lngPerm

 ' Display permissions
 Debug.Print "Final permissions: " & _
 Str(cat.Users("admin").GetPermissions("Orders", adPermObjTable))

 'Clean up
 cnn.Close
 Set cat = Nothing
 Set cnn = Nothing
 Exit Sub

GrantPermissionsError:

 Set cat = Nothing

 If Not cnn Is Nothing Then
 If cnn.State = adStateOpen Then cnn.Close
 End If
 Set cnn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If

End Sub
' EndGrantPermissionsVB


The replica name or ID does not match a currently managed member of the replica set. (Error 3520)

 Copy code hover
[image]

The replica name or ID does not match a currently managed member of the replica set. (Error 3520)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


Form.GoToPage Method (Access)

 Copy code hover
[image]

Form.GoToPage Method (Access)
See also Send feedback

Published: July 16, 2012

The GoToPage method moves the focus to the first control on a specified page in the active form.

Syntax

expression .GoToPage(PageNumber, Right, Down)

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
PageNumber | Required | Long | A numeric expression that's a valid page number for the active form.
Right | Optional | Long | A numeric expression that's a valid horizontal offset (in twips) from the left side of the window to the part of the page to be viewed.
Down | Optional | Long | A numeric expression that's a valid vertical offset (in twips) from the top of the window to the part of the page to be viewed.

Remarks

When you use this method to move to a specified page of a form, the focus is set to the first control on the page, as defined by the form's tab order. To move to a particular control on the form, use the SetFocus method.

You can use the GoToPage method if you've created page breaks on a form to group related information. For example, you might have an Employees form with personal information on the first page, office information on the second page, and sales information on the third page. You can use the GoToPage method to move to the desired page.

You can use the right and down arguments for forms with pages larger than the Microsoft Access window. Use the pagenumber argument to move to the desired page, and then use the right and down arguments to display the part of the page you want to see. Microsoft Access displays the part of the page that's offset from the upper-left corner of the window by the distance specified in the right and down arguments.

Example

The following example uses the GoToPage method to move the focus to the second page of the Customer form at the position specified by the right and down arguments:

VBA Copy code Copy code
Forms!Customer.GoToPage 2, 1440, 600

See also

Concepts

Form Object

Other resources

Form Object Members


Member Object (ADO MD Reference)

 Copy code hover
[image]

Member Object (ADO MD Reference)
Send feedback

In this section

  • Member Object (ADO MD)

  • Member Properties, Methods, and Events (ADO MD)


This Recordset is not updatable. (Error 3326)

 Copy code hover
[image]

This Recordset is not updatable. (Error 3326)
Send feedback

You attempted to edit data in a field that is bound to a snapshot-type result set object. Snapshot fields in a Microsoft Access database engine database cannot be edited.


ComboBox.ColumnWidth Property (Access)

 Copy code hover
[image]

ComboBox.ColumnWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.

Syntax

expression .ColumnWidth

expression A variable that represents a ComboBox object.

Remarks

In Visual Basic , the ColumnWidth property setting is an Integer value that represents the column width in twips. You can specify a width or use one of the following predefined settings.

Setting | Description
0 | Hides the column.
-1 | (Default) Sizes the column to the default width.
Note Note

The ColumnWidth property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

Setting this property to 0, or resizing the field to a zero width in Datasheet view, sets the field's ColumnHidden property to True (-1) and hides the field in Datasheet view.

Setting a field's ColumnHidden property to False (0) restores the field's ColumnWidth property to the value it had before the field was hidden. For example, if the ColumnWidth property was -1 prior to the field being hidden by setting the property to 0, changing the field's ColumnHidden property to False resets the ColumnWidth to -1.

The ColumnWidth property for a field isn't available when the field's ColumnHidden property is set to True.

Example

This example takes effect in Datasheet view of the open Customers form. It sets the row height to 450 twips and sizes the column to fit the size of the visible text.

VBA Copy code Copy code
Forms![Customers].RowHeight = 450
Forms![Customers]![Address].ColumnWidth = -2

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


BoundObjectFrame.Class Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Class Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Class property to specify or determine the class name of an embeddedOLE object. Read/write String.

Syntax

expression .Class

expression A variable that represents a BoundObjectFrame object.

Remarks

The Class property setting is a string expression supplied by you or Microsoft Access when you create or paste an OLE object.

A class name defines the type of OLE object. For example, Microsoft Excel supports several types of OLE objects, including worksheets and charts. Their class names are "Excel.Sheet" and "Excel.Chart" respectively.

Note Note

To determine the class name of an OLE object, see the documentation for the application supplying the object.

The Class property setting is updated when you copy an object from the Clipboard. For example, if you paste a Microsoft Excel chart from the Clipboard into an OLE object that previously contained a Microsoft Excel worksheet, the Class property setting changes from "Excel.Sheet" to "Excel.Chart". You can paste an object from the Clipboard by using Visual Basic to set the control's Action property to acOLEPaste or acOLEPasteSpecialDlg.

Note Note

The OLEClass property and the Class property are similar but not identical. The OLEClass property setting is a general description of the OLE object whereas the Class property setting is the name used to refer to the OLE object in Visual Basic. Examples of OLEClass property settings are Microsoft Excel Chart, Microsoft Word Document, and Paintbrush Picture.

Example

The following example creates a linked OLE object using an unbound object frame named OLE1 and sizes the control to display the object's entire contents when the user clicks a command button.

VBA Copy code Copy code
Sub Command1_Click
 OLE1.Class = "Excel.Sheet" ' Set class name.
 ' Specify type of object.
 OLE1.OLETypeAllowed = acOLELinked
 ' Specify source file.
 OLE1.SourceDoc = "C:\Excel\Oletext.xls"
 ' Specify data to create link to.
 OLE1.SourceItem = "R1C1:R5C5"
 ' Create linked object.
 OLE1.Action = acOLECreateLink
 ' Adjust control size.
 OLE1.SizeMode = acOLESizeZoom
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Application.GUIDFromString Method (Access)

 Copy code hover
[image]

Application.GUIDFromString Method (Access)
See also Send feedback

Published: July 16, 2012

The GUIDFromString function converts a string to a GUID, which is an array of type Byte.

Syntax

expression .GUIDFromString(String)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
String | Required | Variant | A string expression which evaluates to a GUID in string form.

Return Value

Variant

Remarks

The Microsoft Access database engine stores GUIDs as arrays of type Byte. However, Microsoft Access can't return Byte data from a control on a form or report. In order to return the value of a GUID from a control, you must convert it to a string. To convert a GUID to a string, use the StringFromGUID function. To convert a string to a GUID, use the GUIDFromString function.

Example

The following example uses the GUIDFromString function to convert a string to a GUID. The string is a GUID stored in string form in a replicated Employees table. The field, s_GUID, is a hidden field added to every replicated table in a replicated database.

VBA Copy code Copy code
Sub CheckGUIDType()

 Dim dbsConn As ADODB.Connection
 Dim rstEmployees As ADODB.Recordset

 ' Make a connection to the current database.
 Set dbsConn = Application.CurrentProject.Connection
 Set rstEmployees = New ADODB.Recordset
 rstEmployees.Open "Employees", dbsConn, , , adCmdTable

 ' Print the GUID to the immediate window.
 Debug.Print rst!s_GUID
 Debug.Print TypeName(rst!s_GUID)
 Debug.Print TypeName(GuidFromString(rst!s_GUID))

 Set rstEmployees = Nothing
 Set dbsConn = Nothing

End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


CheckBox.KeyPress Event (Access)

 Copy code hover
[image]

CheckBox.KeyPress Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyPress(KeyAscii)

expression A variable that represents a CheckBox object.

Parameters

Name | Required/Optional | Data Type | Description
KeyAscii | Required | Integer | Returns a numeric ANSI key code. The KeyAscii argument is passed by reference; changing it sends a different character to the object. Setting the KeyAscii argument to 0 cancels the keystroke so that the object doesn't recognize that a key was pressed.

Remarks

To run a macro or event procedure when this event occurs, set the OnKeyPress property to the name of the macro or to [Event Procedure].

The object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down an ANSI key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

A KeyPress event can involve any printable keyboard character, the CTRL key combined with a character from the standard alphabet or a special character, and the ENTER or BACKSPACE key. You can use the KeyDown and KeyUp event procedures to handle any keystroke not recognized by the KeyPress event, such as function keys, navigation keys, and any combinations of these with keyboard modifiers (ALT, SHIFT, or CTRL keys). Unlike the KeyDown and KeyUp events, the KeyPress event doesn't indicate the physical state of the keyboard; instead, it indicates the ANSI character that corresponds to the pressed key or key combinations.

KeyPress interprets the uppercase and lowercase of each character as separate key codes and, therefore, as two separate characters.

Note Note

The BACKSPACE key is part of the ANSI character set, but the DEL key isn't. If you delete a character in a control by using the BACKSPACE key, you cause a KeyPress event; if you use the DEL key, you don't.

The KeyDown and KeyPress events occur when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

For example, if you go to a new record and type a character in the first control in the record, the following events occur:

Current (for the new record)

ß

Enter (for the first control in the new record)

ß

GotFocus (for the control)

ß

KeyDown (for the control)

ß

KeyPress (for the control)

ß

BeforeInsert (for the new record in the form)

ß

Change (for the control if it's a text box or combo box)

ß

KeyUp (for the control)

Example

The following example converts text entered in a text box to uppercase as the text is typed in, one character at a time.

To try the example, add the following event procedure to a form that contains a text box named ShipRegion.

VBA Copy code Copy code
Private Sub ShipRegion_KeyPress(KeyAscii As Integer)
 Dim strCharacter As String

 ' Convert ANSI value to character string.
 strCharacter = Chr(KeyAscii)
 ' Convert character to upper case, then to ANSI value.
 KeyAscii = Asc(UCase(strCharacter))
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


The server's MSysConf table exists, but is in an incorrect format. Contact your system administrator. (Error 3407)

 Copy code hover
[image]

The server's MSysConf table exists, but is in an incorrect format. Contact your system administrator. (Error 3407)
Send feedback

The MSysConf table created on the server to help control communications between the Microsoft Access database engine and the linked ODBC data source requires a very specific format.


Report.PSet Method (Access)

 Copy code hover
[image]

Report.PSet Method (Access)
See also Send feedback

Published: July 16, 2012

The PSet method sets a point on a Report object to a specified color when the Print event occurs.

Syntax

expression .PSet(flags, X, Y, color)

expression A variable that represents a Report object.

Parameters

Name | Required/Optional | Data Type | Description
flags | Required | Integer | A keyword that indicates the coordinates are relative to the current graphics position given by the settings for the CurrentX and CurrentY properties of the object argument.
X | Required | Single | The horizontal coordinate of the point to set.
Y | Required | Single | The vertical coordinate of the point to set.
color | Required | Long | the RGB (red-green-blue) color to set the point to. If this argument is omitted, the value of the ForeColor property is used. You can also use the RGB function or QBColor function to specify the color.

Return Value

Nothing

Remarks

The size of the point depends on the DrawWidth property setting. When the DrawWidth property is set to 1, the PSet method sets a single pixel to the specified color. When the DrawWidth property is greater than 1, the point is centered on the specified coordinates.

The way the point is drawn depends on the settings of the DrawMode and DrawStyle properties.

When you apply the PSet method, the CurrentX and CurrentY properties are set to the point specified by the x and y arguments.

To clear a single pixel with the PSet method, specify the coordinates of the pixel and use &HFFFFFF (white) as the color argument.

Example

The following example uses the PSet method to draw a line through the horizontal axis of a report.

To try this example in Microsoft Access, create a new report. Set the OnPrint property of the Detail section to [Event Procedure]. Enter the following code in the report's module, then switch to Print Preview.

VBA Copy code Copy code
Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 Dim sngMidPt As Single, intI As Integer
 ' Set scale to pixels.
 Me.ScaleMode = 3
 ' Calculate midpoint.
 sngMidPt = Me.ScaleHeight / 2
 ' Loop to draw line down horizontal axis pixel by pixel.
 For intI = 1 To Me.ScaleWidth
 Me.PSet(intI, sngMidPt)
 Next intI
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


Source Property (ADO MD)

 Copy code hover
[image]

Source Property (ADO MD)
Send feedback

Indicates the source for the data in the cellset.

Settings and Return Values

Sets or returns a Variant, and is read/write for closed Cellset objects and read-only for open Cellset objects. The Variant should contain a valid String, for example, an MDX query.


Rectangle.Click Event (Access)

 Copy code hover
[image]

Rectangle.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Syntax

expression .Click

expression A variable that represents a Rectangle object.

Remarks

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


OptionButton.ColumnHidden Property (Access)

 Copy code hover
[image]

OptionButton.ColumnHidden Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.

Syntax

expression .ColumnHidden

expression A variable that represents an OptionButton object.

Remarks

For example, you might want to hide a CustomerAddress field that's too wide so you can view the CustomerName and PhoneNumber fields.

Note Note

The ColumnHidden property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

Hiding a column with the ColumnHidden property in Datasheet view doesn't hide fields from the same column in Form view. Similarly, setting a control's Visible property to False in Form view doesn't hide the corresponding column in Datasheet view.

Note Note

To set or change this property for a table or query by using Visual Basic, you must use a column's Properties collection. For details on using the Properties collection, see Properties .

You can display a field in a query even though the column for the field is hidden in table Datasheet view. You can use values from a hidden column as the criteria for a filter even though the column remains hidden after the filter is applied.

Setting a field's ColumnWidth property to 0, or resizing the field to a zero width in Datasheet view, causes Microsoft Access to set the corresponding ColumnHidden property to True. Unhiding a column restores the ColumnWidthColumnWidth property to the value it had before the field was hidden.

Note Note

The ColumnHidden property is not available in Design view.

Example

The following example hides the ProductID field in Datasheet view of the Products form.

VBA Copy code Copy code
Forms!Products!ProductID.ColumnHidden = -1

The next example also hides the ProductID field in Datasheet view of the Products table.

VBA Copy code Copy code
Public Sub SetColumnHidden()

 Dim dbs As DAO.Database
 Dim fld As DAO.Field
 Dim prp As DAO.Property
 Const conErrPropertyNotFound = 3270

 ' Turn off error trapping.
 On Error Resume Next

 Set dbs = CurrentDb

 ' Set field property.
 Set fld = dbs.TableDefs!Products.Fields!ProductID
 fld.Properties("ColumnHidden") = True

 ' Error may have occurred when value was set.
 If Err.Number <> 0 Then
 If Err.Number <> conErrPropertyNotFound Then
 On Error GoTo 0
 MsgBox "Couldn't set property 'ColumnHidden' " & _
 "on field '" & fld.Name & "'", vbCritical
 Else
 On Error GoTo 0
 Set prp = fld.CreateProperty("ColumnHidden", dbLong, True)
 fld.Properties.Append prp
 End If
 End If

 Set prp = Nothing
 Set fld = Nothing
 Set dbs = Nothing

End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


ToggleButton.AddColon Property (Access)

 Copy code hover
[image]

ToggleButton.AddColon Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.

Syntax

expression .AddColon

expression A variable that represents a ToggleButton object.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Recordset2 Object (DAO)

 Copy code hover
[image]

Recordset2 Object (DAO)
Send feedback

A Recordset2 object represents the records in a base table or the records that result from running a query.

Remarks

A Recordset2 object is contains all of the same properties and methods as the Recordset object. The Recordset2 object contains a new property, ParentRecordset, that support multi-valued field types.

Example

The following example shows how to navigate a Recordset that contains a multi-value field.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Sub PrintStudentsAndClasses()
    Dim dbs As DAO.Database
    Dim rsStudents As DAO.Recordset2  'Recordset for students
    Dim rsClasses As DAO.Recordset2  'Recordset for classes
    Dim fld As DAO.Field2

    'open the database
    Set dbs = CurrentDb()

    'get the table of students
    Set rsStudents = dbs.OpenRecordset("tblStudents")

    'loop through the students
    Do While Not rsStudents.EOF

        'get the classes field
        Set fld = rsStudents("Classes")

        'get the classes Recordset
        'make sure the field is a multi-valued field before
        'getting a Recordset object
        If fld.IsComplex Then
            Set rsClasses = fld.Value
        End If

        'access all records in the Recordset
        If Not (rsClasses.BOF And rsClasses.EOF) Then
            rsClasses.MoveLast
            rsClasses.MoveFirst
        End If

        'print the student and number of classes
        Debug.Print rsStudents("FirstName") & " " & rsStudents("LastName"), _
            "Number of classes: " & rsClasses.RecordCount

        'print the classes for this student
        Do While Not rsClasses.EOF
            Debug.Print , rsClasses("Value")
            rsClasses.MoveNext
        Loop

        'close the Classes Recordset
        rsClasses.Close

        'get the next student
        rsStudents.MoveNext

    Loop

    'cleanup
    rsStudents.Close

    Set fld = Nothing
    Set rsStudents = Nothing
    Set dbs = Nothing

End Sub

The following example shows how to navigate the files in an attachment field. The file type and filename of each attachment is printed in the Immediate window.

VBA Copy code Copy code
Sub ListAttachments()
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset2
    Dim rsA As DAO.Recordset2
    Dim fld As DAO.Field2

    'Get the database, recordset, and attachment field
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("tblAttachments")
    Set fld = rst("Attachments")

    'Navigate through the table
    Do While Not rst.EOF

        'Print the first and last name
        Debug.Print rst("FirstName") & " " & rst("LastName")

        'Get the recordset for the Attachments field
        Set rsA = fld.Value

        'Print all attachments in the field
        Do While Not rsA.EOF
            Debug.Print , rsA("FileType"), rsA("FileName")

            'Next attachment
            rsA.MoveNext
        Loop

        rsA.Close

        'Next record
        rst.MoveNext
    Loop

    rst.Close
    dbs.Close

    Set fld = Nothing
    Set rsA = Nothing
    Set rst = Nothing
    Set dbs = Nothing
End Sub

The following example shows how to add files from a specified folder path to an attachment field.

VBA Copy code Copy code
Public Function LoadAttachments(strPath As String, Optional strPattern As String = "*.*") As Long
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset2
    Dim rsA As DAO.Recordset2
    Dim fld  As DAO.Field2
    Dim strFile As String

    'Get the database, recordset, and attachment field
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("tblAttachments")
    Set fld = rst("Attachments")

    'Navigate through the table
    Do While Not rst.EOF

        'Get the recordset for the Attachments field
        Set rsA = fld.Value

        'Load all attachments in the specified directory
        strFile = Dir(strPath & "\*.*")

        rst.Edit
        Do While Len(strFile) > 0
            'Add a new attachment that matches the pattern.
            'Pass "" to match all files.
            If strFile Like strPattern Then
                rsA.AddNew
                rsA("FileData").LoadFromFile strPath & "\" & strFile
                rsA.Update

                'Increment the number of files added
                LoadAttachments = LoadAttachments + 1
            End If
            strFile = Dir
        Loop
        rsA.Close

        rst.Update
        'Next record
        rst.MoveNext
    Loop

    rst.Close
    dbs.Close

    Set fld = Nothing
    Set rsA = Nothing
    Set rst = Nothing
    Set dbs = Nothing
End Function

The following example shows how to save the files stored in an attachment field to the specified folder path.

VBA Copy code Copy code
Public Function SaveAttachments(strPath As String, Optional strPattern As String = "*.*") As Long
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset2
    Dim rsA As DAO.Recordset2
    Dim fld As DAO.Field2
    Dim strFullPath As String

    'Get the database, recordset, and attachment field
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("tblAttachments")
    Set fld = rst("Attachments")

    'Navigate through the table
    Do While Not rst.EOF

        'Get the recordset for the Attachments field
        Set rsA = fld.Value

        'Save all attachments in the field
        Do While Not rsA.EOF
            If rsA("FileName") Like strPattern Then
                strFullPath = strPath & "\" & rsA("FileName")

                'Make sure the file does not exist and save
                If Dir(strFullPath) = "" Then
                    rsA("FileData").SaveToFile strFullPath
                End If

                'Increment the number of files saved
                SaveAttachments = SaveAttachments + 1
            End If

            'Next attachment
            rsA.MoveNext
        Loop
        rsA.Close

        'Next record
        rst.MoveNext
    Loop

    rst.Close
    dbs.Close

    Set fld = Nothing
    Set rsA = Nothing
    Set rst = Nothing
    Set dbs = Nothing
End Function

The following example shows how to delete a file stored in an attachment field.

VBA Copy code Copy code
Function RemoveAttachment(strRemoveFile As String, Optional strFilter As String) As Long
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset2
    Dim rsA As DAO.Recordset2
    Dim fld As DAO.Field2

    'Get the database
    Set dbs = CurrentDb

    'Open the recordset. If the strFilter is supplied, add it to the WHERE
    'clause for the recordset. Otherwise, any files matching strFileName
    'will be deleted
    If Len(strFilter) > 0 Then
        Set rst = dbs.OpenRecordset("SELECT * FROM tblAttachments WHERE " & strFilter)
    Else
        Set rst = dbs.OpenRecordset("tblAttachments")
    End If

    'Get the Attachment field
    Set fld = rst("Attachments")

    'Navigate through the recordset
    Do While Not rst.EOF

        'Get the recordset for the Attachments field
        Set rsA = fld.Value

        'Walk the attachments and look for the file name to remove
        Do While Not rsA.EOF
            If rsA("FileName") Like strRemoveFile Then
                rsA.Delete

                'Increment the number of files removed
                RemoveAttachment = RemoveAttachment + 1
            End If
            rsA.MoveNext
        Loop

        'Cleanup the Attachments recordset
        rsA.Close
        Set rsA = Nothing

        'Next record
        rst.MoveNext
    Loop

    rst.Close
    dbs.Close
    Set fld = Nothing
    Set rst = Nothing
    Set dbs = Nothing
End Function

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


LockTypeEnum

 Copy code hover
[image]

LockTypeEnum
Send feedback

Specifies the type of lock placed on records during editing.

Constant | Value | Description
adLockBatchOptimistic | 4 | Indicates optimistic batch updates. Required for batch update mode.
adLockOptimistic | 3 | Indicates optimistic locking, record by record. The provider uses optimistic locking, locking records only when you call the Update method.
adLockPessimistic | 2 | Indicates pessimistic locking, record by record. The provider does what is necessary to ensure successful editing of the records, usually by locking records at the data source immediately after editing.
adLockReadOnly | 1 | Indicates read-only records. You cannot alter the data.
adLockUnspecified | -1 | Does not specify a type of lock. For clones, the clone is created with the same lock type as the original.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.LockType.BATCHOPTIMISTIC

AdoEnums.LockType.OPTIMISTIC

AdoEnums.LockType.PESSIMISTIC

AdoEnums.LockType.READONLY

AdoEnums.LockType.UNSPECIFIED


Application.DAvg Method (Access)

 Copy code hover
[image]

Application.DAvg Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the DAvg function to calculate the average of a set of values in a specified set of records (a domain).

Syntax

expression .DAvg(Expr, Domain, Criteria)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Expr | Required | String | An expression that identifies the field containing the numeric data you want to average. It can be a string expression identifying a field in a table or query, or it can be an expression that performs a calculation on data in that field. In expr, you can include the name of a field in a table, a control on a form, a constant, or a function. If expr includes a function, it can be either built-in or user-defined, but not another domain aggregate or SQL aggregate function.
Domain | Required | String | A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter.
Criteria | Optional | Variant | An optional string expression used to restrict the range of data on which the DAvg function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the DAvg function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain; otherwise the DAvg function returns a Null.

Return Value

Variant

Remarks

For example, you could use the DAvg function in the criteria row of a select query on freight cost to restrict the results to those records where the freight cost exceeds the average. Or you could use an expression including the DAvg function in a calculated control and display the average value of previous orders next to the value of a new order.

Records containing Null values aren't included in the calculation of the average.

Whether you use the DAvg function in a macro or module, in a query expression, or in a calculated control, you must construct the criteria argument carefully to ensure that it will be evaluated correctly.

You can use the DAvg function to specify criteria in the Criteria row of a query. For example, suppose you want to view a list of all products ordered in quantities above the average order quantity. You could create a query on the Orders, Order Details, and Products tables, and include the Product Name field and the Quantity field, with the following expression in the Criteria row beneath the Quantity field:

VBA Copy code Copy code
>DAvg("[Quantity]", "Orders")

You can also use the DAvg function within a calculated field expression in a query, or in the Update To row of an update query.

Note Note

You can use either the DAvg or Avg function in a calculated field expression in a totals query. If you use the DAvg function, values are averaged before the data is grouped. If you use the Avg function, the data is grouped before values in the field expression are averaged.

Use the DAvg function in a calculated control when you need to specify criteria to restrict the range of data on which the DAvg function is performed. For example, to display the average cost of freight for shipments sent to California, set the ControlSource property of a text box to the following expression:

VBA Copy code Copy code
=DAvg("[Freight]", "Orders", "[ShipRegion] = 'CA'")

If you simply want to average all records in domain, use the Avg function.

You can use the DAvg function in a module or macro or in a calculated control on a form if a field that you need to display isn't in the record source on which your form is based. For example, suppose you have a form based on the Orders table, and you want to include the Quantity field from the Order Details table in order to display the average number of items ordered by a particular customer. You can use the DAvg function to perform this calculation and display the data on your form.

Tips

  • If you use the DAvg function in a calculated control, you may want to place the control on the form header or footer so that the value for this control is not recalculated each time you move to a new record.

  • If the data type of the field from which expr is derived is a number, the DAvg function returns a Double data type. If you use the DAvg function in a calculated control, include a data type conversion function in the expression to improve performance.

  • Although you can use the DAvg function to determine the average of values in a field in a foreign table, it may be more efficient to create a query that contains all of the fields that you need and then base your form or report on that query.

Example

The following function returns the average freight cost for orders shipped on or after a given date. The domain is an Orders table. The criteria argument restricts the resulting set of records based on the given country and ship date. Note that the keyword AND is included in the string to separate the multiple fields in the criteria argument. All records included in the DAvg function calculation will have both of these criteria.

VBA Copy code Copy code
Public Function AvgFreightCost(ByVal strCountry As String, _
                               ByVal dteShipDate As Date) As Double

    AvgFreightCost = DAvg("[Freight]", "Orders", _
                     "[ShipCountry] = '" & strCountry & _
                     "'AND [ShippedDate] >= #" & dteShipDate & "#")

End Function

The following examples show how to use various types of criteria with the DAvg function.

Sample code provided by: Community Member Icon The UtterAccess community | About the Contributors

Copy code Copy code
    ' ***************************
    ' Typical Use
    ' Numerical values. Replace "number" with the number to use.
    variable = DAvg("[FieldName]", "TableName", "[Criteria] = number")

    ' Strings.
    ' Numerical values. Replace "string" with the string to use.
    variable = DAvg("[FieldName]", "TableName", "[Criteria]= 'string'")

    ' Dates. Replace "date" with the string to use.
    variable = DAvg("[FieldName]", "TableName", "[Criteria]= #date#")
    ' ***************************

    ' ***************************
    ' Referring to a control on a form
    ' Numerical values
    variable = DAvg("[FieldName]", "TableName", "[Criteria] = " & Forms!FormName!ControlName)

    ' Strings
    variable = DAvg("[FieldName]", "TableName", "[Criteria] = '" & Forms!FormName!ControlName & "'")

    ' Dates
    variable = DAvg("[FieldName]", "TableName", "[Criteria] = #" & Forms!FormName!ControlName & "#")
    ' ***************************

    ' ***************************
    ' Combinations
    ' Multiple types of criteria
    variable = DAvg("[FieldName]", "TableName", "[Criteria1] = " & Forms![FormName]![Control1] _
             & " AND [Criteria2] = '" & Forms![FormName]![Control2] & "'" _
            & " AND [Criteria3] =#" & Forms![FormName]![Control3] & "#")

    ' Use two fields from a single record.
    variable = DAvg("[LastName] & ', ' & [FirstName]", "tblPeople", "[PrimaryKey] = 7")

    ' Expressions
    variable = DAvg("[Field1] + [Field2]", "tableName", "[PrimaryKey] = 7")

    ' Control Structures
    variable = DAvg("IIf([LastName] Like 'Smith', 'True', 'False')", "tableName", "[PrimaryKey] = 7")
    ' ***************************

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Application Object

Other resources

Application Object Members


OptionButton.HelpContextId Property (Access)

 Copy code hover
[image]

OptionButton.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Syntax

expression .HelpContextId

expression A variable that represents an OptionButton object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Control.GridlineColor Property (Access)

 Copy code hover
[image]

Control.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified control. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineColor

expression A variable that represents a Control object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

Control Object

Other resources

Control Object Members


Refresh Method (RDS)

 Copy code hover
[image]

Refresh Method (RDS)
Send feedback

Requeries the data source specified in the Connect property and updates the query results.

Syntax

DataControl.Refresh

Parameters

  • DataControl

  • An object variable that represents an RDS.DataControl object.

Remarks

You must set the Connect, Server, and SQL properties before you use the Refresh method. All data-bound controls on the form associated with an RDS.DataControl object will reflect the new set of records. Any pre-existing Recordset object is released, and any unsaved changes are discarded. The Refresh method automatically makes the first record the current record.

It's a good idea to call the Refresh method periodically when you work with data. If you retrieve data, and then leave it on your client machine for a while, it is likely to become out of date. It's possible that any changes you make will fail, because someone else might have changed the record and submitted changes before you.


TextBox.Enter Event (Access)

 Copy code hover
[image]

TextBox.Enter Event (Access)
See also Send feedback

Published: July 16, 2012

The Enter event occurs before a control actually receives the focus from a control on the same form or report.

Syntax

expression .Enter

expression A variable that represents a TextBox object.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when these events occur, set the OnEnter or OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Enter event occurs before the GotFocus event. The Exit event occurs before the LostFocus event.

Unlike the GotFocus and LostFocus events, the Enter and Exit events don't occur when a form receives or loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Message in dropbox folder belongs to the wrong Synchronizer. (Error 3567)

 Copy code hover
[image]

Message in dropbox folder belongs to the wrong Synchronizer. (Error 3567)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


ObjectFrame.VerticalAnchor Property (Access)

 Copy code hover
[image]

ObjectFrame.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified object frame is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .VerticalAnchor

expression A variable that represents an ObjectFrame object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Chapter 15: ADOX Fundamentals

 Copy code hover
[image]

Chapter 15: ADOX Fundamentals
Send feedback

Microsoft® ActiveX® Data Objects Extensions for Data Definition Language and Security (ADOX) is an extension to the ADO objects and programming model. ADOX includes objects for schema creation and modification, as well as security. Because it is an object-based approach to schema manipulation, you can write code that will work against various data sources regardless of differences in their native syntaxes.

ADOX is a companion library to the core ADO objects. It exposes additional objects for creating, modifying, and deleting schema objects, such as tables and procedures. It also includes security objects to maintain users and groups and to grant and revoke permissions on objects.

To use ADOX with your development tool, you should establish a reference to the ADOX type library. The description of the ADOX library is "Microsoft ADO Ext. for DDL and Security." The ADOX library file name is Msadox.dll, and the program ID (ProgID) is "ADOX". For more information about establishing references to libraries, see the documentation of your development tool.

The Microsoft OLE DB Provider for the Microsoft Jet Database Engine fully supports ADOX. Certain features of ADOX may not be supported, depending on your data provider. For more information about supported features with the Microsoft OLE DB Provider for ODBC, the Microsoft OLE DB Provider for Oracle, or the Microsoft SQL Server OLE DB Provider, see the MDAC readme file.

This document assumes a working knowledge of the Microsoft® Visual Basic® programming language and a general knowledge of ADO. For more information about ADO, see the ADO Programmer's Guide. For more overview information about ADOX, see the following topics:

  • ADOX Objects

  • ADOX Collections

  • ADOX Properties

  • ADOX Methods

  • ADOX Examples


SubForm.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

SubForm.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified subform. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleBottom

expression A variable that represents a SubForm object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


CommandButton.Visible Property (Access)

 Copy code hover
[image]

CommandButton.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents a CommandButton object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


The database engine could not lock table

 Copy code hover
[image]

The database engine could not lock table <name> because it is already in use by another person or process. (Error 3211)
Send feedback

To complete this operation, a table currently in use by another user must be locked. Wait for the other user to finish working with the table, and then try the operation again.


ObjectFrame.SourceObject Property (Access)

 Copy code hover
[image]

ObjectFrame.SourceObject Property (Access)
See also Send feedback

Published: July 16, 2012

You can use this property for linked unbound object frames to determine the complete path and file name of the file that contains the data linked to the object frame. Read-only String.

Syntax

expression .SourceObject

expression A variable that represents an ObjectFrame object.

Remarks

For unbound object frames, the SourceObject property is set automatically when you use the SourceObject command on the Insert menu to insert a linked OLE object.

For linked unbound object frames, the SourceObject property can't be set in any view.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Databases Collection (DAO)

 Copy code hover
[image]

Databases Collection (DAO)
Send feedback

A Databases collection contains all open Database objects opened or created in a Workspace object.

Remarks

When you open an existing Database object or create a new one from a Workspace, it is automatically appended to the Databases collection. When you close a Database object with the Close method, it is removed from the Databases collection but not deleted from disk. You should close all open Recordset objects before closing a Database object.

In a Microsoft Access workspace, the Name property setting of a database is a string that specifies the path of the database file.

To refer to a Database object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

  • Databases(0)

  • Databases("name")

  • Databases![name]

Note Note

You can open the same data source or database more than once, creating duplicate names in the Databases collection. You should assign Database objects to object variables and refer to them by variable name.

Example

This example creates a new Database object and opens an existing Database object in the default Workspace object. Then it enumerates the Database collection and the Properties collection of each Database object.

VBA Copy code Copy code
Sub DatabaseObjectX()

 Dim wrkAcc As Workspace
 Dim dbsNorthwind As Database
 Dim dbsNew As Database
 Dim dbsLoop As Database
 Dim prpLoop As Property

 Set wrkAcc = CreateWorkspace("AccWorkspace", "admin", _
 "", dbUseJet)

 ' Make sure there isn't already a file with the name of
 ' the new database.
 If Dir("NewDB.mdb") <> "" Then Kill "NewDB.mdb"

 ' Create a new database with the specified
 ' collating order.
 Set dbsNew = wrkAcc.CreateDatabase("NewDB.mdb", _
 dbLangGeneral)
 Set dbsNorthwind = wrkAcc.OpenDatabase("Northwind.mdb")

 ' Enumerate the Databases collection.
 For Each dbsLoop In wrkAcc.Databases
 With dbsLoop
 Debug.Print "Properties of " & .Name
 ' Enumerate the Properties collection of each
 ' Database object.
 For Each prpLoop In .Properties
 If prpLoop <> "" Then Debug.Print " " & _
 prpLoop.Name & " = " & prpLoop
 Next prpLoop
 End With
 Next dbsLoop

 dbsNew.Close
 dbsNorthwind.Close
 wrkAcc.Close

End Sub

This example uses CreateDatabase to create a new, encrypted Database object.

VBA Copy code Copy code
Sub CreateDatabaseX()

 Dim wrkDefault As Workspace
 Dim dbsNew As DATABASE
 Dim prpLoop As Property

 ' Get default Workspace.
 Set wrkDefault = DBEngine.Workspaces(0)

 ' Make sure there isn't already a file with the name of
 ' the new database.
 If Dir("NewDB.mdb") <> "" Then Kill "NewDB.mdb"

 ' Create a new encrypted database with the specified
 ' collating order.
 Set dbsNew = wrkDefault.CreateDatabase("NewDB.mdb", _
 dbLangGeneral, dbEncrypt)

 With dbsNew
 Debug.Print "Properties of " & .Name
 ' Enumerate the Properties collection of the new
 ' Database object.
 For Each prpLoop In .Properties
 If prpLoop <> "" Then Debug.Print " " & _
 prpLoop.Name & " = " & prpLoop
 Next prpLoop
 End With

 dbsNew.Close

End Sub


SmartTagProperties.Count Property (Access)

 Copy code hover
[image]

SmartTagProperties.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents a SmartTagProperties object.

See also

Concepts

SmartTagProperties Collection

Other resources

SmartTagProperties Object Members


Image.Section Property (Access)

 Copy code hover
[image]

Image.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Syntax

expression .Section

expression A variable that represents an Image object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

Image Object

Other resources

Image Object Members


Recordset2.BatchCollisionCount Property (DAO)

 Copy code hover
[image]

Recordset2.BatchCollisionCount Property (DAO)
Send feedback

Syntax

expression .BatchCollisionCount

expression A variable that represents a Recordset2 object.

Remarks

This property indicates how many records encountered collisions or otherwise failed to update during the last batch update attempt. The value of this property corresponds to the number of bookmarks in the BatchCollisions property.

If you set the working Recordset object's Bookmark property to bookmark values in the BatchCollisions array, you can move to each record that failed to complete the most recent batch Update operation.

After the collision records are corrected, a batch-mode Update method can be called again. At this point DAO attempts another batch update, and the BatchCollisions property again reflects the set of records that failed the second attempt. Any records that succeeded in the previous attempt are not sent in the current attempt, because they now have a RecordStatus property of dbRecordUnmodified. This process can continue as long as collisions occur, or until you abandon the updates and close the result set.

Example

This example uses the BatchCollisionCount property and the Update method to demonstrate batch updating where any collisions are resolved by forcing the batch update.

Copy code Copy code
Sub BatchX()

 Dim wrkMain As Workspace
 Dim conMain As Connection
 Dim rstTemp As Recordset2
 Dim intLoop As Integer
 Dim strPrompt As String

 Set wrkMain = CreateWorkspace("ODBCWorkspace", _
 "admin", "", dbUseODBC)
 ' This DefaultCursorDriver setting is required for
 ' batch updating.
 wrkMain.DefaultCursorDriver = dbUseClientBatchCursor

 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conMain = wrkMain.OpenConnection("Publishers", _
 dbDriverNoPrompt, False, _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 ' The following locking argument is required for
 ' batch updating. It is also required that a table
 ' with a primary key is used.
 Set rstTemp = conMain.OpenRecordset( _
 "SELECT * FROM roysched", dbOpenDynaset, 0, _
 dbOptimisticBatch)

 With rstTemp
 ' Modify data in local recordset.
 Do While Not .EOF
 .Edit
 If !royalty <= 20 Then
 !royalty = !royalty - 4
 Else
 !royalty = !royalty + 2
 End If
 .Update
 .MoveNext
 Loop

 ' Attempt a batch update.
 .Update dbUpdateBatch

 ' If there are collisions, give the user the option
 ' of forcing the changes or resolving them
 ' individually.
 If .BatchCollisionCount > 0 Then
 strPrompt = "There are collisions. " & vbCr & _
 "Do you want the program to force " & _
 vbCr & "an update using the local data?"
 If MsgBox(strPrompt, vbYesNo) = vbYes Then _
 .Update dbUpdateBatch, True
 End If

 .Close
 End With

 conMain.Close
 wrkMain.Close

End Sub


GetChildren Method (ADO)

 Copy code hover
[image]

GetChildren Method (ADO)
Send feedback

Returns a Recordset whose rows represent the children of a collection Record.

Syntax

Set recordset = record.GetChildren

Return Value

A Recordset object for which each row represents a child of the current Record object. For example, the children of a Record that represents a directory would be the files and subdirectories contained within the parent directory.

Remarks

The provider determines what columns exist in the returned Recordset. For example, a document source provider always returns a resource Recordset.


How to: Disable PAGE UP and PAGE DOWN Keys in a Form

 Copy code hover
[image]

How to: Disable PAGE UP and PAGE DOWN Keys in a Form
Send feedback

By default, the PAGE UP and PAGE DOWN keys can be used to navigate between records in a form. The followng example illustrates how to use a form's KeyDown event to disable the use of the PAGE UP and PAGE DOWN keys in the form.

VBA Copy code Copy code
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

    ' The Keycode value represents the key that
    ' triggered the event.
    Select Case KeyCode

        ' Check for the PAGE UP and PAGE DOWN keys.
        Case 33, 34

        ' Cancel the keystroke.
        KeyCode = 0
    End Select
End Sub
Note Note

You must set the form's KeyPreview property to True in order for this procedure to work.


NavigationButton.Width Property (Access)

 Copy code hover
[image]

NavigationButton.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .Width

expression A variable that represents a NavigationButton object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


CommandButton.OnClick Property (Access)

 Copy code hover
[image]

CommandButton.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Syntax

expression .OnClick

expression A variable that represents a CommandButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Requery Method (ADO)

 Copy code hover
[image]

Requery Method (ADO)
Send feedback

Updates the data in a Recordset object by re-executing the query on which the object is based.

Syntax

recordset.Requery Options

Parameter

  • Options

  • Optional. A bitmask that contains ExecuteOptionEnum and CommandTypeEnum values affecting this operation.

Note Note

If Options is set to adAsyncExecute, this operation will execute asynchronously and a RecordsetChangeComplete event will be issued when it concludes.

The ExecuteOpenEnum values of adExecuteNoRecords or adExecuteStream should not be used with Requery.

Remarks

Use the Requery method to refresh the entire contents of a Recordset object from the data source by reissuing the original command and retrieving the data a second time. Calling this method is equivalent to calling the Close and Open methods in succession. If you are editing the current record or adding a new record, an error occurs.

While the Recordset object is open, the properties that define the nature of the cursor (CursorType, LockType, MaxRecords, and so forth) are read-only. Thus, the Requery method can only refresh the current cursor. To change any of the cursor properties and view the results, you must use the Close method so that the properties become read/write again. You can then change the property settings and call the Open method to reopen the cursor.


NavigationButton.Alignment Property (Access)

 Copy code hover
[image]

NavigationButton.Alignment Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets how the specified button's caption and picture are aligned. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .Alignment

expression A variable that represents a NavigationButton object.

Remarks

The Alignment property uses the following settings.

Value | Description
0 | General alignment.
1 | Left alignment.
2 | (Default) Center alignment.
3 | Right alignment.
4 | Distribute alignment evenly across the button's width.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


OptionButton.ValidationRule Property (Access)

 Copy code hover
[image]

OptionButton.ValidationRule Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.

Syntax

expression .ValidationRule

expression A variable that represents an OptionButton object.

Remarks

Enter an expression for the ValidationRule property setting and text for the ValidationText property setting. The maximum length for the ValidationRule property setting is 2048 characters. The maximum length for the ValidationText property setting is 255 characters.

For controls, you can set the ValidationRule property to any valid expression. For field and record validation rules, the expression can't contain user-defined functions, domain aggregate or aggregate functions, the Eval function, or CurrentUser method, or references to forms, queries, or tables. In addition, field validation rules can't contain references to other fields. For records, expressions can include references to fields in that table.

For table fields and records, you can also set these properties in Visual Basic by using the DAO ValidationRule property.

Note Note

The ValidationRule and ValidationText properties don't apply to check box, option button, or toggle buttoncontrols when they are in an option group. They apply only to the option group itself.

Microsoft Access automatically validates values based on a field's data type; for example, Microsoft Access doesn't allow text in a numeric field. You can set rules that are more specific by using the ValidationRule property.

If you set the ValidationRule property but not the ValidationText property, Microsoft Access displays a standard error message when the validation rule is violated. If you set the ValidationText property, the text you enter is displayed as the error message.

For example, when a record is added for a new employee, you can enter a ValidationRule property requiring that the value in the employee's StartDate field fall between the company's founding date and the current date. If the date entered isn't in this range, you can display the ValidationText property message: "Start date is incorrect."

If you create a control by dragging a field from the field list, the field's validation rule remains in effect, although it isn't displayed in the control's ValidationRule property box in the property sheet. This is because a field's validation rule is inherited by a control bound to that field.

Control, field, and record validation rules are applied as follows:

  • Validation rules you set for fields and controls are applied when you edit the data and the focus leaves the field or control.

  • Validation rules for records are applied when you move to another record.

  • If you create validation rules for both a field and a control bound to the field, both validation rules are applied when you edit data and the focus leaves the control.

The following table contains expression examples for the ValidationRule and ValidationText properties.

ValidationRule property | ValidationText property
<> 0 | Entry must be a nonzero value.
> 1000 Or Is Null | Entry must be blank or greater than 1000.
Like "A????" | Entry must be 5 characters and begin with the letter "A".
>= #1/1/96# And <#1/1/97# | Entry must be a date in 1996.
DLookup("CustomerID", "Customers", "CustomerID = Forms!Customers!CustomerID") Is Null | Entry must be a unique CustomerID (domain aggregate functions are allowed only for form-level validation).

If you create a validation rule for a field, Microsoft Access doesn't normally allow a Null value to be stored in the field. If you want to allow a Null value, add "Is Null" to the validation rule, as in "<> 8 Or Is Null" and make sure the Required property is set to No.

You can't set field or record validation rules for tables created outside Microsoft Access (for example, dBASE, Paradox, or SQL Server). For these kinds of tables, you can create validation rules for controls only.

Example

The following example creates a validation rule for a field that allows only values over 65 to be entered. If a number less than 65 is entered, a message is displayed. The properties are set by using the SetFieldValidation function.

VBA Copy code Copy code
Dim strTblName As String, strFldName As String
Dim strValidRule As String
Dim strValidText As String, intX As Integer

strTblName = "Customers"
strFldName = "Age"
strValidRule = ">= 65"
strValidText = "Enter a number greater than or equal to 65."
intX = SetFieldValidation(strTblName, strFldName, _
 strValidRule, strValidText)

Function SetFieldValidation(strTblName As String, _
 strFldName As String, strValidRule As String, _
 strValidText As String) As Integer

 Dim dbs As Database, tdf As TableDef, fld As Field

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 Set fld = tdf.Fields(strFldName)
 fld.ValidationRule = strValidRule
 fld.ValidationText = strValidText
End Function

The next example uses the SetTableValidation function to set record-level validation to ensure that the value in the EndDate field comes after the value in the StartDate field.

VBA Copy code Copy code
Dim strTblName As String, strValidRule As String
Dim strValidText As String
Dim intX As Integer

strTblName = "Employees"
strValidRule = "EndDate > StartDate"
strValidText = "Enter an EndDate that is later than the StartDate."
intX = SetTableValidation(strTblName, strValidRule, strValidText)

Function SetTableValidation(strTblName As String, _
 strValidRule As String, strValidText As String) _
 As Integer

 Dim dbs As Database, tdf As TableDef

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 tdf.ValidationRule = strValidRule
 tdf.ValidationText = strValidText
End Function

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


WebBrowserControl.KeyDown Event (Access)

 Copy code hover
[image]

WebBrowserControl.KeyDown Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Version Information

Version Added: Access 2010

Syntax

expression .KeyDown(KeyCode, Shift)

expression A variable that represents a WebBrowserControl object.

Parameters

Name | Required/Optional | Data Type | Description
KeyCode | Required | Integer |
Shift | Required | Integer |

Return Value

nothing

Remarks

To run a macro or event procedure when these events occur, set the OnKeyDown property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyDown event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyDown event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyDown event occurs when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

Example

The following example determines whether you have pressed the SHIFT, CTRL, or ALT key.

To try the example, add the following event procedure to a form containing a text box named KeyHandler.

VBA Copy code Copy code
Private Sub KeyHandler_KeyDown(KeyCode As Integer, _
 Shift As Integer)
 Dim intShiftDown As Integer, intAltDown As Integer
 Dim intCtrlDown As Integer

 ' Use bit masks to determine which key was pressed.
 intShiftDown = (Shift And acShiftMask) > 0
 intAltDown = (Shift And acAltMask) > 0
 intCtrlDown = (Shift And acCtrlMask) > 0
 ' Display message telling user which key was pressed.
 If intShiftDown Then MsgBox "You pressed the SHIFT key."
 If intAltDown Then MsgBox "You pressed the ALT key."
 If intCtrlDown Then MsgBox "You pressed the CTRL key."
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Label.BorderColor Property (Access)

 Copy code hover
[image]

Label.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Syntax

expression .BorderColor

expression A variable that represents a Label object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

Label Object

Other resources

Label Object Members


Label.IsVisible Property (Access)

 Copy code hover
[image]

Label.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Syntax

expression .IsVisible

expression A variable that represents a Label object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

Label Object

Other resources

Label Object Members


Failure in getting a file from the server using FTP. (Error 3680)

 Copy code hover
[image]

Failure in getting a file from the server using FTP. (Error 3680)
Send feedback

Unable to get a file from the internet server. Make sure the server is running and the FTP share folder is configured properly with read/write access. The file you are trying to retrieve might have been deleted.


Label.OnMouseUp Property (Access)

 Copy code hover
[image]

Label.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Syntax

expression .OnMouseUp

expression A variable that represents a Label object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

Label Object

Other resources

Label Object Members


ComboBox.RowSource Property (Access)

 Copy code hover
[image]

ComboBox.RowSource Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the RowSource property (along with the RowSourceType property) to tell Microsoft Access how to provide data tothe specified object. Read/write String.

Syntax

expression .RowSource

expression A variable that represents a ComboBox object.

Remarks

For example, to display rows of data in a list box from a query named CustomerList, set the list box's RowSourceType property to Table/Query and its RowSource property to the query named CustomerList.

The RowSource property setting depends on the RowSourceType property setting.

For this RowSourceType setting | Enter this RowSource setting
Table/Query | A table name, query name, or SQL statement.
Value List | A list of items with semicolons (;) as separators.
Field List | A table name, query name, or SQL statement.

If the RowSourceType property is set to a user-defined function, the RowSource property can be left blank.

For table fields, you can set these properties on the Lookup tab in the Field Properties section of table Design view for fields with the DisplayControl property set to Combo Box or List Box.

Microsoft Access sets these properties automatically when you select Lookup Wizard as the data type for a field in table Design view.

In Visual Basic, set the RowSourceType property by using a string expression with one of these values: "Table/Query", "Value List", or "Field List". You also use a string expression to set the value of the RowSource property. To set the RowSourceType property to a user-defined function, enter the name of the function.

When you have a limited number of values that don't change, you can set the RowSourceType property to Value List and then enter the values that make up the list in the RowSource property.

Example

The following example sets the RowSourceType property for a combo box to Table/Query, and it sets the RowSource property to a query named EmployeeList.

VBA Copy code Copy code
Forms!Employees!cmboNames.RowSourceType = "Table/Query"
Forms!Employees!cmboNames.RowSource = "EmployeeList"

The following example shows how to set the RowSource property of a combo box when a form is loaded. When the form is displayed, the items stored in the Departments field of the tblDepartment combo box are displayed in the cboDept combo box.

Sample code provided by: MVP Contributor Bill Jelen, MrExcel.com | About the Contributors

Copy code Copy code
Private Sub Form_Load()
    Me.Caption = "Today is " & Format$(Date, "dddd mmm-d-yyyy")
    Me.RecordSource = "tblDepartments"
    DoCmd.Maximize
    txtDept.ControlSource = "Department"
    cmdClose.Caption = "&Close"
    cboDept.RowSourceType = "Table/Query"
    cboDept.RowSource = "SELECT Department FROM tblDepartments"
End Sub

About the Contributors

Holy Macro! Books publishes entertaining books for people who use Microsoft Office. See the complete catalog at MrExcel.com.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Attachment.Layout Property (Access)

 Copy code hover
[image]

Attachment.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified attachment. Read-only AcLayoutType.

Version Information

Version Added: Access 2007

Syntax

expression .Layout

expression A variable that represents an Attachment object.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Form.WindowTop Property (Access)

 Copy code hover
[image]

Form.WindowTop Property (Access)
See also Send feedback

Published: July 16, 2012

Returns an Integer indicating the screen position in twips of the top edge of a form relative to the top of the Microsoft Access window. Read-only.

Syntax

expression .WindowTop

expression A variable that represents a Form object.

Remarks

Use the Move method to change the position of a form.

Example

The following example returns the screen position of the top and left edges of the first form in the current project.

VBA Copy code Copy code
With Forms(0)

 MsgBox "The form is " & .WindowLeft _
 & " twips from the left edge of the Access window and " _
 & .WindowTop _
 & " twips from the top edge of the Access window."

End With

See also

Concepts

Form Object

Other resources

Form Object Members


Field.Type Property (DAO)

 Copy code hover
[image]

Field.Type Property (DAO)
Send feedback

Sets or returns a value that indicates the operational type or data type of an object. Read/write Integer.

Syntax

expression .Type

expression A variable that represents a Field object.

Remarks

The setting or return value is a constant that indicates an operational or data type. For a Field object, this property is read/write until the object is appended to a collection or to another object, after which it's read-only.

For a Field object, the possible settings and return values are described in the following table.

Constant | Description
dbBigInt | Big Integer
dbBinary | Binary
dbBoolean | Boolean
dbByte | Byte
dbChar | Char
dbCurrency | Currency
dbDate | Date/Time
dbDecimal | Decimal
dbDouble | Double
dbFloat | Float
dbGUID | GUID
dbInteger | Integer
dbLong | Long
dbLongBinary | Long Binary (OLE Object)
dbMemo | Memo
dbNumeric | Numeric
dbSingle | Single
dbText | Text
dbTime | Time
dbTimeStamp | Time Stamp
dbVarBinary | VarBinary

When you append a new Field, Parameter, or Property object to the collection of an Index, QueryDef, Recordset, or TableDef object, an error occurs if the underlying database doesn't support the data type specified for the new object.


Report.Filter Event (Access)

 Copy code hover
[image]

Report.Filter Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when the user opens a filter window by clicking Advanced Filter/Sort.

Version Information

Version Added: Access 2007

Syntax

expression .Filter(Cancel, FilterType)

expression A variable that represents a Report object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines whether to open the filter window. Setting the Cancel argument to True (-1) prevents the filter window from opening. You can also use the CancelEvent method of the DoCmd object to cancel opening the filter window.
FilterType | Required | Integer | The filter window the user is trying to open. The FilterType argument can be acFilterAdvanced.

Remarks

To run a macro or event procedure when this event occurs, set the OnFilter property to the name of the macro or to [Event Procedure].

You can use the Filter event to:

  • Remove any previous filter for the report. To do this, set the Filter property or ServerFilter property of the report to a zero-length string (" ") in the Filter macro or event procedure. This is especially useful if you want to make sure extraneous criteria do not appear in the new filter. For example, when you use the Filter By Selection feature, the criteria you use (the selected text in the report) is added to the Filter or ServerFilter property WHERE clause expression, and appears in the Advanced Filter/Sort window. You can remove these old criteria by using the Filter event.

  • Enter default settings for the new filter. To do this, set the Filter property or ServerFilter property to include these criteria. For example, you may want all filters for a Products report to display only current products (products for which the Discontinued control in the Products report is not selected).

  • Use your own custom filter window instead of one of the Microsoft Access filter windows. When the Filter event occurs, you can open your own custom form and use the entries on this report to set the Filter property or ServerFilter property and filter the original report. When the user closes this custom form, set the FilterOn property or ServerFilterByForm property of the original report to True (-1) to apply the filter. Canceling the Filter event prevents the Microsoft Access filter window from opening.

See also

Concepts

Report Object

Other resources

Report Object Members


ALL (Microsoft Access SQL reserved word)

 Copy code hover
[image]

ALL (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The ALL keyword is used in these contexts:

ALL, DISTINCT, DISTINCTROW, TOP Predicates

SQL Subqueries

UNION Operation


Description, HelpContext, HelpFile, NativeError, Number, Source, and SQLState Properties Example (VC++)

 Copy code hover
[image]

Description, HelpContext, HelpFile, NativeError, Number, Source, and SQLState Properties Example (VC++)
Send feedback

This example triggers an error, traps it, and displays the Description, HelpContext, HelpFile, NativeError, Number, Source, and SQLState properties of the resulting Error object.

Copy code Copy code
// BeginDescriptionCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll"     no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include<conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void DescriptionX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////////////////////////////////
//                                                       //
//      Main Function                                    //
//                                                       //
///////////////////////////////////////////////////////////

void main()
{
    if(FAILED(::CoInitialize(NULL)))
        return;

    DescriptionX();

    //Wait here for user to see the output..
    printf("\nPress any key to continue...");
    getch();
    ::CoUninitialize();
}

///////////////////////////////////////////////////////////
//                                                       //
//      DescriptionX Function                            //
//                                                       //
///////////////////////////////////////////////////////////

void DescriptionX()
{
    // Define ADO object pointers.
    // Initialize pointers on define.
    // These are in the ADODB::  namespace
    _ConnectionPtr pConnection = NULL;
    ErrorPtr errorLoop = NULL;

    //Define Other Variables
    HRESULT hr = S_OK;

    try
    {
        // Intentionally trigger an error.
        // open connection
        TESTHR(pConnection.CreateInstance(__uuidof(Connection)));

        if (FAILED(hr = pConnection->Open("nothing","","",adConnectUnspecified)))
        {
            _com_issue_error(hr);
            exit(1);
        }

        // Cleanup object before exit.
        pConnection->Close();
    }
    catch(_com_error)
    {
        // Pass a connection pointer.
        PrintProviderError(pConnection);
    }
}

///////////////////////////////////////////////////////////
//                                                       //
//      PrintProviderError Function                      //
//                                                       //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
    //Define Other Variables
    HRESULT  hr = S_OK;
    _bstr_t  strError;
    ErrorPtr  pErr = NULL;

    try
    {
        // Enumerate Errors collection and display
        // properties of each Error object.
        long nCount = pConnection->Errors->Count;

        // Collection ranges from 0 to nCount - 1.
        for(long i = 0; i < nCount; i++)
        {
            pErr = pConnection->Errors->GetItem(i);
            printf("Error #%d\n", pErr->Number);
            printf(" %s\n",(LPCSTR)pErr->Description);
            printf(" (Source: %s)\n",(LPCSTR)pErr->Source);
            printf(" (SQL State: %s)\n",(LPCSTR)pErr->SQLState);
            printf(" (NativeError: %d)\n",(LPCSTR)pErr->NativeError);
            if ((LPCSTR)pErr->GetHelpFile() == NULL)
            {
                printf("\tNo Help file available\n");
            }
            else
            {
                printf("\t(HelpFile: %s\n)" ,pErr->HelpFile);
                printf("\t(HelpContext: %s\n)" , pErr->HelpContext);
            }
        }
    }
    catch(_com_error &e)
    {
        // Notify the user of errors if any.
        PrintComError(e);
    }
}

///////////////////////////////////////////////////////////
//                                                       //
//      PrintComError Function                           //
//                                                       //
///////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
   // Notify the user of errors if any.
   _bstr_t bstrSource(e.Source());
   _bstr_t bstrDescription(e.Description());

    // Print Com errors.

   printf("Error\n");
   printf("\tCode = %08lx\n", e.Error());
   printf("\tCode meaning = %s", e.ErrorMessage());
   printf("\tSource = %s\n", (LPCSTR) bstrSource);
   printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndDescriptionCpp


Members Collection (ADO MD)

 Copy code hover
[image]

Members Collection (ADO MD)
Send feedback

Contains the Member objects from a level or a position along an axis.

Remarks

A Members collection is used to contain the following types of members:

  • The members that make up a level in a cube. These are contained in the Members collection of a Level object. For example, using the sample from Overview of Multidimensional Schemas and Data, the four members of the Countries level are Canada, USA, UK, and Germany.

  • The members that are the children of a specific member within a hierarchy. These members are returned by the Children property of the parent Member object. For example, again using the same sample, the two children of the Canada member are Canada-East and Canada-West.

  • The members that define a specific position along an axis of a cellset. Using the cellset from Working with Multidimensional Data as an example, the two members of the first position on the x-axis are Valentine and Seattle. These members are contained by the Members collection of a Position object.

Members is a standard ADO collection. With the properties and methods of a collection, you can do the following:

  • Obtain the number of objects in the collection with the Count property.

  • Return an object from the collection with the default Item property.

  • Update the objects in the collection from the provider with the Refresh method.


Form.Activate Event (Access)

 Copy code hover
[image]

Form.Activate Event (Access)
See also Send feedback

Published: July 16, 2012

The Activate event occurs when a form receives the focus and becomes the active window.

Syntax

expression .Activate

expression A variable that represents a Form object.

Return Value

nothing

Remarks

Note Note

The Activate event doesn't occur when a form receives focus back from a dialog box, popup, or another form.

To run a macro or event procedure when these events occur, set the OnActivate, or OnDeactivate property to the name of the macro or to [Event Procedure].

You can make a form active by opening it, clicking it or a control on it, or by using the SetFocus method in Visual Basic.

The Activate event can occur only when a form is visible.

The Activate event occurs before the GotFocus event; the Deactivate event occurs after the LostFocus event.

When you switch between two open forms, the Deactivate event occurs for the form being switched from, and the Activate event occurs for the form being switched to. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

When you first open a form, the following events occur in this order:

Open → Load → Resize → Activate → Current

When you close a form, the following events occur in this order:

Unload → Deactivate → Close

See also

Concepts

Form Object

Other resources

Form Object Members


AllFunctions Object (Access)

 Copy code hover
[image]

AllFunctions Object (Access)
See also Send feedback

Published: July 16, 2012

The AllFunctions collection contains an AccessObject object for each function in the CurrentData or CodeData object.

Remarks

The CurrentData or CodeData object has an AllFunctions collection containing AccessObject objects that describe instances of all functions specified by the CurrentData or CodeData objects. For example, you can enumerate the AllFunctions collection in Visual Basic to set or return the values of properties of individual AccessObject objects in the collection.

You can refer to an individual AccessObject object in the AllFunctions collection either by referring to the object by name, or by referring to its index within the collection. If you want to refer to a specific object in the AllFunctions collection, it's better to refer to the function by name because a function's collection index may change.

The AllFunctions collection is indexed beginning with zero. If you refer to a function by its index, the first function is AllFunctions(0), the second table is AllFunctions(1), and so on.

To list all open functions in the database, use the IsLoaded property of each AccessObject object in the AllFunctions collection. You can then use the Name property of each individual AccessObject object to return the name of a function.

You can't add or delete an AccessObject object from the AllFunctions collection.

See also

Concepts

Access Object Model Reference

Other resources

AllFunctions Object Members


Rectangle.Height Property (Access)

 Copy code hover
[image]

Rectangle.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Syntax

expression .Height

expression A variable that represents a Rectangle object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


WebBrowserControl.ScrollLeft Property (Access)

 Copy code hover
[image]

WebBrowserControl.ScrollLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the distance, in pixels, between the left edge of the WebBrowser object and the leftmost portion of the content currently visible in the control. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ScrollLeft

expression A variable that represents a WebBrowserControl object.

Remarks

This property value equals the current horizontal offset of the content within the scrollable range. Although you can set this property to any value, if you assign a value less than 0, the property is set to 0. If you assign a value greater than the maximum value, the property is set to the maximum value.

This property is always 0 for objects that do not have scroll bars. For these objects, setting the property has no effect.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Form.RowHeight Property (Access)

 Copy code hover
[image]

Form.RowHeight Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the RowHeight property to specify the height of all rows in Datasheet view. Read/write Integer.

Syntax

expression .RowHeight

expression A variable that represents a Form object.

Remarks

The RowHeight property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

The RowHeight property setting represents the datasheet row height in twips. To specify the default height for the current font, you can set the RowHeight property to True.

Example

This example takes effect in Datasheet view of the open Customers form. It sets the row height to 450 twips and sizes the column to fit the size of the visible text.

VBA Copy code Copy code
Forms![Customers].RowHeight = 450
Forms![Customers]![Address].ColumnWidth = -2

See also

Concepts

Form Object

Other resources

Form Object Members


TextBox.OnLostFocus Property (Access)

 Copy code hover
[image]

TextBox.OnLostFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnLostFocus

expression A variable that represents a TextBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The LostFocus event occurs when the object loses the focus.

The OnLostFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Lost Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Lost Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnLostFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnLostFocus

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


TextBox.SelText Property (Access)

 Copy code hover
[image]

TextBox.SelText Property (Access)
See also Send feedback

Published: July 16, 2012

The SelText property returns a string containing the selected text. Read/write String.

Syntax

expression .SelText

expression A variable that represents a TextBox object.

Remarks

If no text is selected, the SelText property contains a Null value.

The SelText property uses a string expression that contains the text selected in the control. If the control contains selected text when this property is set, the selected text is replaced by the new SelText setting.

To set or return this property for a control, the control must have the focus. To move the focus to a control, use the SetFocus method.

Example

The following example uses two event procedures to search for text specified by a user. The text to search is set in the form's Load event procedure. The Click event procedure for the Find button (which the user clicks to start the search) prompts the user for the text to search for and selects the text in the text box if the search is successful.

VBA Copy code Copy code
Sub Form_Load()
 Dim ctlTextToSearch As Control
 Set ctlTextToSearch = Forms!Form1!TextBox1
 ctlTextToSearch.SetFocus ' SetFocus to text box.
 ctlTextToSearch.SelText = "This company places large orders " _
 & "twice a year for garlic, oregano, chilies and cumin."
End Sub

Sub Find_Click()
 Dim strSearch As String, intWhere As Integer
 Dim ctlTextToSearch As Control
 ' Get search string from user.
 With Me!Textbox1
 strSearch = InputBox("Enter text to find:")
 ' Find string in text.
 intWhere = InStr(.Value, strSearch)
 If intWhere Then
 ' If found.
 .SetFocus
 .SelStart = intWhere - 1
 .SelLength = Len(strSearch)
 Else
 ' Notify user.
 MsgBox "String not found."
 End If
 End With
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


NavigationControl.GridlineWidthRight Property (Access)

 Copy code hover
[image]

NavigationControl.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthRight

expression A variable that represents a NavigationControl object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Cannot group on Memo or OLE Object

 Copy code hover
[image]

Cannot group on Memo or OLE Object <clause>. (Error 3119)
Send feedback

The GROUP BY clause of an SQL statement cannot include Memo or OLE Object fields.


ToggleButton.TabIndex Property (Access)

 Copy code hover
[image]

ToggleButton.TabIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.

Syntax

expression .TabIndex

expression A variable that represents a ToggleButton object.

Remarks

You can set the TabIndex property to an integer representing the position of the control within the tab order of the form. Valid settings are 0 for the first tab position, up to the total number of controls minus 1 for the last tab position. For example, if a form has three controls that each have a TabIndex property, valid TabIndex property settings are 0, 1, and 2.

Setting the TabIndex property to an integer less than 0 produces an error.

By default, Microsoft Access assigns a tab order to controls in the order that you create them on a form. Each new control is placed last in the tab order. If you change the setting of a control's TabIndex property to adjust the tab order, Microsoft Access automatically renumbers the TabIndex property setting of other controls to reflect insertions and deletions.

In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the TAB key.

Changing the tab order of other controls on the form doesn't affect what happens when you press a control's access key. For example, if you've created an access key for the label of a text box, the focus will move to the text box whenever you press the label's access key — even if you change the TabIndex property setting for the text box.

If you press an access key for a control such as a label that doesn't have a TabIndex property (and thus isn't in the tab order), the focus moves to the next control in the tab order that can receive the focus.

Example

The following example reverses the tab order of a command button and a text box. Because TextBox1 was created first, it has a TabIndex property setting of 0 and Command1 has a setting of 1.

VBA Copy code Copy code
Sub Form_Click()
 Me!Command1.TabIndex = 0
 Me!TextBox1.TabIndex = 1
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


How to: Prevent the Accidental Erasure of Data When Moving Between Controls on a Form

 Copy code hover
[image]

How to: Prevent the Accidental Erasure of Data When Moving Between Controls on a Form
Send feedback

When you tab from one text box or memo field to another in a form, the text in the control is highlighted. This makes it easy for users to accidentally delete the text by pressing a key. By using a few lines of code, you can move the insertion point to the first position in the text box, minimizing the risk of accidentally deleting the text.

To do this, create a procedure for the text box's GotFocus event. In the GotFocus event procedure, set the SelLength property of the text box to its SelStart property. The following example illustrates how to do this for a text box named txtFirstName.

VBA Copy code Copy code
Private Sub txtFirstName_GotFocus()

    Me.txtFirstName.SelLength = Me.txtFirstName.SelStart

End Sub


Count Function (Microsoft Access SQL)

 Copy code hover
[image]

Count Function (Microsoft Access SQL)
Send feedback

Published: July 16, 2012

Calculates the number of records returned by a query.

Syntax

Count(expr)

The expr placeholder represents a string expression identifying the field that contains the data you want to count or an expression that performs a calculation using the data in the field. Operands in expr can include the name of a table field or function (which can be either intrinsic or user-defined but not other SQL aggregate functions). You can count any kind of data, including text.

Remarks

You can use Count to count the number of records in an underlying query. For example, you could use Count to count the number of orders shipped to a particular country or region.

Although expr can perform a calculation on a field, Count simply tallies the number of records. It does not matter what values are stored in the records.

The Count function does not count records that have Null fields unless expr is the asterisk (*) wildcard character. If you use an asterisk, Count calculates the total number of records, including those that contain Null fields. Count(*) is considerably faster than Count([Column Name]). Do not enclose the asterisk in quotation marks (' '). The following example calculates the number of records in the Orders table:

SQL Copy code Copy code
SELECT Count(*)
AS TotalOrders FROM Orders;

If expr identifies multiple fields, the Count function counts a record only if at least one of the fields is not Null. If all of the specified fields are Null, the record is not counted. Separate the field names with an ampersand (&). The following example shows how you can limit the count to records in which either ShippedDate or Freight is not Null:

SQL Copy code Copy code
SELECT
Count('ShippedDate & Freight')
AS [Not Null] FROM Orders;

You can use Count in a query expression. You can also use this expression in the SQL property of a QueryDef object or when creating a Recordset object based on an SQL query.

Example

This example uses the Orders table to calculate the number of orders shipped to the United Kingdom.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

VBA Copy code Copy code
Sub CountX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Calculate the number of orders shipped
    ' to the United Kingdom.
    Set rst = dbs.OpenRecordset("SELECT" _
        & " Count (ShipCountry)" _
        & " AS [UK Orders] FROM Orders" _
        & " WHERE ShipCountry = 'UK';")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 25

    dbs.Close

End Sub


NextRecordset Method Example (VJ++)

 Copy code hover
[image]

NextRecordset Method Example (VJ++)
Send feedback

This example uses the NextRecordset method to view the data in a recordset that uses a compound command statement made up of three separate SELECT statements.

Copy code Copy code

// BeginNextRecordsetJ
import java.io.*;
import com.ms.wfc.data.*;

public class NextRecordsetX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 NextRecordsetX();
 System.exit(0);
 }
 // NextRecordsetX Function
 static void NextRecordsetX()
 {
 // Define ADO Object
 Recordset rstCompound = null;

 // Declarations
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));
 String strCnn;
 int intCount;
 int intDisplayRecords = 15;
 int intRecordCount;

 try
 {
 // Open compound recordset.
 strCnn = "Provider='sqloledb';Data Source='MySqlServer';" +
 "Initial Catalog='Pubs';Integrated Security='SSPI';";

 rstCompound = new Recordset();
 rstCompound.open("select * from Authors;" +
 "select * from stores;" +
 "select * from jobs", strCnn, AdoEnums.CursorType.FORWARDONLY,
 AdoEnums.LockType.READONLY,AdoEnums.CommandType.TEXT);

 // Display results from each select statement.
 intCount=1;

 while (rstCompound != null)
 {
 System.out.println(
 "Contents of recordset #" + intCount + "\n");
 intRecordCount = 0;

 while(!rstCompound.getEOF())
 {
 System.out.println(
 rstCompound.getField(0).getString()+" " +
 rstCompound.getField(1).getString());
 intRecordCount++;

 rstCompound.moveNext();
 if ( intRecordCount == intDisplayRecords)
 {
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 intRecordCount = 0;
 }
 }
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();

 rstCompound = rstCompound.nextRecordset();

 intCount++;
 }
 }
 // System read requires this catch.
 catch(java.io.IOException je)
 {
 PrintIOError(je);
 }
 catch(AdoException ae)
 {
 // Notify the user of any errors that result from ADO.

 // As passing a recordset. check for the null pointer first
 if(rstCompound!=null)
 {
 PrintProviderError(rstCompound.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 catch(java.lang.NullPointerException ne)
 {
 System.out.println("Error Description: " + ne.getMessage());
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstCompound != null)
 if (rstCompound.getState() == 1)
 rstCompound.close();
 }

 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndNextRecordsetJ


Execute Method (ADO Command)

 Copy code hover
[image]

Execute Method (ADO Command)
Send feedback

Executes the query, SQL statement, or stored procedure specified in the CommandText property.

Syntax

For a Recordset-returning Command:

For a non-recordset-returning Command:

Return Value

Returns a Recordset object reference or Nothing.

Parameters

  • RecordsAffected

  • Optional. A Long variable to which the provider returns the number of records that the operation affected. The RecordsAffected parameter applies only for action queries or stored procedures. RecordsAffected does not return the number of records returned by a result-returning query or stored procedure. To obtain this information, use the RecordCount property. The Execute method will not return the correct information when used with adAsyncExecute, simply because when a command is executed asynchronously, the number of records affected may not yet be known at the time the method returns.

  • Parameters

  • Optional. A Variant array of parameter values passed with an SQL statement. (Output parameters will not return correct values when passed in this argument.)

  • Options

  • Optional. A Long value that indicates how the provider should evaluate the CommandText property of the Command object. Can be a bitmask value made using CommandTypeEnum and/or ExecuteOptionEnum values. For example, you could use both adCmdText and adExecuteNoRecords together in combination if you want to have ADO evaluate the value of the CommandText property as text and indicate that the command should discard and not return any records that might be generated when the command text executes.

Remarks

Using the Execute method on a Command object executes the query specified in the CommandText property of the object. If the CommandText property specifies a row-returning query, any results that the execution generates are stored in a new Recordset object. If the command is not a row-returning query, the provider returns a closed Recordset object. Some application languages allow you to ignore this return value if no Recordset is desired.

If the query has parameters, the current values for the Command object's parameters are used unless you override these with parameter values passed with the Execute call. You can override a subset of the parameters by omitting new values for some of the parameters when calling the Execute method. The order in which you specify the parameters is the same order in which the method passes them. For example, if there were four (or more) parameters and you wanted to pass new values for only the first and fourth parameters, you would pass as the Parameters argument.

Note Note

Output parameters will not return correct values when passed in the Parameters argument.

An ExecuteComplete event will be issued when this operation concludes.


OptionButton.HorizontalAnchor Property (Access)

 Copy code hover
[image]

OptionButton.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the option button is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .HorizontalAnchor

expression A variable that represents an OptionButton object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


TabControl.PressedTint Property (Access)

 Copy code hover
[image]

TabControl.PressedTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the PressedColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .PressedTint

expression A variable that represents a TabControl object.

Remarks

The PressedTint property contains a numeric expression that can be used to lighten the theme color in the PressedColor property. The default value of the PressedTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Attachment.ColumnWidth Property (Access)

 Copy code hover
[image]

Attachment.ColumnWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .ColumnWidth

expression A variable that represents an Attachment object.

Remarks

In Visual Basic , the ColumnWidth property setting is an Integer value that represents the column width in twips. You can specify a width or use one of the following predefined settings.

Setting | Description
0 | Hides the column.
-1 | (Default) Sizes the column to the default width.
Note Note

The ColumnWidth property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

Setting this property to 0, or resizing the field to a zero width in Datasheet view, sets the field's ColumnHidden property to True (-1) and hides the field in Datasheet view.

Setting a field's ColumnHidden property to False (0) restores the field's ColumnWidth property to the value it had before the field was hidden. For example, if the ColumnWidth property was -1 prior to the field being hidden by setting the property to 0, changing the field's ColumnHidden property to False resets the ColumnWidth to -1.

The ColumnWidth property for a field isn't available when the field's ColumnHidden property is set to True.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


ComboBox.BorderColor Property (Access)

 Copy code hover
[image]

ComboBox.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Syntax

expression .BorderColor

expression A variable that represents a ComboBox object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


CommandButton.FontUnderline Property (Access)

 Copy code hover
[image]

CommandButton.FontUnderline Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontUnderline property to specify whether text is underlined in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontUnderline

expression A variable that represents a CommandButton object.

Remarks

The FontUnderline property uses the following settings.

Setting | Description
True | The text is underlined.
False | (Default) The text isn't underlined.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Value Property Example (VJ++)

 Copy code hover
[image]

Value Property Example (VJ++)
Send feedback

This example demonstrates the Value property with Field and Property objects by displaying field and property values for the Employees table.

Copy code Copy code

// BeginValueJ
import java.io.*;
import com.ms.wfc.data.*;
import com.ms.com.*;

public class ValueX
{
 // Main Function
 public static void main (String[] args)
 {
 ValueX();
 System.exit(0);
 }
 static void ValueX()
 {
 // Define ADO Objects.
 Recordset rstEmployees = null;
 Field fldLoop = null;
 AdoProperty prpLoop = null;

 // Declarations.
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';" +
 "Initial Catalog='Pubs';Integrated Security='SSPI';";
 int intLoop;
 BufferedReader in = new
 BufferedReader(new InputStreamReader(System.in));
 Variant varPropertyValue;
 String strMessage;

 try
 {
 // Open a Recordset with data from Employees table.
 rstEmployees = new Recordset();
 rstEmployees.open("employee", strCnn,
 AdoEnums.CursorType.FORWARDONLY, AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TABLE);

 System.out.println("Field values in rstEmployees\n");

 // Enumerate the Fields collection of the Employees
 // table.
 for(intLoop = 0;
 intLoop<rstEmployees.getFields().getCount();intLoop++)
 {
 fldLoop = rstEmployees.getFields().getItem(intLoop);
 // Because Value is the default property of a
 // Field object, the use of the actual keyword
 // here is optional.
 System.out.println("\t" + fldLoop.getName() + " = " +
 fldLoop.getValue());
 }
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 System.out.println("Property values in rstEmployees\n");

 // Enumerate the Properties collection of the
 // Recordset object.
 int intCount = 0;
 for(intLoop = 0;
 intLoop<rstEmployees.getProperties().getCount();intLoop++)
 {
 prpLoop = rstEmployees.getProperties().getItem(intLoop);
 // Because Value is the default property of a
 // Field object, the use of the actual keyword
 // here is optional.
 strMessage = "\t" + prpLoop.getName() + " = ";
 varPropertyValue = prpLoop.getValue();
 short vttype =varPropertyValue.getvt();
 switch (vttype)
 {
 case Variant.VariantBoolean :
 {
 if (varPropertyValue.getBoolean())
 strMessage +="True";
 else
 strMessage +="False";
 }
 break;
 case Variant.VariantInt :
 strMessage += varPropertyValue.getInt();
 break;
 default :
 break;
 }
 System.out.println(strMessage);
 intCount++;
 // Loop used to display records
 if (intCount % 15 == 0)
 {
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 intCount = 0;
 }

 }
 // Cleanup objects before exit.
 rstEmployees.close();
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 }
 // System read requires this catch.
 catch(java.io.IOException je)
 {
 PrintIOError(je);
 }
 catch(AdoException ae)
 {
 // Notify the user of any errors that result from ADO.

 // As passing a recordset, check for null pointer first.
 if(rstEmployees != null)
 {
 PrintProviderError(rstEmployees.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstEmployees != null)
 if (rstEmployees.getState() == 1)
 rstEmployees.close();
 }

 }
 // PrintProviderError Function
 static void PrintProviderError(Connection cnn1)
 {
 // Print Provider Errors from Connection Object.
 // ErrItem is an item object in the Connections Errors Collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if ( nCount > 0)
 {
 // Collection ranges from 0 to nCount-1.
 for ( i=0;i<nCount; i++)
 {
 ErrItem = cnn1.getErrors().getItem(i);
 System.out.println("\t Error Number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription());
 }
 }
 }
 // PrintIOError Function
 static void PrintIOError(java.io.IOException je)
 {
 System.out.println("Error: \n");
 System.out.println("\t Source: " + je.getClass() + "\n");
 System.out.println("\t Description: "+ je.getMessage() + "\n");
 }
}
// EndValueJ


LookupRecord Data Block (Access 2013 custom web app)

 Copy code hover
[image]

LookupRecord Data Block (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

A LookupRecord data block performs a set of actions on a specific record.

Note Note

The LookupRecord data block is available only in Data Macros.

Setting

The SetField action has the following arguments.

Argument | Required | Description
In | Yes | A string that identifies the record to operate on. The In argument can contain the name of the table, a select query, or a SQL statement.
Where Condition | No | A string expression used to restrict the range of data on which the LookupRecord data block is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the LookupRecord data block operates on the entire domain specified by the In argument. Any field that is included in criteria must also be a field in In.
Alias | No | A string that provides an alternative name for the record specified by the In argument. Often used to shorten the table name for subsequent references to prevent possible ambiguous references. If Alias is not specified, the table or query name will be used as the alias.

Remarks

If the criteria specified by the In and Where Condition arguments specifies more than one record, then the LookupRecord data block will only operate on the first record.

If no record satisfies Where Condition or if In contains no records, then LookupRecord creates a blank record in which all of the fields contain a Null value.


BoundObjectFrame.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

BoundObjectFrame.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified frame. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleLeft

expression A variable that represents a BoundObjectFrame object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


NavigationButton.TabIndex Property (Access)

 Copy code hover
[image]

NavigationButton.TabIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .TabIndex

expression A variable that represents a NavigationButton object.

Remarks

You can set the TabIndex property to an integer representing the position of the control within the tab order of the form. Valid settings are 0 for the first tab position, up to the total number of controls minus 1 for the last tab position. For example, if a form has three controls that each have a TabIndex property, valid TabIndex property settings are 0, 1, and 2.

Setting the TabIndex property to an integer less than 0 produces an error.

By default, Microsoft Access assigns a tab order to controls in the order that you create them on a form. Each new control is placed last in the tab order. If you change the setting of a control's TabIndex property to adjust the tab order, Microsoft Access automatically renumbers the TabIndex property setting of other controls to reflect insertions and deletions.

In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the TAB key.

Changing the tab order of other controls on the form doesn't affect what happens when you press a control's access key. For example, if you've created an access key for the label of a text box, the focus will move to the text box whenever you press the label's access key — even if you change the TabIndex property setting for the text box.

If you press an access key for a control such as a label that doesn't have a TabIndex property (and thus isn't in the tab order), the focus moves to the next control in the tab order that can receive the focus.

Example

The following example reverses the tab order of a command button and a text box. Because TextBox1 was created first, it has a TabIndex property setting of 0 and Command1 has a setting of 1.

VBA Copy code Copy code
Sub Form_Click()
 Me!Command1.TabIndex = 0
 Me!TextBox1.TabIndex = 1
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


DependencyObjects Members (Access)

 Copy code hover
[image]

DependencyObjects Members (Access)
Send feedback

Published: July 16, 2012

Represents the collection of AccessObject objects that a DependencyInfo object contains.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


EditRecord Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

EditRecord Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Places the current record into edit mode.

Syntax

EditRecord

Remarks

Use the SaveRecord action to save changes made to the record, or the UndoRecord action to discard the changes.

The EditRecord action is equivalent to selecting the Edit button on the action bar.


ComboBox.ListIndex Property (Access)

 Copy code hover
[image]

ComboBox.ListIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ListIndex property to determine which item is selected in a combo box. Read/write Long.

Syntax

expression .ListIndex

expression A variable that represents a ComboBox object.

Remarks

The ListIndex property is an integer from 0 to the total number of items in a list box or combo box minus 1. Microsoft Access sets the ListIndex property value when an item is selected in a list box or list box portion of a combo box. The ListIndex property value of the first item in a list is 0, the value of the second item is 1, and so on.

This property is available only by using a macro or Visual Basic . You can read this property only in Form view and Datasheet view. This property is read-only and isn't available in other views.

The ListIndex property value is also available by setting the BoundColumn property to 0 for a combo box or list box. If the BoundColumn property is set to 0, the underlying table field to which the combo box or list box is bound will contain the same value as the ListIndex property setting.

List boxes also have a MultiSelect property that allows the user to select multiple items from the control. When multiple selections are made in a list box, you can determine which items are selected by using the Selected property of the control. The Selected property is an array of values from 0 to the ListCount property value minus 1. For each item in the list box the Selected property will be True if the item is selected and False if it is not selected.

The ItemsSelected collection also provides a way to access data in the selected rows of a list box or combo box.

Link provided by: Community Member Icon Luke Chung, FMS, Inc. | About the Contributors

  • Tips and Techniques for Using and Validating Combo Boxes

About the Contributors

Luke Chung is the founder and president of FMS, Inc., a leading provider of custom database solutions and developer tools.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Handling Errors in JScript

 Copy code hover
[image]

Handling Errors in JScript
Send feedback

Your Microsoft JScript code must check the Count property of the Connection object's Errors collection. If the value is greater than 0, iterate through the collection and print the values as you would in any of the other languages.

Copy code Copy code

<!-- BeginErrorExampleJS -->
<%@ Language=JScript %>
<HTML>
<HEAD>
<title>Error Handling Example (JScript)</title>
</HEAD>
<BODY>
<h1>Error Handling Example (JScript)</h1>
<%
 var cnn1 = Server.CreateObject("ADODB.Connection");
 var errLoop = Server.CreateObject("ADODB.Error");
 var strError = new String;

 try
 {
 // Intentionally trigger an error.
 cnn1.Open("nothing");
 }
 catch(e)
 {
 Response.Write(e.message);
 }
%>

</BODY>
</HTML>
<!-- EndErrorExampleJS -->


CurrentData.AllQueries Property (Access)

 Copy code hover
[image]

CurrentData.AllQueries Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllQueries property to reference the AllQueries collection and its related properties. Read-only AllQueries object.

Syntax

expression .AllQueries

expression A variable that represents a CurrentData object.

See also

Concepts

CurrentData Object

Other resources

CurrentData Object Members


Cannot create relationships to enforce referential integrity. Existing data in table

 Copy code hover
[image]

Cannot create relationships to enforce referential integrity. Existing data in table <name> violates referential integrity rules in table <name>. (Error 3379)
Send feedback

You are trying to create a relationship using the CONSTRAINT clause of the ALTER TABLE statement, but existing data in the two tables violates referential integrity constraints. For example, there might be records relating to an employee in the related table but no corresponding record for the employee in the primary table.

To create the relationship, you must edit the data so that primary records exist for all related records.


EmptyCell.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

EmptyCell.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthLeft

expression A variable that represents an EmptyCell object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


Optimize Property--Dynamic (ADO)

 Copy code hover
[image]

Optimize Property--Dynamic (ADO)
Send feedback

Specifies whether an index should be created on a field.

Settings and Return Values

Sets or returns a Boolean value that indicates whether an index should be created.

Remarks

An index can improve the performance of operations that find or sort values in a Recordset. The index is internal to ADO — you cannot explicitly access or use it in your application.

To create an index on a field, set the Optimize property to True. To delete the index, set this property to False.

Optimize is a dynamic property appended to the Field object Properties collection when the CursorLocation property is set to adUseClient.

Usage

Copy code Copy code
Dim rs As New Recordset
Dim fld As Field
rs.CursorLocation = adUseClient      'Enable index creation
rs.Fields.Append "Field1", adChar, 35, adFldIsNullable
rs.Open
Set fld = rs.Fields(0)
fld.Properties("Optimize") = True    'Create an index
fld.Properties("Optimize") = False   'Delete an index


JScript ADO Programming

 Copy code hover
[image]

JScript ADO Programming
Send feedback

Creating an ADO Project

Microsoft JScript does not support type libraries, so you do not need to reference ADO in your project. Consequently, no associated features such as command line completion are supported. Also, by default, ADO enumerated constants are not defined in JScript.

However, ADO provides you with two include files containing the following definitions to be used with JScript:

  • For server-side scripting use Adojavas.inc, which is installed in the c:\Program Files\Common Files\System\ado\ folder by default.

  • For client-side scripting use Adcjavas.inc, which is installed in the c:\Program Files\Common Files\System\msdac\ folder by default.

You can either copy and paste constant definitions from these files into your ASP pages, or, if you are doing server-side scripting, copy Adojavas.inc file to a folder on your Web site and references it from your ASP page like this:

Copy code Copy code

<!--#include File="adojavas.inc"-->

Creating ADO Objects in JScript

You must instead use the CreateObject function call:

Copy code Copy code

var Rs1;
Rs1 = Server.CreateObject("ADODB.Recordset");

JScript Example

The following code is a generic example of JScript server-side programming in an Active Server Page (ASP) file that opens a Recordset object:

Copy code Copy code

<%  @LANGUAGE="JScript" %>
<!--#include File="adojavas.inc"-->
<HTML>
<BODY BGCOLOR="White" topmargin="10" leftmargin="10">
<%
var Source = "SELECT * FROM Authors";
var Connect =  "Provider=sqloledb;Data Source=srv;" +
    "Initial Catalog=Pubs;Integrated Security=SSPI;"
var Rs1 = Server.CreateObject( "ADODB.Recordset.2.5" );
Rs1.Open(Source,Connect,adOpenForwardOnly);
Response.Write("Success!");
%>
</BODY>
</HTML>


ListBox.OnMouseDown Property (Access)

 Copy code hover
[image]

ListBox.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Syntax

expression .OnMouseDown

expression A variable that represents a ListBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


CheckBox.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

CheckBox.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified check box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleBottom

expression A variable that represents a CheckBox object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


TextBox.OnMouseDown Property (Access)

 Copy code hover
[image]

TextBox.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Syntax

expression .OnMouseDown

expression A variable that represents a TextBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


The table name

 Copy code hover
[image]

The table name <name> in the partial filter expression is invalid. (Error 3481)
Send feedback

Make sure you are using the correct table name in the expression.


ObjectFrame.Visible Property (Access)

 Copy code hover
[image]

ObjectFrame.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents an ObjectFrame object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


TextBox.OnExit Property (Access)

 Copy code hover
[image]

TextBox.OnExit Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnExit

expression A variable that represents a TextBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Exit event occurs just before a control loses the focus to another control on the same form.

The OnExit value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Exit box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Exit box is blank, the property value is an empty string.

Example

The following example associates the Exit event with the macro "Exit_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnExit = "Exit_Macro"

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Label.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

Label.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Syntax

expression .ShortcutMenuBar

expression A variable that represents a Label object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

Example

The following example sets the "Suppliers_Toolbar" as the custom shortcut menu to display when the user clicks the right mouse button on the "Suppliers" form.

VBA Copy code Copy code
Forms("Suppliers").ShortcutMenuBar = "Suppliers_Toolbar"

See also

Concepts

Label Object

Other resources

Label Object Members


Operation invalid without a current index. (Error 3019)

 Copy code hover
[image]

Operation invalid without a current index. (Error 3019)
Send feedback

Set the Index, and then try the operation again.


ToggleButton.ObjectPalette Property (Access)

 Copy code hover
[image]

ToggleButton.ObjectPalette Property (Access)
See also Send feedback

Published: July 16, 2012

The ObjectPalette property specifies the palette in the application used to create A bitmap or other graphic that is loaded into the specified control by using the Picture property. Read/write Variant.

Syntax

expression .ObjectPalette

expression A variable that represents a ToggleButton object.

Remarks

Microsoft Access sets the value of the ObjectPalette property to a String data type containing the palette information. You can use this setting to set the value of the PaintPalette property for a form or report.

If the application associated with the bitmap or other graphic doesn't have an associated palette, the ObjectPalette property is set to an zero-length string.

The ObjectPalette property is read-only in Form Design view, Form view, and Report Design view. This property setting is unavailable in other views.

The setting of the ObjectPalette property makes the palette of the application associated with the OLE object contained in a control available to the PaintPalette property of a form or report. For example, to make the palette used in Microsoft Graph available when you're designing a form in Microsoft Access, you set the form's PaintPalette property to the ObjectPalette value of an existing chart control.

Note Note

Windows can have only one color palette active at a time. Microsoft Access allows you to have multiple graphics on a form, each using a different color palette. The PaintPalette and PaletteSource properties let you specify which color palette a form should use when displaying graphics.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Understanding Recordset Structure

 Copy code hover
[image]

Understanding Recordset Structure
Send feedback

Every Recordset has a Fields collection consisting of one or more Field objects. A Field object usually represents a table column. The following topics will explain how to navigate through the Fields collection and get information about each field. Then they will discuss what kind of information is available to you via the Field object and how to use it.

  • The Fields Collection

  • The Field Object

  • Working with Recordsets


TextBox Properties (Access)

 Copy code hover
[image]

TextBox Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
AllowAutoCorrect | You can use the AllowAutoCorrect property to specify whetherthe specified control will automatically correct entries made by the user. Read/write Boolean.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AsianLineBreak | Returns or sets a Boolean indicating whether line breaks in text boxes follow rules governing East Asian languages. True to control line breaks based on East Asian language rules. Read/write.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
AutoTab | You can use the AutoTab property to specify whether an automatic tab occurs when the last character permitted by a text box control's input mask is entered. An automatic tab moves the focus to the next control in the form's tab order. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomMargin | Along with the LeftMargin, RightMargin, and TopMargin properties, specifies the location of information displayed within a text box control. Read/write Integer.
BottomPadding | Gets or sets the amount of space (in inches) between the text box and its bottom gridline. Read/write Integer.
CanGrow | Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the control contains. Read/write Boolean.
CanShrink | Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the section or control contains. Read/write Boolean.
ColumnHidden | You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.
ColumnOrder | You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.
ColumnWidth | You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DecimalPlaces | You can use the DecimalPlaces property to specify the number of decimal places Microsoft Access uses to display numbers. Read/write Byte.
DefaultValue | Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.
DisplayAsHyperlink | Gets or sets an AcDisplayAsHyperlink constant that specifies whether to display the contents of the specified text box as a hyperlink. Read/write.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EnterKeyBehavior | You can use the EnterKeyBehavior property to specify what happens when you press ENTER in a text box control in Form view or Datasheet view. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FilterLookup | You can use the FilterLookup property to specify whether values appear in a bound text box control when using the Filter By Form or Server Filter By Form window. Read/write Byte.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontName | You can use the FontName property to specify the font for text in the following situations:
FontSize | You can use the FontSize property to specify the point size for text in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
FontWeight | You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
ForeShade | Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
ForeThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.
ForeTint | Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
Format | You can use the Format property to customize the way numbers, dates, times, and text are displayed and printed. Read/write String.
FormatConditions | You can use the FormatConditions property to return a read-only reference to the FormatConditions collection and its related properties.
FuriganaControl |
GridlineColor | Gets or sets the color of the gridline for the specified text box. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified text box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified text box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified text box. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified text box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified text box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified text box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HideDuplicates | You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the text box is anchored horizontally within its layout. Read/write.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
IMEHold | Language-specific information You can use the IMEHold/Hold KanjiConversionMode property to show whether the Kanji Conversion Mode is maintained when the control loses the focus. Read/write Boolean.
IMEMode |
IMESentenceMode |
InputMask | You can use the InputMask property to make data entry easier and to control the values users can enter in a text boxcontrol. Read/write String.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsHyperlink | You can use the IsHyperlink property to specify or determine if the data contained in a text box is a hyperlink. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
KeyboardLanguage |
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified text box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified text box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftMargin | Along with the TopMargin, RightMargin, and BottomMargin properties. specifies the location of information displayed within a text box control. Read/write Integer. .
LeftPadding | Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.
LineSpacing | You can use the LineSpacing property to specify or determine the location of information displayed within a label or text box control. Read/write Integer.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
NumeralShapes |
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnChange | Sets or returns the value of the On Change box in the Properties window of one of the objects in the Applies To list. Read/write String.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnDirty | Sets or returns the value of the On Dirty box in the Properties window of a form or report. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnUndo | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the Undo event occurs. Read/write..
Parent | Returns the parent object for the specified object. Read-only.
PostalAddress | You can use the PostalAddress Property property to specify or determine the postal code and the Customer Barcode data corresponding to the address information displayed in a specified field/textbox. The PostalAddress Property wizard enables the setting of these properties. Read/write String.
Properties | Returns a reference to a control's Properties collection object. Read-only.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
RightMargin | Along with the TopMargin, Left Margin, and BottomMargin properties, specifies the location of information displayed within text box control. Read/write Integer.
RightPadding | Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.
RunningSum | You can use the RunningSum property to calculate record-by-record or group-by-group totals in a report. Read/write Byte.
ScrollBarAlign | You can use the ScrollBarAlign to specify or determine the alignment of a vertical scroll bar. Read/write Byte.
ScrollBars | You can use the ScrollBars property to specify whether scroll bars appear on a text box control. Read/write Byte.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
SelLength | The SelLength property specifies or determines the number of characters selected in a text box. Read/write Integer.
SelStart | The SelStart property specifies or determines the starting point of the selected text or the position of the insertion point if no text is selected. Read/write Integer.
SelText | The SelText property returns a string containing the selected text. Read/write String.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
ShowDatePicker | Gets or sets whether the date picker control is displayed for the specified text box. Read/write Integer.
SmartTags | Returns a SmartTags collection that represents the collection of smart tags that have been added to a control. .
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Text | You can use the Text property to set or return the text contained in a text box. Read/write String.
TextAlign | The TextAlign property specifies the text alignment in new controls. Read/write Byte.
TextFormat | Gets or sets whether rich text is displayed in the specified text box. Read/write AcTextFormat.
ThemeFontIndex | Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopMargin | Along with the LeftMargin, RightMargin, and BottomMargin properties, specifies the location of information displayed within a text box control. Read/write Integer.
TopPadding | Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.
ValidationRule | You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.
ValidationText | Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.
Value | Determines or specifies the text in the text box. Read/write Variant.
Vertical | You can use the Vertical property to set a form control for vertical display and editing or set a report control for vertical display and printing. Read/write Boolean.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified text box is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


OptionButton.TopPadding Property (Access)

 Copy code hover
[image]

OptionButton.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the option button and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .TopPadding

expression A variable that represents an OptionButton object.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


DoCmd.RefreshRecord Method (Access)

 Copy code hover
[image]

DoCmd.RefreshRecord Method (Access)
See also Send feedback

Published: July 16, 2012

The RefreshRecord method performs the RefreshRecord macro operation from Visual Basic.

Version Information

Version Added: Access 2010

Syntax

expression .RefreshRecord

expression A variable that represents a DoCmd object.

Remarks

In a client database, the RefreshRecord method is equivalent to the Refresh method of the Form object. In a web database, see the RefreshRecord macro action.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Ensuring Sufficient TempDB Space

 Copy code hover
[image]

Ensuring Sufficient TempDB Space
Send feedback

If errors occur while handling Recordset objects that need processing space on Microsoft SQL Server 6.5, you may need to increase the size of the TempDB. (Some queries require temporary processing space; for example, a query with an ORDER BY clause requires a sort of the Recordset, which requires some temporary space.)

Important note Important

Read through this procedure before performing the actions because it isn't as easy to shrink a device once it is expanded.
Note Note

By default in Microsoft SQL Server 7.0 and later, TempDB is set to automatically grow as needed. Therefore, this procedure may only be necessary on servers running versions earlier than 7.0.

To increase the TempDB space on SQL Server 6.5

  1. Start Microsoft® SQL Server Enterprise Manager, open the tree for the Server, and then open the Database Devices tree.

  2. Select a (physical) device to expand, such as Master, and double-click the device to open the Edit Database Device dialog box. This dialog box shows how much space the current databases are using.

  3. In the Size box, increase the device to the desired amount (for example, 50 megabytes (MB) of hard disk space).

  4. Click Change Now to increase the amount of space to which the (logical) TempDB can expand.

  5. Open the Databases tree on the server, and then double-click TempDB to open the Edit Database dialog box. The Database tab lists the amount of space currently allocated to TempDB (Data Size). By default, this is 2 MB.

  6. Under the Size group, click Expand. The graphs show the available and allocated space on each of the physical devices. The bars in maroon color represent available space.

  7. Select a Log Device, such as Master, to display the available size in the Size (MB) box.

  8. Click Expand Now to allocate that space to the TempDB database. The Edit Database dialog box displays the new allocated size for TempDB.

For more information about this topic, search the Microsoft SQL Server Enterprise Manager Help file for "Expand Database dialog box."


Report.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

Report.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Syntax

expression .ShortcutMenuBar

expression A variable that represents a Report object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

Example

The following example sets the "Suppliers_Toolbar" as the custom shortcut menu to display when the user clicks the right mouse button on the "Suppliers" form.

VBA Copy code Copy code
Forms("Suppliers").ShortcutMenuBar = "Suppliers_Toolbar"

See also

Concepts

Report Object

Other resources

Report Object Members


DoCmd.ClearMacroError Method (Access)

 Copy code hover
[image]

DoCmd.ClearMacroError Method (Access)
See also Send feedback

Published: July 16, 2012

Removes information about an error that is stored in the MacroError object.

Version Information

Version Added: Access 2007

Syntax

expression .ClearMacroError

expression A variable that represents a DoCmd object.

Remarks

When an error occurs in a macro, information about the error is stored in the MacroError object. If you have not used the OnError action to suppress error messages, the macro stops and the error information is displayed in a standard error message. However, if you have used the OnError action to suppress error messages, you may want to use the information stored in the MacroError object in a condition or a custom error message.

After an error has been handled, the information in the MacroError object is out of date, so it is a good idea to clear the object using the ClearMacroError action. This resets the error number in the MacroError object back to zero, and clears any other information about the error that is stored in the object, such as the error description, macro name, action name, condition, and arguments. This way, you can inspect the MacroError object again later to see if another error has occurred.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


MoveRecordOptionsEnum

 Copy code hover
[image]

MoveRecordOptionsEnum
Send feedback

Specifies the behavior of the Record object MoveRecord method.

Constant | Value | Description
adMoveUnspecified | -1 | Default. Performs the default move operation: The operation fails if the destination file or directory already exists, and the operation updates hypertext links.
adMoveOverWrite | 1 | Overwrites the destination file or directory, even if it already exists.
adMoveDontUpdateLinks | 2 | Modifies the default behavior of MoveRecord method by not updating the hypertext links of the source Record. The default behavior depends on the capabilities of the provider. Move operation updates links if the provider is capable. If the provider cannot fix links or if this value is not specified, then the move succeeds even when links have not been fixed.
adMoveAllowEmulation | 4 | Requests that the provider attempt to simulate the move (using download, upload, and delete operations). If the attempt to move the Record fails because the destination URL is on a different server or serviced by a different provider than the source, this may cause increased latency or data loss, due to different provider capabilities when moving resources between providers.

ADO/WFC Equivalent

These constants do not have ADO/WFC equivalents.


ComboBox.ControlType Property (Access)

 Copy code hover
[image]

ComboBox.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Syntax

expression .ControlType

expression A variable that represents a ComboBox object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


How to: Find the Number of Working Days Between Two Dates

 Copy code hover
[image]

How to: Find the Number of Working Days Between Two Dates
Send feedback

Microsoft Access does not have a built-in function to determine the number of working days between two dates. The following user-defined function illustrates how to calculate the number of working days between two dates.

Note Note

This function does not account for holidays.
VBA Copy code Copy code
Function Work_Days(BegDate As Variant, EndDate As Variant) As Integer

 Dim WholeWeeks As Variant
 Dim DateCnt As Variant
 Dim EndDays As Integer

 On Error GoTo Err_Work_Days

 BegDate = DateValue(BegDate)
 EndDate = DateValue(EndDate)
 WholeWeeks = DateDiff("w", BegDate, EndDate)
 DateCnt = DateAdd("ww", WholeWeeks, BegDate)
 EndDays = 0

 Do While DateCnt <= EndDate
 If Format(DateCnt, "ddd") <> "Sun" And _
 Format(DateCnt, "ddd") <> "Sat" Then
 EndDays = EndDays + 1
 End If
 DateCnt = DateAdd("d", 1, DateCnt)
 Loop

 Work_Days = WholeWeeks * 5 + EndDays

Exit Function

 Err_Work_Days:

 ' If either BegDate or EndDate is Null, return a zero
 ' to indicate that no workdays passed between the two dates.

 If Err.Number = 94 Then
 Work_Days = 0
 Exit Function
 Else
' If some other error occurs, provide a message.
 MsgBox "Error " & Err.Number & ": " & Err.Description
 End If

End Function


SingleStep Macro Action

 Copy code hover
[image]

SingleStep Macro Action
Send feedback

You can use the SingleStep action to pause macro execution and open the Macro Single Step dialog box.

Setting

The SingleStep action does not have any arguments.

Remarks

  • Use the SingleStep action to troubleshoot a macro that is not working properly. You can add the SingleStep action to a macro just before an action that you suspect may be the cause of the problem. The action pauses the macro and opens the Macro Single Step dialog box. This dialog box displays information about the current macro action, such as the macro name, any specified conditions, the action name, arguments, and the error number, if applicable. In the dialog box, you can click Step to advance to the next macro action, Stop All Macros to stop the current macro and any other macros that are running, or Continue to stop single stepping and resume normal operation of the macro.

  • The SingleStep action has a similar effect to clicking Single Step in the Tools group on the Design tab of the Macro Builder. The difference between doing this and running the SingleStep action is that by running the action, you can place the action in the macro exactly where you want single stepping to begin. That way, you don't have to step through all the previous actions to get to the one you want to examine. On the other hand, when you click Single Step in the Macro Builder, you must do so before running the macro. In that case, single stepping begins at the first action in the macro.

Note Note

If you single-step all the way to the end of a macro without clicking Continue, single stepping will still be in effect when the macro ends. Any subsequent macro you run will start in single step mode. To turn off single stepping, either click Continue in the Macro Single Step dialog box, or, with a macro open in Design view, on the Design tab, in the Tools group, click Single Step so that it is no longer selected.


Custom Methods and Properties

 Copy code hover
[image]

Custom Methods and Properties
Send feedback

You can use a class module to create a definition for a new custom object. When you create a new instance of a class, you create a new object and return a reference to it.

Any public procedures defined within the class module become methods of the new object. The Sub statement defines a method that doesn't return a value; the Function statement defines a method that may return a value of a specified type.

Any Property Let, Property Get or Property Set procedures you define become properties of the new object. Property Get procedures retrieve the value of a property. Property Let procedures set the value of a nonobject property. Property Set procedures set the value of an object property.

For example, you can use a class module to create an interface layer between your application and a set of Windows application programming interface (API) functions that it calls. To do this, you create a set of simple procedures that call more complicated procedures in a DLL. When you create an instance of this class, the procedures you've created become methods of the new object. You can apply these methods as you would the methods of any object, and in doing so you also call the API functions.


ObjectFrame.TabStop Property (Access)

 Copy code hover
[image]

ObjectFrame.TabStop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.

Syntax

expression .TabStop

expression A variable that represents an ObjectFrame object.

Remarks

This property doesn't apply to toggle button controls when they appear in an option group. It applies only to the option group itself.

The TabStop property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) You can move the focus to the control by pressing the TAB key.
No | False | You can't move the focus to the control by pressing the TAB key.

When you create a control on a form, Microsoft Access automatically assigns the control a position in the form's tab order. Each new control is placed last in the tab order. If you want to prevent a control from being available when you tab through the controls in a form, set the control's TabStop property to No.

In Form view, hidden or disabled controls remain in the tab order but are skipped when you move through the controls by pressing TAB, even if their TabStop properties are set to Yes.

As long as a control's Enabled property is set to Yes, you can click the control or use an access key to select it, regardless of its TabStop property setting. For example, you can set the TabStop property of a command button to No to prevent users from selecting the button by pressing TAB. However, they can still click the command button to choose it.

Example

The following example disables the ability to move the focus to the "City" text box on the "Suppliers" form by using the TAB key.

VBA Copy code Copy code
Forms("Suppliers").Controls("City").TabStop = False

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Invalid reference in SELECT statement. (Error 3242)

 Copy code hover
[image]

Invalid reference in SELECT statement. (Error 3242)
Send feedback

You entered an invalid field or table reference in the SELECT statement. For example, the reference may be misspelled or does not exist.


CheckBox.TabStop Property (Access)

 Copy code hover
[image]

CheckBox.TabStop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.

Syntax

expression .TabStop

expression A variable that represents a CheckBox object.

Remarks

This property doesn't apply to toggle button controls when they appear in an option group. It applies only to the option group itself.

The TabStop property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) You can move the focus to the control by pressing the TAB key.
No | False | You can't move the focus to the control by pressing the TAB key.

When you create a control on a form, Microsoft Access automatically assigns the control a position in the form's tab order. Each new control is placed last in the tab order. If you want to prevent a control from being available when you tab through the controls in a form, set the control's TabStop property to No.

In Form view, hidden or disabled controls remain in the tab order but are skipped when you move through the controls by pressing TAB, even if their TabStop properties are set to Yes.

As long as a control's Enabled property is set to Yes, you can click the control or use an access key to select it, regardless of its TabStop property setting. For example, you can set the TabStop property of a command button to No to prevent users from selecting the button by pressing TAB. However, they can still click the command button to choose it.

Example

The following example disables the ability to move the focus to the "City" text box on the "Suppliers" form by using the TAB key.

VBA Copy code Copy code
Forms("Suppliers").Controls("City").TabStop = False

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Internet synchronizer exited unexpectedly. (Error 3683)

 Copy code hover
[image]

Internet synchronizer exited unexpectedly. (Error 3683)
Send feedback

The internet server replied with an invalid response. Retry the operation.


How to: Synchronize a DAO Recordset's Record with a Form's Current Record

 Copy code hover
[image]

How to: Synchronize a DAO Recordset's Record with a Form's Current Record
Send feedback

The following code example uses the RecordsetClone property and the Recordset object to synchronize a recordset's record with the form's current record. When a company name is selected from a combo box, the FindFirst method is used to locate the record for that company and the Recordset object's Bookmark property is assigned to the form's Bookmark property, causing the form to display the found record.

VBA Copy code Copy code
Sub SupplierID_AfterUpdate()
    Dim rst As Recordset
    Dim strSearchName As String

    Set rst = Me.RecordsetClone
    strSearchName = Str(Me!SupplierID)
    rst.FindFirst "SupplierID = " & strSearchName
        If rst.NoMatch Then
            MsgBox "Record not found"
        Else
            Me.Bookmark = rst.Bookmark
        End If
    rst.Close
End Sub


RDS Properties

 Copy code hover
[image]

RDS Properties
Send feedback
Connect (RDS) | Indicates the database name from which the query and update operations are run.
ExecuteOptions (RDS) | Indicates whether asynchronous execution is enabled.
FetchOptions (RDS) | Indicates the type of asynchronous fetching.
FilterColumn (RDS) | Indicates the column on which to evaluate the filter criteria.
FilterCriterion (RDS) | Indicates the evaluation operator to use in the filter value.
FilterValue (RDS) | Indicates the value to filter records.
Handler (RDS) | Indicates the name of a server-side customization program (handler) that extends the functionality of the RDSServer.DataFactory, and any parameters used by the handler.
InternetTimeout (RDS) | Indicates the number of milliseconds to wait before a request times out.
ReadyState (RDS) | Indicates the progress of a DataControl object as it fetches data into its Recordset object.
Recordset and SourceRecordset (RDS) | Indicates the Recordset object returned from a custom business object.
Server (RDS) | Indicates the Internet Information Services (IIS) name and communication protocol.
SortColumn (RDS) | Indicates by which column to sort the records.
SortDirection (RDS) | Indicates whether a sort order is ascending or descending.
SQL (RDS) | Indicates the query string used to retrieve the Recordset.
URL (RDS) | Indicates a string that contains a relative or absolute URL.


ListBox.ControlType Property (Access)

 Copy code hover
[image]

ListBox.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Syntax

expression .ControlType

expression A variable that represents a ListBox object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Error

 Copy code hover
[image]

Error <error text> in validation rule. (Error 3405)
Send feedback

The expression cannot be evaluated correctly for the reason given in the alert. For example, if the error text is "Type Mismatch," the property setting does not match the data type defined for the field.


TabControl.Application Property (Access)

 Copy code hover
[image]

TabControl.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a TabControl object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


The size of the Registry parameter exceeds the maximum allowed. (Error 3552)

 Copy code hover
[image]

The size of the Registry parameter exceeds the maximum allowed. (Error 3552)
Send feedback

Each parameter in the Microsoft Windows Registry has a maximum size. The setting you attempted to use exceeded the allowed maximum. Check the size limitation for the parameter you are setting.


ListBox.ControlSource Property (Access)

 Copy code hover
[image]

ListBox.ControlSource Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.

Syntax

expression .ControlSource

expression A variable that represents a ListBox object.

Remarks

The ControlSource property uses the following settings.

Setting | Description
A field name | The control is bound to a field in a table, query, or SQL statement. Data from the field is displayed in the control. Changes to the data inside the control change the corresponding data in the field. (To make the control read-only, set the Locked property to Yes.) If you click a control bound to a field that has a Hyperlink data type, you jump to the destination specified in the hyperlink address.
An expression | The control displays data generated by an expression. This data can be changed by the user but isn't saved in the database.

For reports, the ControlSource property applies only to report group levels.

Forms and reports act as "windows" into your database. You specify the primary source of data for a form or report by setting its RecordSource property to a table, query, or SQL statement. You can then set the ControlSource property to a field in the source of data or to an expression. If the ControlSource property setting is an expression, the value displayed is read-only and not saved in the database. For example, you can use the following settings.

Sample setting | Description
LastName | For a control, data from the LastName field is displayed in the control. For a report group level, Microsoft Access groups the data on last name.
=Date( ) + 7 | For a control, this expression displays a date seven days from today in the control.
=DatePart("q",ShippedDate) | For a control, this expression displays the quarter of the shipped date. For a report group level, Microsoft Access groups the data on the quarter of the shipped date.

Example

The following example sets the ControlSource property for a text box named AddressPart to a field named City:

VBA Copy code Copy code
Forms!Customers!AddressPart.ControlSource = "City"

The next example sets the ControlSource property for a text box named Expected to the expression =Date() + 7

VBA Copy code Copy code
Me!Expected.ControlSource = "=Date() + 7"

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Table

 Copy code hover
[image]

Table <name> could not be made replicable because it could not be opened exclusively. (Error 3767)
Send feedback

Close any open instance of the table that you are attempting to replicate and then try again.


Connection (Visual C++ Syntax Index with #import)

 Copy code hover
[image]

Connection (Visual C++ Syntax Index with #import)
Send feedback

Methods

Copy code Copy code

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthadocancel_HV10294125.xml( );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthclose_HV10294173.xml( );

_RecordsetPtr Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcnnexecute_HV10294345.xml( _bstr_t CommandText, VARIANT *
 RecordsAffected, long Options );

long Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthbegintrans_HV10294108.xml( );
HRESULT CommitTrans( );
HRESULT RollbackTrans( );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcnnopen_HV10294563.xml( _bstr_t ConnectionString, _bstr_t UserID,
 _bstr_t Password, long Options );

_RecordsetPtr Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthopenschema_HV10294568.xml( enum SchemaEnum Schema, const
 _variant_t & Restrictions = vtMissing, const _variant_t &
 SchemaID =vtMissing);

Properties

Copy code Copy code

_bstr_t GetConnectionString( );
void PutConnectionString( _bstr_t pbstr );
__declspec(property(get=GetConnectionString,put=PutConnectionString))
 _bstr_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdproconnectionstring_HV10294218.xml;

long GetCommandTimeout( );
void PutCommandTimeout( long plTimeout );
__declspec(property(get=GetCommandTimeout,put=PutCommandTimeout)) long
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocommandtimeout_HV10294196.xml;

long GetConnectionTimeout( );
void PutConnectionTimeout( long plTimeout );
__declspec(property(get=GetConnectionTimeout,put=PutConnectionTimeout))
 long Invalid DDUE based on source, error:link not allowed in code, link filename:mdproconnectiontimeout_HV10294222.xml;

_bstr_t GetVersion( );
__declspec(property(get=GetVersion)) _bstr_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdproversion_HV10294926.xml;

ErrorsPtr GetErrors( );
__declspec(property(get=GetErrors)) ErrorsPtr Invalid DDUE based on source, error:link not allowed in code, link filename:mdcolerrors_HV10294338.xml;

_bstr_t GetDefaultDatabase( );
void PutDefaultDatabase( _bstr_t pbstr );
__declspec(property(get=GetDefaultDatabase,put=PutDefaultDatabase))
 _bstr_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdprodefaultdatabase_HV10294288.xml;

enum IsolationLevelEnum GetIsolationLevel( );
void PutIsolationLevel( enum IsolationLevelEnum Level );
__declspec(property(get=GetIsolationLevel,put=PutIsolationLevel)) enum
 IsolationLevelEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdproisolationlevel_HV10294459.xml;

long GetAttributes( );
void PutAttributes( long plAttr );
__declspec(property(get=GetAttributes,put=PutAttributes)) long
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdproattributes_HV10294098.xml;

enum CursorLocationEnum GetCursorLocation( );
void PutCursorLocation( enum CursorLocationEnum plCursorLoc );
__declspec(property(get=GetCursorLocation,put=PutCursorLocation)) enum
 CursorLocationEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocursorlocation_HV10294254.xml;

enum ConnectModeEnum GetMode( );
void PutMode( enum ConnectModeEnum plMode );
__declspec(property(get=GetMode,put=PutMode)) enum ConnectModeEnum
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdpromode_HV10294518.xml;

_bstr_t GetProvider( );
void PutProvider( _bstr_t pbstr );
__declspec(property(get=GetProvider,put=PutProvider)) _bstr_t
 Invalid DDUE based on source, error:link not allowed in code, link filename:mdproprovider_HV10294673.xml;

long GetState( );
__declspec(property(get=GetState)) long Invalid DDUE based on source, error:link not allowed in code, link filename:mdprostate_HV10294804.xml;


Form.AfterRender Event (Access)

 Copy code hover
[image]

Form.AfterRender Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs after the object represented by the chartObject argument has been rendered.

Syntax

expression .AfterRender(drawObject, chartObject)

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
drawObject | Required | Object | A ChChartDraw object. Use the methods and properties of this object to draw objects on the chart.
chartObject | Required | Object | The object that has just been rendered. Use the TypeName function to determine what type of object has just been rendered.

Return Value

nothing

Example

The following example demonstrates the syntax for a subroutine that traps the AfterRender event.

VBA Copy code Copy code
Private Sub Form_AfterRender( _
 ByVal drawObject As Object, ByVal chartObject As Object)
 MsgBox TypeName(chartObject) & " has been rendered."
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


ListBox.Left Property (Access)

 Copy code hover
[image]

ListBox.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Syntax

expression .Left

expression A variable that represents a ListBox object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Set Form, Report, and Control Properties

 Copy code hover
[image]

Set Form, Report, and Control Properties
Send feedback

Each form, report, section, and control has property settings that you can change to alter the look or behavior of that particular item. You view and change properties by using the property sheet, macro, or Visual Basic.

To set properties

  1. In form Design view or report Design view, select the control, section, form, or report for which you want to set the property. You can select:

    • One or more controls. To select multiple controls, hold down the SHIFT key and click the controls, or drag the mouse pointer over the controls you wish to select. If you select multiple controls, the property sheet will display only those properties that the selected controls have in common.

    • One section. Click the section selector of the section you wish to select.

    • The entire form or report. Click the form selector or report selector in the upper-left corner of the form or report.

  2. Display the property sheet by right-clicking the object or section and then clicking Properties on the shortcut menu, or by clicking Properties on the toolbar.

  3. Click the property for which you want to set the value, and then do one of the following:

    • In the property box, type the appropriate setting or expression.

    • If the property box contains an arrow, click the arrow and then click a value in the list.

    • If a Build button appears to the right of the property box, click it to display a builder or to display a dialog box giving you a choice of builders. For example, you can use the Code Builder, Macro Builder, or Query Builder to set some properties.

Tips

  • Microsoft Access provides a Zoom box for typing and viewing expressions or other long property settings. To display the Zoom box, click a property box in the property sheet. Then press SHIFT+F2, or right-click and then click Zoom on the shortcut menu.

  • You can set the ControlSource property for some controls by typing the property setting in the control itself.

  • You can change the default property settings for a type of control so that future controls you create will have the new default settings.

  • The property settings of a bound control might not match the corresponding settings in the field in the underlying table or query to which the control is bound. If the settings are different, the form or report settings typically override those in the table or query. For more information about how properties are inherited, see How control properties relate to properties in their underlying fields.


BoundObjectFrame.DblClick Event (Access)

 Copy code hover
[image]

BoundObjectFrame.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Syntax

expression .DblClick(Cancel)

expression A variable that represents a BoundObjectFrame object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the DblClick event occurs. Setting the Cancel argument to True (-1) cancels the DblClick event.

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


CheckBox.GotFocus Event (Access)

 Copy code hover
[image]

CheckBox.GotFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The GotFocus event occurs when the specified object receives the focus.

Syntax

expression .GotFocus

expression A variable that represents a CheckBox object.

Remarks

To run a macro or event procedure when these events occur, set the OnGotFocus property to the name of the macro or to [Event Procedure].

These events occur when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The GotFocus event differs from the Enter event in that the GotFocus event occurs every time a control receives the focus. For example, suppose the user clicks a check box on a form, then clicks a report, and finally clicks the check box on the form to bring it to the foreground. The GotFocus event occurs both times the check box receives the focus. In contrast, the Enter event occurs only the first time the user clicks the check box. The GotFocus event occurs after the Enter event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Syntax error in Transaction statement. (Error 3708)

 Copy code hover
[image]

Syntax error in Transaction statement. (Error 3708)
Send feedback

When using transactions exclusively through the Microsoft Access database engine (not through an object model like DAO or ADO) the following syntax must be used: BEGIN/ROLLBACK TRANSACTION, WORK or nothing. If any other characters follow BEGIN or ROLLBACK, then this error will occur.


ToggleButton.SizeToFit Method (Access)

 Copy code hover
[image]

ToggleButton.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents a ToggleButton object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


LogEvent Macro Action

 Copy code hover
[image]

LogEvent Macro Action
Send feedback

The LogEvent action writes information to the USysApplicationLog system table.

Note Note

The LogEvent action is available only in Data Macros.

Setting

The LogEvent action has the following arguments.

Argument | Required | Description
Description | No | A string expression that describes the condition that you want to log. The description cannot exceed 255 characters.

Remarks

The LogEvent action can be used to write status information to the USysApplicationLog system table that does not merit using the RaiseError action to throw an error. For example, you could log changes to a specific field, or use the items written to the USysApplicationLog to assist you in debugging your macro.

When you use the LogEvent action to write to the USysApplicationLog table, the Category column is automatically set to User.

To see the USysApplicationLog table, use the following steps:

  1. Click the File menu,and then click Options.

  2. In the Access Options dialog box, click the Current Database tab.

  3. In the Navigation section, click Navigation Options.

  4. In the Navigation Options dialog box, click Show System Objects, and then click OK.

  5. Click OK to dismiss the Access Options dialog box.


EmptyCell.Tag Property (Access)

 Copy code hover
[image]

EmptyCell.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .Tag

expression A variable that represents an EmptyCell object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


NavigationButton.ControlType Property (Access)

 Copy code hover
[image]

NavigationButton.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .ControlType

expression A variable that represents a NavigationButton object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Persisting Filtered and Hierarchical Recordsets

 Copy code hover
[image]

Persisting Filtered and Hierarchical Recordsets
Send feedback

If the Filter property is in effect for the Recordset, only the rows accessible under the filter are saved. If the Recordset is hierarchical, the current child Recordset and its children are saved, including the parent Recordset. If the Save method of a child Recordset is called, the child and all its children are saved, but the parent is not. For more information about hierarchical Recordsets, see Chapter 9: Data Shaping.

Note Note

Some limitations apply when saving hierarchical Recordsets (data shapes) in XML format. For more information, see Hierarchical Recordsets in XML.


Property (Visual C++ Syntax Index with #import)

 Copy code hover
[image]

Property (Visual C++ Syntax Index with #import)
Send feedback

Properties

Copy code Copy code

long GetAttributes( );
void PutAttributes( long plAttributes );
__declspec(property(get=GetAttributes,put=PutAttributes)) long
 Invalid DDUE based on source, error:link not allowed in code, link filename:adproattributes_HV10294099.xml;

_bstr_t GetName( );
__declspec(property(get=GetName)) _bstr_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdproname_HV10294535.xml;

enum DataTypeEnum GetType( );
__declspec(property(get=GetType)) enum DataTypeEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdprotype_HV10294866.xml;

_variant_t GetValue( );
void PutValue( const _variant_t & pval );
__declspec(property(get=GetValue,put=PutValue)) _variant_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdprovalue_HV10294920.xml;


Update and CancelUpdate Methods Example (VC++)

 Copy code hover
[image]

Update and CancelUpdate Methods Example (VC++)
Send feedback

This example demonstrates the Update method in conjunction with the CancelUpdate method.

Copy code Copy code

// BeginUpdateCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <stdio.h>
#include <ole2.h>
#include <malloc.h>
#include <conio.h>
#include "UpdateX.h"

// Function Declartion.
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void UpdateX(void);
void UpdateX2(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 UpdateX();

 //Wait here for user to see the output..
 printf("\nPress any key to continue...");
 getch();

 //Clear the screen for the next display
 system("cls");

 UpdateX2();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// UpdateX Function //
// //
//////////////////////////////////////////////////////////
void UpdateX(void)
{
 HRESULT hr = S_OK;

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstEmployees = NULL;

 // Define string variables.
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 IADORecordBinding *picRs = NULL; // Interface Pointer declared
 CEmployeeRs emprs; // C++ Class object.

 try
 {
 // Open recordset with names from Employee table.
 TESTHR(pRstEmployees.CreateInstance(__uuidof(Recordset)));
 pRstEmployees->CursorType = adOpenKeyset;
 pRstEmployees->LockType = adLockOptimistic;
 pRstEmployees->Open("SELECT fname, lname FROM Employee "
 "ORDER BY lname",strCnn,adOpenKeyset,adLockOptimistic,
 adCmdText);

 // Store original data.
 _bstr_t strOldFirst = pRstEmployees->Fields->
 GetItem("fname")->Value;
 _bstr_t strOldLast = pRstEmployees->Fields->
 GetItem("lname")->Value;

 //Change data in edit buffer.
 pRstEmployees->Fields->GetItem("fname")->Value =
 (_bstr_t)("Linda");
 pRstEmployees->Fields->GetItem("lname")->Value =
 (_bstr_t)("Kobara");

 // Show contents of buffer and get user input.
 printf("\n\nEdit in progress:\n\n");

 printf("Original data = %s %s \n",
 (LPSTR)strOldFirst,(LPSTR)strOldLast);

 printf("Data in buffer = %s %s",
 (LPSTR)(_bstr_t) pRstEmployees->Fields->
 GetItem("fname")->Value, (LPSTR) (_bstr_t) pRstEmployees->Fields->
 GetItem("lname")->Value);

 // Ask if the User wants to Update
 printf("\n\nUse Update to replace the original data with the"
 " buffered data in the Recordset? (y/n): ");
 char chKey = getch();

 if(toupper(chKey) == 'Y')
 pRstEmployees->Update();
 else
 pRstEmployees->CancelUpdate();

 //Open an IADORecordBinding interface pointer which
 //we'll use for binding Recordset to a class.
 TESTHR(pRstEmployees->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 //Bind the Recordset to a C++ Class here.
 TESTHR(picRs->BindToRecordset(&emprs));

 pRstEmployees->MoveFirst();

 // Show the resulting data.
 printf("\nData in recordset = %s %s", emprs.le_fnameStatus ==
 adFldOK ? emprs.m_sze_fname : "<NULL>",
 emprs.le_lnameStatus == adFldOK ?
 emprs.m_sze_lname : "<NULL>");

 // Restore original data because this is a demonstration.
 if ((strcmp((char *)strOldFirst,emprs.m_sze_fname) &&
 strcmp((char *)strOldLast,emprs.m_sze_lname)))
 {
 pRstEmployees->Fields->GetItem("fname")->Value = strOldFirst;
 pRstEmployees->Fields->GetItem("lname")->Value = strOldLast;
 pRstEmployees->Update();
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstEmployees->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (pRstEmployees)
 if (pRstEmployees->State == adStateOpen)
 pRstEmployees->Close();
}

// The next example demonstrates the Update method
// in conjunction with the AddNew method.

//////////////////////////////////////////////////////////
// //
// UpdateX2 Function //
// //
//////////////////////////////////////////////////////////
void UpdateX2(void)
{
 HRESULT hr = S_OK;

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _ConnectionPtr pConnection = NULL;
 _RecordsetPtr pRstEmployees = NULL;

 // Define string variables.
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 IADORecordBinding *picRs = NULL; // Interface Pointer declared
 CEmployeeRs1 emprs; // C++ Class object.

 try
 {
 // Open a connection.
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
 pConnection->Open(strCnn,"","",NULL);

 // Open recordset with data from Employee table.
 TESTHR(pRstEmployees.CreateInstance(__uuidof(Recordset)));
 pRstEmployees->CursorType = adOpenKeyset;
 pRstEmployees->LockType = adLockOptimistic;
 pRstEmployees->Open("employee",
 _variant_t((IDispatch*)pConnection,true),
 adOpenKeyset, adLockOptimistic,adCmdTable);

 pRstEmployees->AddNew();
 _bstr_t strEmpID = "B-S55555M";
 pRstEmployees->Fields->GetItem("emp_id")->Value = strEmpID;
 pRstEmployees->Fields->GetItem("fname")->Value =
 (_bstr_t) ("Bill");
 pRstEmployees->Fields->GetItem("lname")->Value =
 (_bstr_t) ("Sornsin");

 // Show contents of buffer and get user input.
 printf("\n\nAddNew in progress:\n\n");

 printf("Data in buffer = %s , %s %s",
 (LPSTR) (_bstr_t) pRstEmployees->Fields->
 GetItem("emp_id")->Value,
 (LPSTR) (_bstr_t) pRstEmployees->Fields->
 GetItem("fname")->Value,
 (LPSTR) (_bstr_t) pRstEmployees->Fields->
 GetItem("lname")->Value);

 printf("\n\nUse Update to save buffer to recordset?(y/n):");
 char chKey = getch();

 if(toupper(chKey) == 'Y')
 {
 pRstEmployees->Update();

 //Open an IADORecordBinding interface pointer which
 //we'll use for binding Recordset to a class.
 TESTHR(pRstEmployees->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 //Bind the Recordset to a C++ Class here
 TESTHR(picRs->BindToRecordset(&emprs));

 // Go to the new record and show the resulting data.
 printf ("\n\nData in recordset = %s , %s %s",
 emprs.le_empidStatus == adFldOK ?
 emprs.m_sze_empid : "<NULL>",
 emprs.le_fnameStatus == adFldOK ?
 emprs.m_sze_fname : "<NULL>",
 emprs.le_lnameStatus == adFldOK ?
 emprs.m_sze_lname : "<NULL>");
 }
 else
 {
 pRstEmployees->CancelUpdate();
 printf("\n\nNo new record added.\n");
 }
 // Delete new data because this is a demonstration.
 _bstr_t strSQLDelete("DELETE FROM employee WHERE emp_id = '" +
 strEmpID + "'");
 pConnection->Execute(strSQLDelete ,NULL,adExecuteNoRecords);
 }

 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Connection.
 PrintProviderError(pConnection);
 PrintComError(e);
 }

 // Clean up objects before exit.
 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (pRstEmployees)
 if (pRstEmployees->State == adStateOpen)
 pRstEmployees->Close();
 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

//////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
//////////////////////////////////////////////////////////
void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

//////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
//////////////////////////////////////////////////////////
void PrintComError(_com_error &e)
{

 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndUpdateCpp

UpdateX.h

Copy code Copy code

// BeginUpdateH
#include "icrsint.h"

//This Class extracts only fname,lname from employee table.
class CEmployeeRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CEmployeeRs)
 // fname is the 1st field in the recordset
 ADO_VARIABLE_LENGTH_ENTRY2(1, adVarChar, m_sze_fname,
 sizeof(m_sze_fname), le_fnameStatus, FALSE)
 // lname is the 2nd field in the recordset.
 ADO_VARIABLE_LENGTH_ENTRY2(2, adVarChar, m_sze_lname,
 sizeof(m_sze_lname), le_lnameStatus, FALSE)

END_ADO_BINDING()

public:
 CHAR m_sze_lname[31];
 ULONG le_lnameStatus;
 CHAR m_sze_fname[21];
 ULONG le_fnameStatus;
};

//This Class extracts only empid,fname,lname,from employee table.
class CEmployeeRs1 : public CADORecordBinding
{
BEGIN_ADO_BINDING(CEmployeeRs1)
 // emp_id is the 1st field in the table.
 ADO_VARIABLE_LENGTH_ENTRY2(1, adVarChar, m_sze_empid,
 sizeof(m_sze_empid), le_empidStatus, FALSE)
 // fname is the 2nd field in the table.
 ADO_VARIABLE_LENGTH_ENTRY2(2, adVarChar, m_sze_fname,
 sizeof(m_sze_fname), le_fnameStatus, FALSE)
 // lname is the 4rt field in the table.
 ADO_VARIABLE_LENGTH_ENTRY2(4, adVarChar, m_sze_lname,
 sizeof(m_sze_lname), le_lnameStatus, FALSE)

END_ADO_BINDING()

public:
 CHAR m_sze_empid[10];
 ULONG le_empidStatus;
 CHAR m_sze_lname[31];
 ULONG le_lnameStatus;
 CHAR m_sze_fname[21];
 ULONG le_fnameStatus;
};
// EndUpdateH


CheckBox.OnClick Property (Access)

 Copy code hover
[image]

CheckBox.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Syntax

expression .OnClick

expression A variable that represents a CheckBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


TextBox.BackTint Property (Access)

 Copy code hover
[image]

TextBox.BackTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackTint

expression A variable that represents a TextBox object.

Remarks

The BackTint property contains a numeric expression that can be used to lighten the theme color in the BackColor property. The default value of the BackTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens BackColor by 75%.

VBA Copy code Copy code
Me.ctl.BackTint=25

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Cannot have aggregate function in GROUP BY clause

 Copy code hover
[image]

Cannot have aggregate function in GROUP BY clause <clause>. (Error 3098)
Send feedback

You cannot use an aggregate function in the GROUP BY clause of an SQL statement.


 Copy code hover
[image]

<Message> in expression. (Error 3077)
Send feedback

The expression you entered is not valid for the reason indicated in the message. Make sure you entered field names and punctuation correctly, and then try the operation again.


Section.OnMouseDown Property (Access)

 Copy code hover
[image]

Section.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Syntax

expression .OnMouseDown

expression A variable that represents a Section object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

Section Object

Other resources

Section Object Members


Invalid range. (Error 3181)

 Copy code hover
[image]

Invalid range. (Error 3181)
Send feedback

You attempted to import an invalid range of spreadsheet cells.


Form.DatasheetCellsEffect Property (Access)

 Copy code hover
[image]

Form.DatasheetCellsEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DatasheetCellsEffect property to specify whether special effects are applied to cells in a datasheet. Read/write Byte.

Syntax

expression .DatasheetCellsEffect

expression A variable that represents a Form object.

Remarks

The DatasheetCellsEffect property applies only to objects in Datasheet view.

This property is only available within a Microsoft Access database.

The DatasheetCellsEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | acEffectNormal | (Default) No special effects are applied to the cells in the datasheet.
Raised | acEffectRaised | Cells in the datasheet appear raised.
Sunken | acEffectSunken | Cells in the datasheet appear sunken.

This property applies the selected effect to the entire datasheet.

When this property is set to Raised or Sunken, gridlines will be visible on the datasheet regardless of the DatasheetGridlinesBehavior property setting.

The following table contains the properties that don't exist in the DAO Properties collection of until you set them by using the Formatting (Datasheet) toolbar or you can add them in an Access database (.mdb) by using the CreateProperty method and append it to the DAO Properties collection.

DatasheetFontItalic * | DatasheetForeColor *
DatasheetFontHeight * | DatasheetBackColor
DatasheetFontName * | DatasheetGridlinesColor
DatasheetFontUnderline * | DatasheetGridlinesBehavior
DatasheetFontWeight * | DatasheetCellsEffect
Note Note

When you add or set any property listed with an asterisk, Microsoft Access automatically adds all the properties listed with an asterisk to the Properties collection in the database.

See also

Concepts

Form Object

Other resources

Form Object Members


Rectangle.BorderColor Property (Access)

 Copy code hover
[image]

Rectangle.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Syntax

expression .BorderColor

expression A variable that represents a Rectangle object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


ComboBox.LabelX Property (Access)

 Copy code hover
[image]

ComboBox.LabelX Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelX

expression A variable that represents a ComboBox object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ObjectFrame.OnGotFocus Property (Access)

 Copy code hover
[image]

ObjectFrame.OnGotFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnGotFocus

expression A variable that represents an ObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The GotFocus event occurs when the object receives the focus.

The OnGotFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Got Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Got Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnGotFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnGotFocus

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Report.HelpContextId Property (Access)

 Copy code hover
[image]

Report.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Syntax

expression .HelpContextId

expression A variable that represents a Report object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

Report Object

Other resources

Report Object Members


Could not import table or query. No records found, or all records contain errors. (Error 3297)

 Copy code hover
[image]

Could not import table or query. No records found, or all records contain errors. (Error 3297)
Send feedback

The Microsoft Access database engine could not find the table or query you tried to import, or no records were found at the specified source, or all records contained errors. Check the path you specified and try it again.


NavigationControl.ControlTipText Property (Access)

 Copy code hover
[image]

NavigationControl.ControlTipText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .ControlTipText

expression A variable that represents a NavigationControl object.

Remarks

You set the ControlTipText property by using a string expression up to 255 characters long.

For controls on forms, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

You can set the ControlTipText property in any view.

The ControlTipText property provides an easy way to provide helpful information about controls on a form.

There are other ways to provide information about a form or a control on a form. You can use the StatusBarText property to display information in the status bar about a control. To provide more extensive help for a form or control, use the HelpFile and HelpContextID properties.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


AcImeSentenceMode Enumeration (Access)

 Copy code hover
[image]

AcImeSentenceMode Enumeration (Access)
Send feedback

Published: July 16, 2012

Insert introduction here.

Section Heading

Insert section body here.

Subsection Heading

Insert subsection body here.


Recordset2.ValidationText Property (DAO)

 Copy code hover
[image]

Recordset2.ValidationText Property (DAO)
Send feedback

Sets or returns a value that specifies the text of the message that your application displays if the value of a Field object doesn't satisfy the validation rule specified by the ValidationRule property setting (Microsoft Access workspaces only). Read-only String.

Syntax

expression .ValidationText

expression A variable that represents a Recordset2 object.


Execute, Requery, and Clear Methods Example (VBScript)

 Copy code hover
[image]

Execute, Requery, and Clear Methods Example (VBScript)
Send feedback

This example demonstrates the Execute method when run from both a Command object and a Connection object. It also uses the Requery method to retrieve current data in a recordset, and the Clear method to clear the contents of the Errors collection. The ExecuteCommand and PrintOutput procedures are required for this procedure to run.

Use the following example in an Active Server Page (ASP). Use Find to locate the file Adovbs.inc and place it in the directory you plan to use. Cut and paste the following code into Notepad or another text editor, and save it as ExecuteVBS.asp. You can view the result in any client browser.

VBS Copy code Copy code

<!-- BeginExecuteVBS -->
<%@ Language=VBScript %>
<% ' use this meta tag instead of ADOVBS.inc%>
<!-- METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4"  -->
<HTML>
<HEAD>
<META name="VI60_DefaultClientScript"  content=VBScript>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<title>ADO Execute Method</title>
<STYLE>
<!--
BODY {
   font-family: 'Verdana','Arial','Helvetica',sans-serif;
   BACKGROUND-COLOR:white;
   COLOR:black;
    }
.thead {
   background-color: #008080;
   font-family: 'Verdana','Arial','Helvetica',sans-serif;
   font-size: x-small;
   color: white;
   }
.thead2 {
   background-color: #800000;
   font-family: 'Verdana','Arial','Helvetica',sans-serif;
   font-size: x-small;
   color: white;
   }
.tbody {
   text-align: center;
   background-color: #f7efde;
   font-family: 'Verdana','Arial','Helvetica',sans-serif;
   font-size: x-small;
    }
-->
</STYLE>
</HEAD>

<BODY>
<H3>ADO Execute Method</H3>
<HR>
<H4>Recordset Retrieved Using Connection Object</H4>
<!--- Recordsets retrieved using Execute method of Connection and Command Objects-->
<%
     ' connection, command and recordset variables
    Dim Cnxn, strCnxn
    Dim rsCustomers, strSQLCustomers
    Dim Cmd
    Dim rsProducts, strSQLProducts

    ' create and open connection
    Set Cnxn = Server.CreateObject("ADODB.Connection")
    strCnxn="Provider='sqloledb';Data Source=" & _
            Request.ServerVariables("SERVER_NAME") & ";" & _
            "Integrated Security='SSPI';Initial Catalog='Northwind';"
    Cnxn.Open  strCnxn
    ' create and open recordset
    Set rsCustomers = Server.CreateObject("ADODB.Recordset")
    strSQLCustomers = "Customers"
    rsCustomers.Open strSQLCustomers, Cnxn, adOpenKeyset, adLockOptimistic, adCmdTable

    '1st Recordset using Connection - Execute
    Set rsCustomers = Cnxn.Execute(strSQLCustomers)

    Set Cmd = Server.CreateObject("ADODB.Command")
    Cmd.ActiveConnection = Cnxn
    strSQLProducts = "SELECT * From Products"
    Cmd.CommandText = strSQLProducts

    '2nd Recordset Cmd - execute
    Set rsProducts = Cmd.Execute
    %>
    <TABLE COLSPAN=8 CELLPADDING=5 BORDER=0 ALIGN=CENTER>
    <!-- BEGIN column header row for Customer Table-->
    <TR CLASS=thead>
      <TH>Company Name</TH>
      <TH>Contact Name</TH>
      <TH>City</TH>
    </TR>

    <!--Display ADO Data from Customer Table-->
    <%
    Do While Not rsCustomers.EOF %>
      <TR CLASS=tbody>
        <TD>
        <%= rsCustomers("CompanyName")%>
        </TD>
        <TD>
        <%= rsCustomers("ContactName") %>
        </TD>
        <TD>
        <%= rsCustomers("City")%>
        </TD>
      </TR>
      <%
    rsCustomers.MoveNext
    Loop
    %>
</TABLE>

<HR>
<H4>Recordset Retrieved Using Command Object</H4>

<TABLE CELLPADDING=5 BORDER=0 ALIGN=CENTER WIDTH="80%">

<!-- BEGIN column header row for Product List Table-->
<TR CLASS=thead2>
  <TH>Product Name</TH>
  <TH>Unit Price</TH>
</TR>

<!-- Display ADO Data Product List-->
<% Do Until rsProducts.EOF %>
  <TR CLASS=tbody>
    <TD>
    <%= rsProducts("ProductName")%>
    </TD>
    <TD>
    <%= rsProducts("UnitPrice")%>
    </TD>
<%
    rsProducts.MoveNext
    Loop

    ' clean up
    If rsCustomers.State = adStateOpen then
        rsCustomers.Close
    End If
    If rsProducts.State = adStateOpen then
        rsProducts.Close
    End If
    If Cnxn.State = adStateOpen then
        Cnxn.Close
    End If
    Set Cmd = Nothing
    Set rsCustomers = Nothing
    Set rsProducts = Nothing
    Set Cnxn = Nothing
%>
</TABLE>

</BODY>
</HTML>
<!-- EndExecuteVBS -->


CheckBox.Controls Property (Access)

 Copy code hover
[image]

CheckBox.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Syntax

expression .Controls

expression A variable that represents a CheckBox object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


TextBox.ColumnHidden Property (Access)

 Copy code hover
[image]

TextBox.ColumnHidden Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.

Syntax

expression .ColumnHidden

expression A variable that represents a TextBox object.

Remarks

For example, you might want to hide a CustomerAddress field that's too wide so you can view the CustomerName and PhoneNumber fields.

Note Note

The ColumnHidden property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

Hiding a column with the ColumnHidden property in Datasheet view doesn't hide fields from the same column in Form view. Similarly, setting a control's Visible property to False in Form view doesn't hide the corresponding column in Datasheet view.

Note Note

To set or change this property for a table or query by using Visual Basic, you must use a column's Properties collection. For details on using the Properties collection, see Properties .

You can display a field in a query even though the column for the field is hidden in table Datasheet view. You can use values from a hidden column as the criteria for a filter even though the column remains hidden after the filter is applied.

Setting a field's ColumnWidth property to 0, or resizing the field to a zero width in Datasheet view, causes Microsoft Access to set the corresponding ColumnHidden property to True. Unhiding a column restores the ColumnWidth property to the value it had before the field was hidden.

Note Note

The ColumnHidden property is not available in Design view.

Example

The following example hides the ProductID field in Datasheet view of the Products form.

VBA Copy code Copy code
Forms!Products!ProductID.ColumnHidden = -1

The next example also hides the ProductID field in Datasheet view of the Products table.

VBA Copy code Copy code
Public Sub SetColumnHidden()

 Dim dbs As DAO.Database
 Dim fld As DAO.Field
 Dim prp As DAO.Property
 Const conErrPropertyNotFound = 3270

 ' Turn off error trapping.
 On Error Resume Next

 Set dbs = CurrentDb

 ' Set field property.
 Set fld = dbs.TableDefs!Products.Fields!ProductID
 fld.Properties("ColumnHidden") = True

 ' Error may have occurred when value was set.
 If Err.Number <> 0 Then
 If Err.Number <> conErrPropertyNotFound Then
 On Error GoTo 0
 MsgBox "Couldn't set property 'ColumnHidden' " & _
 "on field '" & fld.Name & "'", vbCritical
 Else
 On Error GoTo 0
 Set prp = fld.CreateProperty("ColumnHidden", dbLong, True)
 fld.Properties.Append prp
 End If
 End If

 Set prp = Nothing
 Set fld = Nothing
 Set dbs = Nothing

End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


TabControl.OnKeyPress Property (Access)

 Copy code hover
[image]

TabControl.OnKeyPress Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Press box in the Properties window. Read/write String.

Syntax

expression .OnKeyPress

expression A variable that represents a TabControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyPress event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyPress value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Press box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Press box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyPress property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyPress

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Syntax error in PARAMETER clause. (Error 3139)

 Copy code hover
[image]

Syntax error in PARAMETER clause. (Error 3139)
Send feedback

You entered an SQL statement with an invalid PARAMETERS declaration.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


Users Collection (ADOX) Reference

 Copy code hover
[image]

Users Collection (ADOX) Reference
Send feedback

In this section

  • Users Collection (ADOX)

  • Users Collection Properties, Methods, and Events (ADOX)


NavigationButton.OnMouseUp Property (Access)

 Copy code hover
[image]

NavigationButton.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnMouseUp

expression A variable that represents a NavigationButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


WebBrowserControl.Name Property (Access)

 Copy code hover
[image]

WebBrowserControl.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .Name

expression A variable that represents a WebBrowserControl object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


MacroError.Condition Property (Access)

 Copy code hover
[image]

MacroError.Condition Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the condition of the macro action that was executing when an error occurred. Read-only String.

Version Information

Version Added: Access 2007

Syntax

expression .Condition

expression A variable that represents a MacroError object.

Remarks

When an error occurs in a macro, information about the error is stored in the MacroError object. If you have not used the OnError action to suppress error messages, the macro stops and the error information is displayed in a standard error message. However, if you have used the OnError action to suppress error messages, you may want to use the information stored in the MacroError object in a condition or a custom error message.

After an error has been handled, the information in the MacroError object is out of date, so it is a good idea to clear the object using the ClearMacroError action. This resets the error number in the MacroError object back to zero, and clears any other information about the error that is stored in the object, such as the error description, macro name, action name, condition, and arguments. This way, you can inspect the MacroError object again later to see if another error has occurred.

See also

Concepts

MacroError Object

Other resources

MacroError Object Members


OpenTable Macro Action

 Copy code hover
[image]

OpenTable Macro Action
Send feedback

You can use the OpenTable action to open a table in Datasheet view, Design view, or Print Preview. You can also select a data entry mode for the table.

Setting

The OpenTable action has the following arguments.

Action argument | Description
Table Name | The name of the table to open. The Table Name box in the Action Arguments section of the Macro Builder pane shows all tables in the current database. This is a required argument. If you run a macro containing the OpenTable action in a library database, Microsoft Microsoft Access looks for the table with this name first in the library database, then in the current database.
View | The view in which the table will open. Click Datasheet, Design, Print Preview, PivotTable, or PivotChart in the View box. The default is Datasheet.
Data Mode | The data entry mode for the table. This applies only to tables opened in Datasheet view. Click Add (the user can add new records but can't edit existing records), Edit (the user can edit existing records and add new records), or Read Only (the user can only view records). The default is Edit.

Remarks

This action is similar to double-clicking the table in the Navigation Pane, or right-clicking the table in the Navigation Pane and selecting a view.

Tip Tip

You can drag a table from the Navigation Pane to a macro action row. This automatically creates an OpenTable action that opens the table in Datasheet view.

To run the OpenTable action in a Visual Basic for Applications (VBA) module, use the OpenTable method of the DoCmd object.


NavigationButton.OnKeyUp Property (Access)

 Copy code hover
[image]

NavigationButton.OnKeyUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Up box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnKeyUp

expression A variable that represents a NavigationButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyUp event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyUp

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


How to: Send Information to the Clipboard

 Copy code hover
[image]

How to: Send Information to the Clipboard
Send feedback

Use the RunCommand Method

You can use the RunCommand method with the acCmdCopy constant to copy the contents of the active control on a form or report to the Clipboard. The following example illustrates how to copy the contents of a text box named txtNotes to the Clipboard.

VBA Copy code Copy code
Private Sub cmdCopy_Click()
   Me!txtNotes.SetFocus
   DoCmd.RunCommand acCmdCopy
End Sub

Use the Windows API

To use Windows API calls to send information to the Clipboard, paste the following code into the Declarations section of a standard module.

VBA Copy code Copy code
Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) _
   As Long
Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) _
   As Long
Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, _
   ByVal dwBytes As Long) As Long
Declare Function CloseClipboard Lib "User32" () As Long
Declare Function OpenClipboard Lib "User32" (ByVal hwnd As Long) _
   As Long
Declare Function EmptyClipboard Lib "User32" () As Long
Declare Function lstrcpy Lib "kernel32" (ByVal lpString1 As Any, _
   ByVal lpString2 As Any) As Long
Declare Function SetClipboardData Lib "User32" (ByVal wFormat _
   As Long, ByVal hMem As Long) As Long

Public Const GHND = &H42
Public Const CF_TEXT = 1
Public Const MAXSIZE = 4096

The following procedure illusrtrates how to send information to the Clipboard.

VBA Copy code Copy code
Function ClipBoard_SetData(MyString As String)
   Dim hGlobalMemory As Long, lpGlobalMemory As Long
   Dim hClipMemory As Long, X As Long

   ' Allocate moveable global memory.
   '-------------------------------------------
   hGlobalMemory = GlobalAlloc(GHND, Len(MyString) + 1)

   ' Lock the block to get a far pointer
   ' to this memory.
   lpGlobalMemory = GlobalLock(hGlobalMemory)

   ' Copy the string to this global memory.
   lpGlobalMemory = lstrcpy(lpGlobalMemory, MyString)

   ' Unlock the memory.
   If GlobalUnlock(hGlobalMemory) <> 0 Then
      MsgBox "Could not unlock memory location. Copy aborted."
      GoTo OutOfHere2
   End If

   ' Open the Clipboard to copy data to.
   If OpenClipboard(0&) = 0 Then
      MsgBox "Could not open the Clipboard. Copy aborted."
      Exit Function
   End If

   ' Clear the Clipboard.
   X = EmptyClipboard()

   ' Copy the data to the Clipboard.
   hClipMemory = SetClipboardData(CF_TEXT, hGlobalMemory)

OutOfHere2:

   If CloseClipboard() = 0 Then
      MsgBox "Could not close Clipboard."
   End If

   End Function


ListBox.OnDblClick Property (Access)

 Copy code hover
[image]

ListBox.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Syntax

expression .OnDblClick

expression A variable that represents a ListBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_DblClick" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Attachment Members (Access)

 Copy code hover
[image]

Attachment Members (Access)
Send feedback

Published: July 16, 2012

This object corresponds to an attachment control. Use an attachment control when you want to manipulate the contents fields of the attachment data type.

Events

Name | Description
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
AttachmentCurrent | Occurs when the focus moves to or from a file contained in the specified Attachment control, making it the current attachment, or when the form is refreshed or requeried.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Change | The Change event occurs when the contents of the specified control change.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Dirty | The Dirty event occurs when the content of the specified control changes.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object receives the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.

Methods

Name | Description
Back | Moves the focus to the previous file in the specified Attachment control.
Forward | Moves the focus to the next file in the specified Attachment control.
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AttachmentCount | Gets the number of documents attached to the specified Attachment control. Read-only Long.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears. Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme that is associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the attachment and its bottom gridline. Read/write Integer.
ColumnHidden | You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.
ColumnOrder | You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.
ColumnWidth | You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in the specified Attachment control. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
CurrentAttachment | Gets the index number of the file that has the focus in the Attachment control. Read/write Long.
DefaultPicture | Gets or sets the path and file name of the graphic to be used as a background picture on an attachment control. Read/write String.
DefaultPictureType | Gets or sets the method used to store the image specified by the DefaultPicture property in the database. Read/write Byte.
DisplayAs | Gets or sets an AcDisplayAs constant that specifies how a file should be displayed in the Attachment control. Read/write.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FileName | Returns the full file name of the specified attachment. Read-only String.
FileType | Returns the file extension of the specifed attachment. Read-only String.
FileURL | Returns the Uniform Resource Locator (URL) of the specified attachment. Read-only String.
GridlineColor | Gets or sets the color of the gridline for the specified attachment. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified attachment. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified attachment. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified attachment. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified attachment. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified attachment. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified attachment. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified attachment. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified attachment. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the attachment is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property to determine whether a control on a report is visible. Read/write Boolean.
LabelAlign | The LabelAlign property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified attachment. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified attachment. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the attachment and its left gridline. Read/write Integer.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
OldBorderStyle | You can use this property to set or return the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnAttachmentCurrent | Sets or gets the value of the On Attachment Current box in the Properties window of the specified Attachment. Read/write.
OnChange | Sets or returns the value of the On Change box in the Properties window of one of the objects in the Applies To list. Read/write String.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnDirty | Sets or returns the value of the On Dirty box in the Properties window of a form or report. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of the specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of the specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
PictureAlignment | You can use the PictureAlignment property to specify where a background picture will appear in the Attachment control. Read/write Byte.
PictureSizeMode | You can use the PictureSizeMode property to specify how a picture for an attachment control is sized. Read/write Byte.
PictureTiling | You can use the PictureTiling property to specify whether a background picture is tiled across the entire attachment control. Read/write Boolean.
Properties | Returns a reference to a control's Properties collection object. Read-only.
RightPadding | Gets or sets the amount of space (in inches) between the attachment and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click the specified object. Read/write String.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control in Form view. Read/write Boolean.
Tag | Stores extra information about a control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the attachment and its top gridline. Read/write Integer.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified attachment is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


ComboBox.LeftPadding Property (Access)

 Copy code hover
[image]

ComboBox.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the combo box and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .LeftPadding

expression A variable that represents a ComboBox object.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


QueryDefTypeEnum Enumeration (DAO)

 Copy code hover
[image]

QueryDefTypeEnum Enumeration (DAO)
Send feedback

Used with the Type property to specify the type of QueryDef object.

Name | Value | Description
dbQAction | 240 | Action query
dbQAppend | 64 | Append query
dbQCompound | 160 | Compound query
dbQCrosstab | 16 | Crosstab query
dbQDDL | 96 | Data-definition language (DDL) query
dbQDelete | 32 | Delete query
dbQMakeTable | 80 | Make-table query
dbQProcedure | 224 | SQL procedure that executes a stored procedure
dbQSelect | 0 | Select query
dbQSetOperation | 128 | Set operation query
dbQSPTBulk | 144 | Bulk operation query
dbQSQLPassThrough | 112 | SQL pass-through query
dbQUpdate | 48 | Update query


OptionButton.MouseMove Event (Access)

 Copy code hover
[image]

OptionButton.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents an OptionButton object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Line Properties (Access)

 Copy code hover
[image]

Line Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the line is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LineSlant | You use the LineSlant property to specify whether a line control slants from upper left to lower right or from upper right to lower left. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified line is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


Recordsets.Count Property (DAO)

 Copy code hover
[image]

Recordsets.Count Property (DAO)
Send feedback

Returns the number of objects in the specified collection. Read-only Integer.

Syntax

expression .Count

expression A variable that represents a Recordsets object.

Remarks

Because members of a collection begin with 0, you should always code loops starting with the 0 member and ending with the value of the Count property minus 1. If you want to loop through the members of a collection without checking the Count property, you can use a For Each...Next command.

The Count property setting is never Null. If its value is 0, there are no objects in the collection.


The system tables in your replica are no longer reliable and the replica should not be used. (Error 3595)

 Copy code hover
[image]

The system tables in your replica are no longer reliable and the replica should not be used. (Error 3595)
Send feedback

The replica on your computer is corrupted. When the Microsoft Access database engine repaired the replica, it may have altered one or more system tables. Delete the replica and replace it with a new replica.


QueryDefs.Refresh Method (DAO)

 Copy code hover
[image]

QueryDefs.Refresh Method (DAO)
Send feedback

Not supported for this object.

Syntax

expression .Refresh

expression A variable that represents a QueryDefs object.

Remarks

You can't use the Refresh method with collections that aren't persistent, such as Connections, Databases, Recordsets, Workspaces, or the QueryDefs collection of a Connection object.


This table contains cells that are outside of the range of cells defined in this spreadsheet. (Error 3673)

 Copy code hover
[image]

This table contains cells that are outside of the range of cells defined in this spreadsheet. (Error 3673)
Send feedback

The spreadsheet file that is being read is not correctly formed. It contains data outside the range that was specified in the file header information. The spreadsheet driver cannot read the data reliably if it is not properly formed.

The file may not be a spreadsheet file or it may have become corrupted. Try reading the file into the original spreadsheet product and then re-writing it to another file. The spreadsheet product may be able to fix the errors.


ListBox.Value Property (Access)

 Copy code hover
[image]

ListBox.Value Property (Access)
See also Send feedback

Published: July 16, 2012

Determines or specifies which value or option in the list box is selected. Read/write Variant.

Syntax

expression .Value

expression A variable that represents a ListBox object.

Remarks

Set the Value property to the value in the bound column for the item selected in the list.

The Value property returns or sets a control's default property, which is the property that is assumed when you don't explicitly specify a property name.

Note Note

The Value property is not the same as the DefaultValue property, which specifies the value that a property is assigned when a new record is created.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Field2.AppendOnly Property (DAO)

 Copy code hover
[image]

Field2.AppendOnly Property (DAO)
Send feedback

Gets or sets a Boolean that indicates whether the spcified field is set to append new values to the existing contents of the field as they are added. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .AppendOnly

expression A variable that represents a Field2 object.


User Interface (Access)

 Copy code hover
[image]

User Interface (Access)
Send feedback

In this section

  • Access User Interface How Do I...

  • Ribbon

  • Miscellaneous Topics in Access User Interface


WebBrowserControl.Enter Event (Access)

 Copy code hover
[image]

WebBrowserControl.Enter Event (Access)
See also Send feedback

Published: July 16, 2012

The Enter event occurs before a control actually receives the focus from a control on the same form or report.

Version Information

Version Added: Access 2010

Syntax

expression .Enter

expression A variable that represents a WebBrowserControl object.

Return Value

nothing

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when these events occur, set the OnEnter or OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Enter event occurs before the GotFocus event. The Exit event occurs before the LostFocus event.

Unlike the GotFocus and LostFocus events, the Enter and Exit events don't occur when a form receives or loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


 Copy code hover
[image]

<Name> is not an index in this table. (Error 3800)
Send feedback

An invalid index name was used when trying to reference an index.


CheckBox.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

CheckBox.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified check box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthBottom

expression A variable that represents a CheckBox object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ADO Code Examples in Microsoft Visual C++

 Copy code hover
[image]

ADO Code Examples in Microsoft Visual C++
Send feedback

Use the following code examples to learn how to use the ADO methods, properties, and events when writing in Microsoft Visual C++.

Note Note

Paste the entire code example, from beginning to end, into your code editor. The example may not run correctly if partial examples are used or if paragraph formatting is lost.

Methods

  • AddNew Method Example

  • Append and CreateParameter Methods Example

  • AppendChunk and GetChunk Methods Example

  • BeginTrans, CommitTrans, and RollbackTrans Methods Example

  • Cancel Method Example

  • Clone Method Example

  • CompareBookmarks Method Example

  • Delete Method Example

  • Execute, Requery, and Clear Methods Example

  • Find Method Example

  • GetRows Method Example

  • GetString Method Example

  • MoveFirst, MoveLast, MoveNext, and MovePrevious Methods Example

  • NextRecordset Method Example

  • Open and Close Methods Example

  • OpenSchema Method Example

  • Refresh Method Example

  • Resync Method Example

  • Save and Open Methods Example

  • Seek Method and Index Property Example

  • Supports Method Example

  • Update and CancelUpdate Methods Example

  • UpdateBatch and CancelBatch Methods Example

Properties

  • AbsolutePage, PageCount, and PageSize Properties Example

  • AbsolutePosition and CursorLocation Properties Example

  • ActiveCommand Property Example

  • ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction Properties Example

  • ActualSize and DefinedSize Properties Example

  • Attributes and Name Properties Example

  • BOF, EOF, and Bookmark Properties Example

  • CacheSize Property Example

  • ConnectionString, ConnectionTimeout, and State Properties Example

  • Count Property Example

  • CursorType, LockType, and EditMode Properties Example

  • Description, HelpContext, HelpFile, NativeError, Number, Source, and SQLState Properties Example

  • Filter and RecordCount Properties Example

  • Index Property and Seek Method Example

  • IsolationLevel and Mode Properties Example

  • Item Property Example

  • MarshalOptions Property Example

  • MaxRecords Property Example

  • NumericScale and Precision Properties Example

  • Optimize Property Example

  • OriginalValue and UnderlyingValue Properties Example

  • Prepared Property Example

  • Provider and DefaultDatabase Properties Example

  • Sort Property Example

  • Source Property Example

  • State Property Example

  • Status Property Example

  • StayInSync Property Example

  • Type Property Example (Fields)

  • Type Property Example (Property)

  • Value Property Example

  • Version Property Example

Other

  • ADO Events Model Example


TextBox.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

TextBox.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthBottom

expression A variable that represents a TextBox object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Relations Methods (DAO)

 Copy code hover
[image]

Relations Methods (DAO)
Send feedback

In this section

  • Relations.Append Method (DAO)

  • Relations.Delete Method (DAO)

  • Relations.Refresh Method (DAO)


CodeData.AllQueries Property (Access)

 Copy code hover
[image]

CodeData.AllQueries Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllQueries property to reference the AllQueries collection and its related properties. Read-only AllQueries object.

Syntax

expression .AllQueries

expression A variable that represents a CodeData object.

See also

Concepts

CodeData Object

Other resources

CodeData Object Members


CommandButton.LabelX Property (Access)

 Copy code hover
[image]

CommandButton.LabelX Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelX

expression A variable that represents a CommandButton object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Application.AutomationSecurity Property (Access)

 Copy code hover
[image]

Application.AutomationSecurity Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets an MsoAutomationSecurity constant that represents the security mode that Microsoft Access uses when it is programmatically opening files. Read/write. .

Syntax

expression .AutomationSecurity

expression A variable that represents an Application object.

Remarks

MsoAutomationSecurity can be one of these MsoAutomationSecurity constants:

msoAutomationSecurityByUI Uses the security setting specified in the Security dialog box (Tools menu, Macro submenu). msoAutomationSecurityByUI is the default value when the application is started.

msoAutomationSecurityForceDisable Access will not open any database if the macro security level is set to High or Medium in the Security dialog box (Tools menu, Macro submenu). No security messages are shown to the user.

Note Note

This setting has no effect if the macro security level is set to Low.

msoAutomationSecurityLow Enables all macros.

See also

Concepts

Application Object

Other resources

Application Object Members


BoundObjectFrame.OnKeyDown Property (Access)

 Copy code hover
[image]

BoundObjectFrame.OnKeyDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Down box in the Properties window. Read/write String.

Syntax

expression .OnKeyDown

expression A variable that represents a BoundObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyDown event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyDown

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


ComboBox.OnMouseMove Property (Access)

 Copy code hover
[image]

ComboBox.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Syntax

expression .OnMouseMove

expression A variable that represents a ComboBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


PageBreak.Top Property (Access)

 Copy code hover
[image]

PageBreak.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Syntax

expression .Top

expression A variable that represents a PageBreak object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

PageBreak Object

Other resources

PageBreak Object Members


ToggleButton.LabelX Property (Access)

 Copy code hover
[image]

ToggleButton.LabelX Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelX

expression A variable that represents a ToggleButton object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


NavigationButton.HyperlinkAddress Property (Access)

 Copy code hover
[image]

NavigationButton.HyperlinkAddress Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the HyperlinkAddress property to specify or determine the path to an object, document, Web page or other destination for a hyperlink associated with a the specified control. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .HyperlinkAddress

expression A variable that represents a NavigationButton object.

Remarks

The HyperlinkAddress property is a string expression representing the path to a file (UNC path) or Web page (URL).

Note Note

When you set the HyperlinkAddress property, you automatically specify the Address property for the Hyperlink object associated with the control.

Note Note

When you create a hyperlink by using the Insert Hyperlink dialog box, Microsoft Access automatically sets the HyperlinkAddress property and HyperlinkSubAddress to the location specified in the Type the file or Web page name box. The HyperlinkSubAddress property can also be set to the location specified in the Select an object in this database box.

If you copy a hyperlink from another application and paste it into a form or report, Microsoft Access creates a label control with its Caption property, HyperlinkAddress property, and HyperlinkSubAddress property automatically set.

When you move the cursor over a command button, image control, or label control whose HyperlinkAddress property is set, the cursor changes to an upward-pointing hand. Clicking the control displays the object or Web page specified by the link.

To open objects in the current database, leave the HyperlinkAddress property blank and specify the object type and object name you want to open in the HyperlinkSubAddress property by using the syntax "objecttype objectname". If you want to open an object contained in another Microsoft Access database, enter the database path and file name in the HyperlinkAddress property and specify the database object to open by using the HyperlinkSubAddress property.

The HyperlinkAddress property can contain an absolute or a relative path to a target document. An absolute path is a fully qualified URL or UNC path to a document. A relative path is a path related to the base path specified in the Hyperlink Base setting in the Properties dialog box (available by clicking Database Properties on the File menu) or to the current database path. If Microsoft Access can't resolve the HyperlinkAddress property setting to a valid URL or UNC path, it will assume you've specified a path relative to the base path contained in the Hyperlink Base setting or the current database path.

Note Note

When you follow a hyperlink to another Microsoft Access database object, the database Startup properties are applied. For example, if the destination database has a Display form set, that form is displayed when the database opens.

The following table contains examples of HyperlinkAddress and HyperlinkSubAddress property settings.

HyperlinkAddress | HyperlinkSubAddress | Description
http://www.microsoft.com/ |  | The Microsoft home page on the Web.
C:\Program Files\Microsoft Office\Office\Samples\Cajun.htm |  | The Cajun Delights page in the Access sample applications subdirectory.
C:\Program Files\Microsoft Office\Office\Samples\Cajun.htm | NewProducts | The "NewProducts" Name tag in the Cajun Delights page.
C:\Personal\MyResume.doc | References | The bookmark named "References" in the Microsoft Word document "MyResume.doc".
C:\Finance\First Quarter.xls | Sheet1!TotalSales | The range named "TotalSales" in the Microsoft Excel spreadsheet "First Quarter.xls".
C:\Presentation\NewPlans.ppt | 10 | The 10th slide in the Microsoft PowerPoint document "NewPlans.ppt".

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


ToggleButton.VerticalAnchor Property (Access)

 Copy code hover
[image]

ToggleButton.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified toggle button is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .VerticalAnchor

expression A variable that represents a ToggleButton object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


AcWebUserDisplay Enumeration (Access)

 Copy code hover
[image]

AcWebUserDisplay Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies information about the current user of a Web database.

Version Information

Version Added: Access 2010

Name | Value | Description
acWebUserEmail | 3 | The current user's e-mail address.
acWebUserID | 0 | The current user's member ID.
acWebUserLoginName | 2 | The current user's login name.
acWebUserName | 1 | The current user's display name.


Using Regedit.exe to Overwrite the Default Settings

 Copy code hover
[image]

Using Regedit.exe to Overwrite the Default Settings
Send feedback

Published: July 16, 2012

To customize the Microsoft® Windows® Registry settings, you can use Regedit.exe to overwrite the default settings that are established when the Microsoft Access database engine is registered. This method of modification is the least flexible method because all applications that do not specify another registry location will have these new default settings.


Image.GridlineThemeColorIndex Property (Access)

 Copy code hover
[image]

Image.GridlineThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineThemeColorIndex

expression A variable that represents an Image object.

Remarks

The GridlineThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 (Default) | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the GridlineThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

Image Object

Other resources

Image Object Members


OptionButton.BottomPadding Property (Access)

 Copy code hover
[image]

OptionButton.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the option button and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .BottomPadding

expression A variable that represents an OptionButton object.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Application.CompactRepair Method (Access)

 Copy code hover
[image]

Application.CompactRepair Method (Access)
See also Send feedback

Published: July 16, 2012

Compacts and repairs the specified database or Microsoft Access project (.adp) file. Returns a Boolean; True if the process was successful.

Syntax

expression .CompactRepair(SourceFile, DestinationFile, LogFile)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
SourceFile | Required | String | The full path and filename of the database or project file to compact and repair.
DestinationFile | Required | String | The full path and filename for where the recovered file will be saved.
LogFile | Optional | Boolean | True if a log file is created in the destination directory to record any corruption detected in the source file. A log file is only created if corruption is detected in the source file. If LogFile is False or omitted, no log file is created, even if corruption is detected in the source file.

Return Value

Boolean

Remarks

The source file must not be the current database or be open by any other user, since calling this method will open the file exclusively.

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Compact and Repair

Example

The following example compacts and repairs a database, creates a log if there's any corruption in the source file, and returns a Boolean value based on whether the recovery was successful. For the example to work, you must pass it the paths and file names of the source and destination files.

VBA Copy code Copy code
Function RepairDatabase(strSource As String, _
        strDestination As String) As Boolean
        ' Input values: the paths and file names of
        ' the source and destination files.

    ' Trap for errors.
    On Error GoTo error_handler

    ' Compact and repair the database. Use the return value of
    ' the CompactRepair method to determine if the file was
    ' successfully compacted.
    RepairDatabase = _
        Application.CompactRepair( _
        LogFile:=True, _
        SourceFile:=strSource, _
        DestinationFile:=strDestination)

    ' Reset the error trap and exit the function.
    On Error GoTo 0
    Exit Function

' Return False if an error occurs.
error_handler:
    RepairDatabase = False

End Function

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Application Object

Other resources

Application Object Members


Form.BeforeScreenTip Property (Access)

 Copy code hover
[image]

Form.BeforeScreenTip Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the BeforeScreenTip event occurs. Read/write.

Syntax

expression .BeforeScreenTip

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the BeforeScreenTip event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).BeforeScreenTip = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


ObjectFrame.GridlineWidthRight Property (Access)

 Copy code hover
[image]

ObjectFrame.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified frame. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthRight

expression A variable that represents an ObjectFrame object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


FetchComplete Event (ADO)

 Copy code hover
[image]

FetchComplete Event (ADO)
Send feedback

The FetchComplete event is called after all the records in a lengthy asynchronous operation have been retrieved into the Recordset.

Syntax

FetchComplete pError, adStatus, pRecordset

Parameters

  • pError

  • An Error object. It describes the error that occurred if the value of adStatus is adStatusErrorsOccurred; otherwise it is not set.

  • adStatus

  • EventStatusEnum

    Before this event returns, set this parameter to adStatusUnwantedEvent to prevent subsequent notifications.

  • pRecordset

  • A Recordset object. The object for which the records were retrieved.

Remarks

To use FetchComplete with Microsoft Visual Basic, Visual Basic 6.0 or later is required.


Microsoft Data Access Objects reference

 Copy code hover
[image]

Microsoft Data Access Objects reference
Send feedback

In this section

  • ComplexType Object Reference (DAO)

  • Connection Object Reference (DAO)

  • Connections Object Reference (DAO)

  • Container Object Reference (DAO)

  • Containers Object Reference (DAO)

  • Database Object Reference (DAO)

  • Databases Object Reference (DAO)

  • DBEngine Object Reference (DAO)

  • Document Object Reference (DAO)

  • Documents Object Reference (DAO)

  • Error Object Reference (DAO)

  • Errors Object Reference (DAO)

  • Field Object Reference (DAO)

  • Field2 Object Reference (DAO)

  • Fields Object Reference (DAO)

  • Index Object Reference (DAO)

  • Indexes Object Reference (DAO)

  • Parameter Object Reference (DAO)

  • Parameters Object Reference (DAO)

  • Properties Object Reference (DAO)

  • Property Object Reference (DAO)

  • QueryDef Object Reference (DAO)

  • QueryDefs Object Reference (DAO)

  • Recordset Object Reference (DAO)

  • Recordset2 Object Reference (DAO)

  • Recordsets Object Reference (DAO)

  • Relation Object Reference (DAO)

  • Relations Object Reference (DAO)

  • TableDef Object Reference (DAO)

  • TableDefs Object Reference (DAO)

  • Workspace Object Reference (DAO)

  • Workspaces Object Reference (DAO)

  • Enumerations (DAO Reference)


ListBox.ForeShade Property (Access)

 Copy code hover
[image]

ListBox.ForeShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .ForeShade

expression A variable that represents a ListBox object.

Remarks

The ForeShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the ForeShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the ForeColor property by 75%.

VBA Copy code Copy code
Me.ctl.ForeShade=25

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


CurrentProject.AllForms Property (Access)

 Copy code hover
[image]

CurrentProject.AllForms Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllForms property to reference the AllForms collection and its related properties. Read-only AllForms object.

Syntax

expression .AllForms

expression A variable that represents a CurrentProject object.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


Containers Collection (DAO)

 Copy code hover
[image]

Containers Collection (DAO)
Send feedback

A Containers collection contains all of the Container objects that are defined in a database.

Remarks

Each Database object has a Containers collection consisting of built-in Container objects. Some of these Container objects are defined by the Microsoft Access database engine while others may be defined by other applications.

Example

This example enumerates the Containers collection of the Northwind database and the Properties collection of each Container object in the collection.

Copy code Copy code
Sub ContainerObjectX()

   Dim dbsNorthwind As Database
   Dim ctrLoop As Container
   Dim prpLoop As Property

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   With dbsNorthwind

      ' Enumerate Containers collection.
      For Each ctrLoop In .Containers
         Debug.Print "Properties of " & ctrLoop.Name _
            & " container"

         ' Enumerate Properties collection of each
         ' Container object.
         For Each prpLoop In ctrLoop.Properties
            Debug.Print "  " & prpLoop.Name _
               & " = " prpLoop
         Next prpLoop

      Next ctrLoop

      .Close
   End With

End Sub


OptionGroup.LabelY Property (Access)

 Copy code hover
[image]

OptionGroup.LabelY Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelY

expression A variable that represents an OptionGroup object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Application.SysCmd Method (Access)

 Copy code hover
[image]

Application.SysCmd Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SysCmd method to, display a progress meter or optional specified text in the status bar, return information about Microsoft Access and its associated files, or return the state of a specified database object (to indicate whether the object is open, is a new object, or has been changed but not saved). Variant.

Syntax

expression .SysCmd(Action, Argument2, Argument3)

expression A variable that represents an Application object.

Parameters

Name

Required/Optional

Data Type

Description

Action

Required

AcSysCmdAction

A AcSysCmdAction constant that identifies the type of action to take. This set of constants applies to a progress meter. The SysCmd method returns a null if these actions are successful. Otherwise, Microsoft Access generates a run-time error.

Argument2

Optional

Variant

The text to be displayed left-aligned in the status bar. This argument is required when the action argument is acSysCmdInitMeter, acSysCmdUpdateMeter, or acSysCmdSetStatus; this argument isn't valid for other action argument values.

Note Note

When you specify the acSysCmdGetObjectState value for the Action parameter, then you must specify the appropriate AcObjectType constant.

Argument3

Optional

Variant

A numeric expression that controls the display of the progress meter. This argument is required when the action argument is acSysCmdInitMeter; this argument isn't valid for other action argument values.

Note Note

When you specify the acSysCmdGetObjectState value for the Action parameter, then you must specify the name of the database object.

Return Value

Variant

Remarks

For example, if you are building a custom wizard that creates a new form, you can use the SysCmd method to display a progress meter indicating the progress of your wizard as it constructs the form.

By calling the SysCmd method with the various progress meter actions, you can display a progress meter in the status bar for an operation that has a known duration or number of steps, and update it to indicate the progress of the operation.

To display a progress meter in the status bar, you must first call the SysCmd method with the acSysCmdInitMeter action argument, and the text and value arguments. When the action argument is acSysCmdInitMeter, the value argument is the maximum value of the meter, or 100 percent.

To update the meter to show the progress of the operation, call the SysCmd method with the acSysCmdUpdateMeter action argument and the value argument. When the action argument is acSysCmdUpdateMeter, the SysCmd method uses the value argument to calculate the percentage displayed by the meter. For example, if you set the maximum value to 200 and then update the meter with a value of 100, the progress meter will be half-filled.

You can also change the text that's displayed in the status bar by calling the SysCmd method with the acSysCmdSetStatus action argument and the text argument. For example, during a sort you might change the text to "Sorting...". When the sort is complete, you would reset the status bar by removing the text. The text argument can contain approximately 80 characters. Because the status bar text is displayed by using a proportional font, the actual number of characters you can display is determined by the total width of all the characters specified by the text argument.

As you increase the width of the status bar text, you decrease the length of the meter. If the text is longer than the status bar and the action argument is acSysCmdInitMeter, the SysCmd method ignores the text and doesn't display anything in the status bar. If the text is longer than the status bar and the action argument is acSysCmdSetStatus, the SysCmd method truncates the text to fit the status bar.

You can't set the status bar text to a zero-length string (" "). If you want to remove the existing text from the status bar, set the text argument to a single space. The following examples illustrate ways to remove the text from the status bar:

VBA Copy code Copy code
varReturn = SysCmd(acSysCmdInitMeter, " ", 100)
varReturn = SysCmd(acSysCmdSetStatus, " ")

If the progress meter is already displayed when you set the text by calling the SysCmd method with the acSysCmdSetStatus action argument, the SysCmd method automatically removes the meter.

Call the SysCmd method with other actions to determine system information about Microsoft Access, including which version number of Microsoft Access is running, whether it is a run-time version, the location of the Microsoft Access executable file, the setting for the /profile argument specified in the command line, and the name of an .ini file associated with Microsoft Access.

Note Note

Both general and customized settings for Microsoft Access are now stored in the Windows Registry, so you probably won't need an .ini file with your Microsoft Access application. The acSysCmdIniFile action argument exists for compatibility with earlier versions of Microsoft Access.

Call the SysCmd method with the acSysCmdGetObjectState action argument and the objecttype and objectname arguments to return the state of a specified database object. An object can be in one of four possible states: not open or nonexistent, open, new, or changed but not saved.

For example, if you are designing a wizard that inserts a new field in a table, you need to determine whether the structure of the table has been changed but not yet saved, so that you can save it before modifying its structure. You can check the value returned by the SysCmd method to determine the state of the table.

The SysCmd method with the acSysCmdGetObjectState action argument can return any combination of the following constants.

Constant | State of database object | Value
acObjStateOpen | Open | 1
acObjStateDirty | Design changed but not saved | 2
acObjStateNew | New | 4
Note Note

If the object referred to by the objectname argument is either not open or doesn't exist, the SysCmd method returns a value of zero.

The following code can be used to enable the use of your ActiveX control in expressions when the ActiveX control has been added to a form:

VBA Copy code Copy code
SysCmd 14, "<ActiveX Control GUID>"
Note Note

Replace <ActiveX Control GUID> with the globally unique identifier (GUID) that identifies the ActiveX control that you want to enable in expressions.

Note Note

You cannot remove an ActiveX control once it has been added to the list of allowed controls.

See also

Concepts

Application Object

Other resources

Application Object Members


Running the Address Book Sample Application

 Copy code hover
[image]

Running the Address Book Sample Application
Send feedback

To run the Address Book application, follow this procedure.

To run this application

  1. Make sure that Microsoft SQL Server is running. Click Start, point to Programs, point to Microsoft SQL Server 7.0, and then click Service Manager. If there is a green arrow in the white circle, then SQL Server is running. If it is not (there will be a red square in the white circle), click Start/Continue.

  2. In Microsoft Internet Explorer 4.0 or later, type the following address: http://webserver/RDS/AddressBook/AddrBook.asp where webserver is the name of the Web server where the RDS server components are installed.

  3. You can then try various scenarios in the Address Book sample application, such as searching for a person based on his or her e-mail name, listing all people with the title "Program Manager," or editing existing records. Click Find to fill the data grid with all the available names.


NavigationButton.TopPadding Property (Access)

 Copy code hover
[image]

NavigationButton.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .TopPadding

expression A variable that represents a NavigationButton object.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


CommandButton.Tag Property (Access)

 Copy code hover
[image]

CommandButton.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents a CommandButton object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Field.AllowZeroLength Property (DAO)

 Copy code hover
[image]

Field.AllowZeroLength Property (DAO)
Send feedback

Sets or returns a value that indicates whether a zero-length string ("") is a valid setting for the Value property of the Field object with a Text or Memo data type (Microsoft Access workspaces only).

Syntax

expression .AllowZeroLength

expression A variable that represents a Field object.

Remarks

For an object not yet appended to the Fields collection, this property is read/write.

Once appended to a Fields collection, the availability of the AllowZeroLength property depends on the object that contains the Fields collection, as shown in the following table.

If the Fields collection belongs to an | Then AllowZeroLength is
Index object | Not supported
QueryDef object | Read-only
Recordset object | Read-only
Relation object | Not supported
TableDef object | Read/write

You can use this property along with the Required, ValidateOnSet, or ValidationRule property to validate a value in a field.

Example

In this example, the AllowZeroLength property allows the user to set the value of a Field to an empty string. In this situation, the user can distinguish between a record where data is not known and a record where the data does not apply.

Copy code Copy code
Sub AllowZeroLengthX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim fldTemp As Field
 Dim rstEmployees As Recordset
 Dim strMessage As String
 Dim strInput As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set tdfEmployees = dbsNorthwind.TableDefs("Employees")
 ' Create a new Field object and append it to the Fields
 ' collection of the Employees table.
 Set fldTemp = tdfEmployees.CreateField("FaxPhone", _
 dbText, 24)
 fldTemp.AllowZeroLength = True
 tdfEmployees.Fields.Append fldTemp

 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees")

 With rstEmployees
 ' Get user input.
 .Edit
 strMessage = "Enter fax number for " & _
 !FirstName & " " & !LastName & "." & vbCr & _
 "[? - unknown, X - has no fax]"
 strInput = UCase(InputBox(strMessage))
 If strInput <> "" Then
 Select Case strInput
 Case "?"
 !FaxPhone = Null
 Case "X"
 !FaxPhone = ""
 Case Else
 !FaxPhone = strInput
 End Select

 .Update

 ' Print report.
 Debug.Print "Name - Fax number"
 Debug.Print !FirstName & " " & !LastName & " - ";

 If IsNull(!FaxPhone) Then
 Debug.Print "[Unknown]"
 Else
 If !FaxPhone = "" Then
 Debug.Print "[Has no fax]"
 Else
 Debug.Print !FaxPhone
 End If
 End If

 Else
 .CancelUpdate
 End If

 .Close
 End With

 ' Delete new field because this is a demonstration.
 tdfEmployees.Fields.Delete fldTemp.Name
 dbsNorthwind.Close

End Sub


BoundObjectFrame.GridlineWidthRight Property (Access)

 Copy code hover
[image]

BoundObjectFrame.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified frame. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthRight

expression A variable that represents a BoundObjectFrame object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Section.SpecialEffect Property (Access)

 Copy code hover
[image]

Section.SpecialEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.

Syntax

expression .SpecialEffect

expression A variable that represents a Section object.

Remarks

The SpecialEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | 0 | The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised | 1 | The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken | 2 | The object has a shadow on the top and left and a highlight on the bottom and right.
Etched | 3 | The object has a sunken line surrounding the control.
Shadowed | 4 | The object has a shadow below and to the right of the control.
Chiseled | 5 | The object has a sunken line below the control.

The SpecialEffect property setting affects related property settings for the BorderStyle , BorderColor , and BorderWidth properties. For example, if the SpecialEffect property is set to Raised, the settings for the BorderStyle, BorderColor, and BorderWidth properties are ignored. In addition, changing or setting the BorderStyle, BorderColor, and BorderWidth properties may cause Microsoft Access to change the SpecialEffect property setting to Flat.

Example

The following example sets the appearance of the text box "OrganizationName1" on the "Mailing List" form to raised.

VBA Copy code Copy code
Forms("Mailing List").Controls("OrganizationName1").SpecialEffect = 1

See also

Concepts

Section Object

Other resources

Section Object Members


ListBox.GridlineStyleRight Property (Access)

 Copy code hover
[image]

ListBox.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified list box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleRight

expression A variable that represents a ListBox object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


OptionButton Members (Access)

 Copy code hover
[image]

OptionButton Members (Access)
Send feedback

Published: July 16, 2012

An option button on a form or report is a stand-alone control used to display a Yes/No value from an underlying record source.

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the option button and its bottom gridline. Read/write Integer.
ColumnHidden | You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.
ColumnOrder | You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.
ColumnWidth | You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DefaultValue | Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
GridlineColor | Gets or sets the color of the gridline for the specified option button. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified option button. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified option button. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified option button. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified option button. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified option button. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified option button. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified option button. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified option button. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HideDuplicates | You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the option button is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified option button. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified option button. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the option button and its left gridline. Read/write Integer.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OptionValue | Each control in an option group has a numeric value that you can set with the OptionValue property. Read/write Long.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
RightPadding | Gets or sets the amount of space (in inches) between the option button and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the option button and its top gridline. Read/write Integer.
TripleState | You can use the TripleState property to specify how the specified control will display Null values. Read/write Boolean.
ValidationRule | You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.
ValidationText | Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.
Value | Determines or specifies whether or not the specified option button is selected. Read/write Variant.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified option button is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


Printers Object (Access)

 Copy code hover
[image]

Printers Object (Access)
See also Send feedback

Published: July 16, 2012

The Printers collection contains Printer objects representing all the printers available on the current system.

Remarks

Use the Printers property of the Application object to return the Printers collection. You can enumerate through the Printers collection by using the For Each...Next statement.

You can refer to an individual Printer object in the Printers collection either by referring to the printer by name, or by referring to its index within the collection.

The Printers collection is indexed beginning with zero. If you refer to a printer by its index, the first printer is Printers(0), the second printer is Printers(1), and so on.

You can't add or delete a Printer object from the Printers collection.

Example

The following example displays information about all the printers available to the system.

VBA Copy code Copy code
Dim prtLoop As Printer

For Each prtLoop In Application.Printers
 With prtLoop
 MsgBox "Device name: " & .DeviceName & vbCr _
 & "Driver name: " & .DriverName & vbCr _
 & "Port: " & .Port
 End With
Next prtLoop

See also

Concepts

Access Object Model Reference

Other resources

Printers Object Members


Synchronizing with a non-replicated database is not allowed. The

 Copy code hover
[image]

Synchronizing with a non-replicated database is not allowed. The <name> database is not a Design Master or replica. (Error 3605)
Send feedback

You are attempting to synchronize a replicated database with a non-replicated database or to synchronize two non-replicated databases. Only replicas made from the same replicated database can be synchronized.

If one of the databases has already been replicated, use it to create your second database replica.

If neither database has been replicated, select one of the databases to be used as the Design Master for the replica set. Open that database using Microsoft Access, go to the Tools menu, point to Replication, and click Create Replica. If Microsoft Access is not available but Microsoft Windows 95 Briefcase is available, drag the database into the Briefcase to create a replica. Do not attempt to replicate the second of the two original databases and then synchronize the two databases. The second database must be a replica of the first for synchronization to succeed.


Parameter.Properties Property (DAO)

 Copy code hover
[image]

Parameter.Properties Property (DAO)
Send feedback

Returns the Properties collection of the specified object. Read-only.

Syntax

expression .Properties

expression A variable that represents a Parameter object.


ComboBox.ListCount Property (Access)

 Copy code hover
[image]

ComboBox.ListCount Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ListCount property to determine the number of rows in the list box portion of a combo box. Read/write Long.

Syntax

expression .ListCount

expression A variable that represents a ComboBox object.

Remarks

Microsoft Access sets the ListCount property to the number of rows in the list box or the list box portion of the combo box. The value of the ListCount property is read-only and can't be set by the user.

This property is available only by using a macro or Visual Basic . You can read this property only in Form view and Datasheet view.

The ListCount property setting contains the total number of rows in the combo box list or list box, as determined by the control'sRowSource and RowSourceType properties. If the control is based on a table or query (the RowSourceType property is set to Table/Query and the RowSource property is set to a particular table or query), the ListCount property setting contains the number of records in the table or query result set. If the RowSourceType property is set to Value List, the ListCount property setting contains the number of rows the value list specified in the RowSource property results in (this depends on the value list and the number of columns in the list box or combo box list, as set by the ColumnCount property).

If you set the ColumnHeads property to Yes, the row of column headings is included in the number of rows returned by the ListCount property. For combo boxes and list boxes based on a table or query, adding column headings adds an additional row. For combo boxes and list boxes based on a value list, adding column headings leaves the number of rows unchanged (the first row of values becomes the column headings).

You can use the ListCount property with the ListRows property to specify how many rows you want to display in the list box portion of a combo box.

Example

The following example uses the ListCount property to find the number of rows in the list box portion of the CustomerList combo box on a Customers form. It then sets the ListRows property to display a specified number of rows in the list.

VBA Copy code Copy code
Public Sub SizeCustomerList()

 Dim ListControl As Control

 Set ListControl = Forms!Customers!CustomerList
 With ListControl
 If .ListCount < 8 Then
 .ListRows = .ListCount
 Else
 .ListRows = 8
 End If
 End With

End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Application.ImportNavigationPane Method (Access)

 Copy code hover
[image]

Application.ImportNavigationPane Method (Access)
See also Send feedback

Published: July 16, 2012

Loads a saved Navigation Pane configuration from disk.

Version Information

Version Added: Access 2007

Syntax

expression .ImportNavigationPane(Path, fAppendOnly)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Path | Required | String | The path and name of the XML file that contains the Navigation Pane configuration to load.
fAppendOnly | Optional | Boolean | Set to True to append the imported categories to the existing categories. The default value is False.

See also

Concepts

Application Object

Other resources

Application Object Members


Report.AllowLayoutView Property (Access)

 Copy code hover
[image]

Report.AllowLayoutView Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the specified report can be used in Layout View. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .AllowLayoutView

expression A variable that represents a Report object.

See also

Concepts

Report Object

Other resources

Report Object Members


No unique index found for the referenced field of the primary table. (Error 3609)

 Copy code hover
[image]

No unique index found for the referenced field of the primary table. (Error 3609)
Send feedback

When you create a relationship between tables, the referenced field in the primary table must have a unique index. See the Index object and Primary property topics for more details on how to do this.


Crosstab Query

 Copy code hover
[image]

Crosstab Query
Send feedback

Published: July 16, 2012

A crosstab query computes summary totals based on values for each row and column. It calculates a sum, average, count, or other type of total on records, and then groups the result by two types of information — one down the left side of the datasheet and the other across the top.


CancelUpdate Method Example (VBScript)

 Copy code hover
[image]

CancelUpdate Method Example (VBScript)
Send feedback

To test this example, cut and paste this code between the <Body> and </Body> tags in a normal HTML document and name it CancelUpdateVBS.asp. ASP script will identify your internet server. You will need to edit the name of the server to reflect your own setup. Simply change the value in the connect string from MyServer to the name of your SQL Server installation.

Copy code Copy code
<!-- BeginCancelUpdateVBS --><%@Language=VBScript%>
<%'Option Explicit%><% 'use the following META tag instead of adovbs.inc%>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" --><HTML>
<HEAD><META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE></HEAD>
<BODY><CENTER>
<H1>Remote Data Service</H1><H2>SubmitChanges and CancelUpdate Methods</H2>
<% ' to integrate/test this code replace the Server property value and' the Data Source value in the Connect property with appropriate values%>
<HR><OBJECT ID=RDS classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" HEIGHT=1 WIDTH=1></OBJECT>
<SCRIPT Language="VBScript">
'set RDS properties for control just created
RDS.Server = "http://<%=Request.ServerVariables("SERVER_NAME")%>"RDS.SQL = "Select * from Employees"
RDS.Connect = "Provider='sqloledb';Integrated Security='SSPI';Initial Catalog='Northwind';"RDS.Refresh
</SCRIPT>
<TABLE DATASRC=#RDS><THEAD>
<TR ID="ColHeaders"><TH>ID</TH>
<TH>FName</TH><TH>LName</TH>
<TH>Title</TH><TH>Hire Date</TH>
<TH>Birth Date</TH><TH>Extension</TH>
<TH>Home Phone</TH></TR>
</THEAD><TBODY>
<TR><TD> <INPUT DATAFLD="EmployeeID" size=4> </TD>
<TD> <INPUT DATAFLD="FirstName" size=10> </TD><TD> <INPUT DATAFLD="LastName" size=10> </TD>
<TD> <INPUT DATAFLD="Title" size=10> </TD><TD> <INPUT DATAFLD="HireDate" size=10> </TD>
<TD> <INPUT DATAFLD="BirthDate" size=10> </TD><TD> <INPUT DATAFLD="Extension" size=10> </TD>
<TD> <INPUT DATAFLD="HomePhone" size=8> </TD></TR>
</TBODY></TABLE>
<HR><INPUT TYPE=button NAME="SubmitChange" VALUE="Submit Changes">
<INPUT TYPE=button NAME="CancelChange" VALUE="Cancel Update"><BR>
<H4>Alter a current entry on the grid. Move off that Row. <BR>Submit the Changes to your DBMS or cancel the updates. </H4>
</CENTER><SCRIPT Language="VBScript">
Sub SubmitChange_OnClick
msgbox "Changes will be made"RDS.SubmitChanges
RDS.Refresh
End Sub
Sub CancelChange_OnClick
msgbox "Changes will be cancelled"RDS.CancelUpdate
RDS.Refresh
End Sub-->
</SCRIPT>

</BODY></HTML>
<!-- EndCancelUpdateVBS -->


This member of the replica set has been logically removed from the set and is no longer available. (Error 3569)

 Copy code hover
[image]

This member of the replica set has been logically removed from the set and is no longer available. (Error 3569)
Send feedback

The member of the replica set you are attempting to use has been removed because either it has not been synchronized within the required number of days (retention period) or it has been synchronized with a second Design Master. The member should be deleted from your computer.

If there is data in the member that has not been synchronized with any other member in the replica set, manually enter that data in another member. You can determine which records have unsynchronized data by examining the s_Generation field in each table. A value of 0 in the s_Generation field indicates the record is an inserted or updated and has not been synchronized with another replica in the set. To view the s_Generation field, open Microsoft Access, go to the Tools menu, click Options, select the View tab, and then select the System Objects check box.

If the member is the Design Master, compare the structure of the replica with another replica in the set to determine whether any design changes have not been synchronized.


Recordset.FindNext Method (DAO)

 Copy code hover
[image]

Recordset.FindNext Method (DAO)
Send feedback

Locates the next record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only).

Syntax

expression .FindNext(Criteria)

expression A variable that represents a Recordset object.

Parameters

Name | Required/Optional | Data Type | Description
Criteria | Required | String | A String used to locate the record. It is like the WHERE clause in an SQL statement, but without the word WHERE.

Remarks

If you want to include all the records in your search — not just those that meet a specific condition — use the Move methods to move from record to record. To locate a record in a table-type Recordset, use the Seek method.

If a record matching the criteria isn't located, the current record pointer is unknown, and the NoMatch property is set to True. If recordset contains more than one record that satisfies the criteria, FindFirst locates the first occurrence, FindNext locates the next occurrence, and so on.

Each of the Find methods begins its search from the location and in the direction specified in the following table.

Find method | Begins searching at | Search direction
FindFirst | Beginning of recordset | End of recordset
FindLast | End of recordset | Beginning of recordset
FindNext | Current record | End of recordset
FindPrevious | Current record | Beginning of recordset

Using one of the Find methods isn't the same as using a Move method, however, which simply makes the first, last, next, or previous record current without specifying a condition. You can follow a Find operation with a Move operation.

Always check the value of the NoMatch property to determine whether the Find operation has succeeded. If the search succeeds, NoMatch is False. If it fails, NoMatch is True and the current record isn't defined. In this case, you must position the current record pointer back to a valid record.

Using the Find methods with Microsoft Access database engine-connected ODBC-accessed recordsets can be inefficient. You may find that rephrasing your criteria to locate a specific record is faster, especially when working with large recordsets.

In an ODBCDirect workspace, the Find and Seek methods are not available on any type of Recordset object, because executing a Find or Seek through an ODBC connection is not very efficient over the network. Instead, you should design the query (that is, using the source argument to the OpenRecordset method) with an appropriate WHERE clause that restricts the returned records to only those that meet the criteria you would otherwise use in a Find or Seek method.

When working with Microsoft Access database engine-connected ODBC databases and large dynaset-type v objects, you might discover that using the Find methods or using the Sort or Filter property is slow. To improve performance, use SQL queries with customized ORDER BY or WHERE clauses, parameter queries, or QueryDef objects that retrieve specific indexed records.

You should use the U.S. date format (month-day-year) when you search for fields containing dates, even if you're not using the U.S. version of the Microsoft Access database engine; otherwise, the data may not be found. Use the Visual Basic Format function to convert the date. For example:

VBA Copy code Copy code
rstEmployees.FindFirst "HireDate > #" _
    & Format(mydate, 'm-d-yy' ) & "#"

If criteria is composed of a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strSQL = "PRICE > " & lngPrice, and lngPrice = 125,50), an error occurs when you try to call the method. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and Microsoft Access SQL only accepts U.S. decimal characters.

Note Note

  • For best performance, the criteria should be in either the form "field = value" where field is an indexed field in the underlying base table, or "field LIKE prefix" where field is an indexed field in the underlying base table and prefix is a prefix search string (for example, "ART*" ).

  • In general, for equivalent types of searches, the Seek method provides better performance than the Find methods. This assumes that table-type Recordset objects alone can satisfy your needs.

Example

The following example shows how to use the FindFirst and FindNext methods to find a record in a Recordset.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Sub FindOrgName()

    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset

    'Get the database and Recordset
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("tblCustomers")

    'Search for the first matching record
    rst.FindFirst "[OrgName] LIKE '*parts*'"

    'Check the result
    If rst.NoMatch Then
        MsgBox "Record not found."
        GotTo Cleanup
    Else
        Do While Not rst.NoMatch
            MsgBox "Customer name: " & rst!CustName
            rst.FindNext "[OrgName] LIKE '*parts*'"
        Loop

        'Search for the next matching record
        rst.FindNext "[OrgName] LIKE '*parts*'"
    End If

    Cleanup:
        rst.Close
        Set rst = Nothing
        Set dbs = Nothing

End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Field2.ValidationRule Property (DAO)

 Copy code hover
[image]

Field2.ValidationRule Property (DAO)
Send feedback

Sets or returns a value that validates the data in a field as it's changed or added to a table (Microsoft Access workspaces only). Read/write String.

Syntax

expression .ValidationRule

expression An expression that returns a Field2 object.

Remarks

The settings or return values is a String that describes a comparison in the form of an SQL WHERE clause without the WHERE reserved word. For an object not yet appended to the Fields collection, this property is read/write.

The ValidationRule property determines whether or not a field contains valid data. If the data is not valid, a trappable run-time error occurs. The returned error message is the text of the ValidationText property, if specified, or the text of the expression specified by ValidationRule.

For a Field2 object, use of the ValidationRule property depends on the object that contains the Fields collection to which the Field2 object is appended.

Object appended to | Usage
Index | Not supported
QueryDef | Read-only
Recordset | Read-only
Relation | Not supported
TableDef | Read/write

Validation is supported only for databases that use the Microsoft Access database engine.

The string expression specified by the ValidationRule property of a Field2 object can refer only to that Field2. The expression can't refer to user-defined functions, SQL aggregate functions, or queries. To set a Field2 object's ValidationRule property when its ValidateOnSet property setting is True, the expression must successfully parse (with the field name as an implied operand) and evaluate to True. If its ValidateOnSet property setting is False, the ValidationRule property setting is ignored.

Note Note

If you set the property to a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strRule = "PRICE > " & lngPrice, and lngPrice = 125,50), an error will result when your code attempts to validate any data. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and Microsoft Access database engine SQL only accepts U.S. decimal characters.


NavigationControl.BorderShade Property (Access)

 Copy code hover
[image]

NavigationControl.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents a NavigationControl object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


ActiveX Controls (Access)

 Copy code hover
[image]

ActiveX Controls (Access)
Send feedback

In this section

  • The ActiveX Control's Custom Properties Dialog Box

  • View an ActiveX Control's About Box


DoCmd.GoToRecord Method (Access)

 Copy code hover
[image]

DoCmd.GoToRecord Method (Access)
See also Send feedback

Published: July 16, 2012

The GoToRecord method carries out the GoToRecord action in Visual Basic.

Syntax

expression .GoToRecord(ObjectType, ObjectName, Record, Offset)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
ObjectType | Optional | AcDataObjectType | A AcDataObjectType constant that specifies the type of object that contains the record you want to make current.
ObjectName | Optional | Variant | A string expression that's the valid name of an object of the type selected by the objecttype argument.
Record | Optional | AcRecord | A AcRecord constant that specifies the record to make the current record. The default value is acNext.
Offset | Optional | Variant | A numeric expression that represents the number of records to move forward or backward if you specify acNext or acPrevious for the record argument, or the record to move to if you specify acGoTo for the record argument. The expression must result in a valid record number.

Remarks

You can use the GoToRecord method to make the specified record the current record in an open table, form, or query result set.

If you leave the objecttype and objectname arguments blank (the default constant, acActiveDataObject, is assumed for objecttype), the active object is assumed.

You can use the GoToRecord method to make a record on a hidden form the current record if you specify the hidden form in the objecttype and objectname arguments.

Example

The following example uses the GoToRecord method to make the seventh record in the form Employees current:

VBA Copy code Copy code
DoCmd.GoToRecord acDataForm, "Employees", acGoTo, 7

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


ActiveConnection Property (ADO)

 Copy code hover
[image]

ActiveConnection Property (ADO)
Send feedback

Indicates to which Connection object the specified Command, Recordset, or Record object currently belongs.

Settings and Return Values

Sets or returns a String value that contains a definition for a connection if the connection is closed, or a Variant containing the current Connection object if the connection is open. Default is a null object reference. See the ConnectionString property.

Remarks

Use the ActiveConnection property to determine the Connection object over which the specified Command object will execute or the specified Recordset will be opened.

Command

For Command objects, the ActiveConnection property is read/write.

If you attempt to call the Execute method on a Command object before setting this property to an open Connection object or valid connection string, an error occurs.

Microsoft Visual BasicSetting the ActiveConnection property to Nothing disassociates the Command object from the current Connection and causes the provider to release any associated resources on the data source. You can then associate the Command object with the same or another Connection object. Some providers allow you to change the property setting from one Connection to another, without having to first set the property to Nothing.

If the Parameters collection of the Command object contains parameters supplied by the provider, the collection is cleared if you set the ActiveConnection property to Nothing or to another Connection object. If you manually create Parameter objects and use them to fill the Parameters collection of the Command object, setting the ActiveConnection property to Nothing or to another Connection object leaves the Parameters collection intact.

Closing the Connection object with which a Command object is associated sets the ActiveConnection property to Nothing. Setting this property to a closed Connection object generates an error.

Recordset

For open Recordset objects or for Recordset objects whose Source property is set to a valid Command object, the ActiveConnection property is read-only. Otherwise, it is read/write.

You can set this property to a valid Connection object or to a valid connection string. In this case, the provider creates a new Connection object using this definition and opens the connection. Additionally, the provider may set this property to the new Connection object to give you a way to access the Connection object for extended error information or to execute other commands.

If you use the ActiveConnection argument of the Open method to open a Recordset object, the ActiveConnection property will inherit the value of the argument.

If you set the Source property of the Recordset object to a valid Command object variable, the ActiveConnection property of the Recordset inherits the setting of the Command object's ActiveConnection property.

Remote Data Service UsageWhen used on a client-side Recordset object, this property can be set only to a connection string or (in Microsoft Visual Basic or Visual Basic, Scripting Edition) to Nothing.

Record

This property is read/write when the Record object is closed, and may contain a connection string or reference to an open Connection object. This property is read-only when the Record object is open, and contains a reference to an open Connection object.

A Connection object is created implicitly when the Record object is opened from a URL. Open the Record with an existing, open Connection object by assigning the Connection object to this property, or using the Connection object as a parameter in the Open method call. If the Record is opened from an existing Record or Recordset, then it is automatically associated with that Record or Recordset object's Connection object.

Note Note

URLs using the http scheme will automatically invoke the Microsoft OLE DB Provider for Internet Publishing. For more information, see Absolute and Relative URLs.


Report.KeyUp Event (Access)

 Copy code hover
[image]

Report.KeyUp Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyUp event occurs when the user releases a key while a report has the focus. This event also occurs if you send a keystroke to a report by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyUp(KeyCode, Shift)

expression A variable that represents a Report object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyUp property to the name of the macro or to [Event Procedure].

A report will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the report to Yes. With this property setting, all keyboard events occur first for the report, and then for the control that has the focus. You can respond to specific keys pressed in the report, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a report.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, and then the KeyUp event occurs.

Although the KeyUp event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

See also

Concepts

Report Object

Other resources

Report Object Members


TabControl.GridlineColor Property (Access)

 Copy code hover
[image]

TabControl.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified list box. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineColor

expression A variable that represents a TabControl object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Form.AllowPivotChartView Property (Access)

 Copy code hover
[image]

Form.AllowPivotChartView Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Boolean indicating whether the specified form may be viewed in PivotChart View. True if PivotChart View is allowed. Read/write.

Syntax

expression .AllowPivotChartView

expression A variable that represents a Form object.

Remarks

Use the AllowDatasheetView , AllowPivotChartView , AllowPivotChartView, or AllowPivotTableView properties to control which views are allowed for a form.

Example

The following example makes PivotChart View valid for the specified form and then opens the form in PivotChart View.

VBA Copy code Copy code
Forms(0).AllowPivotChartView = True
DoCmd.OpenForm FormName:=Forms(0).Name, View:=acFormPivotChart

See also

Concepts

Form Object

Other resources

Form Object Members


Index file not found. (Error 3256)

 Copy code hover
[image]

Index file not found. (Error 3256)
Send feedback

You tried to access a dBASE table, but one of the indexes listed in the table's associated .inf file could not be found. The index may have been renamed, moved, or deleted. Either relink the table, or use Microsoft Windows Notepad or another text editor to update the .inf file.


Field Object Reference (DAO)

 Copy code hover
[image]

Field Object Reference (DAO)
Send feedback

In this section

  • Field Object (DAO)

  • Field Members (DAO)

  • Field Properties (DAO)

  • Field Methods (DAO)


ReturnVar.Value Property (Access)

 Copy code hover
[image]

ReturnVar.Value Property (Access)
Send feedback

Published: July 16, 2012

Gets the value of the specified ReturnVar. Read-only Variant.

Version Information

Version Added: Access 2010

Syntax

expression .Value

expression A variable that represents a ReturnVar object.

Remarks

A ReturnVar can store only numeric or text data. Setting the Value property to an Object data type will result in a run-time error.


AllowSpecialKeys Property

 Copy code hover
[image]

AllowSpecialKeys Property
Send feedback

Published: July 16, 2012

You can use the AllowSpecialKeys property to specify whether or not special key sequences (ALT+F1 (F11), CTRL+F11, CTRL+BREAK, and CTRL+G) are disabled or enabled. For example, you can use the AllowSpecialKeys property to prevent a user from displaying the Database window by pressing F11, entering break mode within a Visual Basic module by pressing CTRL+BREAK, or displaying the Immediate window by pressing CTRL+G.

Setting

The AllowSpecialKeys property uses the following settings.

Setting | Description
True (-1) | Enable the special key sequences.
False (0) | Disable the special key sequences.

The easiest way to set this property is by using the Use Access Special Keys option in the Current Database section of the Access Options dialog box. To view the Access Options dialog box, click the Microsoft Office button [image] and then click Access Options. In a Microsoft Access database , you can also set this property by using a macro or Visual Basic .

To set the AllowSpecialKeys property by using a macro or Visual Basic, you must first either set the property in the Access Options dialog box once or create the property in the following ways:

  • In a Microsoft Access database, you can add it by using the CreateProperty method and append it to the Properties collection of the Database object.

  • In a Microsoft Access project (.adp), you can add it to the AccessObjectProperties collection of the CurrentProject object by using the Add method.

Remarks

You should make sure the AllowSpecialKeys property is set to True when debugging an application.

The AllowSpecialKeys property affects the following key sequences.

Key sequences | Effect
ALT+F1 (F11) | Display the Navigation Pane.
CTRL+G | Display the Immediate window.
CTRL+F11 | Toggle between the custom menu bar and the built-in menu bar.
CTRL+BREAK | Enter break mode and display the current module in the Code window.

This property's setting doesn't take effect until the next time the application database opens.


OptionButton.KeyUp Event (Access)

 Copy code hover
[image]

OptionButton.KeyUp Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyUp(KeyCode, Shift)

expression A variable that represents an OptionButton object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyUp property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyUp event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyUp event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Object is invalid or no longer set. (Error 3420)

 Copy code hover
[image]

Object is invalid or no longer set. (Error 3420)
Send feedback

You are attempting to reference an object that is no longer valid or has not been set.

Possible causes:

  • The object has been closed.

  • The object has been orphaned (the parent object has been closed or deleted).

  • The object is out of scope.

  • The object library is not registered in the Microsoft Windows Registry.

  • You are trying to reference a method or property of the collection, but you have not assigned it to a variable first. For example, to reference the Name property, use the following:

    VBA Copy code Copy code
    Dim dbsPublish As Database
Set dbsPublish = OpenDatabase("BIBLIO.mdb")
dbname = dbsPublish.Name


Table Object (ADOX) Reference

 Copy code hover
[image]

Table Object (ADOX) Reference
Send feedback

In this section

  • Table Object (ADOX)

  • Table Properties, Methods, and Events (ADOX)


AllReports Object (Access)

 Copy code hover
[image]

AllReports Object (Access)
See also Send feedback

Published: July 16, 2012

The AllReports collection contains an AccessObject for each report in the CurrentProject or CodeProject object.

Remarks

The CurrentProject or CodeProject object has an AllReports collection containing AccessObject objects that describe instances of all the reports in the database. For example, you can enumerate the AllReports collection in Visual Basic to set or return the values of properties of individual AccessObject objects in the collection.

You can refer to an individual AccessObject object in the AllReports collection either by referring to the item by name, or by referring to its index within the collection. If you want to refer to a specific report in the AllReports collection, it's better to refer to the item by name because the index may change.

The AllReports collection is indexed beginning with zero. If you refer to a report by its index, the first report is AllReports(0), the second report is AllReports(1), and so on.

Note Note

To list all open reports in the database, use the IsLoaded property of each AccessObject object in the AllReports collection. You can then use the Name property of each individual AccessObject object to return the name of a report.

You can't add or delete an AccessObject object from the AllReports collection.

Example

The following example prints the name of each open AccessObject object in the AllReports collection.

VBA Copy code Copy code
Sub AllReports()
 Dim obj As AccessObject, dbs As Object
 Set dbs = Application.CurrentProject
 ' Search for open AccessObject objects in AllReports collection.
 For Each obj In dbs.AllReports
 If obj.IsLoaded = True Then
 ' Print name of obj.
 Debug.Print obj.Name
 End If
 Next obj
End Sub

See also

Concepts

Access Object Model Reference

Other resources

AllReports Object Members


Image.BackColor Property (Access)

 Copy code hover
[image]

Image.BackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the interior color of the specified object. Read/write Long.

Syntax

expression .BackColor

expression A variable that represents an Image object.

Remarks

The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

To use the BackColor property, the BackStyle property, if available, must be set to Normal.

Example

The following example uses the RGB function to set the , BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

Image Object

Other resources

Image Object Members


TextBox.OldBorderStyle Property (Access)

 Copy code hover
[image]

TextBox.OldBorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.

Syntax

expression .OldBorderStyle

expression A variable that represents a TextBox object.

Remarks

The OldBorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines
Note Note

  • If the OldBorderStyle property is set to None or Dialog, the form doesn't have Maximize or Minimize buttons, regardless of its MinMaxButtons property setting.

  • If the OldBorderStyle property is set to None, the form doesn't have a Control menu, regardless of its ControlBox property setting.

  • The OldBorderStyle property setting doesn't affect the display of the scroll bars, navigation buttons, the record number box, or record selectors.

Example

The following example demonstrates the effect of changing a control's BorderStyle property, while leaving the OldBorderStyle unaffected. The example concludes with setting the BorderStyle property to its original unedited value.

VBA Copy code Copy code
With Forms("Order Entry").Controls("Zip Code") .BorderStyle = 3 ' Short dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 3, 1.

    .BorderStyle = 2 ' Dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 2, 1

    .BorderStyle = .OldBorderStyle ' Solid (default) border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 1, 1
End With

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


FormatConditions.Add Method (Access)

 Copy code hover
[image]

FormatConditions.Add Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the Add method to add a conditional format as a FormatCondition object to the FormatConditions collection of a combo box or text box control.

Syntax

expression .Add(Type, Operator, Expression1, Expression2)

expression A variable that represents a FormatConditions object.

Parameters

Name | Required/Optional | Data Type | Description
Type | Required | AcFormatConditionType | An AcFormatConditionType constant that specifies the type of format condition to be added.
Operator | Optional | AcFormatConditionOperator | An AcFormatConditionOperator constant that specified the operator. If the Type argument is acExpression, the Operator argument is ignored. If you leave this argument blank, the default constant (acBetween) is assumed.
Expression1 | Optional | Variant | A value or expression associated with the first part of the conditional format. Can be a constant or a string value.
Expression2 | Optional | Variant | A value or expression associated with the second part of the conditional format when the Operator argument is acBetween or acNotBetween (otherwise, this argument is ignored). Can be a constant or a string value.

Return Value

FormatCondition

Remarks

You can use the Delete method of the FormatConditions collection to delete an existing FormatConditions collection from a combo box or text box control.

See also

Concepts

FormatConditions Collection

Other resources

FormatConditions Object Members


ListBox.IsVisible Property (Access)

 Copy code hover
[image]

ListBox.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Syntax

expression .IsVisible

expression A variable that represents a ListBox object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


SubdatasheetName Property

 Copy code hover
[image]

SubdatasheetName Property
Send feedback

Published: July 16, 2012

You can use the SubdatasheetName property to specify or determine the table or query that is bound to the subdatasheet.

Note Note

The SubdatasheetName property applies only to tables and queries within a Microsoft Access database.

Setting

The SubdatasheetName property in a string expression representing the name of the table or query bound to the subdatasheet.

The easiest way to set the SubdatasheetName property is by using a table's property sheet. You can set this property by using Visual Basic.

To set the SubdatasheetName property by using Visual Basic, you must first either:

  • Set the property in table Design view.

  • Create the property by using the DAO CreateProperty method.


OptionButton.MouseDown Event (Access)

 Copy code hover
[image]

OptionButton.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents an OptionButton object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
         Shift As Integer, X As Single, _
         Y As Single)
    If Button = acLeftButton Then
        MsgBox "You pressed the left button."
    End If
    If Button = acRightButton Then
        MsgBox "You pressed the right button."
    End If
    If Button = acMiddleButton Then
        MsgBox "You pressed the middle button."
    End If
End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Field2.ValidationText Property (DAO)

 Copy code hover
[image]

Field2.ValidationText Property (DAO)
Send feedback

Sets or returns a value that specifies the text of the message that your application displays if the value of a Field2 object doesn't satisfy the validation rule specified by the ValidationRule property setting (Microsoft Access workspaces only). Read/write String.

Syntax

expression .ValidationText

expression A variable that represents a Field2 object.

Remarks

The setting or return value is a String that specifies the text displayed if a user tries to enter an invalid value for a field. For an object not yet appended to a collection, this property is read/write.

For a Field2 object, use of the ValidationText property depends on the object that contains the Fields collection to which the Field2 object is appended, as the following table shows.

Object appended to | Usage
Index | Not supported
QueryDef | Read-only
Recordset | Read-only
Relation | Not supported
TableDef | Read/write


SchemaEnum

 Copy code hover
[image]

SchemaEnum
Send feedback

Specifies the type of schema Recordset that the OpenSchema method retrieves.

Remarks

Additional information about the function and columns returned for each ADO constant can be found in topics of Appendix B of the OLE DB Programmers Reference. The name of each topic is listed in parentheses in the Description section of the table below.

Additional information about the function and columns returned for each ADO MD constant can be found in topics of Chapter 23 of the OLE DB for OLAP documentation. The name of each topic is listed in parentheses and marked with an asterisk (*) in the Description column of the table below.

Translate the data types of columns in the OLE DB documentation to ADO data types by referring to the Description column of the ADO DataTypeEnum topic. For example, an OLE DB data type of DBTYPE_WSTR is equivalent to an ADO data type of adWChar.

ADO generates schema-like results for the constants, adSchemaDBInfoKeywords and adSchemaDBInfoLiterals. ADO creates a Recordset, then fills each row with the values returned respectively by the IDBInfo::GetKeywords and IDBInfo::GetLiteralInfo methods. Additional information about these methods can be found in the IDBInfo section of the OLE DB Programmer's Reference.

Constant | Value | Description | Constraint Columns
adSchemaAsserts | 0 | Returns the assertions defined in the catalog that are owned by a given user. (ASSERTIONS Rowset) | CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME
adSchemaCatalogs | 1 | Returns the physical attributes associated with catalogs accessible from the DBMS. (CATALOGS Rowset) | CATALOG_NAME
adSchemaCharacterSets | 2 | Returns the character sets defined in the catalog that are accessible to a given user. (CHARACTER_SETS Rowset) | CHARACTER_SET_CATALOG CHARACTER_SET_SCHEMA CHARACTER_SET_NAME
adSchemaCheckConstraints | 5 | Returns the check constraints defined in the catalog that are owned by a given user. (CHECK_CONSTRAINTS Rowset) | CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME
adSchemaCollations | 3 | Returns the character collations defined in the catalog that are accessible to a given user. (COLLATIONS Rowset) | COLLATION_CATALOG COLLATION_SCHEMA COLLATION_NAME
adSchemaColumnPrivileges | 13 | Returns the privileges on columns of tables defined in the catalog that are available to, or granted by, a given user. (COLUMN_PRIVILEGES Rowset) | TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME GRANTOR GRANTEE
adSchemaColumns | 4 | Returns the columns of tables (including views) defined in the catalog that are accessible to a given user. (COLUMNS Rowset) | TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME
adSchemaColumnsDomainUsage | 11 | Returns the columns defined in the catalog that are dependent on a domain defined in the catalog and owned by a given user. (COLUMN_DOMAIN_USAGE Rowset) | DOMAIN_CATALOG DOMAIN_SCHEMA DOMAIN_NAME COLUMN_NAME
adSchemaConstraintColumnUsage | 6 | Returns the columns used by referential constraints, unique constraints, check constraints, and assertions, defined in the catalog and owned by a given user. (CONSTRAINT_COLUMN_USAGE Rowset) | TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME
adSchemaConstraintTableUsage | 7 | Returns the tables that are used by referential constraints, unique constraints, check constraints, and assertions defined in the catalog and owned by a given user. (CONSTRAINT_TABLE_USAGE Rowset) | TABLE_CATALOG TABLE_SCHEMA TABLE_NAME
adSchemaCubes | 32 | Returns information about the available cubes in a schema (or the catalog, if the provider does not support schemas). (CUBES Rowset*) | CATALOG_NAME SCHEMA_NAME CUBE_NAME
adSchemaDBInfoKeywords | 30 | Returns a list of provider-specific keywords. (IDBInfo::GetKeywords *) | <None>
adSchemaDBInfoLiterals | 31 | Returns a list of provider-specific literals used in text commands. (IDBInfo::GetLiteralInfo *) | <None>
adSchemaDimensions | 33 | Returns information about the dimensions in a given cube. It has one row for each dimension. (DIMENSIONS Rowset *) | CATALOG_NAME SCHEMA_NAME CUBE_NAME DIMENSION_NAME DIMENSION_UNIQUE_NAME
adSchemaForeignKeys | 27 | Returns the foreign key columns defined in the catalog by a given user. (FOREIGN_KEYS Rowset) | PK_TABLE_CATALOG PK_TABLE_SCHEMA PK_TABLE_NAME FK_TABLE_CATALOG FK_TABLE_SCHEMA FK_TABLE_NAME
adSchemaHierarchies | 34 | Returns information about the hierarchies available in a dimension. (HIERARCHIES Rowset *) | CATALOG_NAME SCHEMA_NAME CUBE_NAME DIMENSION_UNIQUE_NAME HIERARCHY_NAME HIERARCHY_UNIQUE_NAME
adSchemaIndexes | 12 | Returns the indexes defined in the catalog that are owned by a given user. (INDEXES Rowset) | TABLE_CATALOG TABLE_SCHEMA INDEX_NAME TYPE TABLE_NAME
adSchemaKeyColumnUsage | 8 | Returns the columns defined in the catalog that are constrained as keys by a given user. (KEY_COLUMN_USAGE Rowset) | CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME
adSchemaLevels | 35 | Returns information about the levels available in a dimension. (LEVELS Rowset*) | CATALOG_NAME SCHEMA_NAME CUBE_NAME DIMENSION_UNIQUE_NAME HIERARCHY_UNIQUE_NAME LEVEL_NAME LEVEL_UNIQUE_NAME
adSchemaMeasures | 36 | Returns information about the available measures. (MEASURES Rowset *) | CATALOG_NAME SCHEMA_NAME CUBE_NAME MEASURE_NAME MEASURE_UNIQUE_NAME
adSchemaMembers | 38 | Returns information about the available members. (MEMBERS Rowset *) | CATALOG_NAME SCHEMA_NAME CUBE_NAME DIMENSION_UNIQUE_NAME HIERARCHY_UNIQUE_NAME LEVEL_UNIQUE_NAME LEVEL_NUMBER MEMBER_NAME MEMBER_UNIQUE_NAME MEMBER_CAPTION MEMBER_TYPE Tree operator (For more information, see the OLE DB for OLAP documentation.)
adSchemaPrimaryKeys | 28 | Returns the primary key columns defined in the catalog by a given user. (PRIMARY_KEYS Rowset) | PK_TABLE_CATALOG PK_TABLE_SCHEMA PK_TABLE_NAME
adSchemaProcedureColumns | 29 | Returns information about the columns of rowsets returned by procedures. (PROCEDURE_COLUMNS Rowset) | PROCEDURE_CATALOG PROCEDURE_SCHEMA PROCEDURE_NAME COLUMN_NAME
adSchemaProcedureParameters | 26 | Returns information about the parameters and return codes of procedures. (PROCEDURE_PARAMETERS Rowset) | PROCEDURE_CATALOG PROCEDURE_SCHEMA PROCEDURE_NAME PARAMETER_NAME
adSchemaProcedures | 16 | Returns the procedures defined in the catalog that are owned by a given user. (PROCEDURES Rowset) | PROCEDURE_CATALOG PROCEDURE_SCHEMA PROCEDURE_NAME PROCEDURE_TYPE
adSchemaProperties | 37 | Returns information about the available properties for each level of the dimension. (PROPERTIES Rowset *) | CATALOG_NAME SCHEMA_NAME CUBE_NAME DIMENSION_UNIQUE_NAME HIERARCHY_UNIQUE_NAME LEVEL_UNIQUE_NAME MEMBER_UNIQUE_NAME PROPERTY_TYPE PROPERTY_NAME
adSchemaProviderSpecific | -1 | Used if the provider defines its own nonstandard schema queries. | <Provider specific>
adSchemaProviderTypes | 22 | Returns the (base) data types supported by the data provider. (PROVIDER_TYPES Rowset) | DATA_TYPE BEST_MATCH
AdSchemaReferentialConstraints | 9 | Returns the referential constraints defined in the catalog that are owned by a given user. (REFERENTIAL_CONSTRAINTS Rowset) | CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME
adSchemaSchemata | 17 | Returns the schemas (database objects) that are owned by a given user. (SCHEMATA Rowset) | CATALOG_NAME SCHEMA_NAME SCHEMA_OWNER
adSchemaSQLLanguages | 18 | Returns the conformance levels, options, and dialects supported by the SQL-implementation processing data defined in the catalog. (SQL_LANGUAGES Rowset) | <None>
adSchemaStatistics | 19 | Returns the statistics defined in the catalog that are owned by a given user. (STATISTICS Rowset) | TABLE_CATALOG TABLE_SCHEMA TABLE_NAME
adSchemaTableConstraints | 10 | Returns the table constraints defined in the catalog that are owned by a given user. (TABLE_CONSTRAINTS Rowset) | CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
adSchemaTablePrivileges | 14 | Returns the privileges on tables defined in the catalog that are available to, or granted by, a given user. (TABLE_PRIVILEGES Rowset) | TABLE_CATALOG TABLE_SCHEMA TABLE_NAME GRANTOR GRANTEE
adSchemaTables | 20 | Returns the tables (including views) defined in the catalog that are accessible to a given user. (TABLES Rowset) | TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE
adSchemaTranslations | 21 | Returns the character translations defined in the catalog that are accessible to a given user. (TRANSLATIONS Rowset) | TRANSLATION_CATALOG TRANSLATION_SCHEMA TRANSLATION_NAME
adSchemaTrustees | 39 | Reserved for future use. |
adSchemaUsagePrivileges | 15 | Returns the USAGE privileges on objects defined in the catalog that are available to, or granted by, a given user. (USAGE_PRIVILEGES Rowset) | OBJECT_CATALOG OBJECT_SCHEMA OBJECT_NAME OBJECT_TYPE GRANTOR GRANTEE
adSchemaViewColumnUsage | 24 | Returns the columns on which viewed tables, defined in the catalog and owned by a given user, are dependent. (VIEW_COLUMN_USAGE Rowset) | VIEW_CATALOG VIEW_SCHEMA VIEW_NAME
adSchemaViews | 23 | Returns the views defined in the catalog that are accessible to a given user. (VIEWS Rowset) | TABLE_CATALOG TABLE_SCHEMA TABLE_NAME
adSchemaViewTableUsage | 25 | Returns the tables on which viewed tables, defined in the catalog and owned by a given user, are dependent. (VIEW_TABLE_USAGE Rowset) | VIEW_CATALOG VIEW_SCHEMA VIEW_NAME

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.Schema.ASSERTS

AdoEnums.Schema.CATALOGS

AdoEnums.Schema.CHARACTERSETS

AdoEnums.Schema.CHECKCONSTRAINTS

AdoEnums.Schema.COLLATIONS

AdoEnums.Schema.COLUMNPRIVILEGES

AdoEnums.Schema.COLUMNS

AdoEnums.Schema.COLUMNSDOMAINUSAGE

AdoEnums.Schema.CONSTRAINTCOLUMNUSAGE

AdoEnums.Schema.CONSTRAINTTABLEUSAGE

AdoEnums.Schema.CUBES

AdoEnums.Schema.DBINFOKEYWORDS

AdoEnums.Schema.DBINFOLITERALS

AdoEnums.Schema.DIMENSIONS

AdoEnums.Schema.FOREIGNKEYS

AdoEnums.Schema.HIERARCHIES

AdoEnums.Schema.INDEXES

AdoEnums.Schema.KEYCOLUMNUSAGE

AdoEnums.Schema.LEVELS

AdoEnums.Schema.MEASURES

AdoEnums.Schema.MEMBERS

AdoEnums.Schema.PRIMARYKEYS

AdoEnums.Schema.PROCEDURECOLUMNS

AdoEnums.Schema.PROCEDUREPARAMETERS

AdoEnums.Schema.PROCEDURES

AdoEnums.Schema.PROPERTIES

AdoEnums.Schema.PROVIDERSPECIFIC

AdoEnums.Schema.PROVIDERTYPES

AdoEnums.Schema.REFERENTIALCONTRAINTS

AdoEnums.Schema.SCHEMATA

AdoEnums.Schema.SQLLANGUAGES

AdoEnums.Schema.STATISTICS

AdoEnums.Schema.TABLECONSTRAINTS

AdoEnums.Schema.TABLEPRIVILEGES

AdoEnums.Schema.TABLES

AdoEnums.Schema.TRANSLATIONS

AdoEnums.Schema.TRUSTEES

AdoEnums.Schema.USAGEPRIVILEGES

AdoEnums.Schema.VIEWCOLUMNUSAGE

AdoEnums.Schema.VIEWS

AdoEnums.Schema.VIEWTABLEUSAGE


CheckBox.HorizontalAnchor Property (Access)

 Copy code hover
[image]

CheckBox.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the check box is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .HorizontalAnchor

expression A variable that represents a CheckBox object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


EmptyCell Object (Access)

 Copy code hover
[image]

EmptyCell Object (Access)
See also Send feedback

Published: July 16, 2012

Represents an empty cell in a control layout.

Version Information

Version Added: Access 2010

Remarks

An EmptyCell object is created when a control layout contains an empty cell. You cannot explicitly create or delete an EmptyCell object.

When you type inside an empty cell, Microsoft Access automatically inserts a Label control.

See also

Concepts

Access Object Model Reference

Other resources

EmptyCell Object Members


QueryDefs Collection (DAO)

 Copy code hover
[image]

QueryDefs Collection (DAO)
Send feedback

A QueryDefs collection contains all QueryDef objects of a Database object in a Microsoft Access database engine database.

Remarks

To create a new QueryDef object, use the CreateQueryDef method. In a Microsoft Access workspace, if you supply a string for the name argument or if you explicitly set the Name property of the new QueryDef object to a non-zero-length string, you will create a permanent QueryDef that will automatically be appended to the QueryDefs collection and saved to disk. Supplying a zero-length string as the name argument or explicitly setting the Name property to a zero-length string will result in a temporary QueryDef object.

To refer to a QueryDef object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

QueryDefs(0)

QueryDefs("name")

QueryDefs![name]

You can refer to temporary QueryDef objects only by the object variables that you have assigned to them.

Example

This example creates a new QueryDef object and appends it to the QueryDefs collection of the Northwind Database object. It then enumerates the QueryDefs collection and the Properties collection of the new QueryDef.

VBA Copy code Copy code
Sub QueryDefX()

   Dim dbsNorthwind As Database
   Dim qdfNew As QueryDef
   Dim qdfLoop As QueryDef
   Dim prpLoop As Property

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   ' Create new QueryDef object. Because it has a
   ' name, it is automatically appended to the
   ' QueryDefs collection.
   Set qdfNew = dbsNorthwind.CreateQueryDef("NewQueryDef", _
         "SELECT * FROM Categories")

   With dbsNorthwind
      Debug.Print .QueryDefs.Count & _
         " QueryDefs in " & .Name

      ' Enumerate QueryDefs collection.
      For Each qdfLoop In .QueryDefs
         Debug.Print "  " & qdfLoop.Name
      Next qdfLoop

      With qdfNew
         Debug.Print "Properties of " & .Name

         ' Enumerate Properties collection of new
         ' QueryDef object.
         For Each prpLoop In .Properties
            On Error Resume Next
            Debug.Print "  " & prpLoop.Name & " - " & _
               IIf(prpLoop = "", "[empty]", prpLoop)
            On Error Goto 0
         Next prpLoop
      End With

      ' Delete new QueryDef because this is a
      ' demonstration.
      .QueryDefs.Delete qdfNew.Name
      .Close
   End With

End Sub

This example uses the CreateQueryDef method to create and execute both a temporary and a permanent QueryDef. The GetrstTemp function is required for this procedure to run.

VBA Copy code Copy code
Sub CreateQueryDefX()

   Dim dbsNorthwind As Database
   Dim qdfTemp As QueryDef
   Dim qdfNew As QueryDef

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   With dbsNorthwind
      ' Create temporary QueryDef.
      Set qdfTemp = .CreateQueryDef("", _
         "SELECT * FROM Employees")
      ' Open Recordset and print report.
      GetrstTemp qdfTemp
      ' Create permanent QueryDef.
      Set qdfNew = .CreateQueryDef("NewQueryDef", _
         "SELECT * FROM Categories")
      ' Open Recordset and print report.
      GetrstTemp qdfNew
      ' Delete new QueryDef because this is a demonstration.
      .QueryDefs.Delete qdfNew.Name
      .Close
   End With

End Sub

Function GetrstTemp(qdfTemp As QueryDef)

   Dim rstTemp As Recordset

   With qdfTemp
      Debug.Print .Name
      Debug.Print "  " & .SQL
      ' Open Recordset from QueryDef.
      Set rstTemp = .OpenRecordset(dbOpenSnapshot)

      With rstTemp
         ' Populate Recordset and print number of records.
         .MoveLast
         Debug.Print "  Number of records = " & _
            .RecordCount
         Debug.Print
         .Close
      End With

   End With

End Function

The following example shows how to execute a parameter query. The Parameters collection is used to set the Organization parameter of the myActionQuery query before the query is executed.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Public Sub ExecParameterQuery()

    Dim dbs As DAO.Database
    Dim qdf As DAO.QueryDef

    Set dbs = CurrentDb
    Set qdf = dbs.QueryDefs("myActionQuery")

    'Set the value of the QueryDef's parameter
    qdf.Parameters("Organization").Value = "Microsoft"

    'Execute the query
    qdf.Execute dbFailOnError

    'Clean up
    qdf.Close
    Set qdf = Nothing
    Set dbs = Nothing

End Sub

The following example shows how to open a Recordset that is based on a parameter query.

VBA Copy code Copy code
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset

Set dbs = CurrentDb

'Get the parameter query
Set qfd = dbs.QueryDefs("qryMyParameterQuery")

'Supply the parameter value
qdf.Parameters("EnterStartDate") = Date
qdf.Parameters("EnterEndDate") = Date + 7

'Open a Recordset based on the parameter query
Set rst = qdf.OpenRecordset()

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Image.GridlineStyleTop Property (Access)

 Copy code hover
[image]

Image.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified image control. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleTop

expression A variable that represents an Image object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

Image Object

Other resources

Image Object Members


You cannot make a database replicable that is being used by a program that controls modification. (Error 3638)

 Copy code hover
[image]

You cannot make a database replicable that is being used by a program that controls modification. (Error 3638)
Send feedback

The database you are trying to replicate is controlled by a database program that does not support replication. To be able to make the database replicable you must ensure it is not being controlled by the source control program.


Form.Properties Property (Access)

 Copy code hover
[image]

Form.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a Form object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


CheckBox.MouseDown Event (Access)

 Copy code hover
[image]

CheckBox.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents a CheckBox object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
         Shift As Integer, X As Single, _
         Y As Single)
    If Button = acLeftButton Then
        MsgBox "You pressed the left button."
    End If
    If Button = acRightButton Then
        MsgBox "You pressed the right button."
    End If
    If Button = acMiddleButton Then
        MsgBox "You pressed the middle button."
    End If
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


NavigationControl.Enabled Property (Access)

 Copy code hover
[image]

NavigationControl.Enabled Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .Enabled

expression A variable that represents a NavigationControl object.

Remarks

The Enabled property setting is a value that indicates whether the conditional format is enabled or disabled. True enables the conditional format. False disables the conditional format. The default is True.

When the Enabled property is True, the conditional format can be displayed in the Conditional Formatting dialog box.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Set References to Type Libraries

 Copy code hover
[image]

Set References to Type Libraries
Send feedback

When you set a reference to another application's type library, you can use the objects supplied by that application in your code. For example, if you set a reference from Microsoft Access to the Microsoft Excel library, you can then use Microsoft Excel objects through Automation (formerly called OLE Automation). If you set a reference to a Visual Basic project in another Microsoft Access database, you can call its public procedures. If you set a reference to an ActiveX control, you can use that control on Microsoft Access forms.

You can set a reference from Microsoft Access while the Microsoft Visual Basic Editor is open, or you can set a reference in Visual Basic code.

Setting a Reference from Microsoft Access

To set a reference to an application's type library:

  1. On the Tools menu, click References. The References command on the Tools menu is available only when a Module window is open and active in Design view.

  2. Select the check boxes for those applications whose type libraries you want to reference.

Setting a Reference from Visual Basic

To set a reference from Visual Basic, you create a new Reference object representing the desired reference. The References collection contains all currently set references.

To create a new Reference object, use either the AddFromFile or AddFromGUID method of the References collection. To remove a Reference object, use the Remove method.

Advantages of Setting References

Your Automation code will run faster if you set a reference to another application's type library before you work with its objects. If you've set a reference, you can declare an object variable representing an object in the other application as its most specific type. For example, if you're writing code to work with Microsoft Excel objects, you can declare an object variable of type Excel.Application by using the following syntax only if you've created a reference to the Microsoft Excel type library:

Copy code Copy code
Dim appXL As New Excel.Application

If you haven't set a reference to the Microsoft Excel type library, you must declare the variable as a generic variable of type Object. The following code runs more slowly:

Copy code Copy code
Dim appXL As Object

Additionally, if you set a reference to an application's type library, all of its objects, as well as their methods and properties, are listed in the Object Browser. This makes it easy to determine what properties and methods are available to each object.

Since Microsoft Access is an COM component that supports Automation, you can also set a reference to its type library from another application and work with Microsoft Access objects from that application.


Recordset.Bookmarkable Property (DAO)

 Copy code hover
[image]

Recordset.Bookmarkable Property (DAO)
Send feedback

Returns a value that indicates whether a Recordset object supports bookmarks, which you can set by using the Bookmark property.

Syntax

expression .Bookmarkable

expression A variable that represents a Recordset object.

Remarks

Check the Bookmarkable property setting of a Recordset object before you attempt to set or check the Bookmark property.

For Recordset objects based entirely on Microsoft Access database engine tables, the value of the Bookmarkable property is True, and you can use bookmarks. Other database products may not support bookmarks, however. For example, you can't use bookmarks in any Recordset object based on a linked Paradox table that has no primary key.

Example

This example uses the Bookmark and Bookmarkable properties to let the user flag a record in a Recordset and return to it later.

Copy code Copy code
Sub BookmarkX()

 Dim dbsNorthwind As Database
 Dim rstCategories As Recordset
 Dim strMessage As String
 Dim intCommand As Integer
 Dim varBookmark As Variant

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstCategories = _
 dbsNorthwind.OpenRecordset("Categories", _
 dbOpenSnapshot)

 With rstCategories

 If .Bookmarkable = False Then
 Debug.Print "Recordset is not Bookmarkable!"
 Else
 ' Populate Recordset.
 .MoveLast
 .MoveFirst

 Do While True
 ' Show information about current record and get
 ' user input.
 strMessage = "Category: " & !CategoryName & _
 " (record " & (.AbsolutePosition + 1) & _
 " of " & .RecordCount & ")" & vbCr & _
 "Enter command:" & vbCr & _
 "[1 - next / 2 - previous /" & vbCr & _
 "3 - set bookmark / 4 - go to bookmark]"
 intCommand = Val(InputBox(strMessage))

 Select Case intCommand
 ' Move forward or backward, trapping for BOF
 ' or EOF.
 Case 1
 .MoveNext
 If .EOF Then .MoveLast
 Case 2
 .MovePrevious
 If .BOF Then .MoveFirst

 ' Store the bookmark of the current record.
 Case 3
 varBookmark = .Bookmark

 ' Go to the record indicated by the stored
 ' bookmark.
 Case 4
 If IsEmpty(varBookmark) Then
 MsgBox "No Bookmark set!"
 Else
 .Bookmark = varBookmark
 End If

 Case Else
 Exit Do
 End Select

 Loop

 End If

 .Close
 End With

 dbsNorthwind.Close

End Sub


Label.BorderShade Property (Access)

 Copy code hover
[image]

Label.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents a Label object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

Label Object

Other resources

Label Object Members


Only simple SELECT queries are allowed in VIEWS. (Error 3766)

 Copy code hover
[image]

Only simple SELECT queries are allowed in VIEWS. (Error 3766)
Send feedback

This error occurs when trying to create a view from SQL DDL. This error occurs when trying to include parameters or sub-select statements as part of the view definition.


Page Object (Access)

 Copy code hover
[image]

Page Object (Access)
See also Send feedback

Published: July 16, 2012

A Page object corresponds to an individual page on a tab control.

Remarks

A Page object is a member of a tab control's Pages collection.

To return a reference to a particular Page object in the Pages collection, use any of the following syntax forms.

Syntax | Description
Pages!pagename | The pagename argument is the name of the Page object.
Pages("pagename") | The pagename argument is the name of the Page object.
Pages(index) | The index argument is the numeric position of the object within the collection.

You can create, move, or delete Page objects and set their properties either in Visual Basic or in form Design view. To create a new Page object in Visual Basic, use the Add method of the Pages collection. To delete a Page object, use the Remove method of the Pages collection.

To create a new Page object in form Design view, right-click the tab control and then click Insert Page on the shortcut menu. You can also copy an existing page and paste it. You can set the properties of the new Page object in form Design view by using the property sheet.

Each Page object has a PageIndex property that indicates its position within the Pages collection. The Value property of the tab control is equal to the PageIndex property of the current page. You can use these properties to determine which page is currently selected after the user has switched from one page to another, or to change the order in which the pages appear in the control.

A Page object is also a type of Control object. The ControlType property constant for a Page object is acPage. Although it is a control, a Page object belongs to a Pages collection, rather than a Controls collection. A tab control's Pages collection is a special type of Controls collection.

Each Page object can also contain one or more controls. Controls on a Page object belong to that Page object's Controls collection. In order to work with a control on a Page object, you must refer to that control within the Page object's Controls collection.

See also

Concepts

Access Object Model Reference

Other resources

Page Object Members


Rand Function (Access 2013 custom web app)

 Copy code hover
[image]

Rand Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns a pseudo-random number between 0 and 1.

Syntax

Rand( [Seed])

The Rand function contains the following argument.

Argument name | Description
Seed | An integer expression that gives the seed value. If Seed is not specified, a seed value is assigned at random.

Remarks

Repetitive calls of the Rand function with the same seed return the same results.


WebBrowserControl.KeyPress Event (Access)

 Copy code hover
[image]

WebBrowserControl.KeyPress Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Version Information

Version Added: Access 2010

Syntax

expression .KeyPress(KeyAscii, )

expression A variable that represents a WebBrowserControl object.

Parameters

Name | Required/Optional | Data Type | Description
KeyAscii | Required | Integer |

Return Value

nothing

Remarks

To run a macro or event procedure when this event occurs, set the OnKeyPress property to the name of the macro or to [Event Procedure].

The object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down an ANSI key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

A KeyPress event can involve any printable keyboard character, the CTRL key combined with a character from the standard alphabet or a special character, and the ENTER or BACKSPACE key. You can use the KeyDown and KeyUp event procedures to handle any keystroke not recognized by the KeyPress event, such as function keys, navigation keys, and any combinations of these with keyboard modifiers (ALT, SHIFT, or CTRL keys). Unlike the KeyDown and KeyUp events, the KeyPress event doesn't indicate the physical state of the keyboard; instead, it indicates the ANSI character that corresponds to the pressed key or key combinations.

KeyPress interprets the uppercase and lowercase of each character as separate key codes and, therefore, as two separate characters.

Note Note

The BACKSPACE key is part of the ANSI character set, but the DEL key isn't. If you delete a character in a control by using the BACKSPACE key, you cause a KeyPress event; if you use the DEL key, you don't.

The KeyDown and KeyPress events occur when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

For example, if you go to a new record and type a character in the first control in the record, the following events occur:

Current (for the new record)

ß

Enter (for the first control in the new record)

ß

GotFocus (for the control)

ß

KeyDown (for the control)

ß

KeyPress (for the control)

ß

BeforeInsert (for the new record in the form)

ß

Change (for the control if it's a text box or combo box)

ß

KeyUp (for the control)

Example

The following example converts text entered in a text box to uppercase as the text is typed in, one character at a time.

To try the example, add the following event procedure to a form that contains a text box named ShipRegion.

VBA Copy code Copy code
Private Sub ShipRegion_KeyPress(KeyAscii As Integer)
 Dim strCharacter As String

 ' Convert ANSI value to character string.
 strCharacter = Chr(KeyAscii)
 ' Convert character to upper case, then to ANSI value.
 KeyAscii = Asc(UCase(strCharacter))
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


After a database has been replicated, you cannot remove the replication features from the database. (Error 3459)

 Copy code hover
[image]

After a database has been replicated, you cannot remove the replication features from the database. (Error 3459)
Send feedback

You cannot remove the replication features from a database that has been replicated, either by setting its Replicable property to "T" or by converting it with the Microsoft Windows Briefcase, Microsoft Access, or the Replication Manager. Using DAO to set the database's Replicable property to "F" or any other value has no effect on the replicated database. If you need to use a copy of the database that does not have the properties, fields, tables, and other characteristics associated with replication, open the backup copy of the database made before the database was first converted.


Forms.Item Property (Access)

 Copy code hover
[image]

Forms.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only Form.

Syntax

expression .Item(Index)

expression A variable that represents a Forms object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

Forms Collection

Other resources

Forms Object Members


DoCmd.OpenTable Method (Access)

 Copy code hover
[image]

DoCmd.OpenTable Method (Access)
See also Send feedback

Published: July 16, 2012

The OpenTable method carries out the OpenTable action in Visual Basic.

Syntax

expression .OpenTable(TableName, View, DataMode)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
TableName | Required | Variant | A string expression that's the valid name of a table in the current database. If you execute Visual Basic code containing the OpenTable method in a library database, Microsoft Access looks for the table with this name first in the library database, then in the current database.
View | Optional | AcView | A AcView constant that specifies the view in which the table will open. The default value is acViewNormal.
DataMode | Optional | AcOpenDataMode | A AcOpenDataMode constant that specifies the data entry mode for the table. The default value is acEdit.

Remarks

You can use the OpenTable method to open a table in Datasheet view, Design view, or Print Preview. You can also select a data entry mode for the table.

Example

The following example opens the Employees table in Print Preview:

VBA Copy code Copy code
DoCmd.OpenTable "Employees", acViewPreview

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


CommandButton.KeyUp Event (Access)

 Copy code hover
[image]

CommandButton.KeyUp Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyUp(KeyCode, Shift)

expression A variable that represents a CommandButton object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyUp property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyUp event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyUp event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Page.Left Property (Access)

 Copy code hover
[image]

Page.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Syntax

expression .Left

expression A variable that represents a Page object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

Page Object

Other resources

Page Object Members


NavigationButton.HelpContextId Property (Access)

 Copy code hover
[image]

NavigationButton.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HelpContextId

expression A variable that represents a NavigationButton object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


SubForm.Visible Property (Access)

 Copy code hover
[image]

SubForm.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents a SubForm object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


A column requested is not being returned to the Recordset. (Error 3647)

 Copy code hover
[image]

A column requested is not being returned to the Recordset. (Error 3647)
Send feedback

One of the requested columns is not available.


Columns and Tables Append Methods, Name Property Example (VC++)

 Copy code hover
[image]

Columns and Tables Append Methods, Name Property Example (VC++)
Send feedback

The following code demonstrates how to create a new table.

Copy code Copy code

// BeginCreateTableCpp
#import "c:\Program Files\Common Files\system\ado\msadox.dll" no_namespace

#include "iostream.h"
#include "stdio.h"
#include "conio.h"

//Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void CreateTableX(void);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 CreateTableX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// CreateTableX Function //
// //
//////////////////////////////////////////////////////////
void CreateTableX()
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.
 _CatalogPtr m_pCatalog = NULL;
 _TablePtr m_pTable = NULL;

 try
 {
 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof(Catalog)));

 //Open the catalog
 m_pCatalog->PutActiveConnection(
 "Provider='Microsoft.JET.OLEDB.4.0';" "data source='c:\\Program Files\\Microsoft Office"
 "\\Office\\Samples\\Northwind.mdb';");

 TESTHR(hr = m_pTable.CreateInstance(__uuidof(Table)));
 m_pTable->PutName("MyTable");
 m_pTable->Columns->Append("Column1",adInteger,0);
 m_pTable->Columns->Append("Column2",adInteger,0);
 m_pTable->Columns->Append("Column3",adVarWChar,50);
 m_pCatalog->Tables->Append(
 _variant_t((IDispatch *)m_pTable));
 printf("Table 'MyTable' is added.\n");

 // Delete the table as this is a demonstration.
 m_pCatalog->Tables->Delete("MyTable");
 printf("Table 'MyTable' is deleted.\n");
 }

 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }

 catch(...)
 {
 cout << "Error occured in include files...."<< endl;
 }
}
// EndCreateTableCpp


CodeProject.IsWeb Property (Access)

 Copy code hover
[image]

CodeProject.IsWeb Property (Access)
See also Send feedback

Published: July 16, 2012

Gets whether the database is a Web database. Read-only Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .IsWeb

expression A variable that represents a CodeProject object.

Remarks

The IsWeb property contains True if the database is a Web database.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


NavigateTo Macro Action

 Copy code hover
[image]

NavigateTo Macro Action
Send feedback

You can use the NavigateTo action to control the display of database objects in the Navigation Pane. For example, you can change how the database objects are categorized, and you can filter the objects so that only certain ones are displayed.

Setting

The NavigateTo action has the following arguments.

Action argument | Description
Category | Required. The category by which you want the Navigation Pane to display objects. Click Object Type, Tables and Views, Modified Date, Created Date, or Custom in the Category box.
Group | Optional. The Group argument limits which objects in the category appear in the Navigation Pane. If you leave the Group argument blank, the Navigation Pane displays all database objects, categorized by the criteria you specify in the Category argument. Examples of valid Group arguments for the various Category arguments are shown in the following table.

Remarks

  • This action is similar to selecting categories and groups from the title bar of the Navigation Pane.

  • Valid Group arguments depend on which Category argument is used. If you enter an invalid Group argument, an error message appears.The following table contains examples of valid Group arguments for each Category argument.

    Category argument

    Example Group arguments

    Object Type

    Tables; Forms; Queries; Pages; Macros; Modules

    Tables and Views

    Names of specific tables in your database

    Modified Date

    Today; Yesterday; Last Month; Older

    Created Date

    Today; Yesterday; Last Month; Older

    Custom category

    Names of groups you have created for the specified custom category

  • To run the NavigateTo action in a VBA module, use the NavigateTo method of the DoCmd object.

Note Note

To navigate to the top level of a category (for example, All Tables, All Access Objects, or All Dates), you must leave the Group argument blank. For example, when the Category argument is Object Type, entering All Access Objects as a Group argument results in an error.


ListBox.BackShade Property (Access)

 Copy code hover
[image]

ListBox.BackShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackShade

expression A variable that represents a ListBox object.

Remarks

The BackShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the BackShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackShade=25

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Invalid SQL syntax - expected token: Privileges (Error 3689)

 Copy code hover
[image]

Invalid SQL syntax - expected token: Privileges (Error 3689)
Send feedback

This error occurs when using the GRANT or REVOKE keywords. A privilege was not specified. Some valid privileges are SELECT, UPDATE, DELETE, and INSERT.


OptionGroup.IsVisible Property (Access)

 Copy code hover
[image]

OptionGroup.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Syntax

expression .IsVisible

expression A variable that represents an OptionGroup object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Attachment.LabelX Property (Access)

 Copy code hover
[image]

Attachment.LabelX Property (Access)
See also Send feedback

Published: July 16, 2012

Version Information

Version Added: Access 2007

Syntax

expression .LabelX

expression A variable that represents an Attachment object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is right to left, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Microsoft Cursor Service for OLE DB (ADO Service Component)

 Copy code hover
[image]

Microsoft Cursor Service for OLE DB (ADO Service Component)
Send feedback

The Microsoft Cursor Service for OLE DB supplements the cursor support functions of data providers. As a result, the user perceives relatively uniform functionality from all data providers.

The Cursor Service makes dynamic properties available and enhances the behavior of certain methods. For example, the Optimize dynamic property enables the creation of temporary indexes to facilitate certain operations, such as the Find method.

The Cursor Service enables support for batch updating in all cases. It also simulates more capable cursor types, such as dynamic cursors, when a data provider can only supply less capable cursors, such as static cursors.

Keyword

To invoke this service component, set the Recordset or Connection object's CursorLocation property to adUseClient.

Copy code Copy code
                      connection.
                      CursorLocation=adUseClientrecordset.CursorLocation=adUseClient

Dynamic Properties

When the Cursor Service for OLE DB is invoked, the following dynamic properties are added to the Recordset object's Properties collection. The full list of Connection and Recordset object dynamic properties is listed in the ADO Dynamic Property Index. The associated OLE DB property names, where appropriate, are included in parenthesis after the ADO property name.

Changes to some dynamic properties are not visible to the underlying data source after the Cursor Service has been invoked. For example, setting the Command Time out property on a Recordset will not be visible to the underlying data provider.

Copy code Copy code

...
Recordset1.CursorLocation = adUseClient 'invokes cursor service
Recordset1.Open "authors", _
 "Provider=SQLOLEDB;Data Source=DBServer;User Id=usr;" & _
 "Password=pwd;Initial Catalog=pubs;",,adCmdTable
Recordset1.Properties.Item("Command Time out") = 50
' 'Command Time out' property on DBServer is still default (30).
...

If your application requires the Cursor Service, but you need to set dynamic properties on the underlying provider, set the properties before invoking the Cursor Service. Command object property settings are always passed to the underlying data provider regardless of cursor location. Therefore, you can also use a command object to set the properties at any time.

Note Note

The dynamic property DBPROP_SERVERDATAONINSERT is not supported by the cursor service, even if it is supported by the underlying data provider.

Property Name | Description
Auto Recalc (DBPROP_ADC_AUTORECALC) | For recordsets created with the Data Shaping Service, this value indicates how often calculated and aggregate columns are calculated. The default (value=1) is to recalculate whenever the Data Shaping Service determines that the values have changed. If the value is 0, the calculated or aggregate columns are only calculated when the hierarchy is initially built.
Batch Size (DBPROP_ADC_BATCHSIZE) | Indicates the number of update statements that can be batched before being sent to the data store. The more statements in a batch, the fewer round trips to the data store.
Cache Child Rows (DBPROP_ADC_CACHECHILDROWS) | For recordsets created with the Data Shaping Service, this value indicates whether child recordsets are stored in a cache for later use.
Cursor Engine Version (DBPROP_ADC_CEVER) | Indicates the version of the Cursor Service being used.
Maintain Change Status (DBPROP_ADC_MAINTAINCHANGESTATUS) | Indicates the text of the command used for resynchronizing a one or more rows in a multiple table join.
Optimize | Indicates whether an index should be created. When set to True, authorizes the temporary creation of indexes to improve the execution of certain operations.
Reshape Name | Indicates the name of the Recordset. May be referenced within the current, or subsequent, data shaping commands.
Resync Command | Indicates a custom command string that is used by the Resync method when the Unique Table property is in effect.
Unique Catalog | Indicates the name of the database containing the table referenced in the Unique Table property.
Unique Schema | Indicates the name of the owner of the table referenced in the Unique Table property.
Unique Table | Indicates the name of the one table in a Recordset created from multiple tables that may be modified by insertions, updates, or deletions.
Update Criteria (DBPROP_ADC_UPDATECRITERIA) | Indicates which fields in the WHERE clause are used to handle collisions occurring during an update.
Update Resync(DBPROP_ADC_UPDATERESYNC) | Indicates whether the Resync method is implicitly invoked after the UpdateBatch method (and its behavior), when the Unique Table property is in effect.

You may also set or retrieve a dynamic property by specifying its name as the index to the Properties collection. For example, get and print the current value of the Optimize dynamic property, then set a new value, like this:

Copy code Copy code

Debug.Print rs.Properties("Optimize")
rs.Properties("Optimize") = True

Built-in Property Behavior

The Cursor Service for OLE DB also affects the behavior of certain built-in properties.

Property Name | Description
CursorType | Supplements the types of cursors that are available for a Recordset.
LockType | Supplements the types of locks available for a Recordset. Enables batch updates.
Sort | Specifies one or more field names that the Recordset is sorted on, and whether each field is sorted in ascending or descending order.

Method Behavior

The Cursor Service for OLE DB enables or affects the behavior of the Field object's Append method; and the Recordset object's Open, Resync, UpdateBatch, and Save methods.


Line.Tag Property (Access)

 Copy code hover
[image]

Line.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents a Line object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

Line Object

Other resources

Line Object Members


TextBox.HelpContextId Property (Access)

 Copy code hover
[image]

TextBox.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Syntax

expression .HelpContextId

expression A variable that represents a TextBox object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


NavigationButton.OnKeyPress Property (Access)

 Copy code hover
[image]

NavigationButton.OnKeyPress Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Press box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnKeyPress

expression A variable that represents a NavigationButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyPress event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyPress value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Press box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Press box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyPress property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyPress

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


The Microsoft Access database engine cannot find a record in the table

 Copy code hover
[image]

The Microsoft Access database engine cannot find a record in the table <name> with key matching field(s) <name>. (Error 3101)
Send feedback

In a one-to-many relationship, you entered data on the "many" side for which there is no matching record on the "one" side. For example, this error occurs if you join a Customers table and Orders table on a CustomerID field, and then add an order using a CustomerID that does not exist in the Customers table.


DoCmd.Requery Method (Access)

 Copy code hover
[image]

DoCmd.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

Carries out the Requery action in Visual Basic.

Syntax

expression .Requery(ControlName)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
ControlName | Optional | Variant | A string expression that's the name of a control on the active object.

Remarks

You can use the Requery action to update the data in a specified control on the active object by requerying the source of the control. If no control is specified, this action requeries the source of the object itself. Use this action to ensure that the active object or one of its controls displays the most current data.

If you leave the Control Name argument blank, the Requery action has the same effect as pressing SHIFT+F9 when the object has the focus. If a subform control has the focus, this action requeries only the source of the subform (just as pressing SHIFT+F9 does).

If you want to requery a control that isn't on the active object, you must use the Requery method in Visual Basic, not the Requery action or its corresponding Requery method of the DoCmd object. The Requery method in Visual Basic is faster than the Requery action or the DoCmd.Requery method. In addition, when you use the Requery action or the DoCmd.Requery method, Microsoft Access closes the query and reloads it from the database, but when you use the Requery method, Access reruns the query without closing and reloading it. Note that the ActiveX Data Object (ADO) Requery method works the same way as the Access Requery method.

Example

The following example uses the Requery method to update the EmployeeList control:

VBA Copy code Copy code
DoCmd.Requery "EmployeeList"

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Application.NewCurrentDatabase Method (Access)

 Copy code hover
[image]

Application.NewCurrentDatabase Method (Access)
See also Send feedback

Published: July 16, 2012

Creates a new Microsoft Access database.

Syntax

expression .NewCurrentDatabase(filepath, FileFormat, Template, SiteAddress, ListID)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
filepath | Required | String | A string expression that is the name of a new database file, including the path name and the file name extension. If your network supports it, you can also specify a network path in the following form: \\Server\Share\Folder\Filename
FileFormat | Optional | AcNewDatabaseFormat | A AcNewDatabaseFormat constant that specifes the file format to use for the newly created database.
Template | Optional | Variant | The name of the template to be used for the new database.
SiteAddress | Optional | String | Uniform Resource Locator (URL) of the Windows SharePoint Services 3.0 site to link to.
ListID | Optional | String | Globally Unique Identifer (GUID) or the name of the Windows SharePoint Services 3.0 list to link to.

Remarks

You can use this method to create a new database from another application that is controlling Microsoft Access through Automation, formerly called OLE Automation. For example, you can use the NewCurrentDatabase method from Microsoft Excel to create a new database in the Microsoft Access window.

The NewCurrentDatabase method enables you to create a new Microsoft Access database from another application through Automation. Once you have created an instance of Microsoft Access from another application, you must also create a new database. This database opens in the Microsoft Access window.

See also

Concepts

Application Object

Other resources

Application Object Members


CustomControl.Section Property (Access)

 Copy code hover
[image]

CustomControl.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Syntax

expression .Section

expression A variable that represents a CustomControl object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


ComboBox.Recordset Property (Access)

 Copy code hover
[image]

ComboBox.Recordset Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets the ADO Recordset or DAO Recordset object representing the record source for the specified object. Read/write Object.

Syntax

expression .Recordset

expression A variable that represents a ComboBox object.

Remarks

The Recordset property returns the recordset object that provides the data being browsed in a form, report, list box control, or combo box control. If a form is based on a query, for example, referring to the Recordset property is the equivalent of cloning a Recordset object by using the same query. However, unlike using the RecordsetClone property, changing which record is current in the recordset returned by the form's Recordset property also sets the current record of the form.

The read/write behavior of the Recordset property is determined by the type of recordset (ADO or DAO) and the type of data (Access or SQL) contained in the recordset identified by the property.

Recordset type | Based on SQL data | Based on data stored by the Access database engine
ADO | Read/Write | Read/Write
DAO | N/A | Read/Write

The following example opens a form, opens a recordset, and then binds the form to the recordset by setting the form's Recordset property to the newly created Recordset object.

VBA Copy code Copy code
Global rstSuppliers As ADODB.Recordset
Sub MakeRW()
    DoCmd.OpenForm "Suppliers"
    Set rstSuppliers = New ADODB.Recordset
    rstSuppliers.CursorLocation = adUseClient
    rstSuppliers.Open "Select * From Suppliers", _
         CurrentProject.Connection, adOpenKeyset, adLockOptimistic
    Set Forms("Suppliers").Recordset = rstSuppliers
End Sub

Use the Recordset property:

  • To use methods with the Recordset object that aren't directly supported on forms. For example, you can use the Recordset property with the ADO Find or DAO Find methods in a custom dialog for finding a record.

  • To wrap a transaction (which can be rolled back) around a set of edits that affect multiple forms.

Changing a form's Recordset property may also change the RecordSource, RecordsetType, and RecordLocks properties. Also, some data-related properties may be overridden, for example, the Filter, FilterOn, OrderBy, and OrderByOn properties.

Calling the Requery method of a form's recordset (for example, Forms(0).Recordset.Requery) can cause the form to become unbound. To refresh the data in a form bound to a recordset, set the RecordSource property of the form to itself (Forms(0).RecordSource = Forms(0).RecordSource).

  • To bind multiple forms to a common data set. This allows synchronization of multiple forms. For example,

VBA Copy code Copy code
   Set Me.Recordset = Forms!Form1.Recordset

When a form is bound to a recordset, an error occurs if you use the Filter by Form command.

Example

The following example uses the Recordset property to create a new copy of the Recordset object from the current form and then prints the names of the fields in the Debug window.

VBA Copy code Copy code
Sub Print_Field_Names()
    Dim rst As DAO.Recordset, intI As Integer
    Dim fld As Field

    Set rst = Me.Recordset
    For Each fld in rst.Fields
        ' Print field names.
        Debug.Print fld.Name
    Next
End Sub

The next example uses the Recordset property and the Recordset object to synchronize a recordset with the form's current record. When a company name is selected from a combo box, the FindFirst method is used to locate the record for that company, causing the form to display the found record.

VBA Copy code Copy code
Sub SupplierID_AfterUpdate()
    Dim rst As DAO.Recordset
    Dim strSearchName As String

    Set rst = Me.Recordset
    strSearchName = CStr(Me!SupplierID)
    rst.FindFirst "SupplierID = " & strSearchName
    If rst.NoMatch Then
        MsgBox "Record not found"
    End If
    rst.Close
End Sub

The following code helps to determine what type of recordset is returned by the Recordset property under different conditions.

VBA Copy code Copy code
Sub CheckRSType()
    Dim rs as Object

    Set rs=Forms(0).Recordset
    If TypeOf rs Is DAO.Recordset Then
        MsgBox "DAO Recordset"
    ElseIf TypeOf rs is ADODB.Recordset Then
        MsgBox "ADO Recordset"
    End If
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Report.ShowPageMargins Property (Access)

 Copy code hover
[image]

Report.ShowPageMargins Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether page margins are displayed when the specified report is in Layout view. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .ShowPageMargins

expression A variable that represents a Report object.

See also

Concepts

Report Object

Other resources

Report Object Members


Attachment.DisplayWhen Property (Access)

 Copy code hover
[image]

Attachment.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .DisplayWhen

expression A variable that represents an Attachment object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


CHECK Constraints are not allowed in Replicable Databases. (Error 3798)

 Copy code hover
[image]

CHECK Constraints are not allowed in Replicable Databases. (Error 3798)
Send feedback

Remove any CHECK constraint prior to making the database or table replicable.


Parameter.Value Property (DAO)

 Copy code hover
[image]

Parameter.Value Property (DAO)
Send feedback

Sets or returns the value of an object. Read/write Variant.

Syntax

expression .Value

expression A variable that represents a Parameter object.

Remarks

The setting or return value is a Variant data type that evaluates to a value appropriate for the data type, as specified by the Type property of an object.

Generally, the Value property is used to retrieve and alter data in Recordset objects.

The Value property is the default property of the Field, Parameter, and Property objects. Therefore, you can set or return the value of one of these objects by referring to them directly instead of specifying the Value property.

Trying to set or return the Value property in an inappropriate context (for example, the Value property of a Field object in the Fields collection of a TableDef object) will cause a trappable error.

Note Note

When reading decimal values from a Microsoft SQL Server database, they will be formatted using scientific notation through a Microsoft Access workspace, but will appear as normal decimal values through an ODBCDirect workspace.


ListBox.MultiSelect Property (Access)

 Copy code hover
[image]

ListBox.MultiSelect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the MultiSelect property to specify whether a user can make multiple selections in a list box on a form and how the multiple selections can be made. Read/write Byte.

Syntax

expression .MultiSelect

expression A variable that represents a ListBox object.

Remarks

The MultiSelect property uses the following settings.

Setting | Visual Basic | Description
None | 0 | (Default) Multiple selection isn't allowed.
Simple | 1 | Multiple items are selected or deselected by clicking them with the mouse or pressing the SPACEBAR.
Extended | 2 | Multiple items are selected by holding down SHIFT and clicking them with the mouse or by holding down SHIFT and pressing an arrow key to extend the selection from the previously selected item to the current item. You can also select items by dragging with the mouse. Holding down CTRL and clicking an item selects or deselects that item.

This property can be set only in form Design view.

You can use the ListIndex property to return the index number for the selected item. When the MultiSelect property is set to Extended or Simple, you can use the list box's Selected property or ItemsSelected collection to determine the items that are selected. In addition, when the MultiSelect property is set to Extended or Simple, the value of the list box control will always be null.

If the MultiSelect property is set to Extended, requerying the list box clears any selections made by the user.

Example

To return the value of the MultiSelect property for a list box named "Country" on the "Order Entry" form, you can use the following:

VBA Copy code Copy code
Dim b As Byte b = Forms("Order Entry").Controls("Country").MultiSelect

To set the MultiSelect property, you can use the following:

VBA Copy code Copy code
Forms("Order Entry").Controls("Country").MultiSelect = 2 ' Extended.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Form.AfterInsert Event (Access)

 Copy code hover
[image]

Form.AfterInsert Event (Access)
See also Send feedback

Published: July 16, 2012

The AfterInsert event occurs after a new record is added.

Syntax

expression .AfterInsert

expression A variable that represents a Form object.

Return Value

nothing

Remarks

Note Note

Setting the value of a control by using a macro or Visual Basic doesn't trigger these events.

You can use an AfterInsert event procedure or macro to requery a recordset whenever a new record is added.

To run a macro or event procedure when the AfterInsert event occurs, set the OnAfterInsert property to the name of the macro or to [Event Procedure].

Example

This example shows how you can use a BeforeInsert event procedure to verify that the user wants to create a new record, and an AfterInsert event procedure to requery the record source for the Employees form after a record has been added.

To try the example, add the following event procedure to a form named Employees that is based on a table or query. Switch to form Datasheet view and try to insert a record.

VBA Copy code Copy code
Private Sub Form_BeforeInsert(Cancel As Integer)
 If MsgBox("Insert new record here?", _
 vbOKCancel) = vbCancel Then
 Cancel = True
 End If
End Sub

Private Sub Form_AfterInsert()
 Forms!Employees.Requery
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


TabControl.FontItalic Property (Access)

 Copy code hover
[image]

TabControl.FontItalic Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontItalic property to specify whether text is italic in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontItalic

expression A variable that represents a TabControl object.

Remarks

The FontItalic property uses the following settings.

Setting | Description
True | The text is italic.
False | (Default) The text isn't italic.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


ToggleButton.HoverForeThemeColorIndex Property (Access)

 Copy code hover
[image]

ToggleButton.HoverForeThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverForeColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HoverForeThemeColorIndex

expression A variable that represents a ToggleButton object.

Remarks

The HoverForeThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 (Default) | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the HoverThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


DateAdd Function (Access 2013 custom web app)

 Copy code hover
[image]

DateAdd Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns a specified date with the specified number interval (positive or negative integer) added to a specified date part of that date.

Syntax

DateAdd(DatePart, Number, Date)

The DateAdd function contains the following arguments.

Argument name | Description
DatePart | The part of Date to which an integer number is added. Refer to the Remarks section for the list of valid settings.
Number | Is an expression that can be resolved to an integer that is added to a DatePart of Date. If you specify a value with a decimal fraction, the fraction is truncated.
Date | An expression that can be resolved to a Date/Time value. The Date argument expression, column expression, user-defined variable or string literal.

Remarks

The following table lists all valid DatePart arguments.

DatePart

year

quarter

month

dayofyear

day

week

hour

minute

second

millisecond

Example

The following expression calculates the last day of the current month.

Copy code Copy code
DateAdd(Day,-1,DateAdd(Month,DateDiff(Month,0,Today())+1,0))

The following expression calculates the last day of the previous month.

Copy code Copy code
DateAdd(Day,-1,DateAdd(Month,DateDiff(Month,0,Today()),0))


TextBox.OnMouseMove Property (Access)

 Copy code hover
[image]

TextBox.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Syntax

expression .OnMouseMove

expression A variable that represents a TextBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


CommandButton.PictureData Property (Access)

 Copy code hover
[image]

CommandButton.PictureData Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.

Syntax

expression .PictureData

expression A variable that represents a CommandButton object.

Remarks

The PictureData property setting is the PictureData property of another control, form, or report.

You can use this property to display different background pictures in a form, depending on actions taken by the user. For example, you might open a Customers form using a different background picture depending on whether the form is opened for data entry or for browsing.

You can also use the PictureData property together with the Timer event and the TimerInterval property to perform simple animation on a form.

Example

The following example uses three image controls to animate a butterfly image across a form. The Hidden1 image control contains a picture of a butterfly with its wings up and the Hidden2 image control contains a picture of the same butterfly with its wings down. Both image controls have their Visible property set to False. The TimerInterval property is set to 200. Each time the Timer event occurs, the picture in the image control Visible1 is changed by using the PictureData property of the hidden image controls, and the visible image control is moved 200 twips to the right. The visible image control is moved back to the left side of the form when its Left property value is greater than the width of the form stored in the public variable gfrmWidth. The value of gfrmWidth is set to Me.Width in the form's open event.

VBA Copy code Copy code
Private Sub Form_Timer()

 Static intPic As Integer

 Select Case intPic
 Case Is = 1
 Me!Visible1.PictureData = Me!Hidden1.PictureData
 Case Is = 2
 Me!Visible1.PictureData = Me!Hidden2.PictureData
 Case Else
 End Select

 If intPic = 2 Then intPic = 0
 intPic = intPic + 1
 If (Me!Visible1.Left > gfrmWidth) Then Me!Visible1.Left = 0
 Me!Visible1.Left = Me!Visible1.Left + 200

End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Report.PictureSizeMode Property (Access)

 Copy code hover
[image]

Report.PictureSizeMode Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureSizeMode property to specify how a picture for a form or report is sized. Read/write Byte.

Syntax

expression .PictureSizeMode

expression A variable that represents a Report object.

Remarks

The PictureSizeMode property uses the following settings.

Setting | Visual Basic | Description
Clip | 0 | (Default) The picture is displayed in its actual size. If the picture is larger than the form or report, then the picture is clipped.
Stretch | 1 | The picture is stretched horizontally and vertically to fill the entire form, even if its original ratio of height to width is distorted.
Zoom | 3 | The picture is enlarged to the maximum extent possible while keeping its original ratio of height to width.
Stretch Horizontal | 4 | The picture is stretched horizontally to fit the width of the form.
Stretch Vertical | 5 | The picture is stretched vertically to fit the height of the form.

When a small picture is used for the Picture property of a form or report, setting the PictureSizeMode property to Stretch or Zoom can cause substantial distortion of its resolution. Smaller pictures can be tiled across the entire form or report by using the PictureTiling property.

Example

The following example sets the background picture of the "Order Entry" form to "Contacts.gif", and stretches the picture to fit the entire form's background.

VBA Copy code Copy code
With Forms("Order Entry")
 .Picture = "C:\Picture Files\Contacts.gif"
 .PictureSizeMode = 1
End With

See also

Concepts

Report Object

Other resources

Report Object Members


Database Objects

 Copy code hover
[image]

Database Objects
Send feedback

In this section

  • CopyObject Macro Action

  • DeleteObject Macro Action

  • GoToControl Macro Action

  • GoToPage Macro Action

  • GoToRecord Macro Action

  • OpenForm Macro Action

  • OpenReport Macro Action

  • OpenTable Macro Action

  • RenameObject Macro Action

  • SaveObject Macro Action

  • SelectObject Macro Action

  • SetProperty Macro Action

  • RepaintObject Macro Action

  • SetValue Macro Action


Members Collection (ADO MD Reference)

 Copy code hover
[image]

Members Collection (ADO MD Reference)
Send feedback

In this section

  • Members Collection (ADO MD)

  • Members Collection Properties, Methods, and Events (ADO MD)


Recordset2.Bookmark Property (DAO)

 Copy code hover
[image]

Recordset2.Bookmark Property (DAO)
Send feedback

Sets or returns a bookmark that uniquely identifies the current record in a Recordset object.

Syntax

expression .Bookmark

expression A variable that represents a Recordset2 object.

Remarks

For a Recordset object based entirely on Microsoft Access database engine tables, the value of the Bookmarkable property is True, and you can use the Bookmark property with that recordset. Other database products may not support bookmarks, however. For example, you can't use bookmarks in any Recordset2 object based on a linked Paradox table that has no primary key.

When you create or open a Recordset object, each of its records already has a unique bookmark. You can save the bookmark for the current record by assigning the value of the Bookmark property to a variable. To quickly return to that record at any time after moving to a different record, set the Recordset object's Bookmark property to the value of that variable.

There is no limit to the number of bookmarks you can establish. To create a bookmark for a record other than the current record, move to the desired record and assign the value of the Bookmark property to a String variable that identifies the record.

To make sure the Recordset object supports bookmarks, check the value of its Bookmarkable property before you use the Bookmark property. If the Bookmarkable property is False, the Recordset object doesn't support bookmarks, and using the Bookmark property results in a trappable error.

If you use the Clone method to create a copy of a Recordset object, the Bookmark property settings for the original and the duplicate Recordset objects are identical and can be used interchangeably. However, you can't use bookmarks from different Recordset objects interchangeably, even if they were created by using the same object or the same SQL statement.

If you set the Bookmark property to a value that represents a deleted record, a trappable error occurs.

The value of the Bookmark property isn't the same as a record number.

Example

This example uses the Bookmark and Bookmarkable properties to let the user flag a record in a recordset and return to it later.

Copy code Copy code
Sub BookmarkX()

 Dim dbsNorthwind As Database
 Dim rstCategories As Recordset2
 Dim strMessage As String
 Dim intCommand As Integer
 Dim varBookmark As Variant

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstCategories = _
 dbsNorthwind.OpenRecordset("Categories", _
 dbOpenSnapshot)

 With rstCategories

 If .Bookmarkable = False Then
 Debug.Print "Recordset is not Bookmarkable!"
 Else
 ' Populate Recordset.
 .MoveLast
 .MoveFirst

 Do While True
 ' Show information about current record and get
 ' user input.
 strMessage = "Category: " & !CategoryName & _
 " (record " & (.AbsolutePosition + 1) & _
 " of " & .RecordCount & ")" & vbCr & _
 "Enter command:" & vbCr & _
 "[1 - next / 2 - previous /" & vbCr & _
 "3 - set bookmark / 4 - go to bookmark]"
 intCommand = Val(InputBox(strMessage))

 Select Case intCommand
 ' Move forward or backward, trapping for BOF
 ' or EOF.
 Case 1
 .MoveNext
 If .EOF Then .MoveLast
 Case 2
 .MovePrevious
 If .BOF Then .MoveFirst

 ' Store the bookmark of the current record.
 Case 3
 varBookmark = .Bookmark

 ' Go to the record indicated by the stored
 ' bookmark.
 Case 4
 If IsEmpty(varBookmark) Then
 MsgBox "No Bookmark set!"
 Else
 .Bookmark = varBookmark
 End If

 Case Else
 Exit Do
 End Select

 Loop

 End If

 .Close
 End With

 dbsNorthwind.Close

End Sub

This example uses the LastModified property to move the current record pointer to both a record that has been modified and a newly created record.

Copy code Copy code
Sub LastModifiedX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset2
 Dim strFirst As String
 Dim strLast As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", _
 dbOpenDynaset)

 With rstEmployees
 ' Store current data.
 strFirst = !FirstName
 strLast = !LastName
 ' Change data in current record.
 .Edit
 !FirstName = "Julie"
 !LastName = "Warren"
 .Update
 ' Move current record pointer to the most recently
 ' changed or added record.
 .Bookmark = .LastModified
 Debug.Print _
 "Data in LastModified record after Edit: " & _
 !FirstName & " " & !LastName

 ' Restore original data because this is a demonstration.
 .Edit
 !FirstName = strFirst
 !LastName = strLast
 .Update

 ' Add new record.
 .AddNew
 !FirstName = "Roger"
 !LastName = "Harui"
 .Update
 ' Move current record pointer to the most recently
 ' changed or added record.
 .Bookmark = .LastModified
 Debug.Print _
 "Data in LastModified record after AddNew: " & _
 !FirstName & " " & !LastName

 ' Delete new record because this is a demonstration.
 .Delete
 .Close
 End With

 dbsNorthwind.Close

End Sub


Recordset.LastModified Property (DAO)

 Copy code hover
[image]

Recordset.LastModified Property (DAO)
Send feedback

Returns a ookmark indicating the most recently added or changed record.

Syntax

expression .LastModified

expression A variable that represents a Recordset object.

Remarks

You can use the LastModified property to move to the most recently added or updated record. Use the LastModified property with table- and dynaset-type Recordset objects. A record must be added or modified in the Recordset object itself in order for the LastModified property to have a value.

Example

This example uses the LastModified property to move the current record pointer to both a record that has been modified and a newly created record.

VBA Copy code Copy code
Sub LastModifiedX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset
 Dim strFirst As String
 Dim strLast As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", _
 dbOpenDynaset)

 With rstEmployees
 ' Store current data.
 strFirst = !FirstName
 strLast = !LastName
 ' Change data in current record.
 .Edit
 !FirstName = "Julie"
 !LastName = "Warren"
 .Update
 ' Move current record pointer to the most recently
 ' changed or added record.
 .Bookmark = .LastModified
 Debug.Print _
 "Data in LastModified record after Edit: " & _
 !FirstName & " " & !LastName

 ' Restore original data because this is a demonstration.
 .Edit
 !FirstName = strFirst
 !LastName = strLast
 .Update

 ' Add new record.
 .AddNew
 !FirstName = "Roger"
 !LastName = "Harui"
 .Update
 ' Move current record pointer to the most recently
 ' changed or added record.
 .Bookmark = .LastModified
 Debug.Print _
 "Data in LastModified record after AddNew: " & _
 !FirstName & " " & !LastName

 ' Delete new record because this is a demonstration.
 .Delete
 .Close
 End With

 dbsNorthwind.Close

End Sub

This example uses the AddNew method to create a new record with the specified name. The AddName function is required for this procedure to run.

VBA Copy code Copy code
Sub AddNewX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset
 Dim strFirstName As String
 Dim strLastName As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", dbOpenDynaset)

 ' Get data from the user.
 strFirstName = Trim(InputBox( _
 "Enter first name:"))
 strLastName = Trim(InputBox( _
 "Enter last name:"))

 ' Proceed only if the user actually entered something
 ' for both the first and last names.
 If strFirstName <> "" and strLastName <> "" Then

 ' Call the function that adds the record.
 AddName rstEmployees, strFirstName, strLastName

 ' Show the newly added data.
 With rstEmployees
 Debug.Print "New record: " & !FirstName & _
 " " & !LastName
 ' Delete new record because this is a demonstration.
 .Delete
 End With

 Else
 Debug.Print _
 "You must input a string for first and last name!"
 End If

 rstEmployees.Close
 dbsNorthwind.Close

End Sub

Function AddName(rstTemp As Recordset, _
 strFirst As String, strLast As String)

 ' Adds a new record to a Recordset using the data passed
 ' by the calling procedure. The new record is then made
 ' the current record.
 With rstTemp
 .AddNew
 !FirstName = strFirst
 !LastName = strLast
 .Update
 .Bookmark = .LastModified
 End With

End Function


How to: Delete a Record From a DAO Recordset

 Copy code hover
[image]

How to: Delete a Record From a DAO Recordset
Send feedback

You can delete an existing record in a table or dynaset-type Recordset object by using the Delete method. You cannot delete records from a snapshot-type Recordset object. The following code example deletes all the duplicate records in the Shippers table.

VBA Copy code Copy code
Sub DeleteDuplicateShippers()

Dim dbsNorthwind As DAO.Database
Dim rstShippers As DAO.Recordset
Dim strSQL As String
Dim strName As String

On Error GoTo ErrorHandler

   Set dbsNorthwind = CurrentDb
   strSQL = "SELECT * FROM Shippers ORDER BY CompanyName, ShipperID"
   Set rstShippers = dbsNorthwind.OpenRecordset(strSQL, dbOpenDynaset)

   ' If no records in Shippers table, exit.
   If rstShippers.EOF Then Exit Sub

   strName = rstShippers![CompanyName]
   rstShippers.MoveNext

   Do Until rstShippers.EOF
      If rstShippers![CompanyName] = strName Then
         rstShippers.Delete
      Else
         strName = rstShippers![CompanyName]
      End If
      rstShippers.MoveNext
   Loop

Exit Sub

ErrorHandler:
   MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Function

When you use the Delete method, the Microsoft Access database engine immediately deletes the current record without any warning or prompting. Deleting a record does not automatically cause the next record to become the current record; to move to the next record you must use the MoveNext method. Be aware that after you have moved off the deleted record, you cannot move back to it.

If you try to access a record after deleting it on a table-type Recordset, you will see error 3167, "Record is deleted." On a dynaset, you will see error 3021, "No current record."

If you have a Recordset clone positioned at the deleted record and you try to read its value, you will see error 3167 regardless of the type of Recordset object. Trying to use a bookmark to move to a deleted record will also result in error 3167.


Printer.DriverName Property (Access)

 Copy code hover
[image]

Printer.DriverName Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a String indicating the name of the driver used by the specified printer. Read-only.

Syntax

expression .DriverName

expression A variable that represents a Printer object.

Example

The following example displays information about all the printers available to the system.

VBA Copy code Copy code
Dim prtLoop As Printer

For Each prtLoop In Application.Printers
 With prtLoop
 MsgBox "Device name: " & .DeviceName & vbCr _
 & "Driver name: " & .DriverName & vbCr _
 & "Port: " & .Port
 End With
Next prtLoop

See also

Concepts

Printer Object

Other resources

Printer Object Members


QueryDef.MaxRecords Property (DAO)

 Copy code hover
[image]

QueryDef.MaxRecords Property (DAO)
Send feedback

Sets or returns the maximum number of records to return from a query against an ODBC data source.

Syntax

expression .MaxRecords

expression A variable that represents a QueryDef object.

Remarks

The default value is 0, indicating no limit on the number of records returned.

Once the number of rows specified by MaxRecords is returned to your application in a Recordset, the query processor will stop returning additional records even if more records would qualify for inclusion in the Recordset. This property is useful in situations where limited client resources prohibit management of large numbers of records.

Note Note

The MaxRecords property can only be used with an ODBC data source.

Example

This example uses the MaxRecords property to set a limit on how many records are returned by a query on an ODBC data source.

VBA Copy code Copy code
Sub MaxRecordsX()

 Dim dbsCurrent As Database
 Dim qdfPassThrough As QueryDef
 Dim qdfLocal As QueryDef
 Dim rstTemp As Recordset

 ' Open a database from which QueryDef objects can be
 ' created.
 Set dbsCurrent = OpenDatabase("DB1.mdb")

 ' Create a pass-through query to retrieve data from
 ' a Microsoft SQL Server database.
 Set qdfPassThrough = _
 dbsCurrent.CreateQueryDef("")

 ' Set the properties of the new query, limiting the
 ' number of returnable records to 20.
 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 qdfPassThrough.Connect = _
 "ODBC;DATABASE=pubs;DSN=Publishers"
 qdfPassThrough.SQL = "SELECT * FROM titles"
 qdfPassThrough.ReturnsRecords = True
 qdfPassThrough.MaxRecords = 20

 Set rstTemp = qdfPassThrough.OpenRecordset()

 ' Display results of query.
 Debug.Print "Query results:"
 With rstTemp
 Do While Not .EOF
 Debug.Print , .Fields(0), .Fields(1)
 .MoveNext
 Loop
 .Close
 End With

 dbsCurrent.Close

End Sub


TextBox.BorderColor Property (Access)

 Copy code hover
[image]

TextBox.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Syntax

expression .BorderColor

expression A variable that represents a TextBox object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


WebBrowserControl.BeforeUpdate Event (Access)

 Copy code hover
[image]

WebBrowserControl.BeforeUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The BeforeUpdate event occurs before changed data in a control or record is updated.

Version Information

Version Added: Access 2010

Syntax

expression .BeforeUpdate(Cancel, )

expression A variable that represents a WebBrowserControl object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer |

Return Value

nothing

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's BeforeUpdate event does occur.

To run a macro or event procedure when this event occurs, set the BeforeUpdate property to the name of the macro or to [Event Procedure].

This event does not apply to option buttons, check boxes, or toggle buttons in an option group. It applies only to the option group itself.

The BeforeUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB. When the focus leaves the record or if the user clicks Save Record on the Records menu, the entire record is updated, and the data is saved in the database.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

BeforeUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. BeforeUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For forms, you can use the BeforeUpdate event to cancel updating of a record before moving to another record.

If the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

You often use the BeforeUpdate event to validate data, especially when you perform complex validations, such as those that:

  • Involve conditions for more than one value on a form.

  • Display different error messages for different data entered.

  • Can be overridden by the user.

  • Contain references to controls on other forms or contain user-defined functions.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

A run-time error will occur if you attempt to modify the data contained in the control that fired the BeforeUpdate event in the event's procedure.

Example

The following example shows how you can use a BeforeUpdate event procedure to check whether a product name has already been entered in the database. After the user types a product name in the ProductName box, the value is compared to the ProductName field in the Products table. If there is a matching value in the Products table, a message is displayed that informs the user that the product has already been entered.

To try the example, add the following event procedure to a form named Products that contains a text box called ProductName.

VBA Copy code Copy code
Private Sub ProductName_BeforeUpdate(Cancel As Integer)
 If(Not IsNull(DLookup("[ProductName]", _
 "Products", "[ProductName] ='" _
 & Me!ProductName & "'"))) Then
 MsgBox "Product has already been entered in the database."
 Cancel = True
 Me!ProductName.Undo
 End If
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


AllForms.Item Property (Access)

 Copy code hover
[image]

AllForms.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.

Syntax

expression .Item(var)

expression A variable that represents an AllForms object.

Parameters

Name | Required/Optional | Data Type | Description
var | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

AllForms Collection

Other resources

AllForms Object Members


AcPrintDuplex Enumeration (Access)

 Copy code hover
[image]

AcPrintDuplex Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the Duplex property to specify how the printer handles duplex printing.

Name | Value | Description
acPRDPHorizontal | 2 | Double-sided printing using a horizontal page turn.
acPRDPSimplex | 1 | Single-sided printing with the current orientation setting.
acPRDPVertical | 3 | Double-sided printing using a vertical page turn.


ADOX Properties

 Copy code hover
[image]

ADOX Properties
Send feedback
ActiveConnection | Indicates the ADO Connection object to which the catalog belongs.
Attributes | Describes column characteristics.
Clustered | Indicates whether the index is clustered.
Command | Specifies an ADO Command object that can be used to create or execute the procedure.
Count | Indicates the number of objects in a collection.
DateCreated | Indicates the date the object was created.
DateModified | Indicates the date the object was last modified.
DefinedSize | Indicates the stated maximum size of the column.
DeleteRule | Indicates the action performed when a primary key is deleted.
IndexNulls | Indicates whether records that have null values in their index fields have index entries.
Item | Indicates a specific member of a collection, by name or ordinal number.
Name | Indicates the name of the object.
NumericScale | Indicates the scale of a numeric value in the column.
ParentCatalog | Specifies the parent catalog of a table or column to provide access to provider-specific properties.
Precision | Indicates the maximum precision of data values in the column.
PrimaryKey | Indicates whether the index represents the primary key on the table.
RelatedColumn | Indicates the name of the related column in the related table (key columns only).
RelatedTable | Indicates the name of the related table.
SortOrder | Indicates the sort sequence for the column (index columns only).
Type (Column) | Indicates the data type of a column.
Type (Key) | Indicates the data type of the Key.
Type (Table) | Indicates the type of a table.
Unique | Indicates whether the index keys must be unique.
UpdateRule | Indicates the action performed when a primary key is updated.


RightsEnum

 Copy code hover
[image]

RightsEnum
Send feedback

Specifies the rights or permissions for a group or user on an object.

Constant | Value | Description
adRightCreate | 16384 (&H4000) | The user or group has permission to create new objects of this type.
adRightDelete | 65536 (&H10000) | The user or group has permission to delete data from an object. For objects such as Tables, the user has permission to delete data values from records.
adRightDrop | 256 (&H100) | The user or group has permission to remove objects from the catalog. For example, Tables can be deleted by a DROP TABLE SQL command.
adRightExclusive | 512 (&H200) | The user or group has permission to access the object exclusively.
adRightExecute | 536870912 (&H20000000) | The user or group has permission to execute the object.
adRightFull | 268435456 (&H10000000) | The user or group has all permissions on the object.
adRightInsert | 32768 (&H8000) | The user or group has permission to insert the object. For objects such as Tables, the user has permission to insert data into the table.
adRightMaximumAllowed | 33554432 (&H2000000) | The user or group has the maximum number of permissions allowed by the provider. Specific permissions are provider-dependent.
adRightNone | 0 | The user or group has no permissions for the object.
adRightRead | -2147483648 (&H80000000) | The user or group has permission to read the object. For objects such as Tables, the user has permission to read the data in the table.
adRightReadDesign | 1024 (&H400) | The user or group has permission to read the design for the object.
adRightReadPermissions | 131072 (&H20000) | The user or group can view, but not change, the specific permissions for an object in the catalog.
adRightReference | 8192 (&H2000) | The user or group has permission to reference the object.
adRightUpdate | 1073741824 (&H40000000) | The user or group has permission to update the object. For objects such as Tables, the user has permission to update the data in the table.
adRightWithGrant | 4096 (&H1000) | The user or group has permission to grant permissions on the object.
adRightWriteDesign | 2048 (&H800) | The user or group has permission to modify the design for the object.
adRightWriteOwner | 524288 (&H80000) | The user or group has permission to modify the owner of the object.
adRightWritePermissions | 262144 (&H40000) | The user or group can modify the specific permissions for an object in the catalog.


Form.RecordSelectors Property (Access)

 Copy code hover
[image]

Form.RecordSelectors Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the RecordSelectors property to specify whether a form displays record selectors in Form view. Read/write Boolean.

Syntax

expression .RecordSelectors

expression A variable that represents a Form object.

Remarks

The default value is True.

You can use this property to remove record selectors when you create or use a form as a custom dialog box or a palette. You can also use this property for forms whose DefaultView property is set to Single Form.

The record selector displays the unsaved record indicator when a record is being edited. When the RecordSelectors property is set to No and the RecordLocks property is set to Edited Record (record locking is "pessimistic" — only one person can edit a record at a time), there is no visual clue that the record is locked.

Example

The following example specifies that no record has a record selector in the "Employees" form.

VBA Copy code Copy code
Forms("Employees").RecordSelectors = False

See also

Concepts

Form Object

Other resources

Form Object Members


Cellset Properties, Methods, and Events (ADO MD)

 Copy code hover
[image]

Cellset Properties, Methods, and Events (ADO MD)
Send feedback

Properties/Collections

ActiveConnection Property

Axes Collection

FilterAxis Property

Item Property (Cellset)

Properties Collection

Source Property

State Property

Methods

Close Method

Open Method

Events

None.


Document.Name Property (DAO)

 Copy code hover
[image]

Document.Name Property (DAO)
Send feedback

Returns the name of the specified object. Read-only String.

Syntax

expression .Name

expression A variable that represents a Document object.


Recordset.Transactions Property (DAO)

 Copy code hover
[image]

Recordset.Transactions Property (DAO)
Send feedback

Returns a value that indicates whether an object supports transactions. Read-only Boolean.

Syntax

expression .Transactions

expression A variable that represents a Recordset object.

Remarks

In a Microsoft Access workspace, you can also use the Transactions property with dynaset- or table-type Recordset objects. Snapshot- and forward-only-type Recordset objects always return False.

If a dynaset- or table-type Recordset is based on a Microsoft Access database engine table, the Transactions property is True and you can use transactions. Other database engines may not support transactions. For example, you can't use transactions in a dynaset-type Recordset object based on a Paradox table.

Check the Transactions property before using the BeginTrans method on the Recordset object's Workspace object to make sure that transactions are supported. Using the BeginTrans, CommitTrans, or Rollback methods on an unsupported object has no effect.

Example

This example demonstrates the Transactions property in Microsoft Access workspaces.

VBA Copy code Copy code
Sub TransactionsX()

 Dim wrkAcc As Workspace
 Dim dbsNorthwind As Database
 Dim conPubs As Connection
 Dim rstTemp As Recordset

 Set wrkAcc = CreateWorkspace("", "admin", "", dbUseJet)
 Set dbsNorthwind = wrkAcc.OpenDatabase("Northwind.mdb")

 ' Open two different Recordset objects and display the
 ' Transactions property of each.

 Debug.Print "Opening Microsoft Access table-type " & _
 "recordset..."
 Set rstTemp = dbsNorthwind.OpenRecordset( _
 "Employees", dbOpenTable)
 Debug.Print " Transactions = " & rstTemp.Transactions

 Debug.Print "Opening forward-only-type " & _
 "recordset where the source is an SQL statement..."
 Set rstTemp = dbsNorthwind.OpenRecordset( _
 "SELECT * FROM Employees", dbOpenForwardOnly)
 Debug.Print " Transactions = " & rstTemp.Transactions

 rstTemp.Close
 dbsNorthwind.Close
 conPubs.Close
 wrkAcc.Close
End Sub


Image.Picture Property (Access)

 Copy code hover
[image]

Image.Picture Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Picture property to specify a bitmap or other type of graphic to be displayed on the specified control. Read/write String.

Syntax

expression .Picture

expression A variable that represents an Image object.

Remarks

The Picture property contains (bitmap) or the path and file name of a bitmap or other type of graphic to be displayed.

The default setting is (none). After the graphic is loaded into the object, the property setting is (bitmap) or the path and file name of the graphic. If you delete (bitmap) or the path and file name of the graphic from the property setting, the picture is deleted from the object and the property setting is again (none).

If the PictureType property is set to Embedded, the graphic is stored with the object.

You can create custom bitmaps by using Microsoft Paintbrush or another application that creates bitmap files. A bitmap file must have a .bmp, .ico, or .dib extension. You can also use graphics files in the .wmf or .emf formats, or any other graphic file type for which you have a graphics filter. Forms, reports, and image controls support all graphics. Command buttons and toggle buttons only support bitmaps.

See also

Concepts

Image Object

Other resources

Image Object Members


TextBox.BackColor Property (Access)

 Copy code hover
[image]

TextBox.BackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the interior color of the specified object. Read/write Long.

Syntax

expression .BackColor

expression A variable that represents a TextBox object.

Remarks

The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

To use the BackColor property, the BackStyle property, if available, must be set to Normal.

Example

The following example uses the RGB function to set the , BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


MaxRecords Property Example (VC++)

 Copy code hover
[image]

MaxRecords Property Example (VC++)
Send feedback

This example uses the MaxRecords property to open a Recordset containing the 10 most expensive titles in the Titles table.

Copy code Copy code

// BeginMaxRecordsCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF","EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>
#include "MaxRecordsX.h"

// Function Declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void MaxRecordsX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

//////////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 MaxRecordsX();

 printf("Press any key to continue...");
 getch();
 ::CoUninitialize();
}

// MaxRecordsX() Function
void MaxRecordsX(void)
{
 // Define ADO ObjectPointers
 // Initialize Pointers on define
 // These are in the ADODB :: namespace
 _RecordsetPtr pRstTemp = NULL;

 // Define Other Variables
 IADORecordBinding *picRs = NULL; // Interface Pointer Declared
 CTitleRs titlers; // C++ Class Object
 HRESULT hr = S_OK;

 try
 {
 //Assign Connection String to Variable
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 // Open Recordset containing the 10 most expensive titles in the
 // Titles table.
 TESTHR(pRstTemp.CreateInstance(__uuidof(Recordset)));

 pRstTemp->MaxRecords=10;

 pRstTemp->Open("SELECT title,price FROM Titles "
 "ORDER BY Price DESC",strCnn,adOpenForwardOnly,
 adLockReadOnly,adCmdText);

 // Open an IADORecordBinding interface pointer which
 // we will use for binding Recordset to a class
 TESTHR(pRstTemp->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 // Bind the Recordset to a C++ class here
 TESTHR(picRs->BindToRecordset(&titlers));

 // Display the contents of the Recordset
 printf("Top Ten Titles by Price:\n\n");

 while(!(pRstTemp->EndOfFile))
 {
 printf("%s --- %6.2lf\n\n",titlers.lau_TitleStatus ==
 adFldOK ? titlers.m_szau_Title : "<NULL>",
 titlers.lau_PriceStatus == adFldOK ?
 titlers.m_szau_Price : 0.00);
 pRstTemp->MoveNext();
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstTemp->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (pRstTemp)
 if (pRstTemp->State == adStateOpen)
 pRstTemp->Close();
};

//////////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
//////////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 //Print Provider Errors from Connection object
 //pErr is a record object in the Connection's Error collection
 ErrorPtr pErr = NULL;

 if((pConnection->Errors->Count)>0)
 {
 long nCount = pConnection->Errors->Count;

 //Collection ranges from 0 to nCount-1
 for(long i = 0;i < nCount;i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error Number :%x \t %s",pErr->Number,
 pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndMaxRecordsCpp


CommandButton.HoverForeThemeColorIndex Property (Access)

 Copy code hover
[image]

CommandButton.HoverForeThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverForeColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HoverForeThemeColorIndex

expression A variable that represents a CommandButton object.

Remarks

The HoverForeThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 (Default) | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the HoverThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Entity Members (Access)

 Copy code hover
[image]

Entity Members (Access)
Send feedback

Published: July 16, 2012

Represents an entity defined in a Data Service data connection.

Properties

Name | Description
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Operations | Gets the collection of operations defined for the specified Entity. Read-only Operations.
Parent | Returns the parent object for the specified object. Read-only.


NavigationButton.OnClick Property (Access)

 Copy code hover
[image]

NavigationButton.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnClick

expression A variable that represents a NavigationButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Error evaluating

 Copy code hover
[image]

Error evaluating <name> CHECK constraint. <Additional information.> (Error 3802)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for more information.


ObjectFrame.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

ObjectFrame.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents an ObjectFrame object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.BorderThemeColorIndex=2

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Persisting Records in XML Format

 Copy code hover
[image]

Persisting Records in XML Format
Send feedback

Like ADTG format, Recordset persistence in XML format is implemented with the Microsoft OLE DB Persistence Provider. This provider generates a forward-only, read-only rowset from a saved XML file or stream that contains the schema information generated by ADO. Similarly, it can take an ADO Recordset, generate XML, and save it to a file or any object that implements the COM IStream interface. (In fact, a file is just another example of an object that supports IStream.) For versions 2.5 and later, ADO relies on the Microsoft XML Parser (MSXML) to load the XML into the Recordset; therefore msxml.dll is required. For version 2.5, MSXML shipped with Internet Explorer 5. For version 2.6, MSXML shipped with SQL Server 2000.

Note Note

Some limitations apply when saving hierarchical Recordsets (data shapes) to XML format. You cannot save to XML if the hierarchical Recordset contains pending updates, and you cannot save a parameterized hierarchical Recordset. For more information, see Hierarchical Recordsets in XML.

The easiest way to persist data into XML and load it back again through ADO is with the Save and Open methods, respectively. The following ADO code example demonstrates saving the data in the Titles table to a file named titles.sav.

Copy code Copy code

Dim rs as new Recordset
Dim rs2 as new Recordset
Dim c as new Connection
Dim s as new Stream

' Query the Titles table.
c.Open "provider='sqloledb';data source='mydb';initial catalog='pubs';Integrated Security='SSPI'"
rs.cursorlocation = adUseClient
rs.Open "select * from titles", c, adOpenStatic

' Save to the file in the XML format. Note that if you don't specify
' adPersistXML, a binary format (ADTG) will be used by default.
rs.Save "titles.sav", adPersistXML

' Save the Recordset into the ADO Stream object.
rs.save s, adPersistXML
rs.Close
c.Close

set rs = nothing

Reopen the file.
rs.Open "titles.sav",,,,adCmdFile
'Open the Stream back into a Recordset.
rs2.open s

ADO always persists the entire Recordset object. If you wish to only persist a subset of rows of the Recordset object, use the Filter method to narrow down the rows or change your selection clause. However, you must open a Recordset object with a client-side cursor (CursorLocation = adUseClient) to use the Filter method for saving a subset of rows. For example, to retrieve titles that start with the letter "b," you can apply a filter to an open Recordset object:

Copy code Copy code

rs.Filter "title_id like 'B*'"
rs.Save "btitles.sav", adPersistXML

ADO always uses the Client Cursor Engine rowset to produce a scrollable, bookmarkable Recordset object on top of the forward-only data generated by the Persistence Provider.


Setting an exchange with the same Synchronizer is not allowed. (Error 3500)

 Copy code hover
[image]

Setting an exchange with the same Synchronizer is not allowed. (Error 3500)
Send feedback

Use a valid remote Synchronizer ID in your synchronization request.


Attachment.OnKeyDown Property (Access)

 Copy code hover
[image]

Attachment.OnKeyDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Down box in the Properties window. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnKeyDown

expression A variable that represents an Attachment object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyDown event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Down box is blank, the property value is an empty string.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


BoundObjectFrame.InSelection Property (Access)

 Copy code hover
[image]

BoundObjectFrame.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents a BoundObjectFrame object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


TextBox.ForeTint Property (Access)

 Copy code hover
[image]

TextBox.ForeTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .ForeTint

expression A variable that represents a TextBox object.

Remarks

The ForeTint property contains a numeric expression that can be used to lighten the theme color in the ForeColor property. The default value of the ForeTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens ForeColor by 75%.

VBA Copy code Copy code
Me.ctl.ForeTint=25

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Types of Locks

 Copy code hover
[image]

Types of Locks
Send feedback

adLockBatchOptimistic

Indicates optimistic batch updates. Required for batch update mode.

Many applications fetch a number of rows at once and then need to make coordinated updates that include the entire set of rows to be inserted, updated, or deleted. With batch cursors, only one round trip to the server is needed, thus improving update performance and decreasing network traffic. Using a batch cursor library, you can create a static cursor and then disconnect from the data source. At this point you can make changes to the rows and subsequently reconnect and post the changes to the data source in a batch.

adLockOptimistic

Indicates that the provider uses optimistic locking — locking records only when you call the Update method. This means that there is a chance that the data may be changed by another user between the time you edit the record and when you call Update, which creates conflicts. Use this lock type in situations where the chances of a collision are low or where collisions can be readily resolved.

adLockPessimistic

Indicates pessimistic locking, record by record. The provider does what is necessary to ensure successful editing of the records, usually by locking records at the data source immediately before editing. Of course, this means that the records are unavailable to other users once you begin to edit, until you release the lock by calling Update. Use this type of lock in a system where you cannot afford to have concurrent changes to data, such as in a reservation system.

adLockReadOnly

Indicates read-only records. You cannot alter the data. A read-only lock is the "fastest" type of lock because it does not require the server to maintain a lock on the records.

adLockUnspecified

Does not specify a type of lock.


AllMacros.Application Property (Access)

 Copy code hover
[image]

AllMacros.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents an AllMacros object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

AllMacros Collection

Other resources

AllMacros Object Members


NavigationButton.OnKeyDown Property (Access)

 Copy code hover
[image]

NavigationButton.OnKeyDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Down box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnKeyDown

expression A variable that represents a NavigationButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyDown event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyDown

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


ToggleButton.ForeThemeColorIndex Property (Access)

 Copy code hover
[image]

ToggleButton.ForeThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ForeThemeColorIndex

expression A variable that represents a ToggleButton object.

Remarks

The ForeThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the ForeThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Fore Color to the Text 2 color by setting the ForeThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.ForeThemeColorIndex=2

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


BoundObjectFrame.OnEnter Property (Access)

 Copy code hover
[image]

BoundObjectFrame.OnEnter Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnEnter

expression A variable that represents a BoundObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Enter event occurs before a control actually receives the focus from a control on the same form.

The OnEnter value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Enter box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Enter box is blank, the property value is an empty string.

Example

The following example associates the Enter event with the macro "Enter_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnEnter = "Enter_Macro"

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Errors Collection (ADO) Reference

 Copy code hover
[image]

Errors Collection (ADO) Reference
Send feedback

In this section

  • Errors Collection (ADO)

  • Errors Collection Properties, Methods, and Events


ComboBox.KeyPress Event (Access)

 Copy code hover
[image]

ComboBox.KeyPress Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyPress(KeyAscii)

expression A variable that represents a ComboBox object.

Parameters

Name | Required/Optional | Data Type | Description
KeyAscii | Required | Integer | Returns a numeric ANSI key code. The KeyAscii argument is passed by reference; changing it sends a different character to the object. Setting the KeyAscii argument to 0 cancels the keystroke so that the object doesn't recognize that a key was pressed.

Remarks

To run a macro or event procedure when this event occurs, set the OnKeyPress property to the name of the macro or to [Event Procedure].

The object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down an ANSI key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

A KeyPress event can involve any printable keyboard character, the CTRL key combined with a character from the standard alphabet or a special character, and the ENTER or BACKSPACE key. You can use the KeyDown and KeyUp event procedures to handle any keystroke not recognized by the KeyPress event, such as function keys, navigation keys, and any combinations of these with keyboard modifiers (ALT, SHIFT, or CTRL keys). Unlike the KeyDown and KeyUp events, the KeyPress event doesn't indicate the physical state of the keyboard; instead, it indicates the ANSI character that corresponds to the pressed key or key combinations.

KeyPress interprets the uppercase and lowercase of each character as separate key codes and, therefore, as two separate characters.

Note Note

The BACKSPACE key is part of the ANSI character set, but the DEL key isn't. If you delete a character in a control by using the BACKSPACE key, you cause a KeyPress event; if you use the DEL key, you don't.

The KeyDown and KeyPress events occur when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

For example, if you go to a new record and type a character in the first control in the record, the following events occur:

Current (for the new record)

ß

Enter (for the first control in the new record)

ß

GotFocus (for the control)

ß

KeyDown (for the control)

ß

KeyPress (for the control)

ß

BeforeInsert (for the new record in the form)

ß

Change (for the control if it's a text box or combo box)

ß

KeyUp (for the control)

Example

The following example converts text entered in a text box to uppercase as the text is typed in, one character at a time.

To try the example, add the following event procedure to a form that contains a text box named ShipRegion.

VBA Copy code Copy code
Private Sub ShipRegion_KeyPress(KeyAscii As Integer)
 Dim strCharacter As String

 ' Convert ANSI value to character string.
 strCharacter = Chr(KeyAscii)
 ' Convert character to upper case, then to ANSI value.
 KeyAscii = Asc(UCase(strCharacter))
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ObjectFrame.HorizontalAnchor Property (Access)

 Copy code hover
[image]

ObjectFrame.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the object frame is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .HorizontalAnchor

expression A variable that represents an ObjectFrame object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Rectangle.Left Property (Access)

 Copy code hover
[image]

Rectangle.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Syntax

expression .Left

expression A variable that represents a Rectangle object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


ToggleButton.Height Property (Access)

 Copy code hover
[image]

ToggleButton.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Syntax

expression .Height

expression A variable that represents a ToggleButton object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


ComboBox.ControlTipText Property (Access)

 Copy code hover
[image]

ComboBox.ControlTipText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.

Syntax

expression .ControlTipText

expression A variable that represents a ComboBox object.

Remarks

You set the ControlTipText property by using a string expression up to 255 characters long.

For controls on forms, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

You can set the ControlTipText property in any view.

The ControlTipText property provides an easy way to provide helpful information about controls on a form.

There are other ways to provide information about a form or a control on a form. You can use the StatusBarText property to display information in the status bar about a control. To provide more extensive help for a form or control, use the HelpFile and HelpContextID properties.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ComboBox.LabelY Property (Access)

 Copy code hover
[image]

ComboBox.LabelY Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelY

expression A variable that represents a ComboBox object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Application.FileDialog Property (Access)

 Copy code hover
[image]

Application.FileDialog Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a FileDialog object which represents a single instance of a file dialog box. Read-only.

Syntax

expression .FileDialog(dialogType)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
dialogType | Required | MsoFileDialogType | An MsoFileDialogType constant that represents the type of dialog box.

Remarks

The msoFileDialogOpen and msoFileDialogSaveAs constants are not supported in Microsoft Access.

Example

This example illustrates how to use the FileFialog object to display a dialog box that allow the user to select one or more files. The selected files are then added to a listbox named FileList.

VBA Copy code Copy code
Private Sub cmdFileDialog_Click()

   ' Requires reference to Microsoft Office 11.0 Object Library.

   Dim fDialog As Office.FileDialog
   Dim varFile As Variant

   ' Clear listbox contents.
   Me.FileList.RowSource = ""

   ' Set up the File Dialog.
   Set fDialog = Application.FileDialog(msoFileDialogFilePicker)

   With fDialog

      ' Allow user to make multiple selections in dialog box
      .AllowMultiSelect = True

      ' Set the title of the dialog box.
      .Title = "Please select one or more files"

      ' Clear out the current filters, and add our own.
      .Filters.Clear
      .Filters.Add "Access Databases", "*.MDB"
      .Filters.Add "Access Projects", "*.ADP"
      .Filters.Add "All Files", "*.*"

      ' Show the dialog box. If the .Show method returns True, the
      ' user picked at least one file. If the .Show method returns
      ' False, the user clicked Cancel.
      If .Show = True Then

         'Loop through each file selected and add it to our list box.
         For Each varFile In .SelectedItems
            Me.FileList.AddItem varFile
         Next

      Else
         MsgBox "You clicked Cancel in the file dialog box."
      End If
   End With
End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


Form.OnLoad Property (Access)

 Copy code hover
[image]

Form.OnLoad Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Load box in the Properties window of a form. Read/write String.

Syntax

expression .OnLoad

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Load event occurs when a form is opened and its records are displayed.

The OnLoad value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Load box in the form's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Load box is blank, the property value is an empty string.

Example

The following example prints the value of the OnLoad property in the Immediate window for the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").OnLoad

See also

Concepts

Form Object

Other resources

Form Object Members


Recordset.CacheSize Property (DAO)

 Copy code hover
[image]

Recordset.CacheSize Property (DAO)
Send feedback

Sets or returns the number of records retrieved from an ODBC data source that will be cached locally. Read/write Long.

Syntax

expression .CacheSize

expression A variable that represents a Recordset object.

Remarks

The value of the CacheSize property must be between 5 and 1200, but not greater than available memory will allow. A typical value is 100. A setting of 0 turns off caching.

Data caching improves performance if you use Recordset objects to retrieve data from a remote server. A cache is a space in local memory that holds the data most recently retrieved from the server; this is useful if users request the data again while the application is running. When users request data, the Microsoft Access database engine checks the cache for the requested data first rather than retrieving it from the server, which takes more time. The cache only saves data that comes from an ODBC data source.

Any Microsoft Access database engine-connected ODBC data source, such as a linked table, can have a local cache. To create the cache, open a Recordset object from the remote data source, set the CacheSize and CacheStart properties, and then use the FillCache method, or step through the records by using the Move methods.

You can base the CacheSize property setting on the number of records your application can handle at one time. For example, if you're using a Recordset object as the source of the data to be displayed on screen, you could set its CacheSize property to 20 to display 20 records at one time.

The Microsoft Access database engine requests records within the cache range from the cache, and it requests records outside the cache range from the server.

Records retrieved from the cache don't reflect concurrent changes that other users made to the source data.

To force an update of all the cached data, set the CacheSize property of the Recordset object to 0, re-set it to the size of the cache you originally requested, and then use the FillCache method.

Example

This example uses the CreateTableDef and FillCache methods and the CacheSize, CacheStart and SourceTableName properties to enumerate the records in a linked table twice. Then it enumerates the records twice with a 50-record cache. The example then displays the performance statistics for the uncached and cached runs through the linked table.

VBA Copy code Copy code
Sub ClientServerX3()

 Dim dbsCurrent As Database
 Dim tdfRoyalties As TableDef
 Dim rstRemote As Recordset
 Dim sngStart As Single
 Dim sngEnd As Single
 Dim sngNoCache As Single
 Dim sngCache As Single
 Dim intLoop As Integer
 Dim strTemp As String
 Dim intRecords As Integer

 ' Open a database to which a linked table can be
 ' appended.
 Set dbsCurrent = OpenDatabase("DB1.mdb")

 ' Create a linked table that connects to a Microsoft SQL
 ' Server database.
 Set tdfRoyalties = _
 dbsCurrent.CreateTableDef("Royalties")
 ' Note: The DSN referenced below must be set to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 tdfRoyalties.Connect = _
 "ODBC;DATABASE=pubs;DSN=Publishers"
 tdfRoyalties.SourceTableName = "roysched"
 dbsCurrent.TableDefs.Append tdfRoyalties
 Set rstRemote = _
 dbsCurrent.OpenRecordset("Royalties")

 With rstRemote
 ' Enumerate the Recordset object twice and record
 ' the elapsed time.
 sngStart = Timer

 For intLoop = 1 To 2
 .MoveFirst
 Do While Not .EOF
 ' Execute a simple operation for the
 ' performance test.
 strTemp = !title_id
 .MoveNext
 Loop
 Next intLoop

 sngEnd = Timer
 sngNoCache = sngEnd - sngStart

 ' Cache the first 50 records.
 .MoveFirst
 .CacheSize = 50
 .FillCache
 sngStart = Timer

 ' Enumerate the Recordset object twice and record
 ' the elapsed time.
 For intLoop = 1 To 2
 intRecords = 0
 .MoveFirst
 Do While Not .EOF
 ' Execute a simple operation for the
 ' performance test.
 strTemp = !title_id
 ' Count the records. If the end of the
 ' cache is reached, reset the cache to the
 ' next 50 records.
 intRecords = intRecords + 1
 .MoveNext
 If intRecords Mod 50 = 0 Then
 .CacheStart = .Bookmark
 .FillCache
 End If
 Loop
 Next intLoop

 sngEnd = Timer
 sngCache = sngEnd - sngStart

 ' Display performance results.
 MsgBox "Caching Performance Results:" & vbCr & _
 " No cache: " & Format(sngNoCache, _
 "##0.000") & " seconds" & vbCr & _
 " 50-record cache: " & Format(sngCache, _
 "##0.000") & " seconds"
 .Close
 End With

 ' Delete linked table because this is a demonstration.
 dbsCurrent.TableDefs.Delete tdfRoyalties.Name
 dbsCurrent.Close

End Sub


Form.Open Event (Access)

 Copy code hover
[image]

Form.Open Event (Access)
See also Send feedback

Published: July 16, 2012

The Open event occurs when a form is opened, but before the first record is displayed.

Syntax

expression .Open(Cancel, )

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the opening of the form or report occurs. Setting the Cancel argument to True (-1) cancels the opening of the form or report.

Remarks

By running a macro or an event procedure when a form's Open event occurs, you can close another window or move the focus to a particular control on a form. You can also run a macro or an event procedure that asks for information needed before the form or report is opened or printed.

For example, an Open macro or event procedure can open a custom dialog box in which the user enters the criteria to filter the set of records to display on a form or the date range to include for a report.

The Open event doesn't occur when you activate a form that's already open — for example, when you switch to the form from another window in Microsoft Access or use the OpenForm action in a macro to bring the open form to the top. However, the Activate event does occur in these situations.

When you open a form based on an underlying query, Microsoft Access runs the underlying query for the form before it runs the Open macro or event procedure.

If your application can have more than one form loaded at a time, use the Activate and Deactivate events instead of the Open event to display and hide custom toolbars when the focus moves to a different form.

The Open event occurs before the Load event, which is triggered when a form is opened and its records are displayed.

When you first open a form, the following events occur in this order:

Open → Load → Resize → Activate → Current

The Close event occurs after the Unload event, which is triggered after the form is closed but before it is removed from the screen.

When you close a form, the following events occur in this order:

Unload → Deactivate → Close

When the Close event occurs, you can open another window or request the user's name to make a log entry indicating who used the form or report.

If you're trying to decide whether to use the Open or Load event for your macro or event procedure, one significant difference is that the Open event can be canceled, but the Load event can't. For example, if you're dynamically building a record source for a form in an event procedure for the form's Open event, you can cancel opening the form if there are no records to display. Similarly, the Unload event can be canceled, but the Close event can't.

Example

The following example shows how you can cancel the opening of a form when the user clicks a No button. A message box prompts the user to enter order details. If the user clicks No, the Order Details form isn't opened.

To try the example, add the following event procedure to a form.

VBA Copy code Copy code
Private Sub Form_Open(Cancel As Integer)
 Dim intReturn As Integer
 intReturn = MsgBox("Enter order details now?", vbYesNo)
 Select Case intReturn
 Case vbYes
 ' Open Order Details form.
 DoCmd.OpenForm "Order Details"
 Case vbNo
 MsgBox "Remember to enter order details by 5 P.M."
 Cancel = True ' Cancel Open event.
 End Select
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


OpenSchema Method Example (VC++)

 Copy code hover
[image]

OpenSchema Method Example (VC++)
Send feedback

This example uses the OpenSchema method to display the name and type of each table in the Pubs database.

Copy code Copy code

// BeginOpenSchemaCpp
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <oleauto.h>
#include <conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void OpenSchemaX(void);
void OpenSchemaX2(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 OpenSchemaX();

 printf("Press any key to see the results of 2nd "
 "function...\n\n");
 getch();

 OpenSchemaX2();

 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// OpenSchemaX Function //
// //
///////////////////////////////////////////////////////////

void OpenSchemaX()
{
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _ConnectionPtr pConnection = NULL;
 _RecordsetPtr pRstSchema = NULL;

 //Other Variables
 HRESULT hr = S_OK;

 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 // Open connection.
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
 pConnection->Open (strCnn, "", "", adConnectUnspecified);

 pRstSchema = pConnection->OpenSchema(adSchemaTables);

 while(!(pRstSchema->EndOfFile))
 {
 _bstr_t table_name = pRstSchema->Fields->
 GetItem("TABLE_NAME")->Value;

 printf("Table Name: %s\n",(LPCSTR) table_name);

 _bstr_t table_type = pRstSchema->Fields->
 GetItem("TABLE_TYPE")->Value;

 printf("Table type: %s\n\n",(LPCSTR) table_type);

 pRstSchema->MoveNext();

 int intLine = intLine + 1;
 if (intLine % 5 == 0)
 {
 printf("\nPress any key to continue...");
 getch();
 //Clear the screen for the next display
 system("cls");
 }
 }
 }
 catch (_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Connection.
 PrintProviderError(pConnection);
 PrintComError(e);
 }

 // Clean up objects before exit.
 if (pRstSchema)
 if (pRstSchema->State == adStateOpen)
 pRstSchema->Close();
 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

///////////////////////////////////////////////////////////
// //
// OpenSchemaX2 Function //
// //
///////////////////////////////////////////////////////////
void OpenSchemaX2()
{
 HRESULT hr = S_OK;
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _ConnectionPtr pConnection2 = NULL;
 _RecordsetPtr pRstSchema = NULL;

 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 // Open connection.
 TESTHR(pConnection2.CreateInstance(__uuidof(Connection)));
 pConnection2->Open (strCnn, "", "", adConnectUnspecified);

 // Create a safearray which takes four elements,and pass it as
 // 2nd parameter in OpenSchema method.
 SAFEARRAY FAR* psa = NULL;
 SAFEARRAYBOUND rgsabound;
 _variant_t var;
 _variant_t Array;
 rgsabound.lLbound = 0;
 rgsabound.cElements = 4;
 psa = SafeArrayCreate(VT_VARIANT, 1, &rgsabound);
 var.vt = VT_EMPTY;

 long ix;
 ix = 0;
 SafeArrayPutElement(psa, &ix, &var);

 ix= 1;
 SafeArrayPutElement(psa, &ix, &var);

 ix = 2;
 SafeArrayPutElement(psa, &ix, &var);

 var.vt = VT_BSTR;
 char * s1 = "VIEW";
 _bstr_t str = s1;
 var.bstrVal = str;

 ix = 3;
 SafeArrayPutElement(psa, &ix, &var);

 Array.vt = VT_ARRAY|VT_VARIANT;
 Array.parray = psa;

 pRstSchema = pConnection2->OpenSchema(adSchemaTables,&Array);

 while(!(pRstSchema->EndOfFile))
 {
 printf("Table Name: %s\n", (LPCSTR) (_bstr_t) pRstSchema->
 Fields->GetItem("TABLE_NAME")->Value);

 printf("Table type: %s\n\n",(LPCSTR) (_bstr_t) pRstSchema->
 Fields->GetItem("TABLE_TYPE")->Value);

 pRstSchema->MoveNext();

 int intLine = intLine + 1;
 if (intLine % 5 == 0)
 {
 printf("\nPress any key to continue...");
 getch();
 //Clear the screen for the next display
 system("cls");
 }
 }
 } // End Try statement.
 catch (_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Connection.
 PrintProviderError(pConnection2);
 PrintComError(e);
 }

 // Clean up objects before exit.
 if (pRstSchema)
 if (pRstSchema->State == adStateOpen)
 pRstSchema->Close();
 if (pConnection2)
 if (pConnection2->State == adStateOpen)
 pConnection2->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0;i < nCount;i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,
 pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print COM errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndOpenSchemaCpp


SubForm.Layout Property (Access)

 Copy code hover
[image]

SubForm.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified subform. Read-only AcLayoutType.

Version Information

Version Added: Access 2007

Syntax

expression .Layout

expression A variable that represents a SubForm object.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Form.Deactivate Event (Access)

 Copy code hover
[image]

Form.Deactivate Event (Access)
See also Send feedback

Published: July 16, 2012

The Deactivate event occurs when a form loses the focus to a Table, Query, Form, Report, Macro, or Module window, or to the Database window.

Syntax

expression .Deactivate

expression A variable that represents a Form object.

Return Value

nothing

Remarks

When you switch between two open forms, the Deactivate event occurs for the form being switched from, and the Activate event occurs for the form being switched to. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

When you first open a form, the following events occur in this order:

Open → Load → Resize → Activate → Current

When you close a form, the following events occur in this order:

Unload → Deactivate → Close

See also

Concepts

Form Object

Other resources

Form Object Members


Report.OrderByOn Property (Access)

 Copy code hover
[image]

Report.OrderByOn Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OrderByOn property to specify whether an object's OrderBy property setting is applied. Read/write Boolean.

Syntax

expression .OrderByOn

expression A variable that represents a Report object.

Remarks

The OrderByOn property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The OrderBy property setting is applied when the object is opened.
No | False | (Default) The OrderBy property setting isn't applied when the object is opened.

When a new object is created, it inherits the RecordSource , Filter , OrderBy, OrderByOn, and FilterOn properties of the table or query it was created from.

Example

The following example displays a message indicating the state of the OrderByOn property for the "Mailing List" form.

VBA Copy code Copy code
MsgBox "OrderByOn property is " & Forms("Mailing List").OrderByOn

See also

Concepts

Report Object

Other resources

Report Object Members


Now Function (Access 2013 custom web app)

 Copy code hover
[image]

Now Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the current date and time value in the time zone defined by the application.

Syntax

Now()

Remarks

The result of the Now function changes only when the column that contains the formula is refreshed. It is not updated continuously.

The Today function returns the same date but is not precise with regard to time; the time returned is always 12:00:00 AM and only the date is updated.


SQL Aggregate Functions (SQL)

 Copy code hover
[image]

SQL Aggregate Functions (SQL)
Send feedback

Using the SQL aggregate functions, you can determine various statistics on sets of values. You can use these functions in a query and aggregate expressions in the SQL property of a QueryDef object or when creating a Recordset object based on an SQL query.

Avg Function

Count Function

First, Last Functions

Min, Max Functions

StDev, StDevP Functions

Sum Function

Var, VarP Functions


The Microsoft Access database engine does not recognize

 Copy code hover
[image]

The Microsoft Access database engine does not recognize <name> as a valid field name or expression. (Error 3070)
Send feedback

The specified name is not a recognized field name or a valid expression. In a query, this error can occur if you enter a name that improperly refers to a database, table, or field.

Possible causes with Microsoft Access:

  • You have a parameter in a crosstab query or in a query that a crosstab query or chart is based on, and the parameter data type is not explicitly specified in the Query Parameters dialog box. To solve the problem:

    • In the query that contains the parameter, specify the parameter and its data type in the Query Parameters dialog box. And;

    • Set the ColumnHeadings property for the query that contains the parameter.

  • In any type of query, you have improperly referred to a database, table, or field. For example, this error can occur if you refer to a field named Salary in an expression, but you misspell the field name, such as [Sallary]*1.1 .


Form.OrderByOn Property (Access)

 Copy code hover
[image]

Form.OrderByOn Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OrderByOn property to specify whether an object's OrderBy property setting is applied. Read/write Boolean.

Syntax

expression .OrderByOn

expression A variable that represents a Form object.

Remarks

The OrderByOn property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The OrderBy property setting is applied when the object is opened.
No | False | (Default) The OrderBy property setting isn't applied when the object is opened.

When a new object is created, it inherits the RecordSource , Filter , OrderBy, OrderByOn, and FilterOn properties of the table or query it was created from.

Example

The following example displays a message indicating the state of the OrderByOn property for the "Mailing List" form.

VBA Copy code Copy code
MsgBox "OrderByOn property is " & Forms("Mailing List").OrderByOn

See also

Concepts

Form Object

Other resources

Form Object Members


TextBox.RunningSum Property (Access)

 Copy code hover
[image]

TextBox.RunningSum Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the RunningSum property to calculate record-by-record or group-by-group totals in a report. Read/write Byte.

Syntax

expression .RunningSum

expression A variable that represents a TextBox object.

Remarks

The RunningSum property specifies whether a text box on a report displays a running total and lets you set the range over which values are accumulated. For example, you can group data by month and show the sum of each month's sales in the group footer. You can show the running sum of accumulated sales over the entire report (sales for January in the January footer, sales for January plus February in the February footer, and so on) by adding a text box to the footer that shows the sum of sales and setting its RunningSum property to Over All.

The RunningSum property uses the following settings.

Setting | Visual Basic | Description
No | 0 | (Default) The text box displays the data from the underlying field for the current record.
Over Group | 1 | The text box displays a running sum of values in the same group level. The value accumulates until another group level section is encountered.
Over All | 2 | The text box displays a running sum of values in the same group level. The value accumulates until the end of the report.
Note Note

The RunningSum property applies only to a text box on a report.

Place the text box in the Detail section to calculate a record-by-record total. For example, to number the records appearing in a detail section of a report, set the ControlSource property for the text box to "=1", and set the RunningSum property to Over Group.

Place the text box in a group header or group footer to calculate a group-by-group total.

You can have up to 10 nested group levels in a report.

Example

The following example sets the RunningSum property for a text box named SalesTotal to 2 (Over All):

VBA Copy code Copy code
Reports!rptSales!SalesTotal.RunningSum = 2

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Form.BeforeDelConfirm Property (Access)

 Copy code hover
[image]

Form.BeforeDelConfirm Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the BeforeDelConfirm event occurs. Read/write.

Syntax

expression .BeforeDelConfirm

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeDelConfirm event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the BeforeDelConfirm event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).BeforeDelConfirm = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


ExportWithFormatting Macro Action

 Copy code hover
[image]

ExportWithFormatting Macro Action
Send feedback

You can use the ExportWithFormatting action to output the data in the specified Microsoft Access database object (a datasheet, form, report, module, or data access page) to several output formats.

Settings

The ExportWithFormatting action has the following arguments.

Action argument | Description
Object Type | The type of object containing the data to output. Click Table (for a table datasheet), Query (for a query datasheet), Form (for a form or form datasheet), Report, Module, Server View, Stored Procedure, or Function in the Object Type box in the Action Arguments section of the Macro Builder pane. You can't output a macro. If you want to output the active object, select its type with this argument, but leave the Object Name argument blank. This is a required argument. The default is Table.
Object Name | The name of the object containing the data to output. The Object Name box shows all objects in the database of the type selected by the Object Type argument. If you run a macro containing the ExportWithFormatting action in a library database, Access first looks for the object with this name in the library database, and then in the current database.
Output Format | The type of format you want to use to output the data. You can select 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 (*.pdf), Rich Text Format (*.rtf), Text Files (*.txt), or XPS Format (*.xps). If you leave this argument blank, Access prompts you for the output format.
Output File | The file to which you want to output the data, including the full path. You can include the standard file name extension for the output format you select with the Output Format argument, but it is not required. If you leave the Output File argument blank, Access prompts you for an output file name.
Auto Start | Specifies whether you want the appropriate software to start immediately after the ExportWithFormatting action runs, with the file specified by the Output File argument opened.
Template File | The path and file name of a file you want to use as a template for HTML files. The template file is a text file that includes HTML tags and tokens that are unique to Access.
Encoding | The type of character encoding format you want used to output the text or HTML data. You can select MS-DOS, Unicode, or Unicode (UTF-8). The MS-DOS argument setting is available only for text files. If you leave this argument blank, Access outputs the data by using the Windows default encoding for text files and the default system encoding for HTML files.
Output Quality | Select Print to optimize the output for printing, or Screen to optimize the output for display on a screen.

Remarks

The Access data is output in the selected format and can be read by any program that uses the same format. For example, you can output an Access report with its formatting to a Rich Text Format document and then open the document in Microsoft Word.

If you output the database object to HTML format, Access creates a file in HTML format containing the data from the object. You can use the Template File argument to specify a file to be used as a template for the .html file.

The following rules apply when you use the ExportWithFormatting action to output a database object to any of the output formats:

  • You can output data in table, query, and form datasheets. In the output file, all fields in the datasheet appear as they do in Access, with the exception of fields containing OLE objects. The columns for OLE object fields are included in the output file, but the fields are blank.

  • For a control that is bound to a Yes/No field (a toggle button, option button, or check box), the output file displays the value -1 (Yes) or 0 (No).

  • For a text box bound to a Hyperlink field, the output file displays the hyperlink for all output formats with the exception of MS-DOS text (in this case, the hyperlink is displayed as normal text).

  • If you output the data in a form in Form view, the output file always contains the form's Datasheet view.

  • When you output a datasheet, form, or data access page in HTML format, one .html file is created. When you output a report in HTML format, one .html file is created for each page in the report.

The result of running the ExportWithFormatting action is similar to clicking one of the options in the Export group on the External Data tab. The action arguments correspond to the settings in the Export dialog box.

To run the ExportWithFormatting action in a Visual Basic for Applications (VBA) module, use the OutputTo method of the DoCmd object.


Relations Collection (DAO)

 Copy code hover
[image]

Relations Collection (DAO)
Send feedback

A Relations collection contains stored Relation objects of a Database object (Microsoft Access database engine databases only).

Remarks

You can use the Relation object to create new relationships and examine existing relationships in your database. To add a Relation object to the Relations collection, first create it with the CreateRelation method, and then append it to the Relations collection with the Append method. This will save the Relation object when you close the Database object. To remove a Relation object from the collection, use the Delete method.

To refer to a Relation object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

Relations(0)

Relations("name")

Relations![name]

Example

This example shows how an existing Relation object can control data entry. The procedure attempts to add a record with a deliberately incorrect CategoryID; this triggers the error-handling routine.

VBA Copy code Copy code
Sub RelationX()

 Dim dbsNorthwind As Database
 Dim rstProducts As Recordset
 Dim prpLoop As Property
 Dim fldLoop As Field
 Dim errLoop As Error

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstProducts = dbsNorthwind.OpenRecordset("Products")

 ' Print a report showing all the different parts of
 ' the relation and where each part is stored.
 With dbsNorthwind.Relations!CategoriesProducts
 Debug.Print "Properties of " & .Name & " Relation"
 Debug.Print " Table = " & .Table
 Debug.Print " ForeignTable = " & .ForeignTable
 Debug.Print "Fields of " & .Name & " Relation"
 With .Fields!CategoryID
 Debug.Print " " & .Name
 Debug.Print " Name = " & .Name
 Debug.Print " ForeignName = " & .ForeignName
 End With
 End With

 ' Attempt to add a record that violates the relation.
 With rstProducts
 .AddNew
 !ProductName = "Trygve's Lutefisk"
 !CategoryID = 10
 On Error GoTo Err_Relation
 .Update
 On Error GoTo 0
 .Close
 End With

 dbsNorthwind.Close

 Exit Sub

Err_Relation:

 ' Notify user of any errors that result from
 ' the invalid data.
 If DBEngine.Errors.Count > 0 Then
 For Each errLoop In DBEngine.Errors
 MsgBox "Error number: " & errLoop.Number & _
 vbCr & errLoop.Description
 Next errLoop
 End If

 Resume Next

End Sub

This example uses the CreateRelation method to create a Relation between the Employees TableDef and a new TableDef called Departments. This example also demonstrates how creating a new Relation will also create any necessary Indexes in the foreign table (the DepartmentsEmployees Index in the Employees table).

VBA Copy code Copy code
Sub CreateRelationX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim tdfNew As TableDef
 Dim idxNew As Index
 Dim relNew As Relation
 Dim idxLoop As Index

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind
 ' Add new field to Employees table.
 Set tdfEmployees = .TableDefs!Employees
 tdfEmployees.Fields.Append _
 tdfEmployees.CreateField("DeptID", dbInteger, 2)

 ' Create new Departments table.
 Set tdfNew = .CreateTableDef("Departments")

 With tdfNew
 ' Create and append Field objects to Fields
 ' collection of the new TableDef object.
 .Fields.Append .CreateField("DeptID", dbInteger, 2)
 .Fields.Append .CreateField("DeptName", dbText, 20)

 ' Create Index object for Departments table.
 Set idxNew = .CreateIndex("DeptIDIndex")
 ' Create and append Field object to Fields
 ' collection of the new Index object.
 idxNew.Fields.Append idxNew.CreateField("DeptID")
 ' The index in the primary table must be Unique in
 ' order to be part of a Relation.
 idxNew.Unique = True
 .Indexes.Append idxNew
 End With

 .TableDefs.Append tdfNew

 ' Create EmployeesDepartments Relation object, using
 ' the names of the two tables in the relation.
 Set relNew = .CreateRelation("EmployeesDepartments", _
 tdfNew.Name, tdfEmployees.Name, _
 dbRelationUpdateCascade)

 ' Create Field object for the Fields collection of the
 ' new Relation object. Set the Name and ForeignName
 ' properties based on the fields to be used for the
 ' relation.
 relNew.Fields.Append relNew.CreateField("DeptID")
 relNew.Fields!DeptID.ForeignName = "DeptID"
 .Relations.Append relNew

 ' Print report.
 Debug.Print "Properties of " & relNew.Name & _
 " Relation"
 Debug.Print " Table = " & relNew.Table
 Debug.Print " ForeignTable = " & _
 relNew.ForeignTable
 Debug.Print "Fields of " & relNew.Name & " Relation"

 With relNew.Fields!DeptID
 Debug.Print " " & .Name
 Debug.Print " Name = " & .Name
 Debug.Print " ForeignName = " & .ForeignName
 End With

 Debug.Print "Indexes in " & tdfEmployees.Name & _
 " TableDef"
 For Each idxLoop In tdfEmployees.Indexes
 Debug.Print " " & idxLoop.Name & _
 ", Foreign = " & idxLoop.Foreign
 Next idxLoop

 ' Delete new objects because this is a demonstration.
 .Relations.Delete relNew.Name
 .TableDefs.Delete tdfNew.Name
 tdfEmployees.Fields.Delete "DeptID"
 .Close
 End With

End Sub


DatePart Function (Access 2013 custom web app)

 Copy code hover
[image]

DatePart Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns a numeric value that represents the specified date part of the specified date.

Syntax

DatePart(DatePart, Date)

The DatePart function contains the following arguments.

Argument name | Description
DatePart | The part of Date (a date or time value) for which an integer will be returned. Refer to the Remarks section for the list of valid abbreviations.
Date | An expression that can be resolved to a Date/Time value. The Date argument expression, column expression, user-defined variable or string literal.

Remarks

The following table lists all valid DatePart arguments.

DatePart

year

quarter

month

dayofyear

day

week

weekday

hour

minute

second

millisecond


OptionButton.BeforeUpdate Property (Access)

 Copy code hover
[image]

OptionButton.BeforeUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.

Syntax

expression .BeforeUpdate

expression A variable that represents an OptionButton object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeUpdate event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the BeforeUpdate event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).BeforeUpdate = "[Event Procedure]"

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Section.RepeatSection Property (Access)

 Copy code hover
[image]

Section.RepeatSection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the RepeatSection property to specify whether a group header is repeated on the next page or column when a group spans more than one page or column. Read/write Boolean.

Syntax

expression .RepeatSection

expression A variable that represents a Section object.

Remarks

The RepeatSection property only applies to group headers on a report.

The RepeatSection property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The group header is repeated.
No | False | (Default) The group header isn't repeated.

When printing a report that contains a subreport, the subreport's RepeatSection property will determine if the subreport group headers are repeated across pages or columns.

Example

The following example prints the group header "GroupHeader0" at the top of each page.

VBA Copy code Copy code
Reports("Purchase Order").Section("GroupHeader0").RepeatSection = True

See also

Concepts

Section Object

Other resources

Section Object Members


EndOfRecordset Event (ADO)

 Copy code hover
[image]

EndOfRecordset Event (ADO)
Send feedback

The EndOfRecordset event is called when there is an attempt to move to a row past the end of the Recordset.

Syntax

EndOfRecordset fMoreData, adStatus, pRecordset

Parameters

  • fMoreData

  • A VARIANT_BOOL value that, if set to VARIANT_TRUE, indicates more rows have been added to the Recordset.

  • adStatus

  • EventStatusEnum

    When EndOfRecordset is called, this parameter is set to adStatusOK if the operation that caused the event was successful. It is set to adStatusCantDeny if this event cannot request cancellation of the operation that caused this event.

    Before EndOfRecordset returns, set this parameter to adStatusUnwantedEvent to prevent subsequent notifications.

  • pRecordset

  • A Recordset object. The Recordset for which this event occurred.

Remarks

An EndOfRecordset event may occur if the MoveNext operation fails.

This event handler is called when an attempt is made to move past the end of the Recordset object, perhaps as a result of calling MoveNext. However, while in this event, you could retrieve more records from a database and append them to the end of the Recordset. In that case, set fMoreData to VARIANT_TRUE, and return from EndOfRecordset. Then call MoveNext again to access the newly retrieved records.


SmartTagProperties Members (Access)

 Copy code hover
[image]

SmartTagProperties Members (Access)
Send feedback

Published: July 16, 2012

A collection of SmartTagProperty objects that represents the properties related to a smart tag.

Methods

Name | Description
Add | Adds a custom property to a smart tag.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only SmartTagProperty.
Parent | Returns the parent object for the specified object. Read-only.


CodeData.AllViews Property (Access)

 Copy code hover
[image]

CodeData.AllViews Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllViews property to reference the AllViews collection and its related properties. Read-only AllViews object.

Syntax

expression .AllViews

expression A variable that represents a CodeData object.

See also

Concepts

CodeData Object

Other resources

CodeData Object Members


Form.RecordLocks Property (Access)

 Copy code hover
[image]

Form.RecordLocks Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the RecordLocks property to determine how records are locked and what happens when two users try to edit the same record at the same time. Read/write.

Syntax

expression .RecordLocks

expression A variable that represents a Form object.

Remarks

When you edit a record, Microsoft Access can automatically lock that record to prevent other users from changing it before you are finished. For forms, the RecordLocks property specifies how records in the underlying table or query are locked when data in a multiuser database is updated

The RecordLocks property only applies to forms, reports, or queries in a Microsoft Access database.

The RecordLocks property uses the following settings.

Setting | Visual Basic | Description
No Locks | 0 | (Default) In forms, two or more users can edit the same record simultaneously. This is also called "optimistic" locking. If two users attempt to save changes to the same record, Microsoft Access displays a message to the user who tries to save the record second. This user can then discard the record, copy the record to the Clipboard, or replace the changes made by the other user. This setting is typically used on read-only forms or in single-user databases. It is also used in multiuser databases to permit more than one user to be able to make changes to the same record at the same time.
All Records | 1 | All records in the underlying table or query are locked while the form is open in Form view or Datasheet view. Although users can read the records, no one can edit, add, or delete any records until the form is closed.
Edited Record | 2 | (Forms and queries only) A page of records is locked as soon as any user starts editing any field in the record and stays locked until the user moves to another record. Consequently, a record can be edited by only one user at a time. This is also called "pessimistic" locking.
Note Note

Changing the RecordLocks property of an open form or report causes an automatic recreation of the recordset.

You can use the No Locks setting for forms if only one person uses the underlying tables or queries or makes all the changes to the data.

In a multiuser database, you can use the No Locks setting if you want to use optimistic locking and warn users attempting to edit the same record on a form. You can use the Edited Record setting if you want to prevent two or more users editing data at the same time.

In Form view or Datasheet view, each locked record has a locked indicator in its record selector.

To change the default RecordLocks property setting for forms, click Options on the Tools menu, click the Advanced tab on the Options dialog box, and then select the desired option under Default record locking.

Data in a form, report, or query from an Open Database Connectivity (ODBC) database is treated as if the No Locks setting were chosen, regardless of the RecordLocks property setting.

Example

The following example sets the RecordLocks property of the "Employees" form to Edited Record (a page of records is locked as soon as any user starts editing any field in the record and stays locked until the user moves to another record).

VBA Copy code Copy code
Forms("Employees").RecordLocks = 2

See also

Concepts

Form Object

Other resources

Form Object Members


CommandButton.Caption Property (Access)

 Copy code hover
[image]

CommandButton.Caption Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the text that appears in the control. Read/write String.

Syntax

expression .Caption

expression A variable that represents a CommandButton object.

Remarks

The Caption property is a string expression that can contain up to 2,048 characters.

Note Note

The text of the Caption property for a label or command button control is the hyperlink display text when the HyperlinkAddress or HyperlinkSubAddress property is set for the control.

You can use the Caption property to assign an access key to a label or command button. In the caption, include an ampersand (&) immediately preceding the character you want to use as an access key. The character will be underlined. You can press ALT plus the underlined character to move the focus to that control on a form.

Include two ampersands (&&) in the setting for a caption if you want to display an ampersand itself in the caption text. For example, to display "Save & Exit", you should type Save && Exit in the Caption property box.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


FetchProgress Event (ADO)

 Copy code hover
[image]

FetchProgress Event (ADO)
Send feedback

The FetchProgress event is called periodically during a lengthy asynchronous operation to report how many more rows have currently been retrieved into the Recordset.

Syntax

FetchProgress Progress, MaxProgress, adStatus, pRecordset

Parameters

  • Progress

  • A Long value indicating the number of records that have currently been retrieved by the fetch operation.

  • MaxProgress

  • A Long value indicating the maximum number of records expected to be retrieved.

  • adStatus

  • An EventStatusEnum status value.

  • pRecordset

  • A Recordset object that is the object for which the records are being retrieved.

Remarks

When using FetchProgress with a child Recordset, be aware that the Progress and MaxProgress parameter values are derived from the underlying Cursor Service rowset. The values returned represent the total number of records in the underlying rowset, not just the number of records in the current chapter.

Note Note

To use FetchProgress with Microsoft Visual Basic, Visual Basic 6.0 or later is required.


NavigationButton.OldValue Property (Access)

 Copy code hover
[image]

NavigationButton.OldValue Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.

Version Information

Version Added: Access 2010

Syntax

expression .OldValue

expression A variable that represents a NavigationButton object.

Remarks

The OldValue property contains the unedited data from a bound control and is read-only in all views.

Microsoft Access uses the OldValue property to store the original value of a bound control. When you edit a bound control on a form, your changes aren't saved until you move to another record. The OldValue property contains the unedited version of the underlying data.

You can provide your own undo capability by assigning the OldValue property setting to a control. The following example shows how you can undo any changes to text box controls on a form:

VBA Copy code Copy code
Private Sub btnUndo_Click()

 Dim ctlTextbox As Control

 For Each ctlTextbox in Me.Controls
 If ctlTextbox.ControlType = acTextBox Then
 ctlTextbox.Value = ctl.OldValue
 End If
 Next ctlTextbox

End Sub

If the control hasn't been edited, this code has no effect. When you move to another record, the record source is updated, so the current value and the OldValue property will be the same.

The OldValue property setting has the same data type as the field to which the control is bound.

Example

The following example checks to determine if new data entered in a field is within 10 percent of the value of the original data. If the change is greater than 10 percent, the OldValue property is used to restore the original value. This procedure could be called from the BeforeUpdate event of the control that contains data you want to validate.

VBA Copy code Copy code
Public Sub Validate_Field()

 Dim curNewValue As Currency
 Dim curOriginalValue As Currency
 Dim curChange As Currency
 Dim strMsg As String

 curNewValue = Forms!Products!UnitPrice
 curOriginalValue = Forms!Products!UnitPrice.OldValue
 curChange = Abs(curNewValue - curOriginalValue)

 If curChange > (curOriginalValue * .1) Then
 strMsg = "Change is more than 10% of original unit price. " _
 & "Restoring original unit price."
 MsgBox strMsg, vbExclamation, "Invalid change."
 Forms!Products!UnitPrice = curOriginalValue
 End If

End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


CustomControl.ControlType Property (Access)

 Copy code hover
[image]

CustomControl.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Syntax

expression .ControlType

expression A variable that represents a CustomControl object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Concepts (Access 2013 custom web app)

 Copy code hover
[image]

Concepts (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • Reserved Words (Access 2013 custom web app)

  • How to: Create and customize a web app in Access 2013

  • Custom numeric formats for the Format function (Access 2013 custom web app)

  • Custom date and time formats for the Format function (Access 2013 custom web app)

  • How to: Filter a view by using a macro in an Access 2013 app


ComboBox.InheritValueList Property (Access)

 Copy code hover
[image]

ComboBox.InheritValueList Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether a combo box's value list is inherited from its field. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .InheritValueList

expression A variable that represents a ComboBox object.

Remarks

The InheritValueList property is effective only when the combo box is bound to a Lookup field and the RowSourceType property is set to Value List.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Report.PrintCount Property (Access)

 Copy code hover
[image]

Report.PrintCount Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PrintCount property to identify the number of times the OnPrint property has been evaluated for the current section of a report. Read/write Integer.

Syntax

expression .PrintCount

expression A variable that represents a Report object.

Remarks

You can use this property only in a macro or an event procedure specified by a section's OnPrint property setting.

Microsoft Access increments the PrintCount property each time the OnPrint property setting is evaluated for the current section. As the next section is printed, Microsoft Access resets the PrintCount property to 0.

This property isn't available in report Design view.

The PrintCount property is incremented, for example, when the KeepTogether property is set to No for the current section and the section is printed on more than one page. If you print a report containing order information, you might keep a running total of the order amounts.

Example

The following example shows how you can use the PrintCount property to make sure the value in the OrderAmount control is added only once to the running total.

RunningTotal can be a public variable or the name of an unbound control that is incremented each time a section is printed.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
 If PrintCount = 1 Then
 RunningTotal = RunningTotal + OrderAmount
 End If
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


CheckBox.DisplayWhen Property (Access)

 Copy code hover
[image]

CheckBox.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Syntax

expression .DisplayWhen

expression A variable that represents a CheckBox object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Module.Application Property (Access)

 Copy code hover
[image]

Module.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a Module object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

Module Object

Other resources

Module Object Members


Rectangle.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

Rectangle.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents a Rectangle object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BorderThemeColorIndex=2

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


SubForm.AddColon Property (Access)

 Copy code hover
[image]

SubForm.AddColon Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.

Syntax

expression .AddColon

expression A variable that represents a SubForm object.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Database.Execute Method (DAO)

 Copy code hover
[image]

Database.Execute Method (DAO)
Send feedback

Runs an action query or executes an SQL statement on the specified object.

Syntax

expression .Execute(Query, Options)

expression A variable that represents a Database object.

Parameters

Name | Required/Optional | Data Type | Description
Query | Required | String |
Options | Optional | Variant |

Remarks

You can use the following RecordsetOptionEnumconstants for options.

Constant | Description
dbDenyWrite | Denies write permission to other users (Microsoft Access workspaces only).
dbInconsistent | (Default) Executes inconsistent updates (Microsoft Access workspaces only).
dbConsistent | Executes consistent updates (Microsoft Access workspaces only).
dbSQLPassThrough | Executes an SQL pass-through query. Setting this option passes the SQL statement to an ODBC database for processing (Microsoft Access workspaces only).
dbFailOnError | Rolls back updates if an error occurs (Microsoft Access workspaces only).
dbSeeChanges | Generates a run-time error if another user is changing data you are editing (Microsoft Access workspaces only).
dbRunAsync | Executes the query asynchronously (ODBCDirect Connection and QueryDef objects only).
dbExecDirect | Executes the statement without first calling SQLPrepare ODBC API function (ODBCDirect Connection and QueryDef objects only).
Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Note Note

The constants dbConsistent and dbInconsistent are mutually exclusive. You can use one or the other, but not both in a given instance of OpenRecordset. Using both dbConsistent and dbInconsistent causes an error.

The Execute method is valid only for action queries. If you use Execute with another type of query, an error occurs. Because an action query doesn't return any records, Execute doesn't return a Recordset. (Executing an SQL pass-through query in an ODBCDirect workspace will not return an error if a Recordset isn't returned.)

Use the RecordsAffected property of the Connection, Database, or QueryDef object to determine the number of records affected by the most recent Execute method. For example, RecordsAffected contains the number of records deleted, updated, or inserted when executing an action query. When you use the Execute method to run a query, the RecordsAffected property of the QueryDef object is set to the number of records affected.

In a Microsoft Access workspace, if you provide a syntactically correct SQL statement and have the appropriate permissions, the Execute method won't fail — even if not a single row can be modified or deleted. Therefore, always use the dbFailOnError option when using the Execute method to run an update or delete query. This option generates a run-time error and rolls back all successful changes if any of the records affected are locked and can't be updated or deleted.

In earlier versions of the Microsoft Jet database engine, SQL statements were automatically embedded in implicit transactions. If part of a statement executed with dbFailOnError failed, the entire statement would be rolled back. To improve performance, these implicit transactions were removed starting with version 3.5. If you are updating older DAO code, be sure to consider using explicit transactions around Execute statements.

For best performance in a Microsoft Access workspace, especially in a multiuser environment, nest the Execute method inside a transaction. Use the BeginTrans method on the current Workspace object, then use the Execute method, and complete the transaction by using the CommitTrans method on the Workspace. This saves changes on disk and frees any locks placed while the query is running.

Example

This example demonstrates the Execute method when run from both a QueryDef object and a Database object. The ExecuteQueryDef and PrintOutput procedures are required for this procedure to run.

VBA Copy code Copy code
Sub ExecuteX()

 Dim dbsNorthwind As Database
 Dim strSQLChange As String
 Dim strSQLRestore As String
 Dim qdfChange As QueryDef
 Dim rstEmployees As Recordset
 Dim errLoop As Error

 ' Define two SQL statements for action queries.
 strSQLChange = "UPDATE Employees SET Country = " & _
 "'United States' WHERE Country = 'USA'"
 strSQLRestore = "UPDATE Employees SET Country = " & _
 "'USA' WHERE Country = 'United States'"

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 ' Create temporary QueryDef object.
 Set qdfChange = dbsNorthwind.CreateQueryDef("", _
 strSQLChange)
 Set rstEmployees = dbsNorthwind.OpenRecordset( _
 "SELECT LastName, Country FROM Employees", _
 dbOpenForwardOnly)

 ' Print report of original data.
 Debug.Print _
 "Data in Employees table before executing the query"
 PrintOutput rstEmployees

 ' Run temporary QueryDef.
 ExecuteQueryDef qdfChange, rstEmployees

 ' Print report of new data.
 Debug.Print _
 "Data in Employees table after executing the query"
 PrintOutput rstEmployees

 ' Run action query to restore data. Trap for errors,
 ' checking the Errors collection if necessary.
 On Error GoTo Err_Execute
 dbsNorthwind.Execute strSQLRestore, dbFailOnError
 On Error GoTo 0

 ' Retrieve the current data by requerying the recordset.
 rstEmployees.Requery

 ' Print report of restored data.
 Debug.Print "Data after executing the query " & _
 "to restore the original information"
 PrintOutput rstEmployees

 rstEmployees.Close

 Exit Sub

Err_Execute:

 ' Notify user of any errors that result from
 ' executing the query.
 If DBEngine.Errors.Count > 0 Then
 For Each errLoop In DBEngine.Errors
 MsgBox "Error number: " & errLoop.Number & vbCr & _
 errLoop.Description
 Next errLoop
 End If

 Resume Next

End Sub

Sub ExecuteQueryDef(qdfTemp As QueryDef, _
 rstTemp As Recordset)

 Dim errLoop As Error

 ' Run the specified QueryDef object. Trap for errors,
 ' checking the Errors collection if necessary.
 On Error GoTo Err_Execute
 qdfTemp.Execute dbFailOnError
 On Error GoTo 0

 ' Retrieve the current data by requerying the recordset.
 rstTemp.Requery

 Exit Sub

Err_Execute:

 ' Notify user of any errors that result from
 ' executing the query.
 If DBEngine.Errors.Count > 0 Then
 For Each errLoop In DBEngine.Errors
 MsgBox "Error number: " & errLoop.Number & vbCr & _
 errLoop.Description
 Next errLoop
 End If

 Resume Next

End Sub

Sub PrintOutput(rstTemp As Recordset)

 ' Enumerate Recordset.
 Do While Not rstTemp.EOF
 Debug.Print " " & rstTemp!LastName & _
 ", " & rstTemp!Country
 rstTemp.MoveNext
 Loop

End Sub


Document.LastUpdated Property (DAO)

 Copy code hover
[image]

Document.LastUpdated Property (DAO)
Send feedback

Returns the date and time of the most recent change made to an object. Read-only Variant.

Syntax

expression .LastUpdated

expression A variable that represents a Document object.

Remarks

DateCreated and LastUpdated return the date and time that the object was created or last updated. In a multiuser environment, users should get these settings directly from the file server to avoid discrepancies in the DateCreated and LastUpdated property settings.


ListBox.ForeThemeColorIndex Property (Access)

 Copy code hover
[image]

ListBox.ForeThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ForeThemeColorIndex

expression A variable that represents a ListBox object.

Remarks

The ForeThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the ForeThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Fore Color to the Text 2 color by setting the ForeThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.ForeThemeColorIndex=2

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


ToggleButton.ControlType Property (Access)

 Copy code hover
[image]

ToggleButton.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Syntax

expression .ControlType

expression A variable that represents a ToggleButton object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


ListBox.ListCount Property (Access)

 Copy code hover
[image]

ListBox.ListCount Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ListCount property to determine the number of rows in a list box. Read/write Long.

Syntax

expression .ListCount

expression A variable that represents a ListBox object.

Remarks

Microsoft Access sets the ListCount property to the number of rows in the list box or the list box portion of the combo box. The value of the ListCount property is read-only and can't be set by the user.

This property is available only by using a macro or Visual Basic . You can read this property only in Form view and Datasheet view.

The ListCount property setting contains the total number of rows in the combo box list or list box, as determined by the control'sRowSource and RowSourceType properties. If the control is based on a table or query (the RowSourceType property is set to Table/Query and the RowSource property is set to a particular table or query), the ListCount property setting contains the number of records in the table or query result set. If the RowSourceType property is set to Value List, the ListCount property setting contains the number of rows the value list specified in the RowSource property results in (this depends on the value list and the number of columns in the list box or combo box list, as set by the ColumnCount property).

If you set the ColumnHeads property to Yes, the row of column headings is included in the number of rows returned by the ListCount property. For combo boxes and list boxes based on a table or query, adding column headings adds an additional row. For combo boxes and list boxes based on a value list, adding column headings leaves the number of rows unchanged (the first row of values becomes the column headings).

You can use the ListCount property with the ListRows property to specify how many rows you want to display in the list box portion of a combo box.

Example

The following example uses the ListCount property to find the number of rows in the list box portion of the CustomerList combo box on a Customers form. It then sets the ListRows property to display a specified number of rows in the list.

VBA Copy code Copy code
Public Sub SizeCustomerList()

 Dim ListControl As Control

 Set ListControl = Forms!Customers!CustomerList
 With ListControl
 If .ListCount < 8 Then
 .ListRows = .ListCount
 Else
 .ListRows = 8
 End If
 End With

End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Exp Function (Access 2013 custom web app)

 Copy code hover
[image]

Exp Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the exponential value of the specified expression.

Syntax

Exp(NumericExpression)

The Exp function contains the following argument.

Argument name | Description
NumericExpression | An expression of type Double or of a type that can be implicitly converted to Double.

Remarks

The constant e (2.718281…), is the base of natural logarithms.

The exponent of a number is the constant e raised to the power of the number. For example Exp(1.0) = e^1.0 = 2.71828182845905 and Exp(10) = e^10 = 22026.4657948067.

The exponential of the natural logarithm of a number is the number itself: Exp(LOG (n)) = n. And the natural logarithm of the exponential of a number is the number itself: LOG (Exp(n)) = n.


Numeric field overflow. (Error 3349)

 Copy code hover
[image]

Numeric field overflow. (Error 3349)
Send feedback

The data in a Btrieve field is too large to represent in your application.


Members Example (VBScript)

 Copy code hover
[image]

Members Example (VBScript)
Send feedback

This sample uses an MDX query string to retrieve OLAP data and writes the resulting cellset to an HTML table structure using column spanning features for multiple-dimension cellsets.

VBS Copy code Copy code

<%@ Language=VBScript %>
<%
'************************************************************************
'*** Active Server Page displays OLAP data from default or provided
'*** MDX Query string and writes resulting cell set to HTML table
'*** structure. This ASP provides colspan features for multiple
'*** dimension cell sets.
'************************************************************************
Response.Buffer=True
Response.Expires=0
%>
<html>
<head>
</head>
<body bgcolor="Ivory">
<font FACE="Verdana">

<%

Dim cat,cst,i,j,strSource,csw,LevelValue,intDC0,intDC1,intPC0, intPC1
'************************************************************************
'*** Gather Server Name and MDX Query Strings from text box and
'*** text area and assign them to Session Objects of same name
'************************************************************************
Session("ServerName")=Request.Form("strServerName")
Session("InitialCatalog")=Request.Form("strInitialCatalog")
Session("MDXQuery")=Request.Form("MDXQuery")

'************************************************************************
'*** Set Connection Objects for Multi dimensional Catalog and Cell Set
'************************************************************************
Set cat = Server.CreateObject("ADOMD.Catalog")
Set cst = Server.CreateObject("ADOMD.CellSet")

'************************************************************************
'*** Check to see if the Session Object Server Name is present
'*** If present then: Create Active Connection using Server Name
'*** and MSOLAP as connection Provider
'*** If not present then: Use default settings of a known OLAP Server
'*** for Server Name for Connection Set Server Name Session Object
'*** to default value
'************************************************************************
If Len(Session("ServerName")) > 0 Then
   cat.ActiveConnection = "Data Source='" & Session("ServerName") & _
      "';Initial Catalog='" & Session("InitialCatalog") & _
      "';Provider='msolap';"
Else

'************************************************************************
'*** Must set OLAPServerName to OLAP Server that is
'*** present on network
'************************************************************************
   OLAPServerName = "Please set to present OLAP Server"
   cat.ActiveConnection = "Data Source=" & OLAPServerName & _
      ";Initial Catalog=FoodMart;Provider=msolap;"
   Session("ServerName") = OLAPServerName
   Session("InitialCatalog") = "FoodMart"
End if
'************************************************************************
'*** Check to see if the Session Object MDXQuery is present
'*** If present then: Set strSource using MDXQuery Session Object
'*** If not present then: Use default MDX Query string of a known query
'*** that works with default server Set MDXQuery Session Object to
'*** default value
'************************************************************************
If Len(Session("MDXQuery")) < 5 Then
   strSource = strSource & "SELECT "
   strSource = strSource & "CROSSJOIN({[Store].[Store Country].MEMBERS},"
   strSource = strSource & "{[Measures].[Store " & _
      "Invoice],[Measures].[Supply Time]}) ON COLUMNS,"
   strSource = strSource & "CROSSJOIN({[Time].[Year].MEMBERS},"
   strSource = strSource & "CROSSJOIN({[Store Type].[Store " & _
      "Type].Members},{[Product].[Product Family].members})) ON ROWS"
   strSource = strSource & " FROM Warehouse"
Else
   strSource = Session("MDXQuery")
End if

'************************************************************************
'*** Set Cell Set Source property to strSource to be passed on cell set
'*** open method
'************************************************************************
   cst.Source = strSource

'************************************************************************
'*** Set Cell Sets Active connection to use the current Catalogs Active
'*** connection
'************************************************************************
Set cst.ActiveConnection = cat.ActiveConnection

'************************************************************************
'*** Using Open method, Open cell set
'************************************************************************
cst.Open

'************************************************************************
'*** Standard HTML to collect Server Name and MDX Query Information
'*** Note that post action posts back to same page to process
'*** thus using state of Session Variables to change look of page
'************************************************************************
%>
<form action="ASPADOComplex.asp" method="POST" id="form1" name="form1">
<table>
<tr><td align="left">
<b>Olap Server name:</b><br><input type="text" id="strServerName" name="strServerName" value="<%=Session("ServerName")%>" size="20">
<br>
<b>Catalog name:</b><br><input type="text" id="strInitialCatalog" name="strInitialCatalog" value="<%=Session("InitialCatalog")%>" size="20">
</td><td align="center">
<b>MDX Query:</b><br>
<textarea rows="7" cols="70" id="textareaMDX" name="MDXQuery" wrap="soft">
<%=Session("MDXQuery")%>
</textarea>
</td></tr>
</table>
<table>
<tr><td>
<input type="submit" value="Submit MDX Query" id="submit1" name="submit1">
</td><td>
<input type="reset" value="Reset" id="reset1" name="reset1">
</td></tr>
</table>
</form>
<p align="left">
<font color="Black" size="-3">
<%=strSource%>
</font>
</p>
<%
'************************************************************************
'*** Set Dimension Counts minus 1 for Both Axes to intDC0, intDC1
'*** Set Position Counts minus 1 for Both Axes to intPC0, intPC1
'************************************************************************
intDC0 = cst.Axes(0).DimensionCount-1
intDC1 = cst.Axes(1).DimensionCount-1

intPC0 = cst.Axes(0).Positions.Count - 1
intPC1 = cst.Axes(1).Positions.Count - 1

'************************************************************************
'*** Create HTML Table structure to hold MDX Query return Record set
'************************************************************************
Response.Write "<Table width=100% border=1>"

'************************************************************************
'*** Loop to create Column header for all Dimensions based
'*** on Count of Dimensions for Axes(0)
'************************************************************************
For h=0 to intDC0
   Response.Write "<TR>"

'************************************************************************
'*** Loop to create spaces in front of Column headers
'*** to align with Row headers
'************************************************************************
   For c=0 to intDC1
      Response.Write "<TD></TD>"
   Next

'************************************************************************
'*** Check current dimension to see if equal to Last Dimension
'*** If True: Write Table header titles normally to HTML output with out
'*** ColSpan value
'*** If False: Write Table header titles with ColSpan values to HTML
'*** output
'************************************************************************
   If h = intDC0 then

'************************************************************************
'*** Iterate through Axes(0) Positions writing member captions to table
'*** header
'************************************************************************
      For i = 0 To intPC0
         Response.Write "<TH>"
         Response.Write "<FONT size=-2>"
         Response.Write cst.Axes(0).Positions(i).Members(h).Caption
         Response.Write "</FONT>"
         Response.Write "</TH>"
      Next
   Else

'************************************************************************
'*** Iterate through Axes(0) Positions writing member captions to table
'*** header taking into account for the span of columns for duplicate
'*** member captions
'************************************************************************
      CaptionCount = 1
      LastCaption = cst.Axes(0).Positions(0).Members(h).Caption
      Response.Write "<TH"
      For t=1 to intPC0

'************************************************************************
'*** Check to see if LastCaption is equal to current members caption
'*** If True: Add one to CaptionCount to increase Colspan value
'*** If False: Write Table header titles with ColSpan values to HTML
'*** output using current CaptionCount for Colspan and LastCaption for
'*** header string
'************************************************************************
         If LastCaption = _
            cst.Axes(0).Positions(t).Members(h).Caption then
            CaptionCount = CaptionCount+1

'************************************************************************
'*** Check if at last position
'*** If True: Write HTML to finish table row using current
'*** CaptionCount and LastCaption
'************************************************************************
            If t = intPC0 then
               Response.Write " colspan=" & CaptionCount & _
                  "><FONT size=-2>" & LastCaption & "</FONT></TH>"
            End if

         Else
            Response.Write " colspan=" & CaptionCount & _
               "><FONT size=-2>" & LastCaption & "</FONT></TH><TH"
            CaptionCount = 1
            LastCaption=cst.Axes(0).Positions(t).Members(h).Caption
         End if
      Next
         End if
         Response.Write "</TR>"
      Next

'************************************************************************
'*** Iterate through Axes(1) Positions first writing member captions
'*** to table row headers then writing cell set data to table structure
'************************************************************************
      Dim aryRows()
      Dim intArray,Marker
      intArray=0

'************************************************************************
'*** Set value of Array for row header formatting
'************************************************************************
      For a=1 To intDC1
         intArray = intArray+(intPC1+1)
      Next
      intArray = intArray-1
      ReDim aryRows(intArray)
      Marker=0

'************************************************************************
'*** Use Array values for row header formatting to provide
'*** spaces under beginning row header titles
'************************************************************************
      For j = 0 To intPC1
         Response.Write "<TR>"
         For h=0 to intDC1
            If h=intDC1 then
               Response.Write "<TD><B>"
               Response.Write "<FONT size=-2>"
               Response.Write cst.Axes(1).Positions(j).Members(h).Caption
               Response.Write "</FONT>"
               Response.Write "</B></TD>"
            Else
               aryRows(Marker) = _
                  cst.Axes(1).Positions(j).Members(h).Caption
               If Marker < intDC1 then
                  Response.Write "<TD><B>"
                  Response.Write "<FONT size=-2>"
                  Response.Write _
                     cst.Axes(1).Positions(j).Members(h).Caption
                  Response.Write "</FONT>"
                  Response.Write "</B></TD>"
                  Marker = Marker + 1
               Else
                  If aryRows(Marker) = aryRows(Marker - intDC1) then
                     Response.Write "<TD>&nbsp;</TD>"
                     Marker = Marker + 1
                  Else
                     Response.Write "<TD><B>"
                     Response.Write "<FONT size=-2>"
                     Response.Write _
                        cst.Axes(1).Positions(j).Members(h).Caption
                     Response.Write "</FONT>"
                     Response.Write "</B></TD>"
                     Marker = Marker + 1
                  End if
               End if
            End if
         Next

'************************************************************************
'*** Alternates Cell background color
'************************************************************************
         If (j+1) Mod 2 = 0 Then
            csw = "#cccccc"
         Else
            csw = "#ccffff"
         End If
         For k = 0 To intPC0
            Response.Write "<TD align=right bgcolor="
            Response.Write csw
            Response.Write ">"
            Response.Write "<FONT size=-2>"

'************************************************************************
'*** FormattedValue property pulls data
'************************************************************************
            Response.Write cst(k, j).FormattedValue
            Response.Write "</FONT>"
            Response.Write "</TD>"
         Next
         Response.Write "</TR>"
      Next
      Response.Write "</Table>"

%>
</font>
</body>
</html>


Form.Pages Property (Access)

 Copy code hover
[image]

Form.Pages Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Pages property to return information needed to print page numbers in a form. Read/write Integer.

Syntax

expression .Pages

expression A variable that represents a Form object.

Remarks

This property is only available in Print Preview or when printing.

To refer to the Pages property in a macro or Visual Basic, the form or report must include a text box whose ControlSource property is set to an expression that uses Pages. For example, you can use the following expressions as the ControlSource property setting for a text box in a page footer.

This expression | Prints
=Page | A page number (for example, 1, 2, 3) in the page footer.
="Page " & Page & " of " & Pages | "Page n of nn" (for example, Page 1 of 5, Page 2 of 5) in the page footer.
=Pages | The total number pages in the form (for example, 5).

See also

Concepts

Form Object

Other resources

Form Object Members


Field.SourceTable Property (DAO)

 Copy code hover
[image]

Field.SourceTable Property (DAO)
Send feedback

Returns a value that indicates the name of the table that is the original source of the data for a Field object. Read-only String.

Syntax

expression .SourceTable

expression A variable that represents a Field object.

Remarks

For a Field object, use of the SourceField and SourceTable properties depends on the object that contains the Fields collection that the Field object is appended to, as shown in the following table.

Object appended to | Usage
Index | Not supported
QueryDef | Read-only
Recordset | Read-only
Relation | Not supported
TableDef | Read-only

These properties indicate the original field and table names associated with a Field object. For example, you could use these properties to determine the original source of the data in a query field whose name is unrelated to the name of the field in the underlying table.

Note Note

The SourceTable property will not return a meaningful table name if used on a Field object in the Fields collection of a table-type Recordset object.


CodeProject.IsConnected Property (Access)

 Copy code hover
[image]

CodeProject.IsConnected Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsConnected property to determine if the CodeProject object is currently connected. Read-only Boolean.

Syntax

expression .IsConnected

expression A variable that represents a CodeProject object.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


Form.DatasheetForeColor Property (Access)

 Copy code hover
[image]

Form.DatasheetForeColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DatasheetForeColor property in Visual Basic to specify or determine the color of all text in a table, query, or form in Datasheet view within an Access database. Read/write Long.

Syntax

expression .DatasheetForeColor

expression A variable that represents a Form object.

Remarks

Setting the DatasheetForeColor property for a table or query won't affect this property setting for a form that uses the table or query as its source of data.

The following table contains the properties that don't exist in the DAO Properties collection of until you set them by using the Formatting (Datasheet) toolbar or you can add them in an Access database by using the CreateProperty method and append it to the DAO Properties collection.

DatasheetBackColor | DatasheetFontUnderline *
DatasheetCellsEffect | DatasheetFontWeight *
DatasheetFontHeight * | DatasheetForeColor*
DatasheetFontItalic * | DatasheetGridlinesBehavior
DatasheetFontName * | DatasheetGridlinesColor
Note Note

When you add or set any property listed with an asterisk, Microsoft Access automatically adds it to the Properties collection.

Example

The following example uses the SetTableProperty procedure to set a table's font color to dark blue and its background color to light gray. If a "Property not found" error occurs when the property is set, the CreateProperty method is used to add the property to the object's Properties collection.

VBA Copy code Copy code
Dim dbs As Object, objProducts As Object
Const lngForeColor As Long = 8388608 ' Dark blue.
Const lngBackColor As Long = 12632256 ' Light gray.
Const DB_Long As Long = 4
Set dbs = CurrentDb
Set objProducts = dbs!Products
SetTableProperty objProducts, "DatasheetBackColor", DB_Long, lngBackColor
SetTableProperty objProducts, "DatasheetForeColor", DB_Long, lngForeColor

Sub SetTableProperty(objTableObj As Object, strPropertyName As String, _
 intPropertyType As Integer, varPropertyValue As Variant)
 Const conErrPropertyNotFound = 3270
 Dim prpProperty As Variant
 On Error Resume Next ' Don't trap errors.
 objTableObj.Properties(strPropertyName) = varPropertyValue
 If Err <> 0 Then ' Error occurred when value set.
 If Err <> conErrPropertyNotFound Then
 ' Error is unknown.
 MsgBox "Couldn't set property '" & strPropertyName _
 & "' on table '" & tdfTableObj.Name & "'", vbExclamation, Err.Description
 Err.Clear
 Else
 ' Error is "Property not found", so add it to collection.
 Set prpProperty = objTableObj.CreateProperty(strPropertyName, _
 intPropertyType, varPropertyValue)
 objTableObj.Properties.Append prpProperty
 Err.Clear
 End If
 End If
 objTableObj.Properties.Refresh
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Too many expressions in DISTINCT output. (Error 3089)

 Copy code hover
[image]

Too many expressions in DISTINCT output. (Error 3089)
Send feedback

You created an SQL statement that has an ALL, DISTINCT, or DISTINCTROW predicate with more than ten expressions. Remove the DISTINCT reserved word, or remove some of the fields listed in the DISTINCT predicate.


Invalid SQL syntax - Expected token: CASCADE, SET NULL, or NO ACTION. (Error 3725)

 Copy code hover
[image]

Invalid SQL syntax - Expected token: CASCADE, SET NULL, or NO ACTION. (Error 3725)
Send feedback

This error occurs when defining referential integrity through the CREATE TABLE statement or the ALTER TABLE ALTER COLUMN statement. This error occurs when the keyword UPDATE or DELETE is used and is not followed by one of the following keywords: CASCADE, SET NULL, NO ACTION.


Using the Command Object Reference (ADO)

 Copy code hover
[image]

Using the Command Object Reference (ADO)
Send feedback

In this section

  • Using the Command Object (Access)

  • Command Object Overview

  • Creating and Executing a Simple Command

  • Command Object Parameters

  • Calling a Stored Procedure with a Command

  • Named Commands


WebBrowserControl.GridlineColor Property (Access)

 Copy code hover
[image]

WebBrowserControl.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified list box. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineColor

expression A variable that represents a WebBrowserControl object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


ObjectFrame.RightPadding Property (Access)

 Copy code hover
[image]

ObjectFrame.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the object frame and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .RightPadding

expression A variable that represents an ObjectFrame object.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


How to: Change the Filter or Sort Order of a Form or Report

 Copy code hover
[image]

How to: Change the Filter or Sort Order of a Form or Report
Send feedback

After a form or report is open, you can change the filter or sort order in response to users' actions by setting form and report properties in Microsoft Visual Basic for Applications (VBA) code. For example, you may want to provide a button or a shortcut menu that users can use to change the records that are displayed. Or you may include an option group control on a form that users can use to select from common sorting options.

To set the filter of a form or report, set its Filter property to the appropriate wherecondition argument, and then set the FilterOn property to True. To set the sort order, set the OrderBy property to the field or fields you want to sort on, and then set the OrderByOn property to True. If a filter or sort order is already applied on a form, you can change it simply by setting the Filter or OrderBy properties.

When you apply or change the filter or sort order by setting these properties, Access automatically requeries the records in the form or report. For example, the following code changes the sort order of a form based on a user's selection in an option group:

VBA Copy code Copy code
Private Sub SortOptionGrp_AfterUpdate()

 Const conName = 0
 Const conDate = 1

On Error GoTo ErrorHandler

 Select Case SortOptionGrp
 Case conName
 Me.OrderBy = "LastName, FirstName" ' Sort by two fields.
 Case conDate
 Me.OrderBy = "HireDate DESC" ' Sort by descending date.
 End Select

 Me.OrderByOn = True ' Apply the sort order.

 Exit Sub

ErrorHandler:
 MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Sub

Whether the filter and sort order get set in code or by the user, you can apply or remove them by setting the FilterOn and OrderByOn properties to True or False.


Image.OnMouseMove Property (Access)

 Copy code hover
[image]

Image.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Syntax

expression .OnMouseMove

expression A variable that represents an Image object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

Image Object

Other resources

Image Object Members


Page.ControlTipText Property (Access)

 Copy code hover
[image]

Page.ControlTipText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.

Syntax

expression .ControlTipText

expression A variable that represents a Page object.

Remarks

You set the ControlTipText property by using a string expression up to 255 characters long.

For controls on forms, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

You can set the ControlTipText property in any view.

The ControlTipText property provides an easy way to provide helpful information about controls on a form.

There are other ways to provide information about a form or a control on a form. You can use the StatusBarText property to display information in the status bar about a control. To provide more extensive help for a form or control, use the HelpFile and HelpContextID properties.

See also

Concepts

Page Object

Other resources

Page Object Members


Application.RefreshTitleBar Method (Access)

 Copy code hover
[image]

Application.RefreshTitleBar Method (Access)
See also Send feedback

Published: July 16, 2012

The RefreshTitleBar method refreshes the Microsoft Access title bar after the AppTitle or AppIcon property has been set in Visual Basic.

Syntax

expression .RefreshTitleBar

expression A variable that represents an Application object.

Return Value

Nothing

Remarks

For example, you can change the caption in the Microsoft Access title bar to "Contacts Database" by setting the AppTitle property.

The AppTitle and AppIcon properties enable you to customize your application by changing the title and icon that appear in the Microsoft Access title bar. The title bar is not automatically updated after you have set these properties. In order for the change to the title bar to appear, you must use the RefreshTitleBar method.

Note Note

In a Microsoft Access database, you can reset the AppTitle and AppIcon properties to their default value by deleting them from the Properties collection representing the current database. After you delete these properties, you must use the RefreshTitleBar method to restore the Microsoft Access defaults to the title bar.

It the path to the icon specified by the AppIcon property is invalid, then no changes will be refled in the title bar when you call this method.

Example

The following example sets the AppTitle property of the current database and applies the RefreshTitleBar method to update the title bar.

VBA Copy code Copy code
Sub ChangeTitle()
 Dim obj As Object
 Const conPropNotFoundError = 3270

 On Error GoTo ErrorHandler
 ' Return Database object variable pointing to
 ' the current database.
 Set dbs = CurrentDb
 ' Change title bar.
 dbs.Properties!AppTitle = "Contacts Database"
 ' Update title bar on screen.
 Application.RefreshTitleBar
 Exit Sub

ErrorHandler:
 If Err.Number = conPropNotFoundError Then
 Set obj = dbs.CreateProperty("AppTitle", dbText, "Contacts Database")
 dbs.Properties.Append obj
 Else
 MsgBox "Error: " & Err.Number & vbCrLf & Err.Description
 End If
 Resume Next
End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


Synchronizer could not be initialized. (Error 3532)

 Copy code hover
[image]

Synchronizer could not be initialized. (Error 3532)
Send feedback

It is not possible to start the Synchronizer. Shut down and restart your computer. If the error persists, reconfigure the Synchronizer.

To configure the Synchronizer

  1. Start Replication Manager.

  2. On the Tools menu, click Configure Microsoft Replication Manager.

  3. Follow the instructions in the wizard.


ADOX Collections Reference

 Copy code hover
[image]

ADOX Collections Reference
Send feedback

In this section

  • ADOX Collections

  • Columns Collection (ADOX) Reference

  • Groups Collection (ADOX) Reference

  • Indexes Collection (ADOX) Reference

  • Keys Collection (ADOX) Reference

  • Procedures Collection (ADOX) Reference

  • Tables Collection (ADOX) Reference

  • Users Collection (ADOX) Reference

  • Views Collection (ADOX) Reference


Scaling of decimal value resulted in data overflow. (Error 3760)

 Copy code hover
[image]

Scaling of decimal value resulted in data overflow. (Error 3760)
Send feedback

This error occurs when the data being updated or inserted into a DECIMAL data type is greater than the scale defined on the column.


TabControl.GridlineStyleRight Property (Access)

 Copy code hover
[image]

TabControl.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleRight

expression A variable that represents a TabControl object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Workspace.Rollback Method (DAO)

 Copy code hover
[image]

Workspace.Rollback Method (DAO)
Send feedback

Ends the current transaction and restores the databases in the Workspace object to the state they were in when the current transaction began.

Syntax

expression .Rollback

expression A variable that represents a Workspace object.

Remarks

The transaction methods BeginTrans, CommitTrans, and Rollback manage transaction processing during a session defined by a Workspace object. You use these methods with a Workspace object when you want to treat a series of changes made to the databases in a session as one unit.

Typically, you use transactions to maintain the integrity of your data when you must both update records in two or more tables and ensure changes are completed (committed) in all tables or none at all (rolled back). For example, if you transfer money from one account to another, you might subtract an amount from one and add the amount to another. If either update fails, the accounts no longer balance. Use the BeginTrans method before updating the first record, and then, if any subsequent update fails, you can use the Rollback method to undo all of the updates. Use the CommitTrans method after you successfully update the last record.

Note Note

Within one Workspace object, transactions are always global to the Workspace and aren't limited to only one Connection or Database object. If you perform operations on more than one connection or database within a Workspace transaction, resolving the transaction (that is, using the CommitTrans or Rollback method) affects all operations on all connections and databases within that workspace.

After you use CommitTrans, you can't undo changes made during that transaction unless the transaction is nested within another transaction that is itself rolled back. If you nest transactions, you must resolve the current transaction before you can resolve a transaction at a higher level of nesting.

If you want to have simultaneous transactions with overlapping, non-nested scopes, you can create additional Workspace objects to contain the concurrent transactions.

If you close a Workspace object without resolving any pending transactions, the transactions are automatically rolled back.

If you use the CommitTrans or Rollback method without first using the BeginTrans method, an error occurs.

Some ISAM databases used in a Microsoft Access workspace may not support transactions, in which case the Transactions property of the Database object or Recordset object is False. To make sure the database supports transactions, check the value of the Transactions property of the Database object before using the BeginTrans method. If you are using a Recordset object based on more than one database, check the Transactions property of the Recordset object. If a Recordset is based entirely on Microsoft Access database engine tables, you can always use transactions. Recordset objects based on tables created by other database products, however, may not support transactions. For example, you can't use transactions in a Recordset based on a Paradox table. In this case, the Transactions property is False. If the Database or Recordset doesn't support transactions, the methods are ignored and no error occurs.

You can't nest transactions if you are accessing ODBC data sources through the Microsoft Access database engine.

In ODBC workspaces, when you use CommitTrans your cursor may no longer be valid. Use the Requery method to view the changes in the Recordset, or close and re-open the Recordset.

  • You can often improve the performance of your application by breaking operations that require disk access into transaction blocks. This buffers your operations and may significantly reduce the number of times a disk is accessed.

  • In a Microsoft Access workspace, transactions are logged in a file kept in the directory specified by the TEMP environment variable on the workstation. If the transaction log file exhausts the available storage on your TEMP drive, the database engine triggers a run-time error. At this point, if you use CommitTrans, an indeterminate number of operations are committed, but the remaining uncompleted operations are lost, and the operation has to be restarted. Using a Rollback method releases the transaction log and rolls back all operations in the transaction.

  • Closing a clone Recordset within a pending transaction will cause an implicit Rollback operation.


CommandButton.PressedTint Property (Access)

 Copy code hover
[image]

CommandButton.PressedTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the PressedColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .PressedTint

expression A variable that represents a CommandButton object.

Remarks

The PressedTint property contains a numeric expression that can be used to lighten the theme color in the PressedColor property. The default value of the PressedTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Application.HyperlinkPart Method (Access)

 Copy code hover
[image]

Application.HyperlinkPart Method (Access)
See also Send feedback

Published: July 16, 2012

The HyperlinkPart method returns information about data stored as a Hyperlink data type. .

Syntax

expression .HyperlinkPart(Hyperlink, Part)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Hyperlink | Required | Variant | The data stored in a Hyperlink field.
Part | Optional | AcHyperlinkPart | A AcHyperlinkPart constant representing the information you want returned by the HyperlinkPart method.

Return Value

String

Remarks

You use the HyperlinkPart method to return one of three values from a Hyperlink field or the displayed value. The value returned depends on the setting of the part argument. The part argument is optional. If it's not used, the function returns the value Microsoft Access displays for the hyperlink (which corresponds to the acDisplayedValue setting for the part argument). The returned values can be one of the four parts of the Hyperlink field (displaytext, address, subaddress, or screentip), the full address, address#subaddress, or the value Microsoft Access displays for the hyperlink.

Note Note

If you use the HyperlinkPart method in a query, the part argument is required and you can't use the constants listed above but must use the actual value instead.

When a value is provided in the displaytext part of a Hyperlink field, the value displayed by Microsoft Access will be the same as the displaytext setting. When there's no value in the displaytext part of a Hyperlink field, the value displayed will be the address or subaddress part of the Hyperlink field, depending on which value is first present in the field.

The following table shows the values returned by the HyperlinkPart method for data stored in a Hyperlink field.

Hyperlink field data | HyperlinkPart method returned values
#http://www.microsoft.com# | acDisplayedValue: http://www.microsoft.com acDisplayText: acAddress: http://www.microsoft.com acSubAddress: acScreenTip: acFullAddress: http://www.microsoft.com
Microsoft#http://www.microsoft.com# | acDisplayedValue: Microsoft acDisplayText: Microsoft acAddress: http://www.microsoft.com acSubAddress: acScreenTip: acFullAddress: http://www.microsoft.com
Customers#http://www.microsoft.com#Form Customers | acDisplayedValue: Customers acDisplayText: Customers acAddress: http://www.microsoft.com acSubAddress: Form Customers acScreenTip: acFullAddress: http://www.microsoft.com#Form Customer
##Form Customers#Enter Information | acDisplayedValue: Form Customers acDisplayText: acAddress: acSubAddress: Form Customers acScreenTip: Enter Information acFullAddress: #FormCustomer

When you add an address part to a Hyperlink field by using the Insert Hyperlink dialog box (available by clicking Hyperlink on the Insert menu) or by typing an address part directly into a Hyperlink field, Microsoft Access adds the two # symbols that delimit parts of the hyperlink data.

You can add or edit the displaytext part of a hyperlink field by right-clicking a hyperlink in a table, form, or report, pointing to Hyperlink on the shortcut menu, and then typing the display text in the Text to display box.

When you add data to a Hyperlink field directly, you must include the two # symbols to delimit the parts of the hyperlink data.

Example

The following example uses all four of the part argument constants to display information returned by the HyperlinkPart method for each record in a table containing a Hyperlink field. To try this example, paste the DisplayHyperlinkParts procedure into the Declarations section of a module. You can call the DisplayHyperlinkParts procedure from the Debug window, passing to it the name of a table containing hyperlinks and the name of the field containing Hyperlink data. For example:

VBA Copy code Copy code
:DisplayHyperlinkParts "MyHyperlinkTableName", "MyHyperlinkFieldName"

Public Sub DisplayHyperlinkParts(ByVal strTable As String, _
 ByVal strField As String)

 Dim rst As New ADODB.Recordset
 Dim strMsg As String

 rst.Open strTable, CurrentProject.Connection, _
 adOpenForwardOnly, adLockReadOnly

 ' For each record in table.
 Do Until rst.EOF
 strMsg = "DisplayValue = " _
 & HyperlinkPart(rst(strField), acDisplayedValue) _
 & vbCrLf & "DisplayText = " _
 & HyperlinkPart(rst(strField), acDisplayText) _
 & vbCrLf & "Address = " _
 & HyperlinkPart(rst(strField), acAddress) _
 & vbCrLf & "SubAddress = " _
 & HyperlinkPart(rst(strField), acSubAddress) _
 & vbCrLf & "ScreenTip = " _
 & HyperlinkPart(rst(strField), acScreenTip) _
 & vbCrLf & "Full Address = " _
 & HyperlinkPart(rst(strField), acFullAddress)

 ' Show parts returned by HyperlinkPart function.
 MsgBox strMsg
 rst.MoveNext
 Loop

End Sub

When you use the HyperlinkPart method in a query, the part argument is required. For example, the following SQL statement uses the HyperlinkPart method to return information about data stored as a Hyperlink data type in the URL field of the Links table:

VBA Copy code Copy code
SELECT Links.URL, HyperlinkPart([URL],0)
 AS Display, HyperlinkPart([URL],1)
 AS Name, HyperlinkPart([URL],2)
 AS Addr, HyperlinkPart([URL],3)
 AS SubAddr, HyperlinkPart([URL],4)
 AS ScreenTip
 FROM Links

See also

Concepts

Application Object

Other resources

Application Object Members


ListBox.LabelX Property (Access)

 Copy code hover
[image]

ListBox.LabelX Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelX

expression A variable that represents a ListBox object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Open Method (ADO MD)

 Copy code hover
[image]

Open Method (ADO MD)
Send feedback

Retrieves the results of a multidimensional query and returns the results to a cellset.

Syntax

Cellset.Open Source, ActiveConnection

Parameters

  • Source

  • Optional. A Variant that evaluates to a valid multidimensional query, such as a Multidimensional Expression (MDX) query. The Source argument corresponds to the Source property. For more information about MDX, see the OLE DB for OLAP documentation in the Microsoft Data Access Components SDK.

  • ActiveConnection

  • Optional. A Variant that evaluates to a string specifying either a valid ADO Connection object variable name or a definition for a connection. The ActiveConnection argument specifies the connection in which to open the Cellset object. If you pass a connection definition for this argument, ADO opens a new connection using the specified parameters. The ActiveConnection argument corresponds to the ActiveConnection property.

Remarks

The Open method generates an error if either of its parameters is omitted and its corresponding property value has not been set prior to attempting to open the Cellset.


StreamReadEnum

 Copy code hover
[image]

StreamReadEnum
Send feedback

Specifies whether the whole stream or the next line should be read from a Stream object.

Constant | Value | Description
adReadAll | -1 | Default. Reads all bytes from the stream, from the current position onwards to the EOS marker. This is the only valid StreamReadEnum value with binary streams (Type is adTypeBinary).
adReadLine | -2 | Reads the next line from the stream (designated by the LineSeparator property).

ADO/WFC Equivalent

These constants do not have ADO/WFC equivalents.


Specifying Threads Per Processor on IIS

 Copy code hover
[image]

Specifying Threads Per Processor on IIS
Send feedback

When using RDS with Internet Information Services 4.0 or later, the number of threads created per processor can be controlled by manipulating the registry on the Web server. The number of threads per processor can affect performance in a high traffic situation, or in low traffic situations with large query sizes. The user should experiment for best results.

The method used to determine and change the default value for this setting depends upon the configuration of the IIS 4.0 server.

With MDAC 2.1.2.4202.3 (GA) or later installed on the IIS server, RDS uses the same Component Services (or Microsoft Transaction Services, if you are using Windows NT) thread pool as ASP scripts use. The default value for the number of threads per processor is 10. To change the default, you must add the following key to the server registry:

Copy code Copy code

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\InetInfo\Parameters\MaxPoolThreads

where MaxPoolThreads is a REG_DWORD. MaxPoolThreads does not appear in the Registry unless it is specifically added. Valid values range from 5 to a recommended maximum of 20. If the value specified by the registry key is greater than the value of the PoolThreadLimit key (located under the same path), then PoolThreadLimit value is used.

Alternatively, if MDAC 2.1 2.1.1.3711.11 (GA) or earlier is installed on the IIS server, the default value for the number of threads per processor is 6. To change the default, you must add the following key to the registry on the IIS server:

Copy code Copy code

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\ADCThreads

where ADCThreads is a REG_DWORD. ADCThreads does not appear in the Registry unless it is specifically added. The range of valid values is 1 to 50. If the value specified by the registry key is greater than 50, then the maximum value is used (50).


Entity.Operations Property (Access)

 Copy code hover
[image]

Entity.Operations Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the collection of operations defined for the specified Entity. Read-only Operations.

Version Information

Version Added: Access 2010

Syntax

expression .Operations

expression A variable that represents an Entity object.

See also

Concepts

Entity Object

Other resources

Entity Object Members


ComboBox.AfterUpdate Property (Access)

 Copy code hover
[image]

ComboBox.AfterUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.

Syntax

expression .AfterUpdate

expression A variable that represents a ComboBox object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the AfterUpdate event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the AfterUpdate event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).AfterUpdate = "[Event Procedure]"

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ADO MD Objects

 Copy code hover
[image]

ADO MD Objects
Send feedback
Axis | Represents a positional or filter axis of a cellset, containing selected members of one or more dimensions.
Catalog | Contains multidimensional schema information (that is, cubes and underlying dimensions, hierarchies, levels, and members) specific to a multidimensional data provider (MDP).
Cell | Represents the data at the intersection of axis coordinates, contained in a cellset.
Cellset | Represents the results of a multidimensional query. It is a collection of cells selected from cubes or other cellsets.
CubeDef | Represents a cube from a multidimensional schema, containing a set of related dimensions.
Dimension | Represents one of the dimensions of a multidimensional cube, containing one or more hierarchies of members.
Hierarchy | Represents one way in which the members of a dimension can be aggregated or "rolled up." A dimension can be aggregated along one or more hierarchies.
Level | Contains a set of members, each of which has the same rank within a hierarchy.
Member | Represents a member of a level in a cube, the children of a member of a level, or a member of a position along an axis of a cellset.
Position | Represents a set of one or more members of different dimensions that defines a point along an axis.

Also, the Catalog object is connected to an ADO Connection object, which is included with the standard ADO library:

Object | Description
Connection | Represents an open connection to a data source.

Many ADO MD objects can be contained in a corresponding collection. For example, a CubeDef object can be contained in a CubeDefs collection of a Catalog. For more information, see ADO MD Collections.


ComboBox.Dirty Event (Access)

 Copy code hover
[image]

ComboBox.Dirty Event (Access)
See also Send feedback

Published: July 16, 2012

The Dirty event occurs when the contents of the specified control changes.

Syntax

expression .Dirty(Cancel, )

expression A variable that represents a ComboBox object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the Dirty event occurs. Setting the Cancel argument to True (-1) cancels the Dirty event.

Remarks

Examples of this event include entering a character directly in the text box or combo box or changing the control's Text property setting by using a macro or Visual Basic.

  • Modifying a record within a form by using a macro or Visual Basic doesn't trigger this event. You must type the data directly into the record or set the control's Text property.

  • This event applies only to bound forms, not an unbound form or report.

To run a macro or event procedure when this event occurs, set the OnDirty property to the name of the macro or to [Event Procedure].

By running a macro or event procedure when a Dirty event occurs, you can determine if the record can be changed. You can also display a message and ask for edit permission.

Changing the data in a record by using the keyboard causes keyboard events to occur in addition to control events like the Dirty event. For example, if you move to a new record and type an ANSI character in a text box in the record, the following events occur in this order:

KeyDown > KeyPress > BeforeInsert > Dirty > KeyUp

The BeforeUpdate and AfterUpdate events for a record occur after you have entered the new or changed data in the record and moved to another record (or clicked Save Record on the Records menu), and therefore after the Dirty event for the record.

Canceling the Dirty event will cause the changes to the current record to be rolled back. It is equivalent to pressing the ESC key.

Example

The following example enables the btnUndo button when data is changed. The UndoEdits( ) subroutine is called from the Dirty event of text box controls. Clicking the enabled btnUndo button restores the original value of the control by using the OldValue property.

VBA Copy code Copy code
Private Sub Form_Dirty()
 If Me.Dirty Then
 Me!btnUndo.Enabled = True ' Enable button.
 Else
 Me!btnUndo.Enabled = False ' Disable button.
 End If
End Sub

Sub btnUndo_Click()
 Dim ctlC As Control
 ' For each control.
 For Each ctlC in Me.Controls
 If ctlC.ControlType = acTextBox Then
 ' Restore Old Value.
 ctlC.Value = ctlC.OldValue
 End If
 Next ctlC
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Attachment.Visible Property (Access)

 Copy code hover
[image]

Attachment.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents an Attachment object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


ListBox.Controls Property (Access)

 Copy code hover
[image]

ListBox.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Syntax

expression .Controls

expression A variable that represents a ListBox object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


The SQL statement could not be executed because it contains ambiguous outer joins. To force one of the joins to be performed first, create a separate query that performs the first join and then include that query in your SQL statement. (Error 3258)

 Copy code hover
[image]

The SQL statement could not be executed because it contains ambiguous outer joins. To force one of the joins to be performed first, create a separate query that performs the first join and then include that query in your SQL statement. (Error 3258)
Send feedback

You tried to execute an SQL statement that contains multiple joins; the results of the query can differ depending on the order in which the joins are performed. For example, this error can occur if you execute the following SQL statement:

SQL Copy code Copy code
SELECT * FROM Customers, Orders, [Order Details],
Customers LEFT JOIN Orders
ON Customers.CustomerID = Orders.CustomerID,
Orders INNER JOIN [Order Details]
ON Orders.OrderID = [Order Details].OrderID;

Executing this statement produces an error because the order of the joins is ambiguous. To force one of the joins to be performed first, create a separate query that performs the first join and then include that query in your SQL statement. The following queries illustrate how you might construct the preceding query so that the INNER JOIN operation is performed before the LEFT JOIN and RIGHT JOIN operation:

Query1

SQL Copy code Copy code
SELECT * FROM Orders, [Order Details],
Orders INNER JOIN [Order Details]
ON Orders. OrderID = [Order Details].OrderID;

Query2

SQL Copy code Copy code
SELECT * FROM Customers, Query1,
Customers LEFT JOIN Query1
ON Customers.CustomerID = Orders.CustomerID;


Server Property (RDS)

 Copy code hover
[image]

Server Property (RDS)
Send feedback

Indicates the Internet Information Services (IIS) name and communication protocol.

You can set the Server property at design time in the RDS.DataControl object's OBJECT tags, or at run time in scripting code.

Syntax

Protocol

Design-time syntax

HTTP
Copy code Copy code
<PARAM NAME="Server" VALUE="http://awebsrvr:port">

HTTPS
Copy code Copy code
<PARAM NAME="Server" VALUE="https://awebsrvr:port">

DCOM
Copy code Copy code
<PARAM NAME="Server" VALUE="computername">

In-process
Copy code Copy code
<PARAM NAME="Server" VALUE="">

Protocol

Run-time syntax

HTTP
Copy code Copy code
DataControl.Server="http://awebsrvr:port"

HTTPS
Copy code Copy code
DataControl.Server="https://awebsrvr:port"

DCOM
Copy code Copy code
DataControl.Server="computername"

In-process
Copy code Copy code
DataControl.Server=""

Parameters

  • awebsrvr or computername

  • A String value that contains an Internet or intranet path, or computer name, if the server is on a remote computer; or, an empty string if the server is on the local computer.

  • port

  • Optional. A port that is used to connect to an IIS server. The port number is set in Internet Explorer (on the Tools menu, click Internet Options, and then select the Connection tab) or in IIS.

  • DataControl

  • An object variable that represents an RDS.DataControl object.

Remarks

The server is the location where the RDS.DataControl request (that is, a query or update) is processed. By default, all requests are processed by the RDSServer.DataFactory object, MSDFMAP.Handler component, and MSDFMAP.INI file on the specified server. Remember that when changing servers to reconcile settings in the old and new MSDFMAP.INI files. Incompatibilities may cause requests that succeed on one server to fail on another. If the Server property is set to "", these objects will be used on the local machine.


No field defined -- cannot append TableDef or Index. (Error 3264)

 Copy code hover
[image]

No field defined -- cannot append TableDef or Index. (Error 3264)
Send feedback

You cannot append a TableDef until you define one or more fields. Use the CreateField method to create fields, append them to the Fields collection of your TableDef object, and then append the TableDef object to the TableDefs collection.


Form.ServerFilter Property (Access)

 Copy code hover
[image]

Form.ServerFilter Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ServerFilter property to specify a subset of records to be displayed when a server filter is applied to a form within a Microsoft Access project (.adp) or database. Read/write String.

Syntax

expression .ServerFilter

expression A variable that represents a Form object.

Remarks

The ServerFilter property is a string expression consisting of a WHERE clause without the WHERE keyword. For example, the following Visual Basic code defines and applies a filter to show only customers from the USA:

VBA Copy code Copy code
Me.ServerFilter = "Country = 'USA'"
Me.Refresh

To set the ServerFilter property, you must first either:

  • Set the property value in the form's property sheet.

  • Set the property in Visual Basic by typing

    Copy code Copy code
    Forms(0).ServerFilter = "fieldname = value"

Note Note

Setting the ServerFilter property has no effect on the ADO Filter property.

You can use the ServerFilter property to save a filter and apply it at a later time. Filters are saved with the objects in which they are created. They are automatically loaded when the object is opened, but they aren't automatically applied.

To apply a saved filter to a form, you can click Apply Server Filter on the toolbar, click Apply Filter/Sort on the Records menu, or use a macro or Visual Basic to set the ServerFilterByForm property to True.

The Apply Server Filter button indicates the state of the ServerFilter and ServerFilterByForm properties. The button remains disabled until there is a filter to apply. If an existing filter is currently applied, the Apply Server Filter button appears pressed in.

To apply a filter automatically when a form is opened, specify in the OnOpen event property setting of the form either a macro that uses the ApplyFilter action or an event procedure that uses the ApplyFilter method of the DoCmd object. In either case, the form opens in the Server Filter By Form window.

You can only remove a server filter by using Visual Basic to set the ServerFilterByForm property to False or clear all filter criteria in the Server Filter By Form window and then click Apply Server Filter.

When the ServerFilter property is set in form Design view, Microsoft Access does not attempt to validate the SQL expression. If the SQL expression is invalid, an error occurs when the filter is applied.

Note Note

  • When a new object is created, it inherits the RecordSource, Filter, ServerFilter, OrderBy, and OrderByOn properties of the table or query it was created from.

  • The ServerFilter property setting is ignored if the form's record source is a stored procedure.

See also

Concepts

Form Object

Other resources

Form Object Members


ListBox.Layout Property (Access)

 Copy code hover
[image]

ListBox.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified list box. Read-only AcLayoutType.

Version Information

Version Added: Access 2007

Syntax

expression .Layout

expression A variable that represents a ListBox object.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Clone Method Example (VC++)

 Copy code hover
[image]

Clone Method Example (VC++)
Send feedback

This example uses the Clone method to create copies of a Recordset and then lets the user position the record pointer of each copy independently.

Copy code Copy code

// BeginCloneCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <stdio.h>
#include <ole2.h>
#include <conio.h>
#include "CloneX.h"

// Function Declarations.
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void CloneX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);
inline char* mygets(char* strDest, int n)
{
 char strExBuff[10];
 char* pstrRet = fgets(strDest, n, stdin);

 if (pstrRet == NULL)
 return NULL;

 if (!strrchr(strDest, '\n'))
 // Exhaust the input buffer.
 do
 {
 fgets(strExBuff, sizeof(strExBuff), stdin);
 }while (!strrchr(strExBuff, '\n'));
 else
 // Replace '\n' with '\0'
 strDest[strrchr(strDest, '\n') - strDest] = '\0';

 return pstrRet;
}

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 CloneX();

 //Wait here for user to see the output..
 printf("\nPress any key to continue...");
 getch();
 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// CloneX Function //
// //
///////////////////////////////////////////////////////////

void CloneX()
{
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr arstStores[3];

 //Define Other Variables
 HRESULT hr = S_OK;
 int intLoop = 0;
 _bstr_t strSQL;
 _bstr_t strMessage;
 _bstr_t strFind;
 int intLoop1 = 0;
 char *tempStr;
 bool boolFlag = TRUE;
 char m_szS_stor_name[150];

 // Assign SQL statement and connection string to variables.
 strSQL = "SELECT stor_name FROM Stores ORDER BY stor_name";

 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 // Open recordset as a static cursor type recordset.
 arstStores[0].CreateInstance(__uuidof(Recordset));
 arstStores[0]->CursorType = adOpenStatic;
 arstStores[0]->LockType = adLockBatchOptimistic;

 TESTHR(arstStores[0]->Open(strSQL,strCnn, adOpenStatic,
 adLockBatchOptimistic,adCmdText));

 // Create two clones of the original Recordset.
 arstStores[1] = arstStores[0]->Clone(adLockUnspecified);
 arstStores[2] = arstStores[0]->Clone(adLockUnspecified);

 while (boolFlag)
 {
 // Loop through the array so that on each pass,
 // the user is searching a different copy of the
 // same Recordset.
 for (intLoop = 1; intLoop <= 3 ; intLoop++)
 {
 // Ask for search string while showing where
 // the current record pointer is for each Recordset.
 printf("Recordsets from stores table:\n");

 _bstr_t str1 = arstStores[0]->Fields->
 GetItem("stor_name")->Value;
 printf("\t1 - Original - Record pointer at %s",
 (LPCSTR)str1);

 _bstr_t str2 = arstStores[1]->Fields->
 GetItem("stor_name")->Value;
 printf("\n\t2 - Clone - Record pointer at %s",
 (LPCSTR)str2);

 _bstr_t str3 = arstStores[2]->Fields->
 GetItem("stor_name")->Value;
 printf("\n\t3 - Clone - Record pointer at %s",
 (LPCSTR)str3);

 printf("\n\nEnter search string for # %d, "
 "or press Enter to quit.\n", intLoop);
 mygets(m_szS_stor_name, 150);

 // Trim the String.
 tempStr = strtok(m_szS_stor_name, " \t");
 strMessage = tempStr;
 if (tempStr == NULL)
 {
 boolFlag = FALSE;
 break;
 }

 // Find the search string; if there's no
 // match, jump to the last record.
 intLoop1 = intLoop - 1;

 arstStores[intLoop1]->Filter = "stor_name >= '" +
 strMessage + "'";

 if (arstStores[intLoop1]->EndOfFile)
 {
 arstStores[intLoop1]->Filter = (long)adFilterNone;
 arstStores[intLoop1]->MoveLast();
 }
 }
 } // End of While Loop
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _variant_t vtConnect;

 vtConnect = arstStores[0]->GetActiveConnection();

 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 if (arstStores[0])
 if (arstStores[0]->State == adStateOpen)
 arstStores[0]->Close();
 if (arstStores[1])
 if (arstStores[1]->State == adStateOpen)
 arstStores[1]->Close();
 if (arstStores[2])
 if (arstStores[2]->State == adStateOpen)
 arstStores[2]->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
};

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
};
// EndCloneCpp

CloneX.h

Copy code Copy code

// BeginCloneH
#include "icrsint.h"

// This Class extracts only store name
// from "stores" table.
class CStores : public CADORecordBinding
{
BEGIN_ADO_BINDING(CStores)

 //Column stor_name is the 1st field in the recordset

 ADO_VARIABLE_LENGTH_ENTRY2(1, adVarChar, m_szS_stor_name,
 sizeof(m_szS_stor_name), lS_stor_nameStatus, FALSE)

END_ADO_BINDING()

public:
 CHAR m_szS_stor_name[150];
 ULONG lS_stor_nameStatus;
};

// EndCloneH


TextBox.ColumnWidth Property (Access)

 Copy code hover
[image]

TextBox.ColumnWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.

Syntax

expression .ColumnWidth

expression A variable that represents a TextBox object.

Remarks

In Visual Basic , the ColumnWidth property setting is an Integer value that represents the column width in twips. You can specify a width or use one of the following predefined settings.

Setting | Description
0 | Hides the column.
-1 | (Default) Sizes the column to the default width.
Note Note

The ColumnWidth property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

Setting this property to 0, or resizing the field to a zero width in Datasheet view, sets the field's ColumnHidden property to True (-1) and hides the field in Datasheet view.

Setting a field's ColumnHidden property to False (0) restores the field's ColumnWidth property to the value it had before the field was hidden. For example, if the ColumnWidth property was -1 prior to the field being hidden by setting the property to 0, changing the field's ColumnHidden property to False resets the ColumnWidth to -1.

The ColumnWidth property for a field isn't available when the field's ColumnHidden property is set to True.

Example

This example takes effect in Datasheet view of the open Customers form. It sets the row height to 450 twips and sizes the column to fit the size of the visible text.

VBA Copy code Copy code
Forms![Customers].RowHeight = 450
Forms![Customers]![Address].ColumnWidth = -2

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


IsolationLevel Property (ADO)

 Copy code hover
[image]

IsolationLevel Property (ADO)
Send feedback

Indicates the level of isolation for a Connection object.

Settings and Return Values

Sets or returns an IsolationLevelEnum value. The default is adXactChaos.

Remarks

Use the IsolationLevel property to set the isolation level of a Connection object. The setting does not take effect until the next time you call the BeginTrans method. If the level of isolation you request is unavailable, the provider may return the next greater level of isolation.

The IsolationLevel property is read/write.

Remote Data Service UsageWhen used on a client-side Connection object, the IsolationLevel property can be set only to adXactUnspecified.

Because users are working with disconnected Recordset objects on a client-side cache, there may be multiuser issues. For instance, when two different users try to update the same record, Remote Data Service simply allows the user who updates the record first to "win." The second user's update request will fail with an error.


References.ItemRemoved Event (Access)

 Copy code hover
[image]

References.ItemRemoved Event (Access)
See also Send feedback

Published: July 16, 2012

The ItemRemoved event occurs when a reference is removed from the project.

Syntax

expression .ItemRemoved(Reference, )

expression A variable that represents a References object.

Parameters

Name | Required/Optional | Data Type | Description
Reference | Required | Reference | The reference that was removed from the project.

Remarks

  • The ItemRemoved event applies to the References collection. It isn't associated with a control, form, or report, as are most other events. Therefore, in order to create a procedure definition for the ItemRemoved event procedure, you must use a special syntax.

  • The ItemRemoved event can run only an event procedure when it occurs, it cannot run a macro.

This event occurs only when you remove a reference from code. It doesn't occur when you remove a reference from the References dialog box, available by clicking References on the Tools menu when the Module window is the active window.

Example

The following example includes event procedures for the ItemAdded and ItemRemoved events. To try this example, first create a new class module by clicking Class Module on the Insert menu. Paste the following code into the class module and save the module as RefEvents:

VBA Copy code Copy code
' Declare object variable to represent References collection.
Public WithEvents evtReferences As References

' When instance of class is created, initialize evtReferences
' variable.
Private Sub Class_Initialize()
 Set evtReferences = Application.References
End Sub

' When instance is removed, set evtReferences to Nothing.
Private Sub Class_Terminate()
 Set evtReferences = Nothing
End Sub

' Display message when reference is added.
Private Sub evtReferences_ItemAdded(ByVal Reference As _
 Access.Reference)
 MsgBox "Reference to " & Reference.Name & " added."
End Sub

' Display message when reference is removed.
Private Sub evtReferences_ItemRemoved(ByVal Reference As _
 Access.Reference)
 MsgBox "Reference to " & Reference.Name & " removed."
End Sub

The next Function procedure removes a specified reference. When a reference is removed, the ItemRemoved event procedure defined in the RefEvents class runs.

For example, to remove a reference to the calendar control, you could pass the string "MSACAL", which is the name of the Reference object that represents the calendar control.

VBA Copy code Copy code
Function RemoveReference(strRefName As String) As Boolean
 Dim ref As Reference

 On Error GoTo Error_RemoveReference
 ' Return object representing existing reference.
 Set ref = objRefEvents.evtReferences(strRefName)
 ' Remove reference from collection.
 objRefEvents.evtReferences.Remove ref
 RemoveReference = True

Exit_RemoveReference:
 Exit Function

Error_RemoveReference:
 MsgBox Err & ": " & Err.Description
 RemoveReference = False
 Resume Exit_RemoveReference
End Function

See also

Concepts

References Collection

Other resources

References Object Members


An asynchronous OpenConnection call is not yet complete. (Error 3664)

 Copy code hover
[image]

An asynchronous OpenConnection call is not yet complete. (Error 3664)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for more information.


AllQueries.Count Property (Access)

 Copy code hover
[image]

AllQueries.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents an AllQueries object.

See also

Concepts

AllQueries Collection

Other resources

AllQueries Object Members


Cannot open this Paradox 4.x or 5.x table because ParadoxNetStyle is set to 3.x in the Windows Registry. (Error 3419)

 Copy code hover
[image]

Cannot open this Paradox 4.x or 5.x table because ParadoxNetStyle is set to 3.x in the Windows Registry. (Error 3419)
Send feedback

The Microsoft Access database engine was unable to open an external Paradox table because of inconsistencies between the version of the table and your ParadoxNetStyle setting in the Microsoft Windows Registry.

To correct the problem

  1. Exit your application.

  2. Start the Registry Editor, navigate to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Access Connectivity Engine\Engines\Paradox key, and select the ParadoxNetStyle value.

  3. On the Edit menu, click Modify.

  4. Specify the value 4.x in the Value data box.

  5. The ParadoxNetStyle setting must be consistent for all users sharing a database.

  6. Restart your application.

  7. Try opening the table again.


OptionGroup.ControlTipText Property (Access)

 Copy code hover
[image]

OptionGroup.ControlTipText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.

Syntax

expression .ControlTipText

expression A variable that represents an OptionGroup object.

Remarks

You set the ControlTipText property by using a string expression up to 255 characters long.

For controls on forms, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

You can set the ControlTipText property in any view.

The ControlTipText property provides an easy way to provide helpful information about controls on a form.

There are other ways to provide information about a form or a control on a form. You can use the StatusBarText property to display information in the status bar about a control. To provide more extensive help for a form or control, use the HelpFile and HelpContextID properties.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Form.Move Method (Access)

 Copy code hover
[image]

Form.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

If a form is modal, it is still positioned relative to the Access window, but the values for Left and Top can be negative.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

Example

The following example determines whether or not the first form in the current project can be moved; if it can, the example moves the form.

VBA Copy code Copy code
If Forms(0).Moveable Then
 Forms(0).Move _
 Left:=0, Top:=0, Width:=400, Height:=300
Else
 MsgBox "The form cannot be moved."
End If

See also

Concepts

Form Object

Other resources

Form Object Members


SharedResource Methods (Access)

 Copy code hover
[image]

SharedResource Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Delete | Deletes the specified object.


Image.Visible Property (Access)

 Copy code hover
[image]

Image.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents an Image object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

Image Object

Other resources

Image Object Members


Page.Picture Property (Access)

 Copy code hover
[image]

Page.Picture Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Picture property to specify a bitmap or other type of graphic to be displayed on the specified control. Read/write String.

Syntax

expression .Picture

expression A variable that represents a Page object.

Remarks

The Picture property contains (bitmap) or the path and file name of a bitmap or other type of graphic to be displayed.

The default setting is (none). After the graphic is loaded into the object, the property setting is (bitmap) or the path and file name of the graphic. If you delete (bitmap) or the path and file name of the graphic from the property setting, the picture is deleted from the object and the property setting is again (none).

If the PictureType property is set to Embedded, the graphic is stored with the object.

You can create custom bitmaps by using Microsoft Paintbrush or another application that creates bitmap files. A bitmap file must have a .bmp, .ico, or .dib extension. You can also use graphics files in the .wmf or .emf formats, or any other graphic file type for which you have a graphics filter. Forms, reports, and image controls support all graphics. Command buttons and toggle buttons only support bitmaps.

See also

Concepts

Page Object

Other resources

Page Object Members


Deleting Records Using the Delete Method

 Copy code hover
[image]

Deleting Records Using the Delete Method
Send feedback

Using the Delete method marks the current record or a group of records in a Recordset object for deletion. If the Recordset object does not allow record deletion, an error occurs. If you are in immediate update mode, deletions occur in the database immediately. If a record cannot be successfully deleted (due to database integrity violations, for example), the record will remain in edit mode after the call to Update. This means that you must cancel the update using CancelUpdate before moving off the current record (for example, using Close, Move, or NextRecordset).

If you are in batch update mode, the records are marked for deletion from the cache and the actual deletion happens when you call the UpdateBatch method. (To view the deleted records, set the Filter property to adFilterAffectedRecords after Delete is called.)

Attempting to retrieve field values from the deleted record generates an error. After deleting the current record, the deleted record remains current until you move to a different record. Once you move away from the deleted record, it is no longer accessible.

If you nest deletions in a transaction, you can recover deleted records by using the RollbackTrans method. If you are in batch update mode, you can cancel a pending deletion or group of pending deletions by using the CancelBatch method.

If the attempt to delete records fails because of a conflict with the underlying data (for example, a record has already been deleted by another user), the provider returns warnings to the Errors collection but does not halt program execution. A run-time error occurs only if there are conflicts on all the requested records.

If the Unique Table dynamic property is set and the Recordset is the result of executing a JOIN operation on multiple tables, the Delete method will delete rows only from the table named in the Unique Table property.

The Delete method takes an optional argument that allows you to specify which records are affected by the Delete operation. The only valid values for this argument are either of the following ADO AffectEnum enumerated constants:

  • adAffectCurrentAffects only the current record.

  • adAffectGroupAffects only records that satisfy the current Filter property setting. The Filter property must be set to a FilterGroupEnum value or an array of Bookmarks to use this option.

The following code shows an example of specifying adAffectGroup when calling the Delete method. This example adds some records to the sample Recordset and updates the database. Then it filters the Recordset using the adFilterAffectedRecords filter enumerated constant, which leaves only the newly added records visible in the Recordset. Finally, it calls the Delete method and specifies that all of the records that satisfy the current Filter property setting (the new records) should be deleted.

Copy code Copy code

'BeginDeleteGroup
 'add some bogus records
 With objRs1
 For i = 0 To 8
 .AddNew
 .Fields("CompanyName") = "Shipper Number " & i + 1
 .Fields("Phone") = "(425) 555-000" & (i + 1)
 .Update
 Next i

 're-connect & update
 .ActiveConnection = GetNewConnection
 .UpdateBatch

 'filter on newly added records
 .Filter = adFilterAffectedRecords
 Debug.Print "Deleting the " & .RecordCount & _
 " records you just added."

 'delete the newly added bogus records
 .Delete adAffectGroup
 .Filter = adFilterNone
 Debug.Print .RecordCount & " records remain."

 .Close
 End With
'EndDeleteGroup


Chapter 7: Handling ADO Events

 Copy code hover
[image]

Chapter 7: Handling ADO Events
Send feedback

The ADO event model supports certain synchronous and asynchronous ADO operations that issue events, or notifications, before the operation starts or after it completes. An event is actually a call to an event-handler routine that you define in your application.

If you provide handler functions or procedures for the group of events that occur before the operation starts, you can examine or modify the parameters that were passed to the operation. Because it has not been executed yet, you can either cancel the operation or allow it to complete.

The group of events that occur after an operation completes are especially important if you use ADO asynchronously. For example, an application that starts an asynchronous Recordset.Open operation is notified by an execution complete event when the operation concludes.

Using the ADO event model adds some overhead to your application but provides far more flexibility than other methods of dealing with asynchronous operations, such as monitoring the State property of an object with a loop.


TabControl.OldValue Property (Access)

 Copy code hover
[image]

TabControl.OldValue Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.

Syntax

expression .OldValue

expression A variable that represents a TabControl object.

Remarks

The OldValue property contains the unedited data from a bound control and is read-only in all views.

Microsoft Access uses the OldValue property to store the original value of a bound control. When you edit a bound control on a form, your changes aren't saved until you move to another record. The OldValue property contains the unedited version of the underlying data.

You can provide your own undo capability by assigning the OldValue property setting to a control. The following example shows how you can undo any changes to text box controls on a form:

VBA Copy code Copy code
Private Sub btnUndo_Click()

 Dim ctlTextbox As Control

 For Each ctlTextbox in Me.Controls
 If ctlTextbox.ControlType = acTextBox Then
 ctlTextbox.Value = ctl.OldValue
 End If
 Next ctlTextbox

End Sub

If the control hasn't been edited, this code has no effect. When you move to another record, the record source is updated, so the current value and the OldValue property will be the same.

The OldValue property setting has the same data type as the field to which the control is bound.

Example

The following example checks to determine if new data entered in a field is within 10 percent of the value of the original data. If the change is greater than 10 percent, the OldValue property is used to restore the original value. This procedure could be called from the BeforeUpdate event of the control that contains data you want to validate.

VBA Copy code Copy code
Public Sub Validate_Field()

 Dim curNewValue As Currency
 Dim curOriginalValue As Currency
 Dim curChange As Currency
 Dim strMsg As String

 curNewValue = Forms!Products!UnitPrice
 curOriginalValue = Forms!Products!UnitPrice.OldValue
 curChange = Abs(curNewValue - curOriginalValue)

 If curChange > (curOriginalValue * .1) Then
 strMsg = "Change is more than 10% of original unit price. " _
 & "Restoring original unit price."
 MsgBox strMsg, vbExclamation, "Invalid change."
 Forms!Products!UnitPrice = curOriginalValue
 End If

End Sub

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


References.AddFromFile Method (Access)

 Copy code hover
[image]

References.AddFromFile Method (Access)
See also Send feedback

Published: July 16, 2012

The AddFromFile method creates a reference to a type library in a specified file. .

Syntax

expression .AddFromFile(FileName)

expression A variable that represents a References object.

Parameters

Name | Required/Optional | Data Type | Description
FileName | Required | String | A string expression that evaluates to the full path and file name of the file containing the type library to which you wish to set a reference.

Return Value

Reference

See also

Concepts

References Collection

Other resources

References Object Members


How to: Define Relationships Between Tables Using Access SQL

 Copy code hover
[image]

How to: Define Relationships Between Tables Using Access SQL
Send feedback

Relationships are the established associations between two or more tables. Relationships are based on common fields from more than one table, often involving primary and foreign keys.

A primary key is the field (or fields) that is used to uniquely identify each record in a table. There are three requirements for a primary key: It cannot be null, it must be unique, and there can be only one defined per table. You can define a primary key either by creating a primary key index after the table is created, or by using the CONSTRAINT clause in the table declaration, as shown in the examples later in this section. A constraint limits (or constrains) the values that are entered in a field.

A foreign key is a field (or fields) in one table that references the primary key in another table. The data in the fields from both tables is exactly the same, and the table with the primary key record (the primary table) must have existing records before the table with the foreign key record (the foreign table) has the matching or related records. Like primary keys, you can define foreign keys in the table declaration by using the CONSTRAINT clause.

There are essentially three types of relationships:

  • One-to-one For every record in the primary table, there is one and only one record in the foreign table.

  • One-to-many For every record in the primary table, there are one or more related records in the foreign table.

  • Many-to-many For every record in the primary table, there are many related records in the foreign table, and for every record in the foreign table, there are many related records in the primary table.

For example, suppose you want to add an invoices table to an invoicing database. Every customer in your customers table can have many invoices in the invoices table—this is a classic one-to-many scenario. You can take the primary key from the customers table and define it as the foreign key in the invoices table, thereby establishing the proper relationship between the tables.

When defining the relationships between tables, you must make the CONSTRAINT declarations at the field level. This means that the constraints are defined within a CREATE TABLE statement. To apply the constraints, use the CONSTRAINT keyword after a field declaration, name the constraint, name the table that it references, and name the field or fields within that table that will make up the matching foreign key.

The following statement assumes that the tblCustomers table has already been built, and that it has a primary key defined on the CustomerID field. The statement now builds the tblInvoices table, defining its primary key on the InvoiceID field. It also builds the one-to-many relationship between the tblCustomers and tblInvoices tables by defining another CustomerID field in the tblInvoices table. This field is defined as a foreign key that references the CustomerID field in the customers table. Note that the name of each constraint follows the CONSTRAINT keyword.

VBA Copy code Copy code
CREATE TABLE tblInvoices
    (InvoiceID INTEGER CONSTRAINT PK_InvoiceID PRIMARY KEY,
    CustomerID INTEGER NOT NULL CONSTRAINT FK_CustomerID
        REFERENCES tblCustomers (CustomerID),
    InvoiceDate DATETIME,
    Amount CURRENCY)

Note that the primary key index (PK_InvoiceID) for the invoices table is declared within the CREATE TABLE statement. To enhance the performance of the primary key, an index is automatically created for it, so there is no need to use a separate CREATE INDEX statement.

Now create a shipping table that will contain each customer's shipping address. Assume that there will be only one shipping record for each customer record, so you will be establishing a one-to-one relationship.

VBA Copy code Copy code
CREATE TABLE tblShipping
    (CustomerID INTEGER CONSTRAINT PK_CustomerID PRIMARY KEY
        REFERENCES tblCustomers (CustomerID),
    Address TEXT(50),
    City TEXT(50),
    State TEXT(2),
    Zip TEXT(10))

Note that the CustomerID field is both the primary key for the shipping table and the foreign key reference to the customers table.

Constraints

Constraints can be used to establish primary keys and referential integrity, and to restrict values that can be inserted into a field. In general, constraints can be used to preserve the integrity and consistency of the data in your database.

There are two types of constraints: a single-field or field-level constraint, and a multi-field or table-level constraint. Both kinds of constraints can be used in either the CREATE TABLE or the ALTER TABLE statement.

A single-field constraint, also known as a column-level constraint, is declared with the field itself, after the field and data type have been declared. Use the customers table and create a single-field primary key on the CustomerID field. To add the constraint, use the CONSTRAINT keyword with the name of the field.

VBA Copy code Copy code
ALTER TABLE tblCustomers
   ALTER COLUMN CustomerID INTEGER
   CONSTRAINT PK_tblCustomers PRIMARY KEY

Notice that the name of the constraint is given. You could use a shortcut for declaring the primary key that omits the CONSTRAINT clause entirely.

VBA Copy code Copy code
ALTER TABLE tblCustomers
   ALTER COLUMN CustomerID INTEGER PRIMARY KEY

However, using the shortcut method will cause Access to randomly generate a name for the constraint, which will make it difficult to reference in code. It is a good idea always to name your constraints.

To drop a constraint, use the DROP CONSTRAINT clause with the ALTER TABLE statement, and supply the name of the constraint.

VBA Copy code Copy code
ALTER TABLE tblCustomers
   DROP CONSTRAINT PK_tblCustomers

Constraints also can be used to restrict the allowable values for a field. You can restrict values to NOT NULL or UNIQUE, or you can define a check constraint, which is a type of business rule that can be applied to a field. Assume that you want to restrict (or constrain) the values of the first name and last name fields to be unique, meaning that there should never be a combination of first name and last name that is the same for any two records in the table. Because this is a multi-field constraint, it is declared at the table level, not the field level. Use the ADD CONSTRAINT clause and define a multi-field list.

VBA Copy code Copy code
ALTER TABLE tblCustomers
   ADD CONSTRAINT CustomerID UNIQUE
   ([Last Name], [First Name])

A check constraint is a powerful SQL feature that allows you to add data validation to a table by creating an expression that can refer to a single field, or multiple fields across one or more tables. Suppose that you want to make sure that the amounts entered in an invoice record are always greater than $0.00. To do so, use a check constraint by declaring the CHECK keyword and your validation expression in the ADD CONSTRAINT clause of an ALTER TABLE statement.

VBA Copy code Copy code
ALTER TABLE tblInvoices
   ADD CONSTRAINT CheckAmount
   CHECK (Amount > 0)

The expression used to define a check constraint also can refer to more than one field in the same table, or to fields in other tables, and can use any operations that are valid in Microsoft Access SQL, such as SELECT statements, mathematical operators, and aggregate functions. The expression that defines the check constraint can be no more than 64 characters long.

Suppose that you want to check each customer's credit limit before he or she is added to the customers table. Using an ALTER TABLE statement with the ADD COLUMN and CONSTRAINT clauses, create a constraint that will look up the value in the CreditLimit table to verify the customer's credit limit. Use the following SQL statements to create the tblCreditLimit table, add the CustomerLimit field to the tblCustomers table, add the check constraint to the tblCustomers table, and test the check constraint.

VBA Copy code Copy code
CREATE TABLE tblCreditLimit (
   Limit DOUBLE)

INSERT INTO tblCreditLimit
   VALUES (100)

ALTER TABLE tblCustomers
   ADD COLUMN CustomerLimit DOUBLE

ALTER TABLE tblCustomers
   ADD CONSTRAINT LimitRule
   CHECK (CustomerLimit <= (SELECT Limit
      FROM tblCreditLimit))

UPDATE TABLE tblCustomers
   SET CustomerLimit = 200
   WHERE CustomerID = 1

Note that when you execute the UPDATE TABLE statement, you receive a message indicating that the update did not succeed because it violated the check constraint. If you update the CustomerLimit field to a value that is equal to or less than 100, the update will succeed.


Size Property (ADO)

 Copy code hover
[image]

Size Property (ADO)
Send feedback

Indicates the maximum size, in bytes or characters, of a Parameter object.

Settings and Return Values

Sets or returns a Long value that indicates the maximum size in bytes or characters of a value in a Parameter object.

Remarks

Use the Size property to determine the maximum size for values written to or read from the Value property of a Parameter object.

If you specify a variable-length data type for a Parameter object (for example, any String type, such as adVarChar), you must set the object's Size property before appending it to the Parameters collection; otherwise, an error occurs.

If you have already appended the Parameter object to the Parameters collection of a Command object and you change its type to a variable-length data type, you must set the Parameter object's Size property before executing the Command object; otherwise, an error occurs.

If you use the Refresh method to obtain parameter information from the provider and it returns one or more variable-length data type Parameter objects, ADO may allocate memory for the parameters based on their maximum potential size, which could cause an error during execution. To prevent an error, you should explicitly set the Size property for these parameters before executing the command.

The Size property is read/write.


TO (Microsoft Access SQL reserved word)

 Copy code hover
[image]

TO (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The TO keyword is used in these contexts:

ADD USER Statement

GRANT Statement


ComboBox.Requery Method (Access)

 Copy code hover
[image]

ComboBox.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.

Syntax

expression .Requery

expression A variable that represents a ComboBox object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts .

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate function.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

Example

The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form:

VBA Copy code Copy code
Public Sub RequeryList()

    Dim ctlCombo As Control

    ' Return Control object pointing to a combo box.
    Set ctlCombo = Forms!Employees!ReportsTo

    ' Requery source of data for list box.
    ctlCombo.Requery

End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Too few parameters. Expected

 Copy code hover
[image]

Too few parameters. Expected <number>. (Error 3061)
Send feedback

This parameter query requires the specified number of parameters, which you did not supply. Provide the expected number of parameters, and run the query again.

In some cases, this message is generated when unknown field names or expressions are interpreted as query parameters. Be sure to enclose field names containing spaces or punctuation with square brackets [ ].


AddNew Method Example (VJ++)

 Copy code hover
[image]

AddNew Method Example (VJ++)
Send feedback

This example uses the AddNew method to create a new record with the specified name.

Copy code Copy code

// BeginAddNewJ
import com.ms.wfc.data.*;
import java.io.*;

public class AddNewX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 AddNewX();
 System.exit(0);
 }

 // AddNewX function

 static void AddNewX()
 {
 // Define ADO Objects.
 Connection cnConn1 = null;
 Recordset rstEmployees = null;

 //Declarations.
 String strCnn;
 String strID;
 String strFirstName;
 String strLastName;
 boolean booRecordAdded ;
 BufferedReader in =
 new BufferedReader (new InputStreamReader (System.in));
 String line = null;

 try
 {
 // Open a connection.
 strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";
 cnConn1 = new Connection();
 cnConn1.open(strCnn);//,"","",AdoEnums.CommandType.UNSPECIFIED);

 // Open Employees table.
 rstEmployees = new Recordset ();
 rstEmployees.open("employee", cnConn1,
 AdoEnums.CursorType.KEYSET , AdoEnums.LockType.OPTIMISTIC ,
 AdoEnums.CommandType.TABLE );

 /* Get data from the user. The employee ID must be formatted as
 first,middle, and last initial, five numbers, then M or F to
 signify the gender. For example, the employee id for Bill
 Sornsin would be "B-S55555M". */
 System.out.println("\nEnter employee ID :");
 strID = in.readLine().trim();
 System.out.println("\nEnter first name :");
 strFirstName = in.readLine().trim();
 System.out.println("\nEnter last name :");
 strLastName = in.readLine().trim();

 // Proceed only if the user actually entered something
 // for both the first and last names.

 if ( !(strID.compareTo("") == 0) &
 !(strFirstName.compareTo("") == 0) &
 !(strLastName.compareTo("")== 0))
 {
 // Add new record.
 rstEmployees.addNew();
 rstEmployees.getField("emp_id").setString(strID);
 rstEmployees.getField("fname").setString(strFirstName);
 rstEmployees.getField("lname").setString(strLastName);

 // update the record with the new data.
 rstEmployees.update();
 booRecordAdded = true;

 // Show the newly added data.
 System.out.println("\nNew record : "
 + rstEmployees.getField("emp_id").getString()+ " "
 + rstEmployees.getField("fname").getString()+ " "
 + rstEmployees.getField("lname").getString());
 }
 else
 {
 System.out.println("\nPlease enter an employee ID," +
 "first name, and last name.");
 }

 System.out.println("\n\nPress <Enter> key to continue.");
 line = in.readLine();

 // Delete the new record because this is a demonstration.
 cnConn1.execute("DELETE FROM employee WHERE "
 + "emp_id = '" + strID + "'");
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 //Check for null pointer for connection object.
 if(rstEmployees.getActiveConnection()==null)
 System.out.println("Exception: " + ae.getMessage());
 // As passing a Recordset, check for null pointer first.
 if (rstEmployees != null)
 {
 PrintProviderError(rstEmployees.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 System.exit(0);
 }
 // System Read requires this catch.
 catch( java.io.IOException je )
 {
 PrintIOError(je);
 }
 finally
 {
 // Cleanup objects before exit.
 if (rstEmployees != null)
 if (rstEmployees.getState() == 1)
 rstEmployees.close();
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 System.exit(0);
 }

 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 //.PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}

// EndAddNewJ


RunMacro Macro Action

 Copy code hover
[image]

RunMacro Macro Action
Send feedback

You can use the RunMacro action to run a macro. The macro can be in a macro group.

You can use this action:

  • To run a macro from within another macro.

  • To run a macro based on a certain condition.

  • To attach a macro to a custom menu command.

Setting

The RunMacro action has the following arguments.

Action argument | Description
Macro Name | The name of the macro to run. The Macro Name box in the Action Arguments section of the Macro Builder pane shows all macros (and macro groups) in the current database. If the macro is in a macro group, it's listed under the macro group name in the list as macrogroupname.macroname. This is a required argument. If you run a macro containing the RunMacro action in a library database, Microsoft Access looks for the macro with this name in the library database and doesn't look for it in the current database.
Repeat Count | The maximum number of times the macro will run. If you leave this argument blank (and the Repeat Expression argument is also blank), the macro runs once.
Repeat Expression | An expression that evaluates to True (-1) or False (0). The macro stops running if the expression evaluates to False. The expression is evaluated each time the macro runs.

Remarks

If you enter a macro group name for the Macro Name argument, Access runs the first macro in the macro group.

This action is similar to clicking Run Macro on the Database Tools tab, selecting a macro, and clicking OK. However, this command runs the macro only once, whereas the RunMacro action can run a macro as many times as you want.

Tip Tip

You can use the Repeat Count and Repeat Expression arguments to determine how many times the macro runs:

  • If you leave both arguments blank, the macro runs once.

  • If you enter a number for Repeat Count but leave Repeat Expression blank, the macro runs the specified number of times.

  • If you leave Repeat Count blank but enter an expression for Repeat Expression, the macro runs until the expression evaluates to False.

  • If you enter values for both arguments, the macro runs the number of times specified in Repeat Count or until Repeat Expression evaluates to False, whichever occurs first.

When you run a macro containing the RunMacro action, and it reaches the RunMacro action, Access runs the called macro. When the called macro has finished, Access returns to the original macro and runs the next action.

Note Note

  • You can call a macro in the same macro group or in another macro group.

  • You can nest macros. That is, you can run macro A, which in turn calls macro B, and so on. In each case, when the called macro has finished, Access returns to the macro that called it and runs the next action in that macro.

To run the RunMacro action in a Visual Basic for Applications (VBA) module, use the RunMacro method of the DoCmd object.


Indexes Collection (DAO)

 Copy code hover
[image]

Indexes Collection (DAO)
Send feedback

An Indexes collection contains all the stored Index objects of a TableDef object (Microsoft Access workspaces only).

Remarks

When you access a table-type Recordset object, use the object's Index property to specify the order of records. Set this property to the Name property setting of an existing Index object in the Indexes collection of the TableDef object underlying the Recordset object.

Note Note

You can use the Append or Delete method on an Indexes collection only if the Updatable property setting of the containing TableDef object is True.

After you create a new Index object, you should use the Append method to add it to the TableDef object's Indexes collection.

Important note Important

Make sure your data complies with the attributes of your new index. If your index requires unique values, make sure that there are no duplicates in existing data records. If duplicates exist, the Microsoft Access database engine can't create the index; a trappable error results when you attempt to use the Append method on the new index.

Example

This example creates a new Index object, appends it to the Indexes collection of the Employees TableDef, and then enumerates the Indexes collection of the TableDef. Finally, it enumerates a Recordset, first using the primary Index, and then using the new Index. The IndexOutput procedure is required for this procedure to run.

VBA Copy code Copy code
Sub IndexObjectX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim idxNew As Index
 Dim idxLoop As Index
 Dim rstEmployees As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set tdfEmployees = dbsNorthwind!Employees

 With tdfEmployees
 ' Create new index, create and append Field
 ' objects to its Fields collection.
 Set idxNew = .CreateIndex("NewIndex")

 With idxNew
 .Fields.Append .CreateField("Country")
 .Fields.Append .CreateField("LastName")
 .Fields.Append .CreateField("FirstName")
 End With

 ' Add new Index object to the Indexes collection
 ' of the Employees table collection.
 .Indexes.Append idxNew
 .Indexes.Refresh

 Debug.Print .Indexes.Count & " Indexes in " & _
 .Name & " TableDef"

 ' Enumerate Indexes collection of Employees
 ' table.
 For Each idxLoop In .Indexes
 Debug.Print " " & idxLoop.Name
 Next idxLoop

 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees")

 ' Print report using old and new indexes.
 IndexOutput rstEmployees, "PrimaryKey"
 IndexOutput rstEmployees, idxNew.Name
 rstEmployees.Close

 ' Delete new Index because this is a
 ' demonstration.
 .Indexes.Delete idxNew.Name
 End With

 dbsNorthwind.Close

End Sub

Sub IndexOutput(rstTemp As Recordset, _
 strIndex As String)
 ' Report function for FieldX.

 With rstTemp
 ' Set the index.
 .Index = strIndex
 .MoveFirst
 Debug.Print "Recordset = " & .Name & _
 ", Index = " & .Index
 Debug.Print " EmployeeID - Country - Name"

 ' Enumerate the recordset using the specified
 ' index.
 Do While Not .EOF
 Debug.Print " " & !EmployeeID & " - " & _
 !Country & " - " & !LastName & ", " & !FirstName
 .MoveNext
 Loop

 End With

End Sub

This example uses the CreateIndex method to create two new Index objects and then appends them to the Indexes collection of the Employees TableDef object. It then enumerates the Indexes collection of the TableDef object, the Fields collection of the new Index objects, and the Properties collection of the new Index objects. The CreateIndexOutput function is required for this procedure to run.

VBA Copy code Copy code
Sub CreateIndexX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim idxCountry As Index
 Dim idxFirstName As Index
 Dim idxLoop As Index

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set tdfEmployees = dbsNorthwind!Employees

 With tdfEmployees
 ' Create first Index object, create and append Field
 ' objects to the Index object, and then append the
 ' Index object to the Indexes collection of the
 ' TableDef.
 Set idxCountry = .CreateIndex("CountryIndex")
 With idxCountry
 .Fields.Append .CreateField("Country")
 .Fields.Append .CreateField("LastName")
 .Fields.Append .CreateField("FirstName")
 End With
 .Indexes.Append idxCountry

 ' Create second Index object, create and append Field
 ' objects to the Index object, and then append the
 ' Index object to the Indexes collection of the
 ' TableDef.
 Set idxFirstName = .CreateIndex
 With idxFirstName
 .Name = "FirstNameIndex"
 .Fields.Append .CreateField("FirstName")
 .Fields.Append .CreateField("LastName")
 End With
 .Indexes.Append idxFirstName

 ' Refresh collection so that you can access new Index
 ' objects.
 .Indexes.Refresh

 Debug.Print .Indexes.Count & " Indexes in " & _
 .Name & " TableDef"

 ' Enumerate Indexes collection.
 For Each idxLoop In .Indexes
 Debug.Print " " & idxLoop.Name
 Next idxLoop

 ' Print report.
 CreateIndexOutput idxCountry
 CreateIndexOutput idxFirstName

 ' Delete new Index objects because this is a
 ' demonstration.
 .Indexes.Delete idxCountry.Name
 .Indexes.Delete idxFirstName.Name
 End With

 dbsNorthwind.Close

End Sub

Function CreateIndexOutput(idxTemp As Index)

 Dim fldLoop As Field
 Dim prpLoop As Property

 With idxTemp
 ' Enumerate Fields collection of Index object.
 Debug.Print "Fields in " & .Name
 For Each fldLoop In .Fields
 Debug.Print " " & fldLoop.Name
 Next fldLoop

 ' Enumerate Properties collection of Index object.
 Debug.Print "Properties of " & .Name
 For Each prpLoop In .Properties
 Debug.Print " " & prpLoop.Name & " - " & _
 IIf(prpLoop = "", "[empty]", prpLoop)
 Next prpLoop
 End With

End Function


NavigationButton.Visible Property (Access)

 Copy code hover
[image]

NavigationButton.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .Visible

expression A variable that represents a NavigationButton object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Jumping to a Record

 Copy code hover
[image]

Jumping to a Record
Send feedback

The Move method allows you to move forward or backward in the Recordset a specified number of records by using the following syntax:

Copy code Copy code

oRs.Move NumRecords, Start

The Move method is supported on all Recordset objects.

If the NumRecords argument is greater than zero, the current record position moves forward (toward the end of the Recordset). If NumRecords is less than zero, the current record position moves backward (toward the beginning of the Recordset).

If the Move call would move the current record position to a point before the first record, ADO sets the current record to the position before the first record in the Recordset (BOF is True). An attempt to move backward when the BOF property is already True generates an error.

If the Move call would move the current record position to a point after the last record, ADO sets the current record to the position after the last record in the Recordset (EOF is True). An attempt to move forward when the EOF property is already True generates an error.

Calling the Move method from an empty Recordset object generates an error.

If you pass a bookmark in the Start argument, the move is relative to the record with this bookmark, assuming the Recordset object supports bookmarks. A bookmark is obtained by using the Bookmark property. If not specified, the move is relative to the current record.

If you are using the CacheSize property to locally cache records from the provider, passing a NumRecords argument that moves the current record position outside the current group of cached records forces ADO to retrieve a new group of records, starting from the destination record. The CacheSize property determines the size of the newly retrieved group, and the destination record is the first record retrieved.


Forward-Only Cursors

 Copy code hover
[image]

Forward-Only Cursors
Send feedback

The typical default cursor type, called a forward-only (or non-scrollable) cursor, can move only forward through the result set. A forward-only cursor does not support scrolling (the ability to move forward and backward in the result set); it only supports fetching rows from the start to the end of the result set. With some forward-only cursors (such as with the SQL Server cursor library), all insert, update, and delete statements made by the current user (or committed by other users) that affect rows in the result set are visible as the rows are fetched. Because the cursor cannot be scrolled backward, however, changes made to rows in the database after the row was fetched are not visible through the cursor.

After the data for the current row is processed, the forward-only cursor releases the resources that were used to hold that data. Forward-only cursors are dynamic by default, meaning that all changes are detected as the current row is processed. This provides faster cursor opening and enables the result set to display updates made to the underlying tables.

While forward-only cursors do not support backward scrolling, your application can return to the beginning of the result set by closing and reopening the cursor. This is an effective way to work with small amounts of data. As an alternative, your application could read the result set once, cache the data locally, and then browse the local data cache.

If your application does not require scrolling through the result set, the forward-only cursor is the best way to retrieve data quickly with the least amount of overhead. Use the adOpenForwardOnly CursorTypeEnum to indicate that you want to use a forward-only cursor in ADO.


Label.BackStyle Property (Access)

 Copy code hover
[image]

Label.BackStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.

Syntax

expression .BackStyle

expression A variable that represents a Label object.

Remarks

The BackStyle property uses the following settings.

Setting | Visual Basic | Description
Normal | 1 | (Default for all controls except option group) The control has its interior color set by the BackColor property.
Transparent | 0 | (Default for option group) The control is transparent. The color of the form or report behind the control is visible.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

If the Transparent button on the Back Color button palette is selected, the BackStyle property is set to Transparent; otherwise the BackStyle property is set to Normal.

To make a command button invisible, set its Transparent property to Yes.

See also

Concepts

Label Object

Other resources

Label Object Members


Field2 Members (DAO)

 Copy code hover
[image]

Field2 Members (DAO)
Send feedback

A Field2 object represents a column of data with a common data type and a common set of properties.

Methods

Name | Description
AppendChunk | Appends data from a string expression to a Memo or Long Binary Field2 object in a Recordset.
CreateProperty | Creates a new user-defined Property object (Microsoft Access workspaces only).
GetChunk | Returns all or a portion of the contents of a Memo or Long BinaryField2 object in the Fields collection of a Recordset object.
LoadFromFile | Loads the specified file from disk.
SaveToFile | Saves an attachment to disk. .

Properties

Name

Description

AllowZeroLength

Sets or returns a value that indicates whether a zero-length string ("") is a valid setting for the Value property of the Field2 object with a Text or Memo data type (Microsoft Access workspaces only).

AppendOnly

Gets or sets a Boolean that indicates whether the spcified field is set to append new values to the existing contents of the field as they are added. Read/write.

Attributes

Sets or returns a value that indicates one or more characteristics of a Field2 object. Read/write Long.

CollatingOrder

Returns a value that specifies the sequence of the sort order in text for string comparison or sorting (Microsoft Access workspaces only). Read-only Long.

ComplexType

Returns a ComplexType object that represents a multi-valued field. Read-only.

DataUpdatable

Returns a value that indicates whether the data in the field represented by a Field2 object is updatable.

DefaultValue

Sets or returns the default value of a Field2 object. For a Field2 object not yet appended to the Fields collection, this property is read/write (Microsoft Access workspaces only).

Expression

Read/write

FieldSize

Returns the number of bytes used in the database (rather than in memory) of a Memo or Long Binary Field2 object in the Fields collection of a Recordset object.

ForeignName

Sets or returns a value that specifies the name of the Field2 object in a foreign table that corresponds to a field in a primary table for a relationship (Microsoft Access workspaces only).

IsComplex

Returns Boolean that indicates whether the specified field is a multi-valued data type. Read-only.

Name

Returns or sets the name of the specified object. Read/write String if the object has not been appended to a collection. Read-only String if the object has been appended to a collection.

OrdinalPosition

Sets or returns the relative position of a Field2 object within a Fields collection. .

OriginalValue

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Returns the value of a Field2 in the database that existed when the last batch update began (ODBCDirect workspaces only).

Properties

Returns the Properties collection of the specified object. Read-only.

Required

Sets or returns a value that indicates whether a Field2 object requires a non-Null value.

Size

Sets or returns a value that indicates the maximum size, in bytes, of a Field2 object.

SourceField

Returns a value that indicates the name of the field that is the original source of the data for a Field2 object. Read-only String.

SourceTable

Returns a value that indicates the name of the table that is the original source of the data for a Field2 object. Read-only String.

Type

Sets or returns a value that indicates the operational type or data type of an object. Read/write Integer.

ValidateOnSet

Sets or returns a value that specifies whether or not the value of a Field2 object is immediately validated when the object's Value property is set (Microsoft Access workspaces only).

ValidationRule

Sets or returns a value that validates the data in a field as it's changed or added to a table (Microsoft Access workspaces only). Read/write String.

ValidationText

Sets or returns a value that specifies the text of the message that your application displays if the value of a Field2 object doesn't satisfy the validation rule specified by the ValidationRule property setting (Microsoft Access workspaces only). Read/write String.

Value

Sets or returns the value of an object. Read/write Variant.

VisibleValue

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Returns a value currently in the database that is newer than the OriginalValue property as determined by a batch update conflict (ODBCDirect workspaces only).


Report.OnError Property (Access)

 Copy code hover
[image]

Report.OnError Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the OnError box in the Properties window of a form or report. Read/write String.

Syntax

expression .OnError

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Error event occurs when a run-time error is produced in Microsoft Access when a form or report has the focus. This includes Microsoft Jet database engine errors, but not run-time errors in Visual Basic.

The OnError value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the OnError box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the OnError box is blank, the property value is an empty string.

Example

The following example associates the Error event with the macro "Error_Handler_Macro" for the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").OnError = "Error_Handler_Macro"

See also

Concepts

Report Object

Other resources

Report Object Members


ToggleButton.Layout Property (Access)

 Copy code hover
[image]

ToggleButton.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified toggle button. Read-only AcLayoutType.

Version Information

Version Added: Access 2007

Syntax

expression .Layout

expression A variable that represents a ToggleButton object.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


ToggleButton.TabStop Property (Access)

 Copy code hover
[image]

ToggleButton.TabStop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.

Syntax

expression .TabStop

expression A variable that represents a ToggleButton object.

Remarks

This property doesn't apply to toggle button controls when they appear in an option group. It applies only to the option group itself.

The TabStop property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) You can move the focus to the control by pressing the TAB key.
No | False | You can't move the focus to the control by pressing the TAB key.

When you create a control on a form, Microsoft Access automatically assigns the control a position in the form's tab order. Each new control is placed last in the tab order. If you want to prevent a control from being available when you tab through the controls in a form, set the control's TabStop property to No.

In Form view, hidden or disabled controls remain in the tab order but are skipped when you move through the controls by pressing TAB, even if their TabStop properties are set to Yes.

As long as a control's Enabled property is set to Yes, you can click the control or use an access key to select it, regardless of its TabStop property setting. For example, you can set the TabStop property of a command button to No to prevent users from selecting the button by pressing TAB. However, they can still click the command button to choose it.

Example

The following example disables the ability to move the focus to the "City" text box on the "Suppliers" form by using the TAB key.

VBA Copy code Copy code
Forms("Suppliers").Controls("City").TabStop = False

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


RunApplication Macro Action

 Copy code hover
[image]

RunApplication Macro Action
Send feedback

Security note Security Note
Use caution when running executable files or code in macros or applications. Executable files or code can be used to carry out actions that might compromise the security of your computer and data.

You can use the RunApplication action to run a Microsoft Windows-based or MS-DOS-based application, such as Microsoft Excel, Microsoft Word, or Microsoft PowerPoint, from within Microsoft Access. For example, you may want to paste Excel spreadsheet data into your Access database.

Note 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.

Setting

The RunApplication action has the following argument.

Action argument | Description
Command Line | The command line used to start the application (including the path and any other necessary parameters, such as switches that run the application in a particular mode). Enter the command line in the Command Line box in the Action Arguments section of the Macro Builder pane. This is a required argument.

Remarks

The application selected with this action loads and runs in the foreground. The macro containing this action continues to run after starting the application.

You can transfer data between the other application and Access by using the Microsoft Windows dynamic data exchange (DDE) facility or the Clipboard. You can use the SendKeys action to send keystrokes to the other application (although DDE is a more efficient method for transferring data). You can also share data among applications by using automation.

MS-DOS-based applications run in an MS-DOS window within the Windows environment.

In Windows operating systems, there are a number of ways to run an application, including starting the program from the Windows Explorer, using the Run command on the Start menu, and double-clicking a program icon on the Windows Desktop.

You can't run the RunApplication action in a Visual Basic for Applications (VBA) module. Use the VBA Shell function instead.


Cannot create a relationship. (Error 3300)

 Copy code hover
[image]

Cannot create a relationship. (Error 3300)
Send feedback

You are attempting to create a relationship that is not allowed. For example, the tables may be in different databases.


AllForms Properties (Access)

 Copy code hover
[image]

AllForms Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


SubForm.BorderColor Property (Access)

 Copy code hover
[image]

SubForm.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Syntax

expression .BorderColor

expression A variable that represents a SubForm object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Report.Cycle Property (Access)

 Copy code hover
[image]

Report.Cycle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Cycle property to specify what happens when you press the TAB key and the focus is in the last control on a report. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .Cycle

expression A variable that represents a Report object.

Remarks

The Cycle property uses the following settings.

Setting | Visual Basic | Description
All Records | 0 | (Default) Pressing the TAB key from the last control on a report moves the focus to the first control in the tab order in the next record.
Current Record | 1 | Pressing the TAB key from the last control on a record moves the focus to the first control in the tab order in the same record.
Current Page | 2 | Pressing the TAB key from the last control on a page moves the focus back to the first control in the tab order on the page.

You can set the Cycle property by using the report's property sheet, a macro, or Visual Basic.

You can set the Cycle property in any view.

When you press the TAB key on a report, the focus moves through the controls on the report according to each control's place in the tab order.

The Cycle property only controls the TAB key behavior on the report where the property is set. If a subreport control is in the tab order, once the subreport control receives the focus, the Cycle property setting for the subreport determines what happens when you press the TAB key.

To move the focus outside a subreport control, press CTRL+TAB.

See also

Concepts

Report Object

Other resources

Report Object Members


SubForm.GridlineWidthRight Property (Access)

 Copy code hover
[image]

SubForm.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified subform. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthRight

expression A variable that represents a SubForm object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


CommandButton.BackShade Property (Access)

 Copy code hover
[image]

CommandButton.BackShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackShade

expression A variable that represents a CommandButton object.

Remarks

The BackShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the BackShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackShade=25

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


The Microsoft Cursor Service for OLE DB

 Copy code hover
[image]

The Microsoft Cursor Service for OLE DB
Send feedback

When you select a client-side cursor, or set the CursorLocation property to adUseClient, you are invoking the Microsoft Cursor Service for OLE DB. You might also see references to the "Client Cursor Engine", which is essentially the same thing in the context of ADO. This service supplements the cursor-support functions of data providers. As a result, you can perceive relatively uniform functionality from all data providers.

The Cursor Service for OLE DB makes dynamic properties available and enhances the behavior of certain methods. For example, the Optimize dynamic property enables the creation of temporary indexes to facilitate certain operations, such as the Find method.

The Cursor Service enables support for batch updating in all cases. It also simulates more capable cursor types, such as dynamic cursors, when a data provider can only supply less capable cursors, such as static cursors.


DoCmd.SetProperty Method (Access)

 Copy code hover
[image]

DoCmd.SetProperty Method (Access)
See also Send feedback

Published: July 16, 2012

The SetProperty method carries out the SetProperty action in Visual Basic.

Version Information

Version Added: Access 2007

Syntax

expression .SetProperty(ControlName, Property, Value)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
ControlName | Required | Variant | The name of the field or control for which you want to set the property value. Leave this argument blank to set the property for the current form or report.
Property | Optional | Variant | A AcProperty constant that specifies the property that you want to set.
Value | Optional | Variant | The value to which the property is to be set. For properties whose values are either Yes or No, use -1 for Yes and 0 for No.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


WebBrowserControl.InSelection Property (Access)

 Copy code hover
[image]

WebBrowserControl.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .InSelection

expression A variable that represents a WebBrowserControl object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Property Members (DAO)

 Copy code hover
[image]

Property Members (DAO)
Send feedback

A Property object represents a built-in or user-defined characteristic of a DAO object.

Properties

Name | Description
Inherited | Returns a value that indicates whether a Property object is inherited from an underlying object.
Name | Returns or sets the name of the specified object. Read/write String if the object has not been appended to a collection. Read-only String if the object has been appended to a collection.
Properties | Returns the Properties collection of the specified object. Read-only.
Type | Sets or returns a value that indicates the operational type or data type of an object. Read/write Integer.
Value | Sets or returns the value of an object. Read/write Variant.


Application.GetOption Method (Access)

 Copy code hover
[image]

Application.GetOption Method (Access)
See also Send feedback

Published: July 16, 2012

The GetOption method returns the current value of an option in the Access Options dialog box, available by clicking the Microsoft Office Button [image] and then clicking Access Options. Variant.

Syntax

expression .GetOption(OptionName)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
OptionName | Required | String | The name of the option. For a list of optionname argument strings, see Set Options from Visual Basic .

Return Value

Variant

Remarks

The GetOption and SetOption methods provide a means of changing environment options from Visual Basic code. With these methods, you can set or read any option available in the Access Options dialog box.

The available option settings depend on the type of option being set. There are three general types of options:

  • Yes/No options that can be set by selecting or clearing a check box.

  • Options that can be set by entering a string or numeric value.

  • Predefined options that can be chosen from a list box, combo box, or option group.

For options that the user sets by selecting or clearing a check box, the GetOption method returns True (-1) if the option setting is Yes (the check box is selected) or False (0) if the option setting is No (the check box is cleared). To set an option of this kind by using the SetOption method, specify True or False for the setting argument, as in the following example:

VBA Copy code Copy code
Application.SetOption "Show Status Bar", True

For options that the user sets by typing a string or numeric value, the GetOption method returns the setting as it's displayed in the dialog box. The following example returns a string containing the left margin setting:

VBA Copy code Copy code
Dim varSetting As Variant
varSetting = Application.GetOption("Left Margin")

To set this type of option by using the SetOption method, specify the string or numeric value that would be typed in the dialog box. The following example sets the default form template to OrderTemplate:

VBA Copy code Copy code
Application.SetOption "Form Template", "OrderTemplate"

For options with settings that are choices in list boxes or combo boxes, the GetOption method returns a number corresponding to the position of the setting in the list. Indexing begins with zero, so the GetOption method returns zero for the first item, 1 for the second item, and so on. For example, if the Default Field Type option on the Object Designers tab is set to AutoNumber, the sixth item in the list, the GetOption method returns 5.

To set this type of option, specify the option's numeric position within the list as the setting argument for the SetOption method. The following example sets the Default Field Type option to AutoNumber:

VBA Copy code Copy code
Application.SetOption "Default Field Type", 5

Other options are set by clicking on an option button in an option group in the Access Options dialog box. In Visual Basic, these options are also set by specifying a particular option's position within the option group. The first option in the group is numbered zero, the second, 1, and so on. For example, if the Selection Behavior option on the Object Designers tab is set to Partially Enclosed, the GetOption method returns zero, as in the following example:

VBA Copy code Copy code
Debug.Print Application.GetOption("Selection Behavior")

To set an option that's a member of an option group, specify the index number of the option within the group. The following example sets Selection Behavior to Fully Enclosed:

VBA Copy code Copy code
Application.SetOption "Selection Behavior", 1
Note Note

  • When you use the GetOption method or the SetOption method to set an option in the Access Options dialog box, you don't need to specify the individual tab on which the option is found.

  • If the return value of the GetOption method is assigned to a variable, the variable must be declared as a Variant.

  • If your database may run on a version of Microsoft Access for a language other than the one in which you created it, then you must supply the arguments for the GetOption and SetOption methods in English.

When you quit Microsoft Access, you can reset all options to their original settings by using the SetOption method on all changed options. You may want to create public variables to store the values of the original settings. You might include code to reset options in the Close event procedure for a form, or in a custom exit procedure that the user must run to quit the application.

See also

Concepts

Application Object

Other resources

Application Object Members


CodeProject.FullName Property (Access)

 Copy code hover
[image]

CodeProject.FullName Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the full path (including file name) of a specific object. Read-only String.

Syntax

expression .FullName

expression A variable that represents a CodeProject object.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


Cannot save property; property is a schema property. (Error 3394)

 Copy code hover
[image]

Cannot save property; property is a schema property. (Error 3394)
Send feedback

You tried to set or change a schema property. When you create a new schema property, specify True as the fourth argument to the CreateProperty method in order to set or delete this property.


BoundObjectFrame.LostFocus Event (Access)

 Copy code hover
[image]

BoundObjectFrame.LostFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The LostFocus event occurs when the specified object loses the focus.

Syntax

expression .LostFocus

expression A variable that represents a BoundObjectFrame object.

Remarks

To run a macro or event procedure when these events occur, set the OnLostFocus property to the name of the macro or to [Event Procedure].

This events occurs when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The LostFocus event differs from the Exit event in that the LostFocus event occurs every time a control loses the focus. The Exit event occurs only before a control loses the focus to another control on the same form. The LostFocus event occurs after the Exit event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


ToggleButton.GridlineShade Property (Access)

 Copy code hover
[image]

ToggleButton.GridlineShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineShade

expression A variable that represents an ToggleButton object.

Remarks

The GridlineShade property contains a numeric expression that can be used to darken the theme color in the GridlineColor property. The default value of the GridlineShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


The file name you provided is too long. (Error 3549)

 Copy code hover
[image]

The file name you provided is too long. (Error 3549)
Send feedback

Use a smaller file name.


TextBox.IsVisible Property (Access)

 Copy code hover
[image]

TextBox.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Syntax

expression .IsVisible

expression A variable that represents a TextBox object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Open and Close Methods Example (VC++)

 Copy code hover
[image]

Open and Close Methods Example (VC++)
Send feedback

This example uses the Open and Close methods on both Recordset and Connection objects that have been opened.

Copy code Copy code

// BeginOpenCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <oledb.h>
#include <stdio.h>
#include <conio.h>
#include "OpenX.h"

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void OpenX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 OpenX();

 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// OpenX Function //
// //
///////////////////////////////////////////////////////////

void OpenX(void)
{
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace
 _RecordsetPtr pRstEmployee = NULL;
 _ConnectionPtr pConnection = NULL;

 // Define string variables.
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 // Define Other Variables.
 HRESULT hr = S_OK;
 IADORecordBinding *picRs = NULL; // Interface Pointer declared.
 CEmployeeRs emprs; // C++ Class object
 DBDATE varDate;

 try
 {
 // open connection and record set
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
 pConnection->Open(strCnn,"","",adConnectUnspecified);

 TESTHR(pRstEmployee.CreateInstance(__uuidof(Recordset)));
 pRstEmployee->Open("Employee",
 _variant_t((IDispatch *)pConnection,true), adOpenKeyset,
 adLockOptimistic, adCmdTable);

 // Open an IADORecordBinding interface pointer which we'll
 // use for Binding Recordset to a class.
 TESTHR(pRstEmployee->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 //Bind the Recordset to a C++ Class here.
 TESTHR(picRs->BindToRecordset(&emprs));

 // Assign the first employee record's hire date
 // to a variable, then change the hire date.
 varDate = emprs.m_sze_hiredate;
 printf("\nOriginal data\n");
 printf("\tName - Hire Date\n");
 printf(" %s %s - %d/%d/%d\n\n",
 emprs.le_fnameStatus == adFldOK ?
 emprs.m_sze_fname : "<NULL>",
 emprs.le_lnameStatus == adFldOK ?
 emprs.m_sze_lname : "<NULL>",
 emprs.le_hiredateStatus == adFldOK ?
 emprs.m_sze_hiredate.month : 0,
 emprs.le_hiredateStatus == adFldOK ?
 emprs.m_sze_hiredate.day : 0,
 emprs.le_hiredateStatus == adFldOK ?
 emprs.m_sze_hiredate.year : 0);

 emprs.m_sze_hiredate.year=1900;
 emprs.m_sze_hiredate.month=1;
 emprs.m_sze_hiredate.day=1;
 picRs->Update(&emprs);

 printf("\nChanged data\n");
 printf("\tName - Hire Date\n");
 printf(" %s %s - %d/%d/%d\n\n",
 emprs.le_fnameStatus == adFldOK ?
 emprs.m_sze_fname : "<NULL>",
 emprs.le_lnameStatus == adFldOK ?
 emprs.m_sze_lname : "<NULL>",
 emprs.le_hiredateStatus == adFldOK ?
 emprs.m_sze_hiredate.month : 0,
 emprs.le_hiredateStatus == adFldOK ?
 emprs.m_sze_hiredate.day : 0,
 emprs.le_hiredateStatus == adFldOK ?
 emprs.m_sze_hiredate.year : 0);

 // Requery Recordset and reset the hire date.
 pRstEmployee->Requery(adOptionUnspecified);
 // Open an IADORecordBinding interface pointer which we'll
 // use for Binding Recordset to a class.
 TESTHR(pRstEmployee->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 // Rebind the Recordset to a C++ Class here.
 TESTHR(picRs->BindToRecordset(&emprs));
 emprs.m_sze_hiredate = varDate;
 picRs->Update(&emprs);
 printf("\nData after reset\n");
 printf("\tName - Hire Date\n");
 printf(" %s %s - %d/%d/%d",emprs.le_fnameStatus == adFldOK ?
 emprs.m_sze_fname : "<NULL>",
 emprs.le_lnameStatus == adFldOK ?
 emprs.m_sze_lname : "<NULL>",
 emprs.le_hiredateStatus == adFldOK ?
 emprs.m_sze_hiredate.month : 0,
 emprs.le_hiredateStatus == adFldOK ?
 emprs.m_sze_hiredate.day : 0,
 emprs.le_hiredateStatus == adFldOK ?
 emprs.m_sze_hiredate.year : 0);
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Connection.
 PrintProviderError(pConnection);
 PrintComError(e);
 }

 // Clean up objects before exit.
 if (pRstEmployee)
 if (pRstEmployee->State == adStateOpen)
 pRstEmployee->Close();
 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0;i < nCount;i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,
 pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print COM errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndOpenCpp

OpenX.h

Copy code Copy code

// BeginOpenH
#include "icrsint.h"

// This Class extracts only fname,lastname and
// hire_date from employee table
class CEmployeeRs : public CADORecordBinding
{

BEGIN_ADO_BINDING(CEmployeeRs)

 // Column fname is the 2nd field in the table
 ADO_VARIABLE_LENGTH_ENTRY2(2, adVarChar, m_sze_fname,
 sizeof(m_sze_fname), le_fnameStatus, FALSE)

 // Column lname is the 4th field in the table.
 ADO_VARIABLE_LENGTH_ENTRY2(4, adVarChar, m_sze_lname,
 sizeof(m_sze_lname), le_lnameStatus, FALSE)

 // Column hiredate is the 8th field in the table.
 ADO_VARIABLE_LENGTH_ENTRY2(8, adDBDate,m_sze_hiredate,
 sizeof(m_sze_hiredate), le_hiredateStatus, TRUE)

END_ADO_BINDING()

public:
 CHAR m_sze_fname[21];
 ULONG le_fnameStatus;
 CHAR m_sze_lname[31];
 ULONG le_lnameStatus;
 DBDATE m_sze_hiredate;
 ULONG le_hiredateStatus;
};
// EndOpenH


Synchronizer

 Copy code hover
[image]

Synchronizer <name> is also using the same File System dropbox <name> (Error 3629)
Send feedback

Each Synchronizer should have a unique file system dropbox. Using the same dropbox location for multiple Synchronizers can result in lost messages and incomplete exchanges.

Unable to create the signal file, it is already opened by another transporter.


DELETE (Microsoft Access SQL reserved word)

 Copy code hover
[image]

DELETE (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The DELETE keyword is used in these contexts:

DELETE Statement

CREATE PROCEDURE Statement

GRANT Statement

REVOKE Statement


The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. (Error 3022)

 Copy code hover
[image]

The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. (Error 3022)
Send feedback

You tried to duplicate a value in a field that is the underlying table's primary key or an index that does not allow duplicates.

What Is a Primary Key?

A primary key is a field or set of fields in your table that provide Microsoft Access with a unique identifier for every row. In a relational database, such as an Access database, you divide your information into separate, subject-based tables. You then use table relationships and primary keys to tell Access how to bring the information back together again. Access uses primary key fields to quickly associate data from multiple tables and combine that data in a meaningful way.

Often, a unique identification number, such as an ID number or a serial number or code, serves as a primary key in a table. For example, you might have a Customers table where each customer has a unique customer ID number. The customer ID field is the primary key.

An example of a poor choice for a primary key would be a name or address. Both contain information that might change over time.

Access ensures that every record has a value in the primary key field, and that the value is always unique.

What Is an Index?

You can use an index to help Access find and sort records faster. An index stores the location of records based on the field or fields that you choose to index. After Access obtains the location from the index, it can then retrieve the data by moving directly to the correct location. In this way, using an index can be considerably faster than scanning through all of the records to find the data.

If you create a unique index, Access does not allow you to enter a new value in the field if that value already exists in the same field in another record. Access automatically creates a unique index for primary keys.

Solution

To solve the problem, you must design your tables to eliminate the possibility of entering duplicate values in a primary key field or a field that uses a unique index.

If the current primary key field needs to support duplicate values, you should remove the current primary key and add an AutoNumber field to your table to act as its primary key.

To remove the primary key

When you remove the primary key, the field or fields that previously served as primary key no longer provide the primary means of identifying a record. However, removing the primary key does not delete the field or fields from your table, Rather, it removes the primary key designation from those fields. Removing the primary key also removes the index that was created for the primary key.

  1. Before you can remove a primary key, you must ensure that it does not participate in any table relationships. If you try to remove a primary key for which relationships exist, Access warns you that you must delete the relationship first.

    • If the tables that participate in the table relationship are open, close them. You cannot delete a table relationship between open tables.

    • On the Database Tools tab, in the Show/Hide group, click Relationships.

    • If the tables that participate in the table relationship are not visible, on the Design tab, in the Relationships group, click Show Table. Then select the tables to add in the Show Table dialog box, click Add, and then click Close.

    • Click the table relationship line for the table relationship that you want to delete (the line becomes bold when it is selected), and then press the DELETE key.

    • On the Design tab, in the Relationships group, click Close.

  3. In the Navigation Pane, right click the table in which you want to remove the primary key and then click Design View.

  4. Click the row selector for the current primary key.

    • If the primary key consists of a single field, click the row selector for that field.

    • If the primary key consists of multiple fields, click the row selector for any field in the primary key.

  6. On the Design tab, in the Tools group, click Primary Key. The key indicator is removed from the field or fields that you previously specified as the primary key.


Recordset2.CopyQueryDef Method (DAO)

 Copy code hover
[image]

Recordset2.CopyQueryDef Method (DAO)
Send feedback

Returns a QueryDef object that is a copy of the QueryDef used to create the Recordset object represented by the recordset placeholder (Microsoft Access workspaces only). .

Syntax

expression .CopyQueryDef

expression A variable that represents a Recordset2 object.

Return Value

QueryDef

Remarks

You can use the CopyQueryDef method to create a new QueryDef that is a duplicate of the QueryDef used to create the Recordset.

If a QueryDef wasn't used to create this Recordset, an error occurs. You must first open a Recordset with the OpenRecordset method before using the CopyQueryDef method.

This method is useful when you create a Recordset object from a QueryDef, and pass the Recordset to a function, and the function must re-create the SQL equivalent of the query, for example, to modify it in some way.

Example

This example uses the CopyQueryDef method to create a copy of a QueryDef from an existing Recordset and modifies the copy by adding a clause to the SQL property. When you create a permanent QueryDef, spaces, semicolons, or linefeeds may be added to the SQL property; these extra characters must be stripped before any new clauses can be attached to the SQL statement.

VBA Copy code Copy code
Function CopyQueryNew(rstTemp As Recordset, _
 strAdd As String) As QueryDef

 Dim strSQL As String
 Dim strRightSQL As String

 Set CopyQueryNew = rstTemp.CopyQueryDef
 With CopyQueryNew
 ' Strip extra characters.
 strSQL = .SQL
 strRightSQL = Right(strSQL, 1)
 Do While strRightSQL = " " Or strRightSQL = ";" Or _
 strRightSQL = Chr(10) Or strRightSQL = vbCr
 strSQL = Left(strSQL, Len(strSQL) - 1)
 strRightSQL = Right(strSQL, 1)
 Loop
 .SQL = strSQL & strAdd
 End With

End Function

This example shows

This example shows a possible use of CopyQueryNew().

VBA Copy code Copy code
Sub CopyQueryDefX()

 Dim dbsNorthwind As Database
 Dim qdfEmployees As QueryDef
 Dim rstEmployees As Recordset2
 Dim intCommand As Integer
 Dim strOrderBy As String
 Dim qdfCopy As QueryDef
 Dim rstCopy As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set qdfEmployees = dbsNorthwind.CreateQueryDef( _
 "NewQueryDef", "SELECT FirstName, LastName, " & _
 "BirthDate FROM Employees")
 Set rstEmployees = qdfEmployees.OpenRecordset( _
 dbOpenForwardOnly)

 Do While True
 intCommand = Val(InputBox( _
 "Choose field on which to order a new " & _
 "Recordset:" & vbCr & "1 - FirstName" & vbCr & _
 "2 - LastName" & vbCr & "3 - BirthDate" & vbCr & _
 "[Cancel - exit]"))
 Select Case intCommand
 Case 1
 strOrderBy = " ORDER BY FirstName"
 Case 2
 strOrderBy = " ORDER BY LastName"
 Case 3
 strOrderBy = " ORDER BY BirthDate"
 Case Else
 Exit Do
 End Select
 Set qdfCopy = CopyQueryNew(rstEmployees, strOrderBy)
 Set rstCopy = qdfCopy.OpenRecordset(dbOpenSnapshot, _
 dbForwardOnly)
 With rstCopy
 Do While Not .EOF
 Debug.Print !LastName & ", " & !FirstName & _
 " - " & !BirthDate
 .MoveNext
 Loop
 .Close
 End With
 Exit Do
 Loop

 rstEmployees.Close
 ' Delete new QueryDef because this is a demonstration.
 dbsNorthwind.QueryDefs.Delete qdfEmployees.Name
 dbsNorthwind.Close

End Sub


FilterAxis Property (ADO MD)

 Copy code hover
[image]

FilterAxis Property (ADO MD)
Send feedback

Indicates filter information about the current cellset.

Return Values

Returns an Axis object, and is read-only.

Remarks

Use the FilterAxis property to return information about the dimensions that were used to slice the data. The DimensionCount property of the Axis returns the number of slicer dimensions. This axis usually has just one row.

The Axis returned by FilterAxis is not contained in the Axes collection for a Cellset object.


Parameter Properties (DAO)

 Copy code hover
[image]

Parameter Properties (DAO)
Send feedback

In this section

  • Parameter.Direction Property (DAO)

  • Parameter.Name Property (DAO)

  • Parameter.Properties Property (DAO)

  • Parameter.Type Property (DAO)

  • Parameter.Value Property (DAO)


Recordset Properties (DAO)

 Copy code hover
[image]

Recordset Properties (DAO)
Send feedback

In this section

  • Recordset.AbsolutePosition Property (DAO)

  • Recordset.BatchCollisionCount Property (DAO)

  • Recordset.BatchCollisions Property (DAO)

  • Recordset.BatchSize Property (DAO)

  • Recordset.BOF Property (DAO)

  • Recordset.Bookmark Property (DAO)

  • Recordset.Bookmarkable Property (DAO)

  • Recordset.CacheSize Property (DAO)

  • Recordset.CacheStart Property (DAO)

  • Recordset.Connection Property (DAO)

  • Recordset.DateCreated Property (DAO)

  • Recordset.EditMode Property (DAO)

  • Recordset.EOF Property (DAO)

  • Recordset.Fields Property (DAO)

  • Recordset.Filter Property (DAO)

  • Recordset.Index Property (DAO)

  • Recordset.LastModified Property (DAO)

  • Recordset.LastUpdated Property (DAO)

  • Recordset.LockEdits Property (DAO)

  • Recordset.Name Property (DAO)

  • Recordset.NoMatch Property (DAO)

  • Recordset.PercentPosition Property (DAO)

  • Recordset.Properties Property (DAO)

  • Recordset.RecordCount Property (DAO)

  • Recordset.RecordStatus Property (DAO)

  • Recordset.Restartable Property (DAO)

  • Recordset.Sort Property (DAO)

  • Recordset.StillExecuting Property (DAO)

  • Recordset.Transactions Property (DAO)

  • Recordset.Type Property (DAO)

  • Recordset.Updatable Property (DAO)

  • Recordset.UpdateOptions Property (DAO)

  • Recordset.ValidationRule Property (DAO)

  • Recordset.ValidationText Property (DAO)

  • Recordset.RecordsetType Property (DAO)


ADO Programmer's Guide Topics

 Copy code hover
[image]

ADO Programmer's Guide Topics
Send feedback

In this section

  • ADO Programmer's Guide

  • Introduction to ADO

  • Section I: ActiveX Data Objects (Access)

  • Section II: Remote Data Service (Access)

  • Section III: ADO (Multidimensional) (ADO MD) (Access)

  • Section IV: ADO Extensions for Data Definition Language and Security (ADOX) (Access)

  • Section V: Appendixes (Access)


Visual C++ Extensions for ADO

 Copy code hover
[image]

Visual C++ Extensions for ADO
Send feedback

The preferred method of programming ADO with Visual C++ is using the #import directive, as discussed in Microsoft Visual C++ ADO Programming. However, earlier versions of ADO shipped with an alternate method of programming using Visual C++: the Visual C++ Extensions. This section documents this feature for those who must maintain Visual C++ Extensions code, but new ADO code should be written using #import.

One of the most tedious jobs Visual C++ programmers face when retrieving data with ADO is converting data returned as a VARIANT data type into a C++ data type, and then storing the converted data in a class or structure. In addition to being cumbersome, retrieving C++ data through a VARIANT data type diminishes performance.

ADO provides an interface that supports retrieving data into native C/C++ data types without going through a VARIANT, and also provides preprocessor macros that simplify using the interface. The result is a flexible tool that is easier to use and has great performance.

A common C/C++ client scenario is to bind a record in a Recordset to a C/C++ struct or class containing native C/C++ types. When going through VARIANTs, this involves writing conversion code from VARIANT to C/C++ native types. The Visual C++ Extensions for ADO are targeted at making this scenario much easier for the Visual C++ programmer.

See the following topics to learn more about the Visual C++ Extensions for ADO.

  • Using Visual C++ Extensions for ADO

  • Visual C++ Extensions Header

  • ADO with Visual C++ Extensions Example


Document.Properties Property (DAO)

 Copy code hover
[image]

Document.Properties Property (DAO)
Send feedback

Returns the Properties collection of the specified object. Read-only.

Syntax

expression .Properties

expression A variable that represents a Document object.


Database already exists. (Error 3204)

 Copy code hover
[image]

Database already exists. (Error 3204)
Send feedback

You tried to create or rename a database using a name that already exists. Enter a different name, and then try the operation again.


CustomControl.About Property (Access)

 Copy code hover
[image]

CustomControl.About Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String representing version and copyright information for an ActiveX control. Read/write.

Syntax

expression .About

expression A variable that represents a CustomControl object.

Remarks

To view an About box showing version and copyright information for an ActiveX control, click the About property box in the Microsoft Access property sheet. Then click the Build button to the right of the property box.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


ADO Task Table

 Copy code hover
[image]

ADO Task Table
Send feedback

The following table lists programming tasks contained in the ADO Programmer's Guide and provides references for each task. These references can be textual descriptions or code examples in which you can find information about the ADO feature that performs the task.

ADO Task | References
Connecting to a data provider | Making a Connection
Executing commands or calling stored procedures | Using the Command Object
Opening a Recordset | The Recordset Object Open Method
Determining the size of a Recordset | Counting Rows and The Limits of a Recordset
Moving to a specific record | Navigating Through the Data
Accessing column values | The Fields Collection
Searching for data | Working with Recordsets
Modifying data and changing values | Editing Existing Records
Adding new data | Adding Records
Deleting or removing data | Deleting Records Using the Delete Method
Posting changes to the data source | Updating Data
Beginning, committing, and rolling back transactions | Transaction Processing
Saving records to a file (XML or binary) | Persisting Data
Handling errors | ADO Errors
Handling events, asynchronous programming | ADO Event Handler Summary
Choosing cursor location and type | Types of Cursors
Choosing lock types | Types of Locks
Returning related records in a Recordset | Data Shaping Summary
Accessing semi-structured data | Chapter 10: Records and Streams
Publishing to IIS | Using ADO for Internet Publishing


Attachment.BorderShade Property (Access)

 Copy code hover
[image]

Attachment.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents an Attachment object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


AcWebBrowserState Enumeration (Access)

 Copy code hover
[image]

AcWebBrowserState Enumeration (Access)
Send feedback

Published: July 16, 2012

Used by the ReadyState property to determine the state of the Web Browser control.

Version Information

Version Added: Access 2010

Name | Value | Description
acComplete | 3 | The Web Browser control has finished loading the new document and all its contents.
acInteractive | 3 | The Web Browser control has loaded enough of the document to allow limited user interaction, such as clicking hyperlinks that have been displayed.
acLoaded | 2 | The Web Browser control has loaded and initialized the new document, but has not yet received all the document data.
acLoading | 1 | The Web Browser control is loading a new document.
acUnintialized | 0 | No document is currently loaded.


Query

 Copy code hover
[image]

Query <name> contains an ambiguous column name that is conflicting with the correlation (alias) name <name>. (Error 3807)
Send feedback

Either fully qualify the column name or change the correlation (alias) name. A SQL SELECT statement is using a correlation (alias) name that is used in one of the base tables in the FROM clause of the statement. Previous versions of Microsoft Jet returned an incorrect result set with this. To prevent the changing of results sets, this error message is being propagated.

This SQL SELECT statement will work when using the Microsoft OLE DB Provider for Jet by itself or through Active Data Objects (ADO). If this SQL SELECT statement is being used through any part of Microsoft Access outside of ADO using Microsoft OLE DB Provider for Jet, you will need to change the correlation (alias) name to something other than the column name in the base table.

An example of this would be the following: CREATE TABLE Orders (OrderDate DATE, Freight DOUBLE);. The following SQL SELECT statement would now return an error: SELECT OrderDate AS A1, Freight + Freight AS OrderDate. The workaround would be to change the correlation (alias) name OrderDate to some other name or to run this query through ADO using the Microsoft OLE DB Provider for Jet.


ObjectFrame.SpecialEffect Property (Access)

 Copy code hover
[image]

ObjectFrame.SpecialEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.

Syntax

expression .SpecialEffect

expression A variable that represents an ObjectFrame object.

Remarks

The SpecialEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | 0 | The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised | 1 | The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken | 2 | The object has a shadow on the top and left and a highlight on the bottom and right.
Etched | 3 | The object has a sunken line surrounding the control.
Shadowed | 4 | The object has a shadow below and to the right of the control.
Chiseled | 5 | The object has a sunken line below the control.

The SpecialEffect property setting affects related property settings for the BorderStyle , BorderColor , and BorderWidth properties. For example, if the SpecialEffect property is set to Raised, the settings for the BorderStyle, BorderColor, and BorderWidth properties are ignored. In addition, changing or setting the BorderStyle, BorderColor, and BorderWidth properties may cause Microsoft Access to change the SpecialEffect property setting to Flat.

Example

The following example sets the appearance of the text box "OrganizationName1" on the "Mailing List" form to raised.

VBA Copy code Copy code
Forms("Mailing List").Controls("OrganizationName1").SpecialEffect = 1

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


ToggleButton.Properties Property (Access)

 Copy code hover
[image]

ToggleButton.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a ToggleButton object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


NavigationControl.OnClick Property (Access)

 Copy code hover
[image]

NavigationControl.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnClick

expression A variable that represents a NavigationControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


AllTables.Parent Property (Access)

 Copy code hover
[image]

AllTables.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents an AllTables object.

See also

Concepts

AllTables Collection

Other resources

AllTables Object Members


References Methods (Access)

 Copy code hover
[image]

References Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
AddFromFile | The AddFromFile method creates a reference to a type library in a specified file. .
AddFromGuid | The AddFromGUID method creates a Reference object based on the GUID that identifies a type library. Reference object.
Item | The Item method returns a specific member of a collection either by position or by key. Reference object.
Remove | The Remove method removes a Reference object from the References collection.


Control.LeftPadding Property (Access)

 Copy code hover
[image]

Control.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the control and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .LeftPadding

expression A variable that represents a Control object.

See also

Concepts

Control Object

Other resources

Control Object Members


Type Property (ADO Stream)

 Copy code hover
[image]

Type Property (ADO Stream)
Send feedback

Indicates the type of data contained in the Stream (binary or text).

Settings and Return Values

Sets or returns a StreamTypeEnum value that specifies the type of data contained in the Stream object. The default value is adTypeText. However, if binary data is initially written to a new, empty Stream, the Type will be changed to adTypeBinary.

Remarks

The Type property is read/write only when the current position is at the beginning of the Stream (Position is 0), and read-only at any other position.

The Type property determines which methods should be used for reading and writing the Stream. For text Streams, use ReadText and WriteText. For binary Streams, use Read and Write.


SmartTags.Count Property (Access)

 Copy code hover
[image]

SmartTags.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents a SmartTags object.

See also

Concepts

SmartTags Collection

Other resources

SmartTags Object Members


Table

 Copy code hover
[image]

Table <name> does not exist. (Error 3376)
Send feedback

The table you specified does not exist. Check to see if the name you specified exists in the TableDefs collection.


SubForm.GridlineStyleTop Property (Access)

 Copy code hover
[image]

SubForm.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified subform. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleTop

expression A variable that represents a SubForm object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Attachment.MouseDown Event (Access)

 Copy code hover
[image]

Attachment.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents an Attachment object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Section IV: ADO Extensions for Data Definition Language and Security (ADOX)

 Copy code hover
[image]

Section IV: ADO Extensions for Data Definition Language and Security (ADOX)
Send feedback

This section contains the following chapter:

  • Chapter 15: ADOX Fundamentals


Cannot set this property for remote objects. (Error 3365)

 Copy code hover
[image]

Cannot set this property for remote objects. (Error 3365)
Send feedback

This property is not available for objects associated with ODBC databases.


Step 2: Invoke the Server Program (RDS Tutorial)

 Copy code hover
[image]

Step 2: Invoke the Server Program (RDS Tutorial)
Send feedback

When you invoke a method on the client proxy, the actual program on the server executes the method. In this step, you'll execute a query on the server.

Part AIf you weren't using RDSServer.DataFactory in this tutorial, the most convenient way to perform this step would be to use the RDS.DataControl object. The RDS.DataControl combines the previous step of creating a proxy, with this step, issuing the query.

Set the RDS.DataControl object Server property to identify where the server program should be instantiated; the Connect property to specify the connect string to access the data source; and the SQL property to specify the query command text. Then issue the Refresh method to cause the server program to connect to the data source, retrieve rows specified by the query, and return a Recordset object to the client.

This tutorial does not use the RDS.DataControl, but this is how it would look if it did:

Copy code Copy code

Sub RDSTutorial2A()
 Dim DC as New RDS.DataControl
 DC.Server = "http://yourServer"
 DC.Connect = "DSN=Pubs"
 DC.SQL = "SELECT * FROM Authors"
 DC.Refresh
...

Nor does the tutorial invoke RDS with ADO objects, but this is how it would look if it did:

Copy code Copy code

Dim rs as New ADODB.Recordset
rs.Open "SELECT * FROM Authors","Provider=MS Remote;Data Source=Pubs;" & _
"Remote Server=http://yourServer;Remote Provider=SQLOLEDB;"

Part BThe general method of performing this step is to invoke the RDSServer.DataFactory object Query method. That method takes a connect string, which is used to connect to a data source, and a command text, which is used to specify the rows to be returned from the data source.

This tutorial uses the DataFactory object Query method:

Copy code Copy code

Sub RDSTutorial2B()
 Dim DS as New RDS.DataSpace
 Dim DF
 Dim RS as ADODB.Recordset
 Set DF = DS.CreateObject("RDSServer.DataFactory", "http://yourServer")
 Set RS = DF.Query ("DSN=Pubs", "SELECT * FROM Authors")
...


Control.Dropdown Method (Access)

 Copy code hover
[image]

Control.Dropdown Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the Dropdown method to force the list in the specified combo box to drop down.

Syntax

expression .Dropdown

expression A variable that represents a Control object.

Return Value

Nothing

Remarks

For example, you can use this method to cause a combo box listing vendor codes to drop down when the vendor code control receives the focus during data entry.

If the specified combo box control doesn't have the focus, an error occurs. The use of this method is identical to pressing the F4 key when the control has the focus.

Example

The following example shows how you can use the Dropdown method within the GotFocus event procedure to force a combo box named SupplierID to drop down when it receives the focus.

VBA Copy code Copy code
Private Sub SupplierID_GotFocus()
 Me!SupplierID.Dropdown
End Sub

See also

Concepts

Control Object

Other resources

Control Object Members


Report.Orientation Property (Access)

 Copy code hover
[image]

Report.Orientation Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Orientation property to specify or determine the view orientation. Read/write Byte.

Syntax

expression .Orientation

expression A variable that represents a Report object.

Remarks

The Orientation property uses the following settings.

Setting | Visual Basic | Description
Left-to-Right | 0 | Sets the view orientation to left to right.
Right-to-Left | 1 | Sets the view orientation to right to left.

See also

Concepts

Report Object

Other resources

Report Object Members


Field Object (DAO)

 Copy code hover
[image]

Field Object (DAO)
Send feedback

A Field object represents a column of data with a common data type and a common set of properties.

Remarks

The Fields collections of Index, QueryDef, Relation, and TableDef objects contain the specifications for the fields those objects represent. The Fields collection of a Recordset object represents the Field objects in a row of data, or in a record. You use the Field objects in a Recordset object to read and set values for the fields in the current record of the Recordset object.

In a Microsoft Access workspacee, you manipulate a field using a Field object and its methods and properties. For example, you can:

  • Use the OrdinalPosition property to set or return the presentation order of the Field object in a Fields collection.

  • Use the Value property of a field in a Recordset object to set or return stored data.

  • Use the AppendChunk and GetChunk methods and the FieldSize property to get or set a value in an OLE Object or Memo field of a Recordset object.

  • Use the Type, Size, and Attributes properties to determine the type of data that can be stored in the field.

  • Use the SourceField and SourceTable properties to determine the original source of the data.

  • Use the ForeignName property to set or return information about a foreign field in a Relation object.

  • Use the AllowZeroLength, DefaultValue, Required, ValidateOnSet, ValidationRule, or ValidationText properties to set or return validation conditions.

  • Use the DefaultValue property of a field on a TableDef object to set the default value for this field when new records are added.

To create a new Field object in an Index, TableDef, or Relation object, use the CreateField method.

When you access a Field object as part of a Recordset object, data from the current record is visible in the Field object's Value property. To manipulate data in the Recordset object, you don't usually reference the Fields collection directly; instead, you indirectly reference the Value property of the Field object in the Fields collection of the Recordset object.

To refer to a Field object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

Fields(0)

Fields("name")

Fields![name]

With the same syntax forms, you can also refer to the Value property of a Field object that you create and append to a Fields collection. The context of the field reference will determine whether you are referring to the Field object or the Value property of the Field object.

Example

This example shows what properties are valid for a Field object depending on where the Field resides (for example, the Fields collection of a TableDef, the Fields collection of a QueryDef, and so forth). The FieldOutput procedure is required for this procedure to run.

VBA Copy code Copy code
Sub FieldX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset
 Dim fldTableDef As Field
 Dim fldQueryDef As Field
 Dim fldRecordset As Field
 Dim fldRelation As Field
 Dim fldIndex As Field
 Dim prpLoop As Property

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees")

 ' Assign a Field object from different Fields
 ' collections to object variables.
 Set fldTableDef = _
 dbsNorthwind.TableDefs(0).Fields(0)
 Set fldQueryDef =dbsNorthwind.QueryDefs(0).Fields(0)
 Set fldRecordset = rstEmployees.Fields(0)
 Set fldRelation =dbsNorthwind.Relations(0).Fields(0)
 Set fldIndex = _
 dbsNorthwind.TableDefs(0).Indexes(0).Fields(0)

 ' Print report.
 FieldOutput "TableDef", fldTableDef
 FieldOutput "QueryDef", fldQueryDef
 FieldOutput "Recordset", fldRecordset
 FieldOutput "Relation", fldRelation
 FieldOutput "Index", fldIndex

 rstEmployees.Close
 dbsNorthwind.Close

End Sub

Sub FieldOutput(strTemp As String, fldTemp As Field)
 ' Report function for FieldX.

 Dim prpLoop As Property

 Debug.Print "Valid Field properties in " & strTemp

 ' Enumerate Properties collection of passed Field
 ' object.
 For Each prpLoop In fldTemp.Properties
 ' Some properties are invalid in certain
 ' contexts (the Value property in the Fields
 ' collection of a TableDef for example). Any
 ' attempt to use an invalid property will
 ' trigger an error.
 On Error Resume Next
 Debug.Print " " & prpLoop.Name & " = " & _
 prpLoop.Value
 On Error GoTo 0
 Next prpLoop

End Sub

This example uses the CreateField method to create three Fields for a new TableDef. It then displays the properties of those Field objects that are automatically set by the CreateField method. (Properties whose values are empty at the time of Field creation are not shown.)

VBA Copy code Copy code
Sub CreateFieldX()

 Dim dbsNorthwind As Database
 Dim tdfNew As TableDef
 Dim fldLoop As Field
 Dim prpLoop As Property

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 Set tdfNew = dbsNorthwind.CreateTableDef("NewTableDef")

 ' Create and append new Field objects for the new
 ' TableDef object.
 With tdfNew
 ' The CreateField method will set a default Size
 ' for a new Field object if one is not specified.
 .Fields.Append .CreateField("TextField", dbText)
 .Fields.Append .CreateField("IntegerField", dbInteger)
 .Fields.Append .CreateField("DateField", dbDate)
 End With

 dbsNorthwind.TableDefs.Append tdfNew

 Debug.Print "Properties of new Fields in " & tdfNew.Name

 ' Enumerate Fields collection to show the properties of
 ' the new Field objects.
 For Each fldLoop In tdfNew.Fields
 Debug.Print " " & fldLoop.Name

 For Each prpLoop In fldLoop.Properties
 ' Properties that are invalid in the context of
 ' TableDefs will trigger an error if an attempt
 ' is made to read their values.
 On Error Resume Next
 Debug.Print " " & prpLoop.Name & " - " & _
 IIf(prpLoop = "", "[empty]", prpLoop)
 On Error GoTo 0
 Next prpLoop

 Next fldLoop

 ' Delete new TableDef because this is a demonstration.
 dbsNorthwind.TableDefs.Delete tdfNew.Name
 dbsNorthwind.Close

End Sub


ExecuteComplete Event (ADO)

 Copy code hover
[image]

ExecuteComplete Event (ADO)
Send feedback

The ExecuteComplete event is called after a command has finished executing.

Syntax

ExecuteComplete RecordsAffected, pError, adStatus, pCommand, pRecordset, pConnection

Parameters

  • RecordsAffected

  • A Long value indicating the number of records affected by the command.

  • pError

  • An Error object. It describes the error that occurred if the value of adStatus is adStatusErrorsOccurred; otherwise it is not set.

  • adStatus

  • EventStatusEnum

    Before this event returns, set this parameter to adStatusUnwantedEvent to prevent subsequent notifications.

  • pCommand

  • The Command object that was executed. Contains a Command object even when calling Connection.Execute or Recordset.Open without explicitly creating a Command, in which cases the Command object is created internally by ADO.

  • pRecordset

  • A Recordset object that is the result of the executed command. This Recordset may be empty. You should never destroy this Recordset object from within this event handler. Doing so will result in an Access Violation when ADO tries to access an object that no longer exists.

  • pConnection

  • A Connection object. The connection over which the operation was executed.

Remarks

An ExecuteComplete event may occur due to the Connection. Execute, Command. Execute, Recordset. Open, Recordset. Requery, or Recordset. NextRecordset methods.


Locked table. (Error 3714)

 Copy code hover
[image]

Locked table. (Error 3714)
Send feedback

Re-synchronize the replicas when the lock is released on the table.


ObjectFrame.GridlineThemeColorIndex Property (Access)

 Copy code hover
[image]

ObjectFrame.GridlineThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineThemeColorIndex

expression A variable that represents an ObjectFrame object.

Remarks

The GridlineThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 (Default) | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the GridlineThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


CodeProject.Properties Property (Access)

 Copy code hover
[image]

CodeProject.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a CodeProject object's AccessObjectProperties collection. Read-only.

Syntax

expression .Properties

expression A variable that represents a CodeProject object.

Remarks

The AccessObjectProperties collection object is the collection of all the properties related to a CodeProject object. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the AccessObjectProperties collection's Count property minus 1

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


Application.IsCurrentWebUserInGroup Method (Access)

 Copy code hover
[image]

Application.IsCurrentWebUserInGroup Method (Access)
See also Send feedback

Published: July 16, 2012

Gets whether or not the current user of a Web databse is a member of the specified Microsoft SharePoint Foundation 2010 group.

Version Information

Version Added: Access 2010

Syntax

expression .IsCurrentWebUserInGroup(GroupNameOrID)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
GroupNameOrID | Required | Variant | The name or identifier (ID) of the group.

Return Value

Boolean

See also

Concepts

Application Object

Other resources

Application Object Members


Input and InputB Functions (Differences in String Function Operations)

 Copy code hover
[image]

Input and InputB Functions (Differences in String Function Operations)
Send feedback

Published: July 16, 2012

The memory storage formats for text differ between Visual Basic for Applications (VBA) code and Access Basic code. (Access Basic was used in early versions of Microsoft Access.) Text is stored in ANSI format within Access Basic code and in Unicode format in Visual Basic. This topic discusses one potential issue when handling strings in the current version of Microsoft Access. For more information, see Differences in String Function Operations.

The Input function in Microsoft Access converts the number of characters designated when the text is read from the file into a Unicode string and reads them as variables. The InputB function, on the other hand, assumes the data to be binary data and stores it as variables without converting it. If the InputB function is used when reading a file stored in a fixed length field, the fixed byte length data must be converted once it is read.

Copy code Copy code
Open "Data.Dat" For Input As 1
dat1 = StrConv(InputB(10, 1), vbUnicode)
dat2 = StrConv(InputB(10, 1), vbUnicode)
dat3 = StrConv(InputB(10, 1), vbUnicode)

===DATA.DAT
123456789012345678901234567
Name Address Telephone


Failure to execute the HTTP request. (Error 3677)

 Copy code hover
[image]

Failure to execute the HTTP request. (Error 3677)
Send feedback

Failed attempting to send a request to the internet server. The request could have been one of the following:

  • An attempt to open and read a file across the internet.

  • A request to delete a file across the internet.

  • An attempt to start the MSTRAI40.exe syncronization process on the internet server.


ComboBox.OnKeyDown Property (Access)

 Copy code hover
[image]

ComboBox.OnKeyDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Down box in the Properties window. Read/write String.

Syntax

expression .OnKeyDown

expression A variable that represents a ComboBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyDown event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyDown

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Invalid SQL Syntax: expected token: SELECT (Error 3729)

 Copy code hover
[image]

Invalid SQL Syntax: expected token: SELECT (Error 3729)
Send feedback

This error occurs when trying to create a view from SQL DDL. The following would generate this error: CREATE VIEW viewname AS. To avoid the error, use a valid SELECT statement after the AS keyword.


Delete Method Example (VJ++)

 Copy code hover
[image]

Delete Method Example (VJ++)
Send feedback

This example uses the Delete method to remove a specified record from a Recordset.

Copy code Copy code

// BeginDeleteJ
// The WFC class includes the ADO objects.

import com.ms.wfc.data.*;
import java.io.* ;

public class DeleteX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 DeleteX();
 System.exit(0);
 }

 // DeleteX function

 static void DeleteX()
 {

 // Define ADO Objects.
 Recordset rstRoySched = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String line = null;
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";

 String strMessage="";
 String strTitleID;
 int intLoRange =0;
 int intHiRange =0;
 int intRoyalty =0;
 boolean bolFound;

 try
 {
 rstRoySched = new Recordset();
 rstRoySched.setCursorLocation(AdoEnums.CursorLocation.CLIENT);
 rstRoySched.setCursorType(AdoEnums.CursorType.STATIC);
 rstRoySched.setLockType(AdoEnums.LockType.BATCHOPTIMISTIC);

 // Open RoySched table.
 rstRoySched.open("SELECT * FROM roysched " +
 "WHERE royalty = 20", strCnn,
 AdoEnums.CursorType.STATIC,
 AdoEnums.LockType.BATCHOPTIMISTIC,
 AdoEnums.CommandType.TEXT);

 // Prompt for a record to delete.
 strMessage = "Before delete there are "
 + rstRoySched.getRecordCount()
 + " titles with 20 percent royalty:" + "\n\n";
 while(!rstRoySched.getEOF())
 {
 strMessage += rstRoySched.getField("title_id").getString() +
 "\n\n";
 rstRoySched.moveNext();
 }
 strMessage += "Enter the ID of a record to delete:" + "\n";
 System.out.println(strMessage);
 strTitleID = in.readLine().trim().toUpperCase();

 // Move to the record and save data so it can be restored.
 rstRoySched.setFilter("title_id = '" + strTitleID + "'");
 if(!(rstRoySched.getRecordCount()==0))
 {
 intLoRange = rstRoySched.getField("lorange").getInt();
 intHiRange = rstRoySched.getField("hirange").getInt();
 intRoyalty = rstRoySched.getField("royalty").getInt();
 bolFound = true;
 }
 else
 {
 System.out.println("\nIncorrect ID. No Record deleted." );
 bolFound = false;
 }

 // Delete the record.
 if(bolFound)
 {
 rstRoySched.delete();
 rstRoySched.updateBatch();
 }
 // Show the results.
 rstRoySched.setFilter(new Integer(AdoEnums.FilterGroup.NONE));
 rstRoySched.requery();
 strMessage ="";
 strMessage = "\n\nAfter delete there are "
 + rstRoySched.getRecordCount()
 + " titles with 20 percent royalty:" + "\n\n";
 while(!rstRoySched.getEOF())
 {
 strMessage += rstRoySched.getField("title_id").getString() +
 "\n\n";
 rstRoySched.moveNext();
 }
 System.out.println(strMessage);
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();

 // Restore the data because this is a demonstration.
 if(bolFound)
 {
 rstRoySched.addNew();
 rstRoySched.getField("title_id").setString(strTitleID);
 rstRoySched.getField("lorange").setInt(intLoRange);
 rstRoySched.getField("hirange").setInt(intHiRange);
 rstRoySched.getField("royalty").setInt(intRoyalty);
 rstRoySched.updateBatch();
 }
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstRoySched != null)
 {
 PrintProviderError(rstRoySched.getActiveConnection());
 System.out.println("Exception: " + ae.getMessage());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }

 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstRoySched != null)
 if (rstRoySched.getState() == 1)
 rstRoySched.close();
 }

 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}

// EndDeleteJ


CodeProject.UpdateDependencyInfo Method (Access)

 Copy code hover
[image]

CodeProject.UpdateDependencyInfo Method (Access)
See also Send feedback

Published: July 16, 2012

Updates the dependency information for the database.

Syntax

expression .UpdateDependencyInfo

expression A variable that represents a CodeProject object.

Return Value

Nothing

Remarks

The UpdateDependencyInfo method opens, saves, and then closes every table, query, form, and report in the database; no messages are presented to the user.

This method will return a run-time error if any of the following conditions are true:

  • This method is being called from an Access project (.adp).

  • Any database objects are open.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


Recordset.Index Property (DAO)

 Copy code hover
[image]

Recordset.Index Property (DAO)
Send feedback

Sets or returns a value that indicates the name of the current Index object in a table-type Recordset object (Microsoft Access workspaces only).

Syntax

expression .Index

expression A variable that represents a Recordset object.

Remarks

Records in base tables aren't stored in any particular order. Setting the Index property changes the order of records returned from the database; it doesn't affect the order in which the records are stored.

The specified Index object must already be defined. If you set the Index property to an Index object that doesn't exist or if the Index property isn't set when you use the Seek method, a trappable error occurs.

Examine the Indexes collection of a TableDef object to determine what Index objects are available to table-type Recordset objects created from that TableDef object.

You can create a new index for the table by creating a new Index object, setting its properties, appending it to the Indexes collection of the underlying TableDef object, and then reopening the Recordset object.

Records returned from a table-type Recordset object can be ordered only by the indexes defined for the underlying TableDef object. To sort records in some other order, you can open a dynaset-, snapshot-, or forward-only-type Recordset object by using an SQL statement with an ORDER BY clause.

Note Note

  • You don't have to create indexes for tables. With large, unindexed tables, accessing a specific record or creating a Recordset object can take a long time. On the other hand, creating too many indexes slows down update, append, and delete operations because all indexes are automatically updated.

  • Records read from tables without indexes are returned in no particular sequence.

  • The Attributes property of each Field object in the Index object determines the order of records and consequently determines the access techniques to use for that index.

  • A unique index helps optimize finding records.

  • Indexes don't affect the physical order of a base table, indexes affect only how the records are accessed by the table-type Recordset object when a particular index is chosen or when Recordset is opened.

Example

This example uses the Index property to set different record orders for a table-type Recordset.

VBA Copy code Copy code
Sub IndexPropertyX()

   Dim dbsNorthwind As Database
   Dim tdfEmployees As TableDef
   Dim rstEmployees As Recordset
   Dim idxLoop As Index

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   Set rstEmployees = _
      dbsNorthwind.OpenRecordset("Employees")
   Set tdfEmployees = dbsNorthwind.TableDefs!Employees

   With rstEmployees

      ' Enumerate Indexes collection of Employees table.
      For Each idxLoop In tdfEmployees.Indexes
         .Index = idxLoop.Name
         Debug.Print "Index = " & .Index
         Debug.Print "  EmployeeID - PostalCode - Name"
         .MoveFirst

         ' Enumerate Recordset to show the order of records.
         Do While Not .EOF
            Debug.Print "    " & !EmployeeID & " - " & _
               !PostalCode & " - " & !FirstName & " " & _
               !LastName
            .MoveNext
         Loop

      Next idxLoop

      .Close
   End With

   dbsNorthwind.Close

End Sub

This example demonstrates the Seek method by allowing the user to search for a product based on an ID number.

VBA Copy code Copy code
Sub SeekX()

   Dim dbsNorthwind As Database
   Dim rstProducts As Recordset
   Dim intFirst As Integer
   Dim intLast As Integer
   Dim strMessage As String
   Dim strSeek As String
   Dim varBookmark As Variant

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   ' You must open a table-type Recordset to use an index,
   ' and hence the Seek method.
   Set rstProducts = _
      dbsNorthwind.OpenRecordset("Products", dbOpenTable)

   With rstProducts
      ' Set the index.
      .Index = "PrimaryKey"

      ' Get the lowest and highest product IDs.
      .MoveLast
      intLast = !ProductID
      .MoveFirst
      intFirst = !ProductID

      Do While True
         ' Display current record information and ask user
         ' for ID number.
         strMessage = "Product ID: " & !ProductID & vbCr & _
            "Name: " & !ProductName & vbCr & vbCr & _
            "Enter a product ID between " & intFirst & _
            " and " & intLast & "."
         strSeek = InputBox(strMessage)

         If strSeek = "" Then Exit Do

         ' Store current bookmark in case the Seek fails.
         varBookmark = .Bookmark

         .Seek "=", Val(strSeek)

         ' Return to the current record if the Seek fails.
         If .NoMatch Then
            MsgBox "ID not found!"
            .Bookmark = varBookmark
         End If
      Loop

      .Close
   End With

   dbsNorthwind.Close

End Sub

The following example shows how to use the Seek method to find a record in a linked table.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Sub TestSeek()
    ' Get the path to the external database that contains
    ' the tblCustomers table we're going to search.
    Dim strMyExternalDatabase
    Dim dbs    As DAO.Database
    Dim dbsExt As DAO.Database
    Dim rst    As DAO.Recordset
    Dim tdf    As DAO.TableDef

    Set dbs = CurrentDb()
    Set tdf = dbs.TableDefs("tblCustomers")
    strMyExternalDatabase = Mid(tdf.Connect, 11)

    'Open the database that contains the table that is linked
    Set dbsExt = OpenDatabase(strMyExternalDatabase)

    'Open a table-type recordset against the external table
    Set rst = dbsExt.OpenRecordset("tblCustomers", dbOpenTable)

    'Specify which index to search on
    rst.Index = "PrimaryKey"

    'Specify the criteria
    rst.Seek "=", 123

    'Check the result
    If rst.NoMatch Then
        MsgBox "Record not found."
    Else
        MsgBox "Customer name: " & rst!CustName
    End If

    rst.Close
    dbs.Close
    dbsExt.Close
    Set rst = Nothing
    Set tdf = Nothing
    Set dbs = Nothing

End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


CheckBox.OnEnter Property (Access)

 Copy code hover
[image]

CheckBox.OnEnter Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnEnter

expression A variable that represents a CheckBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Enter event occurs before a control actually receives the focus from a control on the same form.

The OnEnter value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Enter box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Enter box is blank, the property value is an empty string.

Example

The following example associates the Enter event with the macro "Enter_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnEnter = "Enter_Macro"

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


SubForm.CanShrink Property (Access)

 Copy code hover
[image]

SubForm.CanShrink Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the section or control contains. Read/write Boolean.

Syntax

expression .CanShrink

expression A variable that represents a SubForm object.

Remarks

The CanShrink property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The section or control shrinks vertically so that the data it contains can be printed or previewed without leaving blank lines.
No | False | (Default) The section or control doesn't shrink.

This property setting is read-only in a macro or Visual Basic in any view but Design view.

You can use this property to control the appearance of printed forms and reports. When you set the property to Yes, the object automatically adjusts so any amount of data can be printed. When a control shrinks, the controls below it move up the page.

If you set a control's CanShrink property to Yes, Microsoft Access does not set the section's CanShrink property to Yes.

Sections shrink vertically across their entire width. For example, suppose a form has two text boxes side by side in a section, and each control has its CanShrink property set to Yes. If one text box contains one line of data and the other text box contains two lines of data, both text boxes will be two lines long because the section is sized across its entire width. To shrink the data independently, you can place two subform or subreport controls side by side, and set their CanShrink property to Yes.

When you use the CanShrink property, remember that:

  • The property settings don't affect the horizontal spacing between controls; they affect only the vertical space the controls occupy.

  • Overlapping controls can't shrink.

  • The height of a large control can prevent controls beside it from shrinking. For example, if several short controls are on the left side of a report's detail section and one tall control, such as an unbound object frame, is on the right side, the controls on the left won't shrink, even if they contain no data.

Note Note

  • The CanShrink property does not apply to form or report page header and page footer sections, although it does apply to controls in such sections.

  • This property affects the display of form sections and controls only when the form is printed or previewed, not when the form is displayed in Form view, Datasheet view, or Design view.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


The Field Object

 Copy code hover
[image]

The Field Object
Send feedback

Each Field object usually corresponds to a column in a database table. However, a Field can also represent a pointer to another Recordset, called a chapter. Exceptions, such as chapter columns, will be covered later in this guide.

Use the Value property of Field objects to set or return data for the current record. Depending on the functionality the provider exposes, some collections, methods, or properties of a Field object may not be available.

With the collections, methods, and properties of a Field object, you can do the following:

  • Return the name of a field by using the Name property.

  • View or change the data in the field by using the Value property. Value is the default property of the Field object.

  • Return the basic characteristics of a field by using the Type, Precision, and NumericScale properties.

  • Return the declared size of a field by using the DefinedSize property.

  • Return the actual size of the data in a given field by using the ActualSize property.

  • Determine what types of functionality are supported for a given field by using the Attributes property and Properties collection.

  • Manipulate the values of fields containing long binary or long character data by using the AppendChunk and GetChunk methods.

Resolve discrepancies in field values during batch updating by using the OriginalValue and UnderlyingValue properties, if the provider supports batch updates.

Describing a Field

The topics that follow will discuss properties of the Field object that represent information that describes the Field object itself — that is, metadata about the field. This information can be used to determine much about the schema of the Recordset. These properties include Type, DefinedSize and ActualSize, Name, and NumericScale and Precision.

Discovering the Data Type

The Type property indicates the data type of the field. The data type enumerated constants that are supported by ADO are described in DataTypeEnum in the ADO Programmer's Reference.

For floating point numeric types such adNumeric, you can obtain more information. The NumericScale property indicates how many digits to the right of the decimal point will be used to represent values for the Field. The Precision property specifies the maximum number of digits used to represent values for the Field.

Determining Field Size

Use the DefinedSize property to determine the data capacity of a Field object.

Use the ActualSize property to return the actual length of a Field object's value. For all fields, the ActualSize property is read-only. If ADO cannot determine the length of the Field object's value, the ActualSize property returns adUnknown.

The DefinedSize and ActualSize properties have different purposes. For example, consider a Field object with a declared type of adVarChar and a DefinedSize property value of 50, containing a single character. The ActualSize property value it returns is the length in bytes of the single character.

Determining Field Contents

The identifier of the column from the data source is represented by the Name property of the Field. The Value property of the Field object returns or sets the actual data content of the field. This is the default property.

To change the data in a field, set the Value property equal to a new value of the correct type. Your cursor type must support updates to change the contents of a field. Database validation is not done here in batch mode, so you will need to check for errors when you call UpdateBatch in such a case. Some providers also support the ADO Field object's UnderlyingValue and OriginalValue properties to assist you with resolving conflicts when you attempt to perform batch updates. For details about how to resolve such conflicts, see Chapter 4: Editing Data.

Note Note

Recordset Field values cannot be set when appending new Fields to a Recordset. Rather, new Fields can be appended to a closed Recordset. Then the Recordset must be opened, and only then can values be assigned to these Fields.

Getting More Field Information

ADO objects have two types of properties: built-in and dynamic. To this point, only the built-in properties of the Field object have been discussed.

Built-in properties are those properties implemented in ADO and immediately available to any new object, using the syntax. They do not appear as Property objects in an object's Properties collection.

Dynamic properties are defined by the underlying data provider, and appear in the Properties collection for the appropriate ADO object. For example, a property specific to the provider may indicate if a Recordset object supports transactions or updating. These additional properties will appear as Property objects in that Recordset object's Properties collection. Dynamic properties can be referenced only through the collection, using the syntax MyObject.Properties(0) or or MyObject.Properties("Name") .

You cannot delete either kind of property.

A dynamic Property object has four built-in properties of its own:

  • The Name property is a string that identifies the property.

  • The Type property is an integer that specifies the property data type.

  • The Value property is a variant that contains the property setting. Value is the default property for a Property object.

  • The Attributes property is a Long value that indicates characteristics of the property specific to the provider.

The Properties collection for the Field object contains additional metadata about the field. The contents of this collection vary depending upon the provider. The following code example examines the Properties collection of the sample Recordset introduced at the beginning of this chapter. It first looks at the contents of the collection. This code uses the OLE DB Provider for SQL Server, so the Properties collection contains information relevant to that provider.

Copy code Copy code

'BeginFieldProps
 Dim objProp As ADODB.Property

 For intLoop = 0 To (objFields.Count - 1)
 Debug.Print objFields.Item(intLoop).Name

 For Each objProp In objFields(intLoop).Properties
 Debug.Print vbTab & objProp.Name & " = " & objProp.Value
 Next objProp
 Next intLoop
'EndFieldProps

Dealing with Binary Data

Use the AppendChunk method on a Field object to fill it with long binary or character data. In situations where system memory is limited, you can use the AppendChunk method to manipulate long values in portions rather than in their entirety.

If the adFldLong bit in the Attributes property of a Field object is set to True, you can use the AppendChunk method for that field.

The first AppendChunk call on a Field object writes data to the field, overwriting any existing data. Subsequent AppendChunk calls add to existing data. If you are appending data to one field and then you set or read the value of another field in the current record, ADO assumes that you are finished appending data to the first field. If you call the AppendChunk method on the first field again, ADO interprets the call as a new AppendChunk operation and overwrites the existing data. Accessing fields in other Recordset objects that are not clones of the first Recordset object will not disrupt AppendChunk operations.

Use the GetChunk method on a Field object to retrieve part or all of its long binary or character data. In situations where system memory is limited, you can use the GetChunk method to manipulate long values in portions, rather than in their entirety.

The data that a GetChunk call returns is assigned to variable. If Size is greater than the remaining data, the GetChunk method returns only the remaining data without padding variable with empty spaces. If the field is empty, the GetChunk method returns a null value.

Each subsequent GetChunk call retrieves data starting from where the previous GetChunk call left off. However, if you are retrieving data from one field and then set or read the value of another field in the current record, ADO assumes you have finished retrieving data from the first field. If you call the GetChunk method on the first field again, ADO interprets the call as a new GetChunk operation and starts reading from the beginning of the data. Accessing fields in other Recordset objects that are not clones of the first Recordset object will not disrupt GetChunk operations.

If the adFldLong bit in the Attributes property of a Field object is set to True, you can use the GetChunk method for that field.

If there is no current record when you use the GetChunk or AppendChunk method on a Field object, error 3021 (no current record) occurs.

For an example of using these methods to manipulate binary data, see the AppendChunk Method and GetChunk Method examples in the ADO Programmer's Reference.


ComboBox.SelStart Property (Access)

 Copy code hover
[image]

ComboBox.SelStart Property (Access)
See also Send feedback

Published: July 16, 2012

The SelStart property specifies or determines the starting point of the selected text or the position of the insertion point if no text is selected. Read/write Integer.

Syntax

expression .SelStart

expression A variable that represents a ComboBox object.

Remarks

The SelStart property uses an Integer in the range 0 to the total number of characters in the text box portion of a combo box.

To set or return this property for a control, the control must have the focus. To move the focus to a control, use the SetFocus method.

Changing the SelStart property cancels the selection, places an insertion point in the text, and sets the SelLength property to 0.

Example

The following example uses two event procedures to search for text specified by a user. The text to search is set in the form's Load event procedure. The Click event procedure for the Find button (which the user clicks to start the search) prompts the user for the text to search for and selects the text in the text box if the search is successful.

VBA Copy code Copy code
Private Sub Form_Load()

 Dim ctlTextToSearch As Control
 Set ctlTextToSearch = Forms!Form1!Textbox1

 ' SetFocus to text box.
 ctlTextToSearch.SetFocus
 ctlTextToSearch.Text = "This company places large orders twice " & _
 "a year for garlic, oregano, chilies and cumin."
 Set ctlTextToSearch = Nothing

End Sub

Public Sub Find_Click()

 Dim strSearch As String
 Dim intWhere As Integer
 Dim ctlTextToSearch As Control

 ' Get search string from user.
 With Me!Textbox1
 strSearch = InputBox("Enter text to find:")

 ' Find string in text.
 intWhere = InStr(.Value, strSearch)
 If intWhere Then
 ' If found.
 .SetFocus
 .SelStart = intWhere - 1
 .SelLength = Len(strSearch)
 Else
 ' Notify user.
 MsgBox "String not found."
 End If
 End With

End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Cannot create a relationship between a field and itself. (Error 3206)

 Copy code hover
[image]

Cannot create a relationship between a field and itself. (Error 3206)
Send feedback

You tried to create a relationship between a field and itself. Choose a different field for the primary or related table, and then try the operation again.


BoundObjectFrame.BorderStyle Property (Access)

 Copy code hover
[image]

BoundObjectFrame.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Syntax

expression .BorderStyle

expression A variable that represents a BoundObjectFrame object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Image.EventProcPrefix Property (Access)

 Copy code hover
[image]

Image.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents an Image object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

Image Object

Other resources

Image Object Members


SetReturnVar Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

SetReturnVar Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

The SetReturnVar action creates a return variable and sets it to a specific value.

Note Note

The SetReturnVar action is available only in Data Macros.

Setting

The SetReturnVar action has the following arguments.

Argument name | Required | Description
Name | Yes | A string that specifies the name of the variable.
Expression | Yes | An expression that will be used to set the value for this temporary variable. Do not precede the expression with the equal sign (=). You can click the Build button to use the Expression Builder to set this argument.

Remarks

The SetReturnVar action is used to create a ReturnVar, which is variable that can be used by macros that call a data macro by using the RunDataMacro action.

Once a ReturnVar is created by the SetReturnVar action, the calling macro can use it in an expression. For example, if you created a ReturnVar named UpdateSuccess, you could use the variable by using the following syntax:

Copy code Copy code
=[ReturnVars]![UpdateSuccess]

The SetReturnVar action can be used only in named data macros. It is not available in data macros that are attached to a data macro event.


Line.Top Property (Access)

 Copy code hover
[image]

Line.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Syntax

expression .Top

expression A variable that represents a Line object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

Line Object

Other resources

Line Object Members


NavigationControl.GridlineThemeColorIndex Property (Access)

 Copy code hover
[image]

NavigationControl.GridlineThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineThemeColorIndex

expression A variable that represents a NavigationControl object.

Remarks

The GridlineThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 (Default) | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the GridlineThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


NavigationButton.Height Property (Access)

 Copy code hover
[image]

NavigationButton.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .Height

expression A variable that represents a NavigationButton object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


ADO NumericScale and Precision Properties Example (VB)

 Copy code hover
[image]

ADO NumericScale and Precision Properties Example (VB)
Send feedback

This example uses the NumericScale and Precision properties to display the numeric scale and precision of fields in the Discounts table of the Pubs database.

Copy code Copy code

'BeginNumericScaleVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 ' connection and recordset variables
 Dim rstDiscounts As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim fldTemp As ADODB.Field
 Dim strCnxn As String
 Dim strSQLDiscounts As String

 ' Open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open recordset
 Set rstDiscounts = New ADODB.Recordset
 strSQLDiscounts = "Discounts"
 rstDiscounts.Open strSQLDiscounts, Cnxn, adOpenStatic, adLockReadOnly, adCmdTable

 ' Display numeric scale and precision of
 ' numeric and small integer fields
 For Each fldTemp In rstDiscounts.Fields
 If fldTemp.Type = adNumeric Or fldTemp.Type = adSmallInt Then
 MsgBox "Field: " & fldTemp.Name & vbCr & _
 "Numeric scale: " & _
 fldTemp.NumericScale & vbCr & _
 "Precision: " & fldTemp.Precision
 End If
 Next fldTemp

 ' clean up
 rstDiscounts.Close
 Cnxn.Close
 Set rstDiscounts = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstDiscounts Is Nothing Then
 If rstDiscounts.State = adStateOpen Then rstDiscounts.Close
 End If
 Set rstDiscounts = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If

End Sub
'EndNumericScaleVB


ListBox.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

ListBox.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified list box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthLeft

expression A variable that represents a ListBox object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Section.OnFormat Property (Access)

 Copy code hover
[image]

Section.OnFormat Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Format box in the Properties window of a report section. Read/write String.

Syntax

expression .OnFormat

expression A variable that represents a Section object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Format event occurs when Microsoft Access determines which data belongs in a report section, but before Access formats the section for previewing or printing.

The OnFormat value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Format box in the report section's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Format box is blank, the property value is an empty string.

Example

The following example prints the value of the OnFormat property in the Immediate window for the "GroupHeader0" section in the "Purchase Order" report.

VBA Copy code Copy code
Debug.Print Reports("Purchase Order").Section("GroupHeader0").OnFormat

See also

Concepts

Section Object

Other resources

Section Object Members


Form.Recalc Method (Access)

 Copy code hover
[image]

Form.Recalc Method (Access)
See also Send feedback

Published: July 16, 2012

The Recalc method immediately updates all calculated controls on a form.

Syntax

expression .Recalc

expression A variable that represents a Form object.

Return Value

Nothing

Remarks

Using this method is equivalent to pressing the F9 key when a form has the focus. You can use this method to recalculate the values of controls that depend on other fields for which the contents may have changed.

Example

The following example uses the Recalc method to update controls on an Orders form. This form includes the Freight text box, which displays the freight cost, and a calculated control that displays the total cost of an order including freight. If the statement containing the Recalc method is placed in the AfterUpdate event procedure for the Freight text box, the total cost of an order is recalculated every time a new freight amount is entered.

VBA Copy code Copy code
Sub Freight_AfterUpdate()
 Me.Recalc
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Mode Property (ADO)

 Copy code hover
[image]

Mode Property (ADO)
Send feedback

Indicates the available permissions for modifying data in a Connection, Record, or Stream object.

Settings and Return Values

Sets or returns a ConnectModeEnum value. The default value for a Connection is adModeUnknown. The default value for a Record object is adModeRead. The default value for a Stream associated with an underlying source (opened with a URL as the source, or as the default Stream of a Record) is adModeRead. The default value for a Stream not associated with an underlying source (instantiated in memory) is adModeUnknown.

Remarks

Use the Mode property to set or return the access permissions in use by the provider on the current connection. You can set the Mode property only when the Connection object is closed.

For a Stream object, if the access mode is not specified, it is inherited from the source used to open the Stream object. For example, if a Stream is opened from a Record object, by default it is opened in the same mode as the Record.

This property is read/write while the object is closed and read-only while the object is open.

Remote Data Service UsageWhen used on a client-side Connection object, the Mode property can only be set to adModeUnknown.


CREATE USER or GROUP Statement (Microsoft Access SQL)

 Copy code hover
[image]

CREATE USER or GROUP Statement (Microsoft Access SQL)
Send feedback

Creates one or more new users or groups.

Syntax

Create a user:

CREATE USER user password pid [, user password pid, …]

Create a group:

CREATE GROUP group pid[, group pid, …]

The CREATE USER or GROUP statement has these parts:

Part | Description
user | The name of a user to be added to the workgroup information file.
group | The name of a group to be added to the workgroup information file.
password | The password to be associated with the specified user name.
pid | The personal id.

Remarks

A user and a group cannot have the same name.

A password is required for each user or group that is created.


View Object (ADOX) Reference

 Copy code hover
[image]

View Object (ADOX) Reference
Send feedback

In this section

  • View Object (ADOX)

  • View Properties, Methods, and Events (ADOX)


Parent Property (ADO MD)

 Copy code hover
[image]

Parent Property (ADO MD)
Send feedback

Indicates the member that is the parent of the current member in a hierarchy.

Return Values

Returns a Member object and is read-only.

Remarks

A member that is at the top level of a hierarchy (the root) has no parent. This property is supported only on Member objects belonging to a Level object. An error occurs when this property is referenced from Member objects belonging to a Position object.


Invalid PageTimeout setting in the Windows Registry. (Error 3249)

 Copy code hover
[image]

Invalid PageTimeout setting in the Windows Registry. (Error 3249)
Send feedback

There is an invalid PageTimeout setting in the Microsoft Windows Registry.

To complete this operation

  1. Exit your application.

  2. Start the Registry Editor, and navigate to the PageTimeout value. Depending on which installable ISAM you are trying to use, the invalid entry is in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Access Connectivity Engine\Engines\Xbase key.

  3. On the Edit menu, click Modify.

  4. Specify a new value in the Value data box.

  5. Restart your application, and then try the operation again.


DoCmd.ShowToolbar Method (Access)

 Copy code hover
[image]

DoCmd.ShowToolbar Method (Access)
See also Send feedback

Published: July 16, 2012

The ShowToolbar method carries out the ShowToolbar action in Visual Basic.

Syntax

expression .ShowToolbar(ToolbarName, Show)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
ToolbarName | Required | Variant | A string expression that's the valid name of a custom toolbar you've created. If you run Visual Basic code containing the ShowToolbar method in a library database, Microsoft Access looks for the toolbar with this name first in the library database, then in the current database.
Show | Optional | AcShowToolbar | A AcShowToolbar constant that specifies whether to display or hide the toolbar and in which views to display or hide it. The default value is acToolbarYes.

Remarks

You can use the ShowToolbar method to display or hide a custom toolbar.

If you want to show a particular toolbar on just one form or report, you can set the OnActivate property of the form or report to the name of a macro that contains a ShowToolbar action to show the toolbar. Then set the OnDeactivate property of the form or report to the name of a macro that contains a ShowToolbar action to hide the toolbar.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Troubleshooting

 Copy code hover
[image]

Troubleshooting
Send feedback

When you have trouble with MDAC technologies, try the following resources to get help before calling Microsoft Product Support Services.

  • MDAC Technical Articles You can find a number of technical articles pertaining to MDAC in the Platform SDK.

  • Web Sites The Universal Data Access Web site and MSDN Library provide articles and technical information that may help you.

  • Microsoft Knowledge Base The articles in this database provide specific solutions, workarounds, and pertinent information about the Microsoft Data Access Components.

  • Public newsgroups: microsoft.public.data.ado and others.


Application.RefreshDatabaseWindow Method (Access)

 Copy code hover
[image]

Application.RefreshDatabaseWindow Method (Access)
See also Send feedback

Published: July 16, 2012

The RefreshDatabaseWindow method updates the Database window after a database object has been created, deleted, or renamed.

Syntax

expression .RefreshDatabaseWindow

expression A variable that represents an Application object.

Return Value

Nothing

Remarks

You can use the RefreshDatabaseWindow method to immediately reflect changes to objects in Microsoft Access in the Database window. For example, if you add a new form from Visual Basic and save it, you can use the RefreshDatabaseWindow method to display the name of the new form on the Forms tab of the Database window immediately after it has been saved.

Example

The following example creates a new form, saves it, and refreshes the Database window:

VBA Copy code Copy code
Sub CreateFormAndRefresh()
 Dim frm As Form

 Set frm = CreateForm
 DoCmd.Save , "NewForm"
 RefreshDatabaseWindow
End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


Application.Name Property (Access)

 Copy code hover
[image]

Application.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.

Syntax

expression .Name

expression A variable that represents an Application object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

Application Object

Other resources

Application Object Members


Using ActiveX Data Objects

 Copy code hover
[image]

Using ActiveX Data Objects
Send feedback

Microsoft Access provides three object models to use in the creation, maintaining and managing of your Access databases and their related data by using Visual Basic.

Microsoft ActiveX Data Objects (ADO)

ADO contains the objects needed to create, maintain, and delete records in a given datasource.

Microsoft ADO Ext. for DDL and Security (ADOX)

ADOX provides the Data Definition Language(DDL) objects needed to create a new database and its contained objects in addition to the objects needed to manage security.

Microsoft Jet and Replication Objects 2.5 Library (JRO)

Since ADO objects were designed to work with many databases in addition to Microsoft Jet databases, functionality specific to Jet was broken out into the JRO library.

The following table lists the functionality provided by each compared to DAO.

Functionality | DAO | ADO1 | ADOX2 | JRO (MDB's Only)
Create Recordsets | X | X |  |
Edit Startup properties | X | X** |  |
Support ANSI92 SQL*** |  | X | X |
Create Tables | X |  | X |
Create New Database | X |  | X* |
Edit Existing Table properties | X |  | X |
Create table relationships | X |  | X* |
Edit security settings | X |  | X* |
Support for Compression attribute for column data |  |  | X |
Edit stored, basic SQL queries or views | X |  | X* |
Create permanent queries that are accessible only through code. |  |  | X* |
Create queries accessible through database container/UI and code. | X |  |  |
Compact/Encode database | X |  |  | X4
Refresh Cache | X |  |  | X
Make Database Replicable | X |  |  | X3
Make Database Replicas | X |  |  | X3
Synchronize Replicas | X |  |  | X3
Edit Database properties | X |  |  |
Create custom database properties | X |  |  |
Edit table column properties | X |  |  |

* Only available when working with Microsoft Access databases. Future versions of the SQL Provider may provide this functionality in Microsoft Access projects (.adp).

** Only available when working with Access projects.

*** Though the Access database engine does support some ANSI 92 SQL it is not yet fully ANSI92 compliant.

1 Uses Connection object to reference to database

2 Uses Catalog object to reference database

3 Uses Replica object to reference database

4 Uses JetEngine object to reference database

Note Note

Unlike DAO, ADO and ADOX objects can perform the marked actions in databases other then Jet as long as the provider for those databases supports that action.


SmartTagActions.Parent Property (Access)

 Copy code hover
[image]

SmartTagActions.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a SmartTagActions object.

See also

Concepts

SmartTagActions Collection

Other resources

SmartTagActions Object Members


Error (ADO for Visual C++ Syntax)

 Copy code hover
[image]

Error (ADO for Visual C++ Syntax)
Send feedback

Properties

            get_Description(BSTR *pbstr)

get_NativeError(long *pl)

get_Number(long *pl)

get_Source(BSTR *pbstr)

get_SQLState(BSTR *pbstr)


BoundObjectFrame.Controls Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Syntax

expression .Controls

expression A variable that represents a BoundObjectFrame object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


NavigationButton.Caption Property (Access)

 Copy code hover
[image]

NavigationButton.Caption Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the text that appears in the control. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .Caption

expression A variable that represents a NavigationButton object.

Remarks

The Caption property is a string expression that can contain up to 2,048 characters.

If you don't set a caption for a form, button, or label, Microsoft Access will assign the object a unique name based on the object, such as "Form1".

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


NavigationControl.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

NavigationControl.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleLeft

expression A variable that represents a NavigationControl object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Application.CreateAccessProject Method (Access)

 Copy code hover
[image]

Application.CreateAccessProject Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the CreateAccessProject method to create a new Microsoft Access project (.adp) on disk.

Syntax

expression .CreateAccessProject(filepath, Connect)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
filepath | Required | String | A string expression that is the name of the new Access project, including the path name and the file name extension. If your network supports it, you can also specify a network path in the following form: \\Server\Share\Folder\Filename.adp
Connect | Optional | Variant | A string expression that's the valid connection string for the Access project. See the ADO ConnectionString property for details about this string.

Return Value

Nothing

Remarks

The CreateAccessProject method enables you to create a new Access project from within Microsoft Access or another application through Automation, formally called OLE Automation. For example, you can use the CreateAccessProject method from Microsoft Excel to create a new Access project on disk. Once you have created an instance of Microsoft Access from another application, you must also create a new Access project.

If the Access project identified by projname already exists, an error occurs.

To create and open a new Access project as the current Access project in the Access window, use the NewAccessProject method of the Application object.

To open an existing Access project as the current Access project in the Access window, use the OpenAccessProject method of the Application object.

Example

The following example creates a Microsoft Access project named "Order Entry.adp" on drive C.

VBA Copy code Copy code
Application.CreateAccessProject "C:\Order Entry.adp"

See also

Concepts

Application Object

Other resources

Application Object Members


Writing Your Own Customized Handler

 Copy code hover
[image]

Writing Your Own Customized Handler
Send feedback

You may want to write your own handler if you are an IIS server administrator who wants the default RDS support, but more control over user requests and access rights.

The MSDFMAP.Handler implements the IDataFactoryHandler interface.

IDataFactoryHandler Interface

This interface has two methods, GetRecordset and Reconnect. Both methods require that the CursorLocation property be set to adUseClient.

Both methods take arguments that appear after the first comma in the "Handler=" keyword. For example, "Handler=progid,arg1,arg2;" will pass an argument string of "arg1,arg2" , and will pass an argument string of "arg1,arg2" , and "Handler=progid" will pass a null argument.

GetRecordset Method

This method queries the data source and creates a new Recordset object using the arguments provided. The Recordset must be opened with adLockBatchOptimistic and must not be opened asynchronously.

Arguments

conn The connection string.

args The arguments for the handler.

query The command text for making a query.

ppRS The pointer where the Recordset should be returned.

Reconnect Method

This method updates the data source. It creates a new Connection object and attaches the given Recordset.

Arguments

conn The connection string.

args The arguments for the handler.

pRS A Recordset object.

msdfhdl.idl

This is the interface definition for IDataFactoryHandler that appears in the msdfhdl.idl file.

Copy code Copy code

[
  uuid(D80DE8B3-0001-11d1-91E6-00C04FBBBFB3),
  version(1.0)
]
library MSDFHDL
{
    importlib("stdole32.tlb");
    importlib("stdole2.tlb");

    // TLib : Microsoft ActiveX Data Objects 2.0 Library
    // {00000200-0000-0010-8000-00AA006D2EA4}
    #ifdef IMPLIB
    importlib("implib\\x86\\release\\ado\\msado15.dll");
    #else
    importlib("msado20.dll");
    #endif

    [
      odl,
      uuid(D80DE8B5-0001-11d1-91E6-00C04FBBBFB3),
      version(1.0)
    ]
    interface IDataFactoryHandler : IUnknown
    {
HRESULT _stdcall GetRecordset(
      [in] BSTR conn,
      [in] BSTR args,
      [in] BSTR query,
      [out, retval] _Recordset **ppRS);

// DataFactory will use the ActiveConnection property
// on the Recordset after calling Reconnect.
   HRESULT _stdcall Reconnect(
      [in] BSTR conn,
      [in] BSTR args,
      [in] _Recordset *pRS);
    };
};


Image.BackTint Property (Access)

 Copy code hover
[image]

Image.BackTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackTint

expression A variable that represents an Image object.

Remarks

The BackTint property contains a numeric expression that can be used to lighten the theme color in the BackColor property. The default value of the BackTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackTint=25

See also

Concepts

Image Object

Other resources

Image Object Members


Parameter.Type Property (DAO)

 Copy code hover
[image]

Parameter.Type Property (DAO)
Send feedback

Sets or returns a value that indicates the operational type or data type of an object. Read/write Integer.

Syntax

expression .Type

expression A variable that represents a Parameter object.

Remarks

The setting or return value is a constant that indicates an operational or data type. For a Parameter object in a Microsoft Access workspace the property is read-only.

For a Parameter object, the possible settings and return values are described in the following table.

Constant | Description
dbBigInt | Big Integer
dbBinary | Binary
dbBoolean | Boolean
dbByte | Byte
dbChar | Char
dbCurrency | Currency
dbDate | Date/Time
dbDecimal | Decimal
dbDouble | Double
dbFloat | Float
dbGUID | GUID
dbInteger | Integer
dbLong | Long
dbLongBinary | Long Binary (OLE Object)
dbMemo | Memo
dbNumeric | Numeric
dbSingle | Single
dbText | Text
dbTime | Time
dbTimeStamp | Time Stamp
dbVarBinary | VarBinary

When you append a new Field, Parameter, or Property object to the collection of an Index, QueryDef, Recordset, or TableDef object, an error occurs if the underlying database doesn't support the data type specified for the new object.


ObjectFrame.BackShade Property (Access)

 Copy code hover
[image]

ObjectFrame.BackShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackShade

expression A variable that represents an ObjectFrame object.

Remarks

The BackShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the BackShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackShade=25

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


ADO for Visual C++ Syntax Index with #import

 Copy code hover
[image]

ADO for Visual C++ Syntax Index with #import
Send feedback

This index is a cross-reference to the ADO Language Reference based on Microsoft Visual C++ and the #import directive.

This particular index was derived by compiling a program with the #import directive against the ADO .dll, then reformatting the *.tlh file that was generated. Only information about methods, properties, and events was preserved. The alternative syntax declared for each property is listed by the corresponding "" directive.

You are strongly encouraged to read Visual C++ ADO Programming for more information.

Method and property syntax in Visual C++ with the #import directive is listed for the following elements:

  • ADO Collections

  • Command Object

  • Connection Object

  • Error Object

  • Field Object

  • Parameter Object

  • Property object

  • Record Object

  • Recordset Object

  • Stream Object

  • Connection Events

  • Recordset Events


REVOKE Statement (Microsoft Access SQL)

 Copy code hover
[image]

REVOKE Statement (Microsoft Access SQL)
Send feedback

Revokes specific privileges from an existing user or group.

Syntax

REVOKE {privilege[, privilege, …]} ON {TABLE table | OBJECT object|

CONTAINTER container} FROM {authorizationname[, authorizationname, …]}

The REVOKE statement has these parts:

Part | Description
privilege | The privilege or privileges to be revoked. Privileges are specified using the following keywords: SELECT, DELETE, INSERT, UPDATE, DROP, SELECTSECURITY, UPDATESECURITY, DBPASSWORD, UPDATEIDENTITY, CREATE, SELECTSCHEMA, SCHEMA and UPDATEOWNER.
table | Any valid table name.
object | This can encompass any non-table object. A stored query (view or procedure) is one example.
container | The name of a valid container.
authorizationname | A user or group name.


While loading the Microsoft Excel installable ISAM, OLE was unable to initialize. (Error 3430)

 Copy code hover
[image]

While loading the Microsoft Excel installable ISAM, OLE was unable to initialize. (Error 3430)
Send feedback

OLE Automation was unable to initialize while loading the Microsoft Excel installable ISAM. Try reinstalling the OLE DLL files.


ComboBox.Enabled Property (Access)

 Copy code hover
[image]

ComboBox.Enabled Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.

Syntax

expression .Enabled

expression A variable that represents a ComboBox object.

Remarks

The Enabled property setting is a value that indicates whether the conditional format is enabled or disabled. True enables the conditional format. False disables the conditional format. The default is True.

When the Enabled property is True, the conditional format can be displayed in the Conditional Formatting dialog box.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


NavigationButton.PressedForeTint Property (Access)

 Copy code hover
[image]

NavigationButton.PressedForeTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .PressedForeTint

expression A variable that represents a NavigationButton object.

Remarks

The PressedForeTint property contains a numeric expression that can be used to lighten the theme color in the PressedForeColor property. The default value of the PressedForeTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


AcWindowMode Enumeration (Access)

 Copy code hover
[image]

AcWindowMode Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the mode in which a form or report is opened.

Name | Value | Description
acDialog | 3 | The form or report's Modal and PopUp properties are set to Yes.
acHidden | 1 | The form or report is hidden.
acIcon | 2 | The form or report opens minimized in the Windows taskbar.
acWindowNormal | 0 | (Default) The form or report opens in the mode set by its properties.


ADOX API Reference

 Copy code hover
[image]

ADOX API Reference
Send feedback

This section of the ADOX documentation contains topics for each ADOX object, collection, method, and property, as well as example code when appropriate. For more information, search for a specific topic in the index or refer to the following topics:

  • ADOX Objects

  • ADOX Collections

  • ADOX Properties

  • ADOX Methods

  • ADOX Enumerated Constants

  • ADOX Code Examples


Binary column

 Copy code hover
[image]

Binary column <name> cannot be used in a Boolean filter. (Error 3658)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for more information.


Report.ActiveControl Property (Access)

 Copy code hover
[image]

Report.ActiveControl Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ActiveControl property together with the Screen object to identify or refer to the control that has the focus. Read-only Control object.

Syntax

expression .ActiveControl

expression A variable that represents a Report object.

Remarks

This property setting contains a reference to the Control object that has the focus at run time.

You can use the ActiveControl property to refer to the control that has the focus at run time together with one of its properties or methods. The following example assigns the name of the control with the focus to the strControlName variable.

VBA Copy code Copy code
Dim ctlCurrentControl As Control
Dim strControlName As String
Set ctlCurrentControl = Screen.ActiveControl
strControlName = ctlCurrentControl.Name

If no control has the focus when you use the ActiveControl property, or if all of the active form's controls are hidden or disabled, an error occurs.

Example

The following example assigns the active control to the ctlCurrentControl variable and then takes different actions depending on the value of the control's Name property.

VBA Copy code Copy code
Dim ctlCurrentControl As Control

Set ctlCurrentControl = Screen.ActiveControl
If ctlCurrentControl.Name = "txtCustomerID" Then
 .
 . ' Do something here.
 .
ElseIf ctlCurrentControl.Name = "btnCustomerDetails" Then
 .
 . ' Do something here.
 .
End If

See also

Concepts

Report Object

Other resources

Report Object Members


NavigationButton.SetFocus Method (Access)

 Copy code hover
[image]

NavigationButton.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Version Information

Version Added: Access 2010

Syntax

expression .SetFocus

expression A variable that represents a NavigationButton object.

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.

Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.

Example

The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:

VBA Copy code Copy code
Forms!Employees!EmployeeID.SetFocus

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Allow Multiple Values Property

 Copy code hover
[image]

Allow Multiple Values Property
Send feedback

Published: July 16, 2012

Specify whether the lookup column employs a multivalued field and allows multiple values to be selected.


ToggleButton.PressedShade Property (Access)

 Copy code hover
[image]

ToggleButton.PressedShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the PressedColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .PressedShade

expression A variable that represents a ToggleButton object.

Remarks

The PressedShade property contains a numeric expression that can be used to darken the theme color in the PressedColor property. The default value of the PressedShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


SmartTag.IsMissing Property (Access)

 Copy code hover
[image]

SmartTag.IsMissing Property (Access)
See also Send feedback

Published: July 16, 2012

Returns True if the specified smart tag is not installed or is installed incorrectly. Read-only Boolean.

Syntax

expression .IsMissing

expression A variable that represents a SmartTag object.

See also

Concepts

SmartTag Object

Other resources

SmartTag Object Members


NavigationButton.VerticalAnchor Property (Access)

 Copy code hover
[image]

NavigationButton.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified text box is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2010

Syntax

expression .VerticalAnchor

expression A variable that represents a NavigationButton object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


NavigationButton.BackTint Property (Access)

 Copy code hover
[image]

NavigationButton.BackTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackTint

expression A variable that represents a NavigationButton object.

Remarks

The BackTint property contains a numeric expression that can be used to lighten the theme color in the BackColor property. The default value of the BackTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackTint=25

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


ADO/WFC

 Copy code hover
[image]

ADO/WFC
Send feedback

ADO for Windows Foundation Classes (ADO/WFC) builds on the ADO event model and presents a simplified application programming interface. In general, ADO/WFC intercepts ADO events, consolidates the event parameters into a single event class, and then calls your event handler.

To use ADO events in ADO/WFC

  1. Define your own event handler to process an event. For example, if you wanted to process the ConnectComplete event in the ConnectionEvent family, you might use this code:

    Copy code Copy code

public void onConnectComplete(Object sender,ConnectionEvent e)
{
    System.out.println("onConnectComplete:" + e);
}

  2. Define a handler object to represent your event handler. The handler object should be of data type ConnectEventHandler for an event of type ConnectionEvent, or data type RecordsetEventHandler for an event of type RecordsetEvent. For example, code the following for your ConnectComplete event handler:

    Copy code Copy code
    ConnectionEventHandler handler =
        new ConnectionEventHandler(this, "onConnectComplete");

    The first argument of the ConnectionEventHandler constructor is a reference to the class that contains the event handler named in the second argument. The Microsoft Visual J++ compiler also supports an equivalent syntax:

    Copy code Copy code

    ConnectionEventHandler handler =
        new ConnectionEventHandler(this, "onConnectComplete");
    Copy code Copy code

    ConnectionEventHandler handler =
        new ConnectionEventHandler(this.onConnectComplete);

    The first argument of the ConnectionEventHandler constructor is a reference to the class that contains the event handler named in the second argument. The Microsoft Visual J++ compiler also supports an equivalent syntax:

    Copy code Copy code

    ConnectionEventHandler handler =
        new ConnectionEventHandler(this.onConnectComplete);

    The single argument is a reference to the desired class (this) and method within the class (onConnectComplete).

  3. Add your event handler to a list of handlers designated to process a particular type of event. Use the method with a name such as addOn EventName(handler).

  4. ADO/WFC internally implements all the ADO event handlers. Therefore, an event caused by a Connection or Recordset operation is intercepted by an ADO/WFC event handler. The ADO/WFC event handler passes ADO ConnectionEvent parameters in an instance of the ADO/WFC ConnectionEvent class, or ADO RecordsetEvent parameters in an instance of the ADO/WFC RecordsetEvent class. These ADO/WFC classes consolidate the ADO event parameters; that is, each ADO/WFC class contains one data member for each unique parameter in all the ADO ConnectionEvent or RecordsetEvent methods.

  5. ADO/WFC then calls your event handler with the ADO/WFC event object. For example, your onConnectComplete handler has a signature like this:

    Copy code Copy code

    public void onConnectComplete(Object sender,ConnectionEvent e)

    The first argument is the type of object that sent the event (Connection or Recordset), and the second argument is the ADO/WFC event object (ConnectionEvent or RecordsetEvent). The signature of your event handler is simpler than an ADO event. However, you must still understand the ADO event model to know what parameters apply to an event and how to respond.

  6. Return from your event handler to the ADO/WFC handler for the ADO event. ADO/WFC copies pertinent ADO/WFC event data members back to the ADO event parameters, and then the ADO event handler returns.

  7. When you are finished processing, remove your handler from the list of ADO/WFC event handlers. Use the method with a name such as removeOn EventName(handler).


Form.OnKeyDown Property (Access)

 Copy code hover
[image]

Form.OnKeyDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Down box in the Properties window. Read/write String.

Syntax

expression .OnKeyDown

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyDown event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyDown

See also

Concepts

Form Object

Other resources

Form Object Members


Report Members (Access)

 Copy code hover
[image]

Report Members (Access)
Send feedback

Published: July 16, 2012

A Report object refers to a particular Microsoft Access report.

Events

Name | Description
Activate | The Activate event occurs when a report receives the focus and becomes the active window.
ApplyFilter | Occurs when a filter is applied to a report.
Click | The Click event occurs when the user presses and then releases a mouse button over a report.
Close | The Close event occurs when a report is closed and removed from the screen.
Current | Occurs when the focus moves to a record, making it the current record, or when the report is refreshed or requeried.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an report within the double-click time limit of the system.
Deactivate | The Deactivate event occurs when a report loses the focus to a Table, Query, Form, Report, Macro, or Module window, or to the Database window.
Error | The Error event occurs when a run-time error is produced in Microsoft Access when a report has the focus.
Filter | Occurs when the user opens a filter window by clicking Advanced Filter/Sort.
GotFocus | The GotFocus event occurs when the report receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a report has the focus. This event also occurs if you send a keystroke to a report by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a report has the focus. This event also occurs if you send an ANSI keystroke to a report by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a report has the focus. This event also occurs if you send a keystroke to a report by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
Load | Occurs when a report is opened and its records are displayed.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.
MouseWheel | Occurs when the user rolls the mouse wheel in Report view or Layout view.
NoData | The NoData event occurs after Microsoft Access formats a report for printing that has no data (the report is bound to an empty recordset), but before the report is printed. You can use this event to cancel printing of a blank report.
Open | The Open occurs before a report is previewed or printed.
Page | The Page event occurs after Microsoft Access formats a page of a report for printing, but before the page is printed. You can use this event to draw a border around the page, or add other graphic elements to the page.
Resize | The Resize event occurs when a report is opened and whenever the size of a report changes.
Timer | The Timer event occurs for a report at regular intervals as specified by the report's TimerInterval property.
Unload | The Unload event occurs after a report is closed but before it's removed from the screen.

Methods

Name | Description
Circle | The Circle method draws a circle, an ellipse, or an arc on a Report object when the Print event occurs.
Line | The Line method draws lines and rectangles on a Report object when the Print event occurs.
Move | Moves the specified object to the coordinates specified by the argument values.
Print | The Print method prints text on a Report object using the current color and font.
PSet | The PSet method sets a point on a Report object to a specified color when the Print event occurs.
Requery | The Requery method updates the data underlying the specified report by requerying the source of data for the control.
Scale | The Scale method defines the coordinate system for a Report object.
TextHeight | The TextHeight method returns the height of a text string as it would be printed in the current font of a Report object.
TextWidth | The TextWidth method returns the width of a text string as it would be printed in the current font of a Report object.

Properties

Name | Description
ActiveControl | You can use the ActiveControl property together with the Screen object to identify or refer to the control that has the focus. Read-only Control object.
AllowLayoutView | Gets or sets whether the specified report can be used in Layout View. Read/write Boolean.
AllowReportView | Gets or sets whether the user is allowed to enter Report view while using the specified report. Read/write Boolean.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoCenter | Returns or sets a Boolean indicating whether a report will be centered automatically in the application window when the form is opened. Read/write.
AutoResize | Returns or sets a Boolean indicating whether a Report window opens automatically sized to display complete records. Read/write.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
Caption | Gets or sets the title of the report in Print Preview. Read/write String.
CloseButton | Specifies whether the Close button on a form is enabled. Read/write Boolean.
ControlBox | Specifies whether a report has a Control menu in Report view. Read/write Boolean.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Integer.
CurrentRecord | You can use the CurrentRecord property to identify the current record in the recordset being viewed. Read/write Long.
CurrentView | You can use the CurrentView property to determine how a report is currently displayed. Read/write Integer.
CurrentX | You can use the CurrentX property (along with the CurrentY property) to specify the horizontal and vertical coordinates for the starting position of the next printing and drawing method on a report. Read/write Single.
CurrentY | You can use the CurrentY property (along with the CurrentX property) to specify the horizontal and vertical coordinates for the starting position of the next printing and drawing method on a report. Read/write Single.
Cycle | You can use the Cycle property to specify what happens when you press the TAB key and the focus is in the last control on a report. Read/write Byte.
DateGrouping | You can use the DateGrouping property to specify how you want to group dates in a report. Read/write Byte.
DefaultControl | The DefaultControl property returns a Control object with which you can set the default properties for a particular type of control on a particular report. Read-only.
DefaultView | You can use the DefaultView property to specify the opening view of a report. Read/write Byte.
Dirty | You can use the Dirty property to determine whether the current record has been modified since it was last saved. Read/write Boolean.
DisplayOnSharePointSite | Gets or sets whether the specified report can be made available as a view on a Microsoft SharePoint Foundation site. Read/write Byte.
DrawMode | You can use the DrawMode property to specify how the pen (the color used in drawing) interacts with existing background colors on a report when the Line , Circle , or Pset method is used to draw on a report when printing. Read/write Integer.
DrawStyle | You can use the DrawStyle property to specify the line style when using the Line and Circle methods to print lines on reports. Read/write Integer.
DrawWidth | You can use the DrawWidth property to specify the line width for the Line , Circle , and Pset methods to print lines on reports. Read/write Integer.
FastLaserPrinting | You can use the FastLaserPrinting property to specify whether lines and rectangles are replaced by text character lines — similar to the underscore (_) and vertical bar (|) characters — when you print a report using most laser printers. Replacing lines and rectangles with text character lines can make printing much faster. Read/write Boolean.
FillColor | You use the FillColor property to specify the color that fills in boxes and circles drawn on reports with the Line and Circle methods. You can also use this property with Visual Basic to create special visual effects on custom reports when you print using a color printer or preview the reports on a color monitor. Read/write Long.
FillStyle | You can use the FillStyle property to specify whether a circle or line drawn by the Circle or Line method on a report is transparent, opaque, or filled with a pattern. Read/write Integer.
Filter | You can use the Filter property to specify a subset of records to be displayed when a filter is applied to a form, reportquery, or table. Read/write String.
FilterOn | You can use the FilterOn property to specify or determine whether the Filter property for a form or report is applied. Read/write Boolean.
FilterOnLoad | Gets or sets whether the filter specified by the Filter property is applied when the report is loaded. Read/write Boolean.
FitToPage | Gets or sets whether the width of the specified report is sized to automatically fit the page. Read/write Boolean.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontName | You can use the FontName property to specify the font for text in the following situations:
FontSize | You can use the FontSize property to specify the point size for text in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
FormatCount | You can use the FormatCount property to determine the number of times the OnFormat property has been evaluated for the current section on a report. Read/write Integer.
GridX | You can use the GridX property (along with the GridY property) to specify the horizontal and vertical divisions of the alignment grid in report Design view. Read/write Integer.
GridY | You can use the GridY property (along with the GridX property) to specify the horizontal and vertical divisions of the alignment grid in report Design view. Read/write Integer.
GroupLevel | You can use the GroupLevel property in Visual Basic to refer to the group level you are grouping or sorting on in a report. Read-only GroupLevel object.
GrpKeepTogether | You can use the GrpKeepTogether property to specify whether groups in a multiple column report that have their KeepTogether property for a group set to Whole Group or With First Detail will be kept together by page or by column. Read/write Byte.
HasData | You can use the HasData property to determine if a report is bound to an empty recordset. Read/write Long.
HasModule | You can use the HasModule property to specify or determine whether a form or report has a class module. Read/write Boolean.
Height | Gets or sets the height of the specified object in twips. Read/write Long.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HelpFile | The name of a help file associated with a report. Read/write String.
Hwnd | You can use the hWnd property to determine the handle (a unique Long Integer value) assigned by Microsoft Windows to the current window. Read/write Long.
InputParameters | You can use the InputParameters property to specify or determine the input parameters that are passed to a SQL statement in the RecordSource property of a form or report or a stored procedure when used as the record source within a Microsoft Access project (.adp). Read/write String.
KeyPreview | You can use the KeyPreview property to specify whether the report-level keyboard event procedures are invoked before a control's keyboard event procedures. Read/write Boolean.
LayoutForPrint | You can use the LayoutForPrint property to specify whether the report uses printer or screen fonts. Read/write Boolean.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Long.
MenuBar | Specifies a custom menu to display for a report. Read/write String.
MinMaxButtons | You can use the MinMaxButtons property to specify whether the Maximize and Minimize buttons will be visible on a report. Read/write Byte.
Modal | You can use the Modal property to specify whether a report opens as a modal window. When a report opens as a modal window, you must close the window before you can move the focus to another object. Read/write Boolean.
Module | You can use the Module property to specify a report module. Read-only Module object.
MouseWheel | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the MouseWheel event occurs. Read/write.
Moveable | Returns or sets a Boolean indicating whether the specified report can be moved by the user; True if it can be moved. Read/write.
MoveLayout | The MoveLayout property specifies whether Microsoft Access should move to the next printing location on the page. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
NextRecord | The NextRecord property specifies whether a section should advance to the next record. Read/write Boolean.
OnActivate | Sets or returns the value of the On Activate box in the Properties window of a form or report. Read/write String.
OnApplyFilter | Sets or returns the value of the On Apply Filter box in the Properties window of a report. Read/write String.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnClose | Sets or returns the value of the On Close box in the Properties window of a form or report. Read/write String.
OnCurrent | Sets or returns the value of the On Current box in the Properties window of a report. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnDeactivate | Sets or returns the value of the On Deactivate box in the Properties window of a form or report. Read/write String.
OnError | Sets or returns the value of the OnError box in the Properties window of a form or report. Read/write String.
OnFilter | Sets or returns the value of the On Filter box in the Properties window of a report. Read/write String.
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified report. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLoad | Sets or returns the value of the On Load box in the Properties window of a report. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified report. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnNoData | Sets or returns the value of the On No Data box in the Properties window of a report. Read/write String.
OnOpen | Sets or returns the value of the On Open box in the Properties window of a form or report. Read/write String.
OnPage | Sets or returns the value of the On Page box in the Properties window of a report. Read/write String.
OnResize | Sets or returns the value of the On Resize box in the Properties window of a report. Read/write String.
OnTimer | Sets or returns the value of the On Timer box in the Properties window of a form. Read/write String.
OnUnload | Sets or returns the value of the On Unload box in the Properties window of a form. Read/write String.
OpenArgs | Determines the string expression specified by the OpenArgs argument of the OpenReport method that opened a Report. Read/write Variant.
OrderBy | You can use the OrderBy property to specify how you want to sort records in a report. Read/write String.
OrderByOn | You can use the OrderByOn property to specify whether an object's OrderBy property setting is applied. Read/write Boolean.
OrderByOnLoad | Gets or sets whether the sorting specified by the OrderBy property is applied when the report is loaded. Read/write Boolean.
Orientation | You can use the Orientation property to specify or determine the view orientation. Read/write Byte.
Page | The Page property specifies the current page number when a report is being printed. Read/write Long.
PageFooter | You can use the PageFooter property to specify whether a report's page footer is printed on the same page as a report footer. Read/write Byte.
PageHeader | You can use the PageHeader property to specify whether a report's page header is printed on the same page as a report header. Read/write Byte.
Pages | You can use the Pages property to return information needed to print page numbers in a report. Read/write Integer.
Painting | You can use the Painting property to specify whether a report is repainted. Read/write Boolean.
PaintPalette | You can use the PaintPalette property to specify a palette to be used by a report. Read/write Variant.
PaletteSource | You can use the PaletteSource property to specify the palette for a report. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Picture | You can use the Picture property to specify a bitmap or other type of graphic to be used as a background picture on a report. Read/write String.
PictureAlignment | You can use the PictureAlignment property to specify where a background picture will appear in an image control or on a form or report. Read/write Byte.Read/write.
PictureData | You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.
PicturePages | You can use the PicturePages property to specify on which page or pages of a report a picture will be displayed. Read/write Byte.
PicturePalette | You can use the PicturePalette property to specify a palette to be used by a report. Read/write Variant.
PictureSizeMode | You can use the PictureSizeMode property to specify how a picture for a form or report is sized. Read/write Byte.
PictureTiling | You can use the PictureTiling property to specify whether a background picture is tiled across the entire image control, Form window, form, or page of a report. Read/write Boolean.
PictureType | You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.
PopUp | Specifies whether a report opens as a pop-up window. Read/write Boolean.
PrintCount | You can use the PrintCount property to identify the number of times the OnPrint property has been evaluated for the current section of a report. Read/write Integer.
Printer | Returns or sets a Printer object representing the default printer on the current system. Read/write.
PrintSection | The PrintSection property specifies whether a section should be printed. Read/write Boolean.
Properties | Returns a reference to a control's Properties collection object. Read-only.
PrtDevMode | You can use the PrtDevMode property to set or return printing device mode information specified for a form or report in the Print dialog box. Read/write Variant.
PrtDevNames | You can use the PrtDevNames property to set or return information about the printer selected in the Print dialog box for a form or report. Read/write Variant.
PrtMip | You can use the PrtMip property in Visual Basic to set or return the device mode information specified for a form or report in the Print dialog box.
RecordLocks | You can use the RecordLocks property to determine how records are locked and what happens when two users try to edit the same record at the same time. Read/write.
Recordset | Returns or sets the ADO Recordset or DAO Recordset object representing the record source for the specified object. Read/write Object.
RecordSource | You can use the RecordSource property to specify the source of the data for a report. Read/write String.
RecordSourceQualifier | Returns or sets a String indicating the SQL Server owner name of the record source for the specified report. Read/write.
Report | You can use the Report property to refer to a report or to refer to the report associated with a subreport control. Read-only Report.
RibbonName | Gets or set the name of the customized ribbon to be displayed when the specified report is loaded. Read/write String.
ScaleHeight | You can use the ScaleHeight property to specify the number of units for the vertical measurement of the page when the Circle , Line , Pset , or Print method is used while a report is printed or previewed, or its output is saved to a file. Read/write Single.
ScaleLeft | You can use the ScaleLeft property to specify the units for the horizontal coordinates that describe the location of the left edge of a page when the Circle , Line , Pset , or Print method is used while a report is previewed, printed, or its output is saved to a file. Read / write Single.
ScaleMode | You can use the ScaleMode property in Visual Basic to specify the unit of measurement for coordinates on a page when the Circle , Line , Pset , or Print method is used while a report is previewed or printed, or its output is saved to a file. Read/write Integer.
ScaleTop | You can use the ScaleTop property to specify the units for the vertical coordinates that describe the location of the top edge of a page when the Circle , Line , Pset , or Print method is used while a report is previewed, printed, or its output is saved to a file. Read / write Single.
ScaleWidth | You can use the ScaleWidth property to specify the number of units for the horizontal measurement of the page when the Circle , Line , Pset , or Print method is used while a report is printed or previewed, or its output is saved to a file. Read/write Single.
ScrollBars | Gets or sets whether scroll bars appear on a report. Read/write Byte.
Section | You can use the Section property to identify a section of a report and provide access to the properties of that section. Read-only Section object.
ServerFilter | You can use the ServerFilter property to specify a subset of records to be displayed when a server filter is applied to a report within a Microsoft Access project (.adp) or database. Read/write String.
Shape | Returns a String representing the shape command corresponding to the sorting and grouping of the specified report. Read-only.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
ShowPageMargins | Gets or sets whether page margins are displayed when the specified report is in Layout view. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
TimerInterval | You can use the TimerInterval property to specify the interval, in milliseconds, between Timer events on a report. Read/write Long.
Toolbar | Specifies a custom toolbar to display for a report. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Long. .
UseDefaultPrinter | Returns or sets a Boolean indicating whether the specified report uses the default printer for the system; True if the form or report uses the default printer. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.
WindowHeight | Returns the height of a report in twips. Read-only Integer.
WindowLeft | Returns an Integer indicating the screen position in twips of the left edge of a report relative to the left edge of the Microsoft Access window. Read-only.
WindowTop | Returns an Integer indicating the screen position in twips of the top edge of a report relative to the top of the Microsoft Access window. Read-only.
WindowWidth | Returns the width of a report in twips. Read-only Integer.


NavigationControl.SetFocus Method (Access)

 Copy code hover
[image]

NavigationControl.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Version Information

Version Added: Access 2010

Syntax

expression .SetFocus

expression A variable that represents a NavigationControl object.

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.

Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.

Example

The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:

VBA Copy code Copy code
Forms!Employees!EmployeeID.SetFocus

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


AcFormatConditionOperator Enumeration (Access)

 Copy code hover
[image]

AcFormatConditionOperator Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the operator to apply when using the Add method to create a conditional format.

Name | Value | Description
acBetween | 0 | The value must be between the values specified by the Expression1 and Expression2 arguments.
acEqual | 2 | The value must equal to the value specified by the Expression1 argument.
acGreaterThan | 4 | The value must be greater than the value specified by the Expression1 argument.
acGreaterThanOrEqual | 6 | The value must be greater than or equal to the value specified by the Expression1 argument.
acLessThan | 5 | The value must be less than the value specified by the Expression1 argument.
acLessThanOrEqual | 7 | The value must be less than or equal to the value specified by the Expression1 argument.
acNotBetween | 1 | The value must not be between the values specified by the Expression1 and Expression2 arguments.
acNotEqual | 3 | The value must not be equal to the value specified by the Expression1 argument.


ComboBox.Move Method (Access)

 Copy code hover
[image]

ComboBox.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a ComboBox object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


NavigationButton.BorderWidth Property (Access)

 Copy code hover
[image]

NavigationButton.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .BorderWidth

expression A variable that represents a NavigationButton object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


ListBox.Visible Property (Access)

 Copy code hover
[image]

ListBox.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents a ListBox object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Image.HelpContextId Property (Access)

 Copy code hover
[image]

Image.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Syntax

expression .HelpContextId

expression A variable that represents an Image object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

Image Object

Other resources

Image Object Members


Recordset2.LockEdits Property (DAO)

 Copy code hover
[image]

Recordset2.LockEdits Property (DAO)
Send feedback

Sets or returns a value indicating the type of locking that is in effect while editing.

Syntax

expression .LockEdits

expression A variable that represents a Recordset2 object.

Remarks

The setting or return value indicates the type of locking, as specified in the following table.

Value | Description
True | Default. Pessimistic locking is in effect. The page containing the record you're editing is locked as soon as you call the Edit method.
False | Optimistic locking is in effect for editing. The page containing the record is not locked until the Update method is executed.

You can use the LockEdits property with updatable Recordset objects.

If a page is locked, no other user can edit records on the same page. If you set LockEdits to True and another user already has the page locked, an error occurs when you use the Edit method. Other users can read data from locked pages.

If you set the LockEdits property to False and later use the Update method while another user has the page locked, an error occurs. To see the changes made to your record by another user, use the Move method with 0 as the argument; however, if you do this, you will lose your changes.

When working with Microsoft Access database engine-connected ODBC data sources, the LockEdits property is always set to False, or optimistic locking. The Microsoft Access database engine has no control over the locking mechanisms used in external database servers.

Note Note

You can preset the value of LockEdits when you first open the Recordset by setting the lockedits argument of the OpenRecordset method. Setting the lockedits argument to dbPessimistic will set the LockEdits property to True, and setting lockedits to any other value will set the LockEdits property to False.

Example

This example demonstrates pessimistic locking by setting the LockEdits property to True, and then demonstrates optimistic locking by setting the LockEdits property to False. It also demonstrates what kind of error handling is required in a multiuser database environment in order to modify a field. The PessimisticLock and OptimisticLock functions are required for this procedure to run.

VBA Copy code Copy code
Sub LockEditsX()

 Dim dbsNorthwind As Database
 Dim rstCustomers As Recordset2
 Dim strOldName As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstCustomers = _
 dbsNorthwind.OpenRecordset("Customers", _
 dbOpenDynaset)

 With rstCustomers
 ' Store original data.
 strOldName = !CompanyName

 If MsgBox("Pessimistic locking demonstration...", _
 vbOKCancel) = vbOK Then

 ' Attempt to modify data with pessimistic locking
 ' in effect.
 If PessimisticLock(rstCustomers, !CompanyName, _
 "Acme Foods") Then
 MsgBox "Record successfully edited."

 ' Restore original data...
 .Edit
 !CompanyName = strOldName
 .Update
 End If

 End If

 If MsgBox("Optimistic locking demonstration...", _
 vbOKCancel) = vbOK Then

 ' Attempt to modify data with optimistic locking
 ' in effect.
 If OptimisticLock(rstCustomers, !CompanyName, _
 "Acme Foods") Then
 MsgBox "Record successfully edited."

 ' Restore original data...
 .Edit
 !CompanyName = strOldName
 .Update
 End If

 End If

 .Close
 End With

 dbsNorthwind.Close

End Sub

Function PessimisticLock(rstTemp As Recordset2, _
 fldTemp As Field, strNew As String) As Boolean

 dim ErrLoop as Error

 PessimisticLock = True

 With rstTemp
 .LockEdits = True

 ' When you set LockEdits to True, you trap for errors
 ' when you call the Edit method.
 On Error GoTo Err_Lock
 .Edit
 On Error GoTo 0

 ' If the Edit is still in progress, then no errors
 ' were triggered; you may modify the data.
 If .EditMode = dbEditInProgress Then
 fldTemp = strNew
 .Update
 .Bookmark = .LastModified
 Else
 ' Retrieve current record to see changes made by
 ' other user.
 .Move 0
 End If

 End With

 Exit Function

Err_Lock:

 If DBEngine.Errors.Count > 0 Then
 ' Enumerate the Errors collection.
 For Each errLoop In DBEngine.Errors
 MsgBox "Error number: " & errLoop.Number & _
 vbCr & errLoop.Description
 Next errLoop
 PessimisticLock = False
 End If

 Resume Next

End Function

Function OptimisticLock(rstTemp As Recordset, _
 fldTemp As Field, strNew As String) As Boolean

 dim ErrLoop as Error

 OptimisticLock = True

 With rstTemp
 .LockEdits = False
 .Edit
 fldTemp = strNew

 ' When you set LockEdits to False, you trap for errors
 ' when you call the Update method.
 On Error GoTo Err_Lock
 .Update
 On Error GoTo 0

 ' If there is no Edit in progress, then no errors were
 ' triggered; you may modify the data.
 If .EditMode = dbEditNone Then
 ' Move current record pointer to the most recently
 ' modified record.
 .Bookmark = .LastModified
 Else
 .CancelUpdate
 ' Retrieve current record to see changes made by
 ' other user.
 .Move 0
 End If

 End With

 Exit Function

Err_Lock:

 If DBEngine.Errors.Count > 0 Then
 ' Enumerate the Errors collection.
 For Each errLoop In DBEngine.Errors
 MsgBox "Error number: " & errLoop.Number & _
 vbCr & errLoop.Description
 Next errLoop
 OptimisticLock = False
 End If

 Resume Next

End Function


ToggleButton.ControlSource Property (Access)

 Copy code hover
[image]

ToggleButton.ControlSource Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.

Syntax

expression .ControlSource

expression A variable that represents a ToggleButton object.

Remarks

The ControlSource property uses the following settings.

Setting | Description
A field name | The control is bound to a field in a table, query, or SQL statement. Data from the field is displayed in the control. Changes to the data inside the control change the corresponding data in the field. (To make the control read-only, set the Locked property to Yes.) If you click a control bound to a field that has a Hyperlink data type, you jump to the destination specified in the hyperlink address.
An expression | The control displays data generated by an expression. This data can be changed by the user but isn't saved in the database.
Note Note

The ControlSource property doesn't apply to check box, option button, or toggle button controls in an option group. It applies only to the option group itself.

For reports, the ControlSource property applies only to report group levels.

Forms and reports act as "windows" into your database. You specify the primary source of data for a form or report by setting its RecordSource property to a table, query, or SQL statement. You can then set the ControlSource property to a field in the source of data or to an expression. If the ControlSource property setting is an expression, the value displayed is read-only and not saved in the database. For example, you can use the following settings.

Sample setting | Description
LastName | For a control, data from the LastName field is displayed in the control. For a report group level, Microsoft Access groups the data on last name.
=Date( ) + 7 | For a control, this expression displays a date seven days from today in the control.
=DatePart("q",ShippedDate) | For a control, this expression displays the quarter of the shipped date. For a report group level, Microsoft Access groups the data on the quarter of the shipped date.

Example

The following example sets the ControlSource property for a text box named AddressPart to a field named City:

VBA Copy code Copy code
Forms!Customers!AddressPart.ControlSource = "City"

The next example sets the ControlSource property for a text box named Expected to the expression =Date() + 7

VBA Copy code Copy code
Me!Expected.ControlSource = "=Date() + 7"

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Attachment.OnMouseUp Property (Access)

 Copy code hover
[image]

Attachment.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnMouseUp

expression A variable that represents an Attachment object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


PageBreak.ControlType Property (Access)

 Copy code hover
[image]

PageBreak.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Syntax

expression .ControlType

expression A variable that represents a PageBreak object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

PageBreak Object

Other resources

PageBreak Object Members


Document Object Reference (DAO)

 Copy code hover
[image]

Document Object Reference (DAO)
Send feedback

In this section

  • Document Object (DAO)

  • Document Members (DAO)

  • Document Properties (DAO)

  • Document Methods (DAO)


Control.Selected Property (Access)

 Copy code hover
[image]

Control.Selected Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Selected property in Visual Basic to determine if an item is selected. Read/write Long.

Syntax

expression .Selected(lRow)

expression A variable that represents a Control object.

Parameters

Name | Required/Optional | Data Type | Description
lRow | Required | Long | The item in the list box. The first item is represented by a zero (0), the second by a one (1), and so on.

Remarks

The Selected property is a zero-based array that contains the selected state of each item in a list box.

Setting | Description
True | The list box item is selected.
False | The list box item isn't selected.

This property is available only at run time.

When a list box control's MultiSelect property is set to None, only one item can have its Selected property set to True. When a list box control's MultiSelect property is set to Simple or Extended, any or all of the items can have their Selected property set to True. A multiple-selection list box bound to a field will always have a Value property equal to Null. You use the Selected property or the ItemsSelected collection to retrieve information about which items are selected.

You can use the Selected property to select items in a list box by using Visual Basic. For example, the following expression selects the fifth item in the list:

VBA Copy code Copy code
Me!Listbox.Selected(4) = True

Example

The following example uses the Selected property to move selected items in the lstSource list box to the lstDestination list box. The lstDestination list box's RowSourceType property is set to Value List and the control's RowSource property is constructed from all the selected items in the lstSource control. The lstSource list box's MultiSelect property is set to Extended. The CopySelected( ) procedure is called from the cmdCopyItem command button.

VBA Copy code Copy code
Private Sub cmdCopyItem_Click()
 CopySelected Me
End Sub

Public Sub CopySelected(ByRef frm As Form)

 Dim ctlSource As Control
 Dim ctlDest As Control
 Dim strItems As String
 Dim intCurrentRow As Integer

 Set ctlSource = frm!lstSource
 Set ctlDest = frm!lstDestination

 For intCurrentRow = 0 To ctlSource.ListCount - 1
 If ctlSource.Selected(intCurrentRow) Then
 strItems = strItems & ctlSource.Column(0, _
 intCurrentRow) & ";"
 End If
 Next intCurrentRow

 ' Reset destination control's RowSource property.
 ctlDest.RowSource = ""
 ctlDest.RowSource = strItems

 Set ctlSource = Nothing
 Set ctlDest = Nothing

End Sub

See also

Concepts

Control Object

Other resources

Control Object Members


Page.HelpContextId Property (Access)

 Copy code hover
[image]

Page.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Syntax

expression .HelpContextId

expression A variable that represents a Page object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

Page Object

Other resources

Page Object Members


CubeDef Object (ADO MD Reference)

 Copy code hover
[image]

CubeDef Object (ADO MD Reference)
Send feedback

In this section

  • CubeDef Object (ADO MD)

  • CubeDef Properties, Methods, and Events (ADO MD)


ADO MD Objects Reference

 Copy code hover
[image]

ADO MD Objects Reference
Send feedback

In this section

  • ADO MD Objects

  • Axis Object (ADO MD Reference)

  • Catalog Object (ADO MD Reference)

  • Cell Object (ADO MD Reference)

  • Cellset Object (ADO MD Reference)

  • CubeDef Object (ADO MD Reference)

  • Dimension Object (ADO MD Reference)

  • Hierarchy Object (ADO MD Reference)

  • Level Object (ADO MD Reference)

  • Member Object (ADO MD Reference)

  • Position Object (ADO MD Reference)


Form.AllowDatasheetView Property (Access)

 Copy code hover
[image]

Form.AllowDatasheetView Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Boolean indicating whether the specified form may be viewed in Datasheet View. True if Datasheet View is allowed. Read/write.

Syntax

expression .AllowDatasheetView

expression A variable that represents a Form object.

Remarks

Use the AllowDatasheetView, AllowFormView, AllowPivotChartView, or AllowPivotTableView properties to control which views are allowed for a form.

Example

The following example makes Datasheet View valid for the specified form and then opens the form in Datasheet View.

VBA Copy code Copy code
Forms(0).AllowDatasheetView = True
DoCmd.OpenForm FormName:=Forms(0).Name, View:=acFormDS

See also

Concepts

Form Object

Other resources

Form Object Members


AcFindField Enumeration (Access)

 Copy code hover
[image]

AcFindField Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies whether the search is confined to the current field in each record or includes all fields in each record.

Name | Value | Description
acAll | 0 | Search in all fields in each record.
acCurrent | -1 | Confine the search to the current field.


 Copy code hover
[image]

<Account name> is not a valid account name. (Error 3030)
Send feedback

The specified account (user) name is not valid. User names can be from 1 to 20 characters long and can include alphabetic characters, accented characters, numbers, spaces, and symbols, with the following exceptions:

  • The characters " / \ [ ] | < > + = ; , : ? *

  • Leading spaces

  • Control characters

User names are not case-sensitive.


Views Collection Properties, Methods, and Events (ADOX)

 Copy code hover
[image]

Views Collection Properties, Methods, and Events (ADOX)
Send feedback

Properties

Count Property

Item Property

Methods

Append Method (Views)

Delete Method (Collections)

Refresh Method

Events

None.


Error Codes

 Copy code hover
[image]

Error Codes
Send feedback

In this section

  • Error Trapping

  • Elements of Run-Time Error Handling


ComboBox.ReadingOrder Property (Access)

 Copy code hover
[image]

ComboBox.ReadingOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.

Syntax

expression .ReadingOrder

expression A variable that represents a ComboBox object.

Remarks

The ReadingOrder property uses the following settings.

Setting | Visual Basic | Description
Context | 0 | Reading order is determined by the language of the first character entered. If a right-to-left language character is entered first, reading order is right to left. If a left-to-right language character is entered first, reading order is left to right.
Left-to-Right | 1 | Sets the reading order to left to right.
Right-to-Left | 2 | Sets the reading order to right to left.

In a combo box or list box, the ReadingOrder property determines reading order behavior for both the text box and list box components of the control.

Example

The following example sets the reading order to right to left for the "Address" text box on the "International Shipping" form.

VBA Copy code Copy code
Forms("International Shipping").Controls("Address").ReadingOrder = 2

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Printer.ItemSizeHeight Property (Access)

 Copy code hover
[image]

Printer.ItemSizeHeight Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Long indicating the height of the detail section of a form or report in twips. Read/write.

Syntax

expression .ItemSizeHeight

expression A variable that represents a Printer object.

Example

The following example sets a variety of printer settings for the form specified in the strFormname argument of the procedure.

VBA Copy code Copy code
Sub SetPrinter(strFormname As String)

 DoCmd.OpenForm FormName:=strFormname, view:=acDesign, _
 datamode:=acFormEdit, windowmode:=acHidden

 With Forms(form1).Printer

 .TopMargin = 1440
 .BottomMargin = 1440
 .LeftMargin = 1440
 .RightMargin = 1440

 .ColumnSpacing = 360
 .RowSpacing = 360

 .ColorMode = acPRCMColor
 .DataOnly = False
 .DefaultSize = False
  .ItemSizeHeight = 2880
 .ItemSizeWidth = 2880
 .ItemLayout = acPRVerticalColumnLayout
 .ItemsAcross = 6

 .Copies = 1
 .Orientation = acPRORLandscape
 .Duplex = acPRDPVertical
 .PaperBin = acPRBNAuto
 .PaperSize = acPRPSLetter
 .PrintQuality = acPRPQMedium

 End With

 DoCmd.Close objecttype:=acForm, objectname:=strFormname, _
 Save:=acSaveYes

End Sub

See also

Concepts

Printer Object

Other resources

Printer Object Members


SaveObject Macro Action

 Copy code hover
[image]

SaveObject Macro Action
Send feedback

You can use the SaveObject action to save either a specified Access object or the active object if none is specified. You can also save the active object with a new name in some cases (this functions the same as the Save As command on the Quick Access Toolbar).

Note 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.

Setting

The SaveObject action has the following arguments.

Action argument | Description
Object Type | The type of object you want to save. Click Table, Query, Form, Report, Macro, Module, Data Access Page, Server View, Diagram, Stored Procedure, or Function in the Object Type box in the Action Arguments section of the Macro Builder pane. To select the active object, leave this argument blank. If you select an object type in this argument, you must select an existing object's name in the Object Name argument.
Object Name | The name of the object to be saved. The Object Name box shows all objects in the database of the type selected by the Object Type argument. If you leave the Object Type argument blank, you can leave this argument blank to save the active object, or, in some cases, enter a new name in this argument to save the active object with this name. If you enter a new name, the name must follow the standard naming conventions for Microsoft Access objects.

Remarks

The SaveObject action works on all database objects that the user can explicitly open and save. The specified object must be open for the SaveObject action to have any effect on the object. This action has the same effect as selecting an object and then saving it by clicking Save on the Quick Access Toolbar. Leaving the Object Type argument blank and entering a new name in the Object Name argument has the same effect as clicking Save As on the Quick Access Toolbar, and entering a new name for the active object. Using the SaveObject action enables you to specify an object to save and to perform a Save As command from a macro.

Note Note

You can't use the SaveObject action to save any of the following with a new name:

  • A form in Form view or Datasheet view.

  • A report in Print Preview.

  • A module.

  • A server view in Datasheet view or Print Preview.

  • A data access page in Page view.

  • A table in Datasheet view or Print Preview.

  • A query in Datasheet view or Print Preview.

  • A stored procedure in Datasheet view or Print Preview.

The SaveObject action, whether it's carried out in a macro run in the current database or in a library database, always saves the specified object or the active object in the database in which the object was created.

If you save the active object with a new name, but the name is the same as the name of an existing object of this type, a dialog box asks if you want to overwrite the existing object. If you've set the Warnings On argument of the SetWarnings action to No, the dialog box isn't displayed and the old object is automatically overwritten.

To run the SaveObject action in a Visual Basic for Applications (VBA) module, use the Save method of the DoCmd object.


TabControl.Value Property (Access)

 Copy code hover
[image]

TabControl.Value Property (Access)
See also Send feedback

Published: July 16, 2012

Determines or specifies the selected Page object. Read/write Variant.

Syntax

expression .Value

expression A variable that represents a TabControl object.

Remarks

The Value property of a tab control contains the index number of the current Page object. There is one Page object for each tab in a tab control. The first Page object always has an index number of 0, the second has an index number of 1, and so on.

The Value property returns or sets a control's default property, which is the property that is assumed when you don't explicitly specify a property name.

Note Note

The Value property is not the same as the DefaultValue property, which specifies the value that a property is assigned when a new record is created.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


TopValues Property

 Copy code hover
[image]

TopValues Property
Send feedback

Published: July 16, 2012

You can use the TopValues property to return a specified number of records or a percentage of records that meet the criteria you specify. For example, you might want to return the top 10 values or the top 25 percent of all values in a field.

Note Note

The TopValues property applies only to append, make-table, and select queries.

Setting

The TopValues property setting is an Integer value that represents the exact number of values to return or a number followed by a percent sign (%) that represents the percent of records to return. For example, to return the top 10 values, set the TopValues property to 10; to return the top 10 percent of values, set the TopValues property to 10%.

You cannot set this property in code directly. It is set in SQL view of the Query window by using a TOP n or TOP n PERCENT clause in the SQL statement.

You can also set the TopValues property by using the query property sheet or the Return box in the Query Setup group on the ribbon.

Note Note

The TopValues property in the query property sheet Return box in the Query Setup group on the ribbon is a combo box that contains a list of values and percentage values. You can select one of these values or you can type any valid setting in the text box portion of this control.

Remarks

Typically, you use the TopValues property setting together with sorted fields. The field you want to display top values for should be the leftmost field that has the Sort box selected in the query design grid. An ascending sort returns the bottom-most records, and a descending sort returns the topmost records. If you specify that a specific number of records be returned, all records with values that match the value in the last record are also returned.

For example, suppose a set of employees has the following sales totals.

Sales | Salesperson
90,000 | Leverling
80,000 | Peacock
70,000 | Davilio
70,000 | King
60,000 | Suyama
50,000 | Buchanan

If you set the TopValues property to 3 with a descending sort on the Sales field, Microsoft Access returns the following four records.

Sales | Salesperson
90,000 | Leverling
80,000 | Peacock
70,000 | Davilio
70,000 | King
Note Note

To return the topmost or bottommost values without displaying duplicate values, set the UniqueValues property in the query property sheet to Yes.

Example

The following code example assigns an SQL string that returns the top 10 most expensive products to the RecordSource property for a form that will display the ten most expensive products.

VBA Copy code Copy code
Dim strGetSQL As String
strGetSQL = "SELECT TOP 10 Products.[ProductName] " _
    & "AS TenMostExpensiveProducts, Products.UnitPrice FROM Products " _
    & "ORDER BY Products.[UnitPrice] DESC;"
Me.RecordSource = strGetSQL


Control.Form Property (Access)

 Copy code hover
[image]

Control.Form Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Form property to refer to a form or to refer to the form associated with a subformcontrol. Read-only Form.

Syntax

expression .Form

expression A variable that represents a Control object.

Remarks

This property refers to a form object. It is read-only in all views.

This property is typically used to refer to the form or report contained in a subform control. For example, the following code uses the Form property to access the OrderID control on a subform contained in the OrderDetails subform control.

VBA Copy code Copy code
Dim intOrderID As Integer
intOrderID = Forms!Orders!OrderDetails.Form!OrderID

The next example calls a function from a property sheet by using the Form property to refer to the active form that contains the control named CustomerID.

VBA Copy code Copy code
=MyFunction(Form!CustomerID)

When you use the Form property in this manner, you are referring to the active form, and the name of the form isn't necessary.

The next example is the Visual Basic equivalent of the preceding example.

VBA Copy code Copy code
X = MyFunction(Forms!Customers!CustomerID)
Note Note

When you use the Forms collection, you must specify the name of the form.

Example

The following example uses the Form property to refer to a control on a subform.

VBA Copy code Copy code
Dim curTotalAmount As Currency

curTotalAmount = Forms!Orders!OrderDetails.Form!TotalAmount

See also

Concepts

Control Object

Other resources

Control Object Members


WebBrowserControl.Layout Property (Access)

 Copy code hover
[image]

WebBrowserControl.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified text box. Read-only AcLayoutType.

Version Information

Version Added: Access 2010

Syntax

expression .Layout

expression A variable that represents a WebBrowserControl object.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


WebBrowserControl.TabIndex Property (Access)

 Copy code hover
[image]

WebBrowserControl.TabIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .TabIndex

expression A variable that represents a WebBrowserControl object.

Remarks

You can set the TabIndex property to an integer representing the position of the control within the tab order of the form. Valid settings are 0 for the first tab position, up to the total number of controls minus 1 for the last tab position. For example, if a form has three controls that each have a TabIndex property, valid TabIndex property settings are 0, 1, and 2.

Setting the TabIndex property to an integer less than 0 produces an error.

By default, Microsoft Access assigns a tab order to controls in the order that you create them on a form. Each new control is placed last in the tab order. If you change the setting of a control's TabIndex property to adjust the tab order, Microsoft Access automatically renumbers the TabIndex property setting of other controls to reflect insertions and deletions.

In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the TAB key.

Changing the tab order of other controls on the form doesn't affect what happens when you press a control's access key. For example, if you've created an access key for the label of a text box, the focus will move to the text box whenever you press the label's access key — even if you change the TabIndex property setting for the text box.

If you press an access key for a control such as a label that doesn't have a TabIndex property (and thus isn't in the tab order), the focus moves to the next control in the tab order that can receive the focus.

Example

The following example reverses the tab order of a command button and a text box. Because TextBox1 was created first, it has a TabIndex property setting of 0 and Command1 has a setting of 1.

VBA Copy code Copy code
Sub Form_Click()
 Me!Command1.TabIndex = 0
 Me!TextBox1.TabIndex = 1
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


onReadyStateChange Event (RDS)

 Copy code hover
[image]

onReadyStateChange Event (RDS)
Send feedback

The onReadyStateChange event is called whenever the value of the ReadyState property changes.

Syntax

onReadyStateChange

Parameters

None.

Remarks

The ReadyState property reflects the progress of an RDS.DataControl object as it asynchronously retrieves data into its Recordset object. Use the onReadyStateChange event to monitor changes in the ReadyState property whenever they occur. This is more efficient than periodically checking the property's value.


Using ADO with Microsoft Visual J++

 Copy code hover
[image]

Using ADO with Microsoft Visual J++
Send feedback

You can implement ADO using Visual J++ in the following ways:

  • With Visual J++ 6.0 (or later), use ADO for Windows Foundation Classes.

  • With Visual J++ 1.x, use the Java Type Library Wizard.

  • Use the Microsoft SDK for Java utilities.

For further information about using ADO with Visual J++, see the following topics:

  • ADO Java Class Wrappers

  • ADO/WFC Syntax Index


Not a valid password. (Error 3031)

 Copy code hover
[image]

Not a valid password. (Error 3031)
Send feedback

You have typed an invalid password. Passwords can be any combination of 20 or fewer characters, except control characters. Passwords are case-sensitive.


CommandButton.HoverForeTint Property (Access)

 Copy code hover
[image]

CommandButton.HoverForeTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .HoverForeTint

expression A variable that represents a CommandButton object.

Remarks

The HoverForeTint property contains a numeric expression that can be used to lighten the theme color in the HoverForeColor property. The default value of the HoverForeTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Index.Properties Property (DAO)

 Copy code hover
[image]

Index.Properties Property (DAO)
Send feedback

Returns the Properties collection of the specified object. Read-only.

Syntax

expression .Properties

expression A variable that represents an Index object.


ComboBox.ForeThemeColorIndex Property (Access)

 Copy code hover
[image]

ComboBox.ForeThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ForeThemeColorIndex

expression A variable that represents a ComboBox object.

Remarks

The ForeThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the ForeThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Fore Color to the Text 2 color by setting the ForeThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.ForeThemeColorIndex=2

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


BoundObjectFrame.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

BoundObjectFrame.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents a BoundObjectFrame object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.BorderThemeColorIndex=2

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


CommandButton.EventProcPrefix Property (Access)

 Copy code hover
[image]

CommandButton.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents a CommandButton object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


SmartTagAction Methods (Access)

 Copy code hover
[image]

SmartTagAction Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Execute | The Execute method performs the specified smart tag action.


Form.Delete Event (Access)

 Copy code hover
[image]

Form.Delete Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when the user performs some action, such as pressing the DEL key, to delete a record, but before the record is actually deleted.

Syntax

expression .Delete(Cancel, )

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the Delete event occurs. Setting the Cancel argument to True (-1) cancels the Delete event.

Remarks

To run a macro or event procedure when these events occur, set the OnDelete, BeforeDelConfirm, or AfterDelConfirm property to the name of the macro or to [Event Procedure].

After a record is deleted, it's stored in a temporary buffer. The BeforeDelConfirm event occurs after the Delete event (or if you've deleted more than one record, after all the records are deleted, with a Delete event occurring for each record), but before the Delete Confirm dialog box is displayed. Canceling the BeforeDelConfirm event restores the record or records from the buffer and prevents the Delete Confirm dialog box from being displayed.

The AfterDelConfirm event occurs after a record or records are actually deleted or after a deletion or deletions are canceled. If the BeforeDelConfirm event isn't canceled, the AfterDelConfirm event occurs after the Delete Confirm dialog box is displayed. The AfterDelConfirm event occurs even if the BeforeDelConfirm event is canceled. The AfterDelConfirm event procedure returns status information about the deletion. For example, you can use a macro or event procedure associated with the AfterDelConfirm event to recalculate totals affected by the deletion of records.

If you cancel the Delete event, the BeforeDelConfirm and AfterDelConfirm events don't occur and the Delete Confirm dialog box isn't displayed.

Note Note

The BeforeDelConfirm and AfterDelConfirm events don't occur and the Delete Confirm dialog box isn't displayed if you clear the Record Changes check box under Confirm on the Advanced tab of the Access Options dialog box, available by clicking the Microsoft Office Button [image] and the clicking Access Options.

By running a macro or an event procedure when the Delete event occurs, you can prevent a record from being deleted or allow a record to be deleted only under certain conditions. You can also use a Delete event to display a dialog box asking whether the user wants to delete a record before it's deleted.

To delete a record, you can click Delete Record on the Edit menu. This deletes the current record (the record indicated by the record selector). You can also click the record selector or click Select Record on the Edit menu to select the record, and then press the DEL key to delete it. If you click Delete Record, the record selector of the current record, or Select Record, the Exit and LostFocus events for the control that has the focus occur. If you've changed any data in the record, the BeforeUpdate and AfterUpdate events for the record occur before the Exit and LostFocus events. If you click the record selector of a different record, the Current event for that record also occurs.

After you delete the record, the focus moves to the next record following the deleted record, and the Current event for that record occurs, followed by the Enter and GotFocus events for the first control in that record.

The BeforeDelConfirm event then occurs, just before Microsoft Access displays the Delete Confirm dialog box asking you to confirm the deletion. After you respond to the dialog box by confirming or canceling the deletion, the AfterDelConfirm event occurs.

You can delete one or more records at a time. The Delete event occurs after each record is deleted. This enables you to access the data in each record before it's actually deleted, and selectively confirm or cancel each deletion in the Delete macro or event procedure. When you delete more than one record, the Current event for the record following the last deleted record and the Enter and GotFocus events for the first control in this record don't occur until all the records are deleted. In other words, a Delete event occurs for each selected record, but no other events occur until all the selected records are deleted. The BeforeDelConfirm and AfterDelConfirm events also don't occur until all the selected records are deleted.

Example

The following example shows how you can prevent a user from deleting records from a table.

To try this example, add the following event procedure to a form that is based on a table. Switch to form Datasheet view and try to delete a record.

VBA Copy code Copy code
Private Sub Form_Delete(Cancel As Integer)
    Cancel = True
    MsgBox "This record can't be deleted."
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


ToggleButton.BottomPadding Property (Access)

 Copy code hover
[image]

ToggleButton.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the toggle button and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .BottomPadding

expression A variable that represents a ToggleButton object.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


TabControl.OnMouseUp Property (Access)

 Copy code hover
[image]

TabControl.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Syntax

expression .OnMouseUp

expression A variable that represents a TabControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Label.Move Method (Access)

 Copy code hover
[image]

Label.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a Label object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

Label Object

Other resources

Label Object Members


SQL Expressions

 Copy code hover
[image]

SQL Expressions
Send feedback

An SQL expression is a string that makes up all or part of an SQL statement. For example, theFindFirst method on a Recordset object uses an SQL expression consisting of the selection criteria found in an SQL WHERE clause.

The Microsoft Access database engine uses the Microsoft® Visual Basic® for Applications (or VBA) expression service to perform simple arithmetic and function evaluation. All of the operators used in Microsoft Access database engine SQL expressions (except Between, In, and Like) are defined by the VBA expression service. In addition, the VBA expression service offers over 100 VBA functions that you can use in SQL expressions. For example, you can use these VBA functions to compose an SQL query in the Microsoft Access query Design view, and you can also use these functions in an SQL query in the DAO OpenRecordset method in Microsoft Visual C++®, Microsoft Visual Basic, and Microsoft Excel code.


ImportExportSpecification.XML Property (Access)

 Copy code hover
[image]

ImportExportSpecification.XML Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the Extensible Markup Language (XML) string that defines an ImportExportSpecification object. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .XML

expression A variable that represents an ImportExportSpecification object.

See also

Concepts

ImportExportSpecification Object

Other resources

ImportExportSpecification Object Members


SmartTagAction.Application Property (Access)

 Copy code hover
[image]

SmartTagAction.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a SmartTagAction object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

SmartTagAction Object

Other resources

SmartTagAction Object Members


CheckBox.TabIndex Property (Access)

 Copy code hover
[image]

CheckBox.TabIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.

Syntax

expression .TabIndex

expression A variable that represents a CheckBox object.

Remarks

You can set the TabIndex property to an integer representing the position of the control within the tab order of the form. Valid settings are 0 for the first tab position, up to the total number of controls minus 1 for the last tab position. For example, if a form has three controls that each have a TabIndex property, valid TabIndex property settings are 0, 1, and 2.

Setting the TabIndex property to an integer less than 0 produces an error.

By default, Microsoft Access assigns a tab order to controls in the order that you create them on a form. Each new control is placed last in the tab order. If you change the setting of a control's TabIndex property to adjust the tab order, Microsoft Access automatically renumbers the TabIndex property setting of other controls to reflect insertions and deletions.

In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the TAB key.

Changing the tab order of other controls on the form doesn't affect what happens when you press a control's access key. For example, if you've created an access key for the label of a text box, the focus will move to the text box whenever you press the label's access key — even if you change the TabIndex property setting for the text box.

If you press an access key for a control such as a label that doesn't have a TabIndex property (and thus isn't in the tab order), the focus moves to the next control in the tab order that can receive the focus.

Example

The following example reverses the tab order of a command button and a text box. Because TextBox1 was created first, it has a TabIndex property setting of 0 and Command1 has a setting of 1.

VBA Copy code Copy code
Sub Form_Click()
 Me!Command1.TabIndex = 0
 Me!TextBox1.TabIndex = 1
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ToggleButton.KeyUp Event (Access)

 Copy code hover
[image]

ToggleButton.KeyUp Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyUp(KeyCode, Shift)

expression A variable that represents a ToggleButton object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyUp property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyUp event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyUp event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Types of Events

 Copy code hover
[image]

Types of Events
Send feedback

There are two basic types of events. "Will Events," which are called before an operation starts, usually include "Will" in their names — for example, WillChangeRecordset or WillConnect. Events that are called after an event has been completed usually include "Complete" in their names — for example, RecordChangeComplete or ConnectComplete. Exceptions exist — such as InfoMessage — but these occur after the associated operation has completed.

Will Events

Event handlers called before the operation starts offer you the opportunity to examine or modify the operation parameters, and then either cancel the operation or allow it to complete. These event-handler routines usually have names of the form WillEvent.

Complete Events

Event handlers called after an operation completes can notify your application that an operation has concluded. Such an event handler is also notified when a Will event handler cancels a pending operation. These event-handler routines usually have names of the form EventComplete.

Will and Complete events are typically used in pairs.

Other Events

The other event handlers — that is, events whose names are not of the form WillEvent or EventComplete — are called only after an operation completes. These events are Disconnect, EndOfRecordset, and InfoMessage.


BoundObjectFrame.DisplayType Property (Access)

 Copy code hover
[image]

BoundObjectFrame.DisplayType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayType property to specify whether Microsoft Access displays an OLE object's content or an icon. Read/write Boolean.

Syntax

expression .DisplayType

expression A variable that represents a BoundObjectFrame object.

Remarks

For example, if the OLE object is a Microsoft Word document and you set this property to Content, the control displays the Word document; if you set this property to Icon, the control displays the Microsoft Word icon.

The DisplayType property uses the following settings.

Setting | Visual Basic | Description
Content | acOLEDisplayContent | (Default) When the control contains an OLE object, the control displays the object's data, such as a document or spreadsheet.
Icon | acOLEDisplayIcon | When the control contains an OLE object, the control displays the object's icon.

For a bound object frame, the DisplayType property can be set either in Design view or in Form view or Datasheet view for new records while they are being added; it can be read in all views. For an unbound object frame or chart, the property can be set in the Insert Object dialog box when the object is created (the default setting is Content or, if you select the Display As Icon check box, the setting is Icon).

The DisplayType property determines the default setting of the Display As Icon check box in the Paste Special dialog box, available by clicking Paste Special on the Edit menu, and the Insert Object dialog box, displayed when inserting an unbound object frame. When you display these dialog boxes in Form view, Datasheet view, or Design view, the Display As Icon check box is automatically selected if the DisplayType property is set to Icon. For example, you will see these boxes selected when using Visual Basic to set the control's Action property to acOLEInsertObjDlg or acOLEPasteSpecialDlg.

The DisplayType property setting has no effect on the state of the Display As Icon check box in the Object dialog box when you insert an object into an unbound object frame. When you paste an object from the Clipboard, the Display As Icon check box reflects the state of the object on the Clipboard.

Changing the DisplayType property of a bound object frame doesn't affect the display of existing objects in the control. However, it will affect new objects that you add to the control by using the Object command on the Insert menu.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


ComboBox.OnLostFocus Property (Access)

 Copy code hover
[image]

ComboBox.OnLostFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnLostFocus

expression A variable that represents a ComboBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The LostFocus event occurs when the object loses the focus.

The OnLostFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Lost Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Lost Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnLostFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnLostFocus

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


The Synchronizer's Registry has no value set for the key you queried. (Error 3503)

 Copy code hover
[image]

The Synchronizer's Registry has no value set for the key you queried. (Error 3503)
Send feedback

You need to reconfigure the Synchronizer on your computer.

To configure the Synchronizer

  1. Start Replication Manager.

  2. On the Tools menu, click Configure Microsoft Replication Manager.

  3. Follow the instructions in the wizard.


Label.Application Property (Access)

 Copy code hover
[image]

Label.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a Label object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

Label Object

Other resources

Label Object Members


Query cannot contain a Database parameter. (Error 3222)

 Copy code hover
[image]

Query cannot contain a Database parameter. (Error 3222)
Send feedback

Change the parameter field data type for this parameter query to a valid field data type, and then try the operation again.


Move Method Example (VC++)

 Copy code hover
[image]

Move Method Example (VC++)
Send feedback

This example uses the Move method to position the record pointer based on user input.

Copy code Copy code

// BeginMoveCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <stdio.h>
#include <ole2.h>
#include <stdlib.h>
#include <conio.h>
#include "MoveX.h"

// Function Declaration.
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void MoveX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);
inline char* mygets(char* strDest, int n)
{
 char strExBuff[10];
 char* pstrRet = fgets(strDest, n, stdin);

 if (pstrRet == NULL)
 return NULL;

 if (!strrchr(strDest, '\n'))
 // Exhaust the input buffer.
 do
 {
 fgets(strExBuff, sizeof(strExBuff), stdin);
 }while (!strrchr(strExBuff, '\n'));
 else
 // Replace '\n' with '\0'
 strDest[strrchr(strDest, '\n') - strDest] = '\0';

 return pstrRet;
}

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 MoveX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////
// //
// MoveX Function //
// //
//////////////////////////////////////////////////

void MoveX(void)
{
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstAuthors = NULL;

 // Define Other Variables
 IADORecordBinding *picRs = NULL; //Interface Pointer declared
 CAuthorsRs authorsrs; //C++ class object
 HRESULT hr = S_OK;

 // Open Authors table
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 // Open recordset from Authors table.
 TESTHR(pRstAuthors.CreateInstance(__uuidof(Recordset)));

 pRstAuthors->CursorType = adOpenStatic;
 // Use client cursor to allow use of AbsolutePosition property.
 pRstAuthors->CursorLocation = adUseClient;

 pRstAuthors->Open("SELECT au_id, au_fname, au_lname, city, "
 "state FROM Authors ORDER BY au_lname", strCnn, adOpenStatic,
 adLockReadOnly, adCmdText);

 // Open an IADORecordBinding interface pointer which we'll use
 // for Binding Recordset to a class.
 TESTHR(pRstAuthors->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 // Bind the Recordset to a C++ Class here.
 TESTHR(picRs->BindToRecordset(&authorsrs));

 pRstAuthors->MoveFirst();

 char *strMove;
 char strTemp[5];
 while(true)
 {
 // Display information about current record and ask how many
 // records to move.
 printf("Record %ld of %d\n", pRstAuthors->AbsolutePosition,
 pRstAuthors->RecordCount);
 printf("Author: %s %s\n",
 authorsrs.lemp_fnameStatus == adFldOK ?
 authorsrs.m_au_fname : "<NULL>",
 authorsrs.lemp_lnameStatus == adFldOK ?
 authorsrs.m_au_lname : "<NULL>");
 printf("Location: %s, %s\n\n",
 authorsrs.lemp_cityStatus == adFldOK ?
 authorsrs.m_au_city : "<NULL>",
 authorsrs.lemp_stateStatus == adFldOK ?
 authorsrs.m_au_state : "<NULL>");

 printf("Enter number of records to Move "
 "\n(positive or negative, Enter to quit): ");
 mygets(strTemp, 5);

 strMove = strtok(strTemp," \t");

 if (strMove == NULL)
 break;

 // if the input is not numeric then notify the user.
 if(!atol(strMove))
 {
 printf("Expecting numeric value...\n");
 continue;
 }

 // Store bookmark in case the Move goes too far
 // forward or backward.
 _variant_t varBookmark = pRstAuthors->Bookmark;

 // Move method requires parameter of data type Long.
 long lngMove = atol(strMove);

 pRstAuthors->Move(lngMove);

 // Trap for BOF or EOF.
 if(pRstAuthors->BOF)
 {
 printf("Too far backward! Returning to current"
 " record.\n");
 pRstAuthors->Bookmark = varBookmark;
 }

 if(pRstAuthors->EndOfFile)
 {
 printf("Too far forward! Returning to current"
 " record.\n");
 pRstAuthors->Bookmark = varBookmark;
 }
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstAuthors->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (pRstAuthors)
 if (pRstAuthors->State == adStateOpen)
 pRstAuthors->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndMoveCpp

MoveX.h

Copy code Copy code

// BeginMoveH

#include "icrsint.h"

// This Class extracts fname, lname, city and state
// from the "authors" table.

class CAuthorsRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CAuthorsRs)

 // Column au_id is the 1st field in the recordset

 ADO_VARIABLE_LENGTH_ENTRY2(2, adVarChar, m_au_fname,
 sizeof(m_au_fname), lemp_fnameStatus, TRUE)

 ADO_VARIABLE_LENGTH_ENTRY2(3, adVarChar, m_au_lname,
 sizeof(m_au_lname), lemp_lnameStatus, TRUE)

 ADO_VARIABLE_LENGTH_ENTRY2(4, adVarChar, m_au_city,
 sizeof(m_au_city), lemp_cityStatus, TRUE)

 ADO_VARIABLE_LENGTH_ENTRY2(5, adChar, m_au_state,
 sizeof(m_au_state), lemp_stateStatus, TRUE)

END_ADO_BINDING()

public:
 char m_au_fname[21];
 ULONG lemp_fnameStatus;
 char m_au_lname[41];
 ULONG lemp_lnameStatus;
 char m_au_city[21];
 ULONG lemp_cityStatus;
 char m_au_state[3];
 ULONG lemp_stateStatus;
};

// EndMoveH


Microsoft OLE DB Provider for Oracle

 Copy code hover
[image]

Microsoft OLE DB Provider for Oracle
Send feedback

The Microsoft OLE DB Provider for Oracle allows ADO to access Oracle databases.

Connection String Parameters

To connect to this provider, set the Provider argument of the ConnectionString property to:

Copy code Copy code

MSDAORA

Reading the Provider property will return this string as well.

If a join query with a keyset or dynamic cursor is executed in an Oracle database, an error occurs. Oracle only supports a static read-only cursor.

Typical Connection String

A typical connection string for this provider is:

Copy code Copy code

"Provider=MSDAORA;Data Source=serverName;User ID=userName; Password=userPassword;"

The string consists of these keywords:

Keyword | Description
Provider | Specifies the OLE DB Provider for Oracle.
Data Source | Specifies the name of a server.
User ID | Specifies the user name.
Password | Specifies the user password.

Provider-Specific Connection Parameters

The provider supports several provider-specific connection parameters in addition to those defined by ADO. As with the ADO connection properties, these provider-specific properties can be set via the Properties collection of a Connection or as part of the ConnectionString.

These parameters are fully described in the OLE DB Programmer's Reference. (The ADO Dynamic Property Index provides a cross-reference between these parameter names and the corresponding OLE DB properties.)

Parameter | Description
Window Handle | Indicates the window handle to use to prompt for additional information.
Locale Identifier | Indicates a unique 32-bit number (for example, 1033) that specifies preferences related to the user's language. These preferences indicate how dates and times are formatted, items are sorted alphabetically, strings are compared, and so on.
OLE DB Services | Indicates a bitmask that specifies OLE DB services to enable or disable.
Prompt | Indicates whether to prompt the user while a connection is being established.
Extended Properties | A string containing provider-specific, extended connection information. Use this property only for provider-specific connection information that cannot be described through the property mechanism.


Application.DDETerminate Method (Access)

 Copy code hover
[image]

Application.DDETerminate Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the DDETerminate statement to close a specified dynamic data exchange (DDE) channel.

Syntax

expression .DDETerminate(ChanNum)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
ChanNum | Required | Variant | A channel number to close, refers to a channel opened by the DDEInitiate function.

Return Value

Nothing

Remarks

For example, if you've opened a DDE channel to transfer data between Microsoft Excel and Microsoft Access, you can use the DDETerminate statement to close that channel once the transfer is complete.

If the channum argument isn't an integer corresponding to an open channel, a run-time error occurs.

Once a channel is closed, any subsequent DDE functions or statements performed on that channel cause a run-time error.

The DDETerminate statement has no effect on active DDE link expressions in fields on forms or reports.

If you need to manipulate another application's objects from Microsoft Access, you may want to consider using Automation.

See also

Concepts

Application Object

Other resources

Application Object Members


ToggleButton.LeftPadding Property (Access)

 Copy code hover
[image]

ToggleButton.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the toggle button and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .LeftPadding

expression A variable that represents a ToggleButton object.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


What You Can Do With ADO

 Copy code hover
[image]

What You Can Do With ADO
Send feedback

ADO is designed to provide developers with a powerful, logical object model for programmatically accessing, editing, and updating a wide variety of data sources through OLE DB system interfaces. The most common usage of ADO is to query a table or tables in a relational database, retrieve and display the results in an application, and perhaps allow users to make and save changes to the data. Other things that can be done programmatically with ADO include:

  • Querying a database using SQL and displaying the results.

  • Accessing information in a file store over the Internet.

  • Manipulating messages and folders in an e-mail system.

  • Saving data from a database into an XML file.

  • Allowing a user to review and make changes to data in database tables.

  • Creating and reusing parameterized database commands.

  • Executing stored procedures.

  • Dynamically creating a flexible structure, called a Recordset, to hold, navigate, and manipulate data.

  • Performing transactional database operations.

  • Filtering and sorting local copies of database information based on run-time criteria.

  • Creating and manipulating hierarchical results from databases.

  • Binding database fields to data-aware components.

  • Creating remote, disconnected Recordsets.

ADO must expose a wide variety of options and settings in order to provide such flexibility. Therefore it's important to take a methodical approach to learning how to use ADO in an application, breaking down each of your goals into manageable pieces.

Four primary operations are involved in most ADO programs: getting data, examining data, editing data, and updating data. The next four chapters examine each of these operations in more detail.

Before proceeding, familiarize yourself with the objects in the ADO Object Model. Then review HelloData: A Simple ADO Application. This application is written in Visual Basic and performs each of the four primary ADO operations.


ToggleButton.StatusBarText Property (Access)

 Copy code hover
[image]

ToggleButton.StatusBarText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.

Syntax

expression .StatusBarText

expression A variable that represents a ToggleButton object.

Remarks

You set the StatusBarText property by using a string expression up to 255 characters long.

Note Note

The length of the text you can display in the status bar depends on your computer hardware and video display.

You can use the StatusBarText property to provide specific information about a control. For example, when a text box has the focus, a brief instruction can tell the user what kind of data to enter

Note Note

You can also use the ControlTipText property to display a ScreenTip for a control.

If you create a control by dragging a field from the field list, the value in a field's Description property is copied to the StatusBarText property.

Example

The following example sets the status bar text to be displayed when the "Address_TextBox" control in the "Mailing List" form has the focus in Form View.

VBA Copy code Copy code
Forms("Mailing List").Controls("Address_TextBox"). _
 StatusBarText = "Enter the company's mailing address."

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


CodeProject.AllForms Property (Access)

 Copy code hover
[image]

CodeProject.AllForms Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllForms property to reference the AllForms collection and its related properties. Read-only AllForms object.

Syntax

expression .AllForms

expression A variable that represents a CodeProject object.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


ADOX Properties Reference

 Copy code hover
[image]

ADOX Properties Reference
Send feedback

In this section

  • ADOX Properties

  • ActiveConnection Property (ADOX)

  • Attributes Property (ADOX)

  • Clustered Property (ADOX)

  • Command Property (ADOX)

  • DateCreated Property (ADOX)

  • DateModified Property (ADOX)

  • DefinedSize Property (ADOX)

  • DeleteRule Property (ADOX)

  • IndexNulls Property (ADOX)

  • Name Property (ADOX)

  • NumericScale Property (ADOX)

  • ParentCatalog Property (ADOX)

  • Precision Property (ADOX)

  • PrimaryKey Property (ADOX)

  • RelatedColumn Property (ADOX)

  • RelatedTable Property (ADOX)

  • SortOrder Property (ADOX)

  • Unique Property (ADOX)

  • UpdateRule Property (ADOX)


OptionButton.Click Event (Access)

 Copy code hover
[image]

OptionButton.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Syntax

expression .Click

expression A variable that represents an OptionButton object.

Remarks

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


ADO Code Examples in Microsoft Visual C++ (Access)

 Copy code hover
[image]

ADO Code Examples in Microsoft Visual C++ (Access)
Send feedback

In this section

  • ADO Code Examples in Microsoft Visual C++

  • ADO Events Model Example (VC++)

  • AbsolutePage, PageCount, and PageSize Properties Example (VC++)

  • AbsolutePosition and CursorLocation Properties Example (VC++)

  • ActiveCommand Property Example (VC++)

  • ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction Properties Example (VC++)

  • ActualSize and DefinedSize Properties Example (VC++)

  • AddNew Method Example (VC++)

  • Append and CreateParameter Methods Example (VC++)

  • AppendChunk and GetChunk Methods Example (VC++)

  • Attributes and Name Properties Example (VC++)

  • BeginTrans, CommitTrans, and RollbackTrans Methods Example (VC++)

  • BOF, EOF, and Bookmark Properties Example (VC++)

  • CacheSize Property Example (VC++)

  • Cancel Method Example (VC++)

  • Clone Method Example (VC++)

  • CompareBookmarks Method Example (VC++)

  • ConnectionString, ConnectionTimeout, and State Properties Example (VC++)

  • Count Property Example (VC++)

  • CursorType, LockType, and EditMode Properties Example (VC++)

  • Delete Method Example (VC++)

  • Description, HelpContext, HelpFile, NativeError, Number, Source, and SQLState Properties Example (VC++)

  • Execute, Requery, and Clear Methods Example (VC++)

  • Filter and RecordCount Properties Example (VC++)

  • Find Method Example (VC++)

  • GetRows Method Example (VC++)

  • IsolationLevel and Mode Properties Example (VC++)

  • Item Property Example (VC++)

  • MarshalOptions Property Example (VC++)

  • MaxRecords Property Example (VC++)

  • Move Method Example (VC++)

  • MoveFirst, MoveLast, MoveNext, and MovePrevious Methods Example (VC++)

  • NextRecordset Method Example (VC++)

  • ADO NumericScale and Precision Properties Example (VC++)

  • Open and Close Methods Example (VC++)

  • OpenSchema Method Example (VC++)

  • Optimize Property Example (VC++)

  • OriginalValue and UnderlyingValue Properties Example (VC++)

  • Prepared Property Example (VC++)

  • Provider and DefaultDatabase Properties Example (VC++)

  • Refresh Method Example (VC++)

  • Resync Method Example (VC++)

  • Save and Open Methods Example (VC++)

  • Seek Method and Index Property Example (VC++)

  • Sort Property Example (VC++)

  • Source Property Example (VC++)

  • State Property Example (VC++)

  • Status Property Example (VC++)

  • StayInSync Property Example (VC++)

  • Supports Method Example (VC++)

  • Type Property Example (Field) (VC++)

  • Type Property Example (Property) (VC++)

  • Update and CancelUpdate Methods Example (VC++)

  • UpdateBatch and CancelBatch Methods Example (VC++)

  • Value Property Example (VC++)

  • Version Property Example (VC++)


Local or Anonymous replicas cannot be made the design master. (Error 3771)

 Copy code hover
[image]

Local or Anonymous replicas cannot be made the design master. (Error 3771)
Send feedback

Local or Anonymous replicas of the Design Master cannot be made because they do not contain the complete system information of the replica set. Only Global replicas of the Design Master can be made. You want to make a new Design Master only if you are sure the current one is invalid and no longer functioning as a Design Master, or if the Design Master needs to be moved.


Cellset Object (ADO MD Reference)

 Copy code hover
[image]

Cellset Object (ADO MD Reference)
Send feedback

In this section

  • Cellset Object (ADO MD)

  • Cellset Properties, Methods, and Events (ADO MD)


Levels Collection (ADO MD)

 Copy code hover
[image]

Levels Collection (ADO MD)
Send feedback

Contains the Level objects that make up a hierarchy.

Remarks

Levels is a standard ADO collection. With the properties and methods of a collection, you can do the following:

  • Obtain the number of objects in the collection with the Count property.

  • Return an object from the collection with the default Item property.

  • Update the objects in the collection from the provider with the Refresh method.


Cannot have aggregate function in WHERE clause

 Copy code hover
[image]

Cannot have aggregate function in WHERE clause <clause>. (Error 3096)
Send feedback

You cannot use an aggregate function in the WHERE clause of an SQL statement.


DataSpace Object and CreateObject Method Example (VBScript)

 Copy code hover
[image]

DataSpace Object and CreateObject Method Example (VBScript)
Send feedback

The following example shows how to use the CreateObject method of the RDS.DataSpace with the default business object, RDSServer.DataFactory. To test this example, cut and paste this code between the <Body> and </Body> tags in a normal HTML document and name it DataSpaceVBS.asp. ASP script will identify your server.

VBS Copy code Copy code
<!-- BeginDataSpaceVBS --><html>
<head><!--use the following META tag instead of adovbs.inc-->
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" --><meta name="VI60_DefaultClientScript" content=VBScript>
<meta name="GENERATOR" content="Microsoft Visual Studio 6.0"><title>DataSpace Object and CreateObject Method Example (VBScript)</title>
<style><!--
body {font-family: 'Verdana','Arial','Helvetica',sans-serif;
BACKGROUND-COLOR:white;COLOR:black;
}.thead {
background-color: #008080;font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;color: white;
}.thead2 {
background-color: #800000;font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;color: white;
}.tbody {
text-align: center;background-color: #f7efde;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
}-->
</style></head>
<body><h1>DataSpace Object and CreateObject Method Example (VBScript)</h1>
<H2>RDS API Code Examples</H2><HR>
<H3>Using Query Method of RDSServer.DataFactory</H3>
<!-- RDS.DataSpace ID rdsDS--><OBJECT ID="rdsDS" WIDTH=1 HEIGHT=1
CLASSID="CLSID:BD96C556-65A3-11D0-983A-00C04FC29E36"></OBJECT>
<!-- RDS.DataControl with parameters set at run time --><OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
ID=RDS WIDTH=1 HEIGHT=1></OBJECT>
<TABLE DATASRC=#RDS><TBODY>
<TR><TD><SPAN DATAFLD="FirstName"></SPAN></TD>
<TD><SPAN DATAFLD="LastName"></SPAN></TD></TR>
</TBODY></TABLE>
<HR><INPUT TYPE=BUTTON NAME="Run" VALUE="Run">
<H4>Click Run -The <i>CreateObject</i> Method of the RDS.DataSpace Object Creates an instance of the RDSServer.DataFactory.
The <i>Query</i> Method of the RDSServer.DataFactory is used to bring back a Recordset.</H4>
<Script Language="VBScript">
Dim rdsDFDim strServer
Dim strCnxnDim strSQL
strServer = "http://<%=Request.ServerVariables("SERVER_NAME")%>"strCnxn = "Provider='sqloledb';Data Source=" & _
"<%=Request.ServerVariables("SERVER_NAME")%>" & ";" & _"Integrated Security='SSPI';Initial Catalog='Northwind';"
strSQL = "Select FirstName, LastName from Employees"
Sub Run_OnClick()
Dim rs' Create Data Factory
Set rdsDF = rdsDS.CreateObject("RDSServer.DataFactory", strServer)'Get Recordset
Set rs = rdsDF.Query(strCnxn, strSQL)' Use RDS.DataControl to bind Recordset to data-aware Table above
RDS.SourceRecordset = rs
End Sub</Script>
</body></html>
<!-- EndDataSpaceVBS -->

The following example shows how to use the CreateObject method to create an instance of a custom business object, VbBusObj.VbBusObjCls. It also uses the Active Server Pages scripting to identify the Web server name.

To see the complete example, open the sample applications selector. In the Client Tier column, select VBScript in Internet Explorer. In the Middle Tier column, select Custom Visual Basic Business Object.

VBS Copy code Copy code

Sub Window_OnLoad()
   strServer = "http://<%=Request.ServerVariables("SERVER_NAME")%>"
   Set BO = ADS1.CreateObject("VbBusObj.VbBusObjCls", strServer)
   txtConnect.Value = "dsn=Pubs;uid=MyUserId;pwd=MyPassword;"
   txtGetRecordset.Value = "Select * From authors for Browse"
End Sub


QueryDef Object Reference (DAO)

 Copy code hover
[image]

QueryDef Object Reference (DAO)
Send feedback

In this section

  • QueryDef Object (DAO)

  • QueryDef Members (DAO)

  • QueryDef Properties (DAO)

  • QueryDef Methods (DAO)


NavigationButton.OnDblClick Property (Access)

 Copy code hover
[image]

NavigationButton.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnDblClick

expression A variable that represents a NavigationButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_DblClick" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


TabControl.BorderTint Property (Access)

 Copy code hover
[image]

TabControl.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderTint

expression A variable that represents a TabControl object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens BorderColor by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Recordset2.RecordStatus Property (DAO)

 Copy code hover
[image]

Recordset2.RecordStatus Property (DAO)
Send feedback

Syntax

expression .RecordStatus

expression A variable that represents a Recordset2 object.

Remarks

The value of the RecordStatus property indicates whether and how the current record will be involved in the next optimistic batch update.

When a user changes a record, the RecordStatus for that record automatically changes to dbRecordModified. Similarly, if a record is added or deleted, RecordStatus reflects the appropriate constant. When you then use a batch-mode Update method, DAO will submit an appropriate operation to the remote server for each record, based on the record's RecordStatus property.

Example

This example uses the RecordStatus and DefaultCursorDriver properties to show how changes to a local Recordset are tracked during batch updating. The RecordStatusOutput function is required for this procedure to run.

VBA Copy code Copy code
Sub RecordStatusX()

 Dim wrkMain As Workspace
 Dim conMain As Connection
 Dim rstTemp As Recordset2

 Set wrkMain = CreateWorkspace("ODBCWorkspace", _
 "admin", "", dbUseODBC)
 ' This DefaultCursorDriver setting is required for
 ' batch updating.
 wrkMain.DefaultCursorDriver = dbUseClientBatchCursor

 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conMain = wrkMain.OpenConnection("Publishers", _
 dbDriverNoPrompt, False, _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 ' The following locking argument is required for
 ' batch updating.
 Set rstTemp = conMain.OpenRecordset( _
 "SELECT * FROM authors", dbOpenDynaset, 0, _
 dbOptimisticBatch)

 With rstTemp
 .MoveFirst
 Debug.Print "Original record: " & !au_lname
 Debug.Print , RecordStatusOutput2(.RecordStatus)

 .Edit
 !au_lname = "Bowen"
 .Update
 Debug.Print "Edited record: " & !au_lname
 Debug.Print , RecordStatusOutput2(.RecordStatus)

 .AddNew
 !au_lname = "NewName"
 .Update
 Debug.Print "New record: " & !au_lname
 Debug.Print , RecordStatusOutput2(.RecordStatus)

 .Delete
 Debug.Print "Deleted record: " & !au_lname
 Debug.Print , RecordStatusOutput2(.RecordStatus)

 ' Close the local recordset without updating the
 ' data on the server.
 .Close
 End With

 conMain.Close
 wrkMain.Close

End Sub

Function RecordStatusOutput(lngTemp As Long) As String

 Dim strTemp As String

 strTemp = ""

 ' Construct an output string based on the RecordStatus
 ' value.
If lngTemp = dbRecordUnmodified Then _
 strTemp = "[dbRecordUnmodified]"
 If lngTemp = dbRecordModified Then _
 strTemp = "[dbRecordModified]"
 If lngTemp = dbRecordNew Then _
 strTemp = "[dbRecordNew]"
 If lngTemp = dbRecordDeleted Then _
 strTemp = "[dbRecordDeleted]"
 If lngTemp = dbRecordDBDeleted Then _
 strTemp = "[dbRecordDBDeleted]"

 RecordStatusOutput = strTemp

End Function


CheckBox.KeyDown Event (Access)

 Copy code hover
[image]

CheckBox.KeyDown Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyDown(KeyCode, Shift)

expression A variable that represents a CheckBox object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyDown property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyDown event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyDown event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyDown event occurs when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

Example

The following example determines whether you have pressed the SHIFT, CTRL, or ALT key.

To try the example, add the following event procedure to a form containing a text box named KeyHandler.

VBA Copy code Copy code
Private Sub KeyHandler_KeyDown(KeyCode As Integer, _
     Shift As Integer)
    Dim intShiftDown As Integer, intAltDown As Integer
    Dim intCtrlDown As Integer

    ' Use bit masks to determine which key was pressed.
    intShiftDown = (Shift And acShiftMask) > 0
    intAltDown = (Shift And acAltMask) > 0
    intCtrlDown = (Shift And acCtrlMask) > 0
    ' Display message telling user which key was pressed.
    If intShiftDown Then MsgBox "You pressed the SHIFT key."
    If intAltDown Then MsgBox "You pressed the ALT key."
    If intCtrlDown Then MsgBox "You pressed the CTRL key."
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


EmptyCell.VerticalAnchor Property (Access)

 Copy code hover
[image]

EmptyCell.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified text box is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2010

Syntax

expression .VerticalAnchor

expression A variable that represents an EmptyCell object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


Attachment.GridlineThemeColorIndex Property (Access)

 Copy code hover
[image]

Attachment.GridlineThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineThemeColorIndex

expression A variable that represents an Attachment object.

Remarks

The GridlineThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 (Default) | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the GridlineThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


CubeDef Object (ADO MD)

 Copy code hover
[image]

CubeDef Object (ADO MD)
Send feedback

Represents a cube from a multidimensional schema, containing a set of related dimensions.

Remarks

With the collections and properties of a CubeDef object, you can do the following:

  • Identify a CubeDef with the Name property.

  • Return a string that describes the cube with the Description property.

  • Return the dimensions that make up the cube with the Dimensions collection.

  • Obtain additional information about the CubeDef with the standard ADO Properties collection.

The Properties collection contains provider-supplied properties. The following table lists properties that might be available. The actual property list may differ depending upon the implementation of the provider. See the documentation for your provider for a more complete list of available properties.

Name | Description
CatalogName | The name of the catalog to which this cube belongs.
CreatedOn | Date and time of cube creation.
CubeGUID | Cube GUID.
CubeName | The name of the cube.
CubeType | The type of the cube.
DataUpdatedBy | User ID of the person doing the last data update.
Description | A meaningful description of the cube.
LastSchemaUpdate | Date and time of last schema update.
SchemaName | The name of the schema to which this cube belongs.
SchemaUpdatedBy | User ID of the person doing the last schema update.


TextBox.SmartTags Property (Access)

 Copy code hover
[image]

TextBox.SmartTags Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a SmartTags collection that represents the collection of smart tags that have been added to a control. .

Syntax

expression .SmartTags

expression A variable that represents a TextBox object.

Remarks

Note Note

Unlike the SmartTags collections in Microsoft Excel and Microsoft Word, the SmartTags collection in Microsoft Access is zero-based. Therefore, the code control.SmartTags(0) returns the first smart tag for the specified control.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


OptionGroup.MouseUp Event (Access)

 Copy code hover
[image]

OptionGroup.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents an OptionGroup object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was released to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Columns Collection Properties, Methods, and Events (ADOX)

 Copy code hover
[image]

Columns Collection Properties, Methods, and Events (ADOX)
Send feedback

Properties

Count Property

Item Property

Methods

Append Method (Columns)

Delete Method (Collections)

Refresh Method

Events

None.


AccessObject.Type Property (Access)

 Copy code hover
[image]

AccessObject.Type Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the value of an AccessObject object type. Read-only AcObjectType.

Syntax

expression .Type

expression A variable that represents an AccessObject object.

See also

Concepts

AccessObject Object

Other resources

AccessObject Object Members


RDS Programming Model with Objects

 Copy code hover
[image]

RDS Programming Model with Objects
Send feedback

The goal of RDS is to gain access to and update data sources through an intermediary such as IIS. The programming model specifies the sequence of activities necessary to accomplish this goal. The object model specifies the objects whose methods and properties affect the programming model.

RDS provides the means to perform the following sequence of actions:

  • Specify the program to be invoked on the server, and obtain a way (proxy) to refer to it from the client (RDS.DataSpace).

  • Invoke the server program. Pass parameters to the server program that identifies the data source and the command to issue (proxy or RDS.DataControl).

  • The server program obtains a Recordset object from the data source, typically by using ADO. Optionally, the Recordset object is processed on the server (RDSServer.DataFactory).

  • The server program returns the final Recordset object to the client application (proxy).

  • On the client, the Recordset object is put into a form that can be easily used by visual controls (visual control and RDS.DataControl).

  • Changes to the Recordset object are sent back to the server and used to update the data source (RDS.DataControl or RDSServer.DataFactory).


Could not decrypt file. (Error 3161)

 Copy code hover
[image]

Could not decrypt file. (Error 3161)
Send feedback

You tried to access an encrypted Btrieve or Paradox table, but the password you provided is not correct. Try the operation again and enter the correct password.


The type of synchronization you are attempting is not valid. (Error 3546)

 Copy code hover
[image]

The type of synchronization you are attempting is not valid. (Error 3546)
Send feedback

The requested synchronization cannot be performed because of an invalid exchange option in the Synchronize method. Use a valid synchronization type in your program.


Operation.Parent Property (Access)

 Copy code hover
[image]

Operation.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Parent

expression A variable that represents an Operation object.

See also

Concepts

Operation Object

Other resources

Operation Object Members


ActionEnum

 Copy code hover
[image]

ActionEnum
Send feedback

Specifies the type of action to be performed when SetPermissions is called.

Constant | Value | Description
adAccessDeny | 3 | The group or user will be denied the specified permissions.
adAccessGrant | 1 | The group or user will have at least the requested permissions.
adAccessRevoke | 4 | Any explicit access rights the group or user has will be revoked.
adAccessSet | 2 | The group or user will have exactly the requested permissions.


Columns Collection (ADOX)

 Copy code hover
[image]

Columns Collection (ADOX)
Send feedback

Contains all Column objects of a table, index, or key.

Remarks

The Append method for a Columns collection is unique for ADOX. You can:

  • Add a new column to the collection with the Append method.

The remaining properties and methods are standard to ADO collections. You can:

  • Access a column in the collection with the Item property.

  • Return the number of columns contained in the collection with the Count property.

  • Remove a column from the collection with the Delete method.

  • Update the objects in the collection to reflect the current database's schema with the Refresh method.

Note Note

An error will occur when appending a Column to the Columns collection of an Index if the Column does not exist in a Table that is already appended to the Tables collection.


ToggleButton.SetFocus Method (Access)

 Copy code hover
[image]

ToggleButton.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Syntax

expression .SetFocus

expression A variable that represents a ToggleButton object.

Return Value

Nothing

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.

Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.

Example

The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:

VBA Copy code Copy code
Forms!Employees!EmployeeID.SetFocus

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Recordset and SourceRecordset Properties Example (VBScript)

 Copy code hover
[image]

Recordset and SourceRecordset Properties Example (VBScript)
Send feedback

The following example shows how to set the necessary parameters of the RDSServer.DataFactory default business rules at run time.

To test this example, cut and paste this code between the <Body> and </Body> tags in a normal HTML document and name it RecordsetVBS.asp. ASP script will identify your server.

VBS Copy code Copy code
<!-- BeginRecordSetVBS --><%@ Language=VBScript %>
<html><head>
<meta name="VI60_DefaultClientScript" content=VBScript><meta name="GENERATOR" content="Microsoft Visual Studio 6.0">
<title>Recordset and SourceRecordset Properties Example (VBScript)</title><style>
<!--body {
font-family: 'Verdana','Arial','Helvetica',sans-serif;BACKGROUND-COLOR:white;
COLOR:black;}
.thead {background-color: #008080;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.thead2 {background-color: #800000;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.tbody {text-align: center;
background-color: #f7efde;font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;}
--></style>
</head>
<body><h1>Recordset and SourceRecordset Properties Example (VBScript)</h1>
<Center><H2>RDS API Code Examples</H2>
<HR><H3>Using SourceRecordset and Recordset with RDSServer.DataFactory</H3>
<!-- RDS.DataSpace ID RDS1 --><OBJECT ID="RDS1" WIDTH=1 HEIGHT=1
CLASSID="CLSID:BD96C556-65A3-11D0-983A-00C04FC29E36"></OBJECT>
<!-- RDS.DataControl with parameters set at Run Time --><OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
ID=RDC WIDTH=1 HEIGHT=1></OBJECT>
<TABLE DATASRC=#RDC><TR>
<TD> <INPUT DATAFLD="FirstName" SIZE=15> </TD><TD> <INPUT DATAFLD="LastName" SIZE=15></TD>
</TR></TABLE>
<HR><Input Size=70 Name="txtServer" Value="http://<%=Request.ServerVariables("SERVER_NAME")%>"><BR>
<Input Size=70 Name="txtConnect" Value="Provider='sqloledb';Integrated Security='SSPI';Initial Catalog='Northwind'"><BR><Input Size=70 Name="txtSQL" Value="SELECT FirstName, LastName FROM Employees">
<HR><INPUT TYPE=BUTTON NAME="Run" VALUE="Run"><BR>
</Center><Script Language="VBScript">
Dim rdsDFDim strServer
strServer = "http://<%=Request.ServerVariables("SERVER_NAME")%>"
Sub Run_OnClick()
Dim rs' Create RDSServer.DataFactory Object
Set rdsDF = RDS1.CreateObject("RDSServer.DataFactory", strServer)' Get Recordset
Set rs = rdsDF.Query(txtConnect.Value,txtSQL.Value)
' Set parameters of RDS.DataControl at run timeRDC.Server = txtServer.Value
RDC.SQL = txtSQL.ValueRDC.Connect = txtConnect.Value
RDC.Refresh
End Sub
</Script>
</body></html>
<!-- EndRecordsetVBS -->


Cannot perform cascading operation on table

 Copy code hover
[image]

Cannot perform cascading operation on table <name> because it is currently in use. (Error 3414)
Send feedback

You are trying to save a value to a primary key field that is included in a relationship.

In Microsoft Access, the Cascade Update Related Fields option is selected for the relationship, or in DAO code, the dbRelationUpdateCascade option is specified for the Relation object's Attributes property. Therefore, your application is attempting to update the matching field in the related table.

The matching field cannot be updated because you have it open or locked on your computer. To save the record, you must first close the related table.


ObjectFrame.BorderStyle Property (Access)

 Copy code hover
[image]

ObjectFrame.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Syntax

expression .BorderStyle

expression A variable that represents an ObjectFrame object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


CommandButton.BorderTint Property (Access)

 Copy code hover
[image]

CommandButton.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderTint

expression A variable that represents a CommandButton object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


OptionGroup.BorderColor Property (Access)

 Copy code hover
[image]

OptionGroup.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Syntax

expression .BorderColor

expression A variable that represents an OptionGroup object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


ADO Properties Reference

 Copy code hover
[image]

ADO Properties Reference
Send feedback

In this section

  • ADO Properties

  • AbsolutePage Property (ADO)

  • AbsolutePosition Property (ADO)

  • ActiveCommand Property (ADO)

  • ActiveConnection Property (ADO)

  • ActualSize Property (ADO)

  • Attributes Property (ADO)

  • BOF, EOF Properties (ADO)

  • Bookmark Property (ADO)

  • CacheSize Property (ADO)

  • Chapter Property (ADO)

  • Charset Property (ADO)

  • CommandText Property (ADO)

  • CommandTimeout Property (ADO)

  • CommandType Property (ADO)

  • ConnectionString Property (ADO)

  • ConnectionTimeout Property (ADO)

  • Count Property (ADO)

  • CursorLocation Property (ADO)

  • CursorType Property (ADO)

  • DataMember Property (ADO)

  • DataSource Property (ADO)

  • DefaultDatabase Property (ADO)

  • DefinedSize Property (ADO)

  • Description Property (ADO)

  • Direction Property (ADO)

  • EditMode Property (ADO)

  • EOS Property (ADO)

  • Filter Property (ADO)

  • HelpContext, HelpFile Properties (ADO)

  • Index Property (ADO)

  • IsolationLevel Property (ADO)

  • Item Property (ADO)

  • LineSeparator Property (ADO)

  • LockType Property (ADO)

  • MarshalOptions Property (ADO)

  • MaxRecords Property (ADO)

  • Mode Property (ADO)

  • Name Property (ADO)

  • NativeError Property (ADO)

  • Number Property (ADO)

  • NumericScale Property (ADO)

  • OriginalValue Property (ADO)

  • PageCount Property (ADO)

  • PageSize Property (ADO)

  • ParentRow Property (ADO)

  • ParentURL Property (ADO)

  • Position Property (ADO)

  • Precision Property (ADO)

  • Prepared Property (ADO)

  • Provider Property (ADO)

  • RecordCount Property (ADO)

  • RecordType Property (ADO)

  • Row Property (ADO)

  • RowPosition Property (ADO)

  • Rowset Property (ADO)

  • Size Property (ADO)

  • Sort Property (ADO)

  • Source Property (ADO Error)

  • Source Property (ADO Record)

  • Source Property (ADO Recordset)

  • SQLState Property (ADO)

  • State Property (ADO)

  • StayInSync Property (ADO)

  • Status Property (ADO Field)

  • Status Property (ADO Recordset)

  • Type Property (ADO)

  • Type Property (ADO Stream)

  • UnderlyingValue Property (ADO)

  • Value Property (ADO)

  • Version Property (ADO)


ToggleButton.HoverForeColor Property (Access)

 Copy code hover
[image]

ToggleButton.HoverForeColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the text displayed on the control when the user rests the mouse cursor over it. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HoverForeColor

expression A variable that represents a ToggleButton object.

Remarks

The HoverForeColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


ComboBox.GridlineShade Property (Access)

 Copy code hover
[image]

ComboBox.GridlineShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineShade

expression A variable that represents a ComboBox object.

Remarks

The GridlineShade property contains a numeric expression that can be used to darken the theme color in the GridlineColor property. The default value of the GridlineShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


CommandButton.Parent Property (Access)

 Copy code hover
[image]

CommandButton.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a CommandButton object.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


BoundObjectFrame.Scaling Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Scaling Property (Access)
See also Send feedback

Published: July 16, 2012

Controls how the contents of an object frame control are displayed. Read/write Byte.

Syntax

expression .Scaling

expression A variable that represents a BoundObjectFrame object.

Remarks

The Scaling property corresponds to the Size Mode box in the object frame's Properties window. This property accepts the following values.

  • 0 (Clip) If the object exceeds the control's boundaries, the object is clipped at the boundaries of the control.

  • 1 (Stretch) If the object does not exceed the control's boundaries, the object is stretched to the edges of the control's boundary.

  • 2 (Zoom) The object is zoomed in or out to fit the control's boundaries. This is different from the Stretch setting, in that the object is not necessarily distorted to touch all boundaries of the control. In other words, the object may touch the horizontal edges of the control, but not necessarily the vertical edges of the control, and vice versa.

Example

The following example sets the size mode of the OLE control "Customer Picture" on the "Order Entry" form to zoomed.

VBA Copy code Copy code
Forms("Order Entry").Controls("Customer Picture").Scaling = 2

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Rectangle Members (Access)

 Copy code hover
[image]

Rectangle Members (Access)
Send feedback

Published: July 16, 2012

This object corresponds to a rectangle control. The rectangle control displays a rectangle on a form or report.

Events

Name | Description
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the rectangle is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified rectangle is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


RecordStatusEnum

 Copy code hover
[image]

RecordStatusEnum
Send feedback

Specifies the status of a record with regard to batch updates and other bulk operations.

Constant | Value | Description
adRecCanceled | 0x100 | Indicates that the record was not saved because the operation was canceled.
adRecCantRelease | 0x400 | Indicates that the new record was not saved because the existing record was locked.
adRecConcurrencyViolation | 0x800 | Indicates that the record was not saved because optimistic concurrency was in use.
adRecDBDeleted | 0x40000 | Indicates that the record has already been deleted from the data source.
adRecDeleted | 0x4 | Indicates that the record was deleted.
adRecIntegrityViolation | 0x1000 | Indicates that the record was not saved because the user violated integrity constraints.
adRecInvalid | 0x10 | Indicates that the record was not saved because its bookmark is invalid.
adRecMaxChangesExceeded | 0x2000 | Indicates that the record was not saved because there were too many pending changes.
adRecModified | 0x2 | Indicates that the record was modified.
adRecMultipleChanges | 0x40 | Indicates that the record was not saved because it would have affected multiple records.
adRecNew | 0x1 | Indicates that the record is new.
adRecObjectOpen | 0x4000 | Indicates that the record was not saved because of a conflict with an open storage object.
adRecOK | 0 | Indicates that the record was successfully updated.
adRecOutOfMemory | 0x8000 | Indicates that the record was not saved because the computer has run out of memory.
adRecPendingChanges | 0x80 | Indicates that the record was not saved because it refers to a pending insert.
adRecPermissionDenied | 0x10000 | Indicates that the record was not saved because the user has insufficient permissions.
adRecSchemaViolation | 0x20000 | Indicates that the record was not saved because it violates the structure of the underlying database.
adRecUnmodified | 0x8 | Indicates that the record was not modified.

ADO/WFC Equivalent

AdoEnums.RecordStatus.

Package: com.ms.wfc.data

Constant

AdoEnums.RecordStatus.CANCELED

AdoEnums.RecordStatus.CANTRELEASE

AdoEnums.RecordStatus.CONCURRENCYVIOLATION

AdoEnums.RecordStatus.DBDELETED

AdoEnums.RecordStatus.DELETED

AdoEnums.RecordStatus.INTEGRITYVIOLATION

AdoEnums.RecordStatus.INVALID

AdoEnums.RecordStatus.MAXCHANGESEXCEEDED

AdoEnums.RecordStatus.MODIFIED

AdoEnums.RecordStatus.MULTIPLECHANGES

AdoEnums.RecordStatus.NEW

AdoEnums.RecordStatus.OBJECTOPEN

AdoEnums.RecordStatus.OK

AdoEnums.RecordStatus.OUTOFMEMORY

AdoEnums.RecordStatus.PENDINGCHANGES

AdoEnums.RecordStatus.PERMISSIONDENIED

AdoEnums.RecordStatus.SCHEMAVIOLATION

AdoEnums.RecordStatus.UNMODIFIED


Cannot replicate the table; the number of columns exceeds the maximum allowed. (Error 3585)

 Copy code hover
[image]

Cannot replicate the table; the number of columns exceeds the maximum allowed. (Error 3585)
Send feedback

The table has exceeded the maximum number of columns allowed. If the table has less than 251 columns, compacting the database may retrieve any available columns that are still counting toward the limit.


TextBox.OnDirty Property (Access)

 Copy code hover
[image]

TextBox.OnDirty Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dirty box in the Properties window of a form or report. Read/write String.

Syntax

expression .OnDirty

expression A variable that represents a TextBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Dirty event occurs when the contents of a form or the text portion of a combo box changes. It also occurs when you move from one page to another page in a tab control.

The OnClose value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dirty box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dirty box is blank, the property value is an empty string.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Database.Transactions Property (DAO)

 Copy code hover
[image]

Database.Transactions Property (DAO)
Send feedback

Returns a value that indicates whether an object supports transactions. Read-only Boolean.

Syntax

expression .Transactions

expression A variable that represents a Database object.


AllModules Object (Access)

 Copy code hover
[image]

AllModules Object (Access)
See also Send feedback

Published: July 16, 2012

The AllModules collection contains an AccessObject of each module in the CurrentProject or CodeProject object.

Remarks

The CurrentProject or CodeProject object has an AllModules collection containing AccessObject objects that describe instances of all the Module objects specified by CurrentProject or CodeProject. For example, you can enumerate the AllModules collection in Visual Basic to set or return the values of properties of individual AccessObject objects in the collection.

You can refer to an individual AccessObject object in the AllModules collection either by referring to the object by name, or by referring to its index within the collection. If you want to refer to a specific object in the AllModules collection, it's better to refer to the module by name because a module's collection index may change.

The AllModules collection is indexed beginning with zero. If you refer to a module by its index, the first module is AllModules(0), the second module is AllModules(1), and so on.

Note Note

To list all open modules in the database, use the IsLoaded property of each AccessObject object in the AllModules collection. You can then use the Name property of each individual AccessObject object to return the name of a module.

You can't add or delete an AccessObject object from the AllModules collection.

Example

The following example prints the name of each open AccessObject object in the AllModules collection.

VBA Copy code Copy code
Sub AllModules()
 Dim obj As AccessObject, dbs As Object
 Set dbs = Application.CurrentProject
 ' Search for open AccessObject objects in AllModules collection.
 For Each obj In dbs.AllModules
 If obj.IsLoaded = True Then
 ' Print name of obj.
 Debug.Print obj.Name
 End If
 Next obj
End Sub

See also

Concepts

Access Object Model Reference

Other resources

AllModules Object Members


The Microsoft Access database engine cannot open the file

 Copy code hover
[image]

The Microsoft Access database engine cannot open the file <name>. It is already opened exclusively by another user, or you need permission to view its data. (Error 3051)
Send feedback

Possible causes:

  • You must have permission to read data in the specified file in order to view its data. To change your permission assignments, see your system administrator or the table or query's creator.

  • You tried to open the indicated file exclusively, but another user already has the file open.


TextBox.KeyDown Event (Access)

 Copy code hover
[image]

TextBox.KeyDown Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyDown(KeyCode, Shift)

expression A variable that represents a TextBox object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyDown property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyDown event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyDown event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyDown event occurs when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

Example

The following example determines whether you have pressed the SHIFT, CTRL, or ALT key.

To try the example, add the following event procedure to a form containing a text box named KeyHandler.

VBA Copy code Copy code
Private Sub KeyHandler_KeyDown(KeyCode As Integer, _
     Shift As Integer)
    Dim intShiftDown As Integer, intAltDown As Integer
    Dim intCtrlDown As Integer

    ' Use bit masks to determine which key was pressed.
    intShiftDown = (Shift And acShiftMask) > 0
    intAltDown = (Shift And acAltMask) > 0
    intCtrlDown = (Shift And acCtrlMask) > 0
    ' Display message telling user which key was pressed.
    If intShiftDown Then MsgBox "You pressed the SHIFT key."
    If intAltDown Then MsgBox "You pressed the ALT key."
    If intCtrlDown Then MsgBox "You pressed the CTRL key."
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Attachment.LabelAlign Property (Access)

 Copy code hover
[image]

Attachment.LabelAlign Property (Access)
See also Send feedback

Published: July 16, 2012

The LabelAlign property specifies the text alignment within attached labels on new controls. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .LabelAlign

expression A variable that represents an Attachment object.

Remarks

The LabelAlign property uses the following settings.

Setting | Description
0 | (Default) The label text aligns to the left.
1 | The label text aligns to the left.
2 | The label text is centered.
3 | The label text aligns to the right.
4 | The label text is evenly distributed.

You can set the LabelAlign property by using a control's default control style or the DefaultControl property in Visual Basic.

When created, controls have an attached label (as long as their AutoLabel property is set to Yes). Changes to the LabelAlign default control style setting affect only controls created on the current form or report.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


CheckBox.GridlineWidthTop Property (Access)

 Copy code hover
[image]

CheckBox.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified check box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthTop

expression A variable that represents a CheckBox object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Filter and RecordCount Properties Example (VC++)

 Copy code hover
[image]

Filter and RecordCount Properties Example (VC++)
Send feedback

This example uses the Filter property to open a new Recordset based on a specified condition applied to an existing Recordset. It uses the RecordCount property to show the number of records in the two Recordsets. The FilterField function is required for this procedure to run.

Copy code Copy code

// BeginFilterCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <stdio.h>
#include <ole2.h>
#include <conio.h>
#include "FilterX.h"

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void FilterX(void);
_RecordsetPtr FilterField(_RecordsetPtr rstTemp, _bstr_t strField, _bstr_t strFilter);
void FilterX2(void);
void PrintProviderError(_ConnectionPtr pCnn1);
void PrintComError(_com_error &e);
inline char* mygets(char* strDest, int n)
{
 char strExBuff[10];
 char* pstrRet = fgets(strDest, n, stdin);

 if (pstrRet == NULL)
 return NULL;

 if (!strrchr(strDest, '\n'))
 // Exhaust the input buffer.
 do
 {
 fgets(strExBuff, sizeof(strExBuff), stdin);
 }while (!strrchr(strExBuff, '\n'));
 else
 // Replace '\n' with '\0'
 strDest[strrchr(strDest, '\n') - strDest] = '\0';

 return pstrRet;
}

void main()
{
 HRESULT hr = S_OK;

 if(FAILED(::CoInitialize(NULL)))
 return;

 FilterX();

 //Wait here for user to see the output..
 printf("\nPress any key to Continue...");
 getch();

 //Clear the screen for the next display
 system("cls");

 FilterX2();

 //Wait here for user to see the output..
 printf("\nPress any key to Exit...");
 getch();
 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// FilterX Function //
// //
///////////////////////////////////////////////////////////

void FilterX()
{
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr rstPublishers = NULL;
 _RecordsetPtr rstPublishersCountry = NULL;

 //Define Other Variables
 HRESULT hr = S_OK;
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");
 int intPublisherCount = 0;
 long recCount = 0;
 _bstr_t strCountry;
 _bstr_t strMessage;
 char *tempStr;
 CHAR sz_CountryName[50];
 bool boolFlag = TRUE;
 try
 {
 // Open recordset with data from Publishers table.
 rstPublishers.CreateInstance(__uuidof(Recordset));
 rstPublishersCountry.CreateInstance(__uuidof(Recordset));

 rstPublishers->CursorType = adOpenStatic;

 TESTHR(rstPublishers->Open("publishers",strCnn,
 adOpenStatic , adLockReadOnly,adCmdTable));

 // Populate the Recordset.
 intPublisherCount = rstPublishers->RecordCount;

 // Get user input.
 printf("Enter a country to filter on:");
 mygets(sz_CountryName, 50);

 // Trim the string
 tempStr = strtok(sz_CountryName, " \t");
 strCountry = tempStr;
 if (tempStr == NULL)
 {
 boolFlag = FALSE;
 }

 if (boolFlag)
 {
 if (strcmp(sz_CountryName,""))
 {
 // Open a filtered Recordset object.
 rstPublishersCountry = FilterField(rstPublishers,
 "Country", strCountry);
 recCount = rstPublishersCountry->GetRecordCount();
 if (recCount==0)
 {
 printf("\nNo publishers from that country.\n");
 }
 else
 {
 // Print number of records for the original
 // Recordset object and the filtered Recordset
 // object.
 printf("\nOrders in original recordset:\n%d",
 intPublisherCount);
 printf("\nOrders in filtered recordset "
 "(Country = '%s'): \n%d\n\n", (LPCSTR)strCountry ,
 rstPublishersCountry->RecordCount);
 }
 }
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _variant_t vtConnect = rstPublishers->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 if (rstPublishers)
 if (rstPublishers->State == adStateOpen)
 rstPublishers->Close();
 if (rstPublishersCountry)
 if (rstPublishersCountry->State == adStateOpen)
 rstPublishersCountry->Close();
}

_RecordsetPtr FilterField(_RecordsetPtr rstTemp,_bstr_t strField,
 _bstr_t strFilter)
{
 // Set a filter on the specified Recordset object and then
 // open a new Recordset object.
 rstTemp->Filter = strField + " = '" + strFilter + "'";
 return rstTemp;
}

void FilterX2(void)
{
 _RecordsetPtr rstPublishers;
 CPublishers publishers;

 //Define Other Variables
 HRESULT hr = S_OK;
 IADORecordBinding *picRs = NULL; //Interface Pointer declared...

 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");
 try
 {
 // Open recordset with data from Publishers table.
 rstPublishers.CreateInstance(__uuidof(Recordset));

 rstPublishers->CursorType = adOpenStatic;

 TESTHR(rstPublishers->Open("SELECT * FROM publishers WHERE "
 "Country='USA'",strCnn,adOpenStatic,adLockReadOnly,
 adCmdText));

 //Open an IADORecordBinding interface pointer
 //which we'll use for Binding Recordset to a class
 TESTHR(rstPublishers->QueryInterface(
 __uuidof(IADORecordBinding), (LPVOID*)&picRs));

 //Bind the Recordset to a C++ Class here
 TESTHR(picRs->BindToRecordset(&publishers));

 // Print current data in recordset.
 rstPublishers->MoveFirst();

 while (!rstPublishers->EndOfFile)
 {
 printf("%s, %s\n",
 publishers.lP_pubnameStatus == adFldOK ?
 publishers.m_szP_pubname: "<NULL>",
 publishers.lP_countryStatus == adFldOK ?
 publishers.m_szP_country: "<NULL>");

 rstPublishers->MoveNext();
 }
 }
 catch (_com_error &e)
 {
 // Notify the user of errors if any.
 _variant_t vtConnect = rstPublishers->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (rstPublishers)
 if (rstPublishers->State == adStateOpen)
 rstPublishers->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pCnn1)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pCnn1->Errors->Count) > 0)
 {
 long nCount = pCnn1->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pCnn1->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndFilterCpp

FilterX.h

Copy code Copy code

// BeginFilterH
#include "icrsint.h"

//This Class extracts only Pub Name and Country Name.
class CPublishers : public CADORecordBinding
{
BEGIN_ADO_BINDING(CPublishers)

 //Column Pub Name is the 2nd field in the recordset
 ADO_VARIABLE_LENGTH_ENTRY2(2, adVarChar, m_szP_pubname,
 sizeof(m_szP_pubname), lP_pubnameStatus, TRUE)

 //Column Country Name is the 5th field in the recordset
 ADO_VARIABLE_LENGTH_ENTRY2(5, adVarChar, m_szP_country ,
 sizeof(m_szP_country), lP_countryStatus, TRUE)

END_ADO_BINDING()

public:
 CHAR m_szP_pubname[50];
 ULONG lP_pubnameStatus;
 CHAR m_szP_country[50];
 ULONG lP_countryStatus;
};
// EndFilterH


CREATE (Microsoft Access SQL reserved word)

 Copy code hover
[image]

CREATE (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The CREATE keyword is used in these contexts:

CREATE INDEX Statement

CREATE TABLE Statement

CREATE VIEW Statement

CREATE PROCEDURE Statement

CREATE USER or GROUP Statement

GRANT Statement

REVOKE Statement


TabControl.OnChange Property (Access)

 Copy code hover
[image]

TabControl.OnChange Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Change box in the Properties window of one of the objects in the Applies To list. Read/write String.

Syntax

expression .OnChange

expression A variable that represents a TabControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Change event occurs when the contents of a text box or the text portion of a combo box changes. It also occurs when you move from one page to another page in a tab control.

The OnChange value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Change box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Change box is blank, the property value is an empty string.

Example

The following example prints the value of the OnChange property in the Immediate window for the "Address" text box on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("Address").OnChange

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Level Object (ADO MD Reference)

 Copy code hover
[image]

Level Object (ADO MD Reference)
Send feedback

In this section

  • Level Object (ADO MD)

  • Level Properties, Methods, and Events (ADO MD)


Attachment.Height Property (Access)

 Copy code hover
[image]

Attachment.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .Height

expression A variable that represents an Attachment object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Section.Visible Property (Access)

 Copy code hover
[image]

Section.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents a Section object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

Section Object

Other resources

Section Object Members


SubForm.OnEnter Property (Access)

 Copy code hover
[image]

SubForm.OnEnter Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnEnter

expression A variable that represents a SubForm object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Enter event occurs before a control actually receives the focus from a control on the same form.

The OnEnter value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Enter box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Enter box is blank, the property value is an empty string.

Example

The following example associates the Enter event with the macro "Enter_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnEnter = "Enter_Macro"

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


NavigationButton.Parent Property (Access)

 Copy code hover
[image]

NavigationButton.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Parent

expression A variable that represents a NavigationButton object.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


TempVars Methods (Access)

 Copy code hover
[image]

TempVars Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Add | Adds a variable to the TempVars collection.
Remove | Removes the specified TempVar object from the TempVars collection.
RemoveAll | Removes all of the TempVar objects from the TempVars collection.


ObjectFrame.OnEnter Property (Access)

 Copy code hover
[image]

ObjectFrame.OnEnter Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnEnter

expression A variable that represents an ObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Enter event occurs before a control actually receives the focus from a control on the same form.

The OnEnter value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Enter box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Enter box is blank, the property value is an empty string.

Example

The following example associates the Enter event with the macro "Enter_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnEnter = "Enter_Macro"

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Recordset-Related Error Information

 Copy code hover
[image]

Recordset-Related Error Information
Send feedback

During batch processing, the Status property of the Recordset object provides information about the individual records in the Recordset. Before a batch update takes place, the Status property of the Recordset reflects information about records to be added, changed and deleted. After UpdateBatch has been called, the Status property indicates the success or failure of the operation. As you move from record to record in the Recordset, the value of the Status property changes to describe the status of the current record.


Image.ObjectPalette Property (Access)

 Copy code hover
[image]

Image.ObjectPalette Property (Access)
See also Send feedback

Published: July 16, 2012

The ObjectPalette property specifies the palette in the application used to create A bitmap or other graphic that is loaded into the specified control by using the Picture property. Read/write Variant.

Syntax

expression .ObjectPalette

expression A variable that represents an Image object.

Remarks

Microsoft Access sets the value of the ObjectPalette property to a String data type containing the palette information. You can use this setting to set the value of the PaintPalette property for a form or report.

If the application associated with the bitmap or other graphic doesn't have an associated palette, the ObjectPalette property is set to an zero-length string.

The setting of the ObjectPalette property makes the palette of the application associated with the OLE object contained in a control available to the PaintPalette property of a form or report. For example, to make the palette used in Microsoft Graph available when you're designing a form in Microsoft Access, you set the form's PaintPalette property to the ObjectPalette value of an existing chart control.

Note Note

Windows can have only one color palette active at a time. Microsoft Access allows you to have multiple graphics on a form, each using a different color palette. The PaintPalette and PaletteSource properties let you specify which color palette a form should use when displaying graphics.

See also

Concepts

Image Object

Other resources

Image Object Members


ADO MD Properties

 Copy code hover
[image]

ADO MD Properties
Send feedback
ActiveConnection | Indicates to which ADO Connection object the current cellset or catalog currently belongs.
Caption | Indicates the text caption to use when displaying a Level or Member object.
ChildCount | Indicates the number of members for which the current Member object is the parent in a hierarchy.
Children | Returns a collection of Members for which the current Member is the parent in the hierarchy.
Count | Indicates the number of objects in a collection.
Depth | Indicates the number of levels between the Level and the root of the hierarchy level.
Description | Returns a text explanation of the current object.
DimensionCount | Indicates the number of dimensions on an axis.
DrilledDown | Indicates whether no children immediately follow the member on the axis.
FilterAxis | Indicates filter information for the current cellset.
Item | Retrieves a cell from a cellset using its coordinates.
Item | Returns a specific member of a collection by name or ordinal number.
FormattedValue | Indicates the formatted display of a cell value.
LevelDepth | Indicates the number of levels between the root of the hierarchy and a member.
LevelName | Indicates the name of the level of a member.
Name | Indicates the name of an object.
Ordinal (Cell) | Uniquely identifies a cell by its position within a cellset.
Ordinal (Position) | Uniquely identifies a position along an axis.
Parent | Indicates the member that is the parent of the current member in a hierarchy.
ParentSameAsPrev | Indicates whether the parent of this position member is the same as the parent of the immediately preceding member.
Source | Indicates the source for the data in the cellset.
State | Indicates the current state of the cellset.
Type | Indicates the type of the current member.
UniqueName | Indicates an unambiguous name for the current object.
Value | Indicates the value of the current cell.


SubForm.GridlineShade Property (Access)

 Copy code hover
[image]

SubForm.GridlineShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineShade

expression A variable that represents an SubForm object.

Remarks

The GridlineShade property contains a numeric expression that can be used to darken the theme color in the GridlineColor property. The default value of the GridlineShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Record(s) cannot be deleted; no delete permission on

 Copy code hover
[image]

Record(s) cannot be deleted; no delete permission on <name>. (Error 3109)
Send feedback

You must have delete permission for the specified table or query in order to delete data. To change your permission assignments, see your system administrator or the table or query's creator.


AllDatabaseDiagrams Object (Access)

 Copy code hover
[image]

AllDatabaseDiagrams Object (Access)
See also Send feedback

Published: July 16, 2012

The AllDatabaseDiagrams collection contains an AccessObject for each database diagram in the CurrentData or CodeData object.

Remarks

The CurrentData or CodeData object has an AllDatabaseDiagrams collection containing AccessObject objects that describe instances of all database diagrams specified by CurrentData or CodeData. For example, you can enumerate the AllDatabaseDiagrams collection in Visual Basic to set or return the values of properties of individual AccessObject objects in the collection.

You can refer to an individual AccessObject object in the AllDatabaseDiagrams collection either by referring to the object by name, or by referring to its index within the collection. If you want to refer to a specific object in the AllDatabaseDiagrams collection, it's better to refer to the database diagram by name because a database diagram's collection index may change.

The AllDatabaseDiagrams collection is indexed beginning with zero. If you refer to a database diagram by its index, the first database diagram is AllDatabaseDiagrams(0), the second database diagram is AllDatabaseDiagrams(1), and so on.

Note Note

  • The AllDatabaseDiagrams collection only contains AccessObject objects within a Microsoft Access project (.adp). A Microsoft Access database does not contain any database diagrams.

  • To list all open database diagrams in the project, use the IsLoaded property of each AccessObject object in the AllDatabaseDiagrams collection. You can then use the Name property of each individual AccessObject object to return the name of a database diagram.

You can't add or delete an AccessObject object from the AllDatabaseDiagrams collection.

Example

The following example prints the name of each open AccessObject object in the AllDatabaseDiagrams collection.

VBA Copy code Copy code
Sub AllDatabaseDiagrams()
    Dim obj As AccessObject, dbs As Object
    Set dbs = Application.CurrentData
    ' Search for open AccessObject objects in
    ' AllDatabaseDiagrams collection.
    For Each obj In dbs.AllDatabaseDiagrams
        If obj.IsLoaded = True Then
            ' Print name of obj.
            Debug.Print obj.Name
        End If
    Next obj
End Sub

See also

Concepts

Access Object Model Reference

Other resources

AllDatabaseDiagrams Object Members


AllStoredProcedures.Count Property (Access)

 Copy code hover
[image]

AllStoredProcedures.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents an AllStoredProcedures object.

See also

Concepts

AllStoredProcedures Collection

Other resources

AllStoredProcedures Object Members


TRANSFORM Statement (Microsoft Access SQL)

 Copy code hover
[image]

TRANSFORM Statement (Microsoft Access SQL)
Send feedback

Creates a crosstab query.

Syntax

TRANSFORM aggfunctionselectstatement PIVOT pivotfield [IN (value1[, value2[, …]])]

The TRANSFORM statement has these parts:

Part | Description
aggfunction | An SQL aggregate function that operates on the selected data.
selectstatement | A SELECT statement.
pivotfield | The field or expression you want to use to create column headings in the query's result set.
value1, value2 | Fixed values used to create column headings.

Remarks

When you summarize data using a crosstab query, you select values from specified fields or expressions as column headings so you can view data in a more compact format than with a select query.

TRANSFORM is optional but when included is the first statement in an SQL string. It precedes a SELECT statement that specifies the fields used as row headings and a GROUP BY clause that specifies row grouping. Optionally, you can include other clauses, such as WHERE, that specify additional selection or sorting criteria. You can also use subqueries as predicates — specifically, those in the WHERE clause — in a crosstab query.

The values returned in pivotfield are used as column headings in the query's result set. For example, pivoting the sales figures on the month of the sale in a crosstab query would create 12 columns. You can restrict pivotfield to create headings from fixed values (value1, value2 ) listed in the optional IN clause. You can also include fixed values for which no data exists to create additional columns.

Example

This example uses the SQL TRANSFORM clause to create a crosstab query showing the number of orders taken by each employee for each calendar quarter of 1994. The SQLTRANSFORMOutput function is required for this procedure to run.

VBA Copy code Copy code
Sub TransformX1()

    Dim dbs As Database
    Dim strSQL As String
    Dim qdfTRANSFORM As QueryDef

    strSQL = "PARAMETERS prmYear SHORT; TRANSFORM " _
        & "Count(OrderID) " _
        & "SELECT FirstName & "" "" & LastName AS " _
        & "FullName FROM Employees INNER JOIN Orders " _
        & "ON Employees.EmployeeID = " _
        & "Orders.EmployeeID WHERE DatePart " _
        & "(""yyyy"", OrderDate) = [prmYear] "

       strSQL = strSQL & "GROUP BY FirstName & " _
        & """ "" & LastName " _
        & "ORDER BY FirstName & "" "" & LastName " _
        & "PIVOT DatePart(""q"", OrderDate)"

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    Set qdfTRANSFORM = dbs.CreateQueryDef _
        ("", strSQL)

    SQLTRANSFORMOutput qdfTRANSFORM, 1994

    dbs.Close

End Sub

This example uses the SQL TRANSFORM clause to create a slightly more complex crosstab query showing the total dollar amount of orders taken by each employee for each calendar quarter of 1994. The SQLTRANSFORMOutput function is required for this procedure to run.

Copy code Copy code
Sub TransformX2()

    Dim dbs As Database
    Dim strSQL As String
    Dim qdfTRANSFORM As QueryDef

    strSQL = "PARAMETERS prmYear SMALLINT; TRANSFORM " _
        & "Sum(Subtotal) SELECT FirstName & "" """ _
        & "& LastName AS FullName " _
        & "FROM Employees INNER JOIN " _
        & "(Orders INNER JOIN [Order Subtotals] " _
        & "ON Orders.OrderID = " _
        & "[Order Subtotals].OrderID) " _
        & "ON Employees.EmployeeID = " _
        & "Orders.EmployeeID WHERE DatePart" _
        & "(""yyyy"", OrderDate) = [prmYear] "

       strSQL = strSQL & "GROUP BY FirstName & "" """ _
        & "& LastName " _
        & "ORDER BY FirstName & "" "" & LastName " _
        & "PIVOT DatePart(""q"",OrderDate)"

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    Set qdfTRANSFORM = dbs.CreateQueryDef _
        ("", strSQL)

    SQLTRANSFORMOutput qdfTRANSFORM, 1994

    dbs.Close

End Sub

Function SQLTRANSFORMOutput(qdfTemp As QueryDef, _
    intYear As Integer)

    Dim rstTRANSFORM As Recordset
    Dim fldLoop As Field
    Dim booFirst As Boolean

    qdfTemp.PARAMETERS!prmYear = intYear
    Set rstTRANSFORM = qdfTemp.OpenRecordset()

    Debug.Print qdfTemp.SQL
    Debug.Print
    Debug.Print , , "Quarter"

    With rstTRANSFORM
        booFirst = True
        For Each fldLoop In .Fields
            If booFirst = True Then
                Debug.Print fldLoop.Name
                Debug.Print , ;
                booFirst = False
            Else
                Debug.Print , fldLoop.Name;
            End If
        Next fldLoop
        Debug.Print

        Do While Not .EOF
            booFirst = True
            For Each fldLoop In .Fields
                If booFirst = True Then
                    Debug.Print fldLoop
                    Debug.Print , ;
                    booFirst = False
                Else
                    Debug.Print , fldLoop;
                End If
            Next fldLoop
            Debug.Print
            .MoveNext
        Loop
    End With

End Function


BoundObjectFrame.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

BoundObjectFrame.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified frame. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleBottom

expression A variable that represents a BoundObjectFrame object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


OptionButton.LabelX Property (Access)

 Copy code hover
[image]

OptionButton.LabelX Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelX

expression A variable that represents an OptionButton object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


How to: Cancel the Deletion of a Record by Using Custom Criteria

 Copy code hover
[image]

How to: Cancel the Deletion of a Record by Using Custom Criteria
Send feedback

The following example illutrates how to use a form's Delete event to prevent the deletion of a record based on custom criteria. In this example, the Delete event is canceled if the value of the DataRequired field is Yes.

VBA Copy code Copy code
Private Sub Form_Delete(Cancel As Integer)

   ' Check the value of the DataRequired field.
    If Me.DataRequired = "Yes" Then

      ' Cancel the record deletion.
      Cancel = True

      ' Notify the user.
       MsgBox "Cannot Delete the Record."
    End If
End Sub


Page.SetTabOrder Method (Access)

 Copy code hover
[image]

Page.SetTabOrder Method (Access)
See also Send feedback

Published: July 16, 2012

Resets the tab order of the controls in the specified Page to their default values.

Version Information

Version Added: Access 2007

Syntax

expression .SetTabOrder

expression A variable that represents a Page object.

See also

Concepts

Page Object

Other resources

Page Object Members


WebServices Object (Access)

 Copy code hover
[image]

WebServices Object (Access)
See also Send feedback

Published: July 16, 2012

Represents the collection of Data Services data connections installed in the database.

Version Information

Version Added: Access 2010

Remarks

Use the WebServices property of the Application Object to return the colleciton of installed Data Services data connections.

Use the following steps to install a Data Services data connection in your database.

  1. Obtain a Data Services data connection file of rthe data source that you want to connect to.

  2. On the ribbon, click the External Data tab.

  3. In the Import & Link group, click the More dropdown and then click Data Services.

  4. At the bottom of the Create Link to Data Services dialog box, click Install New Connection.

  5. In the Select a connection definition file dialog box, browse to and select the XML file that contains the description of the Data Service.

See also

Concepts

Access Object Model Reference

Other resources

WebServices Object Members


Requested page locking, but DB is in row lock mode. (Error 3752)

 Copy code hover
[image]

Requested page locking, but DB is in row lock mode. (Error 3752)
Send feedback

This error occurs when a user specifies that the database open in page locking only mode, but another user already has the database opened in row/page locking mode.


CommandButton.TopPadding Property (Access)

 Copy code hover
[image]

CommandButton.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the button and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .TopPadding

expression A variable that represents a CommandButton object.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ToggleButton Members (Access)

 Copy code hover
[image]

ToggleButton Members (Access)
Send feedback

Published: July 16, 2012

This object corresponds to a toggle button. A toggle button on a form is a stand-alone control used to display a Yes/No value from an underlying record source.

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.
Undo | You can use the Undo method to reset a control or form when its value has been changed.

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
Bevel | Gets or sets the bevel effect applied to the specified object. Read/write Long.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the toggle button and its bottom gridline. Read/write Integer.
Caption | Gets or sets the text that appears in the control. Read/write String.
ColumnHidden | You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.
ColumnOrder | You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.
ColumnWidth | You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DefaultValue | Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontName | You can use the FontName property to specify the font for text in the following situations:
FontSize | You can use the FontSize property to specify the point size for text in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
FontWeight | Use the FontWeight property to specify the line width that Windows uses to display and print characters in a control. Read/write Integer.
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
ForeShade | Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
ForeThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.
ForeTint | Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
Glow | Gets or sets the Glow effect applied to the specified object. Read/write Long.
Gradient | Gets or sets the gradient fill applied to the specified object. Read/write Long.
GridlineColor | Gets or sets the color of the gridline for the specified toggle button. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified toggle button. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified toggle button. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified toggle button. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified toggle button. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified toggle button. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified toggle button. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified toggle button. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified toggle button. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HideDuplicates | You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the toggle button is anchored horizontally within its layout. Read/write.
HoverColor | Gets or sets the color displayed on the control when the user rests the mouse cursor over it. Read/write Long.
HoverForeColor | Gets or sets the color of the text displayed on the control when the user rests the mouse cursor over it. Read/write Long.
HoverForeShade | Gets or sets the shade applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.
HoverForeThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverForeColor property of the specified object. Read/write Long.
HoverForeTint | Gets or sets the tint applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.
HoverShade | Gets or sets the shade that is applied to the theme color in the HoverColor property of the specified object. Read/write Single.
HoverThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverColor property of the specified object. Read/write Long.
HoverTint | Gets or sets the tint applied to the theme color in the HoverColor property of the specified object. Read/write Single.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified toggle button. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified toggle button. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the toggle button and its left gridline. Read/write Integer.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
ObjectPalette | The ObjectPalette property specifies the palette in the application used to create A bitmap or other graphic that is loaded into the specified control by using the Picture property. Read/write Variant.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OptionValue | Each control in an option group has a numeric value that you can set with the OptionValue property. Read/write Long.
Parent | Returns the parent object for the specified object. Read-only.
Picture | You can use the Picture property to specify a bitmap or other type of graphic to be displayed on the specified control. Read/write String.
PictureData | You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.
PictureType | You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.
PressedColor | Gets or sets the color displayed on the control when the user clicks it. Read/write Long.
PressedForeColor | Gets or sets the color of the text displayed on the control when the user clicks it. Read/write Long.
PressedForeShade | Gets or sets the shade applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.
PressedForeThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedForeColor property of the specified object. Read/write Long.
PressedForeTint | Gets or sets the tint applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.
PressedShade | Gets or sets the shade that is applied to the theme color in the PressedColor property of the specified object. Read/write Single.
PressedThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedColor property of the specified object. Read/write Long.
PressedTint | Gets or sets the tint applied to the theme color in the PressedColor property of the specified object. Read/write Single.
Properties | Returns a reference to a control's Properties collection object. Read-only.
QuickStyle | Gets or sets the Quick Style that is applied to the specified object. Read/write Long.
QuickStyleMask | Gets or sets modifications to the Quick Style that is applied to the specified object. Read/write Long.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
RightPadding | Gets or sets the amount of space (in inches) between the toggle button and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
Shadow | Gets or sets the Shadow effect applied to the specified object. Read/write Long.
Shape | Returns or sets the shape of the specified toggle button. Read/write Long.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SoftEdges | Gets or sets the Soft Edges effect applied to the specified object. Read/write Long.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
ThemeFontIndex | Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the toggle button and its top gridline. Read/write Integer.
TripleState | You can use the TripleState property to specify how the specified control will display Null values. Read/write Boolean.
UseTheme | Gets or sets whether the specified object will utilize formatting styles defined in Office Document Themes. Read/write Boolean.
ValidationRule | You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.
ValidationText | Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.
Value | Determines or specifies whether or not the specified toggle button control is selected. Read/write Variant.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified toggle button is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


Syntax error in query. Parameter value. (Error 3746)

 Copy code hover
[image]

Syntax error in query. Parameter value. (Error 3746)
Send feedback

This error can occur when:

  • An invalid parameter data type is being used with parameterized queries/procedures.

  • A procedure and the named parameter are not preceded by the @ symbol.

  • An invalid parameter name is passed after the @ symbol.

  • There is not an equal (=) sign after a parameter.

  • Reserved words are used as parameters without the proper escape characters.


Container Object Reference (DAO)

 Copy code hover
[image]

Container Object Reference (DAO)
Send feedback

In this section

  • Container Object (DAO)

  • Container Members (DAO)

  • Container Properties (DAO)


CheckBox.Enter Event (Access)

 Copy code hover
[image]

CheckBox.Enter Event (Access)
See also Send feedback

Published: July 16, 2012

The Enter event occurs before a control actually receives the focus from a control on the same form or report.

Syntax

expression .Enter

expression A variable that represents a CheckBox object.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when these events occur, set the OnEnter or OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Enter event occurs before the GotFocus event. The Exit event occurs before the LostFocus event.

Unlike the GotFocus and LostFocus events, the Enter and Exit events don't occur when a form receives or loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


There is a sharing violation in the source dropbox folder because the message database is open in another application. (Error 3565)

 Copy code hover
[image]

There is a sharing violation in the source dropbox folder because the message database is open in another application. (Error 3565)
Send feedback

Close the message database. Users must not open the message database directly.


Miscellaneous (Access)

 Copy code hover
[image]

Miscellaneous (Access)
Send feedback

In this section

  • Access Miscellaneous How Do I...

  • Date/Time

  • Criteria Expressions

  • Windows API

  • Maintenance

  • Access Developer Extensions


Could not save; currently locked by another user. (Error 3046)

 Copy code hover
[image]

Could not save; currently locked by another user. (Error 3046)
Send feedback

You tried to save information on a database page that is currently locked by another user. To save your changes, wait for the other user to finish, and then try the operation again.


Line.VerticalAnchor Property (Access)

 Copy code hover
[image]

Line.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified line is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .VerticalAnchor

expression A variable that represents a Line object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

Line Object

Other resources

Line Object Members


Parameters Collection (ADO)

 Copy code hover
[image]

Parameters Collection (ADO)
Send feedback

Contains all the Parameter objects of a Command object.

Remarks

A Command object has a Parameters collection made up of Parameter objects.

Using the Refresh method on a Command object's Parameters collection retrieves provider parameter information for the stored procedure or parameterized query specified in the Command object. Some providers do not support stored procedure calls or parameterized queries; calling the Refresh method on the Parameters collection when using such a provider will return an error.

If you have not defined your own Parameter objects and you access the Parameters collection before calling the Refresh method, ADO will automatically call the method and populate the collection for you.

You can minimize calls to the provider to improve performance if you know the properties of the parameters associated with the stored procedure or parameterized query you wish to call. Use the CreateParameter method to create Parameter objects with the appropriate property settings and use the Append method to add them to the Parameters collection. This lets you set and return parameter values without having to call the provider for the parameter information. If you are writing to a provider that does not supply parameter information, you must manually populate the Parameters collection using this method to be able to use parameters at all. Use the Delete method to remove Parameter objects from the Parameters collection if necessary.

The objects in the Parameters collection of a Recordset go out of scope (therefore becoming unavailable) when the Recordset is closed.


TextBox.BorderShade Property (Access)

 Copy code hover
[image]

TextBox.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents a TextBox object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens BorderColor by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Page Properties (Access)

 Copy code hover
[image]

Page Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Caption | Gets or sets the text that appears at the top of the page. Read/write String.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
PageIndex | You can use the PageIndex property to specify or determine the position of a Page object within a Pages collection. The PageIndex property specifies the order in which the pages on a tab control appear. Read/write Integer.
Parent | Returns the parent object for the specified object. Read-only.
Picture | You can use the Picture property to specify a bitmap or other type of graphic to be displayed on the specified control. Read/write String.
PictureData | You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.
PictureType | You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.
Properties | Returns a reference to a control's Properties collection object. Read-only.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


TabControl.TopPadding Property (Access)

 Copy code hover
[image]

TabControl.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .TopPadding

expression A variable that represents a TabControl object.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


CurrentProject.Application Property (Access)

 Copy code hover
[image]

CurrentProject.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a CurrentProject object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


CustomControl.Visible Property (Access)

 Copy code hover
[image]

CustomControl.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents a CustomControl object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Form.CommandBeforeExecute Property (Access)

 Copy code hover
[image]

Form.CommandBeforeExecute Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the CommandBeforeExecute event occurs. Read/write.

Syntax

expression .CommandBeforeExecute

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the CommandBeforeExecute event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).CommandBeforeExecute = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


Section Events (Access)

 Copy code hover
[image]

Section Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.
Paint | Occurs when the specified section is redrawn.


How to: Use Existing Custom Menus and Toolbars

 Copy code hover
[image]

How to: Use Existing Custom Menus and Toolbars
Send feedback

This topic describes how custom toolbars and menu bars that you created in earlier versions of Access behave when you open those older databases in Microsoft Access 2013. This topic also explains how to turn off the ribbon so that you can use custom toolbars and menu bars.

How earlier version databases behave in Access 2010

If you have an .mdb file that contains custom toolbars, custom menu bars, or a custom startup behavior, those options apply when you open that earlier version database in Access 2010 and when you convert the earlier version database to an Access 2010 file (an .accdb or .accde file). For example, if you turned off built-in toolbars and replaced the default menu bar in a database created in Access 2003, that behavior remains in place when you open the database in Access 2010.

In addition, you can hide the ribbon when you open legacy files (.mdb, .mde, and .mda files) in Access 2010, and when you use to create a legacy file — something you cannot do with .accdb and .accde files. You can define different behaviors for legacy files, because the earlier version database formats use a different working model than the new .accdb and .accde files. Earlier versions of Access opened each object in a separate window; in contrast, (by default) opens all objects in a single, tabbed document and separates open objects with tabs.

In addition, you can turn off the ribbon for a legacy database by setting options for that database in Access 2003, or by setting global program options in . A procedure, later in this topic, explains how to perform both tasks.

When you open a legacy database and you choose to display the ribbon, any custom toolbars appear as groups on the Add-Ins tab. Each group in the tab corresponds to a custom toolbar, and each group uses the name assigned to the original toolbar. However, the toolbars must be visible in the legacy database or they do not appear on the tab.

Reminder To bypass custom startup behaviors, press and hold SHIFT while you open the database.

The following procedure describes how to open and use a database that contains one or more custom toolbars, how to open a database that uses customized startup behavior, and how to hide the ribbon.

Opening and using an earlier version database that contains custom toolbars

  1. Click the File tab, and then click Open.

    The Open dialog box appears.

  2. Use the Look in list to locate your legacy database (a .mdb or .mde file), and then click Open. Access 2010 opens the earlier version database. The database objects — the tables, forms, reports, and so on — appear in the Navigation Pane. If you set a form, switchboard, or other object to appear on startup, that object also appears in the Navigation Pane. Also, if you created custom toolbars or menu bars, they appear in the Add-Ins tab as one or more groups. Each group uses the name originally assigned to the custom toolbar or menu bar.

  3. Click the Add-Ins tab. Your custom toolbars appear as one or more groups, and you can use them when doing so is logical. For example, suppose that one of your custom toolbars contains the Print Relationships command. Access does not enable that command until you display the relationships for the open database.

Note Note

If your database does not contain a custom toolbar, the Add-Ins tab remains hidden.

Opening and using an earlier version database with custom startup behavior

Note Note

These steps assume that you have a database created in an earlier version of Access, and that database uses custom startup settings. If not, you can ignore these steps.

Open a database

  1. Click the File tab, and then click Open. The Open dialog box appears.

  2. Use the Look in list to locate and open the earlier version database. opens the database and runs any startup settings. For example, if the earlier version database was set to run a parameter query before opening any data-entry forms, the dialog boxes for that query appear in Access 2010.

Note Note

If the database uses Visual Basic for Applications (VBA) code, Access blocks the code by default.

Turn off the Ribbon and use just your custom menu bars

The following procedure describes how to hide the ribbon by changing settings in Access 2003 and in Access 2010. To follow these steps, you must have a database created in an earlier version of Access, and that database must contain a custom menu bar. For more information about creating a custom menu bar, see the Help for your earlier version of Access.

Set Access 2003 to use a custom menu bar

  1. Using Access 2003, open your legacy database.

  2. On the Tools menu, click Startup. The Startup dialog box appears.

  3. From the Menu Bar list, select your custom menu bar.

    Note Note

    You must select a menu bar. You cannot select a toolbar.

  4. Clear the Allow Built-in Toolbars check box, click OK, and then close the database. When you open the database in Access 2010, Access shows the Message Bar (if necessary), the custom menu bar set for the database, and any other startup settings, such as a form and any custom toolbars.

Set Access 2010 to use custom menu bars

  1. Open your legacy database in Access 2010.

  2. Click the File tab, and then click Options.

  3. In the Access Options dialog box, click Current Database.

  4. Under Ribbon and Toolbar Options, clear the Allow Full Menus and Allow Built-in Toolbars check boxes.

  5. Click OK.


Text Box Control

 Copy code hover
[image]

Text Box Control
Send feedback

Published: July 16, 2012

Text boxes on a form or report display data from a record source. This type of text box is called a bound text box because it's bound to data in a field. Text boxes can also be unbound. For example, you can create an unbound text box to display the results of a calculation, or to accept input from a user. Data in an unbound text box isn't saved with the database.


Connection Properties (DAO)

 Copy code hover
[image]

Connection Properties (DAO)
Send feedback

In this section

  • Connection.Connect Property (DAO)

  • Connection.Database Property (DAO)

  • Connection.Name Property (DAO)

  • Connection.QueryDefs Property (DAO)

  • Connection.QueryTimeout Property (DAO)

  • Connection.RecordsAffected Property (DAO)

  • Connection.Recordsets Property (DAO)

  • Connection.StillExecuting Property (DAO)

  • Connection.Transactions Property (DAO)

  • Connection.Updatable Property (DAO)


NavigationButton.TabStop Property (Access)

 Copy code hover
[image]

NavigationButton.TabStop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .TabStop

expression A variable that represents a NavigationButton object.

Remarks

This property doesn't apply to toggle button controls when they appear in an option group. It applies only to the option group itself.

The TabStop property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) You can move the focus to the control by pressing the TAB key.
No | False | You can't move the focus to the control by pressing the TAB key.

When you create a control on a form, Microsoft Access automatically assigns the control a position in the form's tab order. Each new control is placed last in the tab order. If you want to prevent a control from being available when you tab through the controls in a form, set the control's TabStop property to No.

In Form view, hidden or disabled controls remain in the tab order but are skipped when you move through the controls by pressing TAB, even if their TabStop properties are set to Yes.

As long as a control's Enabled property is set to Yes, you can click the control or use an access key to select it, regardless of its TabStop property setting. For example, you can set the TabStop property of a command button to No to prevent users from selecting the button by pressing TAB. However, they can still click the command button to choose it.

Example

The following example disables the ability to move the focus to the "City" text box on the "Suppliers" form by using the TAB key.

VBA Copy code Copy code
Forms("Suppliers").Controls("City").TabStop = False

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


How to: Create and customize a web app in Access 2013

 Copy code hover
[image]

How to: Create and customize a web app in Access 2013
Send feedback

Published: July 16, 2012

Applies to: Access 2013

In this article
Introduction
Prerequisites for building an app with Access 2013
Create the app
Explore the app
Customize the app
Conclusion
Additional resources

Introduction

Access 2013 features a new application model that enables subject matter experts to quickly create web-based applications. Included with Access are a set of templates that you can use to jump start creating your application.

Prerequisites for building an app with Access 2013

To follow the steps in this example, you need the following:

  • Access 2013

  • A SharePoint 2013 development environment

For more information about setting up your SharePoint development environment, see Start: Set up the development environment for SharePoint 2013.

For more information about obtaining Access 2013 and SharePoint 2013, see Downloads.

Create the app

Suppose you want to create an Access app that tracks issues for your business. Before you start creating the tables and view from scratch, you should search for a schema template that meets your needs.

To create the issue tracking app

  1. Open Access and choose Custom web app.

  2. Enter a name and the web location for your app. You can also choose a location from the Locations list and choose Create.

  3. Type Issues into the What would you like to track? box and then press ENTER.

    A list of templates that might be useful for tracking issues is displayed in Figure 1.

    Figure 1. Templates that match the search for issues

    Templates that match the search for issues

  4. Choose Issues.

Access creates a set of tables and views.

Explore the app

To understand whether the schema and views meet your needs, you should examine them.

The tables created by selecting the Issues schema are displayed in the Tile Pane. The Issues, Customer, and Employees tables are the main focus of the app. The Issues table stores information about each issue. Each issue is opened by and assigned to an employee on behalf of a customer. The Related Issues and Issue Comments tables play a supporting role in the app. The Related Issues table enables you to link one issue to another. The Issue Comments table stores multiple comments for a single issue.

In an Access desktop (.accdb) database, the relationships between tables are managed in the Relationships window. Access 2013 apps manage relationships by using fields set to the Lookup data type. Let's examine the relationships for the Issues table by right-clicking the Issues tile and selecting Edit Table.

The Customer field is related to the Customers table. To examine the relationship, select the Customer field and then select Modify Lookups. The Lookup Wizard is displayed, as shown in Figure 2.

Figure 2. Lookup Wizard displaying the relationship to the Customers table

Lookup Wizard displaying the relationship

The Lookup Wizard dialog box shows that the Customer field is linked to the Customers table and to return the Display Name First Last field from the Customers table.

The Opened By, Assigned To, and Changed By fields are related to the Employees table. Several other fields are also set to the Lookup data type. In these cases, the Lookup data type is used to specify the specific values to allow for in the field.

Close the Issues table and examine the Tile Pane. The top three tiles, for the Issues, Customers, and Employees tables, are displayed differently than the bottom two tiles for the Related Issues and Issue Comments table, as shown in Figure 3.

Figure 3. Tile Pane for the Issues schema

Tile Pane for the Issues schema

The Related Issues and Issue Comments tables are dimmed because they are to be hidden from the user in the web browser.

Let's use the app to track some issues. To do this, click Launch App to open the app in your web browser.

The app opens the Issues List view of the Issues table. Before adding an issue, it would be a good idea to add some customers and employees. Click the Customers tile to start adding customers.

Use the View Selector to choose one of three views available for the Customers table, labeled List, Datasheet, and Groups as shown in Figure 4.

Figure 4. View Selector

Choosing List activates the Customers List view, which is a List Details view. List Details is one of the views Access automatically generates when you create a table. The main feature that distinguishes a List Details view is the list pane that appears on the left side of the view. The list pane is used to filter and navigate the records contained in the view. In an Access desktop database, implementing a searchable list view would require writing custom code.

Choosing Datasheet opens the Customers Datasheet view. Datasheet is the other kind of view Access automatically generates when you create a table. Datasheet views are useful for those who find it easier to enter, sort, and filter data in a spreadsheet-like manner.

Choosing Groups opens a Summary view. Summary views can be used to group records based on a field and optionally calculate a sum or average.

As you're adding customers, use the Action Bar to add records, edit records, save records, delete records, and cancel edits. The Action Bar is a customizable toolbar that appears at the top of each view, as shown in Figure 5.

Figure 5. Action Bar

Once you've added some customers and employees open the Issues List view and start adding an issue. As you type the name of a customer into the into the Customer box, one or more of the customer names will appear, as shown in Figure 6.

Figure 6. AutoComplete control

The Customer box is an AutoComplete control. The AutoComplete control displays a list of records that match what you're typing into the box. This helps ensure the accuracy of data entry.

Customize the app

Now that you've taken a tour of the app, you notice that the Issues List view doesn't contain contact information for the customer. Let's customize the app to add the customer's work phone to the Issues table as the issue is being created.

To add a field to the Issues table

  1. Open the app in Access.

  2. Choose the Issues tile, choose the Settings/Action icon, and then choose Edit Table.

  3. Enter Contact Number in the first blank cell in the Field Name column.

  4. Choose Short Text in the Data Type column.

  5. Choose Save.

  6. Close the Issues table.

Now that we have field in which to store the phone number, let's create a data macro to look up the contact information.

To create the data macro to look up contact information

  1. In the Create group, choose Advanced, and then choose Data Macro.

  2. Choose Create Parameter.

  3. In the Name box, enter CustID. In the Type dropdown, choose Number (Floating Decimal).

  4. From the Add New Action dropdown, choose LookupRecord.

  5. In the Look Up A Record In dropdown, choose Customers.

  6. In the Where Condition box, enter [Customers].[ID]=[CustID].

  7. Choose SetReturnVar from the Add New Action dropdown.

    Note Note

    You'll see two Add New Action dropdowns, one within the LookupRecord block, and another outside the LookupRecordblock. You should choose the Add New Action dropdown within the LookupRecordblock, as shown in Figure 7.

    Figure 7. Add New Action dropdown

    Add New Action dropdown

  8. In the Name box, enter ContactPhone.

  9. In the Expression box, enter [Customers].[Work Phone].

  10. Choose Save. Enter GetContactPhone in the Macro Name box and then choose OK.

    The macro should resemble the macro shown in Figure 8.

    Figure 8. GetContactPhone data macro

    GetContactPhone data macro

  11. Close macro Design View.

Now we're ready to add the Contact Number field to the Issues List form.

To add the Contact Number field to the Issues List form

  1. Choose the Issues table. This chooses the Issues list form.

  2. In the View selector, choose List, choose the Settings/Action icon, and then choose Edit.

  3. Drag the Contact Number field form the Field List pane to the location on the form where you want the contact number to be displayed.

  4. Choose the Contact Number text box, and then click Data.

  5. In the Control Name box, enter CustomerContact and then close the Data popup.

  6. Choose Save.

Now we should write a user interface (UI) macro that copies the Work Phone field from the Customers table into the Contact Phone field of the Issues table. The After Update event of the CustomerAutocomplete control is a good location for the macro.

To create the AfterUpdate macro

  1. Choose the CustomerAutocomplete control, choose the Actions button, and then choose After Update.

    A blank macro is opened in macro Design View.

  2. From the Add New Action dropdown, choose RunDataMacro.

  3. In the Macro Name dropdown, choose GetContactPhone.

  4. In the CustID box, enter [CustomerAutocomplete].

  5. In the SetLocalVar box, enter Phone.

    When you chose the GetContactPhone data macro that was created earlier, Access automatically filled in the parameter name and return variable for the macro.

    The phone number for the customer is stored in a variable named Phone.

  6. From the Add New Action dropdown, choose SetProperty.

  7. In the Control Name box, enter CustomerContact.

  8. In the Property dropdown, choose Value.

  9. In the Value box, enter =[Phone].

  10. Choose Save.

    The macro should resemble the macro shown in Figure 9.

    Figure 9. After Update macro

    After Update macro

  11. Close macro Design View.

  12. Close the Issues List view. Choose Yes when you are prompted to save your changes.

Now we're ready to text the customization. Click Launch App to open the app in your web browser and then add a new issue. The Contact Number bosx will update automatically after the customer name is entered as shown in Figure 10.

Figure 10. Issues view updated with phone number

Issues view updated with phone number

Conclusion

Using one of the schema templates included with is a good way to jump start the creation of an Access web app. The views that are automatically created for you contain advanced functionally that requires custom code to implement in a Access desktop database.

Additional resources

What's new for Access 2013 developers

Access 2013 custom web app reference


EventReasonEnum

 Copy code hover
[image]

EventReasonEnum
Send feedback

Specifies the reason that caused an event to occur.

Constant | Value | Description
adRsnAddNew | 1 | An operation added a new record.
adRsnClose | 9 | An operation closed the Recordset.
adRsnDelete | 2 | An operation deleted a record.
adRsnFirstChange | 11 | An operation made the first change to a record.
adRsnMove | 10 | An operation moved the record pointer within the Recordset.
adRsnMoveFirst | 12 | An operation moved the record pointer to the first record in the Recordset.
adRsnMoveLast | 15 | An operation moved the record pointer to the last record in the Recordset.
adRsnMoveNext | 13 | An operation moved the record pointer to the next record in the Recordset.
adRsnMovePrevious | 14 | An operation moved the record pointer to the previous record in the Recordset.
adRsnRequery | 7 | An operation requeried the Recordset.
adRsnResynch | 8 | An operation resynchronized the Recordset with the database.
adRsnUndoAddNew | 5 | An operation reversed the addition of a new record.
adRsnUndoDelete | 6 | An operation reversed the deletion of a record.
adRsnUndoUpdate | 4 | An operation reversed the update of a record.
adRsnUpdate | 3 | An operation updated an existing record.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.EventReason.ADDNEW

AdoEnums.EventReason.CLOSE

AdoEnums.EventReason.DELETE

AdoEnums.EventReason.FIRSTCHANGE

AdoEnums.EventReason.MOVE

AdoEnums.EventReason.MOVEFIRST

AdoEnums.EventReason.MOVELAST

AdoEnums.EventReason.MOVENEXT

AdoEnums.EventReason.MOVEPREVIOUS

AdoEnums.EventReason.REQUERY

AdoEnums.EventReason.RESYNCH

AdoEnums.EventReason.UNDOADDNEW

AdoEnums.EventReason.UNDODELETE

AdoEnums.EventReason.UNDOUPDATE

AdoEnums.EventReason.UPDATE


Chapter 3: Examining Data (ADO)

 Copy code hover
[image]

Chapter 3: Examining Data (ADO)
Send feedback

In this section

  • Chapter 3: Examining Data

  • Locating the Current Record (ADO)

  • Navigating Through the Data (ADO)

  • Understanding Recordset Structure (ADO)


Procedures Collection Properties, Methods, and Events (ADOX)

 Copy code hover
[image]

Procedures Collection Properties, Methods, and Events (ADOX)
Send feedback

Properties

Count Property

Item Property

Methods

Append Method (Procedures)

Delete Method (Collections)

Refresh Method

Events

None.


Data Shaping

 Copy code hover
[image]

Data Shaping
Send feedback

Data shaping enables you to define the columns of a shaped Recordset, the relationships between the entities represented by the columns, and the manner in which the Recordset is populated with data.

Columns of a shaped Recordset may contain data from a data provider such as Microsoft SQL Server, references to another Recordset, values derived from a calculation on a single row of a Recordset, values derived from an operation over a column of an entire Recordset; or they may be a newly fabricated, empty column.

When you retrieve the value of a column that contains a reference to another Recordset, ADO automatically returns the actual Recordset represented by the reference. A Recordset that contains another Recordset is called a hierarchical recordset. Hierarchical recordsets exhibit a parent-child relationship, in which the parent is the containing recordset and the child is the contained recordset. The reference to a Recordset is actually a reference to a subset of the child, called a chapter. A single parent may reference more than one child Recordset.

The shape command syntax enables you to programmatically create a shaped Recordset. You can then access the components of the Recordset programmatically or through an appropriate visual control. A shape command is issued like any other ADO command text.

You can make hierarchical Recordset objects in two ways with the shape command syntax. The first appends a child Recordset to a parent Recordset. The parent and child typically have at least one column in common: the value of the column in a row of the parent is the same as the value of the column in all rows of the child.

The second way generates a parent Recordset from a child Recordset. The records in the child Recordset are grouped, typically using the BY clause, and one row is added to the parent Recordset for each resulting group in the child. If the BY clause is omitted, the child Recordset will form a single group and the parent Recordset will contain exactly one row. This is useful for computing "grand total" aggregates over the entire child Recordset.

Regardless of which way the parent Recordset is formed, it will contain a chapter column that is used to relate it to a child Recordset. If you wish, the parent Recordset may also have columns that contain aggregates (SUM, MIN, MAX, and so on) over the child rows. Both the parent and the child Recordset may have columns which contain an expression on the row in the Recordset, as well as columns which are new and initially empty.

You can nest hierarchical Recordset objects to any depth (that is, create child Recordset objects of child Recordset objects, and so on).

You can access the Recordset components of the shaped Recordset programmatically or through an appropriate visual control.

For examples of shape commands and their resulting hierarchies, see Using the Data Shaping Service for OLE DB: A Closer Look.


Image.MouseMove Event (Access)

 Copy code hover
[image]

Image.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents an Image object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

Image Object

Other resources

Image Object Members


Conversion

 Copy code hover
[image]

Conversion
Send feedback

In this section

  • Changes in Access 2013

  • Convert Microsoft Access Tables, Forms, and Reports

  • Converting DAO Code to ADO


RecordsetTypeEnum Enumeration (DAO)

 Copy code hover
[image]

RecordsetTypeEnum Enumeration (DAO)
Send feedback

Used with the Type property to specify the type of Recordset object.

Name | Value | Description
dbOpenDynamic | 16 | Opens a dynaset-type Recordset
dbOpenDynaset | 2 | Opens a dynaset-type Recordset
dbOpenForwardOnly | 8 | Opens a forward-only type Recordset
dbOpenSnapshot | 4 | Opens a snapshot-type Recordset
dbOpenTable | 1 | Opens a table-type Recordset


There is no active transport for the Synchronizer. (Error 3508)

 Copy code hover
[image]

There is no active transport for the Synchronizer. (Error 3508)
Send feedback

You must reconfigure the Replication Manager.

To configure the Synchronizer

  1. Start Replication Manager.

  2. On the Tools menu, click Configure Microsoft Replication Manager.

  3. Follow the instructions in the wizard.


Report.Left Property (Access)

 Copy code hover
[image]

Report.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Long.

Syntax

expression .Left

expression A variable that represents a Report object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


Relation Object Reference (DAO)

 Copy code hover
[image]

Relation Object Reference (DAO)
Send feedback

In this section

  • Relation Object (DAO)

  • Relation Members (DAO)

  • Relation Properties (DAO)

  • Relation Methods (DAO)


Close Method (ADO MD)

 Copy code hover
[image]

Close Method (ADO MD)
Send feedback

Closes an open cellset.

Syntax

Cellset.Close

Remarks

Using the Close method to close a Cellset object will release the associated data, including data in any related Cell, Axis, Position, or Member objects. Closing a Cellset does not remove it from memory; you can change its property settings and open it again later. To completely eliminate an object from memory, set the object variable to Nothing.

You can later call the Open method to reopen the Cellset using the same or another source string. While the Cellset object is closed, retrieving any properties or calling any methods that reference the underlying data or metadata generates an error.


DoCmd.SetMenuItem Method (Access)

 Copy code hover
[image]

DoCmd.SetMenuItem Method (Access)
See also Send feedback

Published: July 16, 2012

The SetMenuItem method carries out the SetMenuItem action in Visual Basic.

Syntax

expression .SetMenuItem(MenuIndex, CommandIndex, SubcommandIndex, Flag)

expression A variable that represents a DoCmd object.

Parameters

Name

Required/Optional

Data Type

Description

MenuIndex

Required

Variant

An integer, counting from 0, that's the valid index of a menu on the custom menu bar or global menu bar for the active window, as defined in the menu bar macro for the custom menu bar or global menu bar. If you select a menu with this argument and leave the commandindex and subcommandindex arguments blank (or set them to -1), you can enable or disable the menu name itself. You can't, however, check or uncheck a menu name (Microsoft Access ignores the acMenuCheck and acMenuUncheck settings for the flag argument for menu names).

CommandIndex

Optional

Variant

An integer, counting from 0, that's the valid index of a command on the menu selected by the menuindex argument, as defined in the macro group that defines the selected menu for the custom menu bar or global menu bar for the active window.

SubcommandIndex

Optional

Variant

An integer, counting from 0, that's the valid index of a subcommand in the submenu selected by the commandindex argument, as defined in the macro group that defines the selected submenu for the custom menu bar or global menu bar for the active window.

Flag

Optional

Variant

The state you want to set the command or subcommand to. Can be one of the following constants.

  • acMenuCheck

  • acMenuGray

  • acMenuUncheck

  • acMenuUngray (default)

Remarks

You can use the SetMenuItem method to set the state of menu items (enabled or disabled, checked or unchecked) on the custom menu bar or global menu bar for the active window.

Note Note

The SetMenuItem method works only with custom menu bars and global menu bars created by using menu bar macros. The SetMenuItem method is included in this version of Microsoft Access only for compatibility with versions prior to Microsoft Access 97. It doesn't work with the new command bars functionality.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Form.DatasheetGridlinesBehavior Property (Access)

 Copy code hover
[image]

Form.DatasheetGridlinesBehavior Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DatasheetGridlinesBehavior property to specify which gridlines will appear in Datasheet view. Read/write Byte.

Syntax

expression .DatasheetGridlinesBehavior

expression A variable that represents a Form object.

Remarks

This DatasheetGridlinesBehavior property applies only to objects in Datasheet view.

This property is only available in Visual Basic within a Microsoft Access database.

The DatasheetGridlinesBehavior property uses the following settings.

Visual Basic | Description
acGridlinesNone | No gridlines are displayed.
acGridlinesHoriz | Only horizontal gridlines are displayed.
acGridlinesVert | Only vertical gridlines are displayed.
acGridlinesBoth | (Default) Horizontal and vertical gridlines are displayed.

The following table contains the properties that don't exist in the DAO Properties collection of until you set them by using the Formatting (Datasheet) toolbar or you can add them in an Access database by using the CreateProperty method and append it to the DAO Properties collection.

DatasheetFontItalic * | DatasheetForeColor *
DatasheetFontHeight * | DatasheetBackColor
DatasheetFontName * | DatasheetGridlinesColor
DatasheetFontUnderline * | DatasheetGridlinesBehavior
DatasheetFontWeight * | DatasheetCellsEffect
Note Note

When you add or set any property listed with an asterisk, Microsoft Access automatically adds all the properties listed with an asterisk to the Properties collection in the database.

See also

Concepts

Form Object

Other resources

Form Object Members


ADOX Code Examples

 Copy code hover
[image]

ADOX Code Examples
Send feedback

Use the following code examples to learn how to use the ADOX objects, methods, properties, and events.

Note Note

Paste the entire code example into your code editor. The example may not run correctly if partial examples are used or if paragraph formatting is lost.

  • ADOX Code Examples in Microsoft Visual Basic

  • ADOX Code Examples in Microsoft Visual C++


CheckBox.GridlineTint Property (Access)

 Copy code hover
[image]

CheckBox.GridlineTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineTint

expression A variable that represents a CheckBox object.

Remarks

The GridlineTint property contains a numeric expression that can be used to lighten the theme color in the GridlineColor property. The default value of the GridlineTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


TableDef Object (DAO)

 Copy code hover
[image]

TableDef Object (DAO)
Send feedback

A TableDef object represents the stored definition of a base table or a linked table (Microsoft Access workspaces only).

Remarks

You manipulate a table definition using a TableDef object and its methods and properties. For example, you can:

  • Examine the field and index structure of any local, linked, or external table in a database.

  • Use the Connect and SourceTableName properties to set or return information about linked tables, and use the RefreshLink method to update connections to linked tables.

  • Use the ValidationRule and ValidationText properties to set or return validation conditions.

  • Use the OpenRecordset method to create a table-, dynaset-, dynamic-, snapshot-, or forward-only-type Recordset object, based on the table definition.

For base tables, the RecordCount property contains the number of records in the specified database table. For linked tables, the RecordCount property setting is always -1.

To create a new TableDef object, use the CreateTableDef method.

To add a field to a table

  1. Make sure any Recordset objects based on the table are all closed.

  2. Use the CreateField method to create a Field object variable and set its properties.

  3. Use the Append method to add the Field object to the Fields collection of the TableDef object.

You can delete a Field object from a TableDefs collection if it doesn't have any indexes assigned to it, but you will lose the field's data.

To create a table that is ready for new records in a database

  1. Use the CreateTableDef method to create a TableDef object.

  2. Set its properties.

  3. For each field in the table, use the CreateField method to create a Field object variable and set its properties.

  4. Use the Append method to add the fields to the Fields collection of the TableDef object.

  5. Use the Append method to add the new TableDef object to the TableDefs collection of the Database object.

A linked table is connected to the database by the SourceTableName and Connect properties of the TableDef object.

To link a table to a database

  1. Use the CreateTableDef method to create a TableDef object.

  2. Set its Connect and SourceTableName properties (and optionally, its Attributes property).

  3. Use the Append method to add it to the TableDefs collection of a Database.

To refer to a TableDef object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

TableDefs(0)

TableDefs("name")

TableDefs![name]

Example

This example creates a new TableDef object and appends it to the TableDefs collection of the Northwind Database object. It then enumerates the TableDefs collection and the Properties collection of the new TableDef.

VBA Copy code Copy code
Sub TableDefX()

   Dim dbsNorthwind As Database
   Dim tdfNew As TableDef
   Dim tdfLoop As TableDef
   Dim prpLoop As Property

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   ' Create new TableDef object, append Field objects
   ' to its Fields collection, and append TableDef
   ' object to the TableDefs collection of the
   ' Database object.
   Set tdfNew = dbsNorthwind.CreateTableDef("NewTableDef")
   tdfNew.Fields.Append tdfNew.CreateField("Date", dbDate)
   dbsNorthwind.TableDefs.Append tdfNew

   With dbsNorthwind
      Debug.Print .TableDefs.Count & _
         " TableDefs in " & .Name

      ' Enumerate TableDefs collection.
      For Each tdfLoop In .TableDefs
         Debug.Print "  " & tdfLoop.Name
      Next tdfLoop

      With tdfNew
         Debug.Print "Properties of " & .Name

         ' Enumerate Properties collection of new
         ' TableDef object, only printing properties
         ' with non-empty values.
         For Each prpLoop In .Properties
            Debug.Print "  " & prpLoop.Name & " - " & _
               IIf(prpLoop = "", "[empty]", prpLoop)
         Next prpLoop

      End With

      ' Delete new TableDef since this is a
      ' demonstration.
      .TableDefs.Delete tdfNew.Name
      .Close
   End With

End Sub

This example creates a new TableDef object in the Northwind database.

VBA Copy code Copy code
Sub CreateTableDefX()

   Dim dbsNorthwind As Database
   Dim tdfNew As TableDef
   Dim prpLoop As Property

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   ' Create a new TableDef object.
   Set tdfNew = dbsNorthwind.CreateTableDef("Contacts")

   With tdfNew
      ' Create fields and append them to the new TableDef
      ' object. This must be done before appending the
      ' TableDef object to the TableDefs collection of the
      ' Northwind database.
      .Fields.Append .CreateField("FirstName", dbText)
      .Fields.Append .CreateField("LastName", dbText)
      .Fields.Append .CreateField("Phone", dbText)
      .Fields.Append .CreateField("Notes", dbMemo)

      Debug.Print "Properties of new TableDef object " & _
         "before appending to collection:"

      ' Enumerate Properties collection of new TableDef
      ' object.
      For Each prpLoop In .Properties
         On Error Resume Next
         If prpLoop <> "" Then Debug.Print "  " & _
           prpLoop.Name & " = " & prpLoop
         On Error GoTo 0
      Next prpLoop

      ' Append the new TableDef object to the Northwind
      ' database.
      dbsNorthwind.TableDefs.Append tdfNew

      Debug.Print "Properties of new TableDef object " & _
         "after appending to collection:"

      ' Enumerate Properties collection of new TableDef
      ' object.
      For Each prpLoop In .Properties
         On Error Resume Next
         If prpLoop <> "" Then Debug.Print "  " & _
           prpLoop.Name & " = " & prpLoop
         On Error GoTo 0
      Next prpLoop

   End With

   ' Delete new TableDef object since this is a
   ' demonstration.
   dbsNorthwind.TableDefs.Delete "Contacts"

   dbsNorthwind.Close

The following example shows how to create a calculated field. The CreateField method creates a field named FullName. The Expression property is then set to the expression that calculates the value of the field.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Sub CreateCalculatedField()
    Dim dbs As DAO.Database
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field2

    ' get the database
    Set dbs = CurrentDb()

    ' create the table
    Set tdf = dbs.CreateTableDef("tblContactsCalcField")

    ' create the fields: first name, last name
    tdf.Fields.Append tdf.CreateField("FirstName", dbText, 20)
    tdf.Fields.Append tdf.CreateField("LastName", dbText, 20)

    ' create the calculated field: full name
    Set fld = tdf.CreateField("FullName", dbText, 50)
    fld.Expression = "[FirstName] & "" "" & [LastName]"
    tdf.Fields.Append fld

    ' append the table and cleanup
    dbs.TableDefs.Append tdf

Cleanup:
    Set fld = Nothing
    Set tdf = Nothing
    Set dbs = Nothing
End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


URL Property (RDS)

 Copy code hover
[image]

URL Property (RDS)
Send feedback

Indicates a string that contains a relative or absolute URL.

You can set the URL property at design time in the DataControl object's OBJECT tag, or at run time in scripting code.

Syntax

Design time: <PARAM NAME="URL" VALUE="Server">

Run time: DataControl.URL="Server"

Parameters

  • Server

  • A String value that contains a valid URL.

  • DataControl

  • An object variable that represents a DataControl object.

Remarks

Typically, the URL identifies an Active Server Page (.asp) file that can produce and return a Recordset. Therefore, the user can obtain a Recordset without having to invoke the server-side DataFactory object, or program a custom business object.

If the URL property has been set, SubmitChanges will submit changes to the location specified by the URL.


Key Object (ADOX)

 Copy code hover
[image]

Key Object (ADOX)
Send feedback

Represents a primary, foreign, or unique key field from a database table.

Remarks

The following code creates a new Key:

Copy code Copy code
Dim obj As New Key

With the properties and collections of a Key object, you can:

  • Identify the key with the Name property.

  • Determine whether the key is primary, foreign, or unique with the Type property.

  • Access the database columns of the key with the Columns collection.

  • Specify the name of the related table with the RelatedTable property.

  • Determine the action performed on deletion or update of a primary key with the DeleteRule and UpdateRule properties.


Printer.PrintQuality Property (Access)

 Copy code hover
[image]

Printer.PrintQuality Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets an AcPrintObjQuality constant indicating the resolution at which the specified printer should print jobs. Read/write.

Syntax

expression .PrintQuality

expression A variable that represents a Printer object.

Example

The following example sets a variety of printer settings for the form specified in the strFormname argument of the procedure.

VBA Copy code Copy code
Sub SetPrinter(strFormname As String)

 DoCmd.OpenForm FormName:=strFormname, view:=acDesign, _
 datamode:=acFormEdit, windowmode:=acHidden

 With Forms(form1).Printer

 .TopMargin = 1440
 .BottomMargin = 1440
 .LeftMargin = 1440
 .RightMargin = 1440

 .ColumnSpacing = 360
 .RowSpacing = 360

 .ColorMode = acPRCMColor
 .DataOnly = False
 .DefaultSize = False
 .ItemSizeHeight = 2880
 .ItemSizeWidth = 2880
 .ItemLayout = acPRVerticalColumnLayout
 .ItemsAcross = 6

 .Copies = 1
 .Orientation = acPRORLandscape
 .Duplex = acPRDPVertical
 .PaperBin = acPRBNAuto
 .PaperSize = acPRPSLetter
  .PrintQuality = acPRPQMedium

 End With

 DoCmd.Close objecttype:=acForm, objectname:=strFormname, _
 Save:=acSaveYes

End Sub

See also

Concepts

Printer Object

Other resources

Printer Object Members


OptionButton.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

OptionButton.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Syntax

expression .ShortcutMenuBar

expression A variable that represents an OptionButton object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

Example

The following example sets the "Suppliers_Toolbar" as the custom shortcut menu to display when the user clicks the right mouse button on the "Suppliers" form.

VBA Copy code Copy code
Forms("Suppliers").ShortcutMenuBar = "Suppliers_Toolbar"

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Invalid expression in the ReplicaFilter property. (Error 3587)

 Copy code hover
[image]

Invalid expression in the ReplicaFilter property. (Error 3587)
Send feedback

The ReplicaFilter string contains an invalid word. Check the syntax for any misspelled or missing words.


Screen Object (Access)

 Copy code hover
[image]

Screen Object (Access)
See also Send feedback

Published: July 16, 2012

The Screen object refers to the particular form, report, or control that currently has the focus.

Remarks

You can use the Screen object together with its properties to refer to a particular form, report, or control that has the focus.

For example, you can use the Screen object with the ActiveForm property to refer to the form in the active window without knowing the form's name. The following example displays the name of the form in the active window:

VBA Copy code Copy code
MsgBox Screen.ActiveForm.Name

Referring to the Screen object doesn't make a form, report, or control active. To make a form, report, or control active, you must use the SelectObject method of the DoCmd object.

If you refer to the Screen object when there's no active form, report, or control, Microsoft Access returns a run-time error. For example, if a standard module is in the active window, the code in the preceding example would return an error.

Example

The following example uses the Screen object to print the name of the form in the active window and of the active control on that form:

VBA Copy code Copy code
Sub ActiveObjects()
 Dim frm As Form, ctl As Control

 ' Return Form object pointing to active form.
 Set frm = Screen.ActiveForm
 MsgBox frm.Name & " is the active form."
 ' Return Control object pointing to active control.
 Set ctl = Screen.ActiveControl
 MsgBox ctl.Name & " is the active control " _
 & "on this form."
End Sub

See also

Concepts

Access Object Model Reference

Other resources

Screen Object Members


ObjectFrame.GridlineColor Property (Access)

 Copy code hover
[image]

ObjectFrame.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified object frame. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineColor

expression A variable that represents an ObjectFrame object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


How to: Specify Date and Time in Criteria Expressions

 Copy code hover
[image]

How to: Specify Date and Time in Criteria Expressions
Send feedback

To specify date or time criteria for an operation, you supply a date or time value as part of the string expression that forms the criteria argument. This value must be enclosed in number signs (#).

Note Note

The number signs indicate to Microsoft Access that the criteria argument contains a date or time within a string.

Suppose that you are creating a filter for an Employees form to display records for all employees born on or after January 1, 1960. You could construct the criteria argument for the form's Filter or ServerFilter property, as shown in the following example. Note the placement of the number signs.

Copy code Copy code
Forms!Employees.Filter = "[BirthDate] >= #1-1-1960#"


Cannot change password on a shared open database. (Error 3621)

 Copy code hover
[image]

Cannot change password on a shared open database. (Error 3621)
Send feedback

To change the password, the database must be opened exclusively.


Report.NextRecord Property (Access)

 Copy code hover
[image]

Report.NextRecord Property (Access)
See also Send feedback

Published: July 16, 2012

The NextRecord property specifies whether a section should advance to the next record. Read/write Boolean.

Syntax

expression .NextRecord

expression A variable that represents a Report object.

Remarks

The NextRecord property uses the following settings.

Setting | Description
True | (Default) The section advances to the next record.
False | The section doesn't advance to the next record.

To set this property, specify an event procedure for a section's OnFormat property.

Microsoft Access sets this property to True before each section's Format event.

Example

The following example sets the NextRecord property to False for a given report.

VBA Copy code Copy code
Public Sub ChangeNextRecord(r As Report)
 r.NextRecord = False
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


Internet Explorer Error Codes

 Copy code hover
[image]

Internet Explorer Error Codes
Send feedback

The following table lists Microsoft Internet Explorer error codes related to Remote Data Service usage. The positive decimal translation of the low two bytes, the negative decimal translation of the full error code, and the hexadecimal values are shown.

Internet Explorer (Wininet) errors | Number | Description
IDS_WinInet_CantConnect | 8195 -2146820093 0x800A2003 | Internet Client Error: Cannot Connect to Server.
IDS_WinInet_ ConnectionReset | 12031 -2146816257 0x800A2EFF | Internet Client Error: Connection Reset.
IDS_WinInet_Error | 8193 -2146820095 0x800A2001 | Internet Client Error.
IDS_WinInet_ InvalidServerResponse | 8430 -2146819858 0x800A20EE | Internet Client Error: Invalid Server Response.
IDS_WinInet_ SSLPostLimitation | 8196 -2146820092 0x800A2004 | Internet Client Error: SSL Error (possibly 32K data upload limitation).
IDS_WinInet_Timeout | 8194 -2146820094 0x800A2002 | Internet Client Error: Request Timeout.


Function is not available in expressions. (Error 2426)

 Copy code hover
[image]

Function is not available in expressions. (Error 2426)
Send feedback

You have entered a function that cannot be used in this expression. The functions DoEvents, LBound, UBound, Spc, and Tab are not available in expressions.


TabControl.Tag Property (Access)

 Copy code hover
[image]

TabControl.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents a TabControl object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Connection Object (ADO) Reference

 Copy code hover
[image]

Connection Object (ADO) Reference
Send feedback

In this section

  • Connection Object (ADO)

  • Connection Properties, Methods, and Events (ADO)


Attachment.BorderTint Property (Access)

 Copy code hover
[image]

Attachment.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderTint

expression A variable that represents an Attachment object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


User-defined properties do not support a Null value. (Error 3385)

 Copy code hover
[image]

User-defined properties do not support a Null value. (Error 3385)
Send feedback

User-defined Property objects cannot be set to Null. Instead, use the Delete method on the property to remove it from its collection.


ActiveCommand Property Example (VB)

 Copy code hover
[image]

ActiveCommand Property Example (VB)
Send feedback

This example demonstrates the ActiveCommand property.

A subroutine is given a Recordset object whose ActiveCommand property is used to display the command text and parameter that created the Recordset.

Copy code Copy code

'BeginActiveCommandVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 'recordset and connection variables
 Dim cmd As ADODB.Command
 Dim rst As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 'record variables
 Dim strPrompt As String
 Dim strName As String

 Set Cnxn = New ADODB.Connection
 Set cmd = New ADODB.Command

 strPrompt = "Enter an author's name (e.g., Ringer): "
 strName = Trim(InputBox(strPrompt, "ActiveCommandX Example"))
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"

 'create SQL command string
 cmd.CommandText = "SELECT * FROM Authors WHERE au_lname = ?"
 cmd.Parameters.Append cmd.CreateParameter("LastName", adChar, adParamInput, 20, strName)

 Cnxn.Open strCnxn
 cmd.ActiveConnection = Cnxn

 'create the recordset by executing command string
 Set rst = cmd.Execute(, , adCmdText)
 'see the results
 Call ActiveCommandXprint(rst)

 ' clean up
 Cnxn.Close
 Set rst = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rst Is Nothing Then
 If rst.State = adStateOpen Then rst.Close
 End If
 Set rst = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndActiveCommandVB

The ActiveCommandXprint routine is given only a Recordset object, yet it must print the command text and parameter that created the Recordset. This can be done because the Recordset object's ActiveCommand property yields the associated Command object.

The Command object's CommandText property yields the parameterized command that created the Recordset. The Command object's Parameters collection yields the value that was substituted for the command's parameter placeholder ("?").

Finally, an error message or the author's name and ID are printed.

Copy code Copy code

'BeginActiveCommandPrintVB
Public Sub ActiveCommandXprint(rstp As ADODB.Recordset)

 Dim strName As String

 strName = rstp.ActiveCommand.Parameters.Item("LastName").Value

 Debug.Print "Command text = '"; rstp.ActiveCommand.CommandText; "'"
 Debug.Print "Parameter = '"; strName; "'"

 If rstp.BOF = True Then
 Debug.Print "Name = '"; strName; "', not found."
 Else
 Debug.Print "Name = '"; rstp!au_fname; " "; rstp!au_lname; _
 "', author ID = '"; rstp!au_id; "'"
 End If

 rstp.Close
 Set rstp = Nothing
End Sub
'EndActiveCommandPrintVB


Resync Method Example (VB)

 Copy code hover
[image]

Resync Method Example (VB)
Send feedback

This example demonstrates using the Resync method to refresh data in a static recordset.

Copy code Copy code

'BeginResyncVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection strings

Public Sub Main()
 On Error GoTo ErrorHandler

 'connection and recordset variables
 Dim Cnxn As ADODB.Connection
 Dim rstTitles As ADODB.Recordset
 Dim strCnxn As String
 Dim strSQLTitles As String

 ' Open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open recordset using object refs to set properties
 ' that allow for updates to the database
 Set rstTitles = New ADODB.Recordset
 Set rstTitles.ActiveConnection = Cnxn
 rstTitles.CursorType = adOpenKeyset
 rstTitles.LockType = adLockOptimistic

 strSQLTitles = "titles"
 rstTitles.Open strSQLTitles

 'rstTitles.Open strSQLTitles, Cnxn, adOpenKeyset, adLockPessimistic, adCmdTable
 'the above line of code passes the same refs as the object refs listed above

 ' Change the type of the first title in the recordset
 rstTitles!Type = "database"

 ' Display the results of the change
 MsgBox "Before resync: " & vbCr & vbCr & _
 "Title - " & rstTitles!Title & vbCr & _
 "Type - " & rstTitles!Type

 ' Resync with database and redisplay results
 rstTitles.Resync
 MsgBox "After resync: " & vbCr & vbCr & _
 "Title - " & rstTitles!Title & vbCr & _
 "Type - " & rstTitles!Type

 ' clean up
 rstTitles.CancelBatch
 rstTitles.Close
 Cnxn.Close
 Set rstTitles = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstTitles Is Nothing Then
 If rstTitles.State = adStateOpen Then
 rstTitles.CancelBatch
 rstTitles.Close
 End If
 End If
 Set rstTitles = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndResyncVB


Chapter 12: RDS Tutorial (ADO)

 Copy code hover
[image]

Chapter 12: RDS Tutorial (ADO)
Send feedback

In this section

  • Chapter 12: RDS Tutorial

  • Step 1: Specify a Server Program (RDS Tutorial)

  • Step 2: Invoke the Server Program (RDS Tutorial)

  • Step 3: Server Obtains a Recordset (RDS Tutorial)

  • Step 4: Server Returns the Recordset (RDS Tutorial)

  • Step 5: DataControl is Made Usable (RDS Tutorial)

  • Step 6: Changes are Sent to the Server (RDS Tutorial)

  • RDS Tutorial (VBScript)

  • RDS Tutorial (Visual J++)


TabControl.HoverForeShade Property (Access)

 Copy code hover
[image]

TabControl.HoverForeShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .HoverForeShade

expression A variable that represents a TabControl object.

Remarks

The HoverForeShade property contains a numeric expression that can be used to darken the theme color in the HoverForeColor property. The default value of the HoverForeShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Do You Have Feedback About MDAC Documentation?

 Copy code hover
[image]

Do You Have Feedback About MDAC Documentation?
Send feedback

The MDAC documentation team welcomes your suggestions and comments about our documentation and samples. You can send feedback quickly and directly to us via e-mail or the Universal Data Access Web site. Many of your suggestions have been implemented in this release of the documentation.

Note Note

If you need technical support, see "Getting Help from Microsoft Product Support Services." The MDAC documentation team cannot answer technical support questions, but we welcome your feedback concerning the presentation, accuracy, and thoroughness of the documentation, as well as your ideas for improving it.

E-mail

The MDAC documentation now includes a Documentation Feedback button at the top of every topic. Clicking this button offers an easy way to send e-mail feedback to the MDAC documentation team. Addresses for each section of the MDAC documentation also appear below.

Documentation | Address
MDAC Overview | mdacdoc@microsoft.com
ADO | adodoc@microsoft.com
OLE DB and providers | oledbdoc@microsoft.com
ODBC and drivers | odbcdoc@microsoft.com
MDAC technical articles | datech@microsoft.com
MDAC samples | dacode@microsoft.com


ObjectFrame.SetFocus Method (Access)

 Copy code hover
[image]

ObjectFrame.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Syntax

expression .SetFocus

expression A variable that represents an ObjectFrame object.

Return Value

Nothing

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.

Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.

Example

The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:

VBA Copy code Copy code
Forms!Employees!EmployeeID.SetFocus

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


AcSection Enumeration (Access)

 Copy code hover
[image]

AcSection Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the section that will contain the new control.

Name | Value | Description
acDetail | 0 | (Default) Detail section
acFooter | 2 | Form or report footer
acGroupLevel1Footer | 6 | Group-level 1 footer (reports only)
acGroupLevel1Header | 5 | Group-level 1 header (reports only)
acGroupLevel2Footer | 8 | Group-level 2 footer (reports only)
acGroupLevel2Header | 7 | Group-level 2 header (reports only)
acHeader | 1 | Form or report header
acPageFooter | 4 | Page footer
acPageHeader | 3 | Page header


Crosstab query contains one or more invalid fixed column headings. (Error 3322)

 Copy code hover
[image]

Crosstab query contains one or more invalid fixed column headings. (Error 3322)
Send feedback

The list of entries for a fixed column heading of a crosstab query (the PIVOT clause in a TRANSFORM statement) is not valid.

Possible causes:

  • There are no entries in the list. There must be at least one value in the parentheses following the IN reserved word in the PIVOT clause.

  • A blank entry appears in the list. Two commas in a row (,,) create a blank entry.

  • The list contains a field name of more than 64 characters.

Correct the PIVOT clause and execute the query again.


ComboBox.FontName Property (Access)

 Copy code hover
[image]

ComboBox.FontName Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontName property to specify the font for text in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write String.

Syntax

expression .FontName

expression A variable that represents a ComboBox object.

Remarks

The FontName property setting is the name of the font that the text is displayed in.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set this property only in an event procedure or in a macro specified by the OnPrint event property setting.

Font availability depends on your system and printer. If you select a font that your system can't display or that isn't installed, Windows substitutes a similar font.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


StDev, StDevP Functions (Microsoft Access SQL)

 Copy code hover
[image]

StDev, StDevP Functions (Microsoft Access SQL)
Send feedback

Published: July 16, 2012

Return estimates of the standard deviation for a population or a population sample represented as a set of values contained in a specified field on a query.

Syntax

StDev(expr)

StDevP(expr)

The expr placeholder represents a string expression identifying the field that contains the numeric data you want to evaluate or an expression that performs a calculation using the data in that field. Operands in expr can include the name of a table field, a constant, or a function (which can be either intrinsic or user-defined but not one of the other SQL aggregate functions).

Remarks

The StDevP function evaluates a population, and the StDev function evaluates a population sample.

If the underlying query contains fewer than two records (or no records, for the StDevP function), these functions return a Null value (which indicates that a standard deviation cannot be calculated).

You can use the StDev and StDevP functions in a query expression. You can also use this expression in the SQL property of a QueryDef object or when creating a Recordset object based on an SQL query.

Example

This example uses the Orders table to estimate the standard deviation of the freight charges for orders shipped to the United Kingdom.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

Copy code Copy code
Sub StDevX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Calculate the standard deviation of the freight
    ' charges for orders shipped to the United Kingdom.
    Set rst = dbs.OpenRecordset("SELECT " _
        & "StDev(Freight) " _
        & "AS [Freight Deviation] FROM Orders " _
        & "WHERE ShipCountry = 'UK';")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 15

    Debug.Print

    Set rst = dbs.OpenRecordset("SELECT " _
        & "StDevP(Freight) " _
        & "AS [Freight DevP] FROM Orders " _
        & "WHERE ShipCountry = 'UK';")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 15

    dbs.Close

End Sub


DoCmd.SendObject Method (Access)

 Copy code hover
[image]

DoCmd.SendObject Method (Access)
See also Send feedback

Published: July 16, 2012

The SendObject method carries out the SendObject action in Visual Basic.

Syntax

expression .SendObject(ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
ObjectType | Optional | AcSendObjectType | A AcSendObjectType constant that specifies the type of object to send.
ObjectName | Optional | Variant | A string expression that's the valid name of an object of the type selected by the ObjectType argument. If you want to include the active object in the mail message, specify the object's type with the ObjectType argument and leave this argument blank. If you leave both the ObjectType and ObjectName arguments blank (the default constant, acSendNoObject, is assumed for the ObjectType argument), Microsoft Access sends a message to the electronic mail application without an included database object. If you run Visual Basic code containing the SendObject method in a library database, Microsoft Access looks for the object with this name first in the library database, then in the current database.
OutputFormat | Optional | Variant |
To | Optional | Variant | A string expression that lists the recipients whose names you want to put on the To line in the mail message. Separate the recipient names you specify in this argument and in the cc and bcc arguments with a semicolon (;) or with the list separator set on the Number tab of the Regional Settings Properties dialog box in Windows Control Panel. If the recipient names aren't recognized by the mail application, the message isn't sent and an error occurs. If you leave this argument blank, Microsoft Access prompts you for the recipients.
Cc | Optional | Variant | A string expression that lists the recipients whose names you want to put on the Cc line in the mail message. If you leave this argument blank, the Cc line in the mail message is blank.
Bcc | Optional | Variant | A string expression that lists the recipients whose names you want to put on the Bcc line in the mail message. If you leave this argument blank, the Bcc line in the mail message is blank.
Subject | Optional | Variant | A string expression containing the text you want to put on the Subject line in the mail message. If you leave this argument blank, the Subject line in the mail message is blank.
MessageText | Optional | Variant | A string expression containing the text you want to include in the body of the mail message, after the object. If you leave this argument blank, the object is all that's included in the body of the mail message.
EditMessage | Optional | Variant | Use True (-1) to open the electronic mail application immediately with the message loaded, so the message can be edited. Use False (0) to send the message without editing it. If you leave this argument blank, the default (True) is assumed.
TemplateFile | Optional | Variant | A string expression that's the full name, including the path, of the file you want to use as a template for an HTML file.

Remarks

You can use the SendObject action to include the specified Microsoft Access datasheet, form, report, or module in an electronic mail message, where it can be viewed and forwarded. You can include objects in Microsoft Excel 2000 (*.xls), MS-DOS text (*.txt), rich-text (*.rtf), or HTML (*.html) format in messages for Microsoft Outlook, Microsoft Exchange, or another electronic mail application that uses the Mail Applications Programming Interface (MAPI).

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 in the datasheet look as they do in Access, except fields containing OLE objects. 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, option button, or check box), the output file displays the value -1 (Yes) or 0 (No).

  • For a text box bound to a Hyperlink field, the output file displays the hyperlink 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, the included object always contains the form's Datasheet view.

  • If you send a report, 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. 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 other than Sum) is included in the object.

  • Subreports are included in the object. Subforms are included when outputting to .asp, but only when outputting as a form (not a datasheet).

  • 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.

Modules can be sent only in MS-DOS Text format, so if you specify acSendModule for the ObjectType argument, you must specify acFormatTXT for the OutputFormat argument.

Note Note

You can save as a PDF or XPS file from a 2007 Microsoft Office system program only after you install an add-in. For more information, search for "Enable support for other file formats, such as PDF and XPS" on the Office Web site.

Link provided by: Community Member Icon Luke Chung, FMS, Inc. | About the Contributors

  • Features and Limits of Using the SendObject Method to Send Emails

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Email from Access

Example

The following code example includes the Employees table in a mail message in Microsoft Excel format and specifies To, Cc, and Subject lines in the mail message. The mail message is sent immediately, without editing.

VBA Copy code Copy code
DoCmd.SendObject acSendTable, "Employees", acFormatXLS, _
    "Nancy Davolio; Andrew Fuller", "Joan Weber", , _
    "Current Spreadsheet of Employees", , False

The following example shows how to create an email message with Microsoft Outlook and display it to the user.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Public Function CreateEmailWithOutlook( _
    MessageTo As String, _
    Subject As String, _
    MessageBody As String)

    ' Define app variable and get Outlook using the "New" keyword
    Dim olApp As New Outlook.Application
    Dim olMailItem As Outlook.MailItem  ' An Outlook Mail item

    ' Create a new email object
    Set olMailItem = olApp.CreateItem(olMailItem)

    ' Add the To/Subject/Body to the message and display the message
    With olMailItem
        .To = MessageTo
        .Subject = Subject
        .Body = MessageBody
        .Display    ' To show the email message to the user
    End With

    ' Release all object variables
    Set olMailItem = Nothing
    Set olApp = Nothing

End Function

The following example shows how to create an email message with Microsoft Outlook and send it without displaying the email message to the user.

VBA Copy code Copy code
Public Function SendEmailWithOutlook( _
    MessageTo As String, _
    Subject As String, _
    MessageBody As String)

    ' Define app variable and get Outlook using the "New" keyword
    Dim olApp As New Outlook.Application
    Dim olMailItem As Outlook.MailItem  ' An Outlook Mail item

    ' Create a new email object
    Set olMailItem = olApp.CreateItem(olMailItem)

    ' Add the To/Subject/Body to the message and display the message
    With olMailItem
        .To = MessageTo
        .Subject = Subject
        .Body = MessageBody
        .Send       ' Send the message immediately
    End With

    ' Release all object variables
    Set olMailItem = Nothing
    Set olApp = Nothing

End Function

About the Contributors

Luke Chung is the founder and president of FMS, Inc., a leading provider of custom database solutions and developer tools.

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Chapter 8: Understanding Cursors and Locks

 Copy code hover
[image]

Chapter 8: Understanding Cursors and Locks
Send feedback

It is important to understand how cursors operate so you can select the best and most efficient cursor type for an application's data-access requirements. A less-than-optimal cursor configuration can make data-access operations painfully slow.

Many capabilities of the ADO Recordset object are determined by the type and location of the cursor, as well as the lock type.

This chapter covers the following topics:

  • What is a Cursor?

  • Types of Cursors

  • The Significance of Cursor Location

  • The Microsoft Cursor Service for OLE DB

  • What is a Lock?

  • Using CacheSize

  • Cursor and Lock Characteristics


ADCPROP_UPDATERESYNC_ENUM

 Copy code hover
[image]

ADCPROP_UPDATERESYNC_ENUM
Send feedback

Specifies whether the UpdateBatch method is followed by an implicit Resync method operation and if so, the scope of that operation.

Constant | Value | Description
adResyncAll | 15 | Invokes Resync with the combined value of all the other ADCPROP_UPDATERESYNC_ENUM members.
adResyncAutoIncrement | 1 | Default. Attempts to retrieve the new identity value for columns that are automatically incremented or generated by the data source, such as Microsoft Jet AutoNumber fields or Microsoft SQL Server Identity columns.
adResyncConflicts | 2 | Invokes Resync for all rows in which the update or delete operation failed because of a concurrency conflict.
adResyncInserts | 8 | Invokes Resync for all successfully inserted rows. However, AutoIncrement column values are not resynchronized. Instead, the contents of newly inserted rows are resynchronized based on the existing primary key value. If the primary key is an AutoIncrement value, Resync won't retrieve the contents of the intended row. For automatically incrementing AutoIncrement primary key values, call UpdateBatch with the combined value adResyncAutoIncrement + adResyncInserts.
adResyncNone | 0 | Does not invoke Resync.
adResyncUpdates | 4 | Invokes Resync for all successfully updated rows.


ADO MD API Reference

 Copy code hover
[image]

ADO MD API Reference
Send feedback

This section of the ADO MD documentation contains topics for each ADO MD object, collection, method, and property, as well as example code when appropriate. For more information, search for a specific topic in the index or refer to the following topics:

  • ADO MD Objects

  • ADO MD Collections

  • ADO MD Properties

  • ADO MD Methods

  • ADO MD Enumerated Constants

  • ADO MD Examples


WebBrowserControl.LeftPadding Property (Access)

 Copy code hover
[image]

WebBrowserControl.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .LeftPadding

expression A variable that represents a WebBrowserControl object.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Persisting Data (ADO)

 Copy code hover
[image]

Persisting Data (ADO)
Send feedback

In this section

  • Persisting Data

  • More About Recordset Persistence

  • Persisting Filtered and Hierarchical Recordsets

  • Persisting Records in XML Format (ADO)


Concepts (Access 2013 Developer Reference)

 Copy code hover
[image]

Concepts (Access 2013 Developer Reference)
Send feedback

This section provides important concepts for developing custom Microsoft Office Access solutions.

Are You Viewing Help in a Microsoft Office Product?

If you are viewing Help from inside your installed version of the documentation, you can use the table of contents to navigate through the topics. To open the table of contents, click the Show Table of Contents toolbar button [image] in the Help window. Click a topic in the table of contents to view it.

If Connected to Office.com appears in the lower-right corner of the Help window, you are searching Help from the Office Web site. If Offline appears, you are searching Help from the files stored on your computer.

Are You Viewing the Content in the MSDN Library?

If you are viewing the content on MSDN, you can use the table of contents located to the left of the topic to navigate through the documentation.


Operation of Non-Parameterized Commands

 Copy code hover
[image]

Operation of Non-Parameterized Commands
Send feedback

For non-parameterized commands, all of the provider commands are executed and the Recordsets are created during command execution. If the command is executed synchronously, all of the Recordsets will be fully populated. If an asynchronous population mode was selected, the populated state of the Recordsets will depend on the population mode and the size of the Recordsets.

For example, the parent-command could return a Recordset of customers for a company from a Customers table, and the child-command could return a Recordset of orders for all customers from an Orders table.

Copy code Copy code

SHAPE {SELECT * FROM Customers}
 APPEND ({SELECT * FROM Orders} AS chapOrders
 RELATE customerID TO customerID)

For non-parameterized parent-child relationships, each parent and child Recordset object must have a column in common to associate them. The columns are named in the RELATE clause, parent-column first and then child-column. The columns may have different names in their respective Recordset objects but must refer to the same information in order to specify a meaningful relation. For example, the Customers and Orders Recordset objects could both have a customerID field. Because the membership of the child Recordset is determined by the provider command, it is possible for the child Recordset to contain orphaned rows. These orphaned rows are inaccessible without further reshaping.

Data shaping appends a chapter column to the parent Recordset. The values in the chapter column are references to rows in the child Recordset, which satisfy the RELATE clause. That is, the same value is in the parent-column of a given parent row as is in the child-column of all the rows of the chapter child. When multiple TO clauses are used in the same RELATE clause, they are implicitly combined using an AND operator. If the parent columns in the relate clause do not constitute a key to the parent Recordset, a single child row may have multiple parent rows.

When you access the reference in the chapter column, ADO automatically retrieves the Recordset represented by the reference. Note that in a non-parameterized command, although the entire child Recordset has been retrieved, the chapter only presents a subset of rows.

If the appended column has no chapter-alias, a name will be generated for it automatically. A Field object for the column will be appended to the Recordset object's Fields collection, and its data type will be adChapter.

For information about navigating a hierarchical Recordset, see Accessing Rows in a Hierarchical Recordset.


Page.EventProcPrefix Property (Access)

 Copy code hover
[image]

Page.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents a Page object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

Page Object

Other resources

Page Object Members


NavigationButton.BackStyle Property (Access)

 Copy code hover
[image]

NavigationButton.BackStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .BackStyle

expression A variable that represents a NavigationButton object.

Remarks

The BackStyle property uses the following settings.

Setting | Visual Basic | Description
Normal | 1 | (Default for all controls except option group) The control has its interior color set by the BackColor property.
Transparent | 0 | (Default for option group) The control is transparent. The color of the form or report behind the control is visible.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

If the Transparent button on the Back Color button palette is selected, the BackStyle property is set to Transparent; otherwise the BackStyle property is set to Normal.

To make a command button invisible, set its Transparent property to Yes.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


AutoCorrect Properties (Access)

 Copy code hover
[image]

AutoCorrect Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
DisplayAutoCorrectOptions | Returns or sets a Boolean value that specifies whether the AutoCorrect Options button is displayed for the specified control. The default value is True. Read/write.


ComboBox.KeyDown Event (Access)

 Copy code hover
[image]

ComboBox.KeyDown Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyDown(KeyCode, Shift)

expression A variable that represents a ComboBox object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyDown property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyDown event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyDown event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyDown event occurs when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

Example

The following example determines whether you have pressed the SHIFT, CTRL, or ALT key.

To try the example, add the following event procedure to a form containing a text box named KeyHandler.

VBA Copy code Copy code
Private Sub KeyHandler_KeyDown(KeyCode As Integer, _
     Shift As Integer)
    Dim intShiftDown As Integer, intAltDown As Integer
    Dim intCtrlDown As Integer

    ' Use bit masks to determine which key was pressed.
    intShiftDown = (Shift And acShiftMask) > 0
    intAltDown = (Shift And acAltMask) > 0
    intCtrlDown = (Shift And acCtrlMask) > 0
    ' Display message telling user which key was pressed.
    If intShiftDown Then MsgBox "You pressed the SHIFT key."
    If intAltDown Then MsgBox "You pressed the ALT key."
    If intCtrlDown Then MsgBox "You pressed the CTRL key."
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


AS (Microsoft Access SQL reserved word)

 Copy code hover
[image]

AS (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The AS keyword is used in these contexts:

SELECT Statement

CREATE VIEW Statement

CREATE PROCEDURE Statement


Report.Load Event (Access)

 Copy code hover
[image]

Report.Load Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when a report is opened and its records are displayed.

Version Information

Version Added: Access 2007

Syntax

expression .Load

expression A variable that represents a Report object.

Remarks

To run a macro or event procedure when these events occur, set the OnLoad property to the name of the macro or to [Event Procedure].

The Load event is caused by user actions such as:

  • Starting an application.

  • Opening a report by clicking Open in the Database window.

  • Running the OpenReport action in a macro.

By running a macro or an event procedure when a report's Load event occurs, you can specify default settings for controls, or display calculated data that depends on the data in the report's records.

By running a macro or an event procedure when a report's Unload event occurs, you can verify that the report should be unloaded or specify actions that should take place when the report is unloaded.

When you first open a report, the following events occur in this order:

Open → Load → Resize → Activate → Current

If you're trying to decide whether to use the Open or Load event for your macro or event procedure, one significant difference is that the Open event can be canceled, but the Load event cannot. For example, if you're dynamically building a record source for a report in an event procedure for the report's Open event, you can cancel opening the report if there are no records to display.

When you close a report, the following events occur in this order:

Unload → Deactivate → Close

The Unload event occurs before the Close event. The Unload event can be canceled, but the Close event cannot.

Note Note

When you create macros or event procedures for events related to the Load event, such as Activate and GotFocus, be sure that they don't conflict (for example, make sure you don't cause something to happen in one macro or procedure that is canceled in another) and that they don't cause cascading events.

See also

Concepts

Report Object

Other resources

Report Object Members


Label.TopPadding Property (Access)

 Copy code hover
[image]

Label.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the label and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .TopPadding

expression A variable that represents a Label object.

See also

Concepts

Label Object

Other resources

Label Object Members


ChangePassword Method (ADOX)

 Copy code hover
[image]

ChangePassword Method (ADOX)
Send feedback

Changes the password for a user account.

Syntax

User.ChangePassword OldPassword, NewPassword

Parameters

  • OldPassword

  • A String value that specifies the user's existing password. If the user doesn't currently have a password, use an empty string ("") for OldPassword.

  • NewPassword

  • A String value that specifies the new password.

Remarks

For security reasons, the old password must be specified in addition to the new password.

An error will occur if the provider does not support the administration of trustee properties.


Clustered Property Example (VB)

 Copy code hover
[image]

Clustered Property Example (VB)
Send feedback

This example demonstrates the Clustered property of an Index. Note that Microsoft Jet databases do not support clustered indexes, so this example will return False for the Clustered property of all indexes in the Northwind database.

Copy code Copy code

' BeginClusteredVB
Sub Main()
 On Error GoTo ClusteredXError

 Dim cnn As New ADODB.Connection
 Dim cat As New ADOX.Catalog
 Dim tblLoop As ADOX.Table
 Dim idxLoop As ADOX.Index
 Dim strCnn As String

 strCnn = "Provider='SQLOLEDB';Data Source='MySqlServer';Initial Catalog='pubs';" & _
 "Integrated Security='SSPI';"
 ' Connect the catalog.
 cnn.Open strCnn
 cat.ActiveConnection = cnn

 ' Enumerate Tables
 For Each tblLoop In cat.Tables
 'Enumerate Indexes
 For Each idxLoop In tblLoop.Indexes
 Debug.Print tblLoop.Name & " " & _
 idxLoop.Name & " " & idxLoop.Clustered
 Next idxLoop
 Next tblLoop

 'Clean up
 cnn.Close
 Set cat = Nothing
 Set cnn = Nothing
 Exit Sub

ClusteredXError:

 Set cat = Nothing

 If Not cnn Is Nothing Then
 If cnn.State = adStateOpen Then cnn.Close
 End If
 Set cnn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndClusteredVB


ClearMacroError Macro Action

 Copy code hover
[image]

ClearMacroError Macro Action
Send feedback

You can use the ClearMacroError action to clear information about an error that is stored in the MacroError object.

Setting

The ClearMacroError action does not have any arguments.

Remarks

  • When an error occurs in a macro, information about the error is stored in the MacroError object. If you have not used the OnError action to suppress error messages, the macro stops and the error information is displayed in a standard error message. However, if you have used the OnError action to suppress error messages, you might want to use the information stored in the MacroError object in a condition or in a custom error message.

    After an error has been handled, the information in the MacroError object is out of date, so it is a good idea to clear the object by using the ClearMacroError action. Doing so resets the error number in the MacroError object to 0 and clears any other information about the error that is stored in the object, such as the error description, macro name, action name, condition, and arguments. This way, you can inspect the MacroError object again later to see if another error has occurred.

  • The MacroError object is automatically cleared when any macro ends, so you do not need to use the ClearMacroError action at the end of a macro.

  • The MacroError object contains information about only one error at a time. If more than one error has occurred in a macro, the MacroError object contains information only about the last error.

  • To run the ClearMacroError action in a VBA module, use the ClearMacroError method of the DoCmd object.

Example

The following macro uses the OnError action with the Next argument to suppress error messages, and then uses the OpenForm action to open a form. For this example, an error is deliberately created by using the GoToRecord action to go to the previous record. The condition [MacroError].[Number]<>0 tests the MacroError object. If an error has occurred, the error number is non-zero, and the MessageBox action runs. The message box displays the name of the action that caused the error (in this case, the GoToRecord action), and the error number is displayed. Finally, running the ClearMacroError action clears the MacroError object.

Condition | Action | Arguments
 | OnError | Go to: Next
 | OpenForm | Form Name: CategoryFormView: Form Window Mode: Normal
 | GoToRecord | Object Type: Form Object Name: CategoryFormRecord: Previous
[MacroError].[Number]<>0 | MessageBox | Message: ="Error # " & [MacroError].[Number] & " on " & [MacroError].[ActionName] & " action."Beep: YesType: Information
 | ClearMacroError |


ListBox.KeyPress Event (Access)

 Copy code hover
[image]

ListBox.KeyPress Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyPress(KeyAscii)

expression A variable that represents a ListBox object.

Parameters

Name | Required/Optional | Data Type | Description
KeyAscii | Required | Integer | Returns a numeric ANSI key code. The KeyAscii argument is passed by reference; changing it sends a different character to the object. Setting the KeyAscii argument to 0 cancels the keystroke so that the object doesn't recognize that a key was pressed.

Remarks

To run a macro or event procedure when this event occurs, set the OnKeyPress property to the name of the macro or to [Event Procedure].

The object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down an ANSI key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

A KeyPress event can involve any printable keyboard character, the CTRL key combined with a character from the standard alphabet or a special character, and the ENTER or BACKSPACE key. You can use the KeyDown and KeyUp event procedures to handle any keystroke not recognized by the KeyPress event, such as function keys, navigation keys, and any combinations of these with keyboard modifiers (ALT, SHIFT, or CTRL keys). Unlike the KeyDown and KeyUp events, the KeyPress event doesn't indicate the physical state of the keyboard; instead, it indicates the ANSI character that corresponds to the pressed key or key combinations.

KeyPress interprets the uppercase and lowercase of each character as separate key codes and, therefore, as two separate characters.

Note Note

The BACKSPACE key is part of the ANSI character set, but the DEL key isn't. If you delete a character in a control by using the BACKSPACE key, you cause a KeyPress event; if you use the DEL key, you don't.

The KeyDown and KeyPress events occur when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

For example, if you go to a new record and type a character in the first control in the record, the following events occur:

Current (for the new record)

ß

Enter (for the first control in the new record)

ß

GotFocus (for the control)

ß

KeyDown (for the control)

ß

KeyPress (for the control)

ß

BeforeInsert (for the new record in the form)

ß

Change (for the control if it's a text box or combo box)

ß

KeyUp (for the control)

Example

The following example converts text entered in a text box to uppercase as the text is typed in, one character at a time.

To try the example, add the following event procedure to a form that contains a text box named ShipRegion.

VBA Copy code Copy code
Private Sub ShipRegion_KeyPress(KeyAscii As Integer)
 Dim strCharacter As String

 ' Convert ANSI value to character string.
 strCharacter = Chr(KeyAscii)
 ' Convert character to upper case, then to ANSI value.
 KeyAscii = Asc(UCase(strCharacter))
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Reference Properties (Access)

 Copy code hover
[image]

Reference Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
BuiltIn | The BuiltIn property returns a Boolean value indicating whether a Reference object points to a default reference that's necessary for Microsoft Access to function properly. Read-only Boolean.
Collection | The Collection property returns a reference to the collection that contains an object. Read-only References object.
FullPath | The FullPath property returns a string containing the path and file name of the referenced type library.
Guid | The GUID property of a Reference object returns a GUID that identifies a type library in the Windows Registry. Read-only String.
IsBroken | The IsBroken property returns a Boolean value indicating whether a Reference object points to a valid reference in the Windows Registry. Read-only Boolean.
Kind | The Kind property indicates the type of reference that a Reference object represents. Read-only vbext_RefKind.
Major | The Major property of a Reference object returns a read-only Long value indicating the major version number of an application to which you have set a reference.
Minor | The Minor property of a Reference object returns a Long value indicating the minor version number of the application to which you have set a reference.
Name | You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.


BoundObjectFrame.GridlineWidthTop Property (Access)

 Copy code hover
[image]

BoundObjectFrame.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified frame. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthTop

expression A variable that represents a BoundObjectFrame object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Configuring DataFactory for Safe or Unrestricted Modes

 Copy code hover
[image]

Configuring DataFactory for Safe or Unrestricted Modes
Send feedback

By default, ADO is installed with a "safe" RDSServer.DataFactory configuration. Safe mode for RDS Server components means that the following are true:

  1. Handler is required with the RDSServer.DataFactory (this is mandated by a registry key setting).

  2. The default handler, msdfmap.handler, is registered, present in the safe-handler list, and marked as the default handler.

  3. Msdfmap.ini file is installed in the Windows directory. You must configure this file according to your needs, before using RDS in three-tier mode.

Optionally, you can configure an unrestricted DataFactory installation. DataFactory can be used directly without the custom handler. Users can still use a custom handler by modifying the connection strings, but it is not required. For more information on the implications of using the RDSServer.DataFactory object, see Securing RDS Applications.

The registry file handsafe.reg has been provided to set up the handler registry entries for a safe configuration. To run in safe mode, run handsafe.reg. The registry file handunsf.reg has been provided to set up the handler registry entries for an unrestricted configuration. To run in unrestricted mode, run handunsf.reg.

After running either handsafe.reg or handunsf.reg, you must stop and restart the World Wide Web Publishing Service on the Web server by typing the following commands in a command window: "NET STOP W3SVC" and "NET START W3SVC".

For more information about using the customization handler feature of RDS, see the technical article Using the Customization Handler Feature in RDS 2.1.


AllForms.Count Property (Access)

 Copy code hover
[image]

AllForms.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents an AllForms object.

Example

For example, if you want to determine the number of forms currently open or existing on the database, you would use the following code strings

VBA Copy code Copy code
' Determine the number of open forms.

forms.count

' Determine the number of forms (open or closed)
' in the current database.

currentproject.allforms.count

See also

Concepts

AllForms Collection

Other resources

AllForms Object Members


VIEW can not contain a parameter (Error 3730)

 Copy code hover
[image]

VIEW can not contain a parameter (Error 3730)
Send feedback

This error occurs when trying to create a view from SQL DDL. If the SELECT statement part of the CREATE view statement contains any parameters, this error will be returned. To work around this issue, use the CREATE PROCEDURE statement instead.


Could not start session. Too many sessions already active. (Error 3198)

 Copy code hover
[image]

Could not start session. Too many sessions already active. (Error 3198)
Send feedback

You tried to perform an operation that would have started a new session, but too many sessions are already active. Wait for one or more sessions to finish, and then try the operation again.


Label.MouseDown Event (Access)

 Copy code hover
[image]

Label.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents a Label object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
         Shift As Integer, X As Single, _
         Y As Single)
    If Button = acLeftButton Then
        MsgBox "You pressed the left button."
    End If
    If Button = acRightButton Then
        MsgBox "You pressed the right button."
    End If
    If Button = acMiddleButton Then
        MsgBox "You pressed the middle button."
    End If
End Sub

See also

Concepts

Label Object

Other resources

Label Object Members


Report.OrderBy Property (Access)

 Copy code hover
[image]

Report.OrderBy Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OrderBy property to specify how you want to sort records in a report. Read/write String.

Syntax

expression .OrderBy

expression A variable that represents a Report object.

Remarks

The OrderBy property is a string expression that is the name of the field or fields on which you want to sort records. When you use more than one field name, separate the names with a comma (,). Use the OrderBy property to save an ordering value and apply it at a later time. OrderBy values are saved with the objects in which they are created. They are automatically loaded when the object is opened, but they aren't automatically applied.

When you set the OrderBy property by entering one or more field names, the records are sorted in ascending order. Similarly, Visual Basic sorts these fields in ascending order by default.

If you want to sort records in descending order, type DESC at the end of the string expression. For example, to sort customer records in descending order by contact name, set the OrderBy property to "ContactName DESC".

Select the field by which you want to sort the records and either click the appropriate Sort button on the toolbar, or point to Sort on the Records menu and click the appropriate command on the submenu. You can also set the OrderByOn property for either forms or reports by using Visual Basic.

Note Note

When a new object is created, it inherits the RecordSource , Filter , OrderBy, and OrderByOn properties of the table or query it was created from. For forms and reports, inherited filters aren't automatically applied when an object is opened.

See also

Concepts

Report Object

Other resources

Report Object Members


How Event Handlers Work Together

 Copy code hover
[image]

How Event Handlers Work Together
Send feedback

Unless you are programming in Visual Basic, all event handlers for Connection and Recordset events must be implemented, regardless of whether you actually process all of the events. The amount of implementation work you have to do depends on your programming language. For more information, see ADO Event Instantiation by Language.

Paired Event Handlers

Each Will event handler has an associated Complete event handler. For example, when your application changes the value of a field, the WillChangeField event handler is called. If the change is acceptable, your application leaves the adStatus parameter unchanged and the operation is performed. When the operation completes, a FieldChangeComplete event notifies your application that the operation has finished. If it completed successfully, adStatus contains adStatusOK; otherwise, adStatus contains adStatusErrorsOccurred and you must check the Error object to determine the cause of the error.

When WillChangeField is called, you might determine that the change should not be made. In that case, set adStatus to adStatusCancel. The operation is canceled and the FieldChangeComplete event receives an adStatus value of adStatusErrorsOccurred. The Error object contains adErrOperationCancelled so that your FieldChangeComplete handler knows that the operation was canceled. However, you need to check the value of the adStatus parameter before changing it, because setting adStatus to adStatusCancel has no effect if the parameter was set to adStatusCantDeny on entry to the procedure.

Sometimes an operation can raise more than one event. For example, the Recordset object has paired events for Field changes and Record changes. When your application changes the value of a Field, the WillChangeField event handler is called. If it determines that the operation can continue, the WillChangeRecord event handler is also raised. If this handler also allows the event to continue, the change is made and the FieldChangeComplete and RecordChangeComplete event handlers are called. The order in which the Will event handlers for a particular operation are called is not defined, so you should avoid writing code that depends on calling handlers in a particular sequence.

In instances when multiple Will events are raised, one of the events might cancel the pending operation. For example, when your application changes the value of a Field, both WillChangeField and WillChangeRecord event handlers would normally be called. However, if the operation is canceled in the first event handler, its associated Complete handler is immediately called with adStatusOperationCancelled. The second handler is never called. If, however, the first event handler allows the event to proceed, the other event handler will be called. If it then cancels the operation, both Complete events will be called as in the earlier examples.

Unpaired Event Handlers

As long as the status passed to the event is not adStatusCantDeny, you can turn off event notifications for any event by returning adStatusUnwantedEvent in the Status parameter. For example, when your Complete event handler is called the first time, you can return adStatusUnwantedEvent. You will subsequently receive only Will events. However, some events can be triggered for more than one reason. In that case, the event will have a Reason parameter. When you return adStatusUnwantedEvent, you will stop receiving notifications for that event only when they occur for that particular reason. In other words, you will potentially receive notification for each possible reason that the event could be triggered.

Single Will event handlers can be useful when you want to examine the parameters that will be used in an operation. You can modify those operation parameters or cancel the operation.

Alternatively, leave Complete event notification enabled. When your first Will event handler is called, return adStatusUnwantedEvent. You will subsequently receive only Complete events.

Single Complete event handlers can be useful for managing asynchronous operations. Each asynchronous operation has an appropriate Complete event.

For example, it can take a long time to populate a large Recordset object. If your application is appropriately written, you can start a operation and continue with other processing. You will eventually be notified when the Recordset is populated by an ExecuteComplete event.

Single Event Handlers and Multiple Objects

The flexibility of a programming language like Microsoft Visual C++ enables you to have one event handler process events from multiple objects. For example, you could have one Disconnect event handler process events from several Connection objects. If one of the connections ended, the Disconnect event handler would be called. You could tell which connection caused the event because the event-handler object parameter would be set to the corresponding Connection object.

Note Note

This technique cannot be used in Visual Basic because that language can correlate only one object to an event handler.


TextBox.KeyUp Event (Access)

 Copy code hover
[image]

TextBox.KeyUp Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyUp(KeyCode, Shift)

expression A variable that represents a TextBox object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyUp property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyUp event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyUp event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


CustomControl.TabIndex Property (Access)

 Copy code hover
[image]

CustomControl.TabIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.

Syntax

expression .TabIndex

expression A variable that represents a CustomControl object.

Remarks

You can set the TabIndex property to an integer representing the position of the control within the tab order of the form. Valid settings are 0 for the first tab position, up to the total number of controls minus 1 for the last tab position. For example, if a form has three controls that each have a TabIndex property, valid TabIndex property settings are 0, 1, and 2.

Setting the TabIndex property to an integer less than 0 produces an error.

By default, Microsoft Access assigns a tab order to controls in the order that you create them on a form. Each new control is placed last in the tab order. If you change the setting of a control's TabIndex property to adjust the tab order, Microsoft Access automatically renumbers the TabIndex property setting of other controls to reflect insertions and deletions.

In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the TAB key.

Changing the tab order of other controls on the form doesn't affect what happens when you press a control's access key. For example, if you've created an access key for the label of a text box, the focus will move to the text box whenever you press the label's access key — even if you change the TabIndex property setting for the text box.

If you press an access key for a control such as a label that doesn't have a TabIndex property (and thus isn't in the tab order), the focus moves to the next control in the tab order that can receive the focus.

Example

The following example reverses the tab order of a command button and a text box. Because TextBox1 was created first, it has a TabIndex property setting of 0 and Command1 has a setting of 1.

VBA Copy code Copy code
Sub Form_Click()
 Me!Command1.TabIndex = 0
 Me!TextBox1.TabIndex = 1
End Sub

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


WSParameters Object (Access)

 Copy code hover
[image]

WSParameters Object (Access)
See also Send feedback

Published: July 16, 2012

Represents the collection of parameters of defined for an Operation.

Version Information

Version Added: Access 2010

Remarks

Use the WSParameters property of the Operation object to get the parameters of a operation.

See also

Concepts

Access Object Model Reference

Other resources

WSParameters Object Members


NavigationButton.AutoRepeat Property (Access)

 Copy code hover
[image]

NavigationButton.AutoRepeat Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AutoRepeat property to specify whether an event procedure or macro runs repeatedly while a command button on a form remains pressed in. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .AutoRepeat

expression A variable that represents a NavigationButton object.

Remarks

The default value is False.

The initial repeat of the event procedure or macro occurs 0.5 seconds after it first runs. Subsequent repeats occur either 0.25 seconds apart or the duration of the event procedure or macro, whichever is longer.

If the code attached to the command button causes the current record to change, the AutoRepeat property has no effect.

If the code attached to the command button causes changes to another control on a form, use the DoEvents function to ensure proper screen updating.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Sum Function (Microsoft Access SQL)

 Copy code hover
[image]

Sum Function (Microsoft Access SQL)
Send feedback

Published: July 16, 2012

Returns the sum of a set of values contained in a specified field on a query.

Syntax

Sum(expr)

The expr placeholder represents a string expression identifying the field that contains the numeric data you want to add or an expression that performs a calculation using the data in that field. Operands in expr can include the name of a table field, a constant, or a function (which can be either intrinsic or user-defined but not one of the other SQL aggregate functions).

Remarks

The Sum function totals the values in a field. For example, you could use the Sum function to determine the total cost of freight charges.

The Sum function ignores records that contain Null fields. The following example shows how you can calculate the sum of the products of UnitPrice and Quantity fields:

SQL Copy code Copy code
SELECT
Sum(UnitPrice * Quantity)
AS [Total Revenue] FROM [Order Details];

You can use the Sum function in a query expression. You can also use this expression in the SQL property of a QueryDef object or when creating a Recordset based on an SQL query.

Example

This example uses the Orders table to calculate the total sales for orders shipped to the United Kingdom.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

VBA Copy code Copy code
Sub SumX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Calculate the total sales for orders shipped to
    ' the United Kingdom.
    Set rst = dbs.OpenRecordset("SELECT" _
        & " Sum(UnitPrice*Quantity)" _
        & " AS [Total UK Sales] FROM Orders" _
        & " INNER JOIN [Order Details] ON" _
        & " Orders.OrderID = [Order Details].OrderID" _
        & " WHERE (ShipCountry = 'UK');")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 15

    dbs.Close

End Sub


DoCmd.Quit Method (Access)

 Copy code hover
[image]

DoCmd.Quit Method (Access)
See also Send feedback

Published: July 16, 2012

The Quit method quits Microsoft Access. You can select one of several options for saving a database object before quitting.

Syntax

expression .Quit(Options)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
Options | Optional | AcQuitOption | An AcQuitOption constant that indicates the action to take when quitting Access. The default value is acQuitSaveAll.

Remarks

The Quit method of the DoCmd object was added to provide backward compatibility for running the Quit action in Visual Basic code in Microsoft Access 95. It's recommended that you use the existing Quit method of the Application object instead.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


AdditionalData Object (Access)

 Copy code hover
[image]

AdditionalData Object (Access)
See also Send feedback

Published: July 16, 2012

Represents the collection of tables and queries that will be included with the parent table that is exported by the ExportXML method.

Remarks

To create an AdditionalData object, use the CreateAdditionalData method of the Application object.

To add a table to an existing AdditionalData object, use the Add method.

Example

The following example exports the contents of the Customers table in the Northwind Traders sample database, along with the contents of the Orders and Orders Details tables, to an XML data file named Customer Orders.xml.

VBA Copy code Copy code
Sub ExportCustomerOrderData()
 Dim objOrderInfo As AdditionalData

 Set objOrderInfo = Application.CreateAdditionalData

 ' Add the Orders and Order Details tables to the data to be exported.
 objOrderInfo.Add "Orders"
 objOrderInfo.Add "Order Details"

 ' Export the contents of the Customers table. The Orders and Order
 ' Details tables will be included in the XML file.
 Application.ExportXML ObjectType:=acExportTable, DataSource:="Customers", _
 DataTarget:="Customer Orders.xml", _
 AdditionalData:=objOrderInfo
End Sub

See also

Concepts

Access Object Model Reference

Other resources

AdditionalData Object Members


Recordset2.UpdateOptions Property (DAO)

 Copy code hover
[image]

Recordset2.UpdateOptions Property (DAO)
Send feedback

Syntax

expression .UpdateOptions

expression A variable that represents a Recordset2 object.

Remarks

When a batch-mode Update is executed, DAO and the client batch cursor library create a series of SQL UPDATE statements to make the needed changes. An SQL WHERE clause is created for each update to isolate the records that are marked as changed by the RecordStatus property. Because some remote servers use triggers or other ways to enforce referential integrity, is it often important to limit the fields being updated to just those affected by the change. To do this, set the UpdateOptions property to one of the constants dbCriteriaKey, dbCriteriaModValues, dbCriteriaAllCols, or dbCriteriaTimeStamp. This way, only the absolute minimum amount of trigger code is executed. As a result, the update operation is executed more quickly, and with fewer potential errors.

You can also concatenate either of the constants dbCriteriaDeleteInsert or dbCriteriaUpdate to determine whether to use a set of SQL DELETE and INSERT statements or an SQL UPDATE statement for each update when sending batched modifications back to the server. In the former case, two separate operations are required to update the record. In some cases, especially where the remote system implements DELETE, INSERT, and UPDATE triggers, choosing the correct UpdateOptions property setting can significantly impact performance.

If you don't specify any constants, dbCriteriaUpdate and dbCriteriaKey will be used.

Newly added records will always generate INSERT statements and deleted records will always generate DELETE statements, so this property only applies to how the cursor library updates modified records.


Application.RunCommand Method (Access)

 Copy code hover
[image]

Application.RunCommand Method (Access)
See also Send feedback

Published: July 16, 2012

The RunCommand method runs a built-in command.

Syntax

expression .RunCommand(Command)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Command | Required | AcCommand | An AcCommand constant that specifies the commend to run.

Remarks

Each menu and toolbar command in Microsoft Access has an associated constant that you can use with the RunCommand method to run that command from Visual Basic.

You can't use the RunCommand method to run a command on a custom menu or toolbar. You can only use it with built-in menus and toolbars.

The RunCommand method replaces the DoMenuItem method of the DoCmd object.

See also

Concepts

Application Object

Other resources

Application Object Members


ADO Code Examples in Microsoft Visual Basic (Access)

 Copy code hover
[image]

ADO Code Examples in Microsoft Visual Basic (Access)
Send feedback

In this section

  • ADO Code Examples in Microsoft Visual Basic

  • AbsolutePage, PageCount, and PageSize Properties Example (VB)

  • AbsolutePosition and CursorLocation Properties Example (VB)

  • ActiveCommand Property Example (VB)

  • ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction Properties Example (VB)

  • ActualSize and DefinedSize Properties Example (VB)

  • AddNew Method Example (VB)

  • Append and CreateParameter Methods Example (VB)

  • AppendChunk and GetChunk Methods Example (VB)

  • Attributes and Name Properties Example (VB)

  • BeginTrans, CommitTrans, and RollbackTrans Methods Example (VB)

  • BOF, EOF, and Bookmark Properties Example (VB)

  • CacheSize Property Example (VB)

  • Cancel Method Example (VB)

  • Clone Method Example (VB)

  • CompareBookmarks Method Example (VB)

  • ConnectionString, ConnectionTimeout, and State Properties Example (VB)

  • ConvertToString Method Example (VB)

  • CopyRecord, CopyTo, and SaveToFile Methods Example (VB)

  • Count Property Example (VB)

  • CreateRecordset Method Example (VB)

  • CursorType, LockType, and EditMode Properties Example (VB)

  • Delete Method Example (VB)

  • DeleteRecord and MoveRecord Methods Example (VB)

  • Description, HelpContext, HelpFile, NativeError, Number, Source, and SQLState Properties Example (VB)

  • EOS and LineSeparator Properties and SkipLine Method Example (VB)

  • Execute, Requery, and Clear Methods Example (VB)

  • Filter and RecordCount Properties Example (VB)

  • Find Method Example (VB)

  • GetRows Method Example (VB)

  • GetString Method Example (VB)

  • IsolationLevel and Mode Properties Example (VB)

  • Item Property Example (VB)

  • MarshalOptions Property Example (VB)

  • MaxRecords Property Example (VB)

  • Move Method Example (VB)

  • MoveFirst, MoveLast, MoveNext, and MovePrevious Methods Example (VB)

  • NextRecordset Method Example (VB)

  • ADO NumericScale and Precision Properties Example (VB)

  • Open and Close Methods Example (VB)

  • OpenSchema Method Example (VB)

  • Optimize Property Example (VB)

  • OriginalValue and UnderlyingValue Properties Example (VB)

  • Prepared Property Example (VB)

  • Provider and DefaultDatabase Properties Example (VB)

  • Read, ReadText, Write, and WriteText Methods Example (VB)

  • Refresh Method Example (VB)

  • Resync Method Example (VB)

  • Save and Open Methods Example (VB)

  • Seek Method and Index Property Example (VB)

  • Sort Property Example (VB)

  • Source Property Example (VB)

  • State Property Example (VB)

  • Status Property Example (Field) (VB)

  • Status Property Example (Recordset) (VB)

  • StayInSync Property Example (VB)

  • Supports Method Example (VB)

  • Type Property Example (Field) (VB)

  • Type Property Example (Property) (VB)

  • Update and CancelUpdate Methods Example (VB)

  • UpdateBatch and CancelBatch Methods Example (VB)

  • Value Property Example (VB)

  • Version Property Example (VB)


Syntax error in CREATE TABLE statement. (Error 3290)

 Copy code hover
[image]

Syntax error in CREATE TABLE statement. (Error 3290)
Send feedback

You entered an SQL statement that includes an invalid CREATE TABLE statement.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


Form Events (Access)

 Copy code hover
[image]

Form Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
Activate | The Activate event occurs when a form receives the focus and becomes the active window.
AfterDelConfirm | The AfterDelConfirm event occurs after the user confirms the deletions and the records are actually deleted or when the deletions are canceled.
AfterFinalRender | Occurs after all elements in the specified PivotChart view have been rendered.
AfterInsert | The AfterInsert event occurs after a new record is added.
AfterLayout | Occurs after all charts in the specfied PivotChart view have been laid out, but before they have been rendered.
AfterRender | Occurs after the object represented by the chartObject argument has been rendered.
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
ApplyFilter | Occurs when a filter is applied to a form.
BeforeDelConfirm | The BeforeDelConfirm event occurs after the user deletes to the buffer one or more records, but before Microsoft Access displays a dialog box asking the user to confirm the deletions.
BeforeInsert | The BeforeInsert event occurs when the user types the first character in a new record, but before the record is actually created.
BeforeQuery | Occurs when the specified PivotTable view queries its data source.
BeforeRender | Occurs before any object in the specified PivotChart view has been rendered.
BeforeScreenTip | Occurs before a ScreenTip is displayed for an element in a PivotChart view or PivotTable view.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
Close | The Close event occurs when a form is closed and removed from the screen.
CommandBeforeExecute | Occurs before a specified command is executed. Use this event when you want to impose certain restrictions before a particular command is executed.
CommandChecked | Occurs when the specified Microsoft Office Web Component determines whether the specified command is checked.
CommandEnabled | Occurs when the specified Microsoft Office Web Component determines whether the specified command is enabled.
CommandExecute | Occurs after the specified command is executed. Use this event when you want to execute a set of commands after a particular command is executed.
Current | Occurs when the focus moves to a record, making it the current record, or when the form is refreshed or requeried.
DataChange | Occurs when certain properties are changed or when certain methods are executed in the specified PivotTable view.
DataSetChange | Occurs whenever the specified PivotTable view is data-bound and the data set changes — for example, when a filter operation takes place. This event also occurs when initial data is available from the data source.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Deactivate | The Deactivate event occurs when a form loses the focus to a Table, Query, Form, Report, Macro, or Module window, or to the Database window.
Delete | Occurs when the user performs some action, such as pressing the DEL key, to delete a record, but before the record is actually deleted.
Dirty | The Dirty event occurs when the contents of the specified control changes.
Error | The Error event occurs when a run-time error is produced in Microsoft Access when a form has the focus.
Filter | Occurs when the user opens a filter window by clicking Filter by Form, Advanced Filter/Sort, or Server Filter By Form.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
Load | Occurs when a form is opened and its records are displayed.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.
MouseWheel | Occurs when the user rolls the mouse wheel in Form View, Split Form View, Datasheet View, Layout View, PivotChart View, or PivotTable View.
OnConnect | Occurs when the specified PivotTable view connects to a data source.
OnDisconnect | Occurs when the specified PivotTable view disconnects from a data source.
Open | The Open event occurs when a form is opened, but before the first record is displayed.
PivotTableChange | Occurs whenever the specified PivotTable view field, field set, or total is added or deleted.
Query | Occurs whenever the specified PivotTable view query becomes necessary. The query may not occur immediately; it may be delayed until the new data is displayed.
Resize | The Resize event occurs when a form is opened and whenever the size of a form changes.
SelectionChange | Occurs whenever the user makes a new selection in a PivotChart view or PivotTable view.
Timer | The Timer event occurs for a form at regular intervals as specified by the form's TimerInterval property.
Undo | Occurs when the user undoes a change.
Unload | The Unload event occurs after a form is closed but before it's removed from the screen. When the form is reloaded, Microsoft Access redisplays the form and reinitializes the contents of all its controls.
ViewChange | Occurs whenever the specified PivotChart view or PivotTable view is redrawn.


CustomControl Members (Access)

 Copy code hover
[image]

CustomControl Members (Access)
Send feedback

Published: July 16, 2012

When setting the properties of an ActiveX control, you may need or prefer to use the control's custom properties dialog box. This custom properties dialog box provides an alternative to the list of properties in the Microsoft Access property sheet for setting ActiveX control properties in Design view.

Events

Name | Description
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
Updated | The Updated event occurs when an OLE object's data has been modified.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Properties

Name | Description
About | Returns or sets a String representing version and copyright information for an ActiveX control. Read/write.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.
Cancel | You can use the Cancel property to specify whether a command button is also the Cancel button on a form. Read/write Boolean.
Class | You can use the Class property to specify or determine the class name of an embeddedOLE object. Read/write String.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
Custom | Returns or sets a String representing the custom properties dialog box for an ActiveX control. Read/write.
Default | You can use the Default property to specify whether a command button is the default button on a form. Read/write Boolean.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
GridlineColor | Gets or sets the color of the gridline for the specified list box. Read/write Long.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified list box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified text box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified text box. Read/write Byte.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified text box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified text box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified text box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the text box is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Layout | Returns the type of layout for the specified text box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified text box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Object | You can use the Object property in Visual Basic to return a reference to the ActiveX object that is associated with a linked or embedded OLE object in a control. By using this reference, you can access the properties or invoke the methods of the OLE object. Read-only Object.
ObjectPalette | The ObjectPalette property specifies the palette in the application used to create an OLE object. Read/write Variant.
ObjectVerbs | You can use the ObjectVerbs property in Visual Basic to determine the list of verbs an OLE object supports. Read-only String.
ObjectVerbsCount | You can use the ObjectVerbsCount property in Visual Basic to determine the number of verbs supported by an OLE object. Read-only Long.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OLEClass | You can use the OLEClass property to obtain a description of the kind of OLE object contained in a chart control or an unbound object frame. Read-only String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnUpdated | Sets or returns the value of the On Updated box in the Properties window of a form or report. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
RightPadding | Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.
Value | Gets or sets the value displayed in the specified control. Read/write Variant.
VarOleObject | Gets a pointer to an IOLEObject that represents the memory address of an OLE object. Read-only Variant.
Verb | You can use the Verb property to specify the operation to perform when an OLE object is activated, which is permitted when the control'sAction property is set to acOLEActivate. Read/write Long.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified text box is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


NavigationButton.PictureData Property (Access)

 Copy code hover
[image]

NavigationButton.PictureData Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.

Version Information

Version Added: Access 2010

Syntax

expression .PictureData

expression A variable that represents a NavigationButton object.

Remarks

The PictureData property setting is the PictureData property of another control, form, or report.

You can use this property to display different background pictures in a form, depending on actions taken by the user. For example, you might open a Customers form using a different background picture depending on whether the form is opened for data entry or for browsing.

You can also use the PictureData property together with the Timer event and the TimerInterval property to perform simple animation on a form.

Example

The following example uses three image controls to animate a butterfly image across a form. The Hidden1 image control contains a picture of a butterfly with its wings up and the Hidden2 image control contains a picture of the same butterfly with its wings down. Both image controls have their Visible property set to False. The TimerInterval property is set to 200. Each time the Timer event occurs, the picture in the image control Visible1 is changed by using the PictureData property of the hidden image controls, and the visible image control is moved 200 twips to the right. The visible image control is moved back to the left side of the form when its Left property value is greater than the width of the form stored in the public variable gfrmWidth. The value of gfrmWidth is set to Me.Width in the form's open event.

VBA Copy code Copy code
Private Sub Form_Timer()

 Static intPic As Integer

 Select Case intPic
 Case Is = 1
 Me!Visible1.PictureData = Me!Hidden1.PictureData
 Case Is = 2
 Me!Visible1.PictureData = Me!Hidden2.PictureData
 Case Else
 End Select

 If intPic = 2 Then intPic = 0
 intPic = intPic + 1
 If (Me!Visible1.Left > gfrmWidth) Then Me!Visible1.Left = 0
 Me!Visible1.Left = Me!Visible1.Left + 200

End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


ComboBox.ShowOnlyRowSourceValues Property (Access)

 Copy code hover
[image]

ComboBox.ShowOnlyRowSourceValues Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the combo box can display values that aren't specified by the RowSource property. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .ShowOnlyRowSourceValues

expression A variable that represents a ComboBox object.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


TabControl.RightPadding Property (Access)

 Copy code hover
[image]

TabControl.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .RightPadding

expression A variable that represents a TabControl object.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Cannot have aggregate function in expression

 Copy code hover
[image]

Cannot have aggregate function in expression <expression>. (Error 3095)
Send feedback

You cannot use an aggregate function in this expression.


CustomControl.Value Property (Access)

 Copy code hover
[image]

CustomControl.Value Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the value displayed in the specified control. Read/write Variant.

Syntax

expression .Value

expression A variable that represents a CustomControl object.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Parameter Properties, Methods, and Events (ADO)

 Copy code hover
[image]

Parameter Properties, Methods, and Events (ADO)
Send feedback

Properties/Collections

Attributes Property

Direction Property

Name Property

NumericScale Property

Precision Property

Properties Collection

Size Property

Type Property

Value Property

Methods

AppendChunk Method

Events

None.


RunSQL Macro Action

 Copy code hover
[image]

RunSQL Macro Action
Send feedback

You can use the RunSQL action to run a Microsoft Access 2013 action query by using the corresponding SQL statement. You can also run a data-definition query.

Note 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.

Setting

The RunSQL action has the following arguments.

Action argument | Description
SQL Statement | The SQL statement for the action query or data-definition query you want to run. The maximum length of this statement is 255 characters. This is a required argument.
Use Transaction | Select Yes to include this query in a transaction. Select No if you don't want to use a transaction. The default is Yes. If you select No for this argument, the query might run faster.

Remarks

You can use action queries to append, delete, and update records and to save a query's result set as a new table. You can use data-definition queries to create, alter, and delete tables, and to create and delete indexes. You can use the RunSQL action to perform these operations directly from a macro without having to use stored queries.

If you need to type an SQL statement longer than 255 characters, use the RunSQL method of the DoCmd object in a Visual Basic for Applications (VBA) module instead. You can type SQL statements of up to 32,768 characters in VBA.

Access queries are actually SQL statements that are created when you design a query by using the design grid in the Query window. The following table shows the Access action queries and data-definition queries and their corresponding SQL statements.

Query type | SQL statement
Action |
Append | INSERT INTO
Delete | DELETE
Make-table | SELECT...INTO
Update | UPDATE
Data-definition (SQL-specific) |
Create a table | CREATE TABLE
Alter a table | ALTER TABLE
Delete a table | DROP TABLE
Create an index | CREATE INDEX
Delete an index | DROP INDEX

You can also use an IN clause with these statements to modify data in another database.

Note Note

To run a select query or crosstab query from a macro, use the View argument of the OpenQuery action to open an existing select query or crosstab query in Datasheet view. You can also run existing action queries and SQL-specific queries in the same way.


GetPermissions and SetPermissions Methods Example (VC++)

 Copy code hover
[image]

GetPermissions and SetPermissions Methods Example (VC++)
Send feedback

This example demonstrates the GetPermissions and SetPermissions methods. The following code gives full access to the Orders table to the Admin user.

Copy code Copy code

// BeginGrantPermissionCpp
#import "c:\Program Files\Common Files\system\ado\msado15.dll"
#import "c:\Program Files\Common Files\system\ado\msadox.dll" no_namespace

#include "iostream.h"
#include "stdio.h"
#include "conio.h"

//Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void GrantPermissionsX(void);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 GrantPermissionsX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// GrantPermissionsX Function //
// //
//////////////////////////////////////////////////////////
void GrantPermissionsX()
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.
 _CatalogPtr m_pCatalog = NULL;

 //Define ADODB object pointers;
 ADODB::_ConnectionPtr m_pCnn = NULL;

 //Define other variables here.
 try
 {
 TESTHR(hr = m_pCnn.CreateInstance(__uuidof(ADODB::Connection)));

 //Opens a connection to the northwind database
 //using the Microsoft Jet 4.0 provider
 m_pCnn->PutProvider("Microsoft.Jet.OLEDB.4.0");
 m_pCnn->Open("data source='c:\\Program Files\\" "Microsoft Office\\Office\\Samples\\Northwind.mdb';" "jet oledb:system database='c:\\Program Files\\Microsoft Office\\Office\\system.mdw'",
 "","",NULL);

 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof(Catalog)));

 m_pCatalog->PutActiveConnection(_variant_t((IDispatch *)m_pCnn));

 //Retrieve original permissions
 long lngPerm = m_pCatalog->Users->GetItem("admin")->
 GetPermissions("Orders",adPermObjTable);
 long lngOrgPerm = lngPerm;
 cout << "Original Permissions: " << lngPerm << "\n" << endl;

 //Revoke all permissions
 m_pCatalog->Users->GetItem("admin")->SetPermissions("Orders",
 adPermObjTable,adAccessRevoke,adRightFull,adInheritNone);

 //Display permissions
 lngPerm = m_pCatalog->Users->GetItem("admin")->
 GetPermissions("Orders",adPermObjTable);
 cout << "Revoked permissions: " << lngPerm << "\n" << endl;

 //Give the Admin user full rights on the orders object
 m_pCatalog->Users->GetItem("admin")->SetPermissions("Orders",
 adPermObjTable,adAccessSet,adRightFull,adInheritNone);

 //Display permissions
 lngPerm = m_pCatalog->Users->GetItem("admin")->
 GetPermissions("Orders",adPermObjTable);
 cout << "Full permissions: " << lngPerm << "\n" << endl;

 //Restore original permissions
 m_pCatalog->Users->GetItem("admin")->SetPermissions("Orders",
 adPermObjTable,adAccessSet,(RightsEnum) lngOrgPerm,
 adInheritNone);

 //Display permissions
 lngPerm = m_pCatalog->Users->GetItem("admin")->
 GetPermissions("Orders",adPermObjTable);
 cout << "Final permissions: " << lngPerm << "\n" << endl;
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }
 catch(...)
 {
 cout << "Error occured in GrantPermissionsX...."<< endl;
 }
}
// EndGrantPermissionCpp


CommandButton.Width Property (Access)

 Copy code hover
[image]

CommandButton.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents a CommandButton object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

Example

The following code resizes a command button to a 1-inch by 1-inch square button (the default unit of measurement in Visual Basic is twips; 1440 twips equals one inch):

VBA Copy code Copy code
Me!cmdSizeButton.Height = 1440 ' 1440 twips = 1 inch.
Me!cmdSizeButton.Width = 1440

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


CommandButton.DisplayWhen Property (Access)

 Copy code hover
[image]

CommandButton.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Syntax

expression .DisplayWhen

expression A variable that represents a CommandButton object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ADO Events Model Example (VC++)

 Copy code hover
[image]

ADO Events Model Example (VC++)
Send feedback

The Visual C++ section of ADO Event Instantiation by Language gives a general description of how to instantiate the ADO event model. The following is a specific example of instantiating the event model within the environment created by the #import directive.

The general description uses adoint.h as a reference for method signatures. However, a few details in the general description change slightly as a result of using the #import directive:

  • The #import directive resolves typedef's, and method signature data types and modifiers to their fundamental forms.

  • The pure virtual methods that must be overwritten are all prefixed by "raw_".

Some of the code simply reflects coding style.

  • The pointer to IUnknown used by the Advise method is obtained explicitly with a call to QueryInterface.

  • You don't need to explicitly code a destructor in the class definitions.

  • You may want to code more robust implementations of QueryInterface, AddRef, and Release.

  • The __uuidof() directive is used extensively to obtain interface IDs.

Finally, the example contains some working code.

  • The example is written as a console application.

  • You should insert your own code under the comment, "// Do some work ".

  • All the event handlers default to doing nothing, and canceling further notifications. You should insert the appropriate code for your application, and allow notifications if required.

Copy code Copy code

// eventmodel.cpp : Defines the entry point for the console application.
//

#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")
#include <comdef.h>
#include <stdio.h>

//----The Connection events----------------------------------------------

class CConnEvent : public ConnectionEventsVt
{
private:
 ULONG m_cRef;
 public:
 CConnEvent() { m_cRef = 0; };
 ~CConnEvent() {};

 STDMETHODIMP QueryInterface(REFIID riid, void ** ppv);
 STDMETHODIMP_(ULONG) AddRef(void);
 STDMETHODIMP_(ULONG) Release(void);

 STDMETHODIMP raw_InfoMessage(
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Connection *pConnection);

 STDMETHODIMP raw_BeginTransComplete(
 LONG TransactionLevel,
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Connection *pConnection);

 STDMETHODIMP raw_CommitTransComplete(
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Connection *pConnection);

 STDMETHODIMP raw_RollbackTransComplete(
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Connection *pConnection);

 STDMETHODIMP raw_WillExecute(
 BSTR *Source,
 CursorTypeEnum *CursorType,
 LockTypeEnum *LockType,
 long *Options,
 EventStatusEnum *adStatus,
 struct _Command *pCommand,
 struct _Recordset *pRecordset,
 struct _Connection *pConnection);

 STDMETHODIMP raw_ExecuteComplete(
 LONG RecordsAffected,
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Command *pCommand,
 struct _Recordset *pRecordset,
 struct _Connection *pConnection);

 STDMETHODIMP raw_WillConnect(
 BSTR *ConnectionString,
 BSTR *UserID,
 BSTR *Password,
 long *Options,
 EventStatusEnum *adStatus,
 struct _Connection *pConnection);

 STDMETHODIMP raw_ConnectComplete(
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Connection *pConnection);

 STDMETHODIMP raw_Disconnect(
 EventStatusEnum *adStatus,
 struct _Connection *pConnection);
};

//-----The Recordset events----------------------------------------------

class CRstEvent : public RecordsetEventsVt
 {
 private:
 ULONG m_cRef;
 public:
 CRstEvent() { m_cRef = 0; };
 ~CRstEvent() {};

 STDMETHODIMP QueryInterface(REFIID riid, void ** ppv);
 STDMETHODIMP_(ULONG) AddRef(void);
 STDMETHODIMP_(ULONG) Release(void);

 STDMETHODIMP raw_WillChangeField(
 LONG cFields,
 VARIANT Fields,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset);

 STDMETHODIMP raw_FieldChangeComplete(
 LONG cFields,
 VARIANT Fields,
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset);

 STDMETHODIMP raw_WillChangeRecord(
 EventReasonEnum adReason,
 LONG cRecords,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset);

 STDMETHODIMP raw_RecordChangeComplete(
 EventReasonEnum adReason,
 LONG cRecords,
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset);

 STDMETHODIMP raw_WillChangeRecordset(
 EventReasonEnum adReason,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset);

 STDMETHODIMP raw_RecordsetChangeComplete(
 EventReasonEnum adReason,
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset);

 STDMETHODIMP raw_WillMove(
 EventReasonEnum adReason,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset);

 STDMETHODIMP raw_MoveComplete(
 EventReasonEnum adReason,
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset);

 STDMETHODIMP raw_EndOfRecordset(
 VARIANT_BOOL *fMoreData,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset);

 STDMETHODIMP raw_FetchProgress(
 long Progress,
 long MaxProgress,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset);

 STDMETHODIMP raw_FetchComplete(
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset);
};

//-----Implement each connection method----------------------------------

 STDMETHODIMP CConnEvent::raw_InfoMessage(
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Connection *pConnection)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

 STDMETHODIMP CConnEvent::raw_BeginTransComplete(
 LONG TransactionLevel,
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Connection *pConnection)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

 STDMETHODIMP CConnEvent::raw_CommitTransComplete(
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Connection *pConnection)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

 STDMETHODIMP CConnEvent::raw_RollbackTransComplete(
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Connection *pConnection)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

 STDMETHODIMP CConnEvent::raw_WillExecute(
 BSTR *Source,
 CursorTypeEnum *CursorType,
 LockTypeEnum *LockType,
 long *Options,
 EventStatusEnum *adStatus,
 struct _Command *pCommand,
 struct _Recordset *pRecordset,
 struct _Connection *pConnection)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

 STDMETHODIMP CConnEvent::raw_ExecuteComplete(
 LONG RecordsAffected,
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Command *pCommand,
 struct _Recordset *pRecordset,
 struct _Connection *pConnection)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

 STDMETHODIMP CConnEvent::raw_WillConnect(
 BSTR *ConnectionString,
 BSTR *UserID,
 BSTR *Password,
 long *Options,
 EventStatusEnum *adStatus,
 struct _Connection *pConnection)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

 STDMETHODIMP CConnEvent::raw_ConnectComplete(
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Connection *pConnection)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

 STDMETHODIMP CConnEvent::raw_Disconnect(
 EventStatusEnum *adStatus,
 struct _Connection *pConnection)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

//-----Implement each recordset method-----------------------------------

 STDMETHODIMP CRstEvent::raw_WillChangeField(
 LONG cFields,
 VARIANT Fields,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

 STDMETHODIMP CRstEvent::raw_FieldChangeComplete(
 LONG cFields,
 VARIANT Fields,
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

 STDMETHODIMP CRstEvent::raw_WillChangeRecord(
 EventReasonEnum adReason,
 LONG cRecords,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

 STDMETHODIMP CRstEvent::raw_RecordChangeComplete(
 EventReasonEnum adReason,
 LONG cRecords,
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

 STDMETHODIMP CRstEvent::raw_WillChangeRecordset(
 EventReasonEnum adReason,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

 STDMETHODIMP CRstEvent::raw_RecordsetChangeComplete(
 EventReasonEnum adReason,
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

 STDMETHODIMP CRstEvent::raw_WillMove(
 EventReasonEnum adReason,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

 STDMETHODIMP CRstEvent::raw_MoveComplete(
 EventReasonEnum adReason,
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

 STDMETHODIMP CRstEvent::raw_EndOfRecordset(
 VARIANT_BOOL *fMoreData,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

 STDMETHODIMP CRstEvent::raw_FetchProgress(
 long Progress,
 long MaxProgress,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

 STDMETHODIMP CRstEvent::raw_FetchComplete(
 struct Error *pError,
 EventStatusEnum *adStatus,
 struct _Recordset *pRecordset)
 {
 *adStatus = adStatusUnwantedEvent;
 return S_OK;
 };

//-----Implement QueryInterface, AddRef, and Release---------------------

 STDMETHODIMP CRstEvent::QueryInterface(REFIID riid, void ** ppv)
 {
 *ppv = NULL;
 if (riid == __uuidof(IUnknown) ||
 riid == __uuidof(RecordsetEventsVt)) *ppv = this;
 if (*ppv == NULL)
 return ResultFromScode(E_NOINTERFACE);
 AddRef();
 return NOERROR;
 }
 STDMETHODIMP_(ULONG) CRstEvent::AddRef(void) { return ++m_cRef; };
 STDMETHODIMP_(ULONG) CRstEvent::Release()
 {
 if (0 != --m_cRef) return m_cRef;
 delete this;
 return 0;
 }

 STDMETHODIMP CConnEvent::QueryInterface(REFIID riid, void ** ppv)

 {
 *ppv = NULL;
 if (riid == __uuidof(IUnknown) ||
 riid == __uuidof(ConnectionEventsVt)) *ppv = this;
 if (*ppv == NULL)
 return ResultFromScode(E_NOINTERFACE);
 AddRef();
 return NOERROR;
 }
 STDMETHODIMP_(ULONG) CConnEvent::AddRef() { return ++m_cRef; };
 STDMETHODIMP_(ULONG) CConnEvent::Release()
 {
 if (0 != --m_cRef) return m_cRef;
 delete this;
 return 0;
 }

//-----Write your main block of code-------------------------------------

int main(int argc, char* argv[])
{
 HRESULT hr;
 DWORD dwConnEvt;
 DWORD dwRstEvt;
 IConnectionPointContainer *pCPC = NULL;
 IConnectionPoint *pCP = NULL;
 IUnknown *pUnk = NULL;
 CRstEvent *pRstEvent = NULL;
 CConnEvent *pConnEvent= NULL;
 int rc = 0;
 _RecordsetPtr pRst;
 _ConnectionPtr pConn;

 ::CoInitialize(NULL);

 hr = pConn.CreateInstance(__uuidof(Connection));
 if (FAILED(hr)) return rc;

 hr = pRst.CreateInstance(__uuidof(Recordset));
 if (FAILED(hr)) return rc;

 // Start using the Connection events

 hr = pConn->QueryInterface(__uuidof(IConnectionPointContainer),
 (void **)&pCPC);
 if (FAILED(hr)) return rc;
 hr = pCPC->FindConnectionPoint(__uuidof(ConnectionEvents), &pCP);
 pCPC->Release();
 if (FAILED(hr)) return rc;

 pConnEvent = new CConnEvent();
 hr = pConnEvent->QueryInterface(__uuidof(IUnknown), (void **) &pUnk);
 if (FAILED(hr)) return rc;
 hr = pCP->Advise(pUnk, &dwConnEvt);
 pCP->Release();
 if (FAILED(hr)) return rc;

 // Start using the Recordset events

 hr = pRst->QueryInterface(__uuidof(IConnectionPointContainer),
 (void **)&pCPC);
 if (FAILED(hr)) return rc;
 hr = pCPC->FindConnectionPoint(__uuidof(RecordsetEvents), &pCP);
 pCPC->Release();
 if (FAILED(hr)) return rc;

 pRstEvent = new CRstEvent();
 hr = pRstEvent->QueryInterface(__uuidof(IUnknown), (void **) &pUnk);
 if (FAILED(hr)) return rc;
 hr = pCP->Advise(pUnk, &dwRstEvt);
 pCP->Release();
 if (FAILED(hr)) return rc;

 // Do some work

 pConn->Open("dsn=Pubs;", "MyUserName", "MyPassword", adConnectUnspecified);
 pRst->Open("SELECT * FROM authors", (IDispatch *) pConn,
 adOpenStatic, adLockReadOnly, adCmdText);
 pRst->MoveFirst();
 while (pRst->EndOfFile == FALSE)
 {
 wprintf(L"Name = '%s'\n", (wchar_t*)
 ((_bstr_t) pRst->Fields->GetItem("au_lname")->Value));
 pRst->MoveNext();
 }

 pRst->Close();
 pConn->Close();

 // Stop using the Connection events

 hr = pConn->QueryInterface(__uuidof(IConnectionPointContainer),
 (void **) &pCPC);
 if (FAILED(hr)) return rc;
 hr = pCPC->FindConnectionPoint(__uuidof(ConnectionEvents), &pCP);
 pCPC->Release();
 if (FAILED(hr)) return rc;
 hr = pCP->Unadvise( dwConnEvt );
 pCP->Release();
 if (FAILED(hr)) return rc;

 // Stop using the Recordset events
 hr = pRst->QueryInterface(__uuidof(IConnectionPointContainer),
 (void **) &pCPC);
 if (FAILED(hr)) return rc;
 hr = pCPC->FindConnectionPoint(__uuidof(RecordsetEvents), &pCP);
 pCPC->Release();
 if (FAILED(hr)) return rc;
 hr = pCP->Unadvise( dwRstEvt );
 pCP->Release();
 if (FAILED(hr)) return rc;

 CoUninitialize();
 return 1;
}


Recordset.CacheStart Property (DAO)

 Copy code hover
[image]

Recordset.CacheStart Property (DAO)
Send feedback

Sets or returns a value that specifies the bookmark of the first record in a dynaset-type Recordset object containing data to be locally cached from an ODBC data source (Microsoft Access workspaces only).

Syntax

expression .CacheStart

expression A variable that represents a Recordset object.

Remarks

Data caching improves performance if you use Recordset objects to retrieve data from a remote server. A cache is a space in local memory that holds the data most recently retrieved from the server; this is useful if users request the data again while the application is running. When users request data, the Microsoft Access database engine checks the cache for the requested data first rather than retrieving it from the server, which takes more time. The cache only saves data that comes from an ODBC data source.

Any Microsoft Access database engine-connected ODBC data source, such as a linked table, can have a local cache. To create the cache, open a Recordset object from the remote data source, set the CacheSize and CacheStart properties, and then use the FillCache method, or step through the records by using the Move methods.

The CacheStart property setting is the bookmark of the first record in the Recordset object to be cached. You can use the bookmark of any record to set the CacheStart property. Make the record you want to start the cache the current record, and set the CacheStart property equal to the Bookmark property.

The Microsoft Access database engine requests records within the cache range from the cache, and it requests records outside the cache range from the server.

Records retrieved from the cache don't reflect changes made concurrently to the source data by other users.

To force an update of all the cached data, set the CacheSize property of the Recordset object to 0, re-set it to the size of the cache you originally requested, and then use the FillCache method.


Invalid HTTP address. (Error 3685)

 Copy code hover
[image]

Invalid HTTP address. (Error 3685)
Send feedback

The HTTP address specified is not valid for this replica set. The HTTP address supplied did not match any values in the field InternetAddress in the system table MSysTranspAddress.


EmptyCell.GridlineWidthTop Property (Access)

 Copy code hover
[image]

EmptyCell.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthTop

expression A variable that represents an EmptyCell object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


Error in evaluating a partial expression. (Error 3656)

 Copy code hover
[image]

Error in evaluating a partial expression. (Error 3656)
Send feedback

You have entered an invalid expression in a Boolean filter used to determine which records to use in a partial replica. The replica filter can take the following values:

Value | Description
A string | A criteria that a record must satisfy in order to appear in the replicated table. The string is similar to an SQL WHERE clause, but you cannot specify subqueries, aggregate functions (such as Count), or user defined functions within the criteria.
True | Replicate all records.
False | (Default) Do not replicate any records.


Step 4: Server Returns the Recordset (RDS Tutorial)

 Copy code hover
[image]

Step 4: Server Returns the Recordset (RDS Tutorial)
Send feedback

RDS converts the retrieved Recordset object to a form that can be sent back to the client (that is, it marshals the Recordset). The exact form of the conversion and how it is sent depends on whether the server is on the Internet or an intranet, a local area network, or is a dynamic-link library. However, this detail is not critical; all that matters is that RDS sends the Recordset back to the client.

On the client side, a Recordset object is returned and assigned to a local variable.

Copy code Copy code

Sub RDSTutorial4()
 Dim DS as New RDS.DataSpace
 Dim RS as ADODB.Recordset
 Dim DF as Object
 Set DF = DS.CreateObject("RDSServer.DataFactory", "http://yourServer")
 Set RS = DF.Query("DSN=Pubs", "SELECT * FROM Authors")
...


Properties.Application Property (Access)

 Copy code hover
[image]

Properties.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a Properties object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

Properties Collection

Other resources

Properties Members


Stream Object (ADO) Reference

 Copy code hover
[image]

Stream Object (ADO) Reference
Send feedback

In this section

  • Stream Object (ADO)

  • Stream Properties, Methods, and Events (ADO)


AllReports.Parent Property (Access)

 Copy code hover
[image]

AllReports.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents an AllReports object.

See also

Concepts

AllReports Collection

Other resources

AllReports Object Members


Hierarchy Properties, Methods, and Events (ADO MD)

 Copy code hover
[image]

Hierarchy Properties, Methods, and Events (ADO MD)
Send feedback

Properties/Collections

Description Property

Levels Collection

Name Property

Properties Collection

UniqueName Property

Methods

None.

Events

None.


TextBox.LabelAlign Property (Access)

 Copy code hover
[image]

TextBox.LabelAlign Property (Access)
See also Send feedback

Published: July 16, 2012

The property specifies the text alignment within attached labels on new controls. Read/write Byte.

Syntax

expression .LabelAlign

expression A variable that represents a TextBox object.

Remarks

The LabelAlign property uses the following settings.

Setting | Description
0 | (Default) The label text aligns to the left.
1 | The label text aligns to the left.
2 | The label text is centered.
3 | The label text aligns to the right.
4 | The label text is evenly distributed.

You can set the LabelAlign property by using a control's default control style or the DefaultControl property in Visual Basic.

When created, controls have an attached label (as long as their AutoLabel property is set to Yes). Changes to the LabelAlign default control style setting affect only controls created on the current form or report.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Converting DAO Code to ADO

 Copy code hover
[image]

Converting DAO Code to ADO
Send feedback
Note Note

Versions of the DAO library prior to 3.6 are not provided or supported in Microsoft Access 2013.

DAO to ADO object Map

DAO | ADO(ADODB) | Note
DBEngine | None |
Workspace | None |
Database | Connection |
Recordset | Recordset |
Dynaset-Type | Keyset | Retrieves a set of pointers to the records in the recordset
Snapshot-Type | Static | Both retrieve full records but a Static recordset can be updated.
Table-Type | Keyset with adCmdTableDirect Option |
Field | Field | When referred to in a recordset

Task

DAO

ADO

Open a Recordset
Copy code Copy code
Dim db as Database
Dim rs as DAO.Recordset
Set db = CurrentDB()
Set rs = db.OpenRecordset("Employees")
Copy code Copy code
Dim rs as New ADODB.Recordset
rs.Open "Employees", CurrentProject.Connection, _
         adOpenKeySet, adLockOptimistic

Edit a Recordset
Copy code Copy code
rs.Edit

rs("TextFieldName") = "NewValue"
rs.Update
Copy code Copy code
rs("TextFieldName") = "NewValue"

rs.Update
Note Note

Moving focus from current record via MoveNext, MoveLast, MoveFirst, MovePrevious without first using the CancelUpdate method will implicitly execute the Update method.

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Choosing between DAO and ADO

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.


TextBox.DisplayAsHyperlink Property (Access)

 Copy code hover
[image]

TextBox.DisplayAsHyperlink Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcDisplayAsHyperlink constant that specifies whether to display the contents of the specified text box as a hyperlink. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .DisplayAsHyperlink

expression A variable that represents a TextBox object.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


CommandButton.ForeThemeColorIndex Property (Access)

 Copy code hover
[image]

CommandButton.ForeThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ForeThemeColorIndex

expression A variable that represents a CommandButton object.

Remarks

The ForeThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the ForeThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Fore Color to the Text 2 color by setting the ForeThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.ForeThemeColorIndex=2

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


How to: Handle Run-Time Errors in VBA

 Copy code hover
[image]

How to: Handle Run-Time Errors in VBA
Send feedback

Errors and Error Handling

When you are programming an application, you need to consider what happens when an error occurs. An error can occur in your application for one of two of reasons. First, some condition at the time the application is running makes otherwise valid code fail. For example, if your code attempts to open a table that the user has deleted, an error occurs. Second, your code may contain improper logic that prevents it from doing what you intended. For example, an error occurs if your code attempts to divide a value by zero.

If you have not implemented error handling, Visual Basic halts execution and displays an error message when an error occurs in your code. The user of your application is likely to be confused and frustrated when this happens. You can forestall many problems by including thorough error-handling routines in your code to handle any error that may occur.

When adding error handling to a procedure, you should consider how the procedure will route execution when an error occurs. The first step in routing execution to an error handler is to enable an error handler by including some form of the On Error statement within the procedure. The On Error statement directs execution in event of an error. If there is no On Error statement, Visual Basic simply halts execution and displays an error message when an error occurs.

When an error occurs in a procedure with an enabled error handler, Visual Basic does not display the normal error message. Instead it routes execution to an error handler, if one exists. When execution passes to an enabled error handler, that error handler becomes active. Within the active error handler, you can determine the type of error that occurred and address it in the manner that you choose. Microsoft Access provides three objects that contain information about errors that have occurred: the ADO Error object, the Visual Basic Err object, and the DAO Error object.

Routing Execution When an Error Occurs

An error handler specifies what happens within a procedure when an error occurs. For example, you may want the procedure to end if a certain error occurs, or you may want to correct the condition that caused the error and resume execution. The On Error and Resume statements determine how execution proceeds in the event of an error.

The On Error Statement

The On Error statement enables or disables an error-handling routine. If an error-handling routine is enabled, execution passes to the error-handling routine when an error occurs.

There are three forms of the On Error statement: On Error GoTo label, On Error GoTo 0, and On Error Resume Next. The On Error GoTo label statement enables an error-handling routine, beginning with the line on which the statement is found. You should enable the error-handling routine before the first line at which an error could occur. When the error handler is active and an error occurs, execution passes to the line specified by the label argument.

The line specified by the label argument should be the beginning of the error-handling routine. For example, the following procedure specifies that if an error occurs, execution passes to the line labeled :

Copy code Copy code
Function MayCauseAnError()
    ' Enable error handler.
    On Error GoTo Error_MayCauseAnError
    .            ' Include code here that may generate error.
    .
    .

Error_MayCauseAnError:
    .            ' Include code here to handle error.
    .
    .
End Function

The On Error GoTo 0 statement disables error handling within a procedure. It does not specify line 0 as the start of the error-handling code, even if the procedure contains a line numbered 0. If there is no On Error GoTo 0 statement in your code, the error handler is automatically disabled when the procedure has run completely. The On Error GoTo 0 statement resets the properties of the Err object, having the same effect as the Clear method of the Err object.

The On Error Resume Next statement ignores the line that causes an error and routes execution to the line following the line that caused the error. Execution is not interrupted. You can use the On Error Resume Next statement if you want to check the properties of the Err object immediately after a line at which you anticipate an error will occur, and handle the error within the procedure rather than in an error handler.

The Resume Statement

The Resume statement directs execution back to the body of the procedure from within an error-handling routine. You can include a Resume statement within an error-handling routine if you want execution to continue at a particular point in a procedure. However, a Resume statement is not necessary; you can also end the procedure after the error-handling routine.

There are three forms of the Resume statement. The Resume or Resume 0 statement returns execution to the line at which the error occurred. The Resume Next statement returns execution to the line immediately following the line at which the error occurred. The Resume label statement returns execution to the line specified by the label argument. The label argument must indicate either a line label or a line number.

You typically use the Resume or Resume 0 statement when the user must make a correction. For example, if you prompt the user for the name of a table to open, and the user enters the name of a table that does not exist, you can prompt the user again and resume execution with the statement that caused the error.

You use the Resume Next statement when your code corrects for the error within an error handler, and you want to continue execution without rerunning the line that caused the error. You use the Resume label statement when you want to continue execution at another point in the procedure, specified by the label argument. For example, you might want to resume execution at an exit routine, as described in the following section.

Exiting a Procedure

When you include an error-handling routine in a procedure, you should also include an exit routine, so that the error-handling routine will run only if an error occurs. You can specify an exit routine with a line label in the same way that you specify an error-handling routine.

For example, you can add an exit routine to the example in the previous section. If an error does not occur, the exit routine runs after the body of the procedure. If an error occurs, then execution passes to the exit routine after the code in the error-handling routine has run. The exit routine contains an Exit statement.

Copy code Copy code
Function MayCauseAnError()
    ' Enable error handler.
    On Error GoTo Error_MayCauseAnError
    .            ' Include code that may generate error.
    .
    .

Exit_MayCauseAnError:
    Exit Function

Error_MayCauseAnError:
    .            ' Include code to handle error.
    .
    .
    ' Resume execution with exit routine to exit function.
    Resume Exit_MayCauseAnError
End Function

Handling Errors in Nested Procedures

When an error occurs in a nested procedure that does not have an enabled error handler, Visual Basic searches backward through the calls list for an enabled error handler in another procedure, rather than simply halting execution. This provides your code with an opportunity to correct the error within another procedure. For example, suppose Procedure A calls Procedure B, and Procedure B calls Procedure C. If an error occurs in Procedure C and there is no enabled error handler, Visual Basic checks Procedure B, then Procedure A, for an enabled error handler. If one exists, execution passes to that error handler. If not, execution halts and an error message is displayed.

Visual Basic also searches backward through the calls list for an enabled error handler when an error occurs within an active error handler. You can force Visual Basic to search backward through the calls list by raising an error within an active error handler with the Raise method of the Err object. This is useful for handling errors that you do not anticipate within an error handler. If an unanticipated error occurs, and you regenerate that error within the error handler, then execution passes back up the calls list to find another error handler, which may be set up to handle the error.

For example, suppose Procedure C has an enabled error handler, but the error handler does not correct for the error that has occurred. Once the error handler has checked for all the errors that you have anticipated, it can regenerate the original error. Execution then passes back up the calls list to the error handler in Procedure B, if one exists, providing an opportunity for this error handler to correct the error. If no error handler exists in Procedure B, or if it fails to correct for the error and regenerates it again, then execution passes to the error handler in Procedure A, assuming one exists.

To illustrate this concept in another way, suppose that you have a nested procedure that includes error handling for a type mismatch error, an error which you have anticipated. At some point, a division-by-zero error, which you have not anticipated, occurs within Procedure C. If you have included a statement to regenerate the original error, then execution passes back up the calls list to another enabled error handler, if one exists. If you have corrected for a division-by-zero error in another procedure in the calls list, then the error will be corrected. If your code does not regenerate the error, then the procedure continues to run without correcting the division-by-zero error. This in turn may cause other errors within the set of nested procedures.

In summary, Visual Basic searches back up the calls list for an enabled error handler if:

  • An error occurs in a procedure that does not include an enabled error handler.

  • An error occurs within an active error handler. If you use the Raise method of the Err object to raise an error, you can force Visual Basic to search backward through the calls list for an enabled error handler.

Getting Information About an Error

After execution has passed to the error-handling routine, your code must determine which error has occurred and address it. Visual Basic and Microsoft Access provide several language elements that you can use to get information about a specific error. Each is suited to different types of errors. Because errors can occur in different parts of your application, you need to determine which element to use in your code based on what errors you expect.

The language elements available for error handling include:

  • The Err object.

  • The ADO Error object and Errors collection.

  • The DAO Error object and Errors collection.

  • The AccessError method.

  • The Error event.

The Err Object

The Err object is provided by Visual Basic. When a Visual Basic error occurs, information about that error is stored in the Err object. The Err object maintains information about only one error at a time. When a new error occurs, the Err object is updated to include information about that error instead.

To get information about a particular error, you can use the properties and methods of the Err object. The Number property is the default property of the Err object; it returns the identifying number of the error that occurred. The Err object's Description property returns the descriptive string associated with a Visual Basic error. The Clear method clears the current error information from the Err object. The Raise method generates a specific error and populates the properties of the Err object with information about that error.

The following example shows how to use the Err object in a procedure that may cause a type mismatch error:

Copy code Copy code
Function MayCauseAnError()
    ' Declare constant to represent likely error.
    Const conTypeMismatch As Integer = 13

    On Error GoTo Error_MayCauseAnError
        .            ' Include code here that may generate error.
        .
        .

Exit_MayCauseAnError:
    Exit Function

Error_MayCauseAnError:
    ' Check Err object properties.
    If Err = conTypeMismatch Then
        .            ' Include code to handle error.
        .
        .
    Else
        ' Regenerate original error.
        Dim intErrNum As Integer
        intErrNum = Err
        Err.Clear
        Err.Raise intErrNum
    End If
    ' Resume execution with exit routine to exit function.
    Resume Exit_MayCauseAnError
End Function

Note that in the preceding example, the Raise method is used to regenerate the original error. If an error other than a type mismatch error occurs, execution will be passed back up the calls list to another enabled error handler, if one exists.

The Err object provides you with all the information you need about Visual Basic errors. However, it does not give you complete information about Microsoft Access errors or Microsoft Access database engine errors. Microsoft Access and Data Access Objects (DAO) provide additional language elements to assist you with those errors.

The Error Object and Errors Collection

The Error object and Errors collection are provided by ADO and DAO. The Error object represents an ADO or DAO error. A single ADO or DAO operation may cause several errors, especially if you are performing DAO ODBC operations. Each error that occurs during a particular data access operation has an associated Error object. All the Error objects associated with a particular ADO or DAO operation are stored in the Errors collection, the lowest-level error being the first object in the collection and the highest-level error being the last object in the collection.

When an ADO or DAO error occurs, the Visual Basic Err object contains the error number for the first object in the Errors collection. To determine whether additional ADO or DAO errors have occurred, check the Errors collection. The values of the ADO Number or DAO Number properties and the ADO Description or DAO Description properties of the first Error object in the Errors collection should match the values of the Number and Description properties of the Visual Basic Err object.

The AccessError Method

You can use the Raise method of the Err object to generate a Visual Basic error that has not actually occurred and determine the descriptive string associated with that error. However, you cannot use the Raise method to generate a Microsoft Access error, an ADO error, or a DAO error. To determine the descriptive string associated with a Microsoft Access error, an ADO error, or a DAO error that has not actually occurred, use the AccessError method.

The Error Event

You can use the Error event to trap errors that occur on a Microsoft Access form or report. For example, if a user tries to enter text in a field whose data type is Date/Time, the Error event occurs. If you add an Error event procedure to an Employees form, and then try to enter a text value in the HireDate field, the Error event procedure runs.

The Error event procedure takes an integer argument, DataErr. When an Error event procedure runs, the DataErr argument contains the number of the Microsoft Access error that occurred. Checking the value of the DataErr argument within the event procedure is the only way to determine the number of the error that occurred. The Err object is not populated with error information after the Error event occurs. You can use the value of the DataErr argument with the AccessError method to determine the number of the error and its descriptive string.

Note Note

The Error statement and Error function are provided for backward compatibility only. When writing new code, use the Err and Error objects, the AccessError function, and the Error event for getting information about an error.


Form.AfterUpdate Property (Access)

 Copy code hover
[image]

Form.AfterUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.

Syntax

expression .AfterUpdate

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the AfterUpdate event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the AfterUpdate event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).AfterUpdate = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


Failed to read the dropbox folder. (Error 3512)

 Copy code hover
[image]

Failed to read the dropbox folder. (Error 3512)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


CheckBox.LabelX Property (Access)

 Copy code hover
[image]

CheckBox.LabelX Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelX

expression A variable that represents a CheckBox object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


After Update Macro Event

 Copy code hover
[image]

After Update Macro Event
Send feedback

The After Update event occurs after a record is changed.

Note Note

The After Update event is available only in Data Macros.

Remarks

Use the After Update event to perform any actions that you want to occur when a record is changed. Common uses for the After Insert include enforcing business rules, updating an aggregate total, and sending notifications.

You can use the Updated("Field Name") function to determine whether a field has changed. The following code example shows how to use an If statement to determine determine whether the PaidInFull field has been changed.

Copy code Copy code

If  Updated("PaidInFull")   Then

    /* Perform actions based on changes to the field.   */

End If

You can use access a the previous value in a field by using the following syntax.

Copy code Copy code
[Old].[Field Name]

For example, to access the previous value of the QuantityInStock field, use the following syntax.

Copy code Copy code
[Old].[QuantityInStock]

The previous values are deleted permanently when the After Update event ends.

The following table lists macro commands can be used in theAfter Update event.

Command Type | Command
Program Flow | Comment Macro Statement
Program Flow | Group Macro Statement
Program Flow | If...Then...Else Macro Block
Data Block | CreateRecord Macro Action
Data Block | EditRecord Macro Action
Data Block | ForEachRecord Macro Action
Data Block | LookupRecord Data Block
Data Action | CancelRecordChange Macro Action
Data Action | ClearMacroError Macro Action
Data Action | DeleteRecord Macro Action
Data Action | ExitForEachRecord Macro Action
Data Action | LogEvent Macro Action
Data Action | OnError Macro Action
Data Action | RaiseError Macro Action
Data Action | RunDataMacro Macro Action
Data Action | SendEmail Macro Action
Data Action | SetField Macro Action
Data Action | SetLocalVar Macro Action
Data Action | StopAllMacros Macro Action
Data Action | StopMacro Macro Action

To create a Data macro that captures the After Update event, use the folloiwng steps:

  1. Open the table for which you want to capture the After Update event.

  2. On the Table tab, in the After Events group, click After Update.

An empty data macro is displayed in the macro designer.

Example

The following code example uses the After Update event to run a named data macro that adds a record to the Comment table each time the status of an issue is updated.

Click here to view a copy of the macro that you can paste into Macro Designer.

To view this example in the macro designer, use the following steps:

  1. Open the table for which you want to capture the After Update event.

  2. On the Table tab, in the After Events group, click After Update.

  3. Select the code in the following code example and then press CTRL+C to copy it to the Clipboard.

  4. Activate the macro designer window and then press CTRL+V.

Copy code Copy code
<DataMacros xmlns="http://schemas.microsoft.com/office/accessservices/2009/04/application">
  <DataMacro Event="AfterUpdate">
    <Statements>
      <ConditionalBlock>
        <If>
          <Condition>Updated("Status")</Condition>
          <Statements>
            <Action Name="RunDataMacro">
              <Argument Name="MacroName">Comments.AddComment</Argument>
              <Parameters>
                <Parameter Name="prmRelatedID" Value="[ID]" />
                <Parameter Name="prmComment" Value="&quot;-- Status changed to &quot; &amp; [Status]" />
                <Parameter Name="prmUserID" Value="[UserID]" />
              </Parameters>
            </Action>
          </Statements>
        </If>
      </ConditionalBlock>
      <ConditionalBlock>
        <If>
          <Condition>Updated("Resolution")</Condition>
          <Statements>
            <Action Name="RunDataMacro">
              <Argument Name="MacroName">Comments.AddComment</Argument>
              <Parameters>
                <Parameter Name="prmRelatedID" Value="[ID]" />
                <Parameter Name="prmUserID" Value="[UserID]" />
                <Parameter Name="prmComment" Value="&quot;-- Issue resolved as &quot; &amp; [Resolution]" />
              </Parameters>
            </Action>
          </Statements>
        </If>
      </ConditionalBlock>
    </Statements>
  </DataMacro>
</DataMacros>
Copy code Copy code

If  Updated("Status")   Then
     RunDataMacro
        Macro Name   Comments.AddComment
     Parameters
       prmRelatedID   = [ID]
         prmComment   ="--Status Changes to "&[Status]
          prmUserID   =[ChangedByUserID]
End If

If   Updated("Resolution")   Then
     RunDataMacro
        Macro Name   Comments.AddComment
     Parameters
       prmRelatedID   = [ID]
          prmUserID   =[ChangedByUserID]
         prmComment   ="--Issue Resolved as "&[Status]
End If


MarshalOptionsEnum

 Copy code hover
[image]

MarshalOptionsEnum
Send feedback

Specifies which records should be returned to the server.

Constant | Value | Description
adMarshalAll | 0 | Default. Returns all rows to the server.
adMarshalModifiedOnly | 1 | Returns only modified rows to the server.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.MarshalOptions.ALL

AdoEnums.MarshalOptions.MODIFIEDONLY


Cannot open database

 Copy code hover
[image]

Cannot open database <name>. It may not be a database that your application recognizes, or the file may be corrupt. (Error 3049)
Send feedback

Possible causes:

  • You tried to open a non-Microsoft Access database engine database, such as a Btrieve, dBASE, or Paradox database or table. Instead, link the database or table to an existing Microsoft Jet database.

  • You tried to import or link a Paradox database or table, and the associated .px file could not be found. Make sure the .px file is the same directory as the Paradox database or table, and then try the operation again.

  • If the specified database is a Microsoft Jet database, it is corrupted. You should attempt to repair the database. If the database cannot be repaired, restore the database from a backup copy, or create a new database.


SmartTagActions Members (Access)

 Copy code hover
[image]

SmartTagActions Members (Access)
Send feedback

Published: July 16, 2012

Represents a collection of actions for an individual smart tag or a type of smart tag.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only SmartTagAction.
Parent | Returns the parent object for the specified object. Read-only.


Form.SelTop Property (Access)

 Copy code hover
[image]

Form.SelTop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SelTop property to specify or determine which row (record) is topmost in the current selection rectangle in a table, query, or form datasheet, or which selected record is topmost in a continuous form.Read/write Long.

Syntax

expression .SelTop

expression A variable that represents a Form object.

Remarks

The SelTop property returns a value between 1 and the number of records in the datasheet or continuous form.

If there's no selection, the value returned by this property is the row and column of the cell with the focus.

If you've selected one or more columns (using the column headings), you can't change the setting of the SelTop property.

You can use these properties with the SelHeight and SelWidth properties to specify or determine the actual size of the selection rectangle. The SelTop and SelLeft properties determine the position of the upper-left corner of the selection rectangle. The SelHeight and SelWidth properties determine the lower-right corner of the selection rectangle.

See also

Concepts

Form Object

Other resources

Form Object Members


Form.BeforeRender Event (Access)

 Copy code hover
[image]

Form.BeforeRender Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs before any object in the specified PivotChart view has been rendered.

Syntax

expression .BeforeRender(drawObject, chartObject, Cancel)

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
drawObject | Required | Object | A reference to the ChChartDraw object. Use the DrawType property of the returned object to determine what type of rendering is about to occur.
chartObject | Required | Object | The object that is to be rendered. Use the TypeName function to determine the type of the object.
Cancel | Required | Object | Set the Value property of this object to True to cancel the rendering of the PivotChart View object.

Return Value

nothing

Example

The following example demonstrates the syntax for a subroutine that traps the BeforeRender event.

VBA Copy code Copy code
Private Sub Form_BeforeRender( _
 ByVal drawObject As Object, _
 ByVal chartObject As Object, _
 ByVal Cancel As Object)
 Dim intResponse As Integer
 Dim strPrompt As String

 strPrompt = "Cancel render of current object?"

 intResponse = MsgBox(strPrompt, vbYesNo)

 If intResponse = vbYes Then
 Cancel.Value = True
 Else
 Cancel.Value = False
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Form.Dirty Property (Access)

 Copy code hover
[image]

Form.Dirty Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Dirty property to determine whether the current record has been modified since it was last saved. Read/write Boolean.

Syntax

expression .Dirty

expression A variable that represents a Form object.

Remarks

For example, you may want to ask the user whether changes to a record were intended and, if not, allow the user to move to the next record without saving the changes.

When a record is saved, Microsoft Access sets the Dirty property to False. When a user makes changes to a record, the property is set to True.

Example

The following example enables the btnUndo button when data is changed. The UndoEdits( ) subroutine is called from the AfterUpdate event of text box controls. Clicking the enabled btnUndo button restores the original value of the control by using the OldValue property.

VBA Copy code Copy code
Sub UndoEdits()
 If Me.Dirty Then
 Me!btnUndo.Enabled = True ' Enable button.
 Else
 Me!btnUndo.Enabled = False ' Disable button.
 End If
End Sub

Sub btnUndo_Click()
 Dim ctlC As Control
 ' For each control.
 For Each ctlC in Me.Controls
 If ctlC.ControlType = acTextBox Then
 ' Restore Old Value.
 ctlC.Value = ctlC.OldValue
 End If
 Next ctlC
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Paradox index is not primary. (Error 3288)

 Copy code hover
[image]

Paradox index is not primary. (Error 3288)
Send feedback

You are attempting to create an index on a Paradox table for which no other indexes are defined. The first index created on a Paradox table must be a primary index.

Possible solutions:

  • Redefine the index as the primary index.

  • If the index you are attempting to create is not the primary index, create the primary index first.


CustomControl.Layout Property (Access)

 Copy code hover
[image]

CustomControl.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified text box. Read-only AcLayoutType.

Version Information

Version Added: Access 2010

Syntax

expression .Layout

expression A variable that represents a CustomControl object.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


NavigationControl.LostFocus Event (Access)

 Copy code hover
[image]

NavigationControl.LostFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The LostFocus event occurs when the specified object loses the focus.

Version Information

Version Added: Access 2010

Syntax

expression .LostFocus

expression A variable that represents a NavigationControl object.

Return Value

nothing

Remarks

To run a macro or event procedure when these events occur, set the OnLostFocus property to the name of the macro or to [Event Procedure].

This events occurs when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The LostFocus event differs from the Exit event in that the LostFocus event occurs every time a control loses the focus. The Exit event occurs only before a control loses the focus to another control on the same form. The LostFocus event occurs after the Exit event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


NavigationControl.Dirty Event (Access)

 Copy code hover
[image]

NavigationControl.Dirty Event (Access)
See also Send feedback

Published: July 16, 2012

The Dirty event occurs when the contents of the specified control changes.

Version Information

Version Added: Access 2010

Syntax

expression .Dirty(Cancel, )

expression A variable that represents a NavigationControl object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer |

Return Value

nothing

Remarks

Examples of this event include entering a character directly in the text box or combo box or changing the control's Text property setting by using a macro or Visual Basic.

  • Modifying a record within a form by using a macro or Visual Basic doesn't trigger this event. You must type the data directly into the record or set the control's Text property.

  • This event applies only to bound forms, not an unbound form or report.

To run a macro or event procedure when this event occurs, set the OnDirty property to the name of the macro or to [Event Procedure].

By running a macro or event procedure when a Dirty event occurs, you can determine if the record can be changed. You can also display a message and ask for edit permission.

Changing the data in a record by using the keyboard causes keyboard events to occur in addition to control events like the Dirty event. For example, if you move to a new record and type an ANSI character in a text box in the record, the following events occur in this order:

KeyDown > KeyPress > BeforeInsert > Dirty > KeyUp

The BeforeUpdate and AfterUpdate events for a record occur after you have entered the new or changed data in the record and moved to another record (or clicked Save Record on the Records menu), and therefore after the Dirty event for the record.

Canceling the Dirty event will cause the changes to the current record to be rolled back. It is equivalent to pressing the ESC key.

Example

The following example enables the btnUndo button when data is changed. The UndoEdits( ) subroutine is called from the Dirty event of text box controls. Clicking the enabled btnUndo button restores the original value of the control by using the OldValue property.

VBA Copy code Copy code
Private Sub Form_Dirty()
 If Me.Dirty Then
 Me!btnUndo.Enabled = True ' Enable button.
 Else
 Me!btnUndo.Enabled = False ' Disable button.
 End If
End Sub

Sub btnUndo_Click()
 Dim ctlC As Control
 ' For each control.
 For Each ctlC in Me.Controls
 If ctlC.ControlType = acTextBox Then
 ' Restore Old Value.
 ctlC.Value = ctlC.OldValue
 End If
 Next ctlC
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Connections Properties (DAO)

 Copy code hover
[image]

Connections Properties (DAO)
Send feedback

In this section

  • Connections.Count Property (DAO)


Len Function (Access 2013 custom web app)

 Copy code hover
[image]

Len Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the number of characters of the specified string expression, excluding trailing blanks.

Syntax

Len(TextExpression)

The Len function contains the following argument.

Argument Name | Description
TextExpression | A string expression.


Section.DblClick Event (Access)

 Copy code hover
[image]

Section.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Syntax

expression .DblClick(Cancel)

expression A variable that represents a Section object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the DblClick event occurs. Setting the Cancel argument to True (-1) cancels the DblClick event.

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

Section Object

Other resources

Section Object Members


ToggleButton.OnEnter Property (Access)

 Copy code hover
[image]

ToggleButton.OnEnter Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnEnter

expression A variable that represents a ToggleButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Enter event occurs before a control actually receives the focus from a control on the same form.

The OnEnter value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Enter box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Enter box is blank, the property value is an empty string.

Example

The following example associates the Enter event with the macro "Enter_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnEnter = "Enter_Macro"

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


NavigationButton.BackColor Property (Access)

 Copy code hover
[image]

NavigationButton.BackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the interior color of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackColor

expression A variable that represents a NavigationButton object.

Remarks

The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

To use the BackColor property, the BackStyle property, if available, must be set to Normal.

Example

The following example uses the RGB function to set the , BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Application.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

Application.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Syntax

expression .ShortcutMenuBar

expression A variable that represents an Application object.

Remarks

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

See also

Concepts

Application Object

Other resources

Application Object Members


Groups Collection Properties, Methods, and Events (ADOX)

 Copy code hover
[image]

Groups Collection Properties, Methods, and Events (ADOX)
Send feedback

Properties

Count Property

Item Property

Methods

Append Method (Groups)

Delete Method (Collections)

Refresh Method

Events

None.


QueryDefs Properties (DAO)

 Copy code hover
[image]

QueryDefs Properties (DAO)
Send feedback

In this section

  • QueryDefs.Count Property (DAO)


Internet not set up. (Error 3653)

 Copy code hover
[image]

Internet not set up. (Error 3653)
Send feedback

There is a problem with the Internet setup.


Ribbon

 Copy code hover
[image]

Ribbon
Send feedback

In this section

  • How to: Hide the Ribbon When Access Starts

  • How to: Apply a Custom Ribbon to a Form or Report

  • How to: Apply a Custom Ribbon When Starting Access


AcOutputObjectType Enumeration (Access)

 Copy code hover
[image]

AcOutputObjectType Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the type of object to output when using the OutputTo method.

Name | Value | Description
acOutputForm | 2 | Form
acOutputFunction | 10 | User-Defined Function
acOutputModule | 5 | Module
acOutputQuery | 1 | Query
acOutputReport | 3 | Report
acOutputServerView | 7 | Server View
acOutputStoredProcedure | 9 | Stored Procedure
acOutputTable | 0 | Table


Parameter Object (ADO)

 Copy code hover
[image]

Parameter Object (ADO)
Send feedback

Represents a parameter or argument associated with a Command object based on a parameterized query or stored procedure.

Remarks

Many providers support parameterized commands. These are commands in which the desired action is defined once, but variables (or parameters) are used to alter some details of the command. For example, an SQL SELECT statement could use a parameter to define the matching criteria of a WHERE clause, and another to define the column name for a SORT BY clause.

Parameter objects represent parameters associated with parameterized queries, or the in/out arguments and the return values of stored procedures. Depending on the functionality of the provider, some collections, methods, or properties of a Parameter object may not be available.

With the collections, methods, and properties of a Parameter object, you can do the following:

  • Set or return the name of a parameter with the Name property.

  • Set or return the value of a parameter with the Value property. Value is the default property of the Parameter object.

  • Set or return parameter characteristics with the Attributes, Direction, Precision, NumericScale, Size, and Type properties.

  • Pass long binary or character data to a parameter with the AppendChunk method.

  • Access provider-specific attributes with the Properties collection.

If you know the names and properties of the parameters associated with the stored procedure or parameterized query you wish to call, you can use the CreateParameter method to create Parameter objects with the appropriate property settings and use the Append method to add them to the Parameters collection. This lets you set and return parameter values without having to call the Refresh method on the Parameters collection to retrieve the parameter information from the provider, a potentially resource-intensive operation.


Page.InSelection Property (Access)

 Copy code hover
[image]

Page.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents a Page object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

Page Object

Other resources

Page Object Members


Field2.ValidateOnSet Property (DAO)

 Copy code hover
[image]

Field2.ValidateOnSet Property (DAO)
Send feedback

Sets or returns a value that specifies whether or not the value of a Field2 object is immediately validated when the object's Value property is set (Microsoft Access workspaces only).

Syntax

expression .ValidateOnSet

expression A variable that represents a Field2 object.

Remarks

Only Field2 objects in Recordset objects support the ValidateOnSet property as read/write.

Setting the ValidateOnSet property to True can be useful in a situation when a user is entering records that include substantial Memo data. Waiting until the Update call to validate the data can result in unnecessary time spent writing the lengthy Memo data to the database if it turns out that the data was invalid anyway because a validation rule was broken in another field.

Example

This example uses the ValidateOnSet property to demonstrate how one might trap for errors during data entry. The ValidateData function is required for this procedure to run.

VBA Copy code Copy code
Sub ValidateOnSetX()

 Dim dbsNorthwind As Database
 Dim fldDays As Field2
 Dim rstEmployees As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 ' Create and append a new Field object to the Fields
 ' collection of the Employees table.
 Set fldDays = _
 dbsNorthwind.TableDefs!Employees.CreateField( _
 "DaysOfVacation", dbInteger, 2)
 fldDays.ValidationRule = "BETWEEN 1 AND 20"
 fldDays.ValidationText = _
 "Number must be between 1 and 20!"
 dbsNorthwind.TableDefs!Employees.Fields.Append fldDays

 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees")

 With rstEmployees

 Do While True
 ' Add new record.
 .AddNew

 ' Get user input for three fields. Verify that the
 ' data do not violate the validation rules for any
 ' of the fields.
 If ValidateData(!FirstName, _
 "Enter first name.") = False Then Exit Do
 If ValidateData(!LastName, _
 "Enter last name.") = False Then Exit Do
 If ValidateData(!DaysOfVacation, _
 "Enter days of vacation.") = False Then Exit Do

 .Update
 .Bookmark = .LastModified
 Debug.Print !FirstName & " " & !LastName & _
 " - " & "DaysOfVacation = " & !DaysOfVacation

 ' Delete new record because this is a demonstration.
 .Delete
 Exit Do
 Loop

 ' Cancel AddNew method if any of the validation rules
 ' were broken.
 If .EditMode <> dbEditNone Then .CancelUpdate
 .Close
 End With

 ' Delete new field because this is a demonstration.
 dbsNorthwind.TableDefs!Employees.Fields.Delete _
 fldDays.Name
 dbsNorthwind.Close

End Sub

Function ValidateData(fldTemp As Field2, _
 strMessage As String) As Boolean

 Dim strInput As String
 Dim errLoop As Error

 ValidateData = True
 ' ValidateOnSet is only read/write for Field objects in
 ' Recordset objects.
 fldTemp.ValidateOnSet = True

 Do While True
 strInput = InputBox(strMessage)
 If strInput = "" Then Exit Do
 ' Trap for errors when setting the Field value.
 On Error GoTo Err_Data
 If fldTemp.Type = dbInteger Then
 fldTemp = Val(strInput)
 Else
 fldTemp = strInput
 End If
 On Error GoTo 0
 If Not IsNull(fldTemp) Then Exit Do
 Loop

 If strInput = "" Then ValidateData = False

 Exit Function

Err_Data:

 If DBEngine.Errors.Count > 0 Then
 ' Enumerate the Errors collection. The description
 ' property of the last Error object will be set to
 ' the ValidationText property of the relevant
 ' field.
 For Each errLoop In DBEngine.Errors
 MsgBox "Error number: " & errLoop.Number & _
 vbCr & errLoop.Description
 Next errLoop
 End If

 Resume Next

End Function


Section.AlternateBackTint Property (Access)

 Copy code hover
[image]

Section.AlternateBackTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the AlternateBackColor property of the section. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .AlternateBackTint

expression A variable that represents a Section object.

Remarks

The AlternateBackTint property contains a numeric expression that can be used to lighten the theme color in the AlternateBackColor property. The default value of the AlternateBackTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

Section Object

Other resources

Section Object Members


Attachment.OnAttachmentCurrent Property (Access)

 Copy code hover
[image]

Attachment.OnAttachmentCurrent Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or gets the value of the On Attachment Current box in the Properties window of the specified Attachment. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .OnAttachmentCurrent

expression A variable that represents an Attachment object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Unknown or invalid field reference

 Copy code hover
[image]

Unknown or invalid field reference <name>. (Error 3345)
Send feedback

Your expression refers to a field incorrectly or to a field that does not exist. Check to make sure the field name is correct.


Using Related Technologies with RDS (ADO)

 Copy code hover
[image]

Using Related Technologies with RDS (ADO)
Send feedback

In this section

  • Using Related Technologies with RDS

  • Using RDS with ODBC Connection Pooling

  • Running Business Objects in Component Services


Database.Properties Property (DAO)

 Copy code hover
[image]

Database.Properties Property (DAO)
Send feedback

Returns the Properties collection of the specified object. Read-only.

Syntax

expression .Properties

expression A variable that represents a Database object.


Detecting and Resolving Conflicts
Send feedback

Detecting and Resolving Conflicts

If you are dealing with your Recordset in immediate mode, there is much less chance for concurrency problems to arise. On the other hand, if your application uses batch mode updating, there may be a good chance that one user will change a record before changes made by another user editing the same record are saved. In such a case, you will want your application to gracefully handle the conflict. It may be your wish that the last person to send an update to the server "wins." Or you may want to let the most recent user to decide which update should take precedence by providing him with a choice between the two conflicting values.

Whatever the case, ADO provides the UnderlyingValue and OriginalValue properties of the Field object in order to handle these types of conflicts. Use these properties in combination with the Resync method and Filter property of the Recordset.

Detecting Errors

When ADO encounters a conflict during a batch update, a warning will be placed in the Errors collection. Therefore, you should always check for errors immediately after calling BatchUpdate, and if you find them, begin testing the assumption that you have encountered a conflict. The first step is to set the Filter property on the Recordset equal to adFilterConflictingRecords (the Filter property is discussed in the preceding chapter). This limits the view on your Recordset to only those records that are in conflict. If the RecordCount property is equal to zero after this step, you know the error was raised by something other than a conflict.

When you call BatchUpdate, ADO and the provider are generating SQL statements to perform updates on the data source. Remember that certain data sources have limitations on which types of columns can be used in a WHERE clause.

Next, call the Resync method on the Recordset with the AffectRecords argument set equal to adAffectGroup and the ResyncValues argument set equal to adResyncUnderlyingValues. The Resync method refreshes the data in the current Recordset object from the underlying database. By using adAffectGroup, you are ensuring that only the records visible with the current filter setting, that is, only the conflicting records, are resynchronized with the database. This could make a significant performance difference if you are dealing with a large Recordset. By setting the ResyncValues argument to adResyncUnderlyingValues when calling Resync, you ensure that the UnderlyingValue property will contain the (conflicting) value from the database, that the Value property will maintain the value entered by the user, and that the OriginalValue property will hold the original value for the field (the value it had before the last successful UpdateBatch call was made). You can then use these values to resolve the conflict programmatically or require the user to choose the value that will be used.

This technique is shown in the code example below. The example artificially creates a conflict by using a separate Recordset to change a value in the underlying table before UpdateBatch is called.

Copy code Copy code

'BeginConflicts
    On Error GoTo ErrHandler:

    Dim objRs1 As New ADODB.Recordset
    Dim objRs2 As New ADODB.Recordset
    Dim strSQL As String
    Dim strMsg As String

    strSQL = "SELECT * FROM Shippers WHERE ShipperID = 2"

    'Open Rs and change a value
    objRs1.CursorLocation = adUseClient
    objRs1.Open strSQL, strConn, adOpenStatic, adLockBatchOptimistic, adCmdText
    objRs1("Phone") = "(111) 555-1111"

    'Introduce a conflict at the db...
    objRs2.Open strSQL, strConn, adOpenKeyset, adLockOptimistic, adCmdText
    objRs2("Phone") = "(999) 555-9999"
    objRs2.Update
    objRs2.Close
    Set objRs2 = Nothing

    On Error Resume Next
    objRs1.UpdateBatch

    If objRs1.ActiveConnection.Errors.Count <> 0 Then
        Dim intConflicts As Integer

        intConflicts = 0

        objRs1.Filter = adFilterConflictingRecords

        intConflicts = objRs1.RecordCount

        'Resync so we can see the UnderlyingValue and offer user a choice.
        'This sample only displays all three values and resets to original.
        objRs1.Resync adAffectGroup, adResyncUnderlyingValues

        If intConflicts > 0 Then
            strMsg = "A conflict occurred with updates for " & intConflicts & _
                     " record(s)." & vbCrLf & "The values will be restored" & _
                     " to their original values." & vbCrLf & vbCrLf

            objRs1.MoveFirst
            While Not objRs1.EOF
                strMsg = strMsg & "SHIPPER = " & objRs1("CompanyName") & vbCrLf
                strMsg = strMsg & "Value = " & objRs1("Phone").Value & vbCrLf
                strMsg = strMsg & "UnderlyingValue = " & _
                                   objRs1("Phone").UnderlyingValue & vbCrLf
                strMsg = strMsg & "OriginalValue = " & _
                                   objRs1("Phone").OriginalValue & vbCrLf
                strMsg = strMsg & vbCrLf & "Original value has been restored."

                MsgBox strMsg, vbOKOnly, _
                      "Conflict " & objRs1.AbsolutePosition & _
                      " of " & intConflicts

                objRs1("Phone").Value = objRs1("Phone").OriginalValue
                objRs1.MoveNext
            Wend

            objRs1.UpdateBatch adAffectGroup
        Else
            'Other error occurred. Minimal handling in this example.
             strMsg = "Errors occurred during the update. " & _
                        objRs1.ActiveConnection.Errors(0).Number & " " & _
                        objRs1.ActiveConnection.Errors(0).Description
        End If

        On Error GoTo 0
    End If

    objRs1.MoveFirst

    'Clean up
    objRs1.Close
    Set objRs1 = Nothing
    Exit Sub

ErrHandler:

    If Not objRs1 Is Nothing Then
        If objRs1.State = adStateOpen Then objRs1.Close
        Set objRs1 = Nothing
    End If

    If Not objRs2 Is Nothing Then
        If objRs2.State = adStateOpen Then objRs2.Close
        Set objRs2 = Nothing
    End If

    If Err <> 0 Then
        MsgBox Err.Source & "-->" & Err.Description, , "Error"
    End If

'EndConflicts

You can use the Status property of the current Record or of a specific Field to determine what kind of a conflict has occurred.

For more detailed information on error handling, see Chapter 6: Error Handling.


BoundObjectFrame.AddColon Property (Access)

 Copy code hover
[image]

BoundObjectFrame.AddColon Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.

Syntax

expression .AddColon

expression A variable that represents a BoundObjectFrame object.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


WebBrowserControl.MouseUp Event (Access)

 Copy code hover
[image]

WebBrowserControl.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Version Information

Version Added: Access 2010

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents a WebBrowserControl object.

Parameters

Name | Required/Optional | Data Type | Description
Button | Required | Integer |
Shift | Required | Integer |
X | Required | Single |
Y | Required | Single |

Return Value

nothing

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


CustomControl.Move Method (Access)

 Copy code hover
[image]

CustomControl.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a CustomControl object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Set Properties of Data Access Objects in Visual Basic

 Copy code hover
[image]

Set Properties of Data Access Objects in Visual Basic
Send feedback

Published: July 16, 2012

Data Access Objects (DAO) enable you to manipulate the structure of your database and the data it contains from Visual Basic. Many DAO objects correspond to objects that you see in your database — for example, a TableDef object corresponds to a Microsoft Access table. A Field object corresponds to a field in a table.

Most of the properties you can set for DAO objects are DAO properties. These properties are defined by the Microsoft Access database engine and are set the same way in any application that includes the Access database engine. Some properties that you can set for DAO objects are defined by Microsoft Access, and aren't automatically recognized by the Access database engine. How you set properties for DAO objects depends on whether a property is defined by the Access database engine or by Microsoft Access.

Setting DAO Properties for DAO Objects

To set a property that's defined by the Access database engine, refer to the object in the DAO hierarchy. The easiest and fastest way to do this is to create object variables that represent the different objects you need to work with, and refer to the object variables in subsequent steps in your code. For example, the following code creates a new TableDef object and sets its Name property:

Copy code Copy code
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Set dbs = CurrentDb
Set tdf = dbs.CreateTableDef
tdf.Name = "Contacts"

Setting Microsoft Access Properties for DAO Objects

When you set a property that's defined by Microsoft Access, but applies to a DAO object, the Access database engine doesn't automatically recognize the property as a valid property. The first time you set the property, you must create the property and append it to the Properties collection of the object to which it applies. Once the property is in the Properties collection, it can be set in the same manner as any DAO property.

If the property is set for the first time in the user interface, it's automatically added to the Properties collection, and you can set it normally.

When writing procedures to set properties defined by Microsoft Access, you should include error-handling code to verify that the property you are setting already exists in the Properties collection. See the Help topic about the CreateProperty method or the individual property topic for more information.

Keep in mind that when you create the property, you must correctly specify its Type property before you append it to the Properties collection. You can determine the Type property based on the information in the Settings section of the Help topic for the individual property. The following table provides some guidelines for determining the setting of the Type property.

If the property setting is | Then the Type property setting should be
A string | dbText
True/False | dbBoolean
An integer | dbInteger

The following table lists some Microsoft Access-defined properties that apply to DAO objects.

DAO object | Microsoft Access-defined properties
Database | AppTitle, AppIcon, StartupShowDBWindow, StartupShowStatusBar, AllowShortcutMenus, AllowFullMenus, AllowBuiltInToolbars, AllowToolbarChanges, AllowBreakIntoCode, AllowSpecialKeys, Replicable, ReplicationConflictFunction
SummaryInfo Container | Title, Subject, Author, Manager, Company, Category, Keywords, Comments, Hyperlink Base (See the Summary tab of the DatabaseName Properties dialog box, available by clicking Database Properties on the File menu.)
UserDefined Container | (See the Summary tab of the DatabaseName Properties dialog box, available by clicking Database Properties on the File menu.)
TableDef | DatasheetBackColor, DatasheetCellsEffect, DatasheetFontHeight, DatasheetFontItalic, DatasheetFontName, DatasheetFontUnderline, DatasheetFontWeight, DatasheetForeColor, DatasheetGridlinesBehavior, DatasheetGridlinesColor, Description, FrozenColumns, RowHeight, ShowGrid
QueryDef | DatasheetBackColor, DatasheetCellsEffect, DatasheetFontHeight, DatasheetFontItalic, DatasheetFontName, DatasheetFontUnderline, DatasheetFontWeight, DatasheetForeColor, DatasheetGridlinesBehavior, DatasheetGridlinesColor, Description, FailOnError, FrozenColumns, LogMessages, MaxRecords, RecordLocks, RowHeight, ShowGrid, UseTransaction
Field | Caption, ColumnHidden, ColumnOrder, ColumnWidth, DecimalPlaces, Description, Format, InputMask


Attachment.AutoLabel Property (Access)

 Copy code hover
[image]

Attachment.AutoLabel Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .AutoLabel

expression A variable that represents an Attachment object.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


NavigationControl.BorderStyle Property (Access)

 Copy code hover
[image]

NavigationControl.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .BorderStyle

expression A variable that represents a NavigationControl object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


XactAttributeEnum

 Copy code hover
[image]

XactAttributeEnum
Send feedback

Specifies the transaction attributes of a Connection object.

Constant | Value | Description
adXactAbortRetaining | 262144 | Performs retaining aborts — that is, calling RollbackTrans automatically starts a new transaction. Not all providers support this.
adXactCommitRetaining | 131072 | Performs retaining commits — that is, calling CommitTrans automatically starts a new transaction. Not all providers support this.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.XactAttribute.ABORTRETAINING

AdoEnums.XactAttribute.COMMITRETAINING


Form.PictureTiling Property (Access)

 Copy code hover
[image]

Form.PictureTiling Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureTiling property to specify whether a background picture is tiled across the entire image control, Form window, form, or page of a report. Read/write Boolean.

Syntax

expression .PictureTiling

expression A variable that represents a Form object.

Remarks

The PictureTiling property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The picture is tiled.
No | False | (Default) The picture isn't tiled.

You can also set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

You can create interesting effects by placing a picture on a form or report and setting the PictureTiling property to Yes. The alignment of the tiled images is affected by the PictureAlignment property setting. For example, if the PictureTiling property is set to Top Left, tiling begins at the top left of the image control, Form window, or page of a report.

If the PictureAlignment property is set to Form Center and the PictureTiling property is set to Yes, the background picture of a form will be tiled across the form, not across the Form window.

See also

Concepts

Form Object

Other resources

Form Object Members


Syntax error in CREATE INDEX statement. (Error 3291)

 Copy code hover
[image]

Syntax error in CREATE INDEX statement. (Error 3291)
Send feedback

You entered an SQL statement that includes an invalid CREATE INDEX statement.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


How to: Detect Whether an Object Is Open

 Copy code hover
[image]

How to: Detect Whether an Object Is Open
Send feedback

It is often necessary to know whether a particular database object is open before you can edit the object programmatically. The following example illustrates how to use the SysCmd method with the acSysCmdGetObjectState action to determine whether a database object is open.

The example function, IsObjectLoaded, accepts two parameters. The strObjectName parameter is the name of the databse object to check for. The strObjectType parameter is an AcObjectType constant that specifies the type of database object to check for. The IsObjectLoaded function returns True if the specified databse object is open, and returns False if it is not open.

VBA Copy code Copy code

Function IsObjectLoaded(ByVal strObjectName As String, ByVal strObjectType As AcObjectType) As Boolean

    If SysCmd(acSysCmdGetObjectState, strObjectType, strObjectName) <> 0 Then

       ' The object is open.
        IsObjectLoaded = True
    Else

       ' The object is not open.
        IsObjectLoaded = False
    End If

End Function


Syntax error in default value. (Error 3355)

 Copy code hover
[image]

Syntax error in default value. (Error 3355)
Send feedback

Possible causes:

  • An unknown function name was included in the default value expression in a table-level validation rule.

  • A default value expression in a table-level validation rule is syntactically incorrect.


Parameter

 Copy code hover
[image]

Parameter <name> has no default value. (Error 3748)
Send feedback

This occurs when using procedures. It occurs when a default value is trying to be utilized and the parameter does not have a defined default value. To prevent this error message, define a default value on the procedure, or pass in a value to the parameter.


Axes Collection (ADO MD Reference)

 Copy code hover
[image]

Axes Collection (ADO MD Reference)
Send feedback

In this section

  • Axes Collection (ADO MD)

  • Axes Collection Properties, Methods, and Events (ADO MD)


Form.PictureData Property (Access)

 Copy code hover
[image]

Form.PictureData Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.

Syntax

expression .PictureData

expression A variable that represents a Form object.

Remarks

The PictureData property setting is the PictureData property of another control, form, or report.

You can use this property to display different background pictures in a form, depending on actions taken by the user. For example, you might open a Customers form using a different background picture depending on whether the form is opened for data entry or for browsing.

You can also use the PictureData property together with the Timer event and the TimerInterval property to perform simple animation on a form.

Example

The following example uses three image controls to animate a butterfly image across a form. The Hidden1 image control contains a picture of a butterfly with its wings up and the Hidden2 image control contains a picture of the same butterfly with its wings down. Both image controls have their Visible property set to False. The TimerInterval property is set to 200. Each time the Timer event occurs, the picture in the image control Visible1 is changed by using the PictureData property of the hidden image controls, and the visible image control is moved 200 twips to the right. The visible image control is moved back to the left side of the form when its Left property value is greater than the width of the form stored in the public variable gfrmWidth. The value of gfrmWidth is set to Me.Width in the form's open event.

VBA Copy code Copy code
Private Sub Form_Timer()

 Static intPic As Integer

 Select Case intPic
 Case Is = 1
 Me!Visible1.PictureData = Me!Hidden1.PictureData
 Case Is = 2
 Me!Visible1.PictureData = Me!Hidden2.PictureData
 Case Else
 End Select

 If intPic = 2 Then intPic = 0
 intPic = intPic + 1
 If (Me!Visible1.Left > gfrmWidth) Then Me!Visible1.Left = 0
 Me!Visible1.Left = Me!Visible1.Left + 200

End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Recordset Object (DAO)

 Copy code hover
[image]

Recordset Object (DAO)
Send feedback

A Recordset object represents the records in a base table or the records that result from running a query.

Remarks

You use Recordset objects to manipulate data in a database at the record level. When you use DAO objects, you manipulate data almost entirely using Recordset objects. All Recordset objects are constructed using records (rows) and fields (columns). There are five types of Recordset objects:

  • Table-type Recordset— representation in code of a base table that you can use to add, change, or delete records from a single database table (Microsoft Access workspaces only).

  • Dynaset-type Recordset— the result of a query that can have updatable records. A dynaset-type Recordset object is a dynamic set of records that you can use to add, change, or delete records from an underlying database table or tables. A dynaset-type Recordset object can contain fields from one or more tables in a database. This type corresponds to an ODBC keyset cursor.

  • Snapshot-type Recordset— a static copy of a set of records that you can use to find data or generate reports. A snapshot-type Recordset object can contain fields from one or more tables in a database but can't be updated. This type corresponds to an ODBC static cursor.

  • Forward-only-type Recordset— identical to a snapshot except that no cursor is provided. You can only scroll forward through records. This improves performance in situations where you only need to make a single pass through a result set. This type corresponds to an ODBC forward-only cursor.

  • Dynamic-type Recordset— a query result set from one or more base tables in which you can add, change, or delete records from a row-returning query. Further, records other users add, delete, or edit in the base tables also appear in your Recordset. This type corresponds to an ODBC dynamic cursor (ODBCDirect workspaces only).

    Note Note

    ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

You can choose the type of Recordset object you want to create using the type argument of the OpenRecordset method.

In a Microsoft Access workspace, if you don't specify a type, DAO attempts to create the type of Recordset with the most functionality available, starting with table. If this type isn't available, DAO attempts a dynaset, then a snapshot, and finally a forward-only type Recordset object.

In an ODBCDirect workspace, if you don't specify a type, DAO attempts to create the type of Recordset with the fastest query response, starting with forward-only. If this type isn't available, DAO attempts a snapshot, then a dynaset, and finally a dynamic- type Recordset object.

When creating a Recordset object using a non-linked TableDef object in a Microsoft Access workspace, table-type Recordset objects are created. Only dynaset-type or snapshot-type Recordset objects can be created with linked tables or tables in Microsoft Access database engine-connected ODBC databases.

A new Recordset object is automatically added to the Recordsets collection when you open the object, and is automatically removed when you close it.

Note Note

If you use variables to represent a Recordset object and the Database object that contains the Recordset, make sure the variables have the same scope, or lifetime. For example, if you declare a public variable that represents a Recordset object, make sure the variable that represents the Database containing the Recordset is also public, or is declared in a Sub or Function procedure using the Static keyword.

You can create as many Recordset object variables as needed. Different Recordset objects can access the same tables, queries, and fields without conflicting.

Dynaset-, snapshot-, and forward-only-type Recordset objects are stored in local memory. If there isn't enough space in local memory to store the data, the Microsoft Access database engine saves the additional data to TEMP disk space. If this space is exhausted, a trappable error occurs.

The default collection of a Recordset object is the Fields collection, and the default property of a Field object is the Value property. Use these defaults to simplify your code.

When you create a Recordset object, the current record is positioned to the first record if there are any records. If there are no records, the RecordCount property setting is 0, and the BOF and EOF property settings are True.

You can use the MoveNext, MovePrevious, MoveFirst, and MoveLast methods to reposition the current record. Forward-only-type Recordset objects support only the MoveNext method. When using the Move methods to visit each record (or "walk" through the Recordset), you can use the BOF and EOF properties to check for the beginning or end of the Recordset object.

With dynaset- and snapshot-type Recordset objects in a Microsoft Access workspace, you can also use the Find methods, such as FindFirst, to locate a specific record based on criteria. If the record isn't found, the NoMatch property is set to True. For table-type Recordset objects, you can scan records using the Seek method.

The Type property indicates the type of Recordset object created, and the Updatable property indicates whether you can change the object's records.

Information about the structure of a base table, such as the names and data types of each Field object and any Index objects, is stored in a TableDef object.

To refer to a Recordset object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

Recordsets(0)

Recordsets("name")

Recordsets![name]

Note Note

You can open a Recordset object from the same data source or database more than once, creating duplicate names in the Recordsets collection. You should assign Recordset objects to object variables and refer to them by variable name.

Example

This example demonstrates Recordset objects and the Recordsets collection by opening four different types of Recordsets, enumerating the Recordsets collection of the current Database, and enumerating the Properties collection of each Recordset.

VBA Copy code Copy code
Sub RecordsetX()

   Dim dbsNorthwind As Database
   Dim rstTable As Recordset
   Dim rstDynaset As Recordset
   Dim rstSnapshot As Recordset
   Dim rstForwardOnly As Recordset
   Dim rstLoop As Recordset
   Dim prpLoop As Property

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   With dbsNorthwind

      ' Open one of each type of Recordset object.
      Set rstTable = .OpenRecordset("Categories", _
         dbOpenTable)
      Set rstDynaset = .OpenRecordset("Employees", _
         dbOpenDynaset)
      Set rstSnapshot = .OpenRecordset("Shippers", _
         dbOpenSnapshot)
      Set rstForwardOnly = .OpenRecordset _
         ("Employees", dbOpenForwardOnly)

      Debug.Print "Recordsets in Recordsets " & _
         "collection of dbsNorthwind"

      ' Enumerate Recordsets collection.
      For Each rstLoop In .Recordsets

         With rstLoop
            Debug.Print "  " & .Name

            ' Enumerate Properties collection of each
            ' Recordset object. Trap for any
            ' properties whose values are invalid in
            ' this context.
            For Each prpLoop In .Properties
               On Error Resume Next
               If prpLoop <> "" Then Debug.Print _
                  "    " & prpLoop.Name & _
                  " = " & prpLoop
               On Error GoTo 0
            Next prpLoop

         End With

      Next rstLoop

      rstTable.Close
      rstDynaset.Close
      rstSnapshot.Close
      rstForwardOnly.Close

      .Close
   End With

End Sub

This example uses the OpenRecordset method to open five different Recordset objects and display their contents. The OpenRecordsetOutput procedure is required for this procedure to run.

VBA Copy code Copy code
Sub OpenRecordsetX()

   Dim wrkAcc As Workspace
   Dim wrkODBC As Workspace
   Dim dbsNorthwind As Database
   Dim conPubs As Connection
   Dim rstTemp As Recordset
   Dim rstTemp2 As Recordset

   ' Open Microsoft Access and ODBCDirect workspaces, Microsoft
   ' Access database, and ODBCDirect connection.
   Set wrkAcc = CreateWorkspace("", "admin", "", dbUseJet)
   Set wrkODBC = CreateWorkspace("", "admin", "", dbUseODBC)
   Set dbsNorthwind = wrkAcc.OpenDatabase("Northwind.mdb")

   ' Note: The DSN referenced below must be set to
   '       use Microsoft Windows NT Authentication Mode to
   '       authorize user access to the Microsoft SQL Server.
   Set conPubs = wrkODBC.OpenConnection("", , , _
      "ODBC;DATABASE=pubs;DSN=Publishers")

   ' Open five different Recordset objects and display the
   ' contents of each.

   Debug.Print "Opening forward-only-type recordset " & _
      "where the source is a QueryDef object..."
   Set rstTemp = dbsNorthwind.OpenRecordset( _
      "Ten Most Expensive Products", dbOpenForwardOnly)
   OpenRecordsetOutput rstTemp

   Debug.Print "Opening read-only dynaset-type " & _
      "recordset where the source is an SQL statement..."
   Set rstTemp = dbsNorthwind.OpenRecordset( _
      "SELECT * FROM Employees", dbOpenDynaset, dbReadOnly)
   OpenRecordsetOutput rstTemp

   ' Use the Filter property to retrieve only certain
   ' records with the next OpenRecordset call.
   Debug.Print "Opening recordset from existing " & _
      "Recordset object to filter records..."
   rstTemp.Filter = "LastName >= 'M'"
   Set rstTemp2 = rstTemp.OpenRecordset()
   OpenRecordsetOutput rstTemp2

   Debug.Print "Opening dynamic-type recordset from " & _
      "an ODBC connection..."
   Set rstTemp = conPubs.OpenRecordset( _
      "SELECT * FROM stores", dbOpenDynamic)
   OpenRecordsetOutput rstTemp

   ' Use the StillExecuting property to determine when the
   ' Recordset is ready for manipulation.
   Debug.Print "Opening snapshot-type recordset based " & _
      "on asynchronous query to ODBC connection..."
   Set rstTemp = conPubs.OpenRecordset("publishers", _
      dbOpenSnapshot, dbRunAsync)
   Do While rstTemp.StillExecuting
      Debug.Print "  [still executing...]"
   Loop
   OpenRecordsetOutput rstTemp

   rstTemp.Close
   dbsNorthwind.Close
   conPubs.Close
   wrkAcc.Close
   wrkODBC.Close

End Sub

Sub OpenRecordsetOutput(rstOutput As Recordset)

   ' Enumerate the specified Recordset object.
   With rstOutput
      Do While Not .EOF
         Debug.Print , .Fields(0), .Fields(1)
         .MoveNext
      Loop
   End With

End Sub

This example opens a dynamic-type Recordset object and enumerates its records.

VBA Copy code Copy code
Sub dbOpenDynamicX()

   Dim wrkMain As Workspace
   Dim conMain As Connection
   Dim qdfTemp As QueryDef
   Dim rstTemp As Recordset
   Dim strSQL As String
   Dim intLoop As Integer

   ' Create ODBC workspace and open connection to
   ' SQL Server database.
   Set wrkMain = CreateWorkspace("ODBCWorkspace", _
      "admin", "", dbUseODBC)

   ' Note: The DSN referenced below must be configured to
   '       use Microsoft Windows NT Authentication Mode to
   '       authorize user access to the Microsoft SQL Server.
   Set conMain = wrkMain.OpenConnection("Publishers", _
      dbDriverNoPrompt, False, _
      "ODBC;DATABASE=pubs;DSN=Publishers")

   ' Open dynamic-type recordset.
   Set rstTemp = _
      conMain.OpenRecordset("authors", _
      dbOpenDynamic)

   With rstTemp
      Debug.Print "Dynamic-type recordset: " & .Name

      ' Enumerate records.
      Do While Not .EOF
         Debug.Print "    " & !au_lname & ", " & _
            !au_fname
         .MoveNext
      Loop

      .Close
   End With

   conMain.Close
   wrkMain.Close

End Sub

This example opens a dynaset-type Recordset and shows the extent to which its fields are updatable.

VBA Copy code Copy code
Sub dbOpenDynasetX()

   Dim dbsNorthwind As Database
   Dim rstInvoices As Recordset
   Dim fldLoop As Field

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   Set rstInvoices = _
      dbsNorthwind.OpenRecordset("Invoices", dbOpenDynaset)

   With rstInvoices
      Debug.Print "Dynaset-type recordset: " & .Name

      If .Updatable Then
         Debug.Print "  Updatable fields:"

         ' Enumerate Fields collection of dynaset-type
         ' Recordset object, print only updatable
         ' fields.
         For Each fldLoop In .Fields
            If fldLoop.DataUpdatable Then
               Debug.Print "    " & fldLoop.Name
            End If
         Next fldLoop

      End If

      .Close
   End With

   dbsNorthwind.Close

End Sub

This example opens a forward-only-type Recordset, demonstrates its read-only characteristics, and steps through the Recordset with the MoveNext method.

VBA Copy code Copy code
Sub dbOpenForwardOnlyX()

   Dim dbsNorthwind As Database
   Dim rstEmployees As Recordset
   Dim fldLoop As Field

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   ' Open a forward-only-type Recordset object. Only the
   ' MoveNext and Move methods may be used to navigate
   ' through the recordset.
   Set rstEmployees = _
      dbsNorthwind.OpenRecordset("Employees", _
      dbOpenForwardOnly)

   With rstEmployees
      Debug.Print "Forward-only-type recordset: " & _
         .Name & ", Updatable = " & .Updatable

      Debug.Print "  Field - DataUpdatable"
      ' Enumerate Fields collection, printing the Name and
      ' DataUpdatable properties of each Field object.
      For Each fldLoop In .Fields
         Debug.Print "    " & _
            fldLoop.Name & " - " & fldLoop.DataUpdatable
      Next fldLoop

      Debug.Print "  Data"
      ' Enumerate the recordset.
      Do While Not .EOF
         Debug.Print "    " & !FirstName & " " & _
            !LastName
         .MoveNext
      Loop

      .Close
   End With

   dbsNorthwind.Close

End Sub

This example opens a snapshot-type Recordset and demonstrates its read-only characteristics.

VBA Copy code Copy code
Sub dbOpenSnapshotX()

   Dim dbsNorthwind As Database
   Dim rstEmployees As Recordset
   Dim prpLoop As Property

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   Set rstEmployees = _
      dbsNorthwind.OpenRecordset("Employees", _
      dbOpenSnapshot)

   With rstEmployees
      Debug.Print "Snapshot-type recordset: " & _
         .Name

      ' Enumerate the Properties collection of the
      ' snapshot-type Recordset object, trapping for
      ' any properties whose values are invalid in
      ' this context.
      For Each prpLoop In .Properties
         On Error Resume Next
         Debug.Print "  " & _
            prpLoop.Name & " = " & prpLoop
         On Error Goto 0
      Next prpLoop

      .Close
   End With

   dbsNorthwind.Close

End Sub

This example opens a table-type Recordset, sets its Index property, and enumerates its records.

VBA Copy code Copy code
Sub dbOpenTableX()

   Dim dbsNorthwind As Database
   Dim rstEmployees As Recordset

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   ' dbOpenTable is default.
   Set rstEmployees = _
      dbsNorthwind.OpenRecordset("Employees")

   With rstEmployees
      Debug.Print "Table-type recordset: " & .Name

      ' Use predefined index.
      .Index = "LastName"
      Debug.Print "  Index = " & .Index

      ' Enumerate records.
      Do While Not .EOF
         Debug.Print "    " & !LastName & ", " & _
            !FirstName
         .MoveNext
      Loop

      .Close
   End With

   dbsNorthwind.Close

End Sub

The following example shows how to use the Seek method to find a record in a linked table.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Sub TestSeek()
    ' Get the path to the external database that contains
    ' the tblCustomers table we're going to search.
    Dim strMyExternalDatabase
    Dim dbs    As DAO.Database
    Dim dbsExt As DAO.Database
    Dim rst    As DAO.Recordset
    Dim tdf    As DAO.TableDef

    Set dbs = CurrentDb()
    Set tdf = dbs.TableDefs("tblCustomers")
    strMyExternalDatabase = Mid(tdf.Connect, 11)

    'Open the database that contains the table that is linked
    Set dbsExt = OpenDatabase(strMyExternalDatabase)

    'Open a table-type recordset against the external table
    Set rst = dbsExt.OpenRecordset("tblCustomers", dbOpenTable)

    'Specify which index to search on
    rst.Index = "PrimaryKey"

    'Specify the criteria
    rst.Seek "=", 123

    'Check the result
    If rst.NoMatch Then
        MsgBox "Record not found."
    Else
        MsgBox "Customer name: " & rst!CustName
    End If

    rst.Close
    dbs.Close
    dbsExt.Close
    Set rst = Nothing
    Set tdf = Nothing
    Set dbs = Nothing

End Sub

The following example shows how to open a Recordset that is based on a parameter query.

VBA Copy code Copy code
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset

Set dbs = CurrentDb

'Get the parameter query
Set qfd = dbs.QueryDefs("qryMyParameterQuery")

'Supply the parameter value
qdf.Parameters("EnterStartDate") = Date
qdf.Parameters("EnterEndDate") = Date + 7

'Open a Recordset based on the parameter query
Set rst = qdf.OpenRecordset()

The following example shows how to open a Recordset based on a table or a query.

VBA Copy code Copy code
Dim dbs As DAO.Database
Dim rsTable As DAO.Recordset
Dim rsQuery As DAO.Recordset

Set dbs = CurrentDb

'Open a table-type Recordset
Set rsTable = dbs.OpenRecordset("Table1", dbOpenTable)

'Open a dynaset-type Recordset using a saved query
Set rsQuery = dbs.OpenRecordset("qryMyQuery", dbOpenDynaset)

The following example shows how to open a Recordset based on a Structured Query Language (SQL) statement.

VBA Copy code Copy code
Dim dbs As DAO.Database
Dim rsSQL As DAO.Recordset
Dim strSQL As String

Set dbs = CurrentDb

'Open a snapshot-type Recordset based on an SQL statement
strSQL = "SELECT * FROM Table1 WHERE Field2 = 33"
Set rsSQL = dbs.OpenRecordset(strSQL, dbOpenSnapshot)

The following example shows how to use the FindFirst and FindNext methods to find a record in a Recordset.

VBA Copy code Copy code
Sub FindOrgName()

    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset

    'Get the database and Recordset
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("tblCustomers")

    'Search for the first matching record
    rst.FindFirst "[OrgName] LIKE '*parts*'"

    'Check the result
    If rst.NoMatch Then
        MsgBox "Record not found."
        GotTo Cleanup
    Else
        Do While Not rst.NoMatch
            MsgBox "Customer name: " & rst!CustName
            rst.FindNext "[OrgName] LIKE '*parts*'"
        Loop

        'Search for the next matching record
        rst.FindNext "[OrgName] LIKE '*parts*'"
    End If

    Cleanup:
        rst.Close
        Set rst = Nothing
        Set dbs = Nothing

End Sub

The following example shows how to copy the results of a query to a worksheet in a new Microsoft Excel workbook.

VBA Copy code Copy code
Public Sub CopyDataFromQuery( _
    xlApp As Excel.Application, _
    strQueryName As String)

    ' If the xlApp object exists
    If Not xlApp Is Nothing Then

        ' If the Workbook exists
        If xlApp.Workbooks.Count = 1 Then

            ' Create Recrodset Object from the Query
            Dim rsQuery As DAO.Recordset
            Set rsQuery = Application.CurrentDb.OpenRecordset(strQueryName)

            ' Get the Cells object
            Dim Cells As Object
            Set Cells = xlApp.Workbooks(1).ActiveSheet.Cells

            ' Copy the Data from the Query into the Sheet
            Cells.CopyFromRecordset rsQuery

        End If
    End If

End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


ObjectFrame.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

ObjectFrame.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified frame. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleLeft

expression A variable that represents an ObjectFrame object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Application.DDEExecute Method (Access)

 Copy code hover
[image]

Application.DDEExecute Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the DDEExecute statement to send a command from a client application to a server application over an open dynamic data exchange (DDE) channel.

Syntax

expression .DDEExecute(ChanNum, Command)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
ChanNum | Required | Variant | A channel number, the long integer returned by the DDEInitiate function.
Command | Required | String | a command recognized by the server application. Check the server application's documentation for a list of these commands.

Remarks

For example, suppose you've opened a DDE channel in Microsoft Access to transfer text data from a Microsoft Excel spreadsheet into a Microsoft Access database. Use the DDEExecute statement to send the New command to Microsoft Excel to specify that you wish to open a new spreadsheet. In this example, Microsoft Access acts as the client application, and Microsoft Excel acts as the server application.

The value of the command argument depends on the application and topic specified when the channel indicated by the channum argument is opened. An error occurs if the channum argument isn't an integer corresponding to an open channel or if the other application can't carry out the specified command.

From Visual Basic, you can use the DDEExecute statement only to send commands to another application. For information on sending commands to Microsoft Access from another application, see Use Microsoft Access as a DDE Server .

If you need to manipulate another application's objects from Microsoft Access, you may want to consider using Automation.

See also

Concepts

Application Object

Other resources

Application Object Members


Recordset2.Seek Method (DAO)

 Copy code hover
[image]

Recordset2.Seek Method (DAO)
Send feedback

Locates the record in an indexed table-type Recordset object that satisfies the specified criteria for the current index and makes that record the current record (Microsoft Access workspaces only).

Syntax

expression .Seek(Comparison, Key1, Key2, Key3, Key4, Key5, Key6, Key7, Key8, Key9, Key10, Key11, Key12, Key13)

expression A variable that represents a Recordset2 object.

Parameters

Name | Required/Optional | Data Type | Description
Comparison | Required | String | One of the following string expressions: <, <=, =, >=, or >.
Key1, Key2...Key13 | Required | Variant | One or more values corresponding to fields in the Recordset object's current index, as specified by its Index property setting. You can use up to 13 key arguments.

Remarks

You must set the current index with the Index property before you use Seek. If the index identifies a nonunique key field, Seek locates the first record that satisfies the criteria.

The Seek method searches through the specified key fields and locates the first record that satisfies the criteria specified by comparison and key1. Once found, it makes that record current and sets the NoMatch property to False. If the Seek method fails to locate a match, the NoMatch property is set to True, and the current record is undefined.

If comparison is equal (=), greater than or equal (>=), or greater than (>), Seek starts at the beginning of the index and searches forward.

If comparison is less than (<) or less than or equal (<=), Seek starts at the end of the index and searches backward. However, if there are duplicate index entries at the end of the index, Seek starts at an arbitrary entry among the duplicates and then searches backward.

You must specify values for all fields defined in the index. If you use Seek with a multiple-column index, and you don't specify a comparison value for every field in the index, then you cannot use the equal (=) operator in the comparison. That's because some of the criteria fields (key2, key3, and so on) will default to Null, which will probably not match. Therefore, the equal operator will work correctly only if you have a record which is all null except the key you're looking for. It's recommended that you use the greater than or equal (>=) operator instead.

The key1 argument must be of the same field data type as the corresponding field in the current index. For example, if the current index refers to a number field (such as Employee ID), key1 must be numeric. Similarly, if the current index refers to a Text field (such as Last Name), key1 must be a string.

There doesn't have to be a current record when you use Seek.

You can use the Indexes collection to enumerate the existing indexes.

To locate a record in a dynaset- or snapshot-type Recordset that satisfies a specific condition that is not covered by existing indexes, use the Find methods. To include all records, not just those that satisfy a specific condition, use the Move methods to move from record to record.

You can't use the Seek method on a linked table because you can't open linked tables as table-type Recordset objects. However, if you use the OpenDatabase method to directly open an installable ISAM (non-ODBC) database, you can use Seek on tables in that database.

Example

This example demonstrates the Seek method by allowing the user to search for a product based on an ID number.

VBA Copy code Copy code
Sub SeekX()

 Dim dbsNorthwind As Database
 Dim rstProducts As Recordset2
 Dim intFirst As Integer
 Dim intLast As Integer
 Dim strMessage As String
 Dim strSeek As String
 Dim varBookmark As Variant

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 ' You must open a table-type Recordset to use an index,
 ' and hence the Seek method.
 Set rstProducts = _
 dbsNorthwind.OpenRecordset("Products", dbOpenTable)

 With rstProducts
 ' Set the index.
 .Index = "PrimaryKey"

 ' Get the lowest and highest product IDs.
 .MoveLast
 intLast = !ProductID
 .MoveFirst
 intFirst = !ProductID

 Do While True
 ' Display current record information and ask user
 ' for ID number.
 strMessage = "Product ID: " & !ProductID & vbCr & _
 "Name: " & !ProductName & vbCr & vbCr & _
 "Enter a product ID between " & intFirst & _
 " and " & intLast & "."
 strSeek = InputBox(strMessage)

 If strSeek = "" Then Exit Do

 ' Store current bookmark in case the Seek fails.
 varBookmark = .Bookmark

 .Seek "=", Val(strSeek)

 ' Return to the current record if the Seek fails.
 If .NoMatch Then
 MsgBox "ID not found!"
 .Bookmark = varBookmark
 End If
 Loop

 .Close
 End With

 dbsNorthwind.Close

End Sub

This example uses the NoMatch property to determine whether a Seek and a FindFirst were successful, and if not, to give appropriate feedback. The SeekMatch and FindMatch procedures are required for this procedure to run.

VBA Copy code Copy code
Sub NoMatchX()

 Dim dbsNorthwind As Database
 Dim rstProducts As Recordset2
 Dim rstCustomers As Recordset2
 Dim strMessage As String
 Dim strSeek As String
 Dim strCountry As String
 Dim varBookmark As Variant

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 ' Default is dbOpenTable; required if Index property will
 ' be used.
 Set rstProducts = dbsNorthwind.OpenRecordset("Products")

 With rstProducts
 .Index = "PrimaryKey"

 Do While True
 ' Show current record information; ask user for
 ' input.
 strMessage = "NoMatch with Seek method" & vbCr & _
 "Product ID: " & !ProductID & vbCr & _
 "Product Name: " & !ProductName & vbCr & _
 "NoMatch = " & .NoMatch & vbCr & vbCr & _
 "Enter a product ID."
 strSeek = InputBox(strMessage)
 If strSeek = "" Then Exit Do

 ' Call procedure that seeks for a record based on
 ' the ID number supplied by the user.
 SeekMatch rstProducts, Val(strSeek)
 Loop

 .Close
 End With

 Set rstCustomers = dbsNorthwind.OpenRecordset( _
 "SELECT CompanyName, Country FROM Customers " & _
 "ORDER BY CompanyName", dbOpenSnapshot)

 With rstCustomers

 Do While True
 ' Show current record information; ask user for
 ' input.
 strMessage = "NoMatch with FindFirst method" & _
 vbCr & "Customer Name: " & !CompanyName & _
 vbCr & "Country: " & !Country & vbCr & _
 "NoMatch = " & .NoMatch & vbCr & vbCr & _
 "Enter country on which to search."
 strCountry = Trim(InputBox(strMessage))
 If strCountry = "" Then Exit Do

 ' Call procedure that finds a record based on
 ' the country name supplied by the user.
 FindMatch rstCustomers, _
 "Country = '" & strCountry & "'"
 Loop

 .Close
 End With

 dbsNorthwind.Close

End Sub

Sub SeekMatch(rstTemp As Recordset, _
 intSeek As Integer)

 Dim varBookmark As Variant
 Dim strMessage As String

 With rstTemp
 ' Store current record location.
 varBookmark = .Bookmark
 .Seek "=", intSeek

 ' If Seek method fails, notify user and return to the
 ' last current record.
 If .NoMatch Then
 strMessage = _
 "Not found! Returning to current record." & _
 vbCr & vbCr & "NoMatch = " & .NoMatch
 MsgBox strMessage
 .Bookmark = varBookmark
 End If

 End With

End Sub

Sub FindMatch(rstTemp As Recordset, _
 strFind As String)

 Dim varBookmark As Variant
 Dim strMessage As String

 With rstTemp
 ' Store current record location.
 varBookmark = .Bookmark
 .FindFirst strFind

 ' If Find method fails, notify user and return to the
 ' last current record.
 If .NoMatch Then
 strMessage = _
 "Not found! Returning to current record." & _
 vbCr & vbCr & "NoMatch = " & .NoMatch
 MsgBox strMessage
 .Bookmark = varBookmark
 End If

 End With

End Sub


Application.CurrentObjectType Property (Access)

 Copy code hover
[image]

Application.CurrentObjectType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the CurrentObjectType property together with the Application object to determine the type of the active database object (table, query, form, report, macro, module, server view, database diagram, or stored procedure). The active database object is the object that has the focus or in which code is running. Read-only AcObjectType.

Syntax

expression .CurrentObjectType

expression A variable that represents an Application object.

Remarks

The following conditions determine which object is considered the active object:

  • If the active object is a property sheet, command bar, menu, palette, or field list of an object, the CurrentObjectType property returns the type of the underlying object.

  • If the active object is a pop-up form, the CurrentObjectType property refers to the pop-up form itself, not the form from which it was opened.

  • If the active object is the Database window, the CurrentObjectType property returns the item selected in the Database window.

  • If no object is selected, the CurrentObjectType property returns True.

  • If the current state is ambiguous (the active object isn't a table, query, form, report, macro, or module) for example, if a dialog box has the focus the CurrentObjectType property returns True.

You can use this property with the SysCmd method to determine the active object and its state (for example, if the object is open, new, or has been changed but not saved).

Example

The following example uses the CurrentObjectType and CurrentObjectName properties with the SysCmd function to determine if the active object is the Products form and if this form is open and has been changed but not saved. If these conditions are true, the form is saved and then closed.

VBA Copy code Copy code
Public Sub CheckProducts()

 Dim intState As Integer
 Dim intCurrentType As Integer
 Dim strCurrentName As String

 intCurrentType = Application.CurrentObjectType
 strCurrentName = Application.CurrentObjectName

 If intCurrentType = acForm And strCurrentName = "Products" Then
 intState = SysCmd(acSysCmdGetObjectState, intCurrentType, _
 strCurrentName)

 ' Products form changed but not saved.
 If intState = acObjStateDirty + acObjStateOpen Then

 ' Close Products form and save changes.
 DoCmd.Close intCurrentType, strCurrentName, acSaveYes
 End If
 End If
End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


NavigationButton.ObjectPalette Property (Access)

 Copy code hover
[image]

NavigationButton.ObjectPalette Property (Access)
See also Send feedback

Published: July 16, 2012

The ObjectPalette property specifies the palette in the application used to create A bitmap or other graphic that is loaded into the specified control by using the Picture property. Read/write Variant.

Version Information

Version Added: Access 2010

Syntax

expression .ObjectPalette

expression A variable that represents a NavigationButton object.

Remarks

Microsoft Access sets the value of the ObjectPalette property to a String data type containing the palette information. You can use this setting to set the value of the PaintPalette property for a form or report.

If the application associated with the bitmap or other graphic doesn't have an associated palette, the ObjectPalette property is set to an zero-length string.

The ObjectPalette property is read-only in Form Design view, Form view, and Report Design view. This property setting is unavailable in other views.

The setting of the ObjectPalette property makes the palette of the application associated with the OLE object contained in a control available to the PaintPalette property of a form or report. For example, to make the palette used in Microsoft Graph available when you're designing a form in Microsoft Access, you set the form's PaintPalette property to the ObjectPalette value of an existing chart control.

Note Note

Windows can have only one color palette active at a time. Microsoft Access allows you to have multiple graphics on a form, each using a different color palette. The PaintPalette and PaletteSource properties let you specify which color palette a form should use when displaying graphics.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


DataControl Object (RDS) (ADO)

 Copy code hover
[image]

DataControl Object (RDS) (ADO)
Send feedback

In this section

  • DataControl Object (RDS)

  • DataControl Properties, Methods, and Events (RDS)


Running Business Objects in Component Services

 Copy code hover
[image]

Running Business Objects in Component Services
Send feedback

Business objects can be executable files (.exe) or dynamic-link libraries (.dll). The configuration you use to run the business object depends on whether the object is a .dll or .exe file:

  • Business objects created as .exe files can be called through DCOM. If these business objects are used through Internet Information Services (IIS), they are subject to additional marshalingof data, which will slow client performance.

  • Business objects created as .dll files can be used via IIS (and therefore HTTP). They can also be used over DCOM only via Component Services (or Microsoft Transaction Server, if you are using Windows NT). Business object DLLs will need to be registered on the IIS server computer to give you accessibility via IIS. (For steps on how to configure a DLL to run on DCOM, see the section, "Enabling a DLL to Run on DCOM.")

Note Note

When business objects on the middle tier are implemented as Component Services components (using GetObjectContext, SetComplete, and SetAbort), they can use Component Services (or MTS, if you are using Windows NT) context objects to maintain their state across multiple client calls. This scenario is possible with DCOM, which is typically implemented between trusted clients and servers (an intranet). In this case, the RDS.DataSpace object and CreateObject method on the client side are replaced by the transaction context object and CreateInstance method (provided by the ITransactionContext interface), implemented by Component Services.


NavigationControl.OnMouseMove Property (Access)

 Copy code hover
[image]

NavigationControl.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnMouseMove

expression A variable that represents a NavigationControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


SetLocalVar Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

SetLocalVar Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

The SetLocalVar action creates a temporary variable and set it to a specific value.

Note Note

The SetLocalVar action is available only in Data Macros.

Setting

The SetLocalVar action has the following arguments.

Argument name | Required | Description
Name | Yes | A string that specifies the name of the variable.
Expression | Yes | An expression that will be used to set the value for this temporary variable. Do not precede the expression with the equal sign (=). You can click the Build button to use the Expression Builder to set this argument.


Stream Properties, Methods, and Events (ADO)

 Copy code hover
[image]

Stream Properties, Methods, and Events (ADO)
Send feedback

Properties

Charset Property

EOS Property

LineSeparator Property

Mode Property

Position Property

Size Property (ADO Stream)

State Property

Type Property (ADO Stream)

Methods

Cancel Method

Close Method

CopyTo Method

Flush Method

LoadFromFile Method

Open Method (ADO Stream)

Read Method

ReadText Method

SaveToFile Method

SetEOS Method

SkipLine Method

Stat Method

Write Method

WriteText Method

Events

None.


Report.ScrollBars Property (Access)

 Copy code hover
[image]

Report.ScrollBars Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether scroll bars appear on a report. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .ScrollBars

expression A variable that represents a Report object.

Remarks

The ScrollBars property uses the following settings.

Setting | Visual Basic | Description
Neither | 0 | No scroll bars appear on the report.
Horizontal Only | 1 | Horizontal scroll bar appears on the report.
Vertical Only | 2 | Vertical scroll bar appears on the report.
Both | 3 | (Default) Vertical and horizontal scroll bars appear on the report.

If your report is larger than the available display window, you can use the ScrollBars property to allow the user to view the entire report.

See also

Concepts

Report Object

Other resources

Report Object Members


PrintOut Macro Action

 Copy code hover
[image]

PrintOut Macro Action
Send feedback

You can use the PrintOut action to print the active object in the open database. You can print datasheets, reports, forms, data access pages, and modules.

Note 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.

Setting

The PrintOut action has the following arguments.

Action argument | Description
Print Range | The range to print. Click All (the user can print all of the object), Selection (the user can print the part of the object that's selected), or Pages (the user can specify a range of pages in the Page From and Page To arguments) in the Print Range box in the Action Arguments section of the Macro Builder pane. The default is All.
Page From | The first page to print. Printing starts at the top of this page. This argument is required if you select Pages in the Print Range box.
Page To | The last page to print. Printing stops at the bottom of this page. This argument is required if you select Pages in the Print Range box.
Print Quality | The print quality. Click High, Medium, Low, or Draft. The lower the quality, the faster the object prints. The default is High.
Copies | The number of copies to print. The default is 1.
Collate Copies | Click Yes (collate the printed copies) or No (do not collate copies). The object may print faster if this argument is set to No. The default is Yes.

Remarks

This action is similar to selecting an object, clicking the File tab and then clicking Print. With this action, however, no Print dialog box appears.

Tip Tip

If you have particular print settings you use frequently, create a macro containing a PrintOut action with these settings in its arguments.

The arguments for this action correspond to options in the Print dialog box. However, unlike the FindRecord action and Find and Replace dialog box, the argument settings aren't shared with the Print dialog box options.

To run the PrintOut action in a Visual Basic for Applications (VBA) module, use the PrintOut method of the DoCmd object.


You cannot use ODBC to import from, export to, or link an external Microsoft Jet or ISAM database table to your database. (Error 3423)

 Copy code hover
[image]

You cannot use ODBC to import from, export to, or link an external Microsoft Jet or ISAM database table to your database. (Error 3423)
Send feedback

You are attempting to link, import data from, or export data to either an external Microsoft Access database engine table or an external ISAM database table (for example, dBASE, Microsoft FoxPro, Paradox, or Btrieve), but you have selected <SQL Database> as the data source. You must select the appropriate data source for the data you are attempting to link.


Report.Height Property (Access)

 Copy code hover
[image]

Report.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Long.

Syntax

expression .Height

expression A variable that represents a Report object.

Remarks

The Height property applies only to form sections and report sections, not to forms and reports.

For report sections, you can't use a macro or Visual Basic to set the Height property when you print or preview a report. For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this propery for an object once the print process has started. For example, attempting to set the Height property in a report's Print event generates an error.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of sections is measured from the inside of their borders. The height of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

Report Object

Other resources

Report Object Members


AffectEnum

 Copy code hover
[image]

AffectEnum
Send feedback

Specifies which records are affected by an operation.

Constant

Value

Description

adAffectAll

3

If there is not a Filter applied to the Recordset, affects all records. If the Filter property is set to a string criteria (such as "Author='Smith'"), then the operation affects visible records in the current chapter. If the Filter property is set to a member of the FilterGroupEnum or an array of Bookmarks, then the operation will affect all rows of the Recordset.

Note Note

adAffectAll is hidden in the Visual Basic Object Browser.

adAffectAllChapters

4

Affects all records in all sibling chapters of the Recordset, including those not visible via any Filter that is currently applied.

adAffectCurrent

1

Affects only the current record.

adAffectGroup

2

Affects only records that satisfy the current Filter property setting. You must set the Filter property to a FilterGroupEnum value or an array of Bookmarks to use this option.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.Affect.ALL

AdoEnums.Affect.ALLCHAPTERS

AdoEnums.Affect.CURRENT

AdoEnums.Affect.GROUP


QueryDef.SQL Property (DAO)

 Copy code hover
[image]

QueryDef.SQL Property (DAO)
Send feedback

Sets or returns the SQL statement that defines the query executed by a QueryDef object.

Syntax

expression .SQL

expression A variable that represents a QueryDef object.

Remarks

The SQL property contains the SQL statement that determines how records are selected, grouped, and ordered when you execute the query. You can use the query to select records to include in a Recordset object. You can also define action queries to modify data without returning records.

The SQL syntax used in a query must conform to the SQL dialect of the query engine, which is determined by the type of workspace. In a Microsoft Access workspace, use the Microsoft Access SQL dialect, unless you create an SQL pass-through query, in which case you should use the dialect of the server.

If the SQL statement includes parameters for the query, you must set these before execution. Until you reset the parameters, the same parameter values are applied each time you execute the query.

In a Microsoft Access workspace, using a QueryDef object is the preferred way to perform SQL pass-through operations on Microsoft Access database engine-connected ODBC data sources. By setting the QueryDef object's Connect property to an ODBC data source, you can use non-Microsoft-Access-database SQL in the query to be passed to the external server. For example, you can use TRANSACT SQL statements (with Microsoft SQL Server or Sybase SQL Server databases), which the Microsoft Access database engine would otherwise not process.

Note Note

If you set the property to a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strSQL = "PRICE > " & lngPrice, and lngPrice = 125,50), an error will result when you try to execute the QueryDef object in a Microsoft Access database engine database. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and Microsoft Access SQL only accepts U.S. decimal characters.

Example

This example demonstrates the SQL property by setting and changing the SQL property of a temporary QueryDef and comparing the results. The SQLOutput function is required for this procedure to run.

VBA Copy code Copy code
Sub SQLX()

   Dim dbsNorthwind As Database
   Dim qdfTemp As QueryDef
   Dim rstEmployees As Recordset

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   Set qdfTemp = dbsNorthwind.CreateQueryDef("")

   ' Open Recordset using temporary QueryDef object and
   ' print report.
   SQLOutput "SELECT * FROM Employees " & _
      "WHERE Country = 'USA' " & _
      "ORDER BY LastName", qdfTemp

   ' Open Recordset using temporary QueryDef object and
   ' print report.
   SQLOutput "SELECT * FROM Employees " & _
      "WHERE Country = 'UK' " & _
      "ORDER BY LastName", qdfTemp

   dbsNorthwind.Close

End Sub

Function SQLOutput(strSQL As String, qdfTemp As QueryDef)

   Dim rstEmployees As Recordset

   ' Set SQL property of temporary QueryDef object and open
   ' a Recordset.
   qdfTemp.SQL = strSQL
   Set rstEmployees = qdfTemp.OpenRecordset

   Debug.Print strSQL

   With rstEmployees
      ' Enumerate Recordset.
      Do While Not .EOF
         Debug.Print "  " & !FirstName & " " & _
            !LastName & ", " & !Country
         .MoveNext
      Loop
      .Close
   End With

End Function

This example uses the CopyQueryDef method to create a copy of a QueryDef from an existing Recordset and modifies the copy by adding a clause to the SQL property. When you create a permanent QueryDef, spaces, semicolons, or linefeeds may be added to the SQL property; these extra characters must be stripped before any new clauses can be attached to the SQL statement.

VBA Copy code Copy code
Function CopyQueryNew(rstTemp As Recordset, _
   strAdd As String) As QueryDef

   Dim strSQL As String
   Dim strRightSQL As String

   Set CopyQueryNew = rstTemp.CopyQueryDef
   With CopyQueryNew
      ' Strip extra characters.
      strSQL = .SQL
      strRightSQL = Right(strSQL, 1)
      Do While strRightSQL = " " Or strRightSQL = ";" Or _
            strRightSQL = Chr(10) Or strRightSQL = vbCr
         strSQL = Left(strSQL, Len(strSQL) - 1)
         strRightSQL = Right(strSQL, 1)
      Loop
      .SQL = strSQL & strAdd
   End With

End Function

This example shows a possible use of CopyQueryNew().

Sub CopyQueryDefX()

   Dim dbsNorthwind As Database
   Dim qdfEmployees As QueryDef
   Dim rstEmployees As Recordset
   Dim intCommand As Integer
   Dim strOrderBy As String
   Dim qdfCopy As QueryDef
   Dim rstCopy As Recordset

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   Set qdfEmployees = dbsNorthwind.CreateQueryDef( _
      "NewQueryDef", "SELECT FirstName, LastName, " & _
      "BirthDate FROM Employees")
   Set rstEmployees = qdfEmployees.OpenRecordset( _
      dbOpenForwardOnly)

   Do While True
      intCommand = Val(InputBox( _
         "Choose field on which to order a new " & _
         "Recordset:" & vbCr & "1 - FirstName" & vbCr & _
         "2 - LastName" & vbCr & "3 - BirthDate" & vbCr & _
         "[Cancel - exit]"))
      Select Case intCommand
         Case 1
            strOrderBy = " ORDER BY FirstName"
         Case 2
            strOrderBy = " ORDER BY LastName"
         Case 3
            strOrderBy = " ORDER BY BirthDate"
         Case Else
            Exit Do
      End Select
      Set qdfCopy = CopyQueryNew(rstEmployees, strOrderBy)
      Set rstCopy = qdfCopy.OpenRecordset(dbOpenSnapshot, _
         dbForwardOnly)
      With rstCopy
         Do While Not .EOF
            Debug.Print !LastName & ", " & !FirstName & _
               " - " & !BirthDate
            .MoveNext
         Loop
         .Close
      End With
      Exit Do
   Loop

   rstEmployees.Close
   ' Delete new QueryDef because this is a demonstration.
   dbsNorthwind.QueryDefs.Delete qdfEmployees.Name
   dbsNorthwind.Close

End Sub

This example uses the CreateQueryDef and OpenRecordset methods and the SQL property to query the table of titles in the Microsoft SQL Server sample database Pubs and return the title and title identifier of the best-selling book. The example then queries the table of authors and instructs the user to send a bonus check to each author based on his or her royalty share (the total bonus is $1,000 and each author should receive a percentage of that amount).

VBA Copy code Copy code
Sub ClientServerX2()

   Dim dbsCurrent As Database
   Dim qdfBestSellers As QueryDef
   Dim qdfBonusEarners As QueryDef
   Dim rstTopSeller As Recordset
   Dim rstBonusRecipients As Recordset
   Dim strAuthorList As String

   ' Open a database from which QueryDef objects can be
   ' created.
   Set dbsCurrent = OpenDatabase("DB1.mdb")

   ' Create a temporary QueryDef object to retrieve
   ' data from a Microsoft SQL Server database.
   Set qdfBestSellers = dbsCurrent.CreateQueryDef("")
   With qdfBestSellers
      ' Note: The DSN referenced below must be configured to
      '       use Microsoft Windows NT Authentication Mode to
      '       authorize user access to the Microsoft SQL Server.
      .Connect = "ODBC;DATABASE=pubs;DSN=Publishers"
      .SQL = "SELECT title, title_id FROM titles " & _
         "ORDER BY ytd_sales DESC"
      Set rstTopSeller = .OpenRecordset()
      rstTopSeller.MoveFirst
   End With

   ' Create a temporary QueryDef to retrieve data from
   ' a Microsoft SQL Server database based on the results from
   ' the first query.
   Set qdfBonusEarners = dbsCurrent.CreateQueryDef("")
   With qdfBonusEarners
      ' Note: The DSN referenced below must be configured to
      '       use Microsoft Windows NT Authentication Mode to
      '       authorize user access to the Microsoft SQL Server.
      .Connect = "ODBC;DATABASE=pubs;DSN=Publishers"
      .SQL = "SELECT * FROM titleauthor " & _
         "WHERE title_id = '" & _
         rstTopSeller!title_id & "'"
      Set rstBonusRecipients = .OpenRecordset()
   End With

   ' Build the output string.
   With rstBonusRecipients
      Do While Not .EOF
         strAuthorList = strAuthorList & "  " & _
            !au_id & ":  $" & (10 * !royaltyper) & vbCr
         .MoveNext
      Loop
   End With

   ' Display results.
   MsgBox "Please send a check to the following " & _
      "authors in the amounts shown:" & vbCr & _
      strAuthorList & "for outstanding sales of " & _
      rstTopSeller!Title & "."

   rstTopSeller.Close
   dbsCurrent.Close

End Sub

The following example shows how to create a parameter query. A query named myQuery is created with two parameters, named Param1 and Param2. To do this, the SQL property of the query is set to a Structured Query Language (SQL) statement that defines the parameters.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Sub CreateQueryWithParameters()

    Dim dbs As DAO.Database
    Dim qdf As DAO.QueryDef
    Dim strSQL As String

    Set dbs = CurrentDb
    Set qdf = dbs.CreateQueryDef("myQuery")
    Application.RefreshDatabaseWindow

    strSQL = "PARAMETERS Param1 TEXT, Param2 INT; "
    strSQL = strSQL & "SELECT * FROM [Table1] "
    strSQL = strSQL & "WHERE [Field1] = [Param1] AND [Field2] = [Param2];"
    qdf.SQL = strSQL

    qdf.Close
    Set qdf = Nothing
    Set dbs = Nothing

End Sub

The following example shows how to replace the Structured Query Language (SQL) statement in a saved query.

VBA Copy code Copy code
Dim qdf as QueryDef
Dim db as Database
Set db = CurrentDB
Set qdf = db.QueryDefs("YourQueryName")
qdf.SQL = ReplaceWhereClause(qdf.SQL, strYourNewWhereClause)
set qdf = Nothing
set db = Nothing

Public Function ReplaceWhereClause(strSQL As Variant, strNewWHERE As Variant)
On Error GoTo Error_Handler

'This subroutine accepts a valid SQL string and Where clause, and
'returns the same SQL statement with the original Where clause (if any)
'replaced by the passed in Where clause.
'
'INPUT:
' strSQL valid SQL string to change
'OUTPUT:
' strNewWHERE New WHERE clause to insert into SQL statement
'
Dim strSELECT As String, strWhere As String
Dim strOrderBy As String, strGROUPBY As String, strHAVING As String

Call ParseSQL(strSQL, strSELECT, strWhere, strOrderBy, _
strGROUPBY, strHAVING)

ReplaceWhereClause = strSELECT &""& strNewWHERE &""_
& strGROUPBY &""& strHAVING &""& strOrderBy

Exit_Procedure:
  Exit Function

Error_Handler:
  MsgBox (Err.Number & ": " & Err.Description)
  Resume Exit_Procedure

End Function

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Parameter Object Reference (DAO)

 Copy code hover
[image]

Parameter Object Reference (DAO)
Send feedback

In this section

  • Parameter Object (DAO)

  • Parameter Members (DAO)

  • Parameter Properties (DAO)


AcPrintPaperSize Enumeration (Access)

 Copy code hover
[image]

AcPrintPaperSize Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the PaperSize property to indicate the paper size to use when printing.

Name | Value | Description
acPRPS10x14 | 16 | 10 x 14 in.
acPRPS11x17 | 17 | 11 x 17 in.
acPRPSA3 | 8 | A3 (297 mm x 420 mm)
acPRPSA4 | 9 | A4 (210 mm x 297 mm)
acPRPSA4Small | 10 | A4 Small (210 mm x 297 mm)
acPRPSA5 | 11 | A5 (148 mm x 210 mm)
acPRPSB4 | 12 | B4 (250 mm x 354 mm)
acPRPSB5 | 13 | B5 (148 mm x 210 mm)
acPRPSCSheet | 24 | C size sheet
acPRPSDSheet | 25 | D size sheet
acPRPSEnv10 | 20 | Envelope #10 (4-1/8 in. x 9-1/2 in.)
acPRPSEnv11 | 21 | Envelope #11 (4-1/2 in. x 10-3/8 in.)
acPRPSEnv12 | 22 | Envelope #12 (4-1/2 in. x 11 in.)
acPRPSEnv14 | 23 | Envelope #14 (5 in. x 11-1/2 in.)
acPRPSEnv9 | 19 | Envelope #9 (3-7/8 in. x 8-7/8 in.)
acPRPSEnvB4 | 33 | Envelope B4 (250 mm x 353 mm)
acPRPSEnvB5 | 34 | Envelope B5 (176 mm x 250 mm)
acPRPSEnvB6 | 35 | Envelope B6 (176 mm x 125 mm)
acPRPSEnvC3 | 29 | Envelope C3 (324 mm x 458 mm)
acPRPSEnvC4 | 30 | Envelope C4 (229 mm x 324 mm)
acPRPSEnvC5 | 28 | Envelope C5 (162 mm x 229 mm)
acPRPSEnvC6 | 31 | Envelope C6 (114 mm x 162 mm)
acPRPSEnvC65 | 32 | Envelope C65 (114 mm x 229 mm)
acPRPSEnvDL | 27 | Envelope DL (110 mm x 220 mm)
acPRPSEnvItaly | 36 | Italian envelope (110 mm x 230 mm)
acPRPSEnvMonarch | 37 | Monarch envelope (3-7/8 in. x 7-1/2 in.)
acPRPSEnvPersonal | 38 | Envelope (3-5/8 in. x 6-1/2 in.)
acPRPSESheet | 26 | E size sheet
acPRPSExecutive | 7 | Executive (7-1/2 in. x 10-1/2 in.)
acPRPSFanfoldLglGerman | 41 | German Legal Fanfold (8-1/2 in. x 13 in.)
acPRPSFanfoldStdGerman | 40 | German Standard Fanfold (8-1/2 in. x 12 in.)
acPRPSFanfoldUS | 39 | U.S. Standard Fanfold (14-7/8 in. x 11 in.)
acPRPSFolio | 14 | Folio (8-1/2 in. x 13 in.)
acPRPSLedger | 4 | Ledger (17 in. x 11 in.)
acPRPSLegal | 5 | Legal (8-1/2 in. x 14 in.)
acPRPSLetter | 1 | Letter (8-1/2 in. x 11 in.)
acPRPSLetterSmall | 2 | Letter Small (8-1/2 in. x 11 in.)
acPRPSNote | 18 | Note (8-1/2 in. x 11 in.)
acPRPSQuarto | 15 | Quarto (215 mm x 275 mm)
acPRPSStatement | 6 | Statement (5-1/2 in. x 8-1/2 in.)
acPRPSTabloid | 3 | Tabloid (11 in. x 17 in.)
acPRPSUser | 256 | User-defined


TextBox.SizeToFit Method (Access)

 Copy code hover
[image]

TextBox.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents a TextBox object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ObjectFrame.Item Property (Access)

 Copy code hover
[image]

ObjectFrame.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns or sets a specific member of a collection. Read/write String.

Syntax

expression .Item

expression A variable that represents an ObjectFrame object.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


CreateRecordset Method (RDS)

 Copy code hover
[image]

CreateRecordset Method (RDS)
Send feedback

Creates an empty, disconnected Recordset.

Syntax

object.CreateRecordset(ColumnInfos)

Parameters

  • Object

  • An object variable that represents an RDSServer.DataFactory or RDS.DataControl object.

  • ColumnsInfos

  • A Variant array of attributes that defines each column in the Recordset created. Each column definition contains an array of four required attributes and one optional attribute. The set of column arrays is then grouped into an array, which defines the Recordset.

    Attribute

    Description

    Name

    Name of the column header.

    Type

    Integer of the data type.

    Size

    Integer of the width in characters, regardless of data type.

    Nullability

    Boolean value.

    Scale
    (Optional)

    This optional attribute defines the scale for numeric fields. If this value is not specified, numeric values will be truncated to a scale of three. Precision is not affected, but the number of digits following the decimal point will be truncated to three.

Remarks

The server-side business object can populate the resulting Recordset with data from a non-OLE DB data provider, such as an operating system file containing stock quotes.

The following table lists the DataTypeEnum values supported by the CreateRecordset method. The number listed is the reference number used to define fields.

Each of the data types is either fixed length or variable length. Fixed-length types should be defined with a size of -1, because the size is predetermined and a size definition is still required. Variable-length data types allow a size from 1 to 32767.

For some of the variable data types, the type may be coerced to the type noted in the Substitution column. You won't see the substitutions until after the Recordset is created and filled. Then you can check for the actual data type, if necessary.

Length | Constant | Number | Substitution
Fixed | adTinyInt | 16 |
Fixed | adSmallInt | 2 |
Fixed | adInteger | 3 |
Fixed | adBigInt | 20 |
Fixed | adUnsignedTinyInt | 17 |
Fixed | adUnsignedSmallInt | 18 |
Fixed | adUnsignedInt | 19 |
Fixed | adUnsignedBigInt | 21 |
Fixed | adSingle | 4 |
Fixed | adDouble | 5 |
Fixed | adCurrency | 6 |
Fixed | adDecimal | 14 |
Fixed | adNumeric | 131 |
Fixed | adBoolean | 11 |
Fixed | adError | 10 |
Fixed | adGuid | 72 |
Fixed | adDate | 7 |
Fixed | adDBDate | 133 |
Fixed | adDBTime | 134 |
Fixed | adDBTimestamp | 135 | 7
Variable | adBSTR | 8 | 130
Variable | adChar | 129 | 200
Variable | adVarChar | 200 |
Variable | adLongVarChar | 201 | 200
Variable | adWChar | 130 |
Variable | adVarWChar | 202 | 130
Variable | adLongVarWChar | 203 | 130
Variable | adBinary | 128 |
Variable | adVarBinary | 204 |
Variable | adLongVarBinary | 205 | 204


OptionButton.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

OptionButton.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents an OptionButton object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.BorderThemeColorIndex=2

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


How to: Hide a Subform if the Main Form Contains No Records

 Copy code hover
[image]

How to: Hide a Subform if the Main Form Contains No Records
Send feedback

The following example illustrates how to hide a subform named Orders_Subform if its main form does not contain any records. The code resides in the main form's Current event procedure.

VBA Copy code Copy code
Private Sub Form_Current()

    With Me![Orders_Subform].Form

        ' Check the RecordCount of the Subform.
        If .RecordsetClone.RecordCount = 0 Then

            ' Hide the subform.
            .Visible = False

        End If
    End With
End Sub


EmptyCell.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

EmptyCell.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthBottom

expression A variable that represents an EmptyCell object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


NavigationControl.GridlineColor Property (Access)

 Copy code hover
[image]

NavigationControl.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified list box. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineColor

expression A variable that represents a NavigationControl object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


OptionButton.Top Property (Access)

 Copy code hover
[image]

OptionButton.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Syntax

expression .Top

expression A variable that represents an OptionButton object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Views Append Method Example (VB)

 Copy code hover
[image]

Views Append Method Example (VB)
Send feedback

The following code demonstrates how to use a Command object and the Views collection Append method to create a new view in the underlying data source.

Copy code Copy code

' BeginCreateViewVB
Sub Main()
 On Error GoTo CreateViewError

 Dim cmd As New ADODB.Command
 Dim cat As New ADOX.Catalog

 ' Open the Catalog
 cat.ActiveConnection = _
 "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\Microsoft Office\" & _
 "Office\Samples\Northwind.mdb';"

 ' Create the command representing the view.
 cmd.CommandText = "Select * From Customers"

 ' Create the new View
 cat.Views.Append "AllCustomers", cmd

 'Clean up
 Set cat.ActiveConnection = Nothing
 Set cat = Nothing
 Set cmd = Nothing
 Exit Sub

CreateViewError:

 Set cat = Nothing
 Set cmd = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndCreateViewVB


EmptyCell.RightPadding Property (Access)

 Copy code hover
[image]

EmptyCell.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .RightPadding

expression A variable that represents an EmptyCell object.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


The database has been placed in a state by an unknown user that prevents it from being opened or locked. (Error 3733)

 Copy code hover
[image]

The database has been placed in a state by an unknown user that prevents it from being opened or locked. (Error 3733)
Send feedback

This error occurs when the new passive shutdown/connection control is being used. This error indicates that another user set the database in a mode that will prevent other users from opening it. It is related to error #3734 and is used when the Microsoft Access database engine cannot determine which user invoked the passive shutdown/connection control.


ImportExportSpecifications Methods (Access)

 Copy code hover
[image]

ImportExportSpecifications Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Add | Adds a new ImportExportSpecification object to the ImportExportSpecifications collection.


ADO Programmer's Reference Topics

 Copy code hover
[image]

ADO Programmer's Reference Topics
Send feedback

In this section

  • ADO API Reference Topics

  • RDS API Reference Topics

  • ADO MD API Reference Topics

  • ADOX API Reference Topics


Databases Members (DAO)

 Copy code hover
[image]

Databases Members (DAO)
Send feedback

A Databases collection contains all open Database objects opened or created in a Workspace object.

Methods

Name | Description
Refresh | Not supported for this object.

Properties

Name | Description
Count | Returns the number of objects in the specified collection. Read-only.


Controls Object (Access)

 Copy code hover
[image]

Controls Object (Access)
See also Send feedback

Published: July 16, 2012

The Controls collection contains all of the controls on a form, report, or subform, within another control, or attached to another control. The Controls collection is a member of a Form , Report , and SubForm objects.

Remarks

You can enumerate individual controls, count them, and set their properties in the Controls collection. For example, you can enumerate the Controls collection of a particular form and set the Height property of each control to a specified value.

It is faster to refer to the Controls collection implicitly, as in the following examples, which refer to a control called NewData on a form named OrderForm. Of the following syntax examples, Me!NewData is the fastest way to refer to the control.

VBA Copy code Copy code
Me!NewData               ' Or Forms!OrderForm!NewData.
VBA Copy code Copy code
Me![New Data]            ' Use if control name contains space.
VBA Copy code Copy code
Me("NewData")            ' Performance is slightly slower.

You can also refer to an individual control by referring explicitly to the Controls collection.

VBA Copy code Copy code
Me.Controls!NewData      ' Or Forms!OrderForm.Controls!NewData.
VBA Copy code Copy code
Me.Controls![New Data]
VBA Copy code Copy code
Me.Controls("NewData")

Additionally, you can refer to a control by its index in the collection. The Controls collection is indexed beginning with zero.

VBA Copy code Copy code
Me(0)                    ' Refer to first item in collection.
VBA Copy code Copy code
Me.Controls(0)
Note Note

You can use the Me keyword to represent a form or report within code only if you're referring to the form or report from code within the form module or report module. If you're referring to a form or report from a standard module or a different form's or report's module, you must use the full reference to the form or report.

To work with the controls on a section of a form or report, use the Section property to return a reference to a Section object. Then refer to the Controls collection of the Section object.

Two types of Control objects, the tab control and option group control, have Controls collections that can contain multiple controls. The Controls collection belonging to the option group control contains any option button, check box, toggle button, or label controls in the option group.

The tab control contains a Pages collection, which is a special type of Controls collection. The Pages collection contains Page objects. Page objects are also controls. The ControlType property constant for a Page control is acPage. A Page object, in turn, has its own Controls collection, which contains all the controls on an individual page.

Other Control objects have a Controls collection that can contain an attached label. These controls include the text box, option group, option button, toggle button, check box, combo box, list box, command button, bound object frame, and unbound object frame controls.

See also

Concepts

Access Object Model Reference

Other resources

Controls Object Members


Windows API

 Copy code hover
[image]

Windows API
Send feedback

In this section

  • How to: Determine When a Shelled Process Ends

  • How to: Retrieve Information from the Clipboard

  • How to: Send Information to the Clipboard

  • How to: Retrieve the Name of the User Logged On To the Network


Recordset (ADO/WFC Syntax)

 Copy code hover
[image]

Recordset (ADO/WFC Syntax)
Send feedback

package com.ms.wfc.data

Constructors

Copy code Copy code

public Invalid DDUE based on source, error:link not allowed in code, link filename:mdobjodbrec_HV10294709.xml()
public Recordset(Object r)

Methods

Copy code Copy code

public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthaddnew_HV10294007.xml(Object[] fieldList, Object[] valueList)
public void addNew(Object[] valueList)
public void addNew()
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthadocancel_HV10294125.xml()
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcancelbatch_HV10294131.xml(int affectRecords)
public void cancelBatch()
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcancelupdate_HV10294132.xml()
public Object Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthclone_HV10294166.xml()
public Object clone(int lockType)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthclose_HV10294173.xml()
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcomparebookmarks_HV10294199.xml(Object bookmark1, Object bookmark2)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthrstdelete_HV10294295.xml(int affectRecords)
public void delete()
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthfindmethodado_HV10294381.xml(String criteria)
public void find(String criteria, int SkipRecords)
public void find(String criteria, int SkipRecords, int searchDirection)
public void find(String criteria, int SkipRecords, int searchDirection, Object bmkStart)
public Object[][] Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthgetrows_HV10294398.xml(int Rows, Object bmkStart, Object[] fieldList)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthmove_HV10294521.xml(int numRecords)
public void move(int numRecords, Object bmkStart)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthmovefirst_HV10294526.xml()
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthmovefirst_HV10294526.xml()
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthmovefirst_HV10294526.xml()
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthmovefirst_HV10294526.xml()
public Recordset Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthnextrec_HV10294541.xml()
public Recordset nextRecordset(int[] recordsAffected)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthrstopen_HV10294566.xml()
public void open(Object source)
public void open(Object source, Object activeConnection)
public void open(Object source, Object activeConnection, int cursorType)
public void open(Object source, Object activeConnection, int cursorType,
 int lockType)public void open(Object source, Object activeConnection, int cursorType,
 int lockType, int options)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthadorequery_HV10294728.xml()
public void requery(int options)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthadoresync_HV10294735.xml()
public void resync(int affectRecords, int resyncValues)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthrstsave_HV10294750.xml(String fileName)
public void save(String fileName, int persistFormat)
public boolean Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthsupports_HV10294844.xml(int cursorOptions)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthupdate_HV10294888.xml()
public void update(Object[] valueList)
public void update(Object[] fieldList, Object[] valueList)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthupdatebatch_HV10294893.xml()
public void updateBatch(int affectRecords)

Properties

Copy code Copy code

public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdproabpage_HV10293970.xml()
public void setAbsolutePage(int page)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdproabpos_HV10293979.xml()
public void setAbsolutePosition(int pos)
public Command Invalid DDUE based on source, error:link not allowed in code, link filename:mdproactivecommand_HV10293982.xml()
public Connection Invalid DDUE based on source, error:link not allowed in code, link filename:mdproactivecon_HV10293988.xml()
public void setActiveConnection(String conn)
public void setActiveConnection(com.ms.wfc.data.Connection c)
public boolean Invalid DDUE based on source, error:link not allowed in code, link filename:mdprobof_HV10294113.xml()
public boolean Invalid DDUE based on source, error:link not allowed in code, link filename:mdprobof_HV10294113.xml()
public Object Invalid DDUE based on source, error:link not allowed in code, link filename:mdprobookmark_HV10294117.xml()
public void setBookmark(Object bmk)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocachesize_HV10294119.xml()
public void setCacheSize(int size)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocursorlocation_HV10294254.xml()
public void setCursorLocation(int cursorLoc)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocursortype_HV10294257.xml()
public void setCursorType(int cursorType)
public String Invalid DDUE based on source, error:link not allowed in code, link filename:mdprodatamember_HV10294276.xml()
public void setDataMember(String pbstrDataMember)
public Iunknown Invalid DDUE based on source, error:link not allowed in code, link filename:mdprodatasource_HV10294277.xml()
public void setDataSource(IUnknown dataSource)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdproeditmode_HV10294326.xml()
public Object Invalid DDUE based on source, error:link not allowed in code, link filename:mdprofilter_HV10294373.xml()
public void setFilter(Object filter)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprolocktype_HV10294487.xml()
public void setLockType(int lockType)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdpromarshaloptions_HV10294491.xml()
public void setMarshalOptions(int options)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdpromaxrecords_HV10294496.xml()
public void setMaxRecords(int maxRecords)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdpropagecount_HV10294585.xml()
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdpropagesize_HV10294586.xml()
public void setPageSize(int pageSize)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprorecordcount_HV10294700.xml()
public String Invalid DDUE based on source, error:link not allowed in code, link filename:mdprosortpropertyado_HV10294782.xml()
public void setSort(String criteria)
public String Invalid DDUE based on source, error:link not allowed in code, link filename:mdprorstsource_HV10294794.xml()
public void setSource(String query)
public void setSource(com.ms.wfc.data.Command command)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprostate_HV10294804.xml()
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprostatus_HV10294810.xml()
public boolean Invalid DDUE based on source, error:link not allowed in code, link filename:mdprostayinsync_HV10294815.xml()
public void setStayInSync(boolean pbStayInSync)
public com.ms.wfc.data.Field Invalid DDUE based on source, error:link not allowed in code, link filename:mdobjfield_HV10294362.xml(int n)
public com.ms.wfc.data.Field getField(String n)
public com.ms.wfc.data.Fields Invalid DDUE based on source, error:link not allowed in code, link filename:mdcolfields_HV10294366.xml()
public AdoProperties Invalid DDUE based on source, error:link not allowed in code, link filename:mdcolproperties_HV10294633.xml()

Events

For more information about ADO/WFC events, see ADO Event Instantiation by Language.

Copy code Copy code

public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtendofrecordset_HV10294329.xml(RecordsetEventHandler handler)
public void removeOnEndOfRecordset(RecordsetEventHandler handler)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtfetchcomplete_HV10294356.xml(RecordsetEventHandler handler)
public void removeOnFetchComplete(RecordsetEventHandler handler)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtfetchprogress_HV10294358.xml(RecordsetEventHandler handler)
public void removeOnFetchProgress(RecordsetEventHandler handler)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillchangefield_HV10294950.xml(RecordsetEventHandler handler)
public void removeOnFieldChangeComplete(RecordsetEventHandler handler)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillmove_HV10294955.xml(RecordsetEventHandler handler)
public void removeOnMoveComplete(RecordsetEventHandler handler)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillchangerecord_HV10294951.xml(RecordsetEventHandler handler)
public void removeOnRecordChangeComplete(RecordsetEventHandler handler)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillchangerecordset_HV10294952.xml(RecordsetEventHandler handler)
public void removeOnRecordsetChangeComplete(RecordsetEventHandler handler)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillchangefield_HV10294950.xml(RecordsetEventHandler handler)
public void removeOnWillChangeField(RecordsetEventHandler handler)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillchangerecord_HV10294951.xml(RecordsetEventHandler handler)
public void removeOnWillChangeRecord(RecordsetEventHandler handler)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillchangerecordset_HV10294952.xml(RecordsetEventHandler handler)
public void removeOnWillChangeRecordset(RecordsetEventHandler handler)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillmove_HV10294955.xml(RecordsetEventHandler handler)
public void removeOnWillMove(RecordsetEventHandler handler)


Form.RecordsetType Property (Access)

 Copy code hover
[image]

Form.RecordsetType Property (Access)
Send feedback

Published: July 16, 2012

You can use the RecordsetType property to specify what kind of recordset is made available to a form. Read/write Byte.

Syntax

expression .RecordsetType

expression A variable that represents an Form object.

Remarks

The RecordsetType property uses the following settings in a Microsoft Access database.

Setting | Type of Recordset | Description
0 | Dynaset | (Default) You can edit bound controls based on a single table or tables with a one-to-one relationship. For controls bound to fields based on tables with a one-to-many relationship, you can't edit data from the join field on the "one" side of the relationship unless cascade update is enabled between the tables
1 | Dynaset (Inconsistent Updates) | All tables and controls bound to their fields can be edited.
2 | Snapshot | No tables or the controls bound to their fields can be edited.
Note Note

If you don't want data in bound controls to be edited when a form is in Form view or Datasheet view, you can set the RecordsetType property to 2.

Note Note

Changing the RecordsetType property of an open form or report causes an automatic recreation of the recordset.

You can create forms based on multiple underlying tables with fields bound to controls on the forms. Depending on the RecordsetType property setting, you can limit which of these bound controls can be edited.

In addition to the editing control provided by RecordsetType, each control on a form has a Locked property that you can set to specify whether the control and its underlying data can be edited. If the Locked property is set to Yes, you can't edit the data.

Example

In the following example, only if the user ID is ADMIN can records be updated. This code sample sets the RecordsetType property to Snapshot if the public variable gstrUserID value is not ADMIN.

VBA Copy code Copy code
Sub Form_Open(Cancel As Integer)
 Const conSnapshot = 2
 If gstrUserID <> "ADMIN" Then
 Forms!Employees.RecordsetType = conSnapshot
 End If
End Sub

Property value

UINT8


NavigationControl.Enter Event (Access)

 Copy code hover
[image]

NavigationControl.Enter Event (Access)
See also Send feedback

Published: July 16, 2012

The Enter event occurs before a control actually receives the focus from a control on the same form or report.

Version Information

Version Added: Access 2010

Syntax

expression .Enter

expression A variable that represents a NavigationControl object.

Return Value

nothing

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when these events occur, set the OnEnter or OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Enter event occurs before the GotFocus event. The Exit event occurs before the LostFocus event.

Unlike the GotFocus and LostFocus events, the Enter and Exit events don't occur when a form receives or loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


User Properties, Methods, and Events (ADOX)

 Copy code hover
[image]

User Properties, Methods, and Events (ADOX)
Send feedback

Properties/Collections

Groups Collection

Name Property

Properties Collection

Methods

ChangePassword Method

GetPermissions Method

SetPermissions Method

Events

None.


Form.HorizontalDatasheetGridlineStyle Property (Access)

 Copy code hover
[image]

Form.HorizontalDatasheetGridlineStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Byte indicating the line style to use for horizontal gridlines on the specified datasheet. Read/write.

Syntax

expression .HorizontalDatasheetGridlineStyle

expression A variable that represents a Form object.

Remarks

Valid values are between zero and seven. Values greater than seven are ignored; negative values or values above 255 cause an error.

Value | Description
0 | Transparent border
1 | Solid
2 | Dashes
3 | Short dashes
4 | Dots
5 | Sparse dots
6 | Dash-dot
7 | Dash-dot-dot

Example

This example sets the horizontal gridline style on the first open form to dash-dot. The form must be set to Datasheet View in order for you to see the change.

VBA Copy code Copy code
Forms(0).HorizontalDatasheetGridlineStyle = 6

See also

Concepts

Form Object

Other resources

Form Object Members


ComboBox.ForeColor Property (Access)

 Copy code hover
[image]

ComboBox.ForeColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ForeColor property to specify the color for text in a control. Read/write Long.

Syntax

expression .ForeColor

expression A variable that represents a ComboBox object.

Remarks

You can use this property for controls on forms or reports to make them easy to read or to convey a special meaning. For example, you can change the color of the text in the UnitsInStock control when its value falls below the reorder level.

You can also use this property on reports to create special visual effects when you print with a color printer. When used on a report, this property specifies the printing and drawing color for the Print , Line , and Circle methods.

The ForeColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors for text in controls.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set the Circle property only by using a macro or a Visual Basic event procedure specified in a section's OnPrint event property setting.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Recordset2.MoveLast Method (DAO)

 Copy code hover
[image]

Recordset2.MoveLast Method (DAO)
Send feedback

Moves to the last record in a specified Recordset object and make that record the current record.

Syntax

expression .MoveLast(Options)

expression A variable that represents a Recordset2 object.

Parameters

Name | Required/Optional | Data Type | Description
Options | Optional | Long | Set to dbRunAsync to rune the call to MoveLast asynchronously.

Remarks

Use the Move methods to move from record to record without applying a condition.

If you edit the current record, be sure you use the Update method to save the changes before you move to another record. If you move to another record without updating, your changes are lost without warning.

When you open a Recordset, the first record is current and the BOF property is False. If the Recordset contains no records, the BOF property is True, and there is no current record.

If the first or last record is already current when you use MoveFirst or MoveLast, the current record doesn't change.

If recordset refers to a table-type Recordset (Microsoft Access workspaces only), movement follows the current index. You can set the current index by using the Index property. If you don't set the current index, the order of returned records is undefined.

Note Note

You can use the MoveLast method to fully populate a dynaset- or snapshot-type Recordset to provide the current number of records in the Recordset. However, if you use MoveLast in this way, you can slow down your application's performance. You should only use MoveLast to get a record count if it is absolutely necessary to obtain an accurate record count on a newly opened Recordset. If you use the dbRunAsync constant with MoveLast, the method call is asynchronous. You can use the StillExecuting property to determine when the Recordset is fully populated, and you can use the Cancel method to terminate execution of the asynchronous MoveLast method call.

You can't use the MoveFirst, MoveLast, and MovePrevious methods on a forward-only-type Recordset object.

To move the position of the current record in a Recordset object a specific number of records forward or backward, use the Move method.


Recordset2.NextRecordset Method (DAO)

 Copy code hover
[image]

Recordset2.NextRecordset Method (DAO)
Send feedback

Syntax

expression .NextRecordset

expression A variable that represents a Recordset2 object.

Return Value

Boolean

Remarks

In an ODBCDirect workspace, you can open a Recordset containing more than one select query in the source argument of OpenRecordset, or the SQL property of a select query QueryDef object, as in the following example.

Copy code Copy code
SELECT LastName, FirstName FROM Authors
WHERE LastName = 'Smith';
SELECT Title, ISBN FROM Titles
WHERE Pub_ID = 9999

The returned Recordset will open with the results of the first query. To obtain the result sets of records from subsequent queries, use the NextRecordset method.

If more records are available (that is, there was another select query in the OpenRecordset call or in the SQL property), the records returned from the next query will be loaded into the Recordset, and NextRecordset will return True, indicating that the records are available. When no more records are available (that is, results of the last select query have been loaded into the Recordset), then NextRecordset will return False, and the Recordset will be empty.

You can also use the Cancel method to flush the contents of a Recordset. However, Cancel also flushes any additional records not yet loaded.

Example

This example uses the NextRecordset method to view the data from a compound SELECT query. The DefaultCursorDriver property must be set to dbUseODBCCursor when executing such queries. The NextRecordset method will return True even if some or all of the SELECT statements return zero records; it will return False only after all the individual SQL clauses have been checked.

VBA Copy code Copy code
Sub NextRecordsetX()

 Dim wrkODBC As Workspace
 Dim conPubs As Connection
 Dim rstTemp As Recordset2
 Dim intCount As Integer
 Dim booNext As Boolean

 ' Create ODBCDirect Workspace object and open Connection
 ' object. The DefaultCursorDriver setting is required
 ' when using compound SQL statements.
 Set wrkODBC = CreateWorkspace("", _
 "admin", "", dbUseODBC)
 wrkODBC.DefaultCursorDriver = dbUseODBCCursor

 ' Note: The DSN referenced below must be set to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conPubs = wrkODBC.OpenConnection("Publishers", , , _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 ' Construct compound SELECT statement.
 Set rstTemp = conPubs.OpenRecordset("SELECT * " & _
 "FROM authors; " & _
 "SELECT * FROM stores; " & _
 "SELECT * FROM jobs")

 ' Try printing results from each of the three SELECT
 ' statements.
 booNext = True
 intCount = 1
 With rstTemp
 Do While booNext
 Debug.Print "Contents of recordset #" & intCount
 Do While Not .EOF
 Debug.Print , .Fields(0), .Fields(1)
 .MoveNext
 Loop
 booNext = .NextRecordset
 Debug.Print " rstTemp.NextRecordset = " & _
 booNext
 intCount = intCount + 1
 Loop
 End With

 rstTemp.Close
 conPubs.Close
 wrkODBC.Close

End Sub

Another way to accomplish the same task would be to create a prepared statement containing the compound SQL statement. The CacheSize property of the QueryDef object must be set to 1, and the Recordset object must be forward-only and read-only.

VBA Copy code Copy code
Sub NextRecordsetX2()

 Dim wrkODBC As Workspace
 Dim conPubs As Connection
 Dim qdfTemp As QueryDef
 Dim rstTemp As Recordset2
 Dim intCount As Integer
 Dim booNext As Boolean

 ' Create ODBCDirect Workspace object and open Connection
 ' object. The DefaultCursorDriver setting is required
 ' when using compound SQL statements.
 Set wrkODBC = CreateWorkspace("", _
 "admin", "", dbUseODBC)
 wrkODBC.DefaultCursorDriver = dbUseODBCCursor

 ' Note: The DSN referenced below must be set to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conPubs = wrkODBC.OpenConnection("Publishers", , , _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 ' Create a temporary stored procedure with a compound
 ' SELECT statement.
 Set qdfTemp = conPubs.CreateQueryDef("", _
 "SELECT * FROM authors; " & _
 "SELECT * FROM stores; " & _
 "SELECT * FROM jobs")
 ' Set CacheSize and open Recordset object with arguments
 ' that will allow access to multiple recordsets.
 qdfTemp.CacheSize = 1
 Set rstTemp = qdfTemp.OpenRecordset(dbOpenForwardOnly, _
 dbReadOnly)

 ' Try printing results from each of the three SELECT
 ' statements.
 booNext = True
 intCount = 1
 With rstTemp
 Do While booNext
 Debug.Print "Contents of recordset #" & intCount
 Do While Not .EOF
 Debug.Print , .Fields(0), .Fields(1)
 .MoveNext
 Loop
 booNext = .NextRecordset
 Debug.Print " rstTemp.NextRecordset = " & _
 booNext
 intCount = intCount + 1
 Loop
 End With

 rstTemp.Close
 qdfTemp.Close
 conPubs.Close
 wrkODBC.Close

End Sub


Documents.Refresh Method (DAO)

 Copy code hover
[image]

Documents.Refresh Method (DAO)
Send feedback

Updates the objects in the specified colletion to reflect the database's current schema.

Syntax

expression .Refresh

expression A variable that represents a Documents object.

Remarks

Use the Refresh method in multiuser environments in which other users may change the database. You may also need to use it on any collections that are indirectly affected by changes to the database. For example, if you change a Users collection, you may need to refresh a Groups collection before using the Groups collection.

A collection is filled with objects the first time it's referred to and won't automatically reflect subsequent changes other users make. If it's likely that another user has changed a collection, use the Refresh method on the collection immediately before carrying out any task in your application that assumes the presence or absence of a particular object in the collection. This will ensure that the collection is as up-to-date as possible. On the other hand, using Refresh can unnecessarily slow performance.


CommandButton.OnKeyDown Property (Access)

 Copy code hover
[image]

CommandButton.OnKeyDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Down box in the Properties window. Read/write String.

Syntax

expression .OnKeyDown

expression A variable that represents a CommandButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyDown event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyDown

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Image.DisplayWhen Property (Access)

 Copy code hover
[image]

Image.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Syntax

expression .DisplayWhen

expression A variable that represents an Image object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

Image Object

Other resources

Image Object Members


Key Properties, Methods, and Events (ADOX)

 Copy code hover
[image]

Key Properties, Methods, and Events (ADOX)
Send feedback

Properties/Collections

Columns Collection

DeleteRule Property

Name Property

RelatedTable Property

Type Property (Key)

UpdateRule Property

Methods

None.

Events

None.


Application.EuroConvert Method (Access)

 Copy code hover
[image]

Application.EuroConvert Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the EuroConvert function to convert a number to euro or from euro to a participating currency. You can also use it to convert a number from one participating currency to another by using the euro as an intermediary (triangulation). The EuroConvert function uses fixed conversion rates established by the European Union.

Syntax

expression .EuroConvert(Number, SourceCurrency, TargetCurrency, FullPrecision, TriangulationPrecision)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Number | Required | Double | The number you want to convert, or a reference to a field containing the number.
SourceCurrency | Required | String | A string expression, or reference to a field containing the string, corresponding to the International Standards Organization (ISO) acronym for the currency you want to convert. Can be one of the ISO codes listed in the Remarks section.
TargetCurrency | Required | String | A string expression, or reference to a field containing the string, corresponding to the ISO code of the currency to which you want to convert the number. For a list of ISO codes, see the Remarks section.
FullPrecision | Optional | Variant | A Boolean value where True (1) ignores the currency-specific rounding rules (called display precision in sourcecurrency argument description) and uses the 6-significant-digit conversion factor with no follow-up rounding. False (0) uses the currency-specific rounding rules to display the result. If the parameter is omitted, the default value is False.
TriangulationPrecision | Optional | Variant | An Integer value greater than or equal to 3 that specifies the number of significant digits in the calculation precision used for the intermediate euro value when converting between two national currencies.

Return Value

Double

Remarks

The following table contains the ISO codes that can be used with the SourceCurrency and TargetCurrency arguments.

Currency | ISO Code | Calculation Precision | Display Precision
Belgian franc | BEF | 0 | 0
Luxembourg franc | LUF | 0 | 0
Deutsche mark | DEM | 2 | 2
Spanish peseta | ESP | 0 | 0
French franc | FRF | 2 | 2
Irish punt | IEP | 2 | 2
Italian lira | ITL | 0 | 0
Netherlands guilder | NLG | 2 | 2
Austrian schilling | ATS | 2 | 2
Portuguese escudo | PTE | 0 | 0
Finnish Markka | FIM | 2 | 2
euro | EUR | 2 | 2

In the preceding table, the calculation precision determines what currency unit to round the result to based on the conversion currency. For example, when converting to Deutsche marks, the calculation precision is 2, and the result is rounded to the nearest pfennig, 100 pfennigs to a mark. The display precision determines how many decimal places appear in the field containing the result.

Later versions of the EuroConvert function may support additional currencies. For information about new participating currencies and updates to the EuroConvert function, see the Microsoft Office Euro Currency Web site.

Currency | ISO Code
Danish Krone | DKK
Drachma | GRD
Swedish Krona | SEK
Pound Sterling | GBP

Any trailing zeros are truncated and invalid parameters return #Error.

If the source ISO code is the same as the target ISO code, the original value of the number is active.

This function does not apply a format.

The EuroConvert function uses the current rates established by the European Union. If the rates change, Microsoft will update the function. To get full information about the rules and the rates currently in effect, see the European Commission publications about the euro. For information about obtaining these publications, see the Microsoft Office Euro Currency Web site.

Example

The first example converts 1.20 Deutsche marks to a euro dollar value (answer = 0.61). The second example converts 1.47 French francs to Deutsche marks (answer = 0.44 DM). They assume conversion rates of 1 euro = 6.55858 French francs and 1.92974 Deutsche marks.

VBA Copy code Copy code
EuroConvert(1.20,"DEM","EUR")
EuroConvert(1.47,"FRF","DEM",TRUE,3)

See also

Concepts

Application Object

Other resources

Application Object Members


Report.FontName Property (Access)

 Copy code hover
[image]

Report.FontName Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontName property to specify the font for text in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write String.

Syntax

expression .FontName

expression A variable that represents a Report object.

Remarks

The FontName property setting is the name of the font that the text is displayed in.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set this property only in an event procedure or in a macro specified by the OnPrint event property setting.

Font availability depends on your system and printer. If you select a font that your system can't display or that isn't installed, Windows substitutes a similar font.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


AbsolutePosition and CursorLocation Properties Example (VJ++)

 Copy code hover
[image]

AbsolutePosition and CursorLocation Properties Example (VJ++)
Send feedback

This example demonstrates how the AbsolutePosition property can track the progress of a loop that enumerates all the records of a Recordset. It uses the CursorLocation property to enable the AbsolutePosition property by setting the cursor to a client cursor.

Copy code Copy code

// BeginAboslutePositionJ
import com.ms.wfc.data.*;
import java.io.*;

public class AbsolutePositionX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 AbsolutePositionX();
 System.exit(0);
 }

 //.AbsolutePositionX function

 static void AbsolutePositionX()
 {

 // define ADO Objects.
 Recordset rstEmployees = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));
 String line = null;
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';" +
 "Initial Catalog='Pubs';Integrated Security='SSPI';";

 String strLName;
 String strMessage;
 String strAbsolutePosition,strRecordCount;
 int intAbsolutePosition;
 int intRecordCount;
 int intChoice;

 try
 {

 rstEmployees = new Recordset();

 // Use client cursor to enable AbsolutePosition property.
 rstEmployees.setCursorLocation( AdoEnums.CursorLocation.CLIENT);

 // Open a recordset for Employees table using a client cursor.
 rstEmployees.open("employee", strCnn,
 AdoEnums.CursorType.FORWARDONLY ,
 AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TABLE);

 // Enumerate Recordset.
 while ( !rstEmployees.getEOF()) // continuous loop
 {
 intRecordCount = rstEmployees.getRecordCount();
 strRecordCount = Integer.toString(intRecordCount);

 // Read data field in the variables.
 strLName = rstEmployees.getField("lname").getString();
 intAbsolutePosition = rstEmployees.getAbsolutePosition();
 strAbsolutePosition = Integer.toString(intAbsolutePosition);

 // Display current record information.
 strMessage = "\nEmployee: " + strLName + "\n" + "(Record " +
 strAbsolutePosition + " of " +strRecordCount + " )";
 System.out.println(strMessage);
 System.out.println(
 "\nDo you want to continue (1 -> Yes / 2 -> No)?");
 //user types a number followed by enter (cr-lf).
 line = in.readLine().trim();
 intChoice = Integer.parseInt(line);
 if ( intChoice != 1)
 break;
 rstEmployees.moveNext();
 }
 }

 catch( NumberFormatException ne)
 {
 System.out.println("\nException : Integer Input required.");
 System.exit(0);
 }

 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // Check for null pointer for connection object.
 if (rstEmployees.getActiveConnection()== null)
 System.out.println("Exception: " + ae.getMessage());
 // As passing a Recordset, check for null pointer first.
 if (rstEmployees != null)
 {
 PrintProviderError(rstEmployees.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstEmployees != null)
 if (rstEmployees.getState() == 1)
 rstEmployees.close();
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 //.PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}

// EndAbsolutePositionJ


Columns and Tables Append Methods, Name Property Example (VB)

 Copy code hover
[image]

Columns and Tables Append Methods, Name Property Example (VB)
Send feedback

The following code demonstrates how to create a new table.

Copy code Copy code

' BeginCreateTableVB
Sub Main()
 On Error GoTo CreateTableError

 Dim tbl As New Table
 Dim cat As New ADOX.Catalog

 ' Open the Catalog.
 cat.ActiveConnection = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\Microsoft Office\" & _
 "Office\Samples\Northwind.mdb';"

 tbl.Name = "MyTable"
 tbl.Columns.Append "Column1", adInteger
 tbl.Columns.Append "Column2", adInteger
 tbl.Columns.Append "Column3", adVarWChar, 50
 cat.Tables.Append tbl
 Debug.Print "Table 'MyTable' is added."

 'Delete the table as this is a demonstration.
 cat.Tables.Delete tbl.Name
 Debug.Print "Table 'MyTable' is deleted."

 'Clean up
 Set cat.ActiveConnection = Nothing
 Set cat = Nothing
 Set tbl = Nothing
 Exit Sub

CreateTableError:

 Set cat = Nothing
 Set tbl = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndCreateTableVB


Form.OnConnect Event (Access)

 Copy code hover
[image]

Form.OnConnect Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when the specified PivotTable view connects to a data source.

Syntax

expression .OnConnect

expression A variable that represents a Form object.

Return Value

nothing

Example

The following example demonstrates the syntax for a subroutine that traps the OnConnect event.

VBA Copy code Copy code
Private Sub Form_OnConnect()
 MsgBox "The PivotTable View has " _
 & "connected to its data source!"
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Introduction to ADO Programming

 Copy code hover
[image]

Introduction to ADO Programming
Send feedback

The ADO Programmer's Guide has been created to assist developers who are new to ADO by giving them a thorough introduction to the technology. This guide describes the libraries of the ADO family and uses sample code in a variety of languages to explain how to use the libraries, best practices for using the libraries, and tips and tricks for maximizing the performance of your ADO application.

The ADO Programmer's Guide contains the following sections and chapters:

  • Section I: ActiveX Data Objects (ADO)

    • Chapter 1: ADO Fundamentals

    • Chapter 2: Getting Data

    • Chapter 3: Examining Data

    • Chapter 4: Editing Data

    • Chapter 5: Updating and Persisting Data

    • Chapter 6: Error Handling

    • Chapter 7: Handling ADO Events

    • Chapter 8: Understanding Cursors and Locks

    • Chapter 9: Data Shaping

    • Chapter 10: Records and Streams

  • Section II: Remote Data Service (RDS)

    • Chapter 11: RDS Fundamentals

    • Chapter 12: RDS Tutorial

    • Chapter 13: RDS Usage and Security

  • Section III: ActiveX Data Objects (Multidimensional) (ADOMD)

    • Chapter 14: ADO MD Fundamentals

  • Section IV: ActiveX Data Objects Extensions for Data Definition Language and Security (ADOX)

    • Chapter 15: ADOX Fundamentals

  • Section V: Appendixes

    • Appendix A: Providers

    • Appendix B: ADO Errors

    • Appendix C: Programming with ADO

    • Appendix D: ADO Samples

  • ADO Glossary


CustomControl.ControlTipText Property (Access)

 Copy code hover
[image]

CustomControl.ControlTipText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.

Syntax

expression .ControlTipText

expression A variable that represents a CustomControl object.

Remarks

You set the ControlTipText property by using a string expression up to 255 characters long.

For controls on forms, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

You can set the ControlTipText property in any view.

The ControlTipText property provides an easy way to provide helpful information about controls on a form.

There are other ways to provide information about a form or a control on a form. You can use the StatusBarText property to display information in the status bar about a control. To provide more extensive help for a form or control, use the HelpFile and HelpContextID properties.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Field Properties, Methods, and Events (ADO)

 Copy code hover
[image]

Field Properties, Methods, and Events (ADO)
Send feedback

Properties/Collections

ActualSize Property

Attributes Property

DefinedSize Property

Name Property

NumericScale Property

OriginalValue Property

Precision Property

Properties Collection

Status Property (ADO Field)

Type Property

UnderlyingValue Property

Value Property

Methods

AppendChunk Method

GetChunk Method

Events

None.


ObjectFrame.Controls Property (Access)

 Copy code hover
[image]

ObjectFrame.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Syntax

expression .Controls

expression A variable that represents an ObjectFrame object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


MacroError Members (Access)

 Copy code hover
[image]

MacroError Members (Access)
Send feedback

Published: July 16, 2012

Represents the properties of a run-time error that occurs in a macro.

Properties

Name | Description
ActionName | Gets the name of the macro action that was executing when an error occurred. Read-only.
Arguments | Gets the arguments specified for the macro action that was executing when an error occurred. Read-only String.
Condition | Gets the condition of the macro action that was executing when an error occurred. Read-only String.
Description | Gets the text that represents the current error message. Read-only String.
MacroName | Gets the name of the macro that was running when an error occurred. Read-only String.
Number | Gets the current error number. Read-only Long.


Cannot perform cascading operation. It would cause field

 Copy code hover
[image]

Cannot perform cascading operation. It would cause field <name> to become a zero-length string, which is not allowed. (Error 3402)
Send feedback

The cascade operation you are attempting would result in a zero-length string in the indicated field, which is set up to not allow zero-length strings. Check the values you are attempting to update and fix them so they do not result in zero-length strings in this field.


Report.PictureTiling Property (Access)

 Copy code hover
[image]

Report.PictureTiling Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureTiling property to specify whether a background picture is tiled across the entire image control, Form window, form, or page of a report. Read/write Boolean.

Syntax

expression .PictureTiling

expression A variable that represents a Report object.

Remarks

The PictureTiling property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The picture is tiled.
No | False | (Default) The picture isn't tiled.

You can also set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

You can create interesting effects by placing a picture on a form or report and setting the PictureTiling property to Yes. The alignment of the tiled images is affected by the PictureAlignment property setting. For example, if the PictureTiling property is set to Top Left, tiling begins at the top left of the image control, Form window, or page of a report.

If the PictureAlignment property is set to Form Center and the PictureTiling property is set to Yes, the background picture of a form will be tiled across the form, not across the Form window.

See also

Concepts

Report Object

Other resources

Report Object Members


Form.Current Event (Access)

 Copy code hover
[image]

Form.Current Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when the focus moves to a record, making it the current record, or when the form is refreshed or requeried.

Syntax

expression .Current

expression A variable that represents a Form object.

Remarks

To run a macro or event procedure when this event occurs, set the OnCurrent property to the name of the macro or to [Event Procedure].

This event occurs both when a form is opened and whenever the focus leaves one record and moves to another. Microsoft Access runs the Current macro or event procedure before the first or next record is displayed.

By running a macro or event procedure when a form's Current event occurs, you can display a message or synchronize records in another form related to the current record. For example, when a customer record becomes current, you can display the customer's previous order. When a supplier record becomes current, you can display the products manufactured by the supplier in a Suppliers form. You can also perform calculations based on the current record or change the form in response to data in the current record.

If your macro or event procedure runs a GoToControl or GoToRecord action or the corresponding method of the DoCmd object in response to an Open event, the Current event occurs.

The Current event also occurs when you refresh a form or requery the form's underlying table or query— for example, when you click Remove Filter/Sort on the Records menu or use the Requery action in a macro or the Requery method in Visual Basic code.

When you first open a form, the following events occur in this order:

Open → Load → Resize → Activate → Current

Example

In the following example, a Current event procedure checks the status of an option button called Discontinued. If the button is selected, the example sets the background color of the ProductName field to red to indicate that the product has been discontinued.

To try the example, add the following event procedure to a form that contains an option called Discontinued and a text box called ProductName.

VBA Copy code Copy code
Private Sub Form_Current()
 If Me!Discontinued Then
 Me!ProductName.BackColor = 255
 EndIf
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Recordset2.LastUpdated Property (DAO)

 Copy code hover
[image]

Recordset2.LastUpdated Property (DAO)
Send feedback

Returns the date and time of the most recent change made to a base table. Read-only Variant.

Syntax

expression .LastUpdated

expression A variable that represents a Recordset2 object.

Remarks

The date and time settings are derived from the computer on which the base table was created or last updated.


Report.OnClick Property (Access)

 Copy code hover
[image]

Report.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnClick

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the report's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Catalog" report, if there is currently no association.

VBA Copy code Copy code
With Reports("Catalog").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

Report Object

Other resources

Report Object Members


SharedResources Object (Access)

 Copy code hover
[image]

SharedResources Object (Access)
See also Send feedback

Published: July 16, 2012

Represents the collection of shared resources in the database.

Version Information

Version Added: Access 2010

Remarks

The SharedResources collection contains Microsoft Office themes and images that are stored once, but used throughout the database.

For example, you may want to display your company logo on every form that you create. In earlier versions of Access, you had to import the logo into every form. In Microsoft Access 2013, you can add the logo as a shared image. Then , it will be displayed in the Image Gallery that is displayed when you click the Insert Image dropdown menu for the Controls group in the Design tab.

Use the Resources property of the CodeProject object or the Resources property of the CurrentProject object to enumerate the SharedResources collection.

To import an image as a SharedResource object, use the AddSharedImage method of the CodeProject object or the AddSharedImage method of the CurrentProject object.

See also

Concepts

Access Object Model Reference

Other resources

SharedResources Object Members


Modules.Count Property (Access)

 Copy code hover
[image]

Modules.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents a Modules object.

See also

Concepts

Modules Collection

Other resources

Modules Object Members


ODBC -- data out of range. (Error 3238)

 Copy code hover
[image]

ODBC -- data out of range. (Error 3238)
Send feedback

Using an ODBC connection, you tried to read from or write to an ODBC database, and the data is not within the prescribed limits.


Attachment.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

Attachment.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified attachment. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthBottom

expression A variable that represents an Attachment object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Item Property (ADO MD Cellset)

 Copy code hover
[image]

Item Property (ADO MD Cellset)
Send feedback

Retrieves a cell from a cellset using its coordinates.

Syntax

Set Cell = Cellset.Item (Positions)

Parameters

  • Positions

  • A Variant Array of values that uniquely specify a cell. Positions can be one of the following:

    • An array of position numbers

    • An array of member names

    • The ordinal position

Remarks

Use the Item property to return a Cell object within a Cellset object. If the Item property cannot find the cell corresponding to the Positions argument, an error occurs.

The Item property is the default property for the Cellset object. The following syntax forms are interchangeable:

Copy code Copy code
Cellset.Item ( Positions )
Cellset ( Positions )

The Positions argument specifies which cell to return. You can specify the cell by ordinal position or by the position along each axis. When specifying the cell by position along each axis, you can specify the numeric value of the position or the names of the members for each position.

The ordinal position is a number that uniquely identifies one cell within the Cellset. Conceptually, cells are numbered in a Cellset as if the Cellset were a p-dimensional array, where p is the number of axes. Cells are addressed in row-major order.

If member names are passed as strings to Item, the members must be listed in increasing order of the numeric axis identifiers. Within an axis, the members must be listed in increasing order of dimension nesting — that is, the outermost dimension's member comes first, followed by members of inner dimensions. Each dimension should be represented by a separate string, and the list of member strings should be separated by commas.

Note Note

Retrieving cells by member name may not be supported by your data provider. See the documentation for your provider for more information.


Application.ExportXML Method (Access)

 Copy code hover
[image]

Application.ExportXML Method (Access)
See also Send feedback

Published: July 16, 2012

The ExportXML method allows developers to export XML data, schemas, and presentation information from Microsoft SQL Server 2000 Desktop Engine (MSDE 2000), Microsoft SQL Server 6.5 or later, or the Microsoft Access database engine.

Syntax

expression .ExportXML(ObjectType, DataSource, DataTarget, SchemaTarget, PresentationTarget, ImageTarget, Encoding, OtherFlags, WhereCondition, AdditionalData)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
ObjectType | Required | AcExportXMLObjectType | A AcExportXMLObjectType that represents the type of AccessObject object to export.
DataSource | Required | String | The name of the AccessObject object to export. The default is the currently open object of the type specified by the ObjectType argument.
DataTarget | Optional | String | The file name and path for the exported data. If this argument is omitted, data is not exported.
SchemaTarget | Optional | String | The file name and path for the exported schema information. If this argument is omitted, schema information is not exported to a separate XML file.
PresentationTarget | Optional | String | The file name and path for the exported presentation information. If this argument is omitted, presentation information is not exported.
ImageTarget | Optional | String | The path for exported images. If this argument is omitted, images are not exported.
Encoding | Optional | AcExportXMLEncoding | A AcExportXMLEncoding constant that specifies the text encoding to use for the exported XML. The default value is acUTF8.
OtherFlags | Optional | AcExportXMLOtherFlags | A bit mask that specifies other behaviors associated with exporting to XML. Can be a combination of AcExportXMLOtherFlags constants.
WhereCondition | Optional | String | Specifies a subset of records to be exported.
AdditionalData | Optional | Variant | Specifies additional tables to export. This argument is ignored if the OtherFlags argument is set to acLiveReportSource.

Return Value

Nothing

Remarks

Although the DataTarget, SchemaTarget, and PresentationTarget arguments are all optional, at least one must be specified when you are using this method. When the ExportXML method is called from within an AccessObject object, the default behavior is to overwrite any existing files specified in any of the arguments.

Example

The following example exports the contents of the Customers table in the Northwind Traders sample database, along with the contents of the Orders and Orders Details tables, to an XML data file named Customer Orders.xml.

VBA Copy code Copy code
Sub ExportCustomerOrderData()
 Dim objOrderInfo As AdditionalData
 Dim objOrderDetailsInfo As AdditionalData

 Set objOrderInfo = Application.CreateAdditionalData

 ' Add the Orders and Order Details tables to the data to be exported.
 Set objOrderDetailsInfo = objOrderInfo.Add("Orders")
 objOrderDetailsInfo.Add "Order Details"

 ' Export the contents of the Customers table. The Orders and Order
 ' Details tables will be included in the XML file.
 Application.ExportXML ObjectType:=acExportTable, DataSource:="Customers", _
 DataTarget:="Customer Orders.xml", _
 AdditionalData:=objOrderInfo
End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


ReturnVars.Count Property (Access)

 Copy code hover
[image]

ReturnVars.Count Property (Access)
Send feedback

Published: July 16, 2012

Gets the number of ReturnVar objects in the ReturnVars collection. Read-only Long.

Version Information

Version Added: Access 2010

Syntax

expression .Count

expression A variable that represents a ReturnVars object.


FieldStatusEnum

 Copy code hover
[image]

FieldStatusEnum
Send feedback

Specifies the status of a Field object.

The adFieldPending* values indicate the operation that caused the status to be set, and may be combined with other status values.

Constant | Value | Description
adFieldAlreadyExists | 26 | Indicates that the specified field already exists.
adFieldBadStatus | 12 | Indicates that an invalid status value was sent from ADO to the OLE DB provider. Possible causes include an OLE DB 1.0 or 1.1 provider, or an improper combination of Value and Status.
adFieldCannotComplete | 20 | Indicates that the server of the URL specified by Source could not complete the operation.
adFieldCannotDeleteSource | 23 | Indicates that during a move operation, a tree or subtree was moved to a new location, but the source could not be deleted.
adFieldCantConvertValue | 2 | Indicates that the field cannot be retrieved or stored without loss of data.
adFieldCantCreate | 7 | Indicates that the field could not be added because the provider exceeded a limitation (such as the number of fields allowed).
adFieldDataOverflow | 6 | Indicates that the data returned from the provider overflowed the data type of the field.
adFieldDefault | 13 | Indicates that the default value for the field was used when setting data.
adFieldDoesNotExist | 16 | Indicates that the field specified does not exist.
adFieldIgnore | 15 | Indicates that this field was skipped when setting data values in the source. The provider set no value.
adFieldIntegrityViolation | 10 | Indicates that the field cannot be modified because it is a calculated or derived entity.
adFieldInvalidURL | 17 | Indicates that the data source URL contains invalid characters.
adFieldIsNull | 3 | Indicates that the provider returned a VARIANT value of type VT_NULL and that the field is not empty.
adFieldOK | 0 | Default. Indicates that the field was successfully added or deleted.
adFieldOutOfSpace | 22 | Indicates that the provider is unable to obtain enough storage space to complete a move or copy operation.
adFieldPendingChange | 0x40000 | Indicates either that the field has been deleted and then re-added, perhaps with a different data type, or that the value of the field that previously had a status of adFieldOK has changed. The final form of the field will modify the Fields collection after the Update method is called.
adFieldPendingDelete | 0x20000 | Indicates that the Delete operation caused the status to be set. The field has been marked for deletion from the Fields collection after the Update method is called.
adFieldPendingInsert | 0x10000 | Indicates that the Append operation caused the status to be set. The Field has been marked to be added to the Fields collection after the Update method is called.
adFieldPendingUnknown | 0x80000 | Indicates that the provider cannot determine what operation caused field status to be set.
adFieldPendingUnknownDelete | 0x100000 | Indicates that the provider cannot determine what operation caused field status to be set, and that the field will be deleted from the Fields collection after the Update method is called.
adFieldPermissionDenied | 9 | Indicates that the field cannot be modified because it is defined as read-only.
adFieldReadOnly | 24 | Indicates that the field in the data source is defined as read-only.
adFieldResourceExists | 19 | Indicates that the provider was unable to perform the operation because an object already exists at the destination URL and it is not able to overwrite the object.
adFieldResourceLocked | 18 | Indicates that the provider was unable to perform the operation because the data source is locked by one or more other application or process.
adFieldResourceOutOfScope | 25 | Indicates that a source or destination URL is outside the scope of the current record.
adFieldSchemaViolation | 11 | Indicates that the value violated the data source schema constraint for the field.
adFieldSignMismatch | 5 | Indicates that data value returned by the provider was signed but the data type of the ADO field value was unsigned.
adFieldTruncated | 4 | Indicates that variable-length data was truncated when reading from the data source.
adFieldUnavailable | 8 | Indicates that the provider could not determine the value when reading from the data source. For example, the row was just created, the default value for the column was not available, and a new value had not yet been specified.
adFieldVolumeNotFound | 21 | Indicates that the provider is unable to locate the storage volume indicated by the URL.

ADO/WFC Equivalent

These constants do not have ADO/WFC equivalents.


Syntax error in DROP TABLE or DROP INDEX. (Error 3295)

 Copy code hover
[image]

Syntax error in DROP TABLE or DROP INDEX. (Error 3295)
Send feedback

You entered an SQL statement that has an invalid DROP statement.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


Control.TopPadding Property (Access)

 Copy code hover
[image]

Control.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the control and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .TopPadding

expression A variable that represents a Control object.

See also

Concepts

Control Object

Other resources

Control Object Members


AcBrowseToObjectType Enumeration (Access)

 Copy code hover
[image]

AcBrowseToObjectType Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the type of object to browse to.

Version Information

Version Added: Access 2010

Name | Value | Description
acBrowseToForm | 2 | Open a form.
acBrowseToReport | 3 | Open a report.


CommandButton.BorderShade Property (Access)

 Copy code hover
[image]

CommandButton.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents a CommandButton object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


SetReturnVar Macro Action

 Copy code hover
[image]

SetReturnVar Macro Action
Send feedback

The SetReturnVar action creates a return variable and sets it to a specific value.

Note Note

The SetReturnVar action is available only in Data Macros.

Setting

The SetReturnVar action has the following arguments.

Argument | Required | Description
Name | Yes | A string that specifies the name of the variable.
Expression | Yes | An expression that will be used to set the value for this temporary variable. Do not precede the expression with the equal sign (=). You can click the Build button to use the Expression Builder to set this argument.

Remarks

The SetReturnVar action is used to create a ReturnVar, which is variable that can be used by macros that call a data macro by using the RunDataMacro action.

Once a ReturnVar is created by the SetReturnVar action, the calling macro can use it in an expression. For example, if you created a ReturnVar named UpdateSuccess, you could use the variable by using the following syntax:

Copy code Copy code
=[ReturnVars]![UpdateSuccess]

The SetReturnVar action can be used only in named data macros. It is not available in data macros that are attached to a data macro event.

Example

The following example shows how to use the SetReturnVar action to return a value from a named data macro. A ReturnVar named CurrentServiceRequest is returned to the macro or Visual Basic for Applications (VBA) subroutine that called the named data macro.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

Copy code Copy code
RunDataMacro
    Macro Name tblServiceRequests.dmGetCurrentServiceRequest

Parameters
    prmAssignedTo =[ID]

SetProperty
    Control Name txtCurrentSR
    Property Value
    Value =[ReturnVars]![CurrentServiceRequest]

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


NavigationControl.GridlineStyleTop Property (Access)

 Copy code hover
[image]

NavigationControl.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleTop

expression A variable that represents a NavigationControl object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Cannot use Memo or OLE Object field

 Copy code hover
[image]

Cannot use Memo or OLE Object field <name> in the SELECT clause of a union query. (Error 3364)
Send feedback

A field you specified in the SELECT part of a union query in the SQL statement for the query has a field data type of Memo or OLE object. You cannot specify a field of either of these types.


Values specified in a TOP clause are not allowed in delete queries or reports. (Error 3318)

 Copy code hover
[image]

Values specified in a TOP clause are not allowed in delete queries or reports. (Error 3318)
Send feedback

Top values, that is, those specified in a TOP clause of a SELECT statement, are not allowed in delete queries or in reports.


How to: Set Properties of ActiveX Data Objects in Visual Basic

 Copy code hover
[image]

How to: Set Properties of ActiveX Data Objects in Visual Basic
Send feedback

ActiveX Data Objects (ADO) enable you to manipulate the structure of your database and the data it contains from Visual Basic. Many ADO objects correspond to objects that you see in your database—for example, a Table object corresponds to a Microsoft Access table. A Field object corresponds to a field in a table.

Most of the properties you can set for ADO objects are ADO properties. These properties are defined by the Microsoft Access database engine and are set the same way in any application that includes the Access database engine. Some properties that you can set for ADO objects are defined by Microsoft Access, and are not automatically recognized by the Access database engine. How you set properties for ADO objects depends on whether a property is defined by the Access database engine or by Microsoft Access.

Setting ADO Properties for ADO Objects

To set a property that is defined by the Access database engine, refer to the object in the ADO hierarchy. The easiest and fastest way to do this is to create object variables that represent the different objects you need to work with, and refer to the object variables in subsequent steps in your code. For example, the following code creates a new TableDef object and sets its Name property:

Copy code Copy code
Dim tbl As New ADOX.Table
Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
tbl.Name = "Contacts"

Setting Microsoft Access Properties for ADO Objects

When you set a property that is defined by Microsoft Access, but applies to an ADO object, the Access database engine does not automatically recognize the property as a valid property. The first time you set the property, you must create the property and append it to the Properties collection of the object to which it applies. Once the property is in the Properties collection, it can be set in the same manner as any ADO property.

If the property is set for the first time in the user interface, it is automatically added to the Properties collection, and you can set it normally.

When writing procedures to set properties defined by Microsoft Access, you should include error-handling code to verify that the property you are setting already exists in the Properties collection.

Keep in mind that when you create the property, you must correctly specify its Type property before you append it to the Properties collection. You can determine the Type property based on the information in the Settings section of the Help topic for the individual property. The following table provides some guidelines for determining the setting of the Type property.

If the property setting is | Then the Type property setting should be
A string | adLongVarWChar or adVarWChar
True/False | adBoolean
An integer | adInteger

The following table lists some Microsoft Access-defined properties that apply to ADO objects.

ADO object | Microsoft Access-defined properties
Connection | AppTitle, AppIcon, StartupShowDBWindow, StartupShowStatusBar, AllowShortcutMenus, AllowFullMenus, AllowBuiltInToolbars, AllowToolbarChanges, AllowBreakIntoCode, AllowSpecialKeys, Replicable, ReplicationConflictFunction
Table | DatasheetBackColor, DatasheetCellsEffect, DatasheetFontHeight, DatasheetFontItalic, DatasheetFontName, DatasheetFontUnderline, DatasheetFontWeight, DatasheetForeColor, DatasheetGridlinesBehavior, DatasheetGridlinesColor, Description, FrozenColumns, RowHeight, ShowGrid
Field | Caption, ColumnHidden, ColumnOrder, ColumnWidth, DecimalPlaces, Description, Format, InputMask


EditRecord Data Block (Access 2013 custom web app)

 Copy code hover
[image]

EditRecord Data Block (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

You can use the EditRecord data block to change the values contained in an existing record.

Note Note

The EditRecord data block is available only in Data Macros.

Setting

The EditRecord data block has the following arguments.

Argument | Description
Alias | A string that identifies the record to edit. If the Alias argument is not specified, then the current record is edited.

Remarks

After the EditRecord statement, you can insert a block of commands that will execute before the changes to the record are committed. The following actions are available in an EditRecord data block.

CancelRecordChange Macro Action

Comment Macro Statement

Group Macro Statement

If...Then...Else Macro Statement

SetField Macro Action

SetLocalVar Macro Action

Use the SetField action to specify the new values of a field in the edited record.

You can use an If...Then...Else statement to perform operations based on a condition.

To cancel the editing of a record, use the CancelRecordChange action. This prevents the changes from being committed and exits the EditRecord data block.

You can use the LastCreateRecordIdentity local variable to work with last record created in a CreateRecord data block. For example, use the following syntax to refer to the AssignedTo field of the most recently created record:

Copy code Copy code
[LastCreateRecordIdentity].[AssignedTo]


Hybrid Commands

 Copy code hover
[image]

Hybrid Commands
Send feedback

Hybrid commands are partially parameterized commands. For example:

Copy code Copy code

SHAPE {select * from plants}
 APPEND( {select * from customers where country = ?}
 RELATE PlantCountry TO PARAMETER 0,
 PlantRegion TO CustomerRegion )

The caching behavior for a hybrid command is the same as that of regular parameterized commands.


DoCmd.OpenFunction Method (Access)

 Copy code hover
[image]

DoCmd.OpenFunction Method (Access)
See also Send feedback

Published: July 16, 2012

Opens a user-defined function in a Microsoft SQL Server database for viewing in Microsoft Access.

Syntax

expression .OpenFunction(FunctionName, View, DataMode)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
FunctionName | Required | Variant | The name of the function to open.
View | Optional | AcView | A AcView constant that specifies the view in which to open the function. The default value is acViewNormal.
DataMode | Optional | AcOpenDataMode | A AcOpenDataMode constant that specifies the mode in which to open the function. The default value is acEdit.

Remarks

Use the AllFunctions collection to retrieve information about the available user-defined functions in a SQL Server database.

Example

The following example opens the first user-defined function in the current database in Design View and read-only mode.

VBA Copy code Copy code
Dim objFunction As AccessObject
Dim strFunction As String

Set objFunction = Application.AllFunctions(0)

DoCmd.OpenFunction FunctionName:=objFunction.Name, _
 View:=acViewDesign, Mode:=acReadOnly

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


NavigationButton.GridlineWidthRight Property (Access)

 Copy code hover
[image]

NavigationButton.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthRight

expression A variable that represents a NavigationButton object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


OpenSchema Method (ADO)

 Copy code hover
[image]

OpenSchema Method (ADO)
Send feedback

Obtains database schema information from the provider .

Syntax

Set recordset = connection.OpenSchema (QueryType, Criteria, SchemaID)

Return Values

Returns a Recordset object that contains schema information. The Recordset will be opened as a read-only, static cursor . The QueryType determines what columns appear in the Recordset.

Parameters

  • QueryType

  • Any SchemaEnum value that represents the type of schema query to run.

  • Criteria

  • Optional. An array of query constraints for each QueryType option, as listed in SchemaEnum.

  • SchemaID

  • The GUID for a provider-schema query not defined by the OLE DB specification. This parameter is required if QueryType is set to adSchemaProviderSpecific; otherwise, it is not used.

Remarks

The OpenSchema method returns self-descriptive information about the data source, such as what tables are in the data source, the columns in the tables, and the data types supported.

The QueryType argument is a GUID that indicates the columns (schemas) returned. The OLE DB specification has a full list of schemas.

The Criteria argument limits the results of a schema query. Criteria specifies an array of values that must occur in a corresponding subset of columns, called constraint columns, in the resulting Recordset.

The constant adSchemaProviderSpecific is used for the QueryType argument if the provider defines its own nonstandard schema queries outside those listed above. When this constant is used, the SchemaID argument is required to pass the GUID of the schema query to execute. If QueryType is set to adSchemaProviderSpecific but SchemaID is not provided, an error will result.

Providers are not required to support all of the OLE DB standard schema queries. Specifically, only adSchemaTables, adSchemaColumns, and adSchemaProviderTypes are required by the OLE DB specification. However, the provider is not required to support the Criteria constraints listed above for those schema queries.

Remote Data Service UsageThe OpenSchema method is not available on a client-side Connection object.

Note Note

In Visual Basic, columns that have a four-byte unsigned integer (DBTYPE UI4) in the Recordset returned from the OpenSchema method on the Connection object cannot be compared to other variables. For more information about OLE DB data types, see Chapter 13 and Appendix A of the Microsoft OLE DB Programmer's Reference.


 Copy code hover
[image]

<Path> is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides. (Error 3044)
Send feedback

Possible causes:

  • You entered an invalid file specification that contains an invalid path. For example, you might have entered a path that does not exist or misspelled an element in the path specification.

  • The specified file is on a network drive and you are not connected to that drive. Make sure the network is available, and then try the operation again.


Hyperlink Members (Access)

 Copy code hover
[image]

Hyperlink Members (Access)
Send feedback

Published: July 16, 2012

The Hyperlink object represents a hyperlink associated with a control on a form, report, or data access page.

Methods

Name | Description
AddToFavorites | The AddToFavorites method adds a hyperlink address to the Favorites folder.
CreateNewDocument | You can use the CreateNewDocument method to create a new document associated with a specified hyperlink.
Follow | The Follow method opens the document or Web page specified by a hyperlink address associated with a control on a form or report.

Properties

Name | Description
Address | You can use the Address property to specify or determine the path to an object, document, Web page or other destination for a Hyperlink object associated with a command button, image control, or label control. Read/write String.
EmailSubject | You can use the EmailSubject property to specify or determine return the email subject line of a hyperlink to an object, document, Web page or other destination for a command button, image control, or label control. Read/write String.
ScreenTip | You can use the ScreenTip property to specify or determine the text that is displayed when you move the cursor over a hyperlink control. Read/write String.
SubAddress | You can use the SubAddress property to specify or determine a location within the target document specified by the Address property. Read/write String. .
TextToDisplay | You can use the TextToDisplay property to specify or determine the display text for a hyperlink. Read/write String.


WebBrowserControl.SpecialEffect Property (Access)

 Copy code hover
[image]

WebBrowserControl.SpecialEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .SpecialEffect

expression A variable that represents a WebBrowserControl object.

Remarks

The SpecialEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | 0 | The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised | 1 | The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken | 2 | The object has a shadow on the top and left and a highlight on the bottom and right.
Etched | 3 | The object has a sunken line surrounding the control.
Shadowed | 4 | The object has a shadow below and to the right of the control.
Chiseled | 5 | The object has a sunken line below the control.

The SpecialEffect property setting affects related property settings for the BorderStyle , BorderColor , and BorderWidth properties. For example, if the SpecialEffect property is set to Raised, the settings for the BorderStyle, BorderColor, and BorderWidth properties are ignored. In addition, changing or setting the BorderStyle, BorderColor, and BorderWidth properties may cause Microsoft Access to change the SpecialEffect property setting to Flat.

Note Note

When you set the SpecialEffect property of a text box to Shadowed, the vertical height of the text display area is reduced. You can adjust the Height property of the text box to increase the size of the text display area.

Example

The following example sets the appearance of the text box "OrganizationName1" on the "Mailing List" form to raised.

VBA Copy code Copy code
Forms("Mailing List").Controls("OrganizationName1").SpecialEffect = 1

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Access denied at destination dropbox folder. (Error 3562)

 Copy code hover
[image]

Access denied at destination dropbox folder. (Error 3562)
Send feedback

Check to see if you have permissions for the drive where the destination dropbox folder resides.


UserEmailAddress Function (Access 2013 custom web app)

 Copy code hover
[image]

UserEmailAddress Function (Access 2013 custom web app)
Send feedback

Returns the email address of the current user.

Syntax

UserEmailAddress()

Remarks

The UserEmailAddress function is available only in user interface (UI) macros.


Hyperlink.TextToDisplay Property (Access)

 Copy code hover
[image]

Hyperlink.TextToDisplay Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TextToDisplay property to specify or determine the display text for a hyperlink. Read/write String.

Syntax

expression .TextToDisplay

expression A variable that represents a Hyperlink object.

Example

The following example displays the words "Go to Home page" as an active hyperlink in the label named "Label20" on the "Suppliers" form. Clicking the hyperlink takes the user to the address specified in the label's HyperlinkAddress property.

VBA Copy code Copy code
Forms.Item("Suppliers").Controls.Item("Label20").Hyperlink. _
 TextToDisplay = "Go to Home page"

See also

Concepts

Hyperlink Object

Other resources

Hyperlink Object Members


Version Property (ADO)

 Copy code hover
[image]

Version Property (ADO)
Send feedback

Indicates the ADO version number.

Return Value

Returns a String value that indicates the version.

Remarks

Use the Version property to return the version number of the ADO implementation.

The version of the provider will be available as a dynamic property in the Properties collection.


ActiveX Control

 Copy code hover
[image]

ActiveX Control
Send feedback

Published: July 16, 2012

In addition to the built-in controls that appear in the toolbox, Microsoft Access supports ActiveX controls (formerly known as custom or OLE controls). An ActiveX control, like a built-in control, is an object that you place on a form to enable or enhance a user's interaction with an application. ActiveX controls have events and can be incorporated into other controls. These controls usually have an .dll or .ocx file name extension. The Calendar control is an example of an ActiveX control.


ListBox.GridlineThemeColorIndex Property (Access)

 Copy code hover
[image]

ListBox.GridlineThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineThemeColorIndex

expression A variable that represents a ListBox object.

Remarks

The GridlineThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 (Default) | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the GridlineThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


There are several tables with that name. Please specify owner in the format 'owner.table'. (Error 3298)

 Copy code hover
[image]

There are several tables with that name. Please specify owner in the format 'owner.table'. (Error 3298)
Send feedback

More than one table with that name exists in the remote ODBC data source. To resolve the ambiguity, specify the owner of the table you want to access, using the owner.table syntax.


Record length is too long for an indexed Paradox table. (Error 3608)

 Copy code hover
[image]

Record length is too long for an indexed Paradox table. (Error 3608)
Send feedback

An indexed Paradox table has a maximum record length of 1350 bytes. Try reducing the size of some Text or Memo fields.


Label.BackTint Property (Access)

 Copy code hover
[image]

Label.BackTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackTint

expression A variable that represents a Label object.

Remarks

The BackTint property contains a numeric expression that can be used to lighten the theme color in the BackColor property. The default value of the BackTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackTint=25

See also

Concepts

Label Object

Other resources

Label Object Members


ObjectFrame Members (Access)

 Copy code hover
[image]

ObjectFrame Members (Access)
Send feedback

Published: July 16, 2012

This object corresponds to an unbound object frame. The unbound object frame control displays a picture, chart, or any OLE object not stored in a table.

Events

Name | Description
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.
Updated | The Updated event occurs when an OLE object's data has been modified.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Properties

Name | Description
Action | You can use the Action property in Visual Basic to specify the operation to perform on an OLE object. Read/write Integer.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoActivate | You can use the AutoActivate property to specify how the user can activate an OLE object. Read/write Integer.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the object frame and its bottom gridline. Read/write Integer.
Class | You can use the Class property to specify or determine the class name of an embeddedOLE object. Read/write String.
ColumnCount | You can use the ColumnCount property to specify the number of columns displayed in a list box or in the list box portion of a combo box, or sent to OLE objects in a chart control or unbound object frame . Read/write Integer.
ColumnHeads | You can use the ColumnHeads property to display a single row of column headings for list boxes, combo boxes, and OLE objects that accept column headings. You can also use this property to create a label for each entry in a chart control . What is actually displayed as the first-row column heading depends on the object's RowSourceType property setting. Read/write Boolean.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayType | You can use the DisplayType property to specify whether Microsoft Access displays an OLE object's content or an icon. Read/write Boolean.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
GridlineColor | Gets or sets the color of the gridline for the specified object frame. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified frame. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified frame. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified frame. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified frame. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified frame. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified frame. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified frame. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified frame. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the object frame is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Item | The Item property returns or sets a specific member of a collection. Read/write String.
Layout | Returns the type of layout for the specified object frame. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified object frame. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the object frame and its left gridline. Read/write Integer.
LinkChildFields | You can use the LinkChildFields property (along with the LinkMasterFields property) together to specify how Microsoft Access links records in a form or report to records in a subform, subreport, or embedded object, such as a chart. If these properties are set, Microsoft Access automatically updates the related record in the subform when you change to a new record in a main form. Read/write String.
LinkMasterFields | You can use the LinkMasterFields property (along with the LinkChildFields property) together to specify how Microsoft Access links records in a form or report to records in a subform, subreport, or embedded object, such as a chart. If these properties are set, Microsoft Access automatically updates the related record in the subform when you change to a new record in a main form. Read/write String.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Object | You can use the Object property in Visual Basic to return a reference to the ActiveX object that is associated with a linked or embedded OLE object in a control. By using this reference, you can access the properties or invoke the methods of the OLE object. Read-only Object.
ObjectPalette | The ObjectPalette property specifies the palette in the application used to create an OLE object. Read/write Variant.
ObjectVerbs | You can use the ObjectVerbs property in Visual Basic to determine the list of verbs an OLE object supports. Read-only String.
ObjectVerbsCount | You can use the ObjectVerbsCount property in Visual Basic to determine the number of verbs supported by an OLE object. Read-only Long.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OLEClass | You can use the OLEClass property to obtain a description of the kind of OLE object contained in a chart control or an unbound object frame. Read-only String.
OLEType | You can use the OLEType property to determine if a control contains an OLE object, and, if so, whether the object is linked or embedded. Read/write Byte.
OLETypeAllowed | You can use the OLETypeAllowed property to specify the type of OLE object a control can contain. Read/write Byte.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnUpdated | Sets or returns the value of the On Updated box in the Properties window of a form or report. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
RightPadding | Gets or sets the amount of space (in inches) between the object frame and its right gridline. Read/write Integer.
RowSource | You can use the RowSource property (along with the RowSourceType property) to tell Microsoft Access how to provide data tothe specified object. Read/write String.
RowSourceType | You can use the RowSourceType property (along with the RowSource property) to tell Microsoft Access how to provide data tothe specified object. Read/write String.
Scaling | Controls how the contents of an object frame control are displayed. Read/write Byte.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SizeMode | You can use the SizeMode property to specify how to size a picture or other object in a bound object frame, an unbound object frame, or an image control.
SourceDoc | You can use the SourceDoc property to specify the file to create a link to or to embed when you create a linked object or embedded object by using the Action property in Visual Basic. Read/write String.
SourceItem | You can use the SourceItem property to specify the data within a file to be linked when you create a linked OLE object. Read/write String.
SourceObject | You can use this property for linked unbound object frames to determine the complete path and file name of the file that contains the data linked to the object frame. Read-only String.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the object frame and its top gridline. Read/write Integer.
UpdateMethod | This property has been deprecated. Use the UpdateOptions property to specify how a linkedOLE object is updated.
UpdateOptions | You can use the UpdateOptions property to specify how a linkedOLE object is updated. Read/write Integer.
VarOleObject | Gets a pointer to an IOLEObject that represents the memory address of an OLE object. Read-only Variant.
Verb | You can use the Verb property to specify the operation to perform when an OLE object is activated, which is permitted when the control'sAction property is set to acOLEActivate. Read/write Long.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified object frame is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


Recordset.FindLast Method (DAO)

 Copy code hover
[image]

Recordset.FindLast Method (DAO)
Send feedback

Locates the last record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only).

Syntax

expression .FindLast(Criteria)

expression A variable that represents a Recordset object.

Parameters

Name | Required/Optional | Data Type | Description
Criteria | Required | String | A String used to locate the record. It is like the WHERE clause in an SQL statement, but without the word WHERE.

Remarks

If you want to include all the records in your search — not just those that meet a specific condition — use the Move methods to move from record to record. To locate a record in a table-type Recordset, use the Seek method.

If a record matching the criteria isn't located, the current record pointer is unknown, and the NoMatch property is set to True. If recordset contains more than one record that satisfies the criteria, FindFirst locates the first occurrence, FindNext locates the next occurrence, and so on.

Each of the Find methods begins its search from the location and in the direction specified in the following table.

Find method | Begins searching at | Search direction
FindFirst | Beginning of recordset | End of recordset
FindLast | End of recordset | Beginning of recordset
FindNext | Current record | End of recordset
FindPrevious | Current record | Beginning of recordset

When you use the FindLast method, the Microsoft Access database engine fully populates your Recordset before beginning the search, if this hasn't already happened.

Using one of the Find methods isn't the same as using a Move method, however, which simply makes the first, last, next, or previous record current without specifying a condition. You can follow a Find operation with a Move operation.

Always check the value of the NoMatch property to determine whether the Find operation has succeeded. If the search succeeds, NoMatch is False. If it fails, NoMatch is True and the current record isn't defined. In this case, you must position the current record pointer back to a valid record.

Using the Find methods with Microsoft Access database engine-connected ODBC-accessed recordsets can be inefficient. You may find that rephrasing your criteria to locate a specific record is faster, especially when working with large recordsets.

When working with Microsoft Access database engine-connected ODBC databases and large dynaset-type Recordset objects, you might discover that using the Find methods or using the Sort or Filter property is slow. To improve performance, use SQL queries with customized ORDER BY or WHERE clauses, parameter queries, or QueryDef objects that retrieve specific indexed records.

You should use the U.S. date format (month-day-year) when you search for fields containing dates, even if you're not using the U.S. version of the Microsoft Access database engine; otherwise, the data may not be found. Use the Visual Basic Format function to convert the date. For example:

VBA Copy code Copy code
rstEmployees.FindFirst "HireDate > #" _
    & Format(mydate, 'm-d-yy' ) & "#"

If criteria is composed of a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strSQL = "PRICE > " & lngPrice, and lngPrice = 125,50), an error occurs when you try to call the method. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and Microsoft Access SQL only accepts U.S. decimal characters.

Note Note

  • For best performance, the criteria should be in either the form "field = value" where field is an indexed field in the underlying base table, or "field LIKE prefix" where field is an indexed field in the underlying base table and prefix is a prefix search string (for example, "ART*" ).

  • In general, for equivalent types of searches, the Seek method provides better performance than the Find methods. This assumes that table-type Recordset objects alone can satisfy your needs.


NavigationButton.KeyUp Event (Access)

 Copy code hover
[image]

NavigationButton.KeyUp Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Version Information

Version Added: Access 2010

Syntax

expression .KeyUp(KeyCode, Shift)

expression A variable that represents a NavigationButton object.

Parameters

Name | Required/Optional | Data Type | Description
KeyCode | Required | Integer |
Shift | Required | Integer |

Return Value

nothing

Remarks

To run a macro or event procedure when these events occur, set the OnKeyUp property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyUp event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyUp event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Image.OnDblClick Property (Access)

 Copy code hover
[image]

Image.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Syntax

expression .OnDblClick

expression A variable that represents an Image object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_DblClick" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

Image Object

Other resources

Image Object Members


EOS and LineSeparator Properties and SkipLine Method Example (VB)

 Copy code hover
[image]

EOS and LineSeparator Properties and SkipLine Method Example (VB)
Send feedback

This example demonstrates how to manipulate text streams one line at a time. The effect of changing the line separator from the default carriage return/linefeed (adCRLF) to simply linefeed (adLF) or carriage return (adCR) is shown.

Copy code Copy code

'BeginSkipLineVB
Private Sub cmdSkipLine_Click()
 On Error GoTo ErrorHandler

 'Declare variables
 Dim i As Integer
 Dim objStream As Stream
 Dim strLine, strChar As String

 'Instantiate and open stream
 Set objStream = New Stream
 objStream.Open

 'Set line separator to line feed
 objStream.LineSeparator = adLF

 'Load text content of list box into stream
 'One line at a time
 For i = 0 To (List1.ListCount - 1)
 objStream.WriteText List1.List(i), adWriteLine
 Next

 'Display the entire stream
 Debug.Print "Whole Stream:"
 objStream.Position = 0
 Debug.Print objStream.ReadText

 'Display the first line
 Debug.Print "First Line:"
 objStream.Position = 0
 strLine = objStream.ReadText(adReadLine)
 Debug.Print strLine
 Debug.Print "Line length: " + Str(Len(strLine))

 'Skip a line, then display another line
 Debug.Print "Third Line:"
 objStream.SkipLine
 strLine = objStream.ReadText(adReadLine)
 Debug.Print strLine
 Debug.Print "Line length: " + Str(Len(strLine))

 'Switch line separator to carriage return
 'All items from list will be considered one line
 'Assuming no CRs have been loaded into stream
 Debug.Print "Whole Stream/First Line:"
 objStream.Position = 0
 objStream.LineSeparator = adCR
 strLine = objStream.ReadText(adReadLine)
 Debug.Print strLine
 Debug.Print "Line length: " + Str(Len(strLine))
 Debug.Print "Stream size: " + Str(objStream.Size)

 'Use EOS to Determine End of Stream
 Debug.Print "Character by character:"
 objStream.Position = 0
 Do Until objStream.EOS
 strChar = objStream.ReadText(1)
 Debug.Print strChar
 Loop

 ' clean up
 objStream.Close
 Set objStream = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not objStream Is Nothing Then
 If objStream.State = adStateOpen Then objStream.Close
 End If
 Set objStream = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub

Private Sub Form_Load()
 List1.AddItem "This is the first line"
 List1.AddItem "This is the second line"
 List1.AddItem "This is the third line"
End Sub
'EndSkipLineVB


NavigationButton.BorderStyle Property (Access)

 Copy code hover
[image]

NavigationButton.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .BorderStyle

expression A variable that represents a NavigationButton object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Label.ForeThemeColorIndex Property (Access)

 Copy code hover
[image]

Label.ForeThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ForeThemeColorIndex

expression A variable that represents a Label object.

Remarks

The ForeThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the ForeThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Fore Color to the Text 2 color by setting the ForeThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.ForeThemeColorIndex=2

See also

Concepts

Label Object

Other resources

Label Object Members


Form.DatasheetBackColor Property (Access)

 Copy code hover
[image]

Form.DatasheetBackColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DatasheetBackColor property in Visual Basic to specify or determine the background color of an entire table, query, or form in Datasheet view within a Microsoft Access database. Read/write Long.

Syntax

expression .DatasheetBackColor

expression A variable that represents a Form object.

Remarks

The following setting information applies to both Microsoft Access database and Access projects (.adp):

Setting the DatasheetBackColor property for a table or query won't affect this property setting for a form that uses the table or query as its source of data.

The following table contains the properties that don't exist in the DAO Properties collection of until you set them by using the Formatting (Datasheet) toolbar or you can add them in an Access database by using the CreateProperty method and append it to the DAO Properties collection.

DatasheetBackColor | DatasheetFontUnderline *
DatasheetCellsEffect | DatasheetFontWeight *
DatasheetFontHeight * | DatasheetForeColor*
DatasheetFontItalic * | DatasheetGridlinesBehavior
DatasheetFontName * | DatasheetGridlinesColor
Note Note

When you add or set any property listed with an asterisk, Microsoft Access automatically adds it to the Properties collection.

Example

The following example uses the SetTableProperty procedure to set a table's font color to dark blue and its background color to light gray. If a "Property not found" error occurs when the property is set, the CreateProperty method is used to add the property to the object's Properties collection.

VBA Copy code Copy code
Dim dbs As Object, objProducts As Object
Const lngForeColor As Long = 8388608 ' Dark blue.
Const lngBackColor As Long = 12632256 ' Light gray.
Const DB_Long As Long = 4
Set dbs = CurrentDb
Set objProducts = dbs!Products
SetTableProperty objProducts, "DatasheetBackColor", DB_Long, lngBackColor
SetTableProperty objProducts, "DatasheetForeColor", DB_Long, lngForeColor

Sub SetTableProperty(objTableObj As Object, strPropertyName As String, _
 intPropertyType As Integer, varPropertyValue As Variant)
 Const conErrPropertyNotFound = 3270
 Dim prpProperty As Variant
 On Error Resume Next ' Don't trap errors.
 objTableObj.Properties(strPropertyName) = varPropertyValue
 If Err <> 0 Then ' Error occurred when value set.
 If Err <> conErrPropertyNotFound Then
 ' Error is unknown.
 MsgBox "Couldn't set property '" & strPropertyName _
 & "' on table '" & tdfTableObj.Name & "'", vbExclamation, Err.Description
 Err.Clear
 Else
 ' Error is "Property not found", so add it to collection.
 Set prpProperty = objTableObj.CreateProperty(strPropertyName, _
 intPropertyType, varPropertyValue)
 objTableObj.Properties.Append prpProperty
 Err.Clear
 End If
 End If
 objTableObj.Properties.Refresh
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


BoundObjectFrame.Move Method (Access)

 Copy code hover
[image]

BoundObjectFrame.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a BoundObjectFrame object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Form.OnUnload Property (Access)

 Copy code hover
[image]

Form.OnUnload Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Unload box in the Properties window of a form. Read/write String.

Syntax

expression .OnUnload

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Unload event occurs after a form is closed but before it's removed from the screen.

The OnUnload value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Unload box in the form's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Unload box is blank, the property value is an empty string.

Example

The following example prints the value of the OnUnload property in the Immediate window for the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").OnUnload

See also

Concepts

Form Object

Other resources

Form Object Members


Section.BackThemeColorIndex Property (Access)

 Copy code hover
[image]

Section.BackThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackThemeColorIndex

expression A variable that represents a Section object.

Remarks

The BackThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BackThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Background Color to the Text 2 color by setting the BackThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BackThemeColorIndex=2

See also

Concepts

Section Object

Other resources

Section Object Members


ComboBox.RightPadding Property (Access)

 Copy code hover
[image]

ComboBox.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the combo box and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .RightPadding

expression A variable that represents a ComboBox object.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Application.Printers Property (Access)

 Copy code hover
[image]

Application.Printers Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Printers collection representing all the available printers on the current system. Read-only Printers collection.

Syntax

expression .Printers

expression A variable that represents an Application object.

Example

The following example displays information about all the printers available on the current system.

VBA Copy code Copy code
Dim prtLoop As Printer

For Each prtLoop In Application.Printers
 With prtLoop
 MsgBox "Device name: " & .DeviceName & vbCr _
 & "Driver name: " & .DriverName & vbCr _
 & "Port: " & .Port
 End With
Next prtLoop

See also

Concepts

Application Object

Other resources

Application Object Members


Report.Count Property (Access)

 Copy code hover
[image]

Report.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Integer.

Syntax

expression .Count

expression A variable that represents a Report object.

See also

Concepts

Report Object

Other resources

Report Object Members


CancelRecordChange Macro Action

 Copy code hover
[image]

CancelRecordChange Macro Action
Send feedback

You can use the CancelRecordChange action to cancel the changes applied to a record in a CreateRecord or EditRecord data block before the changes are committed.

Note Note

The CancelRecordChange action is available only in Data Macros.

Remarks

When you call the CancelRecordChange action, the CreateRecord or EditRecord data block is exited immediately.


Invalid SQL Syntax: expected token: ACTION. (Error 3762)

 Copy code hover
[image]

Invalid SQL Syntax: expected token: ACTION. (Error 3762)
Send feedback

This error occurs when defining referential integrity constraints through the CREATE TABLE syntax or the ALTER TABLE ALTER COLUMN syntax. It occurs when the keyword NO is not followed by the keyword ACTION. For example, by omitting the BOLD ON keyword, the following would generate the error:

CREATE TABLE OrderDetail (OrderId LONG CONSTRAINT fkOrdersOrderId REFERENCES Orders (OrderId) ON UPDATE CASCADE ON DELETE NO ACTION, LineItem LONG, ProductID LONG CONSTRAINT fkProductsProductId REFERENCES Products (ProductId), Quantity LONG);


Handling Errors In Other Languages

 Copy code hover
[image]

Handling Errors In Other Languages
Send feedback

So far, this chapter has discussed errors from a Microsoft Visual Basic point of view. The remainder of this section will give you an overview of error handling in languages other than Visual Basic.


Chapter 10: Records and Streams

 Copy code hover
[image]

Chapter 10: Records and Streams
Send feedback

ADO currently provides theRecordset object as the primary means of accessing information in data sources, such as relational databases. However, some providers support the Record and Stream objects as alternative or complementary objects with which data from providers can be manipulated. For specifics on Record behavior, see your provider's documentation.

Records

Record objects essentially function as one-row Recordsets. However, Records have limited functionality compared to Recordsets and they have different properties and methods.The source for the data in a Record object can be a command which returns one row of data from the provider. Using Record objects rather than Recordset objects to receive the results from a query that returns one row of data eliminates the overhead of instantiating the more complex Recordset object.

Record objects can serve another purpose, particularly with providers for data sources other than traditional relational databases, such as the Microsoft OLE DB Provider for Internet Publishing. Much of the information that must be processed exists, not as tables in databases, but as messages in electronic mail systems and files in modern file systems. The Record and Stream objects facilitate access to information stored in sources other than relational databases.

The Record object can represent and manage data such as directories and files in a file system or folders and messages in an e-mail system. For these purposes, the source for the Record can be the current row of an open Recordset, an absolute URL, or a relative URL in conjunction with an open Connection object.

Typically, a Recordset can be used to represent a container or parent in a hierarchy such as a folder or directory. A Record can be used to return specific information about one node in the parent container, such as a file or document. The primary reason Records are used to represent this type of information is that these sources of data are heterogenous. This means that each Record may have a different set and number of fields. Traditional Recordsets containing rows from a database are homogenous, which means that each row has the same number and type of fields.

For more information about using the Record object for processing this heterogeneous data from providers such as the Internet Publishing Provider, see Using ADO for Internet Publishing.

Streams

The Stream object provides the means to read, write, and manage a stream of bytes. This byte stream may be text or binary and is limited in size only by system resources. Typically, ADO Stream objects are used for the following purposes:

  • To contain the text or bytes that comprise a file or message, typically used with providers such as the Microsoft OLE DB Provider for Internet Publishing. For more information about this use of Stream objects, see Using ADO for Internet Publishing.

A Stream object can be opened on:

  • A simple file specified with a URL.

  • A field of a Record or Recordset containing a Stream object.

  • The default stream of a Record or Recordset object representing a directory or compound file.

  • A resource field containing the URL of a simple file.

  • No particular source at all. In this case, a Stream object is opened in memory. Data can be written to it and then saved in another Stream or file.

  • A BLOB field in a Recordset.


Cell Properties, Methods, and Events (ADO MD)

 Copy code hover
[image]

Cell Properties, Methods, and Events (ADO MD)
Send feedback

Properties/Collections

FormattedValue Property

Ordinal Property (Cell)

Positions Collection

Properties Collection

Value Property

Methods

None.

Events

None.


NavigationControl.Top Property (Access)

 Copy code hover
[image]

NavigationControl.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Version Information

Version Added: Access 2010

Syntax

expression .Top

expression A variable that represents a NavigationControl object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Attachment.DefaultPictureType Property (Access)

 Copy code hover
[image]

Attachment.DefaultPictureType Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the method used to store the image specified by the DefaultPicture property in the database. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .DefaultPictureType

expression A variable that represents an Attachment object.

Remarks

The DefaultPictureType property uses the following settings.

Setting | Value | Meaning
Embedded (Default) | 0 | The image is embedded with the specified Attachment control.
Linked | 1 | The image is stored outside of the database.
Shared | 2 | The image is added to the SharedResources collection.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


CustomControl.TopPadding Property (Access)

 Copy code hover
[image]

CustomControl.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .TopPadding

expression A variable that represents a CustomControl object.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


TextBox Events (Access)

 Copy code hover
[image]

TextBox Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Change | The Change event occurs when the contents of the specified control changes.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Dirty | The Dirty event occurs when the contents of the specified control changes.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.
Undo | Occurs when the user undoes a change.


Recordset2.RecordCount Property (DAO)

 Copy code hover
[image]

Recordset2.RecordCount Property (DAO)
Send feedback

Returns the number of records accessed in a Recordset object, or the total number of records in a table-type Recordset object. or TableDef object. Read-only Long.

Syntax

expression .RecordCount

expression A variable that represents a Recordset2 object.

Remarks

Use the RecordCount property to find out how many records in a Recordset or TableDef object have been accessed. The RecordCount property doesn't indicate how many records are contained in a dynaset-, snapshot-, or forward-only-type Recordset object until all records have been accessed. Once the last record has been accessed, the RecordCount property indicates the total number of undeleted records in the Recordset or TableDef object. To force the last record to be accessed, use the MoveLast method on the Recordset object. You can also use an SQL Count function to determine the approximate number of records your query will return.

Note Note

Using the MoveLast method to populate a newly opened Recordset negatively impacts performance. Unless it is necessary to have an accurate RecordCount as soon as you open a Recordset, it's better to wait until you populate the Recordset with other portions of code before checking the RecordCount property.

As your application deletes records in a dynaset-type Recordset object, the value of the RecordCount property decreases. However, records deleted by other users aren't reflected by the RecordCount property until the current record is positioned to a deleted record. If you execute a transaction that affects the RecordCount property setting and you subsequently roll back the transaction, the RecordCount property won't reflect the actual number of remaining records.

The RecordCount property of a snapshot- or forward-only-type Recordset object isn't affected by changes in the underlying tables.

A Recordset or TableDef object with no records has a RecordCount property setting of 0.

Using the Requery method on a Recordset object resets the RecordCount property just as if the query were re-executed.

Example

This example demonstrates the RecordCount property with different types of Recordsets before and after they're populated.

VBA Copy code Copy code
Sub RecordCountX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset2

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind
 ' Open table-type Recordset and show RecordCount
 ' property.
 Set rstEmployees = .OpenRecordset("Employees")
 Debug.Print _
 "Table-type recordset from Employees table"
 Debug.Print " RecordCount = " & _
 rstEmployees.RecordCount
 rstEmployees.Close

 ' Open dynaset-type Recordset and show RecordCount
 ' property before populating the Recordset.
 Set rstEmployees = .OpenRecordset("Employees", _
 dbOpenDynaset)
 Debug.Print "Dynaset-type recordset " & _
 "from Employees table before MoveLast"
 Debug.Print " RecordCount = " & _
 rstEmployees.RecordCount

 ' Show the RecordCount property after populating the
 ' Recordset.
 rstEmployees.MoveLast
 Debug.Print "Dynaset-type recordset " & _
 "from Employees table after MoveLast"
 Debug.Print " RecordCount = " & _
 rstEmployees.RecordCount
 rstEmployees.Close

 ' Open snapshot-type Recordset and show RecordCount
 ' property before populating the Recordset.
 Set rstEmployees = .OpenRecordset("Employees", _
 dbOpenSnapshot)
 Debug.Print "Snapshot-type recordset " & _
 "from Employees table before MoveLast"
 Debug.Print " RecordCount = " & _
 rstEmployees.RecordCount

 ' Show the RecordCount property after populating the
 ' Recordset.
 rstEmployees.MoveLast
 Debug.Print "Snapshot-type recordset " & _
 "from Employees table after MoveLast"
 Debug.Print " RecordCount = " & _
 rstEmployees.RecordCount
 rstEmployees.Close

 ' Open forward-only-type Recordset and show
 ' RecordCount property before populating the
 ' Recordset.
 Set rstEmployees = .OpenRecordset("Employees", _
 dbOpenForwardOnly)
 Debug.Print "Forward-only-type recordset " & _
 "from Employees table before MoveLast"
 Debug.Print " RecordCount = " & _
 rstEmployees.RecordCount

 ' Show the RecordCount property after calling the
 ' MoveNext method.
 rstEmployees.MoveNext
 Debug.Print "Forward-only-type recordset " & _
 "from Employees table after MoveNext"
 Debug.Print " RecordCount = " & _
 rstEmployees.RecordCount
 rstEmployees.Close

 .Close
 End With

End Sub


After Insert Macro Event

 Copy code hover
[image]

After Insert Macro Event
Send feedback

The After Insert event occurs after a record is added.

Note Note

The After Insert event is available only in Data Macros.

Remarks

Use the After Insert event to perform any actions that you want to occur when a record is added to a table. Common uses for the After Insert include enforcing business rules, workflows, updating an aggregate total, and sending notifications.

You can use the Updated("Field Name") function to determine whether a field has changed. The following code example shows how to use an If statement to determine determine whether the PaidInFull field has been changed.

Copy code Copy code

If  Updated("PaidInFull")   Then

    /* Perform actions based on changes to the field.   */

End If

The following table lists macro commands that can be used in theAfter Insert event.

Command Type | Command
Program Flow | Comment Macro Statement
Program Flow | Group Macro Statement
Program Flow | If...Then...Else Macro Block
Data Block | CreateRecord Macro Action
Data Block | EditRecord Macro Action
Data Block | ForEachRecord Macro Action
Data Block | LookupRecord Data Block
Data Action | CancelRecordChange Macro Action
Data Action | ClearMacroError Macro Action
Data Action | DeleteRecord Macro Action
Data Action | ExitForEachRecord Macro Action
Data Action | LogEvent Macro Action
Data Action | OnError Macro Action
Data Action | RaiseError Macro Action
Data Action | RunDataMacro Macro Action
Data Action | SendEmail Macro Action
Data Action | SetField Macro Action
Data Action | SetLocalVar Macro Action
Data Action | StopAllMacros Macro Action
Data Action | StopMacro Macro Action

To create a Data macro that captures the After Insert event, use the following steps.

  1. Open the table for which you want to capture the After Insert event.

  2. On the Table tab, in the After Events group, click After Insert.

An empty data macro is displayed in the macro designer.

Example

The following code example uses the After Insert event to perform some processing when a record is added to the Donations table. When a record is added, the amount of the donation is added to the DonationsReceived field in the Campaigns table and the TotalDonatedField in the Donors table.

Click here to view a copy of the macro that you can paste into Macro Designer.

To view this example in the macro designer, use the following steps:

  1. Open the table for which you want to capture the After Insert event.

  2. On the Table tab, in the After Events group, click After Insert.

  3. Select the code in the following code example and then press CTRL+C to copy it to the Clipboard.

  4. Activate the macro designer window and then press CTRL+V.

Copy code Copy code
<DataMacros>
  <DataMacro Event="AfterInsert">
    <Statements>
      <Comment>This data macro increments the DonationsReceived field in Campaigns and theAmountCollected field in Pledges </Comment>
      <Action Name="SetLocalVar">
        <Argument Name="Name">varAmount</Argument>
        <Argument Name="Value">[Amount]</Argument>
      </Action>
      <ConditionalBlock>
        <If>
          <Condition>Not (IsNull([CampaignID]))</Condition>
          <Statements>
            <ForEachRecord>
              <Data>
                <Reference>Campaigns</Reference>
                <WhereCondition>[ID]=[Donations].[CampaignID]</WhereCondition>
              </Data>
              <Statements>
                <EditRecord>
                  <Data />
                  <Statements>
                    <Action Name="SetField">
                      <Argument Name="Field">[DonationsReceived]</Argument>
                      <Argument Name="Value">[DonationsReceived]+[varAmount]</Argument>
                    </Action>
                  </Statements>
                </EditRecord>
              </Statements>
            </ForEachRecord>
          </Statements>
        </If>
      </ConditionalBlock>
      <ConditionalBlock>
        <If>
          <Condition>Not (IsNull([DonorID]))</Condition>
          <Statements>
            <ForEachRecord>
              <Data>
                <Reference>Donors</Reference>
                <WhereCondition>[ID]=[Donations].[DonorID]</WhereCondition>
              </Data>
              <Statements>
                <EditRecord>
                  <Data />
                  <Statements>
                    <Action Name="SetField">
                      <Argument Name="Field">[TotalDonated]</Argument>
                      <Argument Name="Value">[TotalDonated]+[varAmount]</Argument>
                    </Action>
                  </Statements>
                </EditRecord>
              </Statements>
            </ForEachRecord>
          </Statements>
        </If>
      </ConditionalBlock>
    </Statements>
  </DataMacro>
</DataMacros>

SetLocalVar
              Name   varAmount
        Expression   =[Amount]

If   Not (IsNull([CampaignID]))   Then

     For Each Record In   Campaigns
        Where Condition   =[ID]=[Donations].[CampaignID]
                  Alias

             EditRecord
                          Alias
                 SetField
                             Name   [DonationsReceived]
                            Value   =[DonationsReceived]+[varAmount]
            End EditRecord
End If

If   Not (IsNull([DonorID]))   Then

     For Each Record In  Donors
        WhereCondition   =[ID]=[Donations].[DonorID]
                 Alias

             EditRecord
                          Alias
                 SetField
                             Name   [TotalDonated]
                            Value   =[TotalDonated]+[varAmount]
             End EditRecord
End If


ToggleButton.Picture Property (Access)

 Copy code hover
[image]

ToggleButton.Picture Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Picture property to specify a bitmap or other type of graphic to be displayed on the specified control. Read/write String.

Syntax

expression .Picture

expression A variable that represents a ToggleButton object.

Remarks

The Picture property contains (bitmap) or the path and file name of a bitmap or other type of graphic to be displayed.

The default setting is (none). After the graphic is loaded into the object, the property setting is (bitmap) or the path and file name of the graphic. If you delete (bitmap) or the path and file name of the graphic from the property setting, the picture is deleted from the object and the property setting is again (none).

If the PictureType property is set to Embedded, the graphic is stored with the object.

You can create custom bitmaps by using Microsoft Paintbrush or another application that creates bitmap files. A bitmap file must have a .bmp, .ico, or .dib extension. You can also use graphics files in the .wmf or .emf formats, or any other graphic file type for which you have a graphics filter. Forms, reports, and image controls support all graphics. Command buttons and toggle buttons only support bitmaps.

Buttons can display either a caption or a picture. If you assign both to a button, the picture will be visible, the caption won't. If the picture is deleted, the caption reappears. Microsoft Access displays the picture centered on the button and clipped if the picture is larger than the button.

To create a command button or toggle button with a caption and a picture, you could include the desired caption as part of the bitmap and assign the bitmap to the Picture property of the control.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


SmartTagAction.Parent Property (Access)

 Copy code hover
[image]

SmartTagAction.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a SmartTagAction object.

See also

Concepts

SmartTagAction Object

Other resources

SmartTagAction Object Members


CheckBox.SizeToFit Method (Access)

 Copy code hover
[image]

CheckBox.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents a CheckBox object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Procedure Object (ADOX) Reference

 Copy code hover
[image]

Procedure Object (ADOX) Reference
Send feedback

In this section

  • Procedure Object (ADOX)

  • Procedure Properties, Methods, and Events (ADOX)


Cancel Method Example (VB)

 Copy code hover
[image]

Cancel Method Example (VB)
Send feedback

This example uses the Cancel method to cancel a command executing on a Connection object if the connection is busy.

Copy code Copy code

'BeginCancelVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 'recordset and connection variables
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim strCmdChange As String
 Dim strCmdRestore As String
 'record variables
 Dim blnChanged As Boolean

 ' Open a connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Define command strings
 strCmdChange = "UPDATE titles SET type = 'self_help' WHERE type = 'psychology'"
 strCmdRestore = "UPDATE titles SET type = 'psychology' " & _
 "WHERE type = 'self_help'"

 ' Begin a transaction, then execute a command asynchronously
 Cnxn.BeginTrans
 Cnxn.Execute strCmdChange, , adAsyncExecute
 ' do something else for a little while -
 ' use i = 1 to 32000 to allow completion
 Dim i As Integer
 For i = 1 To 1000
 i = i + i
 Debug.Print i
 Next i

 ' If the command has NOT completed, cancel the execute and
 ' roll back the transaction; otherwise, commit the transaction
 If CBool(Cnxn.State And adStateExecuting) Then
 Cnxn.Cancel
 Cnxn.RollbackTrans
 blnChanged = False
 MsgBox "Update canceled."
 Else
 Cnxn.CommitTrans
 blnChanged = True
 MsgBox "Update complete."
 End If

 ' If the change was made, restore the data
 ' because this is only a demo
 If blnChanged Then
 Cnxn.Execute strCmdRestore
 MsgBox "Data restored."
 End If

 ' clean up
 Cnxn.Close
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndCancelVB


Index.Foreign Property (DAO)

 Copy code hover
[image]

Index.Foreign Property (DAO)
Send feedback

Returns a value that indicates whether an Index object represents a foreign key in a table (Microsoft Access workspaces only). .

Syntax

expression .Foreign

expression A variable that represents an Index object.

Remarks

The return value is a Boolean data type that returns True if the Index object represents a foreign key.

A foreign key consists of one or more fields in a foreign table that uniquely identify all rows in a primary table.

The Microsoft Access database engine creates an Index object for the foreign table and sets the Foreign property when you create a relationship that enforces referential integrity.

Example

This example shows how the Foreign property can indicate which Index objects in a TableDef are foreign key indexes. Such indexes are created by the Microsoft Access database engine when a Relation is created. The default name for the foreign key indexes is the name of the primary table plus the name of the foreign table. The ForeignOutput function is required for this procedure to run.

VBA Copy code Copy code
Sub ForeignX()

 Dim dbsNorthwind As Database

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind
 ' Print report on foreign key indexes from two
 ' TableDef objects and a QueryDef object.
 ForeignOutput .TableDefs!Products
 ForeignOutput .TableDefs!Orders
 ForeignOutput .TableDefs![Order Details]

 .Close
 End With

End Sub

Function ForeignOutput(tdfTemp As TableDef)

 Dim idxLoop As Index

 With tdfTemp
 Debug.Print "Indexes in " & .Name & " TableDef"
 ' Enumerate the Indexes collection of the specified
 ' TableDef object.
 For Each idxLoop In .Indexes
 Debug.Print " " & idxLoop.Name
 Debug.Print " Foreign = " & idxLoop.Foreign
 Next idxLoop
 End With

End Function


Form.WindowWidth Property (Access)

 Copy code hover
[image]

Form.WindowWidth Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the height of a form in twips. Read-only Integer.

Syntax

expression .WindowWidth

expression A variable that represents a Form object.

Remarks

The WindowWidth property is measured from the upper-left corner of the report to its upper-right corner.

See also

Concepts

Form Object

Other resources

Form Object Members


Could not find field. (Error 3018)

 Copy code hover
[image]

Could not find field. (Error 3018)
Send feedback

Possible causes:

  • The specified field does not exist.

  • You misspelled the field name. Check for missing underscores ( _ ) or other punctuation, and make sure you did not enter leading spaces.

  • You entered an invalid field identifier. For example, [My Table]_[My Field] instead of MyTable![My Field] .

  • You did not use brackets to surround a field name that contains spaces.


Cannot make the

 Copy code hover
[image]

Cannot make the <name> table replicable due to too many indexes. (Error 3706)
Send feedback

The table cannot be made replicable because replication system indexes cannot be added. Adding these indexes would exceed the maximum index limit.


Synchronizer

 Copy code hover
[image]

Synchronizer <name> is also using the same File System dropbox <name> (Error 3630)
Send feedback

Each Synchronizer should have a unique file system dropbox. Using the same dropbox location for multiple Synchronizers can result in lost messages and incomplete exchanges. The applicatin is unable to create the signal file because it is already opened by another transporter.


Form.Visible Property (Access)

 Copy code hover
[image]

Form.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents a Form object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

Form Object

Other resources

Form Object Members


ToggleButton.PressedThemeColorIndex Property (Access)

 Copy code hover
[image]

ToggleButton.PressedThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .PressedThemeColorIndex

expression A variable that represents a ToggleButton object.

Remarks

The PressedThemeColorIndex uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 (Default) | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the PressedThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


FormatCondition Properties (Access)

 Copy code hover
[image]

FormatCondition Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
Expression1 | You can use the Expression1 property to return the values of a conditional format within a FormatCondition object. Read-only String.
Expression2 | You can use the Expression2 property to return the values of a conditional format within a FormatCondition object. Read-only String.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
LongestBarLimit | Gets or sets how the longest data bar is evaluated for the specified FormatCondition. Read/write AcFormatBarLimits.
LongestBarValue | Gets or sets a numeric expression that specifies the value of the longest bar of a FormatCondition. Read/write String.
Operator | You can use the Operator property to return the operator value for the conditional format or data validation of a FormatCondition object. Read-only AcFormatConditionOperator.
ShortestBarLimit | Gets or sets how the shortest data bar is evaluated for the specified FormatCondition. Read/write AcFormatBarLimits.
ShortestBarValue | Gets or sets a numeric expression that specifies the value of the shortest bar of a FormatCondition. Read/write String.
ShowBarOnly | Gets or sets whether the data bar or the data bar and its value are displayed. Set to True to display only the data bar. Read/write Boolean.
Type | Returns the value of a FormatCondition object type. Read-only AcFormatConditionType.


ListBox.Name Property (Access)

 Copy code hover
[image]

ListBox.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a ListBox object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Reference Object (Access)

 Copy code hover
[image]

Reference Object (Access)
See also Send feedback

Published: July 16, 2012

The Reference object refers to a reference set to another application's or project's type library.

Remarks

When you create a Reference object, you set a reference dynamically from Visual Basic.

The Reference object is a member of the References collection. To refer to a particular Reference object in the References collection, use any of the following syntax forms.

Syntax | Description
References!referencename | The referencename argument is the name of the Reference object.
References("referencename") | The referencename argument is the name of the Reference object.
References(index) | The index argument is the object's numerical position within the collection.
Note Note

The following example refers to the Reference object that represents the reference to the Microsoft Access type library:

VBA Copy code Copy code
Dim ref As Reference
Set ref = References!Access

See also

Concepts

Access Object Model Reference

Other resources

Reference Object Members


CurrentProject.UpdateDependencyInfo Method (Access)

 Copy code hover
[image]

CurrentProject.UpdateDependencyInfo Method (Access)
See also Send feedback

Published: July 16, 2012

Updates the dependency information for the database.

Syntax

expression .UpdateDependencyInfo

expression A variable that represents a CurrentProject object.

Remarks

The UpdateDependencyInfo method opens, saves, and then closes every table, query, form, and report in the database; no messages are presented to the user.

This method will return a run-time error if any of the following conditions are true:

  • This method is being called from an Access project (.adp).

  • Any database objects are open.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


Form.PaletteSource Property (Access)

 Copy code hover
[image]

Form.PaletteSource Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PaletteSource property to specify the palette for a form. Read/write String.

Syntax

expression .PaletteSource

expression A variable that represents a Form object.

Remarks

Enter the path and file name of one of the following file types:

  • .dib (device-independent bitmap file)

  • .pal (Windows palette file)

  • .ico (Windows icon file)

  • .bmp (Windows bitmap file)

  • .wmf or .emf file, or other graphics file for which you have a graphics filter

The default setting is (Default), which specifies the palette included with Microsoft Access. If you change this setting by entering a path and file name, the property setting displays (Custom).

For a form, you can set the PaletteSource property in form Design view and Form view. The property setting is unavailable in other views.

Windows can have only one color palette active at a time. Microsoft Access allows you to have multiple graphics on a form, each using a different color palette. The PaletteSource and PaintPalette properties let you specify which color palette a form uses when displaying graphics.

When you set the PaletteSource property for a form or report, Microsoft Access automatically updates its PaintPalette property. Conversely, when you set a form's or report's PaintPalette property, the PaletteSource property is also updated. For example, when you specify a custom palette with the PaintPalette property, the PaletteSource property setting changes to (Custom). The PaintPalette property (which is available only in a macro or Visual Basic) is used to set the palette for the form or report. The PaletteSource property gives you a way to set the palette for the form or report in the property sheet by using an existing graphics file.

Example

The following example sets the PaintPalette property of the Seascape form to the ObjectPalette property of the Ocean control on the DisplayPictures form. (Ocean can be a bound object frame, command button, chart, toggle button, or unbound object frame.)

VBA Copy code Copy code
Forms!Seascape.PaintPalette = _
 Forms!DisplayPictures!Ocean.ObjectPalette

The ObjectPalette and PaintPalette properties are useful for programmatically altering the color palette in use by an open form at run time. A common use of these properties is to set the current form's PaintPalette property to the palette of a graphic displayed in a control that has the focus.

For example, you can have a form with an ocean picture, showing many shades of blue, and a sunset picture, showing many shades of red. Since Windows only allows one color palette active at a time, one picture will look much better than the other. The following example uses a control's Enter event for setting the form's PaintPalette property to the control's ObjectPalette property so the graphic that has the focus will have an optimal appearance.

VBA Copy code Copy code
Sub OceanPicture_Enter()
 Me.PaintPalette = Me!OceanPicture.ObjectPalette
End Sub

Sub SunsetPicture_Enter()
 Me.PaintPalette = Me!SunsetPicture.ObjectPalette
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


OptionButton.Properties Property (Access)

 Copy code hover
[image]

OptionButton.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents an OptionButton object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


CommandButton.Shape Property (Access)

 Copy code hover
[image]

CommandButton.Shape Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets the shape of the specified button. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .Shape

expression A variable that represents a CommandButton object.

Remarks

The Shape property uses the following settings.

Setting | Description
0 | Rectangle
1 (Default) | Rounded Rectangle
2 | Snip Single Corner Rectangle
3 | Snip Same Side Corner Rectangle
4 | Snip Diagonal Corner Rectangle
5 | Snip and Round Single Corner Rectangle
6 | Round Single Corner Rectangle
7 | Round Same Side Corner Rectangle
8 | Round Diagonal Corner Rectangle
9 | Oval

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


CodeProject.AllReports Property (Access)

 Copy code hover
[image]

CodeProject.AllReports Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllReports property to reference the AllReports collection and its related properties. Read-only AllReports object.

Syntax

expression .AllReports

expression A variable that represents a CodeProject object.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


DataControl Properties, Methods, and Events (RDS)

 Copy code hover
[image]

DataControl Properties, Methods, and Events (RDS)
Send feedback

Properties

Connect Property (RDS)

ExecuteOptions Property (RDS)

FetchOptions Property (RDS)

FilterColumn Property (RDS)

FilterCriterion Property (RDS)

FilterValue Property (RDS)

Handler Property (RDS)

InternetTimeout Property (RDS)

ReadyState Property (RDS)

Recordset, SourceRecordset Properties (RDS)

Server Property (RDS)

SortColumn Property (RDS)

SortDirection Property (RDS)

SQL Property (RDS)

URL Property (RDS)

Methods

Cancel Method (RDS)

CancelUpdate Method (RDS)

CreateRecordset Method (RDS)

MoveFirst, MoveLast, MoveNext, and MovePrevious Methods (RDS)

Refresh Method (RDS)

Reset Method (RDS)

SubmitChanges Method (RDS)

Events

OnError Event

OnReadyStateChange Event


WebBrowserControl Methods (Access)

 Copy code hover
[image]

WebBrowserControl Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.
Undo | You can use the Undo method to reset a control or form when its value has been changed.


Report.FilterOn Property (Access)

 Copy code hover
[image]

Report.FilterOn Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FilterOn property to specify or determine whether the Filter property for a form or report is applied. Read/write Boolean.

Syntax

expression .FilterOn

expression A variable that represents a Report object.

Remarks

If you want to specify a server filter within a Microsoft Access project (.adp) for data located on a server, use the ServerFilter property.

To apply a saved filter, press the Apply Filter button for forms, or apply the filter by using a macro or Visual Basic by setting the FilterOn property to True for forms or reports. For reports, you can set the FilterOn property to Yes in the report's property sheet.

The Apply Filter button indicates the state of the Filter and FilterOn properties. The button remains disabled until there is a filter to apply. If an existing filter is currently applied, the Apply Filter button appears pressed in. To apply a filter automatically when a form or report is opened, specify in the OnOpen event property setting of the form either a macro that uses the ApplyFilter action or an event procedure that uses the ApplyFilter method of the DoCmd object.

You can remove a filter by clicking the pressed-in Apply Filter button, clicking Remove Filter/Sort on the Records menu, or by using Visual Basic to set the FilterOn property to False. For reports, you can remove a filter by setting the FilterOn property to No in the report's property sheet.

Note Note

When a new object is created, it inherits the RecordSource , Filter, ServerFilter . OrderBy , and OrderByOn properties of the table or query it was created from. For forms and reports, inherited filters aren't automatically applied when an object is opened.

See also

Concepts

Report Object

Other resources

Report Object Members


IN (Microsoft Access SQL reserved word)

 Copy code hover
[image]

IN (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The IN keyword is used in these contexts:

In Operator

IN Clause

SQL Subqueries

TRANSFORM Statement


Label.FontBold Property (Access)

 Copy code hover
[image]

Label.FontBold Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontBold property to specify whether a font appears in a bold style in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontBold

expression A variable that represents a Label object.

Remarks

The FontBold property uses the following settings.

Setting | Description
True | The text is bold.
False | (Default) The text isn't bold.

To use the FontBold property on a report, first create a Printevent procedure that prints the desired text.

A font's appearance on screen and in print may differ, depending on your computer and printer.

The FontWeight property, which is available in the property sheet for controls, can also be used to set the line width for a control's text. The FontBold property gives you a quick way to make text bold; the FontWeight property gives you finer control over the line width setting for text. The following table shows the relationship between these properties' settings.

If | Then
FontBold = False | FontWeight = Normal (400)
FontBold = True | FontWeight = Bold (700)
FontWeight < 700 | FontBold = False
FontWeight > = 700 | FontBold = True

Example

The following Print event procedure prints a report title and the current date in a bold style on a report at the coordinates specified by the CurrentX and CurrentY property settings.

VBA Copy code Copy code
Private Sub ReportHeader0_Print(Cancel As Integer, _
 PrintCount As Integer)
 Dim MyDate

 MyDate = Date
 Me.FontBold = True
 ' Print report title in bold.
 Me.Print("Sales Management Report")
 Me.Print(MyDate)
End Sub

See also

Concepts

Label Object

Other resources

Label Object Members


Label.TopMargin Property (Access)

 Copy code hover
[image]

Label.TopMargin Property (Access)
See also Send feedback

Published: July 16, 2012

Along with the LeftMargin, RightMargin, and BottomMargin properties, specifies the location of information displayed within a label control. Read/write Integer.

Syntax

expression .TopMargin

expression A variable that represents a Label object.

Remarks

A control's displayed information location is measured from the control's left, top, right, or bottom border to the left, top, right, or bottom edge of the displayed information. Setting the LeftMargin or TopMargin property to 0 places the displayed information's edge at the very left or top of the control. To use a unit of measurement different from the setting in the regional settings of Windows, specify the unit (for example, cm or in).

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

Example

The following example offsets the caption in the label "EmployeeID_Label" in the "Purchase Orders" form by 100 twips from the top of the label's border.

VBA Copy code Copy code
With Forms.Item("Purchase Orders").Controls.Item("EmployeeID_Label")
 .TopMargin = 100
End With

See also

Concepts

Label Object

Other resources

Label Object Members


ToggleButton.DefaultValue Property (Access)

 Copy code hover
[image]

ToggleButton.DefaultValue Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.

Syntax

expression .DefaultValue

expression A variable that represents a ToggleButton object.

Remarks

The DefaultValue property applies to all table fields except those fields with the data type of AutoNumber or OLE Object.

The DefaultValue property specifies text or an expression that's automatically entered in a control or field when a new record is created. For example, if you set the DefaultValue property for a text box control to =Now(), the control displays the current date and time. The maximum length for a DefaultValue property setting is 255 characters.

The DefaultValue property doesn't apply to check box, option button, or toggle buttoncontrols when they are in an option group. It does however apply to the option group itself.

In Visual Basic, use a string expression to set the value of this property. For example, the following code sets the DefaultValue property for a text box control named PaymentMethod to "Cash"

VBA Copy code Copy code
Forms!frmInvoice!PaymentMethod.DefaultValue = """Cash"""
Note Note

To set this property for a field by using Visual Basic, use the ADO DefaultValue property or the DAO DefaultValue property.

The DefaultValue property is applied only when you add a new record. If you change the DefaultValue property, the change isn't automatically applied to existing records.

If you set the DefaultValue property for a form control that's bound to a field that also has a DefaultValue property setting defined in the table, the control setting overrides the table setting.

If you create a control by dragging a field from the field list, the field's DefaultValue property setting, as defined in the table, is applied to the control on the form although the control's DefaultValue property setting will remain blank.

One control can provide the default value for another control. For example, if you set the DefaultValue property for a control to the following expression, the control's default value is set to the DefaultValue property setting for the txtShipTo control.

VBA Copy code Copy code
=Forms!frmInvoice!txtShipTo

If the controls are on the same form, the control that's the source of the default value must appear earlier in the tab order than the control containing the expression.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


OptionButton.EventProcPrefix Property (Access)

 Copy code hover
[image]

OptionButton.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents an OptionButton object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Label.InSelection Property (Access)

 Copy code hover
[image]

Label.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents a Label object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

Label Object

Other resources

Label Object Members


Connection.QueryTimeout Property (DAO)

 Copy code hover
[image]

Connection.QueryTimeout Property (DAO)
Send feedback

Sets or returns a value that specifies the number of seconds to wait before a timeout error occurs when a query is executed on an ODBC data source.

Syntax

expression .QueryTimeout

expression A variable that represents a Connection object.

Remarks

The default value is 60.

When you're using an ODBC database, such as Microsoft SQL Server, there may be delays due to network traffic or heavy use of the ODBC server. Rather than waiting indefinitely, you can specify how long to wait.

When you use QueryTimeout with a Connection or Database object, it specifies a global value for all queries associated with the database. You can override this value for a specific query by setting the ODBCTimeout property of the particular QueryDef object.


SortOrder Property Example (VB)

 Copy code hover
[image]

SortOrder Property Example (VB)
Send feedback

This example demonstrates the SortOrder property of a Column that has been appended to the Columns collection of an Index. The code appends an ascending index to the Country column in the Employees table, then displays the records. Then the code appends a descending index to the Country column in the Employees table and displays the records again. The difference between ascending and descending indexes is shown.

Copy code Copy code

' BeginSortOrderVB
Sub Main()
 On Error GoTo SortOrderXError

 Dim cnn As New ADODB.Connection
 Dim catNorthwind As New ADOX.Catalog
 Dim idxAscending As New ADOX.Index
 Dim idxDescending As New ADOX.Index
 Dim rstEmployees As New ADODB.Recordset

 ' Connect the catalog.
 cnn.Open "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\" & _
 "Microsoft Office\Office\Samples\Northwind.mdb';"
 Set catNorthwind.ActiveConnection = cnn

 ' Append Country column to new index
 idxAscending.Columns.Append "Country"
 idxAscending.Columns("Country").SortOrder = adSortAscending
 idxAscending.Name = "Ascending"
 idxAscending.IndexNulls = adIndexNullsAllow

 'Append new index to Employees table
 catNorthwind.Tables("Employees").Indexes.Append idxAscending

 rstEmployees.Index = idxAscending.Name
 rstEmployees.Open "Employees", cnn, adOpenKeyset, _
 adLockOptimistic, adCmdTableDirect

 With rstEmployees
 .MoveFirst
 Debug.Print "Index = " & .Index
 Debug.Print " Country - Name"

 ' Enumerate the Recordset. The value of the
 ' IndexNulls property will determine if the newly
 ' added record appears in the output.
 Do While Not .EOF
 Debug.Print " " & !Country & " - " & _
 !FirstName & " " & !LastName
 .MoveNext
 Loop

 .Close
 End With

 ' Append Country column to new index
 idxDescending.Columns.Append "Country"
 idxDescending.Columns("Country").SortOrder = adSortDescending
 idxDescending.Name = "Descending"
 idxDescending.IndexNulls = adIndexNullsAllow

 'Append descending index to Employees table
 catNorthwind.Tables("Employees").Indexes.Append idxDescending

 rstEmployees.Index = idxDescending.Name
 rstEmployees.Open "Employees", cnn, adOpenKeyset, _
 adLockOptimistic, adCmdTableDirect

 With rstEmployees
 .MoveFirst
 Debug.Print "Index = " & .Index
 Debug.Print " Country - Name"

 ' Enumerate the Recordset. The value of the
 ' IndexNulls property will determine if the newly
 ' added record appears in the output.
 Do While Not .EOF
 Debug.Print " " & !Country & " - " & _
 !FirstName & " " & !LastName
 .MoveNext
 Loop

 .Close
 End With

 ' Delete new Indexes because this is a demonstration.
 catNorthwind.Tables("Employees").Indexes.Delete idxAscending.Name
 catNorthwind.Tables("Employees").Indexes.Delete idxDescending.Name

 'Clean up
 cnn.Close
 Set catNorthwind = Nothing
 Set idxAscending = Nothing
 Set idxDescending = Nothing
 Set rstEmployees = Nothing
 Set cnn = Nothing
 Exit Sub

SortOrderXError:

 Set catNorthwind = Nothing
 Set idxAscending = Nothing
 Set idxDescending = Nothing

 If Not rstEmployees Is Nothing Then
 If rstEmployees.State = adStateOpen Then rstEmployees.Close
 End If
 Set rstEmployees = Nothing

 If Not cnn Is Nothing Then
 If cnn.State = adStateOpen Then cnn.Close
 End If
 Set cnn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndSortOrderVB


Report.TextWidth Method (Access)

 Copy code hover
[image]

Report.TextWidth Method (Access)
See also Send feedback

Published: July 16, 2012

The TextWidth method returns the width of a text string as it would be printed in the current font of a Report object.

Syntax

expression .TextWidth(Expr)

expression A variable that represents a Report object.

Parameters

Name | Required/Optional | Data Type | Description
Expr | Required | String | The text string for which the text width will be determined.

Return Value

Single

Remarks

You can use the TextWidth method to determine the amount of horizontal space a text string will require in the current font when the report is formatted and printed. For example, a text string formatted in 9-point Arial will require a different amount of space than one formatted in 12-point Courier. To determine the current font and font size for text in a report, check the settings for the report's FontName and FontSize properties.

The value returned by the TextWidth method is expressed in terms of the coordinate system in effect for the report, as defined by the Scale method. You can use the ScaleMode property to determine the coordinate system currently in effect for the report.

If the strexpr argument contains embedded carriage returns, the TextWidth method returns the width of the longest line, from the beginning of the line to the carriage return. You can use the value returned by the TextWidth method to calculate the necessary space and positioning for multiple lines of text within a report.

See also

Concepts

Report Object

Other resources

Report Object Members


NavigationControl.BorderWidth Property (Access)

 Copy code hover
[image]

NavigationControl.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .BorderWidth

expression A variable that represents a NavigationControl object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


CommandTimeout Property (ADO)

 Copy code hover
[image]

CommandTimeout Property (ADO)
Send feedback

Indicates how long to wait while executing a command before terminating the attempt and generating an error.

Settings and Return Values

Sets or returns a Long value that indicates, in seconds, how long to wait for a command to execute. Default is 30.

Remarks

Use the CommandTimeout property on a Connection object or Command object to allow the cancellation of an Execute method call, due to delays from network traffic or heavy server use. If the interval set in the CommandTimeout property elapses before the command completes execution, an error occurs and ADO cancels the command. If you set the property to zero, ADO will wait indefinitely until the execution is complete. Make sure the provider and data source to which you are writing code support the CommandTimeout functionality.

The CommandTimeout setting on a Connection object has no effect on the CommandTimeout setting on a Command object on the same Connection; that is, the Command object's CommandTimeout property does not inherit the value of the Connection object's CommandTimeout value.

On a Connection object, the CommandTimeout property remains read/write after the Connection is opened.


ListBox.ItemData Property (Access)

 Copy code hover
[image]

ListBox.ItemData Property (Access)
See also Send feedback

Published: July 16, 2012

The ItemData property returns the data in the bound column for the specified row in a list box. Read-only Variant.

Syntax

expression .ItemData(Index)

expression A variable that represents a ListBox object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Long | The row in the combo box or list box containing the data you want to return. Rows in combo and list boxes are indexed starting with zero. For example, to return the item in the sixth row of a combo box, you'd specify 5 for the rowindex argument.

Remarks

The ItemData property enables you to iterate through the list of entries in a combo box or list box. For example, suppose you wanted to iterate through all of the items in a list box to search for a particular entry. You can use the ListCount property to determine the number of rows in the list box, and then use the ItemData property to return the data for the bound column in each row.

You can also use the ItemData property to return data only from selected rows in a list box. You can iterate through the ItemsSelected collection to determine which row or rows in the list box have been selected, and use the ItemData property to return the data in those rows. You must set the MultiSelect property of the list box to Simple or Extended to enable the user to select more than one row at a time.

You can use the Column property to return data from a specified row and column, even if the specified column isn't the bound column.

Example

The following example prints the value of the bound column for each selected row in a list box EmployeeList on an Employees form. The list box's MultiSelect property must be set to Simple or Extended.

VBA Copy code Copy code
Sub RowsSelected()
 Dim ctlList As Control, varItem As Variant

 ' Return Control object variable pointing to list box.
 Set ctlList = Forms!Employees!EmployeeList
 ' Enumerate through selected items.
 For Each varItem in ctlList.ItemsSelected
 ' Print value of bound column.
 Debug.Print ctlList.ItemData(varItem)
 Next varItem
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Working with Multidimensional Data

 Copy code hover
[image]

Working with Multidimensional Data
Send feedback

A cellset is the result of a query on multidimensional data. It consists of a collection of axes, usually no more than four axes and typically only two or three. An axis is a collection of members from one or more dimensions, which is used to locate or filter specific values in a cube.

A position is a point along an axis. For an axis consisting of a single dimension, these positions are a subset of the dimension members. If an axis consists of more than one dimension, then each position is a compound entity, which has n parts where n is the number of dimensions oriented along that axis. Each part of the position is a member from one constituent dimension.

For example, if the Geography and Product dimensions from a cube containing sales data are oriented along the x-axis of a cellset, a position along this axis may contain the members "USA" and "Computers." In this example, determining a position along the x-axis requires that members from each dimension are oriented along the axis.

A cell is an object positioned at the intersection of axis coordinates. Each cell has multiple pieces of information associated with it, including the data itself, a formatted string (the displayable form of cell data), and the cell ordinal value. (Each cell is a unique ordinal value in the cellset. The ordinal value of the first cell in the cellset is zero, while the leftmost cell in the second row of a cellset with eight columns would have an ordinal value of eight.)

For example, a cube has the following six dimensions (note that this cube schema differs slightly from the example given in Overview of Multidimensional Schemas and Data):

  • Salesperson

  • Geography (natural hierarchy) — Continents, Countries, States, and so on

  • Quarters — Quarters, Months, Days

  • Years

  • Measures — Sales, PercentChange, BudgetedSales

  • Products

Note Note

The cell values in the example can be viewed as ordered pairs of axis position ordinals where the first digit represents the x-axis position and the second digit the y-axis position.

The characteristics of this cellset are as follows:

  • Axis dimensions: Quarters, Salesperson, Geography

  • Filter dimensions: Measures, Years, Products

  • Two axes: COLUMN (x, or Axis 0) and ROW (y, or Axis 1)

  • x-axis: two nested dimensions, Salesperson and Geography

  • y-axis: Quarters dimension

The x-axis has two nested dimensions: Salesperson and Geography. From Geography, four members are selected: Seattle, Boston, USA-South, and Japan. Two members are selected from Salesperson: Valentine and Nash. This yields a total of eight positions on this axis (8 = 4*2).

Each coordinate is represented as a position with two members — one from the Salesperson dimension and another from the Geography dimension:

Copy code Copy code

(Valentine, Seattle), (Valentine, Boston), (Valentine, USA_North),
(Valentine, Japan), (Nash, Seattle), (Nash, Boston), (Nash, USA_North),
(Nash, Japan)

The y-axis has only one dimension, containing the following eight positions:

Copy code Copy code

Jan, Feb, Mar, Qtr2, Qtr3, Oct, Nov, Dec

Cellsets, cells, axes, and positions are all represented in ADO MD by corresponding objects: Cellset, Cell, Axis, and Position.


Report.PrtDevMode Property (Access)

 Copy code hover
[image]

Report.PrtDevMode Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PrtDevMode property to set or return printing device mode information specified for a form or report in the Print dialog box. Read/write Variant.

Syntax

expression .PrtDevMode

expression A variable that represents a Report object.

Remarks

It is strongly recommended that you consult the Win32 Software Development Kit for complete documentation on the PrtDevMode, PrtDevNames, and PrtMip properties.

The PrtDevMode property setting is a 94-byte structure that mirrors the DEVMODE structure defined in the Win32 Software Development Kit. For complete information on the PrtDevMode property members, consult the Win32 Software Development Kit.

The PrtDevMode property uses the following members.

Member | Description
DeviceName | A string with a maximum of 32 bytes that specifies the name of the device the driver supports — for example, "HP LaserJet IIISi" if the Hewlett-Packard LaserJet IIISi is the specified printer. Each printer driver has a unique string.
SpecVersion | An Integer that specifies the version number of the DEVMODE structure in the Win32 Software Development Kit.
DriverVersion | An Integer that specifies the printer driver version number assigned by the printer driver developer.
Size | An Integer that specifies the size, in bytes, of the DEVMODE structure. (This value doesn't include the optional dmDriverData member for device-specific data, which can follow this structure.) If an application manipulates only the driver-independent portion of the data, you can use this member to find out the length of this structure without having to account for different versions.
DriverExtra | An Integer that specifies the size, in bytes, of the optional dmDriverData member for device-specific data, which can follow this structure. If an application doesn't use device-specific information, you set this member to 0.
Fields | A Long value that specifies which of the remaining members in the DEVMODE structure have been initialized.
Orientation | An Integer that specifies the orientation of the paper. It can be either 1 (portrait) or 2 (landscape).
PaperSize | An Integer that specifies the size of the paper to print on. If you set this member to 0 or 256, the length and width of the paper are specified by the PaperLength and PaperWidth members, respectively. Otherwise, you can set the PaperSize member to a predefined value. For available values, see the PaperSize member values .
PaperLength | An Integer that specifies the paper length in units of 1/10 of a millimeter. This member overrides the paper length specified by the PaperSize member for custom paper sizes or for devices such as dot-matrix printers that can print on a variety of paper sizes.
PaperWidth | An Integer that specifies the paper width in units of 1/10 of a millimeter. This member overrides the paper width specified by the PaperSize member.
Scale | An Integer that specifies the factor by which the printed output will be scaled. The apparent page size is scaled from the physical page size by a factor of scale/100. For example, a piece of paper measuring 8.5 by 11 inches (letter-size) with a Scale value of 50 would contain as much data as a page measuring 17 by 22 inches because the output text and graphics would be half their original height and width.
Copies | An Integer that specifies the number of copies printed if the printing device supports multiple-page copies.
DefaultSource | An Integer that specifies the default bin from which the paper is fed. For available values, see the DefaultSource member values .
PrintQuality | An Integer that specifies the printer resolution. The values are -4 (high), -3 (medium), -2 (low), and -1 (draft).
Color | An Integer. For a color printer, specifies whether the output is printed in color. The values are 1 (color) and 2 (monochrome).
Duplex | An Integer. For a printer capable of duplex printing, specifies whether the output is printed on both sides of the paper. The values are 1 (simplex), 2 (horizontal), and 3 (vertical).
YResolution | An Integer that specifies the y-resolution of the printer in dots per inch (dpi). If the printer initializes this member, the PrintQuality member specifies the x-resolution of the printer in dpi.
TTOption | An Integer that specifies how TrueType fonts will be printed. For available values, see the TTOption member values .
Collate | An Integer that specifies whether collation should be used when printing multiple copies. Using uncollated copies provides faster, more efficient output, since the data is sent to the printer just once.
FormName | A string with a maximum of 16 characters that specifies the size of paper to use; for example, "Letter" or "Legal".
Pad | A Long value that is used to pad out spaces, characters, or values for future versions.
Bits | A Long value that specifies in bits per pixel the color resolution of the display device.
PW | A Long value that specifies the width, in pixels, of the visible device surface (screen or printer).
PH | A Long value that specifies the height, in pixels, of the visible device surface (screen or printer).
DFI | A Long value that specifies the device's display mode.
DFR | A Long value that specifies the frequency, in hertz (cycles per second), of the display device in a particular mode.

This property setting is read/write in Design view and read-only in other views.

Printer drivers can add device-specific data immediately following the 94 bytes of the DEVMODE structure. For this reason, it is important that the DEVMODE data outlined above not exceed 94 bytes.

Only printer drivers that export the ExtDeviceMode function use the DEVMODE structure.

An application can retrieve the paper sizes and names supported by a printer by using the DC_PAPERS, DC_PAPERSIZE, and DC_PAPERNAMES values to call the DeviceCapabilities function.

Before setting the value of the TTOption member, applications should find out how a printer driver can use TrueType fonts by using the DC_TRUETYPE value to call the DeviceCapabilities function.

Example

The following example uses the PrtDevMode property to check the user-defined page size for a report:

VBA Copy code Copy code
Private Type str_DEVMODE
 RGB As String * 94
End Type

Private Type type_DEVMODE
 strDeviceName As String * 32
 intSpecVersion As Integer
 intDriverVersion As Integer
 intSize As Integer
 intDriverExtra As Integer
 lngFields As Long
 intOrientation As Integer
 intPaperSize As Integer
 intPaperLength As Integer
 intPaperWidth As Integer
 intScale As Integer
 intCopies As Integer
 intDefaultSource As Integer
 intPrintQuality As Integer
 intColor As Integer
 intDuplex As Integer
 intResolution As Integer
 intTTOption As Integer
 intCollate As Integer
 strFormName As String * 32
 lngPad As Long
 lngBits As Long
 lngPW As Long
 lngPH As Long
 lngDFI As Long
 lngDFr As Long
End Type

Public Sub CheckCustomPage(ByVal rptName As String)

 Dim DevString As str_DEVMODE
 Dim DM As type_DEVMODE
 Dim strDevModeExtra As String
 Dim rpt As Report
 Dim intResponse As Integer

 ' Opens report in Design view.
 DoCmd.OpenReport rptName, acDesign
 Set rpt = Reports(rptName)

 If Not IsNull(rpt.PrtDevMode) Then
 strDevModeExtra = rpt.PrtDevMode

 ' Gets current DEVMODE structure.
 DevString.RGB = strDevModeExtra
 LSet DM = DevString
 If DM.intPaperSize = 256 Then

 ' Display user-defined size.
 intResponse = MsgBox("The current custom page size is " & _
 DM.intPaperWidth / 254 & " inches wide by " & _
 DM.intPaperLength / 254 & " inches long. Do you want " & _
 "to change the settings?", vbYesNo + vbQuestion)
 Else
 ' Currently not user-defined.
 intResponse = MsgBox("The report does not have a custom page size. " & _
 "Do you want to define one?", vbYesNo + vbQuestion)
 End If

 If intResponse = vbYes Then
 ' User wants to change settings. Initialize fields.
 DM.lngFields = DM.lngFields Or DM.intPaperSize Or _
 DM.intPaperLength Or DM.intPaperWidth

 ' Set custom page.
 DM.intPaperSize = 256

 ' Prompt for length and width.
 DM.intPaperLength = InputBox("Please enter page length in inches.") * 254
 DM.intPaperWidth = InputBox("Please enter page width in inches.") * 254

 ' Update property.
 LSet DevString = DM
 Mid(strDevModeExtra, 1, 94) = DevString.RGB
 rpt.PrtDevMode = strDevModeExtra
 End If
 End If

 Set rpt = Nothing

End Sub

The following example shows how to change the orientation of the report. This example will switch the orientation from portrait to landscape or landscape to portrait depending on the report's current orientation.

VBA Copy code Copy code
Public Sub SwitchOrient(ByVal strName As String)

 Const DM_PORTRAIT = 1
 Const DM_LANDSCAPE = 2
 Dim DevString As str_DEVMODE
 Dim DM As type_DEVMODE
 Dim strDevModeExtra As String
 Dim rpt As Report

 ' Opens report in Design view.
 DoCmd.OpenReport strName, acDesign
 Set rpt = Reports(strName)

 If Not IsNull(rpt.PrtDevMode) Then
 strDevModeExtra = rpt.PrtDevMode
 DevString.RGB = strDevModeExtra
 LSet DM = DevString
 DM.lngFields = DM.lngFields Or DM.intOrientation

 ' Initialize fields.
 If DM.intOrientation = DM_PORTRAIT Then
 DM.intOrientation = DM_LANDSCAPE
 Else
 DM.intOrientation = DM_PORTRAIT
 End If

 ' Update property.
 LSet DevString = DM
 Mid(strDevModeExtra, 1, 94) = DevString.RGB
 rpt.PrtDevMode = strDevModeExtra
 End If

 Set rpt = Nothing

End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


Elements of Run-Time Error Handling

 Copy code hover
[image]

Elements of Run-Time Error Handling
Send feedback

Errors and Error Handling

When you're programming an application, you need to consider what happens when an error occurs. An error can occur in your application for one of two of reasons. First, some condition at the time the application is running makes otherwise valid code fail. For example, if your code attempts to open a table that the user has deleted, an error occurs. Second, your code may contain improper logic that prevents it from doing what you intended. For example, an error occurs if your code attempts to divide a value by zero.

If you've implemented no error handling, then Visual Basic halts execution and displays an error message when an error occurs in your code. The user of your application is likely to be confused and frustrated when this happens. You can forestall many problems by including thorough error-handling routines in your code to handle any error that may occur.

When adding error handling to a procedure, you should consider how the procedure will route execution when an error occurs. The first step in routing execution to an error handler is to enable an error handler by including some form of the On Error statement within the procedure. The On Error statement directs execution in event of an error. If there's no On Error statement, Visual Basic simply halts execution and displays an error message when an error occurs.

When an error occurs in a procedure with an enabled error handler, Visual Basic doesn't display the normal error message. Instead it routes execution to an error handler, if one exists. When execution passes to an enabled error handler, that error handler becomes active. Within the active error handler, you can determine the type of error that occurred and address it in the manner that you choose. Microsoft Access provides three objects that contain information about errors that have occurred, the ADO Error object, the Visual Basic Err object, and the DAO Error object.

Routing Execution When an Error Occurs

An error handler specifies what happens within a procedure when an error occurs. For example, you may want the procedure to end if a certain error occurs, or you may want to correct the condition that caused the error and resume execution. The On Error and Resume statements determine how execution proceeds in the event of an error.

The On Error Statement

The On Error statement enables or disables an error-handling routine. If an error-handling routine is enabled, execution passes to the error-handling routine when an error occurs.

There are three forms of the On Error statement: On Error GoTo label, On Error GoTo 0, and On Error Resume Next. The On Error GoTo label statement enables an error-handling routine, beginning with the line on which the statement is found. You should enable the error-handling routine before the first line at which an error could occur. When the error handler is active and an error occurs, execution passes to the line specified by the label argument.

The line specified by the label argument should be the beginning of the error-handling routine. For example, the following procedure specifies that if an error occurs, execution passes to the line labeled :

Copy code Copy code
Function MayCauseAnError()
    ' Enable error handler.
    On Error GoTo Error_MayCauseAnError
    .            ' Include code here that may generate error.
    .
    .

Error_MayCauseAnError:
    .            ' Include code here to handle error.
    .
    .
End Function

The On Error GoTo 0 statement disables error handling within a procedure. It doesn't specify line 0 as the start of the error-handling code, even if the procedure contains a line numbered 0. If there's no On Error GoTo 0 statement in your code, the error handler is automatically disabled when the procedure has run completely. The On Error GoTo 0 statement resets the properties of the Err object, having the same effect as the Clear method of the Err object.

The On Error Resume Next statement ignores the line that causes an error and routes execution to the line following the line that caused the error. Execution isn't interrupted. You can use the On Error Resume Next statement if you want to check the properties of the Err object immediately after a line at which you anticipate an error will occur, and handle the error within the procedure rather than in an error handler.

The Resume Statement

The Resume statement directs execution back to the body of the procedure from within an error-handling routine. You can include a Resume statement within an error-handling routine if you want execution to continue at a particular point in a procedure. However, a Resume statement isn't necessary; you can also end the procedure after the error-handling routine.

There are three forms of the Resume statement. The Resume or Resume 0 statement returns execution to the line at which the error occurred. The Resume Next statement returns execution to the line immediately following the line at which the error occurred. The Resume label statement returns execution to the line specified by the label argument. The label argument must indicate either a line label or a line number.

You typically use the Resume or Resume 0 statement when the user must make a correction. For example, if you prompt the user for the name of a table to open, and the user enters the name of a table that doesn't exist, you can prompt the user again and resume execution with the statement that caused the error.

You use the Resume Next statement when your code corrects for the error within an error handler, and you want to continue execution without rerunning the line that caused the error. You use the Resume label statement when you want to continue execution at another point in the procedure, specified by the label argument. For example, you might want to resume execution at an exit routine, as described in the following section.

Exiting a Procedure

When you include an error-handling routine in a procedure, you should also include an exit routine, so that the error-handling routine will run only if an error occurs. You can specify an exit routine with a line label in the same way that you specify an error-handling routine.

For example, you can add an exit routine to the example in the previous section. If an error doesn't occur, the exit routine runs after the body of the procedure. If an error occurs, then execution passes to the exit routine after the code in the error-handling routine has run. The exit routine contains an Exit statement.

Copy code Copy code
Function MayCauseAnError()
    ' Enable error handler.
    On Error GoTo Error_MayCauseAnError
    .            ' Include code here that may generate error.
    .
    .

Exit_MayCauseAnError:
    Exit Function

Error_MayCauseAnError:
    .            ' Include code to handle error.
    .
    .
    ' Resume execution with exit routine to exit function.
    Resume Exit_MayCauseAnError
End Function

Handling Errors in Nested Procedures

When an error occurs in a nested procedure that doesn't have an enabled error handler, Visual Basic searches backward through the calls list for an enabled error handler in another procedure, rather than simply halting execution. This provides your code with an opportunity to correct the error within another procedure. For example, suppose Procedure A calls Procedure B, and Procedure B calls Procedure C. If an error occurs in Procedure C and there's no enabled error handler, Visual Basic checks Procedure B, then Procedure A, for an enabled error handler. If one exists, execution passes to that error handler. If not, execution halts and an error message is displayed.

Visual Basic also searches backward through the calls list for an enabled error handler when an error occurs within an active error handler. You can force Visual Basic to search backward through the calls list by raising an error within an active error handler with the Raise method of the Err object. This is useful for handling errors that you don't anticipate within an error handler. If an unanticipated error occurs, and you regenerate that error within the error handler, then execution passes back up the calls list to find another error handler, which may be set up to handle the error.

For example, suppose Procedure C has an enabled error handler, but the error handler doesn't correct for the error that has occurred. Once the error handler has checked for all the errors that you've anticipated, it can regenerate the original error. Execution then passes back up the calls list to the error handler in Procedure B, if one exists, providing an opportunity for this error handler to correct the error. If no error handler exists in Procedure B, or if it fails to correct for the error and regenerates it again, then execution passes to the error handler in Procedure A, assuming one exists.

To illustrate this concept in another way, suppose that you have a nested procedure that includes error handling for a type mismatch error, an error which you've anticipated. At some point, a division-by-zero error, which you haven't anticipated, occurs within Procedure C. If you've included a statement to regenerate the original error, then execution passes back up the calls list to another enabled error handler, if one exists. If you've corrected for a division-by-zero error in another procedure in the calls list, then the error will be corrected. If your code doesn't regenerate the error, then the procedure continues to run without correcting the division-by-zero error. This in turn may cause other errors within the set of nested procedures.

In summary, Visual Basic searches back up the calls list for an enabled error handler if:

  • An error occurs in a procedure that doesn't include an enabled error handler.

  • An error occurs within an active error handler. If you use the Raise method of the Err object to raise an error, you can force Visual Basic to search backward through the calls list for an enabled error handler.

Getting Information About an Error

Once execution has passed to the error-handling routine, your code must determine which error has occurred and address it. Visual Basic and Microsoft Access provide several language elements that you can use to get information about a specific error. Each is suited to different types of errors. Since errors can occur in different parts of your application, you need to determine which to use in your code based on what errors you expect.

The language elements available for error handling include:

  • The Err object.

  • The ADO Error object and Errors collection

  • The DAO Error object and Errors collection.

  • The AccessError method.

  • The Error event.

The Err Object

The Err object is provided by Visual Basic. When a Visual Basic error occurs, information about that error is stored in the Err object. The Err object maintains information about only one error at a time. When a new error occurs, the Err object is updated to include information about that error instead.

To get information about a particular error, you can use the properties and methods of the Err object. The Number property is the default property of the Err object; it returns the identifying number of the error that occurred. The Err object's Description property returns the descriptive string associated with a Visual Basic error. The Clear method clears the current error information from the Err object. The Raise method generates a specific error and populates the properties of the Err object with information about that error.

The following example shows how to use the Err object in a procedure that may cause a type mismatch error:

Copy code Copy code
Function MayCauseAnError()
    ' Declare constant to represent likely error.
    Const conTypeMismatch As Integer = 13

    On Error GoTo Error_MayCauseAnError
        .            ' Include code here that may generate error.
        .
        .

Exit_MayCauseAnError:
    Exit Function

Error_MayCauseAnError:
    ' Check Err object properties.
    If Err = conTypeMismatch Then
        .            ' Include code to handle error.
        .
        .
    Else
        ' Regenerate original error.
        Dim intErrNum As Integer
        intErrNum = Err
        Err.Clear
        Err.Raise intErrNum
    End If
    ' Resume execution with exit routine to exit function.
    Resume Exit_MayCauseAnError
End Function

Note that in the preceding example, the Raise method is used to regenerate the original error. If an error other than a type mismatch error occurs, execution will be passed back up the calls list to another enabled error handler, if one exists.

The Err object provides you with all the information you need about Visual Basic errors. However, it doesn't give you complete information about Microsoft Access errors or Microsoft Access database engine errors. Microsoft Access and Data Access Objects (DAO)) provide additional language elements to assist you with those errors.

The Error Object and Errors Collection

The Error object and Errors collection are provided by ADO and DAO. The Error object represents an ADO or DAO error. A single ADO or DAO operation may cause several errors, especially if you are performing DAO ODBC operations. Each error that occurs during a particular data access operation has an associated Error object. All the Error objects associated with a particular ADO or DAO operation are stored in the Errors collection, the lowest-level error being the first object in the collection and the highest-level error being the last object in the collection.

When a ADO or DAO error occurs, the Visual Basic Err object contains the error number for the first object in the Errors collection. To determine whether additional ADO or DAO errors have occurred, check the Errors collection. The values of the ADO Number or DAO Number properties and the ADO Description or DAO Description properties of the first Error object in the Errors collection should match the values of the Number and Description properties of the Visual Basic Err object.

The AccessError Method

You can use the Raise method of the Err object to generate a Visual Basic error that hasn't actually occurred and determine the descriptive string associated with that error. However, you can't use the Raise method to generate a Microsoft Access error, an ADO error, or a DAO error. To determine the descriptive string associated with a Microsoft Access error, an ADO error, or a DAO error that hasn't actually occurred, use the AccessError method.

The Error Event

You can use the Error event to trap errors that occur on a Microsoft Access form or report. For example, if a user tries to enter text in a field whose data type is Date/Time, the Error event occurs. If you add an Error event procedure to an Employees form, then try to enter a text value in the HireDate field, the Error event procedure runs.

The Error event procedure takes an integer argument, DataErr. When an Error event procedure runs, the DataErr argument contains the number of the Microsoft Access error that occurred. Checking the value of the DataErr argument within the event procedure is the only way to determine the number of the error that occurred. The Err object isn't populated with error information after the Error event occurs. You can use the value of the DataErr argument together with the AccessError method to determine the number of the error and its descriptive string.

Note Note

The Error statement and Error function are provided for backward compatibility only. When writing new code, use the Err and Error objects, the AccessError function, and the Error event for getting information about an error.

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Handling Access Errors with VBA

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.


Fields.Append Method (DAO)

 Copy code hover
[image]

Fields.Append Method (DAO)
Send feedback

Adds a new Field to the Fields collection.

Syntax

expression .Append(Object)

expression A variable that represents a Fields object.

Parameters

Name | Required/Optional | Data Type | Description
Object | Required | Object | An object variable that represents the field being appended to the collection.

Remarks

You can use the Append method to add a new table to a database, add a field to a table, and add a field to an index.

The appended object becomes a persistent object, stored on disk, until you delete it by using the Delete method.

The addition of a new object occurs immediately, but you should use the Refresh method on any other collections that may be affected by changes to the database structure.

If the object you're appending isn't complete (such as when you haven't appended any Field objects to a Fields collection of an Index object before it's appended to an Indexes collection) or if the properties set in one or more subordinate objects are incorrect, using the Append method causes an error. For example, if you haven't specified a field type and then try to append the Field object to the Fields collection in a TableDef object, using the Append method triggers a run-time error.

Example

This example uses either the Append method or the Delete method to modify the Fields collection of a TableDef. The AppendDeleteField procedure is required for this procedure to run.

Copy code Copy code
Sub AppendX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim fldLoop As Field

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set tdfEmployees = dbsNorthwind.TableDefs!Employees

 ' Add three new fields.
 AppendDeleteField tdfEmployees, "APPEND", _
 "E-mail", dbText, 50
 AppendDeleteField tdfEmployees, "APPEND", _
 "Http", dbText, 80
 AppendDeleteField tdfEmployees, "APPEND", _
 "Quota", dbInteger, 5

 Debug.Print "Fields after Append"
 Debug.Print , "Type", "Size", "Name"

 ' Enumerate the Fields collection to show the new fields.
 For Each fldLoop In tdfEmployees.Fields
 Debug.Print , fldLoop.Type, fldLoop.Size, fldLoop.Name
 Next fldLoop

 ' Delete the newly added fields.
 AppendDeleteField tdfEmployees, "DELETE", "E-mail"
 AppendDeleteField tdfEmployees, "DELETE", "Http"
 AppendDeleteField tdfEmployees, "DELETE", "Quota"

 Debug.Print "Fields after Delete"
 Debug.Print , "Type", "Size", "Name"

 ' Enumerate the Fields collection to show that the new
 ' fields have been deleted.
 For Each fldLoop In tdfEmployees.Fields
 Debug.Print , fldLoop.Type, fldLoop.Size, fldLoop.Name
 Next fldLoop

 dbsNorthwind.Close

End Sub

Sub AppendDeleteField(tdfTemp As TableDef, _
 strCommand As String, strName As String, _
 Optional varType, Optional varSize)

 With tdfTemp

 ' Check first to see if the TableDef object is
 ' updatable. If it isn't, control is passed back to
 ' the calling procedure.
 If .Updatable = False Then
 MsgBox "TableDef not Updatable! " & _
 "Unable to complete task."
 Exit Sub
 End If

 ' Depending on the passed data, append or delete a
 ' field to the Fields collection of the specified
 ' TableDef object.
 If strCommand = "APPEND" Then
 .Fields.Append .CreateField(strName, _
 varType, varSize)
 Else
 If strCommand = "DELETE" Then .Fields.Delete _
 strName
 End If

 End With

End Sub


SmartTagProperty Methods (Access)

 Copy code hover
[image]

SmartTagProperty Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Delete | Deletes the specified object.


ListBox.OnMouseUp Property (Access)

 Copy code hover
[image]

ListBox.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Syntax

expression .OnMouseUp

expression A variable that represents a ListBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


NavigationControl.Span Property (Access)

 Copy code hover
[image]

NavigationControl.Span Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the orientation of the navigation buttons. Read/write AcNavigationSpan.

Version Information

Version Added: Access 2010

Syntax

expression .Span

expression A variable that represents a NavigationControl object.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


OptionGroup.EventProcPrefix Property (Access)

 Copy code hover
[image]

OptionGroup.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents an OptionGroup object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


AbsolutePosition and CursorLocation Properties Example (VC++)

 Copy code hover
[image]

AbsolutePosition and CursorLocation Properties Example (VC++)
Send feedback

This example demonstrates how the AbsolutePosition property can track the progress of a loop that enumerates all the records of a Recordset. It uses the CursorLocation property to enable the AbsolutePosition property by setting the cursor to a client cursor.

Copy code Copy code

// BeginAbsolutePositionCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include "conio.h"
#include "AbsolutePositionX.h"

//Function Declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void AbsolutePositionX(void);
void AbsolutePosition2X(void);
void PrintProviderError(_ConnectionPtr pConnection);

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 AbsolutePositionX();

 //Clear the screen for the next display
 printf("Press any key to continue...");
 getch();
 system("cls");

 AbsolutePosition2X();

 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// AbsolutePositionX Function //
// //
///////////////////////////////////////////////////////////

void AbsolutePositionX(void)
{
 HRESULT hr = S_OK;

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstEmployees = NULL;

 //Define Other Variables
 //Interface Pointer declared.(VC++ Extensions)
 IADORecordBinding *picRs = NULL;
 CEmployeeRs emprs; //C++ class object
 _bstr_t strMessage;
 char chKey;

 //Open a recordset using a Client Cursor
 //For the Employee Table

 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 //Open a recordset.
 TESTHR(pRstEmployees.CreateInstance(__uuidof(Recordset)));

 //Use client cursor to enable Absoluteposition property.
 pRstEmployees->CursorLocation = adUseClient;

 //You have to explicitly pass the default Cursor type
 //and LockType to the Recordset.
 TESTHR( pRstEmployees->Open("employee",
 strCnn,adOpenForwardOnly,adLockReadOnly,adCmdTable));

 // Open an IADORecordBinding interface pointer which we'll use
 // for Binding Recordset to a class.
 TESTHR(pRstEmployees->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 //Bind the Recordset to a C++ Class here
 TESTHR(picRs->BindToRecordset(&emprs));

 strMessage= "";

 //Enumerate recordset
 do
 {
 //Display Current Record Information
 printf("Employee : %s \n record %ld of %d",
 emprs.lau_lnameStatus == adFldOK ?
 emprs.m_szau_lname : "<NULL>",
 pRstEmployees->AbsolutePosition,
 pRstEmployees->RecordCount);

 printf("\nContinue?(y/n) :");

 do
 {
 chKey = getch();
 }while(chKey != 'y' && chKey !='n');

 //Clear the Screen for the next output
 system("cls");

 if(chKey == 'n')
 break;

 strMessage = "";
 pRstEmployees->MoveNext();
 }while(!(pRstEmployees->EndOfFile));
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _variant_t vtConnect = pRstEmployees->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 printf("Error:\n");
 printf("Code = %08lx\n", e.Error());
 printf("Message = %s\n", e.ErrorMessage());
 printf("Source = %s\n", (LPCSTR) e.Source());
 printf("Description = %s\n", (LPCSTR) e.Description());
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (pRstEmployees)
 if (pRstEmployees->State == adStateOpen)
 pRstEmployees->Close();
}

///////////////////////////////////////////////////////////
// //
// AbsolutePosition2X Function //
// //
///////////////////////////////////////////////////////////

void AbsolutePosition2X(void)
{
 HRESULT hr = S_OK;

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstEmployees = NULL;

 //Define Other Variables
 //Interface Pointer declared.(VC++ Extensions)
 IADORecordBinding *picRs = NULL;
 CEmployeeRs emprs; //C++ class object
 _bstr_t strMessage;

 //Open a recordset using a Client Cursor
 //For the Employee Table

 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 //Open a recordset.
 TESTHR(pRstEmployees.CreateInstance(__uuidof(Recordset)));

 //Use client cursor to enable Absoluteposition property.
 pRstEmployees->CursorLocation = adUseClient;

 //You have to explicitly pass the default Cursor type
 //and LockType to the Recordset.
 TESTHR(pRstEmployees->Open("employee",
 strCnn,adOpenStatic,adLockReadOnly,adCmdTable));

 // Open an IADORecordBinding interface pointer which we'll use
 // for Binding Recordset to a class.
 TESTHR(pRstEmployees->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 //Bind the Recordset to a C++ Class here
 TESTHR(picRs->BindToRecordset(&emprs));

 long lGoToPos = 21;

 pRstEmployees->AbsolutePosition = (PositionEnum)lGoToPos;

 //Display Current Record Information
 printf("Employee : %s \n record %ld of %d",
 emprs.lau_lnameStatus == adFldOK ? emprs.m_szau_lname : "<NULL>", pRstEmployees->AbsolutePosition,
 pRstEmployees->RecordCount);

 printf("\nPress any key to continue:");
 getch();
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _variant_t vtConnect = pRstEmployees->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 printf("Error:\n");
 printf("Code = %08lx\n", e.Error());
 printf("Message = %s\n", e.ErrorMessage());
 printf("Source = %s\n", (LPCSTR) e.Source());
 printf("Description = %s\n", (LPCSTR) e.Description());
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (pRstEmployees)
 if (pRstEmployees->State == adStateOpen)
 pRstEmployees->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;
 long nCount = 0;
 long i = 0;

 if( (pConnection->Errors->Count) > 0)
 {
 nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s",
 pErr->Number,(LPCSTR) pErr->Description);
 }
 }
}

// EndAbsolutePositionCpp

AbsolutePositionX.h

Copy code Copy code

// BeginAbsolutePositionH
#include <ole2.h>
#include <stdio.h>
#include "icrsint.h"

//This Class extracts lastname.

class CEmployeeRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CEmployeeRs)

 //Column lname is the 4th field in the recordset

 ADO_VARIABLE_LENGTH_ENTRY2(4, adVarChar, m_szau_lname,
 sizeof(m_szau_lname), lau_lnameStatus, TRUE)

END_ADO_BINDING()

public:
 CHAR m_szau_lname[41];
 ULONG lau_lnameStatus;

};
// EndAbsolutePositionH


Syntax error in WITH OWNERACCESS OPTION declaration. (Error 3257)

 Copy code hover
[image]

Syntax error in WITH OWNERACCESS OPTION declaration. (Error 3257)
Send feedback

Possible causes:

  • The WITH OWNERACCESS OPTION declaration is incomplete or includes a space between OWNER and ACCESS.

  • The declaration appears in an unexpected and disallowed position in the SQL statement. For example:

    SQL Copy code Copy code
    SELECT * WITH OWNERACCESS OPTION FROM [My Table];

    The WITH OWNERACCESS OPTION declaration should appear at the end of the SQL statement, usually after the ORDER BY clause, if present:

    SQL Copy code Copy code
    SELECT * FROM [My Table] WITH OWNERACCESS OPTION;


DoCmd.OpenForm Method (Access)

 Copy code hover
[image]

DoCmd.OpenForm Method (Access)
See also Send feedback

Published: July 16, 2012

The OpenForm method carries out the OpenForm action in Visual Basic.

Syntax

expression .OpenForm(FormName, View, FilterName, WhereCondition, DataMode, WindowMode, OpenArgs)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
FormName | Required | Variant | A string expression that's the valid name of a form in the current database. If you execute Visual Basic code containing the OpenForm method in a library database, Microsoft Access looks for the form with this name first in the library database, then in the current database.
View | Optional | AcFormView | A AcFormView constant that specifies the view in which the form will open. The default value is acNormal.
FilterName | Optional | Variant | A string expression that's the valid name of a query in the current database.
WhereCondition | Optional | Variant | A string expression that's a valid SQL WHERE clause without the word WHERE.
DataMode | Optional | AcFormOpenDataMode | A AcFormOpenDataMode constant that specifies the data entry mode for the form. This applies only to forms opened in Form view or Datasheet view. The default value is acFormPropertySettings.
WindowMode | Optional | AcWindowMode | A AcWindowMode constant that specifies the window mode in which the form opens. The default value is acWindowNormal.
OpenArgs | Optional | Variant | A string expression. This expression is used to set the form's OpenArgs property. This setting can then be used by code in a form module, such as the Open event procedure. The OpenArgs property can also be referred to in macros and expressions. For example, suppose that the form you open is a continuous-form list of clients. If you want the focus to move to a specific client record when the form opens, you can specify the client name with the OpenArgs argument, and then use the FindRecord method to move the focus to the record for the client with the specified name.

Remarks

You can use the OpenForm method to open a form in Form view, form Design view, Print Preview, or Datasheet view. You can select data entry and window modes for the form and restrict the records that the form displays.

The maximum length of the WhereCondition argument is 32,768 characters (unlike the Where Condition action argument in the Macro window, whose maximum length is 256 characters).

Example

The following example opens the Employees form in Form view and displays only records with King in the LastName field. The displayed records can be edited, and new records can be added.

VBA Copy code Copy code
DoCmd.OpenForm "Employees", , ,"LastName = 'King'"

The following example opens the frmMainEmployees form in Form view and displays only records that apply to the department chosen the cboDept combo box. The displayed records can be edited, and new records can be added.

Sample code provided by: MVP Contributor Bill Jelen, MrExcel.com | About the Contributors

VBA Copy code Copy code
Private Sub cmdFilter_Click()
    DoCmd.OpenForm "frmMainEmployees", , , "DepartmentID=" & cboDept.Value
End Sub

The following example shows how to use the WhereCondition argument of the OpenForm method to filter the records displayed on a form as it is opened.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Private Sub cmdShowOrders_Click()
If Not Me.NewRecord Then
    DoCmd.OpenForm "frmOrder", _
        WhereCondition:="CustomerID=" & Me.txtCustomerID
End If
End Sub

About the Contributors

Holy Macro! Books publishes entertaining books for people who use Microsoft Office. See the complete catalog at MrExcel.com.

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


TextBox.Layout Property (Access)

 Copy code hover
[image]

TextBox.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified text box. Read-only AcLayoutType.

Version Information

Version Added: Access 2007

Syntax

expression .Layout

expression A variable that represents a TextBox object.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


CommandButton.SizeToFit Method (Access)

 Copy code hover
[image]

CommandButton.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents a CommandButton object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Positions Collection (ADO MD)

 Copy code hover
[image]

Positions Collection (ADO MD)
Send feedback

Contains the Position objects that define a point on an axis.

Remarks

Positions is a standard ADO collection. With the properties and methods of a collection, you can do the following:

  • Obtain the number of objects in the collection with the Count property.

  • Return an object from the collection with the default Item property.

  • Update the objects in the collection from the provider with the Refresh method.


Property Object (DAO)

 Copy code hover
[image]

Property Object (DAO)
Send feedback

A Property object represents a built-in or user-defined characteristic of a DAO object.

Remarks

Every DAO object except the Connection and Error objects contains a Properties collection which has Property objects corresponding to built-in properties of that DAO object. The user can also define Property objects and append them to the Properties collection of some DAO objects. These Property objects (which are often just called properties) uniquely characterize that instance of the object.

You can create user-defined properties for the following objects:

  • Database, Index, QueryDef, and TableDef objects

  • Field objects in Fields collections of QueryDef and TableDef objects

To add a user-defined property, use the CreateProperty method to create a Property object with a unique Name property setting. Set the Type and Value properties of the new Property object, and then append it to the Properties collection of the appropriate object. The object to which you are adding the user-defined property must already be appended to a collection. Referencing a user-defined Property object that has not yet been appended to a Properties collection will cause an error, as will appending a user-defined Property object to a Properties collection containing a Property object of the same name.

You can delete user-defined properties from the Properties collection, but you can't delete built-in properties.

Note Note

A user-defined Property object is associated only with the specific instance of an object. The property isn't defined for all instances of objects of the selected type.

You can use the Properties collection of an object to enumerate the object's built-in and user-defined properties. You don't need to know beforehand exactly which properties exist or what their characteristics (Name and Type properties) are to manipulate them. However, if you try to read a write-only property, such as the Password property of a Workspace object, or try to read or write a property in an inappropriate context, such as the Value property setting of a Field object in the Fields collection of a TableDef object, an error occurs.

The Property object also has four built-in properties:

  • The Name property, a String that uniquely identifies the property.

  • The Type property, an Integer that specifies the property data type.

  • The Value property, a Variant that contains the property setting.

  • The Inherited property, a Boolean that indicates whether the property is inherited from another object. For example, a Field object in a Fields collection of a Recordset object can inherit properties from the underlying TableDef or QueryDef object.

To refer to a built-in Property object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

  • object .Properties(0)

  • object .Properties("name")

  • object .Properties![name]

For a built-in property, you can also use this syntax:

  • object.name

Note Note

For a user-defined property, you must use the full object.Properties("name") syntax.

With the same syntax forms, you can also refer to the Value property of a Property object. The context of the reference will determine whether you are referring to the Property object itself or the Value property of the Property object.


Attachment.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

Attachment.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme that is associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents an Attachment object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.BorderThemeColorIndex=2

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


CommandButton.HoverForeColor Property (Access)

 Copy code hover
[image]

CommandButton.HoverForeColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the text displayed on the control when the user rests the mouse cursor over it. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HoverForeColor

expression A variable that represents a CommandButton object.

Remarks

The HoverForeColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


AddNew Method Example (VBScript)

 Copy code hover
[image]

AddNew Method Example (VBScript)
Send feedback

This example uses the AddNew method to create a new record with the specified name.

Use the following example in an Active Server Page (ASP). Use Find to locate the file Adovbs.inc and place it in the directory you plan to use. Cut and paste the following code to Notepad or another text editor, and save it as AddNewVBS.asp. You can view the result in any client browser.

To exercise the example, add a new record in the HTML form. Click Add New. See the Delete Method Example to remove unwanted records.

VBS Copy code Copy code

<!-- BeginAddNewVBS -->
<%@Language = VBScript %>
<%' use this meta tag instead of adovbs.inc%>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->
<HTML>
<HEAD>
    <TITLE>ADO AddNew Method (VBScript)</TITLE>
    <STYLE>
    <!--
    body {
       font-family: 'Verdana','Arial','Helvetica',sans-serif;
       BACKGROUND-COLOR:white;
       COLOR:black;
        }
    TH {
       background-color: #008080;
       font-family: 'Arial Narrow','Arial',sans-serif;
       font-size: xx-small;
       color: white;
       }
    TD {
       text-align: center;
       background-color: #f7efde;
       font-family: 'Arial Narrow','Arial',sans-serif;
       font-size: xx-small;
        }
    -->
    </STYLE>
</HEAD>
<BODY>

<H1>ADO AddNew Method (VBScript)</H1>

<% ' to integrate/test this code replace the
   ' Data Source value in the Connection string%>
<%
    ' connection and recordset variables
    Dim Cnxn, strCnxn
    Dim rsCustomers, strSQLCustomers
    Dim fld, Err

    ' open connection
    Set Cnxn = Server.CreateObject("ADODB.Connection")
    strCnxn = "Provider='sqloledb';Data Source=" & _
            Request.ServerVariables("SERVER_NAME") & ";" & _
            "Integrated Security='SSPI';Initial Catalog='Northwind';"
    Cnxn.Open strCnxn

     ' create and open Recordset using object refs
    Set rsCustomers = Server.CreateObject("ADODB.Recordset")
    strSQLCustomers = "Customers"

    rsCustomers.ActiveConnection = Cnxn
    rsCustomers.CursorLocation = adUseClient
    rsCustomers.CursorType = adOpenKeyset
    rsCustomers.LockType = adLockOptimistic
    rsCustomers.Source = strSQLCustomers
    rsCustomers.Open

    'If this is first time page is open, Form collection
    'will be empty when data is entered. run AddNew method
    If Not IsEmpty(Request.Form) Then
        If Not Request.Form("CompanyName") = "" Then
            rsCustomers.AddNew
                rsCustomers("CustomerID") = Request.Form("CompanyID")
                rsCustomers("CompanyName") = Request.Form("CompanyName")
                rsCustomers("ContactName") = Request.Form("FirstName") & _
                    " " & Request.Form("LastName")
                rsCustomers("Phone") = Request.Form("PhoneNumber")
                rsCustomers("City") = Request.Form("City")
                rsCustomers("Region") = Request.Form("State")
            rsCustomers.Update
             ' check for errors
            If Cnxn.Errors.Count > 0 Then
                For Each Err In Cnxn.Errors
                    Response.Write("Error " & Err.SQLState & ": " & _
                        Err.Description & " | " & Err.NativeError)
                Next
            Cnxn.Errors.Clear
            rsCustomers.CancelUpdate
            End If
            'On Error GoTo 0
        rsCustomers.MoveFirst
        End If
    End If
%>

<TABLE COLSPAN="8" CELLPADDING=5 BORDER=1 ALIGN="center">
<!-- BEGIN column header row for Customer Table-->
    <TR>
        <TH>Customer ID</TH>
        <TH>Company Name</TH>
        <TH>Contact Name</TH>
        <TH>Phone Number</TH>
        <TH>City</TH>
        <TH>State/Province</TH>
        </TR>

    <% ' show the data
        Do Until rsCustomers.EOF
            Response.Write("<TR>")
            Response.Write("<TD>" & rsCustomers("CustomerID") & "</TD>")
            Response.Write("<TD>" & rsCustomers("CompanyName")& "</TD>")
            Response.Write("<TD>" & rsCustomers("ContactName") & "</TD>")
            Response.Write("<TD>" & rsCustomers("Phone") & "</TD>")
            Response.Write("<TD>" & rsCustomers("City") & "</TD>")
            Response.Write("<TD>" & rsCustomers("Region") & "</TD>")
            Response.Write("</TR>")
        rsCustomers.MoveNext
        Loop
    %>
</TABLE>

<HR>

<!--
    Form to enter new record posts variables
    back to this page
-->
<FORM Method=post Action="AddNewVbs.asp" Name=Form>
    <TABLE>
        <TR>
            <TD>Company ID:</TD>
            <TD><INPUT Size="5" Name="CompanyID" maxLength=5  ></TD>
        </TR>
        <TR>
            <TD>Company Name:</TD>
            <TD><INPUT Size="50" Name="CompanyName" ></TD>
        </TR>
        <TR>
            <TD>Contact First Name:</TD>
            <TD><INPUT Size="50" Name="FirstName" ></TD>
        </TR>
        <TR>
            <TD>Contact Last Name:</TD>
            <TD><INPUT Size="50" Name="LastName" ></TD>
        </TR>
        <TR>
            <TD>Contact Phone:</TD>
            <TD><INPUT Size="50" Name="PhoneNumber" ></TD>
        </TR>
        <TR>
            <TD>City:</TD>
            <TD><INPUT Size="50" Name="City" ></TD>
        </TR>
        <TR>
            <TD>State / Province:</TD>
            <TD><INPUT Size="5" Name="State" ></TD>
        </TR>
        <TR>
            <TD Align="right"><INPUT Type="submit" Value="Add New"></TD>
            <TD Align="left"><INPUT Type="reset" Value="Reset Form"></TD>
        </TR>
    </TABLE>
</FORM>

<%
    ' show connection
    Response.Write("Following is the connection string: <br><br>")
    Response.Write(Cnxn)

    ' Clean up.
    If rsCustomers.State = adStateOpen then
       rsCustomers.Close
    End If
    If Cnxn.State = adStateOpen then
       Cnxn.Close
    End If
    Set rsCustomers=Nothing
    Set Cnxn=Nothing
    Set fld=Nothing
%>

<SCRIPT Language = "VBScript">
Sub Form_OnSubmit
   MsgBox "Sending New Record to Server",,"ADO-ASP _Example"
End Sub
</SCRIPT>
</BODY>
</HTML>
<!-- EndAddNewVBS -->


Could not lock table

 Copy code hover
[image]

Could not lock table <name>; currently in use by user <name> on machine <name>. (Error 3212)
Send feedback

The table cannot be locked because it is currently in use. Wait for the other user's transaction to complete, and then try the operation again.


CheckBox.OnKeyPress Property (Access)

 Copy code hover
[image]

CheckBox.OnKeyPress Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Press box in the Properties window. Read/write String.

Syntax

expression .OnKeyPress

expression A variable that represents a CheckBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyPress event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyPress value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Press box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Press box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyPress property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyPress

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Attachment.Parent Property (Access)

 Copy code hover
[image]

Attachment.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents an Attachment object.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Form.OnClick Property (Access)

 Copy code hover
[image]

Form.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Syntax

expression .OnClick

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

Form Object

Other resources

Form Object Members


OptionButton.ControlSource Property (Access)

 Copy code hover
[image]

OptionButton.ControlSource Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.

Syntax

expression .ControlSource

expression A variable that represents an OptionButton object.

Remarks

The ControlSource property uses the following settings.

Setting | Description
A field name | The control is bound to a field in a table, query, or SQL statement. Data from the field is displayed in the control. Changes to the data inside the control change the corresponding data in the field. (To make the control read-only, set the Locked property to Yes.) If you click a control bound to a field that has a Hyperlink data type, you jump to the destination specified in the hyperlink address.
An expression | The control displays data generated by an expression. This data can be changed by the user but isn't saved in the database.
Note Note

The ControlSource property doesn't apply to check box, option button, or toggle button controls in an option group. It applies only to the option group itself.

You can also set the ControlSource property for a text box by typing a field name or expression directly in the text box in form Design view or report Design view.

For reports, the ControlSource property applies only to report group levels.

Forms and reports act as "windows" into your database. You specify the primary source of data for a form or report by setting its RecordSource property to a table, query, or SQL statement. You can then set the ControlSource property to a field in the source of data or to an expression. If the ControlSource property setting is an expression, the value displayed is read-only and not saved in the database. For example, you can use the following settings.

Sample setting | Description
LastName | For a control, data from the LastName field is displayed in the control. For a report group level, Microsoft Access groups the data on last name.
=Date( ) + 7 | For a control, this expression displays a date seven days from today in the control.
=DatePart("q",ShippedDate) | For a control, this expression displays the quarter of the shipped date. For a report group level, Microsoft Access groups the data on the quarter of the shipped date.

Example

The following example sets the ControlSource property for a text box named AddressPart to a field named City:

VBA Copy code Copy code
Forms!Customers!AddressPart.ControlSource = "City"

The next example sets the ControlSource property for a text box named Expected to the expression =Date() + 7

VBA Copy code Copy code
Me!Expected.ControlSource = "=Date() + 7"

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


TextBox.KeyboardLanguage Property (Access)

 Copy code hover
[image]

TextBox.KeyboardLanguage Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .KeyboardLanguage

expression A variable that represents a TextBox object.

Remarks

Valid values for this property are 0 (zero), which corresponds to the default system language, or plid + 2 where plid is the primary language ID of a language installed on the current system. For example, the primary language ID of English is 9, so the corresponding KeyboardLanguage setting is 11. For a list of languages and their primary language IDs, search for "Primary Language IDs" in the MSDN Web site. (An exception to this list is Traditional Chinese which is represented by the value 200.)

Setting this property to a language that is not installed may either have no effect or cause an error.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


How to: Manipulate Multivalued Fields With DAO

 Copy code hover
[image]

How to: Manipulate Multivalued Fields With DAO
Send feedback

Multivalued fields are represented as Recordset objects in DAO. The recordset for a field is a child of the recordset for the table that contains the multivalued field. To instantiate the child recordset, use the Value property of the multivalued field as follows.

VBA Copy code Copy code
Set childRs = rs.<multi-valued field>.Value

The following code example shows how to instantiate the child recordset of the AssignedTo field of the Tasks table.

VBA Copy code Copy code
   Set rs  = db.OpenRecordSet("Tasks")
   Set childRs = rs.AssignedTo.Value

The child recordset has the same functionality as any DAO Recordset object.

The following code example shows how to iterate through a parent recordset and its child recordset. The example prints the tasks in the Tasks table along with the people assigned to the tasks to the Immediate window.

VBA Copy code Copy code
Sub BrowseMultiValueField()
   Dim db As Database
   Dim rs As Recordset
   Dim childRS As Recordset

   Set db = CurrentDb()

   ' Open a Recordset for the Tasks table.
   Set rs = db.OpenRecordset("Tasks")
   rs.MoveFirst

   Do Until rs.EOF
      ' Print the name of the task to the Immediate window.
      Debug.Print rs!TaskName.Value

      ' Open a Recordset for the multivalued field.
      Set childRS = rs!AssignedTo.Value

         ' Exit the loop if the multivalued field contains no records.
         Do Until childRS.EOF
             childRS.MoveFirst

             ' Loop through the records in the child recordset.
             Do Until childRS.EOF
                 ' Print the owner(s) of the task to the Immediate
                 ' window.
                 Debug.Print Chr(0), childRS!Value.Value
                 childRS.MoveNext
             Loop
         Loop
      rs.MoveNext
   Loop
End Sub


CheckBox.OnMouseMove Property (Access)

 Copy code hover
[image]

CheckBox.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Syntax

expression .OnMouseMove

expression A variable that represents a CheckBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Adding Data to a Recordset

 Copy code hover
[image]

Adding Data to a Recordset
Send feedback

The Recordset is probably the most used of the ADO objects. In ADO a Recordset is best thought of as the combination of a result set from a data source and its associated cursor behaviors. Thus, you can put data into a Recordset and then use the Recordset methods and properties to navigate through the rows of data, view the values in the rows, and otherwise manipulate the result set.

This section will focus on adding data to the Recordset. For information about navigating through the data or updating the data, see Chapter 4: Editing Data and Chapter 5: Updating and Persisting Data. You do not always need the advanced capabilities of a Command object to add your result set to a Recordset. Often, you can execute your command by setting the Source property on the Recordset or passing a command string to the Recordset object Open method.

There are a variety of ways to add data from your data source to a Recordset. The technique you use depends on the needs of your application and the capabilities of your provider.


CommandButton.OldValue Property (Access)

 Copy code hover
[image]

CommandButton.OldValue Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.

Syntax

expression .OldValue

expression A variable that represents a CommandButton object.

Remarks

The OldValue property contains the unedited data from a bound control and is read-only in all views.

Microsoft Access uses the OldValue property to store the original value of a bound control. When you edit a bound control on a form, your changes aren't saved until you move to another record. The OldValue property contains the unedited version of the underlying data.

You can provide your own undo capability by assigning the OldValue property setting to a control. The following example shows how you can undo any changes to text box controls on a form:

VBA Copy code Copy code
Private Sub btnUndo_Click()

 Dim ctlTextbox As Control

 For Each ctlTextbox in Me.Controls
 If ctlTextbox.ControlType = acTextBox Then
 ctlTextbox.Value = ctl.OldValue
 End If
 Next ctlTextbox

End Sub

If the control hasn't been edited, this code has no effect. When you move to another record, the record source is updated, so the current value and the OldValue property will be the same.

The OldValue property setting has the same data type as the field to which the control is bound.

Example

The following example checks to determine if new data entered in a field is within 10 percent of the value of the original data. If the change is greater than 10 percent, the OldValue property is used to restore the original value. This procedure could be called from the BeforeUpdate event of the control that contains data you want to validate.

VBA Copy code Copy code
Public Sub Validate_Field()

 Dim curNewValue As Currency
 Dim curOriginalValue As Currency
 Dim curChange As Currency
 Dim strMsg As String

 curNewValue = Forms!Products!UnitPrice
 curOriginalValue = Forms!Products!UnitPrice.OldValue
 curChange = Abs(curNewValue - curOriginalValue)

 If curChange > (curOriginalValue * .1) Then
 strMsg = "Change is more than 10% of original unit price. " _
 & "Restoring original unit price."
 MsgBox strMsg, vbExclamation, "Invalid change."
 Forms!Products!UnitPrice = curOriginalValue
 End If

End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


CheckBox.OnKeyUp Property (Access)

 Copy code hover
[image]

CheckBox.OnKeyUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Up box in the Properties window. Read/write String.

Syntax

expression .OnKeyUp

expression A variable that represents a CheckBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyUp event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyUp

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Use Microsoft Access as a DDE Server

 Copy code hover
[image]

Use Microsoft Access as a DDE Server
Send feedback

Microsoft Access supports dynamic data exchange (DDE) as either a destination (client) application or a source (server) application. For example, an application such as Microsoft Word, acting as a client, can request data through DDE from a Microsoft Access database that's acting as a server.

Tip Tip

If you need to manipulate Microsoft Access objects from another application, you may want to consider using Automation.

A DDE conversation between a client and server is established on a particular topic. A topic can be either a data file in the format supported by the server application, or it can be the System topic, which supplies information about the server application itself. Once a conversation has begun on a particular topic, only a data item associated with that topic can be transferred.

For example, suppose you are running Microsoft Word and want to insert data from a particular Microsoft Access database into a document. You begin a DDE conversation with Microsoft Access by opening a DDE channel with the DDEInitiate function and specifying the database file name as the topic. You can then transfer data from that database to Microsoft Word through that channel.

As a DDE server, Microsoft Access supports the following topics:

  • The System topic

  • The name of a database (database topic)

  • The name of a table (tablename topic)

  • The name of a query (queryname topic)

  • A Microsoft Access SQL string (sqlstring topic)

Once you've established a DDE conversation, you can use the DDEExecute statement to send a command from the client to the server application. When used as a DDE server, Microsoft Access recognizes any of the following as a valid command:

  • The name of a macro in the current database.

  • Any action that you can carry out in Visual Basic by using one of the methods of the DoCmd object.

  • The OpenDatabase and CloseDatabase actions, which are used only for DDE operations. (For an example of how to use these actions, see the example later in this topic.)

Note Note

When you specify a macro action as a DDEExecute statement, the action and any arguments follow the DoCmd object syntax and must be enclosed in brackets ([ ]). However, applications that support DDE don't recognize intrinsic constants in DDE operations. Also, string arguments must be enclosed in quotation marks (" ") if the string contains a comma. Otherwise, quotation marks aren't required.

The client application can use the DDERequest function to request text data from the server application over an open DDE channel. Or the client can use the DDEPoke statement to send data to the server application. Once the data transfer is complete, the client can use the DDETerminate statement to close the DDE channel, or the DDETerminateAll statement to close all open channels.

Note Note

When your client application has finished receiving data over a DDE channel, it should close that channel to conserve memory resources.

The following example demonstrates how to create a Microsoft Word procedure with Visual Basic that uses Microsoft Access as a DDE server. (For this example to work, Microsoft Access must be running.)

Copy code Copy code
Sub AccessDDE()
    Dim intChan1 As Integer, intChan2 As Integer
    Dim strQueryData As String

    ' Use System topic to open Northwind sample database.
    ' Database must be open before using other DDE topics.
    intChan1 = DDEInitiate("MSAccess", "System")
    ' You may need to change this path to point to actual location
    ' of Northwind sample database.
    DDEExecute intChan1, "[OpenDatabase C:\Access\Samples\Northwind.mdb]"

    ' Get all data from Ten Most Expensive Products query.
    intChan2 = DDEInitiate("MSAccess", "Northwind.mdb;" _
        & "QUERY Ten Most Expensive Products")
    strQueryData = DDERequest(intChan2, "All")
    DDETerminate intChan2

    ' Close database.
    DDEExecute intChan1, "[CloseDatabase]"
    DDETerminate intChan1

    ' Print retrieved data to Debug Window.
    Debug.Print strQueryData
End Sub

The following sections provide information about the valid DDE topics supported by Microsoft Access.

The System Topic

The System topic is a standard topic for all Microsoft Windows-based applications. It supplies information about the other topics supported by the application. To access this information, your code must first call the DDEInitiate function with as the topic argument, and then execute the DDERequest statement with one of the following supplied for the item argument.

Item | Returns
SysItems | A list of items supported by the System topic in Microsoft Access.
Formats | A list of the formats Microsoft Access can copy onto the Clipboard.
Status | "Busy" or "Ready".
Topics | A list of all open databases.

The following example demonstrates the use of the DDEInitiate and DDERequest functions with the System topic:

Copy code Copy code
' In Visual Basic, initiate DDE conversation with Microsoft Access.
Dim intChan1 As Integer, strResults As String
intChan1 = DDEInitiate("MSAccess", "System")
' Request list of topics supported by System topic.
strResults = DDERequest(intChan1, "SysItems")
' Run OpenDatabase action to open Northwind.mdb.
' You may need to change this path to point to actual location
' of Northwind sample database.
DDEExecute intChan1, "[OpenDatabase C:\Access\Samples\Northwind.mdb]"

The

The database topic is the file name of an existing database. You can type either just the base name (Northwind), or its path and .mdb extension (C:\Access\Samples\Northwind.mdb). After you start a DDE conversation with the database, you can request a list of the objects in that database.

Note Note

You can't use DDE to query the Microsoft Access workgroup information file.

The database topic supports the following items.

Item | Returns
TableList | A list of tables.
QueryList | A list of queries.
FormList | A list of forms.
ReportList | A list of reports.
MacroList | A list of macros.
ModuleList | A list of modules.
ViewList | A list of views
StoredProcedureList | A list of stored procedures
DatabaseDiagramList | A list of database diagrams

The following example shows how you can open the Employees form in the Northwind sample database from a Visual Basic procedure:

Copy code Copy code
' In Visual Basic, initiate DDE conversation with
' Northwind sample database.
' Make sure database is open.
intChan2 = DDEInitiate("MSAccess", "Northwind")
' Request list of forms in Northwind sample database.
strResponse = DDERequest(intChan2, "FormList")
' Run OpenForm action and arguments to open Employees form.
DDEExecute intChan2, "[OpenForm Employees,0,,,1,0]"

The TABLE

These topics use the following syntax:

databasename ; TABLE tablename

databasename ; QUERY queryname

databasename ; SQL [ sqlstring ]

Part | Description
databasename | The name of the database that the table or query is in or that the SQL statement applies to, followed by a semicolon (;). The database name can be just the base name (Northwind) or its full path and .mdb extension (C:\Access\Samples\Northwind.mdb).
tablename | The name of an existing table.
queryname | The name of an existing query.
sqlstring | A valid SQL statement up to 256 characters long, ending with a semicolon. To exchange more than 256 characters, omit this argument and instead use successive DDEPoke statements to build an SQL statement. For example, the following Visual Basic code uses the DDEPoke statement to build an SQL statement and then request the results of the query.

The following table lists the valid items for the TABLE tablename, QUERY queryname, and SQL sqlstring topics.

Item | Returns
All | All the data in the table, including field names.
Data | All rows of data, without field names.
FieldNames | A single-row list of field names.
FieldNames;T | A two-row list of field names (first row) and their data types (second row).
 | These are the values returned and the data types they represent:
 | Value | Data type
 | 0 | Invalid
 | 1 | True/False (non-Null)
 | 2 | Unsigned byte
 | 3 | 2-byte signed integer (Integer)
 | 4 | 4-byte signed integer (Long)
 | 5 | 8-byte signed integer (Currency)
 | 6 | 4-byte single-precision floating-point (Single)
 | 7 | 8-byte double-precision floating-point (Double)
 | 8 | Date/Time
 | 9 | Binary data, 256 bytes maximum
 | 10 | ANSI text, not case-sensitive, 256 bytes maximum (Text)
 | 11 | Long binary (OLE Object)
 | 12 | Long text (Memo)
NextRow | The data in the next row in the table or query. When you open a channel, NextRow returns the data in the first row. If the current row is the last record and you run NextRow, the request fails.
PrevRow | The data in the previous row in the table or query. If PrevRow is the first request on a new channel, the data in the last row of the table or query is returned. If the first record is the current row, the request for PrevRow fails.
FirstRow | The data in the first row of the table or query.
LastRow | The data in the last row of the table or query.
FieldCount | The number of fields in the table or query.
SQLText | An SQL statement representing the table or query. For tables, this item returns an SQL statement in the form "SELECT * FROM table;".
SQLText;n | An SQL statement, in n-character chunks, representing the table or query, where n is an integer up to 256. For example, suppose a query is represented by the following SQL statement: The item "SQLText;7" returns the following tab-delimited chunks: The item "SQLText;7" returns the following tab-delimited chunks:

The following example shows how you can use DDE in a Visual Basic procedure to request data from a table in the Northwind sample database and insert that data into a text file:

Copy code Copy code
Sub NorthwindDDE
    Dim intChan1 As Integer, intChan2 As Integer, intChan3 As Integer
    Dim strResp1 As Variant, strResp2 As Variant, strResp3 As Variant

    ' In a Visual Basic module, get data from Categories table,
    ' Catalog query, and Orders table in Northwind.mdb.
    ' Make sure database is open first.
    intChan1 = DDEInitiate("MSAccess", "Northwind;TABLE Shippers")
    intChan2 = DDEInitiate("MSAccess", "Northwind;QUERY Catalog")
    intChan3 = DDEInitiate("MSAccess", "Northwind;SQL SELECT * " _
        & "FROM Orders " _
        & "WHERE OrderID > 10050;")

    strResp1 = DDERequest(intChan1, "All")
    strResp2 = DDERequest(intChan2, "FieldNames;T")
    strResp3 = DDERequest(intChan3, "FieldNames;T")
    DDETerminate intChan1
    DDETerminate intChan2
    DDETerminate intChan3

    ' Insert data into text file.
    Open "C:\DATA.TXT" For Append As #1
    Print #1, strResp1
    Print #1, strResp2
    Print #1, strResp3
    Close #1
End Sub


SmartTagProperties.Parent Property (Access)

 Copy code hover
[image]

SmartTagProperties.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a SmartTagProperties object.

See also

Concepts

SmartTagProperties Collection

Other resources

SmartTagProperties Object Members


Attachment.OnDirty Property (Access)

 Copy code hover
[image]

Attachment.OnDirty Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dirty box in the Properties window of a form or report. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnDirty

expression A variable that represents an Attachment object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Dirty event occurs when the contents of a form or the text portion of a combo box changes. It also occurs when you move from one page to another page in a tab control.

The OnClose value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dirty box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dirty box is blank, the property value is an empty string.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Could not open table 'MSysAccounts' in the workgroup information file. (Error 3173)

 Copy code hover
[image]

Could not open table 'MSysAccounts' in the workgroup information file. (Error 3173)
Send feedback

This operation requires the System.mdw file, which contains the security and option settings for Microsoft Access database tables.


Label.OldBorderStyle Property (Access)

 Copy code hover
[image]

Label.OldBorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.

Syntax

expression .OldBorderStyle

expression A variable that represents a Label object.

Remarks

The OldBorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines
Note Note

  • If the OldBorderStyle property is set to None or Dialog, the form doesn't have Maximize or Minimize buttons, regardless of its MinMaxButtons property setting.

  • If the OldBorderStyle property is set to None, the form doesn't have a Control menu, regardless of its ControlBox property setting.

  • The OldBorderStyle property setting doesn't affect the display of the scroll bars, navigation buttons, the record number box, or record selectors.

Example

The following example demonstrates the effect of changing a control's BorderStyle property, while leaving the OldBorderStyle unaffected. The example concludes with setting the BorderStyle property to its original unedited value.

VBA Copy code Copy code
With Forms("Order Entry").Controls("Zip Code") .BorderStyle = 3 ' Short dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 3, 1.

    .BorderStyle = 2 ' Dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 2, 1

    .BorderStyle = .OldBorderStyle ' Solid (default) border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 1, 1
End With

See also

Concepts

Label Object

Other resources

Label Object Members


WebBrowserControl.Exit Event (Access)

 Copy code hover
[image]

WebBrowserControl.Exit Event (Access)
See also Send feedback

Published: July 16, 2012

The Exit event occurs just before a control loses the focus to another control on the same form or report.

Version Information

Version Added: Access 2010

Syntax

expression .Exit(Cancel, )

expression A variable that represents a WebBrowserControl object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer |

Return Value

nothing

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when this event occurs, set the OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Exit event occurs before the LostFocus event.

Unlike the LostFocus event, the Exit event does not occur when a form loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Failure to delete a file on the server using FTP. (Error 3682)

 Copy code hover
[image]

Failure to delete a file on the server using FTP. (Error 3682)
Send feedback

Unabe to delete a file on the internet server. Make sure the server is running and the FTP share folder is configured properly with read/write access.


Label.Width Property (Access)

 Copy code hover
[image]

Label.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents a Label object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

Label Object

Other resources

Label Object Members


The Microsoft Jet database engine has not been initialized. (Error 3278)

 Copy code hover
[image]

The Microsoft Jet database engine has not been initialized. (Error 3278)
Send feedback

The database engine cannot be initialized.

Possible causes:

  • There is a conflict with another application that uses the Microsoft Access database engine. Quit all other applications, and then restart your application.

  • An error occurred during installation and setup. Reinstall your application.


Entities Properties (Access)

 Copy code hover
[image]

Entities Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Object.
Parent | Returns the parent object for the specified object. Read-only.


Label.GridlineWidthTop Property (Access)

 Copy code hover
[image]

Label.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified label. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthTop

expression A variable that represents a Label object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Label Object

Other resources

Label Object Members


Report.HasModule Property (Access)

 Copy code hover
[image]

Report.HasModule Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the HasModule property to specify or determine whether a form or report has a class module. Read/write Boolean.

Syntax

expression .HasModule

expression A variable that represents a Report object.

Remarks

The HasModule property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The form or report has a class module.
No | False | (Default) The form or report doesn't have a class module.

Setting this property to False can improve the performance and decrease the size of your database.

The HasModule property can be set only in form or report Design view but can be read in any view.

Forms or reports that have the HasModule property set to No are considered lightweight objects. Lightweight objects are smaller and typically load and display faster than objects with associated class modules. In many cases, a form or report doesn't need to use event procedures and doesn't require a class module.

If your application uses a switchboard form to navigate to other forms, instead of using command buttons with event procedures, you can use a command button with a macro or hyperlink. For example, to open the Employees form from a command button on a switchboard, you can set the control's HyperlinkSubAddress property to "Form Employees".

Lightweight objects don't appear in the Object Browser and you can't use the New keyword to create a new instance of the object. A lightweight form or report can be used as a subform or subreport and will appear in the Forms or Reports collection. Lightweight objects support the use of macros, and public procedures that exist in standard modules when called from the object's property sheet.

Microsoft Access sets the HasModule property to True as soon as you attempt to view an object's module, even if no code is actually added to the module. For example, selecting Code from the View menu for a form in Design view causes Microsoft Access to add a class module to the Form object and set its HasModule property to True. You can add a class module to an object in the same way by setting the HasModule property to Yes in an object's property sheet.

If you set the HasModule property to No by using an object's property sheet or set it to False by using Visual Basic, Microsoft Access deletes the object's class module and any code it may contain.

When you use a method of the Module object or refer to the Module property for a form or report in Design view, Microsoft Access creates the associated module and sets the object's HasModule property to True. If you refer to the Module property of a form or report at run-time and the object has its HasModule property set to False, an error will occur.

Objects created by using the CreateForm or CreateReport methods are lightweight by default.

See also

Concepts

Report Object

Other resources

Report Object Members


Containers.Refresh Method (DAO)

 Copy code hover
[image]

Containers.Refresh Method (DAO)
Send feedback

Not supported for the Connections collection.

You can't use the Refresh method with collections that aren't persistent, such as Connections, Databases, Recordsets, Workspaces, or the QueryDefs collection of a Connection object.


SetVariable Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

SetVariable Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

You can use the SetVariable action to create a temporary variable and set it to a specific value. The variable can then be used as a condition or argument in subsequent actions, or you can use the variable in another user interface (UI) macro.

Setting

The SetVariable action has the following arguments.

Action argument | Description
Variable | Enter the name of the temporary variable.
Value = | Enter an expression that will be used to set the value for this temporary variable. Do not precede the expression with the equal (=) sign. You can click the Build button [image] to use the Expression Builder to set this argument.


Cannot create replica of a SQL replica. (Error 3753)

 Copy code hover
[image]

Cannot create replica of a SQL replica. (Error 3753)
Send feedback

A Microsoft SQL replica set supports a hub/spoke topology, where the SQL Publication is the hub and the Jet Subscriber is the spoke. If additional Jet replicas are desired, you must create an additional Push/Pull Subscription from the SQL Publication.


SELECT Statement (Microsoft Access SQL)

 Copy code hover
[image]

SELECT Statement (Microsoft Access SQL)
Send feedback

Instructs the Microsoft Access database engine to return information from the database as a set of records.

Syntax

SELECT [predicate] { * | table.* | [table.]field1 [AS alias1] [, [table.]field2 [AS alias2] [, …]]}
    FROM tableexpression [, …] [IN externaldatabase]
    [WHERE… ]
    [GROUP BY… ]
    [HAVING… ]
    [ORDER BY… ]
    [WITH OWNERACCESS OPTION]

The SELECT statement has these parts:

Part | Description
predicate | One of the following predicates: ALL, DISTINCT, DISTINCTROW, or TOP. You use the predicate to restrict the number of records returned. If none is specified, the default is ALL.
* | Specifies that all fields from the specified table or tables are selected.
table | The name of the table containing the fields from which records are selected.
field1, field2 | The names of the fields containing the data you want to retrieve. If you include more than one field, they are retrieved in the order listed.
alias1, alias2 | The names to use as column headers instead of the original column names in table.
tableexpression | The name of the table or tables containing the data you want to retrieve.
externaldatabase | The name of the database containing the tables in tableexpression if they are not in the current database.

Remarks

To perform this operation, the Microsoft® Jet database engine searches the specified table or tables, extracts the chosen columns, selects rows that meet the criterion, and sorts or groups the resulting rows into the order specified.

SELECT statements do not change data in the database.

SELECT is usually the first word in an SQL statement. Most SQL statements are either SELECT or SELECT…INTO statements.

The minimum syntax for a SELECT statement is:

SELECT fields FROM table

You can use an asterisk (*) to select all fields in a table. The following example selects all of the fields in the Employees table:

SQL Copy code Copy code
SELECT * FROM Employees;

If a field name is included in more than one table in the FROM clause, precede it with the table name and the . (dot) operator. In the following example, the Department field is in both the Employees table and the Supervisors table. The SQL statement selects departments from the Employees table and supervisor names from the Supervisors table:

SQL Copy code Copy code
SELECT Employees.Department, Supervisors.SupvName
FROM Employees INNER JOIN Supervisors
WHERE Employees.Department = Supervisors.Department;

When a Recordset object is created, the Microsoft Jet database engine uses the table's field name as the Field object name in the Recordset object. If you want a different field name or a name is not implied by the expression used to generate the field, use the AS reserved word. The following example uses the title Birth to name the returned Field object in the resulting Recordset object:

SQL Copy code Copy code
SELECT BirthDate
AS Birth FROM Employees;

Whenever you use aggregate functions or queries that return ambiguous or duplicate Field object names, you must use the AS clause to provide an alternate name for the Field object. The following example uses the title HeadCount to name the returned Field object in the resulting Recordset object:

SQL Copy code Copy code
SELECT COUNT(EmployeeID)
AS HeadCount FROM Employees;

You can use the other clauses in a SELECT statement to further restrict and organize your returned data. For more information, see the Help topic for the clause you are using.

Links provided by: Community Member Icon The UtterAccess community | About the Contributors

  • SQL to VBA Formatter

  • Viewing Records Within A Defined Range

Example

Some of the following examples assume the existence of a hypothetical Salary field in an Employees table. Note that this field does not actually exist in the Northwind database Employees table.

This example creates a dynaset-type Recordset based on an SQL statement that selects the LastName and FirstName fields of all records in the Employees table. It calls the EnumFields procedure, which prints the contents of a Recordset object to the Debug window.

VBA Copy code Copy code
Sub SelectX1()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Select the last name and first name values of all
    ' records in the Employees table.
    Set rst = dbs.OpenRecordset("SELECT LastName, " _
        & "FirstName FROM Employees;")

    ' Populate the recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset.
    EnumFields rst,12

    dbs.Close

End Sub

This example counts the number of records that have an entry in the PostalCode field and names the returned field Tally.

VBA Copy code Copy code
Sub SelectX2()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Count the number of records with a PostalCode
    ' value and return the total in the Tally field.
    Set rst = dbs.OpenRecordset("SELECT Count " _
        & "(PostalCode) AS Tally FROM Customers;")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of
    ' the Recordset. Specify field width = 12.
    EnumFields rst, 12

    dbs.Close

End Sub

This example shows the number of employees and the average and maximum salaries.

VBA Copy code Copy code
Sub SelectX3()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Count the number of employees, calculate the
    ' average salary, and return the highest salary.
    Set rst = dbs.OpenRecordset("SELECT Count (*) " _
        & "AS TotalEmployees, Avg(Salary) " _
        & "AS AverageSalary, Max(Salary) " _
        & "AS MaximumSalary FROM Employees;")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of
    ' the Recordset. Pass the Recordset object and
    ' desired field width.
    EnumFields rst, 17

    dbs.Close

End Sub

The Sub procedure EnumFields is passed a Recordset object from the calling procedure. The procedure then formats and prints the fields of the Recordset to the Debug window. The variable is the desired printed field width. Some fields may be truncated.

VBA Copy code Copy code
Sub EnumFields(rst As Recordset, intFldLen As Integer)

    Dim lngRecords As Long, lngFields As Long
    Dim lngRecCount As Long, lngFldCount As Long
    Dim strTitle As String, strTemp As String

    ' Set the lngRecords variable to the number of
    ' records in the Recordset.
    lngRecords = rst.RecordCount

    ' Set the lngFields variable to the number of
    ' fields in the Recordset.
    lngFields = rst.Fields.Count

    Debug.Print "There are " & lngRecords _
        & " records containing " & lngFields _
        & " fields in the recordset."
    Debug.Print

    ' Form a string to print the column heading.
    strTitle = "Record  "
    For lngFldCount = 0 To lngFields - 1
        strTitle = strTitle _
        & Left(rst.Fields(lngFldCount).Name _
        & Space(intFldLen), intFldLen)
    Next lngFldCount

    ' Print the column heading.
    Debug.Print strTitle
    Debug.Print

    ' Loop through the Recordset; print the record
    ' number and field values.
    rst.MoveFirst

    For lngRecCount = 0 To lngRecords - 1
        Debug.Print Right(Space(6) & _
            Str(lngRecCount), 6) & "  ";

        For lngFldCount = 0 To lngFields - 1
            ' Check for Null values.
            If IsNull(rst.Fields(lngFldCount)) Then
                strTemp = "<null>"
            Else
                ' Set strTemp to the field contents.
                Select Case _
                    rst.Fields(lngFldCount).Type
                    Case 11
                        strTemp = ""
                    Case dbText, dbMemo
                        strTemp = _
                            rst.Fields(lngFldCount)
                    Case Else
                        strTemp = _
                            str(rst.Fields(lngFldCount))
                End Select
            End If

            Debug.Print Left(strTemp _
                & Space(intFldLen), intFldLen);
        Next lngFldCount

        Debug.Print

        rst.MoveNext

    Next lngRecCount

End Sub

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.


Form.SelWidth Property (Access)

 Copy code hover
[image]

Form.SelWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SelWidth property to specify or determine the number of selected columns (fields) in the current selection rectangle. Read/write Long.

Syntax

expression .SelWidth

expression A variable that represents a Form object.

Remarks

If there's no selection, the value returned by this property will be zero. Setting this property to 0 removes the selection from the datasheet or form.

If you've selected one or more records in the datasheet (using the record selectors), you can't change the setting of the SelWidth property (except to set it to 0).

You can use these properties with the SelTop and SelLeft properties to specify or determine the actual position of the selection rectangle on the datasheet. If there's no selection, then the SelTop and SelLeft properties return the row number and column number of the cell with the focus.

The SelHeight and SelWidth properties contain the position of the lower-right corner of the selection rectangle. The SelTop and SelLeft property values determine the upper-left corner of the selection rectangle.

Example

The following example shows how to use the SelHeight, SelWidth, SelTop, and SelLeft properties to determine the position and size of a selection rectangle in datasheet view. The SetHeightWidth procedure assigns the height and width of the current selection rectangle to the variables lngNumRows, lngNumColumns, lngTopRow, and lngLeftColumn, and displays those values in a message box.

VBA Copy code Copy code
Public Sub SetHeightWidth(ByRef frm As Form)

 Dim lngNumRows As Long
 Dim lngNumColumns As Long
 Dim lngTopRow As Long
 Dim lngLeftColumn As Long
 Dim strMsg As String

 ' Form is in Datasheet view.
 If frm.CurrentView = 2 Then

 ' Number of rows selected.
 lngNumRows = frm.SelHeight

 ' Number of columns selected.
 lngNumColumns = frm.SelWidth

 ' Topmost row selected.
 lngTopRow = frm.SelTop

 ' Leftmost column selected.
 lngLeftColumn = frm.SelLeft

 ' Display message.
 strMsg = "Number of rows: " & lngNumRows & vbCrLf
 strMsg = strMsg & "Number of columns: " _
 & lngNumColumns & vbCrLf
 strMsg = strMsg & "Top row: " & lngTopRow & vbCrLf
 strMsg = strMsg & "Left column: " & lngLeftColumn
 MsgBox strMsg, vbInformation
 End If

End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Recordset.Requery Method (DAO)

 Copy code hover
[image]

Recordset.Requery Method (DAO)
Send feedback

Updates the data in a Recordset object by re-executing the query on which the object is based.

Syntax

expression .Requery(NewQueryDef)

expression A variable that represents a Recordset object.

Parameters

Name | Required/Optional | Data Type | Description
NewQueryDef | Optional | Variant | Represents the Name property value of a QueryDef object

Remarks

Use this method to make sure that a Recordset contains the most recent data. This method re-populates the current Recordset by using either the current query parameters or (in a Microsoft Access workspace) the new ones supplied by the newquerydef argument.

If you don't specify a newquerydef argument, the Recordset is re-populated based on the same query definition and parameters used to originally populate the Recordset. Any changes to the underlying data will be reflected during this re-population. If you didn't use a QueryDef to create the Recordset, the Recordset is re-created from scratch.

If you specify the original QueryDef in the newquerydef argument, then the Recordset is requeried using the parameters specified by the QueryDef. Any changes to the underlying data will be reflected during this re-population. To reflect any changes to the query parameter values in the Recordset, you must supply the newquerydef argument.

If you specify a different QueryDef than what was originally used to create the Recordset, the Recordset is re-created from scratch.

When you use Requery, the first record in the Recordset becomes the current record.

You can't use the Requery method on dynaset- or snapshot-type Recordset objects whose Restartable property is set to False. However, if you supply the optional newquerydef argument, the Restartable property is ignored.

If both the BOF and EOF property settings of the Recordset object are True after you use the Requery method, the query didn't return any records and the Recordset contains no data.

Example

This example shows how the Requery method can be used to refresh a query after underlying data has been changed.

VBA Copy code Copy code
Sub RequeryX()

 Dim dbsNorthwind As Database
 Dim qdfTemp As QueryDef
 Dim rstView As Recordset
 Dim rstChange As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set qdfTemp = dbsNorthwind.CreateQueryDef("", _
 "PARAMETERS ViewCountry Text; " & _
 "SELECT FirstName, LastName, Country FROM " & _
 "Employees WHERE Country = [ViewCountry] " & _
 "ORDER BY LastName")

 qdfTemp.Parameters!ViewCountry = "USA"
 Debug.Print "Data after initial query, " & _
 [ViewCountry] = USA"
 Set rstView = qdfTemp.OpenRecordset
 Do While Not rstView.EOF
 Debug.Print " " & rstView!FirstName & " " & _
 rstView!LastName & ", " & rstView!Country
 rstView.MoveNext
 Loop

 ' Change underlying data.
 Set rstChange = dbsNorthwind.OpenRecordset("Employees")
 rstChange.AddNew
 rstChange!FirstName = "Nina"
 rstChange!LastName = "Roberts"
 rstChange!Country = "USA"
 rstChange.Update

 rstView.Requery
 Debug.Print "Requery after changing underlying data"
 Set rstView = qdfTemp.OpenRecordset
 Do While Not rstView.EOF
 Debug.Print " " & rstView!FirstName & " " & _
 rstView!LastName & ", " & rstView!Country
 rstView.MoveNext
 Loop

 ' Restore original data because this is only a
 ' demonstration.
 rstChange.Bookmark = rstChange.LastModified
 rstChange.Delete
 rstChange.Close

 rstView.Close
 dbsNorthwind.Close

End Sub

This example shows how the Requery method can be used to refresh a query after the query parameters have been changed.

VBA Copy code Copy code
Sub RequeryX2()

 Dim dbsNorthwind As Database
 Dim qdfTemp As QueryDef
 Dim prmCountry As Parameter
 Dim rstView As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set qdfTemp = dbsNorthwind.CreateQueryDef("", _
 "PARAMETERS ViewCountry Text; " & _
 "SELECT FirstName, LastName, Country FROM " & _
 "Employees WHERE Country = [ViewCountry] " & _
 "ORDER BY LastName")
 Set prmCountry = qdfTemp.Parameters!ViewCountry

 qdfTemp.Parameters!ViewCountry = "USA"
 Debug.Print "Data after initial query, " & _
 [ViewCountry] = USA"
 Set rstView = qdfTemp.OpenRecordset
 Do While Not rstView.EOF
 Debug.Print " " & rstView!FirstName & " " & _
 rstView!LastName & ", " & rstView!Country
 rstView.MoveNext
 Loop

 ' Change query parameter.
 qdfTemp.Parameters!ViewCountry = "UK"
 ' QueryDef argument must be included so that the
 ' resulting Recordset reflects the change in the query
 ' parameter.
 rstView.Requery qdfTemp
 Debug.Print "Requery after changing parameter, " & _
 "[ViewCountry] = UK"
 Do While Not rstView.EOF
 Debug.Print " " & rstView!FirstName & " " & _
 rstView!LastName & ", " & rstView!Country
 rstView.MoveNext
 Loop

 rstView.Close
 dbsNorthwind.Close

End Sub


TextBox.Hyperlink Property (Access)

 Copy code hover
[image]

TextBox.Hyperlink Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.

Syntax

expression .Hyperlink

expression A variable that represents a TextBox object.

Example

The CreateHyperlink procedure in the following example sets the hyperlink properties for a command button, label, or image control to the address and subaddress values passed to the procedure. The address setting is an optional argument, because a hyperlink to an object in the current database uses only the subaddress setting, To try this example, create a form with two text box controls (txtAddress and txtSubAddress) and a command button (cmdFollowLink) and paste the following into the Declarations section of the form's module:

VBA Copy code Copy code
Private Sub cmdFollowLink_Click()
 CreateHyperlink Me!cmdFollowLink, Me!txtSubAddress, _
 Me!txtAddress
End Sub

Sub CreateHyperlink(ctlSelected As Control, _
 strSubAddress As String, Optional strAddress As String)
 Dim hlk As Hyperlink
 Select Case ctlSelected.ControlType
 Case acLabel, acImage, acCommandButton
 Set hlk = ctlSelected.Hyperlink
 With hlk
 If Not IsMissing(strAddress) Then
 .Address = strAddress
 Else
 .Address = ""
 End If
 .SubAddress = strSubAddress
 .Follow
 .Address = ""
 .SubAddress = ""
 End With
 Case Else
 MsgBox "The control '" & ctlSelected.Name _
 & "' does not support hyperlinks."
 End Select
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Report.Name Property (Access)

 Copy code hover
[image]

Report.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a Report object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

Report Object

Other resources

Report Object Members


TextBox.AutoLabel Property (Access)

 Copy code hover
[image]

TextBox.AutoLabel Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.

Syntax

expression .AutoLabel

expression A variable that represents a TextBox object.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


TabControl.FontWeight Property (Access)

 Copy code hover
[image]

TabControl.FontWeight Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.

Syntax

expression .FontWeight

expression A variable that represents a TabControl object.

Remarks

The DatasheetFontWeight property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

These properties are only available in Visual Basic within a Microsoft Access database.

In Visual Basic, the DatasheetFontWeight property setting uses the following Integer values.

Setting | Description
100 | Thin
200 | Extra Light
300 | Light
400 | (Default) Normal
500 | Medium
600 | Semi-bold
700 | Bold
800 | Extra Bold
900 | Heavy

The following table contains the properties that don't exist in the DAO Properties collection of until you set them by using the Formatting (Datasheet) toolbar or you can add them in an Access database by using the CreateProperty method and append it to the DAO Properties collection.

DatasheetFontItalic * | DatasheetForeColor *
DatasheetFontHeight * | DatasheetBackColor
DatasheetFontName * | DatasheetGridlinesColor
DatasheetFontUnderline * | DatasheetGridlinesBehavior
DatasheetFontWeight * | DatasheetCellsEffect
Note Note

When you add or set any property listed with an asterisk, Microsoft Access automatically adds all the properties listed with an asterisk to the Properties collection of the database.

Example

The following example sets the font to MS Serif, the font size to 10 points, and the font weight to medium (500) in Datasheet view of the Products table.

VBA Copy code Copy code

Sub SetDatasheetFont

   Dim dbs As Object, objProducts As Object
   Set dbs = CurrentDb
   Const DB_Text As Long = 10
   Const DB_Integer As Long = 3
   Set objProducts = dbs!Products

   SetTableProperty objProducts, "DatasheetFontName", DB_Text, "MS Serif"
   SetTableProperty objProducts, "DatasheetFontHeight", DB_Integer, 10
   SetTableProperty objProducts, "DatasheetFontWeight", DB_Integer, 500

End Sub

Sub SetTableProperty(objTableObj As Object, strPropertyName As String, _
        intPropertyType As Integer, varPropertyValue As Variant)
    ' Set Microsoft Access-defined table property without causing
    ' nonrecoverable run-time error.
    Const conErrPropertyNotFound = 3270
    Dim prpProperty As Variant
    On Error Resume Next                ' Don't trap errors.
    objTableObj.Properties(strPropertyName) = varPropertyValue
    If Err <> 0 Then                    ' Error occurred when value set.
        If Err <> conErrPropertyNotFound Then
            On Error GoTo 0
            MsgBox "Couldn't set property '" & strPropertyName _
                & "' on table '" & objTableObj.Name & "'", 48, "SetTableProperty"
        Else
            On Error GoTo 0
            Set prpProperty = objTableObj.CreateProperty(strPropertyName, _
                intPropertyType, varPropertyValue)
            objTableObj.Properties.Append prpProperty
        End If
    End If
    objTableObj.Properties.Refresh
End Sub

The next example makes the same changes as the preceding example in Datasheet view of the open Products form.

VBA Copy code Copy code
Forms!Products.DatasheetFontName = "MS Serif"
Forms!Products.DatasheetFontHeight = 10
Forms!Products.DatasheetFontWeight = 500

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


GroupLevel.Properties Property (Access)

 Copy code hover
[image]

GroupLevel.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a GroupLevel object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

GroupLevel Object

Other resources

GroupLevel Object Members


BoundObjectFrame.ControlTipText Property (Access)

 Copy code hover
[image]

BoundObjectFrame.ControlTipText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.

Syntax

expression .ControlTipText

expression A variable that represents a BoundObjectFrame object.

Remarks

You set the ControlTipText property by using a string expression up to 255 characters long.

For controls on forms, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

You can set the ControlTipText property in any view.

The ControlTipText property provides an easy way to provide helpful information about controls on a form.

There are other ways to provide information about a form or a control on a form. You can use the StatusBarText property to display information in the status bar about a control. To provide more extensive help for a form or control, use the HelpFile and HelpContextID properties.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Form.BorderStyle Property (Access)

 Copy code hover
[image]

Form.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies the type of border and border elements (title bar, Control menu, Minimize and Maximize buttons, or Close button) to use for the form. You typically use different border styles for normal forms, pop-up forms, and custom dialog boxes. Read/write Byte.

Syntax

expression .BorderStyle

expression A variable that represents a Form object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
None | 0 | The form has no border or related border elements. The form isn't resizable.
Thin | 1 | The form has a thin border and can include any of the border elements. The form isn't resizable (the Size command on the Control menu isn't available). You often use this setting for pop-up forms. (If you want a form to remain on top of all Microsoft Access windows, you must also set its PopUp property to Yes.)
Sizable | 2 | (Default) The form has the default border for Microsoft Access forms, can include any of the border elements, and can be resized. You often use this setting for normal Microsoft Access forms.
Dialog | 3 | The form has a thick (double) border and can include only a title bar, Close button, and Control menu. The form can't be maximized, minimized, or resized (the Maximize, Minimize, and Size commands aren't available on the Control menu). You often use this setting for custom dialog boxes. (If you want a form to be modal, however, you must also set its Modal property to Yes. If you want it to be a modal pop-up form, like most dialog boxes, you must set both its PopUp and Modal properties to Yes.)

For a form, the BorderStyle property establishes the characteristics that visually identify the form as a normal form, a pop-up form, or a custom dialog box. You may also set the Modal and PopUp properties to further define the form's characteristics.

You may also want to set the form's ControlBox , CloseButton, MinMaxButtons, ScrollBars, NavigationButtons, and RecordSelectors properties. These properties interact in the following ways:

  • If the BorderStyle property is set to None or Dialog, the form doesn't have Maximize or Minimize buttons, regardless of its MinMaxButtons property setting.

  • If the BorderStyle property is set to None, the form doesn't have a Control menu, regardless of its ControlBox property setting.

  • The BorderStyle property setting doesn't affect the display of the scroll bars, navigation buttons, record number box, or record selectors.

The BorderStyle property takes effect only in Form view. The property setting is ignored in form Design view.

If you set the BorderStyle property of a pop-up form to None, you won't be able to close the form unless you add a Close button to it that runs a macro containing the Close action or an event procedure in Visual Basic that uses the Close method.

Pop-up forms are typically fixed in size, but you can make a pop-up form sizable by setting its PopUp property to Yes and its BorderStyle property to Sizable.

See also

Concepts

Form Object

Other resources

Form Object Members


Label.MouseMove Event (Access)

 Copy code hover
[image]

Label.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents a Label object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

Label Object

Other resources

Label Object Members


CustomControl Object (Access)

 Copy code hover
[image]

CustomControl Object (Access)
See also Send feedback

Published: July 16, 2012

When setting the properties of an ActiveX control, you may need or prefer to use the control's custom properties dialog box. This custom properties dialog box provides an alternative to the list of properties in the Microsoft Access property sheet for setting ActiveX control properties in Design view.

Remarks

Note Note

This information only applies to ActiveX controls in a Microsoft Access database environment.

Two Ways to Set Properties

The reason for the custom properties dialog box is that not all applications that use ActiveX controls provide a property sheet like the one in Microsoft Access. The custom properties dialog box provides an interface for setting key control properties regardless of the interface supplied by the hosting application.

For some ActiveX control properties, you can choose either of these two locations to set the property:

  • The Microsoft Access property sheet.

  • The ActiveX control's custom properties dialog box.

In some cases, the custom properties dialog box is the only way to set a property in Design view. This is usually the situation when the interface needed to set a property doesn't work inside the Microsoft Access property sheet. For example, the GridFont property for the Calendar control has a number of arguments; you can't set more than one argument per property in the Microsoft Access property sheet.

Finding the Custom Properties Dialog Box

Not all ActiveX controls provide a custom properties dialog box. To see whether a control provides this custom properties dialog box, look for the Custom property in the Microsoft Access property sheet for this control. If the list of properties contains the name Custom, then the control provides the custom properties dialog box.

After you click the Custom property box in the Microsoft Access property sheet, click the Build button to the right of the property box to display the control's custom properties dialog box, often presented as a tabbed dialog box. Choose the tab that contains the interface for setting the properties that you want to set.

Using the Custom Properties Dialog Box

After you make changes on one tab, you can often apply those changes immediately by clicking the Apply button (if provided). You can click other tabs to set other properties as needed. To approve all changes made in the custom properties dialog box, click the OK button. To return to the Microsoft Access property sheet without changing any property settings, click the Cancel button.

You can also view the custom properties dialog box by clicking the Properties subcommand of the ActiveX control Object command (for example, Calendar Control Object) on the Edit menu, or by clicking this same subcommand on the shortcut menu for the ActiveX control. In addition, some properties in the Microsoft Access property sheet for the ActiveX control, like the GridFontColor property of the Calendar control, have a Build button to the right of the property box. When you click the Build button, the custom properties dialog box is displayed, with the appropriate tab selected (for example, Colors).

See also

Concepts

Access Object Model Reference

Other resources

CustomControl Object Members


TextBox.BottomMargin Property (Access)

 Copy code hover
[image]

TextBox.BottomMargin Property (Access)
See also Send feedback

Published: July 16, 2012

Along with the LeftMargin, RightMargin, and TopMargin properties, specifies the location of information displayed within a text box control. Read/write Integer.

Syntax

expression .BottomMargin

expression A variable that represents a TextBox object.

Remarks

A control's displayed information location is the distance measured from the control's left, top, right, or bottom border to the left, top, right, or bottom edge of the displayed information. To use a unit of measurement different from the setting in the regional settings of Windows, specify the unit (for example, cm or in).

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


The decimal field's precision is too small to accept the numeric you attempted to add. (Error 3761)

 Copy code hover
[image]

The decimal field's precision is too small to accept the numeric you attempted to add. (Error 3761)
Send feedback

This error occurs when the data being updated or inserted into a DECIMAL data type does not match the defined precision of the column.


CommandButton.FontWeight Property (Access)

 Copy code hover
[image]

CommandButton.FontWeight Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.

Syntax

expression .FontWeight

expression A variable that represents a CommandButton object.

Remarks

The DatasheetFontWeight property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

These properties are only available in Visual Basic within a Microsoft Access database.

In Visual Basic, the DatasheetFontWeight property setting uses the following Integer values.

Setting | Description
100 | Thin
200 | Extra Light
300 | Light
400 | (Default) Normal
500 | Medium
600 | Semi-bold
700 | Bold
800 | Extra Bold
900 | Heavy

The following table contains the properties that don't exist in the DAO Properties collection of until you set them by using the Formatting (Datasheet) toolbar or you can add them in an Access database by using the CreateProperty method and append it to the DAO Properties collection.

DatasheetFontItalic * | DatasheetForeColor *
DatasheetFontHeight * | DatasheetBackColor
DatasheetFontName * | DatasheetGridlinesColor
DatasheetFontUnderline * | DatasheetGridlinesBehavior
DatasheetFontWeight * | DatasheetCellsEffect
Note Note

When you add or set any property listed with an asterisk, Microsoft Access automatically adds all the properties listed with an asterisk to the Properties collection of the database.

Example

The following example sets the font to MS Serif, the font size to 10 points, and the font weight to medium (500) in Datasheet view of the Products table.

VBA Copy code Copy code

Sub SetDatasheetFont

   Dim dbs As Object, objProducts As Object
   Set dbs = CurrentDb
   Const DB_Text As Long = 10
   Const DB_Integer As Long = 3
   Set objProducts = dbs!Products

   SetTableProperty objProducts, "DatasheetFontName", DB_Text, "MS Serif"
   SetTableProperty objProducts, "DatasheetFontHeight", DB_Integer, 10
   SetTableProperty objProducts, "DatasheetFontWeight", DB_Integer, 500

End Sub

Sub SetTableProperty(objTableObj As Object, strPropertyName As String, _
        intPropertyType As Integer, varPropertyValue As Variant)
    ' Set Microsoft Access-defined table property without causing
    ' nonrecoverable run-time error.
    Const conErrPropertyNotFound = 3270
    Dim prpProperty As Variant
    On Error Resume Next                ' Don't trap errors.
    objTableObj.Properties(strPropertyName) = varPropertyValue
    If Err <> 0 Then                    ' Error occurred when value set.
        If Err <> conErrPropertyNotFound Then
            On Error GoTo 0
            MsgBox "Couldn't set property '" & strPropertyName _
                & "' on table '" & objTableObj.Name & "'", 48, "SetTableProperty"
        Else
            On Error GoTo 0
            Set prpProperty = objTableObj.CreateProperty(strPropertyName, _
                intPropertyType, varPropertyValue)
            objTableObj.Properties.Append prpProperty
        End If
    End If
    objTableObj.Properties.Refresh
End Sub

The next example makes the same changes as the preceding example in Datasheet view of the open Products form.

VBA Copy code Copy code
Forms!Products.DatasheetFontName = "MS Serif"
Forms!Products.DatasheetFontHeight = 10
Forms!Products.DatasheetFontWeight = 500

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Position Property (ADO)

 Copy code hover
[image]

Position Property (ADO)
Send feedback

Indicates the current position within a Stream object.

Settings and Return Values

Sets or returns a Long value that specifies the offset, in number of bytes, of the current position from the beginning of the stream. The default is 0, which represents the first byte in the stream.

Remarks

The current position can be moved to a point after the end of the stream. If you specify the current position beyond the end of the stream, the Size of the Stream object will be increased accordingly. Any new bytes added in this way will be null.

Note Note

Position always measures bytes. For text streams using multibyte character sets, multiply the position by the character size to determine the character number. For example, for a two-byte character set, the first character is at position 0, the second character at position 2, the third character at position 4, and so on.

Negative values cannot be used to change the current position in a Stream. Only positive numbers can be used for Position.

For read-only Stream objects, ADO will not return an error if Position is set to a value greater than the Size of the Stream. This does not change the size of the Stream, or alter the Stream contents in any way. However, doing this should be avoided because it results in a meaningless Position value.


Find Method (ADO)

 Copy code hover
[image]

Find Method (ADO)
Send feedback

Searches a Recordset for the row that satisfies the specified criteria. Optionally, the direction of the search, starting row, and offset from the starting row may be specified. If the criteria is met, the current row position is set on the found record; otherwise, the position is set to the end (or start) of the Recordset.

Syntax

Find (Criteria, SkipRows, SearchDirection, Start)

Parameters

  • Criteria

  • A String value that contains a statement specifying the column name, comparison operator, and value to use in the search.

  • SkipRows

  • Optional. A Long value, whose default value is zero, that specifies the row offset from the current row or Start bookmark to begin the search. By default, the search will start on the current row.

  • SearchDirection

  • Optional. A SearchDirectionEnum value that specifies whether the search should begin on the current row or the next available row in the direction of the search. An unsuccessful search stops at the end of the Recordset if the value is adSearchForward. An unsuccessful search stops at the start of the Recordset if the value is adSearchBackward.

  • Start

  • Optional. A Variant bookmark that functions as the starting position for the search.

Remarks

Only a single-column name may be specified in criteria. This method does not support multi-column searches.

The comparison operator in Criteria may be ">" (greater than), "<" (less than), "=" (equal), ">=" (greater than or equal), "<=" (less than or equal), "<>" (not equal), or "like" (pattern matching).

The value in Criteria may be a string, floating-point number, or date. String values are delimited with single quotes or "#" (number sign) marks (for example, "state = 'WA'" or "state = #WA#"). Date values are delimited with "#" (number sign) marks (for example, "start_date > #7/22/97#") and can contain hours, minutes and seconds to indicate time stamps but should not contain milliseconds or errors will occur.

If the comparison operator is "like", the string value may contain an asterisk (*) to find one or more occurrences of any character or substring. For example, "state like 'M*'" matches Maine and Massachusetts. You can also use leading and trailing asterisks to find a substring contained within the values. For example, "state like '*as*'" matches Alaska, Arkansas, and Massachusetts.

Asterisks can be used only at the end of a criteria string, or together at both the beginning and end of a criteria string, as shown above. You cannot use the asterisk as a leading wildcard ('*str'), or embedded wildcard ('s*r'). This will cause an error.

Note Note

An error will occur if a current row position is not set before calling Find. Any method that sets row position, such as MoveFirst, should be called before calling Find.
Note Note

If you call the Find method on a recordset, and the current position in the recordset is at the last record or end of file (EOF), you will not find anything. You need to call the MoveFirst method to set the current position/cursor to the beginning of the recordset.


CustomControl.GridlineColor Property (Access)

 Copy code hover
[image]

CustomControl.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified list box. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineColor

expression A variable that represents a CustomControl object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


DBEngine.CreateWorkspace Method (DAO)

 Copy code hover
[image]

DBEngine.CreateWorkspace Method (DAO)
Send feedback

Creates a new Workspace object.

Syntax

expression .CreateWorkspace(Name, UserName, Password, UseType)

expression A variable that represents a DBEngine object.

Parameters

Name

Required/Optional

Data Type

Description

Name

Required

String

A String that uniquely names the new Workspace object. See the Name property for details on valid Workspace names.

UserName

Required

String

A String that identifies the owner of the new Workspace object. See the UserName property for more information.

Password

Required

String

A String containing the password for the new Workspace object. The password can be up to 20 characters long and can include any characters except ASCII character 0 (null).

Note Note

Use strong passwords that combine upper- and lowercase letters, numbers, and symbols. Weak passwords don't mix these elements. Strong password: Y6dh!et5. Weak password: House27. Use a strong password that you can remember so that you don't have to write it down.

UseType

Optional

Variant

One of the WorkspaceTypeEnum values.

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Setting the type argument to dbUseODBC will result in a run-time error. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Return Value

Workspace

Remarks

Once you use the CreateWorkspace method to create a new Workspace object, a Workspace session is started, and you can refer to the Workspace object in your application.

Workspace objects aren't permanent, and you can't save them to disk. Once you create a Workspace object, you can't alter any of its property settings, except for the Name property, which you can modify before appending the Workspace object to the Workspaces collection.

You don't have to append the new Workspace object to a collection before you can use it. You append a newly created Workspace object only if you need to refer to it through the Workspaces collection.

To remove a Workspace object from the Workspaces collection, close all open databases and connections and then use the Close method on the Workspace object.

Example

This example uses the CreateWorkspace method to createMicrosoft Access workspace. It then lists the properties of the workspace.

VBA Copy code Copy code
Sub CreateWorkspaceX()

   Dim wrkAcc As Workspace
   Dim wrkLoop As Workspace
   Dim prpLoop As Property

   DefaultType = dbUseJet
   ' Create an unnamed Workspace object of the type
   ' specified by the DefaultType property of DBEngine
   ' (dbUseJet).
   Set wrkAcc = CreateWorkspace("", "admin", "")

   ' Enumerate Workspaces collection.
   Debug.Print "Workspace objects in Workspaces collection:"
   For Each wrkLoop In Workspaces
      Debug.Print "  " & wrkLoop.Name
   Next wrkLoop

   With wrkAcc
      ' Enumerate Properties collection of Microsoft Access
      ' workspace.
      Debug.Print _
         "Properties of unnamed Microsoft Access workspace"
      On Error Resume Next
      For Each prpLoop In .Properties
         Debug.Print "  " & prpLoop.Name & " = " & prpLoop
      Next prpLoop
      On Error GoTo 0
   End With

   wrkAcc.Close

End Sub


ToggleButton.MouseUp Event (Access)

 Copy code hover
[image]

ToggleButton.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents a ToggleButton object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was released to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Application.CommandBars Property (Access)

 Copy code hover
[image]

Application.CommandBars Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the CommandBars property to return a reference to the CommandBars collection object. Read-only CommandBars object.

Syntax

expression .CommandBars

expression A variable that represents an Application object.

Remarks

The CommandBars collection object is the collection of all built-in and custom command bars in an application. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 1 and the total number of member objects in the collection is the value of the CommandBars collection's Count property.

Once you establish a reference to the CommandBars collection object, you can access all the properties and methods of the object. You can set a reference to the CommandBars collection object by clicking References on the Tools menu while in module Design view. Set a reference to the Microsoft Office 12.0 Object Library in the References dialog box by selecting the appropriate check box.

See also

Concepts

Application Object

Other resources

Application Object Members


Form.OnTimer Property (Access)

 Copy code hover
[image]

Form.OnTimer Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Timer box in the Properties window of a form. Read/write String.

Syntax

expression .OnTimer

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Timer event occurs for a form at regular intervals as specified by the form's TimerInterval property.

The OnTimer value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Timer box in the form's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Timer box is blank, the property value is an empty string.

Example

The following example prints the value of the OnTimer property in the Immediate window for the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").OnTimer

See also

Concepts

Form Object

Other resources

Form Object Members


Report.UseDefaultPrinter Property (Access)

 Copy code hover
[image]

Report.UseDefaultPrinter Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Boolean indicating whether the specified report uses the default printer for the system; True if the form or report uses the default printer. Read/write.

Syntax

expression .UseDefaultPrinter

expression A variable that represents a Report object.

Remarks

This property is read/write in Design view and read-only in all other views.

When this property is True, the form or report inherits all of its printer settings from the settings of the default printer. Changing the printer associated with a form or report by assigning its Printer property to a Printer object sets the UseDefaultPrinter property to False.

Example

The following example checks to see if the specified form is using the default printer; if not, the user is asked if it should.

VBA Copy code Copy code
Function CheckPrinter(frmTemp As Form) As Boolean

 If frmTemp.UseDefaultPrinter = False Then
 If MsgBox("Should this form use " _
 & "the default printer?", _
 vbYesNo) = vbYes Then
 frmTemp.UseDefaultPrinter = True
 End If
 End If

End Function

See also

Concepts

Report Object

Other resources

Report Object Members


DataTypeEnum

 Copy code hover
[image]

DataTypeEnum
Send feedback

Specifies the data type of a Field, Parameter, or Property. The corresponding OLE DB type indicator is shown in parentheses in the description column of the following table. For more information about OLE DB data types, see Chapter 13 and Appendix A of the OLE DB Programmer's Reference.

Constant

Value

Description

AdArray
(Does not apply to ADOX.)

0x2000

A flag value, always combined with another data type constant, that indicates an array of that other data type.

adBigInt

20

Indicates an eight-byte signed integer (DBTYPE_I8).

adBinary

128

Indicates a binary value (DBTYPE_BYTES).

adBoolean

11

Indicates a boolean value (DBTYPE_BOOL).

adBSTR

8

Indicates a null-terminated character string (Unicode) (DBTYPE_BSTR).

adChapter

136

Indicates a four-byte chapter value that identifies rows in a child rowset (DBTYPE_HCHAPTER).

adChar

129

Indicates a string value (DBTYPE_STR).

adCurrency

6

Indicates a currency value (DBTYPE_CY). Currency is a fixed-point number with four digits to the right of the decimal point. It is stored in an eight-byte signed integer scaled by 10,000.

adDate

7

Indicates a date value (DBTYPE_DATE). A date is stored as a double, the whole part of which is the number of days since December 30, 1899, and the fractional part of which is the fraction of a day.

adDBDate

133

Indicates a date value (yyyymmdd) (DBTYPE_DBDATE).

adDBTime

134

Indicates a time value (hhmmss) (DBTYPE_DBTIME).

adDBTimeStamp

135

Indicates a date/time stamp (yyyymmddhhmmss plus a fraction in billionths) (DBTYPE_DBTIMESTAMP).

adDecimal

14

Indicates an exact numeric value with a fixed precision and scale (DBTYPE_DECIMAL).

adDouble

5

Indicates a double-precision floating-point value (DBTYPE_R8).

adEmpty

0

Specifies no value (DBTYPE_EMPTY).

adError

10

Indicates a 32-bit error code (DBTYPE_ERROR).

adFileTime

64

Indicates a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (DBTYPE_FILETIME).

adGUID

72

Indicates a globally unique identifier (GUID) (DBTYPE_GUID).

adIDispatch

9

Indicates a pointer to an IDispatch interface on a COM object (DBTYPE_IDISPATCH).

Note Note

This data type is currently not supported by ADO. Usage may cause unpredictable results.

adInteger

3

Indicates a four-byte signed integer (DBTYPE_I4).

adIUnknown

13

Indicates a pointer to an IUnknown interface on a COM object (DBTYPE_IUNKNOWN).

Note Note

This data type is currently not supported by ADO. Usage may cause unpredictable results.

adLongVarBinary

205

Indicates a long binary value.

adLongVarChar

201

Indicates a long string value.

adLongVarWChar

203

Indicates a long null-terminated Unicode string value.

adNumeric

131

Indicates an exact numeric value with a fixed precision and scale (DBTYPE_NUMERIC).

adPropVariant

138

Indicates an Automation PROPVARIANT (DBTYPE_PROP_VARIANT).

adSingle

4

Indicates a single-precision floating-point value (DBTYPE_R4).

adSmallInt

2

Indicates a two-byte signed integer (DBTYPE_I2).

adTinyInt

16

Indicates a one-byte signed integer (DBTYPE_I1).

adUnsignedBigInt

21

Indicates an eight-byte unsigned integer (DBTYPE_UI8).

adUnsignedInt

19

Indicates a four-byte unsigned integer (DBTYPE_UI4).

adUnsignedSmallInt

18

Indicates a two-byte unsigned integer (DBTYPE_UI2).

adUnsignedTinyInt

17

Indicates a one-byte unsigned integer (DBTYPE_UI1).

adUserDefined

132

Indicates a user-defined variable (DBTYPE_UDT).

adVarBinary

204

Indicates a binary value (Parameter object only).

adVarChar

200

Indicates a string value.

adVariant

12

Indicates an Automation Variant (DBTYPE_VARIANT).

Note Note

This data type is currently not supported by ADO. Usage may cause unpredictable results.

adVarNumeric

139

Indicates a numeric value (Parameter object only).

adVarWChar

202

Indicates a null-terminated Unicode character string.

adWChar

130

Indicates a null-terminated Unicode character string (DBTYPE_WSTR).

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.DataType.ARRAY

AdoEnums.DataType.BIGINT

AdoEnums.DataType.BINARY

AdoEnums.DataType.BOOLEAN

AdoEnums.DataType.BSTR

AdoEnums.DataType.CHAPTER

AdoEnums.DataType.CHAR

AdoEnums.DataType.CURRENCY

AdoEnums.DataType.DATE

AdoEnums.DataType.DBDATE

AdoEnums.DataType.DBTIME

AdoEnums.DataType.DBTIMESTAMP

AdoEnums.DataType.DECIMAL

AdoEnums.DataType.DOUBLE

AdoEnums.DataType.EMPTY

AdoEnums.DataType.ERROR

AdoEnums.DataType.FILETIME

AdoEnums.DataType.GUID

AdoEnums.DataType.IDISPATCH

AdoEnums.DataType.INTEGER

AdoEnums.DataType.IUNKNOWN

AdoEnums.DataType.LONGVARBINARY

AdoEnums.DataType.LONGVARCHAR

AdoEnums.DataType.LONGVARWCHAR

AdoEnums.DataType.NUMERIC

AdoEnums.DataType.PROPVARIANT

AdoEnums.DataType.SINGLE

AdoEnums.DataType.SMALLINT

AdoEnums.DataType.TINYINT

AdoEnums.DataType.UNSIGNEDBIGINT

AdoEnums.DataType.UNSIGNEDINT

AdoEnums.DataType.UNSIGNEDSMALLINT

AdoEnums.DataType.UNSIGNEDTINYINT

AdoEnums.DataType.USERDEFINED

AdoEnums.DataType.VARBINARY

AdoEnums.DataType.VARCHAR

AdoEnums.DataType.VARIANT

AdoEnums.DataType.VARNUMERIC

AdoEnums.DataType.VARWCHAR

AdoEnums.DataType.WCHAR


NavigationControl.Tabs Property (Access)

 Copy code hover
[image]

NavigationControl.Tabs Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the collection of navigation buttons for the specified navigation control. Read-only Children.

Version Information

Version Added: Access 2010

Syntax

expression .Tabs

expression A variable that represents a NavigationControl object.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


SetValue Macro Action

 Copy code hover
[image]

SetValue Macro Action
Send feedback

You can use the SetValue action to set the value of a Microsoft Access field, control, or property on a form, a form datasheet, or a report.

Note Note

You cannot use the SetValue action to set the value of an Access property that returns an object.
Note 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.

Setting

The SetValue action has the following arguments.

Action argument

Description

Item

The name of the field, control, or property whose value you want to set. Enter the field, control, or property name in the Item box in the Action Arguments section of the Macro Builder pane. You must use the full syntax to refer to this item, such as controlname (for a control on the form or report from which the macro was called) or Forms!formname!controlname. This is a required argument.

Expression

The expression Access uses to set the value for this item. You must always use the full syntax to refer to any objects in the expression. For example, to increase the value in a Salary control on an Employees form by 10 percent, use Forms!Employees!Salary*1.1. This is a required argument.

Note Note

You shouldn't use an equal sign (=) before the expression in this argument. If you do, Access evaluates the expression and then uses this value as the expression in this argument. This can produce unexpected results if the expression is a string.

For example, if you type ="String1" for this argument, Access first evaluates the expression as String1. Then it uses String1 as the expression in this argument, expecting to find a control or property named String1 on the form or report that called the macro.

Note Note

In an Access database (.mdb or .accdb), click the Build button to use the Expression Builder to create an expression for either of these arguments.

Remarks

You can use this action to set a value for a field or control on a form, a form datasheet, or a report. You can also set the value for almost all control, form, and report properties in any view. To find out whether a particular property can be set by using a macro and which views it can be set in, see the Help topic for that property in the Visual Basic Editor.

You can also set the value for a field in a form's underlying table even if the form doesn't contain a control bound to the field. Use the syntax Forms!formname!fieldname in the Item box to set the value for such a field. You can also refer to a field in a report's underlying table by using the syntax Reports!reportname!fieldname, but there must be a control on the report bound to this field, or the field must be referred to in a calculated control on the report.

If you set the value of a control on a form, the SetValue action doesn't trigger the control's form-level validation rules, but it does trigger the underlying field's table-level validation rules if the control is a bound control. The SetValue action also triggers recalculation, but the recalculation may not happen immediately. To trigger immediate repainting and force the recalculation to completion, use the RepaintObject action. The value you set in a control by using the SetValue action is also not affected by an input mask set in the control's or underlying field's InputMask property.

To change the value of a control, you can use the SetValue action in a macro specified by the control's AfterUpdate event property. However, you can't use the SetValue action in a macro specified by a control's BeforeUpdate event property to change the value of the control (although you can use the SetValue action to change the value of other controls). You can also use the SetValue action in a macro specified by the BeforeUpdate or AfterUpdate property of a form to change the value of any controls in the current record.

Note Note

You can't use the SetValue action to set the value of the following controls:

  • Bound controls and calculated controls on reports.

  • Calculated controls on forms.
Tip Tip

You can use the SetValue action to hide or show a form in Form view. Enter Forms!formname.Visible in the Item box and No or Yes in the Expression box. Setting a modal form's Visible property to No hides the form and makes it modeless. Setting the property to Yes displays the form and makes it modal again.

Changing the value of or adding new data in a control by using the SetValue action in a macro doesn't trigger events such as BeforeUpdate, BeforeInsert, or Change that occur when you change or enter data in these controls in the user interface. These events also don't occur if you set the value of the control by using a Visual Basic for Applications (VBA) module.

This action isn't available in a VBA module. Set the value directly in VBA.

Example

Set the value of a control by using a macro

The following macro opens the Add Products form from a button on the Suppliers form. It shows the use of the Echo, CloseWindow, OpenForm, SetValue, and GoToControl actions. The SetValue action sets the SupplierID control on the Products form to the current supplier on the Suppliers form. The GoToControl action then moves the focus to the CategoryID field, where you can begin to enter data for the new product. This macro should be attached to the Add Products button on the Suppliers form.

Action | Arguments: Setting | Comment
Echo | Echo On: No | Stop screen updating while the macro is running.
CloseWindow | Object Type: Form Object Name: Product List Save: No | Close the Product List form.
OpenForm | Form Name: Products View: Form Data Mode: Add Window Mode: Normal | Open the Products form.
SetValue | Item: [Forms]![Products]![SupplierID] Expression: SupplierID | Set the SupplierID control to the current supplier on the Suppliers form.
GoToControl | Control Name: CategoryID | Go to the CategoryID control.


CommandButton.LostFocus Event (Access)

 Copy code hover
[image]

CommandButton.LostFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The LostFocus event occurs when the specified object loses the focus.

Syntax

expression .LostFocus

expression A variable that represents a CommandButton object.

Remarks

To run a macro or event procedure when these events occur, set the OnLostFocus property to the name of the macro or to [Event Procedure].

This events occurs when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The LostFocus event differs from the Exit event in that the LostFocus event occurs every time a control loses the focus. The Exit event occurs only before a control loses the focus to another control on the same form. The LostFocus event occurs after the Exit event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


DROP Statement (Microsoft Access SQL)

 Copy code hover
[image]

DROP Statement (Microsoft Access SQL)
Send feedback

Deletes an existing table, procedure, or view from a database, or deletes an existing index from a table.

Note Note

The Microsoft Access database engine does not support the use of DROP, or any of the DDL statements, with non-Microsoft Access database engine databases. Use the DAO Delete method instead.

Syntax

DROP {TABLE table | INDEX index ON table | PROCEDURE procedure | VIEW view}

The DROP statement has these parts:

Part | Description
table | The name of the table to be deleted or the table from which an index is to be deleted.
procedure | The name of the procedure to be deleted.
view | The name of the view to be deleted.
index | The name of the index to be deleted from table.

Remarks

You must close the table before you can delete it or remove an index from it.

You can also use ALTER TABLE to delete an index from a table.

You can use CREATE TABLE to create a table and CREATE INDEX or ALTER TABLE to create an index. To modify a table, use ALTER TABLE.

Example

The following example assumes the existence of a hypothetical NewIndex index on the Employees table in the Northwind database.

This example deletes the index MyIndex from the Employees table.

VBA Copy code Copy code
Sub DropX1()

    Dim dbs As Database

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Delete NewIndex from the Employees table.
    dbs.Execute "DROP INDEX NewIndex ON Employees;"

    dbs.Close

End Sub

This example deletes the Employees table from the database.

VBA Copy code Copy code
Sub DropX2()

    Dim dbs As Database

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Delete the Employees table.
    dbs.Execute "DROP TABLE Employees;"

    dbs.Close

End Sub


TextBox.EventProcPrefix Property (Access)

 Copy code hover
[image]

TextBox.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents a TextBox object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ListBox.SetFocus Method (Access)

 Copy code hover
[image]

ListBox.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Syntax

expression .SetFocus

expression A variable that represents a ListBox object.

Return Value

Nothing

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.

Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.

Example

The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:

VBA Copy code Copy code
Forms!Employees!EmployeeID.SetFocus

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


OptionGroup.Tag Property (Access)

 Copy code hover
[image]

OptionGroup.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents an OptionGroup object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Basic RDS Programming Model

 Copy code hover
[image]

Basic RDS Programming Model
Send feedback

RDS addresses applications that exist in the following environment: A client application specifies a program that will execute on a server and the parameters required to return the desired information. The program invoked on the server gains access to the specified data source, retrieves the information, optionally processes the data, and then returns the resulting information to your client application in a form that it can easily use. RDS provides the means for you to perform the following sequence of actions:

  • Specify the program to be invoked on the server, and obtain a way to refer to it from the client. (This reference is sometimes called a proxy. It represents the remote server program. The client application will "call" the proxy as if it were a local program, but it actually invokes the remote server program.)

  • Invoke the server program. Pass parameters to the server program that identify the data source and the command to issue. (The server program actually uses ADO to gain access to the data source. ADO makes a connection with one of the given parameters, and then issues the command specified in the other parameter.)

  • The server program obtains a Recordset object from the data source. Optionally, the Recordset object is processed on the server.

  • The server program returns the final Recordset object to the client application.

  • On the client, the Recordset object is put into a form that can be easily used by visual controls.

  • Any modifications to the Recordset object are sent back to the server program, which uses them to update the data source.

This programming model contains certain convenience features. If you do not need a complex server program to access the data source, and if you provide the required connection and command parameters, RDS will automatically retrieve the specified data with a simple, default server program.

If you need more complex processing, you can specify your own custom server program. For example, because a custom server program has the full power of ADO at its disposal, it could connect to several different data sources, combine their data in some complex way, and then return a simple, processed result to the client application.

Finally, if your needs are somewhere in between, ADO now supports customizing the behavior of the default server program.


DeleteObject Macro Action

 Copy code hover
[image]

DeleteObject Macro Action
Send feedback

You can use the DeleteObject action to delete a specified database object.

Note 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.

Setting

The DeleteObject action has the following arguments.

Action argument | Description
Object Type | The type of object to delete. Click Table, Query, Form, Report, Macro, Module, Data Access Page, Server View, Diagram, Stored Procedure, or Function in the Object Type box in the Action Arguments section of the Macro Builder pane. To delete the object selected in the Navigation Pane, leave this argument blank.
Object Name | The name of the object to delete. The Object Name box shows all objects in the database of the type selected by the Object Type argument. If you leave the Object Type box blank, leave this box blank also. If you run a macro containing the DeleteObject action in a library database, Microsoft Office Access 2007 first looks for the object with this name in the library database, and then in the current database.
Caution note Caution

If you leave the Object Type and Object Name boxes blank, Access deletes the object selected in the Navigation Pane without displaying a warning message when it encounters the DeleteObject action.

Remarks

You can use the DeleteObject action to delete temporary objects you have created while running the macro. For example, you could use the OpenQuery action to run a make-table query that creates a temporary table. When you are finished using the temporary table, you can use the DeleteObject action to delete it.

This action has the same effect as selecting an object in the Navigation Pane and then pressing the DEL key, or right-clicking the object in the Navigation Pane and clicking Delete.

To run the DeleteObject action in a Visual Basic for Applications module, you can use the DeleteObject method of the DoCmd object.


Fields.Delete Method (DAO)

 Copy code hover
[image]

Fields.Delete Method (DAO)
Send feedback

Deletes a Field from the Fields collection.

Syntax

expression .Delete(Name)

expression A variable that represents a Fields object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Required | String | The field to delete.

Remarks

The deletion of a stored object occurs immediately, but you should use the Refresh method on any other collections that may be affected by changes to the database structure.

Example

This example uses either the Append method or the Delete method to modify the Fields collection of a TableDef. The AppendDeleteField procedure is required for this procedure to run.

VBA Copy code Copy code
Sub AppendX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim fldLoop As Field

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set tdfEmployees = dbsNorthwind.TableDefs!Employees

 ' Add three new fields.
 AppendDeleteField tdfEmployees, "APPEND", _
 "E-mail", dbText, 50
 AppendDeleteField tdfEmployees, "APPEND", _
 "Http", dbText, 80
 AppendDeleteField tdfEmployees, "APPEND", _
 "Quota", dbInteger, 5

 Debug.Print "Fields after Append"
 Debug.Print , "Type", "Size", "Name"

 ' Enumerate the Fields collection to show the new fields.
 For Each fldLoop In tdfEmployees.Fields
 Debug.Print , fldLoop.Type, fldLoop.Size, fldLoop.Name
 Next fldLoop

 ' Delete the newly added fields.
 AppendDeleteField tdfEmployees, "DELETE", "E-mail"
 AppendDeleteField tdfEmployees, "DELETE", "Http"
 AppendDeleteField tdfEmployees, "DELETE", "Quota"

 Debug.Print "Fields after Delete"
 Debug.Print , "Type", "Size", "Name"

 ' Enumerate the Fields collection to show that the new
 ' fields have been deleted.
 For Each fldLoop In tdfEmployees.Fields
 Debug.Print , fldLoop.Type, fldLoop.Size, fldLoop.Name
 Next fldLoop

 dbsNorthwind.Close

End Sub

Sub AppendDeleteField(tdfTemp As TableDef, _
 strCommand As String, strName As String, _
 Optional varType, Optional varSize)

 With tdfTemp

 ' Check first to see if the TableDef object is
 ' updatable. If it isn't, control is passed back to
 ' the calling procedure.
 If .Updatable = False Then
 MsgBox "TableDef not Updatable! " & _
 "Unable to complete task."
 Exit Sub
 End If

 ' Depending on the passed data, append or delete a
 ' field to the Fields collection of the specified
 ' TableDef object.
 If strCommand = "APPEND" Then
 .Fields.Append .CreateField(strName, _
 varType, varSize)
 Else
 If strCommand = "DELETE" Then .Fields.Delete _
 strName
 End If

 End With

End Sub


TempVars.Remove Method (Access)

 Copy code hover
[image]

TempVars.Remove Method (Access)
See also Send feedback

Published: July 16, 2012

Removes the specified TempVar object from the TempVars collection.

Version Information

Version Added: Access 2007

Syntax

expression .Remove(var)

expression A variable that represents a TempVars object.

Parameters

Name | Required/Optional | Data Type | Description
var | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the argument must be the name of a member of the collection.

See also

Concepts

TempVars Collection

Other resources

TempVars Object Members


WebBrowserControl.BorderColor Property (Access)

 Copy code hover
[image]

WebBrowserControl.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderColor

expression A variable that represents a WebBrowserControl object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


ToggleButton.OnMouseDown Property (Access)

 Copy code hover
[image]

ToggleButton.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Syntax

expression .OnMouseDown

expression A variable that represents a ToggleButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


CheckBox.GridlineStyleTop Property (Access)

 Copy code hover
[image]

CheckBox.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified check box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleTop

expression A variable that represents a CheckBox object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


DatabaseTypeEnum Enumeration (DAO)

 Copy code hover
[image]

DatabaseTypeEnum Enumeration (DAO)
Send feedback

Specifies the version of the data format for a compacted database.

Name | Value | Description
dbDecrypt | 4 | Decrypts database while compacting
dbEncrypt | 2 | Encrypts database
dbVersion10 | 1 | Microsoft Jet database engine version 1.0
dbVersion11 | 8 | Microsoft Jet database engine version 1.1
dbVersion120 | 128 | Microsoft Access database engine version 12.0
dbVersion20 | 16 | Microsoft Jet database engine version 2.0
dbVersion30 | 32 | Microsoft Jet database engine version 3.0
dbVersion40 | 64 | Microsoft Jet database engine version 4.0


AllQueries Properties (Access)

 Copy code hover
[image]

AllQueries Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject,.
Parent | Returns the parent object for the specified object. Read-only.


Office 2013 documentation copyright notice

 Copy code hover
[image]

Office 2013 documentation copyright notice
Send feedback

Published: July 16, 2012

This document is provided "as-is". Information and views expressed in this document, including URL and other Internet Web site references, may change without notice. You bear the risk of using it.

Some examples depicted herein are provided for illustration only and are fictitious. No real association or connection is intended or should be inferred.

This document does not provide you with any legal rights to any intellectual property in any Microsoft product. You may copy and use this document for your internal, reference purposes.

© 2013 Microsoft Corporation. All rights reserved.

Microsoft, Access, ActiveX, ClearType, Excel, FrontPage, InfoPath, IntelliSense, JScript, MSDN, MS-DOS, MSN, OneNote, Outlook, PowerPoint, SharePoint, Silverlight, SmartArt, SQL Server, Visio, Visual Basic, Visual C#, Visual C++, Visual Studio, Win32, Windows, Windows PowerShell, Windows Server, and Windows Vista are trademarks of the Microsoft group of companies.

All other trademarks are property of their respective owners.


The wait period for an event has timed out. (Error 3531)

 Copy code hover
[image]

The wait period for an event has timed out. (Error 3531)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


Could not save; currently locked by user

 Copy code hover
[image]

Could not save; currently locked by user <name> on machine <name>. (Error 3186)
Send feedback

Possible causes:

  • You tried to save a record on a 2K database page that is currently locked by another user. Wait for the other user to finish working with the record, and then try the operation again.


ToggleButton.HoverShade Property (Access)

 Copy code hover
[image]

ToggleButton.HoverShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the HoverColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .HoverShade

expression A variable that represents a ToggleButton object.

Remarks

The HoverShade property contains a numeric expression that can be used to darken the theme color in the HoverColor property. The default value of the HoverShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Attachment.HelpContextId Property (Access)

 Copy code hover
[image]

Attachment.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .HelpContextId

expression A variable that represents an Attachment object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the Help topic will display in a "full" Help topic window. If you add a minus sign ("-") in front of the context ID, the Help topic will be displayed in a pop-up window. It is important to note that the context ID does not have to have a negative number when created in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


AccessObjectProperties Properties (Access)

 Copy code hover
[image]

AccessObjectProperties Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObjectProperty.
Parent | Returns the parent object for the specified object. Read-only.


Subform/Subreport Control

 Copy code hover
[image]

Subform/Subreport Control
Send feedback

Published: July 16, 2012

The subform/subreport control embeds a form in a form or a report in a report.

For example, you can use a form with a subform to present one-to-many relationships, such as one product category with the items that fall into that category. In this case, the main form can display the category ID, name, and description; the subform can display the available products in that category.

Tip Tip

Instead of creating the main form, and then adding the subform control to it, you can simultaneously create the main form and subform with a wizard. You can also create a subform or subreport by dragging an existing form or report from the Database window to the main form or report.


ConnectModeEnum

 Copy code hover
[image]

ConnectModeEnum
Send feedback

Specifies the available permissions for modifying data in a Connection, opening a Record, or specifying values for the Mode property of the Record and Stream objects.

Constant | Value | Description
adModeRead | 1 | Indicates read-only permissions.
adModeReadWrite | 3 | Indicates read/write permissions.
adModeRecursive | 0x400000 | Used in conjunction with the other *ShareDeny* values (adModeShareDenyNone, adModeShareDenyWrite, or adModeShareDenyRead) to propagate sharing restrictions to all sub-records of the current Record. It has no affect if the Record does not have any children. A run-time error is generated if it is used with adModeShareDenyNone only. However, it can be used with adModeShareDenyNone when combined with other values. For example, you can use "adModeRead Or adModeShareDenyNone Or adModeRecursive".
adModeShareDenyNone | 16 | Allows others to open a connection with any permissions. Neither read nor write access can be denied to others.
adModeShareDenyRead | 4 | Prevents others from opening a connection with read permissions.
adModeShareDenyWrite | 8 | Prevents others from opening a connection with write permissions.
adModeShareExclusive | 12 | Prevents others from opening a connection.
adModeUnknown | 0 | Default. Indicates that the permissions have not yet been set or cannot be determined.
adModeWrite | 2 | Indicates write-only permissions.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.ConnectMode.READ

AdoEnums.ConnectMode.READWRITE

(There is no equivalent of AdoEnums.ConnectMode.RECURSIVE)

AdoEnums.ConnectMode.SHAREDENYNONE

AdoEnums.ConnectMode.SHAREDENYREAD

AdoEnums.ConnectMode.SHAREDENYWRITE

AdoEnums.ConnectMode.SHAREEXCLUSIVE

AdoEnums.ConnectMode.UNKNOWN

AdoEnums.ConnectMode.WRITE


Invalid database object reference. (Error 3276)

 Copy code hover
[image]

Invalid database object reference. (Error 3276)
Send feedback

The Database object specified is not the result of the OpenDatabase method, or it has been modified and is no longer valid.


Forms.Parent Property (Access)

 Copy code hover
[image]

Forms.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a Forms object.

See also

Concepts

Forms Collection

Other resources

Forms Object Members


TabControl.ForeShade Property (Access)

 Copy code hover
[image]

TabControl.ForeShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .ForeShade

expression A variable that represents a TabControl object.

Remarks

The ForeShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the ForeShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens ForeColor by 75%.

VBA Copy code Copy code
Me.ctl.ForeShade=25

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


There is already a relationship named

 Copy code hover
[image]

There is already a relationship named <name> in the current database. (Error 3378)
Send feedback

You must specify a unique name for each relationship you add to a database by using data-definition queries. Check to see if the name you specified exists in the Relations collection.


CheckBox.Value Property (Access)

 Copy code hover
[image]

CheckBox.Value Property (Access)
See also Send feedback

Published: July 16, 2012

Determines or specifies whether or not the specifed check box is checked. Read /write Variant.

Syntax

expression .Value

expression A variable that represents a CheckBox object.

Remarks

Set to True to select the check box. The default value is False.

The Value property returns or sets a control's default property, which is the property that is assumed when you don't explicitly specify a property name.

Note Note

The Value property is not the same as the DefaultValue property, which specifies the value that a property is assigned when a new record is created.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Cannot join more than one table with the same name

 Copy code hover
[image]

Cannot join more than one table with the same name <name>. (Error 3081)
Send feedback

You tried to join two or more tables that have the same name. Select different tables, rename one of the tables, or use an alias, and then try the operation again. If you are trying to join a table to itself, use a table alias to change the second reference to the table.


Form.PrtDevMode Property (Access)

 Copy code hover
[image]

Form.PrtDevMode Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PrtDevMode property to set or return printing device mode information specified for a form or report in the Print dialog box. Read/write Variant.

Syntax

expression .PrtDevMode

expression A variable that represents a Form object.

Remarks

It is strongly recommended that you consult the Win32 Software Development Kit for complete documentation on the PrtDevMode, PrtDevNames, and PrtMip properties.

The PrtDevMode property setting is a 94-byte structure that mirrors the DEVMODE structure defined in the Win32 Software Development Kit. For complete information on the PrtDevMode property members, consult the Win32 Software Development Kit.

The PrtDevMode property uses the following members.

Member | Description
DeviceName | A string with a maximum of 32 bytes that specifies the name of the device the driver supports — for example, "HP LaserJet IIISi" if the Hewlett-Packard LaserJet IIISi is the specified printer. Each printer driver has a unique string.
SpecVersion | An Integer that specifies the version number of the DEVMODE structure in the Win32 Software Development Kit.
DriverVersion | An Integer that specifies the printer driver version number assigned by the printer driver developer.
Size | An Integer that specifies the size, in bytes, of the DEVMODE structure. (This value doesn't include the optional dmDriverData member for device-specific data, which can follow this structure.) If an application manipulates only the driver-independent portion of the data, you can use this member to find out the length of this structure without having to account for different versions.
DriverExtra | An Integer that specifies the size, in bytes, of the optional dmDriverData member for device-specific data, which can follow this structure. If an application doesn't use device-specific information, you set this member to 0.
Fields | A Long value that specifies which of the remaining members in the DEVMODE structure have been initialized.
Orientation | An Integer that specifies the orientation of the paper. It can be either 1 (portrait) or 2 (landscape).
PaperSize | An Integer that specifies the size of the paper to print on. If you set this member to 0 or 256, the length and width of the paper are specified by the PaperLength and PaperWidth members, respectively. Otherwise, you can set the PaperSize member to a predefined value. For available values, see the PaperSize member values .
PaperLength | An Integer that specifies the paper length in units of 1/10 of a millimeter. This member overrides the paper length specified by the PaperSize member for custom paper sizes or for devices such as dot-matrix printers that can print on a variety of paper sizes.
PaperWidth | An Integer that specifies the paper width in units of 1/10 of a millimeter. This member overrides the paper width specified by the PaperSize member.
Scale | An Integer that specifies the factor by which the printed output will be scaled. The apparent page size is scaled from the physical page size by a factor of scale/100. For example, a piece of paper measuring 8.5 by 11 inches (letter-size) with a Scale value of 50 would contain as much data as a page measuring 17 by 22 inches because the output text and graphics would be half their original height and width.
Copies | An Integer that specifies the number of copies printed if the printing device supports multiple-page copies.
DefaultSource | An Integer that specifies the default bin from which the paper is fed. For available values, see the DefaultSource member values .
PrintQuality | An Integer that specifies the printer resolution. The values are -4 (high), -3 (medium), -2 (low), and -1 (draft).
Color | An Integer. For a color printer, specifies whether the output is printed in color. The values are 1 (color) and 2 (monochrome).
Duplex | An Integer. For a printer capable of duplex printing, specifies whether the output is printed on both sides of the paper. The values are 1 (simplex), 2 (horizontal), and 3 (vertical).
YResolution | An Integer that specifies the y-resolution of the printer in dots per inch (dpi). If the printer initializes this member, the PrintQuality member specifies the x-resolution of the printer in dpi.
TTOption | An Integer that specifies how TrueType fonts will be printed. For available values, see the TTOption member values .
Collate | An Integer that specifies whether collation should be used when printing multiple copies. Using uncollated copies provides faster, more efficient output, since the data is sent to the printer just once.
FormName | A string with a maximum of 16 characters that specifies the size of paper to use; for example, "Letter" or "Legal".
Pad | A Long value that is used to pad out spaces, characters, or values for future versions.
Bits | A Long value that specifies in bits per pixel the color resolution of the display device.
PW | A Long value that specifies the width, in pixels, of the visible device surface (screen or printer).
PH | A Long value that specifies the height, in pixels, of the visible device surface (screen or printer).
DFI | A Long value that specifies the device's display mode.
DFR | A Long value that specifies the frequency, in hertz (cycles per second), of the display device in a particular mode.

This property setting is read/write in Design view and read-only in other views.

Printer drivers can add device-specific data immediately following the 94 bytes of the DEVMODE structure. For this reason, it is important that the DEVMODE data outlined above not exceed 94 bytes.

Only printer drivers that export the ExtDeviceMode function use the DEVMODE structure.

An application can retrieve the paper sizes and names supported by a printer by using the DC_PAPERS, DC_PAPERSIZE, and DC_PAPERNAMES values to call the DeviceCapabilities function.

Before setting the value of the TTOption member, applications should find out how a printer driver can use TrueType fonts by using the DC_TRUETYPE value to call the DeviceCapabilities function.

Example

The following example uses the PrtDevMode property to check the user-defined page size for a report:

VBA Copy code Copy code
Private Type str_DEVMODE
 RGB As String * 94
End Type

Private Type type_DEVMODE
 strDeviceName As String * 32
 intSpecVersion As Integer
 intDriverVersion As Integer
 intSize As Integer
 intDriverExtra As Integer
 lngFields As Long
 intOrientation As Integer
 intPaperSize As Integer
 intPaperLength As Integer
 intPaperWidth As Integer
 intScale As Integer
 intCopies As Integer
 intDefaultSource As Integer
 intPrintQuality As Integer
 intColor As Integer
 intDuplex As Integer
 intResolution As Integer
 intTTOption As Integer
 intCollate As Integer
 strFormName As String * 32
 lngPad As Long
 lngBits As Long
 lngPW As Long
 lngPH As Long
 lngDFI As Long
 lngDFr As Long
End Type

Public Sub CheckCustomPage(ByVal rptName As String)

 Dim DevString As str_DEVMODE
 Dim DM As type_DEVMODE
 Dim strDevModeExtra As String
 Dim rpt As Report
 Dim intResponse As Integer

 ' Opens report in Design view.
 DoCmd.OpenReport rptName, acDesign
 Set rpt = Reports(rptName)

 If Not IsNull(rpt.PrtDevMode) Then
 strDevModeExtra = rpt.PrtDevMode

 ' Gets current DEVMODE structure.
 DevString.RGB = strDevModeExtra
 LSet DM = DevString
 If DM.intPaperSize = 256 Then

 ' Display user-defined size.
 intResponse = MsgBox("The current custom page size is " & _
 DM.intPaperWidth / 254 & " inches wide by " & _
 DM.intPaperLength / 254 & " inches long. Do you want " & _
 "to change the settings?", vbYesNo + vbQuestion)
 Else
 ' Currently not user-defined.
 intResponse = MsgBox("The report does not have a custom page size. " & _
 "Do you want to define one?", vbYesNo + vbQuestion)
 End If

 If intResponse = vbYes Then
 ' User wants to change settings. Initialize fields.
 DM.lngFields = DM.lngFields Or DM.intPaperSize Or _
 DM.intPaperLength Or DM.intPaperWidth

 ' Set custom page.
 DM.intPaperSize = 256

 ' Prompt for length and width.
 DM.intPaperLength = InputBox("Please enter page length in inches.") * 254
 DM.intPaperWidth = InputBox("Please enter page width in inches.") * 254

 ' Update property.
 LSet DevString = DM
 Mid(strDevModeExtra, 1, 94) = DevString.RGB
 rpt.PrtDevMode = strDevModeExtra
 End If
 End If

 Set rpt = Nothing

End Sub

The following example shows how to change the orientation of the report. This example will switch the orientation from portrait to landscape or landscape to portrait depending on the report's current orientation.

VBA Copy code Copy code
Public Sub SwitchOrient(ByVal strName As String)

 Const DM_PORTRAIT = 1
 Const DM_LANDSCAPE = 2
 Dim DevString As str_DEVMODE
 Dim DM As type_DEVMODE
 Dim strDevModeExtra As String
 Dim rpt As Report

 ' Opens report in Design view.
 DoCmd.OpenReport strName, acDesign
 Set rpt = Reports(strName)

 If Not IsNull(rpt.PrtDevMode) Then
 strDevModeExtra = rpt.PrtDevMode
 DevString.RGB = strDevModeExtra
 LSet DM = DevString
 DM.lngFields = DM.lngFields Or DM.intOrientation

 ' Initialize fields.
 If DM.intOrientation = DM_PORTRAIT Then
 DM.intOrientation = DM_LANDSCAPE
 Else
 DM.intOrientation = DM_PORTRAIT
 End If

 ' Update property.
 LSet DevString = DM
 Mid(strDevModeExtra, 1, 94) = DevString.RGB
 rpt.PrtDevMode = strDevModeExtra
 End If

 Set rpt = Nothing

End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


IIF function without (). (Error 2440)

 Copy code hover
[image]

IIF function without (). (Error 2440)
Send feedback

The IIf function requires parentheses around its arguments, as shown in the following syntax:

IIf(expr, truepart, falsepart)


Attachment.OnGotFocus Property (Access)

 Copy code hover
[image]

Attachment.OnGotFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnGotFocus

expression A variable that represents an Attachment object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The GotFocus event occurs when the object receives the focus.

The OnGotFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Got Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Got Focus box is blank, the property value is an empty string.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Step 4: Receive and Display the Data
Send feedback

Step 4: Receive and Display the Data

In this step you will create an HTML file with an embedded RDS.DataControl object that points at the XMLResponse.asp file to get the Recordset. Open default.htm with a text editor, such as Windows Notepad, and add the code below. Replace "sqlserver" in the URL with the name of your server computer.

Copy code Copy code

<HTML>
<HEAD><TITLE>ADO Recordset Persistence Sample</TITLE></HEAD>
<BODY>

<TABLE DATASRC="#RDC1" border="1">
  <TR>
<TD><SPAN DATAFLD="title"></SPAN></TD>
<TD><SPAN DATAFLD="price"></SPAN></TD>
  </TR>
</TABLE>
<OBJECT CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID="RDC1">
   <PARAM NAME="URL" VALUE="XMLResponse.asp">
</OBJECT>

</BODY>
</HTML>

Close the default.htm file and save it to the same folder where you saved XMLResponse.asp. Using Internet Explorer 4.0 or later, open the URL http://sqlserver/XMLPersist/default.htm and observe the results. The data is displayed in a bound DHTML table. Now open the URL http://sqlserver/XMLPersist/XMLResponse.asp and observe the results. The XML is displayed.


FormatCondition Object (Access)

 Copy code hover
[image]

FormatCondition Object (Access)
See also Send feedback

Published: July 16, 2012

The FormatCondition object represents a conditional format of a combo box or text box control and is a member of the FormatConditions collection.

Remarks

You can use the FormatConditions(index), where index is the index number of the conditional format, to return a FormatCondition object.

Use the Add method to create a new conditional format. You can use the Modify method to change one of the formats, or the Delete method to delete a format.

Use the BackColor , Enabled , FontBold , FontItalic , FontUnderline , and ForeColor properties of the FormatCondition object to control the appearance of formatted combo box and text box controls.

See also

Concepts

Access Object Model Reference

Other resources

FormatCondition Object Members


Dropbox address

 Copy code hover
[image]

Dropbox address <name> is syntactically invalid. (Error 3477)
Send feedback

Reset your dropbox folder.


OptionGroup Properties (Access)

 Copy code hover
[image]

OptionGroup Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
ColumnHidden | You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.
ColumnOrder | You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.
ColumnWidth | You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DefaultValue | Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HideDuplicates | You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the option group is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
ValidationRule | You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.
ValidationText | Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.
Value | Gets or sets whether or not the specified option button is selected. Read/write Variant.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified option group is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


Filter and RecordCount Properties Example (JScript)

 Copy code hover
[image]

Filter and RecordCount Properties Example (JScript)
Send feedback

This example opens a Recordset on the Companies table of the Northwind database and then uses the Filter property to limit the records visible to those where the CompanyName field starts with the letter D. Cut and paste the following code to Notepad or another text editor, and save it as FilterJS.asp.


How to: Add a Value to a Bound Combo Box

 Copy code hover
[image]

How to: Add a Value to a Bound Combo Box
Send feedback

Combo boxes are commonly used to display a list of values in a table or query. By responding to the NotInList event, you can provide a way for the user to add values that are not in the list.

Often the value displayed in a combo box is looked up from a record in a related table. Because the list is derived from a table or query, you must provide a way for the user to enter a new record in the underlying table. Then you can use the Requery method to requery the list, so it contains the new value.

When a user types a value in a combo box that is not in the list, the NotInList event of the combo box occurs as long as the combo box's LimitToList property is set to Yes, or a column other than the combo box's bound column is displayed in the box. You can write an event procedure for the NotInList event that provides a way for the user to add a new record to the table that supplies the list's values. The NotInList event procedure includes a string argument named NewData that Access uses to pass the text the user enters to the event procedure.

The NotInList event procedure also has a Response argument, in which you tell Access what to do after the procedure runs. Depending on what action you take in the event procedure, you set the Response argument to one of three predefined constant values:

Constant | Description
acDataErrAdded | If your event procedure enters the new value in the record source for the list or provides a way for the user to do so, set the Response argument to acDataErrAdded. Access then requeries the combo box for you, adding the new value to the list.
acDataErrDisplay | If you do not add the new value and want Access to display the default error message, set the Response argument to acDataErrDisplay. Access requires the user to enter a valid value from the list.
acDataErrContinue | If you display your own message in the event procedure, set the Response argument to acDataErrContinue. Access does not display its default error message, but still requires the user to enter a value in the field. If you do not want the user to select an existing value from the list, you can undo changes to the field by using the Undo method.

For example, the following event procedure asks the user whether to add a value to a list, adds the value, and then uses the Response argument to tell Access to requery the list:

Copy code Copy code
Private Sub ShipperID_NotInList(NewData As String, Response As Integer)

   Dim dbsOrders As DAO.Database
   Dim rstShippers As DAO.Recordset
   Dim intAnswer As Integer

On Error GoTo ErrorHandler

   intAnswer = MsgBox("Add " & NewData & " to the list of shippers?", _
      vbQuestion + vbYesNo)

   If intAnswer = vbYes Then

      ' Add shipper stored in NewData argument to the Shippers table.
      Set dbsOrders = CurrentDb
      Set rstShippers = dbsOrders.OpenRecordset("Shippers")
      rstShippers.AddNew
      rstShippers!CompanyName = NewData
      rstShippers.Update

      Response = acDataErrAdded         ' Requery the combo box list.
   Else
      Response = acDataErrDisplay       ' Require the user to select
                                        ' an existing shipper.
   End If

   rstShippers.Close
   dbsOrders.Close

   Set rstShippers = Nothing
   Set dbsOrders = Nothing

   Exit Sub

ErrorHandler:
   MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Sub


ADOX Objects Reference

 Copy code hover
[image]

ADOX Objects Reference
Send feedback

In this section

  • ADOX Objects

  • Catalog Object (ADOX) Reference

  • Column Object (ADOX) Reference

  • Group Object (ADOX) Reference

  • Index Object (ADOX) Reference

  • Key Object (ADOX) Reference

  • Procedure Object (ADOX) Reference

  • Table Object (ADOX) Reference

  • User Object (ADOX) Reference

  • View Object (ADOX) Reference


DefaultDatabase Property (ADO)

 Copy code hover
[image]

DefaultDatabase Property (ADO)
Send feedback

Indicates the default database for a Connection object.

Settings and Return Values

Sets or returns a String value that evaluates to the name of a database available from the provider.

Remarks

Use the DefaultDatabase property to set or return the name of the default database on a specific Connection object.

If there is a default database, SQL strings may use an unqualified syntax to access objects in that database. To access objects in a database other than the one specified in the DefaultDatabase property, you must qualify object names with the desired database name. Upon connection, the provider will write default database information to the DefaultDatabase property. Some providers allow only one database per connection, in which case you cannot change the DefaultDatabase property.

Some data sources and providers may not support this feature, and may return an error or an empty string.

Remote Data Service UsageThis property is not available on a client-side Connection object.


Form.Modal Property (Access)

 Copy code hover
[image]

Form.Modal Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Modal property to specify whether a form opens as a modal window. When a form opens as a modal window, you must close the window before you can move the focus to another object. Read/write Boolean.

Syntax

expression .Modal

expression A variable that represents a Form object.

Remarks

The Modal property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The form or report opens as a modal window.
No | False | (Default) The form opens as a non-modal window.

When you open a modal window, other windows in Microsoft Access are disabled until you close the form (although you can switch to windows in other applications). To disable menus and toolbars in addition to other windows, set both the Modal and PopUp properties to Yes.

You can use the BorderStyle property to specify the kind of border a form will have. Typically, modal forms have the BorderStyle property set to Dialog.

You can use the Modal, PopUp, and BorderStyle properties to create a custom dialog box. You can set Modal to Yes, PopUp to Yes, and BorderStyle to Dialog for custom dialog boxes.

Setting the Modal property to Yes makes the form modal only when you:

  • Open it in Form view from the Database window.

  • Open it in Form view by using a macro or Visual Basic.

  • Switch from Design view to Form view.

When the form is modal, you can't switch to Datasheet view from Form view, although you can switch to Design view and then to Datasheet view.

The form isn't modal in Design view or Datasheet view and also isn't modal if you switch from Datasheet view to Form view.

Note Note

You can use the Dialog setting of the Window Mode action argument of the OpenForm action to open a form with its Modal and PopUp properties set to Yes.

See also

Concepts

Form Object

Other resources

Form Object Members


AllMacros Object (Access)

 Copy code hover
[image]

AllMacros Object (Access)
See also Send feedback

Published: July 16, 2012

The AllMacros collection contains an AccessObject for each macro in the CurrentProject or CodeProject object.

Remarks

The CurrentProject or CodeProject object has an AllMacros collection containing AccessObject objects that describe instances of all the macros specified by CurrentProject or CodeProject. For example, you can enumerate the AllMacros collection in Visual Basic to set or return the values of properties of individual AccessObject objects in the collection.

You can refer to an individual AccessObject object in the AllMacros collection either by referring to the object by name, or by referring to its index within the collection. If you want to refer to a specific object in the AllMacros collection, it's better to refer to the macro by name because a macro's collection index may change.

The AllMacros collection is indexed beginning with zero. If you refer to a macro by its index, the first macro is AllMacros(0), the second macro is AllMacros(1), and so on.

Note Note

To list all open macros in the database, use the IsLoaded property of each AccessObject object in the AllMacros collection. You can then use the Name property of each individual AccessObject object to return the name of a macro.

You can't add or delete an AccessObject object from the AllMacros collection.

Example

The following example prints the name of each open AccessObject object in the AllMacros collection.

VBA Copy code Copy code
Sub AllMacros()
 Dim obj As AccessObject, dbs As Object
 Set dbs = Application.CurrentProject
 ' Search for open AccessObject objects in AllMacros collection.
 For Each obj In dbs.AllMacros
 If obj.IsLoaded = True Then
 ' Print name of obj.
 Debug.Print obj.Name
 End If
 Next obj
End Sub

See also

Concepts

Access Object Model Reference

Other resources

AllMacros Object Members


ObjectFrame.EventProcPrefix Property (Access)

 Copy code hover
[image]

ObjectFrame.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents an ObjectFrame object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


LanguageConstants Enumeration (DAO)

 Copy code hover
[image]

LanguageConstants Enumeration (DAO)
Send feedback

Specifies a collating order for creating a database.

Name | Value | Description
dbLangArabic | ";LANGID=0x0401;CP=1256;COUNTRY=0" | Arabic
dbLangChineseSimplified | ";LANGID=0x0804;CP=936;COUNTRY=0" | Simplified Chinese
dbLangChineseTraditional | ";LANGID=0x0404;CP=950;COUNTRY=0" | Traditional Chinese
dbLangCyrillic | ";LANGID=0x0419;CP=1251;COUNTRY=0" | Russian
dbLangCzech | ";LANGID=0x0405;CP=1250;COUNTRY=0" | Czech
dbLangDutch | ";LANGID=0x0413;CP=1252;COUNTRY=0" | Dutch
dbLangGeneral | ";LANGID=0x0409;CP=1252;COUNTRY=0" | English, German, French, Portuguese, Italian, and Modern Spanish
dbLangGreek | ";LANGID=0x0408;CP=1253;COUNTRY=0" | Greek
dbLangHebrew | ";LANGID=0x040D;CP=1255;COUNTRY=0" | Hebrew
dbLangHungarian | ";LANGID=0x040E;CP=1250;COUNTRY=0" | Hungarian
dbLangIcelandic | ";LANGID=0x040F;CP=1252;COUNTRY=0" | Icelandic
dbLangJapanese | ";LANGID=0x0411;CP=932;COUNTRY=0" | Japanese
dbLangKorean | ";LANGID=0x0412;CP=949;COUNTRY=0" | Korean
dbLangNordic | ";LANGID=0x041D;CP=1252;COUNTRY=0" | Nordic
dbLangNorwDan | ";LANGID=0x0406;CP=1252;COUNTRY=0" | Norwegian and Danish
dbLangPolish | ";LANGID=0x0415;CP=1250;COUNTRY=0" | Polish
dbLangSlovenian | ";LANGID=0x0424;CP=1250;COUNTRY=0" | Slovenian
dbLangSpanish | ";LANGID=0x040A;CP=1252;COUNTRY=0" | Spanish
dbLangSwedFin | ";LANGID=0x041D;CP=1252;COUNTRY=0" | Swedish and Finnish
dbLangThai | ";LANGID=0x041E;CP=874;COUNTRY=0" | Thai
dbLangTurkish | ";LANGID=0x041F;CP=1254;COUNTRY=0" | Turkish


Line.Left Property (Access)

 Copy code hover
[image]

Line.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Syntax

expression .Left

expression A variable that represents a Line object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

Line Object

Other resources

Line Object Members


Forms Object (Access)

 Copy code hover
[image]

Forms Object (Access)
See also Send feedback

Published: July 16, 2012

The Forms collection contains all of the currently open forms in a Microsoft Access database.

Remarks

Use the Forms collection in Visual Basic or in an expression to refer to forms that are currently open. For example, you can enumerate the Forms collection to set or return the values of properties of individual forms in the collection.

You can refer to an individual Form object in the Forms collection either by referring to the form by name, or by referring to its index within the collection. If you want to refer to a specific form in the Forms collection, it's better to refer to the form by name because a form's collection index may change.

The Forms collection is indexed beginning with zero. If you refer to a form by its index, the first form opened is Forms(0), the second form opened is Forms(1), and so on. If you opened Form1 and then opened Form2, Form2 would be referenced in the Forms collection by its index as Forms(1). If you then closed Form1, Form2 would be referenced in the Forms collection by its index as Forms(0).

Note Note

To list all forms in the database, whether open or closed, enumerate the AllForms collection of the CurrentProject object. You can then use the Name property of each individual AccessObject object to return the name of a form.

You can't add or delete a Form object from the Forms collection.

See also

Concepts

Access Object Model Reference

Other resources

Forms Object Members


AcFileFormat Enumeration (Access)

 Copy code hover
[image]

AcFileFormat Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the Microsoft Access file format to use when converting an Access file.

Name | Value | Description
acFileFormatAccess12 | 12 | Microsoft Access 2007 format
acFileFormatAccess2 | 2 | Microsoft Access 2.0 format
acFileFormatAccess2000 | 9 | Microsoft Access 2000 format
acFileFormatAccess2002 | 10 | Microsoft Access 2002 format
acFileFormatAccess95 | 7 | Microsoft Access 95 format
acFileFormatAccess97 | 8 | Microsoft Access 97 format


Not enough space on disk. (Error 3026)

 Copy code hover
[image]

Not enough space on disk. (Error 3026)
Send feedback

You tried to perform an operation that requires more disk space than is available. Remove unused files from your disk, compress your database, and then try the operation again.


CommandButton.Cancel Property (Access)

 Copy code hover
[image]

CommandButton.Cancel Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Cancel property to specify whether a command button is also the Cancel button on a form. Read/write Boolean.

Syntax

expression .Cancel

expression A variable that represents a CommandButton object.

Remarks

The Cancel property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The command button is the Cancel button.
No | False | (Default) The command button isn't the Cancel button.

Setting the Cancel property to Yes makes the command button the Cancel button in the form. However, you must still write the macro or Visual Basic event procedure that performs whatever action or actions you want the Cancel button to carry out (for example, closing the form without saving any changes to it). Set the command button's OnClick event property to the name of the macro or event procedure.

When a command button's Cancel property setting is Yes and the Form window is active, the user can choose the command button by pressing ESC, by pressing ENTER when the command button has the focus, or by clicking the command button.

Note Note

If a text box has the focus when the user presses ESC, any changes made to the data in the text box will be lost, and the original data will be restored.

When the Cancel property is set to Yes for one command button on a form, it is automatically set to No for all other command buttons on the form.

For a form that supports irreversible operations, such as deletions, it's a good idea to make the Cancel button the default command button. To do this, set both the Cancel property and the Default property to Yes.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Supports Method Example (VJ++)

 Copy code hover
[image]

Supports Method Example (VJ++)
Send feedback

This example uses the Supports method to display the options supported by a recordset opened with different cursor types. The DisplaySupport function is required for this example to run.

Copy code Copy code

// BeginSupportsJ
import com.ms.wfc.data.*;
import java.io.*;

public class SupportsX
{
 // The main entry point of the application.

 public static void main (String[] args)
 {
 SupportsX();
 System.exit(0);
 }
 // SupportsX Function

 static void SupportsX()
 {
 // Define ADO Objects.
 Recordset rstTitles = null;

 // Declarations.
 int[] aintCursorType = new int[4];
 String strCnn;
 int intIndex;
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));

 try
 {
 // Open connections.
 strCnn = "Provider='sqloledb';Data Source='MySqlServer';"+
 "Initial Catalog='Pubs';Integrated Security='SSPI';";

 // Fill array with CursorType constants.
 aintCursorType[0] = AdoEnums.CursorType.FORWARDONLY;
 aintCursorType[1] = AdoEnums.CursorType.KEYSET;
 aintCursorType[2] = AdoEnums.CursorType.DYNAMIC;
 aintCursorType[3] = AdoEnums.CursorType.STATIC;

 // Open recordset using each CursorType and
 // Optimistic Locking. Then call the DisplaySupport
 // procedure to display the supported options.
 for(intIndex = 0; intIndex < 4; intIndex++)
 {
 rstTitles = new Recordset();
 rstTitles.setCursorType(aintCursorType[intIndex]);
 rstTitles.setLockType(AdoEnums.LockType.OPTIMISTIC);
 rstTitles.open("Titles", strCnn, aintCursorType[intIndex],
 AdoEnums.LockType.OPTIMISTIC, AdoEnums.CommandType.TABLE);

 switch(aintCursorType[intIndex])
 {
 case AdoEnums.CursorType.FORWARDONLY:
 System.out.println("ForwardOnly cursor supports:");
 break;
 case AdoEnums.CursorType.KEYSET:
 System.out.println("Keyset cursor supports:");
 break;
 case AdoEnums.CursorType.DYNAMIC:
 System.out.println("Dynamic cursor supports:");
 break;
 case AdoEnums.CursorType.STATIC:
 System.out.println("Static cursor supports:");
 break;
 default:
 break;
 }
 DisplaySupport(rstTitles);
 System.out.println("Press <Enter> to continue..");
 in.readLine();
 }
 }
 catch(AdoException ae)
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstTitles!= null)
 {
 PrintProviderError(rstTitles.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstTitles != null)
 if (rstTitles.getState() == 1)
 rstTitles.close();
 }
 }
 // DisplaySupport Function

 static void DisplaySupport( Recordset rstTemp )
 {
 long[] alngConstants = new long[11];
 boolean booSupports;
 int intIndex;
 try
 {
 // Fill array with cursor option constants.
 alngConstants[0] = AdoEnums.CursorOption.ADDNEW;
 alngConstants[1] = AdoEnums.CursorOption.APPROXPOSITION;
 alngConstants[2] = AdoEnums.CursorOption.BOOKMARK;
 alngConstants[3] = AdoEnums.CursorOption.DELETE;
 alngConstants[4] = AdoEnums.CursorOption.FIND;
 alngConstants[5] = AdoEnums.CursorOption.HOLDRECORDS;
 alngConstants[6] = AdoEnums.CursorOption.MOVEPREVIOUS;
 alngConstants[7] = AdoEnums.CursorOption.NOTIFY;
 alngConstants[8] = AdoEnums.CursorOption.RESYNC;
 alngConstants[9] = AdoEnums.CursorOption.UPDATE;
 alngConstants[10] = AdoEnums.CursorOption.UPDATEBATCH;

 for(intIndex = 0; intIndex <= 10; intIndex++)
 {
 booSupports = rstTemp.supports((int)alngConstants[intIndex]);
 if (booSupports)
 {
 switch((int)alngConstants[intIndex])
 {
 case AdoEnums.CursorOption.ADDNEW:
 System.out.println(" AddNew");
 break;
 case AdoEnums.CursorOption.APPROXPOSITION:
 System.out.println(
 " AbsolutePosition and AbsolutePage");
 break;
 case AdoEnums.CursorOption.BOOKMARK:
 System.out.println(" Bookmark");
 break;
 case AdoEnums.CursorOption.DELETE:
 System.out.println(" Delete");
 break;
 case AdoEnums.CursorOption.FIND:
 System.out.println(" Find");
 break;
 case AdoEnums.CursorOption.HOLDRECORDS:
 System.out.println(" Holding Records");
 break;
 case AdoEnums.CursorOption.MOVEPREVIOUS:
 System.out.println(" MovePrevious and Move");
 break;
 case AdoEnums.CursorOption.NOTIFY:
 System.out.println(" Notifications");
 break;
 case AdoEnums.CursorOption.RESYNC:
 System.out.println(" Resyncing Data");
 break;
 case AdoEnums.CursorOption.UPDATE:
 System.out.println(" Update");
 break;
 case AdoEnums.CursorOption.UPDATEBATCH:
 System.out.println(" Batch Updating");
 break;
 default:
 break;
 }
 }
 }
 }
 catch(AdoException ae)
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstTemp!= null)
 {
 PrintProviderError(rstTemp.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 }

 // PrintProviderError Function
 static void PrintProviderError(Connection cnn1)
 {
 // Print Provider Errors from Connection Object.
 // ErrItem is an item object in the Connections Errors Collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if ( nCount > 0)
 {
 // Collection ranges from 0 to nCount-1.
 for ( i=0;i<nCount; i++)
 {
 ErrItem = cnn1.getErrors().getItem(i);
 System.out.println("\t Error Number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription());
 }
 }
 }
 // PrintIOError Function
 static void PrintIOError(java.io.IOException je)
 {
 System.out.println("Error: \n");
 System.out.println("\t Source: " + je.getClass() + "\n");
 System.out.println("\t Description: "+ je.getMessage() + "\n");
 }
}
// EndSupportsJ


Section III: ADO (Multidimensional) (ADO MD) (Access)

 Copy code hover
[image]

Section III: ADO (Multidimensional) (ADO MD) (Access)
Send feedback

In this section

  • Section III: ADO (Multidimensional) (ADO MD)

  • Chapter 14: ADO MD Fundamentals (ADO)


DBEngine Object Reference (DAO)

 Copy code hover
[image]

DBEngine Object Reference (DAO)
Send feedback

In this section

  • DBEngine Object (DAO)

  • DBEngine Members (DAO)

  • DBEngine Properties (DAO)

  • DBEngine Methods (DAO)


Cannot create a replica using a partial replica. (Error 3634)

 Copy code hover
[image]

Cannot create a replica using a partial replica. (Error 3634)
Send feedback

You are attempting to create a replica using a partial replica as the source. Partial replicas cannot be replicated.


CheckBox.LayoutID Property (Access)

 Copy code hover
[image]

CheckBox.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified check box. Read-only Long.

Version Information

Version Added: Access 2007

Syntax

expression .LayoutID

expression A variable that represents a CheckBox object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ADO Collections

 Copy code hover
[image]

ADO Collections
Send feedback

Each collection can contain its corresponding object. For example, an Error object can be contained in an Errors collection. For more information about objects, see ADO Objects or a specific object topic.

Errors | Contains all the Error objects created in response to a single provider-related failure.
Fields | Contains all the Field objects of a Recordset object.
Parameters | Contains all the Parameter objects of a Command object.
Properties | Contains all the Property objects for a specific instance of an object.


Action Query

 Copy code hover
[image]

Action Query
Send feedback

Published: July 16, 2012

An action query changes data or copies data. Action queries include append, delete, make-table, and update queries. In contrast, a select query doesn't copy or change data; it simply returns a set of records.

Action query type | Description
Append | Adds the records in a query's result set to the end of an existing table.
Delete | Deletes a set of rows that match the criteria you specify.
Make-Table | Creates a new table from the result set of an existing query.
Update | Changes a set of records according to criteria you specify.


CommandButton.BorderWidth Property (Access)

 Copy code hover
[image]

CommandButton.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .BorderWidth

expression A variable that represents a CommandButton object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Form.AutoCenter Property (Access)

 Copy code hover
[image]

Form.AutoCenter Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Boolean indicating whether a form will be centered automatically in the application window when the form is opened. Read/write.

Syntax

expression .AutoCenter

expression A variable that represents a Form object.

Remarks

The AutoCenter property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The form will be centered automatically on opening.
No | False | (Default) The form upper-left corner will be in the same location as when the form was last saved.

You can set this property only in Design view.

Depending on the size and placement of the application window, forms can appear off to one side of the application window, hiding part of the form or report. Centering the form automatically when it's opened makes it easier to view and use.

If you make any changes in Design view to a form whose AutoResize property is set to No and whose AutoCenter property is set to Yes, switch to Form view before saving the form. If you don't, Microsoft Access clips the form on the right and bottom edges the next time you open the form.

See also

Concepts

Form Object

Other resources

Form Object Members


TabControl.Width Property (Access)

 Copy code hover
[image]

TabControl.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents a TabControl object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


TextBox.ControlTipText Property (Access)

 Copy code hover
[image]

TextBox.ControlTipText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.

Syntax

expression .ControlTipText

expression A variable that represents a TextBox object.

Remarks

You set the ControlTipText property by using a string expression up to 255 characters long.

For controls on forms, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

You can set the ControlTipText property in any view.

The ControlTipText property provides an easy way to provide helpful information about controls on a form.

There are other ways to provide information about a form or a control on a form. You can use the StatusBarText property to display information in the status bar about a control. To provide more extensive help for a form or control, use the HelpFile and HelpContextID properties.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Recordset.Edit Method (DAO)

 Copy code hover
[image]

Recordset.Edit Method (DAO)
Send feedback

Copies the current record from an updatable Recordset object to the copy buffer for subsequent editing.

Syntax

expression .Edit

expression A variable that represents a Recordset object.

Remarks

Once you use the Edit method, changes made to the current record's fields are copied to the copy buffer. After you make the desired changes to the record, use the Update method to save your changes.

The current record remains current after you use Edit.

Note Note

If you edit a record and then perform any operation that moves to another record, but without first using Update, your changes are lost without warning. In addition, if you close recordset or end the procedure which declares the Recordset or the parent Database or Connection object, your edited record is discarded without warning.

Using Edit produces an error if:

  • There is no current record.

  • The Connection, Database, or Recordset object was opened as read-only.

  • No fields in the record are updatable.

  • The Database or Recordset was opened for exclusive use by another user (Microsoft Access workspace).

  • Another user has locked the page containing your record (Microsoft Access workspace).

In a Microsoft Access workspace, when the Recordset object's LockEdits property setting is True (pessimistically locked) in a multiuser environment, the record remains locked from the time Edit is used until the update is complete. If the LockEdits property setting is False (optimistically locked), the record is locked and compared with the pre-edited record just before it's updated in the database. If the record has changed since you used the Edit method, the Update operation fails with a run-time error if you use OpenRecordset without specifying dbSeeChanges. By default, Microsoft Access database engine-connected ODBC and installable ISAM databases always use optimistic locking.

Note Note

To add, edit, or delete a record, there must be a unique index on the record in the underlying data source. If not, a "Permission denied" error will occur on the AddNew, Delete, or Edit method call in a Microsoft Access workspace.

Example

This example uses the Edit method to replace the current data with the specified name. The EditName procedure is required for this procedure to run.

VBA Copy code Copy code
Sub EditX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset
 Dim strOldFirst As String
 Dim strOldLast As String
 Dim strFirstName As String
 Dim strLastName As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", _
 dbOpenDynaset)

 ' Store original data.
 strOldFirst = rstEmployees!FirstName
 strOldLast = rstEmployees!LastName

 ' Get new data for record.
 strFirstName = Trim(InputBox( _
 "Enter first name:"))
 strLastName = Trim(InputBox( _
 "Enter last name:"))

 ' Proceed if the user entered something for both fields.
 If strFirstName <> "" and strLastName <> "" Then
 ' Update record with new data.
 EditName rstEmployees, strFirstName, strLastName

 With rstEmployees
 ' Show old and new data.
 Debug.Print "Old data: " & strOldFirst & _
 " " & strOldLast
 Debug.Print "New data: " & !FirstName & _
 " " & !LastName
 ' Restore original data because this is a
 ' demonstration.
 .Edit
 !FirstName = strOldFirst
 !LastName = strOldLast
 .Update
 End With

 Else
 Debug.Print _
 "You must input a string for first and last name!"
 End If

 rstEmployees.Close
 dbsNorthwind.Close

End Sub

Sub EditName(rstTemp As Recordset, _
 strFirst As String, strLast As String)

 ' Make changes to record and set the bookmark to keep
 ' the same record current.
 With rstTemp
 .Edit
 !FirstName = strFirst
 !LastName = strLast
 .Update
 .Bookmark = .LastModified
 End With

End Sub


ComboBox.LabelAlign Property (Access)

 Copy code hover
[image]

ComboBox.LabelAlign Property (Access)
See also Send feedback

Published: July 16, 2012

The property specifies the text alignment within attached labels on new controls. Read/write Byte.

Syntax

expression .LabelAlign

expression A variable that represents a ComboBox object.

Remarks

The LabelAlign property uses the following settings.

Setting | Description
0 | (Default) The label text aligns to the left.
1 | The label text aligns to the left.
2 | The label text is centered.
3 | The label text aligns to the right.
4 | The label text is evenly distributed.

You can set the LabelAlign property by using a control's default control style or the DefaultControl property in Visual Basic.

When created, controls have an attached label (as long as their AutoLabel property is set to Yes). Changes to the LabelAlign default control style setting affect only controls created on the current form or report.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


TextBox.BackThemeColorIndex Property (Access)

 Copy code hover
[image]

TextBox.BackThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackThemeColorIndex

expression A variable that represents a TextBox object.

Remarks

The BackThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BackThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Background Color to the Text 2 color by setting the BackThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BackThemeColorIndex=2

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Recordset.RecordsetType Property (DAO)

 Copy code hover
[image]

Recordset.RecordsetType Property (DAO)
See also Send feedback

You can use the RecordsetType property to specify what kind of recordset is made available to a form. Read/write Byte.

Syntax

expression .RecordsetType

expression A variable that represents a Form object.

Remarks

The RecordsetType property uses the following settings in a Microsoft Access database.

Setting | Type of Recordset | Description
0 | Dynaset | (Default) You can edit bound controls based on a single table or tables with a one-to-one relationship. For controls bound to fields based on tables with a one-to-many relationship, you can't edit data from the join field on the "one" side of the relationship unless cascade update is enabled between the tables.
1 | Dynaset (Inconsistent Updates) | All tables and controls bound to their fields can be edited.
2 | Snapshot | No tables or the controls bound to their fields can be edited.
Note Note

If you don't want data in bound controls to be edited when a form is in Form view or Datasheet view, you can set the RecordsetType property to 2.

The RecordsetType property uses the following settings in a Microsoft Access project (.adp).

Setting | Type of Recordset | Description
3 | Snapshot | No tables or the controls bound to their fields can be edited.
4 | Updatable Snapshot | (Default) All tables and controls bound to their fields can be edited.
Note Note

Changing the RecordsetType property of an open form or report causes an automatic recreation of the recordset.

You can create forms based on multiple underlying tables with fields bound to controls on the forms. Depending on the RecordsetType property setting, you can limit which of these bound controls can be edited.

In addition to the editing control provided by RecordsetType, each control on a form has a Locked property that you can set to specify whether the control and its underlying data can be edited. If the Locked property is set to Yes, you can't edit the data.

Example

In the following example, only if the user ID is ADMIN can records be updated. This code sample sets the RecordsetType property to Snapshot if the public variable gstrUserID value is not ADMIN.

VBA Copy code Copy code
Sub Form_Open(Cancel As Integer)
 Const conSnapshot = 2
 If gstrUserID <> "ADMIN" Then
 Forms!Employees.RecordsetType = conSnapshot
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Option Group Control

 Copy code hover
[image]

Option Group Control
Send feedback

Published: July 16, 2012

An option group on a form or report displays a limited set of alternatives. An option group makes selecting a value easy since you can just click the value you want. Only one option in an option group can be selected at a time.

An option group consists of a group frame and a set of check boxes, toggle buttons, or option buttons.

Remarks

If an option group is bound to a field, only the group frame itself is bound to the field, not the check boxes, toggle buttons, or option buttons inside the frame. Instead of setting the ControlSource property for each control in the option group, you set the OptionValue property of each check box, toggle button, or option button to a number that's meaningful for the field to which the group frame is bound. When you select an option in an option group, Microsoft Access sets the value of the field to which the option group is bound to the value of the selected option's OptionValue property.

Note Note

The OptionValue property is set to a number because the value of an option group can only be a number, not text. Microsoft Access stores this number in the underlying table. In the preceding example, if you want to display the name of the shipper instead of a number in the Orders table, you can create a separate table called Shippers that stores shipper names, and then make the ShipVia field in the Orders table a Lookup field that looks up data in the Shippers table.

An option group can also be set to an expression, or it can be unbound. You can use an unbound option group in a custom dialog box to accept user input and then carry out an action based on that input.


ListBox.HideDuplicates Property (Access)

 Copy code hover
[image]

ListBox.HideDuplicates Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.

Syntax

expression .HideDuplicates

expression A variable that represents a ListBox object.

Remarks

The HideDuplicates property applies only to controls (check box, combo box, list box, option button, option group, text box, toggle button) on a report.

The HideDuplicates property uses the following settings.

Setting | Description
True | If the value of a control or the data it contains is the same as in the preceding record, the control is hidden.
False | (Default) The control is visible regardless of the value in the preceding record.

You can set the HideDuplicates property only in report Design view.

You can use the HideDuplicates property to create a grouped report by using only the detail section rather than a group header and the detail section.

Example

The following example returns the HideDuplicates property setting for the CategoryName text box and assigns the value to the intCurVal variable.

VBA Copy code Copy code
Dim intCurVal As Integer
intCurVal = Me!CategoryName.HideDuplicates

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Batch Mode (ADO)

 Copy code hover
[image]

Batch Mode (ADO)
Send feedback

In this section

  • Batch Mode

  • Sending the Updates: UpdateBatch

  • Filtering for Updated Records

  • Dealing with Failed Updates

  • Detecting and Resolving Conflicts

  • Disconnecting and Reconnecting the Recordset

  • Updating JOINed Results: Unique Table


NavigationButton.HorizontalAnchor Property (Access)

 Copy code hover
[image]

NavigationButton.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the text box is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2010

Syntax

expression .HorizontalAnchor

expression A variable that represents a NavigationButton object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


OptionGroup.DisplayWhen Property (Access)

 Copy code hover
[image]

OptionGroup.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Syntax

expression .DisplayWhen

expression A variable that represents an OptionGroup object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


AllReports.Application Property (Access)

 Copy code hover
[image]

AllReports.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents an AllReports object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

AllReports Collection

Other resources

AllReports Object Members


Entity.Name Property (Access)

 Copy code hover
[image]

Entity.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .Name

expression A variable that represents an Entity object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

Entity Object

Other resources

Entity Object Members


ConvertToString Method Example (VB)

 Copy code hover
[image]

ConvertToString Method Example (VB)
Send feedback
Copy code Copy code

'BeginConvertToStringVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 ' to integrate this code replace the server name
 ' in the CreateObject call

 ' RDS variables
 Dim rdsDS As RDS.DataSpace
 Dim rdsDC As RDS.DataControl
 Dim rdsDF As Object
 ' recordset and connection variables
 Dim rsAuthors As ADODB.Recordset
 Dim strSQLAuthors As String
 Dim strCnxn As String
 Dim varString As Variant

 ' Create a DataSpace object
 Set rdsDS = New RDS.DataSpace
 ' Create a DataFactory object
 Set rdsDF = rdsDS.CreateObject("RDSServer.DataFactory", "http://MyServer") 'MyServer

 ' Get all of the Author records

 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 strSQLAuthors = "SELECT * FROM Authors"
 Set rsAuthors = rdsDF.Query(strCnxn, strSQLAuthors)
 ' Show results
 Debug.Print "Old RDS recordset count:" & rsAuthors.RecordCount

 ' Convert the recordset into a MIME formatted string
 varString = rdsDF.ConvertToString(rsAuthors)
 Debug.Print "Recordset as MIME format string:"
 Debug.Print varString

 ' Convert string value back into an ADO Recordset
 Set rdsDC = New RDS.DataControl
 rdsDC.SQL = varString
 rdsDC.ExecuteOptions = adcExecSync
 rdsDC.FetchOptions = adcFetchUpFront
 rdsDC.Refresh
 ' Show results
 Debug.Print "New ADO recordset count:" & rdsDC.Recordset.RecordCount

 ' clean up
 rsAuthors.Close
 Set rsAuthors = Nothing
 Set rdsDC = Nothing
 Set rdsDS = Nothing
 Set rdsDC = Nothing

ErrorHandler:

 If Not rsAuthors Is Nothing Then
 If rsAuthors.State = adStateOpen Then rsAuthors.Close
 End If
 Set rsAuthors = Nothing
 Set rdsDC = Nothing
 Set rdsDS = Nothing
 Set rdsDC = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If

End Sub
'EndConvertToStringVB


TabControl.FontBold Property (Access)

 Copy code hover
[image]

TabControl.FontBold Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontBold property to specify whether a font appears in a bold style in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontBold

expression A variable that represents a TabControl object.

Remarks

The FontBold property uses the following settings.

Setting | Description
True | The text is bold.
False | (Default) The text isn't bold.

To use the FontBold property on a report, first create a Printevent procedure that prints the desired text.

A font's appearance on screen and in print may differ, depending on your computer and printer.

The FontWeight property, which is available in the property sheet for controls, can also be used to set the line width for a control's text. The FontBold property gives you a quick way to make text bold; the FontWeight property gives you finer control over the line width setting for text. The following table shows the relationship between these properties' settings.

If | Then
FontBold = False | FontWeight = Normal (400)
FontBold = True | FontWeight = Bold (700)
FontWeight < 700 | FontBold = False
FontWeight > = 700 | FontBold = True

Example

The following Print event procedure prints a report title and the current date in a bold style on a report at the coordinates specified by the CurrentX and CurrentY property settings.

VBA Copy code Copy code
Private Sub ReportHeader0_Print(Cancel As Integer, _
 PrintCount As Integer)
 Dim MyDate

 MyDate = Date
 Me.FontBold = True
 ' Print report title in bold.
 Me.Print("Sales Management Report")
 Me.Print(MyDate)
End Sub

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


OpenSchema Method Example (VJ++)

 Copy code hover
[image]

OpenSchema Method Example (VJ++)
Send feedback

This example uses the OpenSchema method to display the name and type of each table in the Pubs database.

Copy code Copy code

// BeginOpenSchemaJ
import com.ms.wfc.data.*;
import java.io.*;
import com.ms.com.*;

public class OpenSchemaX
{
 // The main entry point of the application.

public static void main (String[] args)
{
 System.out.println("\nResults for OpenSchemaX:\n\n");
 OpenSchemaX();
 System.out.println("\nResults for OpenSchemaX2:\n\n");
 OpenSchemaX2();
 System.exit(0);
}

// OpenSchemaX Function
 static void OpenSchemaX()
 {
 // Define ADO Objects
 Connection cnn1 = null;
 Recordset rstSchema = null;

 // Declarations
 String strCnn;
 BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
 int intDisplayRecords = 5;
 int intRecordCount = 0;

 try
 {

 cnn1 = new Connection();
 strCnn = "Provider = Microsoft.Jet.OLEDB.4.0;" +
 "Data Source=C:\\Program Files\\Microsoft " +
 "Office\\Office\\Samples\\Northwind.mdb;";
 cnn1.open(strCnn);
 rstSchema = cnn1.openSchema(AdoEnums.Schema.TABLES);

 while (!rstSchema.getEOF())
 {

 System.out.println("Table Name: " +
 rstSchema.getField("TABLE_NAME").getString()+"\n"+
 "Table Type: " +
 rstSchema.getField("TABLE_TYPE").getString()+"\n");
 intRecordCount++;
 if ( intRecordCount == intDisplayRecords)
 {
 System.out.println("Press <Enter> to continue..");
 in.readLine();
 intRecordCount = 0;
 }
 rstSchema.moveNext();

 }
 System.out.println("Press <Enter> to continue..");
 in.readLine();

 }
 catch(AdoException ae)
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if(rstSchema != null)
 {
 PrintProviderError(rstSchema.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 // System read requires this catch.
 catch(java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstSchema != null)
 if (rstSchema.getState() == 1)
 rstSchema.close();
 if (cnn1 != null)
 if (cnn1.getState() == 1)
 cnn1.close();
 }
 }

 // OpenSchemaX2 Function

 static void OpenSchemaX2()
 {
 // Define ADO Objects
 Connection cnn2 = null;
 Recordset rstSchema = null;

 // Declarations
 String strCnn;
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));
 int intDisplayRecords = 5;
 int intRecordCount = 0;

 try
 {
 cnn2 = new Connection();
 strCnn = "Provider = Microsoft.Jet.OLEDB.4.0;" +
 "Data Source=C:\\Program Files\\Microsoft " +
 "Office\\Office\\Samples\\Northwind.mdb;";
 cnn2.open(strCnn);

 Variant[] va = new Variant[4];
 va[0] = new Variant();
 va[1] = new Variant();
 va[2] = new Variant();
 va[3] = new Variant("VIEW");
 rstSchema = cnn2.openSchema(AdoEnums.Schema.TABLES,(Object[])va);

 while (!rstSchema.getEOF())
 {
 System.out.println("Table Name: " +
 rstSchema.getField("TABLE_NAME").getString()+"\n"+
 "Table Type: " +
 rstSchema.getField("TABLE_TYPE").getString()+"\n");
 intRecordCount++;
 if ( intRecordCount == intDisplayRecords)
 {
 System.out.println("Press <Enter> to continue..");
 in.readLine();
 intRecordCount = 0;
 }
 rstSchema.moveNext();

 }
 System.out.println("Press <Enter> to continue..");
 in.readLine();

 }
 catch(AdoException ae)
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if(rstSchema != null)
 {
 PrintProviderError(rstSchema.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 // System read requires this catch.
 catch(java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup Objects before exit.
 rstSchema.close();
 cnn2.close();
 // Cleanup objects before exit.
 if (rstSchema != null)
 if (rstSchema.getState() == 1)
 rstSchema.close();
 if (cnn2 != null)
 if (cnn2.getState() == 1)
 cnn2.close();
 }

 }
 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndOpenSchemaJ


Access 2013 desktop database reference

 Copy code hover
[image]

Access 2013 desktop database reference
Send feedback

Published: July 16, 2012

In this section

  • Concepts (Access 2013 Developer Reference)

  • How do I... (Access 2013 developer reference)

  • Access Macro Actions (Access 2013 Developer Reference)

  • Access object model reference (Access 2013 developer reference)

  • Microsoft Data Access Objects reference

  • Microsoft ActiveX Data Objects reference

  • Microsoft Access SQL reference


AcCommand Enumeration (Access)

 Copy code hover
[image]

AcCommand Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the RunCommand method to run built-in commands.

Name | Value | Description
acCmdAboutMicrosoftAccess | 35 |
acCmdAddDataMacroAfterDelete | 720 |
acCmdAddDataMacroAfterInsert | 718 |
acCmdAddDataMacroAfterUpdate | 719 |
acCmdAddDataMacroValidateChange | 722 |
acCmdAddDataMacroValidateDelete | 721 |
acCmdAddFromOutlook | 583 |
acCmdAddInManager | 526 |
acCmdAddNamedDataMacro | 723 |
acCmdAddToNewGroup | 494 |
acCmdAddWatch | 201 |
acCmdAdvancedFilterSort | 99 |
acCmdAlignBottom | 46 |
acCmdAlignCenter | 477 |
acCmdAlignLeft | 43 |
acCmdAlignmentAndSizing | 478 |
acCmdAlignMiddle | 476 |
acCmdAlignRight | 44 |
acCmdAlignToGrid | 47 |
acCmdAlignTop | 45 |
acCmdAlignToShortest | 153 |
acCmdAlignToTallest | 154 |
acCmdAnalyzePerformance | 283 |
acCmdAnalyzeTable | 284 |
acCmdAnchorBottomLeft | 616 |
acCmdAnchorBottomRight | 618 |
acCmdAnchorBottomStretchAcross | 617 |
acCmdAnchorStretchAcross | 611 |
acCmdAnchorStretchDown | 613 |
acCmdAnchorStretchDownAcross | 614 |
acCmdAnchorStretchDownRight | 615 |
acCmdAnchorTopLeft | 610 |
acCmdAnchorTopRight | 612 |
acCmdAnswerWizard | 235 |
acCmdApplyAutoFormat1 | 648 |
acCmdApplyAutoFormat10 | 657 |
acCmdApplyAutoFormat11 | 658 |
acCmdApplyAutoFormat12 | 659 |
acCmdApplyAutoFormat13 | 660 |
acCmdApplyAutoFormat14 | 661 |
acCmdApplyAutoFormat15 | 662 |
acCmdApplyAutoFormat16 | 663 |
acCmdApplyAutoFormat17 | 664 |
acCmdApplyAutoFormat18 | 665 |
acCmdApplyAutoFormat19 | 666 |
acCmdApplyAutoFormat2 | 649 |
acCmdApplyAutoFormat20 | 667 |
acCmdApplyAutoFormat21 | 668 |
acCmdApplyAutoFormat22 | 669 |
acCmdApplyAutoFormat23 | 670 |
acCmdApplyAutoFormat24 | 671 |
acCmdApplyAutoFormat25 | 672 |
acCmdApplyAutoFormat3 | 650 |
acCmdApplyAutoFormat4 | 651 |
acCmdApplyAutoFormat5 | 652 |
acCmdApplyAutoFormat6 | 653 |
acCmdApplyAutoFormat7 | 654 |
acCmdApplyAutoFormat8 | 655 |
acCmdApplyAutoFormat9 | 656 |
acCmdApplyDefault | 55 |
acCmdApplyFilterSort | 93 |
acCmdAppMaximize | 10 |
acCmdAppMinimize | 11 |
acCmdAppMove | 12 |
acCmdAppRestore | 9 |
acCmdAppSize | 13 |
acCmdArrangeIconsAuto | 218 |
acCmdArrangeIconsByCreated | 216 |
acCmdArrangeIconsByModified | 217 |
acCmdArrangeIconsByName | 214 |
acCmdArrangeIconsByType | 215 |
acCmdAutoCorrect | 261 |
acCmdAutoDial | 192 |
acCmdAutoFormat | 270 |
acCmdBackgroundPicture | 474 |
acCmdBackgroundSound | 475 |
acCmdBackup | 513 |
acCmdBookmarksClearAll | 310 |
acCmdBookmarksNext | 308 |
acCmdBookmarksPrevious | 309 |
acCmdBookmarksToggle | 307 |
acCmdBringToFront | 52 |
acCmdBrowseSharePointList | 621 |
acCmdCalculatedColumn | 698 |
acCmdCallStack | 172 |
acCmdChangeToCheckBox | 231 |
acCmdChangeToComboBox | 230 |
acCmdChangeToCommandButton | 501 |
acCmdChangeToImage | 234 |
acCmdChangeToLabel | 228 |
acCmdChangeToListBox | 229 |
acCmdChangeToOptionButton | 233 |
acCmdChangeToTextBox | 227 |
acCmdChangeToToggleButton | 232 |
acCmdClearAll | 146 |
acCmdClearAllBreakpoints | 132 |
acCmdClearGrid | 71 |
acCmdClearHyperlink | 343 |
acCmdClearItemDefaults | 237 |
acCmdClose | 58 |
acCmdCloseAll | 646 |
acCmdCloseDatabase | 538 |
acCmdCloseWindow | 186 |
acCmdCollectDataViaEmail | 608 |
acCmdColumnWidth | 117 |
acCmdCompactDatabase | 4 |
acCmdCompatCheckCurrentObject | 696 |
acCmdCompatCheckDatabase | 695 |
acCmdCompileAllModules | 125 |
acCmdCompileAndSaveAllModules | 126 |
acCmdCompileLoadedModules | 290 |
acCmdCompleteWord | 306 |
acCmdConditionalFormatting | 500 |
acCmdConnection | 383 |
acCmdControlMarginsMedium | 630 |
acCmdControlMarginsNarrow | 629 |
acCmdControlMarginsNone | 628 |
acCmdControlMarginsWide | 631 |
acCmdControlPaddingMedium | 634 |
acCmdControlPaddingNarrow | 633 |
acCmdControlPaddingNone | 632 |
acCmdControlPaddingWide | 635 |
acCmdControlWizardsToggle | 197 |
acCmdConvertDatabase | 171 |
acCmdConvertLinkedTableToLocal | 700 |
acCmdConvertMacrosToVisualBasic | 279 |
acCmdCopy | 190 |
acCmdCopyDatabaseFile | 516 |
acCmdCopyHyperlink | 328 |
acCmdCreateMenuFromMacro | 334 |
acCmdCreateRelationship | 150 |
acCmdCreateReplica | 263 |
acCmdCreateShortcut | 219 |
acCmdCreateShortcutMenuFromMacro | 336 |
acCmdCreateToolbarFromMacro | 335 |
acCmdCut | 189 |
acCmdDatabaseProperties | 256 |
acCmdDatabaseSplitter | 520 |
acCmdDataEntry | 78 |
acCmdDataOutline | 468 |
acCmdDatasheetView | 282 |
acCmdDateAndTime | 226 |
acCmdDebugWindow | 123 |
acCmdDelete | 337 |
acCmdDeleteGroup | 493 |
acCmdDeletePage | 332 |
acCmdDeleteQueryColumn | 81 |
acCmdDeleteRecord | 223 |
acCmdDeleteRows | 188 |
acCmdDeleteSharePointList | 627 |
acCmdDeleteTab | 255 |
acCmdDeleteTable | 489 |
acCmdDeleteTableColumn | 271 |
acCmdDeleteWatch | 267 |
acCmdDesignObject | 697 |
acCmdDesignView | 183 |
acCmdDiagramAddRelatedTables | 373 |
acCmdDiagramAutosizeSelectedTables | 378 |
acCmdDiagramDeleteRelationship | 382 |
acCmdDiagramLayoutDiagram | 380 |
acCmdDiagramLayoutSelection | 379 |
acCmdDiagramModifyUserDefinedView | 375 |
acCmdDiagramNewLabel | 372 |
acCmdDiagramNewTable | 381 |
acCmdDiagramRecalculatePageBreaks | 377 |
acCmdDiagramShowRelationshipLabels | 374 |
acCmdDiagramViewPageBreaks | 376 |
acCmdDiscardChanges | 639 |
acCmdDiscardChangesAndRefresh | 640 |
acCmdDocMaximize | 15 |
acCmdDocMinimize | 60 |
acCmdDocMove | 16 |
acCmdDocRestore | 14 |
acCmdDocSize | 17 |
acCmdDocumenter | 285 |
acCmdDropSQLDatabase | 517 |
acCmdDuplicate | 34 |
acCmdEditHyperlink | 325 |
acCmdEditingAllowed | 70 |
acCmdEditListItems | 607 |
acCmdEditRelationship | 151 |
acCmdEditTriggers | 384 |
acCmdEditWatch | 202 |
acCmdEncryptDecryptDatabase | 5 |
acCmdEnd | 198 |
acCmdExit | 3 |
acCmdExportAccess | 559 |
acCmdExportdBase | 565 |
acCmdExportExcel | 556 |
acCmdExportFixedFormat | 592 |
acCmdExportHTML | 564 |
acCmdExportODBC | 562 |
acCmdExportRTF | 558 |
acCmdExportSharePointList | 557 |
acCmdExportSnapShot | 563 |
acCmdExportText | 560 |
acCmdExportXML | 561 |
acCmdFavoritesAddTo | 299 |
acCmdFavoritesOpen | 298 |
acCmdFieldList | 42 |
acCmdFilterByForm | 207 |
acCmdFilterBySelection | 208 |
acCmdFilterExcludingSelection | 277 |
acCmdFilterMenu | 619 |
acCmdFind | 30 |
acCmdFindNext | 341 |
acCmdFindNextWordUnderCursor | 313 |
acCmdFindPrevious | 120 |
acCmdFindPrevWordUnderCursor | 312 |
acCmdFitToWindow | 245 |
acCmdFont | 19 |
acCmdFormatCells | 77 |
acCmdFormHdrFtr | 36 |
acCmdFormView | 281 |
acCmdFreezeColumn | 105 |
acCmdGoBack | 294 |
acCmdGoContinue | 127 |
acCmdGoForward | 295 |
acCmdGroupByTable | 387 |
acCmdGroupControls | 484 |
acCmdHideColumns | 79 |
acCmdHideMessageBar | 677 |
acCmdHidePane | 365 |
acCmdHideTable | 147 |
acCmdHorizontalSpacingDecrease | 158 |
acCmdHorizontalSpacingIncrease | 159 |
acCmdHorizontalSpacingMakeEqual | 157 |
acCmdHyperlinkDisplayText | 329 |
acCmdImportAttachAccess | 544 |
acCmdImportAttachdBase | 552 |
acCmdImportAttachExcel | 545 |
acCmdImportAttachHTML | 550 |
acCmdImportAttachODBC | 549 |
acCmdImportAttachOutlook | 551 |
acCmdImportAttachSharePointList | 547 |
acCmdImportAttachText | 546 |
acCmdImportAttachXML | 548 |
acCmdIndent | 205 |
acCmdIndexes | 152 |
acCmdInsertActiveXControl | 258 |
acCmdInsertChart | 293 |
acCmdInsertFile | 39 |
acCmdInsertFileIntoModule | 118 |
acCmdInsertHyperlink | 259 |
acCmdInsertLogo | 585 |
acCmdInsertLookupColumn | 273 |
acCmdInsertLookupField | 291 |
acCmdInsertMovieFromFile | 469 |
acCmdInsertNavigationButton | 724 |
acCmdInsertObject | 33 |
acCmdInsertPage | 331 |
acCmdInsertPicture | 222 |
acCmdInsertPivotTable | 470 |
acCmdInsertProcedure | 262 |
acCmdInsertQueryColumn | 82 |
acCmdInsertRows | 187 |
acCmdInsertSpreadsheet | 471 |
acCmdInsertSubdatasheet | 499 |
acCmdInsertTableColumn | 272 |
acCmdInsertTitle | 586 |
acCmdInsertUnboundSection | 472 |
acCmdInvokeBuilder | 178 |
acCmdJoinProperties | 72 |
acCmdLastPosition | 339 |
acCmdLayoutGridlinesBoth | 574 |
acCmdLayoutGridlinesBottom | 580 |
acCmdLayoutGridlinesCrossHatch | 578 |
acCmdLayoutGridlinesHorizontal | 576 |
acCmdLayoutGridlinesNone | 577 |
acCmdLayoutGridlinesOutline | 581 |
acCmdLayoutGridlinesTop | 579 |
acCmdLayoutGridlinesVertical | 575 |
acCmdLayoutInsertColumnLeft | 680 |
acCmdLayoutInsertColumnRight | 681 |
acCmdLayoutInsertRowAbove | 678 |
acCmdLayoutInsertRowBelow | 679 |
acCmdLayoutMergeCells | 682 |
acCmdLayoutPreview | 141 |
acCmdLayoutSplitColumnCell | 683 |
acCmdLayoutSplitRowCell | 684 |
acCmdLayoutView | 593 |
acCmdLineUpIcons | 213 |
acCmdLinkedTableManager | 519 |
acCmdLinkTables | 102 |
acCmdListConstants | 303 |
acCmdLoadFromQuery | 95 |
acCmdMacroAllActions | 589 |
acCmdMakeMDEFile | 7 |
acCmdManageAttachments | 673 |
acCmdManageReplies | 609 |
acCmdManageTableEvents | 717 |
acCmdMaximiumRecords | 508 |
acCmdMicrosoftAccessHelpTopics | 100 |
acCmdMicrosoftOnTheWeb | 236 |
acCmdModifySharePointList | 622 |
acCmdModifySharePointListAlerts | 623 |
acCmdModifySharePointListPermissions | 625 |
acCmdModifySharePointListWorkflow | 624 |
acCmdMoreWindows | 8 |
acCmdMoveColumnCellDown | 573 |
acCmdMoveColumnCellUp | 572 |
acCmdNewDatabase | 26 |
acCmdNewGroup | 491 |
acCmdNewObjectAutoForm | 193 |
acCmdNewObjectAutoFormWeb | 705 |
acCmdNewObjectAutoReport | 194 |
acCmdNewObjectAutoReportWeb | 706 |
acCmdNewObjectBlankForm | 600 |
acCmdNewObjectBlankFormWeb | 703 |
acCmdNewObjectBlankReport | 602 |
acCmdNewObjectBlankReportWeb | 704 |
acCmdNewObjectClassModule | 140 |
acCmdNewObjectContinuousForm | 594 |
acCmdNewObjectContinuousFormWeb | 701 |
acCmdNewObjectDatasheetForm | 598 |
acCmdNewObjectDatasheetFormWeb | 702 |
acCmdNewObjectDesignForm | 604 |
acCmdNewObjectDesignQuery | 603 |
acCmdNewObjectDesignReport | 605 |
acCmdNewObjectDesignTable | 606 |
acCmdNewObjectDiagram | 352 |
acCmdNewObjectForm | 136 |
acCmdNewObjectFunction | 394 |
acCmdNewObjectLabelsReport | 601 |
acCmdNewObjectMacro | 138 |
acCmdNewObjectMacroWeb | 708 |
acCmdNewObjectModalForm | 599 |
acCmdNewObjectModule | 139 |
acCmdNewObjectNavigationLeft | 690 |
acCmdNewObjectNavigationLeftWeb | 710 |
acCmdNewObjectNavigationRight | 691 |
acCmdNewObjectNavigationRightWeb | 711 |
acCmdNewObjectNavigationTop | 689 |
acCmdNewObjectNavigationTopLeft | 693 |
acCmdNewObjectNavigationTopLeftWeb | 713 |
acCmdNewObjectNavigationTopRight | 694 |
acCmdNewObjectNavigationTopRightWeb | 714 |
acCmdNewObjectNavigationTopTop | 692 |
acCmdNewObjectNavigationTopTopWeb | 712 |
acCmdNewObjectNavigationTopWeb | 709 |
acCmdNewObjectPivotChart | 596 |
acCmdNewObjectPivotTable | 597 |
acCmdNewObjectQuery | 135 |
acCmdNewObjectQueryWeb | 707 |
acCmdNewObjectReport | 137 |
acCmdNewObjectSplitForm | 595 |
acCmdNewObjectStoredProcedure | 351 |
acCmdNewObjectTable | 134 |
acCmdNewObjectView | 350 |
acCmdObjBrwFindWholeWordOnly | 314 |
acCmdObjBrwGroupMembers | 318 |
acCmdObjBrwHelp | 316 |
acCmdObjBrwShowHiddenMembers | 315 |
acCmdObjBrwViewDefinition | 317 |
acCmdObjectBrowser | 200 |
acCmdOfficeClipboard | 488 |
acCmdOLEDDELinks | 27 |
acCmdOLEObjectConvert | 167 |
acCmdOLEObjectDefaultVerb | 57 |
acCmdOpenDatabase | 25 |
acCmdOpenHyperlink | 326 |
acCmdOpenNewHyperlink | 327 |
acCmdOpenSearchPage | 253 |
acCmdOpenStartPage | 252 |
acCmdOpenTable | 221 |
acCmdOpenURL | 251 |
acCmdOptions | 49 |
acCmdOutdent | 206 |
acCmdOutputToExcel | 175 |
acCmdOutputToRTF | 176 |
acCmdOutputToText | 177 |
acCmdPageHdrFtr | 182 |
acCmdPageNumber | 225 |
acCmdPageProperties | 467 |
acCmdPageSetup | 32 |
acCmdParameterInfo | 305 |
acCmdPartialReplicaWizard | 524 |
acCmdPaste | 191 |
acCmdPasteAppend | 38 |
acCmdPasteAsHyperlink | 490 |
acCmdPasteFormatting | 587 |
acCmdPasteSpecial | 64 |
acCmdPivotAutoAverage | 416 |
acCmdPivotAutoCount | 413 |
acCmdPivotAutoFilter | 398 |
acCmdPivotAutoMax | 415 |
acCmdPivotAutoMin | 414 |
acCmdPivotAutoStdDev | 417 |
acCmdPivotAutoStdDevP | 419 |
acCmdPivotAutoSum | 412 |
acCmdPivotAutoVar | 418 |
acCmdPivotAutoVarP | 420 |
acCmdPivotChartByRowByColumn | 456 |
acCmdPivotChartDrillInto | 457 |
acCmdPivotChartDrillOut | 532 |
acCmdPivotChartMultiplePlots | 458 |
acCmdPivotChartMultiplePlotsUnifiedScale | 459 |
acCmdPivotChartShowLegend | 455 |
acCmdPivotChartSortAscByTotal | 534 |
acCmdPivotChartSortDescByTotal | 535 |
acCmdPivotChartType | 453 |
acCmdPivotChartUndo | 460 |
acCmdPivotChartView | 397 |
acCmdPivotCollapse | 400 |
acCmdPivotDelete | 454 |
acCmdPivotDropAreas | 452 |
acCmdPivotExpand | 401 |
acCmdPivotRefresh | 404 |
acCmdPivotShowAll | 461 |
acCmdPivotShowBottom1 | 432 |
acCmdPivotShowBottom10 | 435 |
acCmdPivotShowBottom10Percent | 440 |
acCmdPivotShowBottom1Percent | 437 |
acCmdPivotShowBottom2 | 433 |
acCmdPivotShowBottom25 | 436 |
acCmdPivotShowBottom25Percent | 441 |
acCmdPivotShowBottom2Percent | 438 |
acCmdPivotShowBottom5 | 434 |
acCmdPivotShowBottom5Percent | 439 |
acCmdPivotShowBottomOther | 442 |
acCmdPivotShowTop1 | 421 |
acCmdPivotShowTop10 | 424 |
acCmdPivotShowTop10Percent | 429 |
acCmdPivotShowTop1Percent | 426 |
acCmdPivotShowTop2 | 422 |
acCmdPivotShowTop25 | 425 |
acCmdPivotShowTop25Percent | 430 |
acCmdPivotShowTop2Percent | 427 |
acCmdPivotShowTop5 | 423 |
acCmdPivotShowTop5Percent | 428 |
acCmdPivotShowTopOther | 431 |
acCmdPivotTableClearCustomOrdering | 527 |
acCmdPivotTableCreateCalcField | 444 |
acCmdPivotTableCreateCalcTotal | 443 |
acCmdPivotTableDemote | 411 |
acCmdPivotTableExpandIndicators | 451 |
acCmdPivotTableExportToExcel | 405 |
acCmdPivotTableFilterBySelection | 528 |
acCmdPivotTableGroupItems | 530 |
acCmdPivotTableHideDetails | 402 |
acCmdPivotTableMoveToColumnArea | 407 |
acCmdPivotTableMoveToDetailArea | 409 |
acCmdPivotTableMoveToFilterArea | 408 |
acCmdPivotTableMoveToRowArea | 406 |
acCmdPivotTablePercentColumnTotal | 447 |
acCmdPivotTablePercentGrandTotal | 450 |
acCmdPivotTablePercentParentColumnItem | 449 |
acCmdPivotTablePercentParentRowItem | 448 |
acCmdPivotTablePercentRowTotal | 446 |
acCmdPivotTablePromote | 410 |
acCmdPivotTableRemove | 529 |
acCmdPivotTableShowAsNormal | 445 |
acCmdPivotTableShowDetails | 403 |
acCmdPivotTableSubtotal | 399 |
acCmdPivotTableUngroupItems | 531 |
acCmdPivotTableView | 396 |
acCmdPrepareDatabaseForWeb | 716 |
acCmdPreviewEightPages | 249 |
acCmdPreviewFourPages | 248 |
acCmdPreviewOnePage | 246 |
acCmdPreviewTwelvePages | 250 |
acCmdPreviewTwoPages | 247 |
acCmdPrimaryKey | 107 |
acCmdPrint | 340 |
acCmdPrintPreview | 54 |
acCmdPrintRelationships | 483 |
acCmdPrintSelection | 590 |
acCmdProcedureDefinition | 122 |
acCmdProperties | 287 |
acCmdPublishDatabase | 537 |
acCmdPublishDefaults | 324 |
acCmdPublishFixedFormat | 591 |
acCmdQueryAddToOutput | 362 |
acCmdQueryGroupBy | 361 |
acCmdQueryParameters | 76 |
acCmdQueryTotals | 73 |
acCmdQueryTypeAppend | 91 |
acCmdQueryTypeCrosstab | 74 |
acCmdQueryTypeDelete | 92 |
acCmdQueryTypeMakeTable | 94 |
acCmdQueryTypeSelect | 89 |
acCmdQueryTypeSQLDataDefinition | 168 |
acCmdQueryTypeSQLPassThrough | 169 |
acCmdQueryTypeSQLUnion | 180 |
acCmdQueryTypeUpdate | 90 |
acCmdQuickInfo | 304 |
acCmdQuickPrint | 278 |
acCmdQuickWatch | 203 |
acCmdRecordsGoToFirst | 67 |
acCmdRecordsGoToLast | 68 |
acCmdRecordsGoToNew | 28 |
acCmdRecordsGoToNext | 65 |
acCmdRecordsGoToPrevious | 66 |
acCmdRecoverDesignMaster | 265 |
acCmdRedo | 199 |
acCmdReferences | 260 |
acCmdRefresh | 18 |
acCmdRefreshData | 541 |
acCmdRefreshPage | 297 |
acCmdRefreshSharePointList | 626 |
acCmdRegisterActiveXControls | 254 |
acCmdRelationships | 133 |
acCmdRemove | 366 |
acCmdRemoveAllFilters | 644 |
acCmdRemoveAllSorts | 645 |
acCmdRemoveFilterFromCurrentColumn | 643 |
acCmdRemoveFilterSort | 144 |
acCmdRemoveFromLayout | 582 |
acCmdRemoveTable | 84 |
acCmdRename | 143 |
acCmdRenameColumn | 274 |
acCmdRenameGroup | 492 |
acCmdRepairDatabase | 6 |
acCmdReplace | 29 |
acCmdReportHdrFtr | 37 |
acCmdReportView | 539 |
acCmdReset | 124 |
acCmdResolveConflicts | 266 |
acCmdRestore | 514 |
acCmdRowHeight | 116 |
acCmdRun | 181 |
acCmdRunMacro | 31 |
acCmdRunOpenMacro | 338 |
acCmdSave | 20 |
acCmdSaveAllModules | 280 |
acCmdSaveAs | 21 |
acCmdSaveAsHTML | 321 |
acCmdSaveAsOutlookContact | 584 |
acCmdSaveAsQuery | 96 |
acCmdSaveAsReport | 142 |
acCmdSaveAsTemplate | 686 |
acCmdSaveDatabaseAsNewTemplatePart | 687 |
acCmdSavedExports | 555 |
acCmdSavedImports | 543 |
acCmdSaveLayout | 145 |
acCmdSaveModuleAsText | 119 |
acCmdSaveRecord | 97 |
acCmdSaveSelectionAsNewDataType | 688 |
acCmdSelectAll | 333 |
acCmdSelectAllRecords | 109 |
acCmdSelectEntireColumn | 571 |
acCmdSelectEntireLayout | 715 |
acCmdSelectEntireRow | 570 |
acCmdSelectForm | 40 |
acCmdSelectRecord | 50 |
acCmdSelectReport | 319 |
acCmdSend | 173 |
acCmdSendToBack | 53 |
acCmdServerFilterByForm | 507 |
acCmdServerProperties | 496 |
acCmdSetCaption | 637 |
acCmdSetControlDefaults | 56 |
acCmdSetDatabasePassword | 275 |
acCmdSetNextStatement | 129 |
acCmdShareOnSharePoint | 542 |
acCmdSharePointSiteRecycleBin | 641 |
acCmdShowAllRelationships | 149 |
acCmdShowColumnHistory | 620 |
acCmdShowDatePicker | 636 |
acCmdShowDirectRelationships | 148 |
acCmdShowEnvelope | 533 |
acCmdShowLogicCatalog | 685 |
acCmdShowMembers | 302 |
acCmdShowMessageBar | 676 |
acCmdShowNextStatement | 130 |
acCmdShowTable | 185 |
acCmdSingleStep | 88 |
acCmdSizeToFit | 59 |
acCmdSizeToFitForm | 69 |
acCmdSizeToGrid | 48 |
acCmdSizeToNarrowest | 155 |
acCmdSizeToWidest | 156 |
acCmdSnapToGrid | 62 |
acCmdSortAscending | 163 |
acCmdSortDescending | 164 |
acCmdSortingAndGrouping | 51 |
acCmdSpeech | 511 |
acCmdSpelling | 269 |
acCmdSQLView | 184 |
acCmdStackedLayout | 568 |
acCmdStartNewWorkflow | 675 |
acCmdStartupProperties | 224 |
acCmdStepInto | 342 |
acCmdStepOut | 311 |
acCmdStepOver | 128 |
acCmdStepToCursor | 204 |
acCmdSubdatasheetCollapseAll | 505 |
acCmdSubdatasheetExpandAll | 504 |
acCmdSubdatasheetRemove | 506 |
acCmdSubformDatasheet | 108 |
acCmdSubformDatasheetView | 463 |
acCmdSubformFormView | 462 |
acCmdSubformInNewWindow | 495 |
acCmdSubformPivotChartView | 465 |
acCmdSubformPivotTableView | 464 |
acCmdSwitchboardManager | 521 |
acCmdSynchronize | 638 |
acCmdSynchronizeNow | 264 |
acCmdSyncWebApplication | 699 |
acCmdTabControlPageOrder | 330 |
acCmdTableAddTable | 498 |
acCmdTableCustomView | 497 |
acCmdTableNames | 75 |
acCmdTabOrder | 41 |
acCmdTabularLayout | 569 |
acCmdTestValidationRules | 196 |
acCmdTileHorizontally | 286 |
acCmdTileVertically | 23 |
acCmdToggleBreakpoint | 131 |
acCmdToggleCacheListData | 642 |
acCmdToggleFilter | 220 |
acCmdToggleOffline | 540 |
acCmdToolbarControlProperties | 301 |
acCmdToolbarsCustomize | 165 |
acCmdTransferSQLDatabase | 515 |
acCmdTransparentBackground | 288 |
acCmdTransparentBorder | 289 |
acCmdUndo | 292 |
acCmdUnfreezeAllColumns | 106 |
acCmdUngroupControls | 485 |
acCmdUnhideColumns | 80 |
acCmdUpsizingWizard | 522 |
acCmdUserAndGroupAccounts | 104 |
acCmdUserAndGroupPermissions | 103 |
acCmdUserLevelSecurityWizard | 276 |
acCmdVerticalSpacingDecrease | 161 |
acCmdVerticalSpacingIncrease | 162 |
acCmdVerticalSpacingMakeEqual | 160 |
acCmdViewCode | 170 |
acCmdViewDetails | 210 |
acCmdViewDiagrams | 354 |
acCmdViewFieldList | 353 |
acCmdViewForms | 112 |
acCmdViewFunctions | 395 |
acCmdViewGrid | 63 |
acCmdViewLargeIcons | 209 |
acCmdViewList | 212 |
acCmdViewMacros | 114 |
acCmdViewModules | 115 |
acCmdViewObjectDependencies | 536 |
acCmdViewQueries | 111 |
acCmdViewReports | 113 |
acCmdViewRuler | 61 |
acCmdViewShowPaneDiagram | 358 |
acCmdViewShowPaneGrid | 359 |
acCmdViewShowPaneSQL | 357 |
acCmdViewSmallIcons | 211 |
acCmdViewStoredProcedures | 355 |
acCmdViewTableColumnNames | 363 |
acCmdViewTableColumnProperties | 368 |
acCmdViewTableKeys | 369 |
acCmdViewTableNameOnly | 364 |
acCmdViewTables | 110 |
acCmdViewTableUserView | 370 |
acCmdViewToolbox | 85 |
acCmdViewVerifySQL | 360 |
acCmdViewViews | 356 |
acCmdVisualBasicEditor | 525 |
acCmdWindowArrangeIcons | 24 |
acCmdWindowCascade | 22 |
acCmdWindowHide | 2 |
acCmdWindowSplit | 121 |
acCmdWindowUnhide | 1 |
acCmdWordMailMerge | 195 |
acCmdWorkflowTasks | 674 |
acCmdWorkgroupAdministrator | 391 |
acCmdZoom10 | 244 |
acCmdZoom100 | 240 |
acCmdZoom1000 | 482 |
acCmdZoom150 | 239 |
acCmdZoom200 | 238 |
acCmdZoom25 | 243 |
acCmdZoom50 | 242 |
acCmdZoom500 | 481 |
acCmdZoom75 | 241 |
acCmdZoomBox | 179 |
acCmdZoomSelection | 371 |


WebBrowserControl.OnMouseMove Property (Access)

 Copy code hover
[image]

WebBrowserControl.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnMouseMove

expression A variable that represents a WebBrowserControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


CustomControl.Top Property (Access)

 Copy code hover
[image]

CustomControl.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Syntax

expression .Top

expression A variable that represents a CustomControl object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Form.PivotTable Property (Access)

 Copy code hover
[image]

Form.PivotTable Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a PivotTable object representing a PivotTable View on a form. Read-only.

Syntax

expression .PivotTable

expression A variable that represents a Form object.

Example

This example reports the version of Microsoft Office Web Components in use for the specified form, assuming that there is a PivotTable View on the form.

VBA Copy code Copy code
Dim objChartSpace As PivotTable

Set objChartSpace = Forms(0).PivotTable

MsgBox "Current version of Office Web Components: " _
 & objChartSpace.Version

See also

Concepts

Form Object

Other resources

Form Object Members


You attempted to link or import a Microsoft Word mail merge file. Although you can export such files, you cannot link or import them. (Error 3439)

 Copy code hover
[image]

You attempted to link or import a Microsoft Word mail merge file. Although you can export such files, you cannot link or import them. (Error 3439)
Send feedback

You attempted to link or import a Microsoft Word mail merge file. Although you can export such files, you cannot link or import them.


CommandButton.FontItalic Property (Access)

 Copy code hover
[image]

CommandButton.FontItalic Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontItalic property to specify whether text is italic in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontItalic

expression A variable that represents a CommandButton object.

Remarks

The FontItalic property uses the following settings.

Setting | Description
True | The text is italic.
False | (Default) The text isn't italic.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Attachment.Exit Event (Access)

 Copy code hover
[image]

Attachment.Exit Event (Access)
See also Send feedback

Published: July 16, 2012

The Exit event occurs just before a control loses the focus to another control on the same form.

Version Information

Version Added: Access 2007

Syntax

expression .Exit(Cancel, )

expression A variable that represents an Attachment object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the Exit event occurs. Setting the Cancel argument to True (-1) cancels the Exit event.

Return Value

nothing

Remarks

The Exit event applies only to controls on a form, not controls on a report. This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when this event occurs, set the OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Exit event occurs before the LostFocus event.

Unlike the LostFocus event, the Exit event does not occur when a form loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control to which you moved.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform to which the focus moved)

ß

GotFocus (for the control on the subform to which the focus moved)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


TableDef.CreateField Method (DAO)

 Copy code hover
[image]

TableDef.CreateField Method (DAO)
Send feedback

Creates a new Field object (Microsoft Access workspaces only).

Syntax

expression .CreateField(Name, Type, Size)

expression A variable that represents a TableDef object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Optional | Variant | A String that uniquely names the new Field object. See the Name property for details on valid Field names.
Type | Optional | Variant | A constant that determines the data type of the new Field object. See the Type property for valid data types.
Size | Optional | Variant | An Integer that indicates the maximum size, in bytes, of a Field object that contains text. See the Size property for valid size values. This argument is ignored for numeric and fixed-width fields.

Return Value

Field

Remarks

You can use the CreateField method to create a new field, as well as specify the name, data type, and size of the field. If you omit one or more of the optional parts when you use CreateField, you can use an appropriate assignment statement to set or reset the corresponding property before you append the new object to a collection. After you append the new object, you can alter some but not all of its property settings. See the individual property topics for more details.

The type and Size arguments apply only to Field objects in a TableDef object. These arguments are ignored when a Field object is associated with an Index or Relation object.

If Name refers to an object that is already a member of the collection, a run-time error occurs when you use the Append method.

To remove a Field object from a Fields collection, use the Delete method on the collection. You can't delete a Field object from a TableDef object's Fields collection after you create an index that references the field.

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Adding a hyperlink field to an existing table with DAO

Example

The following example shows how to create a calculated field. The CreateField method creates a field named FullName. The Expression property is then set to the expression that calculates the value of the field.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Sub CreateCalculatedField()
    Dim dbs As DAO.Database
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field2

    ' get the database
    Set dbs = CurrentDb()

    ' create the table
    Set tdf = dbs.CreateTableDef("tblContactsCalcField")

    ' create the fields: first name, last name
    tdf.Fields.Append tdf.CreateField("FirstName", dbText, 20)
    tdf.Fields.Append tdf.CreateField("LastName", dbText, 20)

    ' create the calculated field: full name
    Set fld = tdf.CreateField("FullName", dbText, 50)
    fld.Expression = "[FirstName] & "" "" & [LastName]"
    tdf.Fields.Append fld

    ' append the table and cleanup
    dbs.TableDefs.Append tdf

Cleanup:
    Set fld = Nothing
    Set tdf = Nothing
    Set dbs = Nothing
End Sub

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


QueryDef.CacheSize Property (DAO)

 Copy code hover
[image]

QueryDef.CacheSize Property (DAO)
Send feedback

Sets or returns the number of records retrieved from an ODBC data source that will be cached locally. Read/write Long.

Syntax

expression .CacheSize

expression A variable that represents a QueryDef object.

Remarks

The value of the CacheSize property must be between 5 and 1200, but not greater than available memory will allow. A typical value is 100. A setting of 0 turns off caching.

The Microsoft Access database engine requests records within the cache range from the cache, and it requests records outside the cache range from the server.

Records retrieved from the cache don't reflect concurrent changes that other users made to the source data.


Invalid table name in filter. (Error 3631)

 Copy code hover
[image]

Invalid table name in filter. (Error 3631)
Send feedback

You have referred to a table in a Boolean filter that is not valid. Boolean filters can only refer to the table that is being filtered.


Cannot update

 Copy code hover
[image]

Cannot update <field name>; field not updatable. (Error 3113)
Send feedback

Possible causes:

  • The specified field is part of a TableDef or dynaset-type Recordset object that cannot be updated. For example, this error occurs if you try to update an AutoNumber field.

  • You executed a query that combines updatable and nonupdatable TableDef objects, and you tried to update one of the fields in the query's results (the resulting dynaset-type Recordset).


QueryDefs.Delete Method (DAO)

 Copy code hover
[image]

QueryDefs.Delete Method (DAO)
Send feedback

Not supported for this collection.

Syntax

expression .Delete(Name)

expression A variable that represents a QueryDefs object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Required | String | N/A


Append Method (ADOX Procedures)

 Copy code hover
[image]

Append Method (ADOX Procedures)
Send feedback

Adds a new Procedure object to the Procedures collection.

Syntax

Procedures.Append Name, Command

Parameters

  • Name

  • A String value that specifies the name of the procedure to create and append.

  • Command

  • An ADO Command object that represents the procedure to create and append.

Remarks

Creates a new procedure in the data source with the name and attributes specified in the Command object.

If the command text that the user specifies represents a view rather than a procedure, the behavior is dependent upon the provider being used. Append will fail if the provider does not support persisting commands.

Note Note

When using the OLE DB Provider for Microsoft Jet, the Procedures collection Append method will allow you to specify a View rather than a Procedure in the Command parameter. The View will be added to the data source and will be added to the Procedures collection. After the Append, if the Procedures and Views collections are refreshed, the View will no longer be in the Procedures collection and will appear in the Views collection.


CommandButton.LeftPadding Property (Access)

 Copy code hover
[image]

CommandButton.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the button and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .LeftPadding

expression A variable that represents a CommandButton object.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


CustomControl.HelpContextId Property (Access)

 Copy code hover
[image]

CustomControl.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Syntax

expression .HelpContextId

expression A variable that represents a CustomControl object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


ListBox.RowSourceType Property (Access)

 Copy code hover
[image]

ListBox.RowSourceType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the RowSourceType property (along with the RowSource property) to tell Microsoft Access how to provide data tothe specified object. Read/write String.

Syntax

expression .RowSourceType

expression A variable that represents a ListBox object.

Remarks

The RowSourceType property uses the following settings.

Setting | Description
Table/Query | (Default) The data is from a table, query, or SQL statement specified by the RowSource setting.
Value List | The data is a list of items specified by the RowSource setting.
Field List | The data is a list of field names from a table, query, or SQL statement specified by the RowSource setting.
Note Note

You can also set the RowSourceType property with a user-defined function. The function name is entered without a preceding equal sign (=) and without the trailing pair of parentheses. You must provide specific function code arguments to tell Microsoft Access how to fill the control.

In Visual Basic, set the RowSourceType property by using a string expression with one of these values: "Table/Query", "Value List", or "Field List". You also use a string expression to set the value of the RowSource property. To set the RowSourceType property to a user-defined function, enter the name of the function.

When you have a limited number of values that don't change, you can set the RowSourceType property to Value List and then enter the values that make up the list in the RowSource property.

When you create a user-defined function to insert items into a list box or combo box, Microsoft Access calls the function repeatedly to get the information it needs. User-defined RowSourceType functions must be written in a very specific function format .

Example

The following example sets the RowSourceType property for a combo box to Table/Query, and it sets the RowSource property to a query named EmployeeList.

VBA Copy code Copy code
Forms!Employees!cmboNames.RowSourceType = "Table/Query"
Forms!Employees!cmboNames.RowSource = "EmployeeList"

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Syntax error in DELETE statement. (Error 3130)

 Copy code hover
[image]

Syntax error in DELETE statement. (Error 3130)
Send feedback

You entered an SQL statement that has an invalid DELETE statement.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


Section.AlternateBackColor Property (Access)

 Copy code hover
[image]

Section.AlternateBackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the background color to display on alternate rows of the specified section. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .AlternateBackColor

expression A variable that represents a Section object.

Remarks

The AlternateBackColor property contains a numeric expression that corresponds to the color used to display on alternate rows of the specified section.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom back colors for controls or sections.

See also

Concepts

Section Object

Other resources

Section Object Members


Syntax error in GROUP BY clause. (Error 3132)

 Copy code hover
[image]

Syntax error in GROUP BY clause. (Error 3132)
Send feedback

You entered an SQL statement that has an invalid GROUP BY clause.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


AllQueries.Application Property (Access)

 Copy code hover
[image]

AllQueries.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents an AllQueries object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

AllQueries Collection

Other resources

AllQueries Object Members


TabControl.UseTheme Property (Access)

 Copy code hover
[image]

TabControl.UseTheme Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the specified object will utilize formatting styles defined in Office Document Themes. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .UseTheme

expression A variable that represents a TabControl object.

Remarks

The default value is True.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


TextBox.Left Property (Access)

 Copy code hover
[image]

TextBox.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Syntax

expression .Left

expression A variable that represents a TextBox object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Module.Lines Property (Access)

 Copy code hover
[image]

Module.Lines Property (Access)
See also Send feedback

Published: July 16, 2012

The Lines property returns a string containing the contents of a specified line or lines in a standard module or a class module. Read-only String.

Syntax

expression .Lines(Line, NumLines)

expression A variable that represents a Module object.

Parameters

Name | Required/Optional | Data Type | Description
Line | Required | Long | The number of the first line to return.
NumLines | Required | Long | The number of lines to return.

Remarks

Lines in a module are numbered beginning with 1. For example, if you read the Lines property with a value of 1 for the line argument and 1 for the numlines argument, the Lines property returns a string containing the text of the first line in the module.

To insert a line of text into a module, use the InsertLines method.

Example

The following example deletes a specified line from a module.

VBA Copy code Copy code
Function DeleteWholeLine(strModuleName, strText As String) _
 As Boolean
 Dim mdl As Module, lngNumLines As Long
 Dim lngSLine As Long, lngSCol As Long
 Dim lngELine As Long, lngECol As Long
 Dim strTemp As String

 On Error GoTo Error_DeleteWholeLine
 DoCmd.OpenModule strModuleName
 Set mdl = Modules(strModuleName)

 If mdl.Find(strText, lngSLine, lngSCol, lngELine, lngECol) Then
 lngNumLines = Abs(lngELine - lngSLine) + 1
 strTemp = LTrim$(mdl.Lines(lngSLine, lngNumLines))
 strTemp = RTrim$(strTemp)
 If strTemp = strText Then
 mdl.DeleteLines lngSLine, lngNumLines
 Else
 MsgBox "Line contains text in addition to '" _
 & strText & "'."
 End If
 Else
 MsgBox "Text '" & strText & "' not found."
 End If
 DeleteWholeLine = True

Exit_DeleteWholeLine:
 Exit Function

Error_DeleteWholeLine:
 MsgBox Err & " :" & Err.Description
 DeleteWholeLine = False
 Resume Exit_DeleteWholeLine
End Function

You could call this function from a procedure such as the following, which searches the module Module1 for a constant declaration and deletes it.

VBA Copy code Copy code
Sub DeletePiConst()
 If DeleteWholeLine("Module1", "Const conPi = 3.14") Then
 Debug.Print "Constant declaration deleted successfully."
 Else
 Debug.Print "Constant declaration not deleted."
 End If
End Sub

See also

Concepts

Module Object

Other resources

Module Object Members


Form.DatasheetFontUnderline Property (Access)

 Copy code hover
[image]

Form.DatasheetFontUnderline Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DatasheetFontUnderline property to specify an underlined appearance for field names and data in Datasheet view. Read/write Boolean.

Syntax

expression .DatasheetFontUnderline

expression A variable that represents a Form object.

Remarks

The DatasheetFontUnderline property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

This property is only available in Visual Basic within a Microsoft Access database.

The following table contains the properties that don't exist in the DAO Properties collection of until you set them by using the Formatting (Datasheet) toolbar or you can add them in an Access database by using the CreateProperty method and append it to the DAO Properties collection.

DatasheetFontItalic * | DatasheetForeColor *
DatasheetFontHeight * | DatasheetBackColor
DatasheetFontName * | DatasheetGridlinesColor
DatasheetFontUnderline * | DatasheetGridlinesBehavior
DatasheetFontWeight * | DatasheetCellsEffect
Note Note

When you add or set any property listed with an asterisk, Microsoft Access automatically adds all the properties listed with an asterisk to the Properties collection of the database.

Example

The following example displays the data and field names in Datasheet view of the Products form as italic and underlined.

VBA Copy code Copy code
Forms![Products].DatasheetFontItalic = True
Forms![Products].DatasheetFontUnderline = True

The next example displays the data and field names in Datasheet view of the Products table as italic and underlined.

To set the DatasheetFontItalic and DatasheetFontUnderline properties, the example uses the SetTableProperty procedure, which is in the database's standard module.

VBA Copy code Copy code
Dim dbs As Object, objProducts As Object
Const DB_Boolean As Long = 1
Set dbs = CurrentDb
Set objProducts = dbs![Products]
SetTableProperty objProducts, "DatasheetFontItalic", DB_Boolean, True
SetTableProperty objProducts, "DatasheetFontUnderline", DB_Boolean, True

Sub SetTableProperty(objTableObj As Object, strPropertyName As String, _
 intPropertyType As Integer, varPropertyValue As Variant)
 ' Set Microsoft Access-defined table property without causing
 ' nonrecoverable run-time error.
 Const conErrPropertyNotFound = 3270
 Dim prpProperty As Variant
 On Error Resume Next ' Don't trap errors.
 objTableObj.Properties(strPropertyName) = varPropertyValue
 If Err <> 0 Then ' Error occurred when value set.
 If Err <> conErrPropertyNotFound Then
 On Error GoTo 0
 MsgBox "Couldn't set property '" & strPropertyName _
 & "' on table '" & objTableObj.Name & "'", 48, "SetTableProperty"
 Else
 On Error GoTo 0
 Set prpProperty = objTableObj.CreateProperty(strPropertyName, _
 intPropertyType, varPropertyValue)
 objTableObj.Properties.Append prpProperty
 End If
 End If
 objTableObj.Properties.Refresh
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Database.OpenRecordset Method (DAO)

 Copy code hover
[image]

Database.OpenRecordset Method (DAO)
Send feedback

Creates a new Recordset object and appends it to the Recordsets collection.

Syntax

expression .OpenRecordset(Name, Type, Options, LockEdit)

expression A variable that represents a Database object.

Parameters

Name

Required/Optional

Data Type

Description

Name

Required

String

The source of the records for the new Recordset. The source can be a table name, a query name, or an SQL statement that returns records. For table-type Recordset objects in Microsoft Access database engine databases, the source can only be a table name.

Type

Optional

Variant

A RecordsetTypeEnum constant that indicates the type of Recordset to open.

Note Note

If you open a Recordset in a Microsoft Access workspace and you don't specify a type, OpenRecordset creates a table-type Recordset, if possible. If you specify a linked table or query, OpenRecordset creates a dynaset-type Recordset.

Options

Optional

Variant

A combination of RecordsetOptionEnum constants that specify characteristics of the new Recordset.

Note Note

The constants dbConsistent and dbInconsistent are mutually exclusive, and using both causes an error. Supplying a LockEdit argument when Options uses the dbReadOnly constant also causes an error.

LockEdit

Optional

Variant

A LockTypeEnum constant that determines the locking for the Recordset.

Note Note

You can use dbReadOnly in either the Options argument or the LockedEdit argument, but not both. If you use it for both arguments, a run-time error occurs.

Return Value

Recordset

Remarks

Typically, if the user gets this error while updating a record, your code should refresh the contents of the fields and retrieve the newly modified values. If the error occurs while deleting a record, your code could display the new record data to the user and a message indicating that the data has recently changed. At this point, your code can request a confirmation that the user still wants to delete the record.

You should also use the dbSeeChanges constant if you open a Recordset in a Microsoft Access database engine-connected ODBC workspace against a Microsoft SQL Server 6.0 (or later) table that has an IDENTITY column, otherwise an error may result.

Opening more than one Recordset on an ODBC data source may fail because the connection is busy with a prior OpenRecordset call. One way around this is to fully populate the Recordset by using the MoveLast method as soon as the Recordset is opened.

Closing a Recordset with the Close method automatically deletes it from the Recordsets collection.

Note Note

If source refers to an SQL statement composed of a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strSQL = "PRICE > " & lngPrice, and lngPrice = 125,50), an error occurs when you try to open the Recordset. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and SQL only accepts U.S. decimal characters.

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Transfer data from Access to Excel

Example

The following example shows how to open a Recordset that is based on a parameter query.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset

Set dbs = CurrentDb

'Get the parameter query
Set qfd = dbs.QueryDefs("qryMyParameterQuery")

'Supply the parameter value
qdf.Parameters("EnterStartDate") = Date
qdf.Parameters("EnterEndDate") = Date + 7

'Open a Recordset based on the parameter query
Set rst = qdf.OpenRecordset()

The following example shows how to open a Recordset based on a table or a query.

VBA Copy code Copy code
Dim dbs As DAO.Database
Dim rsTable As DAO.Recordset
Dim rsQuery As DAO.Recordset

Set dbs = CurrentDb

'Open a table-type Recordset
Set rsTable = dbs.OpenRecordset("Table1", dbOpenTable)

'Open a dynaset-type Recordset using a saved query
Set rsQuery = dbs.OpenRecordset("qryMyQuery", dbOpenDynaset)

The following example shows how to open a Recordset based on a Structured Query Language (SQL) statement.

VBA Copy code Copy code
Dim dbs As DAO.Database
Dim rsSQL As DAO.Recordset
Dim strSQL As String

Set dbs = CurrentDb

'Open a snapshot-type Recordset based on an SQL statement
strSQL = "SELECT * FROM Table1 WHERE Field2 = 33"
Set rsSQL = dbs.OpenRecordset(strSQL, dbOpenSnapshot)

The following sample shows how to use the Filter property to determine the records to be included in a subsequently opened Recordset.

VBA Copy code Copy code
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim rstFiltered As DAO.Recordset
Dim strCity As String

Set dbs = CurrentDb

'Create the first filtered Recordset, returning customer records
'for those visited between 30-60 days ago.
Set rest = dbs.OpenRecordset(_
    "SELECT * FROM Customers WHERE LastVisitDate BETWEEN Date()-60 " & _
    "AND Date()-30 ORDER BY LastVisitDate DESC")

'Begin row processing
Do While Not rst.EOF

    'Retrieve the name of the first city in the selected rows
    strCity = rst!City

    'Now filter the Recordset to return only the customers from that city
    rst.Filter = "City = '" & strCity & "'"
    Set rstFiltered = rst.OpenRecordset

    'Process the rows
    Do While Not rstFiltered.EOF
        rstFiltered.Edit
        rstFiltered!ToBeVisited = True
        rstFiltered.Update
        rstFiltered.MoveNext
    Loop

    'We've done what was needed. Now exit
    Exit Do
    rst.MoveNext

Loop

'Cleanup
rstFiltered.Close
rst.Close

Set rstFiltered = Nothing
Set rst = Nothing

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Supports Method Example (VC++)

 Copy code hover
[image]

Supports Method Example (VC++)
Send feedback

This example uses the Supports method to display the options supported by a recordset opened with different cursor types. The DisplaySupport function is required for this example to run.

Copy code Copy code

// BeginSupportsCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <stdio.h>
#include <ole2.h>
#include <conio.h>

//Function Declarations.
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void SupportsX(void);
void DisplaySupport(_RecordsetPtr pRstTemp);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 SupportsX();

 ::CoUninitialize();
}

///////////////////////////////////////////////
// //
// SupportsX Function //
// //
///////////////////////////////////////////////
void SupportsX(void)
{
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstTitles = NULL;

 // Define Other Variables
 HRESULT hr = S_OK;

 // Assign connection string to a variable
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 // Open a recordset from Titles table
 TESTHR(pRstTitles.CreateInstance(__uuidof(Recordset)));

 // Fill array with CursorType constants.
 int aintCursorType[4];
 aintCursorType[0] = adOpenForwardOnly;
 aintCursorType[1] = adOpenKeyset;
 aintCursorType[2] = adOpenDynamic;
 aintCursorType[3] = adOpenStatic;

 // Open recordset using each CursorType and optimistic locking.
 // Then call the DisplaySupport procedure to display the
 // supported options.
 for (int intIndex=0; intIndex <= 3; intIndex++)
 {
 pRstTitles->CursorType =
 (enum CursorTypeEnum)aintCursorType[intIndex];
 pRstTitles->LockType = adLockOptimistic;

 // Pass the Cursor type and LockType to the Recordset.
 pRstTitles->Open ("titles", strCnn,
 (enum CursorTypeEnum)aintCursorType[intIndex],
 adLockOptimistic, adCmdTable);

 switch(aintCursorType[intIndex])
 {
 case adOpenForwardOnly:
 printf("\nForwardOnly cursor supports:\n");
 break;

 case adOpenKeyset:
 printf("\nKeyset cursor supports:\n");
 break;

 case adOpenDynamic:
 printf("\nDynamic cursor supports:\n");
 break;

 case adOpenStatic:
 printf("\nStatic cursor supports:\n");
 break;

 default :
 break;
 }

 DisplaySupport(pRstTitles);

 printf("\n\nPress any key to continue...");
 getch();

 //Clear the screen for the next display.
 system("cls");
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstTitles->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 if (pRstTitles)
 if (pRstTitles->State == adStateOpen)
 pRstTitles->Close();
}

///////////////////////////////////////////////
// //
// DisplaySupport Function //
// //
///////////////////////////////////////////////
void DisplaySupport (_RecordsetPtr pRstTemp)
{
 // Fill array with cursor option constants.
 long alngConstants[11];
 alngConstants[0] = adAddNew;
 alngConstants[1] = adApproxPosition;
 alngConstants[2] = adBookmark;
 alngConstants[3] = adDelete;
 alngConstants[4] = adFind;
 alngConstants[5] = adHoldRecords;
 alngConstants[6] = adMovePrevious;
 alngConstants[7] = adNotify;
 alngConstants[8] = adResync;
 alngConstants[9] = adUpdate;
 alngConstants[10] = adUpdateBatch;

 for(int intIndex=0; intIndex <= 10; intIndex++)
 {
 bool booSupports = pRstTemp->
 Supports( (enum CursorOptionEnum)alngConstants[intIndex] );

 if(booSupports)
 {
 switch(alngConstants[intIndex])
 {
 case adAddNew :
 printf("\n AddNew");
 break;

 case adApproxPosition :
 printf("\n AbsolutePosition and AbsolutePage");
 break;

 case adBookmark :
 printf("\n Bookmark");
 break;

 case adDelete :
 printf("\n Delete");
 break;

 case adFind :
 printf("\n Find");
 break;

 case adHoldRecords :
 printf("\n Holding Records");
 break;

 case adMovePrevious :
 printf("\n MovePrevious and Move");
 break;

 case adNotify :
 printf("\n Notifications");
 break;

 case adResync :
 printf("\n Resyncing data");
 break;

 case adUpdate :
 printf("\n Update");
 break;

 case adUpdateBatch :
 printf("\n Batch updating");
 break;

 default :
 break;
 }
 }
 }
}

///////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////
void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

///////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////
void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndSupportsCpp


Page.OnMouseUp Property (Access)

 Copy code hover
[image]

Page.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Syntax

expression .OnMouseUp

expression A variable that represents a Page object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

Page Object

Other resources

Page Object Members


Clustered Property Example (VC++)

 Copy code hover
[image]

Clustered Property Example (VC++)
Send feedback

This example demonstrates the Clustered property of an Index. Note that Microsoft Jet databases do not support clustered indexes, so this example will return False for the Clustered property of all indexes in the Northwind database.

Copy code Copy code

// BeginClusteredCpp
#import "c:\Program Files\Common Files\system\ado\msadox.dll" no_namespace

#include "iostream.h"
#include "stdio.h"
#include "conio.h"

//Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void ClusteredX(void);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 ClusteredX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// ClusteredX Function //
// //
//////////////////////////////////////////////////////////
void ClusteredX()
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.
 _CatalogPtr m_pCatalog = NULL;
 _TablePtr m_pTable = NULL;
 _IndexPtr m_pIndex = NULL;

 //Define other variables here
 _variant_t vIndex;
 try
 {
 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof(Catalog)));

 // Connect to the catalog.
 m_pCatalog->PutActiveConnection(
 "Provider='Microsoft.JET.OLEDB.4.0';data source="
 "'c:\\Program Files\\Microsoft Office\\Office\\Samples"
 "\\Northwind.mdb';");

 int iLineCnt = 1;
 //Enumerate Tables.
 for(short iTable = 0;iTable < m_pCatalog->Tables->Count;iTable++)
 {
 vIndex = iTable;
 m_pTable = m_pCatalog->Tables->GetItem(vIndex);

 //Enumerate Indexes.
 for(short iIndex = 0;iIndex < m_pTable->Indexes->Count;
 iIndex++)
 {
 vIndex = iIndex;
 m_pIndex = m_pTable->Indexes->GetItem(vIndex);
 cout << m_pTable->Name << " " ;
 cout << m_pIndex->Name << " " << (m_pIndex->
 GetClustered() ? "True" : "False") << endl;

 if (iLineCnt%15 == 0)
 {
 printf("\nPress any key to continue...\n");
 getch();
 }
 iLineCnt++;
 }
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }
 catch(...)
 {
 cout << "Error occured in ClusteredX...."<< endl;
 }
}
// EndClusteredCpp


ImportExportSpecification Object (Access)

 Copy code hover
[image]

ImportExportSpecification Object (Access)
See also Send feedback

Published: July 16, 2012

Represents a saved import or export operation.

Version Information

Version Added: Access 2007

Remarks

A ImportExportSpecification object contains all the information Access needs to repeat an import or export operation without your having to provide any input. For example, an import specification that imports data from a Microsoft Office Excel 2007 workbook stores the name of the source Excel file, the name of the destination database, and other details, such as whether you appended to or created a new table, primary key information, field names, and so on.

Use the Add method of the ImportExportSpecifications collection to create a new ImportExportSpecification object.

Use the Execute method to run saved import or export operation.

See also

Concepts

Access Object Model Reference

Other resources

ImportExportSpecification Object Members


Page.MouseMove Event (Access)

 Copy code hover
[image]

Page.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents a Page object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

Page Object

Other resources

Page Object Members


Property

 Copy code hover
[image]

Property <name> must be set before using this method. (Error 3386)
Send feedback

You attempted to append a new Property object to a collection without first setting all of the new object's properties: Value, Type, and Name.


OptionGroup.BackColor Property (Access)

 Copy code hover
[image]

OptionGroup.BackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the interior color of the specified object. Read/write Long.

Syntax

expression .BackColor

expression A variable that represents an OptionGroup object.

Remarks

The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

To use the BackColor property, the BackStyle property, if available, must be set to Normal.

Example

The following example uses the RGB function to set the , BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Field2.Properties Property (DAO)

 Copy code hover
[image]

Field2.Properties Property (DAO)
Send feedback

Returns the Properties collection of the specified object. Read-only.

Syntax

expression .Properties

expression A variable that represents a Field2 object.


BoundObjectFrame Methods (Access)

 Copy code hover
[image]

BoundObjectFrame Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.


Command (ADO for Visual C++ Syntax)

 Copy code hover
[image]

Command (ADO for Visual C++ Syntax)
Send feedback

Methods

Cancel(void) CreateParameter(BSTR Name, DataTypeEnum Type, ParameterDirectionEnum Direction, long Size, VARIANT Value, _ADOParameter **ppiprm) Execute(VARIANT *RecordsAffected, VARIANT *Parameters, long Options, _ADORecordset **ppirs)

Properties

            get_ActiveConnection(_ADOConnection **ppvObject)

put_ActiveConnection(VARIANT vConn)

putref_ActiveConnection(_ADOConnection *pCon)

get_CommandText(BSTR *pbstr)

put_CommandText(BSTR bstr)

get_CommandTimeout(LONG *pl)

put_CommandTimeout(LONG Timeout)

get_CommandType(CommandTypeEnum *plCmdType)

put_CommandType(CommandTypeEnum lCmdType)

get_Name(BSTR *pbstrName)

put_Name(BSTR bstrName)

get_Prepared(VARIANT_BOOL *pfPrepared)

put_Prepared(VARIANT_BOOL fPrepared)

get_State(LONG *plObjState)

get_Parameters(ADOParameters **ppvObject)


Failure in putting a file to the server using FTP. (Error 3681)

 Copy code hover
[image]

Failure in putting a file to the server using FTP. (Error 3681)
Send feedback

Unable to put a file on the internet server. Make sure the server is running and the FTP share folder is configured properly with read/write access.


OptionGroup.BeforeUpdate Event (Access)

 Copy code hover
[image]

OptionGroup.BeforeUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The BeforeUpdate event occurs before changed data in a control or record is updated.

Syntax

expression .BeforeUpdate(Cancel)

expression A variable that represents an OptionGroup object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the BeforeUpdate event occurs. Setting the Cancel argument to True (-1) cancels the BeforeUpdate event.

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's BeforeUpdate event does occur.

To run a macro or event procedure when this event occurs, set the BeforeUpdate property to the name of the macro or to [Event Procedure].

This event does not apply to option buttons, check boxes, or toggle buttons in an option group. It applies only to the option group itself.

The BeforeUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB. When the focus leaves the record or if the user clicks Save Record on the Records menu, the entire record is updated, and the data is saved in the database.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

BeforeUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. BeforeUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For forms, you can use the BeforeUpdate event to cancel updating of a record before moving to another record.

If the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

You often use the BeforeUpdate event to validate data, especially when you perform complex validations, such as those that:

  • Involve conditions for more than one value on a form.

  • Display different error messages for different data entered.

  • Can be overridden by the user.

  • Contain references to controls on other forms or contain user-defined functions.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

A run-time error will occur if you attempt to modify the data contained in the control that fired the BeforeUpdate event in the event's procedure.

Example

The following example shows how you can use a BeforeUpdate event procedure to check whether a product name has already been entered in the database. After the user types a product name in the ProductName box, the value is compared to the ProductName field in the Products table. If there is a matching value in the Products table, a message is displayed that informs the user that the product has already been entered.

To try the example, add the following event procedure to a form named Products that contains a text box called ProductName.

VBA Copy code Copy code
Private Sub ProductName_BeforeUpdate(Cancel As Integer)
 If(Not IsNull(DLookup("[ProductName]", _
 "Products", "[ProductName] ='" _
 & Me!ProductName & "'"))) Then
 MsgBox "Product has already been entered in the database."
 Cancel = True
 Me!ProductName.Undo
 End If
End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Label.OnClick Property (Access)

 Copy code hover
[image]

Label.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Syntax

expression .OnClick

expression A variable that represents a Label object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

Label Object

Other resources

Label Object Members


AppTitle Property

 Copy code hover
[image]

AppTitle Property
Send feedback

Published: July 16, 2012

You can use the AppTitle property to specify the text that appears in the application database's title bar. For example, you can use the AppTitle property to specify that the string "Inventory Control" appear in the title bar of your Inventory Control database application.

Setting

The AppTitle property is a string expression containing the text to appear in the title bar.

The easiest way to set this property is by using the Application Title option in the Access Options dialog box, available by clicking the click the Microsoft Office Button [image] and then clicking the Current Database category. You can also set this property by using a macro or Visual Basic .

To set the AppTitle property by using a macro or Visual Basic, you must first either set the property in the Access Options dialog box once or create the property in the following ways:

  • In a Microsoft Access database, you can add it by using the CreateProperty method and append it to the Properties collection of the Database object.

  • In a Microsoft Access project (.adp), you can add it to the AccessObjectProperties collection of the CurrentProject object by using the Add method.

You must also use the RefreshTitleBar method to make any changes visible immediately.

Remarks

If this property isn't set, the string "Microsoft Access" appears in the title bar.

This property's setting takes effect immediately after setting the property in code (as long as the code includes the RefreshTitleBar method) or closing the Access Options dialog box.


AppendChunk and GetChunk Methods Example (VC++)

 Copy code hover
[image]

AppendChunk and GetChunk Methods Example (VC++)
Send feedback

This example uses the AppendChunk and GetChunk methods to fill an image field with data from another record.

Copy code Copy code

// BeginAppendChunkCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#define ChunkSize 100

#include <ole2.h>
#include <stdio.h>
#include "conio.h"
#include "malloc.h"
#include "AppendChunkX.h"

//Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void AppendChunkX(VOID);
void PrintProviderError(_ConnectionPtr pConnection);
inline int myscanf(char* strDest, int n)
{
 char strExBuff[10];
 char* pstrRet = fgets(strDest, n, stdin);

 if (pstrRet == NULL)
 return 0;

 if (!strrchr(strDest, '\n'))
 // Exhaust the input buffer.
 do
 {
 fgets(strExBuff, sizeof(strExBuff), stdin);
 }while (!strrchr(strExBuff, '\n'));
 else
 // Replace '\n' with '\0'
 strDest[strrchr(strDest, '\n') - strDest] = '\0';

 return strlen(strDest);
}
inline char* mygets(char* strDest, int n)
{
 char strExBuff[10];
 char* pstrRet = fgets(strDest, n, stdin);

 if (pstrRet == NULL)
 return NULL;

 if (!strrchr(strDest, '\n'))
 // Exhaust the input buffer.
 do
 {
 fgets(strExBuff, sizeof(strExBuff), stdin);
 }while (!strrchr(strExBuff, '\n'));
 else
 // Replace '\n' with '\0'
 strDest[strrchr(strDest, '\n') - strDest] = '\0';

 return pstrRet;
}

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////
void main()
{
 HRESULT hr = S_OK;

 if(FAILED(::CoInitialize(NULL)))
 return;

 AppendChunkX();

 //Wait here for the user to see the output
 printf("\n\nPress any key to continue..");
 getch();
 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// AppendChunkX Function //
// //
///////////////////////////////////////////////////////////
VOID AppendChunkX(VOID)
{
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstPubInfo = NULL;
 _ConnectionPtr pConnection = NULL;

 //Define other variables
 IADORecordBinding *picRs = NULL; //Interface Pointer declared.(VC++ Extensions)
 CPubInfoRs pubrs; //C++ class object

 HRESULT hr = S_OK;
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 _bstr_t strMessage,strPubID,strPRInfo;
 _variant_t varChunk;
 long lngOffSet,lngLogoSize;
 char pubId[50];
 lngOffSet = 0;

 UCHAR chData;
 SAFEARRAY FAR *psa;
 SAFEARRAYBOUND rgsabound[1];
 rgsabound[0].lLbound = 0;
 rgsabound[0].cElements = ChunkSize;

 try
 {
 //Open a Connection.
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
 hr = pConnection->Open(strCnn,"","",adConnectUnspecified);

 TESTHR(hr= pRstPubInfo.CreateInstance(__uuidof(Recordset)));

 pRstPubInfo->CursorType = adOpenKeyset;
 pRstPubInfo->LockType = adLockOptimistic;

 hr = pRstPubInfo->Open("pub_info",
 _variant_t((IDispatch*)pConnection,true),
 adOpenKeyset,adLockOptimistic,adCmdTable);

 //Open an IADORecordBinding interface pointer which we'll use
 //for Binding Recordset to a class
 TESTHR(pRstPubInfo->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 //Bind the Recordset to a C++ Class here
 TESTHR(picRs->BindToRecordset(&pubrs));

 //Display the available logos here
 strMessage = "Available logos are: " + (_bstr_t)"\n\n";
 printf(strMessage);
 int Counter = 0;
 while(!(pRstPubInfo->EndOfFile))
 {
 printf("\n%s",pubrs.m_sz_pubid);
 printf("\n%s",strtok(pubrs.m_sz_prinfo,","));

 //Display 5 records at a time and wait for user to continue..
 if (++Counter >= 5)
 {
 Counter = 0;
 printf("\nPress any key to continue...");
 getch();
 }
 pRstPubInfo->MoveNext();
 }

 //Prompt For a Logo to Copy
 printf("\nEnter the ID of a logo to copy: ");
 myscanf(pubId, sizeof(pubId));
 strPubID = pubId;

 //Copy the logo to a variable in chunks

 pRstPubInfo->Filter = "pub_id = '" + strPubID + "'";
 lngLogoSize = pRstPubInfo->Fields->Item["logo"]->ActualSize;

 //Create a safe array to store the array of BYTES
 rgsabound[0].cElements = lngLogoSize;
 psa = SafeArrayCreate(VT_UI1,1,rgsabound);

 long index1 = 0;
 while(lngOffSet < lngLogoSize)
 {
 varChunk = pRstPubInfo->Fields->
 Item["logo"]->GetChunk(ChunkSize);

 //Copy the data only upto the Actual Size of Field.
 for(long index=0;index<=(ChunkSize-1);index++)
 {
 hr= SafeArrayGetElement(varChunk.parray,&index,&chData);
 if(SUCCEEDED(hr))
 {
 //Take BYTE by BYTE and advance Memory Location
 hr = SafeArrayPutElement(psa,&index1,&chData);
 index1++;
 }
 else
 break;
 }
 lngOffSet = lngOffSet + ChunkSize;
 }
 lngOffSet = 0;

 printf("Enter a new Pub Id: ");
 myscanf(pubrs.m_sz_pubid, sizeof(pubrs.m_sz_pubid));
 strPubID = pubrs.m_sz_pubid;
 printf("Enter descriptive text: " );
 mygets(pubrs.m_sz_prinfo, sizeof(pubrs.m_sz_prinfo));

 pRstPubInfo->AddNew();
 pRstPubInfo->Fields->GetItem("pub_id")->PutValue(strPubID);
 pRstPubInfo->Fields->GetItem("pr_info")->
 PutValue(pubrs.m_sz_prinfo);

 //Assign the Safe array to a variant.
 varChunk.vt = VT_ARRAY|VT_UI1;
 varChunk.parray = psa;
 hr = pRstPubInfo->Fields->GetItem("logo")->
 AppendChunk(varChunk);

 //Update the table
 pRstPubInfo->Update();

 lngLogoSize = pRstPubInfo->Fields->Item["logo"]->ActualSize;

 //Show the newly added record.
 printf("New Record : %s\n Description : %s\n Logo Size : %s",
 pubrs.m_sz_pubid,
 pubrs.m_sz_prinfo,(LPCSTR)(_bstr_t)pRstPubInfo->Fields->
 Item["logo"]->ActualSize);

 //Delete new record because this is demonstration.
 pConnection->Execute("DELETE FROM PUB_INFO WHERE pub_id = '"
 + strPubID +"'",NULL,adCmdText);
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 PrintProviderError(pConnection);
 printf("Source : %s \n Description : %s\n",(LPCSTR)bstrSource,
 (LPCSTR)bstrDescription);
 }

 // Clean up objects before exit.
 if (pRstPubInfo)
 if (pRstPubInfo->State == adStateOpen)
 pRstPubInfo->Close();
 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

VOID PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;
 long nCount = 0;
 long i = 0;

 if( (pConnection->Errors->Count) > 0)
 {
 nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,(LPCSTR) pErr->Description);
 }
 }
}

// EndAppendChunkCpp

AppendChunkX.h

Copy code Copy code

// BeginAppendChunkH
#include "icrsint.h"

//This Class extracts pubid,prinfo.

class CPubInfoRs : public CADORecordBinding
{
 BEGIN_ADO_BINDING(CPubInfoRs)

 ADO_VARIABLE_LENGTH_ENTRY2(1, adVarChar, m_sz_pubid,
 sizeof(m_sz_pubid), l_pubid, TRUE)

 ADO_VARIABLE_LENGTH_ENTRY2(3, adVarChar, m_sz_prinfo,
 sizeof(m_sz_prinfo), l_prinfo, TRUE)

 END_ADO_BINDING()

public:
 CHAR m_sz_pubid[10];
 ULONG l_pubid;
 CHAR m_sz_prinfo[200];
 ULONG l_prinfo;
};
// EndAppendChunkH


Using ADO with Microsoft Visual J++ Topics

 Copy code hover
[image]

Using ADO with Microsoft Visual J++ Topics
Send feedback

In this section

  • Using ADO with Microsoft Visual J++

  • ADO/WFC Programming

  • Using the Java Type Library Wizard

  • Using the Microsoft SDK for Java

  • ADO Java Class Wrappers


Forms (Access)

 Copy code hover
[image]

Forms (Access)
Send feedback

In this section

  • Access Forms How Do I...

  • User Input

  • Controls How Do I Topics

  • Design

  • Events Access Forms How Do I Topics

  • Printing


TableDefs Properties (DAO)

 Copy code hover
[image]

TableDefs Properties (DAO)
Send feedback

In this section

  • TableDefs.Count Property (DAO)


DDL cannot be completed on this table because it is referenced by constraint

 Copy code hover
[image]

DDL cannot be completed on this table because it is referenced by constraint <name> on table <name>. (Error 3803)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for more information.


CommandButton.LabelAlign Property (Access)

 Copy code hover
[image]

CommandButton.LabelAlign Property (Access)
See also Send feedback

Published: July 16, 2012

The property specifies the text alignment within attached labels on new controls. Read/write Byte.

Syntax

expression .LabelAlign

expression A variable that represents a CommandButton object.

Remarks

The LabelAlign property uses the following settings.

Setting | Description
0 | (Default) The label text aligns to the left.
1 | The label text aligns to the left.
2 | The label text is centered.
3 | The label text aligns to the right.
4 | The label text is evenly distributed.

You can set the LabelAlign property by using a control's default control style or the DefaultControl property in Visual Basic.

When created, controls have an attached label (as long as their AutoLabel property is set to Yes). Changes to the LabelAlign default control style setting affect only controls created on the current form or report.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


TextBox.HideDuplicates Property (Access)

 Copy code hover
[image]

TextBox.HideDuplicates Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.

Syntax

expression .HideDuplicates

expression A variable that represents a TextBox object.

Remarks

The HideDuplicates property applies only to controls (check box, combo box, list box, option button, option group, text box, toggle button) on a report.

The HideDuplicates property uses the following settings.

Setting | Description
True | If the value of a control or the data it contains is the same as in the preceding record, the control is hidden.
False | (Default) The control is visible regardless of the value in the preceding record.

You can set the HideDuplicates property only in report Design view.

You can use the HideDuplicates property to create a grouped report by using only the detail section rather than a group header and the detail section.

Example

The following example returns the HideDuplicates property setting for the CategoryName text box and assigns the value to the intCurVal variable.

VBA Copy code Copy code
Dim intCurVal As Integer
intCurVal = Me!CategoryName.HideDuplicates

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Cannot have Memo or OLE Object fields in criteria

 Copy code hover
[image]

Cannot have Memo or OLE Object fields in criteria <criteria> for aggregate function. (Error 3116)
Send feedback

The HAVING clause of an SQL statement cannot include Memo or OLE Object fields.


CustomControl.OnExit Property (Access)

 Copy code hover
[image]

CustomControl.OnExit Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnExit

expression A variable that represents a CustomControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Exit event occurs just before a control loses the focus to another control on the same form.

The OnExit value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Exit box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Exit box is blank, the property value is an empty string.

Example

The following example associates the Exit event with the macro "Exit_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnExit = "Exit_Macro"

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


NavigationButton.QuickStyle Property (Access)

 Copy code hover
[image]

NavigationButton.QuickStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the Quick Style that is applied to the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .QuickStyle

expression A variable that represents a NavigationButton object.

Remarks

The QuickStyle uses one of the values listed in the following table.

Value | Effect
0 (Default) | No Quick Style
1 | Colored Outline - Black, Dark 1
2 | Colored Outline - Ice Blue, Accent 1
3 | Colored Outline - Orange, Accent 2
4 | Colored Outline - Olive Green, Accent 3
5 | Colored Outline - Gold, Accent 4
6 | Colored Outline - Green, Accent 5
7 | Colored Outline - Gray-50%, Accent 6
8 | Colored Fill - Black, Dark 1
9 | Colored Fill - Ice Blue, Accent 1
10 | Colored Fill - Orange, Accent 2
11 | Colored Fill - Olive Green, Accent 3
12 | Colored Fill - Gold, Accent 4
13 | Colored Fill - Green, Accent 5
14 | Colored Fill - Gray-50%, Accent 6
15 | Light 1 Outline, Colored Fill - Black, Dark 1
16 | Light 1 Outline, Colored Fill - Ice Blue, Accent 1
17 | Light 1 Outline, Colored Fill - Orange, Accent 2
18 | Light 1 Outline, Colored Fill - Olive Green, Accent 3
19 | Light 1 Outline, Colored Fill - Gold, Accent 4
10 | Light 1 Outline, Colored Fill - Green, Accent 5
21 | Light 1 Outline, Colored Fill - Gray-50%, Accent 6
22 | Subtle Effect - Black, Dark 1
23 | Subtle Effect - Ice Blue, Accent 1
24 | Subtle Effect - Orange, Accent 2
25 | Subtle Effect - Olive Green, Accent 3
26 | Subtle Effect - Gold, Accent 4
27 | Subtle Effect - Green, Accent 5
28 | Subtle Effect - Gray-50%, Accent 6
29 | Moderate Effect - Black, Dark 1
30 | Moderate Effect - Ice Blue, Accent 1
31 | Moderate Effect - Orange, Accent 2
32 | Moderate Effect - Olive Green, Accent 3
33 | Moderate Effect - Gold, Accent 4
34 | Moderate Effect - Green, Accent 5
35 | Moderate Effect - Gray-50%, Accent 6
36 | Intense Effect - Black, Dark 1
37 | Intense Effect - Ice Blue, Accent 1
38 | Intense Effect - Orange, Accent 2
39 | Intense Effect - Olive Green, Accent 3
40 | Intense Effect - Gold, Accent 4
41 | Intense Effect - Green, Accent 5
42 | Intense Effect - Gray-50%, Accent 6

To see the available Quick Styles and apply a Quick Style through the user interface, first open the form or report in Layout view or Design view by right-clicking the form or report in the Navigation Pane, and then clicking the view you want. Then, click the object to which you want to apply a shadow effect. Next, on the Format tab, in the Control Formatting group, click Quick Styles and choose a Quick Style. Notice that the Quick Styles are indexed from left to right, and then top to bottom. So the first item,Colored Outline - Black, Dark 1, has the value 1. The first row contains Quick Styles with values from 1 to 7. The second row from 8 to 14, and so on.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Form.CurrentRecord Property (Access)

 Copy code hover
[image]

Form.CurrentRecord Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the CurrentRecord property to identify the current record in the recordset being viewed on a form. Read/write Long.

Syntax

expression .CurrentRecord

expression A variable that represents a Form object.

Remarks

Microsoft Access sets this property to a Long Integer value that represents the current record number displayed on a form.

The CurrentRecord property is read-only in Form view and Datasheet view. It's not available in Design view.

The value specified by this property corresponds to the value shown in the record number box found in the lower-left corner of the form.

See also

Concepts

Form Object

Other resources

Form Object Members


Syntax error in CONSTRAINT clause. (Error 3289)

 Copy code hover
[image]

Syntax error in CONSTRAINT clause. (Error 3289)
Send feedback

You entered an SQL statement that includes an invalid CONSTRAINT clause.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


NavigationButton.ParentTab Property (Access)

 Copy code hover
[image]

NavigationButton.ParentTab Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the top-level navigation button associated with the specified navigation button. Read-only NavigationButton.

Version Information

Version Added: Access 2010

Syntax

expression .ParentTab

expression A variable that represents a NavigationButton object.

Remarks

The ParentTab propety will return a run-time error if the specified navigation button is a top-level navigation button.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Invalid SQL syntax - Expected token: NULL. (Error 3726)

 Copy code hover
[image]

Invalid SQL syntax - Expected token: NULL. (Error 3726)
Send feedback

This error occurs when issuing a DDL statement that is associated with an index. It can occur when the NULL keyword is not used after the following keywords: CREATE INDEX, WITH PRIMARY, or IGNORE.


TextBox.InputMask Property (Access)

 Copy code hover
[image]

TextBox.InputMask Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InputMask property to make data entry easier and to control the values users can enter in a text boxcontrol. Read/write String.

Syntax

expression .InputMask

expression A variable that represents a TextBox object.

Remarks

Input masks are helpful for data-entry operations such as an input mask for a Phone Number field that shows you exactly how to enter a new number: (___) ___-____. It is often easier to use the Input Mask Wizard to set the property for you.

The InputMask property can contain up to three sections separated by semicolons (;).

Section | Description
First | Specifies the input mask itself; for example, !(999) 999-9999. For a list of characters you can use to define the input mask, see the following table.
Second | Specifies whether Microsoft Access stores the literal display characters in the table when you enter data. If you use 0 for this section, all literal display characters (for example, the parentheses in a phone number input mask) are stored with the value; if you enter 1 or leave this section blank, only characters typed into the control are stored.
Third | Specifies the character that Microsoft Access displays for the space where you should type a character in the input mask. For this section, you can use any character; to display an empty string, use a space enclosed in quotation marks (" ").

In Visual Basic you use a string expression to set this property. For example, the following specifies an input mask for a text box control used for entering a phone number:

VBA Copy code Copy code
Forms!Customers!Telephone.InputMask = "(###) ###-####"

When you create an input mask, you can use special characters to require that certain data be entered (for example, the area code for a phone number) and that other data be optional (such as a telephone extension). These characters specify the type of data, such as a number or character, that you must enter for each character in the input mask.

You can define an input mask by using the following characters.

Character | Description
0 | Digit (0 to 9, entry required, plus [+] and minus [-] signs not allowed).
9 | Digit or space (entry not required, plus and minus signs not allowed).
# | Digit or space (entry not required; spaces are displayed as blanks while in Edit mode, but blanks are removed when data is saved; plus and minus signs allowed).
L | Letter (A to Z, entry required).
? | Letter (A to Z, entry optional).
A | Letter or digit (entry required).
a | Letter or digit (entry optional).
& | Any character or a space (entry required).
C | Any character or a space (entry optional).
. , : ; - / | Decimal placeholder and thousand, date, and time separators. (The actual character used depends on the settings in the Regional Settings Properties dialog box in Windows Control Panel).
< | Causes all characters to be converted to lowercase.
> | Causes all characters to be converted to uppercase.
! | Causes the input mask to display from right to left, rather than from left to right. Characters typed into the mask always fill it from left to right. You can include the exclamation point anywhere in the input mask.
\ | Causes the character that follows to be displayed as the literal character (for example, \A is displayed as just A).
Note Note

Setting the InputMask property to the word "Password" creates a password-entry control. Any character typed in the control is stored as the character but is displayed as an asterisk (*). You use the Password input mask to prevent displaying the typed characters on the screen.

When you type data in a field for which you've defined an input mask, the data is always entered in Overtype mode. If you use the BACKSPACE key to delete a character, the character is replaced by a blank space.

If you move text from a field for which you've defined an input mask onto the Clipboard, the literal display characters are copied, even if you have specified that they not be saved with data.

Note Note

Only characters that you type directly in a control or combo box are affected by the input mask. Microsoft Access ignores any input masks when you import data, run an action query, or enter characters in a control by setting the control's Text property in Visual Basic or by using the SetValue action in a macro.

When you've defined an input mask and set the Format property for the same field, the Format property takes precedence when the data is displayed. This means that even if you've saved an input mask, the input mask is ignored when data is formatted and displayed. The data in the underlying table itself isn't changed; the Format property affects only how the data is displayed.

The following table shows some useful input masks and the type of values you can enter in them.

Input mask | Sample values
(000) 000-0000 | (206) 555-0248
(999) 999-9999 | (206) 555-0248
 | ( ) 555-0248
(000) AAA-AAAA | (206) 555-TELE
#999 | -20
 | 2000
>L????L?000L0 | GREENGR339M3
 | MAY R 452B7
>L0L 0L0 | T2F 8M4
00000-9999 | 98115-
 | 98115-3007
>L<?????????????? | Maria
 | Brendan
SSN 000-00-0000 | SSN 555-55-5555
>LL00000-0000 | DB51392-0493

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ADOX Enumerated Constants Reference

 Copy code hover
[image]

ADOX Enumerated Constants Reference
Send feedback

In this section

  • ADOX Enumerated Constants

  • ActionEnum

  • AllowNullsEnum

  • ColumnAttributesEnum

  • InheritTypeEnum

  • KeyTypeEnum

  • RightsEnum

  • RuleEnum

  • SortOrderEnum


Module.AddFromFile Method (Access)

 Copy code hover
[image]

Module.AddFromFile Method (Access)
See also Send feedback

Published: July 16, 2012

The AddFromFile method adds the contents of a text file to a Module object. The Module object may represent a standard module or a class module.

Syntax

expression .AddFromFile(FileName)

expression A variable that represents a Module object.

Parameters

Name | Required/Optional | Data Type | Description
FileName | Required | String | The name and full path of a text (.txt) file or another file that stores text in an ANSI format.

Remarks

The AddFromFile method places the contents of the specified text file immediately after the Declarations section and before the first procedure in the module if it contains other procedures.

The AddFromFile method enables you to import code or comments stored in a text file.

In order to add the contents of a file to a form or report module, the form or report must be open in form Design view or report Design view. In order to add the contents of a file to a standard module or class module, the module must be open.

Example

The following example places the contents of the file "ShippingRoutines.bas" into the module "CalculateShipping" immediately after the Declarations section, but before the first procedure in the module.

VBA Copy code Copy code
Modules("CalculateShipping").AddFromFile "C:\Shipping\ShippingRoutines.bas"

See also

Concepts

Module Object

Other resources

Module Object Members


ListBox.GridlineWidthRight Property (Access)

 Copy code hover
[image]

ListBox.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified list box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthRight

expression A variable that represents a ListBox object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


CommandButton.PictureType Property (Access)

 Copy code hover
[image]

CommandButton.PictureType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.

Syntax

expression .PictureType

expression A variable that represents a CommandButton object.

Remarks

The PictureType property uses the following settings.

Setting | Description
0 | (Default) The picture is embedded in the object and becomes part of the database file.
1 | The picture is linked to the object. Microsoft Access stores a pointer to the location of the picture on the disk.

This property can be set only in form Design view or report Design view.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

When this property is set to 0, the size of the database increases by the size of the picture file and, with some .wmf files, the size may increase as much as twice the size of the picture file. When this property is set to 1, there is no increase in the size of the database because Microsoft Access only saves a pointer to the picture's location on the disk.

Note Note

If a linked file is moved to another location on the disk, you must re-establish the link by using the object's Picture property.

For embedded pictures, the object's PictureData property stores the individual bits that make up a picture's image. For linked pictures, this property stores the path to the picture's file.

You can modify a linked picture by using a separate application and changes to the picture will appear the next time the object containing that picture is displayed in the database.

Example

The following example links the picture in the "Customer Photo" image control on the "Order Entry" form to the picture on the disk. The picture is not part of the database file.

VBA Copy code Copy code
Forms("Order Entry").Controls("Customer Photo").PictureType = 1

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Sending the Updates: UpdateBatch

 Copy code hover
[image]

Sending the Updates: UpdateBatch
Send feedback

Sending the Updates: UpdateBatch Method

The following code opens a Recordset in batch mode by setting the LockType property to adLockBatchOptimistic and the CursorLocation to adUseClient. It adds two new records and changes the value of a field in an existing record, saving the original values, and then calls UpdateBatch to send the changes back to the data source.

Copy code Copy code

'BeginBatchUpdate
    strSQL = "SELECT ShipperId, CompanyName, Phone FROM Shippers"

    objRs1.CursorLocation = adUseClient
    objRs1.Open strSQL, strConn, adOpenStatic, adLockBatchOptimistic, adCmdText

    ' Change value of Phone field for first record in Recordset, saving value
    ' for later restoration.
    intId = objRs1("ShipperId")
    strPhone = objRs1("Phone")

    objRs1("Phone") = "(111) 555-1111"

    'Add two new records
    For i = 0 To 1
        objRs1.AddNew
        objRs1(1) = "New Shipper #" & CStr((i + 1))
        objRs1(2) = "(nnn) 555-" & i & i & i & i
    Next i

    ' Send the updates
    objRs1.UpdateBatch
'EndBatchUpdate

If you are editing the current record or adding a new record when you call the UpdateBatch method, ADO will automatically call the Update method to save any pending changes to the current record before transmitting the batched changes to the provider.


OptionButton.OnExit Property (Access)

 Copy code hover
[image]

OptionButton.OnExit Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnExit

expression A variable that represents an OptionButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Exit event occurs just before a control loses the focus to another control on the same form.

The OnExit value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Exit box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Exit box is blank, the property value is an empty string.

Example

The following example associates the Exit event with the macro "Exit_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnExit = "Exit_Macro"

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Log Function (Access 2013 custom web app)

 Copy code hover
[image]

Log Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the natural logarithm, or the logarithm of the given base, of the specified expression.

Syntax

Log(NumericExpression, [Base])

The Log function contains the following arguments.

Argument name | Description
NumericExpression | The positive number for which you want the logarithm.
Base | The base of the logarithm. If omitted, the Log function returns the natural logarithm.

Remarks

The function Log10 is similar, but always returns the common logarithm, meaning the logarithm for the base 10.

The natural logarithm is the logarithm to the base e, where e is an irrational constant approximately equal to 2.718281828.


ADO Dynamic Properties

 Copy code hover
[image]

ADO Dynamic Properties
Send feedback

Dynamic properties can be added to the Properties collections of the Connection, Command, or Recordset objects. The source for these properties is either a data provider, such as the OLE DB Provider for SQL Server, or a service provider, such as the Microsoft Cursor Service for OLE DB. Refer to the appropriate data provider or service provider documentation for more information about a specific dynamic property.

The ADO Dynamic Property Index provides a cross-reference between the ADO and OLE DB names for each standard OLE DB provider dynamic property.

The following dynamic properties are of special interest, and are also documented in the sources mentioned above. Special functionality with ADO is documented in the ADO help topics listed below.

Optimize | Specifies whether an index should be created on this field.
Prompt | Specifies whether the OLE DB provider should prompt the user for initialization information.
Reshape Name | Specifies a name for the Recordset object.
Resync Command | Specifies a user-supplied command string that the Resync method issues to refresh the data in the table named in the Unique Table dynamic property.
Unique Table, Unique Schema, Unique Catalog | Unique Table — specifies the name of the base table upon which updates, insertions, and deletions are allowed. Unique Schema — specifies the schema, or name of the owner of the table. Unique Catalog — specifies the catalog, or name of the database containing the table.
Update Resync | Specifies whether the UpdateBatch method is followed by an implicit Resync method operation, and if so, the scope of that operation.


Set a Reference to a Visual Basic Project in Another Microsoft Access Database or Project

 Copy code hover
[image]

Set a Reference to a Visual Basic Project in Another Microsoft Access Database or Project
Send feedback

Each Microsoft Access database includes a Visual Basic project. The Visual Basic project is the set of all modules in the project, including both standard modules and class modules. Every Microsoft Access database, library database, or add-in contained in an .mde file includes a Visual Basic project.

The name of the Access database and the name of the project can differ. The name of the Access database is determined by the name of the .mdb (or .mda or .mde) or .adp file, while the name of the project is determined by the setting of the Project Name option on the General tab of the ProjectName -Project Properties dialog box, available by clicking ProjectName Properties on the Tools menu in the Visual Basic Editor. When you first create a database (.mdb or .adp), the database name and project name are the same by default. However, if you rename the database, the project name doesn't automatically change. Likewise, changing the project name has no effect on the database name.

You can set a reference from a Visual Basic project in one Microsoft Access database to a project in another Microsoft Access database, a library database, or an add-in contained in an .mde file. Once you've set a reference, you can run Visual Basic procedures in the referenced project. For example, the Northwind sample database includes a module named Utility Functions that contains a function called IsLoaded. You can set a reference to the project in the Northwind sample database from the project in the current database, and then call the IsLoaded function just as you would if it were defined within the current database.

Note Note

  • Set a reference to the project in another Microsoft Access database when you want to call a public procedure that's defined within a standard module in that database. You can't call procedures that are defined within a class module or procedures in a standard module that are preceded with the Private keyword.

  • You can set a reference to the project in a Microsoft Access database only from another Microsoft Access database.

  • You can set a reference to a project only in another Microsoft Access 2002 or later database. To set a reference to a project in a database created in an earlier version of Microsoft Access, first convert that database to Microsoft Access 2002 or later.

  • If you set a reference to a project or type library from Microsoft Access and then move the file that contains that project or type library to a different folder, Microsoft Access will attempt to locate the file and reestablish the reference. If the RefLibPaths key exists in the registry, Microsoft Access will first search there. If there's no matching entry, Microsoft Access will search for the file first in the current folder, then in all the folders on the drive. You can create the RefLibPaths key by using the Registry Editor in Windows, under the registry key \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\version\Access. For more information about using the Registry Editor, see your Windows documentation.


ToggleButton.OnKeyUp Property (Access)

 Copy code hover
[image]

ToggleButton.OnKeyUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Up box in the Properties window. Read/write String.

Syntax

expression .OnKeyUp

expression A variable that represents a ToggleButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyUp event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyUp

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


OptionButton.TabIndex Property (Access)

 Copy code hover
[image]

OptionButton.TabIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.

Syntax

expression .TabIndex

expression A variable that represents an OptionButton object.

Remarks

You can set the TabIndex property to an integer representing the position of the control within the tab order of the form. Valid settings are 0 for the first tab position, up to the total number of controls minus 1 for the last tab position. For example, if a form has three controls that each have a TabIndex property, valid TabIndex property settings are 0, 1, and 2.

Setting the TabIndex property to an integer less than 0 produces an error.

By default, Microsoft Access assigns a tab order to controls in the order that you create them on a form. Each new control is placed last in the tab order. If you change the setting of a control's TabIndex property to adjust the tab order, Microsoft Access automatically renumbers the TabIndex property setting of other controls to reflect insertions and deletions.

In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the TAB key.

Changing the tab order of other controls on the form doesn't affect what happens when you press a control's access key. For example, if you've created an access key for the label of a text box, the focus will move to the text box whenever you press the label's access key — even if you change the TabIndex property setting for the text box.

If you press an access key for a control such as a label that doesn't have a TabIndex property (and thus isn't in the tab order), the focus moves to the next control in the tab order that can receive the focus.

Example

The following example reverses the tab order of a command button and a text box. Because TextBox1 was created first, it has a TabIndex property setting of 0 and Command1 has a setting of 1.

VBA Copy code Copy code
Sub Form_Click()
 Me!Command1.TabIndex = 0
 Me!TextBox1.TabIndex = 1
End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Overview of Multidimensional Schemas and Data

 Copy code hover
[image]

Overview of Multidimensional Schemas and Data
Send feedback

Understanding Multidimensional Schemas

The central metadata object in ADO MD is the cube, which consists of a structured set of related dimensions, hierarchies, levels, and members.

A dimension is an independent category of data from your multidimensional database, derived from your business entities. A dimension typically contains items to be used as query criteria for the measures of the database.

A hierarchy is a path of aggregation of a dimension. A dimension may have multiple levels of granularity, which have parent-child relationships. A hierarchy defines how these levels are related.

A level is a step of aggregation in a hierarchy. For dimensions with multiple layers of information, each layer is a level.

A member is a data item in a dimension. Typically, you create a caption or describe a measure of the database using members.

Cubes are represented by CubeDef objects in ADO MD. Dimensions, hierarchies, levels, and members are also represented by their corresponding ADO MD objects: Dimension, Hierarchy, Level, and Member.

Dimensions

The dimensions of a cube depend on your business entities and types of data to be modeled in the database. Typically, each dimension is an independent entry point or mechanism for selecting data.

For example, a cube containing sales data has the following five dimensions: Salesperson, Geography, Time, Products, and Measures. The Measures dimension contains actual sales data values, while the other dimensions represent ways to categorize and group the sales data values.

The Geography dimension has the following set of members:

Copy code Copy code

{All, North America, Europe, Canada, USA, UK, Germany, Canada-West,
Canada-East, USA-NW, USA-SW, USA-NE, USA-SE, England, Scotland,
Wales,Ireland, Germany-North, Germany-South, Ottawa, Toronto,
Vancouver, Calgary, Seattle, Boise, Los Angeles, Houston,
Shreveport, Miami, Boston, New York, London, Dover, Glasgow,
Edinburgh, Cardiff, Pembroke, Belfast, Berlin,
Hamburg, Munich, Stuttgart}

Hierarchies

Hierarchies define the ways in which the levels of a dimension can be "rolled up" or grouped. A dimension can have more than one hierarchy.

Levels

In the example Geography dimension pictured in the previous figure, each box represents a level in the hierarchy.

Each level has a set of members, as follows:

  • The World = {All}

  • Continents = {North America, Europe}

  • Countries = {Canada, USA, UK, Germany}

  • Regions = {Canada-East, Canada-West, USA-NE, USA-NW, USA-SE, USA-SW, England, Ireland, Scotland, Wales, Germany-North, Germany-South}

  • Cities = {Ottawa, Toronto, Vancouver, Calgary, Seattle, Boise, Los Angeles, Houston, Shreveport, Miami, Boston, New York, London, Dover, Glasgow, Edinburgh, Cardiff, Pembroke, Belfast, Berlin, Hamburg, Munich, Stuttgart}

Members

Members at the leaf level of a hierarchy have no children, and members at the root level have no parent. All other members have at least one parent and at least one child. For example, a partial traversal of the hierarchy tree in the Geography dimension yields the following parent-child relationships:

  • {All} (parent of) {Europe, North America}

  • {North America} (parent of) {Canada, USA}

  • {USA} (parent of) {USA-NE, USA-NW, USA-SE, USA-SW}

  • {USA-NW} (parent of) {Boise, Seattle}

Members can be consolidated along one or more hierarchies per dimension.

This example also illustrates another characteristic: Some members of the Week level of the Year-Week hierarchy do not appear in any level of the Year-Quarter hierarchy. Thus, a hierarchy need not include all members of a dimension.

Understanding Multidimensional Schemas

The central metadata object in ADO MD is the cube, which consists of a structured set of related dimensions, hierarchies, levels, and members.

A dimension is an independent category of data from your multidimensional database, derived from your business entities. A dimension typically contains items to be used as query criteria for the measures of the database.

A hierarchy is a path of aggregation of a dimension. A dimension may have multiple levels of granularity, which have parent-child relationships. A hierarchy defines how these levels are related.

A level is a step of aggregation in a hierarchy. For dimensions with multiple layers of information, each layer is a level.

A member is a data item in a dimension. Typically, you create a caption or describe a measure of the database using members.

Cubes are represented by CubeDef objects in ADO MD. Dimensions, hierarchies, levels, and members are also represented by their corresponding ADO MD objects: Dimension, Hierarchy, Level, and Member.

Dimensions

The dimensions of a cube depend on your business entities and types of data to be modeled in the database. Typically, each dimension is an independent entry point or mechanism for selecting data.

For example, a cube containing sales data has the following five dimensions: Salesperson, Geography, Time, Products, and Measures. The Measures dimension contains actual sales data values, while the other dimensions represent ways to categorize and group the sales data values.

The Geography dimension has the following set of members:

Copy code Copy code

{All, North America, Europe, Canada, USA, UK, Germany, Canada-West,
Canada-East, USA-NW, USA-SW, USA-NE, USA-SE, England, Scotland,
Wales,Ireland, Germany-North, Germany-South, Ottawa, Toronto,
Vancouver, Calgary, Seattle, Boise, Los Angeles, Houston,
Shreveport, Miami, Boston, New York, London, Dover, Glasgow,
Edinburgh, Cardiff, Pembroke, Belfast, Berlin,
Hamburg, Munich, Stuttgart}

Hierarchies

Hierarchies define the ways in which the levels of a dimension can be "rolled up" or grouped. A dimension can have more than one hierarchy.

Levels

In the example Geography dimension pictured in the previous figure, each box represents a level in the hierarchy.

Each level has a set of members, as follows:

  • The World = {All}

  • Continents = {North America, Europe}

  • Countries = {Canada, USA, UK, Germany}

  • Regions = {Canada-East, Canada-West, USA-NE, USA-NW, USA-SE, USA-SW, England, Ireland, Scotland, Wales, Germany-North, Germany-South}

  • Cities = {Ottawa, Toronto, Vancouver, Calgary, Seattle, Boise, Los Angeles, Houston, Shreveport, Miami, Boston, New York, London, Dover, Glasgow, Edinburgh, Cardiff, Pembroke, Belfast, Berlin, Hamburg, Munich, Stuttgart}

Members

Members at the leaf level of a hierarchy have no children, and members at the root level have no parent. All other members have at least one parent and at least one child. For example, a partial traversal of the hierarchy tree in the Geography dimension yields the following parent-child relationships:

  • {All} (parent of) {Europe, North America}

  • {North America} (parent of) {Canada, USA}

  • {USA} (parent of) {USA-NE, USA-NW, USA-SE, USA-SW}

  • {USA-NW} (parent of) {Boise, Seattle}

Members can be consolidated along one or more hierarchies per dimension.

This example also illustrates another characteristic: Some members of the Week level of the Year-Week hierarchy do not appear in any level of the Year-Quarter hierarchy. Thus, a hierarchy need not include all members of a dimension.


Attachment.BorderStyle Property (Access)

 Copy code hover
[image]

Attachment.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .BorderStyle

expression A variable that represents an Attachment object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Report.PicturePages Property (Access)

 Copy code hover
[image]

Report.PicturePages Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PicturePages property to specify on which page or pages of a report a picture will be displayed. Read/write Byte.

Syntax

expression .PicturePages

expression A variable that represents a Report object.

Remarks

The PicturePages property uses the following settings.

Setting | Visual Basic | Description
All Pages | 0 | (Default) The picture appears on all pages of the report.
First Page | 1 | The picture appears only on the first page of the report.
No Pages | 2 | The picture doesn't appear on the report.

Example

The following example prints a stretched version of the picture "Logo.gif" on only the first page of the "Purchase Order" report.

VBA Copy code Copy code
With Reports("Purchase Order")
 .Picture = "C:\Picture Files\Logo.gif"
 .PictureSizeMode = 1
 .PicturePages = 1
End With

See also

Concepts

Report Object

Other resources

Report Object Members


NavigationButton.DblClick Event (Access)

 Copy code hover
[image]

NavigationButton.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Version Information

Version Added: Access 2010

Syntax

expression .DblClick(Cancel, )

expression A variable that represents a NavigationButton object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer |

Return Value

nothing

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Field.CollatingOrder Property (DAO)

 Copy code hover
[image]

Field.CollatingOrder Property (DAO)
Send feedback

Returns a value that specifies the sequence of the sort order in text for string comparison or sorting (Microsoft Access workspaces only). Read-only Long.

Syntax

expression .CollatingOrder

expression A variable that represents a Field object.

Remarks

The return value is a Long value or constant that can be one of the following values.

Constant | Sort order
dbSortGeneral | General (English, French, German, Portuguese, Italian, and Modern Spanish)
dbSortArabic | Arabic
dbSortChineseSimplified | Simplified Chinese
dbSortChineseTraditional | Traditional Chinese
dbSortCyrillic | Russian
dbSortCzech | Czech
dbSortDutch | Dutch
dbSortGreek | Greek
dbSortHebrew | Hebrew
dbSortHungarian | Hungarian
dbSortIcelandic | Icelandic
dbSortJapanese | Japanese
dbSortKorean | Korean
dbSortNeutral | Neutral
dbSortNorwDan | Norwegian or Danish
dbSortPDXIntl | Paradox International
dbSortPDXNor | Paradox Norwegian or Danish
dbSortPDXSwe | Paradox Swedish or Finnish
dbSortPolish | Polish
dbSortSlovenian | Slovenian
dbSortSpanish | Spanish
dbSortSwedFin | Swedish or Finnish
dbSortThai | Thai
dbSortTurkish | Turkish
dbSortUndefined | Undefined or unknown

The availability of the CollatingOrder property depends on the object that contains the Fields collection, as shown in the following table.

If the Fields collection belongs to an | Then CollatingOrder is
Index object | Not supported
QueryDef object | Read-only
Recordset object | Read-only
Relation object | Not supported
TableDef object | Read-only

The CollatingOrder property setting corresponds to the locale argument of the CreateDatabase method when the database was created or the CompactDatabase method when the database was most recently compacted.

The CollatingOrder and Attributes property settings of a Field object in a Fields collection of an Index object together determine the sequence and direction of the sort order in an index. However, you can't set a collating order for an individual index— you can only set it for an entire table.


Maintenance

 Copy code hover
[image]

Maintenance
Send feedback

In this section

  • How to: Compact and Repair a Database

  • How to: Recover Tables Deleted from a Database

  • How to: Handle Run-Time Errors in VBA


AcSysCmdAction Enumeration (Access)

 Copy code hover
[image]

AcSysCmdAction Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the SysCmd method to specify an action to take.

Name | Value | Description
acSysCmdAccessDir | 9 | Returns the name of the directory where Msaccess.exe is located.
acSysCmdAccessVer | 7 | Returns the version number of Microsoft Access.
acSysCmdClearHelpTopic | 11 |
acSysCmdClearStatus | 5 | Provides information on the state of a database object.
acSysCmdGetObjectState | 10 | Returns the state of the specified database object. You must specify argument1 and argument2 when you use this action value.
acSysCmdGetWorkgroupFile | 13 | Returns the path to the workgroup file (System.mdw).
acSysCmdIniFile | 8 | Returns the name of the .ini file associated with Microsoft Access.
acSysCmdInitMeter | 1 | Initializes the progress meter. You must specify the argument1 and argument2 arguments when you use this action.
acSysCmdProfile | 12 | Returns the /profile setting specified by the user when starting Microsoft Access from the command line.
acSysCmdRemoveMeter | 3 | Removes the progress meter.
acSysCmdRuntime | 6 | Returns True (-1) if a run-time version of Microsoft Access is running.
acSysCmdSetStatus | 4 | Sets the status bar text to the text argument.
acSysCmdUpdateMeter | 2 | Updates the progress meter with the specified value. You must specify the text argument when you use this action.


TableDefs Collection (DAO)

 Copy code hover
[image]

TableDefs Collection (DAO)
Send feedback

A TableDefs collection contains all stored TableDef objects in a database (Microsoft Access workspaces only).

Remarks

You manipulate a table definition using a TableDef object and its methods and properties.

The default collection of a Database object is the TableDefs collection.

To refer to a TableDef object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

TableDefs(0)

TableDefs("name")

TableDefs![name]

Links provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Re-Linker Multi-Backends

  • Swap/Relink Between LIVE, TEST and LOCAL Data

Example

This example creates a new TableDef object and appends it to the TableDefs collection of the Northwind Database object. It then enumerates the TableDefs collection and the Properties collection of the new TableDef.

VBA Copy code Copy code
Sub TableDefX()

   Dim dbsNorthwind As Database
   Dim tdfNew As TableDef
   Dim tdfLoop As TableDef
   Dim prpLoop As Property

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   ' Create new TableDef object, append Field objects
   ' to its Fields collection, and append TableDef
   ' object to the TableDefs collection of the
   ' Database object.
   Set tdfNew = dbsNorthwind.CreateTableDef("NewTableDef")
   tdfNew.Fields.Append tdfNew.CreateField("Date", dbDate)
   dbsNorthwind.TableDefs.Append tdfNew

   With dbsNorthwind
      Debug.Print .TableDefs.Count & _
         " TableDefs in " & .Name

      ' Enumerate TableDefs collection.
      For Each tdfLoop In .TableDefs
         Debug.Print "  " & tdfLoop.Name
      Next tdfLoop

      With tdfNew
         Debug.Print "Properties of " & .Name

         ' Enumerate Properties collection of new
         ' TableDef object, only printing properties
         ' with non-empty values.
         For Each prpLoop In .Properties
            Debug.Print "  " & prpLoop.Name & " - " & _
               IIf(prpLoop = "", "[empty]", prpLoop)
         Next prpLoop

      End With

      ' Delete new TableDef since this is a
      ' demonstration.
      .TableDefs.Delete tdfNew.Name
      .Close
   End With

End Sub

This example creates a new TableDef object in the Northwind database.

VBA Copy code Copy code
Sub CreateTableDefX()

   Dim dbsNorthwind As Database
   Dim tdfNew As TableDef
   Dim prpLoop As Property

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   ' Create a new TableDef object.
   Set tdfNew = dbsNorthwind.CreateTableDef("Contacts")

   With tdfNew
      ' Create fields and append them to the new TableDef
      ' object. This must be done before appending the
      ' TableDef object to the TableDefs collection of the
      ' Northwind database.
      .Fields.Append .CreateField("FirstName", dbText)
      .Fields.Append .CreateField("LastName", dbText)
      .Fields.Append .CreateField("Phone", dbText)
      .Fields.Append .CreateField("Notes", dbMemo)

      Debug.Print "Properties of new TableDef object " & _
         "before appending to collection:"

      ' Enumerate Properties collection of new TableDef
      ' object.
      For Each prpLoop In .Properties
         On Error Resume Next
         If prpLoop <> "" Then Debug.Print "  " & _
           prpLoop.Name & " = " & prpLoop
         On Error GoTo 0
      Next prpLoop

      ' Append the new TableDef object to the Northwind
      ' database.
      dbsNorthwind.TableDefs.Append tdfNew

      Debug.Print "Properties of new TableDef object " & _
         "after appending to collection:"

      ' Enumerate Properties collection of new TableDef
      ' object.
      For Each prpLoop In .Properties
         On Error Resume Next
         If prpLoop <> "" Then Debug.Print "  " & _
           prpLoop.Name & " = " & prpLoop
         On Error GoTo 0
      Next prpLoop

   End With

   ' Delete new TableDef object since this is a
   ' demonstration.
   dbsNorthwind.TableDefs.Delete "Contacts"

   dbsNorthwind.Close

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.


SearchForRecord Macro Action

 Copy code hover
[image]

SearchForRecord Macro Action
Send feedback

You can use the SearchForRecord action to search for a specific record in a table, query, form or report.

Setting

The SearchForRecord action has the following arguments.

Action argument

Description

Object Type

Enter or select the type of database object that you are searching in. You can select Table, Query, Form, or Report.

Object Name

Enter or select the specific object that contains the record to search for. The drop-down list shows all database objects of the type you selected for the Object Type argument.

Record

Specify the starting point and direction of the search.

Setting | Description
Previous | Search backward from the current record.
Next | Search forward from the current record.
First | Search forward from the first record. This is the default value for this argument.
Last | Search backward from the last record.

Where Condition

Enter the criteria for the search using the same syntax as an SQL WHERE clause, only without the word "WHERE". For example,

Copy code Copy code
Description = "Beverages"

To create a criterion that includes a value from a text box on a form, you must create an expression that concatenates the first part of the criterion with the name of the text box containing the value for which to search. For example, the following criterion will search the Description field for the value in the text box named txtDescription on the form named frmCategories. Note the equal sign (=) at the beginning of the expression, and the use of single quotation marks (') on either side of the text box reference:

Copy code Copy code
="Description = '" & Forms![frmCategories]![txtDescription] & "'"

Remarks

  • In cases where more than one record matches the criteria in the Where Condition argument, the following factors determine which record is found:

    • The Record argument settingSee the table in the Settings section for more information about the Record argument.

    • The sort order of the recordsFor example, if the Record argument is set to First, changing the sort order of the records might change which record is found.

  • The object specified in the Object Name argument must be open before this action is run. Otherwise, an error occurs.

  • If the criteria in the Where Condition argument are not met, no error occurs and the focus remains on the current record.

  • When searching for the previous or next record, the search does not "wrap" when it reaches the end of the data. If there are no further records that match the criteria, no error occurs and the focus remains on the current record. To confirm that a match was found, you can enter a condition for the next action, and make the condition the same as the criteria in the Where Condition argument.

  • To run the SearchForRecord action in a VBA module, use the SearchForRecord method of the DoCmd object.

  • The SearchForRecord action is similar to the FindRecord action, but SearchForRecord has more powerful search features. The FindRecord action is primarily used for finding strings, and it duplicates the functionality of the Find dialog box. The SearchForRecord action uses criteria that are more like those of a filter or an SQL query. The following list demonstrates some things you can do with the SearchForRecord action:

    • You can use complex criteria in the Where Condition argument, such as

      Copy code Copy code
      Description = "Beverages" and CategoryID = 11

    • You can refer to fields that are in the record source of a form or report but aren't displayed on the form or report. In the preceding example, neither Description nor CategoryID must be displayed on the form or report for the criteria to work.

    • You can use logical operators, such as <, >, AND, OR, and BETWEEN. The FindRecord action only matches strings that equal, start with, or contain the string being searched for.

Example

The following macro first opens the Categories table by using the OpenTable action. The macro then uses the SearchForRecord action to find the first record in the table where the Description field equals "Beverages."

Action | Arguments
OpenTable | Table Name: CategoriesView: Datasheet Data Mode: Edit
SearchForRecord | Object Type: Table Object Name: CategoriesRecord: First Where Condition: Description = "Beverages"


Form.ViewChange Event (Access)

 Copy code hover
[image]

Form.ViewChange Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs whenever the specified PivotChart view or PivotTable view is redrawn.

Syntax

expression .ViewChange(Reason )

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Reason | Required | Long | A PivotViewReasonEnum constant that indicates how the view was changed. Reason always returns -1 for PivotChart Views.

Example

The following example demonstrates the syntax for a subroutine that traps the ViewChange event.

VBA Copy code Copy code
Private Sub Form_ViewChange(ByVal Reason As Long)
 If Reason = OWC.plViewReasonShowDetails Then
 MsgBox "You've opted to show details."
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Form.Toolbar Property (Access)

 Copy code hover
[image]

Form.Toolbar Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies a custom toolbar to display for a form. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .Toolbar

expression A variable that represents a Form object.

Remarks

When opening a form in Microsoft Access 2013 that is part of a database that was created in an earlier version of Microsoft Access, the specified toolbar will be displayed differently depending on the current settings of the AllowFullMenus and AllowBuiltInToolbars properties. If the AllowFullMenus and AllowBuiltInToolbars properties are set to False, the specified toolbar will replace the ribbon as the default set of commands available to the user. If the AllowFullMenus or AllowBuiltInToolbars property is set to True, then the specified toolbar is displayed on the ribbon Add-Ins tab.

See also

Concepts

Form Object

Other resources

Form Object Members


Axis Object (ADO MD)

 Copy code hover
[image]

Axis Object (ADO MD)
Send feedback

Represents a positional or filter axis of a cellset, containing selected members of one or more dimensions.

Remarks

An Axis object can be contained by an Axes collection, or returned by the FilterAxis property of a Cellset.

With the collections and properties of an Axis object, you can do the following:

  • Identify the Axis with the Name property.

  • Iterate through each position along an Axis using the Positions collection.

  • Obtain the number of dimensions on the Axis with the DimensionCount property.

  • Obtain provider-specific attributes of the Axis with the standard ADO Properties collection.


Index.Unique Property (DAO)

 Copy code hover
[image]

Index.Unique Property (DAO)
Send feedback

Sets or returns a value that indicates whether an Index object represents a unique (key) index for a table (Microsoft Access workspaces only).

Syntax

expression .Unique

expression A variable that represents an Index object.

Remarks

This property setting is read/write until the object is appended to a collection, after which it's read-only.

A unique index consists of one or more fields that logically arrange all records in a table in a unique, predefined order. If the index consists of one field, values in that field must be unique for the entire table. If the index consists of more than one field, each field can contain duplicate values, but each combination of values from all the indexed fields must be unique.

If both the Unique and Primary properties of an Index object are set to True, the index is unique and primary: It uniquely identifies all records in the table in a predefined, logical order. If the Primary property is set to False, the index is a secondary index. Secondary indexes (both key and nonkey) logically arrange records in a predefined order without serving as an identifier for records in the table.

Note Note

  • You don't have to create indexes for tables, but in large, unindexed tables, accessing a specific record can take a long time.

  • Records retrieved from tables without indexes are returned in no particular sequence.

  • The Attributes property of each Field object in the Index object determines the order of records and consequently determines the access techniques to use for that Index object.

  • A unique index helps optimize finding records.

  • Indexes don't affect the physical order of a base table indexes affect only how the records are accessed by the table-type Recordset object when a particular index is chosen or when the Microsoft Access database engine creates Recordset objects.

Example

This example sets the Unique property of a new Index object to True, and appends the Index to the Indexes collection of the Employees table. It then enumerates the Indexes collection of the TableDef and the Properties collection of each Index. The new Index will only allow one record with a particular combination of Country, LastName, and FirstName in the TableDef.

VBA Copy code Copy code
Sub UniqueX()

   Dim dbsNorthwind As Database
   Dim tdfEmployees As TableDef
   Dim idxNew As Index
   Dim idxLoop As Index
   Dim prpLoop As Property

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   Set tdfEmployees = dbsNorthwind!Employees

   With tdfEmployees
      ' Create and append new Index object to the Indexes
      ' collection of the Employees table.
      Set idxNew = .CreateIndex("NewIndex")

      With idxNew
         .Fields.Append .CreateField("Country")
         .Fields.Append .CreateField("LastName")
         .Fields.Append .CreateField("FirstName")
         .Unique = True
      End With

      .Indexes.Append idxNew
      .Indexes.Refresh

      Debug.Print .Indexes.Count & " Indexes in " & _
         .Name & " TableDef"

      ' Enumerate Indexes collection of Employees table.
      For Each idxLoop In .Indexes
         Debug.Print "  " & idxLoop.Name

         ' Enumerate Properties collection of each Index
         ' object.
         For Each prpLoop In idxLoop.Properties
            Debug.Print "    " & prpLoop.Name & _
               " = " & IIf(prpLoop = "", "[empty]", prpLoop)
         Next prpLoop

      Next idxLoop

      ' Delete new Index because this is a demonstration.
      .Indexes.Delete idxNew.Name
   End With

   dbsNorthwind.Close

End Sub


Data Access Objects (DAO)

 Copy code hover
[image]

Data Access Objects (DAO)
Send feedback

In this section

  • How to: Add a Record to a DAO Recordset

  • How to: Build SQL Statements That Include Variables and Controls

  • How to: Change Tables Involved in a One-to-Many Relationship in a DAO Recordset

  • How to: Count the Number of Records in a DAO Recordset

  • How to: Create a DAO Recordset From a Form

  • How to: Create a DAO Recordset From a Query

  • How to: Create a DAO Recordset From a Table In the Current Database

  • How to: Create a User-Defined Property

  • How to: Delete a Record From a DAO Recordset

  • How to: Detect the Limits of a DAO Recordset

  • How to: Extract Data from a Record in a DAO Recordset

  • How to: Find a Record in a Dynaset-Type or Snapshot-Type DAO Recordset

  • How to: Find a Record in a Table-Type DAO Recordset

  • How to: Find the Current Position in a DAO Recordset

  • How to: Make Bulk Changes to a DAO Recordset

  • How to: Manipulate Multivalued Fields With DAO

  • How to: Mark a Position in a DAO Recordset

  • How to: Modify a Query from a DAO Recordset

  • How to: Modify an Existing Record in a DAO Recordset

  • How to: Move Through a DAO Recordset

  • How to: Read From and Write To a Field in a DAO Recordset

  • How to: Return a Random Record from a DAO Recordset

  • How to: Set Properties of Data Access Objects in Visual Basic

  • How to: Sort Data in a DAO Recordset

  • How to: Synchronize a DAO Recordset's Record with a Form's Current Record

  • How to: Track Design Changes to a Table-Type DAO Recordset

  • How to: Work With Attachments In DAO

  • How to: Use Transactions in a DAO Recordset


Reference.Guid Property (Access)

 Copy code hover
[image]

Reference.Guid Property (Access)
See also Send feedback

Published: July 16, 2012

The GUID property of a Reference object returns a GUID that identifies a type library in the Windows Registry. Read-only String.

Syntax

expression .Guid

expression A variable that represents a Reference object.

Remarks

Every type library has an associated GUID which is stored in the Registry. When you set a reference to a type library, Microsoft Access uses the type library's GUID to identify the type library.

You can use the AddFromGUID method to create a Reference object from a type library's GUID.

Example

The following example prints the value of the FullPath, GUID, IsBroken, Major, and Minor properties for each Reference object in the References collection:

VBA Copy code Copy code
Sub ReferenceProperties()
 Dim ref As Reference

 ' Enumerate through References collection.
 For Each ref In References
 ' Check IsBroken property.
 If ref.IsBroken = False Then
 Debug.Print "Name: ", ref.Name
 Debug.Print "FullPath: ", ref.FullPath
 Debug.Print "Version: ", ref.Major & "." & ref.Minor
 Else
 Debug.Print "GUIDs of broken references:"
 Debug.Print ref.GUID
 EndIf
 Next ref
End Sub

See also

Concepts

Reference Object

Other resources

Reference Object Members


NavigationButton.GridlineTint Property (Access)

 Copy code hover
[image]

NavigationButton.GridlineTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineTint

expression A variable that represents a NavigationButton object.

Remarks

The GridlineTint property contains a numeric expression that can be used to lighten the theme color in the GridlineColor property. The default value of the GridlineTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


The Synchronizer is already serving a client. (Error 3530)

 Copy code hover
[image]

The Synchronizer is already serving a client. (Error 3530)
Send feedback

You are attempting to start a second client of the Synchronizer, but the Synchronizer can have only one client at a time. Identify the application or user that is already using the Synchronizer and close the application.


DoCmd.OpenDiagram Method (Access)

 Copy code hover
[image]

DoCmd.OpenDiagram Method (Access)
See also Send feedback

Published: July 16, 2012

The OpenDiagram method carries out the OpenDiagram action in Visual Basic.

Syntax

expression .OpenDiagram(DiagramName)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
DiagramName | Required | Variant | A string expression that's the valid name of a database diagram in the current database. If you execute Visual Basic code containing the OpenDiagram method in a library database, Microsoft Access looks for the database diagram with this name first in the library database, then in the current database.

Remarks

In a Microsoft Access project, you can use the OpenDiagram method to open a database diagram in Design view.

Example

The following example opens the database diagram named "Data Model".

VBA Copy code Copy code
DoCmd.OpenDiagram " Data Model"

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


TextBox.Enabled Property (Access)

 Copy code hover
[image]

TextBox.Enabled Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.

Syntax

expression .Enabled

expression A variable that represents a TextBox object.

Remarks

The Enabled property setting is a value that indicates whether the conditional format is enabled or disabled. True enables the conditional format. False disables the conditional format. The default is True.

When the Enabled property is True, the conditional format can be displayed in the Conditional Formatting dialog box.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Step 1: Set Up the Application
Send feedback

Step 1: Set Up the Application

Create an IIS virtual directory named "XMLPersist" with script permissions. Create two new text files in the folder to which the virtual directory points, one named "XMLResponse.asp," the other named "Default.htm."

Next Step 2: Get the Data


ListBox.Move Method (Access)

 Copy code hover
[image]

ListBox.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a ListBox object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


 Copy code hover
[image]

<Name> in criteria expression. (Error 3076)
Send feedback

The expression you entered is not valid for the reason indicated in the message. Make sure you entered field names and punctuation correctly, and then try the operation again.


CommandButton.GridlineTint Property (Access)

 Copy code hover
[image]

CommandButton.GridlineTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineTint

expression A variable that represents a CommandButton object.

Remarks

The GridlineTint property contains a numeric expression that can be used to lighten the theme color in the GridlineColor property. The default value of the GridlineTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Quotation Marks in Strings

 Copy code hover
[image]

Quotation Marks in Strings
Send feedback

In situations where you must construct strings to be concatenated, you may need to embed a string within another string, or a string variable within a string. Situations in which you might need to nest one string within another include:

  • When specifying criteria for domain aggregate functions .

  • When specifying criteria for the Find methods.

  • When specifying criteria for the Filter or ServerFilter property of a form.

  • When building SQL strings.

In all of these instances, Microsoft Access must pass a string to the Microsoft Jet database engine. When you specify a criteria argument for a domain aggregate function, for example, Microsoft Access must evaluate any variables, concatenate them into a string, and then pass the entire string to the Jet database engine.

If you embed a numeric variable, Microsoft Access evaluates the variable and simply concatenates the value into the string. If the variable is a text string, however, the resulting criteria string will contain a string within a string. A string within a string must be identified by string delimiters. Otherwise, the Jet database engine won't be able to determine which part of the string is the value you want to use.

The string delimiters aren't actually part of the variable itself, but they must be included in the string in the criteria argument. There are three different ways to construct the string in the criteria argument. Each method results in a criteria argument that looks like one of the following examples.

Copy code Copy code
"[LastName] = 'Smith'"

- or -

Copy code Copy code
"[LastName] = ""Smith"""

Include Single Quotation Marks

You should include single quotation marks in the criteria argument in such a way that when the value of the variable is concatenated into the string, it will be enclosed within the single quotation marks. For instance, suppose your criteria argument must contain a string variable called . You could construct the criteria argument as in the following example:

Copy code Copy code
"[LastName] = '" & strName & "'"

When the variable is evaluated and concatenated into the criteria string, the criteria string becomes:

Copy code Copy code
"[LastName] = 'Smith'"
Note Note

This syntax does not permit the use of apostrophes (') within the value of the variable itself. If the value of the string variable includes an apostrophe, Microsoft Access generates a run-time error. If your variable may represent values containing apostrophes, consider using one of the other syntax forms discussed in the following sections.

Include Double Quotation Marks

You should include double quotation marks within the criteria argument in such a way so that when the value of the variable is evaluated, it will be enclosed within the quotation marks. Within a string, you must use two sets of double quotation marks to represent a single set of double quotation marks. You could construct the criteria argument as in the following example:

Copy code Copy code
"[LastName] = """ & strName & """"

When the variable is evaluated and concatenated into the criteria argument, each set of two double quotation marks is replaced by one single quotation mark. The criteria argument becomes:

Copy code Copy code
"[LastName] = 'Smith'"

This syntax may appear more complicated than the single quotation mark syntax, but it enables you to embed a string that contains an apostrophe within the criteria argument. It also enables you to nest one or more strings within the embedded string.

Include a Variable Representing Quotation Marks

You can create a string variable that represents double quotation marks, and concatenate this variable into the criteria argument along with the value of the variable. The ANSI representation for double quotation marks is Chr$(34); you could assign this value to a string variable called . You could then construct the criteria argument as in the following example:

Copy code Copy code
"[LastName] = " & strQuote & strName & strQuote

When the variables are evaluated and concatenated into the criteria argument, the criteria argument becomes:

Copy code Copy code
[LastName] = "Smith"


Report.OnKeyUp Property (Access)

 Copy code hover
[image]

Report.OnKeyUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Up box in the Properties window. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnKeyUp

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyUp event occurs when a user presses a key while a report or control has the focus. This event also occurs if you send a keystroke to a report or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Up box in the report's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Up box is blank, the property value is an empty string.

See also

Concepts

Report Object

Other resources

Report Object Members


ComboBox.ColumnOrder Property (Access)

 Copy code hover
[image]

ComboBox.ColumnOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.

Syntax

expression .ColumnOrder

expression A variable that represents a ComboBox object.

Remarks

To set or change this property for a table or query by using Visual Basic, you must use a column's Properties collection. For details on using the Properties collection, see Properties .

Note Note

The ColumnOrder property isn't available in Design view.

The ColumnOrder property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

In Datasheet view, a field's ColumnOrder property setting is determined by the field's position. For example, the field in the leftmost column in Datasheet view has a ColumnOrder property setting of 1, the next field has a setting of 2, and so on. Changing a field's ColumnOrder property resets the property for that field and every field to the left of its original position in Datasheet view.

In other views, the property setting is 0 unless you explicitly change the order of one or more fields in Datasheet view (either by dragging the fields to new positions or by changing their ColumnOrder property settings). Fields to the right of the moved field's new position will have a property setting of 0 in views other than Datasheet view.

The order of the fields in Datasheet view doesn't affect the order of the fields in table Design view or Form view.

Example

The following example displays the ProductName and QuantityPerUnit fields in the first two columns in Datasheet view of the Products form.

VBA Copy code Copy code
Forms!Products!ProductName.ColumnOrder = 1
Forms!Products!QuantityPerUnit.ColumnOrder = 2

The next example displays the ProductName and QuantityPerUnit fields in the first two columns of the Products table in Datasheet view. To set the ColumnOrder property, the example uses the SetFieldProperty procedure. If this procedure is run while the table is open, changes will not be displayed until it is closed and reopened.

VBA Copy code Copy code
Public Sub SetColumnOrder()

 Dim dbs As DAO.Database
 Dim tdf As DAO.TableDef

 Set dbs = CurrentDb
 Set tdf = dbs!Products

 ' Call the procedure to set the ColumnOrder property.
 SetFieldProperty tdf!ProductName, "ColumnOrder", dbLong, 2
 SetFieldProperty tdf!QuantityPerUnit, "ColumnOrder", dbLong, 3

 Set tdf = Nothing
 Set dbs = Nothing

End Sub

Private Sub SetFieldProperty(ByRef fld As DAO.Field, _
 ByVal strPropertyName As String, _
 ByVal intPropertyType As Integer, _
 ByVal varPropertyValue As Variant)
 ' Set field property without producing nonrecoverable run-time error.

 Const conErrPropertyNotFound = 3270
 Dim prp As Property

 ' Turn off error handling.
 On Error Resume Next

 fld.Properties(strPropertyName) = varPropertyValue

 ' Check for errors in setting the property.
 If Err <> 0 Then
 If Err <> conErrPropertyNotFound Then
 On Error GoTo 0
 MsgBox "Couldn't set property '" & strPropertyName & _
 "' on field '" & fld.Name & "'", vbCritical
 Else
 On Error GoTo 0
 Set prp = fld.CreateProperty(strPropertyName, intPropertyType, _
 varPropertyValue)
 fld.Properties.Append prp
 End If
 End If

 Set prp = Nothing

End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Understanding Recordset Structure (ADO)

 Copy code hover
[image]

Understanding Recordset Structure (ADO)
Send feedback

In this section

  • Understanding Recordset Structure

  • The Fields Collection

  • The Field Object

  • Working with Recordsets


ComboBox.Properties Property (Access)

 Copy code hover
[image]

ComboBox.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a ComboBox object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


SmartTag Members (Access)

 Copy code hover
[image]

SmartTag Members (Access)
Send feedback

Published: July 16, 2012

Represents a smart tag that has been added to a control on a form or report. The SmartTag object is a member of the SmartTags collection.

Methods

Name | Description
Delete | Deletes the specified object.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
IsMissing | Returns True if the specified smart tag is not installed or is installed incorrectly. Read-only Boolean.
Name | You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a SmartTagProperties collection that represents the collection of properties for a particular smart tag. Read-only.
SmartTagActions | Returns a SmartTagActions collection that represents the actions available for a specific smart tag. Read-only.
XML | Returns a String that represents the related XML code for a smart tag. Read-only.


RecordType Property (ADO)

 Copy code hover
[image]

RecordType Property (ADO)
Send feedback

Indicates the type of Record object.

Return Value

Returns a RecordTypeEnum value.

Remarks

The RecordType property is read-only.


Label Members (Access)

 Copy code hover
[image]

Label Members (Access)
Send feedback

Published: July 16, 2012

This object corresponds to a label control. Labels on a form or report display descriptive text such as titles, captions, or brief instructions.

Events

Name | Description
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomMargin | Along with the LeftMargin, RightMargin, and TopMargin properties, specifies the location of information displayed within a label control. Read/write Integer.
BottomPadding | Gets or sets the amount of space (in inches) between the label and its bottom gridline. Read/write Integer.
Caption | Gets or sets the text that appears in the control. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontName | You can use the FontName property to specify the font for text in the following situations:
FontSize | You can use the FontSize property to specify the point size for text in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
FontWeight | You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
ForeShade | Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
ForeThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.
ForeTint | Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
GridlineColor | Gets or sets the color of the gridline for the specified label. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified label. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified label. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified label. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified label. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified label. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified label. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified label. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified label. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the label is anchored horizontally within its layout. Read/write.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
HyperlinkAddress | You can use the HyperlinkAddress property to specify or determine the path to an object, document, Web page or other destination for a hyperlink associated with a the specified control. Read/write String.
HyperlinkSubAddress | You can use the HyperlinkSubAddress property to specify or determine a location within the target document specified by the HyperlinkAddress property. Read/write String.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Layout | Returns the type of layout for the specified label. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified label. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftMargin | Along with the TopMargin, RightMargin, and BottomMargin properties, specifies the location of information displayed within a label control. Read/write Integer. .
LeftPadding | Gets or sets the amount of space (in inches) between the label and its left gridline. Read/write Integer.
LineSpacing | You can use the LineSpacing property to specify or determine the location of information displayed within a label or text box control. Read/write Integer.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
NumeralShapes |
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
RightMargin | Along with the TopMargin, Left Margin, and BottomMargin properties, specifies the location of information displayed within a label control. Read/write Integer.
RightPadding | Gets or sets the amount of space (in inches) between the label and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SmartTags | Returns a SmartTags collection that represents the collection of smart tags that have been added to a control. .
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
TextAlign | The TextAlign property specifies the text alignment in new controls. Read/write Byte.
ThemeFontIndex | Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopMargin | Along with the LeftMargin, RightMargin, and BottomMargin properties, specifies the location of information displayed within a label control. Read/write Integer.
TopPadding | Gets or sets the amount of space (in inches) between the label and its top gridline. Read/write Integer.
Vertical | You can use the Vertical property to set a form control for vertical display and editing or set a report control for vertical display and printing. Read/write Boolean.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified label is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


SharedResources.Parent Property (Access)

 Copy code hover
[image]

SharedResources.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Parent

expression A variable that represents a SharedResources object.

See also

Concepts

SharedResources Collection

Other resources

SharedResources Object Members


Data entry operations (Access 2013 custom web app)

 Copy code hover
[image]

Data entry operations (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • DeleteRecord Macro Action (Access 2013 custom web app)

  • EditRecord Macro Action (Access 2013 custom web app)

  • NewRecord Macro Action (Access 2013 custom web app)

  • SaveRecord Macro Action (Access 2013 custom web app)

  • UndoRecord Macro Action (Access 2013 custom web app)


Form.FastLaserPrinting Property (Access)

 Copy code hover
[image]

Form.FastLaserPrinting Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FastLaserPrinting property to specify whether lines and rectangles are replaced by text character lines — similar to the underscore (_) and vertical bar (|) characters — when you print a form using most laser printers. Replacing lines and rectangles with text character lines can make printing much faster. Read/write Boolean.

Syntax

expression .FastLaserPrinting

expression A variable that represents a Form object.

Remarks

The FastLaserPrinting property affects any line or rectangle on a form or report, including controls that have these shapes (for example, a border around a text box).

This property has no effect on PostScript printers, dot-matrix printers, or earlier versions of laser printers that don't support text character lines.

When this property is set to True and the form or report being printed has overlapping rectangles or lines, the rectangles or lines on top don't erase the rectangles or lines they overlap. If you require overlapping graphics on your report, set the FastLaserPrinting property to False.

Example

The following example shows how to set the FastLaserPrinting property for the Invoice report while in report Design view:

VBA Copy code Copy code
DoCmd.OpenReport "Invoice", acDesign
Reports!Invoice.FastLaserPrinting = True
DoCmd.Close acReport, "Invoice", acSaveYes

See also

Concepts

Form Object

Other resources

Form Object Members


ComboBox.GridlineStyleTop Property (Access)

 Copy code hover
[image]

ComboBox.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified combo box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleTop

expression A variable that represents a ComboBox object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Year Function (Access 2013 custom web app)

 Copy code hover
[image]

Year Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns a numeric value that represents the year of the specified date in the Gregorian calendar.

Syntax

Year(Date)

The Year function contains the following arguments.

Argument name | Description
Date | An expression that can be resolved to a Date/Time value. The Date argument expression, column expression, user-defined variable or string literal.

Remarks

Values returned by the Year, Month, and Day functions will be Gregorian values regardless of the display format for the supplied date value. For example, if the display format of the supplied date uses the Hijri calendar, the returned values for the Year, Month, and Day functions will be values associated with the equivalent Gregorian date.


AllFunctions.Application Property (Access)

 Copy code hover
[image]

AllFunctions.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents an AllFunctions object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

AllFunctions Collection

Other resources

AllFunctions Object Members


Design in Access Reports

 Copy code hover
[image]

Design in Access Reports
Send feedback

In this section

  • How to: Create Alternating Row Colors on a Report


SelectObject Macro Action

 Copy code hover
[image]

SelectObject Macro Action
Send feedback

You can use the SelectObject action to select a specified database object.

Setting

The SelectObject action has the following arguments.

Action argument

Description

Object Type

The type of database object to select. Click Table, Query, Form, Report, Macro, Module, Data Access Page, Server View, Diagram, Stored Procedure, or Function in the Object Type box in the Action Arguments section of the Macro Builder pane. This is a required argument.

Object Name

The name of the object to select. The Object Name box shows all objects in the database of the type selected by the Object Type argument. This is a required argument, unless you set the In Navigation Pane argument to Yes.

Note Note

The object names for Server View, Diagram, or Stored Procedure objects are not displayed in the Object Name box of an Access project (.adp).

In Navigation Pane

Specifies whether Microsoft Access selects the object in the Navigation Pane. Click Yes (to select the object in the Navigation Pane) or No (not to select the object in the Navigation Pane). The default is No.

Remarks

The SelectObject action works with any Access object that can receive the focus. This action gives the specified object the focus and shows the object if it's hidden. If the object is a form, the SelectObject action sets the form's Visible property to Yes and returns the form to the mode set by its form properties (for example, as a modal or pop-up form).

If the object isn't open in one of the other Access windows, you can select it in the Navigation Pane by setting the In Navigation Pane argument to Yes. If you set the In Navigation Pane argument to No, an error message appears when you try to select an object that isn't open.

Often, you might use this action to select an object on which you want to perform additional actions. For example, if you have Access configured to use overlapping windows instead of tabbed documents, you may want to restore an object that has been minimized (by using the RestoreWindow action) or maximize a window that contains an object you want to work with (by using the MaximizeWindow action).

If you select a form, you can use the GoToControl, GoToRecord, and GoToPage actions to move to specific areas on the form. The GoToRecord action also works for datasheets.

To run the SelectObject action in a Visual Basic for Applications (VBA) module, use the SelectObject method of the DoCmd object.


SharedResource Object (Access)

 Copy code hover
[image]

SharedResource Object (Access)
See also Send feedback

Published: July 16, 2012

Represents a Microsoft Office theme or image that is available as a shared resource in the database.

Version Information

Version Added: Access 2010

Remarks

A shared recource is stored once in the database, but can be used many times. For example, you may want to display your company logo on every form that you create. In earlier versions of Access, you had to import the logo into every form. In Microsoft Access 2013, you can add the logo as a shared image. Then , it will be displayed in the Image Gallery that is displayed when you click the Insert Image dropdown menu for the Controls group in the Design tab.

To import an image as a SharedResource object, use the AddSharedImage method of the CodeProject object or the AddSharedImage method of the CurrentProject object.

See also

Concepts

Access Object Model Reference

Other resources

SharedResource Object Members


Update and CancelUpdate Methods Example (VJ++)

 Copy code hover
[image]

Update and CancelUpdate Methods Example (VJ++)
Send feedback

This example demonstrates the Update method in conjunction with the CancelUpdate method.

Copy code Copy code

// BeginUpdateJ
import java.io.*;
import com.ms.wfc.data.*;

public class UpdateX
{
 // The main entry point of the application.

 public static void main (String[] args)
 {
 UpdateX();
 UpdateX2();
 System.exit(0);
 }
 // UpdateX Function

 static void UpdateX()
 {
 // Define ADO objects.
 Recordset rstEmployees = null;

 // Declarations.
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"+
 "Initial Catalog='Pubs';Integrated Security='SSPI';";
 String strOldFirst;
 String strOldLast;
 String strMessage;
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));

 try
 {
 // Open Recordset with names from Employees table.
 rstEmployees = new Recordset();
 rstEmployees.setCursorType(AdoEnums.CursorType.KEYSET);
 rstEmployees.setLockType(AdoEnums.LockType.OPTIMISTIC);
 rstEmployees.open("SELECT fname,lname FROM Employees " +
 "ORDER BY lname", strCnn, AdoEnums.CursorType.KEYSET,
 AdoEnums.LockType.OPTIMISTIC, AdoEnums.CommandType.TEXT);

 // Store Original data.
 strOldFirst = rstEmployees.getField("fname").getString();
 strOldLast = rstEmployees.getField("lname").getString();

 // Change data in edit buffer.
 rstEmployees.getField("fname").setString("Linda");
 rstEmployees.getField("lname").setString("Kobara");

 // Show contents of buffer and get user input.
 strMessage = "Edit in Progress :\n" +
 "\tOriginal Data = " + strOldFirst + " " + strOldLast +
 "\n\tData in Buffer = " +
 rstEmployees.getField("fname").getString() + " " +
 rstEmployees.getField("lname").getString() + "\n\n" +
 "Use Update to replace the original data with " +
 "the buffered data in the Recordset?Enter (Y/N)";

 System.out.println(strMessage);
 if(in.readLine().trim().equalsIgnoreCase("Y"))
 rstEmployees.update();
 else
 rstEmployees.cancelUpdate();

 // Show the resulting data.
 System.out.println("Data in Recordset = " +
 rstEmployees.getField("fname").getString() +
 " " + rstEmployees.getField("lname").getString()+ "\n");

 // Restore original data because this is a demonstration.
 if(!(strOldFirst.equals(
 rstEmployees.getField("fname").getString()) &&
 strOldLast.equals(
 rstEmployees.getField("lname").getString())))
 {
 rstEmployees.getField("fname").setString(strOldFirst);
 rstEmployees.getField("lname").setString(strOldLast);
 rstEmployees.update();
 }
 // Cleanup Objects before exit.
 rstEmployees.close();

 System.out.println("Press <Enter> to continue..");
 in.readLine();

 }
 catch(AdoException ae)
 {
 // Notify the user of any errors that result from ADO.

 // As passing a recordset, check for null pointer first.
 if(rstEmployees != null)
 {
 PrintProviderError(rstEmployees.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: "+ ae.getMessage());
 }
 }
 // System read requires this catch.
 catch(java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstEmployees != null)
 if (rstEmployees.getState() == 1)
 rstEmployees.close();
 }
 }
 // UpdateX2 Function

 static void UpdateX2()
 {
 // This example demonstrates the Update method in conjunction
 // with the AddNew method.

 // Define ADO Objects.
 Connection cnn1 = null;
 Recordset rstEmployees = null;

 // Declarations.
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"+
 "Initial Catalog='Pubs';Integrated Security='SSPI';";
 String strEmpID;
 String strOldFirst;
 String strOldLast;
 String strMessage;
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));

 try
 {
 // Open a connection.
 cnn1 = new Connection();
 cnn1.open(strCnn);

 // Open Recordset with data from Employees table.
 rstEmployees = new Recordset();
 rstEmployees.setCursorType(AdoEnums.CursorType.KEYSET);
 rstEmployees.setLockType(AdoEnums.LockType.OPTIMISTIC);
 rstEmployees.open("employee", cnn1, AdoEnums.CursorType.KEYSET,
 AdoEnums.LockType.OPTIMISTIC, AdoEnums.CommandType.TABLE);

 rstEmployees.addNew();
 strEmpID="B-S55555M";
 rstEmployees.getField("emp_id").setString(strEmpID);
 rstEmployees.getField("fname").setString("Bill");
 rstEmployees.getField("lname").setString("Sornsin");

 // Show contents of buffer and get user input.
 strMessage = "AddNew in progress : " + "\n" +
 "\tData in Buffer = " +
 rstEmployees.getField("emp_id").getString() +
 " " + rstEmployees.getField("fname").getString() + " " +
 rstEmployees.getField("lname").getString()+ "\n\n" +
 "Use Update to save buffer to recordset?Enter (Y/N)";
 System.out.println(strMessage);
 if(in.readLine().trim().equalsIgnoreCase("Y"))
 {
 rstEmployees.update();
 // Go to the new record and show the resulting data.
 System.out.println("Data in recordset = " +
 rstEmployees.getField("emp_id").getString()+
 " " + rstEmployees.getField("fname").getString() +
 " " + rstEmployees.getField("lname").getString() + "\n");
 }
 else
 {
 rstEmployees.cancelUpdate();
 System.out.println("No new Record added.\n");
 }
 // Delete new data because this is a demonstration.
 cnn1.execute(
 "DELETE FROM employee WHERE emp_id='" + strEmpID +"'");

 // Cleanup Objects before exit
 rstEmployees.close();

 System.out.println("Press <Enter> to continue..");
 in.readLine();
 }
 catch(AdoException ae)
 {
 // Notify the user of any errors that result from ADO.

 // As passing a recordset, check for null pointer first.
 if(rstEmployees != null)
 {
 PrintProviderError(rstEmployees.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: "+ ae.getMessage());
 }
 }
 // System read requires this catch.
 catch(java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstEmployees != null)
 if (rstEmployees.getState() == 1)
 rstEmployees.close();
 }
 }
 // PrintProviderError Function
 static void PrintProviderError(Connection cnn1)
 {
 // Print Provider Errors from Connection Object.
 // ErrItem is an item object in the Connections Errors Collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if ( nCount > 0)
 {
 // Collection ranges from 0 to nCount-1.
 for ( i=0;i<nCount; i++)
 {
 ErrItem = cnn1.getErrors().getItem(i);
 System.out.println("\t Error Number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription());
 }
 }
 }
 // PrintIOError Function
 static void PrintIOError(java.io.IOException je)
 {
 System.out.println("Error: \n");
 System.out.println("\t Source: " + je.getClass() + "\n");
 System.out.println("\t Description: "+ je.getMessage() + "\n");
 }
}
// EndUpdateJ


ToggleButton.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

ToggleButton.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified toggle button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthBottom

expression A variable that represents a ToggleButton object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Form.RecordSource Property (Access)

 Copy code hover
[image]

Form.RecordSource Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the RecordSource property to specify the source of the data for a form. Read/write String.

Syntax

expression .RecordSource

expression A variable that represents a Form object.

Remarks

The RecordSource property setting can be a table name, a query name, or an SQL statement. For example, you can use the following settings.

Sample setting | Description
Employees | A table name specifying the Employees table as the source of data.
SELECT Orders!OrderDate FROM Orders; | An SQL statement specifying the OrderDate field on the Orders table as the source of data. You can bind a control on the form or report to the OrderDate field in the Orders table by setting the control's ControlSource property to OrderDate.
Note Note

Changing the record source of an open form or report causes an automatic requery of the underlying data. If a form's Recordset property is set at runtime, the form's RecordSource property is updated.

After you have created a form or report, you can change its source of data by changing the RecordSource property. The RecordSource property is also useful if you want to create a reusable form or report. For example, you could create a form that incorporates a standard design, then copy the form and change the RecordSource property to display data from a different table, query, or SQL statement.

Limiting the number of records contained in a form's record source can enhance performance, especially when your application is running on a network. For example, you can set a form's RecordSource property to an SQL statement that returns a single record and change the form's record source depending on criteria selected by the user.

Example

The following example sets a form's RecordSource property to the Customers table:

VBA Copy code Copy code
Forms!frmCustomers.RecordSource = "Customers"

The next example changes a form's record source to a single record in the Customers table, depending on the company name selected in the cmboCompanyName combo box control. The combo box is filled by an SQL statement that returns the customer ID (in the bound column) and the company name. The CustomerID has a Text data type.

VBA Copy code Copy code
Sub cmboCompanyName_AfterUpdate()
 Dim strNewRecord As String
 strNewRecord = "SELECT * FROM Customers " _
 & " WHERE CustomerID = '" _
 & Me!cmboCompanyName.Value & "'"
 Me.RecordSource = strNewRecord
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


AllForms Members (Access)

 Copy code hover
[image]

AllForms Members (Access)
Send feedback

Published: July 16, 2012

The AllForms collection contains an AccessObject object for each form in the CurrentProject or CodeProject object.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


SeekEnum

 Copy code hover
[image]

SeekEnum
Send feedback

Specifies the type of Seek to execute.

Constant | Value | Description
adSeekFirstEQ | 1 | Seeks the first key equal to KeyValues.
adSeekLastEQ | 2 | Seeks the last key equal to KeyValues.
adSeekAfterEQ | 4 | Seeks either a key equal to KeyValues or just after where that match would have occurred.
adSeekAfter | 8 | Seeks a key just after where a match with KeyValues would have occurred.
adSeekBeforeEQ | 16 | Seeks either a key equal to KeyValues or just before where that match would have occurred.
adSeekBefore | 32 | Seeks a key just before where a match with KeyValues would have occurred.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.Seek.FIRSTEQ

AdoEnums.Seek.LASTEQ

AdoEnums.Seek.AFTEREQ

AdoEnums.Seek.AFTER

AdoEnums.Seek.BEFOREEQ

AdoEnums.Seek.BEFORE


PROCEDURE Clause (Microsoft Access SQL)

 Copy code hover
[image]

PROCEDURE Clause (Microsoft Access SQL)
Send feedback

Defines a name and optional parameters for a query.

Note Note

The PROCEDURE clause has been superseded by the PROCEDURE statement. Although the PROCEDURE clause is still supported, the PROCEDURE statement provides a superset of the capability of the PROCEDURE clause and is the recommended syntax.

Syntax

PROCEDURE name [param1 datatype[, param2 datatype[, …]]

The PROCEDURE clause has these parts:

Part

Description

name

A name for the procedure. It must follow standard naming conventions.

param1, param2

One or more field names or parameters. For example:

SQL Copy code Copy code
PROCEDURE Sales_By_Country [Beginning Date] DateTime, [Ending Date] DateTime;

For more information on parameters, see parameters.

datatype

One of the primary Microsoft Access SQL data types or their synonyms.

Remarks

An SQL procedure consists of a PROCEDURE clause (which specifies the name of the procedure), an optional list of parameter definitions, and a single SQL statement. For example, the procedure Get_Part_Number might run a query that retrieves a specified part number.

Note Note

  • If the clause includes more than one field definition (that is, param-datatype pairs), separate them with commas.

  • The PROCEDURE clause must be followed by an SQL statement (for example, a SELECT or UPDATE statement).

Example

This example names the query CategoryList.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

Copy code Copy code
Sub ProcedureX()

    Dim dbs As Database, rst As Recordset
    Dim qdf As QueryDef, strSql As String

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    strSql = "PROCEDURE CategoryList; " _
        & "SELECT DISTINCTROW CategoryName, " _
        & "CategoryID FROM Categories " _
        & "ORDER BY CategoryName;"

    ' Create a named QueryDef based on the SQL
    ' statement.
    Set qdf = dbs.CreateQueryDef("NewQry", strSql)

    ' Create a temporary snapshot-type Recordset.
    Set rst = qdf.OpenRecordset(dbOpenSnapshot)

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 15

    ' Delete the QueryDef because this is a
    ' demonstration.
    dbs.QueryDefs.Delete "NewQry"

    dbs.Close

End Sub


NavigationButton Events (Access)

 Copy code hover
[image]

NavigationButton Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.


CommandButton.SoftEdges Property (Access)

 Copy code hover
[image]

CommandButton.SoftEdges Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the Soft Edges effect applied to the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .SoftEdges

expression A variable that represents a CommandButton object.

Remarks

The SoftEdges property uses one of the values listed in the following table.

Value | Effect
0 (Default) | No Soft Edges
1 | 1 Point
2 | 2.5 Points
3 | 5 Points
4 | 10 Points
5 | 25 Points
6 | 50 Points

To see the available shadow effects and apply a shadow through the user interface, first open the form or report in Layout view or Design view by right-clicking the form or report in the Navigation Pane, and then clicking the view you want. Then, click the object to which you want to apply a soft edge effect. Next, on the Format tab, in the Control Formatting group, click Shape Effects, then click Soft Edges and choose a soft edge effect. Notice that the shadow effects are indexed from top to bottom.

This property is not surfaced in the property sheet.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ListBox.ColumnCount Property (Access)

 Copy code hover
[image]

ListBox.ColumnCount Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnCount property to specify the number of columns displayed in a list box or in the list box portion of a combo box, or sent to OLE objects in a chart control or unbound object frame . Read/write Integer.

Syntax

expression .ColumnCount

expression A variable that represents a ListBox object.

Remarks

The ColumnCount property holds an integer between 1 and the maximum number of fields in the table, query, or SQL statement, or the maximum number of values in the value list, specified in the RowSource property of the control.

For table fields , you can set this property on the Lookup tab in the Field Properties section of table Design view for fields with the DisplayControl property set to Combo Box or List Box.

For example, if you set the ColumnCount property for a list box on an Employees form to 3, one column can list last names, another can list first names, and the third can list employee ID numbers.

A combo box or list box can have multiple columns. If the control's RowSource property contains the name of a table, query, or SQL statement, a combo box or list box will display the fields from that source, from left to right, up to the number specified by the ColumnCount property.

To display a different combination of fields, create either a new query or a new SQL statement for the RowSource property, specifying the fields and the order you want.

If the RowSource property contains a list of values (the RowSourceType property is set to Value List), the values are put into the rows and columns of the combo box or list box in the order they are listed in the RowSource property. For example, if the RowSource property contains the list "Red; Green; Blue; Yellow" and the ColumnCount property is set to 2, the first row of the combo box or list box list will contain "Red" in the first column and "Green" in the second column. The second row will contain "Blue" in the first column and "Yellow" in the second column.

You can use the ColumnWidths property to set the width of the columns displayed in the control, or to hide columns.

Example

The following example uses the Column property and the ColumnCount property to print the values of a list box selection.

VBA Copy code Copy code
Public Sub Read_ListBox()

 Dim intNumColumns As Integer
 Dim intI As Integer
 Dim frmCust As Form

 Set frmCust = Forms!frmCustomers
 If frmCust!lstCustomerNames.ItemsSelected.Count > 0 Then

 ' Any selection?
 intNumColumns = frmCust!lstCustomerNames.ColumnCount
 Debug.Print "The list box contains "; intNumColumns; _
 IIf(intNumColumns = 1, " column", " columns"); _
 " of data."

 Debug.Print "The current selection contains:"
 For intI = 0 To intNumColumns - 1
 ' Print column data.
 Debug.Print frmCust!lstCustomerNames.Column(intI)
 Next intI
 Else
 Debug.Print "You haven't selected an entry in the " _
 & "list box."
 End If

 Set frmCust = Nothing

End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


ToggleButton.BeforeUpdate Property (Access)

 Copy code hover
[image]

ToggleButton.BeforeUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.

Syntax

expression .BeforeUpdate

expression A variable that represents a ToggleButton object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeUpdate event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the BeforeUpdate event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).BeforeUpdate = "[Event Procedure]"

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


TabControl.Properties Property (Access)

 Copy code hover
[image]

TabControl.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a TabControl object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Stream (Visual C++ Syntax Index with #import)

 Copy code hover
[image]

Stream (Visual C++ Syntax Index with #import)
Send feedback

Methods

Copy code Copy code

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthadocancel_HV10294125.xml( );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthclose_HV10294173.xml( );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcopyto_HV10294233.xml( struct _Stream * DestStream, int CharNumber );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthflush_HV10294386.xml( );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthloadfromfile_HV10294485.xml( _bstr_t FileName );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthopenstream_HV10294567.xml( const _variant_t & Source, enum
 ConnectModeEnum Mode, enum StreamOpenOptionsEnum Options, _bstr_t
 UserName, _bstr_t Password );

_variant_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthread_HV10294692.xml( long NumBytes );

_bstr_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthreadtext_HV10294694.xml( long NumChars );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthsavetofile_HV10294752.xml( _bstr_t FileName, enum SaveOptionsEnumOptions );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthseteos_HV10294771.xml( );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthskipline_HV10294780.xml( );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthwrite_HV10294958.xml( const _variant_t & Buffer );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthwritetext_HV10294959.xml( _bstr_t Data, enum StreamWriteEnumOptions );

Properties

Copy code Copy code

_bstr_t GetCharset( );
void PutCharset( _bstr_t pbstrCharset );
__declspec(property(get=GetCharset,put=PutCharset)) _bstr_t Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocharset_HV10294162.xml;

VARIANT_BOOL GetEOS( );
__declspec(property(get=GetEOS)) VARIANT_BOOL Invalid DDUE based on source, error:link not allowed in code, link filename:mdproeos_HV10294332.xml;

enum LineSeparatorEnum GetLineSeparator( );
void PutLineSeparator( enum LineSeparatorEnum pLS );
__declspec(property(get=GetLineSeparator,put=PutLineSeparator)) enum
 LineSeparatorEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdprolineseparator_HV10294483.xml;

enum ConnectModeEnum GetMode( );
void PutMode( enum ConnectModeEnum pMode );
__declspec(property(get=GetMode,put=PutMode)) enum ConnectModeEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdpromode_HV10294518.xml;

long GetPosition( );
void PutPosition( long pPos );
__declspec(property(get=GetPosition,put=PutPosition)) long Invalid DDUE based on source, error:link not allowed in code, link filename:mdproposition_HV10294611.xml;

long GetSize( );
__declspec(property(get=GetSize)) long Invalid DDUE based on source, error:link not allowed in code, link filename:mdprosizestream_HV10294778.xml;

enum ObjectStateEnum GetState( );
__declspec(property(get=GetState)) enum ObjectStateEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdprostate_HV10294804.xml;

enum StreamTypeEnum GetType( );
void PutType( enum StreamTypeEnum ptype );
__declspec(property(get=GetType,put=PutType)) enum StreamTypeEnum Invalid DDUE based on source, error:link not allowed in code, link filename:mdprotypestream_HV10294865.xml;


Formal Shape Grammar

 Copy code hover
[image]

Formal Shape Grammar
Send feedback

This is the formal grammar for creating any shape command:

  • Required grammatical terms are text strings delimited by angle brackets ("<>").

  • Optional terms are delimited by square brackets ("[ ]").

  • Alternatives are indicated by a virgule ("|").

  • Repeating alternatives are indicated by an ellipsis ("...").

  • Alpha indicates a string of alphabetical letters.

  • Digit indicates a string of numbers.

  • Unicode-digit indicates a string of unicode digits.

All other terms are literals.

Term | Definition
<shape-command> | SHAPE [<table-exp> [[AS] <alias>]][<shape-action>]
<table-exp> | {<provider-command-text>} | (<shape-command>) | TABLE <quoted-name> | <quoted-name>
<shape-action> | APPEND <aliased-field-list> | COMPUTE <aliased-field-list> [BY <field-list>]
<aliased-field-list> | <aliased-field> [, <aliased-field...>]
<aliased-field> | <field-exp> [[AS] <alias>]
<field-exp> | (<relation-exp>) | <calculated-exp> | <aggregate-exp> | <new-exp>
<relation_exp> | <table-exp> [[AS] <alias>] <table-exp> [[AS] <alias>]
<relation-cond-list> | <relation-cond> [, <relation-cond>...]
<relation-cond> | <field-name> TO <child-ref>
<child-ref> | <field-name> | PARAMETER <param-ref>
<param-ref> | <number>
<field-list> | <field-name> [, <field-name>]
<aggregate-exp> | SUM(<qualified-field-name>) | AVG(<qualified-field-name>) | MIN(<qualified-field-name>) | MAX(<qualified-field-name>) | COUNT(<qualified-alias> | <qualified-name>) | STDEV(<qualified-field-name>) | ANY(<qualified-field-name>)
<calculated-exp> | CALC(<expression>)
<qualified-field-name> | <alias>.[<alias>...]<field-name>
<alias> | <quoted-name>
<field-name> | <quoted-name> [[AS] <alias>]
<quoted-name> | "<string>" | '<string>' | [<string>] | <name>
<qualified-name> | alias[.alias...]
<name> | alpha [ alpha | digit | _ | # | : | ...]
<number> | digit [digit...]
<new-exp> | NEW <field-type> [(<number> [, <number>])]
<field-type> | An OLE DB or ADO data type.
<string> | unicode-char [unicode-char...]
<expression> | A Visual Basic for Applications expression whose operands are other non-CALC columns in the same row.


TabControl.HoverColor Property (Access)

 Copy code hover
[image]

TabControl.HoverColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color displayed on the control when the user rests the mouse cursor over it. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HoverColor

expression A variable that represents a TabControl object.

Remarks

The HoverColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


UNION Operation (Microsoft Access SQL)

 Copy code hover
[image]

UNION Operation (Microsoft Access SQL)
Send feedback

Creates a union query, which combines the results of two or more independent queries or tables.

Syntax

[TABLE] query1 UNION [ALL] [TABLE] query2 [UNION [ALL] [TABLE] queryn [ … ]]

The UNION operation has these parts:

Part | Description
query1-n | A SELECT statement, the name of a stored query, or the name of a stored table preceded by the TABLE keyword.

Remarks

You can merge the results of two or more queries, tables, and SELECT statements, in any combination, in a single UNION operation. The following example merges an existing table named New Accounts and a SELECT statement:

SQL Copy code Copy code
TABLE [New Accounts] UNION ALL
SELECT *
FROM Customers
WHERE OrderAmount > 1000;

By default, no duplicate records are returned when you use a UNION operation; however, you can include the ALL predicate to ensure that all records are returned. This also makes the query run faster.

All queries in a UNION operation must request the same number of fields; however, the fields do not have to be of the same size or data type.

Use aliases only in the first SELECT statement because they are ignored in any others. In the ORDER BY clause, refer to fields by what they are called in the first SELECT statement.

Note Note

  • You can use a GROUP BY or HAVING clause in each query argument to group the returned data.

  • You can use an ORDER BY clause at the end of the last query argument to display the returned data in a specified order.

Example

This example retrieves the names and cities of all suppliers and customers in Brazil.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

VBA Copy code Copy code
Sub UnionX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Retrieve the names and cities of all suppliers
    ' and customers in Brazil.
    Set rst = dbs.OpenRecordset("SELECT CompanyName," _
        & " City FROM Suppliers" _
        & " WHERE Country = 'Brazil' UNION" _
        & " SELECT CompanyName, City FROM Customers" _
        & " WHERE Country = 'Brazil';")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 12

    dbs.Close

End Sub


AccessObject.DateModified Property (Access)

 Copy code hover
[image]

AccessObject.DateModified Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a Date indicating the date and time when the design of the specified object was last modified. Read-only.

Syntax

expression .DateModified

expression A variable that represents an AccessObject object.

Example

The following example lists all the reports in the current database and when their designs were created and modified.

VBA Copy code Copy code
Dim acobjLoop As AccessObject

For Each acobjLoop In CurrentProject.AllReports
 With acobjLoop
 Debug.Print .Name & " - Created " & .DateCreated _
 & " - Modified " & .DateModified
 End With
Next acobjLoop

See also

Concepts

AccessObject Object

Other resources

AccessObject Object Members


NavigationControl.MouseMove Event (Access)

 Copy code hover
[image]

NavigationControl.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Version Information

Version Added: Access 2010

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents a NavigationControl object.

Parameters

Name | Required/Optional | Data Type | Description
Button | Required | Integer |
Shift | Required | Integer |
X | Required | Single |
Y | Required | Single |

Return Value

nothing

Remarks

  • The MouseMove event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


CheckBox.Width Property (Access)

 Copy code hover
[image]

CheckBox.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents a CheckBox object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Form.Load Event (Access)

 Copy code hover
[image]

Form.Load Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when a form is opened and its records are displayed.

Syntax

expression .Load

expression A variable that represents a Form object.

Remarks

To run a macro or event procedure when these events occur, set the OnLoad property to the name of the macro or to [Event Procedure].

The Load event is caused by user actions such as:

  • Starting an application.

  • Opening a form by clicking Open in the Database window.

  • Running the OpenForm action in a macro.

By running a macro or an event procedure when a form's Load event occurs, you can specify default settings for controls, or display calculated data that depends on the data in the form's records.

By running a macro or an event procedure when a form's Unload event occurs, you can verify that the form should be unloaded or specify actions that should take place when the form is unloaded. You can also open another form or display a dialog box requesting the user's name to make a log entry indicating who used the form.

When you first open a form, the following events occur in this order:

Open → Load → Resize → Activate → Current

If you're trying to decide whether to use the Open or Load event for your macro or event procedure, one significant difference is that the Open event can be canceled, but the Load event can't. For example, if you're dynamically building a record source for a form in an event procedure for the form's Open event, you can cancel opening the form if there are no records to display.

When you close a form, the following events occur in this order:

Unload → Deactivate → Close

The Unload event occurs before the Close event. The Unload event can be canceled, but the Close event can't.

Note Note

When you create macros or event procedures for events related to the Load event, such as Activate and GotFocus, be sure that they don't conflict (for example, make sure you don't cause something to happen in one macro or procedure that is canceled in another) and that they don't cause cascading events.

Example

The following example displays the current date in the form's caption when the form is loaded.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_Load()
 Me.Caption = Date
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Application.Printer Property (Access)

 Copy code hover
[image]

Application.Printer Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Printer object representing the default printer on the current system. Read/write.

Syntax

expression .Printer

expression A variable that represents an Application object.

Example

The following example makes the first printer in the Printers collection the default printer for the system, and then reports its name, driver information, and port information.

VBA Copy code Copy code
Dim prtDefault As Printer

Set Application.Printer = Application.Printers(0)

Set prtDefault = Application.Printer

With prtDefault
 MsgBox "Device name: " & .DeviceName & vbCr _
 & "Driver name: " & .DriverName & vbCr _
 & "Port: " & .Port
End With

See also

Concepts

Application Object

Other resources

Application Object Members


EmptyCell.GridlineTint Property (Access)

 Copy code hover
[image]

EmptyCell.GridlineTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineTint

expression A variable that represents an EmptyCell object.

Remarks

The GridlineTint property contains a numeric expression that can be used to lighten the theme color in the GridlineColor property. The default value of the GridlineTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


Attachment.DisplayAs Property (Access)

 Copy code hover
[image]

Attachment.DisplayAs Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcDisplayAs constant that specifies how a file should be displayed in the Attachment control. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .DisplayAs

expression A variable that represents an Attachment object.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Controls in Access Reports

 Copy code hover
[image]

Controls in Access Reports
Send feedback

In this section

  • How to: Set Form, Report, and Control Properties in Code


Application.SaveAsAXL Method (Access)

 Copy code hover
[image]

Application.SaveAsAXL Method (Access)
See also Send feedback

Published: July 16, 2012

Exports the specified object to an Application XML (AXL) file.

Version Information

Version Added: Access 2010

Syntax

expression .SaveAsAXL(ObjectType, ObjectName, FileName)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
ObjectType | Required | AcObjectType | Specifies the type of object to export.
ObjectName | Required | String | Specifies the name of the object to export.
FileName | Required | String | Specifies the full path and filename of the AXL file to create.

Remarks

The SaveAsAXL method does not provide a warning when the file specified in the FileName argument already exists. If this occurs, the file will be overwritten.

The SaveAsAXL method generates a run-time error if the current database is not a Web database.

For more information about AXL, see [MS-AXL]: Access Application Transfer Protocol Structure Specification.

See also

Concepts

Application Object

Other resources

Application Object Members


References.Parent Property (Access)

 Copy code hover
[image]

References.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a References object.

See also

Concepts

References Collection

Other resources

References Object Members


Document.Container Property (DAO)

 Copy code hover
[image]

Document.Container Property (DAO)
Send feedback

Returns the name of the Container object to which a Document object belongs (Microsoft Access workspaces only). .

Syntax

expression .Container

expression A variable that represents a Document object.

Example

This example displays the Container property for a variety of Document objects.

VBA Copy code Copy code
Sub ContainerPropertyX()

 Dim dbsNorthwind As Database
 Dim ctrLoop As Container

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 ' Display the container name for the first Document
 ' object in each Container object's Documents collection.
 For Each ctrLoop In dbsNorthwind.Containers
 Debug.Print "Document: " & ctrLoop.Documents(0).Name
 Debug.Print " Container = " & _
 ctrLoop.Documents(0).Container
 Next ctrLoop

 dbsNorthwind.Close

End Sub


Recordset.RecordCount Property (DAO)

 Copy code hover
[image]

Recordset.RecordCount Property (DAO)
Send feedback

Returns the number of records accessed in a Recordset object, or the total number of records in a table-type Recordset object. or TableDef object. Read-only Long.

Syntax

expression .RecordCount

expression A variable that represents a Recordset object.

Remarks

Use the RecordCount property to find out how many records in a Recordset or TableDef object have been accessed. The RecordCount property doesn't indicate how many records are contained in a dynaset-, snapshot-, or forward-only-type Recordset object until all records have been accessed. Once the last record has been accessed, the RecordCount property indicates the total number of undeleted records in the Recordset or TableDef object. To force the last record to be accessed, use the MoveLast method on the Recordset object. You can also use an SQL Count function to determine the approximate number of records your query will return.

Note Note

Using the MoveLast method to populate a newly opened Recordset negatively impacts performance. Unless it is necessary to have an accurate RecordCount as soon as you open a Recordset, it's better to wait until you populate the Recordset with other portions of code before checking the RecordCount property.

As your application deletes records in a dynaset-type Recordset object, the value of the RecordCount property decreases. However, records deleted by other users aren't reflected by the RecordCount property until the current record is positioned to a deleted record. If you execute a transaction that affects the RecordCount property setting and you subsequently roll back the transaction, the RecordCount property won't reflect the actual number of remaining records.

The RecordCount property of a snapshot- or forward-only-type Recordset object isn't affected by changes in the underlying tables.

A Recordset or TableDef object with no records has a RecordCount property setting of 0.

Using the Requery method on a Recordset object resets the RecordCount property just as if the query were re-executed.

Example

This example demonstrates the RecordCount property with different types of Recordsets before and after they're populated.

VBA Copy code Copy code
Sub RecordCountX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind
 ' Open table-type Recordset and show RecordCount
 ' property.
 Set rstEmployees = .OpenRecordset("Employees")
 Debug.Print _
 "Table-type recordset from Employees table"
 Debug.Print " RecordCount = " & _
 rstEmployees.RecordCount
 rstEmployees.Close

 ' Open dynaset-type Recordset and show RecordCount
 ' property before populating the Recordset.
 Set rstEmployees = .OpenRecordset("Employees", _
 dbOpenDynaset)
 Debug.Print "Dynaset-type recordset " & _
 "from Employees table before MoveLast"
 Debug.Print " RecordCount = " & _
 rstEmployees.RecordCount

 ' Show the RecordCount property after populating the
 ' Recordset.
 rstEmployees.MoveLast
 Debug.Print "Dynaset-type recordset " & _
 "from Employees table after MoveLast"
 Debug.Print " RecordCount = " & _
 rstEmployees.RecordCount
 rstEmployees.Close

 ' Open snapshot-type Recordset and show RecordCount
 ' property before populating the Recordset.
 Set rstEmployees = .OpenRecordset("Employees", _
 dbOpenSnapshot)
 Debug.Print "Snapshot-type recordset " & _
 "from Employees table before MoveLast"
 Debug.Print " RecordCount = " & _
 rstEmployees.RecordCount

 ' Show the RecordCount property after populating the
 ' Recordset.
 rstEmployees.MoveLast
 Debug.Print "Snapshot-type recordset " & _
 "from Employees table after MoveLast"
 Debug.Print " RecordCount = " & _
 rstEmployees.RecordCount
 rstEmployees.Close

 ' Open forward-only-type Recordset and show
 ' RecordCount property before populating the
 ' Recordset.
 Set rstEmployees = .OpenRecordset("Employees", _
 dbOpenForwardOnly)
 Debug.Print "Forward-only-type recordset " & _
 "from Employees table before MoveLast"
 Debug.Print " RecordCount = " & _
 rstEmployees.RecordCount

 ' Show the RecordCount property after calling the
 ' MoveNext method.
 rstEmployees.MoveNext
 Debug.Print "Forward-only-type recordset " & _
 "from Employees table after MoveNext"
 Debug.Print " RecordCount = " & _
 rstEmployees.RecordCount
 rstEmployees.Close

 .Close
 End With

End Sub


Report.RecordSource Property (Access)

 Copy code hover
[image]

Report.RecordSource Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the RecordSource property to specify the source of the data for a report. Read/write String.

Syntax

expression .RecordSource

expression A variable that represents a Report object.

Remarks

The RecordSource property setting can be a table name, a query name, or an SQL statement. For example, you can use the following settings.

Sample setting | Description
Employees | A table name specifying the Employees table as the source of data.
SELECT Orders!OrderDate FROM Orders; | An SQL statement specifying the OrderDate field on the Orders table as the source of data. You can bind a control on the form or report to the OrderDate field in the Orders table by setting the control's ControlSource property to OrderDate.
Note Note

Changing the record source of an open form or report causes an automatic requery of the underlying data. If a form's Recordset property is set at runtime, the form's RecordSource property is updated.

After you have created a form or report, you can change its source of data by changing the RecordSource property. The RecordSource property is also useful if you want to create a reusable form or report. For example, you could create a form that incorporates a standard design, then copy the form and change the RecordSource property to display data from a different table, query, or SQL statement.

Example

The following example sets a form's RecordSource property to the Customers table:

VBA Copy code Copy code
Forms!frmCustomers.RecordSource = "Customers"

The next example changes a form's record source to a single record in the Customers table, depending on the company name selected in the cmboCompanyName combo box control. The combo box is filled by an SQL statement that returns the customer ID (in the bound column) and the company name. The CustomerID has a Text data type.

VBA Copy code Copy code
Sub cmboCompanyName_AfterUpdate()
    Dim strNewRecord As String
    strNewRecord = "SELECT * FROM Customers " _
        & " WHERE CustomerID = '" _
        & Me!cmboCompanyName.Value & "'"
    Me.RecordSource = strNewRecord
End Sub

The following example shows how to use a Structured Query Language (SQL) statement to establish the data source of a report as it is opened.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Private Sub Report_Open(Cancel As Integer)

    On Error GoTo Error_Handler

    Me.Caption = "My Application"

    DoCmd.OpenForm FormName:="frmReportSelector_MemberList", _
    Windowmode:=acDialog

    'Cancel the report if "cancel" was selected on the dialog form.

    If Forms!frmReportSelector_MemberList!txtContinue = "no" Then
        Cancel = True
        GoTo Exit_Procedure
    End If
    Me.RecordSource = ReplaceWhereClause(Me.RecordSource, _
      Forms!frmReportSelector_MemberList!txtWhereClause)

Exit_Procedure:
    Exit Sub

Error_Handler:
    MsgBox Err.Number & ": " & Err.Description
    Resume Exit_Procedure
    Resume

End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.

See also

Concepts

Report Object

Other resources

Report Object Members


Workspace.BeginTrans Method (DAO)

 Copy code hover
[image]

Workspace.BeginTrans Method (DAO)
Send feedback

Begins a new transaction. Read/write Database.

Syntax

expression .BeginTrans

expression A variable that represents a Workspace object.

Remarks

The transaction methods BeginTrans, CommitTrans, and Rollback manage transaction processing during a session defined by a Workspace object. You use these methods with a Workspace object when you want to treat a series of changes made to the databases in a session as one unit.

Typically, you use transactions to maintain the integrity of your data when you must both update records in two or more tables and ensure changes are completed (committed) in all tables or none at all (rolled back). For example, if you transfer money from one account to another, you might subtract an amount from one and add the amount to another. If either update fails, the accounts no longer balance. Use the BeginTrans method before updating the first record, and then, if any subsequent update fails, you can use the Rollback method to undo all of the updates. Use the CommitTrans method after you successfully update the last record.

Note Note

Within one Workspace object, transactions are always global to the Workspace and aren't limited to only one Connection or Database object. If you perform operations on more than one connection or database within a Workspace transaction, resolving the transaction (that is, using the CommitTrans or Rollback method) affects all operations on all connections and databases within that workspace.

After you use CommitTrans, you can't undo changes made during that transaction unless the transaction is nested within another transaction that is itself rolled back. If you nest transactions, you must resolve the current transaction before you can resolve a transaction at a higher level of nesting.

If you want to have simultaneous transactions with overlapping, non-nested scopes, you can create additional Workspace objects to contain the concurrent transactions.

If you close a Workspace object without resolving any pending transactions, the transactions are automatically rolled back.

If you use the CommitTrans or Rollback method without first using the BeginTrans method, an error occurs.

Some ISAM databases used in a Microsoft Access workspace may not support transactions, in which case the Transactions property of the Database object or Recordset object is False. To make sure the database supports transactions, check the value of the Transactions property of the Database object before using the BeginTrans method. If you are using a Recordset object based on more than one database, check the Transactions property of the Recordset object. If a Recordset is based entirely on Microsoft Access database engine tables, you can always use transactions. Recordset objects based on tables created by other database products, however, may not support transactions. For example, you can't use transactions in a Recordset based on a Paradox table. In this case, the Transactions property is False. If the Database or Recordset doesn't support transactions, the methods are ignored and no error occurs.

You can't nest transactions if you are accessing ODBC data sources through the Microsoft Access database engine.

In ODBC workspaces, when you use CommitTrans your cursor may no longer be valid. Use the Requery method to view the changes in the Recordset, or close and re-open the Recordset.

Note Note

  • You can often improve the performance of your application by breaking operations that require disk access into transaction blocks. This buffers your operations and may significantly reduce the number of times a disk is accessed.

  • In a Microsoft Access workspace, transactions are logged in a file kept in the directory specified by the TEMP environment variable on the workstation. If the transaction log file exhausts the available storage on your TEMP drive, the database engine triggers a run-time error. At this point, if you use CommitTrans, an indeterminate number of operations are committed, but the remaining uncompleted operations are lost, and the operation has to be restarted. Using a Rollback method releases the transaction log and rolls back all operations in the transaction.

  • Closing a clone Recordset within a pending transaction will cause an implicit Rollback operation.

Example

The following example shows how to use a transaction in a Data Access Objects (DAO) workspace.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Public Sub TransferFunds()
    Dim wrk As DAO.Workspace
    Dim dbC As DAO.Database
    Dim dbX As DAO.Database

    Set wrk = DBEngine(0)
    Set dbC = CurrentDb
    Set dbX = wrk.OpenDatabase("e:\books\acc2007vba\myDB.accdb")

    On Error GoTo trans_Err

    'Begin the transaction

    wrk.BeginTrans

    'Withdraw funds from one account table
    dbC.Execute "INSERT INTO tblAccounts ( Amount, Txn, TxnDate ) SELECT -20, 'DEBIT', Date()", dbFailOnError

    'Deposit funds into another account table
    dbX.Execute "INSERT INTO tblAccounts ( Amount, Txn, TxnDate ) SELECT 20, 'CREDIT', Date()", dbFailOnError

    'Commit the transaction
    wrk.CommitTrans dbForceOSFlush

trans_Exit:
    'Clean up
    wrk.Close
    Set dbC = Nothing
    Set dbX = Nothing
    Set wrk = Nothing
    Exit Sub

trans_Err:
    'Roll back the transaction
    wrk.Rollback
    Resume trans_Exit

End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Operation.WSParameters Property (Access)

 Copy code hover
[image]

Operation.WSParameters Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the collection of parameters defined for the specified operation. Read-only WSParameters.

Version Information

Version Added: Access 2010

Syntax

expression .WSParameters

expression A variable that represents an Operation object.

See also

Concepts

Operation Object

Other resources

Operation Object Members


OptionGroup Object (Access)

 Copy code hover
[image]

OptionGroup Object (Access)
See also Send feedback

Published: July 16, 2012

An option group on a form or report displays a limited set of alternatives. An option group makes selecting a value easy since you can just click the value you want. Only one option in an option group can be selected at a time.

Remarks

An option group consists of a group frame and a set of check boxes, toggle buttons, or option buttons.

If an option group is bound to a field, only the group frame itself is bound to the field, not the check boxes, toggle buttons, or option buttons inside the frame. Instead of etting the ControlSource property for each control in the option group, you set the OptionValue property of each check box, toggle button, or option button to a number that's meaningful for the field to which the group frame is bound. When you select an option in an option group, Microsoft Access sets the value of the field to which the option group is bound to the value of the selected option's OptionValue property.

Note Note

The OptionValue property is set to a number because the value of an option group can only be a number, not text. Microsoft Access stores this number in the underlying table. In the preceding example, if you want to display the name of the shipper instead of a number in the Orders table, you can create a separate table called Shippers that stores shipper names, and then make the ShipVia field in the Orders table a Lookup field that looks up data in the Shippers table.

An option group can also be set to an expression, or it can be unbound. You can use an unbound option group in a custom dialog box to accept user input and then carry out an action based on that input.

See also

Concepts

Access Object Model Reference

Other resources

OptionGroup Object Members


Page.OnMouseMove Property (Access)

 Copy code hover
[image]

Page.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Syntax

expression .OnMouseMove

expression A variable that represents a Page object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

Page Object

Other resources

Page Object Members


TempVars Object (Access)

 Copy code hover
[image]

TempVars Object (Access)
See also Send feedback

Published: July 16, 2012

Represents the collection of TempVar objects.

Version Information

Version Added: Access 2007

Remarks

Use the Add method or the SetTempVar macro action to create a TempVar object.

Use the Remove method or the RemoveTempVar macro action to delete a TempVar object from the TempVars collection.

Use the RemoveAll method or RemoveAllTempVars macro action to delete all TempVar objects from the TempVars collection.

The TempVars collection can store up to 255 TempVar objects. If you do not remove a TempVar object, it will remain in memory until you close the database. It is a good practice to remove TempVar object variables when you are finished using them.

To refer to a TempVar object in a collection by its ordinal number or by its Name property setting, use the following syntax form:

  • TempVar![name]

See also

Concepts

Access Object Model Reference

Other resources

TempVars Object Members


Recordset.EOF Property (DAO)

 Copy code hover
[image]

Recordset.EOF Property (DAO)
Send feedback

Returns a value that indicates whether the current record position is after the last record in a Recordset object. Read-only Boolean.

Syntax

expression .EOF

expression A variable that represents a Recordset object.

Remarks

You can use the BOF and EOF properties to determine whether a Recordset object contains records or whether you've gone beyond the limits of a Recordset object when you move from record to record.

The location of the current record pointer determines the BOF and EOF return values.

If either the BOF or EOF property is True, there is no current record.

If you open a Recordset object containing no records, the BOF and EOF properties are set to True, and the Recordset object's RecordCount property setting is 0. When you open a Recordset object that contains at least one record, the first record is the current record and the BOF and EOF properties are False; they remain False until you move beyond the beginning or end of the Recordset object by using the MovePrevious or MoveNext method, respectively. When you move beyond the beginning or end of the Recordset, there is no current record or no record exists.

If you delete the last remaining record in the Recordset object, the BOF and EOF properties may remain False until you attempt to reposition the current record.

If you use the MoveLast method on a Recordset object containing records, the last record becomes the current record; if you then use the MoveNext method, the current record becomes invalid and the EOF property is set to True. Conversely, if you use the MoveFirst method on a Recordset object containing records, the first record becomes the current record; if you then use the MovePrevious method, there is no current record and the BOF property is set to True.

Typically, when you work with all the records in a Recordset object, your code will loop through the records by using the MoveNext method until the EOF property is set to True.

If you use the MoveNext method while the EOF property is set to True or the MovePrevious method while the BOF property is set to True, an error occurs.

This table shows which Move methods are allowed with different combinations of the BOF and EOF properties.

 | MoveFirst, MoveLast | MovePrevious, Move < 0 | Move 0 | MoveNext, Move > 0
BOF=True, EOF=False | Allowed | Error | Error | Allowed
BOF=False, EOF=True | Allowed | Allowed | Error | Error
Both True | Error | Error | Error | Error
Both False | Allowed | Allowed | Allowed | Allowed

Allowing a Move method doesn't mean that the method will successfully locate a record. It merely indicates that an attempt to perform the specified Move method is allowed and won't generate an error. The state of the BOF and EOF properties may change as a result of the attempted Move.

An OpenRecordset method internally invokes a MoveFirst method. Therefore, using an OpenRecordset method on an empty set of records sets the BOF and EOF properties to True. (See the following table for the behavior of a failed MoveFirst method.)

All Move methods that successfully locate a record will set both BOF and EOF to False.

In a Microsoft Access workspace, if you add a record to an empty Recordset, BOF will become False, but EOF will remain True, indicating that the current position is at the end of Recordset.

Any Delete method, even if it removes the only remaining record from a Recordset, won't change the setting of the BOF or EOF property.

The following table shows how Move methods that don't locate a record affect the BOF and EOF property settings.

 | BOF | EOF
MoveFirst, MoveLast | True | True
Move 0 | No change | No change
MovePrevious, Move < 0 | True | No change
MoveNext, Move > 0 | No change | True


DateWithTimeFromParts Function (Access 2013 custom web app)

 Copy code hover
[image]

DateWithTimeFromParts Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns a Date and Time based on a specified year, month, day, and time.

Syntax

DateWithTimeFromParts (Year, Month, Day, Hour, Minute, Second)

The DateWithTimeFromParts function contains the following arguments.

Argument name | Description
Year | Integer expression specifying a year.
Month | Integer expression specifying a month.
Day | Integer expression specifying a day.
Hour | Integer expression specifying hours.
Minute | Integer expression specifying minutes.
Second | Integer expression specifying seconds.

Remarks

DateWithTimeFromParts returns a fully initialized Date/Time value. If the arguments are not valid, an error is raised. If required arguments are Null, then Null is returned.


RecordsetEvents (Visual C++ Syntax Index with #import)

 Copy code hover
[image]

RecordsetEvents (Visual C++ Syntax Index with #import)
Send feedback

Events

Copy code Copy code

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillchangefield_HV10294950.xml( long cFields, const
 _variant_t & Fields, enum EventStatusEnum * adStatus, struct
 _Recordset * pRecordset );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillchangefield_HV10294950.xml( long cFields, const
 _variant_t & Fields, struct Error * pError, enum EventStatusEnum
 * adStatus, struct _Recordset * pRecordset );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillchangerecord_HV10294951.xml( enum EventReasonEnum
 adReason, long cRecords, enum EventStatusEnum * adStatus, struct
 _Recordset * pRecordset );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillchangerecord_HV10294951.xml( enum EventReasonEnum
 adReason, long cRecords, struct Error * pError, enum
 EventStatusEnum * adStatus, struct _Recordset * pRecordset );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillchangerecordset_HV10294952.xml( enum EventReasonEnum
 adReason, enum EventStatusEnum * adStatus, struct _Recordset *pRecordset );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillchangerecordset_HV10294952.xml( enum
 EventReasonEnum adReason, struct Error * pError, enum
 EventStatusEnum * adStatus, struct _Recordset * pRecordset );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillmove_HV10294955.xml( enum EventReasonEnum adReason, enum
 EventStatusEnum * adStatus, struct _Recordset * pRecordset );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillmove_HV10294955.xml( enum EventReasonEnum adReason, struct
 Error * pError, enum EventStatusEnum * adStatus, struct
 _Recordset * pRecordset );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtendofrecordset_HV10294329.xml( VARIANT_BOOL * fMoreData, enum
 EventStatusEnum * adStatus, struct _Recordset * pRecordset );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtfetchprogress_HV10294358.xml( long Progress, long MaxProgress,
 enum EventStatusEnum * adStatus, struct _Recordset * pRecordset );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtfetchcomplete_HV10294356.xml( struct Error * pError, enum
 EventStatusEnum * adStatus, struct _Recordset * pRecordset );


InheritTypeEnum

 Copy code hover
[image]

InheritTypeEnum
Send feedback

Specifies how objects will inherit permissions set with SetPermissions.

Constant | Value | Description
adInheritBoth | 3 | Both objects and other containers contained by the primary object inherit the entry.
adInheritContainers | 2 | Other containers that are contained by the primary object inherit the entry.
adInheritNone | 0 | Default. No inheritance occurs.
adInheritNoPropagate | 4 | The adInheritObjects and adInheritContainers flags are not propagated to an inherited entry.
adInheritObjects | 1 | Non-container objects in the container inherit the permissions.


SmartTagProperty.Delete Method (Access)

 Copy code hover
[image]

SmartTagProperty.Delete Method (Access)
See also Send feedback

Published: July 16, 2012

Deletes the specified object.

Syntax

expression .Delete

expression A variable that represents a SmartTagProperty object.

Return Value

Nothing

See also

Concepts

SmartTagProperty Object

Other resources

SmartTagProperty Object Members


CommandButton.BackColor Property (Access)

 Copy code hover
[image]

CommandButton.BackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the interior color of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackColor

expression A variable that represents a CommandButton object.

Remarks

The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

To use the BackColor property, the BackStyle property, if available, must be set to Normal.

Example

The following example uses the RGB function to set the , BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Workspaces Properties (DAO)

 Copy code hover
[image]

Workspaces Properties (DAO)
Send feedback

In this section

  • Workspaces.Count Property (DAO)


Delete Method Example (VBScript)

 Copy code hover
[image]

Delete Method Example (VBScript)
Send feedback

This example uses the Delete method to remove a specified record from a Recordset.

Use the following example in an Active Server Page (ASP).

Use Find to locate the file Adovbs.inc and place it in the directory you plan to use. Cut and paste the following code into Notepad or another text editor, and save it as DeleteVBS.asp. You can view the result in any client browser.

To exercise the example, try using the AddNew example first to add some records. Then you can try to delete them. View the result in any client browser.

Copy code Copy code

<!-- BeginDeleteVBS -->
<%@ Language=VBScript %>
<% ' use this meta tag instead of ADOVBS.inc%>
<!-- METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->
<HTML>
<HEAD>
<TITLE>ADO Delete Method</TITLE>
</HEAD>
<STYLE>
<!--
TH {
 background-color: #008080;
 font-family: 'Arial Narrow','Arial',sans-serif;
 font-size: xx-small;
 color: white;
 }
TD {
 text-align: center;
 background-color: #f7efde;
 font-family: 'Arial Narrow','Arial',sans-serif;
 font-size: xx-small;
 }
-->
</STYLE>

<BODY>
<H3>ADO Delete Method</H3>

<%
 ' to integrate this code replace the DataSource value in the connection string

 ' connection and recordset variables
 Dim Cnxn, strCnxn
 Dim rsCustomers, strSQLCustomers

 ' create and open connection
 Set Cnxn = Server.CreateObject("ADODB.Connection")
 strCnxn="Provider='sqloledb';Data Source=" & _
 Request.ServerVariables("SERVER_NAME") & ";" & _
 "Integrated Security='SSPI';Initial Catalog='Northwind';"
 Cnxn.Open strCnxn
 ' create and open recordset
 Set rsCustomers = Server.CreateObject("ADODB.Recordset")
 strSQLCustomers = "Customers"
 rsCustomers.Open strSQLCustomers, Cnxn, adOpenKeyset, adLockOptimistic, adCmdTable

 ' Move to designated record and delete it
 If Not IsEmpty(Request.Form("WhichRecord")) Then
 'Get value to move from Form Post method
 Moves = Request.Form("WhichRecord")

 rsCustomers.Move CInt(Moves)
 If Not rsCustomers.EOF or rsCustomers.BOF Then
 ' handle any db errors
 On Error Resume Next
 rsCustomers.Delete 1
 If Cnxn.Errors.Count <> 0 Then
 Response.Write "Cannot delete since there are related records in other tables."
 Response.End
 End If
 rsCustomers.MoveFirst
 On Error GoTo 0
 Else
 Response.Write "Not a Valid Record Number"
 rsCustomers.MoveFirst
 End If
 End If
%>

<!-- BEGIN column header row for Customer Table-->
<TABLE COLSPAN=8 CELLPADDING=5 BORDER=0>
<TR>
 <TH>Rec. #</TH>
 <TH>Company Name</TH>
 <TH>Contact Name</TH>
 <TH>City</TH>
</TR>

 <%
 ' Display ADO Data from Customer Table
 ' Loop through Recordset adding one row to HTML Table each pass
 Dim iCount
 iCount = 0
 Do Until rsCustomers.EOF %>
 <TR>
 <TD> <%= CStr(iCount) %>
 <TD> <%= rsCustomers("CompanyName")%> </TD>
 <TD> <%= rsCustomers("ContactName")%> </TD>
 <TD> <%= rsCustomers("City")%> </TD>
 </TR>
 <%
 iCount = iCount + 1
 rsCustomers.MoveNext
 Loop
 %>
</TABLE>

<!-- Do Client side Input Data Validation Move to named record and Delete it -->
<Center>
<H4>Clicking Button Will Remove Designated Record</H4>
<H5>There are <%=rsCustomers.RecordCount%> Records in this Set</H5>

<Form Method=Post Action="Deletevbs.asp" Name=Form>
 <Input Type=Text Name="WhichRecord" Size=3>
 <Input Type=Button Name=cmdDelete Value="Delete Record">
</Form>

</BODY>

<Script Language = "VBScript">
Sub cmdDelete_OnClick
 If IsNumeric(Document.Form.WhichRecord.Value) Then
 Document.Form.WhichRecord.Value = CInt(Document.Form.WhichRecord.Value)
 Dim Response
 Response = MsgBox("Are You Sure About Deleting This Record?", vbYesNo, "ADO-ASP Example")

 If Response = vbYes Then
 Document.Form.Submit
 End If
 Else
 MsgBox "You Must Enter a Valid Record Number",,"ADO-ASP Example"
 End If
End Sub
</Script>

<%
 ' clean up
 If rsCustomers.State = adStateOpen then
 rsCustomers.Close
 End If
 If Cnxn.State = adStateOpen then
 Cnxn.Close
 End If
%>
</HTML>
<!-- EndDeleteVBS -->


RelatedColumn Property (ADOX)

 Copy code hover
[image]

RelatedColumn Property (ADOX)
Send feedback

Indicates the name of the related column in the related table (key columns only).

Settings and Return Values

Sets and returns a String value that is the name of the related column in the related table.

Remarks

The default value is an empty string ("").

This property is read-only for Column objects already appended to a collection.


ComboBox.BottomMargin Property (Access)

 Copy code hover
[image]

ComboBox.BottomMargin Property (Access)
See also Send feedback

Published: July 16, 2012

Along with the LeftMargin, RightMargin, and TopMargin properties, specifies the location of information displayed within a text box control. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .BottomMargin

expression A variable that represents a ComboBox object.

Remarks

A control's displayed information location is the distance measured from the control's left, top, right, or bottom border to the left, top, right, or bottom edge of the displayed information. To use a unit of measurement different from the setting in the regional settings of Windows, specify the unit (for example, cm or in).

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Macro Actions and Methods of the DoCmd Object

 Copy code hover
[image]

Macro Actions and Methods of the DoCmd Object
Send feedback

To carry out macro actions from code in Microsoft Access, use the DoCmd object and its methods. This object replaces the DoCmd statement that you used in versions 1.x and 2.0 of Microsoft Access to carry out a macro action.

When you convert a database, Microsoft Access automatically converts any DoCmd statements and the actions that they carried out in your Access Basic code to methods of the DoCmd object by replacing the space with the . (dot) operator.

Some macro actions work differently in Microsoft Access 9.0 and later than in version 1.x, 2.0, or 7.0; these differences are detailed below.

Databases Created with Microsoft Access 95

The DoMenuItem Action

The DoMenuItem action is no longer used in Microsoft Access. The RunCommand action can be used to accomplish the tasks for which you used to use the DoMenuItem action.

When you enable a database created with a prior version of Microsoft Access, the DoMenuItem action will continue to work as it did before.

When you convert a database created with a prior version of Microsoft Access, all DoMenuItem actions in macros are replaced with RunCommand actions the first time that the macros are saved after conversion. DoMenuItem methods used in Visual Basic procedures aren't changed.

Databases Created with Microsoft Access Version 1.

The TransferSpreadsheet Action

Microsoft Access can't import Microsoft Excel version 2.0 spreadsheets or Lotus 1-2-3 version 1.0 spreadsheets. If your converted database contains a macro that provided this functionality by using the TransferSpreadsheet action in Microsoft Access version 1.x or 2.0, converting the database will change the Spreadsheet Type argument to Microsoft Excel version 3.0 (if you originally specified Microsoft Excel version 2.0), or causes an error if you originally specified Lotus 1-2-3 version 1.0 format.

To work around this problem, convert the spreadsheets to a later version of Microsoft Excel or Lotus 1-2-3 before importing them into Microsoft Access.

The TransferText and TransferSpreadsheet Actions

In Microsoft Access, you can't use a SQL statement to specify data to export when you're using the TransferText action or the TransferSpreadsheet action. Instead of using a SQL statement, you must first create a query and then specify the name of the query in the Table Name argument.

Comparisons Involving Null Values

In Microsoft Access versions 1.x and 2.0, if you compare two expressions within a macro condition by using a comparison operator and one of the expressions is Null, Access Basic will return True or False for the comparison, depending on which comparison operator you use. In Microsoft Access 2000 and later, Visual Basic returns Null for a comparison in which one expression is Null. To determine whether the comparison evaluates to Null, use the IsNull function to check the result of the comparison.


Incompatible version of an installable ISAM. (Error 3429)

 Copy code hover
[image]

Incompatible version of an installable ISAM. (Error 3429)
Send feedback

You attempted to use an older version of an installable ISAM with the current version of the Microsoft Access database engine. Run Setup again to install the correct version of the installable ISAM.


Controls.Item Property (Access)

 Copy code hover
[image]

Controls.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only Object.

Syntax

expression .Item(Index)

expression A variable that represents a Controls object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

Controls Collection

Other resources

Controls Object Members


ListBox.RightPadding Property (Access)

 Copy code hover
[image]

ListBox.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the list box and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .RightPadding

expression A variable that represents a ListBox object.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


ObjectFrame.MouseMove Event (Access)

 Copy code hover
[image]

ObjectFrame.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents an ObjectFrame object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Recordset.Update Method (DAO)

 Copy code hover
[image]

Recordset.Update Method (DAO)
Send feedback

Syntax

expression .Update(UpdateType, Force)

expression A variable that represents a Recordset object.

Parameters

Name | Required/Optional | Data Type | Description
UpdateType | Optional | Long | A UpdateTypeEnum constant indicating the type of update, as specified in Settings (ODBCDirect workspaces only).
Force | Optional | Boolean | A Boolean value indicating whether or not to force the changes into the database, regardless of whether the underlying data has been changed by another user since the AddNew, Delete, or Edit call. If True, the changes are forced and changes made by other users are simply overwritten. If False (default), changes made by another user while the update is pending will cause the update to fail for those changes that are in conflict. No error occurs, but the BatchCollisionCount and BatchCollisions properties will indicate the number of conflicts and the rows affected by conflicts, respectively (ODBCDirect workspaces only).

Remarks

Use Update to save the current record and any changes you've made to it.

Important note Important

Changes to the current record are lost if:

  • You use the Edit or AddNew method, and then move to another record without first using Update.

  • You use Edit or AddNew, and then use Edit or AddNew again without first using Update.

  • You set the Bookmark property to another record.

  • You close the Recordset without first using Update.

  • You cancel the Edit operation by using CancelUpdate.

To edit a record, use the Edit method to copy the contents of the current record to the copy buffer. If you don't use Edit first, an error occurs when you use Update or attempt to change a field's value.

In an ODBCDirect workspace, you can do batch updates, provided the cursor library supports batch updates, and the Recordset was opened with the optimistic batch locking option.

In a Microsoft Access workspace, when the Recordset object's LockEdits property setting is True (pessimistically locked) in a multiuser environment, the record remains locked from the time Edit is used until the Update method is executed or the edit is canceled. If the LockEdits property setting is False (optimistically locked), the record is locked and compared with the pre-edited record just before it is updated in the database. If the record has changed since you used the Edit method, the Update operation fails. Microsoft Access database engine-connected ODBC and installable ISAM databases always use optimistic locking. To continue the Update operation with your changes, use the Update method again. To revert to the record as the other user changed it, refresh the current record by using Move 0.

Note Note

To add, edit, or delete a record, there must be a unique index on the record in the underlying data source. If not, a "Permission denied" error will occur on the AddNew, Delete, or Edit method call in a Microsoft Access workspace, or an "Invalid argument" error will occur on the Update call in an ODBCDirect workspace.

Example

This example demonstrates the Update method in conjunction with Edit method.

VBA Copy code Copy code
Sub UpdateX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset
 Dim strOldFirst As String
 Dim strOldLast As String
 Dim strMessage As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees")

 With rstEmployees
 .Edit
 ' Store original data.
 strOldFirst = !FirstName
 strOldLast = !LastName
 ' Change data in edit buffer.
 !FirstName = "Linda"
 !LastName = "Kobara"

 ' Show contents of buffer and get user input.
 strMessage = "Edit in progress:" & vbCr & _
 " Original data = " & strOldFirst & " " & _
 strOldLast & vbCr & " Data in buffer = " & _
 !FirstName & " " & !LastName & vbCr & vbCr & _
 "Use Update to replace the original data with " & _
 "the buffered data in the Recordset?"

 If MsgBox(strMessage, vbYesNo) = vbYes Then
 .Update
 Else
 .CancelUpdate
 End If

 ' Show the resulting data.
 MsgBox "Data in recordset = " & !FirstName & " " & _
 !LastName

 ' Restore original data because this is a demonstration.
 If Not (strOldFirst = !FirstName And _
 strOldLast = !LastName) Then
 .Edit
 !FirstName = strOldFirst
 !LastName = strOldLast
 .Update
 End If

 .Close
 End With

 dbsNorthwind.Close

End Sub

This example demonstrates the Update method in conjunction with the AddNew method.

VBA Copy code Copy code
Sub UpdateX2()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset
 Dim strOldFirst As String
 Dim strOldLast As String
 Dim strMessage As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees")

 With rstEmployees
 .AddNew
 !FirstName = "Bill"
 !LastName = "Sornsin"

 ' Show contents of buffer and get user input.
 strMessage = "AddNew in progress:" & vbCr & _
 " Data in buffer = " & !FirstName & " " & _
 !LastName & vbCr & vbCr & _
 "Use Update to save buffer to recordset?"

 If MsgBox(strMessage, vbYesNoCancel) = vbYes Then
 .Update
 ' Go to the new record and show the resulting data.
 .Bookmark = .LastModified
 MsgBox "Data in recordset = " & !FirstName & _
 " " & !LastName
 ' Delete new data because this is a demonstration.
 .Delete
 Else
 .CancelUpdate
 MsgBox "No new record added."
 End If

 .Close
 End With

 dbsNorthwind.Close

End Sub

This example uses the BatchCollisionCount property and the Update method to demonstrate batch updating where any collisions are resolved by forcing the batch update.

VBA Copy code Copy code
Sub BatchX()

 Dim wrkMain As Workspace
 Dim conMain As Connection
 Dim rstTemp As Recordset
 Dim intLoop As Integer
 Dim strPrompt As String

 Set wrkMain = CreateWorkspace("ODBCWorkspace", _
 "admin", "", dbUseODBC)
 ' This DefaultCursorDriver setting is required for
 ' batch updating.
 wrkMain.DefaultCursorDriver = dbUseClientBatchCursor

 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conMain = wrkMain.OpenConnection("Publishers", _
 dbDriverNoPrompt, False, _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 ' The following locking argument is required for
 ' batch updating. It is also required that a table
 ' with a primary key is used.
 Set rstTemp = conMain.OpenRecordset( _
 "SELECT * FROM roysched", dbOpenDynaset, 0, _
 dbOptimisticBatch)

 With rstTemp
 ' Modify data in local recordset.
 Do While Not .EOF
 .Edit
 If !royalty <= 20 Then
 !royalty = !royalty - 4
 Else
 !royalty = !royalty + 2
 End If
 .Update
 .MoveNext
 Loop

 ' Attempt a batch update.
 .Update dbUpdateBatch

 ' If there are collisions, give the user the option
 ' of forcing the changes or resolving them
 ' individually.
 If .BatchCollisionCount > 0 Then
 strPrompt = "There are collisions. " & vbCr & _
 "Do you want the program to force " & _
 vbCr & "an update using the local data?"
 If MsgBox(strPrompt, vbYesNo) = vbYes Then _
 .Update dbUpdateBatch, True
 End If

 .Close
 End With

 conMain.Close
 wrkMain.Close

End Sub

This example uses the AddNew method to create a new record with the specified name. The AddName function is required for this procedure to run.

VBA Copy code Copy code
Sub AddNewX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset
 Dim strFirstName As String
 Dim strLastName As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", dbOpenDynaset)

 ' Get data from the user.
 strFirstName = Trim(InputBox( _
 "Enter first name:"))
 strLastName = Trim(InputBox( _
 "Enter last name:"))

 ' Proceed only if the user actually entered something
 ' for both the first and last names.
 If strFirstName <> "" and strLastName <> "" Then

 ' Call the function that adds the record.
 AddName rstEmployees, strFirstName, strLastName

 ' Show the newly added data.
 With rstEmployees
 Debug.Print "New record: " & !FirstName & _
 " " & !LastName
 ' Delete new record because this is a demonstration.
 .Delete
 End With

 Else
 Debug.Print _
 "You must input a string for first and last name!"
 End If

 rstEmployees.Close
 dbsNorthwind.Close

End Sub

Function AddName(rstTemp As Recordset, _
 strFirst As String, strLast As String)

 ' Adds a new record to a Recordset using the data passed
 ' by the calling procedure. The new record is then made
 ' the current record.
 With rstTemp
 .AddNew
 !FirstName = strFirst
 !LastName = strLast
 .Update
 .Bookmark = .LastModified
 End With

End Function


Could not lock table

 Copy code hover
[image]

Could not lock table <name>; currently in use by user <name> on machine <name>. (Error 3262)
Send feedback

You tried to lock a table while opening it, but the table cannot be locked because it is currently in use. Wait a moment, and then try the operation again.


Handler Property (RDS)

 Copy code hover
[image]

Handler Property (RDS)
Send feedback

Indicates the name of a server-side customization program (handler) that extends the functionality of the RDSServer.DataFactory, and any parameters used by the handler.

Syntax

DataControl.Handler = String

Parameters

  • DataControl

  • An object variable that represents an RDS.DataControl object.

  • String

  • A String value that contains the name of the handler and any parameters, all separated by commas (for example, "handlerName,parm1,parm2,...,parm N" ).

Remarks

This property supports customization, a functionality that requires setting the CursorLocation property to adUseClient.

The name of the handler and its parameters, if any, are separated by commas (","). Unpredictable behavior will result if a semicolon (";") appears anywhere within String. You can write your own handler, provided it supports the IDataFactoryHandler interface.

The name of the default handler is MSDFMAP.Handler, and its default parameter is a customization file named MSDFMAP.INI. Use this property to invoke alternate customization files created by your server administrator.

The alternative to setting the Handler property is to specify a handler and parameters in the ConnectionString property; that is, "Handler=handlerName,parm1,parm2,...;".


NavigationControl.SpecialEffect Property (Access)

 Copy code hover
[image]

NavigationControl.SpecialEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .SpecialEffect

expression A variable that represents a NavigationControl object.

Remarks

The SpecialEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | 0 | The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised | 1 | The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken | 2 | The object has a shadow on the top and left and a highlight on the bottom and right.
Etched | 3 | The object has a sunken line surrounding the control.
Shadowed | 4 | The object has a shadow below and to the right of the control.
Chiseled | 5 | The object has a sunken line below the control.

The SpecialEffect property setting affects related property settings for the BorderStyle , BorderColor , and BorderWidth properties. For example, if the SpecialEffect property is set to Raised, the settings for the BorderStyle, BorderColor, and BorderWidth properties are ignored. In addition, changing or setting the BorderStyle, BorderColor, and BorderWidth properties may cause Microsoft Access to change the SpecialEffect property setting to Flat.

Note Note

When you set the SpecialEffect property of a text box to Shadowed, the vertical height of the text display area is reduced. You can adjust the Height property of the text box to increase the size of the text display area.

Example

The following example sets the appearance of the text box "OrganizationName1" on the "Mailing List" form to raised.

VBA Copy code Copy code
Forms("Mailing List").Controls("OrganizationName1").SpecialEffect = 1

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


CurrentProject.WebSite Property (Access)

 Copy code hover
[image]

CurrentProject.WebSite Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the Uniform Resource Locator (URL) of the Web site to which the database has been published. Read-only String.

Version Information

Version Added: Access 2010

Syntax

expression .WebSite

expression A variable that represents a CurrentProject object.

Remarks

The WebSite property contains a zero-length string if the database has not been published.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


Indexes Collection (ADOX)

 Copy code hover
[image]

Indexes Collection (ADOX)
Send feedback

Contains all Index objects of a table.

Remarks

The Append method for an Indexes collection is unique for ADOX. You can:

  • Add a new index to the collection with the Append method.

The remaining properties and methods are standard to ADO collections. You can:

  • Access an index in the collection with the Item property.

  • Return the number of indexes contained in the collection with the Count property.

  • Remove an index from the collection with the Delete method.

  • Update the objects in the collection to reflect the current database's schema with the Refresh method.


OptionGroup.Enter Event (Access)

 Copy code hover
[image]

OptionGroup.Enter Event (Access)
See also Send feedback

Published: July 16, 2012

The Enter event occurs before a control actually receives the focus from a control on the same form or report.

Syntax

expression .Enter

expression A variable that represents an OptionGroup object.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when these events occur, set the OnEnter or OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Enter event occurs before the GotFocus event. The Exit event occurs before the LostFocus event.

Unlike the GotFocus and LostFocus events, the Enter and Exit events don't occur when a form receives or loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


NavigationControl Object (Access)

 Copy code hover
[image]

NavigationControl Object (Access)
See also Send feedback

Published: July 16, 2012

This object represents a navigation control on a form.

Version Information

Version Added: Access 2010

Remarks

The NavigationControl contains a collection of navigation buttons, each of which is represented by a NavigationButton objects. When a user clicks a navigation button, the assocated form or report is displayed in the control specified by the SubForm property.

Use the Tabs property to return the collection of navigation buttons for the navigation control.

Use SelectedTab property to return the navigation button that is currently selected.

See also

Concepts

Access Object Model Reference

Other resources

NavigationControl Object Members


ComboBox.KeyUp Event (Access)

 Copy code hover
[image]

ComboBox.KeyUp Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyUp(KeyCode, Shift)

expression A variable that represents a ComboBox object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyUp property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyUp event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyUp event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ToggleButton.Value Property (Access)

 Copy code hover
[image]

ToggleButton.Value Property (Access)
See also Send feedback

Published: July 16, 2012

Determines or specifies whether or not the specified toggle button control is selected. Read/write Variant.

Syntax

expression .Value

expression A variable that represents a ToggleButton object.

Remarks

When the Value proprty is set to True, the toggle button is pressed in.

The Value property returns or sets a control's default property, which is the property that is assumed when you don't explicitly specify a property name.

Note Note

The Value property is not the same as the DefaultValue property, which specifies the value that a property is assigned when a new record is created.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Invalid operation. (Error 3219)

 Copy code hover
[image]

Invalid operation. (Error 3219)
Send feedback

Possible causes:

  • You tried to write to a read-only property. See the Help topic for the property to determine whether it is read/write.

  • You tried to use a method or property on a type of Recordset object that the method or property does not apply to. See the Recordset object summary topic to determine which methods and properties apply to a given type of Recordset object.

  • You tried to append a property to a Properties collection of an object that does not support user-defined properties.

  • You tried to use the Update method on a read-only Recordset object.


NavigationButton.SoftEdges Property (Access)

 Copy code hover
[image]

NavigationButton.SoftEdges Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the Soft Edges effect applied to the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .SoftEdges

expression A variable that represents a NavigationButton object.

Remarks

The SoftEdges property uses one of the values listed in the following table.

Value | Effect
0 (Default) | No Soft Edges
1 | 1 Point
2 | 2.5 Points
3 | 5 Points
4 | 10 Points
5 | 25 Points
6 | 50 Points

To see the available shadow effects and apply a shadow through the user interface, first open the form or report in Layout view or Design view by right-clicking the form or report in the Navigation Pane, and then clicking the view you want. Then, click the object to which you want to apply a soft edge effect. Next, on the Format tab, in the Control Formatting group, click Shape Effects, then click Soft Edges and choose a soft edge effect. Notice that the shadow effects are indexed from top to bottom.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


StringFormatEnum

 Copy code hover
[image]

StringFormatEnum
Send feedback

Specifies the format when retrieving a Recordset as a string.

Constant | Value | Description
adClipString | 2 | Delimits rows by RowDelimiter, columns by ColumnDelimiter, and null values by NullExpr. These three parameters of the GetString method are valid only with a StringFormat of adClipString.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.StringFormat.CLIPSTRING


BoundObjectFrame.SourceItem Property (Access)

 Copy code hover
[image]

BoundObjectFrame.SourceItem Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SourceItem property to specify the data within a file to be linked when you create a linked OLE object. Read/write String.

Syntax

expression .SourceItem

expression A variable that represents a BoundObjectFrame object.

Remarks

You can set the SourceItem property by specifying data in units recognized by the application supplying the object. For example, when you link to Microsoft Excel, you specify the SourceItem property setting by using a cell or cell-range reference such as R1C1 or R3C4:R9C22 or a named range such as Revenues.

Note Note

To determine the syntax to describe a unit of data for a particular object, see the documentation for the application that was used to create the object.

The control's OLETypeAllowed property must be set to Linked or Either when you use this property. Use the control's SourceDoc property to specify the file to link.

Example

The following example creates a linked OLE object using an unbound object frame named OLE1 and sizes the control to display the object's entire contents when the user clicks a command button.

VBA Copy code Copy code
Sub Command1_Click
 OLE1.Class = "Excel.Sheet" ' Set class name.
 ' Specify type of object.
 OLE1.OLETypeAllowed = acOLELinked
 ' Specify source file.
 OLE1.SourceDoc = "C:\Excel\Oletext.xls"
 ' Specify data to create link to.
 OLE1.SourceItem = "R1C1:R5C5"
 ' Create linked object.
 OLE1.Action = acOLECreateLink
 ' Adjust control size.
 OLE1.SizeMode = acOLESizeZoom
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Image.OldBorderStyle Property (Access)

 Copy code hover
[image]

Image.OldBorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.

Syntax

expression .OldBorderStyle

expression A variable that represents an Image object.

Remarks

The OldBorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines
Note Note

  • If the OldBorderStyle property is set to None or Dialog, the form doesn't have Maximize or Minimize buttons, regardless of its MinMaxButtons property setting.

  • If the OldBorderStyle property is set to None, the form doesn't have a Control menu, regardless of its ControlBox property setting.

  • The OldBorderStyle property setting doesn't affect the display of the scroll bars, navigation buttons, the record number box, or record selectors.

Example

The following example demonstrates the effect of changing a control's BorderStyle property, while leaving the OldBorderStyle unaffected. The example concludes with setting the BorderStyle property to its original unedited value.

VBA Copy code Copy code
With Forms("Order Entry").Controls("Zip Code") .BorderStyle = 3 ' Short dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 3, 1.

    .BorderStyle = 2 ' Dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 2, 1

    .BorderStyle = .OldBorderStyle ' Solid (default) border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 1, 1
End With

See also

Concepts

Image Object

Other resources

Image Object Members


CopyRecordOptionsEnum

 Copy code hover
[image]

CopyRecordOptionsEnum
Send feedback

Specifies the behavior of the CopyRecord method.

Constant | Value | Description
adCopyAllowEmulation | 4 | Indicates that the Source provider attempts to simulate the copy using download and upload operations if this method fails due to Destination being on a different server or is serviced by a different provider than Source. Note that differing provider capabilities may hamper performance or lose data.
adCopyNonRecursive | 2 | Copies the current directory, but none of its subdirectories, to the destination. The copy operation is not recursive.
adCopyOverWrite | 1 | Overwrites the file or directory if the Destination points to an existing file or directory.
adCopyUnspecified | -1 | Default. Performs the default copy operation: The operation fails if the destination file or directory already exists, and the operation copies recursively.

ADO/WFC Equivalent

These constants do not have ADO/WFC equivalents.


Form.OnActivate Property (Access)

 Copy code hover
[image]

Form.OnActivate Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Activate box in the Properties window of a form or report. Read/write String.

Syntax

expression .OnActivate

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Activate event occurs when the form or report receives the focus and becomes the active window.

The OnActivate value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Activate box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Activate box is blank, the property value is an empty string.

Example

The following example associates the Activate event with the macro "Activate_Macro" for the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").OnActivate = "Activate_Macro"

See also

Concepts

Form Object

Other resources

Form Object Members


Setting Properties and Options

 Copy code hover
[image]

Setting Properties and Options
Send feedback

In this section

  • Set Form, Report, and Control Properties

  • Set Options from Visual Basic

  • Set Properties by Using Visual Basic

  • Set Startup Properties and Options in Code


ComboBox.IMEHold Property (Access)

 Copy code hover
[image]

ComboBox.IMEHold Property (Access)
See also Send feedback

Published: July 16, 2012

Language-specific information You can use the IMEHold/Hold KanjiConversionMode property to show whether the Kanji Conversion Mode is maintained when the control loses the focus. Read/write Boolean.

Syntax

expression .IMEHold

expression A variable that represents a ComboBox object.

Remarks

The IMEHold/Hold KanjiConversionMode property uses the following settings.

Setting | Description
True | Maintains the Kanji Conversion Mode set in the last control.
False | Does not maintain the Kanji Conversion Mode set in the last control (default).

By setting the IMEMode/KanjiConversionMode property, you can designate whether or not the Kanji Conversion Mode is maintained when the control loses the focus. If this property is set to Yes, the Kanji Conversion Mode setting is maintained when the control loses the focus and once that control regains the focus, the Kanji Conversion Mode setting for that control is restored. If this property is set to No (default setting), the Kanji Conversion Mode will be set by the IMEMode/KanjiConversionMode property for that control.

Note Note

To set the Kanji Conversion Mode when the focus shifts to the control, set the IMEMode/KanjiConversionMode property.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


CurrentProject.Connection Property (Access)

 Copy code hover
[image]

CurrentProject.Connection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Connection property to return a reference to the current ActiveX Data Objects (ADO) Connection object and its related properties. Read-only Connection.

Syntax

expression .Connection

expression A variable that represents a CurrentProject object.

Remarks

Use the Connection property to refer to the Connection object of the current Microsoft Access project (.adp) or Access database object. You can use the Connection property to call methods on the Connection object such as BeginTrans and CommitTrans.

Note Note

The Connection property actually returns a reference to a copy of the ActiveX Data Object (ADO) connection for the active database. Thus, applying the Close method or in anyway attempting to alter the connection through the Connection object's methods or properties will have no affect on the actual connection object used by Microsoft Access to hold a live connection to the current database. Since the Connection property is the main Shape provider connection, the following information is necessary when using this property.

  1. MSDataShape uses Recordset.CursorLocation = adUseClient. Do not set CursorLocation prior to assigning a recordset to CurrentProject.Connect.

  2. MSDataShape uses Recordset.CursorType = adOpenStatic. Do not set CursorType prior to assinging a recordset to CurrentProject.Connection.

  3. MSDataShape accepts Recordset.LockType = adLockOptimistic, adLockBatchOptimistic, or adLockReadOnly (default). If set to adLockPessimistic, it is changed to adLockOptimistic.

  4. The shape connection does not support the all ADOX operation, specifically the Columns.Properties collection is not supported.

  5. In order to ensure that a shape connection will work correctly, the Command.CommandType must be set to adCmdTable.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


AccessObject.IsDependentUpon Method (Access)

 Copy code hover
[image]

AccessObject.IsDependentUpon Method (Access)
See also Send feedback

Published: July 16, 2012

Returns a Boolean value that indicates whether the specified object is dependent upon the database object specified in the ObjectName argument.

Syntax

expression .IsDependentUpon(ObjectType, ObjectName)

expression A variable that represents an AccessObject object.

Parameters

Name | Required/Optional | Data Type | Description
ObjectType | Required | AcObjectType | An AcObjectType constant that represents the type of database object to check for dependency.
ObjectName | Required | String | The name of the database object to check for dependency.

Return Value

Boolean

Remarks

This method will return a run-time error if any of the following conditions are true:

  • The Track name AutoCorrect info setting (Tools menu, Options dialog box, General tab) is disabled. You can use the following code to enable the Track name AutoCorrect info setting and update the dependency information for all of the objects in the database:

    Application.SetOption "Track Name AutoCorrect Info", 1

  • You have insufficient permissions to check the dependency information for the specified AccessObject object.

  • This method is being called from an Access project (.adp).

Access does not search Visual Basic for Applications (VBA) code, macros, or data access pages for dependencies.

See also

Concepts

AccessObject Object

Other resources

AccessObject Object Members


Cannot sort on Memo or OLE Object

 Copy code hover
[image]

Cannot sort on Memo or OLE Object <clause>. (Error 3117)
Send feedback

The ORDER BY clause of an SQL statement cannot include Memo or OLE Object fields.


PageBreak.EventProcPrefix Property (Access)

 Copy code hover
[image]

PageBreak.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents a PageBreak object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

PageBreak Object

Other resources

PageBreak Object Members


Attachment.OldBorderStyle Property (Access)

 Copy code hover
[image]

Attachment.OldBorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use this property to set or return the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .OldBorderStyle

expression A variable that represents an Attachment object.

Remarks

The OldBorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines
Note Note

  • If the OldBorderStyle property is set to None or Dialog, the form doesn't have Maximize or Minimize buttons, regardless of its MinMaxButtons property setting.

  • If the OldBorderStyle property is set to None, the form doesn't have a Control menu, regardless of its ControlBox property setting.

  • The OldBorderStyle property setting doesn't affect the display of the scroll bars, navigation buttons, the record number box, or record selectors.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Attachment.DblClick Event (Access)

 Copy code hover
[image]

Attachment.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Version Information

Version Added: Access 2007

Syntax

expression .DblClick(Cancel)

expression A variable that represents an Attachment object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the DblClick event occurs. Setting the Cancel argument to True (-1) cancels the DblClick event.

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • The DblClick event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Form.AllowDeletions Property (Access)

 Copy code hover
[image]

Form.AllowDeletions Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllowDeletions property to specify whether a user can delete a record when using a form. Read/write Boolean.

Syntax

expression .AllowDeletions

expression A variable that represents a Form object.

Remarks

You can set this property to No to allow users to view and edit existing records but not to delete them. When AllowDeletions is set to Yes, records may be deleted so long as existing referential integrity rules aren't broken.

If you want to prevent changes to existing records (make a form read-only), set the AllowAdditions , AllowDeletions, and AllowEdits properties to No. You can also make records read-only by setting the RecordsetType property to Snapshot.

When the AllowDeletions property is set to No, the Delete Record command on the Edit menu isn't available.

Note Note

When the Data Mode argument of the OpenForm action is set, Microsoft Access will override a number of form property settings. If the Data Mode argument of the OpenForm action is set to Edit, Microsoft Access will open the form with the following property settings:

  • AllowEdits — Yes

  • AllowDeletions — Yes

  • AllowAdditions — Yes

  • DataEntry — No

To prevent the OpenForm action from overriding any of these existing property settings, omit the Data Mode argument setting so that Microsoft Access will use the property settings defined by the form.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Connection.RecordsAffected Property (DAO)

 Copy code hover
[image]

Connection.RecordsAffected Property (DAO)
Send feedback

Returns the number of records affected by the most recently invoked Execute method.

Syntax

expression .RecordsAffected

expression A variable that represents a Connection object.


Syntax error. (Error 2438)

 Copy code hover
[image]

Syntax error. (Error 2438)
Send feedback

You entered an expression that has invalid syntax. For example, an operand or operator may be missing, you may have entered an invalid character or comma, or you may have entered text without surrounding it by quotation marks ("). Check the expression to make sure you entered it correctly.


ConnectionString, ConnectionTimeout, and State Properties Example (VB)

 Copy code hover
[image]

ConnectionString, ConnectionTimeout, and State Properties Example (VB)
Send feedback

This example demonstrates different ways of using the ConnectionString property to open a Connection object. It also uses the ConnectionTimeout property to set a connection timeout period, and the State property to check the state of the connections. The GetState function is required for this procedure to run.

Copy code Copy code

'BeginConnectionStringVB

 'To integrate this code replace
 'the database, DSN or Data Source values

Public Sub Main()
 On Error GoTo ErrorHandler

 Dim Cnxn1 As ADODB.Connection
 Dim Cnxn2 As ADODB.Connection
 Dim Cnxn3 As ADODB.Connection
 Dim Cnxn4 As ADODB.Connection

 ' Open a connection without using a Data Source Name (DSN)
 Set Cnxn1 = New ADODB.Connection
 Cnxn1.ConnectionString = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn1.Open
 MsgBox "Cnxn1 state: " & GetState(Cnxn1.State)

 ' Open a connection using a DSN and ODBC tags
 ' It is assumed that you have create DSN 'Pubs' with a user name as
 ' 'MyUserId' and password as 'MyPassword'.
 Set Cnxn2 = New ADODB.Connection
 Cnxn2.ConnectionString = "Data Source='Pubs';" & _
 "User ID='MyUserId';Password='MyPassword';"
 Cnxn2.ConnectionTimeout = 30
 Cnxn2.Open
 MsgBox "Cnxn2 state: " & GetState(Cnxn2.State)

 ' Open a connection using a DSN and OLE DB tags
 ' It is assumed that you have create DSN 'Pubs1' with windows authentication.
 Set Cnxn3 = New ADODB.Connection
 Cnxn3.ConnectionString = "Data Source='Pubs1';"
 Cnxn3.Open
 MsgBox "Cnxn2 state: " & GetState(Cnxn3.State)

 ' Open a connection using a DSN and individual
 ' arguments instead of a connection string
 ' It is assumed that you have create DSN 'Pubs' with a user name as
 ' 'MyUserId' and password as 'MyPassword'.
 Set Cnxn4 = New ADODB.Connection
 Cnxn4.Open "Pubs", "MyUserId", "MyPassword"
 MsgBox "Cnxn4 state: " & GetState(Cnxn4.State)

 ' clean up
 Cnxn1.Close
 Cnxn2.Close
 Cnxn3.Close
 Cnxn4.Close
 Set Cnxn1 = Nothing
 Set Cnxn2 = Nothing
 Set Cnxn3 = Nothing
 Set Cnxn4 = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not Cnxn1 Is Nothing Then
 If Cnxn1.State = adStateOpen Then Cnxn1.Close
 End If
 Set Cnxn1 = Nothing

 If Not Cnxn2 Is Nothing Then
 If Cnxn2.State = adStateOpen Then Cnxn2.Close
 End If
 Set Cnxn2 = Nothing

 If Not Cnxn3 Is Nothing Then
 If Cnxn3.State = adStateOpen Then Cnxn3.Close
 End If
 Set Cnxn3 = Nothing

 If Not Cnxn4 Is Nothing Then
 If Cnxn4.State = adStateOpen Then Cnxn4.Close
 End If
 Set Cnxn4 = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub

Public Function GetState(intState As Integer) As String

 Select Case intState
 Case adStateClosed
 GetState = "adStateClosed"
 Case adStateOpen
 GetState = "adStateOpen"
 End Select

End Function
'EndConnectionStringVB


LockNavigationPane Macro Action

 Copy code hover
[image]

LockNavigationPane Macro Action
Send feedback

You can use the LockNavigationPane action to prevent users from deleting database objects that are displayed in the Navigation Pane.

Setting

The LockNavigationPane action has the following argument.

Action argument | Description
Lock | Select Yes to lock the Navigation Pane, or No to unlock the Navigation Pane.

Remarks

Locking the Navigation Pane prevents you from deleting database objects or cutting database objects to the clipboard. It does not prevent you from performing any of the following operations:

  • Copying database objects to the clipboard

  • Pasting database objects from the clipboard

  • Displaying or hiding the Navigation Pane

  • Selecting different Navigation Pane organization schemes

  • Showing or hiding sections of the Navigation Pane

To run the LockNavigationPane action in a VBA module, use the LockNavigationPane method of the DoCmd object.


ALTER (Microsoft Access SQL reserved word)

 Copy code hover
[image]

ALTER (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The ALTER keyword is used in these contexts:

ALTER TABLE Statement

ALTER USER or DATABASE Statement


NavigationButton.HoverShade Property (Access)

 Copy code hover
[image]

NavigationButton.HoverShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the HoverColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .HoverShade

expression A variable that represents a NavigationButton object.

Remarks

The HoverShade property contains a numeric expression that can be used to darken the theme color in the HoverColor property. The default value of the HoverShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


RDS Properties (Access)

 Copy code hover
[image]

RDS Properties (Access)
Send feedback

In this section

  • RDS Properties

  • Connect Property (RDS)

  • ExecuteOptions Property (RDS)

  • FetchOptions Property (RDS)

  • FilterColumn Property (RDS)

  • FilterCriterion Property (RDS)

  • FilterValue Property (RDS)

  • Handler Property (RDS)

  • InternetTimeout Property (RDS)

  • ReadyState Property (RDS)

  • Recordset, SourceRecordset Properties (RDS)

  • Server Property (RDS)

  • SortColumn Property (RDS)

  • SortDirection Property (RDS)

  • URL Property (RDS)


IsolationLevel and Mode Properties Example (VB)

 Copy code hover
[image]

IsolationLevel and Mode Properties Example (VB)
Send feedback

This example uses the Mode property to open an exclusive connection, and the IsolationLevel property to open a transaction that is conducted in isolation of other transactions.

Copy code Copy code

'BeginIsolationLevelVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 Dim Cnxn As ADODB.Connection
 Dim rstTitles As ADODB.Recordset
 Dim strCnxn As String
 Dim strSQLTitles As String

 ' Open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Mode = adModeShareExclusive
 Cnxn.IsolationLevel = adXactIsolated
 Cnxn.Open strCnxn

 ' open Titles table
 Set rstTitles = New ADODB.Recordset
 strSQLTitles = "titles"
 rstTitles.Open strSQLTitles, Cnxn, adOpenDynamic, adLockPessimistic, adCmdTable

 Cnxn.BeginTrans

 ' Display connection mode
 If Cnxn.Mode = adModeShareExclusive Then
 MsgBox "Connection mode is exclusive."
 Else
 MsgBox "Connection mode is not exclusive."
 End If

 ' Display isolation level
 If Cnxn.IsolationLevel = adXactIsolated Then
 MsgBox "Transaction is isolated."
 Else
 MsgBox "Transaction is not isolated."
 End If

 ' Change the type of psychology titles
 Do Until rstTitles.EOF
 If Trim(rstTitles!Type) = "psychology" Then
 rstTitles!Type = "self_help"
 rstTitles.Update
 End If
 rstTitles.MoveNext
 Loop

 ' Print current data in recordset
 rstTitles.Requery
 Do While Not rstTitles.EOF
 Debug.Print rstTitles!Title & " - " & rstTitles!Type
 rstTitles.MoveNext
 Loop

 ' clean up
 rstTitles.Close
 Cnxn.RollbackTrans
 Cnxn.Close
 Set rstTitles = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstTitles Is Nothing Then
 If rstTitles.State = adStateOpen Then rstTitles.Close
 End If
 Set rstTitles = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then
 Cnxn.RollbackTrans
 Cnxn.Close
 End If
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndIsolationLevelVB


ToggleButton.ColumnWidth Property (Access)

 Copy code hover
[image]

ToggleButton.ColumnWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.

Syntax

expression .ColumnWidth

expression A variable that represents a ToggleButton object.

Remarks

In Visual Basic , the ColumnWidth property setting is an Integer value that represents the column width in twips. You can specify a width or use one of the following predefined settings.

Setting | Description
0 | Hides the column.
-1 | (Default) Sizes the column to the default width.
Note Note

The ColumnWidth property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

Setting this property to 0, or resizing the field to a zero width in Datasheet view, sets the field's ColumnHidden property to True (-1) and hides the field in Datasheet view.

Setting a field's ColumnHidden property to False (0) restores the field's ColumnWidth property to the value it had before the field was hidden. For example, if the ColumnWidth property was -1 prior to the field being hidden by setting the property to 0, changing the field's ColumnHidden property to False resets the ColumnWidth to -1.

The ColumnWidth property for a field isn't available when the field's ColumnHidden property is set to True.

Example

This example takes effect in Datasheet view of the open Customers form. It sets the row height to 450 twips and sizes the column to fit the size of the visible text.

VBA Copy code Copy code
Forms![Customers].RowHeight = 450
Forms![Customers]![Address].ColumnWidth = -2

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Page.Properties Property (Access)

 Copy code hover
[image]

Page.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a Page object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

Page Object

Other resources

Page Object Members


EmptyCell.SizeToFit Method (Access)

 Copy code hover
[image]

EmptyCell.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Version Information

Version Added: Access 2010

Syntax

expression .SizeToFit

expression A variable that represents an EmptyCell object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


NavigationButton Object (Access)

 Copy code hover
[image]

NavigationButton Object (Access)
See also Send feedback

Published: July 16, 2012

This object represents a navigation button in a navigation control on a form.

Version Information

Version Added: Access 2010

Remarks

When you click a navigation button, the form or report specified in the NavigationTargetName is displayed. You can use the NavigationWhereClause to filter the records displayed on the form.

Use the Tabs property of the NavigationControl object to return the collection of navigation buttons for a navigation control. Use SelectedTab property of the NavigationControl object to return the navigation button that is currently selected.

See also

Concepts

Access Object Model Reference

Other resources

NavigationButton Object Members


CustomControl.GridlineWidthRight Property (Access)

 Copy code hover
[image]

CustomControl.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthRight

expression A variable that represents a CustomControl object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


ComboBox.VerticalAnchor Property (Access)

 Copy code hover
[image]

ComboBox.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified combo box is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .VerticalAnchor

expression A variable that represents a ComboBox object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


How to: Create an ADO Connection String

 Copy code hover
[image]

How to: Create an ADO Connection String
Send feedback

To connect to a data source, you must specify a connection string, the parameters of which might differ for each provider and data source. ADO directly supports five arguments in a connection string. Other arguments are passed to the provider that is named in the Provider argument without any processing by ADO.

Argument | Description
Provider | Specifies the name of a provider to use for the connection.
File Name | Specifies the name of a provider-specific file (for example, a persisted data source object) containing preset connection information.
URL | Specifies the connection string as an absolute URL identifying a resource, such as a file or directory.
Remote Provider | Specifies the name of a provider to use when opening a client-side connection. (Remote Data Service only.)
Remote Server | Specifies the path name of the server to use when opening a client-side connection. (Remote Data Service only.)

The following example

VBA Copy code Copy code
m_sConnStr = "Provider='SQLOLEDB';Data Source='MySqlServer';" & _
 "Initial Catalog='Northwind';Integrated Security='SSPI';"

The only ADO parameter supplied in this connection string was "Provider=SQLOLEDB", which indicated the Microsoft OLE DB Provider for SQL Server. Other valid parameters that can be passed in the connection string can be determined by referring to individual providers' documentation.

To open the connection, simply pass the connection string as the first argument in the Connection object's Open method:

VBA Copy code Copy code
objConn.Open m_sConnStr

It is also possible to supply much of this information by setting properties of the Connection object before opening the connection. For example, you could achieve the same effect as the connection string above by using the following code:

VBA Copy code Copy code
With objConn
 .Provider = "SQLOLEDB"
 .DefaultDatabase = "Northwind"
 .Properties("Data Source") = "MySqlServer"
 .Properties("Integrated Security") = "SSPI"
 .Open
End With


ComboBox.Value Property (Access)

 Copy code hover
[image]

ComboBox.Value Property (Access)
See also Send feedback

Published: July 16, 2012

Determines or specifies which value or option in the combo box is selected. Read/write Variant.

Syntax

expression .Value

expression A variable that represents a ComboBox object.

Remarks

The Value property is set to the text in the text box portion of the control. This may or may not be the same as the setting for the Text property of the control. The current setting for the Text property is what is displayed in the text box portion of the combo box; the Value property is set to the Text property setting only after this text is saved.

The Value property returns or sets a control's default property, which is the property that is assumed when you don't explicitly specify a property name.

Note Note

The Value property is not the same as the DefaultValue property, which specifies the value that a property is assigned when a new record is created.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


TableDef Properties (DAO)

 Copy code hover
[image]

TableDef Properties (DAO)
Send feedback

In this section

  • TableDef.Attributes Property (DAO)

  • TableDef.ConflictTable Property (DAO)

  • TableDef.Connect Property (DAO)

  • TableDef.DateCreated Property (DAO)

  • TableDef.Fields Property (DAO)

  • TableDef.Indexes Property (DAO)

  • TableDef.LastUpdated Property (DAO)

  • TableDef.Name Property (DAO)

  • TableDef.Properties Property (DAO)

  • TableDef.RecordCount Property (DAO)

  • TableDef.ReplicaFilter Property (DAO)

  • TableDef.SourceTableName Property (DAO)

  • TableDef.Updatable Property (DAO)

  • TableDef.ValidationRule Property (DAO)

  • TableDef.ValidationText Property (DAO)


Line.Visible Property (Access)

 Copy code hover
[image]

Line.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents a Line object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

Line Object

Other resources

Line Object Members


Execute, Requery, and Clear Methods Example (VC++)

 Copy code hover
[image]

Execute, Requery, and Clear Methods Example (VC++)
Send feedback

This example demonstrates the Execute method when run from both a Command object and a Connection object. It also uses the Requery method to retrieve current data in a recordset, and the Clear method to clear the contents of the Errors collection. The ExecuteCommand and PrintOutput functions are required for this example to run.

Copy code Copy code

// BeginExecuteCpp
#include <ole2.h>
#include <stdio.h>

#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void ExecuteX(void);
void ExecuteCommand(_CommandPtr pCmdTemp, _RecordsetPtr pRstTemp);
void PrintOutput(_RecordsetPtr pRstTemp);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

////////////////////////////////
// Main Function //
////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 ExecuteX();

 ::CoUninitialize();
}

///////////////////////////////////
// ExecuteX Function //
///////////////////////////////////

void ExecuteX(void)
{
 HRESULT hr = S_OK;

 // Define string variables.
 _bstr_t strSQLChange("UPDATE Titles SET Type = "
 "'self_help' WHERE Type = 'psychology'");
 _bstr_t strSQLRestore("UPDATE Titles SET Type = "
 "'psychology' WHERE Type = 'self_help'");
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _ConnectionPtr pConnection = NULL;
 _CommandPtr pCmdChange = NULL;
 _RecordsetPtr pRstTitles = NULL;

 try
 {
 // Open connection.
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
 pConnection->Open (strCnn, "", "", adConnectUnspecified);

 // Create command object.
 TESTHR(pCmdChange.CreateInstance(__uuidof(Command)));
 pCmdChange->ActiveConnection = pConnection;
 pCmdChange->CommandText = strSQLChange;

 // Open titles table, casting Connection pointer to an
 // IDispatch type so converted to correct type of variant.
 TESTHR(pRstTitles.CreateInstance(__uuidof(Recordset)));
 pRstTitles->Open ("Titles", _variant_t((IDispatch *) pConnection,
 true), adOpenStatic, adLockOptimistic, adCmdTable);

 // Print report of original data.
 printf(
 "\n\nData in Titles table before executing the query: \n");

 // Call function to print loop recordset contents.
 PrintOutput(pRstTitles);

 // Clear extraneous errors from the Errors collection.
 pConnection->Errors->Clear();

 // Call ExecuteCommand subroutine to execute pCmdChange command.
 ExecuteCommand(pCmdChange, pRstTitles);

 // Print report of new data.
 printf(
 "\n\n\tData in Titles table after executing the query: \n");
 PrintOutput(pRstTitles);

 // Use the Connection object's execute method to
 // execute SQL statement to restore data.
 pConnection->Execute(strSQLRestore, NULL, adExecuteNoRecords);

 // Retrieve the current data by requerying the recordset.
 pRstTitles->Requery(adCmdUnknown);

 // Print report of restored data.
 printf(
 "\n\n\tData after exec. query to restore original info: \n");
 PrintOutput(pRstTitles);
 }
 catch (_com_error &e)
 {
 PrintProviderError(pConnection);
 PrintComError(e);
 }

 // Clean up objects before exit.
 if (pRstTitles)
 if (pRstTitles->State == adStateOpen)
 pRstTitles->Close();
 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

//////////////////////////////////////////
// ExecuteCommand Function //
//////////////////////////////////////////

void ExecuteCommand(_CommandPtr pCmdTemp, _RecordsetPtr pRstTemp)
{
 try
 {
 // CommandText property already set before function was called.
 pCmdTemp->Execute(NULL, NULL, adCmdText);

 // Retrieve the current data by requerying the recordset.
 pRstTemp->Requery(adCmdUnknown);
 }

 catch(_com_error &e)
 {
 // Notify user of any errors that result from
 // executing the query.
 // Pass a connection pointer accessed from the Recordset.
 PrintProviderError(pRstTemp->GetActiveConnection());
 PrintComError(e);
 }
}

/////////////////////////////////////
// PrintOutput Function //
/////////////////////////////////////

void PrintOutput(_RecordsetPtr pRstTemp)
{
 // Ensure at top of recordset.
 pRstTemp->MoveFirst();

 // If EOF is true, then no data and skip print loop.
 if( pRstTemp->EndOfFile )
 {
 printf("\tRecordset empty\n");
 }
 else
 {
 // Define temporary strings for output conversions.
 // Initialize to first record's values.
 _bstr_t bstrTitle;
 _bstr_t bstrType;

 // Enumerate Recordset and print from each.
 while(!(pRstTemp->EndOfFile))
 {
 // Convert variant string to convertable string type.
 bstrTitle = pRstTemp->Fields->GetItem("Title")->Value;
 bstrType = pRstTemp->Fields->GetItem("Type")->Value;
 printf("\t%s, %s \n",
 (LPCSTR) bstrTitle,
 (LPCSTR) bstrType);

 pRstTemp->MoveNext();
 }
 }
}

///////////////////////////////////////////////
// PrintProviderError Function //
///////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,
 pErr->Description);
 }
 }
}

//////////////////////////////////////
// PrintComError Function //
//////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndExecuteCpp


Could not parse field names from the first row of the import table. (Error 3245)

 Copy code hover
[image]

Could not parse field names from the first row of the import table. (Error 3245)
Send feedback

The first row of data contains invalid field names, such as quoted and unquoted strings in the same field name. In the following example, the third and fourth field names cannot be parsed:

SQL Copy code Copy code
"Name", Date, "ID " Number, Phone" Number"

The first two fields are valid, but the third and fourth are not because they contain nonspace characters outside the quotation marks.

Check the import table for properly matched quotation marks, and then try the import operation again


CubeDefs Collection (ADO MD Reference)

 Copy code hover
[image]

CubeDefs Collection (ADO MD Reference)
Send feedback

In this section

  • CubeDefs Collection (ADO MD)

  • CubeDefs Collection Properties, Methods, and Events (ADO MD)


NavigationButton.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

NavigationButton.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleLeft

expression A variable that represents a NavigationButton object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Operations Properties (Access)

 Copy code hover
[image]

Operations Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Object.
Parent | Returns the parent object for the specified object. Read-only.


BoundObjectFrame.BackTint Property (Access)

 Copy code hover
[image]

BoundObjectFrame.BackTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackTint

expression A variable that represents a BoundObjectFrame object.

Remarks

The BackTint property contains a numeric expression that can be used to lighten the theme color in the BackColor property. The default value of the BackTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackTint=25

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


TabControl.BottomPadding Property (Access)

 Copy code hover
[image]

TabControl.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .BottomPadding

expression A variable that represents a TabControl object.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Application.Visible Property (Access)

 Copy code hover
[image]

Application.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether a Microsoft Access application is minimized. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents an Application object.

Remarks

When an application is launched by the user, the Visible and UserControl properties of the Application object are both set to True. When the UserControl property is set to True, it isn't possible to set the Visible property of the object to False.

When an Application object is created by using Automation, the Visible and UserControl properties of the object are both set to False.

See also

Concepts

Application Object

Other resources

Application Object Members


Parameters Collection (ADO) Reference

 Copy code hover
[image]

Parameters Collection (ADO) Reference
Send feedback

In this section

  • Parameters Collection (ADO)

  • Parameters Collection Properties, Methods, and Events


CommandButton.QuickStyle Property (Access)

 Copy code hover
[image]

CommandButton.QuickStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the Quick Style that is applied to the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .QuickStyle

expression A variable that represents a CommandButton object.

Remarks

The QuickStyle uses one of the values listed in the following table.

Value | Effect
0 (Default) | No Quick Style
1 | Colored Outline - Black, Dark 1
2 | Colored Outline - Ice Blue, Accent 1
3 | Colored Outline - Orange, Accent 2
4 | Colored Outline - Olive Green, Accent 3
5 | Colored Outline - Gold, Accent 4
6 | Colored Outline - Green, Accent 5
7 | Colored Outline - Gray-50%, Accent 6
8 | Colored Fill - Black, Dark 1
9 | Colored Fill - Ice Blue, Accent 1
10 | Colored Fill - Orange, Accent 2
11 | Colored Fill - Olive Green, Accent 3
12 | Colored Fill - Gold, Accent 4
13 | Colored Fill - Green, Accent 5
14 | Colored Fill - Gray-50%, Accent 6
15 | Light 1 Outline, Colored Fill - Black, Dark 1
16 | Light 1 Outline, Colored Fill - Ice Blue, Accent 1
17 | Light 1 Outline, Colored Fill - Orange, Accent 2
18 | Light 1 Outline, Colored Fill - Olive Green, Accent 3
19 | Light 1 Outline, Colored Fill - Gold, Accent 4
10 | Light 1 Outline, Colored Fill - Green, Accent 5
21 | Light 1 Outline, Colored Fill - Gray-50%, Accent 6
22 | Subtle Effect - Black, Dark 1
23 | Subtle Effect - Ice Blue, Accent 1
24 | Subtle Effect - Orange, Accent 2
25 | Subtle Effect - Olive Green, Accent 3
26 | Subtle Effect - Gold, Accent 4
27 | Subtle Effect - Green, Accent 5
28 | Subtle Effect - Gray-50%, Accent 6
29 | Moderate Effect - Black, Dark 1
30 | Moderate Effect - Ice Blue, Accent 1
31 | Moderate Effect - Orange, Accent 2
32 | Moderate Effect - Olive Green, Accent 3
33 | Moderate Effect - Gold, Accent 4
34 | Moderate Effect - Green, Accent 5
35 | Moderate Effect - Gray-50%, Accent 6
36 | Intense Effect - Black, Dark 1
37 | Intense Effect - Ice Blue, Accent 1
38 | Intense Effect - Orange, Accent 2
39 | Intense Effect - Olive Green, Accent 3
40 | Intense Effect - Gold, Accent 4
41 | Intense Effect - Green, Accent 5
42 | Intense Effect - Gray-50%, Accent 6

To see the available Quick Styles and apply a Quick Style through the user interface, first open the form or report in Layout view or Design view by right-clicking the form or report in the Navigation Pane, and then clicking the view you want. Then, click the object to which you want to apply a shadow effect. Next, on the Format tab, in the Control Formatting group, click Quick Styles and choose a Quick Style. Notice that the Quick Styles are indexed from left to right, and then top to bottom. So the first item,Colored Outline - Black, Dark 1, has the value 1. The first row contains Quick Styles with values from 1 to 7. The second row from 8 to 14, and so on.

This property is not surfaced in the property sheet.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ToggleButton.Gradient Property (Access)

 Copy code hover
[image]

ToggleButton.Gradient Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the gradient fill applied to the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .Gradient

expression A variable that represents a ToggleButton object.

Remarks

The Gradient property contains a numeric expression that represents the gradient fill applied to the specified object. The default value of the Gradient property is 0, which does not apply a gradient. The values are listed in the following table.

Value | Gradient Fill
0 | None
1 | Linear Diagonal - Top Left to Bottom Right, Light
2 | Linear Down, Light
3 | Linear Diagonal - Top Right to Bottom Left, Light
4 | From Bottom Right Corner, Light
5 | From Bottom Left Corner, Light
6 | Linear Left, Light
7 | Linear Center, Light
8 | Linear Right, Light
9 | From Top Right Corner, Light
10 | From Top Left Corner, Light
11 | Linear Diagonal - Bottom Left to Top Right, Light
12 | Linear Up, Light
13 | Linear Diagonal - Bottom Right to Top Left, Light
14 | Linear Diagonal - Top Left to Bottom Right, Dark
15 | Linear Down, Dark
16 | Linear Diagonal - Top Right to Bottom Left, Dark
17 | From Bottom Right Corner, Dark
18 | From Bottom Left Corner, Dark
19 | Linear Left, Dark
20 | Linear Center, Dark
21 | Linear Right, Dark
22 | From Top Right Corner, Dark
23 | From Top Left Corner, Dark
24 | Linear Diagonal - Bottom Left to Top Right, Dark
25 | Linear Up, Dark
26 | Linear Diagonal - Bottom Right to Top Left, Light

To see the available gradient fills and apply a gradient through the user interface, first open the form or report in Layout view or Design view by right-clicking the form or report in the Navigation Pane, and then clicking the view you want. Then, click the object to which you want to apply a gradient fill. Next, on the Format tab, in the Control Formatting group, click Shape Fill, then click Gradient and choose a gradient fill. You can hover over a gradient fill to see a description.

This property is not surfaced in the property sheet.

Example

The following code example sets the gradient fill to Linear Down, Light.

VBA Copy code Copy code
Me.ctl.Gradient = 2

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


References Object (Access)

 Copy code hover
[image]

References Object (Access)
See also Send feedback

Published: July 16, 2012

The References collection contains Reference objects representing each reference that's currently set.

Remarks

The Reference objects in the References collection correspond to the list of references in the References dialog box, available by clicking References on the Tools menu. Each Reference object represents one selected reference in the list. References that appear in the References dialog box but haven't been selected aren't in the References collection.

You can enumerate through the References collection by using the For Each...Next statement.

The References collection belongs to the Microsoft Access Application object.

Individual Reference objects in the References collection are indexed beginning with 1.

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Display List of References - Both Good and Broken

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Access Object Model Reference

Other resources

References Object Members


OptionGroup.ValidationRule Property (Access)

 Copy code hover
[image]

OptionGroup.ValidationRule Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.

Syntax

expression .ValidationRule

expression A variable that represents an OptionGroup object.

Remarks

Enter an expression for the ValidationRule property setting and text for the ValidationText property setting. The maximum length for the ValidationRule property setting is 2048 characters. The maximum length for the ValidationText property setting is 255 characters.

For controls, you can set the ValidationRule property to any valid expression. For field and record validation rules, the expression can't contain user-defined functions, domain aggregate or aggregate functions, the Eval function, or CurrentUser method, or references to forms, queries, or tables. In addition, field validation rules can't contain references to other fields. For records, expressions can include references to fields in that table.

For table fields and records, you can also set these properties in Visual Basic by using the DAO ValidationRule property.

Note Note

The ValidationRule and ValidationText properties don't apply to check box, option button, or toggle buttoncontrols when they are in an option group. They apply only to the option group itself.

Microsoft Access automatically validates values based on a field's data type; for example, Microsoft Access doesn't allow text in a numeric field. You can set rules that are more specific by using the ValidationRule property.

If you set the ValidationRule property but not the ValidationText property, Microsoft Access displays a standard error message when the validation rule is violated. If you set the ValidationText property, the text you enter is displayed as the error message.

For example, when a record is added for a new employee, you can enter a ValidationRule property requiring that the value in the employee's StartDate field fall between the company's founding date and the current date. If the date entered isn't in this range, you can display the ValidationText property message: "Start date is incorrect."

If you create a control by dragging a field from the field list, the field's validation rule remains in effect, although it isn't displayed in the control's ValidationRule property box in the property sheet. This is because a field's validation rule is inherited by a control bound to that field.

Control, field, and record validation rules are applied as follows:

  • Validation rules you set for fields and controls are applied when you edit the data and the focus leaves the field or control.

  • Validation rules for records are applied when you move to another record.

  • If you create validation rules for both a field and a control bound to the field, both validation rules are applied when you edit data and the focus leaves the control.

The following table contains expression examples for the ValidationRule and ValidationText properties.

ValidationRule property | ValidationText property
<> 0 | Entry must be a nonzero value.
> 1000 Or Is Null | Entry must be blank or greater than 1000.
Like "A????" | Entry must be 5 characters and begin with the letter "A".
>= #1/1/96# And <#1/1/97# | Entry must be a date in 1996.
DLookup("CustomerID", "Customers", "CustomerID = Forms!Customers!CustomerID") Is Null | Entry must be a unique CustomerID (domain aggregate functions are allowed only for form-level validation).

If you create a validation rule for a field, Microsoft Access doesn't normally allow a Null value to be stored in the field. If you want to allow a Null value, add "Is Null" to the validation rule, as in "<> 8 Or Is Null" and make sure the Required property is set to No.

You can't set field or record validation rules for tables created outside Microsoft Access (for example, dBASE, Paradox, or SQL Server). For these kinds of tables, you can create validation rules for controls only.

Example

The following example creates a validation rule for a field that allows only values over 65 to be entered. If a number less than 65 is entered, a message is displayed. The properties are set by using the SetFieldValidation function.

VBA Copy code Copy code
Dim strTblName As String, strFldName As String
Dim strValidRule As String
Dim strValidText As String, intX As Integer

strTblName = "Customers"
strFldName = "Age"
strValidRule = ">= 65"
strValidText = "Enter a number greater than or equal to 65."
intX = SetFieldValidation(strTblName, strFldName, _
 strValidRule, strValidText)

Function SetFieldValidation(strTblName As String, _
 strFldName As String, strValidRule As String, _
 strValidText As String) As Integer

 Dim dbs As Database, tdf As TableDef, fld As Field

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 Set fld = tdf.Fields(strFldName)
 fld.ValidationRule = strValidRule
 fld.ValidationText = strValidText
End Function

The next example uses the SetTableValidation function to set record-level validation to ensure that the value in the EndDate field comes after the value in the StartDate field.

VBA Copy code Copy code
Dim strTblName As String, strValidRule As String
Dim strValidText As String
Dim intX As Integer

strTblName = "Employees"
strValidRule = "EndDate > StartDate"
strValidText = "Enter an EndDate that is later than the StartDate."
intX = SetTableValidation(strTblName, strValidRule, strValidText)

Function SetTableValidation(strTblName As String, _
 strValidRule As String, strValidText As String) _
 As Integer

 Dim dbs As Database, tdf As TableDef

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 tdf.ValidationRule = strValidRule
 tdf.ValidationText = strValidText
End Function

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


NavigationControl.OnKeyUp Property (Access)

 Copy code hover
[image]

NavigationControl.OnKeyUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Up box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnKeyUp

expression A variable that represents a NavigationControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyUp event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyUp

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


DependencyInfo.Parent Property (Access)

 Copy code hover
[image]

DependencyInfo.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a DependencyInfo object.

See also

Concepts

DependencyInfo Object

Other resources

DependencyInfo Object Members


DataControl Object (RDS)

 Copy code hover
[image]

DataControl Object (RDS)
Send feedback

Binds a data query Recordset to one or more controls (for example, a text box, grid control, or combo box) to display the Recordset data on a Web page.

Syntax

Copy code Copy code
<OBJECT CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID="DataControl"
   <PARAM NAME="Connect" VALUE="DSN=DSNName;UID=usr;PWD=pw;">
   <PARAM NAME="Server" VALUE="http://awebsrvr">
   <PARAM NAME="SQL" VALUE="QueryText">
</OBJECT>

Remarks

The class ID for the RDS.DataControl object is BD96C556-65A3-11D0-983A-00C04FC29E33.

Note Note

If you get an error that an RDS.DataSpace or RDS.DataControl object doesn't load, make sure you are using the correct class ID. The class IDs for these objects have changed from version 1.0 and 1.1.

For a basic scenario, you need to set only the SQL, Connect, and Server properties of the RDS.DataControl object, which will automatically call the default business object, RDSServer.DataFactory.

All the properties in the RDS.DataControl are optional because custom business objects can replace their functionality.

Note Note

If you query for multiple results, only the first Recordset is returned. If multiple result sets are needed, assign each to its own DataControl. An example of a query for multiple results could be the following:
"Select * from Authors, Select * from Topics"

Adding "DFMode=20;" to your connection string when using the RDS.DataControl object can improve your server's performance when updating data. With this setting, the RDSServer.DataFactory object on the server uses a less resource-intensive mode. However, the following features are not available in this configuration:

  • Using parameterized queries.

  • Getting parameter or column information before calling the Execute method.

  • Setting Transact Updates to True.

  • Getting row status.

  • Calling the Resync method.

  • Refreshing (explicitly or automatically) via the Update Resync property.

  • Setting Command or Recordset properties.

  • Using adCmdTableDirect.

The RDS.DataControl object runs in asynchronous mode by default. If you require synchronous execution for your application, set the ExecuteOptions parameter equal to adcExecSync and the FetchOptions parameter equal to adcFetchUpFront, as shown in the following example.

Copy code Copy code
<OBJECT CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
    ID="DataControl"
   <PARAM NAME="Connect" VALUE="DSN=DSNName;UID=usr;PWD=pw;">
   <PARAM NAME="Server" VALUE="http://awebsrvr">
   <PARAM NAME="SQL" VALUE="QueryText">
   <PARAM NAME="ExecuteOptions" VALUE="1">
   <PARAM NAME="FetchOptions" VALUE="1">
</OBJECT>

Use one RDS.DataControl object to link the results of a single query to one or more visual controls. For example, suppose you code a query requesting customer data such as Name, Residence, Place of Birth, Age, and Priority Customer Status. You can use a single RDS.DataControl object to display a customer's Name, Age, and Region in three separate text boxes; Priority Customer Status in a check box; and all the data in a grid control.

Use different RDS.DataControl objects to link the results of multiple queries to different visual controls. For example, suppose you use one query to obtain information about a customer, and a second query to obtain information about merchandise that the customer has purchased. You want to display the results of the first query in three text boxes and one check box, and the results of the second query in a grid control. If you use the default business object (RDSServer.DataFactory), you need to do the following:

  • Add two RDS.DataControl objects to your Web page.

  • Write two queries, one for each SQL property of the two RDS.DataControl objects. One RDS.DataControl object will contain an SQL query requesting customer information; the second will contain a query requesting a list of merchandise the customer has purchased.

  • In each of the bound controls' OBJECT tags, specify the DATAFLD value to set the values for the data you want to display in each visual control.

There is no count restriction on the number of RDS.DataControl objects that you can embed via OBJECT tags on a single Web page.

When you define the RDS.DataControl object on a Web page, use nonzero Height and Width values such as 1 (to avoid the inclusion of extra space).

Remote Data Service client components are already included as part of Internet Explorer 4.0; therefore, you don't need to include a CODEBASE parameter in your RDS.DataControl object tag.

With Internet Explorer 4.0 or later, you can bind to data by using HTML controls and ActiveX® controls only if they are marked as apartment model controls.

Microsoft Visual Basic UsersThe RDS.DataControl is used only in Web-based applications. A Visual Basic client application has no need for it.


WebBrowserControl.RightPadding Property (Access)

 Copy code hover
[image]

WebBrowserControl.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .RightPadding

expression A variable that represents a WebBrowserControl object.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


CustomControl.BorderWidth Property (Access)

 Copy code hover
[image]

CustomControl.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Syntax

expression .BorderWidth

expression A variable that represents a CustomControl object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


ADO MD Enumerated Constants Reference

 Copy code hover
[image]

ADO MD Enumerated Constants Reference
Send feedback

In this section

  • ADO MD Enumerated Constants

  • MemberTypeEnum


NavigationButton.OnMouseMove Property (Access)

 Copy code hover
[image]

NavigationButton.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnMouseMove

expression A variable that represents a NavigationButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Recordset Properties, Methods, and Events (ADO)

 Copy code hover
[image]

Recordset Properties, Methods, and Events (ADO)
Send feedback

Properties/Collections

AbsolutePage Property

AbsolutePosition Property

ActiveCommand Property

ActiveConnection Property

BOF, EOF Properties

Bookmark Property

CacheSize Property

CursorLocation Property

CursorType Property

DataMember Property

DataSource Property

EditMode Property

Fields Collection

Filter Property

Index Property

LockType Property

MarshalOptions Property

MaxRecords Property

PageCount Property

PageSize Property

Properties Collection

RecordCount Property

Sort Property

Source Property (ADO Recordset)

State Property

Status Property (ADO Recordset)

StayInSync Property

Methods

AddNew Method

Cancel Method

CancelBatch Method

CancelUpdate Method

Clone Method

Close Method

CompareBookmarks Method

Delete Method (ADO Recordset)

Find Method

GetRows Method

GetString Method

Move Method

MoveFirst, MoveLast, MoveNext, and MovePrevious Methods

NextRecordset Method

Open Method (ADO Recordset)

Requery Method

Resync Method

Save Method

Seek Method

Supports Method

Update Method

UpdateBatch Method

Events

EndOfRecordset Event

FetchComplete Event

FetchProgress Event

WillChangeField and FieldChangeComplete Events

WillChangeRecord and RecordChangeComplete Events

WillChangeRecordset and RecordsetChangeComplete Events

WillMove and MoveComplete Events


Invalid SQL Syntax: expected token: AS (Error 3728)

 Copy code hover
[image]

Invalid SQL Syntax: expected token: AS (Error 3728)
Send feedback

This error occurs when defining or creating a view or procedure through SQL DDL. The error would be generated with the following syntax: CREATE VIEW viewname SELECT…. To avoid the error, change the syntax to the following: CREATE VIEW viewname AS SELECT….


OptionButton.Requery Method (Access)

 Copy code hover
[image]

OptionButton.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.

Syntax

expression .Requery

expression A variable that represents an OptionButton object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts .

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate function.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

Example

The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form:

VBA Copy code Copy code
Public Sub RequeryList()

    Dim ctlCombo As Control

    ' Return Control object pointing to a combo box.
    Set ctlCombo = Forms!Employees!ReportsTo

    ' Requery source of data for list box.
    ctlCombo.Requery

End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


SubForm.GridlineThemeColorIndex Property (Access)

 Copy code hover
[image]

SubForm.GridlineThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineThemeColorIndex

expression A variable that represents a SubForm object.

Remarks

The GridlineThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 (Default) | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the GridlineThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Appendix A: Providers (ADO)

 Copy code hover
[image]

Appendix A: Providers (ADO)
Send feedback

In this section

  • Appendix A: Providers

  • Microsoft OLE DB Provider for ODBC

  • Microsoft OLE DB Provider for Microsoft Indexing Service

  • Microsoft OLE DB Provider for Microsoft Active Directory Service

  • Microsoft OLE DB Provider for Microsoft Jet

  • Microsoft OLE DB Provider for Oracle

  • Microsoft OLE DB Provider for SQL Server

  • Microsoft OLE DB Provider for Internet Publishing

  • Microsoft Data Shaping Service for OLE DB (ADO Service Provider)

  • Microsoft OLE DB Persistence Provider (ADO Service Provider)

  • Microsoft OLE DB Remoting Provider (ADO Service Provider)

  • Microsoft Cursor Service for OLE DB (ADO Service Component)


Date/time functions (Access 2013 custom web app)

 Copy code hover
[image]

Date/time functions (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • DateAdd Function (Access 2013 custom web app)

  • DateDiff Function (Access 2013 custom web app)

  • DateFromParts Function (Access 2013 custom web app)

  • DatePart Function (Access 2013 custom web app)

  • Day Function (Access 2013 custom web app)

  • EOMonth Function (Access 2013 custom web app)

  • Month Function (Access 2013 custom web app)

  • Now Function (Access 2013 custom web app)

  • Today Function (Access 2013 custom web app)

  • Year Function (Access 2013 custom web app)


TextBox.OnMouseUp Property (Access)

 Copy code hover
[image]

TextBox.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Syntax

expression .OnMouseUp

expression A variable that represents a TextBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Section Methods (Access)

 Copy code hover
[image]

Section Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
SetTabOrder | Resets the tab order of the controls in the specified Section to their default values.


SmartTag.Application Property (Access)

 Copy code hover
[image]

SmartTag.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a SmartTag object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

SmartTag Object

Other resources

SmartTag Object Members


Appendix C: Programming with ADO

 Copy code hover
[image]

Appendix C: Programming with ADO
Send feedback

ADO is a COM automation interface component that can be used with many programming languages, including Microsoft Visual Basic, VBScript, JScript, Visual C++, and Visual J++. A version of ADO is installed with each of these tools and other applications, such as Microsoft Office and Microsoft SQL Server. See the Data Platform Developer Center for more information.

The library for ADO is msado15.dll and the program ID (ProgID) prefix is "ADODB." For example, to explicitly refer to an ADO Recordset, use .

For more information about programming with ADO in various development environments, see the following topics:

  • Using ADO with Microsoft Visual Basic

  • Using ADO with Scripting Languages

  • Using ADO with Microsoft Visual C++

  • Using ADO with Microsoft Visual J++


Form.Moveable Property (Access)

 Copy code hover
[image]

Form.Moveable Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Boolean indicating whether the specified form can be moved by the user; True if it can be moved. Read/write.

Syntax

expression .Moveable

expression A variable that represents a Form object.

Remarks

You can use the Move method to programmatically move a form or report regardless of the value of the Moveable property.

Example

The following example determines whether or not the first form in the current project can be moved.

VBA Copy code Copy code
If Forms(0).Moveable Then
 MsgBox "You may move the form."
Else
 MsgBox "The form cannot be moved."
End If

See also

Concepts

Form Object

Other resources

Form Object Members


CurrentProject Properties (Access)

 Copy code hover
[image]

CurrentProject Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
AccessConnection | You can use the AccessConnection property to return a reference to the current Microsoft ActiveX Data Objects (ADO) Connection object and its related properties. Read-only Connection.
AllForms | You can use the AllForms property to reference the AllForms collection and its related properties. Read-only AllForms object.
AllMacros | You can use the AllMacros property to reference the AllMacros collection and its related properties. Read-only AllMacros object.
AllModules | You can use the AllModules property to reference the AllModules collection and its related properties. Read-only AllModules object.
AllReports | You can use the AllReports property to reference the AllReports collection and its related properties. Read-only AllReports object.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BaseConnectionString | You can use the BaseConnectionString property to return the base connection string for the specified object. Read-only String.
Connection | You can use the Connection property to return a reference to the current ActiveX Data Objects (ADO) Connection object and its related properties. Read-only Connection.
FileFormat | Returns an AcFileFormat constant indicating the Microsoft Access version format of the specified project. Read-only.
FullName | Sets or returns the full path (including file name) of a specific object. Read-only String.
ImportExportSpecifications | Returns a ImportExportSpecifications collection that represents the collection of saved import or export operations for the specified object. Read-only.
IsConnected | You can use the IsConnected property to determine if the CurrentProject object is currently connected. Read-only Boolean.
IsTrusted | Gets whether or not macros and Visual Basic for Applications (VBA) code have been enabled in the current project. Read-only Boolean.
IsWeb | Gets whether the database is a Web database. Read-only Boolean.
Name | You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.
Parent | Returns the parent object for the specified object. Read-only.
Path | You can use the Path property to determine the location where data is stored for a Microsoft Access project (.adp) or Microsoft Access database. Read-only String.
ProjectType | You can use the ProjectType property to determine the type of project that is currently open. Read-only AcProjectType.
Properties | Returns a reference to a CurrentProject object's AccessObjectProperties collection. Read-only.
RemovePersonalInformation | Returns or sets a Boolean indicating whether personal information about the user is stored in the specified project. True if personal information is removed. Read-write.
Resources | Gets the SharedResources collection for the specified object. Read-only SharedResources.
WebSite | Gets the Uniform Resource Locator (URL) of the Web site to which the database has been published. Read-only String.


Attributes and Name Properties Example (VJ++)

 Copy code hover
[image]

Attributes and Name Properties Example (VJ++)
Send feedback

This example displays the value of the Attributes property for Connection, Field, and Property objects. It uses the Name property to display the name of each Field and Property object.

Copy code Copy code

// BeginAttributesJ
import com.ms.wfc.data.*;
import java.io.*;

public class AttributesX
{
 // The main entry point for the application
 public static void main (String[] args)
 {
 AttributesX();
 System.exit(0);
 }

 // AttributeX Function

 static void AttributesX()
 {
 // Define ADO Objects.
 Connection cnConn1 = null;
 Recordset rstEmployees = null;
 Fields listOfFields = null;
 AdoProperties listOfProperties = null;

 //Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String line = null;
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";
 int recordDisplaySize = 15;
 int propertyCount = 0;
 try
 {
 // Open connection and recordset.
 cnConn1 = new Connection();
 cnConn1.open(strCnn);

 rstEmployees = new Recordset ();
 rstEmployees.open("employee",
 cnConn1,AdoEnums.CursorType.FORWARDONLY,
 AdoEnums.LockType.READONLY, AdoEnums.CommandType.TABLE);

 // Display the attributes of the connection.
 System.out.println("Connection attributes = "
 + cnConn1.getAttributes());
 // Display the attributes of the Employees table's fields.
 System.out.println("\n\nField attributes : " + "\n");

 listOfFields = rstEmployees.getFields();

 for ( int i=0; i < listOfFields.getCount();i++)
 {
 System.out.println("\t\t" + listOfFields.getItem(i).getName()
 + " = " + listOfFields.getItem(i).getAttributes());
 }

 // Display fields of the Employees table which are NULLABLE.
 System.out.println("\n\nNULLABLE Fields : " + "\n");
 for ( int i=0; i < listOfFields.getCount();i++)
 {
 if ((listOfFields.getItem(i).getAttributes() &
 AdoEnums.FieldAttribute.ISNULLABLE) > 0)
 System.out.println("\t\t" +
 listOfFields.getItem(i).getName());

 }

 System.out.println ("\n\nPress <Enter> key to continue..");
 line = in.readLine();

 // Display the attributes of the Employees table's properties.
 System.out.println("\n\nProperty attributes : " );
 listOfProperties = rstEmployees.getProperties();
 for ( int i=0; i < listOfProperties.getCount() ;i++)
 {
 System.out.println("\t\t" +
 listOfProperties.getItem(i).getName()
 + " = " + listOfProperties.getItem(i).getAttributes());

 if (propertyCount == recordDisplaySize)
 {
 System.out.println ("\n\nPress <Enter> key to continue.");
 line = in.readLine();
 propertyCount = 0;
 }
 propertyCount++;
 }

 System.out.println ("\n\nPress <Enter> key to continue.");
 line = in.readLine();
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // Check for null pointer for connection object.
 if (rstEmployees.getActiveConnection()==null)
 System.out.println("Exception: " + ae.getMessage());

 // As passing a Recordset, check for null pointer first.

 if (rstEmployees != null)
 {
 PrintProviderError(rstEmployees.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstEmployees != null)
 if (rstEmployees.getState() == 1)
 rstEmployees.close();
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 //.PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}

// EndAttributesJ


Reference.Collection Property (Access)

 Copy code hover
[image]

Reference.Collection Property (Access)
See also Send feedback

Published: July 16, 2012

The Collection property returns a reference to the collection that contains an object. Read-only References object.

Syntax

expression .Collection

expression A variable that represents a Reference object.

Remarks

You can use the Collection property to access the collection to which an object belongs. For example, the Collection property of a Reference object returns an object reference to the References collection.

The Collection property is similar to the Parent property.

See also

Concepts

Reference Object

Other resources

Reference Object Members


QueryDef.Execute Method (DAO)

 Copy code hover
[image]

QueryDef.Execute Method (DAO)
Send feedback

Executes an SQL statement on the specified object.

Syntax

expression .Execute(Options)

expression A variable that represents a QueryDef object.

Parameters

Name | Required/Optional | Data Type | Description
Options | Optional | Variant |

Remarks

You can use the following RecordsetOptionEnum constants for Options.

Constant | Description
dbDenyWrite | Denies write permission to other users (Microsoft Access workspaces only).
dbInconsistent | (Default) Executes inconsistent updates (Microsoft Access workspaces only).
dbConsistent | Executes consistent updates (Microsoft Access workspaces only).
dbSQLPassThrough | Executes an SQL pass-through query. Setting this option passes the SQL statement to an ODBC database for processing (Microsoft Access workspaces only).
dbFailOnError | Rolls back updates if an error occurs (Microsoft Access workspaces only).
dbSeeChanges | Generates a run-time error if another user is changing data you are editing (Microsoft Access workspaces only).
dbRunAsync | Executes the query asynchronously (ODBCDirect Connection and QueryDef objects only).
dbExecDirect | Executes the statement without first calling SQLPrepare ODBC API function (ODBCDirect Connection and QueryDef objects only).
Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Note Note

The constants dbConsistent and dbInconsistent are mutually exclusive. You can use one or the other, but not both in a given instance of OpenRecordset. Using both dbConsistent and dbInconsistent causes an error.

Use the RecordsAffected property of the Connection, Database, or QueryDef object to determine the number of records affected by the most recent Execute method. For example, RecordsAffected contains the number of records deleted, updated, or inserted when executing an action query. When you use the Execute method to run a query, the RecordsAffected property of the QueryDef object is set to the number of records affected.

In a Microsoft Access workspace, if you provide a syntactically correct SQL statement and have the appropriate permissions, the Execute method won't fail — even if not a single row can be modified or deleted. Therefore, always use the dbFailOnError option when using the Execute method to run an update or delete query. This option generates a run-time error and rolls back all successful changes if any of the records affected are locked and can't be updated or deleted.

In earlier versions of the Microsoft Jet database engine, SQL statements were automatically embedded in implicit transactions. If part of a statement executed with dbFailOnError failed, the entire statement would be rolled back. To improve performance, these implicit transactions were removed starting with version 3.5. If you are updating older DAO code, be sure to consider using explicit transactions around Execute statements.

For best performance in a Microsoft Access workspace, especially in a multiuser environment, nest the Execute method inside a transaction. Use the BeginTrans method on the current Workspace object, then use the Execute method, and complete the transaction by using the CommitTrans method on the Workspace. This saves changes on disk and frees any locks placed while the query is running.

Example

This example demonstrates the Execute method when run from both a QueryDef object and a Database object. The ExecuteQueryDef and PrintOutput procedures are required for this procedure to run.

VBA Copy code Copy code
Sub ExecuteX()

   Dim dbsNorthwind As Database
   Dim strSQLChange As String
   Dim strSQLRestore As String
   Dim qdfChange As QueryDef
   Dim rstEmployees As Recordset
   Dim errLoop As Error

   ' Define two SQL statements for action queries.
   strSQLChange = "UPDATE Employees SET Country = " & _
      "'United States' WHERE Country = 'USA'"
   strSQLRestore = "UPDATE Employees SET Country = " & _
      "'USA' WHERE Country = 'United States'"

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   ' Create temporary QueryDef object.
   Set qdfChange = dbsNorthwind.CreateQueryDef("", _
      strSQLChange)
   Set rstEmployees = dbsNorthwind.OpenRecordset( _
      "SELECT LastName, Country FROM Employees", _
      dbOpenForwardOnly)

   ' Print report of original data.
   Debug.Print _
      "Data in Employees table before executing the query"
   PrintOutput rstEmployees

   ' Run temporary QueryDef.
   ExecuteQueryDef qdfChange, rstEmployees

   ' Print report of new data.
   Debug.Print _
      "Data in Employees table after executing the query"
   PrintOutput rstEmployees

   ' Run action query to restore data. Trap for errors,
   ' checking the Errors collection if necessary.
   On Error GoTo Err_Execute
   dbsNorthwind.Execute strSQLRestore, dbFailOnError
   On Error GoTo 0

   ' Retrieve the current data by requerying the recordset.
   rstEmployees.Requery

   ' Print report of restored data.
   Debug.Print "Data after executing the query " & _
      "to restore the original information"
   PrintOutput rstEmployees

   rstEmployees.Close

   Exit Sub

Err_Execute:

   ' Notify user of any errors that result from
   ' executing the query.
   If DBEngine.Errors.Count > 0 Then
      For Each errLoop In DBEngine.Errors
         MsgBox "Error number: " & errLoop.Number & vbCr & _
            errLoop.Description
      Next errLoop
   End If

   Resume Next

End Sub

Sub ExecuteQueryDef(qdfTemp As QueryDef, _
   rstTemp As Recordset)

   Dim errLoop As Error

   ' Run the specified QueryDef object. Trap for errors,
   ' checking the Errors collection if necessary.
   On Error GoTo Err_Execute
   qdfTemp.Execute dbFailOnError
   On Error GoTo 0

   ' Retrieve the current data by requerying the recordset.
   rstTemp.Requery

   Exit Sub

Err_Execute:

   ' Notify user of any errors that result from
   ' executing the query.
   If DBEngine.Errors.Count > 0 Then
      For Each errLoop In DBEngine.Errors
         MsgBox "Error number: " & errLoop.Number & vbCr & _
            errLoop.Description
      Next errLoop
   End If

   Resume Next

End Sub

Sub PrintOutput(rstTemp As Recordset)

   ' Enumerate Recordset.
   Do While Not rstTemp.EOF
      Debug.Print "  " & rstTemp!LastName & _
         ", " & rstTemp!Country
      rstTemp.MoveNext
   Loop

End Sub

The following example shows how to execute a parameter query. The Parameters collection is used to set the Organization parameter of the myActionQuery query before the query is executed.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Public Sub ExecParameterQuery()

    Dim dbs As DAO.Database
    Dim qdf As DAO.QueryDef

    Set dbs = CurrentDb
    Set qdf = dbs.QueryDefs("myActionQuery")

    'Set the value of the QueryDef's parameter
    qdf.Parameters("Organization").Value = "Microsoft"

    'Execute the query
    qdf.Execute dbFailOnError

    'Clean up
    qdf.Close
    Set qdf = Nothing
    Set dbs = Nothing

End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


OptionGroup.Undo Method (Access)

 Copy code hover
[image]

OptionGroup.Undo Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the Undo method to reset a control or form when its value has been changed.

Syntax

expression .Undo

expression A variable that represents an OptionGroup object.

Remarks

For example, you can use the Undo method to clear a change to a record that contains an invalid entry.

If the Undo method is applied to a form, all changes to the current record are lost. If the Undo method is applied to a control, only the control itself is affected.

This method must be applied before the form or control is updated. You may want to include this method in a form's BeforeUpdate event or in a control's Change event.

The Undo method offers an alternative to using the SendKeys statement to send the value of the ESC key in an event procedure.

Example

The following example shows how you can use the Undo method within a control's Change event procedure to force a field named LastName to reset to its original value, if it changed.

VBA Copy code Copy code
Private Sub LastName_Change()
 Me!LastName.Undo
End Sub

The next example uses the Undo method to reset all changes to a form before the form is updated.

VBA Copy code Copy code
Private Sub Form_BeforeUpdate(Cancel As Integer)
 Me.Undo
End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Column Object (ADOX)

 Copy code hover
[image]

Column Object (ADOX)
Send feedback

Represents a column from a table, index, or key.

Remarks

The following code creates a new Column:

Copy code Copy code
Dim obj As New Column

With the properties and collections of a Column object, you can:

  • Identify the column with the Name property.

  • Specify the data type of the column with the Type property.

  • Determine if the column is fixed-length, or if it can contain null values with the Attributes property.

  • Specify the maximum size of the column with the DefinedSize property.

  • For numeric data values, specify the scale with the NumericScale property.

  • For numeric data value, specify the maximum precision with the Precision property.

  • Specify the Catalog that owns the column with the ParentCatalog property.

  • For key columns, specify the name of the related column in the related table with the RelatedColumn property.

  • For index columns, specify whether the sort order is ascending or descending with the SortOrder property.

  • Access provider-specific properties with the Properties collection.

Note Note

Not all properties of Column objects may be supported by your data provider. An error will occur if you have set a value for a property that the provider does not support. For new Column objects, the error will occur when the object is appended to the collection. For existing objects, the error will occur when setting the property.

When creating Column objects, the existence of an appropriate default value for an optional property does not guarantee that your provider supports the property. For more information about which properties your provider supports, see your provider documentation.


WebService.Entities Property (Access)

 Copy code hover
[image]

WebService.Entities Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the collection of entities defined for the spcified Data Service data connection. Read-only Entities.

Version Information

Version Added: Access 2010

Syntax

expression .Entities

expression A variable that represents a WebService object.

See also

Concepts

WebService Object

Other resources

WebService Object Members


ComboBox.BorderStyle Property (Access)

 Copy code hover
[image]

ComboBox.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Syntax

expression .BorderStyle

expression A variable that represents a ComboBox object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Shape Commands in General

 Copy code hover
[image]

Shape Commands in General
Send feedback

Data shaping defines the columns of a shaped Recordset, the relationships between the entities represented by the columns, and the manner in which the Recordset is populated with data.

A shaped Recordset may consist of the following types of columns.

Column type | Description
data | Fields from a Recordset returned by a query command to a data provider, table, or previously shaped Recordset.
chapter | A reference to another Recordset, called a chapter. Chapter columns make it possible to define a parent-child relationship where the parent is the Recordset containing the chapter column and the child is the Recordset represented by the chapter.
aggregate | The value of the column is derived by executing an aggregate function on all the rows or a column of all the rows of a child Recordset. (See Aggregate Functions in the following topic, Aggregate Functions, the CALC Function, and the NEW Keyword.)
calculated expression | The value of the column is derived by calculating a Visual Basic for Applications expression on columns in the same row of the Recordset. The expression is the argument to the CALC function. (See Calculated Expression in the following topic, Aggregate Functions, the CALC Function, and the NEW Keyword and in Visual Basic for Applications Functions.)
new | Empty, fabricated fields, which may be populated with data at a later time. The column is defined with the NEW keyword. (See NEW keyword in the following topic, Aggregate Functions, the CALC Function, and the NEW Keyword.)

A shape command may contain a clause specifying a query command to an underlying data provider that will return a Recordset object. The query's syntax depends on the requirements of the underlying data provider. This will usually be Structured Query Language (SQL), although ADO does not require the use of any particular query language.

You could use a SQL JOIN clause to relate two tables; however, a hierarchical Recordset may represent the information more efficiently. Each row of a Recordset created by a JOIN repeats information redundantly from one of the tables. A hierarchical Recordset has only one parent Recordset for each of multiple child Recordset objects.

Shape commands can be issued by Recordset objects or by setting the CommandText property of the Command object and then calling the Execute method.

Shape commands can be nested. That is, the parent-command or child-command may itself be another shape command.

The shape provider always returns a client cursor, even when the user specifies a cursor location of adUseServer.

For information about navigating a hierarchical Recordset, see Accessing Rows in a Hierarchical Recordset.

For precise information about syntactically correct shape commands, see Formal Shape Grammar.


Chapter 7: Handling ADO Events (ADO)

 Copy code hover
[image]

Chapter 7: Handling ADO Events (ADO)
Send feedback

In this section

  • Chapter 7: Handling ADO Events

  • ADO Event Handler Summary

  • Types of Events

  • Event Parameters

  • How Event Handlers Work Together

  • ADO Event Instantiation by Language (ADO)


BoundObjectFrame.Section Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Syntax

expression .Section

expression A variable that represents a BoundObjectFrame object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Application.DBEngine Property (Access)

 Copy code hover
[image]

Application.DBEngine Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DBEngine property in Visual Basic to access the current DBEngine object and its related properties. Read-only DBEngine.

Syntax

expression .DBEngine

expression A variable that represents an Application object.

Remarks

The DBEngine property of the Application object represents the Microsoft Access database engine. The DBEngine object is the top-level object in the Data Access Objects (DAO) model and it contains and controls all other objects in the hierarchy of Data Access Objects.

Example

The following example displays the DBEngine properties in a message box.

VBA Copy code Copy code
Private Sub Command1_Click()
 DisplayApplicationInfo Me
End Sub

Function DisplayApplicationInfo(obj As Object) As Integer
 Dim objApp As Object, intI As Integer, strProps As String
 On Error Resume Next
 ' Form Application property.
 Set objApp = obj.Application
 MsgBox "Application Visible property = " & objApp.Visible
 If objApp.UserControl = True Then
 For intI = 0 To objApp.DBEngine.Properties.Count - 1
 strProps = strProps & objApp.DBEngine.Properties(intI).Name & ", "
 Next intI
 End If
 MsgBox Left(strProps, Len(strProps) - 2) & ".", vbOK, "DBEngine Properties"
End Function

See also

Concepts

Application Object

Other resources

Application Object Members


Recordset2.Updatable Property (DAO)

 Copy code hover
[image]

Recordset2.Updatable Property (DAO)
Send feedback

Returns a value that indicates whether you can change a DAO object. Read-only Boolean.

Syntax

expression .Updatable

expression A variable that represents a Recordset2 object.

Remarks

Snapshot- and forward-only-type Recordset objects always return False.

Many types of objects can contain fields that can't be updated. For example, you can create a dynaset-type Recordset object in which only some fields can be changed. These fields can be fixed or contain data that increments automatically, or the dynaset can result from a query that combines updatable and nonupdatable tables.

If the object contains only read-only fields, the value of the Updatable property is False. When one or more fields are updatable, the property's value is True. You can edit only the updatable fields. A trappable error occurs if you try to assign a new value to a read-only field.

Because an updatable object can contain read-only fields, check the DataUpdatable property of each field in the Fields collection of a Recordset object before you edit a record.


Errors.Count Property (DAO)

 Copy code hover
[image]

Errors.Count Property (DAO)
Send feedback

Returns the number of objects in the specified collection. Read-only.

Syntax

expression .Count

expression A variable that represents an Errors object.

Remarks

Because members of a collection begin with 0, you should always code loops starting with the 0 member and ending with the value of the Count property minus 1. If you want to loop through the members of a collection without checking the Count property, you can use a For Each...Next command.

The Count property setting is never Null. If its value is 0, there are no objects in the collection.


SubForm.Properties Property (Access)

 Copy code hover
[image]

SubForm.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a SubForm object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Errors Collection Properties, Methods, and Events

 Copy code hover
[image]

Errors Collection Properties, Methods, and Events
Send feedback

Properties

Count Property

Item Property

Methods

Clear Method

Refresh Method

Events

None.


CurrentProject Members (Access)

 Copy code hover
[image]

CurrentProject Members (Access)
Send feedback

Published: July 16, 2012

The CurrentProject object refers to the project for the current Microsoft Access project (.adp) or Access database.

Methods

Name | Description
AddSharedImage | Imports the the specified image into the database and adds it to the SharedResources collection.
CloseConnection | You can use the CloseConnection method to close the current connection between the CurrentProject object in a Microsoft Access project (.adp) or Access database and the database specified in the project's base connection string.
OpenConnection | You can use the OpenConnection method to open an ADO connection to an existing Microsoft Access project (.adp) or Access database as the current Access project or database in the Microsoft Access window.
UpdateDependencyInfo | Updates the dependency information for the database.

Properties

Name | Description
AccessConnection | You can use the AccessConnection property to return a reference to the current Microsoft ActiveX Data Objects (ADO) Connection object and its related properties. Read-only Connection.
AllForms | You can use the AllForms property to reference the AllForms collection and its related properties. Read-only AllForms object.
AllMacros | You can use the AllMacros property to reference the AllMacros collection and its related properties. Read-only AllMacros object.
AllModules | You can use the AllModules property to reference the AllModules collection and its related properties. Read-only AllModules object.
AllReports | You can use the AllReports property to reference the AllReports collection and its related properties. Read-only AllReports object.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BaseConnectionString | You can use the BaseConnectionString property to return the base connection string for the specified object. Read-only String.
Connection | You can use the Connection property to return a reference to the current ActiveX Data Objects (ADO) Connection object and its related properties. Read-only Connection.
FileFormat | Returns an AcFileFormat constant indicating the Microsoft Access version format of the specified project. Read-only.
FullName | Sets or returns the full path (including file name) of a specific object. Read-only String.
ImportExportSpecifications | Returns a ImportExportSpecifications collection that represents the collection of saved import or export operations for the specified object. Read-only.
IsConnected | You can use the IsConnected property to determine if the CurrentProject object is currently connected. Read-only Boolean.
IsTrusted | Gets whether or not macros and Visual Basic for Applications (VBA) code have been enabled in the current project. Read-only Boolean.
IsWeb | Gets whether the database is a Web database. Read-only Boolean.
Name | You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.
Parent | Returns the parent object for the specified object. Read-only.
Path | You can use the Path property to determine the location where data is stored for a Microsoft Access project (.adp) or Microsoft Access database. Read-only String.
ProjectType | You can use the ProjectType property to determine the type of project that is currently open. Read-only AcProjectType.
Properties | Returns a reference to a CurrentProject object's AccessObjectProperties collection. Read-only.
RemovePersonalInformation | Returns or sets a Boolean indicating whether personal information about the user is stored in the specified project. True if personal information is removed. Read-write.
Resources | Gets the SharedResources collection for the specified object. Read-only SharedResources.
WebSite | Gets the Uniform Resource Locator (URL) of the Web site to which the database has been published. Read-only String.


WebBrowserControl.ScrollTop Property (Access)

 Copy code hover
[image]

WebBrowserControl.ScrollTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the distance, in pixels, between the top edge of the WebBrowser object and the topmost portion of the content currently visible in the control. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ScrollTop

expression A variable that represents a WebBrowserControl object.

Remarks

This property value equals the current horizontal offset of the content within the scrollable range. Although you can set this property to any value, if you assign a value less than 0, the property is set to 0. If you assign a value greater than the maximum value, the property is set to the maximum value.

This property is always 0 for objects that do not have scroll bars. For these objects, setting the property has no effect.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Unable to delete the specified Registry parameter for the Synchronizer. (Error 3551)

 Copy code hover
[image]

Unable to delete the specified Registry parameter for the Synchronizer. (Error 3551)
Send feedback

You need to reconfigure the Synchronizer on your computer.


Delete Method (ADO Fields Collection)

 Copy code hover
[image]

Delete Method (ADO Fields Collection)
Send feedback

Deletes an object from the Fields collection.

Syntax

Fields.Delete Field

Parameters

  • Field

  • A Variant that designates the Field object to delete. This parameter can be the name of the Field object or the ordinal position of the Field object itself.

Remarks

Calling the Fields.Delete method on an open Recordset causes a run-time error.


Recordset2.Name Property (DAO)

 Copy code hover
[image]

Recordset2.Name Property (DAO)
Send feedback

Returns the name of the specified object. Read-only String.

Syntax

expression .Name

expression A variable that represents a Recordset2 object.

Remarks

The Name property of a Recordset object opened by using an SQL statement is the first 256 characters of the SQL statement.


Properties Properties (Access)

 Copy code hover
[image]

Properties Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | Returns the number of objects in the specified collection. Read-only.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Object.
Parent | Returns the parent object for the specified object. Read-only.


OptionGroup.Value Property (Access)

 Copy code hover
[image]

OptionGroup.Value Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether or not the specified option button is selected. Read/write Variant.

Syntax

expression .Value

expression A variable that represents an OptionGroup object.

Remarks

Set the Value proprty to True to select the option button. The default value is False.

The Value property returns or sets a control's default property, which is the property that is assumed when you don't explicitly specify a property name.

Note Note

The Value property is not the same as the DefaultValue property, which specifies the value that a property is assigned when a new record is created.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


NavigationButton.AutoLabel Property (Access)

 Copy code hover
[image]

NavigationButton.AutoLabel Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .AutoLabel

expression A variable that represents a NavigationButton object.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


TextBox.Change Event (Access)

 Copy code hover
[image]

TextBox.Change Event (Access)
See also Send feedback

Published: July 16, 2012

The Change event occurs when the contents of the specified control changes.

Syntax

expression .Change

expression A variable that represents a TextBox object.

Remarks

Examples of this event include entering a character directly in the text box or combo box or changing the control's Text property setting by using a macro or Visual Basic.

Note Note

Setting the value of a control by using a macro or Visual Basic doesn't trigger this event for the control. You must type the data directly into the control, or set the control's Text property.

To run a macro or event procedure when this event occurs, set the OnChange property to the name of the macro or to [Event Procedure].

By running a macro or event procedure when a Change event occurs, you can coordinate data display among controls. You can also display data or a formula in one control and the results in another control.

The Change event doesn't occur when a value changes in a calculated control.

Note Note

A Change event can cause a cascading event. This occurs when a macro or event procedure that runs in response to the control's Change event alters the control's contents — for example, by changing a property setting that determines the control's value, such as the Text property for a text box. To prevent a cascading event:

  • If possible, avoid attaching a Change macro or event procedure to a control that alters the control's contents.

  • Avoid creating two or more controls having Change events that affect each other — for example, two text boxes that update each other.

Changing the data in a text box or combo box by using the keyboard causes keyboard events to occur in addition to control events like the Change event. For example, if you move to a new record and type an ANSI character in a text box in the record, the following events occur in this order:

KeyDown → KeyPress → BeforeInsert → Change → KeyUp

The BeforeUpdate and AfterUpdate events for the text box or combo box control occur after you have entered the new or changed data in the control and moved to another control (or clicked Save Record on the Records menu), and therefore after all of the Change events for the control.

In combo boxes for which the LimitToList property is set to Yes, the NotInList event occurs after you enter a value that isn't in the list and attempt to move to another control or save the record. It occurs after all the Change events for the combo box. In this case, the BeforeUpdate and AfterUpdate events for the combo box don't occur, because Microsoft Access doesn't accept a value that is not in the list.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


State Property (ADO)

 Copy code hover
[image]

State Property (ADO)
Send feedback

Indicates for all applicable objects whether the state of the object is open or closed.

Indicates for all applicable objects executing an asynchronous method, whether the current state of the object is connecting, executing, or retrieving.

Return Value

Returns a Long value that can be an ObjectStateEnum value. The default value is adStateClosed.

Remarks

You can use the State property to determine the current state of a given object at any time.

The object's State property can have a combination of values. For example, if a statement is executing, this property will have a combined value of adStateOpen and adStateExecuting.

The State property is read-only.


Attachment.RightPadding Property (Access)

 Copy code hover
[image]

Attachment.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the attachment and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .RightPadding

expression A variable that represents an Attachment object.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


 Copy code hover
[image]

<Parameter name> is invalid because it is too long or contains invalid characters. (Error 3223)
Send feedback

The parameter name is too long or contains invalid characters. Correct the name, and then try the operation again.


Connection (ADO/WFC Syntax)

 Copy code hover
[image]

Connection (ADO/WFC Syntax)
Send feedback

package com.ms.wfc.data

Constructor

Copy code Copy code

public Invalid DDUE based on source, error:link not allowed in code, link filename:mdobjconnection_HV10294216.xml()
public Connection(String connectionstring)

Methods

Copy code Copy code

public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthbegintrans_HV10294108.xml()
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthbegintrans_HV10294108.xml()
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthbegintrans_HV10294108.xml()
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthadocancel_HV10294125.xml()
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthclose_HV10294173.xml()
public com.ms.wfc.data.Recordset Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcnnexecute_HV10294345.xml(String commandText)
public com.ms.wfc.data.Recordset execute(String commandText, int options)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcnnexecute_HV10294345.xml(String commandText)
public int executeUpdate(String commandText, int options)

The executeUpdate method is a special case method that calls the underlying ADO execute method with certain parameters. The executeUpdate method does not support the return of a Recordset object, so the execute method's options parameter is modified with AdoEnums.ExecuteOptions.NORECORDS. After the execute method completes, its updated RecordsAffected parameter is passed back to the executeUpdate method, which is finally returned as an int.

Copy code Copy code

public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcnnopen_HV10294563.xml()
public void open(String connectionString)
public void open(String connectionString, String userID)
public void open(String connectionString, String userID, String password)
public void open(String connectionString, String userID, String password, int options)
public Recordset Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthopenschema_HV10294568.xml(int schema, Object[]
 restrictions, String schemaID)
public Recordset openSchema(int schema)
public Recordset openSchema(int schema, Object[] restrictions)

Properties

Copy code Copy code

public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdproattributes_HV10294098.xml()
public void setAttributes(int attr)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocommandtimeout_HV10294196.xml()
public void setCommandTimeout(int timeout)
public String Invalid DDUE based on source, error:link not allowed in code, link filename:mdproconnectionstring_HV10294218.xml()
public void setConnectionString(String con)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdproconnectiontimeout_HV10294222.xml()
public void setConnectionTimeout(int timeout)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocursorlocation_HV10294254.xml()
public void setCursorLocation(int cursorLoc)
public String Invalid DDUE based on source, error:link not allowed in code, link filename:mdprodefaultdatabase_HV10294288.xml()
public void setDefaultDatabase(String db)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdproisolationlevel_HV10294459.xml()
public void setIsolationLevel(int level)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdpromode_HV10294518.xml()
public void setMode(int mode)
public String Invalid DDUE based on source, error:link not allowed in code, link filename:mdproprovider_HV10294673.xml()
public void setProvider(String provider)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprostate_HV10294804.xml()
public String Invalid DDUE based on source, error:link not allowed in code, link filename:mdproversion_HV10294926.xml()
public AdoProperties Invalid DDUE based on source, error:link not allowed in code, link filename:mdcolproperties_HV10294633.xml()
public com.ms.wfc.data.Errors Invalid DDUE based on source, error:link not allowed in code, link filename:mdcolerrors_HV10294338.xml()

Events

For more information about ADO/WFC events, see ADO Event Instantiation by Language.

Copy code Copy code

public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtbegintranscomplete_HV10294112.xml(ConnectionEventHandler handler)
public void removeOnBeginTransComplete(ConnectionEventHandler handler)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtbegintranscomplete_HV10294112.xml(ConnectionEventHandler handler)
public void removeOnCommitTransComplete(ConnectionEventHandler handler)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtconnectconnectionevents_HV10294210.xml(ConnectionEventHandler handler)
public void removeOnConnectComplete(ConnectionEventHandler handler)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtconnectconnectionevents_HV10294210.xml(ConnectionEventHandler handler)
public void removeOnDisconnect(ConnectionEventHandler handler)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtexecutecomplete_HV10294351.xml(ConnectionEventHandler handler)
public void removeOnExecuteComplete(ConnectionEventHandler handler)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtinfomessage_HV10294445.xml(ConnectionEventHandler handler)
public void removeOnInfoMessage(ConnectionEventHandler handler)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtbegintranscomplete_HV10294112.xml(ConnectionEventHandler handler)
public void removeOnRollbackTransComplete(ConnectionEventHandler handler)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillconnectevent_HV10294953.xml(ConnectionEventHandler handler)
public void removeOnWillConnect(ConnectionEventHandler handler)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillexecuteevent_HV10294954.xml(ConnectionEventHandler handler)
public void removeOnWillExecute(ConnectionEventHandler handler)


Report.Current Event (Access)

 Copy code hover
[image]

Report.Current Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when the focus moves to a record, making it the current record, or when the report is refreshed or requeried.

Version Information

Version Added: Access 2007

Syntax

expression .Current

expression A variable that represents a Report object.

Remarks

To run a macro or event procedure when this event occurs, set the OnCurrent property to the name of the macro or to [Event Procedure].

This event occurs both when a report is opened and whenever the focus leaves one record and moves to another. Microsoft Access runs the Current macro or event procedure before the first or next record is displayed.

By running a macro or event procedure when a form's Current event occurs, you can display a message or perform an operation related to the current record.

The Current event also occurs when you refresh a report or requery the report's underlying table or query— for example, when you use the Requery action in a macro or the Requery method in Visual Basic code.

When you first open a report, the following events occur in this order:

Open → Load → Resize → Activate → Current

See also

Concepts

Report Object

Other resources

Report Object Members


Access User Interface How Do I...

 Copy code hover
[image]

Access User Interface How Do I...
Send feedback

This page links to help on widely used user-interface tasks. For more information about other popular Help tasks, see How Do I… in Access.

Ribbon

  • How to: Apply a Custom Ribbon When Starting Access

    • Describes how to display a custom ribbon when Access starts.

  • How to: Apply a Custom Ribbon to a Form or Report

    • Describes how to display a custom ribbon when a particular form or report is opened.

  • How to: Hide the Ribbon When Access Starts

    • Describes how to hide the ribbon when opening a database.

Miscellaneous

  • How to: Detect User Idle Time or Inactivity

    • Illustrates how to use a hidden form to detect when a user has been inactive for a given period of time.

  • How to: Detect Whether an Object Is Open

    • Describes how to determine whether an object is already open.

  • How to: Display and Use the File Dialog Box

    • Describes how to use the FileDialog object to display the file dialog box used by Microsoft Access and to determine what files were selected by the user.

  • How to: Use Existing Custom Menus and Toolbars

    • Describes how to use menu and toolbar customizations of databases created in earlier versions of Access.

  • How to: Use the Status Bar Progress Meter

    • Describes how to use the SysCmd method to create a progress meter on the status bar.

  • How Do I... in Access


Documents Collection (DAO)

 Copy code hover
[image]

Documents Collection (DAO)
Send feedback

A Documents collection contains all of the Document objects for a specific type of object (Microsoft Access database engine databases only).

Remarks

Each Container object has a Documents collection containing Document objects that describe instances of built-in objects of the type specified by the Container.

To refer to a Document object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

  • Documents(0)

  • Documents("name")

  • Documents![name]

Example

This example enumerates the Documents collection of the Tables container, and then enumerates the Properties collection of the first Document object in the collection.

VBA Copy code Copy code
Sub DocumentX()

 Dim dbsNorthwind As Database
 Dim docLoop As Document
 Dim prpLoop As Property

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind.Containers!Tables
 Debug.Print "Documents in " & .Name & " container"
 ' Enumerate the Documents collection of the Tables
 ' container.
 For Each docLoop In .Documents
 Debug.Print " " & docLoop.Name
 Next docLoop
 With .Documents(0)
 ' Enumerate the Properties collection of the first.
 ' Document object of the Tables container.
 Debug.Print "Properties of " & .Name & " document"
 On Error Resume Next
 For Each prpLoop In .Properties
 Debug.Print " " & prpLoop.Name & " = " & _
 prpLoop
 Next prpLoop
 On Error GoTo 0
 End With
 End With

 dbsNorthwind.Close

End Sub


ToggleButton.MouseMove Event (Access)

 Copy code hover
[image]

ToggleButton.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents a ToggleButton object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


EmptyCell.Width Property (Access)

 Copy code hover
[image]

EmptyCell.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .Width

expression A variable that represents an EmptyCell object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


Image.LayoutID Property (Access)

 Copy code hover
[image]

Image.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified image. Read-only Long.

Version Information

Version Added: Access 2007

Syntax

expression .LayoutID

expression A variable that represents an Image object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

Image Object

Other resources

Image Object Members


Rectangle.Top Property (Access)

 Copy code hover
[image]

Rectangle.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Syntax

expression .Top

expression A variable that represents a Rectangle object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


NavigationControl.AfterUpdate Event (Access)

 Copy code hover
[image]

NavigationControl.AfterUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The AfterUpdate event occurs after changed data in a control or record is updated.

Version Information

Version Added: Access 2010

Syntax

expression .AfterUpdate

expression A variable that represents a NavigationControl object.

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's AfterUpdate event does occur.

To run a macro or event procedure when this event occurs, set the AfterUpdate property to the name of the macro or to [Event Procedure].

The AfterUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

AfterUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. AfterUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For bound controls, the OldValue property isn't set to the updated value until after the AfterUpdate event for the form occurs. Even if the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Record is table

 Copy code hover
[image]

Record is table <name> is locked by another user. (Error 3330)
Send feedback

The row or page that you are trying to update is currently locked by another user. The Microsoft Access database engine allows users to have the database opened in a mode that allows for row-level locking. That mode can substantially reduce the number of times this error is generated.


More Ways to Move in a Recordset

 Copy code hover
[image]

More Ways to Move in a Recordset
Send feedback

The following four methods are used to move around, or scroll, in the Recordset: MoveFirst, MoveLast, MoveNext, and MovePrevious. (Some of these methods are unavailable on forward-only cursors.)

MoveFirst changes the current record position to the first record in the Recordset. MoveLast changes the current record position to the last record in the Recordset. To use MoveFirst or MoveLast, the Recordset object must support bookmarks or backward cursor movement; otherwise, the method call will generate an error.

MoveNext moves the current record position one place forward. If you are on the last record when you call MoveNext, EOF will be set to True. MovePrevious moves the current record position one place backward. If you are on the first record when you call MovePrevious, BOF will be set to True. It is wise to check the EOF and BOF properties when using these methods and to move the cursor back to a valid current record position if you move off either end of the Recordset, as shown here:

Copy code Copy code

. . .
oRs.MoveNext
If oRs.EOF Then oRs.MoveLast
. . .

Or, in the case of the MovePrevious method:

Copy code Copy code

. . .
oRs.MovePrevious
If oRs.BOF Then oRs.MoveFirst
. . .

In cases where the Recordset has been filtered or sorted and the current record's data is changed, the position may also change. In such cases the MoveNext method works normally, but be aware that the position is moved one record forward from the new position, not the old position. For example, changing the data in the current record, such that the record is moved to the end of the sorted Recordset, would mean that calling MoveNext results in ADO setting the current record to the position after the last record in the Recordset (EOF = True).

The behavior of the various Move methods of the Recordset object depends, to some extent, on the data within the Recordset. New records added to the Recordset are initially added in a particular order, which is defined by the data source and may be dependent implicitly or explicitly on the data in the new record. For example, if a sort or a join is done within the query that populates the Recordset, the new record will be inserted in the appropriate place within the Recordset. If ordering is not explicitly specified when creating the Recordset, changes in the data source implementation may cause the ordering of the returned rows to change inadvertently. In addition, the sorting, filtering, and editing functions of the Recordset can affect the order and possibly which rows in the recordset will be visible.

Therefore, MoveNext, MovePrevious, MoveFirst, MoveLast, and Move are all sensitive to other operations performed on the same Recordset. ADO will always try to maintain your current position until you explicitly move it, but sometimes intervening changes make it difficult to understand the effects of a subsequent move. For example, if you call MoveFirst to position on the first row of a sorted Recordset and you change the sort from ascending order to descending order, you are still on the same row — but now it is the last row in the Recordset. MoveFirst will take you to a different row (the new first row).

As another example, if you are positioned on a particular row in the middle of a Recordset and you call Delete and then call MoveNext, you are now on the record immediately following the deleted record. But calling MovePrevious makes the record preceding the one you deleted the current record, because the deleted record is no longer counted in the active membership of the Recordset.

It is particularly difficult to define consistent move semantics across all providers for methods that move relative to the current record — MovePrevious, MoveNext, and Move — in the face of changing data in the current record. For example, if you are working with a sorted, filtered Recordset, and you change the data in the current record so that it would precede all other records, but your changed data also no longer matches the filter, it is not clear where a MoveNext operation should take you. The safest conclusion is that relative movement within a Recordset is riskier than absolute movement (such as using MoveFirst or MoveLast) when the data is changing while records are being edited, added, or deleted. Sorting and filtering should be based on a primary key or ID, because this type of value should not change.


ActiveCommand Property Example (JScript)

 Copy code hover
[image]

ActiveCommand Property Example (JScript)
Send feedback

This example demonstrates the ActiveCommand property. Cut and paste the following code to Notepad or another text editor, and save it as ActiveCommandJS.asp.

Copy code Copy code

<!-- BeginActiveCommandJS -->
<%@LANGUAGE="JScript" %>
<%// use this meta tag instead of adojavas.inc%>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->

<%
 // user input
 strName = new String(Request.Form("ContactName"))
%>

<html>

<head>
<title>ActiveCommand Property Example (JScript)</title>
<style>
<!--
BODY {
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 BACKGROUND-COLOR:white;
 COLOR:black;
 }
-->
</style>
</head>

<body bgcolor="White">

<h1>ActiveCommand Property Example (JScript)</h1>

<%
if (strName.length > 0)
 {
 // connection and recordset variables
 var Cnxn = Server.CreateObject("ADODB.Connection")
 var strCnxn = "Provider='sqloledb';Data Source=" + Request.ServerVariables("SERVER_NAME") + ";" +
 "Initial Catalog='Northwind';Integrated Security='SSPI';";
 var cmdContact = Server.CreateObject("ADODB.Command");
 var rsContact = Server.CreateObject("ADODB.Recordset");
 // display variables
 var strMessage;

 try
 {
 // open connection
 Cnxn.Open(strCnxn);

 // Open a recordset using a command object
 cmdContact.CommandText = "SELECT ContactName FROM Customers WHERE City = ?";
 cmdContact.ActiveConnection = Cnxn;
 // create parameter and insert variable value
 cmdContact.Parameters.Append(cmdContact.CreateParameter("ContactName", adChar, adParamInput, 30, strName));

 rsContact = cmdContact.Execute();

 while(!rsContact.EOF){
 // start new line
 strMessage = "<P>";

 // get data
 strMessage += rsContact("ContactName")

 // end the line
 strMessage += "</P>";

 // show data
 Response.Write(strMessage);

 // get next record
 rsContact.MoveNext;
 }
 }
 catch (e)
 {
 Response.Write(e.message);
 }
 finally
 {
 // 'clean up
 if (rsContact.State == adStateOpen)
 rsContact.Close;
 if (Cnxn.State == adStateOpen)
 Cnxn.Close;
 rsContact = null;
 Cnxn = null;
 }
 }
%>

<hr>

<form method="POST" action="ActiveCommandJS.asp">
 <p align="left">Enter city of customer to find (e.g., Paris): <input type="text" name="ContactName" size="40" value=""></p>
 <p align="left"><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>

</html>
<!-- EndActiveCommandJS -->


Solutions for Remote Data Access

 Copy code hover
[image]

Solutions for Remote Data Access
Send feedback

The Issue

ADO enables your application to directly gain access to and modify data sources (sometimes called a two-tier system). For example, if your connection is to the data source that contains your data, that is a direct connection in a two-tier system.

However, you may want to access data sources indirectly through an intermediary such as Microsoft® Internet Information Services (IIS). This arrangement is sometimes called a three-tier system. IIS is a client/server system that provides an efficient way for a local, or client, application to invoke a remote, or server, program across the Internet or an intranet. The server program gains access to the data source and optionally processes the acquired data.

For example, your intranet Web page contains an application written in Microsoft® Visual Basic Scripting Edition (VBScript), which connects to IIS. IIS in turn connects to the actual data source, retrieves the data, processes it in some way, and then returns the processed information to your application.

In this example, your application never directly connected to the data source; IIS did. And IIS accessed the data by means of ADO.

Note Note

The client/server application does not have to be based on the Internet or an intranet (that is, Web-based) — it could consist solely of compiled programs on a local area network. However, the typical case is a Web-based application.

Because some visual control, such as a grid, check box, or list, may use the returned information, the returned information must be easily used by a visual control.

You want a simple and efficient application-programming interface that supports three-tier systems, and returns information as easily as if it had been retrieved on a two-tier system. Remote Data Service (RDS) is this interface.

The Solution

RDS defines a programming model — the sequence of activities necessary to gain access to and update a data source — to gain access to data through an intermediary, such as Internet Information Services (IIS). The programming model summarizes the entire functionality of RDS.


SubString Function (Access 2013 custom web app)

 Copy code hover
[image]

SubString Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns part of a text expression.

Syntax

SubString (TextExpression, Start, Length)

The SubString function contains the following arguments.

Argument name | Description
TextExpression | A text expression.
Start | An integer expression that specifies where the returned characters start. If start is less than 1, the returned expression will begin at the first character that is specified in expression. In this case, the number of characters that are returned is the largest value of either the sum of start + length- 1 or 0. If start is greater than the number of characters in the value expression, a zero-length expression is returned.
Length | A positive integer expression that specifies how many characters of the expression will be returned. If length is negative, an error is generated and the statement is terminated. If the sum of start and length is greater than the number of characters in expression, the whole value expression beginning at start is returned.


Dynamic Cursors

 Copy code hover
[image]

Dynamic Cursors
Send feedback

Dynamic cursors detect all changes made to the rows in the result set, regardless of whether the changes occur from inside the cursor or by other users outside the cursor. All insert, update, and delete statements made by all users are visible through the cursor. The dynamic cursor can detect any changes made to the rows, order, and values in the result set after the cursor is opened. Updates made outside the cursor are not visible until they are committed (unless the cursor transaction isolation level is set to "uncommitted").

For example, suppose a dynamic cursor fetches two rows and another application, and then updates one of those rows and deletes the other. If the dynamic cursor then fetches those rows, it will not find the deleted row, but it will display the new values for the updated row.

The dynamic cursor is a good choice if your application must detect all concurrent updates made by other users. Use the adOpenDynamic CursorTypeEnum to indicate that you want to use a dynamic cursor in ADO.

Forward-Only Cursors | Static Cursors | Keyset Cursors


EventStatusEnum

 Copy code hover
[image]

EventStatusEnum
Send feedback

Specifies the current status of the execution of an event.

Constant | Value | Description
adStatusCancel | 4 | Requests cancellation of the operation that caused the event to occur.
adStatusCantDeny | 3 | Indicates that the operation cannot request cancellation of the pending operation.
adStatusErrorsOccurred | 2 | Indicates that the operation that caused the event failed due to an error or errors.
adStatusOK | 1 | Indicates that the operation that caused the event was successful.
adStatusUnwantedEvent | 5 | Prevents subsequent notifications before the event method has finished executing.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.EventStatus.CANCEL

AdoEnums.EventStatus.CANTDENY

AdoEnums.EventStatus.ERRORSOCCURRED

AdoEnums.EventStatus.OK

AdoEnums.EventStatus.UNWANTEDEVENT


DoCmd.SetDisplayedCategories Method (Access)

 Copy code hover
[image]

DoCmd.SetDisplayedCategories Method (Access)
See also Send feedback

Published: July 16, 2012

Specifies which categories are displayed under Navigate to Category in the title bar of the Navigation Pane. .

Version Information

Version Added: Access 2007

Syntax

expression .SetDisplayedCategories(Show, Category)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
Show | Required | Variant | Set to Yes to show the category or categories. Set to No to hide them.
Category | Optional | Variant | The name of the category you want to show or hide. Leave blank to show or hide all categories.

Remarks

For example, if you want to prevent users from switching the Navigation Pane so that it displays objects sorted by Created Date, you can use this method to hide that option in the title bar's drop-down list.

The caption in the title bar of the Navigation Pane indicates which filter, if any, is currently active. Click anywhere in the bar to display the drop-down list. The items that this method controls are listed under Navigate to Category.

This method only enables or disables the display of the specified category or categories; it does not perform any switching of the Navigation Pane display. For example, if you are displaying objects sorted by Creation Date and you use the SetDisplayedCategories method to disable the Creation Date option, Access does not switch the Navigation Pane to another category.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Aggregation expressions cannot use GUIDS. (Error 3600)

 Copy code hover
[image]

Aggregation expressions cannot use GUIDS. (Error 3600)
Send feedback

The SQL statement cannot contain a column that has a GUID data type in an aggregate, such as MAX, MIN, SUM, and so on.


TabControl.OnClick Property (Access)

 Copy code hover
[image]

TabControl.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Syntax

expression .OnClick

expression A variable that represents a TabControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


TextBox.DblClick Event (Access)

 Copy code hover
[image]

TextBox.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Syntax

expression .DblClick(Cancel)

expression A variable that represents a TextBox object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the DblClick event occurs. Setting the Cancel argument to True (-1) cancels the DblClick event.

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


CheckBox.Properties Property (Access)

 Copy code hover
[image]

CheckBox.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a CheckBox object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


TextBox.MouseDown Event (Access)

 Copy code hover
[image]

TextBox.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents a TextBox object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
         Shift As Integer, X As Single, _
         Y As Single)
    If Button = acLeftButton Then
        MsgBox "You pressed the left button."
    End If
    If Button = acRightButton Then
        MsgBox "You pressed the right button."
    End If
    If Button = acMiddleButton Then
        MsgBox "You pressed the middle button."
    End If
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Enumerations (Access)

 Copy code hover
[image]

Enumerations (Access)
Send feedback

This section contains documentation for the enumerations in the Access object model.


Command Button Control

 Copy code hover
[image]

Command Button Control
Send feedback

Published: July 16, 2012

A command button on a form can start an action or a set of actions. For example, you could create a command button that opens another form. To make a command button do something, you write a macro or event procedure and attach it to the button's OnClick property.

Remarks

You can display text on a command button by setting its Caption property, or you can display a picture by setting its Picture property.

Tip Tip

You can create over 30 different types of command buttons with the Command Button Wizard. When you use the Command Button Wizard, Microsoft Access creates the button and the event procedure for you.


WebBrowserControl.OnNavigateError Property (Access)

 Copy code hover
[image]

WebBrowserControl.OnNavigateError Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the value of the On Navigate Error box in the property sheet os a Web Browser control. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnNavigateError

expression A variable that represents a WebBrowserControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Recordset.PercentPosition Property (DAO)

 Copy code hover
[image]

Recordset.PercentPosition Property (DAO)
Send feedback

Sets or returns a value indicating the approximate location of the current record in the Recordset object based on a percentage of the records in the Recordset.

Syntax

expression .PercentPosition

expression A variable that represents a Recordset object.

Remarks

To indicate or change the approximate position of the current record in a Recordset object, you can check or set the PercentPosition property. When working with a dynaset- or snapshot-type Recordset object opened directly from a base table, first populate the Recordset object by moving to the last record before you set or check the PercentPosition property. If you use the PercentPosition property before fully populating the Recordset object, the amount of movement is relative to the number of records accessed as indicated by the RecordCount property setting. You can move to the last record by using the MoveLast method.

Note Note

Using the PercentPosition property to move the current record to a specific record in a Recordset object isn't recommended?the Bookmark property is better suited for this task.

Once you set the PercentPosition property to a value, the record at the approximate position corresponding to that value becomes current, and the PercentPosition property is reset to a value that reflects the approximate position of the current record. For example, if your Recordset object contains only five records, and you set its PercentPosition property value to 77, the value returned from the PercentPosition property may be 80, not 77.

The PercentPosition property applies to all types of Recordset objects except for forward-only-type Recordset objects or Recordset objects opened from pass-through queries against remote databases.

You can use the PercentPosition property with a scroll bar on a form or text box to indicate the location of the current record in a Recordset object.

Example

This example uses the PercentPosition property to show the position of the current record pointer relative to the beginning of the Recordset.

VBA Copy code Copy code
Sub PercentPositionX()

 Dim dbsNorthwind As Database
 Dim rstProducts As Recordset
 Dim strFind As String
 Dim strMessage As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 ' PercentPosition only works with dynasets or snapshots.
 Set rstProducts = dbsNorthwind.OpenRecordset( _
 "SELECT ProductName FROM Products " & _
 "ORDER BY ProductName", dbOpenSnapshot)

 With rstProducts
 ' Populate the Recordset.
 .MoveLast
 .MoveFirst

 Do While True
 ' Show current record information and ask user
 ' for input.
 strMessage = "Product: " & !ProductName & vbCr & _
 "The record pointer is " & _
 Format(.PercentPosition, "##0.0") & _
 "% from the " & vbCr & _
 "beginning of the Recordset." & vbCr & _
 "Please enter a character search string " & _
 "for a product name."
 strFind = Trim(InputBox(strMessage))
 If strFind = "" Then Exit Do

 ' Try to find a record matching the search string.
 .FindFirst "ProductName >= '" & strFind & "'"
 If .NoMatch Then .MoveLast
 Loop

 .Close
 End With

 dbsNorthwind.Close

End Sub


DateModified Property (ADOX)

 Copy code hover
[image]

DateModified Property (ADOX)
Send feedback

Indicates the date the object was last modified.

Return Values

Returns a Variant value specifying the date modified. The value is null if DateModified is not supported by the provider.

Remarks

The DateModified property is null for newly appended objects. After appending a new View or Procedure, you must call the Refresh method of the Views or Procedures collection to obtain values for the DateModified property.


BoundObjectFrame.Enter Event (Access)

 Copy code hover
[image]

BoundObjectFrame.Enter Event (Access)
See also Send feedback

Published: July 16, 2012

The Enter event occurs before a control actually receives the focus from a control on the same form or report.

Syntax

expression .Enter

expression A variable that represents a BoundObjectFrame object.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when these events occur, set the OnEnter or OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Enter event occurs before the GotFocus event. The Exit event occurs before the LostFocus event.

Unlike the GotFocus and LostFocus events, the Enter and Exit events don't occur when a form receives or loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


BoundObjectFrame.OnExit Property (Access)

 Copy code hover
[image]

BoundObjectFrame.OnExit Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnExit

expression A variable that represents a BoundObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Exit event occurs just before a control loses the focus to another control on the same form.

The OnExit value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Exit box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Exit box is blank, the property value is an empty string.

Example

The following example associates the Exit event with the macro "Exit_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnExit = "Exit_Macro"

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Save and Open Methods Example (VB)

 Copy code hover
[image]

Save and Open Methods Example (VB)
Send feedback

These three examples demonstrate how the Save and Open methods can be used together.

Assume you are going on a business trip and want to take along a table from a database. Before you go, you access the data as a Recordset and save it in a transportable form. When you arrive at your destination, you access the Recordset as a local, disconnected Recordset. You make changes to the Recordset, then save it again. Finally, when you return home, you connect to the database again and update it with the changes you made on the road.

First, access and save the Authors table.

Copy code Copy code

'BeginSaveVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 'recordset and connection variables
 Dim rstAuthors As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim strSQLAuthors As String

 ' Open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 Set rstAuthors = New ADODB.Recordset
 strSQLAuthors = "SELECT au_id, au_lname, au_fname, city, phone FROM Authors"
 rstAuthors.Open strSQLAuthors, Cnxn, adOpenDynamic, adLockOptimistic, adCmdText

 'For sake of illustration, save the Recordset to a diskette in XML format
 rstAuthors.Save "c:\Pubs.xml", adPersistXML

 ' clean up
 rstAuthors.Close
 Cnxn.Close
 Set rstAuthors = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 'clean up
 If Not rstAuthors Is Nothing Then
 If rstAuthors.State = adStateOpen Then rstAuthors.Close
 End If
 Set rstAuthors = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndSaveVB

At this point, you have arrived at your destination. You will access the Authors table as a local, disconnected Recordset. Don't forget you must have the MSPersist provider on the machine that you are using in order to access the saved file, a:\Pubs.xml.

Copy code Copy code

'BeginSave2VB
Public Sub Main()
 On Error GoTo ErrorHandler

 Dim rst As ADODB.Recordset
 Set rst = New ADODB.Recordset

 'For sake of illustration, we specify all parameters
 rst.Open "c:\Pubs.xml", "Provider=MSPersist;", adOpenForwardOnly, adLockBatchOptimistic, adCmdFile

 'Now you have a local, disconnected Recordset - Edit as you desired
 '(In this example the change makes no difference)
 rst.Find "au_lname = 'Carson'"
 If rst.EOF Then
 Debug.Print "Name not found."
 Exit Sub
 End If

 rst!city = "Chicago"
 rst.Update

 'Save changes in ADTG format this time, purely for sake of illustration.
 'Note that the previous version is still on the diskette, as a:\Pubs.xml.
 rst.Save "c:\Pubs.adtg", adPersistADTG

 ' clean up
 rst.Close
 Set rst = Nothing
 Exit Sub

ErrorHandler:
 'clean up
 If Not rst Is Nothing Then
 If rst.State = adStateOpen Then rst.Close
 End If
 Set rst = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndSave2VB

Finally, you return home. Now update the database with your changes.

Copy code Copy code

'BeginSave3VB
Public Sub Main()
 On Error GoTo ErrorHandler

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

 Dim Cnxn As New ADODB.Connection
 Dim rst As ADODB.Recordset
 Dim strCnxn As String

 Set rst = New ADODB.Recordset
 ' The lock mode is batch optimistic because we are going to
 ' use the UpdateBatch method.
 rst.Open "c:\Pubs.adtg", "Provider=MSPersist;", adOpenForwardOnly, adLockBatchOptimistic, adCmdFile

 ' Connect to the database, associate the Recordset with the connection
 ' then update the database table with the changed Recordset
 strCnxn = "Provider=SQLOLEDB;Data Source=MySqlServer;Integrated Security=SSPI;Initial Catalog=pubs;"
 Cnxn.Open strCnxn

 rst.ActiveConnection = Cnxn
 rst.UpdateBatch

 ' clean up
 rst.Close
 Cnxn.Close
 Set rst = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 'clean up
 If Not rst Is Nothing Then
 If rst.State = adStateOpen Then rst.Close
 End If
 Set rst = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndSave3VB


Section V: Appendixes

 Copy code hover
[image]

Section V: Appendixes
Send feedback

The ADO Programmer's Guide contains the following appendixes:

  • Appendix A: Providers

  • Appendix B: ADO Errors

  • Appendix C: Programming with ADO

  • Appendix D: ADO Samples


FIRST (Microsoft Access SQL reserved word)

 Copy code hover
[image]

FIRST (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The FIRST keyword is used in these contexts:

First, Last Functions


CheckBox.Layout Property (Access)

 Copy code hover
[image]

CheckBox.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified check box. Read-only AcLayoutType.

Version Information

Version Added: Access 2007

Syntax

expression .Layout

expression A variable that represents a CheckBox object.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


State Property Example (VC++)

 Copy code hover
[image]

State Property Example (VC++)
Send feedback

This example uses the State property to display a message while asynchronous connections are opening and asynchronous commands are executing.

Copy code Copy code

// BeginStateCpp
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void StateX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 StateX();

 ::CoUninitialize();
}

///////////////////////////////////////////////
// //
// StateX Function //
// //
///////////////////////////////////////////////
void StateX(void)
{
 HRESULT hr = S_OK;

 // Define string variables.
 _bstr_t strSQLChange("UPDATE Titles SET Type = "
 "'self_help' WHERE Type = 'psychology'");
 _bstr_t strSQLRestore("UPDATE Titles SET Type = "
 "'psychology' WHERE Type = 'self_help'");
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _ConnectionPtr pConnection = NULL;
 _ConnectionPtr pConnection2 = NULL;
 _CommandPtr pCmdChange = NULL;
 _CommandPtr pCmdRestore = NULL;

 try
 {
 // Open two asynchronous connections,displaying
 // a message while connecting.
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
 TESTHR(pConnection2.CreateInstance(__uuidof(Connection)));

 pConnection->Open (strCnn, "", "", adAsyncConnect);
 while(pConnection->State == adStateConnecting)
 {
 printf("Opening first connection....\n\n");
 }

 pConnection2->Open (strCnn, "", "", adAsyncConnect);
 while(pConnection2->State == adStateConnecting)
 {
 printf("Opening second connection....\n\n");
 }

 // Create two command objects.
 TESTHR(pCmdChange.CreateInstance(__uuidof(Command)));
 pCmdChange->ActiveConnection = pConnection;
 pCmdChange->CommandText = strSQLChange;

 TESTHR(pCmdRestore.CreateInstance(__uuidof(Command)));
 pCmdRestore->ActiveConnection = pConnection2;
 pCmdRestore->CommandText = strSQLRestore;

 // Executing the commands,displaying a message
 // while they are executing.
 pCmdChange->Execute(NULL,NULL,adAsyncExecute);
 while(pCmdChange->State == adStateExecuting)
 {
 printf("Change command executing...\n\n");
 }

 pCmdRestore->Execute(NULL,NULL,adAsyncExecute);
 while(pCmdRestore->State == adStateExecuting)
 {
 printf("Restore command executing...\n\n");
 }
 }
 catch (_com_error &e)
 {
 // Notify the user of errors if any.
 PrintProviderError(pConnection);
 PrintComError(e);
 }

 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
 if (pConnection2)
 if (pConnection2->State == adStateOpen)
 pConnection2->Close();
}

///////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////
void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

///////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////
void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndStateCpp


Application.GetHiddenAttribute Method (Access)

 Copy code hover
[image]

Application.GetHiddenAttribute Method (Access)
See also Send feedback

Published: July 16, 2012

The GetHiddenAttribute method returns the value of hidden attribute of a Microsoft Access object in the object's Properties dialog box, available by selecting the object in the Database window and clicking Properties on the View menu.

Syntax

expression .GetHiddenAttribute(ObjectType, ObjectName)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
ObjectType | Required | AcObjectType | A AcObjectType constant that specifies the type of Access object.
ObjectName | Required | String | The name of the Access object.

Return Value

Boolean

Remarks

The GetHiddenAttribute method (along with the SetHiddenAttribute method) provide a means of changing an object's hidden attribute from Visual Basic code. With these methods, you can set or read the hidden option available in the object's Properties dialog box.

Since the hidden attributes that the user can set by selecting or clearing a check box, the GetHiddenAttribute method returns True if the option setting is Yes (the check box is selected) or False if the option setting is No (the check box is cleared). For example, to set an option of this kind by using the SetHiddenAttribute method, specify True or False for the setting argument, as in the following:

VBA Copy code Copy code
Application.SetHiddenAttribute acTable,"Customers", True

See also

Concepts

Application Object

Other resources

Application Object Members


Cannot make a new replica because the

 Copy code hover
[image]

Cannot make a new replica because the <name> object in <name> container could not be made replicable. (Error 3582)
Send feedback

The database could not be made replicable because the specified object could not be replicated. For example, if the maximum number of allowed indexes is exceeded on a table, the table cannot be replicated. To prevent this error, prior to making the database replicable ensure that the objects in the database adhere to replication requirements.


CheckBox Members (Access)

 Copy code hover
[image]

CheckBox Members (Access)
Send feedback

Published: July 16, 2012

This object corresponds to a check box on a form or report. This check box is a stand-alone control that displays a Yes/No value from an underlying record source.

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.
Undo | You can use the Undo method to reset a control or form when its value has been changed.

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the check box and its bottom gridline. Read/write Integer.
ColumnHidden | You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.
ColumnOrder | You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.
ColumnWidth | You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DefaultValue | Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
GridlineColor | Gets or sets the color of the gridline for the specified check box. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified check box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified check box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified check box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified check box. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified check box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified check box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified check box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified check box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HideDuplicates | You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the check box is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified check box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified check box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the check box and its left gridline. Read/write Integer.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OptionValue | Each control in an option group has a numeric value that you can set with the OptionValue property. Read/write Long.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
RightPadding | Gets or sets the amount of space (in inches) between the check box and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the check box and its top gridline. Read/write Integer.
TripleState | You can use the TripleState property to specify how the specified control will display Null values. Read/write Boolean.
ValidationRule | You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.
ValidationText | Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.
Value | Determines or specifies whether or not the specifed check box is checked. Read /write Variant.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified check box is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


Application Object (Access)

 Copy code hover
[image]

Application Object (Access)
See also Send feedback

Published: July 16, 2012

The Application object refers to the active Microsoft Access application.

Remarks

The Application object contains all Access objects and collections.

You can use the Application object to apply methods or property settings to the entire Access application. For example, you can use the SetOption method of the Application object to set database options from Visual Basic. The following example shows how you can set the Display Status Bar check box on the Current Database tab of the Access Options dialog box.

VBA Copy code Copy code
Application.SetOption "Show Status Bar", True

Access is a COM component that supports Automation, formerly called OLE Automation. You can manipulate Access objects from another application that also supports Automation. To do this, you use the Application object.

For example, Microsoft Visual Basic is a COM component. You can open anAccess database from Visual Basic and work with its objects. From Visual Basic, first create a reference to the Microsoft Access 2013 object library. Then create a new instance of the Application class and point an object variable to it, as in the following example:

VBA Copy code Copy code
Dim appAccess As New Access.Application

From applications that do not support the New keyword, you can create a new instance of the Application class by using the CreateObject function:

VBA Copy code Copy code
Dim appAccess As Object
Set appAccess = CreateObject("Access.Application")

After you create a new instance of the Application class, you can open a database or create a new database, by using either the OpenCurrentDatabase method or the NewCurrentDatabase method. You can then set the properties of the Application object and call its methods. When you return a reference to the CommandBars object by using the CommandBars property of the Application object, you can access all Microsoft Office command bar objects and collections by using this reference.

You can also manipulate other Access objects through the Application object. For example, by using the OpenForm method of the Access DoCmd object, you can open an Access form from Microsoft Office Excel:

VBA Copy code Copy code
appAccess.DoCmd.OpenForm "Orders"

For more information about creating a reference and controlling objects by using Automation, see the documentation for the application that is acting as the COM component.

See also

Concepts

Access Object Model Reference

Other resources

Application Object Members


TextBox.Visible Property (Access)

 Copy code hover
[image]

TextBox.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents a TextBox object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ADO MD API Reference Topics

 Copy code hover
[image]

ADO MD API Reference Topics
Send feedback

In this section

  • ADO MD API Reference

  • ADO MD Objects Reference

  • ADO MD Collections Reference

  • ADO MD Properties Reference

  • ADO MD Methods Reference

  • ADO MD Enumerated Constants Reference


Form.OnClose Property (Access)

 Copy code hover
[image]

Form.OnClose Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Close box in the Properties window of a form or report. Read/write String.

Syntax

expression .OnClose

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Close event occurs when when a form or report is closed and removed from the screen.

The OnClose value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Close box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Close box is blank, the property value is an empty string.

See also

Concepts

Form Object

Other resources

Form Object Members


Attachment.MouseUp Event (Access)

 Copy code hover
[image]

Attachment.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents an Attachment object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was released to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


GetObjectOwner and SetObjectOwner Methods Example (VC++)

 Copy code hover
[image]

GetObjectOwner and SetObjectOwner Methods Example (VC++)
Send feedback

This example demonstrates the GetObjectOwner and SetObjectOwner methods. This code assumes the existence of the group Accounting (see the Groups and Users Append, ChangePassword Methods Example (VC++) to see how to add this group to the system). The owner of the Categories table is set to Accounting.

Copy code Copy code

// BeginOwnersCpp
#import "c:\Program Files\Common Files\system\ado\msadox.dll" no_namespace

#include "iostream.h"
#include "stdio.h"
#include "conio.h"

//Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void OwnersX(void);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 OwnersX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// OwnersX Function //
// //
//////////////////////////////////////////////////////////
void OwnersX()
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.
 _TablePtr m_pTable = NULL;
 _CatalogPtr m_pCatalog = NULL;

 try
 {
 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof(Catalog)));
 TESTHR(hr = m_pTable.CreateInstance(__uuidof(Table)));

 //Open the Catalog.
 m_pCatalog->PutActiveConnection(
 "Provider='Microsoft.JET.OLEDB.4.0';" "data source='c:\\Program Files\\Microsoft Office\\"
 "Office\\Samples\\Northwind.mdb';"
 "jet oledb:system database='c:\\Program Files\\Microsoft Office\\"
 "Office\\system.mdw'");

 //Print the original owner of Categories
 _bstr_t strOwner = m_pCatalog->GetObjectOwner("Categories",
 adPermObjTable);
 cout << "Owner of Categories: " << strOwner << "\n" << endl;
 int iLineCnt = 2;

 //Create and append new group with a string.
 m_pCatalog->Groups->Append("Accounting");

 //Set the owner of Categories to Accounting.
 m_pCatalog->SetObjectOwner("Categories",
 adPermObjTable,"Accounting");

 _variant_t vIndex;
 //List the owners of all tables and columns in the catalog.
 for (long iIndex = 0; iIndex < m_pCatalog->Tables->Count; iIndex++)
 {
 vIndex = iIndex;
 m_pTable = m_pCatalog->Tables->GetItem(vIndex);
 cout << "Table: " << m_pTable->Name << endl;
 cout << " Owner: " << m_pCatalog->
 GetObjectOwner(m_pTable->Name,adPermObjTable) << endl;
 if (iLineCnt%16 == 0)
 {
 printf("\nPress any key to continue...\n");
 getch();
 }
 iLineCnt = iLineCnt + 2;
 }

 //Restore the original owner of Categories
 m_pCatalog->SetObjectOwner("Categories",adPermObjTable,strOwner);

 //Delete Accounting
 m_pCatalog->Groups->Delete("Accounting");
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }

 catch(...)
 {
 cout << "Error occured in include files...."<< endl;
 }
}
// EndOwnersCpp


TabControl.HorizontalAnchor Property (Access)

 Copy code hover
[image]

TabControl.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the tab control is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .HorizontalAnchor

expression A variable that represents a TabControl object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


QuitAccess Macro Action

 Copy code hover
[image]

QuitAccess Macro Action
Send feedback

You can use the QuitAccess action to exit Microsoft Access. The QuitAccess action can also specify one of several options for saving database objects prior to exiting Access.

Note 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.

Setting

The QuitAccess action has the following argument.

Action argument | Description
Options | Specifies what happens to unsaved objects when you quit Access. Click Prompt (to display dialog boxes that ask whether to save each object), Save All (to save all objects without prompting by dialog boxes), or Exit (to quit without saving any objects) in the Options box in the Action Arguments section of the Macro Builder pane. The default is Save All.

Remarks

Access doesn't run any actions that follow the QuitAccess action in a macro.

You can use this action to quit Access without prompts from Save dialog boxes by using a custom menu command or a button on a form. For example, you might have a master form that you use to display the objects in your custom workspace. This form could have a Quit button that runs a macro containing the QuitAccess action with the Options argument set to Save All.

This action has the same effect as clicking the File tab and then clicking Exit. If you have any unsaved objects when you click this command, the dialog boxes that appear are the same as those displayed when you use Prompt for the Options argument of the QuitAccess action.

You can use the SaveObject action in a macro to save a specified object without having to quit Access or close the object.

To run the QuitAccess action in a Visual Basic for Applications (VBA) module, use the Quit method of the DoCmd object.


Page.OnDblClick Property (Access)

 Copy code hover
[image]

Page.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Syntax

expression .OnDblClick

expression A variable that represents a Page object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_DblClick" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

Page Object

Other resources

Page Object Members


Execute Method (ADO Connection)

 Copy code hover
[image]

Execute Method (ADO Connection)
Send feedback

Executes the specified query, SQL statement, stored procedure, or provider-specific text.

Syntax

For a non-row-returning command string:

For a row-returning command string:

Return Value

Returns a Recordset object reference.

Parameters

  • CommandText

  • A String value that contains the SQL statement, stored procedure, a URL, or provider-specific text to execute. Optionally, table names can be used but only if the provider is SQL aware. For example if a table name of "Customers" is used, ADO will automatically prepend the standard SQL Select syntax to form and pass "SELECT * FROM Customers" as a T-SQL statement to the provider.

  • RecordsAffected

  • Optional. A Long variable to which the provider returns the number of records that the operation affected.

  • Options

  • Optional. A Long value that indicates how the provider should evaluate the CommandText argument. Can be a bitmask of one or more CommandTypeEnum or ExecuteOptionEnum values.

Note Note

Use the ExecuteOptionEnum value adExecuteNoRecords to improve performance by minimizing internal processing.

Do not use the CommandTypeEnum values of adCmdFile or adCmdTableDirect with Execute. These values can only be used as options with the Open and Requery methods of a Recordset.

Remarks

Using the Execute method on a Connection object executes whatever query you pass to the method in the CommandText argument on the specified connection. If the CommandText argument specifies a row-returning query, any results that the execution generates are stored in a new Recordset object. If the command is not intended to return results (for example, an SQL UPDATE query) the provider returns Nothing as long as the option adExecuteNoRecords is specified; otherwise Execute returns a closed Recordset.

The returned Recordset object is always a read-only, forward-only cursor. If you need a Recordset object with more functionality, first create a Recordset object with the desired property settings, then use the Recordset object's Open method to execute the query and return the desired cursor type.

The contents of the CommandText argument are specific to the provider and can be standard SQL syntax or any special command format that the provider supports.

An ExecuteComplete event will be issued when this operation concludes.

Note Note

URLs using the http scheme will automatically invoke the Microsoft OLE DB Provider for Internet Publishing. For more information, see Absolute and Relative URLs.


ToggleButton.LayoutID Property (Access)

 Copy code hover
[image]

ToggleButton.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified toggle button. Read-only Long.

Version Information

Version Added: Access 2007

Syntax

expression .LayoutID

expression A variable that represents a ToggleButton object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


WebBrowserControl.Top Property (Access)

 Copy code hover
[image]

WebBrowserControl.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Version Information

Version Added: Access 2010

Syntax

expression .Top

expression A variable that represents a WebBrowserControl object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


StopMacro Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

StopMacro Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

You can use the StopMacro action to stop the currently running macro.

Setting

The StopMacro action doesn't have any arguments.

Remarks

You typically use this action when a condition makes it necessary to stop the macro. For example, you might create a user interface (UI) macro that opens a view showing the daily order totals for the date entered in the current view. You could use a conditional expression to be sure that the Order Date control on the dialog box contains a valid date. If it doesn't, the MessageBox action can display an error message and the StopMacro action can stop the UI macro.


Programming with ADO MD

 Copy code hover
[image]

Programming with ADO MD
Send feedback

To use ADO MD with your development tool, you should establish a reference to the ADO MD type library. The description of the ADO MD library is Microsoft ActiveX Data Objects (Multi-dimensional) Library. The ADO MD library filename is msadomd.dll, and the program ID (ProgID) is "ADOMD". For more information about establishing references to libraries, see the documentation of your development tool.


Chapter 5: Updating and Persisting Data (ADO)

 Copy code hover
[image]

Chapter 5: Updating and Persisting Data (ADO)
Send feedback

In this section

  • Chapter 5: Updating and Persisting Data

  • Updating Data (ADO)

  • Persisting Data (ADO)


AllStoredProcedures.Application Property (Access)

 Copy code hover
[image]

AllStoredProcedures.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents an AllStoredProcedures object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

AllStoredProcedures Collection

Other resources

AllStoredProcedures Object Members


CurrentProject.Parent Property (Access)

 Copy code hover
[image]

CurrentProject.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a CurrentProject object.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


Configuring RDS

 Copy code hover
[image]

Configuring RDS
Send feedback

To implement RDS efficiently, be sure you are familiar with the various configurations available to you. This section includes important information about security and scalability in your implementation of RDS. See the following topics for information about configuring your computers to use RDS.

  • Granting Guest Privileges to a Web Server Computer

  • Registering a Custom Business Object

  • Marking Business Objects as Safe for Scripting

  • Registering Business Objects on the Client for Use with DCOM

  • Setting DCOM Stream Marshaling Format

  • Enabling a DLL to Run on DCOM

  • Configuring Virtual Servers on IIS

  • Specifying Threads Per Processor on IIS

  • Securing RDS Applications

  • Configuring DataFactory for Safe or Unrestricted Modes


CommandButton.KeyPress Event (Access)

 Copy code hover
[image]

CommandButton.KeyPress Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyPress(KeyAscii)

expression A variable that represents a CommandButton object.

Parameters

Name | Required/Optional | Data Type | Description
KeyAscii | Required | Integer | Returns a numeric ANSI key code. The KeyAscii argument is passed by reference; changing it sends a different character to the object. Setting the KeyAscii argument to 0 cancels the keystroke so that the object doesn't recognize that a key was pressed.

Remarks

To run a macro or event procedure when this event occurs, set the OnKeyPress property to the name of the macro or to [Event Procedure].

The object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down an ANSI key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

A KeyPress event can involve any printable keyboard character, the CTRL key combined with a character from the standard alphabet or a special character, and the ENTER or BACKSPACE key. You can use the KeyDown and KeyUp event procedures to handle any keystroke not recognized by the KeyPress event, such as function keys, navigation keys, and any combinations of these with keyboard modifiers (ALT, SHIFT, or CTRL keys). Unlike the KeyDown and KeyUp events, the KeyPress event doesn't indicate the physical state of the keyboard; instead, it indicates the ANSI character that corresponds to the pressed key or key combinations.

KeyPress interprets the uppercase and lowercase of each character as separate key codes and, therefore, as two separate characters.

Note Note

The BACKSPACE key is part of the ANSI character set, but the DEL key isn't. If you delete a character in a control by using the BACKSPACE key, you cause a KeyPress event; if you use the DEL key, you don't.

The KeyDown and KeyPress events occur when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

For example, if you go to a new record and type a character in the first control in the record, the following events occur:

Current (for the new record)

ß

Enter (for the first control in the new record)

ß

GotFocus (for the control)

ß

KeyDown (for the control)

ß

KeyPress (for the control)

ß

BeforeInsert (for the new record in the form)

ß

Change (for the control if it's a text box or combo box)

ß

KeyUp (for the control)

Example

The following example converts text entered in a text box to uppercase as the text is typed in, one character at a time.

To try the example, add the following event procedure to a form that contains a text box named ShipRegion.

VBA Copy code Copy code
Private Sub ShipRegion_KeyPress(KeyAscii As Integer)
 Dim strCharacter As String

 ' Convert ANSI value to character string.
 strCharacter = Chr(KeyAscii)
 ' Convert character to upper case, then to ANSI value.
 KeyAscii = Asc(UCase(strCharacter))
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Entity.Parent Property (Access)

 Copy code hover
[image]

Entity.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Parent

expression A variable that represents an Entity object.

See also

Concepts

Entity Object

Other resources

Entity Object Members


Cannot locate the requested Xbase memo file. (Error 3166)

 Copy code hover
[image]

Cannot locate the requested Xbase memo file. (Error 3166)
Send feedback

You tried to access a dBASE (.dbf) file, but the file's associated memo (.dbt) file could not be found. Make sure the .dbt file is in the same directory as the .dbf file, and then try the operation again.


FROM (Microsoft Access SQL reserved word)

 Copy code hover
[image]

FROM (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The FROM keyword is used in these contexts:

SELECT Statement

DROP USER or GROUP Statement

REVOKE Statement


OptionButton.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

OptionButton.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified option button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthBottom

expression A variable that represents an OptionButton object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


How to: Use Multiple Fields in Criteria Expressions

 Copy code hover
[image]

How to: Use Multiple Fields in Criteria Expressions
Send feedback

You can specify multiple fields in a criteria argument.

To specify multiple fields in the criteria argument, you must ensure that multiple string expressions are concatenated correctly to form a valid SQL WHERE clause. In an SQL WHERE clause with multiple fields, fields may be joined with one of three keywords: AND, OR, or NOT. Your expression must evaluate to a string that includes one of these keywords.

For example, suppose that you want to set the Filter property of an Employees form to display records restricted by two sets of criteria. The following example filters the form so that it displays only those employees whose title is "Sales Representative" and who were hired since January 1, 1993:

Copy code Copy code
Dim datHireDate As Date
Dim strTitle As String

datHireDate = #1/1/93#
strTitle = "Sales Representative"

Forms!Employees.Filter = "[HireDate] >= #" & _
    datHireDate & "# AND [Title] = '" & strTitle & "'"
Forms!Employees.FilterOn = True

The criteria argument evaluates to the following string:

Copy code Copy code
"[HireDate] >= #1-1-93# AND [Title] = 'Sales Representative'"

To troubleshoot an expression in the criteria argument, break the expression into smaller components and test each individually in the Immediate window. When all of the components are working correctly, put them back together one at a time until the complete expression works correctly.


OptionButton.BorderShade Property (Access)

 Copy code hover
[image]

OptionButton.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents an OptionButton object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens BorderColor by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


CheckBox.ReadingOrder Property (Access)

 Copy code hover
[image]

CheckBox.ReadingOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.

Syntax

expression .ReadingOrder

expression A variable that represents a CheckBox object.

Remarks

The ReadingOrder property uses the following settings.

Setting | Visual Basic | Description
Context | 0 | Reading order is determined by the language of the first character entered. If a right-to-left language character is entered first, reading order is right to left. If a left-to-right language character is entered first, reading order is left to right.
Left-to-Right | 1 | Sets the reading order to left to right.
Right-to-Left | 2 | Sets the reading order to right to left.

Example

The following example sets the reading order to right to left for the "Address" text box on the "International Shipping" form.

VBA Copy code Copy code
Forms("International Shipping").Controls("Address").ReadingOrder = 2

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


SmartTagActions Properties (Access)

 Copy code hover
[image]

SmartTagActions Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only SmartTagAction.
Parent | Returns the parent object for the specified object. Read-only.


CheckBox.OldValue Property (Access)

 Copy code hover
[image]

CheckBox.OldValue Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.

Syntax

expression .OldValue

expression A variable that represents a CheckBox object.

Remarks

The OldValue property contains the unedited data from a bound control and is read-only in all views.

Microsoft Access uses the OldValue property to store the original value of a bound control. When you edit a bound control on a form, your changes aren't saved until you move to another record. The OldValue property contains the unedited version of the underlying data.

You can provide your own undo capability by assigning the OldValue property setting to a control. The following example shows how you can undo any changes to text box controls on a form:

VBA Copy code Copy code
Private Sub btnUndo_Click()

 Dim ctlTextbox As Control

 For Each ctlTextbox in Me.Controls
 If ctlTextbox.ControlType = acTextBox Then
 ctlTextbox.Value = ctl.OldValue
 End If
 Next ctlTextbox

End Sub

If the control hasn't been edited, this code has no effect. When you move to another record, the record source is updated, so the current value and the OldValue property will be the same.

The OldValue property setting has the same data type as the field to which the control is bound.

Example

The following example checks to determine if new data entered in a field is within 10 percent of the value of the original data. If the change is greater than 10 percent, the OldValue property is used to restore the original value. This procedure could be called from the BeforeUpdate event of the control that contains data you want to validate.

VBA Copy code Copy code
Public Sub Validate_Field()

 Dim curNewValue As Currency
 Dim curOriginalValue As Currency
 Dim curChange As Currency
 Dim strMsg As String

 curNewValue = Forms!Products!UnitPrice
 curOriginalValue = Forms!Products!UnitPrice.OldValue
 curChange = Abs(curNewValue - curOriginalValue)

 If curChange > (curOriginalValue * .1) Then
 strMsg = "Change is more than 10% of original unit price. " _
 & "Restoring original unit price."
 MsgBox strMsg, vbExclamation, "Invalid change."
 Forms!Products!UnitPrice = curOriginalValue
 End If

End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ToggleButton.ForeTint Property (Access)

 Copy code hover
[image]

ToggleButton.ForeTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .ForeTint

expression A variable that represents a ToggleButton object.

Remarks

The ForeTint property contains a numeric expression that can be used to lighten the theme color in the ForeColor property. The default value of the ForeTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the ForeColor by 75%.

VBA Copy code Copy code
Me.ctl.ForeTint=25

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


ObjectTypeEnum

 Copy code hover
[image]

ObjectTypeEnum
Send feedback

Specifies the type of database object for which to set permissions or ownership.

Constant | Value | Description
adPermObjColumn | 2 | The object is a column.
adPermObjDatabase | 3 | The object is a database.
adPermObjProcedure | 4 | The object is a procedure.
adPermObjProviderSpecific | -1 | The object is a type defined by the provider. An error will occur if the ObjectType parameter is adPermObjProviderSpecific and an ObjectTypeId is not supplied.
adPermObjTable | 1 | The object is a table.
adPermObjView | 5 | The object is a view.


ComboBox.GridlineTint Property (Access)

 Copy code hover
[image]

ComboBox.GridlineTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineTint

expression A variable that represents a ComboBox object.

Remarks

The GridlineTint property contains a numeric expression that can be used to lighten the theme color in the GridlineColor property. The default value of the GridlineTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Circular reference caused by alias

 Copy code hover
[image]

Circular reference caused by alias <name> in query definition's SELECT list. (Error 3103)
Send feedback

The specified alias created a reference that cannot be resolved. This error can occur, for example, if you enter the following SQL statement, in which A is the circular reference:

SQL Copy code Copy code
SELECT A + B AS C, C + D AS E, E + F AS A

FROM MyTable;
SQL Copy code Copy code
SELECT week1 + week2 as hours, hours + overtime as gross, gross + ytdpay as week1FROM EmployeePay


WebBrowserControl.VerticalAnchor Property (Access)

 Copy code hover
[image]

WebBrowserControl.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified text box is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2010

Syntax

expression .VerticalAnchor

expression A variable that represents a WebBrowserControl object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


AccessObjectProperty Object (Access)

 Copy code hover
[image]

AccessObjectProperty Object (Access)
See also Send feedback

Published: July 16, 2012

An AccessObjectProperty object represents a built-in or user-defined characteristic of an AccessObject object.

Remarks

Every AccessObject object contains an AccessObjectProperties collection that has AccessObjectProperty objects corresponding to the properties of that AccessObject object. The user can also define AccessObjectProperty objects and append them to the AccessObjectProperties collection of some AccessObject objects.

You can create user-defined properties for the following objects:

  • CodeData, CodeProject, CurrentProject, and CurrentData objects

  • AccessObject objects in the following collections.

    CurrentProject and CodeProject object collections

    CodeData and CodeProject object collections

    AllForms

    AllQueries

    AllReports

    AllViews

    AllMacros

    AllStoredProcedures

    AllModules

    AllDatabaseDiagrams

    AllTables

Note Note

The AccessObjectProperties collection isn't accessible for objects derived from the CurrentData object (for example, CurrentData.AllTables!Table1). For objects derived in this manner, you can only access their built-in properties by direct calls to the desired property (for example, CurrentData.AllTables!Table1.Name).

To add a user-defined property, use the Add method to create and add an AccessObjectProperty object with a unique Name property setting and Value property of the new AccessObjectProperty object to the AccessObjectProperties collection of the appropriate object. The object to which you are adding the user-defined property must already be appended to a collection. Referencing a user-defined AccessObjectProperty object that has not yet been appended to an AccessObjectProperties collection will cause an error, as will appending a user-defined AccessObjectProperty object to an AccessObjectProperties collection containing an AccessObjectProperty object of the same name.

You can delete user-defined properties from the AccessObjectProperties collection.

Note Note

A user-defined AccessObjectProperty object is associated only with the specific instance of an object. The property isn't defined for all instances of objects of the selected type.

The AccessObjectProperty object has two built-in properties:

  • The Name property, a String that uniquely identifies the property.

  • The Value property, a Variant that contains the property setting.

To refer to a built-in or user-defined AccessObjectProperty object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

VBA Copy code Copy code
CurrentProject.AllForms("Form1").Properties(0)
CurrentProject.AllForms("Form1").Properties("name")
CurrentProject.AllForms("Form1").Properties![name]

With the same syntax forms, you can also refer to the Value property of a AccessObjectProperty object. The context of the reference will determine whether you are referring to the AccessObjectProperty object itself or the Value property of the AccessObjectProperty object.

Note Note

Properties in the AccessObjectProperties collection are not stored and can be lost when when the object they are associated with is checked in or out using the Source Code Control add-in.

See also

Concepts

Access Object Model Reference

Other resources

AccessObjectProperty Object Members


Data Shaping Summary

 Copy code hover
[image]

Data Shaping Summary
Send feedback

The following sections describe concepts of data shaping, hierarchical recordsets, reshaping, grandchild aggregates, parameterized shapes, and saving shapes to files.

  • Data Shaping

  • Reshaping

  • Grandchild Aggregates

  • Parameterized Commands with Intervening COMPUTE Commands

  • Persisting Hierarchical Recordsets


OptionButton Properties (Access)

 Copy code hover
[image]

OptionButton Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the option button and its bottom gridline. Read/write Integer.
ColumnHidden | You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.
ColumnOrder | You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.
ColumnWidth | You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DefaultValue | Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
GridlineColor | Gets or sets the color of the gridline for the specified option button. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified option button. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified option button. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified option button. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified option button. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified option button. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified option button. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified option button. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified option button. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HideDuplicates | You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the option button is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified option button. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified option button. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the option button and its left gridline. Read/write Integer.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OptionValue | Each control in an option group has a numeric value that you can set with the OptionValue property. Read/write Long.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
RightPadding | Gets or sets the amount of space (in inches) between the option button and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the option button and its top gridline. Read/write Integer.
TripleState | You can use the TripleState property to specify how the specified control will display Null values. Read/write Boolean.
ValidationRule | You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.
ValidationText | Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.
Value | Determines or specifies whether or not the specified option button is selected. Read/write Variant.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified option button is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


Position Properties, Methods, and Events (ADO MD)

 Copy code hover
[image]

Position Properties, Methods, and Events (ADO MD)
Send feedback

Properties/Collections

Members Collection

Ordinal Property (Position)

Methods

None.

Events

None.


In the text file specification

 Copy code hover
[image]

In the text file specification <name>, the <name> option is invalid. (Error 3442)
Send feedback

One of the options in the text file specification for the Text ISAM is invalid. The specification can be set in a number of ways:

  • From Microsoft Access, these values are set in the Link Text wizard. You can also see them in the system tables MSysIMEXSpecs and MSysIMEXColumns.


Comparison of Data Types

 Copy code hover
[image]

Comparison of Data Types
Send feedback

The Microsoft Access database engine recognizes several overlapping sets of data types. In Microsoft Access, there are four different contexts in which you may need to specify a data type — in table Design view, in the Query Parameters dialog box, in Visual Basic, and in SQL view in a query.

The following table compares the five sets of data types that correspond to each context. The first column lists the Type property settings available in table Design view and the five FieldSize property settings for the Number data type. The second column lists the corresponding query parameter data types available for designing parameter queries in the Query Parameters dialog box. The third column lists the corresponding Visual Basic data types. The fourth column lists ADO Field object data types. The fifth column lists the corresponding Jet database engine SQL data types defined by the Access database engine along with their valid synonyms.

Table fields | Query parameters | Visual Basic | ADO Data Type property constants | Microsoft Access database engine SQL and synonyms
Not supported | Binary | Not supported | adBinary | BINARY (See Notes) (Synonym: VARBINARY)
Yes/No | Yes/No | Boolean | adBoolean | BOOLEAN (Synonyms: BIT, LOGICAL, LOGICAL1, YESNO)
Number (FieldSize = Byte) | Byte | Byte | adUnsignedTinyInt | BYTE (Synonym: INTEGER1)
AutoNumber (FieldSize= Long Integer) | Long Integer | Long | adInteger | COUNTER (Synonym: AUTOINCREMENT)
Currency | Currency | Currency | adCurrency | CURRENCY (Synonym: MONEY)
Date/Time | Date/Time | Date | adDate | DATETIME (Synonyms: DATE, TIME, TIMESTAMP)
Number (FieldSize = Double) | Double | Double | adDouble | DOUBLE (Synonyms: FLOAT, FLOAT8, IEEEDOUBLE, NUMBER, NUMERIC)
AutoNumber /GUID (FieldSize = Replication ID) | Replication ID | Not supported | adGUID | GUID
Number (FieldSize = Long Integer) | Long Integer | Long | adInteger | LONG (See Notes) (Synonyms: INT, INTEGER, INTEGER4)
OLE Object | OLE Object | String | adLongVarBinary | LONGBINARY (Synonyms: GENERAL, OLEOBJECT)
Memo | Memo | String | adLongVarWChar | LONGTEXT (Synonyms: LONGCHAR, MEMO, NOTE)
Number (FieldSize = Single) | Single | Single | adSingle | SINGLE (Synonyms: FLOAT4, IEEESINGLE, REAL)
Number (FieldSize = Integer) | Integer | Integer | adSmallInt | SHORT (See Notes) (Synonyms: INTEGER2, SMALLINT)
Text | Text | String | adVarWChar | TEXT (Synonyms: ALPHANUMERIC, CHAR, CHARACTER, STRING, VARCHAR)
Hyperlink | Memo | String | adLongVarWChar | LONGTEXT (Synonyms: LONGCHAR, MEMO, NOTE)
Not supported | Value | Variant | adVariant | VALUE (See Notes)
Note Note

  • Microsoft Access itself doesn't use the BINARY data type. It's recognized only for use in queries on linked tables from other database products that support the BINARY data type.

  • The INTEGER data type in the Access database engine SQL doesn't correspond to the Integer data type for table fields, query parameters, or Visual Basic. Instead, in SQL, the INTEGER data type corresponds to a Long Integer data type for table fields and query parameters and to a Long data type in Visual Basic.

  • The VALUE reserved word doesn't represent a data type defined by the Access database engine. However, in Microsoft Access or SQL queries, the VALUE reserved word can be considered a valid synonym for the Visual Basic Variant data type.

  • If you are setting the data type for a DAO object in Visual Basic code, you must set the object's Type property.


Control.Name Property (Access)

 Copy code hover
[image]

Control.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.

Syntax

expression .Name

expression A variable that represents a Control object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For controls, the name may be as long as 255 characters.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

Control Object

Other resources

Control Object Members


Refresh Method Example (VBScript)

 Copy code hover
[image]

Refresh Method Example (VBScript)
Send feedback

The following example shows how to set the necessary parameters of RDS.DataControl at run time. The manner in which a Recordset is retrieved using the Refresh method is determined by the settings of the ExecuteOptions and FetchOptions properties. To test this example, cut and paste the following code into a normal ASP document and name it RefreshVBS.asp. Use Find to locate the file Adovbs.inc and place it in the directory you plan to use. ASP script will identify your server.

VBS Copy code Copy code
<!-- BeginRefreshVBS --><%@ Language=VBScript %>
<!--use the following META tag instead of adovbs.inc--><!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->
<html><head>
<meta name="VI60_DefaultClientScript" content=VBScript><meta name="GENERATOR" content="Microsoft Visual Studio 6.0">
<title>Refresh Method Example (VBScript)</title><style>
<!--body {
font-family: 'Verdana','Arial','Helvetica',sans-serif;BACKGROUND-COLOR:white;
COLOR:black;}
.thead {background-color: #008080;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.thead2 {background-color: #800000;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.tbody {text-align: center;
background-color: #f7efde;font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;}
--></style>
</head>
<body><h1>Refresh Method Example (VBScript)</h1>
<H2>RDS API Code Examples </H2><HR>
<TABLE DATASRC=#RDC><TR>
<TD> <INPUT DATAFLD="FirstName" SIZE=15> </TD><TD> <INPUT DATAFLD="LastName" SIZE=15> </TD>
<TD> <INPUT DATAFLD="Title" SIZE=15> </TD><TD> <INPUT DATAFLD="HireDate" SIZE=15> </TD>
</TR></TABLE>
<!-- RDS.DataControl with no parameters set at design time --><OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
ID=RDC HEIGHT=1 WIDTH=1></OBJECT>
<HR>Server: <Input Size=70 Name="txtServer" Value="http://<%=Request.ServerVariables("SERVER_NAME")%>"><BR>
Connect: <Input Size=70 Name="txtConnect" Value="Provider='sqloledb';Integrated Security='SSPI';Initial Catalog='Northwind'"><BR>SQL: <Input Size=70 Name="txtSQL" Value="Select * from Employees">
<HR><TABLE BORDER=1 WIDTH="60%">
<TR><TD COLSPAN=3 BGCOLOR=silver>
Choose if you want the Recordset brought back Synchronously on thecurrent calling thread or Asynchronously on another thread.
</TD></TR>
<TR><TD>Synchronously: <BR>
<Input Type="Radio" Name="optExecuteOptions" Checked OnClick="SetExO('adcExecSync')"></TD>
<TD>Asynchronously: <BR><Input Type="Radio" Name="optExecuteOptions" OnClick="SetExO('adcExecAsync')">
</TD><TD>&nbsp;</TD>
</TR><TR>
<TD COLSPAN=3 BGCOLOR=silver>Fetch Up Front, Background Fetch with Blocking or Background Fetch
without Blocking</TD>
<TR><TD>Up Front:<BR>
<Input Type="Radio" Name="optFetchOptions" OnClick="SetFO('adcFetchUpFront')"></TD>
<TD>Background w/ Blocking:<BR><Input Type="Radio" Name="optFetchOptions" Checked OnClick="SetFO('adcFetchBackground')">
</TD><TD>Background w/o Blocking:<BR>
<Input Type="Radio" Name="optFetchOptions" OnClick="SetFO('adcFetchAsync')"></TD>
</TR></TABLE>
<INPUT TYPE=BUTTON NAME="Run" VALUE="Run"><BR>
<Script Language="VBScript"><!--
Dim EO 'ExecuteOptionsDim FO 'FetchOptions
EO = "adcExecSync" 'Default valueFO = "adcFetchBackground" 'Default value
Sub SetExO(NewEO)EO = NewEO
End Sub
Sub SetFO(NewFO)FO = NewFO
End Sub
' Set parameters of RDS.DataControl at Run TimeSub Run_OnClick
RDC.Server = txtServer.ValueRDC.SQL = txtSQL.Value
RDC.Connect = txtConnect.ValueIf EO = "adcExecSync" Then 'Determine which ExecuteOption chosen
RDC.ExecuteOptions = adcExecSyncMsgBox "Recordset brought in on current calling thread Syncronously"
ElseRDC.ExecuteOptions = adcExecAsync
MsgBox "Recordset brought in on another thread Asyncronously"End If
If FO = "adcFetchBackground" Then 'Determine 'which FetchOption chosenRDC.FetchOptions = adcFetchBackground
MsgBox "Control goes back to user after first batch of records returned"ElseIf FO = " adcFetchUpFront" Then
RDC.FetchOptions = adcFetchUpFrontMsgBox "All records returned before control goes back to user"
ElseRDC.FetchOptions = adcFetchAsync
MsgBox "Control goes back to user immediately"End If
RDC.RefreshEnd Sub
--></Script>
</body></html>
<!-- EndRefreshVBS -->


SmartTag Methods (Access)

 Copy code hover
[image]

SmartTag Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Delete | Deletes the specified object.


The ReplicaID for this member of the replica set was reassigned during a move or copy procedure. (Error 3574)

 Copy code hover
[image]

The ReplicaID for this member of the replica set was reassigned during a move or copy procedure. (Error 3574)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


TextBox.Requery Method (Access)

 Copy code hover
[image]

TextBox.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.

Syntax

expression .Requery

expression A variable that represents a TextBox object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts .

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate function.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

Example

The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form:

VBA Copy code Copy code
Public Sub RequeryList()

    Dim ctlCombo As Control

    ' Return Control object pointing to a combo box.
    Set ctlCombo = Forms!Employees!ReportsTo

    ' Requery source of data for list box.
    ctlCombo.Requery

End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


AcPrintItemLayout Enumeration (Access)

 Copy code hover
[image]

AcPrintItemLayout Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the ItemLayout property to specify how columns are laid out when printing.

Name | Value | Description
acPRHorizontalColumnLayout | 1953 | Columns are laid across, then down.
acPRVerticalColumnLayout | 1954 | Columns are laid down, then across.


Attachment.LostFocus Event (Access)

 Copy code hover
[image]

Attachment.LostFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The LostFocus event occurs when the specified object receives the focus.

Version Information

Version Added: Access 2007

Syntax

expression .LostFocus

expression A variable that represents an Attachment object.

Remarks

To run a macro or event procedure when these events occur, set the OnLostFocus property to the name of the macro or to [Event Procedure].

This event occurs when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The LostFocus event differs from the Exit event in that the LostFocus event occurs every time a control loses the focus. The Exit event occurs only before a control loses the focus to another control on the same form. The LostFocus event occurs after the Exit event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control to which you moved.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform to which the focus moved)

ß

GotFocus (for the control on the subform to which the focus moved)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Error (ADO/WFC Syntax)

 Copy code hover
[image]

Error (ADO/WFC Syntax)
Send feedback

package com.ms.wfc.data

Properties

Copy code Copy code

public String Invalid DDUE based on source, error:link not allowed in code, link filename:mdprodescription_HV10294309.xml()
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdpronativeerror_HV10294539.xml()
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdpronumber_HV10294545.xml()
public String Invalid DDUE based on source, error:link not allowed in code, link filename:mdproerrsource_HV10294791.xml()
public String Invalid DDUE based on source, error:link not allowed in code, link filename:mdprosqlstate_HV10294801.xml()


TempVars.Item Property (Access)

 Copy code hover
[image]

TempVars.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only TempVar.

Version Information

Version Added: Access 2007

Syntax

expression .Item(Index)

expression A variable that represents a TempVars object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection.

See also

Concepts

TempVars Collection

Other resources

TempVars Object Members


QueryDef.Close Method (DAO)

 Copy code hover
[image]

QueryDef.Close Method (DAO)
Send feedback

Closes an open QueryDef.

Syntax

expression .Close

expression A variable that represents a QueryDef object.

Remarks

If the QueryDef object is already closed when you use Close, a run-time error occurs.

An alternative to the Close method is to set the value of an object variable to Nothing (Set dbsTemp = Nothing).


Table Field

 Copy code hover
[image]

Table Field
Send feedback

Published: July 16, 2012

Table fields are separate pieces of information that make up a record within a table. You can control the appearance of data, specify default values, and speed up searching and sorting by setting field properties in the Field Properties section of table Design view.

Microsoft Access uses field properties when you view or edit data. For example, the Format, InputMask, and Caption properties that you set affect the appearance of table and query databases. The controls on new forms and reports that are based on the table inherit these properties by default. You can use other properties to set rules for data or to require data entry in your fields, which Microsoft Access enforces whenever you add or edit data in a table.


Report.MoveLayout Property (Access)

 Copy code hover
[image]

Report.MoveLayout Property (Access)
See also Send feedback

Published: July 16, 2012

The MoveLayout property specifies whether Microsoft Access should move to the next printing location on the page. Read/write Boolean.

Syntax

expression .MoveLayout

expression A variable that represents a Report object.

Remarks

The MoveLayout property uses the following settings.

Setting | Description
True | (Default) The section's Left and Top properties are advanced to the next print location.
False | The section's Left and Top properties are unchanged.

To set this property, specify an event procedure for a section's OnFormat property.

Microsoft Access sets this property to True before each section's Format event.

Example

The following example sets the MoveLayout property for the "Purchase Order" report to its default setting.

VBA Copy code Copy code
Reports("Purchase Order").MoveLayout = True

See also

Concepts

Report Object

Other resources

Report Object Members


Cannot designate a partial replica as the Design Master for the replica set. (Error 3479)

 Copy code hover
[image]

Cannot designate a partial replica as the Design Master for the replica set. (Error 3479)
Send feedback

Select a different replica to become the Design Master.


BeginTrans, CommitTrans, and RollbackTrans Methods Example (VC++)

 Copy code hover
[image]

BeginTrans, CommitTrans, and RollbackTrans Methods Example (VC++)
Send feedback

This example changes the book type of all psychology books in the Titles table of the database. After the BeginTrans method starts a transaction that isolates all the changes made to the Titles table, the CommitTrans method saves the changes. You can use the RollbackTrans method to undo changes that you saved using the Update method.

Copy code Copy code

// BeginBeginTransCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <stdio.h>
#include <ole2.h>
#include <conio.h>
#include <assert.h>
#include <malloc.h>
#include "BeginTransX.h"

inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void BeginTransX(void);
void PrintProviderError(_ConnectionPtr pConnection);

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 BeginTransX();

 //Wait here for user to see the output.
 printf("\nPress any key to continue...");
 getch();

 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// BeginTransX Function //
// //
///////////////////////////////////////////////////////////

void BeginTransX()
{
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr rstTitles = NULL;
 _ConnectionPtr pConnection = NULL;

 //Define Other Variables
 HRESULT hr = S_OK;
 IADORecordBinding *picRs = NULL; //Interface Pointer declared...
 CTitlesRs titlrs;
 _bstr_t strTitle;
 _bstr_t strMessage;
 LPSTR p_TempStr = NULL;
 char chKey;
 int i = 0;

 try
 {
 // open connection.
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));

 TESTHR(pConnection->Open(strCnn,"","",adConnectUnspecified));

 rstTitles.CreateInstance(__uuidof(Recordset));

 rstTitles->CursorType = adOpenDynamic;
 rstTitles->LockType = adLockPessimistic;

 // open Titles table
 TESTHR(rstTitles->Open("titles",
 _variant_t((IDispatch*)pConnection,true),
 adOpenDynamic, adLockPessimistic,adCmdTable));

 rstTitles->MoveFirst();
 pConnection->BeginTrans();

 //Open an IADORecordBinding interface pointer which
 //we'll use for Binding Recordset to a class
 TESTHR(rstTitles->QueryInterface(
 __uuidof(IADORecordBinding), (LPVOID*)&picRs));

 //Bind the Recordset to a C++ Class here
 TESTHR(picRs->BindToRecordset(&titlrs));

 // Loop through recordset and ask user if he wants
 // to change the type for a specified title.
 // Allocate memory to p_TempStr string pointer.
 p_TempStr = (LPSTR) malloc(sizeof(titlrs.m_szT_type));

 // Check for null string.
 assert(p_TempStr != NULL);
 while (VARIANT_FALSE == rstTitles->EndOfFile)
 {
 // Set the final character of the destination string to NULL.
 p_TempStr[sizeof(titlrs.m_szT_type)-1] = '\0';
 // The source string will get truncated if its length is
 // longer than the length of the destination string minus one.
 strncpy(p_TempStr,strtok(titlrs.m_szT_type," "),sizeof(titlrs.m_szT_type)-1);

 // Compare type with psychology
 if (!strcmp(p_TempStr,"psychology"))
 {
 strTitle = titlrs.m_szT_title;
 strMessage = "Title: " + strTitle +
 "\n Change type to Self help?(y/n)";

 // Change the title for specified employee
 printf("%s\n",(LPCSTR)strMessage);
 do
 {
 chKey = getch();
 }while(chKey != 'y' && chKey !='n');
 if(chKey == 'y')
 {
 // Set the final character of the destination string to NULL.
 titlrs.m_szT_type[sizeof(titlrs.m_szT_type)-1] = '\0';
 // Copy "self_help" title field.
 // The source string will get truncated if its length is
 // longer than the length of the destination string minus one.
 strncpy(titlrs.m_szT_type,"self_help", sizeof(titlrs.m_szT_type)-1);
 picRs->Update(&titlrs);
 }
 }
 rstTitles->MoveNext();
 }
 // Ask if the User wants to commit to all the
 // changes made above
 printf("\n\n Save all changes(y/n)?");
 do
 {
 chKey = getch();
 }while(chKey != 'y' && chKey !='n');

 if(chKey == 'y')

 // Save the changes to the title table
 pConnection->CommitTrans();
 else
 // Unsave the changes to the title table
 pConnection->RollbackTrans();

 // Print current data in recordset.
 rstTitles->Requery(0);

 // Move to the first record of the title table
 rstTitles->MoveFirst();
 printf("\n\nPress any key to continue...");
 getch();

 // Clear the screen for the next display
 //system("cls");

 // Open IADORecordBinding interface pointer again
 // for binding Recordset to a class.
 TESTHR(rstTitles->QueryInterface(
 __uuidof(IADORecordBinding),
 (LPVOID*)&picRs));

 // Rebind the Recordset to a C++ Class.
 TESTHR(picRs->BindToRecordset(&titlrs));

 while (!rstTitles->EndOfFile)
 {
 i= i+1;
 if (i % 23 == 0)
 {
 printf("\nPress any key to continue...");
 getch();

 //Clear the screen for the next display
 //system("cls");
 }
 printf("%s - %s\n",titlrs.m_szT_title,titlrs.m_szT_type);
 rstTitles->MoveNext();
 }
 // Restore original data becasue this is a demonstration.
 rstTitles->MoveFirst();

 while (VARIANT_FALSE == rstTitles->EndOfFile)
 {
 // Set the final character of the destination string to NULL.
 p_TempStr[sizeof(titlrs.m_szT_type)-1] = '\0';
 // The source string will get truncated if its length is
 // longer than the length of the destination string minus one.
 strncpy(p_TempStr,titlrs.m_szT_type,sizeof(titlrs.m_szT_type)-1);
 p_TempStr = strtok(p_TempStr," ");

 if (!strcmp(p_TempStr,"self_help"))
 {
 // Set the final character of the destination string to NULL.
 titlrs.m_szT_type[sizeof(titlrs.m_szT_type)-1] = '\0';
 // The source string will get truncated if its length is
 // longer than the length of the destination string minus one.
 strncpy(titlrs.m_szT_type,"psychology",sizeof(titlrs.m_szT_type)-1);
 picRs->Update(&titlrs);
 }
 rstTitles->MoveNext();
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 PrintProviderError(pConnection);

 printf("Source : %s\n",(LPCSTR)bstrSource);
 printf("Description : %s\n",(LPCSTR)bstrDescription);
 }

 // Deallocate the memory
 if (p_TempStr)
 free(p_TempStr);
 // Clean up objects before exit.
 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (rstTitles)
 if (rstTitles->State == adStateOpen)
 rstTitles->Close();
 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
};

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;
 long nCount = 0;
 long i = 0;

 if( (pConnection->Errors->Count) > 0)
 {
 nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n", pErr->Number,(LPCSTR) pErr->Description);
 }
 }
}
// EndBeginTransCpp

BeginTransX.h

Copy code Copy code

// BeginBeginTransH
#include "icrsint.h"

//This Class extracts only title and type
class CTitlesRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CTitlesRs)
 //Column title is the 2nd field in the recordset
 ADO_VARIABLE_LENGTH_ENTRY2(2, adVarChar, m_szT_title,
 sizeof(m_szT_title), lT_titleStatus, FALSE)

 //Column type is the 3rd field in the recordset
 ADO_VARIABLE_LENGTH_ENTRY2(3, adVarChar, m_szT_type,
 sizeof(m_szT_type), lT_typeStatus, TRUE)
END_ADO_BINDING()

public:
 CHAR m_szT_title[150];
 ULONG lT_titleStatus;
 CHAR m_szT_type[40];
 ULONG lT_typeStatus;
};
// EndBeginTransH


Form.PictureSizeMode Property (Access)

 Copy code hover
[image]

Form.PictureSizeMode Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureSizeMode property to specify how a picture for a form or report is sized. Read/write Byte.

Syntax

expression .PictureSizeMode

expression A variable that represents a Form object.

Remarks

The PictureSizeMode property uses the following settings.

Setting | Visual Basic | Description
Clip | 0 | (Default) The picture is displayed in its actual size. If the picture is larger than the form or report, then the picture is clipped.
Stretch | 1 | The picture is stretched horizontally and vertically to fill the entire form, even if its original ratio of height to width is distorted.
Zoom | 3 | The picture is enlarged to the maximum extent possible while keeping its original ratio of height to width.
Stretch Horizontal | 4 | The picture is stretched horizontally to fit the width of the form.
Stretch Vertical | 5 | The picture is stretched vertically to fit the height of the form.

When a small picture is used for the Picture property of a form or report, setting the PictureSizeMode property to Stretch or Zoom can cause substantial distortion of its resolution. Smaller pictures can be tiled across the entire form or report by using the PictureTiling property.

Example

The following example sets the background picture of the "Order Entry" form to "Contacts.gif", and stretches the picture to fit the entire form's background.

VBA Copy code Copy code
With Forms("Order Entry")
 .Picture = "C:\Picture Files\Contacts.gif"
 .PictureSizeMode = 1
End With

See also

Concepts

Form Object

Other resources

Form Object Members


CheckBox.OnLostFocus Property (Access)

 Copy code hover
[image]

CheckBox.OnLostFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnLostFocus

expression A variable that represents a CheckBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The LostFocus event occurs when the object loses the focus.

The OnLostFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Lost Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Lost Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnLostFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnLostFocus

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ADO Code Examples in Microsoft Visual J++ (Access)

 Copy code hover
[image]

ADO Code Examples in Microsoft Visual J++ (Access)
Send feedback

In this section

  • ADO Code Examples in Microsoft Visual J++

  • AbsolutePage, PageCount, and PageSize Properties Example (VJ++)

  • AbsolutePosition and CursorLocation Properties Example (VJ++)

  • ActiveCommand Property Example (VJ++)

  • ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction Properties Example (VJ++)

  • ActualSize and DefinedSize Properties Example (VJ++)

  • AddNew Method Example (VJ++)

  • Append and CreateParameter Methods Example (VJ++)

  • AppendChunk and GetChunk Methods Example (VJ++)

  • Attributes and Name Properties Example (VJ++)

  • BeginTrans, CommitTrans, and RollbackTrans Methods Example (VJ++)

  • BOF, EOF, and Bookmark Properties Example (VJ++)

  • CacheSize Property Example (VJ++)

  • Cancel Method Example (VJ++)

  • Clone Method Example (VJ++)

  • CompareBookmarks Method Example (VJ++)

  • ConnectionString, ConnectionTimeout, and State Properties Example (VJ++)

  • Count Property Example (VJ++)

  • CursorType, LockType, and EditMode Properties Example (VJ++)

  • Delete Method Example (VJ++)

  • Description, HelpContext, HelpFile, NativeError, Number, Source, and SQLState Properties Example (VJ++)

  • Execute, Requery, and Clear Methods Example (VJ++)

  • Filter and RecordCount Properties Example (VJ++)

  • Find Method Example (VJ++)

  • GetRows Method Example (VJ++)

  • GetString Method Example (VJ++)

  • IsolationLevel and Mode Properties Example (VJ++)

  • Item Property Example (VJ++)

  • MarshalOptions Property Example (VJ++)

  • MaxRecords Property Example (VJ++)

  • Move Method Example (VJ++)

  • MoveFirst, MoveLast, MoveNext, and MovePrevious Methods Example (VJ++)

  • NextRecordset Method Example (VJ++)

  • NumericScale and Precision Properties Example (VJ++)

  • Open and Close Methods Example (VJ++)

  • OpenSchema Method Example (VJ++)

  • Optimize Property Example (VJ++)

  • OriginalValue and UnderlyingValue Properties Example (VJ++)

  • Prepared Property Example (VJ++)

  • Provider and DefaultDatabase Properties Example (VJ++)

  • Refresh Method Example (VJ++)

  • Resync Method Example (VJ++)

  • Save and Open Methods Example (VJ++)

  • Sort Property Example (VJ++)

  • Source Property Example (VJ++)

  • State Property Example (VJ++)

  • Status Property Example (VJ++)

  • StayInSync Property Example (VJ++)

  • Supports Method Example (VJ++)

  • Update and CancelUpdate Methods Example (VJ++)

  • UpdateBatch and CancelBatch Methods Example (VJ++)

  • Value Property Example (VJ++)

  • Version Property Example (VJ++)


WebBrowserControl.OnMouseDown Property (Access)

 Copy code hover
[image]

WebBrowserControl.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnMouseDown

expression A variable that represents a WebBrowserControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


NavigationButton.Click Event (Access)

 Copy code hover
[image]

NavigationButton.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Version Information

Version Added: Access 2010

Syntax

expression .Click

expression A variable that represents a NavigationButton object.

Return Value

nothing

Remarks

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Could not start transaction; too many transactions already nested. (Error 3003)

 Copy code hover
[image]

Could not start transaction; too many transactions already nested. (Error 3003)
Send feedback

You tried to nest a transaction more than five levels deep. Use the CommitTrans or Rollback method to save or roll back the current before you begin another one.


Field.CreateProperty Method (DAO)

 Copy code hover
[image]

Field.CreateProperty Method (DAO)
Send feedback

Creates a new user-defined Property object (Microsoft Access workspaces only).

Syntax

expression .CreateProperty(Name, Type, Value, DDL)

expression A variable that represents a Field object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Optional | Variant | A String that uniquely names the new Property object. See the Name property for details on valid Property names.
Type | Optional | Variant | A constant that defines the data type of the new Property object. See the Type property for valid data types.
Value | Optional | Variant | A Variant containing the initial property value. See the Value property for details.
DDL | Optional | Variant | A Variant (Boolean subtype) that indicates whether or not the Property is a DDL object. The default is False. If DDL is True, users can't change or delete this Property object unless they have dbSecWriteDef permission.

Return Value

Property

Remarks

You can create a user-defined Property object only in the Properties collection of an object that is persistent.

If you omit one or more of the optional parts when you use CreateProperty, you can use an appropriate assignment statement to set or reset the corresponding property before you append the new object to a collection. After you append the object, you can alter some but not all of its property settings. See the Name, Type, and Value property topics for more details.

If name refers to an object that is already a member of the collection, a run-time error occurs when you use the Append method.

To remove a user-defined Property object from the collection, use the Delete method on the Properties collection. You can't delete built-in properties.

Note Note

If you omit the DDL argument, it defaults to False (non-DDL). Because no corresponding DDL property is exposed, you must delete and re-create a Property object you want to change from DDL to non-DDL.


Use International Date Formats in SQL Statements

 Copy code hover
[image]

Use International Date Formats in SQL Statements
Send feedback

You must use English (United States) date formats in SQL statements in Visual Basic. However, you can use international date formats in the query design grid.


TabControl.ThemeFontIndex Property (Access)

 Copy code hover
[image]

TabControl.ThemeFontIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ThemeFontIndex

expression A variable that represents a TabControl object.

Remarks

The ThemeFontIndex property uses one of the values listed in the following table.

Value | Description
0 | Header font
1 (Default) | Detail font

If no theme is applied, the ThemeFontIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


WebBrowserControl.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

WebBrowserControl.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified list box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleBottom

expression A variable that represents a WebBrowserControl object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


StartNewWorkflow Macro Action

 Copy code hover
[image]

StartNewWorkflow Macro Action
Send feedback

You can use the StartNewWorkflow action to start a new workflow for an item in a linked Microsoft SharePoint Foundation list.

Setting

The StartNewWorkflow action has the following argument.

Action argument | Description
Record Number | The position of the item in the SharePoint Foundation list, starting with 1 for the first item in the list, 2 for the second item, and so on. You can also enter an expression for this argument.

Remarks

  • The StartNewWorkflow action opens the Start New Workflow dialog box. This dialog box displays all workflows that are available for the specified item. A workflow must be defined for the list in SharePoint Foundation before you can start it using this action.

  • The StartNewWorkflow action can only be used after a linked SharePoint list has been opened and selected. To open and select the linked list, use the OpenTable action. If the list is already open, use the SelectObject action to select it.

  • The StartNewWorkflow action has the same effect as right-clicking any cell in a linked SharePoint list while it is open in Datasheet view, pointing to Workflow, and then clicking Start New Workflow.

  • To run the StartNewWorkflow action in a VBA module, use the StartNewWorkflow method of the DoCmd object.


Appendix A: Providers

 Copy code hover
[image]

Appendix A: Providers
Send feedback

This section addresses three kinds of providers: data providers, service providers, and service components. Providers fall into two categories: those providing data and those providing services. A data provider owns its own data and exposes it in tabular form to your application. A service provider encapsulates a service by producing and consuming data, augmenting features in your ADO applications. A service provider may also be further defined as a service component, which must work in conjunction with other service providers or components.

Data Providers

ADO is powerful and flexible because it can connect to any of several different data providers and still expose the same programming model, regardless of the specific features of any given provider.

However, because each data provider is unique, how your application interacts with ADO will vary slightly by data provider. The differences usually fall into one of three categories:

  • Connection parameters in the ConnectionString property.

  • Command object usage.

  • Provider-specific Recordset behavior.

Details for each of the data providers currently available from Microsoft are listed as follows.

Area | Topic
ODBC databases | Microsoft OLE DB Provider for ODBC
Microsoft Indexing Service | Microsoft OLE DB Provider for Microsoft Indexing Service
Microsoft Active Directory Service | Microsoft OLE DB Provider for Microsoft Active Directory Service
Microsoft Jet databases | OLE DB Provider for Microsoft Jet
Microsoft SQL Server | Microsoft OLE DB Provider for SQL Server
Oracle databases | Microsoft OLE DB Provider for Oracle
Internet Publishing | Microsoft OLE DB Provider for Internet Publishing

Provider-Specific Dynamic Properties

The Properties collections of the Connection, Command, and Recordset objects include dynamic properties specific to the provider. These properties provide information about functionality specific to the provider beyond the built-in properties that ADO supports.

After establishing the connection and creating these objects, use the Refresh method on the object's Properties collection to obtain the provider-specific properties. Refer to the provider documentation and the OLE DB Programmer's Reference for detailed information about these dynamic properties.

Service Providers

To use a service provider, you must supply a keyword. You should also be aware of the provider-specific dynamic properties associated with each service provider. Provider-specific details are listed for each of the service providers currently available from Microsoft:

  • Microsoft Data Shaping Service for OLE DB

  • Microsoft OLE DB Persistence Provider

  • Microsoft OLE DB Remoting Provider

Service Components

The Cursor Service for OLE DB service component supplements the cursor support functions of data providers. It also requires a keyword and has dynamic properties.

For more information about providers, see the documentation for Microsoft OLE DB in the Microsoft Data Access Components SDK or visit the Data Platform Developer Center.

Provider Commands

For each provider listed here, if your applications allow users to enter SQL statements as the provider commands, you must always validate the user input and be vigilant of possible hacker attacks using potentially dangerous SQL statement, such as, , as part of the user input.


ListBox.LabelAlign Property (Access)

 Copy code hover
[image]

ListBox.LabelAlign Property (Access)
See also Send feedback

Published: July 16, 2012

The property specifies the text alignment within attached labels on new controls. Read/write Byte.

Syntax

expression .LabelAlign

expression A variable that represents a ListBox object.

Remarks

The LabelAlign property uses the following settings.

Setting | Description
0 | (Default) The label text aligns to the left.
1 | The label text aligns to the left.
2 | The label text is centered.
3 | The label text aligns to the right.
4 | The label text is evenly distributed.

You can set the LabelAlign property by using a control's default control style or the DefaultControl property in Visual Basic.

When created, controls have an attached label (as long as their AutoLabel property is set to Yes). Changes to the LabelAlign default control style setting affect only controls created on the current form or report.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Type Property Example (Property) (VB)

 Copy code hover
[image]

Type Property Example (Property) (VB)
Send feedback

This example demonstrates the Type property. It is a model of a utility for listing the names and types of a collection, like Properties, Fields, etc.

We do not need to open the Recordset to access its Properties collection; they come into existence when the Recordset object is instantiated. However, setting the CursorLocation property to adUseClient adds several dynamic properties to the Recordset object's Properties collection, making the example a little more interesting. For sake of illustration, we explicitly use the Item property to access each Property object.

Copy code Copy code

'BeginTypePropertyVB
Public Sub Main()
 On Error GoTo ErrorHandler

 ' recordset variables
 Dim rst As ADODB.Recordset
 Dim prop As ADODB.Property
 ' property variables
 Dim ix As Integer
 Dim strMsg As String

 ' create client-side recordset
 Set rst = New ADODB.Recordset
 rst.CursorLocation = adUseClient
 ' enumerate property types
 For ix = 0 To rst.Properties.Count - 1
 Set prop = rst.Properties.Item(ix)
 Select Case prop.Type
 Case adBigInt
 strMsg = "adBigInt"
 Case adBinary
 strMsg = "adBinary"
 Case adBoolean
 strMsg = "adBoolean"
 Case adBSTR
 strMsg = "adBSTR"
 Case adChapter
 strMsg = "adChapter"
 Case adChar
 strMsg = "adChar"
 Case adCurrency
 strMsg = "adCurrency"
 Case adDate
 strMsg = "adDate"
 Case adDBDate
 strMsg = "adDBDate"
 Case adDBTime
 strMsg = "adDBTime"
 Case adDBTimeStamp
 strMsg = "adDBTimeStamp"
 Case adDecimal
 strMsg = "adDecimal"
 Case adDouble
 strMsg = "adDouble"
 Case adEmpty
 strMsg = "adEmpty"
 Case adError
 strMsg = "adError"
 Case adFileTime
 strMsg = "adFileTime"
 Case adGUID
 strMsg = "adGUID"
 Case adIDispatch
 strMsg = "adIDispatch"
 Case adInteger
 strMsg = "adInteger"
 Case adIUnknown
 strMsg = "adIUnknown"
 Case adLongVarBinary
 strMsg = "adLongVarBinary"
 Case adLongVarChar
 strMsg = "adLongVarChar"
 Case adLongVarWChar
 strMsg = "adLongVarWChar"
 Case adNumeric
 strMsg = "adNumeric"
 Case adPropVariant
 strMsg = "adPropVariant"
 Case adSingle
 strMsg = "adSingle"
 Case adSmallInt
 strMsg = "adSmallInt"
 Case adTinyInt
 strMsg = "adTinyInt"
 Case adUnsignedBigInt
 strMsg = "adUnsignedBigInt"
 Case adUnsignedInt
 strMsg = "adUnsignedInt"
 Case adUnsignedSmallInt
 strMsg = "adUnsignedSmallInt"
 Case adUnsignedTinyInt
 strMsg = "adUnsignedTinyInt"
 Case adUserDefined
 strMsg = "adUserDefined"
 Case adVarBinary
 strMsg = "adVarBinary"
 Case adVarChar
 strMsg = "adVarChar"
 Case adVariant
 strMsg = "adVariant"
 Case adVarNumeric
 strMsg = "adVarNumeric"
 Case adVarWChar
 strMsg = "adVarWChar"
 Case adWChar
 strMsg = "adWChar"
 Case Else
 strMsg = "*UNKNOWN*"
 End Select
 'show results
 Debug.Print "Property " & ix & ": " & prop.Name & _
 ", Type = " & strMsg
 Next ix

 ' clean up
 Set rst = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 Set rst = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If

End Sub
'EndTypePropertyVB


ComboBox.Layout Property (Access)

 Copy code hover
[image]

ComboBox.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified combo box. Read-only AcLayoutType.

Version Information

Version Added: Access 2007

Syntax

expression .Layout

expression A variable that represents a ComboBox object.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Line Object (Access)

 Copy code hover
[image]

Line Object (Access)
See also Send feedback

Published: July 16, 2012

The line control displays a horizontal, vertical, or diagonal line on a form or report.

Remarks

You can use the BorderWidth property to change the line width. You can use the BorderColor property to change the color of the border or make it transparent. You can change the line style (dots, dashes, and so on) of the border by using the BorderStyle property.

See also

Concepts

Access Object Model Reference

Other resources

Line Object Members


Form.CommandExecute Event (Access)

 Copy code hover
[image]

Form.CommandExecute Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs after the specified command is executed. Use this event when you want to execute a set of commands after a particular command is executed.

Syntax

expression .CommandExecute(Command, )

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Command | Required | Variant | The command that is executed.

Return Value

nothing

Remarks

The OCCommandId, ChartCommandIdEnum, and PivotCommandId constants contain lists of the supported commands for each of the Microsoft Office Web Components.

Example

The following example demonstrates the syntax for a subroutine that traps the CommandExecute event.

VBA Copy code Copy code
Private Sub Form_CommandExecute(ByVal Command As Variant) MsgBox "The command specified by " _
 & Command.Name & " has been executed."
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Form.BeforeUpdate Property (Access)

 Copy code hover
[image]

Form.BeforeUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.

Syntax

expression .BeforeUpdate

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeUpdate event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the BeforeUpdate event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).BeforeUpdate = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


ComboBox.AddColon Property (Access)

 Copy code hover
[image]

ComboBox.AddColon Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.

Syntax

expression .AddColon

expression A variable that represents a ComboBox object.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ToggleButton.Enter Event (Access)

 Copy code hover
[image]

ToggleButton.Enter Event (Access)
See also Send feedback

Published: July 16, 2012

The Enter event occurs before a control actually receives the focus from a control on the same form or report.

Syntax

expression .Enter

expression A variable that represents a ToggleButton object.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when these events occur, set the OnEnter or OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Enter event occurs before the GotFocus event. The Exit event occurs before the LostFocus event.

Unlike the GotFocus and LostFocus events, the Enter and Exit events don't occur when a form receives or loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Application.ProductCode Property (Access)

 Copy code hover
[image]

Application.ProductCode Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ProductCode property to determine the Microsoft Access 2013 globally unique identifier (GUID). Read-only String.

Syntax

expression .ProductCode

expression A variable that represents an Application object.

Example

The following example displays a message indicating the GUID for Microsoft Access for the user's computer.

VBA Copy code Copy code
MsgBox "The GUID for Microsoft Access on this computer is " & Application.ProductCode & "."

See also

Concepts

Application Object

Other resources

Application Object Members


OutputAllFields Property

 Copy code hover
[image]

OutputAllFields Property
Send feedback

Published: July 16, 2012

You can use the OutputAllFields property to show all fields in the query's underlying data source and in the field list of a form or report. Setting this property is an easy way to show all fields without having to click the Show box in the query design grid for each field in the query.

Note Note

The OutputAllFields property applies only to append, make-table, and select queries.

Setting

The OutputAllFields property uses the following settings.

Setting | Description
Yes | Displays all the fields in the underlying tables and in the field list of a form or report.
No | (Default) Displays only fields that have the Show box selected in the query design grid.

You can set this property only by using the query's property sheet.

Note Note

The use of an asterisk (*) in an SQL statement in place of a field name is the equivalent of setting the OutputAllFields property to Yes.

Remarks

When the OutputAllFields property is set to Yes, the only fields you need to include in the query design grid are those that you want to sort on or specify criteria for.

When you save a filter as a query, Microsoft Access sets the OutputAllFields property to Yes.


Form.OnDisconnect Event (Access)

 Copy code hover
[image]

Form.OnDisconnect Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when the specified PivotTable view disconnects from a data source.

Syntax

expression .OnDisconnect

expression A variable that represents a Form object.

Return Value

nothing

Example

The following example demonstrates the syntax for a subroutine that traps the OnDisconnect event.

VBA Copy code Copy code
Private Sub Form_OnDisconnect()
 MsgBox "The PivotTable View has " _
 & "disconnected from its data source!"
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


TextBox.ColumnOrder Property (Access)

 Copy code hover
[image]

TextBox.ColumnOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.

Syntax

expression .ColumnOrder

expression A variable that represents a TextBox object.

Remarks

To set or change this property for a table or query by using Visual Basic, you must use a column's Properties collection. For details on using the Properties collection, see Properties .

Note Note

The ColumnOrder property isn't available in Design view.

The ColumnOrder property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

In Datasheet view, a field's ColumnOrder property setting is determined by the field's position. For example, the field in the leftmost column in Datasheet view has a ColumnOrder property setting of 1, the next field has a setting of 2, and so on. Changing a field's ColumnOrder property resets the property for that field and every field to the left of its original position in Datasheet view.

In other views, the property setting is 0 unless you explicitly change the order of one or more fields in Datasheet view (either by dragging the fields to new positions or by changing their ColumnOrder property settings). Fields to the right of the moved field's new position will have a property setting of 0 in views other than Datasheet view.

The order of the fields in Datasheet view doesn't affect the order of the fields in table Design view or Form view.

Example

The following example displays the ProductName and QuantityPerUnit fields in the first two columns in Datasheet view of the Products form.

VBA Copy code Copy code
Forms!Products!ProductName.ColumnOrder = 1
Forms!Products!QuantityPerUnit.ColumnOrder = 2

The next example displays the ProductName and QuantityPerUnit fields in the first two columns of the Products table in Datasheet view. To set the ColumnOrder property, the example uses the SetFieldProperty procedure. If this procedure is run while the table is open, changes will not be displayed until it is closed and reopened.

VBA Copy code Copy code
Public Sub SetColumnOrder()

 Dim dbs As DAO.Database
 Dim tdf As DAO.TableDef

 Set dbs = CurrentDb
 Set tdf = dbs!Products

 ' Call the procedure to set the ColumnOrder property.
 SetFieldProperty tdf!ProductName, "ColumnOrder", dbLong, 2
 SetFieldProperty tdf!QuantityPerUnit, "ColumnOrder", dbLong, 3

 Set tdf = Nothing
 Set dbs = Nothing

End Sub

Private Sub SetFieldProperty(ByRef fld As DAO.Field, _
 ByVal strPropertyName As String, _
 ByVal intPropertyType As Integer, _
 ByVal varPropertyValue As Variant)
 ' Set field property without producing nonrecoverable run-time error.

 Const conErrPropertyNotFound = 3270
 Dim prp As Property

 ' Turn off error handling.
 On Error Resume Next

 fld.Properties(strPropertyName) = varPropertyValue

 ' Check for errors in setting the property.
 If Err <> 0 Then
 If Err <> conErrPropertyNotFound Then
 On Error GoTo 0
 MsgBox "Couldn't set property '" & strPropertyName & _
 "' on field '" & fld.Name & "'", vbCritical
 Else
 On Error GoTo 0
 Set prp = fld.CreateProperty(strPropertyName, intPropertyType, _
 varPropertyValue)
 fld.Properties.Append prp
 End If
 End If

 Set prp = Nothing

End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


SubForm.LinkMasterFields Property (Access)

 Copy code hover
[image]

SubForm.LinkMasterFields Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the LinkMasterFields property (along with the LinkChildFields property) together to specify how Microsoft Access links records in a form or report to records in a subform, subreport, or embedded object, such as a chart. If these properties are set, Microsoft Access automatically updates the related record in the subform when you change to a new record in a main form. Read/write String.

Syntax

expression .LinkMasterFields

expression A variable that represents a SubForm object.

Remarks

You can set the LinkChildFields and LinkMasterFields properties for the subform, subreport, or embedded object as follows:

  • The LinkChildFields property. Enter the name of one or more linking fields in the subform, subreport, or embedded object.

  • The LinkMasterFields property. Enter the name of one or more linking fields or controls in the main form or report.

You can use the Subform/Subreport Field Linker to set these properties by clicking the Build button to the right of the property box in the property sheet.

The properties can only be set in Design view or during the Open event of a form or report.

The fields or controls you use to set these properties don't need to have the same names, but they must contain the same kind of data and have the same or a compatible data type and field size. For example, an AutoNumber field is compatible with a Number field if the FieldSize property for the Number field is set to Long Integer.

You can use the name of a control (including the name of a calculated control) to set the LinkMasterFields property, but you can't use the name of a control to set the LinkChildFields property. If you want to use a calculated value as the link for a subform, subreport, or embedded object, define a calculated field in the child object's underlying query and set the LinkChildFields property to the field.

When you specify more than one field or control name for these property settings, you must enter the same number of fields or controls for each property setting and separate the names with a semicolon (;).

When you create a subform or subreport by dragging a form or report from the Database window onto another form or report or by using the Form Wizard, Microsoft Access automatically sets the LinkChildFields and LinkMasterFields properties under the following conditions:

  • Both the main form or report and the child object are based on tables, and a relationship between those tables has been defined with the Relationships command. Microsoft Access uses the fields that relate the two tables as the linking fields.

  • The main form or report is based on a table with a primary key, and the subform or subreport is based on a table or query that contains a field with the same name and the same or a compatible data type as the primary key. Microsoft Access uses the primary key from the main object's underlying table and the identically named field from the child object's underlying table or query as the linking fields.

Note Note

The linking fields don't have to be included in the main object or in the child object. As long as they are contained in the objects' underlying tables or queries, you can use the fields to link the objects. When you use a wizard, Microsoft Access automatically includes the linking fields.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


TabControl.MultiRow Property (Access)

 Copy code hover
[image]

TabControl.MultiRow Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the MultiRow property to specify or determine whether a tab control can display more than one row of tabs. Read/write Boolean.

Syntax

expression .MultiRow

expression A variable that represents a TabControl object.

Remarks

The MultiRow property uses the following settings.

Setting | Visual Basic | Description
Yes | True | Multiple rows are allowed.
No | False | (Default) Multiple rows aren't allowed.

You can also set the default for this property by setting a control's DefaultControl property in Visual Basic.

When the MultiRow property is set to True, the number of rows is determined by the width and number of tabs. The number of rows may change if the control is resized or if additional tabs are added to the control.

When the MultiRow property is set to False and the width of the tabs exceeds the width of the control, navigation buttons appear on the right side of the tab control. You can use the navigation buttons to scroll through all the tabs on the tab control.

Example

To return the value of the MultiRow property for a tab control named "Details" on the "Order Entry" form, you can use the following:

VBA Copy code Copy code
Dim b As Boolean
b = Forms("Order Entry").Controls("Details").MultiRow

To set the value of the MultiRow property, you can use the following:

VBA Copy code Copy code
Forms("Order Entry").Controls("Details").MultiRow = True

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


OptionButton.Width Property (Access)

 Copy code hover
[image]

OptionButton.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents an OptionButton object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


WebBrowserControl.GridlineTint Property (Access)

 Copy code hover
[image]

WebBrowserControl.GridlineTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineTint

expression A variable that represents a WebBrowserControl object.

Remarks

The GridlineTint property contains a numeric expression that can be used to lighten the theme color in the GridlineColor property. The default value of the GridlineTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Line.DisplayWhen Property (Access)

 Copy code hover
[image]

Line.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Syntax

expression .DisplayWhen

expression A variable that represents a Line object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

Line Object

Other resources

Line Object Members


Printer.DefaultSize Property (Access)

 Copy code hover
[image]

Printer.DefaultSize Property (Access)
See also Send feedback

Published: July 16, 2012

True if the size of the detail section in Design View is used for printing; otherwise, the values of the ItemSizeHeight and ItemSizeWidth properties are used. Read/write Boolean.

Syntax

expression .DefaultSize

expression A variable that represents a Printer object.

Remarks

When this property is True, the ItemSizeHeight and ItemSizeWidth properties are ignored.

Example

The following example sets a variety of printer settings for the form specified in the strFormname argument of the procedure.

VBA Copy code Copy code
Sub SetPrinter(strFormname As String)

 DoCmd.OpenForm FormName:=strFormname, view:=acDesign, _
 datamode:=acFormEdit, windowmode:=acHidden

 With Forms(form1).Printer

 .TopMargin = 1440
 .BottomMargin = 1440
 .LeftMargin = 1440
 .RightMargin = 1440

 .ColumnSpacing = 360
 .RowSpacing = 360

 .ColorMode = acPRCMColor
 .DataOnly = False
 .DefaultSize = False
 .ItemSizeHeight = 2880
 .ItemSizeWidth = 2880
 .ItemLayout = acPRVerticalColumnLayout
 .ItemsAcross = 6

 .Copies = 1
 .Orientation = acPRORLandscape
 .Duplex = acPRDPVertical
 .PaperBin = acPRBNAuto
 .PaperSize = acPRPSLetter
 .PrintQuality = acPRPQMedium

 End With

 DoCmd.Close objecttype:=acForm, objectname:=strFormname, _
 Save:=acSaveYes

End Sub

See also

Concepts

Printer Object

Other resources

Printer Object Members


Levels Collection (ADO MD Reference)

 Copy code hover
[image]

Levels Collection (ADO MD Reference)
Send feedback

In this section

  • Levels Collection (ADO MD)

  • Levels Collection Properties, Methods, and Events (ADO MD)


Appendix B: ADO Errors

 Copy code hover
[image]

Appendix B: ADO Errors
Send feedback

See the following topics for more information about particular error messages:

  • ADO Error Codes

  • DataControl Error Codes

  • Internet Explorer Error Codes

  • Internet Information Services Error Codes


Invalid SQL syntax - expected a view name. (Error 3780)

 Copy code hover
[image]

Invalid SQL syntax - expected a view name. (Error 3780)
Send feedback

This error occurs when trying to create or drop a view using SQL DDL's CREATE VIEW or DROP VIEW syntax. It occurs if a valid name is not specified. For example, the following statement would generate the error: CREATE VIEW AS SELECT * FROM table1.


ToggleButton.OnKeyDown Property (Access)

 Copy code hover
[image]

ToggleButton.OnKeyDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Down box in the Properties window. Read/write String.

Syntax

expression .OnKeyDown

expression A variable that represents a ToggleButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyDown event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyDown

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Cannot append. An object with that name already exists in the collection. (Error 3367)

 Copy code hover
[image]

Cannot append. An object with that name already exists in the collection. (Error 3367)
Send feedback

You tried to append an object to a collection that already contains an object of the same name. Use the Refresh method on the collection and check to see whether the object you want to append already exists, or try changing the object's Name property setting.


* (Multiply) (Access 2013 custom web app)

 Copy code hover
[image]

* (Multiply) (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Multiplies two expressions.

Syntax

expression * expression

expression Any valid expression of any one of the data types in the numeric category.

Return Value

Returns the data type of the argument with the higher precedence.


Report.ScaleWidth Property (Access)

 Copy code hover
[image]

Report.ScaleWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ScaleWidth property to specify the number of units for the horizontal measurement of the page when the Circle , Line , Pset , or Print method is used while a report is printed or previewed, or its output is saved to a file. Read/write Single.

Syntax

expression .ScaleWidth

expression A variable that represents a Report object.

Remarks

The default setting is the internal width of a report page in twips.

You can set the ScaleWidth property by using a macro or a Visual Basic event procedure specified by a section's OnPrint property setting.

You can use the ScaleWidth property to create a custom coordinate scale for drawing or printing. For example, the statement ScaleWidth = 100 defines the internal width of the section as 100 units, or one horizontal unit as one one-hundredth of the width.

Use the ScaleMode property to define a scale based on a standard unit of measurement, such as points, pixels, characters, inches, millimeters, or centimeters.

Setting the ScaleWidth property to a positive value makes coordinates increase in value from left to right. Setting it to a negative value makes coordinates increase in value from right to left.

By using these properties and the related ScaleLeft and ScaleTop properties, you can set up a custom coordinate system with both positive and negative coordinates. All four of these Scale properties interact with the ScaleMode property in the following ways:

  • Setting any other Scale property to any value automatically sets the ScaleMode property to 0.

  • Setting the ScaleMode property to a number greater than 0 changes the ScaleHeight and ScaleWidth properties to the new unit of measurement and sets the ScaleLeft and ScaleTop properties to 0. Also, the CurrentX and CurrentY property settings change to reflect the new coordinates of the current point.

You can also use the Scale method to set the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties in one statement.

Note Note

The ScaleWidth properties isn't the same as the Width property.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


ReturnVars.Item Property (Access)

 Copy code hover
[image]

ReturnVars.Item Property (Access)
Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only ReturnVar.

Version Information

Version Added: Access 2010

Syntax

expression .Item(Index)

expression A variable that represents a ReturnVars object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection.


Database.MakeReplica Method (DAO)

 Copy code hover
[image]

Database.MakeReplica Method (DAO)
Send feedback

Makes a new replica from another database replica (Microsoft Access workspaces only).

Syntax

expression .MakeReplica(PathName, Description, Options)

expression A variable that represents a Database object.

Parameters

Name | Required/Optional | Data Type | Description
PathName | Required | String | The path and file name of the new replica. If replica is an existing file name, then an error occurs.
Description | Required | String | A String that describes the replica that you are creating
Options | Optional | Variant | A ReplicaTypeEnum constant that specifies characteristics of the replica you are creating.

Remarks

A newly created partial replica will have all ReplicaFilter properties set to False, meaning that no data will be in the tables.

Example

This function uses the MakeReplica method to create an additional replica of an existing Design Master. The intOptions argument can be a combination of the constants dbRepMakeReadOnly and dbRepMakePartial, or it can be 0. For example, to create a read-only partial replica, you should pass the value dbRepMakeReadOnly + dbRepMakePartial as the value of intOptions.

VBA Copy code Copy code
Function MakeAdditionalReplica(strReplicableDB As _
 String, strNewReplica As String, intOptions As _
 Integer) As Integer

 Dim dbsTemp As Database
 On Error GoTo ErrorHandler

 Set dbsTemp = OpenDatabase(strReplicableDB)

 ' If no options are passed to
 ' MakeAdditionalReplica, omit the
 ' options argument, which defaults to
 ' a full, read/write replica. Otherwise,
 ' use the value of intOptions.

 If intOptions = 0 Then
 dbsTemp.MakeReplica strNewReplica, _
 "Replica of " & strReplicableDB
 Else
 dbsTemp.MakeReplica strNewReplica, _
 "Replica of " & strReplicableDB, _
 intOptions
 End If

 dbsTemp.Close

ErrorHandler:
 Select Case Err
 Case 0:
 MakeAdditionalReplica = 0
 Exit Function
 Case Else:
 MsgBox "Error " & Err & " : " & Error
 MakeAdditionalReplica = Err
 Exit Function
 End Select

End Function


FastFind cannot search on non-column references (Error 3768)

 Copy code hover
[image]

FastFind cannot search on non-column references (Error 3768)
Send feedback

DAO's FIND method cannot reference columns that are based on a parameter or an expression.


Max Function (Access 2013 custom web app)

 Copy code hover
[image]

Max Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the maximum value in the expression in a query or table.

Syntax

Max(Expression)

The Max function contains the following argument.

Argument name | Description
Expression | A string expression identifying the field that contains the data you want to evaluate or an expression that performs a calculation using the data in that field. Operands in Expression can include the name of a table field, a constant, or a function (which can be either intrinsic or user-defined but not one of the other SQL aggregate functions).


AbsolutePage Property (ADO)

 Copy code hover
[image]

AbsolutePage Property (ADO)
Send feedback

Indicates on which page the current record resides.

Settings and Return Values

Sets or returns a Long value from 1 to the number of pages in the Recordset object ( PageCount ), or returns one of the PositionEnum values.

Remarks

This property can be used to identify the page number on which the current record is located. It uses the PageSize property to logically divide the total rowset count of the Recordset object into a series of pages, each of which has the number of records equal to PageSize (except for the last page, which may have fewer records). The provider must support the appropriate functionality for this property to be available.

When getting or setting the AbsolutePage property, ADO uses the AbsolutePosition property and the PageSize property together as follows:

  • To get the AbsolutePage, ADO first retrieves the AbsolutePosition, and then divides it by the PageSize.

  • To set the AbsolutePage, ADO moves the AbsolutePosition as follows: it multiplies the PageSize by the new AbsolutePage value and then adds 1 to the value. As a result, the current position in the Recordset after successfully setting AbsolutePage is, the first record in that page.

Like the AbsolutePosition property, AbsolutePage is 1-based and equals 1 when the current record is the first record in the Recordset. Set this property to move to the first record of a particular page. Obtain the total number of pages from the PageCount property.


BoundObjectFrame.HorizontalAnchor Property (Access)

 Copy code hover
[image]

BoundObjectFrame.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the object frame is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .HorizontalAnchor

expression A variable that represents a BoundObjectFrame object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


AddNew Method Example (JScript)

 Copy code hover
[image]

AddNew Method Example (JScript)
Send feedback

This example uses the AddNew method to create a new record with the specified name. Cut and paste the following code to Notepad or another text editor, and save it as AddNewJS.asp.

Copy code Copy code

<!-- BeginAddNewJS -->
<%@LANGUAGE="JScript" %>
<!-- Include file for JScript ADO Constants -->
<%// use this meta tag instead of adojavas.inc%>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->

<html>

<head>
 <title>Add New Method Example (JScript)</title>
<style>
<!--
body {
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 BACKGROUND-COLOR:white;
 COLOR:black;
 }
-->
</style>
</head>

<body>
<h1>AddNew Method Example (JScript)</h1>

<%
 if (Request.Form("Addit") == "AddNew")
 {
 // connection and recordset variables
 var Cnxn = Server.CreateObject("ADODB.Connection")
 var strCnxn = "Provider='sqloledb';Data Source=" + Request.ServerVariables("SERVER_NAME") + ";" +
 "Initial Catalog='Northwind';Integrated Security='SSPI';";
 var rsEmployee = Server.CreateObject("ADODB.Recordset");
 //record variables
 var FName = String(Request.Form("FirstName"));
 var LName = String(Request.Form("LastName"));

 try
 {
 // open connection
 Cnxn.Open(strCnxn)

 // open Employee recordset using client-side cursor
 rsEmployee.CursorLocation = adUseClient;
 rsEmployee.Open("Employees", strCnxn, adOpenKeyset, adLockOptimistic, adCmdTable);

 rsEmployee.AddNew();
 rsEmployee("FirstName") = FName;
 rsEmployee("LastName") = LName;
 rsEmployee.Update;

 // of course, you would normally do error handling here
 Response.Write("New record added.")
 }
 catch (e)
 {
 Response.Write(e.message);
 }
 finally
 {
 // clean up
 if (rsEmployee.State == adStateOpen)
 rsEmployee.Close;
 if (Cnxn.State == adStateOpen)
 Cnxn.Close;
 rsEmployee = null;
 Cnxn = null;
 }
 }
%>

<form method="post" action="AddNewJS.asp" id=form1 name=form1>
<table>
<tr>
 <td colspan="2">
 <h4>Please enter the record to add:</h4>
 </td>
</tr>
<tr>
 <td>
 First Name:
 </td>
 <td>
 <input name="FirstName" maxLength=20>
 </td>
</tr>
<tr>
 <td>
 Last Name:
 </td>
 <td>
 <input name="LastName" size="30" maxLength=30>
 </td>
</tr>
<tr>
 <td align="right">
 <input type="submit" value="Submit" name="Submit">
 </td>
 <TD align="left">
 <INPUT type="reset" value="Reset" name="Reset">
 </TD>
</tr>
</table>
<INPUT type="hidden" value="AddNew" name="Addit">
</form>
</body>
</HTML>
<!-- EndAddNewJS -->


GroupLevel.ControlSource Property (Access)

 Copy code hover
[image]

GroupLevel.ControlSource Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.

Syntax

expression .ControlSource

expression A variable that represents a GroupLevel object.

Remarks

The ControlSource property uses the following settings.

Setting | Description
A field name | The control is bound to a field in a table, query, or SQL statement. Data from the field is displayed in the control. Changes to the data inside the control change the corresponding data in the field. (To make the control read-only, set the Locked property to Yes.) If you click a control bound to a field that has a Hyperlink data type, you jump to the destination specified in the hyperlink address.
An expression | The control displays data generated by an expression. This data can be changed by the user but isn't saved in the database.

For reports, the ControlSource property applies only to report group levels.

For a report group level, the ControlSource property determines the field or expression to group on.

Forms and reports act as "windows" into your database. You specify the primary source of data for a form or report by setting its RecordSource property to a table, query, or SQL statement. You can then set the ControlSource property to a field in the source of data or to an expression. If the ControlSource property setting is an expression, the value displayed is read-only and not saved in the database. For example, you can use the following settings.

Sample setting | Description
LastName | For a control, data from the LastName field is displayed in the control. For a report group level, Microsoft Access groups the data on last name.
=Date( ) + 7 | For a control, this expression displays a date seven days from today in the control.
=DatePart("q",ShippedDate) | For a control, this expression displays the quarter of the shipped date. For a report group level, Microsoft Access groups the data on the quarter of the shipped date.

Example

The following example sets the ControlSource property for a text box named AddressPart to a field named City:

VBA Copy code Copy code
Forms!Customers!AddressPart.ControlSource = "City"

The next example sets the ControlSource property for a text box named Expected to the expression =Date() + 7

VBA Copy code Copy code
Me!Expected.ControlSource = "=Date() + 7"

See also

Concepts

GroupLevel Object

Other resources

GroupLevel Object Members


SharedResource.Name Property (Access)

 Copy code hover
[image]

SharedResource.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .Name

expression A variable that represents a SharedResource object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

SharedResource Object

Other resources

SharedResource Object Members


Connection.QueryDefs Property (DAO)

 Copy code hover
[image]

Connection.QueryDefs Property (DAO)
Send feedback

Returns a QueryDefs collection that contains all of the QueryDef objects of the specified connection. Read-only.

Syntax

expression .QueryDefs

expression A variable that represents a Connection object.


Append Method (ADOX Users)

 Copy code hover
[image]

Append Method (ADOX Users)
Send feedback

Adds a new User object to the Users collection.

Syntax

Users.Append User[,Password]

Parameters

  • User

  • A Variant value that contains the User object to append or the name of the user to create and append.

  • Password

  • Optional. A String value that contains the password for the user. The Password parameter corresponds to the value specified by the ChangePassword method of a User object.

Remarks

The Users collection of a Catalog represents all the catalog's users. The Users collection for a Group represents only the users that have a membership in the specific group.

An error will occur if the provider does not support creating users.

Note Note

Before appending a User object to the Users collection of a Group object, a User object with the same Name as the one to be appended must already exist in the Users collection of the Catalog.


Reference.Major Property (Access)

 Copy code hover
[image]

Reference.Major Property (Access)
See also Send feedback

Published: July 16, 2012

The Major property of a Reference object returns a read-only Long value indicating the major version number of an application to which you have set a reference.

Syntax

expression .Major

expression A variable that represents a Reference object.

Remarks

The Major property returns the value to the left of the decimal point in a version number. For example, if you've set a reference to an application whose version number is 2.5, the Major property returns 2.

Example

The following example displays a message with information about all the references in the current project.

VBA Copy code Copy code
Dim r As Reference
Dim strInfo As String

For Each r In Application.References
 strInfo = strInfo & r.Name & " " & r.Major & "." & r.Minor & vbCrLf
Next

MsgBox "Current References: " & vbCrLf & strInfo

See also

Concepts

Reference Object

Other resources

Reference Object Members


RDS Code Examples in Microsoft Visual J++

 Copy code hover
[image]

RDS Code Examples in Microsoft Visual J++
Send feedback

Use the following code examples to learn how to use RDS properties when writing in Microsoft Visual J++.

Note Note

Paste the entire code example, from beginning to end, into your code editor. The example may not run correctly if partial examples are used or if paragraph formatting is lost.

  • Handler Property Example

  • InternetTimeout Property Example


Fields Members (DAO)

 Copy code hover
[image]

Fields Members (DAO)
Send feedback

A Fields collection contains all stored Field objects of an Index, QueryDef, Recordset, Relation, or TableDef object.

Methods

Name | Description
Append | Adds a new Field to the Fields collection.
Delete | Deletes a Field from the Fields collection.
Refresh | Updates the objects in the specified colletion to reflect the database's current schema.

Properties

Name | Description
Count | Returns the number of objects in the specified collection. Read-only Integer.


OptionButton.TabStop Property (Access)

 Copy code hover
[image]

OptionButton.TabStop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.

Syntax

expression .TabStop

expression A variable that represents an OptionButton object.

Remarks

This property doesn't apply to toggle button controls when they appear in an option group. It applies only to the option group itself.

The TabStop property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) You can move the focus to the control by pressing the TAB key.
No | False | You can't move the focus to the control by pressing the TAB key.

When you create a control on a form, Microsoft Access automatically assigns the control a position in the form's tab order. Each new control is placed last in the tab order. If you want to prevent a control from being available when you tab through the controls in a form, set the control's TabStop property to No.

In Form view, hidden or disabled controls remain in the tab order but are skipped when you move through the controls by pressing TAB, even if their TabStop properties are set to Yes.

As long as a control's Enabled property is set to Yes, you can click the control or use an access key to select it, regardless of its TabStop property setting. For example, you can set the TabStop property of a command button to No to prevent users from selecting the button by pressing TAB. However, they can still click the command button to choose it.

Example

The following example disables the ability to move the focus to the "City" text box on the "Suppliers" form by using the TAB key.

VBA Copy code Copy code
Forms("Suppliers").Controls("City").TabStop = False

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


CommandButton.BackStyle Property (Access)

 Copy code hover
[image]

CommandButton.BackStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .BackStyle

expression A variable that represents a CommandButton object.

Remarks

The BackStyle property uses the following settings.

Setting | Visual Basic | Description
Normal | 1 | (Default) The control has its interior color set by the BackColor property.
Transparent | 0 | The control is transparent. The color of the form or report behind the control is visible.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

If the Transparent button on the Back Color button palette is selected, the BackStyle property is set to Transparent; otherwise the BackStyle property is set to Normal.

To make a command button invisible, set its Transparent property to Yes.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Report.MouseMove Event (Access)

 Copy code hover
[image]

Report.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents a Report object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Return Value

nothing

Remarks

This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a report to occur, press the mouse button in a blank area on the report. To cause a MouseMove event for a report section to occur, press the mouse button in a blank area of the report section.

Note Note

  • Moving a report can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a report in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the report section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the report section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

See also

Concepts

Report Object

Other resources

Report Object Members


Field.ValidationRule Property (DAO)

 Copy code hover
[image]

Field.ValidationRule Property (DAO)
Send feedback

Sets or returns a value that validates the data in a field as it's changed or added to a table (Microsoft Access workspaces only). Read/write String.

Syntax

expression .ValidationRule

expression An expression that returns a Field object.

Remarks

The settings or return values is a String that describes a comparison in the form of an SQL WHERE clause without the WHERE reserved word. For an object not yet appended to the Fields collection, this property is read/write.

The ValidationRule property determines whether or not a field contains valid data. If the data is not valid, a trappable run-time error occurs. The returned error message is the text of the ValidationText property, if specified, or the text of the expression specified by ValidationRule.

For a Field object, use of the ValidationRule property depends on the object that contains the Fields collection to which the Field object is appended.

Object appended to | Usage
Index | Not supported
QueryDef | Read-only
Recordset | Read-only
Relation | Not supported
TableDef | Read/write

Validation is supported only for databases that use the Microsoft Access database engine.

The string expression specified by the ValidationRule property of a Field object can refer only to that Field. The expression can't refer to user-defined functions, SQL aggregate functions, or queries. To set a Field object's ValidationRule property when its ValidateOnSet property setting is True, the expression must successfully parse (with the field name as an implied operand) and evaluate to True. If its ValidateOnSet property setting is False, the ValidationRule property setting is ignored.

Note Note

If you set the property to a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strRule = "PRICE > " & lngPrice, and lngPrice = 125,50), an error will result when your code attempts to validate any data. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and Microsoft Access database engine SQL only accepts U.S. decimal characters.


ListBox.BeforeUpdate Property (Access)

 Copy code hover
[image]

ListBox.BeforeUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.

Syntax

expression .BeforeUpdate

expression A variable that represents a ListBox object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeUpdate event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the BeforeUpdate event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).BeforeUpdate = "[Event Procedure]"

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


CurrentProject.Name Property (Access)

 Copy code hover
[image]

CurrentProject.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.

Syntax

expression .Name

expression A variable that represents a CurrentProject object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


Rectangle.DisplayWhen Property (Access)

 Copy code hover
[image]

Rectangle.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Syntax

expression .DisplayWhen

expression A variable that represents a Rectangle object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


CommandButton.GotFocus Event (Access)

 Copy code hover
[image]

CommandButton.GotFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The GotFocus event occurs when the specified object receives the focus.

Syntax

expression .GotFocus

expression A variable that represents a CommandButton object.

Remarks

To run a macro or event procedure when these events occur, set the OnGotFocus property to the name of the macro or to [Event Procedure].

These events occur when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The GotFocus event differs from the Enter event in that the GotFocus event occurs every time a control receives the focus. For example, suppose the user clicks a check box on a form, then clicks a report, and finally clicks the check box on the form to bring it to the foreground. The GotFocus event occurs both times the check box receives the focus. In contrast, the Enter event occurs only the first time the user clicks the check box. The GotFocus event occurs after the Enter event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Reports (Access)

 Copy code hover
[image]

Reports (Access)
Send feedback

In this section

  • Access Reports How Do I...

  • Design in Access Reports

  • Controls in Access Reports

  • Printing in Access Reports

  • Events in Access Reports


Section.OnDblClick Property (Access)

 Copy code hover
[image]

Section.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Syntax

expression .OnDblClick

expression A variable that represents a Section object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_DblClick" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

Section Object

Other resources

Section Object Members


NavigationButton.SizeToFit Method (Access)

 Copy code hover
[image]

NavigationButton.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Version Information

Version Added: Access 2010

Syntax

expression .SizeToFit

expression A variable that represents a NavigationButton object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


DoCmd Methods (Access)

 Copy code hover
[image]

DoCmd Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
AddMenu | The AddMenu method carries out the AddMenu action in Visual Basic.
ApplyFilter | The ApplyFilter method carries out the ApplyFilter action in Visual Basic.
Beep | The Beep method carries out the Beep action in Visual Basic.
BrowseTo | The BrowseTo method performs the BrowseTo action in Visual Basic.
CancelEvent | The CancelEvent method carries out the CancelEvent action in Visual Basic.
ClearMacroError | Removes information about an error that is stored in the MacroError object.
Close | The Close method carries out the Close action in Visual Basic.
CloseDatabase | Closes the current database.
CopyDatabaseFile | Copies the database connected to the current project to a Microsoft SQL Server database file for export.
CopyObject | The CopyObject method carries out the CopyObject action in Visual Basic.
DeleteObject | The DeleteObject method carries out the DeleteObject action in Visual Basic.
DoMenuItem | Displays the appropriate menu or toolbar command for Microsoft Access.
Echo | Carries out the Echo action in Visual Basic.
FindNext | The FindNext method carries out the FindNext action in Visual Basic.
FindRecord | The FindRecord method carries out the FindRecord action in Visual Basic.
GoToControl | The GoToControl method performs the GoToControl action action in Visual Basic.
GoToPage | Carries out the GoToPage action in Visual Basic. .
GoToRecord | The GoToRecord method carries out the GoToRecord action in Visual Basic.
Hourglass | The Hourglass method carries out the Hourglass action in Visual Basic.
LockNavigationPane | You can use the LockNavigationPane action to prevent users from deleting database objects that are displayed in the Navigation Pane.
Maximize | The Maximize method carries out the Maximize action in Visual Basic.
Minimize | The Minimize method carries out the Minimize action in Visual Basic.
MoveSize | The MoveSize method carries out the MoveSize action in Visual Basic.
NavigateTo | You can use the NavigateTo method to control the display of database objects in the Navigation Pane. .
OpenDataAccessPage | The OpenDataAccessPage method carries out the OpenDataAccessPage action in Visual Basic.
OpenDiagram | The OpenDiagram method carries out the OpenDiagram action in Visual Basic.
OpenForm | The OpenForm method carries out the OpenForm action in Visual Basic.
OpenFunction | Opens a user-defined function in a Microsoft SQL Server database for viewing in Microsoft Access.
OpenModule | The OpenModule method carries out the OpenModule action in Visual Basic.
OpenQuery | The OpenQuery method carries out the OpenQuery action in Visual Basic.
OpenReport | The OpenReport method carries out the OpenReport action in Visual Basic.
OpenStoredProcedure | The OpenStoredProcedure method carries out the OpenStoredProcedure action in Visual Basic.
OpenTable | The OpenTable method carries out the OpenTable action in Visual Basic.
OpenView | The OpenView method carries out the OpenView action in Visual Basic.
OutputTo | The OutputTo method carries out the OutputTo action in Visual Basic.
PrintOut | The PrintOut method carries out the PrintOut action in Visual Basic.
Quit | The Quit method quits Microsoft Access. You can select one of several options for saving a database object before quitting.
RefreshRecord | The RefreshRecord method performs the RefreshRecord macro operation from Visual Basic.
Rename | The Rename method carries out the Rename action in Visual Basic.
RepaintObject | The RepaintObject method carries out the RepaintObject action in Visual Basic.
Requery | Carries out the Requery action in Visual Basic.
Restore | The Restore method carries out the Restore action in Visual Basic.
RunCommand | The RunCommand method runs a built-in command.
RunDataMacro | Use the RunDataMacro method to run a named data macro from Visual Basic.
RunMacro | The RunMacro method carries out the RunMacro action in Visual Basic.
RunSavedImportExport | Rrun a saved import or export specification.
RunSQL | The RunSQL method carries out the RunSQL action in Visual Basic.
Save | The Save method carries out the Save action in Visual Basic.
SearchForRecord | You can use the SearchForRecord method to search for a specific record in a table, query, form, or report.
SelectObject | The SelectObject method carries out the SelectObject action in Visual Basic.
SendObject | The SendObject method carries out the SendObject action in Visual Basic.
SetDisplayedCategories | Specifies which categories are displayed under Navigate to Category in the title bar of the Navigation Pane. .
SetFilter | Use the SetFilter method to apply a filter to the records in the active datasheet, form, report, or table.
SetMenuItem | The SetMenuItem method carries out the SetMenuItem action in Visual Basic.
SetOrderBy | Use the SetOrderBy method to apply a sort to the active datasheet, form, report, or table.
SetParameter | Use the SetParameter method to create a parameter for use by the BrowseTo , OpenForm, OpenQuery, OpenReport, or RunDataMacro methods.
SetProperty | The SetProperty method carries out the SetProperty action in Visual Basic.
SetWarnings | The SetWarnings method carries out the SetWarnings action in Visual Basic.
ShowAllRecords | The ShowAllRecords method carries out the ShowAllRecords action in Visual Basic.
ShowToolbar | The ShowToolbar method carries out the ShowToolbar action in Visual Basic.
SingleStep | Pauses macro execution and opens the Macro Single Step dialog box.
TransferDatabase | The TransferDatabase method carries out the TransferDatabase action in Visual Basic.
TransferSharePointList | You can use the TransferSharePointList method to import or link data from a SharePoint Foundation site.
TransferSpreadsheet | The TransferSpreadsheet method carries out the TransferSpreadsheet action in Visual Basic.
TransferSQLDatabase | Transfers the entire specified Microsoft SQL Server database to another SQL Server database.
TransferText | The TransferText method carries out the TransferText action in Visual Basic.


Not a valid table name. (Error 3177)

 Copy code hover
[image]

Not a valid table name. (Error 3177)
Send feedback

The name you entered does not follow standard naming conventions. Enter a new name, and then try the operation again.


ListBox.Height Property (Access)

 Copy code hover
[image]

ListBox.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Syntax

expression .Height

expression A variable that represents a ListBox object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


EmptyCell.EventProcPrefix Property (Access)

 Copy code hover
[image]

EmptyCell.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .EventProcPrefix

expression A variable that represents an EmptyCell object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


FormatCondition Methods (Access)

 Copy code hover
[image]

FormatCondition Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Delete | Deletes the specified object.
Modify | You can use the Modify method to change the format conditions of a FormatCondition object in the FormatConditions collection of a combo box or text box control.


ObjectFrame.Top Property (Access)

 Copy code hover
[image]

ObjectFrame.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Syntax

expression .Top

expression A variable that represents an ObjectFrame object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


WebBrowserControl.OnKeyUp Property (Access)

 Copy code hover
[image]

WebBrowserControl.OnKeyUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Up box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnKeyUp

expression A variable that represents a WebBrowserControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyUp event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyUp

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


CommandButton.Bevel Property (Access)

 Copy code hover
[image]

CommandButton.Bevel Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bevel effect applied to the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .Bevel

expression A variable that represents a CommandButton object.

Remarks

The Bevel property contains a numeric expression that represents the bevel effect applied to the specified object. The default value of the Bevel property is 0, which does not apply a bevel effect.

The Bevel effects include values that are listed in the following table.

Value | Effect
0 | None
1 | Circle
2 | Relaxed Inset
3 | Cross
4 | Cool Slant
5 | Angle
6 | Soft Round
7 | Convex
8 | Slope
9 | Divot
10 | Riblet
11 | Hard Edge
12 | Art Deco

To see the available bevel effects and apply a bevel through the user interface, first open the form or report in Layout view or Design view by right-clicking the form or report in the Navigation Pane, and then clicking the view you want. Then, click the object to which you want to apply a bevel effect. Next, on the Format tab, in the Control Formatting group, click Shape Effects, then click Bevel and choose a bevel effect. Notice that the bevel effects are indexed from left to right, and then top to bottom. So the first item, under No Bevel, has the value 0. Then, under Bevel, the first row contains bevel effects with values from 1 to 4. The second row from 5 to 8, and the third row from 9 to 12.

This property is not surfaced in the property sheet.

Example

The following code example sets the bevel effect to Cross.

VBA Copy code Copy code
Public Const BevelEffectNone = 0
Public Const BevelEffectCircle = 1
Public Const BevelEffectRelaxedInset = 2
Public Const BevelEffectCross = 3
Public Const BevelEffectCoolSlant = 4
Public Const BevelEffectAngle = 5
Public Const BevelEffectSoftRound = 6
Public Const BevelEffectConvex = 7
Public Const BevelEffectSlope = 8
Public Const BevelEffectDivot = 9
Public Const BevelEffectRiblet = 10
Public Const BevelEffectHardEdge = 11
Public Const BevelEffectArtDeco = 12
Me.ctl.Bevel = BevelEffectCross

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Report.OnLoad Property (Access)

 Copy code hover
[image]

Report.OnLoad Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Load box in the Properties window of a report. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnLoad

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Load event occurs when a report is opened and its records are displayed.

The OnLoad value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Load box in the report's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Load box is blank, the property value is an empty string.

See also

Concepts

Report Object

Other resources

Report Object Members


Application.VBE Property (Access)

 Copy code hover
[image]

Application.VBE Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the VBE property to return a reference to the current VBE object and its related properties. The VBE property of the Application object represents the Microsoft Visual Basic for Applications editor. Read-only VBE object.

Syntax

expression .VBE

expression A variable that represents an Application object.

Remarks

Once you establish a reference to the VBE object, you can access all the properties and methods of the object. You can set a reference to the VBE object by clicking References on the Tools menu while in module Design view. Then set a reference to the Microsoft Visual Basic for Applications Extensibility 5.3 Object Library in the References dialog box by selecting the appropriate check box. Microsoft Access can set this reference for you if you use a Microsoft Visual Basic for Applications Extensibility 5.3 Object Library constant to set a VBE object's property or as an argument to a VBE object's method.

Example

This example displays the number of references available for the active project.

VBA Copy code Copy code
MsgBox "Number of References = " & VBE.ActiveVBProject _
 .References.Count

See also

Concepts

Application Object

Other resources

Application Object Members


Cell Object (ADO MD)

 Copy code hover
[image]

Cell Object (ADO MD)
Send feedback

Represents the data at the intersection of axis coordinates contained in a cellset.

Remarks

A Cell object is returned by the Item property of a Cellset object.

With the collections and properties of a Cell object, you can do the following:

  • Return the data in the Cell with the Value property.

  • Return the string representing the formatted display of the Value property with the FormattedValue property.

  • Return the ordinal value of the Cell within the Cellset with the Ordinal property.

  • Determine the position of the Cell within the CubeDef with the Positions collection.

  • Retrieve other information about the Cell with the standard ADO Properties collection.

The Properties collection contains provider-supplied properties. The following table lists properties that might be available. The actual property list may differ depending upon the implementation of the provider. See the documentation for your provider for a more complete list of available properties.

Name | Description
BackColor | Background color used when displaying the cell.
FontFlags | Bitmask detailing effects on the font.
FontName | Font used to display the cell value.
FontSize | Font size used to display the cell value.
ForeColor | Foreground color used when displaying the cell.
FormatString | Value in a formatted string.


Clone Method Example (VBScript)

 Copy code hover
[image]

Clone Method Example (VBScript)
Send feedback

This example uses the Clone method to create copies of a Recordset and then lets the user position the record pointer of each copy independently.

Use the following example in an Active Server Page (ASP). This example uses the Northwind database distributed with Microsoft Access. Cut and paste the following code to Notepad or another text editor and save it as CloneVBS.asp. You can view the result in any client browser.

To exercise the example, change the line RsCustomerList.Source = "Customers" to to RsCustomerList.Source = "Products" to count a larger table.

VBS Copy code Copy code

<!-- BeginCloneVBS -->
<% Language = VBScript %>
<%' use this meta tag instead of adovbs.inc%>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->
<HTML>
<HEAD>
<TITLE>ADO Clone Method</TITLE>
</HEAD>

<BODY>

<H1 align="center">ADO Clone Method</H1>
<HR>
<% ' to integrate/test this code replace the
   ' Data Source value in the Connection string%>
<%
    ' connection and recordset variables
    Dim Cnxn, strCnxn
    Dim rsCustomers, strSQLCustomers
    Dim rsFirst, rsLast, rsCount
    Dim rsClone
    Dim CloneFirst, CloneLast, CloneCount

    ' open connection
    Set Cnxn = Server.CreateObject("ADODB.Connection")
    strCnxn = "Provider='sqloledb';Data Source=" & _
            Request.ServerVariables("SERVER_NAME") & ";" & _
            "Integrated Security='SSPI';Initial Catalog='Northwind';"
    Cnxn.Open strCnxn

    ' create and open Recordset using object refs
    Set rsCustomers = Server.CreateObject("ADODB.Recordset")
    strSQLCustomers = "Customers"

    rsCustomers.ActiveConnection = Cnxn
    rsCustomers.CursorLocation = adUseClient
    rsCustomers.CursorType = adOpenKeyset
    rsCustomers.LockType = adLockOptimistic
    rsCustomers.Source = strSQLCustomers
    rsCustomers.Open

    rsCustomers.MoveFirst
    rsCount = rsCustomers.RecordCount
    rsFirst = rsCustomers("CompanyName")
    rsCustomers.MoveLast
    rsLast = rsCustomers("CompanyName")

    ' create clone
    Set rsClone = rsCustomers.Clone
    rsClone.MoveFirst
    CloneCount = rsClone.RecordCount
    CloneFirst = rsClone("CompanyName")
    rsClone.MoveLast
    CloneLast = rsClone("CompanyName")
%>

<!-- Display Results -->
<H3>There Are <%=rsCount%> Records in the original recordset</H3>
<H3>The first record is <%=rsFirst%> and the last record is <%=rsLast%></H3>
<BR><HR>
<H3>There Are <%=CloneCount%> Records in the original recordset</H3>
<H3>The first record is <%=CloneFirst%> and the last record is <%=CloneLast%></H3>
<BR><HR>
<H4>Location of OLEDB Database</H4>

<%
    ' Show location of DSN data source
    Response.Write(Cnxn)

    ' Clean up
    If rsCustomers.State = adStateOpen then
       rsCustomers.Close
    End If
    If rsClone.State = adStateOpen then
       rsClone.Close
    End If
    If Cnxn.State = adStateOpen then
       Cnxn.Close
    End If
    Set rsCustomers = Nothing
    Set rsClone = Nothing
    Set Cnxn = Nothing
%>
</BODY>
</HTML>
<!-- EndCloneVBS -->


Form.MenuBar Property (Access)

 Copy code hover
[image]

Form.MenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies a custom menu to display for a form. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .MenuBar

expression A variable that represents a Form object.

Remarks

When opening a form in Microsoft Access 2013 that is part of a database that was created in an earlier version of Microsoft Access, the specified menu bar will be displayed differently depending on the curent settings of the AllowFullMenus and AllowBuiltInToolbars properties. If the AllowFullMenus and AllowBuiltInToolbars properties are set to False, the specified menu bar will replace the ribbon as the default set of commands available to the user. If the AllowFullMenus or AllowBuiltInToolbars property is set to True, then the specified menu bar is displayed on the ribbon Add-Ins tab.

See also

Concepts

Form Object

Other resources

Form Object Members


AutoCorrect Object (Access)

 Copy code hover
[image]

AutoCorrect Object (Access)
See also Send feedback

Published: July 16, 2012

The AutoCorrect object represents the AutoCorrect functionality of Microsoft Access.

Remarks

To return an AutoCorrect object, use the AutoCorrect property.

To enable or disable the display of the AutoCorrect Options button, use the DisplayAutoCorrectOptions property.

To enable or disable AutoCorrect functionality for a particular TextBox or ComboBox object, use the AllowAutoCorrect property.

See also

Concepts

Access Object Model Reference

Other resources

AutoCorrect Object Members


ToggleButton.PictureType Property (Access)

 Copy code hover
[image]

ToggleButton.PictureType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.

Syntax

expression .PictureType

expression A variable that represents a ToggleButton object.

Remarks

The PictureType property uses the following settings.

Setting | Description
0 | (Default) The picture is embedded in the object and becomes part of the database file.
1 | The picture is linked to the object. Microsoft Access stores a pointer to the location of the picture on the disk.

This property can be set only in form Design view or report Design view.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

When this property is set to 0, the size of the database increases by the size of the picture file and, with some .wmf files, the size may increase as much as twice the size of the picture file. When this property is set to 1, there is no increase in the size of the database because Microsoft Access only saves a pointer to the picture's location on the disk.

Note Note

If a linked file is moved to another location on the disk, you must re-establish the link by using the object's Picture property.

For embedded pictures, the object's PictureData property stores the individual bits that make up a picture's image. For linked pictures, this property stores the path to the picture's file.

You can modify a linked picture by using a separate application and changes to the picture will appear the next time the object containing that picture is displayed in the database.

Example

The following example links the picture in the "Customer Photo" image control on the "Order Entry" form to the picture on the disk. The picture is not part of the database file.

VBA Copy code Copy code
Forms("Order Entry").Controls("Customer Photo").PictureType = 1

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Value Property (ADO MD)

 Copy code hover
[image]

Value Property (ADO MD)
Send feedback

Indicates the value of the current cell.

Return Values

Returns a Variant and is read-only.


OpenStoredProcedure Macro Action

 Copy code hover
[image]

OpenStoredProcedure Macro Action
Send feedback

In an Access project, you can use the OpenStoredProcedure action to open a stored procedure in Datasheet view, stored procedure Design view, or Print Preview. This action runs the named stored procedure when opened in Datasheet view. You can select the data entry mode for the stored procedure and restrict the records that the stored procedure displays.

Note 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.

Setting

The OpenStoredProcedure action has the following arguments.

Action argument | Description
Procedure Name | The name of the stored procedure to open. The Procedure Name box box in the Action Arguments section of the Macro Builder pane shows all stored procedures in the current database. This is a required argument. If you run a macro containing the OpenStoredProcedure action in a library database, Microsoft Access first looks for the stored procedure with this name first in the library database, and then in the current database.
View | The view in which the stored procedure will open. Click Datasheet, Design, Print Preview, PivotTable, or PivotChart in the View box. The default is Datasheet.
Data Mode | The data entry mode for the stored procedure. This applies only to stored procedures opened in Datasheet view. Click Add (the user can add new records but can't view or edit existing records), Edit (the user can view or edit existing records and add new records), or Read Only (the user can only view records). The default is Edit.

Remarks

This action is similar to double-clicking the stored procedure in the Navigation Pane, or right-clicking the stored procedure in the Navigation Pane and selecting the command you want.

Switching to Design view while the stored procedure is open removes the Data Mode argument setting for the stored procedure. This setting is not in effect, even if the user returns to Datasheet view.

Tip Tip

  • You can drag a stored procedure from the Navigation Pane to a macro action row. This automatically creates an OpenStoredProcedure action that opens the stored procedure in Datasheet view.

  • If you do not want to display the system messages that normally appear when a stored procedure is run (indicating it is a stored procedure and showing how many records will be affected), you can use the SetWarning action to suppress the display of these messages.

To run the OpenStoredProcedure action in a Visual Basic for Applications (VBA) module, use the OpenStoredProcedure method of the DoCmd object.


Users Collection Properties, Methods, and Events (ADOX)

 Copy code hover
[image]

Users Collection Properties, Methods, and Events (ADOX)
Send feedback

Properties

Count Property

Item Property

Methods

Append Method (Users)

Delete Method (Collections)

Refresh Method

Events

None.


ToggleButton.ControlTipText Property (Access)

 Copy code hover
[image]

ToggleButton.ControlTipText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.

Syntax

expression .ControlTipText

expression A variable that represents a ToggleButton object.

Remarks

You set the ControlTipText property by using a string expression up to 255 characters long.

For controls on forms, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

You can set the ControlTipText property in any view.

The ControlTipText property provides an easy way to provide helpful information about controls on a form.

There are other ways to provide information about a form or a control on a form. You can use the StatusBarText property to display information in the status bar about a control. To provide more extensive help for a form or control, use the HelpFile and HelpContextID properties.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


How to: Find a Record in a Table-Type DAO Recordset

 Copy code hover
[image]

How to: Find a Record in a Table-Type DAO Recordset
Send feedback

You use the Seek method to locate a record in a table-type Recordset object.

When you use the Seek method to locate a record, the Microsoft Access database engine uses the table's current index, as defined by the Index property.

Note Note

If you use the Seek method on a table-type Recordset object without first setting the current index, a run-time error occurs.

The following example opens a table-type Recordset object called Employees, and uses the Seek method to locate the record containing a value of lngEmpID in the EmployeeID field. It returns the hire date for the specified employee.

VBA Copy code Copy code
Function GetHireDate(lngEmpID As Long) As Variant

Dim dbsNorthwind As DAO.Database
Dim rstEmployees As DAO.Recordset

On Error GoTo ErrorHandler

   Set dbsNorthwind = CurrentDB
   Set rstEmployees = dbsNorthwind.OpenRecordset("Employees")

   ' The index name for Employee ID.
   rstEmployees.Index = "PrimaryKey"
   rstEmployees.Seek "=", lngEmpID

   If rstEmployees.NoMatch Then
      GetHireDate = Null
   Else
      GetHireDate = rstEmployees!HireDate
   End If

   rstEmployees.Close
   dbsNorthwind.Close

   Set rstEmployees = Nothing
   Set dbsNorthwind = Nothing

Exit Function

ErrorHandler:
   MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Function

The Seek method always starts searching for records at the beginning of the Recordset object. If you use the Seek method with the same arguments more than once on the same Recordset, it finds the same record.

You can use the NoMatch property on the Recordset object to test whether a record matching the search criteria was found. If the record matching the criteria was found, the NoMatch property will be False; otherwise it will be True.

The following code example shows how you can create a function that uses the Seek method to locate a record by using a multiple-field index.

VBA Copy code Copy code
Function GetFirstPrice(lngOrderID As Long, lngProductID As Long) As Variant

Dim dbsNorthwind As DAO.Database
Dim rstOrderDetail As DAO.Recordset

On Error GoTo ErrorHandler

   Set dbsNorthwind = CurrentDb
   Set rstOrderDetail = dbsNorthwind.OpenRecordset("Order Details")

   rstOrderDetail.Index = "PrimaryKey"
   rstOrderDetail.Seek "=", lngOrderID, lngProductID

   If rstOrderDetail.NoMatch Then
      GetFirstPrice = Null
   Else
      GetFirstPrice = rstOrderDetail!UnitPrice
   End If

   rstOrderDetail.Close
   dbsNorthwind.Close

   Set rstOrderDetail = Nothing
   Set dbsNorthwind = Nothing

Exit Function

ErrorHandler:
   MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Function

In this example, the table's primary key consists of two fields: OrderID and ProductID. When you call the GetFirstPrice function with a valid (existing) combination of OrderID and ProductID field values, the function returns the unit price from the found record. If it cannot find the combination of field values you want in the table, the function returns the Null value.

If the current index is a multiple-field index, trailing key values can be omitted and are treated as Null values. That is, you can leave off any number of key values from the end of a Seek method's key argument, but not from the beginning or the middle. However, if you do not specify all values in the index, you can use only the ">" or "<" comparison string with the Seek method.


DBEngine.IniPath Property (DAO)

 Copy code hover
[image]

DBEngine.IniPath Property (DAO)
Send feedback

Sets or returns information about the Windows Registry key that contains values for the Microsoft Access database engine (Microsoft Access workspaces only).

Syntax

expression .IniPath

expression A variable that represents a DBEngine object.

Remarks

You can configure the Microsoft Access databse engine with the Windows Registry. You can use the Registry to set options, such as installable ISAM DLLs.

For this option to have any effect, you must set the IniPath property before your application invokes any other DAO code. The scope of this setting is limited to your application and can't be changed without restarting your application.

You also use the Registry to provide initialization parameters for some installable ISAM database drivers. For example, to use Paradox version 4.0, set the IniPath property to a part of the Registry containing the appropriate parameters.

This property recognizes either HKEY_LOCAL_MACHINE or HKEY_LOCAL_USER. If no root key is supplied, the default is HKEY_LOCAL_MACHINE.


Recordset2.DateCreated Property (DAO)

 Copy code hover
[image]

Recordset2.DateCreated Property (DAO)
Send feedback

Returns the date and time a base table was created (Microsoft Access workspaces only). Read-only Variant.

Syntax

expression .DateCreated

expression A variable that represents a Recordset2 object.

Remarks

The date and time settings are derived from the computer on which the base table was created or last updated.


NavigationButton.Gradient Property (Access)

 Copy code hover
[image]

NavigationButton.Gradient Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the gradient fill applied to the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .Gradient

expression A variable that represents a NavigationButton object.

Remarks

The Gradient property contains a numeric expression that represents the gradient fill applied to the specified object. The default value of the Gradient property is 0, which does not apply a gradient. The values are listed in the following table.

Value | Gradient Fill
0 | None
1 | Linear Diagonal - Top Left to Bottom Right, Light
2 | Linear Down, Light
3 | Linear Diagonal - Top Right to Bottom Left, Light
4 | From Bottom Right Corner, Light
5 | From Bottom Left Corner, Light
6 | Linear Left, Light
7 | Linear Center, Light
8 | Linear Right, Light
9 | From Top Right Corner, Light
10 | From Top Left Corner, Light
11 | Linear Diagonal - Bottom Left to Top Right, Light
12 | Linear Up, Light
13 | Linear Diagonal - Bottom Right to Top Left, Light
14 | Linear Diagonal - Top Left to Bottom Right, Dark
15 | Linear Down, Dark
16 | Linear Diagonal - Top Right to Bottom Left, Dark
17 | From Bottom Right Corner, Dark
18 | From Bottom Left Corner, Dark
19 | Linear Left, Dark
20 | Linear Center, Dark
21 | Linear Right, Dark
22 | From Top Right Corner, Dark
23 | From Top Left Corner, Dark
24 | Linear Diagonal - Bottom Left to Top Right, Dark
25 | Linear Up, Dark
26 | Linear Diagonal - Bottom Right to Top Left, Light

To see the available gradient fills and apply a gradient through the user interface, first open the form or report in Layout view or Design view by right-clicking the form or report in the Navigation Pane, and then clicking the view you want. Then, click the object to which you want to apply a gradient fill. Next, on the Format tab, in the Control Formatting group, click Shape Fill, then click Gradient and choose a gradient fill. You can hover over a gradient fill to see a description.

This property is not surfaced in the property sheet.

Example

The following code example sets the gradient fill to Linear Down, Light.

VBA Copy code Copy code
Me.ctl.Gradient = 2

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


BrowseTo Macro Action

 Copy code hover
[image]

BrowseTo Macro Action
Send feedback

You can use the BrowseTo action to navigate between objects in place. You can also change the source object of a subform control by specifying the Path to Subform Control argument. Use BrowseTo to navigate from form1 to form2 without opening up a new window.

Setting

The BrowseTo action has the following argument.

Action argument | Description
Object Type | The object type to which to browse.
Object Name | The object that loads inside the subform control referenced by the Path to Subform Control argument.
Path to Subform Control | If specified, the path from the main form of the application to the target subform control that loads the object specified by the Object Name argument.
Where Condition | If specified, replaces the Where condition of the object record source.
Page | If specified, sets the page of the continuous form that will be made the current page. This argument is Web only.
Data Mode | If specified, the data entry mode of the form.

Remarks

The PathToSubFormControl argument must be specified using the syntax in the following code example:

Copy code Copy code
Main Form.SubForm Ctrl 1>Form 2.SubForm Ctrl 2>Form 3.SubFormCtrl3

In this example, the Main Form is the top level form in the Access client application. The Path to Sub Form Control argument must alternately specify form and subform control names leading from the main form to the subform control that is the container of the object specified by the Object Name argument. Each subform control specified must be a control on the form that precedes it. The path must end with a subform control.

Example

The following example shows how to use the BrowseTo action to open a report in a subform control or within a navigation control.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

Copy code Copy code
OnError
    Go to Next
    Macro Name

/* Try to load the report in the host form (frmAuthorsParameter)    */
BrowseTo
    Object Type Report
    Object Name rptChapters
    Path to Subform Control frmAuthorsParameter.sfrmChild
    Where Condition
    Page
    Data Mode Edit

Parameters
    SelectedAuthor =[cboAuthor]

/* if this fails, try to load it in the navigation subform     */
BrowseTo
    Object Type Report
    Object Name rptChapters
    Path to Subform Control frmMain.NavigationSubform>frmAuthorsParameter.sfrmChild
    Where Condition
    Page
    Data Mode Edit

Parameters
    SelectedAuthor =[cboAuthor]

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Label.Left Property (Access)

 Copy code hover
[image]

Label.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Syntax

expression .Left

expression A variable that represents a Label object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

Label Object

Other resources

Label Object Members


CommandButton.PictureCaptionArrangement Property (Access)

 Copy code hover
[image]

CommandButton.PictureCaptionArrangement Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets how the specified button's caption is arranged in relation to its picture. Read/write AcPictureCaptionArrangement.

Version Information

Version Added: Access 2007

Syntax

expression .PictureCaptionArrangement

expression A variable that represents a CommandButton object.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Report.KeyDown Event (Access)

 Copy code hover
[image]

Report.KeyDown Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyDown event occurs when the user presses a key while a report has the focus. This event also occurs if you send a keystroke to a report by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyDown(KeyCode, Shift)

expression A variable that represents a Report object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyDown property to the name of the macro or to [Event Procedure].

A report will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the report to Yes. With this property setting, all keyboard events occur first for the report, and then for the control that has the focus. You can respond to specific keys pressed in the report, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a report.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, and then the KeyUp event occurs.

Although the KeyDown event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

See also

Concepts

Report Object

Other resources

Report Object Members


Cast Function (Access 2013 custom web app)

 Copy code hover
[image]

Cast Function (Access 2013 custom web app)
Send feedback

Converts an expression of one data type to another.

Syntax

Convert(Expression, DataType)

Argument Name | Description
Expression | A valid expression.
DataType | The target data type.


SELECT (Microsoft Access SQL reserved word)

 Copy code hover
[image]

SELECT (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The SELECT keyword is used in these contexts:

SELECT Statement

SELECT … INTO Statement

CREATE VIEW Statement

CREATE PROCEDURE Statement

GRANT Statement

REVOKE Statement


DependencyObjects.Parent Property (Access)

 Copy code hover
[image]

DependencyObjects.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a DependencyObjects object.

See also

Concepts

DependencyObjects Collection

Other resources

DependencyObjects Object Members


CheckBox.ControlTipText Property (Access)

 Copy code hover
[image]

CheckBox.ControlTipText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.

Syntax

expression .ControlTipText

expression A variable that represents a CheckBox object.

Remarks

You set the ControlTipText property by using a string expression up to 255 characters long.

For controls on forms, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

You can set the ControlTipText property in any view.

The ControlTipText property provides an easy way to provide helpful information about controls on a form.

There are other ways to provide information about a form or a control on a form. You can use the StatusBarText property to display information in the status bar about a control. To provide more extensive help for a form or control, use the HelpFile and HelpContextID properties.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


EmptyCell.LayoutID Property (Access)

 Copy code hover
[image]

EmptyCell.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified text box. Read-only Long.

Version Information

Version Added: Access 2010

Syntax

expression .LayoutID

expression A variable that represents an EmptyCell object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


Query Field

 Copy code hover
[image]

Query Field
Send feedback

Published: July 16, 2012

A query field represents data from a table linked to the query. By default, a query field inherits all the properties that it has in the underlying table or query. For example, if a table design specifies the display format of the Order Date field as Medium Date in the field's Format property, the Order Date field is formatted in the query recordset as Medium Date. Because the underlying field properties are the defaults, they aren't displayed on the property sheet.

If a field property is changed in the table design, the query field automatically inherits the change. If, however, you change a property within the query, the property setting within the table design is overridden. If the property is later changed in the table design, the change isn't reflected in the query.

You can set the properties for query fields within the Field Properties window of the query Design view.


CustomControl.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

CustomControl.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthBottom

expression A variable that represents a CustomControl object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


ComboBox.Enter Event (Access)

 Copy code hover
[image]

ComboBox.Enter Event (Access)
See also Send feedback

Published: July 16, 2012

The Enter event occurs before a control actually receives the focus from a control on the same form or report.

Syntax

expression .Enter

expression A variable that represents a ComboBox object.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when these events occur, set the OnEnter or OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Enter event occurs before the GotFocus event. The Exit event occurs before the LostFocus event.

Unlike the GotFocus and LostFocus events, the Enter and Exit events don't occur when a form receives or loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Command Object Parameters

 Copy code hover
[image]

Command Object Parameters
Send feedback

A more interesting use for the Command object is shown in the next example, in which the text of the SQL command has been modified to make it parameterized. This makes it possible to reuse the command, passing in a different value for the parameter each time. Because the Prepared property on the Command object is set equal to True, ADO will require the provider to compile the command specified in CommandText before executing it for the first time. It also will retain the compiled command in memory. This slows the execution of the command slightly the first time it is executed because of the overhead required to prepare it, but results in a performance gain each time the command is called thereafter. Thus, commands should be prepared only if they will be used more than once.

Copy code Copy code

'BeginManualParamCmd
 On Error GoTo ErrHandler:

 Dim objConn As New ADODB.Connection
 Dim objCmd As New ADODB.Command
 Dim objParm1 As New ADODB.Parameter
 Dim objRs As New ADODB.Recordset

 ' Set the CommandText as a parameterized SQL query.
 objCmd.CommandText = "SELECT OrderID, OrderDate, " & _
 "RequiredDate, ShippedDate " & _
 "FROM Orders " & _
 "WHERE CustomerID = ? " & _
 "ORDER BY OrderID"
 objCmd.CommandType = adCmdText

 ' Prepare command since we will be executing it more than once.
 objCmd.Prepared = True

 ' Create new parameter for CustomerID. Initial value is ALFKI.
 Set objParm1 = objCmd.CreateParameter("CustId", adChar, _
 adParamInput, 5, "ALFKI")
 objCmd.Parameters.Append objParm1

 ' Connect to the data source.
 Set objConn = GetNewConnection
 objCmd.ActiveConnection = objConn

 ' Execute once and display...
 Set objRs = objCmd.Execute

 Debug.Print objParm1.Value
 Do While Not objRs.EOF
 Debug.Print vbTab & objRs(0) & vbTab & objRs(1) & vbTab & _
 objRs(2) & vbTab & objRs(3)
 objRs.MoveNext
 Loop

 ' ...then set new param value, re-execute command, and display.
 objCmd("CustId") = "CACTU"
 Set objRs = objCmd.Execute

 Debug.Print objParm1.Value
 Do While Not objRs.EOF
 Debug.Print vbTab & objRs(0) & vbTab & objRs(1) & vbTab & _
 objRs(2) & vbTab & objRs(3)
 objRs.MoveNext
 Loop

 'clean up
 objRs.Close
 objConn.Close
 Set objRs = Nothing
 Set objConn = Nothing
 Set objCmd = Nothing
 Set objParm1 = Nothing
 Exit Sub

ErrHandler:
 'clean up
 If objRs.State = adStateOpen Then
 objRs.Close
 End If

 If objConn.State = adStateOpen Then
 objConn.Close
 End If

 Set objRs = Nothing
 Set objConn = Nothing
 Set objCmd = Nothing
 Set objParm1 = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
'EndManualParamCmd

Not all providers support prepared commands. If the provider does not support command preparation, it might return an error as soon as this property is set to True. If it does not return an error, it ignores the request to prepare the command and sets the Prepared property to False.


Form.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

Form.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Syntax

expression .ShortcutMenuBar

expression A variable that represents a Form object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

Example

The following example sets the "Suppliers_Toolbar" as the custom shortcut menu to display when the user clicks the right mouse button on the "Suppliers" form.

VBA Copy code Copy code
Forms("Suppliers").ShortcutMenuBar = "Suppliers_Toolbar"

See also

Concepts

Form Object

Other resources

Form Object Members


WebService Properties (Access)

 Copy code hover
[image]

WebService Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Entities | Gets the collection of entities defined for the spcified Data Service data connection. Read-only Entities.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.


CheckBox.Application Property (Access)

 Copy code hover
[image]

CheckBox.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a CheckBox object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Locating the Current Record

 Copy code hover
[image]

Locating the Current Record
Send feedback

The current position of the cursor in the Recordset delineates the current record position. Assuming that the command issued returns results, the cursor is automatically placed at the first record when the Recordset Open method is called. So, with the sample Recordset, the cursor would be on the first record, "Uncle Bob's Organic Dried Pears."


Dimension Object (ADO MD Reference)

 Copy code hover
[image]

Dimension Object (ADO MD Reference)
Send feedback

In this section

  • Dimension Object (ADO MD)

  • Dimension Properties, Methods, and Events (ADO MD)


Attributes and Name Properties Example (VB)

 Copy code hover
[image]

Attributes and Name Properties Example (VB)
Send feedback

This example displays the value of the Attributes property for Connection, Field, and Property objects. It uses the Name property to display the name of each Field and Property object.

Copy code Copy code

'BeginAttributesVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 'recordset and connection variables
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim rstEmployees As ADODB.Recordset
 Dim strSQLEmployee As String
 'record variables
 Dim adoField As ADODB.Field
 Dim adoProp As ADODB.Property

 ' Open connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Set Cnxn = New ADODB.Connection
 Cnxn.Open strCnxn

 ' Open recordset
 Set rstEmployees = New ADODB.Recordset
 strSQLEmployee = "employee"
 rstEmployees.Open strSQLEmployee, Cnxn, adOpenForwardOnly, adLockReadOnly, adCmdTable
 'the above two lines openign the recordset are identical as
 'the default values for CursorType and LockType arguments match those shown

 ' Display the attributes of the connection
 Debug.Print "Connection attributes = " & Cnxn.Attributes

 ' Display the property attributes of the Employee Table
 Debug.Print "Property attributes:"
 For Each adoProp In rstEmployees.Properties
 Debug.Print " " & adoProp.Name & " = " & adoProp.Attributes
 Next adoProp

 ' Display the field attributes of the Employee Table
 Debug.Print "Field attributes:"
 For Each adoField In rstEmployees.Fields
 Debug.Print " " & adoField.Name & " = " & adoField.Attributes
 Next adoField

 ' Display fields of the Employee Table which are NULLABLE
 Debug.Print "NULLABLE Fields:"
 For Each adoField In rstEmployees.Fields
 If CBool(adoField.Attributes And adFldIsNullable) Then
 Debug.Print " " & adoField.Name
 End If
 Next adoField

 ' clean up
 rstEmployees.Close
 Cnxn.Close
 Set rstEmployees = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstEmployees Is Nothing Then
 If rstEmployees.State = adStateOpen Then rstEmployees.Close
 End If
 Set rstEmployees = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndAttributesVB


ToggleButton Events (Access)

 Copy code hover
[image]

ToggleButton Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.


OriginalValue and UnderlyingValue Properties Example (VC++)

 Copy code hover
[image]

OriginalValue and UnderlyingValue Properties Example (VC++)
Send feedback

This example demonstrates the OriginalValue and UnderlyingValue properties by displaying a message if a record's underlying data has changed during a Recordset batch update.

Copy code Copy code

// BeginOriginalValueCpp
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>
#include "OriginalValueX.h"

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void OriginalValueX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 OriginalValueX();

 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// OriginalValueX Function //
// //
///////////////////////////////////////////////////////////

void OriginalValueX(void)
{
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _ConnectionPtr pConnection = NULL;
 FieldPtr pFldType = NULL;
 _RecordsetPtr pRstTitles = NULL;

 // Define string variables.
 _bstr_t strSQLChange("UPDATE Titles SET Type = "
 "'sociology' WHERE Type = 'psychology'");
 _bstr_t strSQLRestore("UPDATE Titles SET Type = "
 "'psychology' WHERE Type = 'sociology'");

 // Define Other Variables
 HRESULT hr = S_OK;
 IADORecordBinding *picRs = NULL; //Interface Pointer declared
 CTitleRs titlers; // C++ Class object

 try
 {
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 // Open connection.
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
 pConnection->Open (strCnn, "", "", adConnectUnspecified);

 // Open Recordset for batch update.
 TESTHR(pRstTitles.CreateInstance(__uuidof(Recordset)));
 pRstTitles->PutActiveConnection(
 _variant_t((IDispatch *)pConnection,true));
 pRstTitles->CursorType = adOpenKeyset;
 pRstTitles->LockType = adLockBatchOptimistic;

 // Cast Connection pointer to an IDispatch type so converted
 // to correct type of variant.
 pRstTitles->Open("Titles",
 _variant_t((IDispatch *)pConnection,true),
 adOpenKeyset, adLockBatchOptimistic, adCmdTable);

 //Open an IADORecordBinding interface pointer which
 //we'll use for Binding Recordset to a class.
 TESTHR(pRstTitles->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 //Bind the Recordset to a C++ Class here
 TESTHR(picRs->BindToRecordset(&titlers));

 // Set field object variable for Type field.
 pFldType = pRstTitles->Fields->GetItem("type");

 // Change the type of psychology titles.
 while(!(pRstTitles->EndOfFile))
 {
 if (!strcmp(strtok((char *)titlers.m_szau_Type," "),
 "psychology"))
 {
 pFldType->Value = "self_help";
 }
 pRstTitles->MoveNext();
 }

 // Simulate a change by another user by updating data
 // using a command string.
 pConnection->Execute(strSQLChange,NULL,0);

 // Check for changes.
 pRstTitles->MoveFirst();
 while(!(pRstTitles->EndOfFile))
 {
 if (strcmp(pFldType->OriginalValue.pcVal,
 pFldType->UnderlyingValue.pcVal))
 {
 printf("\n\nData has changed!");

 printf("\n\nTitle ID: %s",titlers.lau_Title_idStatus ==
 adFldOK ? titlers.m_szau_Title_id : "<NULL>");

 printf("\n\nCurrent Value: %s",
 (LPCSTR) (_bstr_t) pFldType->Value);

 printf("\n\nOriginal Value: %s",
 (LPCSTR) (_bstr_t) pFldType->OriginalValue);

 printf("\n\nUnderlying Value: %s\n\n",
 (LPCSTR) (_bstr_t) pFldType->UnderlyingValue);

 printf("Press any key to continue...");
 getch();

 system("cls");
 }
 pRstTitles->MoveNext();
 }
 }
 catch (_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Connection.
 PrintProviderError(pConnection);
 PrintComError(e);
 }

 // Clean up objects before exit.
 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (pRstTitles)
 if (pRstTitles->State == adStateOpen)
 {
 // Cancel the update because this is a demonstration.
 pRstTitles->CancelBatch(adAffectAll);
 pRstTitles->Close();
 }
 if (pConnection)
 if (pConnection->State == adStateOpen)
 {
 // Restore Original Values.
 pConnection->Execute(strSQLRestore,NULL,0);
 pConnection->Close();
 }
};

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////
void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;

 // Collection ranges from 0 to nCount -1.
 for(long i = 0;i < nCount;i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,
 pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////
void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print COM errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndOriginalValueCpp

OriginalValueX.h

Copy code Copy code

// BeginOriginalValueH
#include "icrsint.h"

//This class extracts title_id and type from titles table
class CTitleRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CTitleRs)
 // Column title_id is the 1st field in the Recordset
 ADO_VARIABLE_LENGTH_ENTRY2(1, adVarChar, m_szau_Title_id,
 sizeof(m_szau_Title_id), lau_Title_idStatus, FALSE)

 // Column type is the 3rd field in the Recordset
 ADO_VARIABLE_LENGTH_ENTRY2(3, adVarChar, m_szau_Type,
 sizeof(m_szau_Type), lau_TypeStatus, TRUE)
END_ADO_BINDING()

public:
 CHAR m_szau_Title_id[7];
 ULONG lau_Title_idStatus;
 CHAR m_szau_Type[13];
 ULONG lau_TypeStatus;
};
// EndOriginalValueH


Document Object (DAO)

 Copy code hover
[image]

Document Object (DAO)
Send feedback

A Document object includes information about one instance of an object. The object can be a database, saved table, query, or relationship (Microsoft Access database engine databases only).

Remarks

Each Container object has a Documents collection containing Document objects that describe instances of built-in objects of the type specified by the Container. The following table lists the type of object each Document describes, the name of its Container object, and what type of information Document contains.

Document | Container | Contains information about
Database | Databases | Saved database
Table or query | Tables | Saved table or query
Relationship | Relations | Saved relationship

Note Note

Don't confuse the Container objects listed in the preceding table with the collections of the same name. The Databases Container object refers to all saved database objects, but the Databases collection refers only to database objects that are open in a particular workspace.

With a Document object, you can:

  • Use the Name property to return the name that a user or the Microsoft Access database engine gave to the object when it was created.

  • Use the Container property to return the name of the Container object that contains the Document object.

  • Use the Owner property to set or return the owner of the object. To set the Owner property, you must have write permission for the Document object, and you must set the property to the name of an existing User or Group object.

  • Use the UserName or Permissions properties to set or return the access permissions of a user or group for the object. To set these properties, you must have write permission for the Document object, and you must set the UserName property to the name of an existing User or Group object.

  • Use the DateCreated and LastUpdated properties to return the date and time when the Document object was created and last modified.

Because a Document object corresponds to an existing object, you can't create new Document objects or delete existing ones. To refer to a Document object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

  • Documents(0)

  • Documents("name")

  • Documents![name]

Example

This example enumerates the Documents collection of the Tables container, and then enumerates the Properties collection of the first Document object in the collection.

VBA Copy code Copy code
Sub DocumentX()

 Dim dbsNorthwind As Database
 Dim docLoop As Document
 Dim prpLoop As Property

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind.Containers!Tables
 Debug.Print "Documents in " & .Name & " container"
 ' Enumerate the Documents collection of the Tables
 ' container.
 For Each docLoop In .Documents
 Debug.Print " " & docLoop.Name
 Next docLoop
 With .Documents(0)
 ' Enumerate the Properties collection of the first.
 ' Document object of the Tables container.
 Debug.Print "Properties of " & .Name & " document"
 On Error Resume Next
 For Each prpLoop In .Properties
 Debug.Print " " & prpLoop.Name & " = " & _
 prpLoop
 Next prpLoop
 On Error GoTo 0
 End With
 End With

 dbsNorthwind.Close

End Sub

This example uses the Owner and SystemDB properties to show the owners of a variety of Document objects.

VBA Copy code Copy code
Sub OwnerX()

 ' Ensure that the Microsoft Access workgroup file is
 ' available.
 DBEngine.SystemDB = "system.mdw"

 Dim dbsNorthwind As Database
 Dim ctrLoop As Container

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind
 Debug.Print "Document owners:"
 ' Enumerate Containers collection and show the owner
 ' of the first Document in each container's Documents
 ' collection.
 For Each ctrLoop In .Containers
 With ctrLoop
 Debug.Print " [" & .Documents(0).Name & _
 "] in [" & .Name & _
 "] container owned by [" & _
 .Documents(0).Owner & "]"
 End With
 Next ctrLoop

 .Close
 End With

End Sub


NavigationControl.HelpContextId Property (Access)

 Copy code hover
[image]

NavigationControl.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HelpContextId

expression A variable that represents a NavigationControl object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Option Button Control

 Copy code hover
[image]

Option Button Control
Send feedback

Published: July 16, 2012

An option button on a form or report is a stand-alone control used to display a Yes/No value from an underlying record source

Remarks

When you select or clear an option button that's bound to a Yes/No field, Microsoft Access displays the value in the underlying table according to the field's Format property (Yes/No, True/False, or On/Off).

You can also use option buttons in an option group to display values to choose from.

It's also possible to use an unbound option button in a custom dialog box to accept user input.


Count Property (ADO)

 Copy code hover
[image]

Count Property (ADO)
Send feedback

Indicates the number of objects in a collection.

Return Value

Returns a Long value.

Remarks

Use the Count property to determine how many objects are in a given collection.

Because numbering for members of a collection begins with zero, you should always code loops starting with the zero member and ending with the value of the Count property minus 1. If you are using Microsoft Visual Basic and want to loop through the members of a collection without checking the Count property, use the For Each...Next command.

If the Count property is zero, there are no objects in the collection.


Customization File UserList Section

 Copy code hover
[image]

Customization File UserList Section
Send feedback

The userlist section pertains to the connect section with the same section identifier parameter.

This section can contain a user access entry, which specifies access rights for the specified user and overrides the default access entry in the matching connect section.

Syntax

A user access entry is of the form:

userName =accessRights

Part

Description

userName

The user name of the person employing this connection. Valid user names are established with the IIS Service Manager dialog.

accessRights

One of the following access rights:

  • NoAccess — User cannot access the data source.

  • ReadOnly — User can read the data source.

  • ReadWrite — User can read or write to the data source.


Cannot perform cascading operation. It would cause field

 Copy code hover
[image]

Cannot perform cascading operation. It would cause field <name> to become Null, which is not allowed. (Error 3401)
Send feedback

The cascade operation you are attempting would result in a Null value in the indicated field, which has been set up to not allow Null values. Check the values you are attempting to update and fix them so they do not result in Null values in this field.


References Properties (Access)

 Copy code hover
[image]

References Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Parent | Returns the parent object for the specified object. Read-only.


Label.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

Label.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified label. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthBottom

expression A variable that represents a Label object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Label Object

Other resources

Label Object Members


How to: Make Bulk Changes to a DAO Recordset

 Copy code hover
[image]

How to: Make Bulk Changes to a DAO Recordset
Send feedback

After you have created a table-type or dynaset-type Recordset object, you can change, delete, or add new records. You cannot change, delete, or add records to a snapshot-type or forward-only-type Recordset object.

Many of the changes you may otherwise perform in a loop can be done more efficiently with an update or delete query using SQL. The following example creates a QueryDef object to update the Employees table and then runs the query.

VBA Copy code Copy code
Dim dbsNorthwind As DAO.Database
Dim qdfChangeTitles As DAO.QueryDef

   Set dbsNorthwind = CurrentDb
   Set qdfChangeTitles = dbsNorthwind.CreateQueryDef("")

   qdfChangeTitles.SQL = "UPDATE Employees SET Title = " & _
                         "'Account Executive' WHERE Title = " & _
                         "'Sales Representative'"

   ' Invoke query.
   qdfChangeTitles.Execute dbFailOnError

You can replace the entire SQL string in this example with a stored parameter query, in which case the procedure would prompt the user for parameter values. The following example shows how the previous example may be rewritten as a stored parameter query.

VBA Copy code Copy code
Dim dbsNorthwind As DAO.Database
Dim qdfChangeTitles As DAO.QueryDef
Dim strSQLUpdate As String
Dim strOld As String
Dim strNew As String

   Set dbsNorthwind = CurrentDb

   strSQLUpdate = "PARAMETERS [Old Title] Text, [New Title] Text; " & _
                  "UPDATE Employees SET Title = [New Title] WHERE " & _
                  "Title = [Old Title]"

   ' Create the unstored QueryDef object.
   Set qdfChangeTitles = dbsNorthwind.CreateQueryDef("", strSQLUpdate)

   ' Prompt for old title.
   strOld = InputBox("Enter old job title:")

   ' Prompt for new title.
   strNew = InputBox("Enter new job title:")

   ' Set parameters.
   qdfChangeTitles.Parameters("Old Title") = strOld
   qdfChangeTitles.Parameters("New Title") = strNew

   ' Invoke query.
   qdfChangeTitles.Execute
Note Note

A delete query is much more efficient than code that loops through a Recordset, modifying or deleting one record at a time.


ADO Programmer's Guide

 Copy code hover
[image]

ADO Programmer's Guide
Send feedback

For an introduction to the Microsoft ActiveX Data Objects (ADO) Programmer's Guide, see the following topics:

  • Introduction

  • What's New in ADO

  • Prerequisites

  • The ADO Family of Libraries

  • The Role of ADO in Microsoft Data Access

  • ADO Task Table

  • ADO Technology Table


CurrentProject.ProjectType Property (Access)

 Copy code hover
[image]

CurrentProject.ProjectType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ProjectType property to determine the type of project that is currently open. Read-only AcProjectType.

Syntax

expression .ProjectType

expression A variable that represents a CurrentProject object.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


ListBox.AfterUpdate Property (Access)

 Copy code hover
[image]

ListBox.AfterUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.

Syntax

expression .AfterUpdate

expression A variable that represents a ListBox object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the AfterUpdate event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the AfterUpdate event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).AfterUpdate = "[Event Procedure]"

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


TextBox.LayoutID Property (Access)

 Copy code hover
[image]

TextBox.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified text box. Read-only Long.

Version Information

Version Added: Access 2007

Syntax

expression .LayoutID

expression A variable that represents a TextBox object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Parameter.Direction Property (DAO)

 Copy code hover
[image]

Parameter.Direction Property (DAO)
Send feedback

Syntax

expression .Direction

expression A variable that represents a Parameter object.

Remarks

The setting or return value is a Long that can be set to one of the ParameterDirectionEnum constants.

Use the Direction property to determine whether the parameter is an input parameter, output parameter, both, or the return value from the procedure. Some ODBC drivers do not provide information on the direction of parameters to a SELECT statement or procedure call. In these cases, it is necessary to set the direction prior to executing the query.

For example, the following procedure returns a value from a stored procedure named "get_employees":

{? = call get_employees}

This call produces one parameter — the return value. You need to set the direction of this parameter to dbParamOutput or dbParamReturnValue before executing the QueryDef.

You need to set all parameter directions except dbParamInput before accessing or setting the values of the parameters and before executing the QueryDef.

You should use dbParamReturnValue for return values, but in cases where that option is not supported by the driver or the server, you can use dbParamOutput instead.

The Microsoft SQL Server driver automatically sets the Direction property for all procedure parameters. Not all ODBC drivers can determine the direction of a query parameter. In these cases, it is necessary to set the direction prior to executing the query.

Example

This example uses the Direction property to configure the parameters of a query to an ODBC data source.

VBA Copy code Copy code
Sub DirectionX()

 Dim wrkMain As Workspace
 Dim conMain As Connection
 Dim qdfTemp As QueryDef
 Dim rstTemp As Recordset
 Dim strSQL As String
 Dim intLoop As Integer

 ' Create ODBC workspace and open a connection to a
 ' Microsoft SQL Server database.
 Set wrkMain = CreateWorkspace("ODBCWorkspace", _
 "admin", "", dbUseODBC)

 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conMain = wrkMain.OpenConnection("Publishers", _
 dbDriverNoPrompt, False, _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 ' Set SQL string to call the stored procedure
 ' getempsperjob.
 strSQL = "{ call getempsperjob (?, ?) }"

 Set qdfTemp = conMain.CreateQueryDef("", strSQL)

 With qdfTemp
 ' Indicate that the two query parameters will only
 ' pass information to the stored procedure.
 .Parameters(0).Direction = dbParamInput
 .Parameters(1).Direction = dbParamInput

 ' Assign initial parameter values.
 .Parameters(0) = "0877"
 .Parameters(1) = 0

 Set rstTemp = .OpenRecordset()

 With rstTemp
 ' Loop through all valid values for the second
 ' parameter. For each value, requery the recordset
 ' to obtain the correct results and then print out
 ' the contents of the recordset.
 For intLoop = 1 To 14
 qdfTemp.Parameters(1) = intLoop
 .Requery
 Debug.Print "Publisher = " & _
 qdfTemp.Parameters(0) & _
 ", job = " & intLoop
 Do While Not .EOF
 Debug.Print , .Fields(0), .Fields(1)
 .MoveNext
 Loop
 Next intLoop
 .Close
 End With

 End With

 conMain.Close
 wrkMain.Close

End Sub


Module.ProcBodyLine Property (Access)

 Copy code hover
[image]

Module.ProcBodyLine Property (Access)
See also Send feedback

Published: July 16, 2012

The ProcBodyLine property returns the number of the line at which the body of a specified procedure begins in a standard module or a class module. Read-only Long.

Syntax

expression .ProcBodyLine(ProcName, ProcKind)

expression A variable that represents a Module object.

Parameters

Name | Required/Optional | Data Type | Description
ProcName | Required | String | The name of a procedure in the module.
ProcKind | Required | vbext_ProcKind | The type of procedure. See the Remarks section for the possible settings.

Remarks

The ProcKind argument can be one of the following vbext_ProcKind constants:

Constant | Description
vbext_pk_Get | A Property Get procedure.
vbext_pk_Let | A Property Let procedure.
vbext_pk_Proc | A Sub or Function procedure.
vbext_pk_Set | A Property Set procedure.

The body of a procedure begins with the procedure definition, denoted by one of the following:

  • A Sub statement.

  • A Function statement.

  • A Property Get statement.

  • A Property Let statement.

  • A Property Set statement.

The ProcBodyLine property returns a number that identifies the line on which the procedure definition begins. In contrast, the ProcStartLine property returns a number that identifies the line at which a procedure is separated from the preceding procedure in a module. Any comments or compilation constants that precede the procedure definition (the body of a procedure) are considered part of the procedure, but the ProcBodyLine property ignores them.

Note Note

The ProcBodyLine property treats Sub and Function procedures similarly, but distinguishes between each type of Property procedure.

Example

The following example displays a message indicating on which line the procedure definition begins.

VBA Copy code Copy code
Dim strForm As String
Dim strProc As String

strForm = "Products"
strProc = "Products_Subform_Enter"

MsgBox "The definition of the " & strProc & " procedure begins on line " & _
 Forms(strForm).Module.ProcStartLine(strProc, vbext_pk_Proc) & "."

See also

Concepts

Module Object

Other resources

Module Object Members


CommandButton.Alignment Property (Access)

 Copy code hover
[image]

CommandButton.Alignment Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets how the specified button's caption and picture are aligned. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .Alignment

expression A variable that represents a CommandButton object.

Remarks

The Alignment property uses the following settings.

Value | Description
0 | General alignment.
1 | Left alignment.
2 | (Default) Center alignment.
3 | Right alignment.
4 | Distribute alignment evenly across the button's width.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Attachment.BottomPadding Property (Access)

 Copy code hover
[image]

Attachment.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the attachment and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .BottomPadding

expression A variable that represents an Attachment object.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


CommandButton.Click Event (Access)

 Copy code hover
[image]

CommandButton.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Syntax

expression .Click

expression A variable that represents a CommandButton object.

Remarks

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

For a command button only, Microsoft Access runs the macro or event procedure specified by the OnClick property when the user chooses the command button by pressing the ENTER key or an access key. The macro or event procedure runs once. If you want the macro or event procedure to run repeatedly while the command button is pressed, set its AutoRepeat property to Yes. For other types of controls, you must click the control by using the mouse button to trigger the Click event.

The Click event for a command button occurs when you choose the command button. In addition, if the command button doesn't already have the focus when you choose it, the Enter and GotFocus events for the command button occur before the Click event.

Double-clicking a control causes both the DblClick and Click events to occur. For command buttons, double-clicking triggers the following events, in this order:

MouseDown → MouseUp → Click → DblClick → Click

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ComboBox.GridlineColor Property (Access)

 Copy code hover
[image]

ComboBox.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified combo box. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineColor

expression A variable that represents a ComboBox object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


System Commands

 Copy code hover
[image]

System Commands
Send feedback

In this section

  • Beep Macro Action

  • CloseDatabase Macro Action

  • DisplayHourglassPointer Macro Action

  • PrintOut Macro Action

  • QuitAccess Macro Action

  • RunApplication Macro Action

  • SendKeys Macro Action

  • SetWarnings Macro Action


ComboBox.SmartTags Property (Access)

 Copy code hover
[image]

ComboBox.SmartTags Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a SmartTags collection that represents the collection of smart tags that have been added to a control. .

Syntax

expression .SmartTags

expression A variable that represents a ComboBox object.

Remarks

Note Note

Unlike the SmartTags collections in Microsoft Excel and Microsoft Word, the SmartTags collection in Microsoft Access is zero-based. Therefore, the code control.SmartTags(0) returns the first smart tag for the specified control.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ToggleButton.OptionValue Property (Access)

 Copy code hover
[image]

ToggleButton.OptionValue Property (Access)
See also Send feedback

Published: July 16, 2012

Each control in an option group has a numeric value that you can set with the OptionValue property. Read/write Long.

Syntax

expression .OptionValue

expression A variable that represents a ToggleButton object.

Remarks

When the control is selected, the number is assigned to the option group. If the option group is bound to a field, the value of the selected control's OptionValue property is stored in the field.

For example, this Region option group is bound to the Region field in a table. The Europe button has an OptionValue property setting of 1, the Asia button has a setting of 2, and the Africa button has a setting of 3. When one of these buttons is selected, the Region option group value will be the same as the OptionValue property setting for the selected control. In this case, because the Region option group is bound to the Region field, the value of this field in the table also equals 2.

The OptionValue property applies only to the check box, option button, and toggle button controls in an option group.

Unless you change the OptionValue property yourself, the first control you place in an option group has a value of 1, the second control has a value of 2, and so on.

The OptionValue property is only available when the control is placed inside an option group control. When a check box, a toggle button, or an option button isn't in an option group, the control has no OptionValue property. Instead, each such control has a ControlSource property, and the value of each control will be either True if selected or False if not selected.

Example

The following example sets the OptionValue property for three option buttons in the "Ship Method Group" option group when a form opens. When an option button is selected in the option group, a message displays indicating the shipper's assigned ID number.

VBA Copy code Copy code
Private Sub Form_Open(Cancel As Integer)

 Me.Controls("ABC Couriers").OptionValue = 15876
 Me.Controls("Speedy Delivery").OptionValue = 742
 Me.Controls("Lightning Express").OptionValue = 1256

End Sub

Private Sub Ship_Method_Group_Click()

 MsgBox "The ID for the selected shipper is " & Me.Controls("Ship Method Group").Value

End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Label Methods (Access)

 Copy code hover
[image]

Label Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.


RowPosition Property (ADO)

 Copy code hover
[image]

RowPosition Property (ADO)
Send feedback

Gets or sets an OLE DB RowPosition object from/on an ADORecordsetConstruction object. When you use put_RowPosition to set the RowPosition object, the resulting Recordset object uses the RowPosition object to determine the current row.

Read/write.

Syntax

HRESULT get_RowPosition([out, retval] IUnknown** ppRowPos);

HRESULT put_RowPosition([in] IUnknown* pRowPos);

Parameters

  • ppRowPos

  • Pointer to an OLE DB RowPosition object.

  • PRowPos

  • An OLE DB RowPosition object.

Return Values

This property method returns the standard HRESULT values, including S_OK and E_FAIL.

Remarks

When this property is set, if the Rowset object on the RowPosition object is different from the Rowset object on the Recordset object, the former overrides the latter. The same behavior applies to the current Chapter of the RowPosition as well.

Applies To

ADORecordsetConstruction


External table is not in the expected format. (Error 3274)

 Copy code hover
[image]

External table is not in the expected format. (Error 3274)
Send feedback

The format of the table has changed since it was linked. Link the table again, and then retry the operation.


ListBox.NumeralShapes Property (Access)

 Copy code hover
[image]

ListBox.NumeralShapes Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .NumeralShapes

expression A variable that represents a ListBox object.

Remarks

The NumeralShapes property uses the following settings.

Setting | Visual Basic | Description
System | 0 | Numeral shapes determined by the Numeral Shapes system setting.
Arabic | 1 | Arabic digit shapes will be used to display and print numerals.
National | 2 | National digit shapes will be used to display and print numerals.
Context | 3 | Numeral shapes determined by Unicode context rules for adjacent text.

Example

The following example changes the NumeralShapes property for the selected control to 0 (numeral shapes will be determined by the Numeral Shapes system setting).

VBA Copy code Copy code
Public Sub ChangeNumeralShapes(ctl As Control)
 ctl.NumeralShapes = 0
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Report.OnDblClick Property (Access)

 Copy code hover
[image]

Report.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnDblClick

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the report's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the DblClick event with the "OK_DblClick" event procedure for the button named "OK" on the "Catalog" report, if there is currently no association.

VBA Copy code Copy code
With Reports("Catalog").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

Report Object

Other resources

Report Object Members


Application.SetHiddenAttribute Method (Access)

 Copy code hover
[image]

Application.SetHiddenAttribute Method (Access)
See also Send feedback

Published: July 16, 2012

The SetHiddenAttribute method sets the hidden attribute of an Access object.

Syntax

expression .SetHiddenAttribute(ObjectType, ObjectName, fHidden)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
ObjectType | Required | AcObjectType | A AcObjectType constant that specifies the type of Access object.
ObjectName | Required | String | The name of the Access object.
fHidden | Required | Boolean | True sets the hidden attribute and False clears the attribute.

Return Value

Nothing

Remarks

Together with the GetHiddenAttribute method, the SetHiddenAttribute method provides a means of changing an object's visibility from Visual Basic code. With these methods, you can set or read the Hidden property available in the object's Properties dialog box.

To set this option by using the SetHiddenAttribute method, specify True or False for the setting, as in the following example.

VBA Copy code Copy code
Application.SetHiddenAttribute acTable,"Customers", True

See also

Concepts

Application Object

Other resources

Application Object Members


Counter definition not in valid range. (Error 3770)

 Copy code hover
[image]

Counter definition not in valid range. (Error 3770)
Send feedback

This error occurs when trying to create a column that is an IDENTITY or COUNTER data type and specifying the optional seed and increment values. The seed and increment values must be in the valid range of a LONG data type.


CheckBox.LostFocus Event (Access)

 Copy code hover
[image]

CheckBox.LostFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The LostFocus event occurs when the specified object loses the focus.

Syntax

expression .LostFocus

expression A variable that represents a CheckBox object.

Remarks

To run a macro or event procedure when these events occur, set the OnLostFocus property to the name of the macro or to [Event Procedure].

This events occurs when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The LostFocus event differs from the Exit event in that the LostFocus event occurs every time a control loses the focus. The Exit event occurs only before a control loses the focus to another control on the same form. The LostFocus event occurs after the Exit event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ListBox.AfterUpdate Event (Access)

 Copy code hover
[image]

ListBox.AfterUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The AfterUpdate event occurs after changed data in a control or record is updated.

Syntax

expression .AfterUpdate

expression A variable that represents a ListBox object.

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's AfterUpdate event does occur.

To run a macro or event procedure when this event occurs, set the AfterUpdate property to the name of the macro or to [Event Procedure].

The AfterUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

AfterUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. AfterUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For bound controls, the OldValue property isn't set to the updated value until after the AfterUpdate event for the form occurs. Even if the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Report.FastLaserPrinting Property (Access)

 Copy code hover
[image]

Report.FastLaserPrinting Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FastLaserPrinting property to specify whether lines and rectangles are replaced by text character lines — similar to the underscore (_) and vertical bar (|) characters — when you print a report using most laser printers. Replacing lines and rectangles with text character lines can make printing much faster. Read/write Boolean.

Syntax

expression .FastLaserPrinting

expression A variable that represents a Report object.

Remarks

The FastLaserPrinting property affects any line or rectangle on a form or report, including controls that have these shapes (for example, a border around a text box).

This property has no effect on PostScript printers, dot-matrix printers, or earlier versions of laser printers that don't support text character lines.

When this property is set to True and the form or report being printed has overlapping rectangles or lines, the rectangles or lines on top don't erase the rectangles or lines they overlap. If you require overlapping graphics on your report, set the FastLaserPrinting property to False.

Example

The following example shows how to set the FastLaserPrinting property for the Invoice report while in report Design view:

VBA Copy code Copy code
DoCmd.OpenReport "Invoice", acDesign
Reports!Invoice.FastLaserPrinting = True
DoCmd.Close acReport, "Invoice", acSaveYes

See also

Concepts

Report Object

Other resources

Report Object Members


Report.Pages Property (Access)

 Copy code hover
[image]

Report.Pages Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Pages property to return information needed to print page numbers in a report. Read/write Integer.

Syntax

expression .Pages

expression A variable that represents a Report object.

Remarks

This property is only available in Print Preview or when printing.

To refer to the Pages property in a macro or Visual Basic, the form or report must include a text box whose ControlSource property is set to an expression that uses Pages. For example, you can use the following expressions as the ControlSource property setting for a text box in a page footer.

This expression | Prints
=Page | A page number (for example, 1, 2, 3) in the page footer.
="Page " & Page & " of " & Pages | "Page n of nn" (for example, Page 1 of 5, Page 2 of 5) in the page footer.
=Pages | The total number pages in the report (for example, 5).

Example

The following example displays a message that tells how many pages the report contains. For this example to work, the report must include a text box for which the ControlSource property is set to the expression =Pages. To test this example, paste the following code into the Page Event for the Alphabetical List of Products form.

VBA Copy code Copy code
Dim intTotalPages As Integer
Dim strMsg As String

intTotalPages = Me.Pages
strMsg = "This report contains " & intTotalPages & " pages."
MsgBox strMsg

See also

Concepts

Report Object

Other resources

Report Object Members


Form.CommandExecute Property (Access)

 Copy code hover
[image]

Form.CommandExecute Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the CommandExecute event occurs. Read/write.

Syntax

expression .CommandExecute

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the CommandExecute event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).CommandExecute = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


ComboBox.Tag Property (Access)

 Copy code hover
[image]

ComboBox.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents a ComboBox object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ObjectFrame.LeftPadding Property (Access)

 Copy code hover
[image]

ObjectFrame.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the object frame and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .LeftPadding

expression A variable that represents an ObjectFrame object.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Report.ScaleHeight Property (Access)

 Copy code hover
[image]

Report.ScaleHeight Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ScaleHeight property to specify the number of units for the vertical measurement of the page when the Circle , Line , Pset , or Print method is used while a report is printed or previewed, or its output is saved to a file. Read/write Single.

Syntax

expression .ScaleHeight

expression A variable that represents a Report object.

Remarks

The default setting is the internal height of a report page in twips.

You can set the ScaleHeight property by using a macro or a Visual Basic event procedure specified by a section's OnPrint property setting.

You can use the ScaleHeight property to create a custom coordinate scale for drawing or printing. For example, the statement ScaleHeight = 100 defines the internal height of the section as 100 units, or one vertical unit as one one-hundredth of the height.

Use the ScaleMode property to define a scale based on a standard unit of measurement, such as points, pixels, characters, inches, millimeters, or centimeters.

Setting the ScaleHeight property to a positive value makes coordinates increase in value from top to bottom. Setting it to a negative value makes coordinates increase in value from bottom to top.

By using these properties and the related ScaleLeft and ScaleTop properties, you can set up a custom coordinate system with both positive and negative coordinates. All four of these Scale properties interact with the ScaleMode property in the following ways:

  • Setting any other Scale property to any value automatically sets the ScaleMode property to 0.

  • Setting the ScaleMode property to a number greater than 0 changes the ScaleHeight and ScaleWidth properties to the new unit of measurement and sets the ScaleLeft and ScaleTop properties to 0. Also, the CurrentX and CurrentY property settings change to reflect the new coordinates of the current point.

You can also use the Scale method to set the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties in one statement.

Note Note

The ScaleHeight property isn't the same as the Height property.

Example

The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

VBA Copy code Copy code
Private Sub Detail_Format(Cancel As Integer, _
 FormatCount As Integer)
 Dim rpt as Report
 Dim strMessage As String
 Dim intHorSize As Integer, intVerSize As Integer

 Set rpt = Me
 strMessage = "DisplayMessage"
 With rpt
 'Set scale to pixels, and set FontName and
 'FontSize properties.
 .ScaleMode = 3
 .FontName = "Courier"
 .FontSize = 24
 End With
 ' Horizontal width.
 intHorSize = Rpt.TextWidth(strMessage)
 ' Vertical height.
 intVerSize = Rpt.TextHeight(strMessage)
 ' Calculate location of text to be displayed.
 Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
 Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
 ' Print text on Report object.
 Rpt.Print strMessage
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


FormatCondition.BackColor Property (Access)

 Copy code hover
[image]

FormatCondition.BackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the interior color of the specified object. Read/write Long.

Syntax

expression .BackColor

expression A variable that represents a FormatCondition object.

Remarks

The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

To use the BackColor property, the BackStyle property, if available, must be set to Normal.

Example

The following example uses the RGB function to set the , BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

FormatCondition Object

Other resources

FormatCondition Object Members


TableDef.Indexes Property (DAO)

 Copy code hover
[image]

TableDef.Indexes Property (DAO)
Send feedback

Returns an Indexes collection that contains all of the stored Index objects for the specified table. Read-only.

Syntax

expression .Indexes

expression A variable that represents a TableDef object.


BY (Microsoft Access SQL reserved word)

 Copy code hover
[image]

BY (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The BY keyword is used in these contexts:

GROUP BY Clause

ORDER BY Clause


QueryDef.ODBCTimeout Property (DAO)

 Copy code hover
[image]

QueryDef.ODBCTimeout Property (DAO)
Send feedback

Indicates the number of seconds to wait before a timeout error occurs when a QueryDef is executed on an ODBC database.

Syntax

expression .ODBCTimeout

expression A variable that represents a QueryDef object.

Remarks

When the ODBCTimeout property is set to -1, the timeout defaults to the current setting of the QueryTimeout property of the Connection or Database object that contains the QueryDef. When the ODBCTimeout property is set to 0, no timeout error occurs.

When you're using an ODBC database, such as Microsoft SQL Server, delays can occur because of network traffic or heavy use of the ODBC server. Rather than waiting indefinitely, you can specify how long to wait before returning an error.

Setting the ODBCTimeout property of a QueryDef object overrides the value specified by the QueryTimeout property of the Connection or Database object containing the QueryDef, but only for that QueryDef object.

Example

This example uses the ODBCTimeout and QueryTimeout properties to show how the QueryTimeout setting on a Database object sets the default ODBCTimeout setting on any QueryDef objects created from the Database object.

VBA Copy code Copy code
Sub ODBCTimeoutX()

 Dim dbsCurrent As Database
 Dim qdfStores As QueryDef
 Dim rstStores As Recordset

 Set dbsCurrent = OpenDatabase("Northwind.mdb")

 ' Change the default QueryTimeout of the Northwind
 ' database.
 Debug.Print "Default QueryTimeout of Database: " & _
 dbsCurrent.QueryTimeout
 dbsCurrent.QueryTimeout = 30
 Debug.Print "New QueryTimeout of Database: " & _
 dbsCurrent.QueryTimeout

 ' Create a new QueryDef object.
 Set qdfStores = dbsCurrent.CreateQueryDef("Stores", _
 "SELECT * FROM stores")

 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the SQL Server.
 qdfStores.Connect = _
 "ODBC;DATABASE=pubs;DSN=Publishers"

 ' Change the ODBCTimeout setting of the new QueryDef
 ' object from its default setting.
 Debug.Print "Default ODBCTimeout of QueryDef: " & _
 qdfStores.ODBCTimeout
 qdfStores.ODBCTimeout = 0
 Debug.Print "New ODBCTimeout of QueryDef: " & _
 qdfStores.ODBCTimeout

 ' Execute the query and display the results.
 Set rstStores = qdfStores.OpenRecordset()

 Debug.Print "Contents of recordset:"
 With rstStores
 Do While Not .EOF
 Debug.Print , .Fields(0), .Fields(1)
 .MoveNext
 Loop
 .Close
 End With

 ' Delete new QueryDef because this is a demonstration.
 dbsCurrent.QueryDefs.Delete qdfStores.Name
 dbsCurrent.Close

End Sub


FormatCondition.ShortestBarValue Property (Access)

 Copy code hover
[image]

FormatCondition.ShortestBarValue Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a numeric expression that specifies the value of the shortest bar of a FormatCondition. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .ShortestBarValue

expression A variable that represents a FormatCondition object.

Remarks

By default, the ShortestBarValue contains a zero-length string ("").

If the value of the ShortestBarLimit property is acAutomatic, then the ShortestBarValue is ignored.

See also

Concepts

FormatCondition Object

Other resources

FormatCondition Object Members


Form.DataSetChange Event (Access)

 Copy code hover
[image]

Form.DataSetChange Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs whenever the specified PivotTable view is data-bound and the data set changes — for example, when a filter operation takes place. This event also occurs when initial data is available from the data source.

Syntax

expression .DataSetChange

expression A variable that represents a Form object.

Return Value

nothing

Example

The following example demonstrates the syntax for a subroutine that traps the DataSetChange event.

VBA Copy code Copy code
Private Sub Form_DataSetChange()
 MsgBox "The data set for the PivotChart view has changed."
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Hyperlink.SubAddress Property (Access)

 Copy code hover
[image]

Hyperlink.SubAddress Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SubAddress property to specify or determine a location within the target document specified by the Address property. Read/write String. .

Syntax

expression .SubAddress

expression A variable that represents a Hyperlink object.

Remarks

The SubAddress property can be an object within a Microsoft Access database, a bookmark within a Microsoft Word document, a named range within a Microsoft Excel spreadsheet, a slide within a Microsoft PowerPoint presentation, or a location within an HTML document.

The SubAddress property represents the HyperlinkSubAddress property of a named location within the target document specified by the HyperlinkAddress property

When you move the cursor over a command button, image control, or label control whose HyperlinkSubAddress property is set, the cursor changes to an upward-pointing hand. Clicking the control displays the object or Web page specified by the link.

For more information about hyperlink addresses and their format, see the HyperlinkAddress and HyperlinkSubAddress property topics.

Example

The following example turns a label named "Label20" on the "Suppliers" form into an active hyperlink. When the user click the hyperlink, Access opens the "Mailing List" form in the "Postal Operations" database.

VBA Copy code Copy code
With Forms("Suppliers").Controls("Label20").Hyperlink
 .Address = "PostalOperations.mdb"
 .SubAddress = "Form Mailing List"
End With

See also

Concepts

Hyperlink Object

Other resources

Hyperlink Object Members


ToggleButton.PressedColor Property (Access)

 Copy code hover
[image]

ToggleButton.PressedColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color displayed on the control when the user clicks it. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .PressedColor

expression A variable that represents a ToggleButton object.

Remarks

The PressedColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Step 3: Populate the Fields List Box
Send feedback

Step 3: Populate the Fields List Box

To populate the Fields list box

Insert the following code into the Click event handler of lstMain:

Copy code Copy code

Private Sub lstMain_Click()
    Dim rec As Record
    Dim rs As Recordset
    Set rec = New Record
    Set rs = New Recordset
    grs.MoveFirst
    grs.Move lstMain.ListIndex
    lstDetails.Clear
    rec.Open grs
    Select Case rec.RecordType
        Case adCollectionRecord:
            Set rs = rec.GetChildren
            While Not rs.EOF
                lstDetails.AddItem rs(0)
                rs.MoveNext
            Wend
        Case adSimpleRecord:
            recFields rec, lstDetails, txtDetails

        Case adStructDoc:
    End Select

End Sub

This code declares and instantiates local Record and Recordset objects, rec and and rs, respectively.

The row corresponding to the resource selected in lstMain is made the current row of grs. Then the Details list box is cleared and rec is opened with the current row of . Then the Details list box is cleared and rec is opened with the current row of grs as the source.

If the resource is a collection record (as specified by RecordType), the local Recordset, rs, is opened on the children of rec. Then lstDetails is filled with the values from the rows of is opened on the children of rec. Then lstDetails is filled with the values from the rows of rs.

If the resource is a simple record, recFields is called. For more information about recFields, see the next step.

No code is implemented if the resource is a structured document.


Form.MouseUp Event (Access)

 Copy code hover
[image]

Form.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents a Form object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was released to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

Form Object

Other resources

Form Object Members


Forms Members (Access)

 Copy code hover
[image]

Forms Members (Access)
Send feedback

Published: July 16, 2012

The Forms collection contains all of the currently open forms in a Microsoft Access database.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Form.
Parent | Returns the parent object for the specified object. Read-only.


Enabling a DLL to Run on DCOM

 Copy code hover
[image]

Enabling a DLL to Run on DCOM
Send feedback

The following steps outline how to enable a business object dynamic-link libraries to use both DCOM and Microsoft® Internet Information Services (HTTP) via Component Services.

  1. Create a new empty package in the Component Services MMC snap-in. You will use the Component Services MMC snap-in to create a package and add the DLL into this package. This makes the .dll accessible through DCOM, but it removes the accessibility through IIS. (If you check in the registry for the .dll, the Inproc key is now empty; setting the Activation attribute, explained later in this topic, adds a value in the Inproc key.)

  2. Install a business object into the package. -or- Import the RDSServer.DataFactory object into the package.

  3. Set the Activation attribute for the package to In the creator's process (Library application). To make the .dll accessible through DCOM and IIS on the same computer, you must set the component's Activation attribute in the Component Services MMC snap-in. After you set the attribute to In the creator's process, you will notice that an Inproc server key in the registry has been added that points to a Component Services surrogate .dll.


HelloData Code

 Copy code hover
[image]

HelloData Code
Send feedback
Copy code Copy code

'BeginHelloData
Option Explicit

Dim m_oRecordset As ADODB.Recordset
Dim m_sConnStr As String
Dim m_flgPriceUpdated As Boolean

Private Sub cmdGetData_Click()
 GetData

 If Not m_oRecordset Is Nothing Then
 If m_oRecordset.State = adStateOpen Then
 ' Set the proper states for the buttons.
 cmdGetData.Enabled = False
 cmdExamineData.Enabled = True
 End If
 End If
End Sub

Private Sub cmdExamineData_Click()
 ExamineData
End Sub

Private Sub cmdEditData_Click()
 EditData
End Sub

Private Sub cmdUpdateData_Click()
 UpdateData

 ' Set the proper states for the buttons.
 cmdUpdateData.Enabled = False
End Sub

Private Sub GetData()
 On Error GoTo GetDataError

 Dim sSQL As String
 Dim oConnection1 As ADODB.Connection

 m_sConnStr = "Provider='SQLOLEDB';Data Source='MySqlServer';" & _
 "Initial Catalog='Northwind';Integrated Security='SSPI';"

 ' Create and Open the Connection object.
 Set oConnection1 = New ADODB.Connection
 oConnection1.CursorLocation = adUseClient
 oConnection1.Open m_sConnStr

 sSQL = "SELECT ProductID, ProductName, CategoryID, UnitPrice " & _
 "FROM Products"

 ' Create and Open the Recordset object.
 Set m_oRecordset = New ADODB.Recordset
 m_oRecordset.Open sSQL, oConnection1, adOpenStatic, _
 adLockBatchOptimistic, adCmdText

 m_oRecordset.MarshalOptions = adMarshalModifiedOnly

 ' Disconnect the Recordset.
 Set m_oRecordset.ActiveConnection = Nothing
 oConnection1.Close
 Set oConnection1 = Nothing

 ' Bind Recordset to the DataGrid for display.
 Set grdDisplay1.DataSource = m_oRecordset

 Exit Sub

GetDataError:
 If Err <> 0 Then
 If oConnection1 Is Nothing Then
 HandleErrs "GetData", m_oRecordset.ActiveConnection
 Else
 HandleErrs "GetData", oConnection1
 End If
 End If

 If Not oConnection1 Is Nothing Then
 If oConnection1.State = adStateOpen Then oConnection1.Close
 Set oConnection1 = Nothing
 End If
End Sub

Private Sub ExamineData()
 On Err GoTo ExamineDataErr

 Dim iNumRecords As Integer
 Dim vBookmark As Variant

 iNumRecords = m_oRecordset.RecordCount

 DisplayMsg "There are " & CStr(iNumRecords) & _
 " records in the current Recordset."

 ' Loop through the Recordset and print the
 ' value of the AbsolutePosition property.
 DisplayMsg "****** Start AbsolutePosition Loop ******"

 Do While Not m_oRecordset.EOF
 ' Store the bookmark for the 3rd record,
 ' for demo purposes.
 If m_oRecordset.AbsolutePosition = 3 Then _
 vBookmark = m_oRecordset.Bookmark

 DisplayMsg m_oRecordset.AbsolutePosition

 m_oRecordset.MoveNext
 Loop

 DisplayMsg "****** End AbsolutePosition Loop ******" & vbCrLf

 ' Use our bookmark to move back to 3rd record.
 m_oRecordset.Bookmark = vBookmark
 MsgBox vbCr & "Moved back to position " & _
 m_oRecordset.AbsolutePosition & " using bookmark.", , _
 "Hello Data"

 ' Display meta-data about each field. See WalkFields() sub.
 Call WalkFields

 ' Apply a filter on the type field.
 MsgBox "Filtering on type field. (CategoryID=2)", _
 vbOKOnly, "Hello Data"

 m_oRecordset.Filter = "CategoryID=2"

 ' Set the proper states for the buttons.
 cmdExamineData.Enabled = False
 cmdEditData.Enabled = True

 Exit Sub

ExamineDataErr:
 HandleErrs "ExamineData", m_oRecordset.ActiveConnection
End Sub

Private Sub EditData()
 On Error GoTo EditDataErr

 'Recordset still filtered on CategoryID=2.
 'Increase price by 10% for filtered records.
 MsgBox "Increasing unit price by 10%" & vbCr & _
 "for all records with CategoryID = 2.", , "Hello Data"

 m_oRecordset.MoveFirst

 Dim cVal As Currency
 Do While Not m_oRecordset.EOF
 cVal = m_oRecordset.Fields("UnitPrice").Value
 m_oRecordset.Fields("UnitPrice").Value = (cVal * 1.1)
 m_oRecordset.MoveNext
 Loop

 ' Set the proper states for the buttons.
 cmdEditData.Enabled = False
 cmdUpdateData.Enabled = True

 Exit Sub

EditDataErr:
 HandleErrs "EditData", m_oRecordset.ActiveConnection
End Sub

Private Sub UpdateData()
 On Error GoTo UpdateDataErr

 Dim oConnection2 As New ADODB.Connection

 MsgBox "Removing Filter (adFilterNone).", , "Hello Data"
 m_oRecordset.Filter = adFilterNone

 Set grdDisplay1.DataSource = Nothing
 Set grdDisplay1.DataSource = m_oRecordset

 MsgBox "Applying Filter (adFilterPendingRecords).", , "Hello Data"
 m_oRecordset.Filter = adFilterPendingRecords

 Set grdDisplay1.DataSource = Nothing
 Set grdDisplay1.DataSource = m_oRecordset

 DisplayMsg "*** PRE-UpdateBatch values for 'UnitPrice' field. ***"

 ' Display Value, UnderlyingValue, and OriginalValue for
 ' type field in first record.
 If m_oRecordset.Supports(adMovePrevious) Then
 m_oRecordset.MoveFirst
 DisplayMsg "OriginalValue = " & _
 m_oRecordset.Fields("UnitPrice").OriginalValue
 DisplayMsg "Value = " & _
 m_oRecordset.Fields("UnitPrice").Value
 End If

 oConnection2.ConnectionString = m_sConnStr
 oConnection2.Open

 Set m_oRecordset.ActiveConnection = oConnection2
 m_oRecordset.UpdateBatch

 m_flgPriceUpdated = True

 DisplayMsg "*** POST-UpdateBatch values for 'UnitPrice' field ***"

 If m_oRecordset.Supports(adMovePrevious) Then
 m_oRecordset.MoveFirst
 DisplayMsg "OriginalValue = " & _
 m_oRecordset.Fields("UnitPrice").OriginalValue
 DisplayMsg "Value = " & _
 m_oRecordset.Fields("UnitPrice").Value
 End If

 MsgBox "See value comparisons in txtDisplay.", , _
 "Hello Data"

 'Clean up
 oConnection2.Close
 Set oConnection2 = Nothing
 Exit Sub

UpdateDataErr:
 If Err <> 0 Then
 HandleErrs "UpdateData", oConnection2
 End If

 If Not oConnection2 Is Nothing Then
 If oConnection2.State = adStateOpen Then oConnection2.Close
 Set oConnection2 = Nothing
 End If
End Sub

Private Sub WalkFields()
 On Error GoTo WalkFieldsErr

 Dim iFldCnt As Integer
 Dim oFields As ADODB.Fields
 Dim oField As ADODB.Field
 Dim sMsg As String

 Set oFields = m_oRecordset.Fields

 DisplayMsg "****** BEGIN FIELDS WALK ******"

 For iFldCnt = 0 To (oFields.Count - 1)
 Set oField = oFields(iFldCnt)
 sMsg = ""
 sMsg = sMsg & oField.Name
 sMsg = sMsg & vbTab & "Type: " & GetTypeAsString(oField.Type)
 sMsg = sMsg & vbTab & "Defined Size: " & oField.DefinedSize
 sMsg = sMsg & vbTab & "Actual Size: " & oField.ActualSize

 grdDisplay1.SelStartCol = iFldCnt
 grdDisplay1.SelEndCol = iFldCnt
 DisplayMsg sMsg
 MsgBox sMsg, , "Hello Data"
 Next iFldCnt

 DisplayMsg "****** END FIELDS WALK ******" & vbCrLf

 'Clean up
 Set oField = Nothing
 Set oFields = Nothing
 Exit Sub

WalkFieldsErr:
 Set oField = Nothing
 Set oFields = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub

Private Function GetTypeAsString(dtType As ADODB.DataTypeEnum) As String
 ' To save space, we are only checking for data types
 ' that we know are present.
 Select Case dtType
 Case adChar
 GetTypeAsString = "adChar"
 Case adVarChar
 GetTypeAsString = "adVarChar"
 Case adVarWChar
 GetTypeAsString = "adVarWChar"
 Case adCurrency
 GetTypeAsString = "adCurrency"
 Case adInteger
 GetTypeAsString = "adInteger"
 End Select
End Function

Private Sub HandleErrs(sSource As String, ByRef m_oConnection As ADODB.Connection)
 DisplayMsg "ADO (OLE) ERROR IN " & sSource
 DisplayMsg vbTab & "Error: " & Err.Number
 DisplayMsg vbTab & "Description: " & Err.Description
 DisplayMsg vbTab & "Source: " & Err.Source

 If Not m_oConnection Is Nothing Then
 If m_oConnection.Errors.Count <> 0 Then
 DisplayMsg "PROVIDER ERROR"
 Dim oError1 As ADODB.Error
 For Each oError1 In m_oConnection.Errors
 DisplayMsg vbTab & "Error: " & oError1.Number
 DisplayMsg vbTab & "Description: " & oError1.Description
 DisplayMsg vbTab & "Source: " & oError1.Source
 DisplayMsg vbTab & "Native Error:" & oError1.NativeError
 DisplayMsg vbTab & "SQL State: " & oError1.SQLState
 Next oError1
 m_oConnection.Errors.Clear
 Set oError1 = Nothing
 End If
 End If

 MsgBox "Error(s) occurred. See txtDisplay1 for specific information.", , _
 "Hello Data"

 Err.Clear
End Sub

Private Sub DisplayMsg(sText As String)
 txtDisplay1.Text = (txtDisplay1.Text & vbCrLf & sText)
End Sub

Private Sub Form_Resize()
 grdDisplay1.Move 100, 700, Me.ScaleWidth - 200, (Me.ScaleHeight - 800) / 2
 txtDisplay1.Move 100, grdDisplay1.Top + grdDisplay1.Height + 100, _
 Me.ScaleWidth - 200, (Me.ScaleHeight - 1000) / 2
End Sub

Private Sub Form_Load()
 cmdGetData.Enabled = True
 cmdExamineData.Enabled = False
 cmdEditData.Enabled = False
 cmdUpdateData.Enabled = False

 grdDisplay1.AllowAddNew = False
 grdDisplay1.AllowDelete = False
 grdDisplay1.AllowUpdate = False
 m_flgPriceUpdated = False
End Sub

Private Sub Form_Unload(Cancel As Integer)
 On Error GoTo ErrHandler:

 Dim oConnection3 As New ADODB.Connection
 Dim sSQL As String
 Dim lAffected As Long

 ' Undo the changes we've made to the database on the server.
 If m_flgPriceUpdated Then
 sSQL = "UPDATE Products SET UnitPrice=(UnitPrice/1.1) " & _
 "WHERE CategoryID=2"
 oConnection3.Open m_sConnStr
 oConnection3.Execute sSQL, lAffected, adCmdText

 MsgBox "Restored prices for " & CStr(lAffected) & _
 " records affected.", , "Hello Data"
 End If

 'Clean up
 oConnection3.Close
 Set oConnection3 = Nothing
 m_oRecordset.Close
 Set m_oRecordset = Nothing
 Exit Sub

ErrHandler:

 If Not oConnection3 Is Nothing Then
 If oConnection3.State = adStateOpen Then oConnection3.Close
 Set oConnection3 = Nothing
 End If
 If Not m_oRecordset Is Nothing Then
 If m_oRecordset.State = adStateOpen Then m_oRecordset.Close
 Set m_oRecordset = Nothing
 End If
End Sub

'EndHelloData


ComboBox.ListRows Property (Access)

 Copy code hover
[image]

ComboBox.ListRows Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ListRows property to set the maximum number of rows to display in the list box portion of a combo box. Read/write Integer.

Syntax

expression .ListRows

expression A variable that represents a ComboBox object.

Remarks

The ListRows property holds an integer that indicates the maximum number of rows to display. The default setting is 16. The setting for the ListRows property must be from 1 to 255.

Note Note

Microsoft Access sets the ListRows property automatically when you select Lookup Wizard as the data type for a field in table Design view.

You can set the default for this property by using a combo box's default control style or the DefaultControl property in Visual Basic.

If the actual number of rows exceeds the number specified by the ListRows property setting, a vertical scroll bar appears in the list box portion of the combo box.

Example

The following example uses the ListCount property to find the number of rows in the list box portion of the CustomerList combo box on a Customers form. It then sets the ListRows property to display a specified number of rows in the list.

VBA Copy code Copy code
Public Sub SizeCustomerList()

 Dim ListControl As Control

 Set ListControl = Forms!Customers!CustomerList
 With ListControl
 If .ListCount < 8 Then
 .ListRows = .ListCount
 Else
 .ListRows = 8
 End If
 End With

End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ListBox.GotFocus Event (Access)

 Copy code hover
[image]

ListBox.GotFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The GotFocus event occurs when the specified object receives the focus.

Syntax

expression .GotFocus

expression A variable that represents a ListBox object.

Remarks

To run a macro or event procedure when these events occur, set the OnGotFocus property to the name of the macro or to [Event Procedure].

These events occur when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The GotFocus event differs from the Enter event in that the GotFocus event occurs every time a control receives the focus. For example, suppose the user clicks a check box on a form, then clicks a report, and finally clicks the check box on the form to bring it to the foreground. The GotFocus event occurs both times the check box receives the focus. In contrast, the Enter event occurs only the first time the user clicks the check box. The GotFocus event occurs after the Enter event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


ListBox.TopPadding Property (Access)

 Copy code hover
[image]

ListBox.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the list box and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .TopPadding

expression A variable that represents a ListBox object.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


ComboBox.LeftMargin Property (Access)

 Copy code hover
[image]

ComboBox.LeftMargin Property (Access)
See also Send feedback

Published: July 16, 2012

Along with the TopMargin, RightMargin, and BottomMargin properties, specifies the location of information displayed within a text box control. Read/write Integer. .

Version Information

Version Added: Access 2007

Syntax

expression .LeftMargin

expression A variable that represents a ComboBox object.

Remarks

A control's displayed information location is measured from the control's left, top, right, or bottom border to the left, top, right, or bottom edge of the displayed information. Setting the LeftMargin or TopMargin property to 0 places the displayed information's edge at the very left or top of the control. To use a unit of measurement different from the setting in the regional settings of Windows, specify the unit (for example, cm or in).

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


CheckBox.ColumnOrder Property (Access)

 Copy code hover
[image]

CheckBox.ColumnOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.

Syntax

expression .ColumnOrder

expression A variable that represents a CheckBox object.

Remarks

To set or change this property for a table or query by using Visual Basic, you must use a column's Properties collection. For details on using the Properties collection, see Properties .

Note Note

The ColumnOrder property isn't available in Design view.

The ColumnOrder property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

In Datasheet view, a field's ColumnOrder property setting is determined by the field's position. For example, the field in the leftmost column in Datasheet view has a ColumnOrder property setting of 1, the next field has a setting of 2, and so on. Changing a field's ColumnOrder property resets the property for that field and every field to the left of its original position in Datasheet view.

In other views, the property setting is 0 unless you explicitly change the order of one or more fields in Datasheet view (either by dragging the fields to new positions or by changing their ColumnOrder property settings). Fields to the right of the moved field's new position will have a property setting of 0 in views other than Datasheet view.

The order of the fields in Datasheet view doesn't affect the order of the fields in table Design view or Form view.

Example

The following example displays the ProductName and QuantityPerUnit fields in the first two columns in Datasheet view of the Products form.

VBA Copy code Copy code
Forms!Products!ProductName.ColumnOrder = 1
Forms!Products!QuantityPerUnit.ColumnOrder = 2

The next example displays the ProductName and QuantityPerUnit fields in the first two columns of the Products table in Datasheet view. To set the ColumnOrder property, the example uses the SetFieldProperty procedure. If this procedure is run while the table is open, changes will not be displayed until it is closed and reopened.

VBA Copy code Copy code
Public Sub SetColumnOrder()

 Dim dbs As DAO.Database
 Dim tdf As DAO.TableDef

 Set dbs = CurrentDb
 Set tdf = dbs!Products

 ' Call the procedure to set the ColumnOrder property.
 SetFieldProperty tdf!ProductName, "ColumnOrder", dbLong, 2
 SetFieldProperty tdf!QuantityPerUnit, "ColumnOrder", dbLong, 3

 Set tdf = Nothing
 Set dbs = Nothing

End Sub

Private Sub SetFieldProperty(ByRef fld As DAO.Field, _
 ByVal strPropertyName As String, _
 ByVal intPropertyType As Integer, _
 ByVal varPropertyValue As Variant)
 ' Set field property without producing nonrecoverable run-time error.

 Const conErrPropertyNotFound = 3270
 Dim prp As Property

 ' Turn off error handling.
 On Error Resume Next

 fld.Properties(strPropertyName) = varPropertyValue

 ' Check for errors in setting the property.
 If Err <> 0 Then
 If Err <> conErrPropertyNotFound Then
 On Error GoTo 0
 MsgBox "Couldn't set property '" & strPropertyName & _
 "' on field '" & fld.Name & "'", vbCritical
 Else
 On Error GoTo 0
 Set prp = fld.CreateProperty(strPropertyName, intPropertyType, _
 varPropertyValue)
 fld.Properties.Append prp
 End If
 End If

 Set prp = Nothing

End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Containers Methods (DAO)

 Copy code hover
[image]

Containers Methods (DAO)
Send feedback

In this section

  • Containers.Refresh Method (DAO)


TextBox.VerticalAnchor Property (Access)

 Copy code hover
[image]

TextBox.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified text box is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .VerticalAnchor

expression A variable that represents a TextBox object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


How to: Retrieve Records Using Access SQL

 Copy code hover
[image]

How to: Retrieve Records Using Access SQL
Send feedback

The most basic and most often used SQL statement is the SELECT statement. SELECT statements are the workhorses of all SQL statements, and they are commonly referred to as select queries. You use the SELECT statement to retrieve data from the database tables, and the results are usually returned in a set of records (or rows) made up of any number of fields (or columns). You must use the FROM clause to designate which table or tables to select from. The basic structure of a SELECT statement is:

VBA Copy code Copy code
SELECT field list
    FROM table list

To select all fields from a table, use an asterisk (*). For example, the following statement selects all the fields and all the records from the Customers table.

VBA Copy code Copy code
SELECT *
    FROM tblCustomers

To limit the fields retrieved by the query, simply use the field names instead. For example.

VBA Copy code Copy code
SELECT [Last Name], Phone
    FROM tblCustomers

To designate a different name for a field in the result set, use the AS keyword to establish an alias for that field.

VBA Copy code Copy code
SELECT CustomerID AS [Customer Number]
    FROM tblCustomers

Restricting the Result Set

More often than not, you will not want to retrieve all records from a table. You will want only a subset of those records based on some qualifying criteria. To qualify a SELECT statement, you must use a WHERE clause, which will allow you to specify exactly which records you want to retrieve.

VBA Copy code Copy code
SELECT *
    FROM tblInvoices
    WHERE CustomerID = 1

Be aware of the CustomerID = 1 portion of the WHERE clause. A WHERE clause can contain up to 40 such expressions, and they can be joined with the And or Or logical operators. Using more than one expression allows you to further filter out records in the result set.

VBA Copy code Copy code
SELECT *
    FROM tblInvoices
    WHERE CustomerID = 1 AND InvoiceDate > #01/01/98#

Be aware that the date string is enclosed in number signs (#). If you are using a regular string in an expression, you must enclose the string in single quotation marks ('). For example.

VBA Copy code Copy code
SELECT *
    FROM tblCustomers
    WHERE [Last Name] = 'White'

If you do not know the whole string value, you can use wildcard characters with the Like operator.

VBA Copy code Copy code
SELECT *
    FROM tblCustomers
    WHERE [Last Name] LIKE 'W*'

There are a number of wildcard characters to choose from, and the following table lists what they are and what they can be used for.

Wildcard character | Description
* | Zero or more characters
? | Any single character
# | Any single digit (0-9)
[charlist] | Any single character in charlist
[!charlist] | Any single character not in charlist

Sorting the Result Set

To specify a particular sort order on one or more fields in the result set, use the optional ORDER BY clause. Records can be sorted in either ascending (ASC) or descending (DESC) order; ascending is the default.

Fields referenced in the ORDER BY clause do not have to be part of the SELECT statement's field list, and sorting can be applied to string, numeric, and date/time values. Always place the ORDER BYclause at the end of the SELECT statement.

VBA Copy code Copy code
SELECT *
    FROM tblCustomers
    ORDER BY [Last Name], [First Name] DESC

You can also use the field numbers (or positions) instead of field names in the ORDER BY clause.

VBA Copy code Copy code
SELECT *
    FROM tblCustomers
    ORDER BY 2, 3 DESC


CurrentProject.ImportExportSpecifications Property (Access)

 Copy code hover
[image]

CurrentProject.ImportExportSpecifications Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a ImportExportSpecifications collection that represents the collection of saved import or export operations for the specified object. Read-only.

Version Information

Version Added: Access 2007

Syntax

expression .ImportExportSpecifications

expression A variable that represents a CurrentProject object.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


Form.AfterUpdate Event (Access)

 Copy code hover
[image]

Form.AfterUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The AfterUpdate event occurs after changed data in a control or record is updated.

Syntax

expression .AfterUpdate

expression A variable that represents a Form object.

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's AfterUpdate event does occur.

To run a macro or event procedure when this event occurs, set the AfterUpdate property to the name of the macro or to [Event Procedure].

The AfterUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

AfterUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. AfterUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For bound controls, the OldValue property isn't set to the updated value until after the AfterUpdate event for the form occurs. Even if the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

See also

Concepts

Form Object

Other resources

Form Object Members


TabControl.GridlineWidthRight Property (Access)

 Copy code hover
[image]

TabControl.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthRight

expression A variable that represents a TabControl object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Application.CodeContextObject Property (Access)

 Copy code hover
[image]

Application.CodeContextObject Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the CodeContextObject property to determine the object in which a macro or Visual Basic code is executing. Read-only Object.

Syntax

expression .CodeContextObject

expression A variable that represents an Application object.

Remarks

The CodeContextObject property is set by Microsoft Access and is read-only in all views.

The ActiveControl, ActiveDatasheet , ActiveForm , and ActiveReport properties of the Screen object always return the object that currently has the focus. The object with the focus may or may not be the object where a macro or Visual Basic code is currently running, for example, when Visual Basic code runs in the Timer event on a hidden form.

Example

In the following example the CodeContextObject property is used in a function to identify the name of the object in which an error occurred. The object name is then used in the message box title as well as in the body of the error message. The Error statement is used in the command button's click event to generate the error for this example.

VBA Copy code Copy code
Private Sub Command1_Click()
 On Error GoTo Command1_Err
 Error 11 ' Generate divide-by-zero error.
 Exit Sub

 Command1_Err:
 If ErrorMessage("Command1_Click() Event", vbYesNo + _
 vbInformation, Err) = vbYes Then
 Exit Sub
 Else
 Resume
 End If
End Sub

Function ErrorMessage(strText As String, intType As Integer, _
 intErrVal As Integer) As Integer
 Dim objCurrent As Object
 Dim strMsgboxTitle As String
 Set objCurrent = CodeContextObject
 strMsgboxTitle = "Error in " & objCurrent.Name
 strText = strText & "Error #" & intErrVal _
 & " occured in " & objCurrent.Name
 ErrorMessage = MsgBox(strText, intType, strMsgboxTitle)
 Err = 0
End Function

See also

Concepts

Application Object

Other resources

Application Object Members


NavigationControl.ScrollBarAlign Property (Access)

 Copy code hover
[image]

NavigationControl.ScrollBarAlign Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ScrollBarAlign to specify or determine the alignment of a vertical scroll bar. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .ScrollBarAlign

expression A variable that represents a NavigationControl object.

Remarks

The ScrollBarAlign property uses the following settings.

Setting | Visual Basic | Description
System | 0 | Vertical scroll bar is placed on the left if the form or report Orientation property is right to left; and on the right if the form or report Orientation property is left to right.
Right | 1 | Aligns vertical scroll bar on the right side of the control.
Left | 2 | Aligns vertical scroll bar on the left side of the control.

Example

The following example aligns the vertical scroll bar on the left side of the "Country" combo box in the "International Shipping" form.

VBA Copy code Copy code
Forms("International Shipping").Controls("Country").ScrollBarAlign = 2

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Wait For Post Processing

 Copy code hover
[image]

Wait For Post Processing
Send feedback

Published: July 16, 2012

Insert introduction here.

Section Heading

Insert section body here.

Subsection Heading

Insert subsection body here.


Database.Close Method (DAO)

 Copy code hover
[image]

Database.Close Method (DAO)
Send feedback

Closes an open Database.

Syntax

expression .Close

expression A variable that represents a Database object.

Remarks

If the Database object is already closed when you use Close, a run-time error occurs.

An alternative to the Close method is to set the value of an object variable to Nothing (Set dbsTemp = Nothing).


Form.BeforeUpdate Event (Access)

 Copy code hover
[image]

Form.BeforeUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The BeforeUpdate event occurs before changed data in a control or record is updated.

Syntax

expression .BeforeUpdate(Cancel)

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the BeforeUpdate event occurs. Setting the Cancel argument to True (-1) cancels the BeforeUpdate event.

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's BeforeUpdate event does occur.

To run a macro or event procedure when this event occurs, set the BeforeUpdate property to the name of the macro or to [Event Procedure].

This event does not apply to option buttons, check boxes, or toggle buttons in an option group. It applies only to the option group itself.

The BeforeUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB. When the focus leaves the record or if the user clicks Save Record on the Records menu, the entire record is updated, and the data is saved in the database.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

BeforeUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. BeforeUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For forms, you can use the BeforeUpdate event to cancel updating of a record before moving to another record.

If the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

You often use the BeforeUpdate event to validate data, especially when you perform complex validations, such as those that:

  • Involve conditions for more than one value on a form.

  • Display different error messages for different data entered.

  • Can be overridden by the user.

  • Contain references to controls on other forms or contain user-defined functions.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

A run-time error will occur if you attempt to modify the data contained in the control that fired the BeforeUpdate event in the event's procedure.

Example

The following example shows how you can use a BeforeUpdate event procedure to check whether a product name has already been entered in the database. After the user types a product name in the ProductName box, the value is compared to the ProductName field in the Products table. If there is a matching value in the Products table, a message is displayed that informs the user that the product has already been entered.

To try the example, add the following event procedure to a form named Products that contains a text box called ProductName.

VBA Copy code Copy code
Private Sub ProductName_BeforeUpdate(Cancel As Integer)
    If(Not IsNull(DLookup("[ProductName]", _
        "Products", "[ProductName] ='" _
        & Me!ProductName & "'"))) Then
        MsgBox "Product has already been entered in the database."
        Cancel = True
        Me!ProductName.Undo
    End If
End Sub

The following example shows how to display a message when a control is empty on a continuous form when a user moves to another record.

Sample code provided by: MVP Contributor Bill Jelen, MrExcel.com | About the Contributors

VBA Copy code Copy code
Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim oContr As Control
    For Each oContr In Me.Detail.Controls
        If IsNull(oContr) = True Then
            If MsgBox(oContr.Name & " is empty", vbOKCancel) = vbCancel Then
                Cancel = True: oContr.SetFocus: Exit Sub
            End If
        End If
    Next oContr
End Sub

The following example shows how to use the BeforeUpdate event of a form to require that a value be entered into one control when another control also has data.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Private Sub Form_BeforeUpdate(Cancel As Integer)
If (IsNull(Me.FieldOne)) Or (Me.FieldOne.Value =  "") Then
    ' No action required
Else
    If (IsNull(Me.FieldTwo)) or (Me.FieldTwo.Value = "") Then
        MsgBox "You must provide data for field 'FieldTwo', " & _
            "if a value is entered in FieldOne", _
            vbOKOnly, "Required Field"
        Me.FieldTwo.SetFocus
        Cancel = True
        Exit Sub
    End If
End If

End Sub

About the Contributors

Holy Macro! Books publishes entertaining books for people who use Microsoft Office. See the complete catalog at MrExcel.com.

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.

See also

Concepts

Form Object

Other resources

Form Object Members


DependencyObjects.Item Property (Access)

 Copy code hover
[image]

DependencyObjects.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.

Syntax

expression .Item(Index)

expression A variable that represents a DependencyObjects object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

DependencyObjects Collection

Other resources

DependencyObjects Object Members


Report.Visible Property (Access)

 Copy code hover
[image]

Report.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents a Report object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

Report Object

Other resources

Report Object Members


Relations Members (DAO)

 Copy code hover
[image]

Relations Members (DAO)
Send feedback

A Relations collection contains stored Relation objects of a Database object (Microsoft Access database engine databases only).

Methods

Name | Description
Append | Adds a new Relation to the Relations collection.
Delete | Deletes the specified Relation from the Relations collection.
Refresh | Updates the objects in the specified colletion to reflect the database's current schema.

Properties

Name | Description
Count | Returns the number of objects in the specified collection. Read-only.


DoCmd.DoMenuItem Method (Access)

 Copy code hover
[image]

DoCmd.DoMenuItem Method (Access)
See also Send feedback

Published: July 16, 2012

Displays the appropriate menu or toolbar command for Microsoft Access.

Syntax

expression .DoMenuItem(MenuBar, MenuName, Command, Subcommand, Version)

expression A variable that represents a DoCmd object.

Parameters

Name

Required/Optional

Data Type

Description

MenuBar

Required

Variant

Use the intrinsic constant acFormBar for the menu bar in Form view. For other views, use the number of the view in the menu bar argument list, as shown in the Macro window in previous versions of Microsoft Access (count down the list, starting from 0).

MenuName

Required

Variant

You can use one of the following intrinsic constants.

  • acFile

  • acEditMenu

  • acRecordsMenu

  • You can use acRecordsMenu only for the Form view menu bar in Microsoft Access version 2.0 and Microsoft Access 95 databases. For other menus, use the number of the menu in the menu name argument list, as shown in the Macro window in previous versions of Microsoft Access (count down the list, starting from 0).

Command

Required

Variant

You can use one of the following intrinsic constants.

  • acNew

  • acSaveForm

  • acSaveFormAs

  • acSaveRecord

  • acUndo

  • acCut

  • acCopy

  • acPaste

  • acDelete

  • acSelectRecord

  • acSelectAllRecords

  • acObjacRefreshect

  • For other commands, use the number of the command in the command argument list, as shown in the Macro window in previous versions of Microsoft Access (count down the list, starting from 0).

Subcommand

Optional

Variant

You can use one of the following intrinsic constants.

  • acObjectVerb

  • acObjectUpdate

  • The acObjectVerb constant represents the first command on the submenu of the Object command on the Edit menu. The type of object determines the first command on the submenu. For example, this command is Edit for a Paintbrush object that can be edited.

  • For other commands on submenus, use the number of the subcommand in the subcommand argument list, as shown in the Macro window in previous versions of Microsoft Access (count down the list, starting from 0).

Version

Optional

Variant

Use the intrinsic constant acMenuVer70 for code written for Microsoft Access 95 databases, the intrinsic constant acMenuVer20 for code written for Microsoft Access version 2.0 databases, and the intrinsic constant acMenuVer1X for code written for Microsoft Access version 1.x databases. This argument is available only in Visual Basic.

Note Note

The default for this argument is acMenuVer1X, so that any code written for Microsoft Access version 1.x databases will run unchanged. If you're writing code for a Microsoft Access 95 or version 2.0 database and want to use the Microsoft Access 95 or version 2.0 menu commands with the DoMenuItem method, you must set this argument to acMenuVer70 or acMenuVer20.

Also, when you are counting down the lists for the Menu Bar, Menu Name, Command, and Subcommand action arguments in the Macro window to get the numbers to use for the arguments in the DoMenuItem method, you must use the Microsoft Access 95 lists if the Version argument is acMenuVer70, the Microsoft Access version 2.0 lists if the Version argument is Version, and the Microsoft Access version 1.x lists if Version is acMenuVer1X (or blank).

Note Note

There is no acMenuVer80 setting for this argument. You can't use the DoMenuItem method to display Microsoft Access 2013 commands (although existing DoMenuItem methods in Visual Basic code will still work). Use the RunCommand method instead.

Remarks

Note Note

In Microsoft Access 97 and later, the DoMenuItem method was replaced by the RunCommand method. The DoMenuItem method is included in this version of Microsoft Access only for compatibility with previous versions. When you run existing Visual Basic code containing a DoMenuItem method, Microsoft Access will display the appropriate menu or toolbar command for Microsoft Access 2000. However, unlike the DoMenuItem action in a macro, a DoMenuItem method in Visual Basic code isn't converted to a RunCommand method when you convert a database created in a previous version of Microsoft Access.

Some commands from previous versions of Microsoft Access aren't available in Access 2013, and DoMenuItem methods that run these commands will cause an error when they're executed in Visual Basic. You must edit your Visual Basic code to replace or delete occurrences of such DoMenuItem methods.

The selections in the lists for the menu name, command, and subcommand action arguments in the Macro window depend on what you've selected for the previous arguments. You must use numbers or intrinsic constants that are appropriate for each MenuBar, MenuName, Command, and Subcommand argument.

If you leave the Subcommand argument blank but specify the Version argument, you must include the Subcommand argument's comma. If you leave the Subcommand and Version arguments blank, don't use a comma following the Command argument.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Hyperlink.ScreenTip Property (Access)

 Copy code hover
[image]

Hyperlink.ScreenTip Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ScreenTip property to specify or determine the text that is displayed when you move the cursor over a hyperlink control. Read/write String.

Syntax

expression .ScreenTip

expression A variable that represents a Hyperlink object.

Remarks

When you move the cursor over a hyperlink control whose HyperlinkSubAddress property is set, Microsoft Access changes the cursor to an upward-pointing hand and displays the text string defined by the ScreenTip property. Clicking the control displays the object or Web page specified by the link.

For more information about hyperlink addresses and their format, see the HyperlinkAddress and HyperlinkSubAddress property topics.

Example

The following example displays the message "Go to Home page" when the cursor hovers over the hyperlink named "HomePage" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("HomePage").Hyperlink.ScreenTip = "Go to Home page"

See also

Concepts

Hyperlink Object

Other resources

Hyperlink Object Members


IS [NOT] NULL (Access 2013 custom web app)

 Copy code hover
[image]

IS [NOT] NULL (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Determines whether a specified expression is NULL.

Syntax

expression IS [NOT ] NULL

The IS [NOT] NULL predicate contains the following arguments.

expression | Any valid expression.
NOT | Specifies that the Boolean result be negated. The predicate reverses its return values, returning TRUE if the value is not NULL, and FALSE if the value is NULL.

Remarks

If the value of expression is NULL, IS NULL returns TRUE; otherwise, it returns FALSE.

If the value of expression is NULL, IS NOT NULL returns FALSE; otherwise, it returns TRUE.


NavigationControl.Application Property (Access)

 Copy code hover
[image]

NavigationControl.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Version Information

Version Added: Access 2010

Syntax

expression .Application

expression A variable that represents a NavigationControl object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


ListBox.FontBold Property (Access)

 Copy code hover
[image]

ListBox.FontBold Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontBold property to specify whether a font appears in a bold style in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontBold

expression A variable that represents a ListBox object.

Remarks

The FontBold property uses the following settings.

Setting | Description
True | The text is bold.
False | (Default) The text isn't bold.

To use the FontBold property on a report, first create a Printevent procedure that prints the desired text.

A font's appearance on screen and in print may differ, depending on your computer and printer.

The FontWeight property, which is available in the property sheet for controls, can also be used to set the line width for a control's text. The FontBold property gives you a quick way to make text bold; the FontWeight property gives you finer control over the line width setting for text. The following table shows the relationship between these properties' settings.

If | Then
FontBold = False | FontWeight = Normal (400)
FontBold = True | FontWeight = Bold (700)
FontWeight < 700 | FontBold = False
FontWeight > = 700 | FontBold = True

Example

The following Print event procedure prints a report title and the current date in a bold style on a report at the coordinates specified by the CurrentX and CurrentY property settings.

VBA Copy code Copy code
Private Sub ReportHeader0_Print(Cancel As Integer, _
 PrintCount As Integer)
 Dim MyDate

 MyDate = Date
 Me.FontBold = True
 ' Print report title in bold.
 Me.Print("Sales Management Report")
 Me.Print(MyDate)
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


AcPrintPaperBin Enumeration (Access)

 Copy code hover
[image]

AcPrintPaperBin Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the PaperBin property to indicate which paper bin the specified printer should use.

Name | Value | Description
acPRBNAuto | 7 | (Default) Use paper from the current default bin.
acPRBNCassette | 14 | Use paper from the attached cassette cartridge.
acPRBNEnvelope | 5 | Use envelopes from the envelope feeder.
acPRBNEnvManual | 6 | Use envelopes from the envelope feeder, but wait for manual insertion.
acPRBNFormSource | 15 | Use paper from the forms bin.
acPRBNLargeCapacity | 11 | Use paper from the large capacity feeder.
acPRBNLargeFmt | 10 | Use paper from the large paper bin.
acPRBNLower | 2 | Use paper from the lower bin.
acPRBNManual | 4 | Wait for manual insertion of each sheet of paper.
acPRBNMiddle | 3 | Use paper from the middle bin.
acPRBNSmallFmt | 9 | Use paper from the small paper feeder.
acPRBNTractor | 8 | Use paper from the tractor feeder.
acPRBNUpper | 1 | Use paper from the upper bin.


Using CacheSize

 Copy code hover
[image]

Using CacheSize
Send feedback

Use the CacheSize property to control how many records to retrieve at one time into local memory from the provider. For example, if the CacheSize is 10, after first opening the Recordset object, the provider retrieves the first 10 records into local memory. As you move through the Recordset object, the provider returns the data from the local memory buffer. As soon as you move past the last record in the cache, the provider retrieves the next 10 records from the data source into the cache.

Note Note

CacheSize is based on the Maximum Open Rows provider-specific property (in the Properties collection of the Recordset object). You cannot set CacheSize to a value greater than Maximum Open Rows. To modify the number of rows that can be opened by the provider, set Maximum Open Rows.

The value of CacheSize can be adjusted during the life of the Recordset object, but changing this value only affects the number of records in the cache after subsequent retrievals from the data source. Changing the property value alone will not change the current contents of the cache.

If there are fewer records to retrieve than CacheSize specifies, the provider returns the remaining records and no error occurs.

A CacheSize setting of zero is not allowed and returns an error.

Records retrieved from the cache do not reflect concurrent changes that other users made to the source data. To force an update of all the cached data, use the Resync method.

If CacheSize is set to a value greater than 1, the navigation methods (Move, MoveFirst, MoveLast, MoveNext, and MovePrevious) may result in navigation to a deleted record, if deletion occurs after the records were retrieved. After the initial fetch, subsequent deletions will not be reflected in your data cache until you attempt to access a data value from a deleted row. However, setting CacheSize to 1 eliminates this issue because deleted rows cannot be fetched.


RunSavedImportExport Macro Action

 Copy code hover
[image]

RunSavedImportExport Macro Action
Send feedback

You can use the RunSavedImportExport action to run a saved import or export specification that you created by using the Import Wizard or the Export Wizard.

Note 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.

Setting

The RunSavedImportExport action has the following argument.

Action argument | Description
Saved Import Export Name | Select the name of a saved import or export specification from the drop-down list.

Remarks

  • This macro action has the same effect as performing the following procedure in Access:

    1. On the External Data tab, click either Saved Imports or Saved Exports.

    2. In the Manage Data Tasks dialog box, on the Saved Imports or Saved Exports tab (depending on your choice in the preceding step), click the specification that you want to run.

    3. Click Run.

  • Before running the RunSavedImportExport action, make sure that the source and destination files exist, the source data is ready for importing, and that the operation will not accidentally overwrite any data in your destination file.

  • Find links to more information about saving and running import and export specifications in the See Also section.

  • If the saved import or export specification you choose for the Saved Import Export Name argument is deleted after the macro is created, Access displays the following error message when the macro is run: The specification with the specified index does not exist. Specify a different index. 'specification name'.


DBEngine.Version Property (DAO)

 Copy code hover
[image]

DBEngine.Version Property (DAO)
Send feedback

Rreturns the version of DAO currently in use. Read-only String.

Syntax

expression .Version

expression A variable that represents a DBEngine object.

Remarks

The return value is a String that evaluates to a version number in the form "major.minor". For example, "3.0". The product version number consists of the version number (3), a period, and the release number (0).


Description Property (Access)

 Copy code hover
[image]

Description Property (Access)
Send feedback

Published: July 16, 2012

You can use the Description property to provide information about objects contained in the Database window as well as about individual table or query fields.

Setting

For a database object, click Properties on the View menu and enter the description text in the Description box. For tables or queries, you can also enter the description in the table's or query's property sheet. An object's description appears next to the object's name in the Database window when you click Details on the View menu.

For individual table or query fields, enter the field description in the upper portion of table Design view or in the Field Properties property sheet in the Query window. The maximum length is 255 characters.

In Visual Basic , to set this property for the first time in a Microsoft Access project (.adp), you must create an application-defined property by using the Add method. In a Microsoft Access database (.mdb), you must use the DAO CreateProperty method.

Remarks

An object's description is displayed in the Description column in the Details view of the Database window.

If you create controls by dragging a field from the field list, Microsoft Access copies the field's Description property to the control's StatusBarText property.

Note Note

For a linked table, Microsoft Access displays the connection information in the Description property.


SubForm.SpecialEffect Property (Access)

 Copy code hover
[image]

SubForm.SpecialEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.

Syntax

expression .SpecialEffect

expression A variable that represents a SubForm object.

Remarks

The SpecialEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | 0 | The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised | 1 | The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken | 2 | The object has a shadow on the top and left and a highlight on the bottom and right.
Etched | 3 | The object has a sunken line surrounding the control.
Shadowed | 4 | The object has a shadow below and to the right of the control.
Chiseled | 5 | The object has a sunken line below the control.

The SpecialEffect property setting affects related property settings for the BorderStyle , BorderColor , and BorderWidth properties. For example, if the SpecialEffect property is set to Raised, the settings for the BorderStyle, BorderColor, and BorderWidth properties are ignored. In addition, changing or setting the BorderStyle, BorderColor, and BorderWidth properties may cause Microsoft Access to change the SpecialEffect property setting to Flat.

Example

The following example sets the appearance of the text box "OrganizationName1" on the "Mailing List" form to raised.

VBA Copy code Copy code
Forms("Mailing List").Controls("OrganizationName1").SpecialEffect = 1

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


CommandButton.PressedForeColor Property (Access)

 Copy code hover
[image]

CommandButton.PressedForeColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the text displayed on the control when the user clicks it. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .PressedForeColor

expression A variable that represents a CommandButton object.

Remarks

The PressedForeColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Invalid field data type. (Error 3259)

 Copy code hover
[image]

Invalid field data type. (Error 3259)
Send feedback

The data type specified in the Field object's Type property is not valid. Choose one of the valid types as shown in the Type property Help topic.


Could not update; currently locked. (Error 3218)

 Copy code hover
[image]

Could not update; currently locked. (Error 3218)
Send feedback

You tried to update data that is located on a page that is currently locked.

Possible causes:

  • You tried to save a query that is being used by someone else. To save your query, wait for the other user to finish or enter a different name, and then try the operation again.

  • You tried to use the Edit method on a data page containing a record that is already open or locked.


DBEngine.DefaultType Property (DAO)

 Copy code hover
[image]

DBEngine.DefaultType Property (DAO)
Send feedback

Sets or returns a value that indicates what type of workspace will be used by the next Workspace object created.

Syntax

expression .DefaultType

expression A variable that represents a DBEngine object.

Remarks

The setting or return value can be one of the of the WorkspaceTypeEnum constants.

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

The setting can be overridden for a single Workspace by setting the type argument to the CreateWorkspace method.


EmptyCell.Visible Property (Access)

 Copy code hover
[image]

EmptyCell.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .Visible

expression A variable that represents an EmptyCell object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


QueryDef.OpenRecordset Method (DAO)

 Copy code hover
[image]

QueryDef.OpenRecordset Method (DAO)
Send feedback

Creates a new Recordset object and appends it to the Recordsets collection.

Syntax

expression .OpenRecordset(Type, Options, LockEdit)

expression A variable that represents a QueryDef object.

Parameters

Name

Required/Optional

Data Type

Description

Type

Optional

Variant

A RecordsetTypeEnum constant that indicates the type of Recordset to open.

Note Note

If you open a Recordset in a Microsoft Access workspace and you don't specify a type, OpenRecordset creates a table-type Recordset, if possible. If you specify a linked table or query, OpenRecordset creates a dynaset-type Recordset.

Options

Optional

Variant

A combination of RecordsetOptionEnum constants that specify characteristics of the new Recordset.

Note Note

The constants dbConsistent and dbInconsistent are mutually exclusive, and using both causes an error. Supplying a lockedits argument when options uses the dbReadOnly constant also causes an error.

LockEdit

Optional

Variant

A LockTypeEnum constant that determines the locking for the Recordset.

Note Note

You can use dbReadOnly in either the options argument or the lockedits argument, but not both. If you use it for both arguments, a run-time error occurs.

Return Value

Recordset

Remarks

You should also use the dbSeeChanges constant if you open a Recordset in a Microsoft Access database engine-connected ODBC workspace against a Microsoft SQL Server 6.0 (or later) table that has an IDENTITY column, otherwise an error may result.

Opening more than one Recordset on an ODBC data source may fail because the connection is busy with a prior OpenRecordset call. One way around this is to fully populate the Recordset by using the MoveLast method as soon as the Recordset is opened.

Closing a Recordset with the Close method automatically deletes it from the Recordsets collection.

Note Note

If source refers to an SQL statement composed of a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strSQL = "PRICE > " & lngPrice, and lngPrice = 125,50), an error occurs when you try to open the Recordset. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and SQL only accepts U.S. decimal characters.


NavigationButton.GridlineThemeColorIndex Property (Access)

 Copy code hover
[image]

NavigationButton.GridlineThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineThemeColorIndex

expression A variable that represents a NavigationButton object.

Remarks

The GridlineThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 (Default) | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the GridlineThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Number Property (ADO)

 Copy code hover
[image]

Number Property (ADO)
Send feedback

Indicates the number that uniquely identifies an Error object.

Return Value

Returns a Long value that may correspond to one of the ErrorValueEnum constants.

Remarks

Use the Number property to determine which error occurred. The value of the property is a unique number that corresponds to the error condition.

The Errors collection returns an HRESULT in either hexadecimal format (for example, 0x80004005) or long value (for example, 2147467259). These HRESULTs can be raised by underlying components, such as OLE DB or even OLE itself. For more information about these numbers, see Chapter 16 of the OLE DB Programmer's Reference.


Application.FollowHyperlink Method (Access)

 Copy code hover
[image]

Application.FollowHyperlink Method (Access)
See also Send feedback

Published: July 16, 2012

The FollowHyperlink method opens the document or Web page specified by a hyperlink address.

Syntax

expression .FollowHyperlink(Address, SubAddress, NewWindow, AddHistory, ExtraInfo, Method, HeaderInfo)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Address | Required | String | A string expression that evaluates to a valid hyperlink address.
SubAddress | Optional | String | A string expression that evaluates to a named location in the document specified by the address argument. The default is a zero-length string (" ").
NewWindow | Optional | Boolean | A Boolean value where True (-1) opens the document in a new window and False (0) opens the document in the current window. The default is False.
AddHistory | Optional | Boolean | A Boolean value where True adds the hyperlink to the History folder and False doesn't add the hyperlink to the History folder. The default is True.
ExtraInfo | Optional | Variant | A string or an array of Byte data that specifies additional information for navigating to a hyperlink. For example, this argument may be used to specify a search parameter for an .asp or .idc file. In your Web browser, the extrainfo argument may appear after the hyperlink address, separated from the address by a question mark (?). You don't need to include the question mark when you specify the extrainfo argument.
Method | Optional | MsoExtraInfoMethod | A MsoExtraInfoMethod constant that specifies how the extrainfo argument is attached.
HeaderInfo | Optional | String | A string that specifies header information. By default the headerinfo argument is a zero-length string.

Remarks

By using the FollowHyperlink method, you can follow a hyperlink that doesn't exist in a control. This hyperlink may be supplied by you or by the user. For example, you can prompt a user to enter a hyperlink address in a dialog box, then use the FollowHyperlink method to follow that hyperlink.

You can use the extrainfo and method arguments to supply additional information when navigating to a hyperlink. For example, you can supply parameters to a search engine.

You can use the Follow method to follow a hyperlink associated with a control.

Example

The following function prompts a user for a hyperlink address and then follows the hyperlink:

VBA Copy code Copy code
Function GetUserAddress() As Boolean
    Dim strInput As String

    On Error GoTo Error_GetUserAddress
    strInput = InputBox("Enter a valid address")
    Application.FollowHyperlink strInput, , True
    GetUserAddress = True

Exit_GetUserAddress:
    Exit Function

Error_GetUserAddress:
    MsgBox Err & ": " & Err.Description
    GetUserAddress = False
    Resume Exit_GetUserAddress
End Function

You could call this function with a procedure such as the following:

VBA Copy code Copy code
Sub CallGetUserAddress()
    If GetUserAddress = True Then
        MsgBox "Successfully followed hyperlink."
    Else
        MsgBox "Could not follow hyperlink."
    End If
End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


RDS Tutorial (Visual J++)

 Copy code hover
[image]

RDS Tutorial (Visual J++)
Send feedback

ADO/WFC does not completely follow the RDS object model in that it does not implement the RDS.DataControl object. ADO/WFC only implements the client-side class, RDS.DataSpace.

The DataSpace class implements one method, CreateObject, which returns an ObjectProxy object. The DataSpace class also implements the InternetTimeout property.

The ObjectProxy class implements one method, call, which can invoke any server-side business object.

This is the beginning of the tutorial.

Copy code Copy code

import com.ms.wfc.data.*;
public class RDSTutorial
{
 public void tutorial()
 {
// Step 1: Specify a server program.
 ObjectProxy obj =
 DataSpace.createObject(
 "RDSServer.DataFactory",
 "http://YourServer");

// Step 2: Server returns a Recordset.
 Recordset rs = (Recordset) obj.call(
 "Query",
 new Object[] {"DSN=Pubs;", "SELECT * FROM Authors"});

// Step 3: Changes are sent to the server.
 ... // Edit Recordset.
 obj.call(
 "SubmitChanges",
 new Object[] {"DSN=Pubs;", rs});
 return;
 }
}

This is the end of the tutorial.


How to: Modify a Query from a DAO Recordset

 Copy code hover
[image]

How to: Modify a Query from a DAO Recordset
Send feedback

You can use the Requery method on a dynaset-type or snapshot-type Recordset object when you want to run the underlying query again after changing a parameter. This is more convenient than opening a new Recordset, and it runs faster.

The following code example creates a Recordset object and passes it to a function that uses the CopyQueryDef method to extract the equivalent SQL string. It then prompts the user to add an additional constraint clause to the query. The code uses the Requery method to run the modified query.

VBA Copy code Copy code
Sub AddQuery()

Dim dbsNorthwind As DAO.Database
Dim qdfSalesReps As DAO.QueryDef
Dim rstSalesReps As DAO.Recordset

On Error GoTo ErrorHandler

   Set dbsNorthwind = CurrentDb

   Set qdfSalesReps = dbsNorthwind.CreateQueryDef("SalesRepQuery")
   qdfSalesReps.SQL = "SELECT * FROM Employees WHERE Title = " & _
                      "'Sales Representative'"

   Set rstSalesReps = qdfSalesReps.OpenRecordset()

   ' Call the function to add a constraint.
   AddQueryFilter rstSalesReps

   ' Return database to original.
   dbsNorthwind.QueryDefs.Delete "SalesRepQuery"

   rstSalesReps.Close
   qdfSalesReps.Close
   dbsNorthwind.Close

   Set rstSalesReps = Nothing
   Set qdfSalesReps = Nothing
   Set dbsNorthwind = Nothing

   Exit Sub

ErrorHandler:
   MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Sub

Sub AddQueryFilter(rstData As Recordset)

Dim qdfData As DAO.QueryDef
Dim strNewFilter As String
Dim strRightSQL As String

On Error GoTo ErrorHandler

   Set qdfData = rstData.CopyQueryDef

   ' Try "LastName LIKE 'D*'".
   strNewFilter = InputBox("Enter new criteria")

   strRightSQL = Right(qdfData.SQL, 1)

   ' Strip characters from the end of the query,
   ' as needed.
   Do While strRightSQL = " " Or strRightSQL = ";" Or _
                          strRightSQL = vbCR Or strRightSQL = vbLF
      qdfData.SQL = Left(qdfData.SQL, Len(qdfData.SQL) - 1)
      strRightSQL = Right(qdfData.SQL, 1)
   Loop

   qdfData.SQL = qdfData.SQL & " AND " & strNewFilter
   rstData.Requery qdfData         'Requery the Recordset.
   rstData.MoveLast               'Populate the Recordset.

   ' "Lastname LIKE 'D*'" should return 2 records.
   MsgBox "Number of records found:  " & rstData.RecordCount & "."

   qdfData.Close
   Set qdfData = Nothing

   Exit Sub

ErrorHandler:
   MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Sub
Note Note

To use the Requery method, the Restartable property of the Recordset object must be set to True. The Restartable property is always set to True when the Recordset is created from a query other than a crosstab query against tables in an Access database. You cannot restart SQL pass-through queries. You may or may not be able to restart queries against linked tables in another database format. To determine whether a Recordset object can rerun its query, check the Restartable property.


Image.Controls Property (Access)

 Copy code hover
[image]

Image.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Syntax

expression .Controls

expression A variable that represents an Image object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

Image Object

Other resources

Image Object Members


Field.Name Property (DAO)

 Copy code hover
[image]

Field.Name Property (DAO)
Send feedback

Returns or sets the name of the specified object. Read/write String if the object has not been appended to a collection. Read-only String if the object has been appended to a collection.

Syntax

expression .Name

expression A variable that represents a Field object.

Remarks

The maximum length for the name of a Field object is 64 characters.


TextBox.ForeShade Property (Access)

 Copy code hover
[image]

TextBox.ForeShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .ForeShade

expression A variable that represents a TextBox object.

Remarks

The ForeShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the ForeShade property is 100, which is neutral, and does not change the theme color. To darken the color you first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, you subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code darkens ForeColor by 75%.

VBA Copy code Copy code
Me.ctl.ForeShade=25

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


AcShowToolbar Enumeration (Access)

 Copy code hover
[image]

AcShowToolbar Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the ShowToolbar method to specify whether to display a particular custom toolbar.

Name | Value | Description
acToolbarNo | 2 | Hide the toolbar.
acToolbarWhereApprop | 1 | Display the toolbar while in the appropriate view.
acToolbarYes | 0 | Display the toolbar.


Field.GetChunk Method (DAO)

 Copy code hover
[image]

Field.GetChunk Method (DAO)
Send feedback

Returns all or a portion of the contents of a Memo or Long Binary Field object in the Fields collection of a Recordset object.

Syntax

expression .GetChunk(Offset, Bytes)

expression A variable that represents a Field object.

Parameters

Name | Required/Optional | Data Type | Description
Offset | Required | Long | The number of bytes to skip before copying begins.
Bytes | Required | Long | The number of bytes you want to return.

Return Value

Variant

Remarks

The bytes returned by GetChunk are assigned to variable. Use GetChunk to return a portion of the total data value at a time. You can use the AppendChunk method to reassemble the pieces.

If offset is 0, GetChunk begins copying from the first byte of the field.

If numbytes is greater than the number of bytes in the field, GetChunk returns the actual number of remaining bytes in the field.

Note Note

Use a Memo field for text, and put binary data only in Long Binary fields. Doing otherwise will cause undesirable results.

Example

This example uses the AppendChunk and GetChunk methods to fill an OLE object field with data from another record, 32K at a time. In a real application, one might use a procedure like this to copy an employee record (including the employee's photo) from one table to another. In this example, the record is simply being copied back to same table. Note that all the chunk manipulation takes place within a single AddNew-Update sequence.

VBA Copy code Copy code
Sub AppendChunkX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset
 Dim rstEmployees2 As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 ' Open two recordsets from the Employees table.
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", _
 dbOpenDynaset)
 Set rstEmployees2 = rstEmployees.Clone

 ' Add a new record to the first Recordset and copy the
 ' data from a record in the second Recordset.
 With rstEmployees
 .AddNew
 !FirstName = rstEmployees2!FirstName
 !LastName = rstEmployees2!LastName
 CopyLargeField rstEmployees2!Photo, !Photo
 .Update

 ' Delete new record because this is a demonstration.
 .Bookmark = .LastModified
 .Delete
 .Close
 End With

 rstEmployees2.Close
 dbsNorthwind.Close

End Sub

Function CopyLargeField(fldSource As Field, _
 fldDestination As Field)

 ' Set size of chunk in bytes.
 Const conChunkSize = 32768

 Dim lngOffset As Long
 Dim lngTotalSize As Long
 Dim strChunk As String

 ' Copy the photo from one Recordset to the other in 32K
 ' chunks until the entire field is copied.
 lngTotalSize = fldSource.FieldSize
 Do While lngOffset < lngTotalSize
 strChunk = fldSource.GetChunk(lngOffset, conChunkSize)
 fldDestination.AppendChunk strChunk
 lngOffset = lngOffset + conChunkSize
 Loop

End Function


Report.PictureData Property (Access)

 Copy code hover
[image]

Report.PictureData Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.

Syntax

expression .PictureData

expression A variable that represents a Report object.

Remarks

The PictureData property setting is the PictureData property of another control, form, or report.

You can use this property to display different background pictures in a form, depending on actions taken by the user. For example, you might open a Customers form using a different background picture depending on whether the form is opened for data entry or for browsing.

You can also use the PictureData property together with the Timer event and the TimerInterval property to perform simple animation on a form.

Example

The following example uses three image controls to animate a butterfly image across a form. The Hidden1 image control contains a picture of a butterfly with its wings up and the Hidden2 image control contains a picture of the same butterfly with its wings down. Both image controls have their Visible property set to False. The TimerInterval property is set to 200. Each time the Timer event occurs, the picture in the image control Visible1 is changed by using the PictureData property of the hidden image controls, and the visible image control is moved 200 twips to the right. The visible image control is moved back to the left side of the form when its Left property value is greater than the width of the form stored in the public variable gfrmWidth. The value of gfrmWidth is set to Me.Width in the form's open event.

VBA Copy code Copy code
Private Sub Form_Timer()

 Static intPic As Integer

 Select Case intPic
 Case Is = 1
 Me!Visible1.PictureData = Me!Hidden1.PictureData
 Case Is = 2
 Me!Visible1.PictureData = Me!Hidden2.PictureData
 Case Else
 End Select

 If intPic = 2 Then intPic = 0
 intPic = intPic + 1
 If (Me!Visible1.Left > gfrmWidth) Then Me!Visible1.Left = 0
 Me!Visible1.Left = Me!Visible1.Left + 200

End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


A call to an OLE system function was not successful. Try reinstalling the application that returned the error. (Error 3448)

 Copy code hover
[image]

A call to an OLE system function was not successful. Try reinstalling the application that returned the error. (Error 3448)
Send feedback

An OLE Automation function called failed. Try reinstalling the application that returned the error.


ADCPROP_ASYNCTHREADPRIORITY_ENUM

 Copy code hover
[image]

ADCPROP_ASYNCTHREADPRIORITY_ENUM
Send feedback

For an RDS Recordset object, specifies the execution priority of the asynchronous thread that retrieves data.

Use these constants with the Recordset "Background Thread Priority" dynamic property, which is referenced in the ADO Dynamic Property Index and documented in the Microsoft Cursor Service for OLE DB documentation.

Constant | Value | Description
adPriorityAboveNormal | 4 | Sets priority between normal and highest.
adPriorityBelowNormal | 2 | Sets priority between lowest and normal.
adPriorityHighest | 5 | Sets priority to the highest possible.
AdPriorityLowest | 1 | Sets priority to the lowest possible.
adPriorityNormal | 3 | Sets priority to normal.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.AdcPropAsyncThreadPriority.ABOVENORMAL

AdoEnums.AdcPropAsyncThreadPriority.BELOWNORMAL

AdoEnums.AdcPropAsyncThreadPriority.HIGHEST

AdoEnums.AdcPropAsyncThreadPriority.LOWEST

AdoEnums.AdcPropAsyncThreadPriority.NORMAL


TextBox.Undo Method (Access)

 Copy code hover
[image]

TextBox.Undo Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the Undo method to reset a control or form when its value has been changed.

Syntax

expression .Undo

expression A variable that represents a TextBox object.

Remarks

For example, you can use the Undo method to clear a change to a record that contains an invalid entry.

If the Undo method is applied to a form, all changes to the current record are lost. If the Undo method is applied to a control, only the control itself is affected.

This method must be applied before the form or control is updated. You may want to include this method in a form's BeforeUpdate event or in a control's Change event.

The Undo method offers an alternative to using the SendKeys statement to send the value of the ESC key in an event procedure.

Example

The following example shows how you can use the Undo method within a control's Change event procedure to force a field named LastName to reset to its original value, if it changed.

VBA Copy code Copy code
Private Sub LastName_Change()
 Me!LastName.Undo
End Sub

The next example uses the Undo method to reset all changes to a form before the form is updated.

VBA Copy code Copy code
Private Sub Form_BeforeUpdate(Cancel As Integer)
 Me.Undo
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


WillChangeRecord and RecordChangeComplete Events (ADO)

 Copy code hover
[image]

WillChangeRecord and RecordChangeComplete Events (ADO)
Send feedback

The WillChangeRecord event is called before one or more records (rows) in the Recordset change. The RecordChangeComplete event is called after one or more records change.

Syntax

WillChangeRecord adReason, cRecords, adStatus, pRecordset

RecordChangeComplete adReason, cRecords, pError, adStatus, pRecordset

Parameters

  • adReason

  • An EventReasonEnum value that specifies the reason for this event. Its value can be adRsnAddNew, adRsnDelete, adRsnUpdate, adRsnUndoUpdate, adRsnUndoAddNew, adRsnUndoDelete, or adRsnFirstChange.

  • cRecords

  • A Long value that indicates the number of records changing (affected).

  • pError

  • An Error object. It describes the error that occurred if the value of adStatus is adStatusErrorsOccurred; otherwise it is not set.

  • adStatus

  • EventStatusEnum

    When WillChangeRecord is called, this parameter is set to adStatusOK if the operation that caused the event was successful. It is set to adStatusCantDeny if this event cannot request cancellation of the pending operation.

    When RecordChangeComplete is called, this parameter is set to adStatusOK if the operation that caused the event was successful, or to adStatusErrorsOccurred if the operation failed.

    Before WillChangeRecord returns, set this parameter to adStatusCancel to request cancellation of the operation that caused this event or set this parameter to adStatusUnwantedEvent to prevent subsequent notications.

    Before RecordChangeComplete returns, set this parameter to adStatusUnwantedEvent to prevent subsequent notifications.

  • pRecordset

  • A Recordset object. The Recordset for which this event occurred.

Remarks

A WillChangeRecord or RecordChangeComplete event may occur for the first changed field in a row due to the following Recordset operations: Update, Delete, CancelUpdate, AddNew, UpdateBatch, and CancelBatch. The value of the Recordset CursorType determines which operations cause the events to occur.

During the WillChangeRecord event, the Recordset Filter property is set to adFilterAffectedRecords. You cannot change this property while processing the event.

You must set the adStatus parameter to adStatusUnwantedEvent for each possible adReason value in order to completely stop event noticiation for any event that includes an adReason parameter.


CommandButton.UseTheme Property (Access)

 Copy code hover
[image]

CommandButton.UseTheme Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the specified object will utilize formatting styles defined in Office Document Themes. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .UseTheme

expression A variable that represents a CommandButton object.

Remarks

The default value is True.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


EmptyCell.Section Property (Access)

 Copy code hover
[image]

EmptyCell.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .Section

expression A variable that represents an EmptyCell object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


Adding Records Using AddNew

 Copy code hover
[image]

Adding Records Using AddNew
Send feedback

This is the basic syntax of the AddNew method:

Copy code Copy code
                      recordset
                      .AddNew
                      FieldList
                      ,
                      Values

The FieldList and Values arguments are optional. FieldList is either a single name or an array of names or ordinal positions of the fields in the new record.

The Values argument is either a single value or an array of values for the fields in the new record.

Typically, when you intend to add a single record, you will call the AddNew method without any arguments. Specifically, you will call AddNew, set the Value of each field in the new record, and then call Update and/or UpdateBatch. You can ensure that your Recordset supports adding new records by using the Supports property with the adAddNew enumerated constant.

The following code uses this technique to add a new Shipper to the sample Recordset. The ShipperID field value is supplied automatically by SQL Server, so the code does not attempt to supply a field value for the new records.

Copy code Copy code

'BeginAddNew1.1
 If objRs1.Supports(adAddNew) Then
 With objRs1
 .AddNew
 .Fields("CompanyName") = "Sample Shipper"
 .Fields("Phone") = "(931) 555-6334"
 .Update
 End With
 End If
'EndAddNew1.1

Because this code uses a disconnected Recordset with a client-side cursor in batch mode, you must reconnect the Recordset to the data source with a new Connection object before you can call the UpdateBatch method to post changes to the database. This is easily done by using the new function GetNewConnection.

Copy code Copy code

'BeginAddNew1.2
 'Re-establish a Connection and update
 Set objRs1.ActiveConnection = GetNewConnection
 objRs1.UpdateBatch
'EndAddNew1.2


Cannot load DLL

 Copy code hover
[image]

Cannot load DLL <name>. (Error 3633)
Send feedback

The specified DLL is either not registered, or not in the path.


Control.Application Property (Access)

 Copy code hover
[image]

Control.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a Control object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

Control Object

Other resources

Control Object Members


ObjectFrame.OnMouseMove Property (Access)

 Copy code hover
[image]

ObjectFrame.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Syntax

expression .OnMouseMove

expression A variable that represents an ObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


OptionGroup Methods (Access)

 Copy code hover
[image]

OptionGroup Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.
Undo | You can use the Undo method to reset a control or form when its value has been changed.


Batch Mode

 Copy code hover
[image]

Batch Mode
Send feedback

Batch mode is in effect when the LockType property is set to adLockBatchOptimistic and batch updating is supported by the provider. Certain lock type settings are not available depending on cursor location. For instance, a pessimistic lock type is not available when the CursorLocation is set to adUseClient. Conversely, a provider may not support a batch optimistic lock when the cursor location is on the server. You should use batch updating with either a keyset or static cursor only.

The UpdateBatch method is used to send Recordset changes held in the copy buffer to the server to update the data source. In the following section, we will open a Recordset in batch mode, make changes to the copy buffer, and then send our changes to the data source using a call to UpdateBatch.


ComboBox.OnMouseDown Property (Access)

 Copy code hover
[image]

ComboBox.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Syntax

expression .OnMouseDown

expression A variable that represents a ComboBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


CheckBox.AutoLabel Property (Access)

 Copy code hover
[image]

CheckBox.AutoLabel Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.

Syntax

expression .AutoLabel

expression A variable that represents a CheckBox object.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ToggleButton.BackColor Property (Access)

 Copy code hover
[image]

ToggleButton.BackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the interior color of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackColor

expression A variable that represents a ToggleButton object.

Remarks

The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

To use the BackColor property, the BackStyle property, if available, must be set to Normal.

Example

The following example uses the RGB function to set the , BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


AllForms Object (Access)

 Copy code hover
[image]

AllForms Object (Access)
See also Send feedback

Published: July 16, 2012

The AllForms collection contains an AccessObject object for each form in the CurrentProject or CodeProject object.

Remarks

The CurrentProject and CodeProject object has an AllForms collection containing AccessObject objects that describe instances of all the forms in the database. For example, you can enumerate the AllForms collection in Visual Basic to set or return the values of properties of individual AccessObject objects in the collection.

You can refer to an individual AccessObject object in the AllForms collection either by referring to the object by name, or by referring to its index within the collection. If you want to refer to a specific object in the AllForms collection, it's better to refer to the form by name because a form's collection index may change.

The AllForms collection is indexed beginning with zero. If you refer to a form by its index, the first form is AllForms(0), the second form is AllForms(1), and so on.

Note Note

To list all open forms in the database, use the IsLoaded property of each AccessObject object in the AllForms collection. You can then use the Name property of each individual AccessObject object to return the name of a form.

You can't add or delete an AccessObject object from the AllForms collection.

Example

The following example prints the name of each open AccessObject object in the AllForms collection.

VBA Copy code Copy code
Sub AllForms()
    Dim obj As AccessObject, dbs As Object
    Set dbs = Application.CurrentProject
    ' Search for open AccessObject objects in AllForms collection.
    For Each obj In dbs.AllForms
        If obj.IsLoaded = True Then
            ' Print name of obj.
            Debug.Print obj.Name
        End If
    Next obj
End Sub

The following example shows how to prevent a user form opening a particular form directly from the Navigation Pane.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
'Don't let this form be opened from the Navigator
If Not CurrentProject.AllForms(cFormUsage).IsLoaded Then
    MsgBox "This form cannot be opened from the Navigation Pane.", _
        vbInformation + vbOKOnly, "Invalid form usage"
    Cancel = True
    Exit Sub
End If

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.

See also

Concepts

Access Object Model Reference

Other resources

AllForms Object Members


Application.COMAddIns Property (Access)

 Copy code hover
[image]

Application.COMAddIns Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the COMAddIns property to return a reference to the current COMAddIns collection object and its related properties. Read-only COMAddIns object.

Syntax

expression .COMAddIns

expression A variable that represents an Application object.

Remarks

The COMAddIns collection object is the collection of all currently registered COM add-ins of an application. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 1 and the total number of member objects in the collection is the value of the COMAddIns collection's Count property.

Once you establish a reference to the COMAddIns collection object, you can access all the properties and methods of the object. You can set a reference to the COMAddIns collection object by clicking References on the Tools menu while in module Design view. Then set a reference to the Microsoft Office 12.0 Object Library in the References dialog box by selecting the appropriate check box. Microsoft Access can set this reference for you if you use a Microsoft Office 12.0 Object Library constant to set a COMAddIns collection object's property or as an argument to a COMAddIns collection object's method.

See also

Concepts

Application Object

Other resources

Application Object Members


SubForm.LabelAlign Property (Access)

 Copy code hover
[image]

SubForm.LabelAlign Property (Access)
See also Send feedback

Published: July 16, 2012

The property specifies the text alignment within attached labels on new controls. Read/write Byte.

Syntax

expression .LabelAlign

expression A variable that represents a SubForm object.

Remarks

The LabelAlign property uses the following settings.

Setting | Description
0 | (Default) The label text aligns to the left.
1 | The label text aligns to the left.
2 | The label text is centered.
3 | The label text aligns to the right.
4 | The label text is evenly distributed.

You can set the LabelAlign property by using a control's default control style or the DefaultControl property in Visual Basic.

When created, controls have an attached label (as long as their AutoLabel property is set to Yes). Changes to the LabelAlign default control style setting affect only controls created on the current form or report.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Form.SetFocus Method (Access)

 Copy code hover
[image]

Form.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Syntax

expression .SetFocus

expression A variable that represents a Form object.

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.

Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.

Example

The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:

VBA Copy code Copy code
Forms!Employees!EmployeeID.SetFocus

See also

Concepts

Form Object

Other resources

Form Object Members


Form.VerticalDatasheetGridlineStyle Property (Access)

 Copy code hover
[image]

Form.VerticalDatasheetGridlineStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Byte indicating the line style to use for vertical gridlines on the specified datasheet. Read/write.

Syntax

expression .VerticalDatasheetGridlineStyle

expression A variable that represents a Form object.

Remarks

Valid values are between zero and seven. Values greater than seven are ignored; negative values or values above 255 cause an error.

Value | Description
0 | Transparent border
1 | Solid
2 | Dashes
3 | Short dashes
4 | Dots
5 | Sparse dots
6 | Dash-dot
7 | Dash-dot-dot

Example

This example sets the vertical gridline style on the first open form to dashes. The form must be set to Datasheet View in order for you to see the change.

VBA Copy code Copy code
Forms(0).VerticalDatasheetGridlineStyle = 2

See also

Concepts

Form Object

Other resources

Form Object Members


How to: Create a DAO Recordset From a Table In the Current Database

 Copy code hover
[image]

How to: Create a DAO Recordset From a Table In the Current Database
Send feedback

The following code example uses the OpenRecordset method to create a table-type Recordset object for a table in the current database.

VBA Copy code Copy code
Dim dbsNorthwind As DAO.Database
Dim rstCustomers As DAO.Recordset

Set dbsNorthwind = CurrentDb
Set rstCustomers = dbsNorthwind.OpenRecordset("Customers")


Properties Properties (DAO)

 Copy code hover
[image]

Properties Properties (DAO)
Send feedback

In this section

  • Properties.Count Property (DAO)


CommandButton.Default Property (Access)

 Copy code hover
[image]

CommandButton.Default Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Default property to specify whether a command button is the default button on a form. Read/write Boolean.

Syntax

expression .Default

expression A variable that represents a CommandButton object.

Remarks

The Default property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The command button is the default button.
No | False | (Default) The command button isn't the default button.

When the command button's Default property setting is Yes and the Form window is active, the user can choose the command button by pressing ENTER (if no other command button has the focus) as well as by clicking the command button.

Only one command button on a form can be the default button. When the Default property is set to Yes for one command button, it is automatically set to No for all other command buttons on the form.

For a form that supports irreversible operations, such as deletions, it's a good idea to make the Cancel button the default command button. To do this, set both the Default property and the Cancel property to Yes.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Attachment Object (Access)

 Copy code hover
[image]

Attachment Object (Access)
See also Send feedback

Published: July 16, 2012

This object corresponds to an attachment control. Use an attachment control when you want to manipulate the contents fields of the attachment data type.

Version Information

Version Added: Access 2007

Remarks

Note Note

You can attach files only to databases that you create in Office Access 2007 and that use the new .accdb file format. You cannot share attachments between a Office Access 2007 (.accdb) database and a database in the earlier (.mdb) file format.

You can attach a maximum of two gigabytes of data (the maximum size for an Access database). Individual files cannot exceed 256 megabytes in size.

Supported image file formats

Office Access 2007 supports the following graphic file formats natively, meaning the attachment control renders them without the need for additional software.

  • BMP (Windows Bitmap)

  • RLE (Run Length Encoded Bitmap)

  • DIB (Device Independent Bitmap)

  • GIF (Graphics Interchange Format)

  • JPEG, JPG, JPE (Joint Photographic Experts Group)

  • EXIF (Exchangeable File Format)

  • PNG (Portable Network Graphics)

  • TIFF, TIF (Tagged Image File Format)

  • ICON, ICO (Icon)

  • WMF (Windows Metafile)

  • EMF (Enhanced Metafile)

Supported formats for documents and other files

As a rule, you can attach any file that was created with one of the 2007 Microsoft Office system programs. You can also attach log files (.log), text files (.text, .txt), and compressed .zip files.

File-naming conventions

The names of your attached files can contain any Unicode character supported by the NTFS file system used in Microsoft Windows NT (NTFS). In addition, file names must conform to these guidelines:

  • Names must not exceed 255 characters, including the file name extensions.

  • Names cannot contain the following characters: question marks (?), quotation marks ("), forward or backward slashes (/ \), opening or closing brackets (< >), asterisks (*), vertical bars or pipes (|), colons (:), or paragraph marks (¶).

Types of files that Access compresses

Access will compress your attached files unless those files are compressed natively. For example, JPEG files are compressed by the graphics program that created them, so Access does not compress them. the following table lists some supported file types and whether or not Access compresses them.

File Extension | Compressed? | Reason
.jpg, .jpeg | No | Already compressed
.gif | No | Already compressed
.png | No | Already compressed
.tif, .tiff | Yes |
.exif | Yes |
.bmp | Yes |
.emf | Yes |
.wmf | Yes |
.ico | Yes |
.zip | No | Already compressed
.cab | No | Already compressed
.docx | No | Already compressed
.xlsx | No | Already compressed
.xlsb | No | Already compressed
.pptx | No | Already compressed

Blocked file formats

Office Access 2007 blocks the following types of attached files. At this time, you cannot unblock any of the file types listed here.

.ade | .ins | .mda | .scr
.adp | .isp | .mdb | .sct
.app | .its | .mde | .shb
.asp | .js | .mdt | .shs
.bas | .jse | .mdw | .tmp
.bat | .ksh | .mdz | .url
.cer | .lnk | .msc | .vb
.chm | .mad | .msi | .vbe
.cmd | .maf | .msp | .vbs
.com | .mag | .mst | .vsmacros
.cpl | .mam | .ops | .vss
.crt | .maq | .pcd | .vst
.csh | .mar | .pif | .vsw
.exe | .mas | .prf | .ws
.fxp | .mat | .prg | .wsc
.hlp | .mau | .pst | .wsf
.hta | .mav | .reg | .wsh
.inf | .maw | .scf |

See also

Concepts

Access Object Model Reference

Other resources

Attachment Object Members


ListBox.Locked Property (Access)

 Copy code hover
[image]

ListBox.Locked Property (Access)
See also Send feedback

Published: July 16, 2012

The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.

Syntax

expression .Locked

expression A variable that represents a ListBox object.

Remarks

The default setting of the Locked property is True. This setting allows editing, adding, and deleting data.

Use the Locked property to protect data in a field by making it read-only. For example, you might want a control to only display information without allowing editing, or you might want to lock a control until a specific condition is met.

Example

The following example toggles the Enabled property of a command button and the Enabled and Locked properties of a control, depending on the type of employee displayed in the current record. If the employee is a manager, then the SalaryDetails button is enabled and the PersonalInfo control is unlocked and enabled.

VBA Copy code Copy code
Sub Form_Current()
 If Me!EmployeeType = "Manager" Then
 Me!SalaryDetails.Enabled = True
 Me!PersonalInfo.Enabled = True
 Me!PersonalInfo.Locked = False
 Else
 Me!SalaryDetails.Enabled = False
 Me!PersonalInfo.Enabled = False
 Me!PersonalInfo.Locked = True
 End If
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Report.GridX Property (Access)

 Copy code hover
[image]

Report.GridX Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the GridX property (along with the GridY property) to specify the horizontal and vertical divisions of the alignment grid in report Design view. Read/write Integer.

Syntax

expression .GridX

expression A variable that represents a Report object.

Remarks

Enter an integer between 1 and 64 representing the number of subdivisions per unit of measurement. If the Measurement system box is set to U.S. on the Numbers tab of the Regional Options dialog box of Windows Control Panel, the default setting is 24 for the GridX property (horizontal) and 24 for the GridY property (vertical).

In Visual Basic, you set this property by using a numeric expression.

The GridX and GridY properties provide control over the placement and alignment of objects on a form or report. You can adjust the grid for greater or lesser precision. To see the grid, click Grid on the View menu. If the setting for either the GridX or GridY properties is greater than 24, the grid points disappear from view (although the grid lines are still displayed).

See also

Concepts

Report Object

Other resources

Report Object Members


Page.Section Property (Access)

 Copy code hover
[image]

Page.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Syntax

expression .Section

expression A variable that represents a Page object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

Page Object

Other resources

Page Object Members


OptionGroup.ColumnOrder Property (Access)

 Copy code hover
[image]

OptionGroup.ColumnOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.

Syntax

expression .ColumnOrder

expression A variable that represents an OptionGroup object.

Remarks

To set or change this property for a table or query by using Visual Basic, you must use a column's Properties collection. For details on using the Properties collection, see Properties .

Note Note

The ColumnOrder property isn't available in Design view.

The ColumnOrder property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

In Datasheet view, a field's ColumnOrder property setting is determined by the field's position. For example, the field in the leftmost column in Datasheet view has a ColumnOrder property setting of 1, the next field has a setting of 2, and so on. Changing a field's ColumnOrder property resets the property for that field and every field to the left of its original position in Datasheet view.

In other views, the property setting is 0 unless you explicitly change the order of one or more fields in Datasheet view (either by dragging the fields to new positions or by changing their ColumnOrder property settings). Fields to the right of the moved field's new position will have a property setting of 0 in views other than Datasheet view.

The order of the fields in Datasheet view doesn't affect the order of the fields in table Design view or Form view.

Example

The following example displays the ProductName and QuantityPerUnit fields in the first two columns in Datasheet view of the Products form.

VBA Copy code Copy code
Forms!Products!ProductName.ColumnOrder = 1
Forms!Products!QuantityPerUnit.ColumnOrder = 2

The next example displays the ProductName and QuantityPerUnit fields in the first two columns of the Products table in Datasheet view. To set the ColumnOrder property, the example uses the SetFieldProperty procedure. If this procedure is run while the table is open, changes will not be displayed until it is closed and reopened.

VBA Copy code Copy code
Public Sub SetColumnOrder()

 Dim dbs As DAO.Database
 Dim tdf As DAO.TableDef

 Set dbs = CurrentDb
 Set tdf = dbs!Products

 ' Call the procedure to set the ColumnOrder property.
 SetFieldProperty tdf!ProductName, "ColumnOrder", dbLong, 2
 SetFieldProperty tdf!QuantityPerUnit, "ColumnOrder", dbLong, 3

 Set tdf = Nothing
 Set dbs = Nothing

End Sub

Private Sub SetFieldProperty(ByRef fld As DAO.Field, _
 ByVal strPropertyName As String, _
 ByVal intPropertyType As Integer, _
 ByVal varPropertyValue As Variant)
 ' Set field property without producing nonrecoverable run-time error.

 Const conErrPropertyNotFound = 3270
 Dim prp As Property

 ' Turn off error handling.
 On Error Resume Next

 fld.Properties(strPropertyName) = varPropertyValue

 ' Check for errors in setting the property.
 If Err <> 0 Then
 If Err <> conErrPropertyNotFound Then
 On Error GoTo 0
 MsgBox "Couldn't set property '" & strPropertyName & _
 "' on field '" & fld.Name & "'", vbCritical
 Else
 On Error GoTo 0
 Set prp = fld.CreateProperty(strPropertyName, intPropertyType, _
 varPropertyValue)
 fld.Properties.Append prp
 End If
 End If

 Set prp = Nothing

End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


ComboBox.ColumnHeads Property (Access)

 Copy code hover
[image]

ComboBox.ColumnHeads Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnHeads property to display a single row of column headings for list boxes, combo boxes, and OLE objects that accept column headings. You can also use this property to create a label for each entry in a chart control . What is actually displayed as the first-row column heading depends on the object's RowSourceType property setting. Read/write Boolean.

Syntax

expression .ColumnHeads

expression A variable that represents a ComboBox object.

Remarks

The ColumnHeads property uses the following settings.

Setting | Visual Basic | Description
Yes | True | Column headings are enabled and either field captions, field names, or the first row of data items are used as column headings or chart labels.
No | False | (Default) Column headings are not enabled.

For table fields , you can set this property on the Lookup tab of the Field Properties section of table Design view for fields with the DisplayControl property set to Combo Box or List Box.

The RowSourceType property specifies whether field names or the first row of data items are used to create column headings. If the RowSourceType property is set to Table/Query, the field names are used as column headings. If the field has a caption, then the caption is displayed. For example, if a list box has three columns (the ColumnCount property is set to 3) and the RowSourceType property is set to Table/Query, the first three field names (or captions) are used as headings.

If the RowSourceType property is set to Value List, the first row of data items entered in the value list (as the setting of the RowSource property) will be column headings. For example, if a list box has three columns and the RowSourceType property is set to Value List, the first three items in the RowSource property setting are used as column headings.

If you can't select the first row of a list box or combo box in Form view, check to see if the ColumnHeads property is set to Yes.

Headings in combo boxes appear only when displaying the list in the control.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Syntax error in union query. (Error 3319)

 Copy code hover
[image]

Syntax error in union query. (Error 3319)
Send feedback

There is a syntax error in an SQL string of the union query.

Possible causes:

  • A reserved word or argument name is misspelled.

  • A reserved word or argument is missing.

  • Punctuation is incorrect.


BoundObjectFrame Object (Access)

 Copy code hover
[image]

BoundObjectFrame Object (Access)
See also Send feedback

Published: July 16, 2012

A bound object frame object displays a picture, chart, or any OLE object stored in a table in a Microsoft Access database. For example, if you store pictures of your employees in a table in Microsoft Access, you can use a bound object frame to display these pictures on a form or report.

Remarks

This object type allows you to create or edit the object from within the form or report by using the OLE server.

A bound object frame is bound to a field in an underlying table.

The field in the underlying table to which the bound object frame is bound must be of the OLE Object data type.

The object in a bound object frame is different for each record. The bound object frame can display linked or embedded objects. If you want to display objects not stored in an underlying table, use an unbound object frame or an image control.

See also

Concepts

Access Object Model Reference

Other resources

BoundObjectFrame Object Members


TabControl.DisplayWhen Property (Access)

 Copy code hover
[image]

TabControl.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Syntax

expression .DisplayWhen

expression A variable that represents a TabControl object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


StreamWriteEnum

 Copy code hover
[image]

StreamWriteEnum
Send feedback

Specifies whether a line separator is appended to the string written to a Stream object.

Constant | Value | Description
adWriteChar | 0 | Default. Writes the specified text string (specified by the Data parameter) to the Stream object.
adWriteLine | 1 | Writes a text string and a line separator character to a Stream object. If the LineSeparator property is not defined, then this returns a run-time error.

ADO/WFC Equivalent

These constants do not have ADO/WFC equivalents.


Label.BackColor Property (Access)

 Copy code hover
[image]

Label.BackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the interior color of the specified object. Read/write Long.

Syntax

expression .BackColor

expression A variable that represents a Label object.

Remarks

The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

To use the BackColor property, the BackStyle property, if available, must be set to Normal.

Example

The following example uses the RGB function to set the , BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

Label Object

Other resources

Label Object Members


Record is too large. (Error 3047)

 Copy code hover
[image]

Record is too large. (Error 3047)
Send feedback

You defined or imported a table with records larger than 4K. This error occurs when you enter data into the record — not when you define the table structure. Redefine the table by making some fields shorter, removing unneeded fields, or moving some fields to other tables.


EmptyCell.TopPadding Property (Access)

 Copy code hover
[image]

EmptyCell.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .TopPadding

expression A variable that represents an EmptyCell object.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


How to: Add a Record to a DAO Recordset

 Copy code hover
[image]

How to: Add a Record to a DAO Recordset
Send feedback

You can add a new record to a table-type or dynaset-type Recordset object by using the AddNew method.

To add a record to a table-type or dynaset-type Recordset object:

  1. Use the AddNew method to create a record you can edit.

  2. Assign values to each of the record's fields.

  3. Use the Update method to save the new record.

The following code example adds a record to a table-type Recordset called Shippers.

VBA Copy code Copy code
Dim dbsNorthwind As DAO.Database
Dim rstShippers As DAO.Recordset

   Set dbsNorthwind = CurrentDb
   Set rstShippers = dbsNorthwind.OpenRecordset("Shippers")

   rstShippers.AddNew
   rstShippers!CompanyName = "Global Parcel Service"
      .
      . ' Set remaining fields.
      .

   rstShippers.Update

When you use the AddNew method, the Microsoft Access database engine prepares a new, blank record and makes it the current record. When you use the Update method to save the new record, the record that was current before you used the AddNew method becomes the current record again.

The new record's position in the Recordset depends on whether you added the record to a dynaset-type or a table-type Recordset object. If you add a record to a dynaset-type Recordset, the new record appears at the end of the Recordset, no matter how the Recordset is sorted. To force the new record to appear in its properly sorted position, you can either use the Requery method or recreate the Recordset object.

If you add a record to a table-type Recordset, the record appears positioned according to the current index, or at the end of the table if there is no current index. Because the Access databse engine allows multiple users to create records in a table simultaneously, your record may not appear at the end of the Recordset. Be sure to use the LastModified property rather than the MoveLast method to move to the record you just added.

Note Note

If you use the AddNew method to add a record, and then move to another record or close the Recordset object without first using the Update method, your changes are lost without warning. For example, omitting the Update method from the preceding example results in no changes being made to the Shippers table.


TextBox.EnterKeyBehavior Property (Access)

 Copy code hover
[image]

TextBox.EnterKeyBehavior Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the EnterKeyBehavior property to specify what happens when you press ENTER in a text box control in Form view or Datasheet view. Read/write Boolean.

Syntax

expression .EnterKeyBehavior

expression A variable that represents a TextBox object.

Remarks

For example, you can use this property if you have a control bound to a Memo field in a table to make entering multiple-line text easier. If you don't set this property to New Line In Field, you must press CTRL+ENTER to enter a new line in the text box.

You can also set the default for this property by setting a control's DefaultControl property in Visual Basic.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


The

 Copy code hover
[image]

The <name> query cannot be used in a CHECK constraint clause. (Error 3801)
Send feedback

This error occurs when using the CREATE TABLE or ALTER TABLE ALTER COLUMN syntax and using the CHECK constraint clause. The error occurs when a CHECK constraint attempts to reference an attached/linked table or a view/procedure/stored query.


Reference.Name Property (Access)

 Copy code hover
[image]

Reference.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.

Syntax

expression .Name

expression A variable that represents a Reference object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

Reference Object

Other resources

Reference Object Members


ComboBox.BoundColumn Property (Access)

 Copy code hover
[image]

ComboBox.BoundColumn Property (Access)
See also Send feedback

Published: July 16, 2012

When you make a selection from a combo box, the BoundColumn property tells Microsoft Access which column's values to use as the value of the control. If the control is bound to a field, the value in the column specified by the BoundColumn property is stored in the field named in the ControlSource property. Read/write Long.

Syntax

expression .BoundColumn

expression A variable that represents a ComboBox object.

Remarks

The BoundColumn property uses the following settings.

Setting | Description
0 | The ListIndex property value, rather than the column value, is stored in the current record. The ListIndex property value of the first row is 0, the second row is 1, and so on. Microsoft Access sets the ListIndex property when an item is selected from a list box or the list box portion of a combo box. Setting the BoundColumn property to 0 and using the ListIndex property value of the control might be useful if, for example, you are only interested in storing a sequence of numbers.
1 or greater | (Default is 1) The value in the specified column becomes the control's value. If the control is bound to a field, then this setting is stored in that field in the current record. The BoundColumn property can't be set to a value larger than the setting of the ColumnCount property.

For table fields , you can set this property on the Lookup tab in the Field Properties section of table Design view for fields with the DisplayControl property set to Combo Box or List Box.

In Visual Basic, set the BoundColumn property by using a number or a numeric expression equal to a value from 0 to the setting of the ColumnCount property.

The leftmost visible column in a combo box (the leftmost column whose setting in the combo box's ColumnWidths property is not 0) contains the data that appears in the text box part of the combo box in Form view or in a report. The BoundColumn property determines which column's value in the text box or combo box list will be stored when you make a selection. This allows you to display different data than you store as the value of the control.

Note Note

If the bound column is not the same as the leftmost visible column in the control (or if you set the BoundColumn property to 0), the LimitToList property is set to Yes.

Microsoft Access uses zero-based numbers to refer to columns in the Column property. That is, the first column is referenced by using the expression Column(0); the second column is referenced by using the expression Column(1); and so on. However, the BoundColumn property uses 1-based numbers to refer to the columns. This means that if the BoundColumn property is set to 1, you could access the value stored in that column by using the expression Column(0).

If the AutoExpand property is set to Yes, Microsoft Access automatically fills in a value in the text box portion of the combo box that matches a value in the combo box list as you type.

Example

The following example show how to create a combo box that is bound to one column while displaying another. Setting the ColumnCount property to 2 specifies that the cboDept combo box will display the first two columns of the data source specified by the RowSource property. Setting the BoundColumn property to 1 specifies that the value stored in the first column will be returned when you inspect the value of the combo box.

The ColumnWidths property specifies the width of the two columns. By setting the width of the first column to 0in., the first column is not displayed in the combo box.

Sample code provided by: MVP Contributor Bill Jelen, MrExcel.com | About the Contributors

Copy code Copy code
Private Sub cboDept_Enter()
    With cboDept
        .RowSource = "SELECT * FROM tblDepartments ORDER BY Department"
        .ColumnCount = 2
        .BoundColumn = 1
        .ColumnWidths = "0in.;1in."
    End With
End Sub

About the Contributors

Holy Macro! Books publishes entertaining books for people who use Microsoft Office. See the complete catalog at MrExcel.com.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


NavigationButton.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

NavigationButton.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthBottom

expression A variable that represents a NavigationButton object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Recordset.Fields Property (DAO)

 Copy code hover
[image]

Recordset.Fields Property (DAO)
Send feedback

Returns a Fields collection that represents all stored Field objects for the specified object. Read-only.

Syntax

expression .Fields

expression A variable that represents a Recordset object.


Section.Name Property (Access)

 Copy code hover
[image]

Section.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a Section object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

Section Object

Other resources

Section Object Members


Image.HyperlinkSubAddress Property (Access)

 Copy code hover
[image]

Image.HyperlinkSubAddress Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the HyperlinkSubAddress property to specify or determine a location within the target document specified by the HyperlinkAddress property. Read/write String.

Syntax

expression .HyperlinkSubAddress

expression A variable that represents an Image object.

Remarks

The HyperlinkSubAddress property can be an object within a Microsoft Access database, a bookmark within a Microsoft Word document, a named range within a Microsoft Excel spreadsheet, a slide within a Microsoft PowerPoint presentation, or a location within an HTML document.

The HyperlinkSubAddress property is a string expression representing a named location within the target document specified by the HyperlinkAddress property.

Note Note

When you create a hyperlink by using the Insert Hyperlink dialog box, Microsoft Access automatically sets the HyperlinkAddress property and HyperlinkSubAddress to the location specified in the Type the file or Web page name box. The HyperlinkSubAddress property can also be set to the location specified in the Select an object in this database box.

If you copy a hyperlink from another application and paste it into a form or report, Microsoft Access creates a label control with its Caption property, HyperlinkAddress property, and HyperlinkSubAddress property automatically set.

When you move the cursor over a command button, image control, or label control whose HyperlinkAddress property is set, the cursor changes to an upward-pointing hand. Clicking the control displays the object or Web page specified by the link.

To open objects in the current database, leave the HyperlinkAddress property blank and specify the object type and object name you want to open in the HyperlinkSubAddress property by using the syntax "objecttype objectname". If you want to open an object contained in another Microsoft Access database, enter the database path and file name in the HyperlinkAddress property and specify the database object to open by using the HyperlinkSubAddress property.

The HyperlinkAddress property can contain an absolute or a relative path to a target document. An absolute path is a fully qualified URL or UNC path to a document. A relative path is a path related to the base path specified in the Hyperlink Base setting in the Properties dialog box (available by clicking Database Properties on the File menu) or to the current database path. If Microsoft Access can't resolve the HyperlinkAddress property setting to a valid URL or UNC path, it will assume you've specified a path relative to the base path contained in the Hyperlink Base setting or the current database path.

Note Note

When you follow a hyperlink to another Microsoft Access database object, the database Startup properties are applied. For example, if the destination database has a Display form set, that form is displayed when the database opens.

The following table contains examples of HyperlinkAddress and HyperlinkSubAddress property settings.

HyperlinkAddress | HyperlinkSubAddress | Description
http://www.microsoft.com/ |  | The Microsoft home page on the Web.
C:\Program Files\Microsoft Office\Office\Samples\Cajun.htm |  | The Cajun Delights page in the Access sample applications subdirectory.
C:\Program Files\Microsoft Office\Office\Samples\Cajun.htm | NewProducts | The "NewProducts" Name tag in the Cajun Delights page.
C:\Personal\MyResume.doc | References | The bookmark named "References" in the Microsoft Word document "MyResume.doc".
C:\Finance\First Quarter.xls | Sheet1!TotalSales | The range named "TotalSales" in the Microsoft Excel spreadsheet "First Quarter.xls".
C:\Presentation\NewPlans.ppt | 10 | The 10th slide in the Microsoft PowerPoint document "NewPlans.ppt".

See also

Concepts

Image Object

Other resources

Image Object Members


ToggleButton.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

ToggleButton.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Syntax

expression .ShortcutMenuBar

expression A variable that represents a ToggleButton object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

Example

The following example sets the "Suppliers_Toolbar" as the custom shortcut menu to display when the user clicks the right mouse button on the "Suppliers" form.

VBA Copy code Copy code
Forms("Suppliers").ShortcutMenuBar = "Suppliers_Toolbar"

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


CommandButton.BorderStyle Property (Access)

 Copy code hover
[image]

CommandButton.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .BorderStyle

expression A variable that represents a CommandButton object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


NavigationButton.Picture Property (Access)

 Copy code hover
[image]

NavigationButton.Picture Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Picture property to specify a bitmap or other type of graphic to be displayed on the specified control. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .Picture

expression A variable that represents a NavigationButton object.

Remarks

The Picture property contains (bitmap) or the path and file name of a bitmap or other type of graphic to be displayed.

The default setting is (none). After the graphic is loaded into the object, the property setting is (bitmap) or the path and file name of the graphic. If you delete (bitmap) or the path and file name of the graphic from the property setting, the picture is deleted from the object and the property setting is again (none).

If the PictureType property is set to Embedded, the graphic is stored with the object.

You can create custom bitmaps by using Microsoft Paintbrush or another application that creates bitmap files. A bitmap file must have a .bmp, .ico, or .dib extension. You can also use graphics files in the .wmf or .emf formats, or any other graphic file type for which you have a graphics filter. Forms, reports, and image controls support all graphics. Command buttons and toggle buttons only support bitmaps.

Buttons can display either a caption or a picture. If you assign both to a button, the picture will be visible, the caption won't. If the picture is deleted, the caption reappears. Microsoft Access displays the picture centered on the button and clipped if the picture is larger than the button.

To create a command button or toggle button with a caption and a picture, you could include the desired caption as part of the bitmap and assign the bitmap to the Picture property of the control.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


How to: Calculate and Display Specific Date Values

 Copy code hover
[image]

How to: Calculate and Display Specific Date Values
Send feedback

Because a Date value is stored as a double-precision number, you may receive incorrect formatting results when you try to manipulate Date values in an expression. This topic illustrates how to create expressions and custom functions for displaying specific dates and calculating time intervals.

Displaying Specific Dates

The current month:

VBA Copy code Copy code
DateSerial(Year(Date()), Month(Date()), 1)

The next month:

VBA Copy code Copy code
DateSerial(Year(Date()), Month(Date()) + 1, 1)

The last day of the current month:

VBA Copy code Copy code
DateSerial(Year(Date()), Month(Date()) + 1, 0)

The last day of the next month:

VBA Copy code Copy code
DateSerial(Year(Date()), Month(Date()) + 2, 0)

The first day of the previous month:

VBA Copy code Copy code
DateSerial(Year(Date()), Month(Date())-1,1)

The last day of the previous month:

VBA Copy code Copy code
DateSerial(Year(Date()), Month(Date()),0)

The first day of the current quarter:

VBA Copy code Copy code
DateSerial(Year(Date()), Int((Month(Date()) - 1) / 3) * 3 + 1, 1)

The last day of the current quarter:

VBA Copy code Copy code
DateSerial(Year(Date()), Int((Month(Date()) - 1) / 3) * 3 + 4, 0)

The first day of the current week (assuming Sunday = day 1):

VBA Copy code Copy code
Date() - WeekDay(Date()) + 1

The last day of the current week:

VBA Copy code Copy code
Date() - WeekDay(Date()) + 7


ToggleButton.Click Event (Access)

 Copy code hover
[image]

ToggleButton.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Syntax

expression .Click

expression A variable that represents a ToggleButton object.

Remarks

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Form.HasModule Property (Access)

 Copy code hover
[image]

Form.HasModule Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the HasModule property to specify or determine whether a form or report has a class module. Read/write Boolean.

Syntax

expression .HasModule

expression A variable that represents a Form object.

Remarks

The HasModule property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The form or report has a class module.
No | False | (Default) The form or report doesn't have a class module.

Setting this property to False can improve the performance and decrease the size of your database.

The HasModule property can be set only in form or report Design view but can be read in any view.

Forms or reports that have the HasModule property set to No are considered lightweight objects. Lightweight objects are smaller and typically load and display faster than objects with associated class modules. In many cases, a form or report doesn't need to use event procedures and doesn't require a class module.

If your application uses a switchboard form to navigate to other forms, instead of using command buttons with event procedures, you can use a command button with a macro or hyperlink. For example, to open the Employees form from a command button on a switchboard, you can set the control's HyperlinkSubAddress property to "Form Employees".

Lightweight objects don't appear in the Object Browser and you can't use the New keyword to create a new instance of the object. A lightweight form or report can be used as a subform or subreport and will appear in the Forms or Reports collection. Lightweight objects support the use of macros, and public procedures that exist in standard modules when called from the object's property sheet.

Microsoft Access sets the HasModule property to True as soon as you attempt to view an object's module, even if no code is actually added to the module. For example, selecting Code from the View menu for a form in Design view causes Microsoft Access to add a class module to the Form object and set its HasModule property to True. You can add a class module to an object in the same way by setting the HasModule property to Yes in an object's property sheet.

If you set the HasModule property to No by using an object's property sheet or set it to False by using Visual Basic, Microsoft Access deletes the object's class module and any code it may contain.

When you use a method of the Module object or refer to the Module property for a form or report in Design view, Microsoft Access creates the associated module and sets the object's HasModule property to True. If you refer to the Module property of a form or report at run-time and the object has its HasModule property set to False, an error will occur.

Objects created by using the CreateForm or CreateReport methods are lightweight by default.

See also

Concepts

Form Object

Other resources

Form Object Members


Open Method (ADO Record)

 Copy code hover
[image]

Open Method (ADO Record)
Send feedback

Opens an existing Record object, or creates a new item represented by the Record (such as a file or directory).

Syntax

Open Source, ActiveConnection, Mode, CreateOptions, Options, UserName, Password

Parameters

  • Source

  • Optional. A Variant that may represent the URL of the entity to be represented by this Record object, a Command, an open Recordset or another Record object, a string containing a SQL SELECT statement or a table name.

  • ActiveConnection

  • Optional. A Variant that represents the connect string or open Connection object.

  • Mode

  • Optional. A ConnectModeEnum value, whose default value is adModeUnknown, that specifies the access mode for the resultant Record object.

  • CreateOptions

  • Optional. A RecordCreateOptionsEnum value, whose default value is adFailIfNotExists, that specifies whether an existing file or directory should be opened, or a new file or directory should be created. If set to the default value, the access mode is obtained from the Mode property. This parameter is ignored when the Source parameter doesnt contain a URL.

  • Options

  • Optional. A RecordOpenOptionsEnum value, whose default value is adOpenRecordUnspecified, that specifies options for opening the Record. These values may be combined.

  • UserName

  • Optional. A String value that contains the user ID that, if needed, authorizes access to Source.

  • Password

  • Optional. A String value that contains the password that, if needed, verifies UserName.

Remarks

Source may be:

  • A URL. If the protocol for the URL is http, then the Internet Provider will be invoked by default. If the URL points to a node that contains an executable script (such as an .ASP page), then a Record containing the source rather than the executed contents is opened by default. Use the Options argument to modify this behavior.

  • A Record object. A Record object opened from another Record will clone the original Record object.

  • A Command object. The opened Record object represents the single row returned by executing the Command. If the results contain more than a single row, the contents of the first row are placed in the record and an error may be added to the Errors collection.

  • A SQL SELECT statement. The opened Record object represents the single row returned by executing the contents of the string. If the results contain more than a single row, the contents of the first row are placed in the record and an error may be added to the Errors collection.

  • A table name.

If the Record object represents an entity that cannot be accessed with a URL (for example, a row of a Recordset derived from a database), then the values of both the ParentURL property and the field accessed with the adRecordURL constant are null.

Note Note

URLs using the http scheme will automatically invoke the Microsoft OLE DB Provider for Internet Publishing. For more information, see Absolute and Relative URLs.


CloseWindow Macro Action

 Copy code hover
[image]

CloseWindow Macro Action
Send feedback

You can use the CloseWindow action to close either a specified Microsoft Access 2013 document tab or the active document tab if none is specified.

Setting

The CloseWindow action has the following arguments.

Action argument

Description

Object Type

The type of object whose document tab you want to close. Click Table, Query, Form, Report, Macro, Module, Data Access Page, Server View, Diagram, Stored Procedure, or Function in the Object Type box in the Action Arguments section of the Macro Builder pane. To select the active document tab, leave this argument blank.

Note Note

If you are closing a module in the Visual Basic Editor, you must use Module in the Object Type argument.

Object Name

The name of the object to be closed. The Object Name box shows all objects in the database of the type selected by the Object Type argument. Click the object to close. If you leave the Object Type argument blank, leave this argument blank also.

Save

Whether to save changes to the object when it is closed. Click Yes (save the object), No (close the object without saving it), or Prompt (prompt the user whether or not to save the object). The default is Prompt.

Remarks

The CloseWindow action works on all database objects that the user can explicitly open or close. This action has the same effect as selecting an object and then closing it by right-clicking the object's document tab and then clicking Close on the shortcut menu, or clicking the Close button for the object.

If the Save argument is set to Prompt and the object hasn't already been saved before the CloseWindow action is carried out, a dialog box prompts the user to save the object before the macro closes it. If you have set the Warnings On argument of the SetWarnings action to No, the dialog box is not displayed and the object is automatically saved.

To run the CloseWindow action in a Visual Basic for Applications (VBA) module, use the CloseWindow method of the DoCmd object.


Not enough space on temporary disk. (Error 3183)

 Copy code hover
[image]

Not enough space on temporary disk. (Error 3183)
Send feedback

You tried to perform an operation that requires more space than is available on the temporary disk. Your temporary disk location is based on the TEMP DOS environment variable, which was set when your system started.

For example, you may be trying to create a query that creates temporary files larger than the temporary disk. Reduce the size of the temporary files by accessing smaller amounts of data at one time or increase the size of the temporary disk.

You can increase the amount of available temporary disk space in several ways:

  • Select fewer records. Dynaset-type, forward-only — type, and snapshot-type Recordset objects record keys and data to the temporary disk.

  • Select a different drive for your temporary disk.

  • If the temporary disk is a RAM disk, increase the amount of available RAM and the space allocated to the RAM disk, or move it to a fixed disk.

  • Free some space by deleting data or by removing unneeded tables, queries, forms, macros, and modules from your database.

  • Free some space by compressing deleted records out of your database.

  • If you still need additional space, consider removing other unused files from your disk.


LevelDepth Property (ADO MD)

 Copy code hover
[image]

LevelDepth Property (ADO MD)
Send feedback

Indicates the number of levels between the root of the hierarchy and a member.

Return Values

Returns a Long integer, and is read-only.

Remarks

Use the LevelDepth property to determine the distance of the Member object from the root level of the hierarchy. The LevelDepth of a member at the root level is 0. This corresponds to the Depth property of a Level object.


Using ADO with Microsoft Visual C++ Topics

 Copy code hover
[image]

Using ADO with Microsoft Visual C++ Topics
Send feedback

In this section

  • Using ADO with Microsoft Visual C++

  • Visual C++ ADO Programming

  • Visual C++ Extensions for ADO

  • Using Visual C++ Extensions

  • Visual C++ Extensions Header

  • Visual C++ Extensions Example


DeleteRecord Method (ADO)

 Copy code hover
[image]

DeleteRecord Method (ADO)
Send feedback

Deletes a the entity represented by a Record.

Syntax

Record.DeleteRecord Source, Async

Parameters

  • Source

  • Optional. A String value that contains a URL identifying the entity (for example, the file or directory) to be deleted. If Source is omitted or specifies an empty string, the entity represented by the current Record is deleted. If the Record is a collection record (RecordType of adCollectionRecord, such as a directory) all children (for example, subdirectories) will also be deleted.

  • Async

  • Optional. A Boolean value that, when True, specifies that the delete operation is asynchronous.

Remarks

Operations on the object represented by this Record may fail after this method completes. After calling DeleteRecord, the Record should be closed because the behavior of the Record may become unpredictable depending upon when the provider updates the Record with the data source.

If this Record was obtained from a Recordset, then the results of this operation will not be reflected immediately in the Recordset. Refresh the Recordset by closing and re-opening it, or by executing the Recordset Requery, or Update and Resync methods.

Note Note

URLs using the http scheme will automatically invoke the Microsoft OLE DB Provider for Internet Publishing. For more information, see Absolute and Relative URLs.


OptionGroup.BorderTint Property (Access)

 Copy code hover
[image]

OptionGroup.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderTint

expression A variable that represents an OptionGroup object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens BorderColor by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Recordset.LockEdits Property (DAO)

 Copy code hover
[image]

Recordset.LockEdits Property (DAO)
Send feedback

Sets or returns a value indicating the type of locking that is in effect while editing.

Syntax

expression .LockEdits

expression A variable that represents a Recordset object.

Remarks

The setting or return value indicates the type of locking, as specified in the following table.

Value | Description
True | Default. Pessimistic locking is in effect. The page containing the record you're editing is locked as soon as you call the Edit method.
False | Optimistic locking is in effect for editing. The page containing the record is not locked until the Update method is executed.

You can use the LockEdits property with updatable Recordset objects.

If a page is locked, no other user can edit records on the same page. If you set LockEdits to True and another user already has the page locked, an error occurs when you use the Edit method. Other users can read data from locked pages.

If you set the LockEdits property to False and later use the Update method while another user has the page locked, an error occurs. To see the changes made to your record by another user, use the Move method with 0 as the argument; however, if you do this, you will lose your changes.

When working with Microsoft Access database engine-connected ODBC data sources, the LockEdits property is always set to False, or optimistic locking. The Microsoft Access database engine has no control over the locking mechanisms used in external database servers.

Note Note

You can preset the value of LockEdits when you first open the Recordset by setting the lockedits argument of the OpenRecordset method. Setting the lockedits argument to dbPessimistic will set the LockEdits property to True, and setting lockedits to any other value will set the LockEdits property to False.

Example

This example demonstrates pessimistic locking by setting the LockEdits property to True, and then demonstrates optimistic locking by setting the LockEdits property to False. It also demonstrates what kind of error handling is required in a multiuser database environment in order to modify a field. The PessimisticLock and OptimisticLock functions are required for this procedure to run.

VBA Copy code Copy code
Sub LockEditsX()

 Dim dbsNorthwind As Database
 Dim rstCustomers As Recordset
 Dim strOldName As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstCustomers = _
 dbsNorthwind.OpenRecordset("Customers", _
 dbOpenDynaset)

 With rstCustomers
 ' Store original data.
 strOldName = !CompanyName

 If MsgBox("Pessimistic locking demonstration...", _
 vbOKCancel) = vbOK Then

 ' Attempt to modify data with pessimistic locking
 ' in effect.
 If PessimisticLock(rstCustomers, !CompanyName, _
 "Acme Foods") Then
 MsgBox "Record successfully edited."

 ' Restore original data...
 .Edit
 !CompanyName = strOldName
 .Update
 End If

 End If

 If MsgBox("Optimistic locking demonstration...", _
 vbOKCancel) = vbOK Then

 ' Attempt to modify data with optimistic locking
 ' in effect.
 If OptimisticLock(rstCustomers, !CompanyName, _
 "Acme Foods") Then
 MsgBox "Record successfully edited."

 ' Restore original data...
 .Edit
 !CompanyName = strOldName
 .Update
 End If

 End If

 .Close
 End With

 dbsNorthwind.Close

End Sub

Function PessimisticLock(rstTemp As Recordset, _
 fldTemp As Field, strNew As String) As Boolean

 dim ErrLoop as Error

 PessimisticLock = True

 With rstTemp
 .LockEdits = True

 ' When you set LockEdits to True, you trap for errors
 ' when you call the Edit method.
 On Error GoTo Err_Lock
 .Edit
 On Error GoTo 0

 ' If the Edit is still in progress, then no errors
 ' were triggered; you may modify the data.
 If .EditMode = dbEditInProgress Then
 fldTemp = strNew
 .Update
 .Bookmark = .LastModified
 Else
 ' Retrieve current record to see changes made by
 ' other user.
 .Move 0
 End If

 End With

 Exit Function

Err_Lock:

 If DBEngine.Errors.Count > 0 Then
 ' Enumerate the Errors collection.
 For Each errLoop In DBEngine.Errors
 MsgBox "Error number: " & errLoop.Number & _
 vbCr & errLoop.Description
 Next errLoop
 PessimisticLock = False
 End If

 Resume Next

End Function

Function OptimisticLock(rstTemp As Recordset, _
 fldTemp As Field, strNew As String) As Boolean

 dim ErrLoop as Error

 OptimisticLock = True

 With rstTemp
 .LockEdits = False
 .Edit
 fldTemp = strNew

 ' When you set LockEdits to False, you trap for errors
 ' when you call the Update method.
 On Error GoTo Err_Lock
 .Update
 On Error GoTo 0

 ' If there is no Edit in progress, then no errors were
 ' triggered; you may modify the data.
 If .EditMode = dbEditNone Then
 ' Move current record pointer to the most recently
 ' modified record.
 .Bookmark = .LastModified
 Else
 .CancelUpdate
 ' Retrieve current record to see changes made by
 ' other user.
 .Move 0
 End If

 End With

 Exit Function

Err_Lock:

 If DBEngine.Errors.Count > 0 Then
 ' Enumerate the Errors collection.
 For Each errLoop In DBEngine.Errors
 MsgBox "Error number: " & errLoop.Number & _
 vbCr & errLoop.Description
 Next errLoop
 OptimisticLock = False
 End If

 Resume Next

End Function


Provider and DefaultDatabase Properties Example (VJ++)

 Copy code hover
[image]

Provider and DefaultDatabase Properties Example (VJ++)
Send feedback

This example demonstrates the Provider property by opening three Connection objects using different providers. It also uses the DefaultDatabase property to set the default database for the Microsoft ODBC Provider.

Copy code Copy code

// BeginProviderJ
import java.io.*;
import com.ms.wfc.data.*;

public class ProviderX
{
 // The main entry point of the application.
 public static void main (String[] args)
 {
 ProviderX();
 System.exit(0);
 }
 // ProviderX Function
 static void ProviderX()
 {
 // Define ADO Objects.
 Connection cnn1 = null;
 Connection cnn2 = null;
 Connection cnn3 = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));
 try
 {
 // Open a connection using the Microsoft ODBC Provider.
 cnn1 = new Connection();
 cnn1.setConnectionString("driver={SQL Server};"+
 "server='MySqlServer';User ID='MyUserID';Password='MyPassword';");
 cnn1.open();
 cnn1.setDefaultDatabase("Pubs");

 // Display the provider.
 System.out.println("\n\n\tCnn1 provider: "+ cnn1.getProvider());

 // Open connection using the OLE DB Provider for Microsoft Jet.
 cnn2 = new Connection();
 cnn2.setProvider("Microsoft.Jet.OLEDB.4.0");
 cnn2.open("C:\\Program Files\\Microsoft Office\\Office\\Samples\\Northwind.mdb","admin","");

 // Display the provider.
 System.out.println("\n\n\tCnn2 provider: " +
 cnn2.getProvider());

 // Open a connection using the Microsoft SQL Server Provider.
 cnn3 = new Connection();
 cnn3.setProvider("sqloledb");
 cnn3.open("Data Source='MySqlServer';Initial Catalog='Pubs';Integrated Security='SSPI';","","");

 // Display the provider.
 System.out.println("\n\n\tCnn3 provider: " +
 cnn3.getProvider());

 System.out.println("\n\n\tPress <Enter> to continue..");
 in.readLine();
 }
 catch(AdoException ae)
 {
 // Notify the user of any errors that result from ADO.

 // As passing a Connection, check for null pointer first.
 if(cnn1 != null)
 {
 PrintProviderError(cnn1);
 }
 else
 {
 System.out.println("Exception: " + ae.getLocalizedMessage());
 }
 }
 // System read requires needs this catch.
 catch(java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (cnn1 != null)
 if (cnn1.getState() == 1)
 cnn1.close();
 if (cnn2 != null)
 if (cnn2.getState() == 1)
 cnn2.close();
 if (cnn3 != null)
 if (cnn3.getState() == 1)
 cnn3.close();
 }
 }
 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndProviderJ


Form.DblClick Event (Access)

 Copy code hover
[image]

Form.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Syntax

expression .DblClick(Cancel)

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the DblClick event occurs. Setting the Cancel argument to True (-1) cancels the DblClick event.

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Rectangle.BorderStyle Property (Access)

 Copy code hover
[image]

Rectangle.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Syntax

expression .BorderStyle

expression A variable that represents a Rectangle object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


Report.Top Property (Access)

 Copy code hover
[image]

Report.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Long. .

Syntax

expression .Top

expression A variable that represents a Report object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

For reports, the Top property setting is the amount the current section is offset from the top of the page. This property setting is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Top property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False. The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)
Const conTopMargin = 1880
' Don't advance to next record or print next section
' if Top property setting is less than 1880 twips.
 If Me.Top < conTopMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


You cannot replicate a password-protected database or set password protection on a replicated database. (Error 3592)

 Copy code hover
[image]

You cannot replicate a password-protected database or set password protection on a replicated database. (Error 3592)
Send feedback

If a database password is set on the database, remove the password.


AddNew Method (ADO)

 Copy code hover
[image]

AddNew Method (ADO)
Send feedback

Creates a new record for an updatable Recordset object.

Syntax

recordset.AddNew FieldList, Values

Parameters

  • recordset

  • A Recordset object.

  • FieldList

  • Optional. A single name, or an array of names or ordinal positions of the fields in the new record.

  • Values

  • Optional. A single value, or an array of values for the fields in the new record. If Fieldlist is an array, Values must also be an array with the same number of members; otherwise, an error occurs. The order of field names must match the order of field values in each array.

Remarks

Use the AddNew method to create and initialize a new record. Use the Supports method with adAddNew (a CursorOptionEnum value) to verify whether you can add records to the current Recordset object.

After you call the AddNew method, the new record becomes the current record and remains current after you call the Update method. Since the new record is appended to the Recordset, a call to MoveNext following the Update will move past the end of the Recordset, making EOF True. If the Recordset object does not support bookmarks, you may not be able to access the new record once you move to another record. Depending on your cursor type, you may need to call the Requery method to make the new record accessible.

If you call AddNew while editing the current record or while adding a new record, ADO calls the Update method to save any changes and then creates the new record.

The behavior of the AddNew method depends on the updating mode of the Recordset object and whether you pass the Fieldlist and Values arguments.

In immediate update mode (in which the provider writes changes to the underlying data source once you call the Update method), calling the AddNew method without arguments sets the EditMode property to adEditAdd (an EditModeEnum value). The provider caches any field value changes locally. Calling the Update method posts the new record to the database and resets the EditMode property to adEditNone (an EditModeEnum value). If you pass the Fieldlist and Values arguments, ADO immediately posts the new record to the database (no Update call is necessary); the EditMode property value does not change (adEditNone).

In batch update mode (in which the provider caches multiple changes and writes them to the underlying data source only when you call the UpdateBatch method), calling the AddNew method without arguments sets the EditMode property to adEditAdd. The provider caches any field value changes locally. Calling the Update method adds the new record to the current Recordset and resets the EditMode property to adEditNone, but the provider does not post the changes to the underlying database until you call the UpdateBatch method. If you pass the Fieldlist and Values arguments, ADO sends the new record to the provider for storage in a cache; you need to call the UpdateBatch method to post the new record to the underlying database.


Cannot open library database

 Copy code hover
[image]

Cannot open library database <name>. (Error 3007)
Send feedback

The specified database is an internal Microsoft Access database engine library database, which you cannot open.


Form.Recordset Property (Access)

 Copy code hover
[image]

Form.Recordset Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets the ADO Recordset or DAO Recordset object representing the record source for the specified object. Read/write Object.

Syntax

expression .Recordset

expression A variable that represents a Form object.

Remarks

The Recordset property returns the recordset object that provides the data being browsed in a form, report, list box control, or combo box control. If a form is based on a query, for example, referring to the Recordset property is the equivalent of cloning a Recordset object by using the same query. However, unlike using the RecordsetClone property, changing which record is current in the recordset returned by the form's Recordset property also sets the current record of the form.

The read/write behavior of the Recordset property is determined by the type of recordset (ADO or DAO) and the type of data (Access or SQL) contained in the recordset identified by the property.

Recordset type | Based on SQL data | Based on data stored by the Access database engine
ADO | Read/Write | Read/Write
DAO | N/A | Read/Write

The following example opens a form, opens a recordset, and then binds the form to the recordset by setting the form's Recordset property to the newly created Recordset object.

VBA Copy code Copy code
Global rstSuppliers As ADODB.Recordset
Sub MakeRW()
    DoCmd.OpenForm "Suppliers"
    Set rstSuppliers = New ADODB.Recordset
    rstSuppliers.CursorLocation = adUseClient
    rstSuppliers.Open "Select * From Suppliers", _
         CurrentProject.Connection, adOpenKeyset, adLockOptimistic
    Set Forms("Suppliers").Recordset = rstSuppliers
End Sub

Use the Recordset property:

  • To use methods with the Recordset object that aren't directly supported on forms. For example, you can use the Recordset property with the ADO Find or DAO Find methods in a custom dialog for finding a record.

  • To wrap a transaction (which can be rolled back) around a set of edits that affect multiple forms.

Changing a form's Recordset property may also change the RecordSource, RecordsetType, and RecordLocks properties. Also, some data-related properties may be overridden, for example, the Filter, FilterOn, OrderBy, and OrderByOn properties.

Calling the Requery method of a form's recordset (for example, Forms(0).Recordset.Requery) can cause the form to become unbound. To refresh the data in a form bound to a recordset, set the RecordSource property of the form to itself (Forms(0).RecordSource = Forms(0).RecordSource).

  • To bind multiple forms to a common data set. This allows synchronization of multiple forms. For example,

VBA Copy code Copy code
   Set Me.Recordset = Forms!Form1.Recordset

When a form is bound to a recordset, an error occurs if you use the Filter by Form command.

Example

The following example uses the Recordset property to create a new copy of the Recordset object from the current form and then prints the names of the fields in the Debug window.

VBA Copy code Copy code
Sub Print_Field_Names()
    Dim rst As DAO.Recordset, intI As Integer
    Dim fld As Field

    Set rst = Me.Recordset
    For Each fld in rst.Fields
        ' Print field names.
        Debug.Print fld.Name
    Next
End Sub

The next example uses the Recordset property and the Recordset object to synchronize a recordset with the form's current record. When a company name is selected from a combo box, the FindFirst method is used to locate the record for that company, causing the form to display the found record.

VBA Copy code Copy code
Sub SupplierID_AfterUpdate()
    Dim rst As DAO.Recordset
    Dim strSearchName As String

    Set rst = Me.Recordset
    strSearchName = CStr(Me!SupplierID)
    rst.FindFirst "SupplierID = " & strSearchName
    If rst.NoMatch Then
        MsgBox "Record not found"
    End If
    rst.Close
End Sub

The following code helps to determine what type of recordset is returned by the Recordset property under different conditions.

VBA Copy code Copy code
Sub CheckRSType()
    Dim rs as Object

    Set rs=Forms(0).Recordset
    If TypeOf rs Is DAO.Recordset Then
        MsgBox "DAO Recordset"
    ElseIf TypeOf rs is ADODB.Recordset Then
        MsgBox "ADO Recordset"
    End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Parameter

 Copy code hover
[image]

Parameter <name> specified where a table name is required. (Error 3216)
Send feedback

You created a parameter query that specifies an invalid parameter type. The following example produces this error.

SQL Copy code Copy code
PARAMETERS Param1 Text;

INSERT INTO Param1
SELECT *
FROM Customers;

Param1 is a text parameter, but the INSERT INTO statement expects a table name.

Change the parameter type from Text to TableID, and then try the operation again.


Cannot make the

 Copy code hover
[image]

Cannot make the <name> object in <name> container replicable. (Error 3583)
Send feedback

An object (table, form, report, module, macro) in the indicated container cannot be made replicable.

An example of an object that cannot be made replicable is a table that has 253 or more fields. Since replication needs to add a minumum of 3 additional fields, this would exceed the 255 field limit.


How to: Include Quotation Marks in String Expressions

 Copy code hover
[image]

How to: Include Quotation Marks in String Expressions
Send feedback

In situations where you must construct strings to be concatenated, you may need to embed a string within another string, or a string variable within a string. Situations in which you might need to nest one string within another include:

  • When specifying criteria for domain aggregate functions.

  • When specifying criteria for the Find methods.

  • When specifying criteria for the Filter or ServerFilter property of a form.

  • When building SQL strings.

In all of these instances, Microsoft Access must pass a string to the Microsoft Access database engine. When you specify a criteria argument for a domain aggregate function, for example, Microsoft Access must evaluate any variables, concatenate them into a string, and then pass the entire string to the Access database engine.

If you embed a numeric variable, Microsoft Access evaluates the variable and simply concatenates the value into the string. If the variable is a text string, however, the resulting criteria string will contain a string within a string. A string within a string must be identified by string delimiters. Otherwise, the Access database engine will not be able to determine which part of the string is the value you want to use.

The string delimiters are not actually part of the variable itself, but they must be included in the string in the criteria argument. There are three different ways to construct the string in the criteria argument. Each method results in a criteria argument that looks like one of the following examples.

Copy code Copy code
"[LastName] = 'Smith'"

- or -

Copy code Copy code
"[LastName] = ""Smith"""

Include Single Quotation Marks

You should include single quotation marks in the criteria argument in such a way that when the value of the variable is concatenated into the string, it will be enclosed within the single quotation marks. For instance, suppose your criteria argument must contain a string variable called . You could construct the criteria argument as in the following example:

Copy code Copy code
"[LastName] = '" & strName & "'"

When the variable strName is evaluated and concatenated into the criteria string, the criteria string becomes:

Copy code Copy code
"[LastName] = 'Smith'"
Note Note

This syntax does not permit the use of apostrophes (') within the value of the variable itself. If the value of the string variable includes an apostrophe, Microsoft Access generates a run-time error. If your variable may represent values containing apostrophes, consider using one of the other syntax forms discussed in the following sections.

Include Double Quotation Marks

You should include double quotation marks within the criteria argument in such a way so that when the value of the variable is evaluated, it will be enclosed within the quotation marks. Within a string, you must use two sets of double quotation marks to represent a single set of double quotation marks. You could construct the criteria argument as in the following example:

Copy code Copy code
"[LastName] = """ & strName & """"

When the variable strName is evaluated and concatenated into the criteria argument, each set of two double quotation marks is replaced by one single quotation mark. The criteria argument becomes:

Copy code Copy code
"[LastName] = 'Smith'"

This syntax may appear more complicated than the single quotation mark syntax, but it enables you to embed a string that contains an apostrophe within the criteria argument. It also enables you to nest one or more strings within the embedded string.

Include a Variable Representing Quotation Marks

You can create a string variable that represents double quotation marks, and concatenate this variable into the criteria argument along with the value of the variable. The ANSI representation for double quotation marks is Chr$(34); you could assign this value to a string variable called strQuote. You could then construct the criteria argument as in the following example:

Copy code Copy code
"[LastName] = " & strQuote & strName & strQuote

When the variables are evaluated and concatenated into the criteria argument, the criteria argument becomes:

Copy code Copy code
[LastName] = "Smith"


Cancel Method Example (VC++)

 Copy code hover
[image]

Cancel Method Example (VC++)
Send feedback

This example uses the Cancel method to cancel a command executing on a Connection object if the connection is busy.

Copy code Copy code

// BeginCancelCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include<conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void CancelX();
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 CancelX();

 //Wait here for user to see the output..
 printf("\nPress any key to continue...");
 getch();

 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// CancelX Function //
// //
///////////////////////////////////////////////////////////

void CancelX()
{
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace
 _ConnectionPtr pConnection = NULL;

 //Define Other Variables
 HRESULT hr = S_OK;
 _bstr_t strCmdChange;
 _bstr_t strCmdRestore;
 BOOL booChanged = FALSE;

 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 // open a connection.
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
 pConnection->Open(strCnn,"","",adConnectUnspecified);

 // Define command strings.
 strCmdChange = "UPDATE titles SET type = 'self_help' "
 "WHERE type = 'psychology'";

 strCmdRestore = "UPDATE titles SET type = 'psychology' "
 "WHERE type = 'self_help'";

 // Begin a transaction, then execute a command asynchronously.
 pConnection->BeginTrans();
 pConnection->Execute(strCmdChange,NULL,adAsyncExecute);

 // do something else for a little while - this could be changed
 for (int i = 1; i<=100000 ;i++)
 {
 // i = i + i;
 printf("%d\n", i);
 }

 // If the command has NOT completed, cancel the execute
 // and roll back the transaction. Otherwise, commit the
 // transaction.
 if ((pConnection->GetState()))
 {
 pConnection->Cancel();
 pConnection->RollbackTrans();
 booChanged = FALSE;
 printf("Update canceled.\n");
 printf("GetState = %d\n", pConnection->GetState());
 }
 else
 {
 pConnection->CommitTrans();
 booChanged = TRUE;
 printf("Update complete.\n");

 }

 // If the change was made, restore the data
 // because this is a demonstration.
 if (booChanged)
 {
 pConnection->Execute(strCmdRestore,NULL,0);
 printf("Data restored.\n");
 }
 }
 catch(_com_error &e)
 {
 // Notify user of any errors that result from
 // executing the query.
 // Pass a connection pointer accessed from the Connection.
 PrintProviderError(pConnection);
 PrintComError(e);
 }

 // Cleanup object before exit
 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;

 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s", pErr->Number,
 pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndCancelCpp


Form.OnCurrent Property (Access)

 Copy code hover
[image]

Form.OnCurrent Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Current box in the Properties window of a form. Read/write String.

Syntax

expression .OnCurrent

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Current event occurs when the focus moves to a record, making it the current record, or when the form is refreshed or requeried.

The OnCurrent value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Apply Filter box in the form's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Current box is blank, the property value is an empty string.

Example

The following example associates the Current event with the macro "Current_Macro" for the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").OnDeactivate = "Current_Macro"

See also

Concepts

Form Object

Other resources

Form Object Members


OptionButton.Left Property (Access)

 Copy code hover
[image]

OptionButton.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Syntax

expression .Left

expression A variable that represents an OptionButton object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Form.DefaultView Property (Access)

 Copy code hover
[image]

Form.DefaultView Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DefaultView property to specify the opening view of a form. Read/write Byte.

Syntax

expression .DefaultView

expression A variable that represents a Form object.

Remarks

The DefaultView property uses the following settings.

Setting | Visual Basic | Description
Single Form | 0 | (Default) Displays one record at a time.
Continuous Forms | 1 | Displays multiple records (as many as will fit in the current window), each in its own copy of the form's detail section.
Datasheet | 2 | Displays the form fields arranged in rows and columns like a spreadsheet.
PivotTable | 3 | Displays the form as a PivotTable.
PivotChart | 4 | Displays the form as a PivotChart.
Split Form | 5 | Displayes a split view of a Single Form and a datasheet containing the form's records.

The views displayed in the View button list depend on the setting of the ViewsAllowed property. For example, if the ViewsAllowed property is set to Datasheet, Form View is disabled in the View button list and on the View menu.

The combination of these properties creates the following conditions.

DefaultView | ViewsAllowed | Description
Single, Continuous Forms, or Datasheet | Both | Users can switch between Form view and Datasheet view.
Single or Continuous Forms | Form | Users can't switch from Form view to Datasheet view.
Single or Continuous Forms | Datasheet | Users can switch from Form view to Datasheet view but not back again.
Datasheet | Form | Users can switch from Datasheet view to Form view but not back again.
Datasheet | Datasheet | Users can't switch from Datasheet view to Form view.

See also

Concepts

Form Object

Other resources

Form Object Members


TextBox.GridlineWidthTop Property (Access)

 Copy code hover
[image]

TextBox.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthTop

expression A variable that represents a TextBox object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Replication Manager cannot find the ExchangeID in the MSysExchangeLog table. (Error 3496)

 Copy code hover
[image]

Replication Manager cannot find the ExchangeID in the MSysExchangeLog table. (Error 3496)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


TextBox Members (Access)

 Copy code hover
[image]

TextBox Members (Access)
Send feedback

Published: July 16, 2012

This object corresponds to a text box. Text boxes on a form or report display data from a record source.

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Change | The Change event occurs when the contents of the specified control changes.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Dirty | The Dirty event occurs when the contents of the specified control changes.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.
Undo | Occurs when the user undoes a change.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.
Undo | You can use the Undo method to reset a control or form when its value has been changed.

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
AllowAutoCorrect | You can use the AllowAutoCorrect property to specify whetherthe specified control will automatically correct entries made by the user. Read/write Boolean.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AsianLineBreak | Returns or sets a Boolean indicating whether line breaks in text boxes follow rules governing East Asian languages. True to control line breaks based on East Asian language rules. Read/write.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
AutoTab | You can use the AutoTab property to specify whether an automatic tab occurs when the last character permitted by a text box control's input mask is entered. An automatic tab moves the focus to the next control in the form's tab order. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomMargin | Along with the LeftMargin, RightMargin, and TopMargin properties, specifies the location of information displayed within a text box control. Read/write Integer.
BottomPadding | Gets or sets the amount of space (in inches) between the text box and its bottom gridline. Read/write Integer.
CanGrow | Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the control contains. Read/write Boolean.
CanShrink | Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the section or control contains. Read/write Boolean.
ColumnHidden | You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.
ColumnOrder | You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.
ColumnWidth | You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DecimalPlaces | You can use the DecimalPlaces property to specify the number of decimal places Microsoft Access uses to display numbers. Read/write Byte.
DefaultValue | Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.
DisplayAsHyperlink | Gets or sets an AcDisplayAsHyperlink constant that specifies whether to display the contents of the specified text box as a hyperlink. Read/write.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EnterKeyBehavior | You can use the EnterKeyBehavior property to specify what happens when you press ENTER in a text box control in Form view or Datasheet view. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FilterLookup | You can use the FilterLookup property to specify whether values appear in a bound text box control when using the Filter By Form or Server Filter By Form window. Read/write Byte.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontName | You can use the FontName property to specify the font for text in the following situations:
FontSize | You can use the FontSize property to specify the point size for text in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
FontWeight | You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
ForeShade | Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
ForeThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.
ForeTint | Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
Format | You can use the Format property to customize the way numbers, dates, times, and text are displayed and printed. Read/write String.
FormatConditions | You can use the FormatConditions property to return a read-only reference to the FormatConditions collection and its related properties.
FuriganaControl |
GridlineColor | Gets or sets the color of the gridline for the specified text box. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified text box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified text box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified text box. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified text box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified text box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified text box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HideDuplicates | You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the text box is anchored horizontally within its layout. Read/write.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
IMEHold | Language-specific information You can use the IMEHold/Hold KanjiConversionMode property to show whether the Kanji Conversion Mode is maintained when the control loses the focus. Read/write Boolean.
IMEMode |
IMESentenceMode |
InputMask | You can use the InputMask property to make data entry easier and to control the values users can enter in a text boxcontrol. Read/write String.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsHyperlink | You can use the IsHyperlink property to specify or determine if the data contained in a text box is a hyperlink. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
KeyboardLanguage |
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified text box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified text box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftMargin | Along with the TopMargin, RightMargin, and BottomMargin properties. specifies the location of information displayed within a text box control. Read/write Integer. .
LeftPadding | Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.
LineSpacing | You can use the LineSpacing property to specify or determine the location of information displayed within a label or text box control. Read/write Integer.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
NumeralShapes |
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnChange | Sets or returns the value of the On Change box in the Properties window of one of the objects in the Applies To list. Read/write String.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnDirty | Sets or returns the value of the On Dirty box in the Properties window of a form or report. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnUndo | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the Undo event occurs. Read/write..
Parent | Returns the parent object for the specified object. Read-only.
PostalAddress | You can use the PostalAddress Property property to specify or determine the postal code and the Customer Barcode data corresponding to the address information displayed in a specified field/textbox. The PostalAddress Property wizard enables the setting of these properties. Read/write String.
Properties | Returns a reference to a control's Properties collection object. Read-only.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
RightMargin | Along with the TopMargin, Left Margin, and BottomMargin properties, specifies the location of information displayed within text box control. Read/write Integer.
RightPadding | Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.
RunningSum | You can use the RunningSum property to calculate record-by-record or group-by-group totals in a report. Read/write Byte.
ScrollBarAlign | You can use the ScrollBarAlign to specify or determine the alignment of a vertical scroll bar. Read/write Byte.
ScrollBars | You can use the ScrollBars property to specify whether scroll bars appear on a text box control. Read/write Byte.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
SelLength | The SelLength property specifies or determines the number of characters selected in a text box. Read/write Integer.
SelStart | The SelStart property specifies or determines the starting point of the selected text or the position of the insertion point if no text is selected. Read/write Integer.
SelText | The SelText property returns a string containing the selected text. Read/write String.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
ShowDatePicker | Gets or sets whether the date picker control is displayed for the specified text box. Read/write Integer.
SmartTags | Returns a SmartTags collection that represents the collection of smart tags that have been added to a control. .
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Text | You can use the Text property to set or return the text contained in a text box. Read/write String.
TextAlign | The TextAlign property specifies the text alignment in new controls. Read/write Byte.
TextFormat | Gets or sets whether rich text is displayed in the specified text box. Read/write AcTextFormat.
ThemeFontIndex | Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopMargin | Along with the LeftMargin, RightMargin, and BottomMargin properties, specifies the location of information displayed within a text box control. Read/write Integer.
TopPadding | Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.
ValidationRule | You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.
ValidationText | Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.
Value | Determines or specifies the text in the text box. Read/write Variant.
Vertical | You can use the Vertical property to set a form control for vertical display and editing or set a report control for vertical display and printing. Read/write Boolean.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified text box is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


FormatCondition.FontUnderline Property (Access)

 Copy code hover
[image]

FormatCondition.FontUnderline Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontUnderline property to specify whether text is underlined in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontUnderline

expression A variable that represents a FormatCondition object.

Remarks

The FontUnderline property uses the following settings.

Setting | Description
True | The text is underlined.
False | (Default) The text isn't underlined.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

FormatCondition Object

Other resources

FormatCondition Object Members


Textual Criteria from a Control on a Form

 Copy code hover
[image]

Textual Criteria from a Control on a Form
Send feedback

If you want to change the criteria argument for an operation based on a user's decision, you can specify that the criteria comes from a control on a form. For example, you could specify that the criteria argument comes from a list box containing the last names of all employees in an Employees table.

To specify textual criteria coming from a control on a form, you include in the criteria argument an expression that references the control on the form. This expression should be separate from the string expression, so that Microsoft Access will evaluate the control expression first and concatenate it with the rest of the string expression before performing the appropriate operation.

In addition to enclosing the entire string expression in double quotation marks ("), you must also ensure that the textual criteria within the string expression is enclosed in single quotation marks ('). The quotation marks must be included in the strings flanking the expression that references the control on the form.

Note Note

The single quotation marks indicate to Microsoft Access that the criteria argument contains a string within a string.

The following example performs a lookup on an Employees table and returns the region in which an employee lives, based on the employee's last name. The current value of a list box control called LastName on the Employees form determines the criteria. Note the placement of the single quotation marks.

Copy code Copy code
=DLookup("[Region]", "Employees", "[LastName] = '" _
 & Forms!Employees!LastName & "'")

If the current value of the control is , the following criteria argument is passed to the DLookup function after Microsoft Access evaluates the expression and concatenates the strings:

Copy code Copy code
"[LastName] = 'King'"

Keep in mind that the entire string comprising the criteria argument must also be enclosed in double quotation marks once the strings have been concatenated.

Tip Tip

To troubleshoot an expression in the criteria argument, break the expression into smaller components and test each individually in the Immediate window. When all of the components are working correctly, put them back together one at a time until the complete expression works correctly.

You can also include a variable representing a textual string in the criteria argument. The variable should be separate from the string expression, so that Microsoft Access will evaluate the variable first and then concatenate it with the rest of the string expression. The textual string must be enclosed in single or double quotation marks.

The following example shows how to construct a criteria argument that includes a variable representing a textual string:

Copy code Copy code
Dim strLastName As String
Dim varResult As Variant

strLastName = "King"
varResult = DLookup("[EmployeeID]", "Employees", "[LastName] = '" _
 & strLastName & "'")


TextBox.Text Property (Access)

 Copy code hover
[image]

TextBox.Text Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Text property to set or return the text contained in a text box. Read/write String.

Syntax

expression .Text

expression A variable that represents a TextBox object.

Remarks

You can set the Text property to the text you want to display in the control. You can also use the Text property to read the text currently in the control.

Note Note

To set or return a control's Text property, the control must have the focus, or an error occurs. To move the focus to a control, you can use the SetFocus method or GoToControl action.

While the control has the focus, the Text property contains the text data currently in the control; the Value property contains the last saved data for the control. When you move the focus to another control, the control's data is updated, and the Value property is set to this new value. The Text property setting is then unavailable until the control gets the focus again. If you use the Save Record command on the Records menu to save the data in the control without moving the focus, the Text property and Value property settings will be the same.

Example

The following example uses the Text property to enable a Next button named btnNext whenever the user enters text into a text box named txtName. Anytime the text box is empty, the Next button is disabled.

VBA Copy code Copy code
Sub txtName_Change()
 btnNext.Enabled = Len(Me!txtName.Text & "")<>0
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Image.GridlineColor Property (Access)

 Copy code hover
[image]

Image.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified image control. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineColor

expression A variable that represents an Image object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

Image Object

Other resources

Image Object Members


CustomControl.SetFocus Method (Access)

 Copy code hover
[image]

CustomControl.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Syntax

expression .SetFocus

expression A variable that represents a CustomControl object.

Return Value

Nothing

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.

Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.

Example

The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:

VBA Copy code Copy code
Forms!Employees!EmployeeID.SetFocus

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Arithmetic Operators (Access 2013 custom web app)

 Copy code hover
[image]

Arithmetic Operators (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • - (Subtract) (Access 2013 custom web app)

  • * (Multiply) (Access 2013 custom web app)

  • / (Divide) (Access 2013 custom web app)

  • + (Add) (Access 2013 custom web app)

  • Mod (Access 2013 custom web app)


Sqrt Function (Access 2013 custom web app)

 Copy code hover
[image]

Sqrt Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the square root of the specified value.

Syntax

Sqrt (NumericExpression)

The Sqrt function contains the following argument.

Argument name | Description
NumericExpression | A numeric expression.


Recordset2.Connection Property (DAO)

 Copy code hover
[image]

Recordset2.Connection Property (DAO)
Send feedback

Returns the Connection object that corresponds to the database.

Syntax

expression .Connection

expression A variable that represents a Recordset2 object.


Attachment.VerticalAnchor Property (Access)

 Copy code hover
[image]

Attachment.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified attachment is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .VerticalAnchor

expression A variable that represents an Attachment object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


ListBox.ForeColor Property (Access)

 Copy code hover
[image]

ListBox.ForeColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ForeColor property to specify the color for text in a control. Read/write Long.

Syntax

expression .ForeColor

expression A variable that represents a ListBox object.

Remarks

You can use this property for controls on forms or reports to make them easy to read or to convey a special meaning. For example, you can change the color of the text in the UnitsInStock control when its value falls below the reorder level.

You can also use this property on reports to create special visual effects when you print with a color printer. When used on a report, this property specifies the printing and drawing color for the Print , Line , and Circle methods.

The ForeColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors for text in controls.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set the Circle property only by using a macro or a Visual Basic event procedure specified in a section's OnPrint event property setting.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Label.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

Label.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified label. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleLeft

expression A variable that represents a Label object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Label Object

Other resources

Label Object Members


NavigationControl.Move Method (Access)

 Copy code hover
[image]

NavigationControl.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Version Information

Version Added: Access 2010

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a NavigationControl object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant |
Top | Optional | Variant |
Width | Optional | Variant |
Height | Optional | Variant |

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


CustomControl Methods (Access)

 Copy code hover
[image]

CustomControl Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.


TextBox.GotFocus Event (Access)

 Copy code hover
[image]

TextBox.GotFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The GotFocus event occurs when the specified object receives the focus.

Syntax

expression .GotFocus

expression A variable that represents a TextBox object.

Remarks

To run a macro or event procedure when these events occur, set the OnGotFocus property to the name of the macro or to [Event Procedure].

These events occur when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The GotFocus event differs from the Enter event in that the GotFocus event occurs every time a control receives the focus. For example, suppose the user clicks a check box on a form, then clicks a report, and finally clicks the check box on the form to bring it to the foreground. The GotFocus event occurs both times the check box receives the focus. In contrast, the Enter event occurs only the first time the user clicks the check box. The GotFocus event occurs after the Enter event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Workspaces.Count Property (DAO)

 Copy code hover
[image]

Workspaces.Count Property (DAO)
Send feedback

Returns the number of objects in the specified collection. Read-only.

Syntax

expression .Count

expression A variable that represents a Workspaces object.

Remarks

Because members of a collection begin with 0, you should always code loops starting with the 0 member and ending with the value of the Count property minus 1. If you want to loop through the members of a collection without checking the Count property, you can use a For Each...Next command.

The Count property setting is never Null. If its value is 0, there are no objects in the collection.


Parameters.Count Property (DAO)

 Copy code hover
[image]

Parameters.Count Property (DAO)
Send feedback

Returns the number of objects in the specified collection. Read-only.

Syntax

expression .Count

expression A variable that represents a Parameters object.

Remarks

Because members of a collection begin with 0, you should always code loops starting with the 0 member and ending with the value of the Count property minus 1. If you want to loop through the members of a collection without checking the Count property, you can use a For Each...Next command.

The Count property setting is never Null. If its value is 0, there are no objects in the collection.


FilterColumn, FilterCriterion, FilterValue, SortColumn, and SortDirection Properties and Reset Method Example (VBScript)

 Copy code hover
[image]

FilterColumn, FilterCriterion, FilterValue, SortColumn, and SortDirection Properties and Reset Method Example (VBScript)
Send feedback

Published: July 16, 2012

The following code shows how to set the RDS.DataControlServer parameter at design time and bind it to a data-aware HTML table using a data source. Cut and paste the following code to Notepad or another text editor and save it as FilterColumnVBS.asp.

VBS Copy code Copy code
<!-- BeginFilterColumnVBS --><%@ Language=VBScript %>
<HTML><HEAD>
<META name="VI60_DefaultClientScript" Content="VBScript">
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"><TITLE>FilterColumn, FilterCriterion, FilterValue, SortColumn, and SortDirection
Properties and Reset Method Example (VBScript)</TITLE></HEAD>
<BODY><h1>FilterColumn, FilterCriterion, FilterValue, SortColumn, and SortDirection
Properties and Reset Method Example (VBScript)</h1>
<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID=RDS HEIGHT=1 WIDTH=1><PARAM NAME="SQL" VALUE="Select FirstName, LastName, Title, ReportsTo, Extension from Employees">
<PARAM NAME="Connect" VALUE="Provider='sqloledb';Data Source=<%=Request.ServerVariables("SERVER_NAME")%>;Integrated Security='SSPI';Initial Catalog='Northwind'"><PARAM NAME="Server" VALUE="http://<%=Request.ServerVariables("SERVER_NAME")%>">
</OBJECT>
Sort Column: <SELECT NAME="cboSortColumn"><OPTION VALUE=""></OPTION>
<OPTION VALUE=ID>ID</OPTION><OPTION VALUE=FirstName>FirstName</OPTION>
<OPTION VALUE=LastName>LastName</OPTION><OPTION VALUE=Title>Title</OPTION>
<OPTION VALUE=Title>ReportsTo</OPTION><OPTION VALUE=Phone>Extension</OPTION>
</SELECT><br>
Sort Direction: <SELECT NAME="cboSortDir"><OPTION VALUE=""></OPTION>
<OPTION VALUE=TRUE>Ascending</OPTION><OPTION VALUE=FALSE>Descending</OPTION>
</SELECT><HR WIDTH="25%">
Filter Column: <SELECT NAME="cboFilterColumn"><OPTION VALUE=""></OPTION>
<OPTION VALUE=FirstName>FirstName</OPTION><OPTION VALUE=LastName>LastName</OPTION>
<OPTION VALUE=Title>Title</OPTION><OPTION VALUE=Room>ReportsTo</OPTION>
<OPTION VALUE=Phone>Extension</OPTION></SELECT>
<br>Filter Criterion: <SELECT NAME="cboCriterion">
<OPTION VALUE=""></OPTION><OPTION VALUE="=">=</OPTION>
<OPTION VALUE="&gt;">&gt;</OPTION><OPTION VALUE="&lt;">&lt;</OPTION>
<OPTION VALUE="&gt;=">&gt;=</OPTION><OPTION VALUE="&lt;=">&lt;=</OPTION>
<OPTION VALUE="&lt;&gt;">&lt;&gt;</OPTION></SELECT>
<br>Filter Value: <INPUT NAME="txtFilterValue">
<HR WIDTH="25%"><INPUT TYPE=BUTTON NAME=Clear VALUE="CLEAR ALL"> &nbsp;
<INPUT TYPE=BUTTON NAME=SortFilter VALUE="APPLY">
<HR><TABLE DATASRC=#RDS ID="DataTable">
<THEAD><TR>
<TH>FirstName</TH><TH>LastName</TH>
<TH>Title</TH><TH>Reports To</TH>
<TH>Extension</TH></TR>
</THEAD><TBODY>
<TR><TD><SPAN DATAFLD="FirstName"></SPAN></TD>
<TD><SPAN DATAFLD="LastName"></SPAN></TD><TD><SPAN DATAFLD="Title"></SPAN></TD>
<TD><SPAN DATAFLD="ReportsTo"></SPAN></TD><TD><SPAN DATAFLD="Extension"></SPAN></TD>
</TR></TBODY>
</TABLE>
<Script Language="VBScript"><!--
Const adFilterNone = 0
Sub SortFilter_OnClickDim vCriterion
Dim vSortDirDim vSortCol
Dim vFilterCol
' The value of SortColumn will be the' value of what the user picks in the
' cboSortColumn box.vSortCol = cboSortColumn.options(cboSortColumn.selectedIndex).value
If(vSortCol <> "") thenRDS.SortColumn = vSortCol
End If
' The value of SortDirection will be the' value of what the user specifies in the
' cboSortdirection box.
If (vSortCol <> "") thenvSortDir = cboSortDir.options(cboSortDir.selectedIndex).value
If (vSortDir = "") thenMsgBox "You must select a direction for the sort."
Exit SubElse
If vSortDir = "Ascending" Then vSortDir = "TRUE"If vSortDir = "Descending" Then vSortDir = "FALSE"
RDS.SortDirection = vSortDirEnd If
End If
' The value of FilterColumn will be the' value of what the user specifies in the
' cboFilterColumn box.vFilterCol = cboFilterColumn.options(cboFilterColumn.selectedIndex).value
If(vFilterCol <> "") thenRDS.FilterColumn = vFilterCol
End If
' The value of FilterCriterion will be the' text value of what the user specifies in the
' cboCriterion box.vCriterion = cboCriterion.options(cboCriterion.selectedIndex).value
If (vCriterion <> "") ThenRDS.FilterCriterion = vCriterion
End If
' txtFilterValue is a rich text box' control. The value of FilterValue will be the
' text value of what the user specifies in the' txtFilterValue box.
If (txtFilterValue.value <> "") ThenRDS.FilterValue = txtFilterValue.value
End If
' Execute the sort and filter on a client-side' Recordset based on the specified sort and filter
' properties. Calling Reset refreshes the result set' that is displayed in the data-bound controls to
' display the filtered, sorted recordset.RDS.Reset
End Sub
Sub Clear_onClick()'clear the HTML input controls
cboSortColumn.selectedIndex = 0cboSortDir.selectedIndex = 0
cboFilterColumn.selectedIndex = 0cboCriterion.selectedIndex = 0
txtFilterValue.value = ""
'clear the filterRDS.FilterCriterion = ""
RDS.Reset(FALSE)End Sub
--></Script>
</BODY></HTML>
<!-- EndFilterColumnVBS -->


ListBox.MouseDown Event (Access)

 Copy code hover
[image]

ListBox.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents a ListBox object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
         Shift As Integer, X As Single, _
         Y As Single)
    If Button = acLeftButton Then
        MsgBox "You pressed the left button."
    End If
    If Button = acRightButton Then
        MsgBox "You pressed the right button."
    End If
    If Button = acMiddleButton Then
        MsgBox "You pressed the middle button."
    End If
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Relation.CreateField Method (DAO)

 Copy code hover
[image]

Relation.CreateField Method (DAO)
Send feedback

Creates a new Field object (Microsoft Access workspaces only).

Syntax

expression .CreateField(Name, Type, Size)

expression A variable that represents a Relation object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Optional | Variant | A String that uniquely names the new Field object. See the Name property for details on valid Field names.
Type | Optional | Variant | Argument not supported for this object.
Size | Optional | Variant | Argument not supported for this object.

Return Value

Field

Remarks

You can use the CreateField method to create a new field, as well as specify the name, data type, and size of the field. If you omit one or more of the optional parts when you use CreateField, you can use an appropriate assignment statement to set or reset the corresponding property before you append the new object to a collection. After you append the new object, you can alter some but not all of its property settings. See the individual property topics for more details.

The type and size arguments apply only to Field objects in a TableDef object. These arguments are ignored when a Field object is associated with an Index or Relation object.

If name refers to an object that is already a member of the collection, a run-time error occurs when you use the Append method.

To remove a Field object from a Fields collection, use the Delete method on the collection. You can't delete a Field object from a TableDef object's Fields collection after you create an index that references the field.


FormatCondition.Enabled Property (Access)

 Copy code hover
[image]

FormatCondition.Enabled Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.

Syntax

expression .Enabled

expression A variable that represents a FormatCondition object.

Remarks

The Enabled property setting is a value that indicates whether the conditional format is enabled or disabled. True enables the conditional format. False disables the conditional format. The default is True.

When the Enabled property is True, the conditional format can be displayed in the Conditional Formatting dialog box.

See also

Concepts

FormatCondition Object

Other resources

FormatCondition Object Members


Users Collection (ADOX)

 Copy code hover
[image]

Users Collection (ADOX)
Send feedback

Contains all stored User objects of a catalog or group.

Remarks

The Users collection of a Catalog represents all the catalog's users. The Users collection for a Group represents only the users that have a membership in the specific group.

The Append method for a Users collection is unique for ADOX. You can:

  • Add a new user to the collection with the Append method.

The remaining properties and methods are standard to ADO collections. You can:

  • Access a user in the collection with the Item property.

  • Return the number of users contained in the collection with the Count property.

  • Remove a user from the collection with the Delete method.

  • Update the objects in the collection to reflect the current database's schema with the Refresh method.

Note Note

Before appending a User object to the Users collection of a Group object, a User object with the same Name as the one to be appended must already exist in the Users collection of the Catalog.


Operation not supported in transactions. (Error 3246)

 Copy code hover
[image]

Operation not supported in transactions. (Error 3246)
Send feedback

You tried to perform an operation that is not valid within a transaction. A transaction can be one you create using a BeginTrans statements, or an internal transaction created by the Microsoft Access database engine, such as when you delete multiple records in a single operation.


SmartTagProperty Properties (Access)

 Copy code hover
[image]

SmartTagProperty Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Value | Gets or sets the value of the specified object. Read/write Variant.


WillChangeField and FieldChangeComplete Events (ADO)

 Copy code hover
[image]

WillChangeField and FieldChangeComplete Events (ADO)
Send feedback

The WillChangeField event is called before a pending operation changes the value of one or more Field objects in the Recordset. The FieldChangeComplete event is called after the value of one or more Field objects has changed.

Syntax

WillChangeField cFields, Fields, adStatus, pRecordset

FieldChangeComplete cFields, Fields, pError, adStatus, pRecordset

Parameters

  • cFields

  • A Long that indicates the number of Field objects in Fields.

  • Fields

  • For WillChangeField, the Fields parameter is an array of Variants that contains Field objects with the original values.

    For FieldChangeComplete, the Fields parameter is an array of Variants that contains Field objects with the changed values.

  • pError

  • An Error object. It describes the error that occurred if the value of adStatus is adStatusErrorsOccurred; otherwise it is not set.

  • adStatus

  • EventStatusEnum

    When WillChangeField is called, this parameter is set to adStatusOK if the operation that caused the event was successful. It is set to adStatusCantDeny if this event cannot request cancellation of the pending operation.

    When FieldChangeComplete is called, this parameter is set to adStatusOK if the operation that caused the event was successful, or to adStatusErrorsOccurred if the operation failed.

    Before WillChangeField returns, set this parameter to adStatusCancel to request cancellation of the pending operation.

    Before FieldChangeComplete returns, set this parameter to adStatusUnwantedEvent to prevent subsequent notifications.

  • pRecordset

  • A Recordset object. The Recordset for which this event occurred.

Remarks

A WillChangeField or FieldChangeComplete event may occur when setting the Value property and calling the Update method with field and value array parameters.


Application.FeatureInstall Property (Access)

 Copy code hover
[image]

Application.FeatureInstall Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FeatureInstall property to specify or determine how Microsoft Access handles calls to methods and properties that require features not yet installed. Read/write MsoFeatureInstall.

Syntax

expression .FeatureInstall

expression A variable that represents an Application object.

Remarks

When VBA code references an object that is not installed the Microsoft Installer technology will attempt to install the required feature. You use the FeatureInstall property to control what happens when an uninstalled object is referenced. When this property is set to the default, any attempt to use an uninstalled object causes the Installer technology to try to install the requested feature. In some circumstances this may take some time, and the user may believe that the machine has stopped responding to additional commands.

You can set the FeatureInstall property to msoFeatureInstallOnDemandWithUI so users can see that something is happening as the feature is being installed. You can set the FeatureInstall property to msoFeatureInstallNone if you want to trap the error that is returned and display your own dialog box to the user or take some other custom action.

If you have the UserControl property set to False, users will not be prompted to install new features even if the FeatureInstall property is set to msoFeatureInstallOnDemand. If the UserControl property is set to True, an installation progress meter will appear if the FeatureInstall property is set to msoFeatureInstallOnDemand.

Example

This example checks the value of the FeatureInstall property. If the property is set to msoFeatureInstallNone, the code displays a message box that asks the user whether they want to change the property setting. If the user responds "Yes", the property is set to msoFeatureInstallOnDemand. The example uses an object variable named MyOfficeApp that is dimensioned as an application object.

VBA Copy code Copy code

Dim myofficeapp As Access.Application
Set myofficeapp = New Access.Application

With MyOfficeApp
    If .FeatureInstall = msoFeatureInstallNone Then
        Reply = MsgBox("Uninstalled features for " _
            & "this application may " & vbCrLf _
            & "cause a run-time error when called." _
            & vbCrLf & vbCrLf _
            & "Would you like to change this setting" & vbCrLf _
            & "to automatically install missing features?", _
            vbYesNo, "Feature Install Setting")
            If Reply = vbYes Then
                .FeatureInstall = msoFeatureInstallOnDemand
            End If
    End If
End With

See also

Concepts

Application Object

Other resources

Application Object Members


TableDef Members (DAO)

 Copy code hover
[image]

TableDef Members (DAO)
Send feedback

A TableDef object represents the stored definition of a base table or a linked table (Microsoft Access workspaces only).

Methods

Name | Description
CreateField | Creates a new Field object (Microsoft Access workspaces only). .
CreateIndex | Creates a new Index object (Microsoft Access workspaces only). .
CreateProperty | Creates a new user-defined Property object (Microsoft Access workspaces only).
OpenRecordset | Creates a new Recordset object and appends it to the Recordsets collection.
RefreshLink | Updates the connection information for a linked table (Microsoft Access workspaces only).

Properties

Name | Description
Attributes | Sets or returns a value that indicates one or more characteristics of a TableDef object. Read/write Long.
ConflictTable | Returns the name of a conflict table containing the database records that conflicted during the synchronization of two replicas (Microsoft Access workspaces only). Read-only String.
Connect | Sets or returns a value that provides information about a linked table. Read/write String.
DateCreated | Returns the date and time that an object was created (Microsoft Access workspaces only). Read-only Variant.
Fields | Returns a Fields collection that represents all stored Field objects for the specified object. Read-only.
Indexes | Returns an Indexes collection that contains all of the stored Index objects for the specified table. Read-only.
LastUpdated | Returns the date and time of the most recent change made to an object. Read-only Variant.
Name | Returns or sets the name of the specified object. Read/write String.
Properties | Returns the Properties collection of the specified object. Read-only.
RecordCount | Returns the total number of records in a TableDef object. Read-only Long.
ReplicaFilter | Sets or returns a value on a TableDef object within a partial replica that indicates which subset of records is replicated to that table from a full replica. (Microsoft Access workspaces only).
SourceTableName | Sets or returns a value that specifies the name of a linked table or the name of a base table (Microsoft Access workspaces only).
Updatable | Returns a value that indicates whether you can change a DAO object. Read-only Boolean.
ValidationRule | Sets or returns a value that validates the data in a field as it's changed or added to a table (Microsoft Access workspaces only).Read/write String.
ValidationText | Sets or returns a value that specifies the text of the message that your application displays if the value of a Field object doesn't satisfy the validation rule specified by the ValidationRule property setting (Microsoft Access workspaces only). Read/write String.


Attachment.TabIndex Property (Access)

 Copy code hover
[image]

Attachment.TabIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabIndex property to specify a control's place in the tab order on a form. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .TabIndex

expression A variable that represents an Attachment object.

Remarks

The TabIndex property applies only to controls on a form, not controls on a report.

You can set the TabIndex property to an integer representing the position of the control within the tab order of the form. Valid settings are 0 for the first tab position, up to the total number of controls minus 1 for the last tab position. For example, if a form has three controls that each have a TabIndex property, valid TabIndex property settings are 0, 1, and 2.

Setting the TabIndex property to an integer less than 0 produces an error.

By default, Microsoft Access assigns a tab order to controls in the order that you create them on a form. Each new control is placed last in the tab order. If you change the setting of a control's TabIndex property to adjust the tab order, Microsoft Access automatically renumbers the TabIndex property setting of other controls to reflect insertions and deletions.

In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the TAB key.

Changing the tab order of other controls on the form doesn't affect what happens when you press a control's access key. For example, if you've created an access key for the label of a text box, the focus will move to the text box whenever you press the label's access key — even if you change the TabIndex property setting for the text box.

If you press an access key for a control such as a label that doesn't have a TabIndex property (and thus isn't in the tab order), the focus moves to the next control in the tab order that can receive the focus.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Unions not allowed in a subquery. (Error 3361)

 Copy code hover
[image]

Unions not allowed in a subquery. (Error 3361)
Send feedback

You cannot use a UNION operation in a subquery expression. To use a union query in a subquery, first create the union query and save it as a named query. Then include the name of the saved query in your subquery expression.


ToggleButton.OnGotFocus Property (Access)

 Copy code hover
[image]

ToggleButton.OnGotFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnGotFocus

expression A variable that represents a ToggleButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The GotFocus event occurs when the object receives the focus.

The OnGotFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Got Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Got Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnGotFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnGotFocus

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


CubeDef Example (VBScript)

 Copy code hover
[image]

CubeDef Example (VBScript)
Send feedback

This example displays cube metadata on a web page.

VBS Copy code Copy code

<%@ Language=VBScript %>
<%
Response.Buffer=True
'Response.Expires=0
%>
<html>
<head>
<meta NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</head>
<body>

<%
Server.ScriptTimeout=360
Dim cat,cdf,di,hi,le,mem,strServer,strSource,strCubeName

'************************************************************************
'*** Set Session Variables
'************************************************************************
Session("CubeName") = Request.Form("strCubeName")
Session("CatalogName") = Request.Form("strCatalogName")
Session("ServerName") = Request.Form("strServerName")
Session("chkDim") = Request.Form("chkDimension")
Session("chkHier") =  Request.Form("chkHierarchy")
Session("chkLev") =  Request.Form("chkLevel")

'************************************************************************
'*** Create Catalog Object
'************************************************************************************
Set cat = Server.CreateObject("ADOMD.Catalog")

If Len(Session("ServerName")) > 0 Then
   cat.ActiveConnection = "Data Source='" & Session("ServerName") & "';Initial Catalog='" & Session("CatalogName") & "';Provider='msolap';"
Else
'************************************************************************************
'*** Must set OLAPServerName to OLAP Server that is
'*** present on network
'************************************************************************
OLAPServerName = "Please set to present OLAP Server"
   cat.ActiveConnection = "Data Source=" & OLAPServerName & _
      ";Initial Catalog=FoodMart;Provider=msolap;"
   Session("ServerName") = OLAPServerName
   Session("InitialCatalog") = "FoodMart"
End if

If Len(Session("CubeName")) > 0 Then
   Set cdf = cat.CubeDefs(Session("CubeName"))
Else
   Set cdf = cat.CubeDefs("Sales")
   Session("CubeName")="Sales"
End if

'************************************************************************
'*** Collect Information in HTML Form
'************************************************************************
%>
<form action="ASPADOCubeDoc.asp" method="post" id="form1" name="form1">
<table>
   <tr>
      <td>
      <b>Olap Server name:  </b><br><input type="text" id="strServerName" name="strServerName" value="<%=Session("ServerName")%>" size="20"><br>

      <b>Catalog Name:  </b><br><input type="text" id="strCatalogName" name="strCatalogName" value="<%=Session("CatalogName")%>" size="20"><br>

      <b>Cube Name:  </b><br><input type="text" id="strCubeName" name="strCubeName" value="<%=Session("CubeName")%>" size="20">
      </td>
      <td <TD>
         <b>Add Property Detail:  </b><br>
         Dimension Detail: <input type="checkbox" id="chkDimension" name="chkDimension"><br>

         Hierarchy Detail: <input type="checkbox" id="chkHierarchy" name="chkHierarchy"><br>

         Level Detail: <input type="checkbox" id="chkLevel" name="chkLevel">
      </td>
   </tr>
</table>
<input type="submit" value="Cube Information" id="submit1" name="submit1"><input type="reset" value="Reset" id="reset1" name="reset1">
</form>
<%

'************************************************************************
'*** Start of Report
'************************************************************************
Response.Write "<H3>Report for " & Session("CubeName") & " Cube</H3>"
Response.Write "<OL TYPE='i'>"

'************************************************************************
'*** Show properties of Cube
'************************************************************************
            For i = 0 To cdf.Properties.Count - 1
               Response.Write "<LI>"
               Response.Write "<FONT size=-2>" & cdf.Properties(i).Name & ": " & cdf.Properties(i).Value & "</FONT>"
            Next
            Response.Write "</OL>"
            Response.Write "<UL TYPE='SQUARE'>"
 '************************************************************************
'*** Loop to display Dimension Name and Properties if Check box is
'*** Checked
'************************************************************************
      For di = 0 To cdf.Dimensions.Count - 1
         Response.Write "<LI>"
         Response.Write "<FONT size=4><B>Dimension: " & _
            cdf.Dimensions(di).Name & "</B></FONT>"
         If Request.Form("chkDimension") = "on" Then
            Response.Write "<OL TYPE='1'>"
            For i = 0 To cdf.Dimensions(di).Properties.Count - 1
               Response.Write "<LI>"
               Response.Write "<FONT size=-2>" & _
                  cdf.Dimensions(di).Properties(i).Name & ": " & _
                  cdf.Dimensions(di).Properties(i).Value & "</FONT>"
            Next
            Response.Write "</OL>"
         End If
         Response.Write "<UL TYPE= 'Circle'>"
'************************************************************************
'*** Loop to display Hierarchy Name and Properties if Check box is
'*** Checked
'************************************************************************
         For hi = 0 To cdf.Dimensions(di).Hierarchies.Count - 1
            Response.Write "<LI>"
            Response.Write "<FONT size=3><B>Hierarchy: " & _
               cdf.Dimensions(di).Hierarchies(hi).Name & "</B></FONT>"
            If Request.Form("chkHierarchy") = "on" Then
               Response.Write "<OL TYPE='1'>"
               For i = 0 To _
                  cdf.Dimensions(di).Hierarchies(hi).Properties.Count - 1
                  Response.Write "<LI>"
                  Response.Write "<FONT size=-2>" & _
                     cdf.Dimensions(di).Hierarchies(hi).Properties(i)._
                     Name & ": " & _
                     cdf.Dimensions(di).Hierarchies(hi).Properties(i)._
                     Value & "</FONT>"
               Next
               Response.Write "</OL>"
            End If
            Response.Write "<UL TYPE='Disc'>"
'************************************************************************
'*** Loop to display Level Name and Properties if Check box is Checked
'************************************************************************
      For le = 0 To cdf.Dimensions(di).Hierarchies(hi).Levels.Count - 1
               Response.Write "<LI>"
               Response.Write "<FONT size=2><B>Level: " & _
                  cdf.Dimensions(di).Hierarchies(hi).Levels(le).Name & _
                  " with a Member Count of: " & _
                  cdf.Dimensions(di).Hierarchies(hi).Levels(le)._
                  Properties("LEVEL_CARDINALITY") & "</B></FONT>"
               If Request.Form("chkLevel") = "on" Then
                  Response.Write "<OL TYPE='1'>"
                  For i = 0 To
                     cdf.Dimensions(di).Hierarchies(hi).Levels(le)._
                     Properties.Count - 1
                     Response.Write "<LI>"
                     Response.Write "<FONT size=-2>" & _
                        cdf.Dimensions(di).Hierarchies(hi).Levels(le)._
                        Properties(i).Name & ": " & _
                        cdf.Dimensions(di).Hierarchies(hi).Levels(le)._
                        Properties(i).Value & "</FONT>"
                  Next
                  Response.Write "</OL>"
               End If
            Next
            Response.Write "</UL>"
         Next
         Response.Write "</UL>"
      Next
      Response.Write "</UL>"
%>
</body>
</html>


PageBreak.Visible Property (Access)

 Copy code hover
[image]

PageBreak.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents a PageBreak object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

PageBreak Object

Other resources

PageBreak Object Members


Section IV: ADO Extensions for Data Definition Language and Security (ADOX) (Access)

 Copy code hover
[image]

Section IV: ADO Extensions for Data Definition Language and Security (ADOX) (Access)
Send feedback

In this section

  • Section IV: ADO Extensions for Data Definition Language and Security (ADOX)

  • Chapter 15: ADOX Fundamentals (ADO)


Address Book Command Buttons

 Copy code hover
[image]

Address Book Command Buttons
Send feedback

The Address Book application includes the following command buttons:

  • A Find button to submit a query to the database.

  • A Clear button to clear the text boxes before starting a new search.

  • An Update Profile button to save changes to an employee record.

  • A Cancel Changes button to discard changes.

Find Button

Clicking the Find button activates the VBScript Find_OnClick Sub procedure, which builds and sends the SQL query. Clicking this button populates the data grid.

Building the SQL Query

The first part of the Find_OnClick Sub procedure builds the SQL query, one phrase at a time, by appending text strings to a global SQL SELECT statement. It begins by setting the variable to a SQL SELECT statement that requests all rows of data from the data source table. Next, the Sub procedure scans each of the four input boxes on the page.

Because the program uses the word in building the SQL statements, the queries are substring searches rather than exact matches.

For example, if the Last Name box contained the entry "Berge" and the Title box contained the entry "Program Manager", the SQL statement (value of ) would read:

Copy code Copy code

Select FirstName, LastName, Title, Email, Building, Room, Phone from Employee where lastname like 'Berge%' and title like 'Program Manager%'

If the query was successful, all persons with a last name containing the text "Berge" (such as Berge and Berger) and with a title containing the words "Program Manager" (for example, Program Manager, Advanced Technologies) are displayed in the HTML data grid.

Preparing and Sending the Query

The last part of the Find_OnClick Sub procedure consists of two statements. The first statement assigns the SQL property of the RDS.DataControl object equal to the dynamically built SQL query. The second statement causes the RDS.DataControl object () to query the database, and then display the new results of the query in the grid.

Copy code Copy code

Sub Find_OnClick
 '...
 DC1.SQL = myQuery
 DC1.Refresh
End Sub

Update Profile Button

Clicking the Update Profile button activates the VBScript Update_OnClick Sub procedure, which executes the RDS.DataControl object's () SubmitChanges and Refresh methods.

Copy code Copy code

Sub Update_OnClick
 DC1.SubmitChanges
 DC1.Refresh
End Sub

When DC1.SubmitChanges executes, the Remote Data Service packages all the update information and sends it to the server via HTTP. The update is all-or-nothing; if a part of the update is unsuccessful, none of the changes is made, and a status message is returned. executes, the Remote Data Service packages all the update information and sends it to the server via HTTP. The update is all-or-nothing; if a part of the update is unsuccessful, none of the changes is made, and a status message is returned. DC1.Refresh isn't necessary after SubmitChanges with Remote Data Service, but it ensures fresh data.

Cancel Changes Button

Clicking Cancel Changes activates the VBScript Cancel_OnClick Sub procedure, which executes the RDS.DataControl object's ( CancelUpdate method.

Copy code Copy code

Sub Cancel_OnClick
 DC1.CancelUpdate
End Sub

When executes, it discards any edits that a user has made to an employee record on the data grid since the last query or update. It restores the original values.


Delete Method (ADOX Collections)

 Copy code hover
[image]

Delete Method (ADOX Collections)
Send feedback

Removes an object from a collection.

Syntax

Collection.Delete Name

Parameters

  • Name

  • A Variant that specifies the name or ordinal position (index) of the object to delete.

Remarks

An error will occur if the Name does not exist in the collection.

For Tables and Users collections, an error will occur if the provider does not support deleting tables or users, respectively. For Procedures and Views collections, Delete will fail if the provider does not support persisting commands.


Hyperlink.CreateNewDocument Method (Access)

 Copy code hover
[image]

Hyperlink.CreateNewDocument Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the CreateNewDocument method to create a new document associated with a specified hyperlink.

Syntax

expression .CreateNewDocument(FileName, EditNow, Overwrite)

expression A variable that represents a Hyperlink object.

Parameters

Name | Required/Optional | Data Type | Description
FileName | Required | String | The name and path of the document. The type of document format you want used can be determine by the extension used with the filename. to output the data. You can create HTML (*.htm), Microsoft Active Server Pages (*.asp), Microsoft Excel (*.xls), Microsoft IIS (*.htx, *.idc), MS-DOS Text (*.txt), or Rich Text Format (*.rtf). Modules can be output only to MS-DOS text format. Microsoft Internet Information Server and Microsoft Active Server formats are available only for tables, queries, and forms.
EditNow | Required | Boolean | True opens the document in design view and False stores the new document in the specified database directory. The default is True.
Overwrite | Required | Boolean | True overwrites an existing document if the filename argument identifies an existing document and False requires that the filename argument specifies a new filename. The default is False.

Return Value

Nothing

Remarks

The CreateNewDocument method provides a way to programmatically create a document associated with a hyperlink within a control.

Example

The following example utilizes a hyperlink control's Click event. This event creates a new file named "Report.txt" when the user clicks the hyperlink control named "GenerateReport" on a form. The new file opened for editing. If a file named "Report.txt" already exists on drive C, it is replaced with this new file.

VBA Copy code Copy code
Private Sub GenerateReport_Click()
 ActiveControl.Hyperlink.CreateNewDocument _
 "C:\Report.txt", EditNow:=True, Overwrite:=True
End Sub

See also

Concepts

Hyperlink Object

Other resources

Hyperlink Object Members


Image.BackStyle Property (Access)

 Copy code hover
[image]

Image.BackStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.

Syntax

expression .BackStyle

expression A variable that represents an Image object.

Remarks

The BackStyle property uses the following settings.

Setting | Visual Basic | Description
Normal | 1 | (Default for all controls except option group) The control has its interior color set by the BackColor property.
Transparent | 0 | (Default for option group) The control is transparent. The color of the form or report behind the control is visible.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

If the Transparent button on the Back Color button palette is selected, the BackStyle property is set to Transparent; otherwise the BackStyle property is set to Normal.

To make a command button invisible, set its Transparent property to Yes.

See also

Concepts

Image Object

Other resources

Image Object Members


CacheSize Property Example (VC++)

 Copy code hover
[image]

CacheSize Property Example (VC++)
Send feedback

This example uses the CacheSize property to show the difference in performance for an operation performed with and without a 30-record cache.

Copy code Copy code

// BeginCacheSizeCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>
#include <winbase.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void CacheSizeX();
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 CacheSizeX();

 //Wait here for user to see the output..
 printf("\nPress any key to continue...");
 getch();

 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// CacheSizeX Function //
// //
///////////////////////////////////////////////////////////

void CacheSizeX()
{
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace
 _RecordsetPtr pRstRoySched = NULL;

 //Define Other Variables
 HRESULT hr = S_OK;
 DWORD sngStart;
 DWORD sngEnd;
 float sngNoCache;
 float sngCache;
 int intLoop = 0;
 _bstr_t strTemp;

 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 //Open the RoySched table.
 TESTHR(pRstRoySched.CreateInstance(__uuidof(Recordset)));
 pRstRoySched->Open("roysched", strCnn, adOpenForwardOnly,
 adLockReadOnly, adCmdTable);

 // Enumerate the Recordset object twice and record
 // the elapsed time.
 sngStart = GetTickCount();

 for (intLoop = 1; intLoop < 2; intLoop++)
 {
 pRstRoySched->MoveFirst();

 while(!(pRstRoySched->EndOfFile))
 {
 // Execute a simple operation for the
 // performance test.
 strTemp = pRstRoySched->Fields->
 Item["title_id"]->Value;
 pRstRoySched->MoveNext();
 }
 }
 sngEnd = GetTickCount();
 sngNoCache = (float)(sngEnd - sngStart)/(float)1000;

 // Cache records in groups of 30 records.
 pRstRoySched->MoveFirst();
 pRstRoySched->CacheSize = 30;

 sngStart = GetTickCount();

 // Enumerate the Recordset object twice and record
 // the elapsed time.
 for (intLoop = 1;intLoop < 2; intLoop++)
 {
 pRstRoySched->MoveFirst();
 while(!(pRstRoySched->EndOfFile))
 {
 // Execute a simple operation for the
 // performance test.
 strTemp = pRstRoySched->Fields->
 Item["title_id"]->Value;
 pRstRoySched->MoveNext();
 }
 }
 sngEnd = GetTickCount();
 sngCache = (float)(sngEnd - sngStart)/(float)1000;

 // Display performance results.
 printf("Caching Performance Results:\n");
 printf("No cache: %6.3f seconds \n", sngNoCache);
 printf("30-record cache: %6.3f seconds \n", sngCache);
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _variant_t vtConnect = pRstRoySched->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 // Pass a connection pointer accessed from the Recordset.
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 if (pRstRoySched)
 if (pRstRoySched->State == adStateOpen)
 pRstRoySched->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.

 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s", pErr->Number,
 pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);

}
// EndCacheSizeCpp


ExecuteOptionEnum

 Copy code hover
[image]

ExecuteOptionEnum
Send feedback

Specifies how a provider should execute a command.

Constant | Value | Description
adAsyncExecute | 0x10 | Indicates that the command should execute asynchronously. This value cannot be combined with the CommandTypeEnum value adCmdTableDirect.
adAsyncFetch | 0x20 | Indicates that the remaining rows after the initial quantity specified in the CacheSize property should be retrieved asynchronously.
adAsyncFetchNonBlocking | 0x40 | Indicates that the main thread never blocks while retrieving. If the requested row has not been retrieved, the current row automatically moves to the end of the file. If you open a Recordset from a Stream containing a persistently stored Recordset, adAsyncFetchNonBlocking will not have an effect; the operation will be synchronous and blocking. adAsynchFetchNonBlocking has no effect when the adCmdTableDirect option is used to open the Recordset.
adExecuteNoRecords | 0x80 | Indicates that the command text is a command or stored procedure that does not return rows (for example, a command that only inserts data). If any rows are retrieved, they are discarded and not returned. adExecuteNoRecords can only be passed as an optional parameter to the Command or Connection Execute method.
adExecuteStream | 0x400 | Indicates that the results of a command execution should be returned as a stream. adExecuteStream can only be passed as an optional parameter to the Command Execute method.
adExecuteRecord |  | Indicates that the CommandText is a command or stored procedure that returns a single row which should be returned as a Record object.
adOptionUnspecified | -1 | Indicates that the command is unspecified.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.ExecuteOption.ASYNCEXECUTE

AdoEnums.ExecuteOption.ASYNCFETCH

AdoEnums.ExecuteOption.ASYNCFETCHNONBLOCKING

AdoEnums.ExecuteOption.NORECORDS

AdoEnums.ExecuteOption.UNSPECIFIED


SharedResource Members (Access)

 Copy code hover
[image]

SharedResource Members (Access)
Send feedback

Published: July 16, 2012

Represents a Microsoft Office theme or image that is available as a shared resource in the database.

Methods

Name | Description
Delete | Deletes the specified object.

Properties

Name | Description
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Type | Gets the type of the SharedResource object. Read-only AcResourceType.


AbsolutePage, PageCount, and PageSize Properties Example (VB)

 Copy code hover
[image]

AbsolutePage, PageCount, and PageSize Properties Example (VB)
Send feedback
Copy code Copy code

'BeginAbsolutePageVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 'recordset and connection variables
 Dim rstEmployees As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim strSQL As String
 'record variables
 Dim strMessage As String
 Dim intPage As Integer
 Dim intPageCount As Integer
 Dim intRecord As Integer

 'Open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open employee recordset
 ' Use client cursor to enable AbsolutePosition property
 Set rstEmployees = New ADODB.Recordset
 strSQL = "employee"
 rstEmployees.Open strSQL, strCnxn, adUseClient, adLockReadOnly, adCmdTable

 ' Display names and hire dates, five records at a time
 rstEmployees.PageSize = 5
 intPageCount = rstEmployees.PageCount
 For intPage = 1 To intPageCount
 rstEmployees.AbsolutePage = intPage
 strMessage = ""
 For intRecord = 1 To rstEmployees.PageSize
 strMessage = strMessage & _
 rstEmployees!fname & " " & _
 rstEmployees!lname & " " & _
 rstEmployees!hire_date & vbCr
 rstEmployees.MoveNext
 If rstEmployees.EOF Then Exit For
 Next intRecord
 MsgBox strMessage
 Next intPage

 ' clean up
 rstEmployees.Close
 Cnxn.Close
 Set rstEmployees = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstEmployees Is Nothing Then
 If rstEmployees.State = adStateOpen Then rstEmployees.Close
 End If
 Set rstEmployees = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndAbsolutePageVB


WebBrowserControl Members (Access)

 Copy code hover
[image]

WebBrowserControl Members (Access)
Send feedback

Published: July 16, 2012

Represents a Web browser control on a form.

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeNavigate2 | Occurs before navigation occurs in the given WebBrowserControl.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Change | The Change event occurs when the contents of the specified control changes.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Dirty | The Dirty event occurs when the contents of the specified control changes.
DocumentComplete | Occurs when a document is completely loaded and initialized.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.
NavigateError | Occurs when an error occurs during navigation.
ProgressChange | Occurs when the progress of a download operation is updated.
Updated | The Updated event occurs when an OLE object's data has been modified.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.
Undo | You can use the Undo method to reset a control or form when its value has been changed.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
GridlineColor | Gets or sets the color of the gridline for the specified list box. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified list box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified text box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified text box. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified text box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified text box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified text box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the text box is anchored horizontally within its layout. Read/write.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
Layout | Returns the type of layout for the specified text box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified text box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.
LocationURL | Gets the Uniform Resource Locator (URL) of the current document. Read-only String.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Object | You can use the Object property in Visual Basic to return a reference to the ActiveX object that is associated with a linked or embedded OLE object in a control. By using this reference, you can access the properties or invoke the methods of the OLE object. Read-only Object.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnBeforeNavigate | Gets or sets the value of the On Before Navigate box in the property sheet os a Web Browser control. Read/write String.
OnDocumentComplete | Gets or sets the value of the On Document Complete box in the property sheet os a Web Browser control. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnNavigateError | Gets or sets the value of the On Navigate Error box in the property sheet os a Web Browser control. Read/write String.
OnProgressChange | Gets or sets the value of the On Progress Change box in the property sheet os a Web Browser control. Read/write String.
OnUpdated | Sets or returns the value of the On Updated box in the Properties window of a form or report. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Progress | Specifies the amount of total progress of a download operation. Read-only Long.
Properties | Returns a reference to a control's Properties collection object. Read-only.
ReadyState | Gets the status of the specified Web Browser control. Read-only AcWebBrowserState.
RightPadding | Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.
ScrollBars | You can use the ScrollBars property to specify whether scroll bars appear on a text box control. Read/write Byte.
ScrollLeft | Gets or sets the distance, in pixels, between the left edge of the WebBrowser object and the leftmost portion of the content currently visible in the control. Read/write Long.
ScrollTop | Gets or sets the distance, in pixels, between the top edge of the WebBrowser object and the topmost portion of the content currently visible in the control. Read/write Long.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.
Transform | Read/write
Value | Determines or specifies the text in the text box. Read/write Variant.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified text box is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


OptionButton Events (Access)

 Copy code hover
[image]

OptionButton Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.


Cannot delete spreadsheet cells. (Error 3435)

 Copy code hover
[image]

Cannot delete spreadsheet cells. (Error 3435)
Send feedback

Data in the specified spreadsheet range of cells cannot be deleted. These cells may contain formulas, or they may be protected cells.


The expression you are trying to use for the DefaultValue property is invalid because

 Copy code hover
[image]

The expression you are trying to use for the DefaultValue property is invalid because <error text>. Use a valid expression to set this property. (Error 3406)
Send feedback

The expression you are trying to use for the DefaultValue property is invalid. Set the property to a valid expression.


Recordset.DateCreated Property (DAO)

 Copy code hover
[image]

Recordset.DateCreated Property (DAO)
Send feedback

Returns the date and time a base table was created (Microsoft Access workspaces only). Read-only Variant.

Syntax

expression .DateCreated

expression A variable that represents a Recordset object.

Remarks

The date and time settings are derived from the computer on which the base table was created or last updated.


Connect Property Example (VBScript)

 Copy code hover
[image]

Connect Property Example (VBScript)
Send feedback

This code shows how to set the Connect property at design time:

Copy code Copy code

<OBJECT CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID="ADC1">
.
   <PARAM NAME="SQL" VALUE="Select * from Sales">
   <PARAM NAME="CONNECT" VALUE="Provider=SQLOLEDB;Integrated Security=SSPI;Initial Catalog=Pubs">
   <PARAM NAME="Server" VALUE="http://MyWebServer">
.
</OBJECT>

The following example shows how to set the Connect property at run time in VBScript code.

To test this example, copy and paste this code between the <Body> and </Body> tags in a normal HTML document and name it ConnectVBS.asp. ASP script will identify your server.

VBS Copy code Copy code
<!-- BeginConnectVBS --><%@ Language=VBScript %>
<HTML><HEAD>
<title>ADO Connect Property</title><%' local style sheet used for display%>
<STYLE><!--
BODY {font-family: 'Verdana','Arial','Helvetica',sans-serif;
BACKGROUND-COLOR:white;COLOR:black;
}.tbody {
text-align: center;background-color: #f7efde;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
}-->
</STYLE></HEAD>
<BODY><h1>ADO Connect Property (RDS)</h1>
<HR><H3>Set Connect Property at Run Time</H3>
<% ' RDS.DataControl with no parameters set at design time %><OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID=RDS HEIGHT=1 WIDTH=1></OBJECT>
<% ' Bind table to control for data display %><TABLE DATASRC=#RDS>
<TBODY><TR class="tbody">
<TD><SPAN DATAFLD="FirstName"></SPAN></TD><TD><SPAN DATAFLD="LastName"></SPAN></TD>
</TR></TBODY>
</TABLE><FORM name="frmInput">
SERVER: <INPUT Name="txtServer" Size="103" Value="http://<%=Request.ServerVariables("SERVER_NAME")%>"><BR>DATA SOURCE: <INPUT Name="txtDataSource" Size="93" Value="<%=Request.ServerVariables("SERVER_NAME")%>"><BR>
CONNECT: <INPUT Name="txtConnect" Size="100"><BR>SQL: <INPUT Name="txtSQL" Size="110" Value="Select FirstName, LastName from Employees">
<BR><INPUT TYPE=BUTTON NAME="Run" VALUE="Run">
<h4>To make data grid appear, click 'Run' to see the connect string in text box above.
</h4></FORM>
<Script Language="VBScript">' Set parameters of RDS.DataControl at Run Time
Sub Run_OnClickDim Cnxn
' build connection stringCnxn = "Provider='sqloledb';"
Cnxn = Cnxn & "Data Source="Cnxn = Cnxn & document.frmInput.txtDataSource.value & ";"
Cnxn = Cnxn & "Initial Catalog='Northwind';"Cnxn = Cnxn & "Integrated Security='SSPI';"
' assign the valuedocument.frmInput.txtConnect.value = Cnxn
MsgBox "Here we go!"' set RDS properties
RDS.Server = document.frmInput.txtServer.valueRDS.SQL = document.frmInput.txtSQL.value
RDS.Connect = document.frmInput.txtConnect.valueRDS.Refresh
End Sub</Script>
</BODY></HTML>
<!-- EndConnectVBS -->


AllDatabaseDiagrams.Application Property (Access)

 Copy code hover
[image]

AllDatabaseDiagrams.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents an AllDatabaseDiagrams object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

AllDatabaseDiagrams Collection

Other resources

AllDatabaseDiagrams Object Members


ToggleButton.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

ToggleButton.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents a ToggleButton object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BorderThemeColorIndex=2

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


ObjectFrame.Layout Property (Access)

 Copy code hover
[image]

ObjectFrame.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified object frame. Read-only AcLayoutType.

Version Information

Version Added: Access 2007

Syntax

expression .Layout

expression A variable that represents an ObjectFrame object.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


NavigationButton.Enter Event (Access)

 Copy code hover
[image]

NavigationButton.Enter Event (Access)
See also Send feedback

Published: July 16, 2012

The Enter event occurs before a control actually receives the focus from a control on the same form or report.

Version Information

Version Added: Access 2010

Syntax

expression .Enter

expression A variable that represents a NavigationButton object.

Return Value

nothing

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when these events occur, set the OnEnter or OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Enter event occurs before the GotFocus event. The Exit event occurs before the LostFocus event.

Unlike the GotFocus and LostFocus events, the Enter and Exit events don't occur when a form receives or loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


OptionButton Methods (Access)

 Copy code hover
[image]

OptionButton Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.


NavigationButton.Tag Property (Access)

 Copy code hover
[image]

NavigationButton.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .Tag

expression A variable that represents a NavigationButton object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Introduction to ADO

 Copy code hover
[image]

Introduction to ADO
Send feedback

In this section

  • Introduction to ADO Programming

  • What's New in ADO

  • Prerequisites (ADO Introduction)

  • The ADO Family of Libraries

  • The Role of ADO in Microsoft Data Access

  • ADO Task Table

  • ADO Technology Table

  • ADO Glossary


Attributes Property Example (VB)

 Copy code hover
[image]

Attributes Property Example (VB)
Send feedback

This example demonstrates the Attributes property of a Column. Setting it to adColNullable allows the user to set the value of a Recordset Field to an empty string. In this situation, the user can distinguish between a record where data is not known and a record where the data does not apply.

Copy code Copy code

' BeginAttributesVB
Sub Main()
 On Error GoTo AttributesXError

 Dim cnn As New ADODB.Connection
 Dim cat As New ADOX.Catalog
 Dim colTemp As New ADOX.Column
 Dim rstEmployees As New Recordset
 Dim strMessage As String
 Dim strInput As String
 Dim tblEmp As ADOX.Table

 ' Connect the catalog.
 cnn.Open "Provider='Microsoft.Jet.OLEDB.4.0';data source=" & _
 "'c:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb';"
 Set cat.ActiveConnection = cnn

 Set tblEmp = cat.Tables("Employees")

 ' Create a new Field object and append it to the Fields
 ' collection of the Employees table.
 colTemp.Name = "FaxPhone"
 colTemp.Type = adVarWChar
 colTemp.DefinedSize = 24
 colTemp.Attributes = adColNullable
 cat.Tables("Employees").Columns.Append colTemp.Name, adWChar, 24

 ' Open the Employees table for updating as a Recordset
 rstEmployees.Open "Employees", cnn, adOpenKeyset, adLockOptimistic, adCmdTable

 With rstEmployees
 ' Get user input.
 strMessage = "Enter fax number for " & _
 !FirstName & " " & !LastName & "." & vbCr & _
 "[? - unknown, X - has no fax]"
 strInput = UCase(InputBox(strMessage))
 If strInput <> "" Then
 Select Case strInput
 Case "?"
 !FaxPhone = Null
 Case "X"
 !FaxPhone = ""
 Case Else
 !FaxPhone = strInput
 End Select
 .Update

 ' Print report.
 Debug.Print "Name - Fax number"
 Debug.Print !FirstName & " " & !LastName & " - ";

 If IsNull(!FaxPhone) Then
 Debug.Print "[Unknown]"
 Else
 If !FaxPhone = "" Then
 Debug.Print "[Has no fax]"
 Else
 Debug.Print !FaxPhone
 End If
 End If

 End If

 .Close
 End With

 'Clean up
 tblEmp.Columns.Delete colTemp.Name
 cnn.Close
 Set rstEmployees = Nothing
 Set cat = Nothing
 Set colTemp = Nothing
 Set cnn = Nothing
 Exit Sub

AttributesXError:

 If Not rstEmployees Is Nothing Then
 If rstEmployees.State = adStateOpen Then rstEmployees.Close
 End If
 Set rstEmployees = Nothing

 If Not tblEmp Is Nothing Then tblEmp.Columns.Delete colTemp.Name

 Set cat = Nothing
 Set colTemp = Nothing

 If Not cnn Is Nothing Then
 If cnn.State = adStateOpen Then cnn.Close
 End If
 Set cnn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If

End Sub
' EndAttributesVB


MessageBox Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

MessageBox Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

You can use the MessageBox action to display a message box containing a warning or an informational message. For example, you can use the MessageBox action with validation macros. When a control or record fails a validation condition in the macro, a message box can display an error message and provide instructions about the kind of data that should be entered.

Setting

The MessageBox action has the following argument.

Action argument | Description
Message | The text in the message box. You can type up to 255 characters or enter an expression (preceded by an equal sign).


Form.UseDefaultPrinter Property (Access)

 Copy code hover
[image]

Form.UseDefaultPrinter Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Boolean indicating whether the specified form uses the default printer for the system; True if the form or report uses the default printer. Read/write.

Syntax

expression .UseDefaultPrinter

expression A variable that represents a Form object.

Remarks

This property is read/write in Design view and read-only in all other views.

When this property is True, the form or report inherits all of its printer settings from the settings of the default printer. Changing the printer associated with a form or report by assigning its Printer property to a Printer object sets the UseDefaultPrinter property to False.

Example

The following example checks to see if the specified form is using the default printer; if not, the user is asked if it should.

VBA Copy code Copy code
Function CheckPrinter(frmTemp As Form) As Boolean

 If frmTemp.UseDefaultPrinter = False Then
 If MsgBox("Should this form use " _
 & "the default printer?", _
 vbYesNo) = vbYes Then
 frmTemp.UseDefaultPrinter = True
 End If
 End If

End Function

See also

Concepts

Form Object

Other resources

Form Object Members


BoundObjectFrame.GridlineTint Property (Access)

 Copy code hover
[image]

BoundObjectFrame.GridlineTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineTint

expression A variable that represents a BoundObjectFrame object.

Remarks

The GridlineTint property contains a numeric expression that can be used to lighten the theme color in the GridlineColor property. The default value of the GridlineTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Field2.CreateProperty Method (DAO)

 Copy code hover
[image]

Field2.CreateProperty Method (DAO)
Send feedback

Creates a new user-defined Property object (Microsoft Access workspaces only).

Syntax

expression .CreateProperty(Name, Type, Value, DDL)

expression A variable that represents a Field2 object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Optional | Variant | A String that uniquely names the new Property object. See the Name property for details on valid Property names.
Type | Optional | Variant | A constant that defines the data type of the new Property object. See the Type property for valid data types.
Value | Optional | Variant | A Variant containing the initial property value. See the Value property for details.
DDL | Optional | Variant | A Variant (Boolean subtype) that indicates whether or not the Property is a DDL object. The default is False. If DDL is True, users can't change or delete this Property object unless they have dbSecWriteDef permission.

Return Value

Property

Remarks

You can create a user-defined Property object only in the Properties collection of an object that is persistent.

If you omit one or more of the optional parts when you use CreateProperty, you can use an appropriate assignment statement to set or reset the corresponding property before you append the new object to a collection. After you append the object, you can alter some but not all of its property settings. See the Name, Type, and Value property topics for more details.

If name refers to an object that is already a member of the collection, a run-time error occurs when you use the Append method.

To remove a user-defined Property object from the collection, use the Delete method on the Properties collection. You can't delete built-in properties.

Note Note

If you omit the DDL argument, it defaults to False (non-DDL). Because no corresponding DDL property is exposed, you must delete and re-create a Property object you want to change from DDL to non-DDL.


Label.Visible Property (Access)

 Copy code hover
[image]

Label.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents a Label object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

Label Object

Other resources

Label Object Members


Open and Close Methods Example (VJ++)

 Copy code hover
[image]

Open and Close Methods Example (VJ++)
Send feedback

This example uses the Open and Close methods on both Recordset and Connection objects that have been opened.

Copy code Copy code

// BeginOpenJ
import com.ms.wfc.data.*;
import java.io.* ;
import com.ms.com.*;

public class OpenX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 OpenX();
 System.exit(0);
 }

 // OpenX function

 static void OpenX()
 {

 // Define ADO Objects.
 Connection cnConn1 = null;
 Recordset rstEmployees = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";
 Variant varDate;
 String strHDate;

 try
 {
 // Open connection.
 cnConn1 = new Connection();
 cnConn1.open(strCnn);

 // Open Employees table.
 rstEmployees = new Recordset();
 rstEmployees.setCursorType(AdoEnums.CursorType.KEYSET);
 rstEmployees.setLockType(AdoEnums.LockType.OPTIMISTIC);
 rstEmployees.open("Employee", cnConn1,
 AdoEnums.CursorType.KEYSET,
 AdoEnums.LockType.OPTIMISTIC,
 AdoEnums.CommandType.TABLE);

 // Assign the first employee record's hire date
 // to a variable, then change the hire date.
 varDate = rstEmployees.getField("hire_date").getOriginalValue();
 System.out.println("Original data\n");
 System.out.println("\tName - Hire Date");
 strHDate = rstEmployees.getField("hire_date").getString();
 strHDate = strHDate.substring(5,7) + "/" +
 strHDate.substring(8,10)
 + "/" + strHDate.substring(2,4);
 System.out.println("\t" +
 rstEmployees.getField("fName").getString()+ " "
 + rstEmployees.getField("lName").getString()+ " - "
 + strHDate);
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 rstEmployees.getField("hire_date").setString("1/1/1900");
 rstEmployees.update();
 System.out.println("Changed data\n");
 System.out.println("\tName - Hire Date");
 strHDate = rstEmployees.getField("hire_date").getString();
 strHDate = strHDate.substring(5,7) + "/" +
 strHDate.substring(8,10)
 + "/" + strHDate.substring(0,4);
 System.out.println("\t" +
 rstEmployees.getField("fName").getString()+ " "
 + rstEmployees.getField("lName").getString()+ " - "
 + strHDate);
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();

 // Requery Recordset and reset the hire date.
 rstEmployees.requery();
 rstEmployees.getField("hire_date").setValue(varDate);
 rstEmployees.update();
 System.out.println("Data after reset\n");
 System.out.println("\tName - Hire Date");
 strHDate = rstEmployees.getField("hire_date").getString();
 strHDate = strHDate.substring(5,7) + "/" +
 strHDate.substring(8,10)
 + "/" + strHDate.substring(2,4);
 System.out.println("\t" +
 rstEmployees.getField("fName").getString()+ " "
 + rstEmployees.getField("lName").getString()+ " - "
 + strHDate);
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstEmployees != null)
 {
 PrintProviderError(rstEmployees.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }

 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstEmployees != null)
 if (rstEmployees.getState() == 1)
 rstEmployees.close();
 // Cleanup objects before exit.
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 }

 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndOpenJ


Syntax error in DROP INDEX statement. (Error 3294)

 Copy code hover
[image]

Syntax error in DROP INDEX statement. (Error 3294)
Send feedback

You entered an SQL statement that has an invalid DROP INDEX statement.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


Container Members (DAO)

 Copy code hover
[image]

Container Members (DAO)
Send feedback

A Container object groups similar types of Document objects together.

Properties

Name | Description
Documents | Returns a Documents collection that contains all of the documents stored in the specified object. Read-only.
Name | Returns the name of the specified object. Read-only String.
Properties | Returns the Properties collection of the specified object. Read-only.


NavigationButton.FontBold Property (Access)

 Copy code hover
[image]

NavigationButton.FontBold Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontBold property to specify whether a font appears in a bold style in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .FontBold

expression A variable that represents a NavigationButton object.

Remarks

The FontBold property uses the following settings.

Setting | Description
True | The text is bold.
False | (Default) The text isn't bold.

To use the FontBold property on a report, first create a Printevent procedure that prints the desired text.

A font's appearance on screen and in print may differ, depending on your computer and printer.

The FontWeight property, which is available in the property sheet for controls, can also be used to set the line width for a control's text. The FontBold property gives you a quick way to make text bold; the FontWeight property gives you finer control over the line width setting for text. The following table shows the relationship between these properties' settings.

If | Then
FontBold = False | FontWeight = Normal (400)
FontBold = True | FontWeight = Bold (700)
FontWeight < 700 | FontBold = False
FontWeight > = 700 | FontBold = True

Example

The following Print event procedure prints a report title and the current date in a bold style on a report at the coordinates specified by the CurrentX and CurrentY property settings.

VBA Copy code Copy code
Private Sub ReportHeader0_Print(Cancel As Integer, _
 PrintCount As Integer)
 Dim MyDate

 MyDate = Date
 Me.FontBold = True
 ' Print report title in bold.
 Me.Print("Sales Management Report")
 Me.Print(MyDate)
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Status Property Example (VJ++)

 Copy code hover
[image]

Status Property Example (VJ++)
Send feedback

This example uses the Status property to display which records have been modified in a batch operation before a batch update has occurred.

Copy code Copy code

// BeginStatusJ
import java.io.*;
import com.ms.wfc.data.*;

public class StatusX
{
 // The main entry point of the application.

 public static void main (String[] args)
 {
 StatusX();
 System.exit(0);
 }
 // StatusX Function

 static void StatusX()
 {
 // Define ADO Objects.
 Recordset rstTitles = null;

 // Declarations.
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"+
 "Initial Catalog='Pubs';Integrated Security='SSPI';";
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));

 try
 {
 // Open Recordset for batch update.
 rstTitles = new Recordset();
 rstTitles.setCursorType(AdoEnums.CursorType.KEYSET);
 rstTitles.setLockType(AdoEnums.LockType.BATCHOPTIMISTIC);
 rstTitles.open("Titles", strCnn, AdoEnums.CursorType.KEYSET,
 AdoEnums.LockType.BATCHOPTIMISTIC,
 AdoEnums.CommandType.TABLE);

 // Change the type of psychology titles.
 while(!rstTitles.getEOF())
 {
 if(rstTitles.getField("Type").getString().trim().
 equals(new String("psychology")))
 rstTitles.getField("Type").setString("self_help");

 rstTitles.moveNext();
 }

 // Display Title ID and status.
 rstTitles.moveFirst();

 while(!rstTitles.getEOF())
 {
 if(rstTitles.getStatus()==AdoEnums.RecordStatus.MODIFIED)
 System.out.println(rstTitles.getField("title_id").
 getString() + "- Modified");
 else
 System.out.println(rstTitles.getField("title_id").
 getString());
 rstTitles.moveNext();
 }

 // Cancel the update because this is a demonstration.
 rstTitles.cancelBatch();

 System.out.println("Press <Enter> to continue..");
 in.readLine();
 }
 catch(AdoException ae)
 {
 // Notify the user of any errors that result from ADO.

 // As passing a Recordset, check for the null pointer first.
 if(rstTitles != null)
 {
 PrintProviderError(rstTitles.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 // System read requires this catch.
 catch(java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstTitles != null)
 if (rstTitles.getState() == 1)
 rstTitles.close();
 }
 }
 // PrintProviderError Function
 static void PrintProviderError(Connection cnn1)
 {
 // Print Provider Errors from Connection Object.
 // ErrItem is an item object in the Connections Errors Collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if ( nCount > 0)
 {
 // Collection ranges from 0 to nCount-1.
 for ( i=0;i<nCount; i++)
 {
 ErrItem = cnn1.getErrors().getItem(i);
 System.out.println("\t Error Number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription());
 }
 }
 }
 // PrintIOError Function
 static void PrintIOError(java.io.IOException je)
 {
 System.out.println("Error: \n");
 System.out.println("\t Source: " + je.getClass() + "\n");
 System.out.println("\t Description: "+ je.getMessage() + "\n");
 }
}
// EndStatusJ


ToggleButton.Exit Event (Access)

 Copy code hover
[image]

ToggleButton.Exit Event (Access)
See also Send feedback

Published: July 16, 2012

The Exit event occurs just before a control loses the focus to another control on the same form or report.

Syntax

expression .Exit(Cancel)

expression A variable that represents a ToggleButton object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | Set to True to cancel the event.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when this event occurs, set the OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Exit event occurs before the LostFocus event.

Unlike the LostFocus event, the Exit event does not occur when a form loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


ComboBox.OnEnter Property (Access)

 Copy code hover
[image]

ComboBox.OnEnter Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnEnter

expression A variable that represents a ComboBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Enter event occurs before a control actually receives the focus from a control on the same form.

The OnEnter value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Enter box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Enter box is blank, the property value is an empty string.

Example

The following example associates the Enter event with the macro "Enter_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnEnter = "Enter_Macro"

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Page.OnClick Property (Access)

 Copy code hover
[image]

Page.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Syntax

expression .OnClick

expression A variable that represents a Page object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

Page Object

Other resources

Page Object Members


Attachment.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

Attachment.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click the specified object. Read/write String.

Syntax

expression .ShortcutMenuBar

expression A variable that represents an Attachment object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


DependencyInfo Members (Access)

 Copy code hover
[image]

DependencyInfo Members (Access)
Send feedback

Published: July 16, 2012

Represents the dependency information for an AccessObject object.

Properties

Name | Description
Dependants | Returns a DependencyObjects collection that represents the objects that depend upon the specified AccessObject object. Read-only.
Dependencies | Returns a DependencyObjects collection that represents the objects that the specified AccessObject object depends upon. Read-only.
InsufficientPermissions | Returns a DependencyObjects collection that contains a collection of objects to which you don't have sufficient permissions to check for dependencies. Read-only.
OutOfDateObjects | Returns a DependencyObjects collection that represents the AccessObject objects for which the dependency information is outdated. Read-only.
Parent | Returns the parent object for the specified object. Read-only.
UnsupportedObjects | Returns a DependencyObjects collection that contains objects that cannot be searched for dependency. Read-only.


Item Property Example (VJ++)

 Copy code hover
[image]

Item Property Example (VJ++)
Send feedback

This example demonstrates how the Item property accesses members of a collection. The example opens the Authors table of the Pubs database with a parameterized command.

The parameter in the command issued against the database is accessed from the Command object's Parameters collection by index and name. Then the fields of the returned Recordset are accessed from that object's Fields collection by index and name.

Copy code Copy code

// BeginItemJ
import com.ms.wfc.data.*;
import java.io.* ;
import com.ms.com.*;

public class ItemX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 ItemX();
 System.exit(0);
 }

 // ItemX function

 static void ItemX()
 {

 // Define ADO Objects.
 Connection cnConn1 = null;
 Recordset rstAuthors = null;
 Command cmd = null;
 Parameter prm = null;
 Field fld = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';" +
 "Initial Catalog='Pubs';Integrated Security='SSPI';";
 Variant [] varColumn = null;
 int intIndex;
 int intLimit;

 try
 {
 cnConn1 = new Connection();
 rstAuthors = new Recordset();
 cmd = new Command();

 // Set the array with the Authors table field (column) names.
 varColumn = new Variant[9];
 varColumn[0] = new Variant("au_id");
 varColumn[1] = new Variant("au_lname");
 varColumn[2] = new Variant("au_fname");
 varColumn[3] = new Variant("phone");
 varColumn[4] = new Variant("address");
 varColumn[5] = new Variant("city");
 varColumn[6] = new Variant("state");
 varColumn[7] = new Variant("zip");
 varColumn[8] = new Variant("contract");

 cmd.setCommandText("SELECT * FROM Authors WHERE state = ?");
 prm = cmd.createParameter("ItemXparm",
 AdoEnums.DataType.CHAR,
 AdoEnums.ParameterDirection.INPUT,
 2,
 "CA");
 cmd.getParameters().append(prm);

 cnConn1.open(strCnn);
 cmd.setActiveConnection(cnConn1);

 // Connection and CommandType are omitted
 // because a Command Object is provided.
 rstAuthors.open(cmd,
 null ,
 AdoEnums.CursorType.STATIC,
 AdoEnums.LockType.READONLY);

 System.out.println(
 "The Parameters collection accessed by index...");
 prm = cmd.getParameters().getItem(0);
 System.out.println("Parameter name = '" +
 prm.getName() +
 "', value = '" +
 prm.getValue().toString() + "'\n");

 System.out.println(
 "The Parameters collection accessed by name...");
 prm = cmd.getParameters().getItem("ItemXparm");
 System.out.println("Parameters name = '" +
 prm.getName() +
 "', value = '" +
 prm.getValue().toString() + "'\n");
 System.out.println("Press <Enter> to continue..");
 in.readLine();

 System.out.println(
 "The Fields collection accessed by index...");
 rstAuthors.moveFirst();
 intLimit = rstAuthors.getFields().getCount() - 1;
 for(intIndex = 0; intIndex <= intLimit; intIndex++)
 {
 fld = rstAuthors.getFields().getItem(intIndex);
 short intVtType = fld.getValue().getvt();
 String strFieldValue;
 switch(intVtType)
 {
 case Variant.VariantString :
 strFieldValue = fld.getValue().toString();
 break;
 case Variant.VariantBoolean :
 if(fld.getValue().getBoolean())
 strFieldValue = "True";
 else
 strFieldValue = "False";
 break;
 default :
 strFieldValue = fld.getValue().toString();
 break;
 }
 System.out.println("Field " +
 Integer.toString(intIndex) +
 " : Name = '" +
 fld.getName() +
 "', value = '" +
 strFieldValue +
 "'");
 }
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();

 System.out.println("The Fields collection accessed by name...");
 rstAuthors.moveFirst();
 for(intIndex = 0; intIndex <= 8; intIndex++)
 {
 fld = rstAuthors.getFields().getItem
 (varColumn[intIndex].toString());
 short intVtType = fld.getValue().getvt();
 String strFieldValue;
 switch(intVtType)
 {
 case Variant.VariantString :
 strFieldValue = fld.getValue().toString();
 break;
 case Variant.VariantBoolean :
 if(fld.getValue().getBoolean())
 strFieldValue = "True";
 else
 strFieldValue = "False";
 break;
 default :
 strFieldValue = fld.getValue().toString();
 break;
 }
 System.out.println("Field " +
 "name = '" +
 fld.getName() +
 "', value = '" +
 strFieldValue +
 "'");
 }
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstAuthors != null)
 {
 PrintProviderError(rstAuthors.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstAuthors != null)
 if (rstAuthors.getState() == 1)
 rstAuthors.close();
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndItemJ


CancelBatch Method (ADO)

 Copy code hover
[image]

CancelBatch Method (ADO)
Send feedback

Cancels a pending batch update.

Syntax

recordset.CancelBatch AffectRecords

Parameters

  • AffectRecords

  • Optional. An AffectEnum value that indicates how many records the CancelBatch method will affect.

Remarks

Use the CancelBatch method to cancel any pending updates in a Recordset in batch update mode. If the Recordset is in immediate update mode, calling CancelBatch without adAffectCurrent generates an error.

If you are editing the current record or are adding a new record when you call CancelBatch, ADO first calls the CancelUpdate method to cancel any cached changes. After that, all pending changes in the Recordset are canceled.

It's possible that the current record will be indeterminable after a CancelBatch call, especially if you were in the process of adding a new record. For this reason, it is prudent to set the current record position to a known location in the Recordset after the CancelBatch call. For example, call the MoveFirst method.

If the attempt to cancel the pending updates fails because of a conflict with the underlying data (for example, a record has been deleted by another user), the provider returns warnings to the Errors collection but does not halt program execution. A run-time error occurs only if there are conflicts on all the requested records. Use the Filter property (adFilterAffectedRecords) and the Status property to locate records with conflicts.


ObjectFrame.ColumnCount Property (Access)

 Copy code hover
[image]

ObjectFrame.ColumnCount Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnCount property to specify the number of columns displayed in a list box or in the list box portion of a combo box, or sent to OLE objects in a chart control or unbound object frame . Read/write Integer.

Syntax

expression .ColumnCount

expression A variable that represents an ObjectFrame object.

Remarks

The ColumnCount property holds an integer between 1 and the maximum number of fields in the table, query, or SQL statement, or the maximum number of values in the value list, specified in the RowSource property of the control.

For table fields , you can set this property on the Lookup tab in the Field Properties section of table Design view for fields with the DisplayControl property set to Combo Box or List Box.

For example, if you set the ColumnCount property for a list box on an Employees form to 3, one column can list last names, another can list first names, and the third can list employee ID numbers.

A combo box or list box can have multiple columns. If the control's RowSource property contains the name of a table, query, or SQL statement, a combo box or list box will display the fields from that source, from left to right, up to the number specified by the ColumnCount property.

To display a different combination of fields, create either a new query or a new SQL statement for the RowSource property, specifying the fields and the order you want.

If the RowSource property contains a list of values (the RowSourceType property is set to Value List), the values are put into the rows and columns of the combo box or list box in the order they are listed in the RowSource property. For example, if the RowSource property contains the list "Red; Green; Blue; Yellow" and the ColumnCount property is set to 2, the first row of the combo box or list box list will contain "Red" in the first column and "Green" in the second column. The second row will contain "Blue" in the first column and "Yellow" in the second column.

You can use the ColumnWidths property to set the width of the columns displayed in the control, or to hide columns.

Example

The following example uses the Column property and the ColumnCount property to print the values of a list box selection.

VBA Copy code Copy code
Public Sub Read_ListBox()

 Dim intNumColumns As Integer
 Dim intI As Integer
 Dim frmCust As Form

 Set frmCust = Forms!frmCustomers
 If frmCust!lstCustomerNames.ItemsSelected.Count > 0 Then

 ' Any selection?
 intNumColumns = frmCust!lstCustomerNames.ColumnCount
 Debug.Print "The list box contains "; intNumColumns; _
 IIf(intNumColumns = 1, " column", " columns"); _
 " of data."

 Debug.Print "The current selection contains:"
 For intI = 0 To intNumColumns - 1
 ' Print column data.
 Debug.Print frmCust!lstCustomerNames.Column(intI)
 Next intI
 Else
 Debug.Print "You haven't selected an entry in the " _
 & "list box."
 End If

 Set frmCust = Nothing

End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


CommandButton.HoverForeShade Property (Access)

 Copy code hover
[image]

CommandButton.HoverForeShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .HoverForeShade

expression A variable that represents a CommandButton object.

Remarks

The HoverForeShade property contains a numeric expression that can be used to darken the theme color in the HoverForeColor property. The default value of the HoverForeShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Object is invalid for operation. (Error 3350)

 Copy code hover
[image]

Object is invalid for operation. (Error 3350)
Send feedback

You used the RefreshLink method on an object other than a linked table. An object ceases to exist when it is destroyed and when its associated DAO object is closed or is no longer defined in the current scope.


ListBox.ValidationText Property (Access)

 Copy code hover
[image]

ListBox.ValidationText Property (Access)
See also Send feedback

Published: July 16, 2012

Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.

Syntax

expression .ValidationText

expression A variable that represents a ListBox object.

Remarks

Enter an expression for the ValidationRule property setting and text for the ValidationText property setting. The maximum length for the ValidationRule property setting is 2048 characters. The maximum length for the ValidationText property setting is 255 characters.

For controls, you can set the ValidationRule property to any valid expression. For field and record validation rules, the expression can't contain user-defined functions, domain aggregate or aggregate functions, the Eval function, or CurrentUser method, or references to forms, queries, or tables. In addition, field validation rules can't contain references to other fields. For records, expressions can include references to fields in that table.

For table fields and records, you can also set these properties in Visual Basic by using the DAO ValidationRule property.

Microsoft Access automatically validates values based on a field's data type; for example, Microsoft Access doesn't allow text in a numeric field. You can set rules that are more specific by using the ValidationRule property.

If you set the ValidationRule property but not the ValidationText property, Microsoft Access displays a standard error message when the validation rule is violated. If you set the ValidationText property, the text you enter is displayed as the error message.

For example, when a record is added for a new employee, you can enter a ValidationRule property requiring that the value in the employee's StartDate field fall between the company's founding date and the current date. If the date entered isn't in this range, you can display the ValidationText property message: "Start date is incorrect."

If you create a control by dragging a field from the field list, the field's validation rule remains in effect, although it isn't displayed in the control's ValidationRule property box in the property sheet. This is because a field's validation rule is inherited by a control bound to that field.

Control, field, and record validation rules are applied as follows:

  • Validation rules you set for fields and controls are applied when you edit the data and the focus leaves the field or control.

  • Validation rules for records are applied when you move to another record.

  • If you create validation rules for both a field and a control bound to the field, both validation rules are applied when you edit data and the focus leaves the control.

The following table contains expression examples for the ValidationRule and ValidationText properties.

ValidationRule property | ValidationText property
<> 0 | Entry must be a nonzero value.
> 1000 Or Is Null | Entry must be blank or greater than 1000.
Like "A????" | Entry must be 5 characters and begin with the letter "A".
>= #1/1/96# And <#1/1/97# | Entry must be a date in 1996.
DLookup("CustomerID", "Customers", "CustomerID = Forms!Customers!CustomerID") Is Null | Entry must be a unique CustomerID (domain aggregate functions are allowed only for form-level validation).

If you create a validation rule for a field, Microsoft Access doesn't normally allow a Null value to be stored in the field. If you want to allow a Null value, add "Is Null" to the validation rule, as in "<> 8 Or Is Null" and make sure the Required property is set to No.

You can't set field or record validation rules for tables created outside Microsoft Access (for example, dBASE, Paradox, or SQL Server). For these kinds of tables, you can create validation rules for controls only.

Example

The following example creates a validation rule for a field that allows only values over 65 to be entered. If a number less than 65 is entered, a message is displayed. The properties are set by using the SetFieldValidation function.

VBA Copy code Copy code
Dim strTblName As String, strFldName As String
Dim strValidRule As String
Dim strValidText As String, intX As Integer

strTblName = "Customers"
strFldName = "Age"
strValidRule = ">= 65"
strValidText = "Enter a number greater than or equal to 65."
intX = SetFieldValidation(strTblName, strFldName, _
 strValidRule, strValidText)

Function SetFieldValidation(strTblName As String, _
 strFldName As String, strValidRule As String, _
 strValidText As String) As Integer

 Dim dbs As Database, tdf As TableDef, fld As Field

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 Set fld = tdf.Fields(strFldName)
 fld.ValidationRule = strValidRule
 fld.ValidationText = strValidText
End Function

The next example uses the SetTableValidation function to set record-level validation to ensure that the value in the EndDate field comes after the value in the StartDate field.

VBA Copy code Copy code
Dim strTblName As String, strValidRule As String
Dim strValidText As String
Dim intX As Integer

strTblName = "Employees"
strValidRule = "EndDate > StartDate"
strValidText = "Enter an EndDate that is later than the StartDate."
intX = SetTableValidation(strTblName, strValidRule, strValidText)

Function SetTableValidation(strTblName As String, _
 strValidRule As String, strValidText As String) _
 As Integer

 Dim dbs As Database, tdf As TableDef

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 tdf.ValidationRule = strValidRule
 tdf.ValidationText = strValidText
End Function

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


ObjectFrame.Section Property (Access)

 Copy code hover
[image]

ObjectFrame.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Syntax

expression .Section

expression A variable that represents an ObjectFrame object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


ForEachRecord Data Block

 Copy code hover
[image]

ForEachRecord Data Block
Send feedback

A ForEachRecord data block repeats a set of statements for each record in a domain.

Note Note

The ForEachRecord data block is available only in Data Macros.

Setting

The ForEachRecord action has the following arguments.

Argument

Required

Description

In

Yes

A string that identifies the domain of records to operate on. The In argument can contain the name of the table, a select query, or a SQL statement.

Note Note

The specified domain cannot include data stored in a linked table or ODBC data source.

Where Condition

No

A string expression used to restrict the range of data on which the ForEachRecord data block is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the ForEachRecord data block operates on the entire domain specified by the In argument. Any field that is included in criteria must also be a field in In.

Alias

No

A string that provides an alternative name for the domain specified by the In argument. Often used to shorten the table name for subsequent references to prevent possible ambiguous references.If Alias is not specified, the table or query name will be used as the alias.

Remarks

Use the ExitForEachRecord action to exit a ForEachRecord data block immediately.


Ordinal Property (ADO MD Cell)

 Copy code hover
[image]

Ordinal Property (ADO MD Cell)
Send feedback

Uniquely identifies a cell by its position within a cellset.

Return Values

Returns a Long integer and is read-only.

Remarks

The cell's ordinal value uniquely identifies the cell within a cellset. Conceptually, cells are numbered in a cellset as if the cellset were a p-dimensional array, where p is the number of axes. Cells are numbered starting from zero in row-major order.

The cell's ordinal value can be used with the Item property of the Cellset object to quickly retrieve the Cell.


TextBox.ControlSource Property (Access)

 Copy code hover
[image]

TextBox.ControlSource Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.

Syntax

expression .ControlSource

expression A variable that represents a TextBox object.

Remarks

The ControlSource property uses the following settings.

Setting | Description
A field name | The control is bound to a field in a table, query, or SQL statement. Data from the field is displayed in the control. Changes to the data inside the control change the corresponding data in the field. (To make the control read-only, set the Locked property to Yes.) If you click a control bound to a field that has a Hyperlink data type, you jump to the destination specified in the hyperlink address.
An expression | The control displays data generated by an expression. This data can be changed by the user but isn't saved in the database.

You can also set the ControlSource property for a text box by typing a field name or expression directly in the text box in form Design view or report Design view.

For reports, the ControlSource property applies only to report group levels.

Forms and reports act as "windows" into your database. You specify the primary source of data for a form or report by setting its RecordSource property to a table, query, or SQL statement. You can then set the ControlSource property to a field in the source of data or to an expression. If the ControlSource property setting is an expression, the value displayed is read-only and not saved in the database. For example, you can use the following settings.

Sample setting | Description
LastName | For a control, data from the LastName field is displayed in the control. For a report group level, Microsoft Access groups the data on last name.
=Date( ) + 7 | For a control, this expression displays a date seven days from today in the control.
=DatePart("q",ShippedDate) | For a control, this expression displays the quarter of the shipped date. For a report group level, Microsoft Access groups the data on the quarter of the shipped date.

Example

The following example sets the ControlSource property for a text box named AddressPart to a field named City:

VBA Copy code Copy code
Forms!Customers!AddressPart.ControlSource = "City"

The next example sets the ControlSource property for a text box named Expected to the expression =Date() + 7

VBA Copy code Copy code
Me!Expected.ControlSource = "=Date() + 7"

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Avg Function (Microsoft Access SQL)

 Copy code hover
[image]

Avg Function (Microsoft Access SQL)
Send feedback

Published: July 16, 2012

Calculates the arithmetic mean of a set of values contained in a specified field on a query.

Syntax

Avg(expr)

The expr placeholder represents a string expression identifying the field that contains the numeric data you want to average or an expression that performs a calculation using the data in that field. Operands in expr can include the name of a table field, a constant, or a function (which can be either intrinsic or user-defined but not one of the other SQL aggregate functions).

Remarks

The average calculated by Avg is the arithmetic mean (the sum of the values divided by the number of values). You could use Avg, for example, to calculate average freight cost.

The Avg function does not include any Null fields in the calculation.

You can use Avg in a query expression and in the SQL property of a QueryDef object or when creating a Recordset object based on an SQL query.

Example

This example uses the Orders table to calculate the average freight charges for orders with freight charges over $100.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

Copy code Copy code
Sub AvgX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Calculate the average freight charges for orders
    ' with freight charges over $100.
    Set rst = dbs.OpenRecordset("SELECT Avg(Freight)" _
        & " AS [Average Freight]" _
        & " FROM Orders WHERE Freight > 100;")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 25

    dbs.Close

End Sub


Access Macro Actions (Access 2013 Developer Reference)

 Copy code hover
[image]

Access Macro Actions (Access 2013 Developer Reference)
Send feedback

In this section

  • Program Flow

  • Data Entry Operations

  • Data Import/Export

  • Database Objects

  • Filter/Query/Search

  • Macro Commands

  • System Commands

  • User Interface Commands

  • Window Management

  • Data Blocks

  • Data Actions

  • ADP Objects

  • Data Macro Events


The password used by the Synchronizer to write to a destination dropbox folder is invalid. (Error 3484)

 Copy code hover
[image]

The password used by the Synchronizer to write to a destination dropbox folder is invalid. (Error 3484)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


BoundObjectFrame.BottomPadding Property (Access)

 Copy code hover
[image]

BoundObjectFrame.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the object frame and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .BottomPadding

expression A variable that represents a BoundObjectFrame object.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


SubForm.GridlineWidthTop Property (Access)

 Copy code hover
[image]

SubForm.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified subform. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthTop

expression A variable that represents a SubForm object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


ADO Objects and Interfaces

 Copy code hover
[image]

ADO Objects and Interfaces
Send feedback

The relationships between these objects are represented in the ADO Object Model.

Each object can be contained in its corresponding collection. For example, an Error object can be contained in an Errors collection. For more information, see ADO Collections or a specific collection topic.

ADORecordConstruction | Constructs an ADO Record object from an OLE DB Row object in a C/C++ application.
ADORecordsetConstruction | Constructs an ADO Recordset object from an OLE DB Rowset object in a C/C++ application.
Error | Contains details about data access errors that pertain to a single operation involving the provider.
Field | Represents a column of data with a common data type.
Parameter | Represents a parameter or argument associated with a Command object based on a parameterized query or stored procedure.
Property | Represents a dynamic characteristic of an ADO object that is defined by the provider.
Record | Represents a row of a Recordset, or a directory or file in a file system.
Recordset | Represents the entire set of records from a base table or the results of an executed command. At any time, the Recordset object refers to only a single record within the set as the current record.
Stream | Represents a binary stream of data.


Image.BorderStyle Property (Access)

 Copy code hover
[image]

Image.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Syntax

expression .BorderStyle

expression A variable that represents an Image object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

Image Object

Other resources

Image Object Members


SubForm.SourceObject Property (Access)

 Copy code hover
[image]

SubForm.SourceObject Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SourceObject property to identify the form or report that is the source of the subform or subreport on a form or report. Read/write String.

Syntax

expression .SourceObject

expression A variable that represents a SubForm object.

Remarks

Enter the name of the form or report that is the source of the subform or subreport in the control's property sheet. If you add a subform or subreport to the form or report by dragging it from the Database window, the SourceObject property is set automatically in the property sheet.

In Visual Basic, you set this property by using a string expression that is a name of a form or report.

Note Note

You can't set or change the SourceObject property in the Open or Format events of a report.

If you delete the SourceObject property setting in the property sheet for a subform or subreport, the control remains on the form but is no longer bound to the source form or report.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


CacheSize Property Example (JScript)

 Copy code hover
[image]

CacheSize Property Example (JScript)
Send feedback

This example uses the CacheSize property to show the difference in performance for an operation performed with and without a 30-record cache. Cut and paste the following code to Notepad or another text editor, and save it as CacheSizeJS.asp.

Copy code Copy code

<!-- BeginCacheSizeJS -->
<%@ Language="JScript" %>
<%// use this meta tag instead of adojavas.inc%>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->

<HTML>
<HEAD>
<title>CacheSize Property Example (JScript)</title>
<style>
<!--
body {
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 BACKGROUND-COLOR:white;
 COLOR:black;
 }
.thead2 {
 background-color: #800000;
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 font-size: x-small;
 color: white;
 }
.tbody {
 text-align: center;
 background-color: #f7efde;
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 font-size: x-small;
 }
-->
</style>
</HEAD>
<BODY>
<h1>CacheSize Property Example (JScript)</h1>
<%
 // connection and recordset variables
 var Cnxn = Server.CreateObject("ADODB.Connection")
 var strCnxn = "Provider='sqloledb';Data Source=" + Request.ServerVariables("SERVER_NAME") + ";" +
 "Initial Catalog='Northwind';Integrated Security='SSPI';";
 var rsCustomer = Server.CreateObject("ADODB.Recordset");
 // caching variables
 var Now = new Date();
 var Start = Now.getTime();
 var End, Cache, NoCache

 try
 {
 // open connection
 Cnxn.Open(strCnxn)

 // open a recordset on the Employee table using client-side cursor
 rsCustomer.CursorLocation = adUseClient;
 rsCustomer.Open("Customers", strCnxn);

 // loop through the recordset 20 times
 for (var i=1; i<=20; i++)
 {
 rsCustomer.MoveFirst();
 while (!rsCustomer.EOF)
 {
 // do something with the record
 var strTemp = new String(rsCustomer("CompanyName"));
 rsCustomer.MoveNext();
 }
 }

 Now = new Date();
 End = Now.getTime();
 NoCache = End - Start;

 // cache records in groups of 30
 rsCustomer.MoveFirst();
 rsCustomer.CacheSize = 30;

 Now = new Date();
 Start = Now.getTime();

 // loop through the recordset 20 times
 for (var i=1; i<=20; i++)
 {
 rsCustomer.MoveFirst();
 while (!rsCustomer.EOF)
 {
 // do something with the record
 var strTemp = new String(rsCustomer("CompanyName"));
 rsCustomer.MoveNext();
 }
 }

 Now = new Date();
 End = Now.getTime();
 var Cache = End - Start;
 }
 catch (e)
 {
 Response.Write(e.message);
 }
 finally
 {
 // clean up
 if (rsCustomer.State == adStateOpen)
 rsCustomer.Close;
 if (Cnxn.State == adStateOpen)
 Cnxn.Close;
 rsCustomer = null;
 Cnxn = null;
 }
%>

 <table border="2">
 <tr class="thead2">
 <th>No Cache</th>
 <th>30 Record Cache</th>
 </tr>
 <tr class="tbody">
 <td><%=NoCache%></td>
 <td><%=Cache%></td>
 </tr>
 </table>

</BODY>
</HTML>
<!-- EndCacheSizeJS -->


Page.OnMouseDown Property (Access)

 Copy code hover
[image]

Page.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Syntax

expression .OnMouseDown

expression A variable that represents a Page object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

Page Object

Other resources

Page Object Members


ListBox.GridlineWidthTop Property (Access)

 Copy code hover
[image]

ListBox.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified list box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthTop

expression A variable that represents a ListBox object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


NavigationControl.LineSpacing Property (Access)

 Copy code hover
[image]

NavigationControl.LineSpacing Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the LineSpacing property to specify or determine the location of information displayed within a label or text box control. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .LineSpacing

expression A variable that represents a NavigationControl object.

Remarks

A control's displayed information location is the distance measured between each line of the displayed information. To use a unit of measurement different from the setting in the Regional Options dialog box in Windows Control Panel, specify the unit, such as cm or in (for example, 3 cm or 2 in).

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

Example

The following example sets the line spacing to 0.25 inches for the text box "PurchaseOrderInformation" on the "Purchase Order Form"

VBA Copy code Copy code
' 0.25 inches = 360/1440 twips.
 Forms("Purchase Orders").Controls("PurchaseOrderDescription").LineSpacing = 360

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Fields Collection (ADO) Reference

 Copy code hover
[image]

Fields Collection (ADO) Reference
Send feedback

In this section

  • Fields Collection (ADO)

  • Fields Collection Properties, Methods, and Events


Cannot input from internal report query

 Copy code hover
[image]

Cannot input from internal report query <name>. (Error 3124)
Send feedback

You tried to use an SQL statement that includes an explicit reference to a disallowed internal report query.


Workspace Object (DAO)

 Copy code hover
[image]

Workspace Object (DAO)
Send feedback

A Workspace object defines a named session for a user. It contains open databases and provides mechanisms for simultaneous transactions and, in Microsoft Access workspaces, secure workgroup support.

Remarks

A Workspace is a non-persistent object that defines how your application interacts with data by using the Microsoft Access database engine. Use the Workspace object to manage the current session or to start an additional session. In a session, you can open multiple databases or connections, and manage transactions. For example, you can:

  • Use the Name, UserName, and Type properties to establish a named session. The session creates a scope in which you can open multiple databases and conduct one instance of nested transactions.

  • Use the Close method to terminate a session.

  • Use the OpenDatabase method to open one or more existing databases on a Workspace.

  • Use the BeginTrans, CommitTrans, and Rollback methods to manage nested transaction processing within a Workspace and use several Workspace objects to conduct multiple, simultaneous, and overlapping transactions.

When you first refer to or use a Workspace object, you automatically create the default workspace, DBEngine.Workspaces(0). The settings of the Name and UserName properties of the default workspace are "#Default Workspace#" and "Admin," respectively. If security is enabled, the UserName property setting is the name of the user who logged on.

When you use transactions, all databases in the specified Workspace are affected— even if multiple Database objects are opened in the Workspace. For example, you use a BeginTrans method, update several records in a database, and then delete records in another database. If you then use the Rollback method, both the update and delete operations are canceled and rolled back. You can create additional Workspace objects to manage transactions independently across Database objects.

You can create Workspace objects with the CreateWorkspace method. After you create a new Workspace object, you must append it to the Workspaces collection if you need to refer to it from the Workspaces collection.

You can use a newly created Workspace object without appending it to the Workspaces collection. However, you must refer to it by the object variable to which you have assigned it.

To refer to a Workspace object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

DBEngine.Workspaces(0)

DBEngine.Workspaces("name")

DBEngine.Workspaces![name]

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Example

This example creates a new Microsoft Access Workspace object and appends it to the Workspaces collection. It then enumerates the Workspaces collections and the Properties collection of the Workspace object.

VBA Copy code Copy code
Sub WorkspaceX()

   Dim wrkNewAcc As Workspace
   Dim wrkLoop As Workspace
   Dim prpLoop As Property

   ' Create a new Microsoft Access workspace.
   Set wrkNewAcc = CreateWorkspace("NewAccessWorkspace", _
      "admin", "", dbUseJet)
   Workspaces.Append wrkNewAcc

   ' Enumerate the Workspaces collection.
   For Each wrkLoop In Workspaces
      With wrkLoop
         Debug.Print "Properties of " & .Name
         ' Enumerate the Properties collection of the new
         ' Workspace object.
         For Each prpLoop In .Properties
            On Error Resume Next
            If prpLoop <> "" Then Debug.Print "  " & _
               prpLoop.Name & " = " & prpLoop
            On Error GoTo 0
         Next prpLoop
      End With
   Next wrkLoop

   wrkNewAcc.Close
End Sub

This example uses the CreateWorkspace method to create a Microsoft Access workspace. It then lists the properties of theworkspace.

VBA Copy code Copy code
Sub CreateWorkspaceX()

   Dim wrkAcc As Workspace
   Dim wrkLoop As Workspace
   Dim prpLoop As Property

   DefaultType = dbUseJet
   ' Create an unnamed Workspace object of the type
   ' specified by the DefaultType property of DBEngine
   ' (dbUseJet).
   Set wrkAcc = CreateWorkspace("", "admin", "")

   ' Enumerate Workspaces collection.
   Debug.Print "Workspace objects in Workspaces collection:"
   For Each wrkLoop In Workspaces
      Debug.Print "  " & wrkLoop.Name
   Next wrkLoop

   With wrkAcc
      ' Enumerate Properties collection of Microsoft Access
      ' workspace.
      Debug.Print _
         "Properties of unnamed Microsoft Access workspace"
      On Error Resume Next
      For Each prpLoop In .Properties
         Debug.Print "  " & prpLoop.Name & " = " & prpLoop
      Next prpLoop
      On Error GoTo 0
   End With

   wrkAcc.Close

End Sub

The following example shows how to use a transaction in a Data Access Objects (DAO) workspace.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Public Sub TransferFunds()
    Dim wrk As DAO.Workspace
    Dim dbC As DAO.Database
    Dim dbX As DAO.Database

    Set wrk = DBEngine(0)
    Set dbC = CurrentDb
    Set dbX = wrk.OpenDatabase("e:\books\acc2007vba\myDB.accdb")

    On Error GoTo trans_Err

    'Begin the transaction

    wrk.BeginTrans

    'Withdraw funds from one account table
    dbC.Execute "INSERT INTO tblAccounts ( Amount, Txn, TxnDate ) SELECT -20, 'DEBIT', Date()", dbFailOnError

    'Deposit funds into another account table
    dbX.Execute "INSERT INTO tblAccounts ( Amount, Txn, TxnDate ) SELECT 20, 'CREDIT', Date()", dbFailOnError

    'Commit the transaction
    wrk.CommitTrans dbForceOSFlush

trans_Exit:
    'Clean up
    wrk.Close
    Set dbC = Nothing
    Set dbX = Nothing
    Set wrk = Nothing
    Exit Sub

trans_Err:
    'Roll back the transaction
    wrk.Rollback
    Resume trans_Exit

End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Status Property (ADO Recordset)

 Copy code hover
[image]

Status Property (ADO Recordset)
Send feedback

Indicates the status of the current record with respect to batch updates or other bulk operations.

Return Value

Returns a sum of one or more RecordStatusEnum values.

Remarks

Use the Status property to see what changes are pending for records modified during batch updating. You can also use the Status property to view the status of records that fail during bulk operations, such as when you call the Resync, UpdateBatch, or CancelBatch methods on a Recordset object, or set the Filter property on a Recordset object to an array of bookmarks. With this property, you can determine how a given record failed and resolve it accordingly.


Printer.DeviceName Property (Access)

 Copy code hover
[image]

Printer.DeviceName Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a String indicating name of the specified printer device. Read-only.

Syntax

expression .DeviceName

expression A variable that represents a Printer object.

Example

The following example displays information about all the printers available to the system.

VBA Copy code Copy code
Dim prtLoop As Printer

For Each prtLoop In Application.Printers
 With prtLoop
 MsgBox "Device name: " & .DeviceName & vbCr _
 & "Driver name: " & .DriverName & vbCr _
 & "Port: " & .Port
 End With
Next prtLoop

See also

Concepts

Printer Object

Other resources

Printer Object Members


ComboBox.OnMouseUp Property (Access)

 Copy code hover
[image]

ComboBox.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Syntax

expression .OnMouseUp

expression A variable that represents a ComboBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Cannot create a replica of a workgroup information file. (Error 3639)

 Copy code hover
[image]

Cannot create a replica of a workgroup information file. (Error 3639)
Send feedback

You are attempting to replicate a workgroup information file. This is not allowed.


Report.AutoResize Property (Access)

 Copy code hover
[image]

Report.AutoResize Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Boolean indicating whether a Report window opens automatically sized to display complete records. Read/write.

Syntax

expression .AutoResize

expression A variable that represents a Report object.

Remarks

The AutoResize property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) The Report window is automatically sized to display a complete record.
No | False | When opened, the Report window has the last saved size. To save a window's size, open the form, size the window, save the form by clicking Save on the File menu, and close the form or report. When you next open the form or report, it will be the saved window size.

This property can be set only in Design view.

See also

Concepts

Report Object

Other resources

Report Object Members


NavigationControl.Height Property (Access)

 Copy code hover
[image]

NavigationControl.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .Height

expression A variable that represents a NavigationControl object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Attachment.GridlineStyleTop Property (Access)

 Copy code hover
[image]

Attachment.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified attachment. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleTop

expression A variable that represents an Attachment object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


RecordStatusEnum Enumeration (DAO)

 Copy code hover
[image]

RecordStatusEnum Enumeration (DAO)
Send feedback

Used with the RecordStatus property to indicate the update status of the current record if it is part of a batch update.

Name | Value | Description
dbRecordDBDeleted | 4 | The record has been deleted locally and in the database.
dbRecordDeleted | 3 | The record has been deleted, but not yet deleted in the database.
dbRecordModified | 1 | The record has been modified and not updated in the database.
dbRecordNew | 2 | The record has been inserted with the AddNew method, but not yet inserted into the database.
dbRecordUnmodified | 0 | (Default) The record has not been modified or has been updated successfully.


ListBox.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

ListBox.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified list box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthBottom

expression A variable that represents a ListBox object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


WebBrowserControl.Value Property (Access)

 Copy code hover
[image]

WebBrowserControl.Value Property (Access)
See also Send feedback

Published: July 16, 2012

Determines or specifies the text in the text box. Read/write Variant.

Version Information

Version Added: Access 2010

Syntax

expression .Value

expression A variable that represents a WebBrowserControl object.

Remarks

The Text property returns the formatted string. The Text property may be different than the Value property for a text box control. The Text property is the current contents of the control. The Value property is the saved value of the text box control. The Text property is always current while the control has the focus.

The Value property returns or sets a control's default property, which is the property that is assumed when you don't explicitly specify a property name.

Note Note

The Value property is not the same as the DefaultValue property, which specifies the value that a property is assigned when a new record is created.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Property.Type Property (DAO)

 Copy code hover
[image]

Property.Type Property (DAO)
Send feedback

Sets or returns a value that indicates the operational type or data type of an object. Read/write Integer.

Syntax

expression .Type

expression A variable that represents a Property object.

Remarks

The setting or return value is a constant that indicates an operational or data type. For a Property object, this property is read/write until the object is appended to a collection or to another object, after which it's read-only.

For a Property object, the possible settings and return values are described in the following table.

Constant | Description
dbBigInt | Big Integer
dbBinary | Binary
dbBoolean | Boolean
dbByte | Byte
dbChar | Char
dbCurrency | Currency
dbDate | Date/Time
dbDecimal | Decimal
dbDouble | Double
dbFloat | Float
dbGUID | GUID
dbInteger | Integer
dbLong | Long
dbLongBinary | Long Binary (OLE Object)
dbMemo | Memo
dbNumeric | Numeric
dbSingle | Single
dbText | Text
dbTime | Time
dbTimeStamp | Time Stamp
dbVarBinary | VarBinary

When you append a new Field, Parameter, or Property object to the collection of an Index, QueryDef, Recordset, or TableDef object, an error occurs if the underlying database doesn't support the data type specified for the new object.


AllReports Members (Access)

 Copy code hover
[image]

AllReports Members (Access)
Send feedback

Published: July 16, 2012

The AllReports collection contains an AccessObject for each report in the CurrentProject or CodeProject object.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


Control.Object Property (Access)

 Copy code hover
[image]

Control.Object Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Object property in Visual Basic to return a reference to the ActiveX object that is associated with a linked or embedded OLE object in a control. By using this reference, you can access the properties or invoke the methods of the OLE object. Read-only Object.

Syntax

expression .Object

expression A variable that represents a Control object.

Remarks

The Object property returns a reference to an ActiveX object. You can use the Set statement to assign this ActiveX object to an object variable. The type of object reference returned depends on which application created the OLE object.

When you embed or link an OLE object in a Microsoft Access form, you can set properties that determine the type of object and the behavior of the container control. However, you can't directly set or read the OLE object's properties or apply its methods, as you can when performing Automation. The Object property returns a reference to an Automation object that represents the linked or embedded OLE object. By using this reference, you can change the OLE object by setting or reading its properties or applying its methods. For example, Microsoft Excel is an COM component that supports Automation. If you've embedded a Microsoft Excel worksheet in a Microsoft Access form, you can use the Object property to set a reference to the Worksheet object associated with that worksheet. You can then use any of the properties and methods of the Worksheet object.

For information on which properties and methods an ActiveX object supports, see the documentation for the application that was used to create the OLE object.

Example

The following example uses the Object property of an unbound object frame named OLE1. Customer name and address information is inserted in an embedded Microsoft Word document formatted as a form letter with placeholders for the name and address information and boilerplate text in the body of the letter. The procedure replaces the placeholder information for each record and prints the form letter. It doesn't save copies of the printed form letter.

VBA Copy code Copy code
Sub PrintFormLetter_Click()
 Dim objWord As Object
 Dim strCustomer As String, strAddress As String
 Dim strCity As String, strRegion As String

 ' Assign object property of control to variable.
 Set objWord = Me!OLE1.Object.Application.Wordbasic
 ' Assign customer address to variables.
 strCustomer = Me!CompanyName
 strAddress = Me!Address
 strCity = Me!City & ", "
 If Not IsNull(Me!Region) Then
 strRegion = Me!Region
 Else
 strRegion = Me!Country
 End If
 ' Activate ActiveX control.
 Me!OLE1.Action = acOLEActivate
 With objWord
 .StartOfDocument
 ' Go to first placeholder.
 .LineDown 2
 ' Highlight placeholder text.
 .EndOfLine 1
 ' Insert customer name.
 .Insert strCustomer
 ' Go to next placeholder.
 .LineDown
 .StartOfLine
 ' Highlight placeholder text.
 .EndOfLine 1
 ' Insert address.
 .Insert strAddress
 ' Go to last placeholder.
 .LineDown
 .StartOfLine
 ' Highlight placeholder text.
 .EndOfLine 1
 ' Insert City and Region.
 .Insert strCity & strRegion
 .FilePrint
 .FileClose
 End With
 Set objWord = Nothing
End Sub

See also

Concepts

Control Object

Other resources

Control Object Members


Attachment Events (Access)

 Copy code hover
[image]

Attachment Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
AttachmentCurrent | Occurs when the focus moves to or from a file contained in the specified Attachment control, making it the current attachment, or when the form is refreshed or requeried.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Change | The Change event occurs when the contents of the specified control change.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Dirty | The Dirty event occurs when the content of the specified control changes.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object receives the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.


NavigationButton.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

NavigationButton.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .ShortcutMenuBar

expression A variable that represents a NavigationButton object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

Example

The following example sets the "Suppliers_Toolbar" as the custom shortcut menu to display when the user clicks the right mouse button on the "Suppliers" form.

VBA Copy code Copy code
Forms("Suppliers").ShortcutMenuBar = "Suppliers_Toolbar"

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Program flow (Access 2013 custom web app)

 Copy code hover
[image]

Program flow (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • Comment Macro Block (Access 2013 custom web app)

  • If...Then...Else Macro Block (Access 2013 custom web app)

  • Group Macro Block (Access 2013 custom web app)


EmptyCell.GridlineColor Property (Access)

 Copy code hover
[image]

EmptyCell.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified list box. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineColor

expression A variable that represents an EmptyCell object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


DependencyInfo.InsufficientPermissions Property (Access)

 Copy code hover
[image]

DependencyInfo.InsufficientPermissions Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a DependencyObjects collection that contains a collection of objects to which you don't have sufficient permissions to check for dependencies. Read-only.

Syntax

expression .InsufficientPermissions

expression A variable that represents a DependencyInfo object.

Remarks

The DependencyObjects collection returned by this property contains a collection of AccessObject objects.

See also

Concepts

DependencyInfo Object

Other resources

DependencyInfo Object Members


AccessObject.Properties Property (Access)

 Copy code hover
[image]

AccessObject.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a AccessObject object's AccessObjectProperties collection. Read-only.

Syntax

expression .Properties

expression A variable that represents an AccessObject object.

Remarks

The AccessObjectProperties collection object is the collection of all the properties related to a AccessObject object. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the AccessObjectProperties collection's Count property minus 1

See also

Concepts

AccessObject Object

Other resources

AccessObject Object Members


Windows Registry Settings for External Data Sources

 Copy code hover
[image]

Windows Registry Settings for External Data Sources
Send feedback

In this section

  • Customizing Windows Registry Settings for the Microsoft Access Database Engine

  • Initializing the dBASE Database Driver

  • Initializing the Lotus Driver

  • Initializing the Microsoft Excel Driver

  • Initializing the Microsoft Exchange Data Source Driver

  • Initializing the Paradox Database Driver

  • Initializing the Text Data Source Driver


CursorType, LockType, and EditMode Properties Example (VJ++)

 Copy code hover
[image]

CursorType, LockType, and EditMode Properties Example (VJ++)
Send feedback

This example demonstrates setting the CursorType and LockType properties before opening a Recordset. It also shows the value of the EditMode property under various conditions. The EditModeOutput function is required for this procedure to run.

Copy code Copy code

// BeginEditModeJ
import com.ms.wfc.data.*;
import java.io.* ;

public class EditModeX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 EditModeX ();
 System.exit(0);
 }

 // EditModeX function

 static void EditModeX ()
 {

 // Define ADO Objects.
 Connection cnConn1 = null;
 Recordset rstEmployees = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String line = null;
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";

 try
 {
 // Open recordset with data from Employees table.

 cnConn1 = new Connection();
 cnConn1.open(strCnn);
 rstEmployees = new Recordset();
 rstEmployees.setActiveConnection(cnConn1);
 rstEmployees.setCursorLocation(AdoEnums.CursorLocation.CLIENT);
 rstEmployees.setCursorType(AdoEnums.CursorType.STATIC);
 rstEmployees.setLockType(AdoEnums.LockType.BATCHOPTIMISTIC);
 rstEmployees.open("employee", cnConn1,
 AdoEnums.CursorType.STATIC,
 AdoEnums.LockType.BATCHOPTIMISTIC,
 AdoEnums.CommandType.TABLE);

 // Show the EditMode property under different editing states.

 rstEmployees.addNew();
 rstEmployees.getField("emp_id").setString("T-T55555M");
 rstEmployees.getField("fname").setString("temp_fname");
 rstEmployees.getField("lname").setString("temp_lname");
 EditModeOutput("After AddNew:", rstEmployees.getEditMode());
 rstEmployees.updateBatch();
 EditModeOutput("After Update:", rstEmployees.getEditMode());
 rstEmployees.getField("fname").setString("test");
 EditModeOutput("After Edit:", rstEmployees.getEditMode());

 System.out.println("\n\nPress <Enter> to continue..");
 in.readLine();

 // Delete new record because this is a demonstration.
 cnConn1.execute(
 "DELETE FROM employee WHERE emp_id = 'T-T55555M'");

 // Cleanup objects before exit.
 rstEmployees.close();
 cnConn1.close();

 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // Check for null pointer for connection object.
 if (cnConn1==null)
 System.out.println("Exception: " + ae.getMessage());

 // As passing a Recordset, check for null pointer first.
 if (rstEmployees != null)
 {
 PrintProviderError(rstEmployees.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstEmployees != null)
 if (rstEmployees.getState() == 1)
 rstEmployees.close();
 }
 }

 // EditModeOutput Function

 static void EditModeOutput(String strTemp, int intEditMode)
 {
 String strMessage="";
 // Print report based on the value of the EditMode
 // property.

 System.out.println("\n" + strTemp);
 strMessage ="\n\tEditMode = ";
 switch(intEditMode)
 {
 case AdoEnums.EditMode.NONE :
 strMessage+="adEditNone";
 break;
 case AdoEnums.EditMode.INPROGRESS :
 strMessage+="adEditInProgress";
 break;
 case AdoEnums.EditMode.ADD :
 strMessage+="adEditAdd";
 break;
 default :
 break;
 }
 System.out.println(strMessage);
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndEditModeJ


EmptyCell.GridlineWidthRight Property (Access)

 Copy code hover
[image]

EmptyCell.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthRight

expression A variable that represents an EmptyCell object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


ADOX Collections

 Copy code hover
[image]

ADOX Collections
Send feedback
Columns | Contains all Column objects of a table, index, or key.
Groups | Contains all stored Group objects of a catalog or user.
Indexes | Contains all Index objects of a table.
Keys | Contains all Key objects of a table.
Procedures | Contains all Procedure objects of a catalog.
Tables | Contains all Table objects of a catalog.
Users | Contains all stored User objects of a catalog or group.
Views | Contains all View objects of a catalog.


FormatCondition.LongestBarValue Property (Access)

 Copy code hover
[image]

FormatCondition.LongestBarValue Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a numeric expression that specifies the value of the longest bar of a FormatCondition. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .LongestBarValue

expression A variable that represents a FormatCondition object.

Remarks

By default, the LongestBarValue contains a zero-length string ("").

If the value of the LongestBarLimit property is acAutomatic, then the LongestBarValue is ignored.

See also

Concepts

FormatCondition Object

Other resources

FormatCondition Object Members


Workspace.CreateDatabase Method (DAO)

 Copy code hover
[image]

Workspace.CreateDatabase Method (DAO)
Send feedback

Creates a new Database object, saves the database to disk, and returns an opened Database object (Microsoft Access workspaces only).

Syntax

expression .CreateDatabase(Name, Connect, Option)

expression A variable that represents a Workspace object.

Parameters

Name

Required/Optional

Data Type

Description

Name

Required

String

A String up to 255 characters long that is the name of the database file that you're creating. It can be the full path and file name. If your network supports it, you can also specify a network path, such as "\\server1\share1\dir1\db1". You can only create Microsoft Access database files with this method.

Connect

Required

String

  • A string expression that specifies a collating order for creating the database, as specified in Settings. You must supply this argument or an error occurs.

  • You can also create a password for the new Database object by concatenating the password string (starting with ";pwd=") with a constant in the locale argument, like this:

  • dbLangSpanish & ";pwd=NewPassword"

  • If you want to use the default locale, but specify a password, simply enter a password string for the locale argument:

  • ";pwd=NewPassword"

  • Use strong passwords that combine upper- and lowercase letters, numbers, and symbols. Weak passwords don't mix these elements. Strong password: Y6dh!et5. Weak password: House27. Use a strong password that you can remember so that you don't have to write it down.

Option

Optional

Variant

A constant or combination of constants that indicates one or more options, as specified in Settings. You can combine options by summing the corresponding constants.

Remarks

You can use one of the following constants for the locale argument to specify the CollatingOrder property of text for string comparisons.

Constant | Collating order
dbLangGeneral | English, German, French, Portuguese, Italian, and Modern Spanish
dbLangArabic | Arabic
dbLangChineseSimplified | Simplified Chinese
dbLangChineseTraditional | Traditional Chinese
dbLangCyrillic | Russian
dbLangCzech | Czech
dbLangDutch | Dutch
dbLangGreek | Greek
dbLangHebrew | Hebrew
dbLangHungarian | Hungarian
dbLangIcelandic | Icelandic
dbLangJapanese | Japanese
dbLangKorean | Korean
dbLangNordic | Nordic languages (Microsoft Jet database engine version 1.0 only)
dbLangNorwDan | Norwegian and Danish
dbLangPolish | Polish
dbLangSlovenian | Slovenian
dbLangSpanish | Traditional Spanish
dbLangSwedFin | Swedish and Finnish
dbLangThai | Thai
dbLangTurkish | Turkish

You can use one or more of the following constants in the options argument to specify which version the data format should have and whether or not to encrypt the database.

Constant | Description
dbEncrypt | Creates an encrypted database.
dbVersion10 | Creates a database that uses the Microsoft Jet database engine version 1.0 file format.
dbVersion11 | Creates a database that uses the Microsoft Jet database engine version 1.1 file format.
dbVersion20 | Creates a database that uses the Microsoft Jet database engine version 2.0 file format.
dbVersion30 | Creates a database that uses the Microsoft Jet database engine version 3.0 file format (compatible with version 3.5).
dbVersion40 | Creates a database that uses the Microsoft Jet database engine version 4.0 file format.
dbVersion120 | Creates a database that uses the Microsoft Access database engine version 12.0 file format.

If you omit the encryption constant, CreateDatabase creates an un-encrypted database.

Use the CreateDatabase method to create and open a new, empty database, and return the Database object. You must complete its structure and content by using additional DAO objects. If you want to make a partial or complete copy of an existing database, you can use the CompactDatabase method to make a copy that you can customize.

Example

This example uses CreateDatabase to create a new, encrypted Database object.

VBA Copy code Copy code
Sub CreateDatabaseX()

   Dim wrkDefault As Workspace
   Dim dbsNew As DATABASE
   Dim prpLoop As Property

   ' Get default Workspace.
   Set wrkDefault = DBEngine.Workspaces(0)

   ' Make sure there isn't already a file with the name of
   ' the new database.
   If Dir("NewDB.mdb") <> "" Then Kill "NewDB.mdb"

   ' Create a new encrypted database with the specified
   ' collating order.
   Set dbsNew = wrkDefault.CreateDatabase("NewDB.mdb", _
      dbLangGeneral, dbEncrypt)

   With dbsNew
      Debug.Print "Properties of " & .Name
      ' Enumerate the Properties collection of the new
      ' Database object.
      For Each prpLoop In .Properties
         If prpLoop <> "" Then Debug.Print "  " & _
            prpLoop.Name & " = " & prpLoop
      Next prpLoop
   End With

   dbsNew.Close

End Sub


Could not delete from specified tables. (Error 3086)

 Copy code hover
[image]

Could not delete from specified tables. (Error 3086)
Send feedback

You tried to delete data from one or more tables, but the deletion could not be completed.

Possible causes:

  • You do not have permission to modify the table. To change your permissions assignments, see your system administrator or the table's creator.

  • The database was opened for read-only access. The database is read-only for one of these reasons:

    • You used the OpenDatabase method and opened the database for read-only access.

    • The database file is defined as read-only in the database server operating system or by your network.

    • In a network environment, you do not have write privileges for the database file.

    • In Microsoft Visual Basic, you used the Data control and set the ReadOnly property to True.

To delete the data, close the database, resolve the read-only condition, and then reopen the file for read/write access.


ToggleButton.FontItalic Property (Access)

 Copy code hover
[image]

ToggleButton.FontItalic Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontItalic property to specify whether text is italic in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontItalic

expression A variable that represents a ToggleButton object.

Remarks

The FontItalic property uses the following settings.

Setting | Description
True | The text is italic.
False | (Default) The text isn't italic.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Too many FastFind Sessions were invoked. (Error 3408)

 Copy code hover
[image]

Too many FastFind Sessions were invoked. (Error 3408)
Send feedback

DAO's FIND method can only be executed once on a table or recordset.


EmptyCell.StatusBarText Property (Access)

 Copy code hover
[image]

EmptyCell.StatusBarText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .StatusBarText

expression A variable that represents an EmptyCell object.

Remarks

You set the StatusBarText property by using a string expression up to 255 characters long.

Note Note

The length of the text you can display in the status bar depends on your computer hardware and video display.

You can use the StatusBarText property to provide specific information about a control. For example, when a text box has the focus, a brief instruction can tell the user what kind of data to enter

Note Note

You can also use the ControlTipText property to display a ScreenTip for a control.

If you create a control by dragging a field from the field list, the value in a field's Description property is copied to the StatusBarText property.

Example

The following example sets the status bar text to be displayed when the "Address_TextBox" control in the "Mailing List" form has the focus in Form View.

VBA Copy code Copy code
Forms("Mailing List").Controls("Address_TextBox"). _
 StatusBarText = "Enter the company's mailing address."

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


Form.OnMouseMove Property (Access)

 Copy code hover
[image]

Form.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Syntax

expression .OnMouseMove

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

Form Object

Other resources

Form Object Members


Could not build key. (Error 3250)

 Copy code hover
[image]

Could not build key. (Error 3250)
Send feedback

When building a primary index, the Microsoft Access database engine could not build a primary key. Make sure the key fields are named properly and that there are no duplicate records based on this key.

This error can occur when you use the Seek method and pass it a value for a field that is not part of the index. For example, suppose you want to use the Seek method on a Recordset whose current index uses the LastName field of the underlying table, and you write it this way:

Copy code Copy code
rstEmployees.Seek "=", "Smith", "Joe"

The Microsoft Access database engine will try to construct a primary key from two fields, but because one field is indexed, the attempt will fail and this error results.


Troubleshooting RDS

 Copy code hover
[image]

Troubleshooting RDS
Send feedback

Refer to this section for solutions to specific errors or issues with RDS. The issues discussed in this section are:

  • Configuring RDS on Windows 2000

  • "Internet Server Error: Access Denied"

  • RDS Returns "Stream Not Read" Error

  • Deadlocks With Read Repeatable Isolation Level

  • Ensuring Sufficient TempDB Space

  • Minimizing Log File Space Usage


Line.IsVisible Property (Access)

 Copy code hover
[image]

Line.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Syntax

expression .IsVisible

expression A variable that represents a Line object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

Line Object

Other resources

Line Object Members


Controls How Do I Topics

 Copy code hover
[image]

Controls How Do I Topics
Send feedback

In this section

  • How to: Add "(All)" to a Combo Box or List Box

  • How to: Allow Users to Add Items to an Unbound Combo Box

  • How to: Assign a Control a Value From a Table

  • How to: Call Procedures in a Subform or Subreport

  • How to: Hide a Subform if the Main Form Contains No Records

  • How to: Prevent the Accidental Erasure of Data When Moving Between Controls on a Form

  • How to: Refer to Tab Control Objects in VBA


Too many expressions in GROUP BY clause. (Error 3087)

 Copy code hover
[image]

Too many expressions in GROUP BY clause. (Error 3087)
Send feedback

You created an SQL statement with more than 10 fields listed in the GROUP BY clause. Remove some of the fields listed in the GROUP BY clause.


Table Properties, Methods, and Events (ADOX)

 Copy code hover
[image]

Table Properties, Methods, and Events (ADOX)
Send feedback

Properties/Collections

DateCreated Property

DateModified Property

Indexes Collection

Keys Collection

Name Property

ParentCatalog Property

Type Property (Table)

Methods

None.

Events

None.


CreateRecordset Method Example (VB)

 Copy code hover
[image]

CreateRecordset Method Example (VB)
Send feedback

You can create a Recordset object and specify the column information. You can then insert data into the Recordset object; the underlying rowset buffers the inserts.

The following code example shows how to define a Recordset by using the RDSServer.DataFactory object. You can also do this with the RDS.DataControl object.

Copy code Copy code

'BeginRsDefineShapeVB
Sub Main()
 On Error GoTo ErrorHandler

 Dim ADF As RDSServer.DataFactory
 Dim vntRecordShape(3)
 Dim vntField1Shape(3)
 Dim vntField2Shape(3)
 Dim vntField3Shape(3)
 Dim vntField4Shape(3)

 Set ADF = New RDSServer.DataFactory

 ' For each field, specify the name,
 ' type, size, and nullability.

 vntField1Shape(0) = "Name" ' Column name.
 vntField1Shape(1) = CInt(129) ' Column type.
 vntField1Shape(2) = CInt(40) ' Column size.
 vntField1Shape(3) = False ' Nullable?

 vntField2Shape(0) = "Age"
 vntField2Shape(1) = CInt(3)
 vntField2Shape(2) = CInt(-1)
 vntField2Shape(3) = True

 vntField3Shape(0) = "DateOfBirth"
 vntField3Shape(1) = CInt(7)
 vntField3Shape(2) = CInt(-1)
 vntField3Shape(3) = True

 vntField4Shape(0) = "Balance"
 vntField4Shape(1) = CInt(6)
 vntField4Shape(2) = CInt(-1)
 vntField4Shape(3) = True

 ' Put all fields into an array of arrays.
 vntRecordShape(0) = vntField1Shape
 vntRecordShape(1) = vntField2Shape
 vntRecordShape(2) = vntField3Shape
 vntRecordShape(3) = vntField4Shape

 ' Use the RDSServer.DataFactory to create an empty
 ' recordset. It takes an array of variants where
 ' every element is itself another array of
 ' variants, one for every column required in the
 ' recordset.
 ' The elements of the inner array are the column's
 ' name, type, size, and nullability.
 '
 ' NOTE: You could just use the RDS.DataControl object
 ' instead of the RDSServer.DataFactory object. In
 ' that case, the following code would be Set NewRS
 ' = ADC1.CreateRecordset(vntRecordShape)
 Dim NewRs As ADODB.Recordset
 Set NewRs = ADF.CreateRecordSet(vntRecordShape)

 Dim fields(3)
 fields(0) = vntField1Shape(0)
 fields(1) = vntField2Shape(0)
 fields(2) = vntField3Shape(0)
 fields(3) = vntField4Shape(0)

 ' Populate the new recordset with data values.
 Dim fieldVals(3)

 ' Use AddNew to add the records.
 fieldVals(0) = "Joe"
 fieldVals(1) = 5
 fieldVals(2) = CDate(#1/5/1996#)
 fieldVals(3) = 123.456
 NewRs.AddNew fields, fieldVals

 fieldVals(0) = "Mary"
 fieldVals(1) = 6
 fieldVals(2) = CDate(#6/5/1996#)
 fieldVals(3) = 31
 NewRs.AddNew fields, fieldVals

 fieldVals(0) = "Alex"
 fieldVals(1) = 13
 fieldVals(2) = CDate(#1/6/1996#)
 fieldVals(3) = 34.0001
 NewRs.AddNew fields, fieldVals

 fieldVals(0) = "Susan"
 fieldVals(1) = 13
 fieldVals(2) = CDate(#8/6/1996#)
 fieldVals(3) = 0#
 NewRs.AddNew fields, fieldVals

 NewRs.MoveFirst

 ' Set the newly created and populated Recordset to
 ' the SourceRecordset property of the
 ' RDS.DataControl to bind to visual controls
 Dim ADC1 As RDS.DataControl
 Set ADC1 = New RDS.DataControl
 Set ADC1.SourceRecordset = NewRs

 'Clean up
 If NewRs.State = adStateOpen Then NewRs.Close
 Set NewRs = Nothing
 Set ADC1 = Nothing
 Set ADF = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not NewRs Is Nothing Then
 If NewRs.State = adStateOpen Then NewRs.Close
 End If
 Set NewRs = Nothing
 Set ADC1 = Nothing
 Set ADF = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndRsDefineShapeVB


Attachment.OnClick Property (Access)

 Copy code hover
[image]

Attachment.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnClick

expression A variable that represents an Attachment object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


ActiveConnection Property (ADOX)

 Copy code hover
[image]

ActiveConnection Property (ADOX)
Send feedback

Indicates the ADO Connection object to which the Catalog belongs.

Settings and Return Values

Sets a Connection object or a String containing the definition for a connection. Returns the active Connection object.

Remarks

The default value is a null object reference.


Section.BackTint Property (Access)

 Copy code hover
[image]

Section.BackTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackTint

expression A variable that represents a Section object.

Remarks

The BackTint property contains a numeric expression that can be used to lighten the theme color in the BackColor property. The default value of the BackTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens BackColor by 75%.

VBA Copy code Copy code
Me.ctl.BackTint=25

See also

Concepts

Section Object

Other resources

Section Object Members


Data Providers

 Copy code hover
[image]

Data Providers
Send feedback

Data providers represent diverse sources of data such as SQL databases, indexed-sequential files, spreadsheets, document stores, and mail files. Providers expose data uniformly using a common abstraction called the rowset.

ADO is powerful and flexible because it can connect to any of several different data providers and still expose the same programming model, regardless of the specific features of any given provider. However, because each data provider is unique, how your application interacts with ADO will vary by data provider.

For example, the capabilities and features of the OLE DB Provider for SQL Server, which is used to access Microsoft SQL Server databases, are considerably different from those of the Microsoft OLE DB Provider for Internet Publishing, which is used to access file stores on a Web server.


Attachment.BackThemeColorIndex Property (Access)

 Copy code hover
[image]

Attachment.BackThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackThemeColorIndex

expression A variable that represents an Attachment object.

Remarks

The BackThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BackThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Background Color to the Text 2 color by setting the BackThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BackThemeColorIndex=2

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Image Members (Access)

 Copy code hover
[image]

Image Members (Access)
Send feedback

Published: July 16, 2012

This object corresponds to an image control. The image control can add a picture to a form or report. For example, you could include an image control for a logo on an Invoice report.

Events

Name | Description
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the image control and its bottom gridline. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
GridlineColor | Gets or sets the color of the gridline for the specified image control. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified image control. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified image. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified image control. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified image control. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified image control. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified image control. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified image control. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified image control. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the image is anchored horizontally within its layout. Read/write.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
HyperlinkAddress | You can use the HyperlinkAddress property to specify or determine the path to an object, document, Web page or other destination for a hyperlink associated with a the specified control. Read/write String.
HyperlinkSubAddress | You can use the HyperlinkSubAddress property to specify or determine a location within the target document specified by the HyperlinkAddress property. Read/write String.
ImageHeight | You can use the ImageHeight property to determine the height in twips of the picture in an image control. Read/write Long.
ImageWidth | You can use the ImageWidth property to determine the width in twips of a picture in an image control. Read/write Long.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Layout | Returns the type of layout for the specified image. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified image. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the image control and its left gridline. Read/write Integer.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
ObjectPalette | The ObjectPalette property specifies the palette in the application used to create A bitmap or other graphic that is loaded into the specified control by using the Picture property. Read/write Variant.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Picture | You can use the Picture property to specify a bitmap or other type of graphic to be displayed on the specified control. Read/write String.
PictureAlignment | You can use the PictureAlignment property to specify where a background picture will appear in an image control or on a form or report. Read/write Byte.Read/write.
PictureData | You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.
PictureTiling | You can use the PictureTiling property to specify whether a background picture is tiled across the entire image control, Form window, form, or page of a report. Read/write Boolean.
PictureType | You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.
Properties | Returns a reference to a control's Properties collection object. Read-only.
RightPadding | Gets or sets the amount of space (in inches) between the image control and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SizeMode | You can use the SizeMode property to specify how to size a picture or other object in a bound object frame, an unbound object frame, or an image control.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the image control and its top gridline. Read/write Integer.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified image is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


SortOrder Property (ADOX)

 Copy code hover
[image]

SortOrder Property (ADOX)
Send feedback

Indicates the sort sequence for the column (index columns only).

Settings and Return Values

Sets and returns a Long value that can be one of the SortOrderEnum constants. The default value is adSortAscending.

Remarks

This property only applies to Column objects in the Columns collection of an Index.


CurrentProject.AccessConnection Property (Access)

 Copy code hover
[image]

CurrentProject.AccessConnection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AccessConnection property to return a reference to the current Microsoft ActiveX Data Objects (ADO) Connection object and its related properties. Read-only Connection.

Syntax

expression .AccessConnection

expression A variable that represents a CurrentProject object.

Remarks

You should use the AccessConnection property if you intend to create ADO recordsets that will be bound to Access forms. The form will not be updateable unless it is created by using the OLE DB Provider for Microsoft Access, even if the recordset is updateable in ADO.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


Attachment.OnChange Property (Access)

 Copy code hover
[image]

Attachment.OnChange Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Change box in the Properties window of one of the objects in the Applies To list. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnChange

expression A variable that represents an Attachment object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Change event occurs when the contents of a text box or the text portion of a combo box changes. It also occurs when you move from one page to another page in a tab control.

The OnChange value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Change box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Change box is blank, the property value is an empty string.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


CustomControl.OnEnter Property (Access)

 Copy code hover
[image]

CustomControl.OnEnter Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnEnter

expression A variable that represents a CustomControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Enter event occurs before a control actually receives the focus from a control on the same form.

The OnEnter value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Enter box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Enter box is blank, the property value is an empty string.

Example

The following example associates the Enter event with the macro "Enter_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnEnter = "Enter_Macro"

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Report Section

 Copy code hover
[image]

Report Section
Send feedback

Published: July 16, 2012

A report section is part of a report such as a header, footer, or detail section.

You can set report section properties that are attributes of a report which affect the appearance or behavior of a specific section. For example, you can set the CanGrow property to specify whether the section will increase vertically to print all the data the section contains. Section properties are set in report Design view.


AppendChunk and GetChunk Methods Example (VJ++)

 Copy code hover
[image]

AppendChunk and GetChunk Methods Example (VJ++)
Send feedback

This example uses the AppendChunk and GetChunk methods to fill an image field with data from another record.

Copy code Copy code

// BeginAppendChunkJ
import com.ms.wfc.data.*;
import java.io.*;
import com.ms.com.*;
import java.util.*;

public class AppendChunkX
{

 // The main entry point for the application.

 public static void main (String[] args)
 {
 AppendChunkX();
 System.exit(0);
 }

 // AppendChunkX function

 static void AppendChunkX()
 {
 // Define ADO Objects.
 Connection cnConn1 = null;
 Recordset rstPubInfo = null;

 //Declarations.
 String strCnn;
 String strPubID;
 String strPRInfo;
 String strMessage = "";
 long lngOffset = 0;
 long lngLogoSize;
 final int conChunkSize = 100;
 byte[] varChunk = new byte[conChunkSize];
 int intCommand = 0 ;
 int intMulChunkSize,intLastChunkSize;
 Vector varLogo = new Vector();
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));
 String line = null;
 int noOfRecords;
 int noOfRecordesDisplayed = 5;
 int recordCount = 0;
 String info;
 int indexOfComma ;

 try
 {
 // Open a connection.
 strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";
 cnConn1 = new Connection();
 cnConn1.open(strCnn,"","",AdoEnums.CommandType.UNSPECIFIED);

 // Open the pub_info Table.
 rstPubInfo = new Recordset();
 rstPubInfo.setCursorType(AdoEnums.CursorType.KEYSET );
 rstPubInfo.setLockType(AdoEnums.LockType.OPTIMISTIC );

 rstPubInfo.open("pub_info", cnConn1,AdoEnums.CursorType.KEYSET ,
 AdoEnums.LockType.OPTIMISTIC, AdoEnums.CommandType.TABLE );
 System.out.println ("Available logos are : \n");

 noOfRecords = rstPubInfo.getRecordCount();

 // Prompt for the Logo to copy.
 for ( int i = 0; i < noOfRecords; i++)
 {
 recordCount++;
 strMessage = strMessage +
 rstPubInfo.getField("pub_id").getString() + "\n";
 indexOfComma =
 rstPubInfo.getField("pr_info").getString().indexOf(",");
 info =
 rstPubInfo.getField("pr_info").getString().substring(0,
 indexOfComma );
 strMessage = strMessage + info + "\n\n";
 // Display five records at a time.
 if ( recordCount == noOfRecordesDisplayed)
 {
 System.out.println(strMessage);
 System.out.println("\n\nPress <Enter> to continue..");
 line = in.readLine();
 strMessage = "";
 recordCount = 0;
 }
 rstPubInfo.moveNext();
 // Display last records and exit if last record.
 if(rstPubInfo.getEOF())
 {
 System.out.println(strMessage);
 break;
 }
 }
 System.out.println ("\nEnter the ID of a logo to copy :\n" );
 strPubID = in.readLine();

 // Copy the logo to a variable in chunks.
 rstPubInfo.setFilter("pub_id = '" + strPubID + "'");
 lngLogoSize = rstPubInfo.getField("logo").getActualSize();
 while (lngOffset < lngLogoSize)
 {
 varChunk = rstPubInfo.getField("logo")
 .getByteChunk(conChunkSize);
 int i = 0;
 while (i < conChunkSize && varLogo.size() < (int)lngLogoSize)
 {
 varLogo.addElement(new Byte(varChunk[i]));
 i++;
 }
 lngOffset = lngOffset + conChunkSize ;
 }
 //Get the data for New ID from the user.
 System.out.println
 ("\nEnter a new pub ID [must be > 9899 & < 9999]:");
 strPubID = in.readLine().trim();

 System.out.println ("\nEnter descriptive text :");
 strPRInfo = in.readLine().trim();

 //Temporarily add new publisher to publishers table to
 //avoid getting error foreign key constraint.
 cnConn1.execute("INSERT publishers(pub_id) VALUES('" +
 strPubID + "')");

 //Add a new record.
 rstPubInfo.addNew();
 rstPubInfo.getField("pub_id").setString(strPubID);
 rstPubInfo.getField("pr_info").setString(strPRInfo);

 //Copy the selected logo to the new logo in chunks.
 lngOffset = 0;

 //Divide logosize in multiples of constant chunk size.
 intMulChunkSize =
 (varLogo.size()/conChunkSize) * conChunkSize;
 intLastChunkSize = varLogo.size()- intMulChunkSize ;
 byte[] arrChunk = new byte[conChunkSize];
 byte[] lastChunk = new byte[intLastChunkSize];

 while ( lngOffset < varLogo.size () )
 {
 int ii = 0 ;
 // Copy the logo in constant chunk size.
 if ( (int)lngOffset < intMulChunkSize)
 {
 while (ii < conChunkSize &&
 (int)lngOffset < varLogo.size () )
 {
 arrChunk[ii] =
 ((Byte)varLogo.elementAt
 ((int)lngOffset)).byteValue();
 ii++;
 lngOffset++;
 }
 rstPubInfo.getField("logo").appendChunk(arrChunk);
 }
 // Copy the last remaining chunk.
 else
 {
 while (ii < intLastChunkSize &&
 (int)lngOffset < varLogo.size () )
 {
 lastChunk[ii] =
 ((Byte)varLogo.elementAt
 ((int)lngOffset)).byteValue();
 ii++;
 lngOffset++;

 }
 rstPubInfo.getField("logo").appendChunk(lastChunk);
 }

 }

 // Update the new recordset with new logo.

 rstPubInfo.update();

 //Show the newly added data.
 System.out.println ("\nNew Record : " +
 rstPubInfo.getField("pub_id").getString() + "\n");
 System.out.println ("Description : " +
 rstPubInfo.getField("pr_info").getString() + "\n");
 System.out.println ("Logo Size : " +
 rstPubInfo.getField("logo").getActualSize() );

 System.out.println ("\n\nPress <Enter> key to continue.");
 in.readLine();

 //Delete new records because this is a demonstration.
 rstPubInfo.requery();
 cnConn1.execute("DELETE FROM pub_info WHERE pub_id = '" +
 strPubID + "'");
 cnConn1.execute("DELETE FROM publishers WHERE pub_id = '" +
 strPubID + "'");
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // Check for null pointer for connection object.
 if(rstPubInfo.getActiveConnection()==null)
 System.out.println("Exception: " + ae.getMessage());
 // As passing a Recordset, check for null pointer first.
 if (rstPubInfo != null)
 {
 PrintProviderError(rstPubInfo.getActiveConnection());
 PrintADOError(ae);
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 // System Read requires this catch.
 catch( java.io.IOException je )
 {
 PrintIOError(je);
 }
 finally
 {
 // Cleanup objects before exit.
 if (rstPubInfo != null)
 if (rstPubInfo.getState() == 1)
 rstPubInfo.close();
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }

 // PrintADOError Function

 static void PrintADOError(AdoException ae)
 {
 System.out.println("\t Error Source = " + ae.getSource() + "\n");
 System.out.println("\t Description = " + ae.getMessage() + "\n");
 }
}
// EndAppendChunkJ


Module Members (Access)

 Copy code hover
[image]

Module Members (Access)
Send feedback

Published: July 16, 2012

A Module object refers to a standard module or a class module.

Methods

Name | Description
AddFromFile | The AddFromFile method adds the contents of a text file to a Module object. The Module object may represent a standard module or a class module.
AddFromString | The AddFromString method adds a string to a Module object. The Module object may represent a standard module or a class module.
CreateEventProc | The CreateEventProc method creates an event procedure in a class module.
DeleteLines | The DeleteLines method deletes lines from a standard module or a class module.
Find | Finds specified text in a standard module or class module.
InsertLines | The InsertLines method inserts a line or group of lines of code in a standard module or a class module.
InsertText | The InsertText method inserts a specified string of text into a standard module or a class module.
ReplaceLine | The ReplaceLine method replaces a specified line in a standard module or a class module.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
CountOfDeclarationLines | The CountOfDeclarationLines property returns a Long value indicating the number of lines of code in the Declarations section in a standard module or class module. Read-only Long.
CountOfLines | The CountOfLines property returns a Long value indicating the number of lines of code in a standard module or class module. Read-only Long.
Lines | The Lines property returns a string containing the contents of a specified line or lines in a standard module or a class module. Read-only String.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
ProcBodyLine | The ProcBodyLine property returns the number of the line at which the body of a specified procedure begins in a standard module or a class module. Read-only Long.
ProcCountLines | The ProcCountLines property returns the number of lines in a specified procedure in a standard module or a class module. Read-only Long.
ProcOfLine | The ProcOfLine property returns the name of the procedure that contains a specified line in a standard module or a class module. Read-only string.
ProcStartLine | The ProcStartLine property returns avalue identifying the line at which a specified procedure begins in a standard module or a class module. Read-only Long.
Type | Indicates whether a module is a standard module or a class module. Read-only AcModuleType.


Single-row update/delete affected more than one row of a linked table. Unique index contains duplicate values. (Error 3362)

 Copy code hover
[image]

Single-row update/delete affected more than one row of a linked table. Unique index contains duplicate values. (Error 3362)
Send feedback

Your update or delete query affected more than one record in the linked SQL table. An update and delete query can affect only one record at a time.


WSParameter.Type Property (Access)

 Copy code hover
[image]

WSParameter.Type Property (Access)
See also Send feedback

Published: July 16, 2012

Get the data type of the specified parameter. Read-only Integer.

Version Information

Version Added: Access 2010

Syntax

expression .Type

expression A variable that represents a WSParameter object.

See also

Concepts

WSParameter Object

Other resources

WSParameter Object Members


Cannot delete field

 Copy code hover
[image]

Cannot delete field <name>. It is part of one or more relationships. (Error 3383)
Send feedback

You are trying to delete a field for which relationships have been defined in the database. To delete the field, you must first delete its relationships.


Application.IsCompiled Property (Access)

 Copy code hover
[image]

Application.IsCompiled Property (Access)
See also Send feedback

Published: July 16, 2012

The IsCompiled property returns a Boolean value indicating whether the Visual Basic project is in a compiled state. Read-only Boolean.

Syntax

expression .IsCompiled

expression A variable that represents an Application object.

Remarks

The IsCompiled property of the Application object is False when the project has never been fully compiled, if a module has been added, edited, or deleted after compilation, or if a module hasn't been saved in a compiled state.

See also

Concepts

Application Object

Other resources

Application Object Members


CurrentProject.IsTrusted Property (Access)

 Copy code hover
[image]

CurrentProject.IsTrusted Property (Access)
See also Send feedback

Published: July 16, 2012

Gets whether or not macros and Visual Basic for Applications (VBA) code have been enabled in the current project. Read-only Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .IsTrusted

expression A variable that represents a CurrentProject object.

Example

The following example shows how to use the IsTrusted property in a macro to determine whether the database has been opened with trust enabled. If trust has been enabled, the Visual Basic for Applications (VBA) subroutine Init is called. Otherwise, the use is notified that the database has been opened in disabled mode.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

Copy code Copy code
If [currentproject].[istrusted] Then
    RunCode
        Function Name =Init()

Else
    MessageBox
        Message The application is opened in disabled mode. Please enable the application for full functionality.
        Beep Yes
        Type None
        Title Disabled Mode Check

End If

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


Seek Method and Index Property Example (VB)

 Copy code hover
[image]

Seek Method and Index Property Example (VB)
Send feedback

This example uses the Recordset object's Seek method and Index property in conjunction with a given Employee ID, to locate the employee's name in the Employees table of the Nwind.mdb database.

Copy code Copy code

'BeginSeekVB
Public Sub Main()
 On Error GoTo ErrorHandler

 ' To integrate this code replace the data source
 ' in the connection string

 'recordset and connection variables
 Dim rstEmployees As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim strSQLEmployees As String

 Dim strID As String
 Dim strPrompt As String
 strPrompt = "Enter an EmployeeID (e.g., 1 to 9)"

 ' Open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\Microsoft Office\Office\Samples\northwind.mdb';"
 Cnxn.Open strCnxn

 ' open recordset server-side for indexing
 Set rstEmployees = New ADODB.Recordset
 rstEmployees.CursorLocation = adUseServer
 strSQLEmployees = "employees"
 rstEmployees.Open strSQLEmployees, strCnxn, adOpenKeyset, adLockReadOnly, adCmdTableDirect

 ' Does this provider support Seek and Index?
 If rstEmployees.Supports(adIndex) And rstEmployees.Supports(adSeek) Then
 rstEmployees.Index = "PrimaryKey"
 ' Display all the employees
 rstEmployees.MoveFirst
 Do While rstEmployees.EOF = False
 Debug.Print rstEmployees!EmployeeId; ": "; rstEmployees!firstname; " "; _
 rstEmployees!LastName
 rstEmployees.MoveNext
 Loop

 ' Prompt the user for an EmployeeID between 1 and 9
 rstEmployees.MoveFirst
 Do
 strID = LCase(Trim(InputBox(strPrompt, "Seek Example")))
 ' Quit if strID is a zero-length string (CANCEL, null, etc.)
 If Len(strID) = 0 Then Exit Do
 If Len(strID) = 1 And strID >= "1" And strID <= "9" Then
 rstEmployees.Seek Array(strID), adSeekFirstEQ
 If rstEmployees.EOF Then
 Debug.Print "Employee not found."
 Else
 Debug.Print strID; ": Employee='"; rstEmployees!firstname; " "; _
 rstEmployees!LastName; "'"
 End If
 End If
 Loop
 End If

 ' clean up
 rstEmployees.Close
 Cnxn.Close
 Set rstEmployees = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstEmployees Is Nothing Then
 If rstEmployees.State = adStateOpen Then rstEmployees.Close
 End If
 Set rstEmployees = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndSeekVB


Could not start session. (Error 3002)

 Copy code hover
[image]

Could not start session. (Error 3002)
Send feedback

You tried to initiate an operation that requires a new session, but you have reached the limit of sessions that can be active at one time. Wait for other operations to finish or stop other operations, and then try the operation again.


TabControl.KeyUp Event (Access)

 Copy code hover
[image]

TabControl.KeyUp Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyUp(KeyCode, Shift)

expression A variable that represents a TabControl object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyUp property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyUp event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyUp event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Database.Connect Property (DAO)

 Copy code hover
[image]

Database.Connect Property (DAO)
Send feedback

Sets or returns a value that provides information about the source an open database. Read/write String.

Syntax

expression .Connect

expression A variable that represents a Database object.

Remarks

The Connect property setting is a String composed of a database type specifier and zero or more parameters separated by semicolons. The Connect property passes additional information to ODBC and certain ISAM drivers as needed.

To perform an SQL pass-through query on a table linked to your Microsoft Access database file, you must first set the Connect property of the linked table's database to a valid ODBC connection string.

The path as shown in the following table is the full path for the directory containing the database files and must be preceded by the identifier DATABASE=. In some cases (as with Microsoft Excel and Microsoft Access database engine databases), you should include a specific file name in the database path argument.

The following table shows possible database types and their corresponding database specifiers and paths for the Connect property setting.

Database type | Specifier | Example
Microsoft Access Database | [database]; | drive:\path\filename
dBASE III | dBASE III; | drive:\path
dBASE IV | dBASE IV; | drive:\path
dBASE 5 | dBASE 5.0; | drive:\path
Paradox 3.x | Paradox 3.x; | drive:\path
Paradox 4.x | Paradox 4.x; | drive:\path
Paradox 5.x | Paradox 5.x; | drive:\path
Microsoft Excel 3.0 | Excel 3.0; | drive:\path\filename.xls
Microsoft Excel 4.0 | Excel 4.0; | drive:\path\filename.xls
Microsoft Excel 5.0 or Microsoft Excel 95 | Excel 5.0; | drive:\path\filename.xls
Microsoft Excel 97 | Excel 8.0; | drive:\path\filename.xls
Lotus 1-2-3 WKS and WK1 | Lotus WK1; | drive:\path\filename.wk1
Lotus 1-2-3 WK3 | Lotus WK3; | drive:\path\filename.wk3
Lotus 1-2-3 WK4 | Lotus WK4; | drive:\path\filename.wk4
HTML Import | HTML Import; | drive:\path\filename
HTML Export | HTML Export; | drive:\path
Text | Text; | drive:\path
ODBC | ODBC; DATABASE=database; UID=user; PWD=password; DSN= datasourcename; [LOGINTIMEOUT=seconds;] | None
Microsoft Exchange | Exchange 4.0; MAPILEVEL=folderpath; [TABLETYPE={ 0 | 1 }];[PROFILE=profile;] [PWD=password;] [DATABASE=database;] | drive:\path\filename

If the specifier is only "ODBC;", the ODBC driver displays a dialog box listing all registered ODBC data source names so that the user can select a database.

If a password is required but not provided in the Connect property setting, a login dialog box is displayed the first time a table is accessed by the ODBC driver and again if the connection is closed and reopened.

For data in Microsoft Exchange, the required MAPILEVEL key should be set to a fully-resolved folder path (for example, "Mailbox - Pat SmithIAlpha/Today"). The path does not include the name of the folder that will be opened as a table; that folder's name should instead be specified as the name argument to the CreateTable method. The TABLETYPE key should be set to "0" to open a folder (default) or "1" to open an address book. The PROFILE key defaults to the profile currently in use.

You can set the Connect property for a Database object by providing a source argument to the OpenDatabase method. You can check the setting to determine the type, path, user ID, password, or ODBC data source of the database.

Note Note

  • You must set the Connect property before you set the ReturnsRecords property.

  • You must have access permissions to the computer that contains the database server you're trying to access.


Container.Name Property (DAO)

 Copy code hover
[image]

Container.Name Property (DAO)
Send feedback

Returns the name of the specified object. Read-only String.

Syntax

expression .Name

expression A variable that represents a Container object.


Report.Page Event (Access)

 Copy code hover
[image]

Report.Page Event (Access)
See also Send feedback

Published: July 16, 2012

The Page event occurs after Microsoft Access formats a page of a report for printing, but before the page is printed. You can use this event to draw a border around the page, or add other graphic elements to the page.

Syntax

expression .Page

expression A variable that represents a Report object.

Return Value

Nothing

Remarks

To run a macro or event procedure when this event occurs, set the OnPage property to the name of the macro or to [Event Procedure].

This event occurs after all the Format events for the report, and after all the Print events for the page, but before the page is actually printed.

You normally use the Line, Circle, or PSet methods in the Page event procedure to create the desired graphics for the page.

The NoData event occurs before the first Page event for the report.

Example

The following example shows how to draw a rectangle around a report page by using the Line method. The ScaleWidth and ScaleHeight properties by default return the internal width and height of the report.

VBA Copy code Copy code
Private Sub Report_Page()
    Me.Line(0, 0)-(Me.ScaleWidth, Me.ScaleHeight), , B
End Sub

The following example shows how to use the Page event to add a watermark to a report before it is printed.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Private Sub Report_Page()
    Dim strWatermarkText As String
    Dim sizeHor As Single
    Dim sizeVer As Single

#If RUN_PAGE_EVENT = True Then
    With Me
        '// Print page border
        Me.Line (0, 0)-(.ScaleWidth - 1, .ScaleHeight - 1), vbBlack, B

        '// Print watermark
        strWatermarkText = "Confidential"

        .ScaleMode = 3
        .FontName = "Segoe UI"
        .FontSize = 48
        .ForeColor = RGB(255, 0, 0)

        '// Calculate text metrics
        sizeHor = .TextWidth(strWatermarkText)
        sizeVer = .TextHeight(strWatermarkText)

        '// Set the print location
        .CurrentX = (.ScaleWidth / 2) - (sizeHor / 2)
        .CurrentY = (.ScaleHeight / 2) - (sizeVer / 2)

        '// Print the watermark
        .Print strWatermarkText
    End With
#End If

End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.

See also

Concepts

Report Object

Other resources

Report Object Members


WebBrowserControl.DisplayWhen Property (Access)

 Copy code hover
[image]

WebBrowserControl.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .DisplayWhen

expression A variable that represents a WebBrowserControl object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


CheckBox.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

CheckBox.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified check box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleLeft

expression A variable that represents a CheckBox object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


MoveFirst, MoveLast, MoveNext, and MovePrevious Methods Example (VC++)

 Copy code hover
[image]

MoveFirst, MoveLast, MoveNext, and MovePrevious Methods Example (VC++)
Send feedback

This example uses the MoveFirst, MoveLast, MoveNext, and MovePrevious methods to move the record pointer of a Recordset based on the supplied command. The MoveAny function is required for this example to run.

Copy code Copy code

// BeginMoveFirstCpp
#include <ole2.h>
#include <stdio.h>

#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void MoveFirstX();
void MoveAny(int intChoice, _RecordsetPtr pRstTemp);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

/////////////////////////////////
// Main Function //
/////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 MoveFirstX();

 ::CoUninitialize();
}

//////////////////////////////////////
// MoveFirstX Function //
//////////////////////////////////////

void MoveFirstX()
{
 HRESULT hr = S_OK;
 _RecordsetPtr pRstAuthors = NULL;
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");
 _bstr_t strMessage("UPDATE Titles SET Type = "
 "'psychology' WHERE Type = 'self_help'");
 int intCommand = 0;

 // Temporary string variable for type conversion for printing.
 _bstr_t bstrFName;
 _bstr_t bstrLName;

 try
 {
 // Open recordset from Authors table.
 TESTHR(pRstAuthors.CreateInstance(__uuidof(Recordset)));
 pRstAuthors->CursorType = adOpenStatic;

 // Use client cursor to enable AbsolutePosition property.
 pRstAuthors->CursorLocation = adUseClient;
 pRstAuthors->Open("Authors", strCnn, adOpenStatic,
 adLockBatchOptimistic, adCmdTable);

 // Show current record information and get user's method choice.
 while (true) // Continuous loop.
 {
 // Convert variant string to convertable string type.
 bstrFName = pRstAuthors->Fields->Item["au_fName"]->Value;
 bstrLName = pRstAuthors->Fields->Item["au_lName"]->Value;

 printf("Name: %s %s\n Record %d of %d\n\n",
 (LPCSTR) bstrFName,
 (LPCSTR) bstrLName,
 pRstAuthors->AbsolutePosition,
 pRstAuthors->RecordCount);
 printf("[1 - MoveFirst, 2 - MoveLast, \n");
 printf(" 3 - MoveNext, 4 - MovePrevious, 5 - Quit]\n");

 scanf("%d", &intCommand);

 if ((intCommand < 1) || (intCommand > 4))
 break; // Out of range entry exits program loop.

 // Call method based on user's input.
 MoveAny(intCommand, pRstAuthors);
 }
 }
 catch (_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstAuthors->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 if (pRstAuthors)
 if (pRstAuthors->State == adStateOpen)
 pRstAuthors->Close();
}

/////////////////////////////////
// MoveAny Function //
/////////////////////////////////

void MoveAny(int intChoice, _RecordsetPtr pRstTemp)
{
 // Use specified method, trapping for BOF and EOF
 try
 {
 switch(intChoice)
 {
 case 1:
 pRstTemp->MoveFirst();
 break;
 case 2:
 pRstTemp->MoveLast();
 break;
 case 3:
 pRstTemp->MoveNext();
 if (pRstTemp->EndOfFile)
 {
 printf("\nAlready at end of recordset!\n");
 pRstTemp->MoveLast();
 } //End If
 break;
 case 4:
 pRstTemp->MovePrevious();
 if (pRstTemp->BOF)
 {
 printf("\nAlready at beginning of recordset!\n");
 pRstTemp->MoveFirst();
 }
 break;
 default:
 ;
 }
 }

 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstTemp->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }
}

////////////////////////////////////////////
// PrintProviderError Function //
////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.

 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount - 1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,
 pErr->Description);
 }
 }
}

//////////////////////////////////////
// PrintComError Function //
//////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndMoveFirstCpp


Recordset.Bookmark Property (DAO)

 Copy code hover
[image]

Recordset.Bookmark Property (DAO)
Send feedback

Sets or returns a bookmark that uniquely identifies the current record in a Recordset object.

Syntax

expression .Bookmark

expression A variable that represents a Recordset object.

Remarks

For a Recordset object based entirely on Microsoft Access database engine tables, the value of the Bookmarkable property is True, and you can use the Bookmark property with that Recordset. Other database products may not support bookmarks, however. For example, you can't use bookmarks in any Recordset object based on a linked Paradox table that has no primary key.

When you create or open a Recordset object, each of its records already has a unique bookmark. You can save the bookmark for the current record by assigning the value of the Bookmark property to a variable. To quickly return to that record at any time after moving to a different record, set the Recordset object's Bookmark property to the value of that variable.

There is no limit to the number of bookmarks you can establish. To create a bookmark for a record other than the current record, move to the desired record and assign the value of the Bookmark property to a String variable that identifies the record.

To make sure the Recordset object supports bookmarks, check the value of its Bookmarkable property before you use the Bookmark property. If the Bookmarkable property is False, the Recordset object doesn't support bookmarks, and using the Bookmark property results in a trappable error.

If you use the Clone method to create a copy of a Recordset object, the Bookmark property settings for the original and the duplicate Recordset objects are identical and can be used interchangeably. However, you can't use bookmarks from different Recordset objects interchangeably, even if they were created by using the same object or the same SQL statement.

If you set the Bookmark property to a value that represents a deleted record, a trappable error occurs.

The value of the Bookmark property isn't the same as a record number.

Example

This example uses the Bookmark and Bookmarkable properties to let the user flag a record in a Recordset and return to it later.

Copy code Copy code
Sub BookmarkX()

 Dim dbsNorthwind As Database
 Dim rstCategories As Recordset
 Dim strMessage As String
 Dim intCommand As Integer
 Dim varBookmark As Variant

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstCategories = _
 dbsNorthwind.OpenRecordset("Categories", _
 dbOpenSnapshot)

 With rstCategories

 If .Bookmarkable = False Then
 Debug.Print "Recordset is not Bookmarkable!"
 Else
 ' Populate Recordset.
 .MoveLast
 .MoveFirst

 Do While True
 ' Show information about current record and get
 ' user input.
 strMessage = "Category: " & !CategoryName & _
 " (record " & (.AbsolutePosition + 1) & _
 " of " & .RecordCount & ")" & vbCr & _
 "Enter command:" & vbCr & _
 "[1 - next / 2 - previous /" & vbCr & _
 "3 - set bookmark / 4 - go to bookmark]"
 intCommand = Val(InputBox(strMessage))

 Select Case intCommand
 ' Move forward or backward, trapping for BOF
 ' or EOF.
 Case 1
 .MoveNext
 If .EOF Then .MoveLast
 Case 2
 .MovePrevious
 If .BOF Then .MoveFirst

 ' Store the bookmark of the current record.
 Case 3
 varBookmark = .Bookmark

 ' Go to the record indicated by the stored
 ' bookmark.
 Case 4
 If IsEmpty(varBookmark) Then
 MsgBox "No Bookmark set!"
 Else
 .Bookmark = varBookmark
 End If

 Case Else
 Exit Do
 End Select

 Loop

 End If

 .Close
 End With

 dbsNorthwind.Close

End Sub

This example uses the LastModified property to move the current record pointer to both a record that has been modified and a newly created record.

Copy code Copy code
Sub LastModifiedX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset
 Dim strFirst As String
 Dim strLast As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", _
 dbOpenDynaset)

 With rstEmployees
 ' Store current data.
 strFirst = !FirstName
 strLast = !LastName
 ' Change data in current record.
 .Edit
 !FirstName = "Julie"
 !LastName = "Warren"
 .Update
 ' Move current record pointer to the most recently
 ' changed or added record.
 .Bookmark = .LastModified
 Debug.Print _
 "Data in LastModified record after Edit: " & _
 !FirstName & " " & !LastName

 ' Restore original data because this is a demonstration.
 .Edit
 !FirstName = strFirst
 !LastName = strLast
 .Update

 ' Add new record.
 .AddNew
 !FirstName = "Roger"
 !LastName = "Harui"
 .Update
 ' Move current record pointer to the most recently
 ' changed or added record.
 .Bookmark = .LastModified
 Debug.Print _
 "Data in LastModified record after AddNew: " & _
 !FirstName & " " & !LastName

 ' Delete new record because this is a demonstration.
 .Delete
 .Close
 End With

 dbsNorthwind.Close

End Sub


CloseDatabase Macro Action

 Copy code hover
[image]

CloseDatabase Macro Action
Send feedback

You can use the CloseDatabase action to close the current database.

Setting

The CloseDatabase action does not have any arguments.

Remarks

  • Access will not run any actions that follow the CloseDatabase action in a macro.

  • This action has the same effect as clicking the File tab and then clicking Close Database. If there are any unsaved objects open when you run the CloseDatabase action, the dialog boxes that appear are the same as those displayed when you click Close Database.

  • To run the CloseDatabase action in a Visual Basic for Applications (VBA) module, use the CloseDatabase method of the DoCmd object.


Form.ControlBox Property (Access)

 Copy code hover
[image]

Form.ControlBox Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether a form has a Control menu in Form view and Datasheet view. Read/write Boolean.

Syntax

expression .ControlBox

expression A variable that represents a Form object.

Remarks

The default value is True.

Setting the ControlBox property to False also removes the Minimize, Maximize, and Close buttons on a form.

It can only be set in form Design view.

To display a Control menu on a form, the ControlBox property must be set to Yes and the form's BorderStyle property must be set to Thin, Sizable, or Dialog.

Even when a form's ControlBox property is set to No, the form always has a Control menu when opened in Design view.

Setting the ControlBox property to No suppresses the Control menu when you:

  • Open the form in Form view from the Database window.

  • Open the form from a macro.

  • Open the form from Visual Basic.

  • Open the form in Datasheet view.

  • Switch to Form or Datasheet view from Design view.

See also

Concepts

Form Object

Other resources

Form Object Members


Unique key violation. (Error 3715)

 Copy code hover
[image]

Unique key violation. (Error 3715)
Send feedback

This record has the same key value as another record; however, only unique values are permitted. Either change the key value in this conflict record or in the winning record and then resubmit this record, or delete this conflict record.


Values for the TTOption Member

 Copy code hover
[image]

Values for the TTOption Member
Send feedback

Published: July 16, 2012

Value | Meaning
1 | Print TrueType fonts as graphics. This is the default for dot-matrix printers.
2 | Download TrueType fonts as soft fonts (fonts that are loaded into the printer's memory for rendering). This is the default for Hewlett-Packard printers that use Printer Control Language (PCL).
3 | Substitute device fonts for TrueType fonts. This is the default for PostScript printers.


Version Property Example (VJ++)

 Copy code hover
[image]

Version Property Example (VJ++)
Send feedback

This example uses the Version property of a Connection object to display the current ADO version. It also uses several dynamic properties to show:

  • the current DBMS name and version.

  • OLE DB version.

  • provider name and version.

  • ODBC version.

  • ODBC driver name and version.

Copy code Copy code

// BeginVersionJ
import com.ms.wfc.data.*;
import java.io.*;

public class VersionX
{
 // The main entry point of the application.
 public static void main (String[] args)
 {
 VersionX();
 System.exit(0);
 }
 // VersionX Function
 static void VersionX()
 {
 // Define ADO Objects.
 Connection cnn1 = null;

 // Declarations.
 String strCnn = "Driver={SQL Server};Server='MySqlServer';" +
 "User ID='MyUserID';Password='MyPassword';database='Pubs';";
 String strVersionInfo;
 BufferedReader in = new
 BufferedReader(new InputStreamReader(System.in));
 try
 {
 // Open connection.
 cnn1 = new Connection();
 cnn1.open(strCnn);

 strVersionInfo = "\tADO Version:\t\t" +
 cnn1.getVersion().toString()+"\n"+
 "\tDBMS Name:\t\t" +
 cnn1.getProperties().getItem("DBMS Name").getString() +"\n"+
 "\tDBMS Version:\t\t"+
 cnn1.getProperties().getItem("DBMS Version").getString() +
 "\n" + "\tOLE DB Version:\t\t" +
 cnn1.getProperties().getItem("OLE DB Version").getString()+
 "\n" + "\tProvider Name:\t\t" +
 cnn1.getProperties().getItem("Provider Name").getString() +
 "\n" + "\tProvider Version:\t" +
 cnn1.getProperties().getItem("Provider Version").
 getString() + "\n" + "\tDriver Name:\t\t" +
 cnn1.getProperties().getItem("Driver Name").getString() +
 "\n" + "\tDriver Version:\t\t" +
 cnn1.getProperties().getItem("Driver Version").getString()+
 "\n" + "\tDriver ODBC Version:\t" +
 cnn1.getProperties().getItem(
 "Driver ODBC Version").getString()+ "\n";
 System.out.println("\n\n" + strVersionInfo);

 System.out.println("Press <Enter> to continue..");
 in.readLine();
 }
 // System read requires this catch.
 catch(java.io.IOException je)
 {
 PrintIOError(je);
 }
 catch(AdoException ae)
 {
 // Notify the user of any errors that result from ADO.

 // As passing a recordset, check for null pointer first.
 if(cnn1!= null)
 {
 PrintProviderError(cnn1);
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 finally
 {
 // Cleanup objects before exit.
 if (cnn1 != null)
 if (cnn1.getState() == 1)
 cnn1.close();
 }

 }
 // PrintProviderError Function
 static void PrintProviderError(Connection cnn1)
 {
 // Print Provider Errors from Connection Object.
 // ErrItem is an item object in the Connections Errors Collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if ( nCount > 0)
 {
 // Collection ranges from 0 to nCount-1.
 for ( i=0;i<nCount; i++)
 {
 ErrItem = cnn1.getErrors().getItem(i);
 System.out.println("\t Error Number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription());
 }
 }
 }
 // PrintIOError Function
 static void PrintIOError(java.io.IOException je)
 {
 System.out.println("Error: \n");
 System.out.println("\t Source: " + je.getClass() + "\n");
 System.out.println("\t Description: "+ je.getMessage() + "\n");
 }
}
// EndVersionJ


FormatCondition.ShowBarOnly Property (Access)

 Copy code hover
[image]

FormatCondition.ShowBarOnly Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the data bar or the data bar and its value are displayed. Set to True to display only the data bar. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .ShowBarOnly

expression A variable that represents a FormatCondition object.

See also

Concepts

FormatCondition Object

Other resources

FormatCondition Object Members


Image.BottomPadding Property (Access)

 Copy code hover
[image]

Image.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the image control and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .BottomPadding

expression A variable that represents an Image object.

See also

Concepts

Image Object

Other resources

Image Object Members


Dimensions Collection Properties, Methods, and Events (ADO MD)

 Copy code hover
[image]

Dimensions Collection Properties, Methods, and Events (ADO MD)
Send feedback

Properties

Count Property

Item Property

Methods

Refresh Method

Events

None.


NavigationButton.Move Method (Access)

 Copy code hover
[image]

NavigationButton.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Version Information

Version Added: Access 2010

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a NavigationButton object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant |
Top | Optional | Variant |
Width | Optional | Variant |
Height | Optional | Variant |

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


A disk I/O error occurred while reading or writing to the TEMP directory. (Error 3572)

 Copy code hover
[image]

A disk I/O error occurred while reading or writing to the TEMP directory. (Error 3572)
Send feedback

A problem has occurred accessing the TEMP directory on your computer. Check that the path to the TEMP directory is set properly.


Attachment.ControlTipText Property (Access)

 Copy code hover
[image]

Attachment.ControlTipText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .ControlTipText

expression A variable that represents an Attachment object.

Remarks

You set the ControlTipText property by using a string expression up to 255 characters long.

For controls on forms, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

You can set the ControlTipText property in any view.

The ControlTipText property provides an easy way to provide helpful information about controls on a form.

There are other ways to provide information about a form or a control on a form. You can use the StatusBarText property to display information in the status bar about a control. To provide more extensive help for a form or control, use the HelpFile and HelpContextID properties.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


ComboBox.TextAlign Property (Access)

 Copy code hover
[image]

ComboBox.TextAlign Property (Access)
See also Send feedback

Published: July 16, 2012

The TextAlign property specifies the text alignment in new controls. Read/write Byte.

Syntax

expression .TextAlign

expression A variable that represents a ComboBox object.

Remarks

The TextAlign property uses the following settings.

Setting | Visual Basic | Description
General | 0 | (Default) The text aligns to the left; numbers and dates align to the right.
Left | 1 | The text, numbers, and dates align to the left.
Center | 2 | The text, numbers, and dates are centered.
Right | 3 | The text, numbers, and dates align to the right.
Distribute | 4 | The text, numbers, and dates are evenly distributed.

You can set the default for the TextAlign property by using a control's default control style or the DefaultControl property in Visual Basic.

Example

The following example aligns the text in the "Address" text box on the "Suppliers" form to the right.

VBA Copy code Copy code
Forms("Suppliers").Controls("Address").TextAlign = 3

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


BoundObjectFrame.KeyPress Event (Access)

 Copy code hover
[image]

BoundObjectFrame.KeyPress Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyPress(KeyAscii)

expression A variable that represents a BoundObjectFrame object.

Parameters

Name | Required/Optional | Data Type | Description
KeyAscii | Required | Integer | Returns a numeric ANSI key code. The KeyAscii argument is passed by reference; changing it sends a different character to the object. Setting the KeyAscii argument to 0 cancels the keystroke so that the object doesn't recognize that a key was pressed.

Remarks

To run a macro or event procedure when this event occurs, set the OnKeyPress property to the name of the macro or to [Event Procedure].

The object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down an ANSI key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

A KeyPress event can involve any printable keyboard character, the CTRL key combined with a character from the standard alphabet or a special character, and the ENTER or BACKSPACE key. You can use the KeyDown and KeyUp event procedures to handle any keystroke not recognized by the KeyPress event, such as function keys, navigation keys, and any combinations of these with keyboard modifiers (ALT, SHIFT, or CTRL keys). Unlike the KeyDown and KeyUp events, the KeyPress event doesn't indicate the physical state of the keyboard; instead, it indicates the ANSI character that corresponds to the pressed key or key combinations.

KeyPress interprets the uppercase and lowercase of each character as separate key codes and, therefore, as two separate characters.

Note Note

The BACKSPACE key is part of the ANSI character set, but the DEL key isn't. If you delete a character in a control by using the BACKSPACE key, you cause a KeyPress event; if you use the DEL key, you don't.

The KeyDown and KeyPress events occur when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

For example, if you go to a new record and type a character in the first control in the record, the following events occur:

Current (for the new record)

ß

Enter (for the first control in the new record)

ß

GotFocus (for the control)

ß

KeyDown (for the control)

ß

KeyPress (for the control)

ß

BeforeInsert (for the new record in the form)

ß

Change (for the control if it's a text box or combo box)

ß

KeyUp (for the control)

Example

The following example converts text entered in a text box to uppercase as the text is typed in, one character at a time.

To try the example, add the following event procedure to a form that contains a text box named ShipRegion.

VBA Copy code Copy code
Private Sub ShipRegion_KeyPress(KeyAscii As Integer)
 Dim strCharacter As String

 ' Convert ANSI value to character string.
 strCharacter = Chr(KeyAscii)
 ' Convert character to upper case, then to ANSI value.
 KeyAscii = Asc(UCase(strCharacter))
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


CommandButton.PressedColor Property (Access)

 Copy code hover
[image]

CommandButton.PressedColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color displayed on the control when the user clicks it. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .PressedColor

expression A variable that represents a CommandButton object.

Remarks

The PressedColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


SubForm.Top Property (Access)

 Copy code hover
[image]

SubForm.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Syntax

expression .Top

expression A variable that represents a SubForm object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Unknown name. (Error 2424)

 Copy code hover
[image]

Unknown name. (Error 2424)
Send feedback

You entered an expression that has a field or property name that cannot be recognized. Make sure the object exists, or check the expression to make sure you entered it correctly.


CurrentProject.AddSharedImage Method (Access)

 Copy code hover
[image]

CurrentProject.AddSharedImage Method (Access)
See also Send feedback

Published: July 16, 2012

Imports the the specified image into the database and adds it to the SharedResources collection.

Version Information

Version Added: Access 2010

Syntax

expression .AddSharedImage(SharedImageName, FileName)

expression A variable that represents a CurrentProject object.

Parameters

Name | Required/Optional | Data Type | Description
SharedImageName | Required | String | Specifies the string used to identify the image in the collection.
FileName | Required | String | Specifies the full name and path to the image file.

Remarks

Use the AddSharedImage method when you have an image that you want to use repeatedly, such as a companny logo. The AddSharedImage method makes the image available in the Insert Image dropdown of the Controls group in the Design tab.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


Query is too complex. (Error 3360)

 Copy code hover
[image]

Query is too complex. (Error 3360)
Send feedback

The query is too complex. Reduce the number of fields in the SELECT clause or the number of subqueries or tables in the join.


Form.AfterFinalRender Property (Access)

 Copy code hover
[image]

Form.AfterFinalRender Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the AfterFinalRender event occurs. Read/write.

Syntax

expression .AfterFinalRender

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the AfterFinalRender event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).AfterFinalRender = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


Control Members (Access)

 Copy code hover
[image]

Control Members (Access)
Send feedback

Published: July 16, 2012

The Control object represents a control on a form, report, or section, within another control, or attached to another control.

Methods

Name | Description
Dropdown | You can use the Dropdown method to force the list in the specified combo box to drop down.
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.
Undo | You can use the Undo method to reset a control or form when its value has been changed.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BottomPadding | Gets or sets the amount of space (in inches) between the control and its bottom gridline. Read/write Integer.
Column | You can use the Column property to refer to a specific column, or column and row combination, in a multiple-column combo box or list box. Read-only Variant.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
Form | You can use the Form property to refer to a form or to refer to the form associated with a subformcontrol. Read-only Form.
GridlineColor | Gets or sets the color of the gridline for the specified control. Read/write Long.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified control. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified control. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified control. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified control. Read/write Byte.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified control. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified control. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified control. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified control. Read/write Byte.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the control is anchored horizontally within its layout. Read/write.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
ItemData | The ItemData property returns the data in the bound column for the specified row in a combo box or list box. Read-only Variant.
ItemsSelected | You can use the ItemsSelected property to return a read-only reference to the hidden ItemsSelected collection. This hidden collection can be used to access data in the selected rows of a multiselect list box control.
Layout | Returns the type of layout for the specified control. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified control. Read-only Long.
LeftPadding | Gets or sets the amount of space (in inches) between the control and its left gridline. Read/write Integer.
Name | You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.
Object | You can use the Object property in Visual Basic to return a reference to the ActiveX object that is associated with a linked or embedded OLE object in a control. By using this reference, you can access the properties or invoke the methods of the OLE object. Read-only Object.
ObjectVerbs | You can use the ObjectVerbs property in Visual Basic to determine the list of verbs an OLE object supports. Read-only String.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
Pages | Returns a Pages collection that represents the pages in the specified control that supports tabbed pages (for example, a TabControl object). Read-only.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
Report | You can use the Report property to refer to a report or to refer to the report associated with a subreport control. Read-only Report.
RightPadding | Gets or sets the amount of space (in inches) between the control and its right gridline. Read/write Integer.
Selected | You can use the Selected property in Visual Basic to determine if an item is selected. Read/write Long.
SmartTags | Returns a SmartTags collection that represents the collection of smart tags that have been added to a control. .
TopPadding | Gets or sets the amount of space (in inches) between the control and its top gridline. Read/write Integer.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified control is anchored vertically within its layout. Read/write.


Application.DDERequest Method (Access)

 Copy code hover
[image]

Application.DDERequest Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the DDERequest function over an open dynamic data exchange (DDE) channel to request an item of information from a DDE server application.

Syntax

expression .DDERequest(ChanNum, Item)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
ChanNum | Required | Variant | A channel number, the integer returned by the DDEInitiate function.
Item | Required | String | A string expression that's the name of a data item recognized by the application specified by the DDEInitiate function. Check the application's documentation for a list of possible items.

Return Value

String

Remarks

For example, if you have an open DDE channel between Microsoft Access and Microsoft Excel, you can use the DDERequest function to transfer text from a Microsoft Excel spreadsheet to a Microsoft Access database.

The channum argument specifies the channel number of the desired DDE conversation, and the item argument identifies which data should be retrieved from the server application. The value of the item argument depends on the application and topic specified when the channel indicated by the channum argument is opened. For example, the item argument may be a range of cells in a Microsoft Excel spreadsheet.

The DDERequest function returns a Variant as a string containing the requested information if the request was successful.

The data is requested in alphanumeric text format. Graphics or text in any other format can't be transferred.

If the channum argument isn't an integer corresponding to an open channel, or if the data requested can't be transferred, a run-time error occurs.

If you need to manipulate another application's objects from Microsoft Access, you may want to consider using Automation .

See also

Concepts

Application Object

Other resources

Application Object Members


AccessObjectProperties.Remove Method (Access)

 Copy code hover
[image]

AccessObjectProperties.Remove Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the Remove method to remove an AccessObjectProperty object from the AccessObjectProperties collection of an AccessObject object.

Syntax

expression .Remove(Item)

expression A variable that represents an AccessObjectProperties object.

Parameters

Name | Required/Optional | Data Type | Description
Item | Required | Variant | An expression that specifies the position of a member of the collection referred to by the object argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection.

See also

Concepts

AccessObjectProperties Collection

Other resources

AccessObjectProperties Object Members


Application.ImportXML Method (Access)

 Copy code hover
[image]

Application.ImportXML Method (Access)
See also Send feedback

Published: July 16, 2012

The ImportXML method allows developers to import XML data and/or schema information into Microsoft SQL Server 2000 Desktop Engine (MSDE 2000), Microsoft SQL Server 7.0 or later, or the Microsoft Access database engine.

Syntax

expression .ImportXML(DataSource, ImportOptions)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
DataSource | Required | String | The name and path of the XML file to import.
ImportOptions | Optional | AcImportXMLOption | A AcImportXMLOption constant that specifies the option to use when importing XML files. The default value is acStructureAndData.

Return Value

Nothing

Example

The following example imports an XML file into a new table named Employees in the current database.

VBA Copy code Copy code
Application.ImportXML _
 DataSource:="employees.xml", _
 ImportOptions:=acStructureAndData

See also

Concepts

Application Object

Other resources

Application Object Members


SubForm.Report Property (Access)

 Copy code hover
[image]

SubForm.Report Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Report property to refer to a report or to refer to the report associated with a subreport control. Read-only Report.

Syntax

expression .Report

expression A variable that represents a SubForm object.

Remarks

This property is typically used to refer to the report contained in a subreport control.

Note Note

When you use the Reports collection, you must specify the name of the report.

Example

The following example uses the Report property to refer to a control on a subreport.

VBA Copy code Copy code
Dim curTotalSales As Currency

curTotalSales = Reports!Sales!Employees.Report!TotalSales

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


TabControl.PressedForeThemeColorIndex Property (Access)

 Copy code hover
[image]

TabControl.PressedForeThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedForeColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .PressedForeThemeColorIndex

expression A variable that represents a TabControl object.

Remarks

The PressedForeThemeColorIndex uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 (Default) | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the PressedForeThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Form.ApplyFilter Event (Access)

 Copy code hover
[image]

Form.ApplyFilter Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when a filter is applied to a form.

Syntax

expression .ApplyFilter(Cancel, ApplyType)

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the ApplyFilter event occurs. Setting the Cancel argument to True cancels the ApplyFilter event and the filter is not applied to the form.
ApplyType | Required | Integer | Returns the type of filter that was applied.

Remarks

To run a macro or event procedure when this event occurs, set the OnApplyFilter property to the name of the macro or to [Event Procedure].

You can use the ApplyFilter event to:

  • Make sure the filter that is being applied is correct. For example, you may want to be sure that any filter applied to an Orders form includes criteria restricting the OrderDate field. To do this, check the form's Filter or ServerFilter property value to make sure this criteria is included in the WHERE clause expression.

  • Change the display of the form before the filter is applied. For example, when you apply a certain filter, you may want to disable or hide some fields that aren't appropriate for the records displayed by this filter.

  • Undo or change actions you took when the Filter event occurred. For example, you can disable or hide some controls on the form when the user is creating the filter, because you don't want these controls to be included in the filter criteria. You can then enable or show these controls after the filter is applied.

The actions in the ApplyFilter macro or event procedure occur before the filter is applied or removed; or after the Advanced Filter/Sort, Filter By Form, or Server Filter By Form window is closed, but before the form is redisplayed. The criteria you've entered in the newly created filter are available to the ApplyFilter macro or event procedure as the setting of the Filter or ServerFilter property.

Note Note

The ApplyFilter event doesn't occur when the user does one of the following:

  • Applies or removes a filter by using the ApplyFilter, OpenReport, or ShowAllRecords actions in a macro, or their corresponding methods of the DoCmd object in Visual Basic.

  • Uses the Close action or the Close method of the DoCmd object to close the Advanced Filter/Sort, Filter By Form, or Server Filter By Form window

  • Sets the Filter or ServerFilter property or FilterOn or ServerFilterByForm property in a macro or Visual Basic (although you can set these properties in an ApplyFilter macro or event procedure).

Example

The following example shows how to hide the AmountDue, Tax, and TotalDue controls on an Orders form when the applied filter restricts the records to only those orders that have been paid for.

To try this example, add the following event procedure to an Orders form that contains AmountDue, Tax, and TotalDue controls. Run a filter that lists only those orders that have been paid for.

VBA Copy code Copy code
Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
 If Not IsNull(Me.Filter) And (InStr(Me.Filter, "Orders.Paid = -1")>0 _
 Or InStr(Me.Filter, "Orders.Paid = True")>0)Then
 If ApplyType = acApplyFilter Then
 Forms!Orders!AmountDue.Visible = False
 Forms!Orders!Tax.Visible = False
 Forms!Orders!TotalDue.Visible = False
 ElseIf ApplyType = acShowAllRecords Then
 Forms!Orders!AmountDue.Visible = True
 Forms!Orders!Tax.Visible = True
 Forms!Orders!TotalDue.Visible = True
 End If
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


RaiseError Macro Action

 Copy code hover
[image]

RaiseError Macro Action
Send feedback

The RaiseError action throws an exception that can be handled by the OnError macro action.

Note Note

The RaiseError action is available only in Data Macros.

Setting

The RaiseError action has the following arguments.

Argument | Required | Description
Error Number | Yes | A number or an expression that resolves to the Long data type.
Error Description | No | A string expression that describes the error.

Remarks

If the RaiseError action is called in a Before Change or Before Delete macro event, the event is cancelled.

If there is not an active OnError statment that is handling errors, then the error thrown by the RaiseError action is added to the USysApplicationLog system table. When the RaiseError action to writes to the USysApplicationLog table, the Category column is automatically set to Execution.

To see the USysApplicationLog table, use the following steps:

  1. Click the File menu, and then click Options.

  2. In the Access Options dialog box, click the Current Database tab.

  3. In the Navigation section, click Navigation Options.

  4. In the Navigation Options dialog box, click Show System Objects, and then click OK.

  5. Click OK to dismiss the Access Options dialog box.

Example

The following example shows how to use the RaiseError action to cancel the Before Change data macro event. When the AssignedTo field is updated, a LookupRecord data block is used to determine whether the assigned technician is currently assigned to an open service request. If this is true, then the Before Change event is cancelled and the record is not updated.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

Copy code Copy code
/* Get the name of the technician  */
Look Up A Record In tblTechnicians
    Where Condition =[tblTechnicians].[ID]=[tblServiceRequests].[AssignedTo]
SetLocalVar
    Name TechName
    Expression [tblTechnicians].[FirstName] & " " & [tblTechnicians].[LastName]
/* End LookUpRecord  */

If Updated("AssignedTo") Then
    Look Up A Record In tblServiceRequests
        Where Condition SR.[AssignedTo]=tblServiceRequests[AssignedTo] And
            SR.[ID]<>tblServiceRequests.[ID] And IsNull(SR.[ActualCompletionDate])
        Alias SR
        RaiseError
            Error Number 1234
            Error Description ="Cannot assign a request to the specified technician: " & [TechName]

End If

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Incorrect collating sequence. (Error 3220)

 Copy code hover
[image]

Incorrect collating sequence. (Error 3220)
Send feedback

You tried to link a Paradox table that was created with an international sort order that is not the same as the one you are using.


CurrentData Object (Access)

 Copy code hover
[image]

CurrentData Object (Access)
See also Send feedback

Published: July 16, 2012

The CurrentData object refers to the objects stored in the current database by the source (server) application.

Remarks

The CurrentData object has several collections that contain specific AccessObject objects within the current database. The following table lists the name of each collection defined by the database and the types of objects it contains.

Collections | Object type | Available in Access database | Available in Access Project (.adp)
AllTables | All tables | Yes | Yes
AllFunctions | All functions | No | Yes
AllQueries | All queries | Yes | Yes
AllViews | All views | No | Yes
AllStoredProcedures | All stored procedures | No | Yes
AllDatabaseDiagrams | All database diagrams | No | Yes
Note Note

The collections in the preceding table contain all of the respective objects in the database regardless if they are opened or closed.

For example, an AccessObject representing a table is a member of the AllTables collection, which is a collection of AccessObject objects within the current database. Within the AllTables collection, individual tables are indexed beginning with zero. You can refer to an individual AccessObject object in the AllTables collection either by referring to the table by name, or by referring to its index within the collection. If you want to refer to a specific item in the AllTables collection, it's better to refer to it by name because the item's index may change. If the object name includes a space, the name must be surrounded by brackets ([ ]).

Syntax | Example
AllTables!tablename | AllTables!OrderTable
AllTables![table name] | AllTables![Order Table]
AllTables("tablename") | AllTables("OrderTable")
AllTables(index) | AllTables(0)

See also

Concepts

Access Object Model Reference

Other resources

CurrentData Object Members


CommandType Property (ADO)

 Copy code hover
[image]

CommandType Property (ADO)
Send feedback

Indicates the type of a Command object.

Settings and Return Values

Sets or returns one or more CommandTypeEnum values.

Note Note

Do not use the CommandTypeEnum values of adCmdFile or adCmdTableDirect with CommandType. These values can only be used as options with the Open and Requery methods of a Recordset.

Remarks

Use the CommandType property to optimize evaluation of the CommandText property.

If the CommandType property value equals adCmdUnknown (the default value), you may experience diminished performance because ADO must make calls to the provider to determine if the CommandText property is an SQL statement, a stored procedure, or a table name. If you know what type of command you're using, setting the CommandType property instructs ADO to go directly to the relevant code. If the CommandType property does not match the type of command in the CommandText property, an error occurs when you call the Execute method.


CommandButton.ForeShade Property (Access)

 Copy code hover
[image]

CommandButton.ForeShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .ForeShade

expression A variable that represents a CommandButton object.

Remarks

The ForeShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the ForeShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the ForeColor property by 75%.

VBA Copy code Copy code
Me.ctl.ForeShade=25

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ADO MD Enumerated Constants

 Copy code hover
[image]

ADO MD Enumerated Constants
Send feedback

To assist debugging, the ADO MD enumerated constants list a value for each constant. However, this value is purely advisory, and may change from one release of ADO MD to another. Your code should only depend on the name, not the actual value, of enumerated constants.

The following enumeration is defined.

  • MemberTypeEnum


Label.Top Property (Access)

 Copy code hover
[image]

Label.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Syntax

expression .Top

expression A variable that represents a Label object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

Label Object

Other resources

Label Object Members


You tried to call Update or CancelUpdate or attempted to update a Field in a recordset without first calling AddNew or Edit. (Error 3020)

 Copy code hover
[image]

You tried to call Update or CancelUpdate or attempted to update a Field in a recordset without first calling AddNew or Edit. (Error 3020)
Send feedback

On a Microsoft Access database engine database, you called the Update or CancelUpdate method but did not use the AddNew or Edit method before writing data to a record.

On an ODBCDirect database, this error occurs when you attempt to write data to a record without first calling AddNew or Edit.


ListBox.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

ListBox.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified list box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleLeft

expression A variable that represents a ListBox object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


NavigationButton.Left Property (Access)

 Copy code hover
[image]

NavigationButton.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .Left

expression A variable that represents a NavigationButton object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Label Events (Access)

 Copy code hover
[image]

Label Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.


TabControl.BorderStyle Property (Access)

 Copy code hover
[image]

TabControl.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .BorderStyle

expression A variable that represents a TabControl object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Precision Property (ADO)

 Copy code hover
[image]

Precision Property (ADO)
Send feedback

Indicates the degree of precision for numeric values in a Parameter object or for numeric Field objects.

Settings and Return Values

Sets or returns a Byte value that indicates the maximum number of digits used to represent values.

Remarks

Use the Precision property to determine the maximum number of digits used to represent values for a numeric Parameter or Field object.

The value is read/write on a Parameter object.

For a Field object, Precision is normally read-only. However, for new Field objects that have been appended to the Fields collection of a Record, Precision is read/write only after the Value property for the Field has been specified and the data provider has successfully added the new Field by calling the Update method of the Fields collection.


Application.Reports Property (Access)

 Copy code hover
[image]

Application.Reports Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Reports property to access the read-only Reports collection and its related properties.

Syntax

expression .Reports

expression A variable that represents an Application object.

Remarks

The Reports collection contains all of the currently open reports in a Microsoft Access database or Microsoft Access project (.adp).

See also

Concepts

Application Object

Other resources

Application Object Members


GroupLevel.GroupFooter Property (Access)

 Copy code hover
[image]

GroupLevel.GroupFooter Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the GroupFooter property to create a group footer for a selected field or expression in a report. Read/write Boolean.

Syntax

expression .GroupFooter

expression A variable that represents a GroupLevel object.

Remarks

You can use group headers and footers to label or summarize data in a group of records. For example, if you set the GroupHeader property to Yes for the Categories field, each group of products will begin with its category name.

Note Note

You can't set or refer to these properties directly in Visual Basic. To create a group header or footer for a field or expression in Visual Basic, use the CreateGroupLevel method.

To set the grouping properties — GroupOn , GroupInterval , and KeepTogether — to other than their default values, you must first set the GroupHeader or GroupFooter property or both to Yes for the selected field or expression.

See also

Concepts

GroupLevel Object

Other resources

GroupLevel Object Members


CheckBox.BorderWidth Property (Access)

 Copy code hover
[image]

CheckBox.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Syntax

expression .BorderWidth

expression A variable that represents a CheckBox object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Invalid SQL syntax: expected token: UPDATE or DELETE (Error 3724)

 Copy code hover
[image]

Invalid SQL syntax: expected token: UPDATE or DELETE (Error 3724)
Send feedback

This error occurs when defining referential integrity through the CREATE TABLE statement or the ALTER TABLE ALTER COLUMN statement. This error occurs when the keyword CASCADE is used and the keyword UPDATE or DELETE is not before it.


Section.NewRowOrCol Property (Access)

 Copy code hover
[image]

Section.NewRowOrCol Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the NewRowOrCol property to specify whether a section and its associated data is printed in a new row or column within a multiple-column report or multiple-column form. Read/write Byte.

Syntax

expression .NewRowOrCol

expression A variable that represents a Section object.

Remarks

The NewRowOrCol property uses the following settings.

Setting | Visual Basic | Description
None | 0 | (Default) The row or column breaks are determined by the settings in the Page Setup dialog box (available by clicking Page Setup on the File menu) and the available space on the page.
Before Section | 1 | Microsoft Access starts printing the current section (the section for which you're setting the property, such as a group header section) in a new row or column. It then prints the next section, such as a detail section, in that same row or column.
After Section | 2 | Microsoft Access starts printing the current section, such as a group header section, in the current row or column. It starts printing the next section, such as a detail section, in the next row or column.
Before & After | 3 | Microsoft Access starts printing the current section in a new row or column. It starts printing the following section in the next row or column.

You can set the NewRowOrCol property only in form Design view or report Design view.

The following items are some sample settings for a group header section in a multiple-column report. Make sure Down, Then Across is selected under Column Layout on the Columns tab of the Page Setup dialog box.

Sample setting | Result
Before Section | The group header is printed at the top of a new column.
After Section | The detail section is printed at the top of a new column.
Before & After | The group header is printed in a column by itself, and the detail section is printed at the top of a new column.

Sections in a form or report are normally printed vertically down a page. The default Column Layout option is Across, then Down. You can print the sections in multiple columns across a page by clicking Down, then Across under Column Layout on the Columns tab of the Page Setup dialog box.

If you set the NewRowOrCol property to Before Section, the vertical or horizontal orientation of the page affects how the section appears when printed. If you click Across, then Down under Column Layout on the Columns tab of the Page Setup dialog box, Microsoft Access starts printing the section at the beginning of a new row; if you click Down, then Across, Microsoft Access starts printing the section at the beginning of a new column.

The following example returns the NewRowOrCol property setting and assigns it to the intGetVal variable.

VBA Copy code Copy code
Dim intGetVal As Integer
intGetVal = Me.Section(1).NewRowOrCol

The next example presents two layouts for a report that divides data into four groups (Head1 to Head4). Each group includes three to six records, and each record has field a and field b. The layouts differ only in their settings under Column Layout on the Columns tab of the Page Setup dialog box and the values of their NewRowOrCol properties. Note that the Width box under Column Size on the Columns tab must be set to the actual width of the field. Also, the Before Section setting of the NewRowOrCol property requires a page header section greater than zero for the Down, then Across option to function correctly.

  • Column Layout — Across, then Down

    Head1
    1a 1b 2a 2b 3a 3b 4a 4b
    5a 5b
    Head2
    1a 1b 2a 2b 3a 3b 4a 4b
    Head3
    1a 1b 2a 2b 3a 3b
    Head4
    1a 1b 2a 2b 3a 3b 4a 4b
    5a 5b 6a 6b

  • Grid Settings — Number of Columns set to 4

  • NewRowOrCol property setting for group header section — Before & After

  • Column Layout — Down, then Across

    Head1 Head2 Head3 Head4
    1a 1b 1a 1b 1a 1b 1a 1b
    2a 2b 2a 2b 2a 2b 2a 2b
    3a 3b 3a 3b 3a 3b 3a 3b
    4a 4b 4a 4b 4a 4b
    5a 5b 5a 5b
    6a 6b

  • Grid Settings — Number of Columns set to 4

  • NewRowOrCol property setting for group header section — Before Section

See also

Concepts

Section Object

Other resources

Section Object Members


EmptyCell.Properties Property (Access)

 Copy code hover
[image]

EmptyCell.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Properties

expression A variable that represents an EmptyCell object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


SQL Statements

 Copy code hover
[image]

SQL Statements
Send feedback

In this section

  • Build SQL Statements That Include Variables and Controls

  • Use International Date Formats in SQL Statements


ComboBox.TabStop Property (Access)

 Copy code hover
[image]

ComboBox.TabStop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.

Syntax

expression .TabStop

expression A variable that represents a ComboBox object.

Remarks

This property doesn't apply to toggle button controls when they appear in an option group. It applies only to the option group itself.

The TabStop property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) You can move the focus to the control by pressing the TAB key.
No | False | You can't move the focus to the control by pressing the TAB key.

When you create a control on a form, Microsoft Access automatically assigns the control a position in the form's tab order. Each new control is placed last in the tab order. If you want to prevent a control from being available when you tab through the controls in a form, set the control's TabStop property to No.

In Form view, hidden or disabled controls remain in the tab order but are skipped when you move through the controls by pressing TAB, even if their TabStop properties are set to Yes.

As long as a control's Enabled property is set to Yes, you can click the control or use an access key to select it, regardless of its TabStop property setting. For example, you can set the TabStop property of a command button to No to prevent users from selecting the button by pressing TAB. However, they can still click the command button to choose it.

Example

The following example disables the ability to move the focus to the "City" text box on the "Suppliers" form by using the TAB key.

VBA Copy code Copy code
Forms("Suppliers").Controls("City").TabStop = False

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Chapter 4: Editing Data (ADO)

 Copy code hover
[image]

Chapter 4: Editing Data (ADO)
Send feedback

In this section

  • Chapter 4: Editing Data

  • Editing Existing Records

  • Determining What is Supported

  • Deleting Records Using the Delete Method

  • Alternatives: Using SQL Statements

  • Adding Records (ADO)


WebService.Parent Property (Access)

 Copy code hover
[image]

WebService.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Parent

expression A variable that represents a WebService object.

See also

Concepts

WebService Object

Other resources

WebService Object Members


Recordset.AbsolutePosition Property (DAO)

 Copy code hover
[image]

Recordset.AbsolutePosition Property (DAO)
Send feedback

Sets or returns the relative record number of a Recordset object's current record.

Syntax

expression .AbsolutePosition

expression A variable that represents a Recordset object.

Remarks

You can use the AbsolutePosition property to position the current record pointer to a specific record based on its ordinal position in a dynaset- or snapshot-type Recordset object. You can also determine the current record number by checking the AbsolutePosition property setting.

Because the AbsolutePosition property value is zero-based (that is, a setting of 0 refers to the first record in the Recordset object), you cannot set it to a value greater than or equal to the number of populated records; doing so causes a trappable error. You can determine the number of populated records in the Recordset object by checking the RecordCount property setting. The maximum allowable setting for the AbsolutePosition property is the value of the RecordCount property minus 1.

If there is no current record, as when there are no records in the Recordset object, AbsolutePosition returns -1. If the current record is deleted, the AbsolutePosition property value isn't defined, and a trappable error occurs if it's referenced. New records are added to the end of the sequence.

You shouldn't use this property as a surrogate record number. Bookmarks are still the recommended way of retaining and returning to a given position and are the only way to position the current record across all types of Recordset objects. In particular, the position of a record changes when one or more records preceding it are deleted. There is also no assurance that a record will have the same absolute position if the Recordset object is re-created again because the order of individual records within a Recordset object isn't guaranteed unless it's created with an SQL statement by using an ORDER BY clause.

Note Note

  • Setting the AbsolutePosition property to a value greater than zero on a newly opened but unpopulated Recordset object causes a trappable error. Populate the Recordset object first with the MoveLast method.

  • The AbsolutePosition property isn't available on forward-only-type Recordset objects, or on Recordset objects opened from pass-through queries against Microsoft Access database engine-connected ODBC databases.

Example

This example uses the AbsolutePosition property to track the progress of a loop that enumerates all the records of a Recordset.

Copy code Copy code
Sub AbsolutePositionX()

   Dim dbsNorthwind As Database
   Dim rstEmployees As Recordset
   Dim strMessage As String

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   ' AbsolutePosition only works with dynasets or snapshots.
   Set rstEmployees = _
      dbsNorthwind.OpenRecordset("Employees", _
      dbOpenSnapshot)

   With rstEmployees
      ' Populate Recordset.
      .MoveLast
      .MoveFirst

      ' Enumerate Recordset.
      Do While Not .EOF
         ' Display current record information. Add 1 to
         ' AbsolutePosition value because it is zero-based.
         strMessage = "Employee: " & !LastName & vbCr & _
            "(record " & (.AbsolutePosition + 1) & _
            " of " & .RecordCount & ")"
         If MsgBox(strMessage, vbOKCancel) = vbCancel _
            Then Exit Do
         .MoveNext
      Loop

      .Close
   End With

   dbsNorthwind.Close

End Sub


ListBox Properties (Access)

 Copy code hover
[image]

ListBox Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
AllowValueListEdits | Gets or sets whether the Edit List Items command is available when the user right-clicks a list box. Read/write Boolean.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.
BoundColumn | When you make a selection from a list box, the BoundColumn property tells Microsoft Access which column's values to use as the value of the control. If the control is bound to a field, the value in the column specified by the BoundColumn property is stored in the field named in the ControlSource property. Read/write Long.
Column | You can use the Column property to refer to a specific column, or column and row combination, in a multiple-column combo box or list box. Read-only Variant.
ColumnCount | You can use the ColumnCount property to specify the number of columns displayed in a list box or in the list box portion of a combo box, or sent to OLE objects in a chart control or unbound object frame . Read/write Integer.
ColumnHeads | You can use the ColumnHeads property to display a single row of column headings for list boxes, combo boxes, and OLE objects that accept column headings. You can also use this property to create a label for each entry in a chart control . What is actually displayed as the first-row column heading depends on the object's RowSourceType property setting. Read/write Boolean.
ColumnHidden | You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.
ColumnOrder | You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.
ColumnWidth | You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.
ColumnWidths | You can use the ColumnWidths property to specify the width of each column in a multiple-column list box. Read/write String.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DefaultValue | Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontName | You can use the FontName property to specify the font for text in the following situations:
FontSize | You can use the FontSize property to specify the point size for text in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
FontWeight | You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
ForeShade | Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
ForeThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.
ForeTint | Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
GridlineColor | Gets or sets the color of the gridline for the specified list box. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified list box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified list box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified list box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified list box. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified list box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified list box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified list box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified list box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HideDuplicates | You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the list box is anchored horizontally within its layout. Read/write.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
IMEHold | Language-specific information You can use the IMEHold/Hold KanjiConversionMode property to show whether the Kanji Conversion Mode is maintained when the control loses the focus. Read/write Boolean.
IMEMode |
IMESentenceMode |
InheritValueList | Gets or sets whether a list box's value list is inherited from its field. Read/write Boolean.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
ItemData | The ItemData property returns the data in the bound column for the specified row in a list box. Read-only Variant.
ItemsSelected | You can use the ItemsSelected property to return a read-only reference to the hidden ItemsSelected collection. This hidden collection can be used to access data in the selected rows of a multiselect list box control.
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified list box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified list box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the list box and its left gridline. Read/write Integer.
ListCount | You can use the ListCount property to determine the number of rows in a list box. Read/write Long.
ListIndex | You can use the ListIndex property to determine which item is selected in a list box. Read/write Long.
ListItemsEditForm | Gets or sets the name of the form that is displayed when the user clicks Edit List Items. Read/write String.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
MultiSelect | You can use the MultiSelect property to specify whether a user can make multiple selections in a list box on a form and how the multiple selections can be made. Read/write Byte.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
NumeralShapes |
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
Recordset | Returns or sets the ADO Recordset or DAO Recordset object representing the record source for the specified object. Read/write Object.
RightPadding | Gets or sets the amount of space (in inches) between the list box and its right gridline. Read/write Integer.
RowSource | You can use the RowSource property (along with the RowSourceType property) to tell Microsoft Access how to provide data tothe specified object. Read/write String.
RowSourceType | You can use the RowSourceType property (along with the RowSource property) to tell Microsoft Access how to provide data tothe specified object. Read/write String.
ScrollBarAlign | You can use the ScrollBarAlign to specify or determine the alignment of a vertical scroll bar. Read/write Byte.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
Selected | You can use the Selected property in Visual Basic to determine if an item in a list box is selected. Read/write Long.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
ShowOnlyRowSourceValues | Gets or sets whether the list box can display values that aren't specified by the RowSource property. Read/write Boolean.
SmartTags | Returns a SmartTags collection that represents the collection of smart tags that have been added to a control. .
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
ThemeFontIndex | Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the list box and its top gridline. Read/write Integer.
ValidationRule | You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.
ValidationText | Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.
Value | Determines or specifies which value or option in the list box is selected. Read/write Variant.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified list box is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


Record Properties, Methods, and Events (ADO)

 Copy code hover
[image]

Record Properties, Methods, and Events (ADO)
Send feedback

Properties/Collections

ActiveConnection Property

Fields Collection

Mode Property

ParentURL Property

Properties Collection

RecordType Property

Source Property (ADO Record)

State Property

Methods

Cancel Method

Close Method

CopyRecord Method

DeleteRecord Method

GetChildren Method

MoveRecord Method

Open Method (ADO Record)

Events

None.


There is no suitable replica to exchange with. (Error 3684)

 Copy code hover
[image]

There is no suitable replica to exchange with. (Error 3684)
Send feedback

There are no suitable replicas to synchronize with the HTTP address supplied.


Parameters Object Reference (DAO)

 Copy code hover
[image]

Parameters Object Reference (DAO)
Send feedback

In this section

  • Parameters Collection (DAO)

  • Parameters Members (DAO)

  • Parameters Properties (DAO)

  • Parameters Methods (DAO)


CommandButton.ControlType Property (Access)

 Copy code hover
[image]

CommandButton.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Syntax

expression .ControlType

expression A variable that represents a CommandButton object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Positions Collection Properties, Methods, and Events (ADO MD)

 Copy code hover
[image]

Positions Collection Properties, Methods, and Events (ADO MD)
Send feedback

Properties

Count Property

Item Property

Methods

Refresh Method

Events

None.


OptionButton.HideDuplicates Property (Access)

 Copy code hover
[image]

OptionButton.HideDuplicates Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.

Syntax

expression .HideDuplicates

expression A variable that represents an OptionButton object.

Remarks

The HideDuplicates property applies only to controls (check box, combo box, list box, option button, option group, text box, toggle button) on a report.

The HideDuplicates property uses the following settings.

Setting | Description
True | If the value of a control or the data it contains is the same as in the preceding record, the control is hidden.
False | (Default) The control is visible regardless of the value in the preceding record.

The DefaultValue property doesn't apply to check box, option button, or toggle buttoncontrols when they are in an option group. It does however apply to the option group itself.

You can set the HideDuplicates property only in report Design view.

You can use the HideDuplicates property to create a grouped report by using only the detail section rather than a group header and the detail section.

Example

The following example returns the HideDuplicates property setting for the CategoryName text box and assigns the value to the intCurVal variable.

VBA Copy code Copy code
Dim intCurVal As Integer
intCurVal = Me!CategoryName.HideDuplicates

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Rectangle.SpecialEffect Property (Access)

 Copy code hover
[image]

Rectangle.SpecialEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.

Syntax

expression .SpecialEffect

expression A variable that represents a Rectangle object.

Remarks

The SpecialEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | 0 | The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised | 1 | The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken | 2 | The object has a shadow on the top and left and a highlight on the bottom and right.
Etched | 3 | The object has a sunken line surrounding the control.
Shadowed | 4 | The object has a shadow below and to the right of the control.
Chiseled | 5 | The object has a sunken line below the control.

The SpecialEffect property setting affects related property settings for the BorderStyle , BorderColor , and BorderWidth properties. For example, if the SpecialEffect property is set to Raised, the settings for the BorderStyle, BorderColor, and BorderWidth properties are ignored. In addition, changing or setting the BorderStyle, BorderColor, and BorderWidth properties may cause Microsoft Access to change the SpecialEffect property setting to Flat.

Example

The following example sets the appearance of the text box "OrganizationName1" on the "Mailing List" form to raised.

VBA Copy code Copy code
Forms("Mailing List").Controls("OrganizationName1").SpecialEffect = 1

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


ImportExportSpecifications.Add Method (Access)

 Copy code hover
[image]

ImportExportSpecifications.Add Method (Access)
See also Send feedback

Published: July 16, 2012

Adds a new ImportExportSpecification object to the ImportExportSpecifications collection.

Version Information

Version Added: Access 2007

Syntax

expression .Add(Name, SpecificationDefinition)

expression A variable that represents an ImportExportSpecifications object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Required | String | The name to use for the ImportExportSpecification.
SpecificationDefinition | Required | String | The XML markup that represents the settings to save for the import or export operation.

Return Value

ImportExportSpecification

See also

Concepts

ImportExportSpecifications Collection

Other resources

ImportExportSpecifications Object Members


CommandButton.Enabled Property (Access)

 Copy code hover
[image]

CommandButton.Enabled Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.

Syntax

expression .Enabled

expression A variable that represents a CommandButton object.

Remarks

The Enabled property setting is a value that indicates whether the conditional format is enabled or disabled. True enables the conditional format. False disables the conditional format. The default is True.

When the Enabled property is True, the conditional format can be displayed in the Conditional Formatting dialog box.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


NavigationControl.Click Event (Access)

 Copy code hover
[image]

NavigationControl.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Version Information

Version Added: Access 2010

Syntax

expression .Click

expression A variable that represents a NavigationControl object.

Return Value

nothing

Remarks

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Recordset.BOF Property (DAO)

 Copy code hover
[image]

Recordset.BOF Property (DAO)
Send feedback

Returns a value that indicates whether the current record position is before the first record in a Recordset object. Read-only Boolean.

Syntax

expression .BOF

expression A variable that represents a Recordset object.

Remarks

You can use the BOF and EOF properties to determine whether a Recordset object contains records or whether you've gone beyond the limits of a Recordset object when you move from record to record.

The location of the current record pointer determines the BOF and EOF return values.

If either the BOF or EOF property is True, there is no current record.

If you open a Recordset object containing no records, the BOF and EOF properties are set to True, and the Recordset object's RecordCount property setting is 0. When you open a Recordset object that contains at least one record, the first record is the current record and the BOF and EOF properties are False; they remain False until you move beyond the beginning or end of the Recordset object by using the MovePrevious or MoveNext method, respectively. When you move beyond the beginning or end of the Recordset, there is no current record or no record exists.

If you delete the last remaining record in the Recordset object, the BOF and EOF properties may remain False until you attempt to reposition the current record.

If you use the MoveLast method on a Recordset object containing records, the last record becomes the current record; if you then use the MoveNext method, the current record becomes invalid and the EOF property is set to True. Conversely, if you use the MoveFirst method on a Recordset object containing records, the first record becomes the current record; if you then use the MovePrevious method, there is no current record and the BOF property is set to True.

Typically, when you work with all the records in a Recordset object, your code will loop through the records by using the MoveNext method until the EOF property is set to True.

If you use the MoveNext method while the EOF property is set to True or the MovePrevious method while the BOF property is set to True, an error occurs.

This table shows which Move methods are allowed with different combinations of the BOF and EOF properties.

 | MoveFirst, MoveLast | MovePrevious, Move < 0 | Move 0 | MoveNext, Move > 0
BOF=True, EOF=False | Allowed | Error | Error | Allowed
BOF=False, EOF=True | Allowed | Allowed | Error | Error
Both True | Error | Error | Error | Error
Both False | Allowed | Allowed | Allowed | Allowed

Allowing a Move method doesn't mean that the method will successfully locate a record. It merely indicates that an attempt to perform the specified Move method is allowed and won't generate an error. The state of the BOF and EOF properties may change as a result of the attempted Move.

An OpenRecordset method internally invokes a MoveFirst method. Therefore, using an OpenRecordset method on an empty set of records sets the BOF and EOF properties to True. (See the following table for the behavior of a failed MoveFirst method.)

All Move methods that successfully locate a record will set both BOF and EOF to False.

In a Microsoft Access workspace, if you add a record to an empty Recordset, BOF will become False, but EOF will remain True, indicating that the current position is at the end of Recordset.

Any Delete method, even if it removes the only remaining record from a Recordset, won't change the setting of the BOF or EOF property.

The following table shows how Move methods that don't locate a record affect the BOF and EOF property settings.

 | BOF | EOF
MoveFirst, MoveLast | True | True
Move 0 | No change | No change
MovePrevious, Move < 0 | True | No change
MoveNext, Move > 0 | No change | True


GroupLevel Properties (Access)

 Copy code hover
[image]

GroupLevel Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
GroupFooter | You can use the GroupFooter property to create a group footer for a selected field or expression in a report. Read/write Boolean.
GroupHeader | You can use the GroupHeader property to create a group header for a selected field or expression in a report. Read/write Boolean.
GroupInterval | You can use the GroupInterval property with the GroupOn property to specify how records are grouped in a report. Read/write Long.
GroupOn | You can use the GroupOn property in a report to specify how to group data in a field or expression by data type. For example, this property lets you group a Date field by month. Read/write Integer.
KeepTogether | You can use the KeepTogether property for a group in a report to keep parts of a group — including the group header, detail section, and group footer — together on the same page. For example, you might want a group header to always be printed on the same page with the first detail section. Read/write Byte.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
SortOrder | You use the SortOrder property to specify the sort order for fields and expressions in a report. For example, if you're printing a list of suppliers, you can sort the records alphabetically by company name. Read/write Boolean.


TextBox.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

TextBox.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified text box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleBottom

expression A variable that represents a TextBox object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Invalid NetworkAccess setting in the Windows Registry. (Error 3248)

 Copy code hover
[image]

Invalid NetworkAccess setting in the Windows Registry. (Error 3248)
Send feedback

There is an invalid NetworkAccess setting in the Microsoft Windows Registry.

To complete this operation

  1. Exit your application.

  2. Start the Registry Editor, and navigate to the NetworkAccess value. Depending on which installable ISAM you are trying to use, the invalid entry is in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Access Connectivity Engine\Engines\Xbase key.

  3. On the Edit menu, click Modify.

  4. Specify either On or Off in the Value data box.

  5. Restart your application, and then try the operation again.


This property is not supported for external data sources or for databases created with a previous version of Microsoft Jet. (Error 3310)

 Copy code hover
[image]

This property is not supported for external data sources or for databases created with a previous version of Microsoft Jet. (Error 3310)
Send feedback

You attempted to set or check a property that is not available for this object in a database stored in a Microsoft Jet database version 1.x, 2.x, or in an external data source. Search for the object in Help, and then display the Summary topic for the object to see a list of its valid properties.


ConnectionString Property (ADO)

 Copy code hover
[image]

ConnectionString Property (ADO)
Send feedback

Indicates the information used to establish a connection to a data source.

Settings and Return Values

Sets or returns a String value.

Remarks

Use the ConnectionString property to specify a data source by passing a detailed connection string containing a series of argument = value statements separated by semicolons.

ADO supports five arguments for the ConnectionString property; any other arguments pass directly to the provider without any processing by ADO. The arguments ADO supports are as follows.

Argument | Description
Provider= | Specifies the name of a provider to use for the connection.
File Name= | Specifies the name of a provider-specific file (for example, a persisted data source object) containing preset connection information.
Remote Provider= | Specifies the name of a provider to use when opening a client-side connection. (Remote Data Service only.)
Remote Server= | Specifies the path name of the server to use when opening a client-side connection. (Remote Data Service only.)
URL= | Specifies the connection string as an absolute URL identifying a resource, such as a file or directory.

After you set the ConnectionString property and open the Connection object, the provider may alter the contents of the property, for example, by mapping the ADO-defined argument names to their provider equivalents.

The ConnectionString property automatically inherits the value used for the ConnectionString argument of the Open method, so you can override the current ConnectionString property during the Open method call.

Because the File Name argument causes ADO to load the associated provider, you cannot pass both the Provider and File Name arguments.

The ConnectionString property is read/write when the connection is closed and read-only when it is open.

Duplicates of an argument in the ConnectionString property are ignored. The last instance of any argument is used.

Remote Data Service UsageWhen used on a client-side Connection object, the ConnectionString property can include only the Remote Provider and Remote Server parameters.


Access SQL and expressions reference (Access 2013 custom web app)

 Copy code hover
[image]

Access SQL and expressions reference (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • Conversion functions (Access 2013 custom web app)

  • Database functions (Access 2013 custom web app)

  • Date/time functions (Access 2013 custom web app)

  • Inspection functions (Access 2013 custom web app)

  • Math functions (Access 2013 custom web app)

  • Program flow functions (Access 2013 custom web app)

  • Text functions (Access 2013 custom web app)

  • Operators (Access 2013 custom web app)


Out of Memory - could not complete operation.

 Copy code hover
[image]

Out of Memory - could not complete operation.
Send feedback

This message has the following cause and solution:

  • Your computer has run out of memory.

Close unused applications. If the problem persists, restart your computer.


CommandButton.Application Property (Access)

 Copy code hover
[image]

CommandButton.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a CommandButton object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ObjectFrame.BackColor Property (Access)

 Copy code hover
[image]

ObjectFrame.BackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the interior color of the specified object. Read/write Long.

Syntax

expression .BackColor

expression A variable that represents an ObjectFrame object.

Remarks

The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

To use the BackColor property, the BackStyle property, if available, must be set to Normal.

Example

The following example uses the RGB function to set the , BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Index.Fields Property (DAO)

 Copy code hover
[image]

Index.Fields Property (DAO)
Send feedback

Returns a Fields collection that represents all stored Field objects for the specified object. Read/write.

Syntax

expression .Fields

expression A variable that represents an Index object.


Field.FieldSize Property (DAO)

 Copy code hover
[image]

Field.FieldSize Property (DAO)
Send feedback

Returns the number of bytes used in the database (rather than in memory) of a Memo or Long Binary Field object in the Fields collection of a Recordset object.

Syntax

expression .FieldSize

expression A variable that represents a Field object.

Remarks

You can use FieldSize with the AppendChunk and GetChunk methods to manipulate large fields.

Because the size of a Long Binary or Memo field can exceed 64K, you should assign the value returned by FieldSize to a variable large enough to store a Long variable.

To determine the size of a Field object other than Memo and Long Binary types, use the Size property.

  • If the database server or ODBC driver does not support server-side cursors.

  • If you are using the ODBC cursor library (that is, the DefaultCursorDriver property is set to dbUseODBC, or to dbUseDefault when the server does not support server-side cursors).

  • If you are using a cursorless query (that is, the DefaultCursorDriver property is set to dbUseNoCursor).

The FieldSize property and the VBA Len() or LenB() functions may return different values as the length of the same string. Strings are stored in a Microsoft Access database in multi-byte character set (MBCS) form, but exposed through VBA in Unicode format. As a result, the Len() function will always return the number of characters, LenB will always return the number of characters X 2 (Unicode uses two bytes for each character), but FieldSize will return some value in between if the string has any MBCS characters. For example, given a string consisting of three normal characters and two MBCS characters, Len() will return 5, LenB() will return 10, and FieldSize will return 7, the sum of 1 for each normal character and 2 for each MBCS character.

Example

This example uses the FieldSize property to list the number of bytes used by the Memo and Long Binary Field objects in two different tables.

VBA Copy code Copy code
Sub FieldSizeX()

 Dim dbsNorthwind As Database
 Dim rstCategories As Recordset
 Dim rstEmployees As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstCategories = _
 dbsNorthwind.OpenRecordset("Categories", _
 dbOpenDynaset)
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", _
 dbOpenDynaset)

 Debug.Print _
 "Field sizes from records in Categories table"

 With rstCategories
 Debug.Print " CategoryName - " & _
 "Description (bytes) - Picture (bytes)"

 ' Enumerate the Categories Recordset and print the size
 ' in bytes of the picture field for each record.
 Do While Not .EOF
 Debug.Print " " & !CategoryName & " - " & _
 !Description.FieldSize & " - " & _
 !Picture.FieldSize
 .MoveNext
 Loop

 .Close
 End With

 Debug.Print "Field sizes from records in Employees table"

 With rstEmployees
 Debug.Print " LastName - Notes (bytes) - " & _
 "Photo (bytes)"

 ' Enumerate the Employees Recordset and print the size
 ' in bytes of the picture field for each record.
 Do While Not .EOF
 Debug.Print " " & !LastName & " - " & _
 !Notes.FieldSize & " - " & !Photo.FieldSize
 .MoveNext
 Loop

 .Close
 End With

 dbsNorthwind.Close

End Sub

This example uses the AppendChunk and GetChunk methods to fill an OLE object field with data from another record, 32K at a time. In a real application, one might use a procedure like this to copy an employee record (including the employee's photo) from one table to another. In this example, the record is simply being copied back to same table. Note that all the chunk manipulation takes place within a single AddNew-Update sequence.

VBA Copy code Copy code
Sub AppendChunkX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset
 Dim rstEmployees2 As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 ' Open two recordsets from the Employees table.
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", _
 dbOpenDynaset)
 Set rstEmployees2 = rstEmployees.Clone

 ' Add a new record to the first Recordset and copy the
 ' data from a record in the second Recordset.
 With rstEmployees
 .AddNew
 !FirstName = rstEmployees2!FirstName
 !LastName = rstEmployees2!LastName
 CopyLargeField rstEmployees2!Photo, !Photo
 .Update

 ' Delete new record because this is a demonstration.
 .Bookmark = .LastModified
 .Delete
 .Close
 End With

 rstEmployees2.Close
 dbsNorthwind.Close

End Sub

Function CopyLargeField(fldSource As Field, _
 fldDestination As Field)

 ' Set size of chunk in bytes.
 Const conChunkSize = 32768

 Dim lngOffset As Long
 Dim lngTotalSize As Long
 Dim strChunk As String

 ' Copy the photo from one Recordset to the other in 32K
 ' chunks until the entire field is copied.
 lngTotalSize = fldSource.FieldSize
 Do While lngOffset < lngTotalSize
 strChunk = fldSource.GetChunk(lngOffset, conChunkSize)
 fldDestination.AppendChunk strChunk
 lngOffset = lngOffset + conChunkSize
 Loop

End Function


You must enter a personal identifier (PID) consisting of at least 4 and no more than 20 characters and digits. (Error 3304)

 Copy code hover
[image]

You must enter a personal identifier (PID) consisting of at least 4 and no more than 20 characters and digits. (Error 3304)
Send feedback

A personal identifier (PID) must be at least 4 characters and no more than 20 characters long.


Database.QueryTimeout Property (DAO)

 Copy code hover
[image]

Database.QueryTimeout Property (DAO)
Send feedback

Sets or returns a value that specifies the number of seconds to wait before a timeout error occurs when a query is executed on an ODBC data source.

Syntax

expression .QueryTimeout

expression A variable that represents a Database object.

Remarks

The default value is 60.

When you're using an ODBC database, such as Microsoft SQL Server, there may be delays due to network traffic or heavy use of the ODBC server. Rather than waiting indefinitely, you can specify how long to wait.

When you use QueryTimeout with a Connection or Database object, it specifies a global value for all queries associated with the database. You can override this value for a specific query by setting the ODBCTimeout property of the particular QueryDef object.

Example

This example uses the ODBCTimeout and QueryTimeout properties to show how the QueryTimeout setting on a Database object sets the default ODBCTimeout setting on any QueryDef objects created from the Database object.

VBA Copy code Copy code
Sub ODBCTimeoutX()

 Dim dbsCurrent As Database
 Dim qdfStores As QueryDef
 Dim rstStores As Recordset

 Set dbsCurrent = OpenDatabase("Northwind.mdb")

 ' Change the default QueryTimeout of the Northwind
 ' database.
 Debug.Print "Default QueryTimeout of Database: " & _
 dbsCurrent.QueryTimeout
 dbsCurrent.QueryTimeout = 30
 Debug.Print "New QueryTimeout of Database: " & _
 dbsCurrent.QueryTimeout

 ' Create a new QueryDef object.
 Set qdfStores = dbsCurrent.CreateQueryDef("Stores", _
 "SELECT * FROM stores")

 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the SQL Server.
 qdfStores.Connect = _
 "ODBC;DATABASE=pubs;DSN=Publishers"

 ' Change the ODBCTimeout setting of the new QueryDef
 ' object from its default setting.
 Debug.Print "Default ODBCTimeout of QueryDef: " & _
 qdfStores.ODBCTimeout
 qdfStores.ODBCTimeout = 0
 Debug.Print "New ODBCTimeout of QueryDef: " & _
 qdfStores.ODBCTimeout

 ' Execute the query and display the results.
 Set rstStores = qdfStores.OpenRecordset()

 Debug.Print "Contents of recordset:"
 With rstStores
 Do While Not .EOF
 Debug.Print , .Fields(0), .Fields(1)
 .MoveNext
 Loop
 .Close
 End With

 ' Delete new QueryDef because this is a demonstration.
 dbsCurrent.QueryDefs.Delete qdfStores.Name
 dbsCurrent.Close

End Sub


References.ItemAdded Event (Access)

 Copy code hover
[image]

References.ItemAdded Event (Access)
See also Send feedback

Published: July 16, 2012

The ItemAdded event occurs when a reference is added to the project from Visual Basic.

Syntax

expression .ItemAdded(Reference, )

expression A variable that represents a References object.

Parameters

Name | Required/Optional | Data Type | Description
Reference | Required | Reference | The reference that was added to the project.

Remarks

  • The ItemAdded event applies to the References collection. It isn't associated with a control, form, or report, as are most other events. Therefore, in order to create a procedure definition for the ItemAdded event procedure, you must use a special syntax.

  • The ItemAdded event can run only an event procedure when it occurs, it cannot run a macro.

This event occurs only when you add a reference from code. It doesn't occur when you add a reference from the References dialog box, available by clicking References on the Tools menu when the Module window is the active window.

Example

The following example includes event procedures for the ItemAdded and ItemRemoved events. To try this example, first create a new class module by clicking Class Module on the Insert menu. Paste the following code into the class module and save the module as RefEvents:

VBA Copy code Copy code
' Declare object variable to represent References collection.
Public WithEvents evtReferences As References

' When instance of class is created, initialize evtReferences
' variable.
Private Sub Class_Initialize()
 Set evtReferences = Application.References
End Sub

' When instance is removed, set evtReferences to Nothing.
Private Sub Class_Terminate()
 Set evtReferences = Nothing
End Sub

' Display message when reference is added.
Private Sub evtReferences_ItemAdded(ByVal Reference As _
 Access.Reference)
 MsgBox "Reference to " & Reference.Name & " added."
End Sub

' Display message when reference is removed.
Private Sub evtReferences_ItemRemoved(ByVal Reference As _
 Access.Reference)
 MsgBox "Reference to " & Reference.Name & " removed."
End Sub

The following Function procedure adds a specified reference. When a reference is added, the ItemAdded event procedure defined in the RefEvents class runs.

VBA Copy code Copy code
' Create new instance of RefEvents class.
Dim objRefEvents As New RefEvents

' Pass file name and path of type library to this procedure.
Function AddReference(strFileName As String) As Boolean
 Dim ref As Reference

 On Error GoTo Error_AddReference
 ' Create new reference on References object variable.
 Set ref = objRefEvents.evtReferences.AddFromFile(strFileName)
 AddReference = True

Exit_AddReference:
 Exit Function

Error_AddReference:
 MsgBox Err & ": " & Err.Description
 AddReference = False
 Resume Exit_AddReference
End Function

See also

Concepts

References Collection

Other resources

References Object Members


Set Options from Visual Basic

 Copy code hover
[image]

Set Options from Visual Basic
Send feedback

You can use the SetOption and GetOption methods to set and return option values in the Access Options dialog box from code. To view the Access Options dialog box, click the Microsoft Office Button [image] and then click Access Options.

The value that you pass to the SetOption method as the setting argument depends on which type of option you are setting. The following table establishes some guidelines for setting options.

If the option is | Then the setting argument is
A text box | A string
A check box | A Boolean value — True (-1) or False (0)
An option button in an option group, or an option in a combo box or a list box | An integer corresponding to the option's position in the option group or list (starting with zero [0])

The following tables list the names of all options that can be set or returned from code and the tabs on which they can be found in the Access Options dialog box, followed by the corresponding string argument that you must pass to the SetOption or GetOption method.

Popular Tab

Creating Databases Section

Option Text | String Argument
New database sort order | New Database Sort Order
Default database folder | Default Database Directory
Default file format | Default File Format

Current Database Tab

Application Options section

Option Text | String Argument
Compact on Close | Auto Compact
Remove personal information from file properties on save | Remove Personal Information
Use Windows-themed Controls on Forms | Themed Form Controls
Enable Layout View for this database | DesignWithData
Check for truncated number fields | CheckTruncatedNumFields
Picture Property Storage Format | Picture Property Storage Format

Name AutoCorrect Options section

Option Text | String Argument
Track name AutoCorrect info | Track Name AutoCorrect Info
Perform name AutoCorrect | Perform Name AutoCorrect
Log name AutoCorrect changes | Log Name AutoCorrect Changes

Filter Lookup options for <Database Name> Database section

Option Text | String Argument
Show list of values in, Local indexed fields | Show Values in Indexed
Show list of values in, Local nonindexed fields | Show Values in Non-Indexed
Show list of values in, ODBC fields | Show Values in Remote
Show list of values in, Records in local snapshot | Show Values in Snapshot
Show list of values in, Records at server | Show Values in Server
Don't display lists where more than this number of records read | Show Values Limit

Datasheet Tab

Default colors section

Option Text | String Argument
Font color | Default Font Color
Background color | Default Background Color
Alternate background color | _64
Gridlines color | Default Gridlines Color

Gridlines and cell effects section

Option Text | String Argument
Default gridlines showing, Horizontal | Default Gridlines Horizontal
Default gridlines showing, Vertical | Default Gridlines Vertical
Default cell effect | Default Cell Effect
Default column width | Default Column Width

Default font section

Option Text | String Argument
Font | Default Font Name
Size | Default Font Size
Weight | Default Font Weight
Underline | Default Font Underline
Italic | Default Font Italic

Object Designers Tab

Table design section

Option Text | String Argument
Default text field size | Default Text Field Size
Default number field size | Default Number Field Size
Default field type | Default Field Type
AutoIndex on Import/Create | AutoIndex on Import/Create
Show Property Update Option Buttons | Show Property Update Options Buttons

Query design section

Option Text | String Argument
Show table names | Show Table Names
Output all fields | Output All Fields
Enable AutoJoin | Enable AutoJoin
SQL Server Compatible Syntax (ANSI 92), This database | ANSI Query Mode
SQL Server Compatible Syntax (ANSI 92), Default for new databases | ANSI Query Mode Default
Query design font, Font | Query Design Font Name
Query design font, Size | Query Design Font Size

Forms/Reports section

Option Text | String Argument
Selection behavior | Selection Behavior
Form template | Form Template
Report template | Report Template
Always use event procedures | Always Use Event Procedures

Error checking section

Option Text | String Argument
Enable error checking | Enable Error Checking
Error indicator color | Error Checking Indicator Color
Check for unassociated label and control | Unassociated Label and Control Error Checking
Check for new unassociated labels | New Unassociated Labels Error Checking
Check for keyboard shortcut errors | Keyboard Shortcut Errors Error Checking
Check for invalid control properties | Invalid Control Properties Error Checking
Check for common report errors | Common Report Errors Error Checking

Proofing Tab

When correcting spelling in Microsoft Office programs section

Option Text | String Argument
Ignore words in UPPERCASE | Spelling ignore words in UPPERCASE
Ignore words that contain numbers | Spelling ignore words with number
Ignore Internet and file addresses | Spelling ignore Internet and file addresses
Suggest from main dictionary only | Spelling suggest from main dictionary only
Dictionary Language | Spelling dictionary language

Advanced Tab

Editing section

Option Text | String Argument
Move after enter | Move After Enter
Behavior entering field | Behavior Entering Field
Arrow key behavior | Arrow Key Behavior
Cursor stops at first/last field | Cursor Stops at First/Last Field
Default find/replace behavior | Default Find/Replace Behavior
Confirm, Record changes | Confirm Record Changes
Confirm, Document deletions | Confirm Document Deletions
Confirm, Action queries | Confirm Action Queries
Default direction | Default Direction
General alignment | General Alignment
Cursor movement | Cursor Movement
Datasheet IME control | Datasheet Ime Control
Use Hijri Calendar | Use Hijri Calendar

Display section

Option Text | String Argument
Show this number of Recent Documents | Size of MRU File List
Status bar | Show Status Bar
Show animations | Show Animations
Show Smart Tags on Datasheets | Show Smart Tags on Datasheets
Show Smart Tags on Forms and Reports | Show Smart Tags on Forms and Reports
Show in Macro Design, Names column | Show Macro Names Column
Show in Macro Design, Conditions column | Show Conditions Column

Printing section

Option Text | String Argument
Left margin | Left Margin
Right margin | Right Margin
Top margin | Top Margin
Bottom margin | Bottom Margin

General section

Option Text | String Argument
Provide feedback with sound | Provide Feedback with Sound
Use four-year digit year formatting, This database | Four-Digit Year Formatting
Use four-year digit year formatting, All databases | Four-Digit Year Formatting All Databases

Advanced Section

Option Text | String Argument
Open last used database when Access starts | Open Last Used Database When Access Starts
Default open mode | Default Open Mode for Databases
Default record locking | Default Record Locking
Open databases by using record-level locking | Use Row Level Locking
OLE/DDE timeout (sec) | OLE/DDE Timeout (sec)
Refresh interval (sec) | Refresh Interval (sec)
Number of update retries | Number of Update Retries
ODBC refresh interval (sec) | ODBC Refresh Interval (sec)
Update retry interval (msec) | Update Retry Interval (msec)
DDE operations, Ignore DDE requests | Ignore DDE Requests
DDE operations, Enable DDE refresh | Enable DDE Refresh
Command-line arguments | Command-Line Arguments

Note Note

  • If your database may run on a version of Microsoft Access for a language other than the one in which you created it, then you must supply the arguments for the GetOption and SetOption methods in English.

  • Some options are available only within a Microsoft Access database or Access project (.adp).

  • If you are developing a database application, add-in, library database, or referenced database, make sure that the Error Trapping option is set to 2 (Break On Unhandled Errors) when you have finished debugging your code.


ToggleButton.ThemeFontIndex Property (Access)

 Copy code hover
[image]

ToggleButton.ThemeFontIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ThemeFontIndex

expression A variable that represents a ToggleButton object.

Remarks

The ThemeFontIndex property uses one of the values listed in the following table.

Value | Description
0 | Header font
1 (Default) | Detail font

If no theme is applied, the ThemeFontIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Form.CloseButton Property (Access)

 Copy code hover
[image]

Form.CloseButton Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether the Close button on a form is enabled. Read/write Boolean.

Syntax

expression .CloseButton

expression A variable that represents a Form object.

Remarks

The CloseButton property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) The Close button is enabled.
No | False | The Close button is disabled and the Close command isn't available on the Control menu.

You can set the CloseButton property only in form Design view.

If you set the CloseButton property to No, the Close button remains visible but appears dimmed (grayed), and you must provide some other way to close the form — for example, a command button or custom menu command that runs a macro or event procedure that closes the form.

You can also close the form by pressing ALT+F4.

See also

Concepts

Form Object

Other resources

Form Object Members


Query Method (RDS)

 Copy code hover
[image]

Query Method (RDS)
Send feedback

Uses a valid SQL query string to return a Recordset.

Syntax

Set Recordset = DataFactory.Query(Connection, Query)

Parameters

  • Recordset

  • An object variable that represents a Recordset object.

  • DataFactory

  • An object variable that represents an RDSServer.DataFactory object.

  • Connection

  • A String value that contains the server connection information. This is similar to the Connect property.

  • Query

  • A String that contains the SQL query.

Remarks

The query should use the SQL dialect of the database server. A result status is returned if there is an error with the query that was executed. The Query method doesn't perform any syntax checking on the Query string.


DBEngine.Idle Method (DAO)

 Copy code hover
[image]

DBEngine.Idle Method (DAO)
Send feedback

Suspends data processing, enabling the Microsoft Access database engine to complete any pending tasks, such as memory optimization or page timeouts (Microsoft Access workspaces only).

Syntax

expression .Idle(Action)

expression A variable that represents a DBEngine object.

Parameters

Name | Required/Optional | Data Type | Description
Action | Optional | Variant | Specifies the action to take. Can be one of the IdleEnum constants.

Remarks

The Idle method allows the Microsoft Access database engine to perform background tasks that may not be up-to-date because of intense data processing. This is often true in multiuser, multitasking environments that don't have enough background processing time to keep all records in a Recordset current.

Usually, read locks are removed and data in local dynaset-type Recordset objects are updated only when no other actions (including mouse movements) occur. If you periodically use the Idle method, the Microsoft Access database engine can catch up on background processing tasks by releasing unneeded read locks.

Specifying the optional dbRefreshCache argument refreshes memory with only the most current data from the database.

You don't need to use this method in single-user environments unless multiple instances of an application are running. The Idle method may increase performance in a multiuser environment because it forces the database engine to write data to disk, releasing locks on memory.

Note Note

You can also release read locks by making operations part of a transaction.

Example

This example uses the Idle method to ensure that an output procedure is accessing the most current data available from the database. The IdleOutput procedure is required for this procedure to run.

VBA Copy code Copy code
Sub IdleX()

 Dim dbsNorthwind As Database
 Dim strCountry As String
 Dim strSQL As String
 Dim rstOrders As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 ' Get name of country from user and build SQL statement
 ' with it.
 strCountry = Trim(InputBox("Enter country:"))
 strSQL = "SELECT * FROM Orders WHERE ShipCountry = '" & _
 strCountry & "' ORDER BY OrderID"

 ' Open Recordset object with SQL statement.
 Set rstOrders = dbsNorthwind.OpenRecordset(strSQL)

 ' Display contents of Recordset object.
 IdleOutput rstOrders, strCountry

 rstOrders.Close
 dbsNorthwind.Close

End Sub

Sub IdleOutput(rstTemp As Recordset, strTemp As String)

 ' Call the Idle method to release unneeded locks, force
 ' pending writes, and refresh the memory with the current
 ' data in the .mdb file.
 DBEngine.Idle dbRefreshCache

 ' Enumerate the Recordset object.
 With rstTemp
 Debug.Print "Orders from " & strTemp & ":"
 Debug.Print , "OrderID", "CustomerID", "OrderDate"
 Do While Not .EOF
 Debug.Print , !OrderID, !CustomerID, !OrderDate
 .MoveNext
 Loop
 End With

End Sub


Textual Criteria Expressions

 Copy code hover
[image]

Textual Criteria Expressions
Send feedback

To specify textual criteria for an operation, you supply a text string as part of the string expression that forms the criteria argument. This text string must be enclosed in single quotation marks (').

Note Note

The single quotation marks indicate to Microsoft Access that the criteria argument contains a string within a string.

Suppose that you are using the ADO Find method to find the first occurrence of a last name in an Employees table. You could construct the criteria argument as in the following example, which moves the current record pointer to the first record in which an employee's last name is Buchanan. Note that the string literal is enclosed in single quotation marks and the entire string comprising the criteria argument must also be enclosed in double quotation marks (").

Copy code Copy code
Dim rst As New ADODB.Connection

rst.open "Employees", CurrentProject.Connection,_
 dbOpenDynaset, adlockoptimistic)
rst.Find "[LastName] = 'Buchanan'"


Attachment.GridlineStyleRight Property (Access)

 Copy code hover
[image]

Attachment.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified attachment. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleRight

expression A variable that represents an Attachment object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Aggregate Functions, the CALC Function, and the NEW Keyword

 Copy code hover
[image]

Aggregate Functions, the CALC Function, and the NEW Keyword
Send feedback

Data shaping supports the following functions. The name assigned to the chapter containing the column to be operated on is the chapter-alias.

A chapter-alias may be fully qualified, consisting of each chapter column name leading to the chapter containing the column-name, all separated by periods. For example, if the parent chapter, chap1, contains a child chapter, chap2, that has an amount column, amt, then the qualified name would be chap1.chap2.amt.

Aggregate Functions

Description

SUM(chapter-alias.column-name)

Calculates the sum of all values in the specified column.

AVG(chapter-alias.column-name)

Calculates the average of all values in the specified column.

MAX(chapter-alias.column-name)

Calculates the maximum value in the specified column.

MIN(chapter-alias.column-name)

Calculates the minimum value in the specified column.

COUNT(chapter-alias[.column-name])

Counts the number of rows in the specified alias. If a column is specified, only rows for which that column is non-Null are included in the count.

STDEV(chapter-alias.column-name)

Calculates the standard deviation in the specified column.

ANY(chapter-alias.column-name)

A value of the specified column. ANY has a predictable value only when the value of the column is the same for all rows in the chapter.

Note Note

If the column does not contain the same value for all of the rows in the chapter, the SHAPE command arbitrarily returns one of the values to be the value of the ANY function.

Calculated expression | Description
CALC(expression) | Calculates an arbitrary expression, but only on the row of the Recordset containing the CALC function. Any expression using these Visual Basic for Applications (VBA) Functions is allowed.
NEW keyword | Description
NEW field-type [(width | scale | precision | error [, scale | error])] | Adds an empty column of the specified type to the Recordset.

The field-type passed with the NEW keyword can be any of the following data types.

OLE DB data types | ADO data type equivalent(s)
DBTYPE_BSTR | adBSTR
DBTYPE_BOOL | adBoolean
DBTYPE_DECIMAL | adDecimal
DBTYPE_UI1 | adUnsignedTinyInt
DBTYPE_I1 | adTinyInt
DBTYPE_UI2 | adUnsignedSmallInt
DBTYPE_UI4 | adUnsignedInt
DBTYPE_I8 | adBigInt
DBTYPE_UI8 | adUnsignedBigInt
DBTYPE_GUID | adGuid
DBTYPE_BYTES | adBinary, AdVarBinary, adLongVarBinary
DBTYPE_STR | adChar, adVarChar, adLongVarChar
DBTYPE_WSTR | adWChar, adVarWChar, adLongVarWChar
DBTYPE_NUMERIC | adNumeric
DBTYPE_DBDATE | adDBDate
DBTYPE_DBTIME | adDBTime
DBTYPE_DBTIMESTAMP | adDBTimeStamp
DBTYPE_VARNUMERIC | adVarNumeric
DBTYPE_FILETIME | adFileTime
DBTYPE_ERROR | adError

When the new field is of type decimal (in OLE DB, DBTYPE_DECIMAL, or in ADO, adDecimal), you must specify the precision and scale values.


Name Property (ADOX)

 Copy code hover
[image]

Name Property (ADOX)
Send feedback

Indicates the name of the object.

Settings and Return Values

Sets or returns a String value.

Remarks

Names do not have to be unique within a collection.

The Name property is read/write on Column, Group, Key, Index, Table, and User objects. The Name property is read-only on Catalog, Procedure, and View objects.

For read/write objects (Column, Group, Key, Index, Table and User objects), the default value is an empty string ("").

Note Note

For keys, this property is read-only on Key objects already appended to a collection.
Note Note

For tables, this property is read-only for Table objects already appended to a collection.


Caption Property (ADO MD)

 Copy code hover
[image]

Caption Property (ADO MD)
Send feedback

Indicates the text caption to use when displaying a Level or Member object.

Return Values

Returns a String and is read-only.


ToggleButton.PressedForeTint Property (Access)

 Copy code hover
[image]

ToggleButton.PressedForeTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .PressedForeTint

expression A variable that represents a ToggleButton object.

Remarks

The PressedForeTint property contains a numeric expression that can be used to lighten the theme color in the PressedForeColor property. The default value of the PressedForeTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Troubleshooting RDS (ADO)

 Copy code hover
[image]

Troubleshooting RDS (ADO)
Send feedback

In this section

  • Troubleshooting RDS

  • Configuring RDS on Windows 2000

  • Internet Server Error: Access Denied

  • RDS Returns "Stream Not Read" Error

  • Deadlocks With Read Repeatable Isolation Level

  • Ensuring Sufficient TempDB Space

  • Minimizing Log File Space Usage


GroupLevel Members (Access)

 Copy code hover
[image]

GroupLevel Members (Access)
Send feedback

Published: July 16, 2012

You can use the GroupLevel property in Visual Basic to refer to the group level you are grouping or sorting on in a report.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
GroupFooter | You can use the GroupFooter property to create a group footer for a selected field or expression in a report. Read/write Boolean.
GroupHeader | You can use the GroupHeader property to create a group header for a selected field or expression in a report. Read/write Boolean.
GroupInterval | You can use the GroupInterval property with the GroupOn property to specify how records are grouped in a report. Read/write Long.
GroupOn | You can use the GroupOn property in a report to specify how to group data in a field or expression by data type. For example, this property lets you group a Date field by month. Read/write Integer.
KeepTogether | You can use the KeepTogether property for a group in a report to keep parts of a group — including the group header, detail section, and group footer — together on the same page. For example, you might want a group header to always be printed on the same page with the first detail section. Read/write Byte.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
SortOrder | You use the SortOrder property to specify the sort order for fields and expressions in a report. For example, if you're printing a list of suppliers, you can sort the records alphabetically by company name. Read/write Boolean.


CheckBox.Parent Property (Access)

 Copy code hover
[image]

CheckBox.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a CheckBox object.

Remarks

The Parent property of a label control is the control the label is linked to. The Parent property for a check box, option button, or toggle button in an option group is the name of the option group control. The Parent property of an option group control is the name of the form.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ComboBox.FontBold Property (Access)

 Copy code hover
[image]

ComboBox.FontBold Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontBold property to specify whether a font appears in a bold style in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontBold

expression A variable that represents a ComboBox object.

Remarks

The FontBold property uses the following settings.

Setting | Description
True | The text is bold.
False | (Default) The text isn't bold.

To use the FontBold property on a report, first create a Printevent procedure that prints the desired text.

A font's appearance on screen and in print may differ, depending on your computer and printer.

The FontWeight property, which is available in the property sheet for controls, can also be used to set the line width for a control's text. The FontBold property gives you a quick way to make text bold; the FontWeight property gives you finer control over the line width setting for text. The following table shows the relationship between these properties' settings.

If | Then
FontBold = False | FontWeight = Normal (400)
FontBold = True | FontWeight = Bold (700)
FontWeight < 700 | FontBold = False
FontWeight > = 700 | FontBold = True

Example

The following Print event procedure prints a report title and the current date in a bold style on a report at the coordinates specified by the CurrentX and CurrentY property settings.

VBA Copy code Copy code
Private Sub ReportHeader0_Print(Cancel As Integer, _
 PrintCount As Integer)
 Dim MyDate

 MyDate = Date
 Me.FontBold = True
 ' Print report title in bold.
 Me.Print("Sales Management Report")
 Me.Print(MyDate)
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


AllViews.Application Property (Access)

 Copy code hover
[image]

AllViews.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents an AllViews object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

AllViews Collection

Other resources

AllViews Object Members


References.Item Method (Access)

 Copy code hover
[image]

References.Item Method (Access)
See also Send feedback

Published: July 16, 2012

The Item method returns a specific member of a collection either by position or by key. Reference object.

Syntax

expression .Item(var)

expression A variable that represents a References object.

Parameters

Name | Required/Optional | Data Type | Description
var | Required | Variant | An expression that specifies the position of a member of the collection. If a numeric expression, the var argument must be a number from 1 to the value of the collection's Count property. If a string expression, the var argument must be the name of a member of the collection.

Return Value

Reference

Remarks

If the value provided for the var argument doesn't match any existing member of the collection, an error occurs.

The Item method is the default member of the References collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print References(1).Name
VBA Copy code Copy code
Debug.Print References.Item(1).Name

See also

Concepts

References Collection

Other resources

References Object Members


Flush Method (ADO)

 Copy code hover
[image]

Flush Method (ADO)
Send feedback

Forces the contents of the Stream remaining in the ADO buffer to the underlying object with which the Stream is associated.

Syntax

Stream.Flush

Remarks

This method may be used to send the contents of the stream buffer to the underlying object (for example, the node or file represented by the URL that is the source of the Stream object). This method should be called when you want to ensure that all changes made to the contents of a Stream have been written. However, with ADO it is not usually necessary to call Flush, as ADO continuously flushes its buffer as much as possible in the background. Changes to the content of a Stream are made automatically, not cached until Flush is called.

Closing a Stream with the Close method flushes the contents of a Stream automatically; there is no need to explicitly call Flush immediately before Close.


ToggleButton.InSelection Property (Access)

 Copy code hover
[image]

ToggleButton.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents a ToggleButton object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Form.OnDeactivate Property (Access)

 Copy code hover
[image]

Form.OnDeactivate Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Deactivate box in the Properties window of a form or report. Read/write String.

Syntax

expression .OnDeactivate

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Deactivate event occurs when the form or report loses the focus to a Table, Query, Form, Report, Macro, or Module window, or to the Database window.

The OnDeactivate value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Deactivate box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Deactivate box is blank, the property value is an empty string.

Example

The following example associates the Deactivate event with the macro "Deactivate_Macro" for the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").OnDeactivate = "Deactivate_Macro"

See also

Concepts

Form Object

Other resources

Form Object Members


HelloData: A Simple ADO Application

 Copy code hover
[image]

HelloData: A Simple ADO Application
Send feedback

To lay the groundwork for an exploration of the ADO library, consider a simple ADO application called "HelloData." HelloData steps through each of the four major ADO operations (getting, examining, editing, and updating data). In order to focus on the fundamentals of ADO and prevent code clutter, minimal error handling is done in the example.

The application queries the Northwind sample database that is included with Microsoft SQL Server 2000.

To run HelloData

  1. Create a new Standard Executable Visual Basic Project that references the ADO 2.5 library.

  2. Create four command buttons at the top of the form, setting the Name and Caption properties to the values shown in the table below.

  3. Below the buttons, add a Microsoft DataGrid Control (Msdatgrd.ocx). The Msdatgrd.ocx file comes with Visual Basic and is located in your \windows\system32 or \winnt\system32 directory. To add the DataGrid control to your Visual Basic toolbox pane, select Components... from the Project menu. Then check the box next to "Microsoft DataGrid Control 6.0 (SP3) (OLEDB)" and click OK. To add the control to the project, drag the DataGrid control from the Toolbox to the Visual Basic form.

  4. Create a TextBox on the form below the grid and set its properties as shown in the table. The form should look similar to the following figure when you are finished.

  5. Finally, copy the code listed in "HelloData Code" and paste it into the code editor window of the form. Press F5 to run the code.

Note Note

In the following example, and throughout the guide, the user id "MyId" with a password of "123aBc" is used to authenticate against the server. You should substitute these values with valid logon credentials for your server. Also, substitute the "MyServer" value with the name of your server.

For a detailed description of the code, see "HelloData Details."

Control Type | Property | Value
Form | Name | Form1
 | Height | 6500
 | Width | 6500
MS DataGrid | Name | grdDisplay1
TextBox | Name | txtDisplay1
 | Multiline | true
Command Button | Name | cmdGetData
 | Caption | Get Data
Command Button | Name | cmdExamineData
 | Caption | Examine Data
Command Button | Name | cmdEditData
 | Caption | Edit Data
Command Button | Name | cmdUpdateData
 | Caption | Update Data


TLV violation. (Error 3716)

 Copy code hover
[image]

TLV violation. (Error 3716)
Send feedback

This record contains a field value that does not meet the table level validation constraint. Either update the field value that violates the validation rule and then resubmit this conflict record, or delete this conflict record.


Control.Layout Property (Access)

 Copy code hover
[image]

Control.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified control. Read-only AcLayoutType.

Version Information

Version Added: Access 2007

Syntax

expression .Layout

expression A variable that represents a Control object.

See also

Concepts

Control Object

Other resources

Control Object Members


Invalid use of parentheses. (Error 2442)

 Copy code hover
[image]

Invalid use of parentheses. (Error 2442)
Send feedback

You entered an expression that has invalid parentheses. For example, you may be trying to use the parentheses syntax for an identifier in a query. In a query, you can use only the standard identifier syntax.


CustomControl.GotFocus Event (Access)

 Copy code hover
[image]

CustomControl.GotFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The GotFocus event occurs when the specified object receives the focus.

Syntax

expression .GotFocus

expression A variable that represents a CustomControl object.

Remarks

To run a macro or event procedure when these events occur, set the OnGotFocus property to the name of the macro or to [Event Procedure].

These events occur when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The GotFocus event differs from the Enter event in that the GotFocus event occurs every time a control receives the focus. For example, suppose the user clicks a check box on a form, then clicks a report, and finally clicks the check box on the form to bring it to the foreground. The GotFocus event occurs both times the check box receives the focus. In contrast, the Enter event occurs only the first time the user clicks the check box. The GotFocus event occurs after the Enter event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Image.IsVisible Property (Access)

 Copy code hover
[image]

Image.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Syntax

expression .IsVisible

expression A variable that represents an Image object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

Image Object

Other resources

Image Object Members


SubForm.IsVisible Property (Access)

 Copy code hover
[image]

SubForm.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Syntax

expression .IsVisible

expression A variable that represents a SubForm object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Hyperlink Methods (Access)

 Copy code hover
[image]

Hyperlink Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
AddToFavorites | The AddToFavorites method adds a hyperlink address to the Favorites folder.
CreateNewDocument | You can use the CreateNewDocument method to create a new document associated with a specified hyperlink.
Follow | The Follow method opens the document or Web page specified by a hyperlink address associated with a control on a form or report.


OpenForm Macro Action

 Copy code hover
[image]

OpenForm Macro Action
Send feedback

You can use the OpenForm action to open a form in Form view, Design view, Print Preview, or Datasheet view. You can select data entry and window modes for the form and restrict the records that the form displays.

Setting

The OpenForm action has the following arguments.

Action argument

Description

Form Name

The name of the form to open. The Form Name box in the Action Arguments section of the Macro Builder pane shows all forms in the current database. This is a required argument. If you run a macro containing the OpenForm action in a library database, Microsoft Access first looks for the form with this name in the library database, and then in the current database.

View

The view in which the form will open. Click Form, Design, Print Preview, Datasheet, PivotTable, or PivotChart in the View box. The default is Form.

Note Note

The View argument setting overrides the settings of the form's DefaultView and ViewsAllowed properties. For example, if a form's ViewsAllowed property is set to Datasheet, you can still use the OpenForm action to open the form in Form view.

Filter Name

A filter that restricts or sorts the form's records. You can enter the name of either an existing query or a filter that was saved as a query. However, the query must include all the fields in the form you are opening or have its OutputAllFields property set to Yes.

Where Condition

A valid SQL WHERE clause (without the word WHERE) or expression that Access uses to select records from the form's underlying table or query. If you select a filter with the Filter Name argument, Access applies this WHERE clause to the results of the filter. To open a form and restrict its records to those specified by the value of a control on another form, use the following expression: [fieldname] = Forms![formname]![controlname on other form] Replace fieldname with the name of a field in the underlying table or query of the form you want to open. Replace formname and controlname on other form with the name of the other form and the control on the other form that contains the value you want records in the first form to match.

Note Note

The maximum length of the Where Condition argument is 255 characters. If you need to enter a more complex SQL WHERE clause longer than this, use the OpenForm method of the DoCmd object in a Visual Basic for Applications (VBA) module instead. You can enter SQL WHERE clause statements of up to 32,768 characters in VBA.

Data Mode

The data entry mode for the form. This applies only to forms opened in Form view or Datasheet view. Click Add (the user can add new records but can't edit existing records), Edit (the user can edit existing records and add new records), or Read Only (the user can only view records). The default is Edit. Notes

  • The Data Mode argument setting overrides the settings of the form's AllowEdits, AllowDeletions, AllowAdditions, and DataEntry properties. For example, if a form's AllowEdits property is set to No, you can still use the OpenForm action to open the form in Edit mode.

  • If you leave this argument blank, Access opens the form in the data entry mode set by the form's AllowEdits, AllowDeletions, AllowAdditions, and DataEntry properties.

Window Mode

The window mode in which the form opens. Click Normal (the form opens in the mode set by its properties), Hidden (the form is hidden), Icon (the form opens minimized as a small title bar at the bottom of the screen), or Dialog (the form's Modal and PopUp properties are set to Yes). The default is Normal.

Note Note

Some Window Mode argument settings do not apply when using tabbed documents. To switch to overlapping windows:

  1. Click the File tab and then click Options.

  2. In the Access Options dialog box, click Current Database.

  3. In the Application Optionssection, under Document Window Options, click Overlapping Windows.

  4. Click OK, then close and reopen the database.

Remarks

This action is similar to double-clicking a form in the Navigation Pane, or right-clicking the form in the Navigation Pane and then selecting a view.

A form can be modal (it must be closed or hidden before the user can perform any other action) or modeless (the user can move to other windows while the form is open). It can also be a pop-up form (a form used to collect or display information that remains on top of all other Access windows). You set the Modal and PopUp properties when you design the form. If you use Normal for the Window Mode argument, the form opens in the mode specified by these property settings. If you use Dialog for the Window Mode argument, these properties are both set to Yes. A form opened as hidden or as an icon returns to the mode specified by its property settings when you show or restore it.

When you open a form with the Window Mode argument set to Dialog, Access suspends the macro until the form is closed or hidden. You can hide a form by setting its Visible property to No by using the SetValue action.

Tip Tip

You can select a form in the Navigation Pane and drag it to a macro action row. This automatically creates an OpenForm action that opens the form in Form view.

The filter and WHERE condition you apply become the setting of the form's Filter property.

Examples

Set the value of a control by using a macro

The following macro opens the Add Products form from a button on the Suppliers form. It shows the use of the Echo, CloseWindow, OpenForm, SetValue, and GoToControl actions. The SetValue action sets the Supplier ID control on the Products form to the current supplier on the Suppliers form. The GoToControl action then moves the focus to the Category ID field, where you can begin to enter data for the new product. This macro should be attached to the Add Products button on the Suppliers form.

Action | Arguments: Setting | Comment
Echo | Echo On: No | Stop screen updating while the macro is running.
CloseWindow | Object Type: Form Object Name: Product List Save: No | Close the Product List form.
OpenForm | Form Name: Products View: Form Data Mode: Add Window Mode: Normal | Open the Products form.
SetValue | Item: [Forms]![Products]![SupplierID] Expression: SupplierID | Set the Supplier ID control to the current supplier on the Suppliers form.
GoToControl | Control Name: CategoryID | Go to the Category ID control.

The following macro opens a Product List form in the lower-right corner of the Suppliers form, displaying the current supplier's products. It shows the use of the Echo, MessageBox, GoToControl, StopMacro, OpenForm, and MoveAndSizeWindow actions. It also shows the use of a conditional expression with the MessageBox, GoToControl, and StopMacro actions. This macro should be attached to the Review Products button on the Suppliers form.

Synchronize forms by using a macro

Condition | Action | Arguments: Setting | Comment
 | Echo | Echo On: No | Stop screen updating while the macro is running.
IsNull([SupplierID]) | MessageBox | Message: Move to the supplier record whose products you want to see, then click the Review Products button again. Beep: Yes Type: None Title: Select a Supplier | If there is no current supplier on the Suppliers form, display a message.
... | GoToControl | Control Name: CompanyName | Move focus to the CompanyName control.
... | StopMacro |  | Stop the macro.
 | OpenForm | Form Name: Product List View: Datasheet Filter Name: Where Condition: [SupplierID] = [Forms]![Suppliers]![SupplierID] Data Mode: Read Only Window Mode: Normal | Open the Product List form and show the current supplier's products.
 | MoveAndSizeWindow | Right: 0.7799" Down: 1.8" | Position the Product List form in the lower right of the Suppliers form.


Report.InputParameters Property (Access)

 Copy code hover
[image]

Report.InputParameters Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InputParameters property to specify or determine the input parameters that are passed to a SQL statement in the RecordSource property of a form or report or a stored procedure when used as the record source within a Microsoft Access project (.adp). Read/write String.

Syntax

expression .InputParameters

expression A variable that represents a Report object.

Remarks

When used with a RecordSource property:

An example InputParameters property string used with a SQL statement in the RecordSource property would use the following syntax.

state char=[Forms]![formname]![StateList], salesyear smallint=[Forms]![formname]![Enter year of interest]

This would result in the state parameter being set to the current value of the StateList control, and the user getting prompted for the salesyear parameter. If there were any other parameters that were not in this list, they would get default values assigned.

The query should be executed with one ? marker for each non-default parameter in the InputParameters list.

A refresh or requery command (via menu, keyboard, or Navigation Bar) in Access should trigger a reexecute of the query. Users can do this in code by calling the standard Recordset.Requery method. If the value of a parameter is bound to a control on the form, the current value of the control is used at requery time. The query is not automatically reexecuted when the value of the control changes.

When used with a stored procedure:

An example InputParameters property string used with stored procedure would be:

@state char=[Forms]![formname]![StateList], @salesyear smallint=[Forms]![formname]![Enter year of interest]

This would result in the @state parameter being set to the current value of the StateList control, and the user getting prompted for the @salesyear parameter. If there were any other parameters to the stored proc that were not in this list, they would get default values assigned.

The stored procedure should be executed using a command string containing the {call } syntax with one ? marker for each non-default parameter in the InputParameters list.

A refresh or requery command (via menu, keyboard, or Navigation Bar) in Access should trigger a reexecute of the stored procedure. Users can do this in code by calling the standard Recordset.Requery method. If the value of a parameter is bound to a control on the form, the current value of the control is used at requery time. The stored procedure is not automatically reexecuted when the value of the control changes.

This builder dialog is invoked when a stored procedure is first selected as the record source of a form if the stored procedure has any parameters. After initial creation of the InputParameters string, this same dialog is used as a builder for changing the string. In this case however the list of parameters comes from what already exists in the string.

Parameter values are also settable in code using the ActiveX Data Object's (ADO) Command and Parameter objects. If the result returns a result set, a form can be bound to it by setting the form's Recordset property. ADO coding is the only way to handle stored procedures that do not return result sets such as action queries, those that return output parameters, or those that return multiple result sets.

See also

Concepts

Report Object

Other resources

Report Object Members


ORDER BY clause

 Copy code hover
[image]

ORDER BY clause <clause> conflicts with DISTINCT. (Error 3093)
Send feedback

You created an SQL statement with an ALL, DISTINCT, or DISTINCTROW predicate and an ORDER BY clause that contains a field not listed in the SELECT statement. Remove the DISTINCT reserved word, or remove the specified field from the ORDER BY clause.


ListBox.Parent Property (Access)

 Copy code hover
[image]

ListBox.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a ListBox object.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


DeleteRecord Macro Action

 Copy code hover
[image]

DeleteRecord Macro Action
Send feedback

You can use the DeleteRecord action to delete a record.

Setting

The CreateRecord data block has the following arguments.

Argument | Description
Record Alias | A string that identifies the record to delete. If the Alias argument is not specified, then the current record is deleted.

Remarks

You can use the LastCreateRecordIdentity local variable to work with last record created in a CreateRecord data block. For example, use the following syntax to refer to the most recently created record:

Copy code Copy code
[LastCreateRecordIdentity]


WorkspaceTypeEnum Enumeration (DAO)

 Copy code hover
[image]

WorkspaceTypeEnum Enumeration (DAO)
Send feedback

Used with the CreateWorkspace method to specify the type of workspace to create.

Name | Value | Description
dbUseJet | 2 | Create a Microsoft Access workspace.


CodeProject.ProjectType Property (Access)

 Copy code hover
[image]

CodeProject.ProjectType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ProjectType property to determine the type of project that is currently open. Read-only AcProjectType.

Syntax

expression .ProjectType

expression A variable that represents a CodeProject object.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


Field Object (ADO) Reference

 Copy code hover
[image]

Field Object (ADO) Reference
Send feedback

In this section

  • Field Object (ADO)

  • Field Properties, Methods, and Events (ADO)


The size of a field is too long. (Error 3017)

 Copy code hover
[image]

The size of a field is too long. (Error 3017)
Send feedback

Possible causes:

  • You tried to define or create a Text field longer than 254 characters. Use a number between 1 and 254, and then try the operation again, or create a Memo field for the data.

  • You tried to define a query parameter longer than 255 characters.


NavigationButton.OnLostFocus Property (Access)

 Copy code hover
[image]

NavigationButton.OnLostFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnLostFocus

expression A variable that represents a NavigationButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The LostFocus event occurs when the object loses the focus.

The OnLostFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Lost Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Lost Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnLostFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnLostFocus

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Abs Function (Access 2013 custom web app)

 Copy code hover
[image]

Abs Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the absolute (positive) value of the specified numeric expression.

Syntax

Abs(NumericExpression)

The Abs function contains the following argument.

Argument name | Description
NumericExpression | A numeric expression.


ADO Code Examples in Microsoft Visual J++

 Copy code hover
[image]

ADO Code Examples in Microsoft Visual J++
Send feedback

Use the following code examples to learn how to use the ADO methods and properties when writing in Microsoft Visual J++.

Note Note

Paste the entire code example, from beginning to end, into your code editor. The example may not run correctly if partial examples are used or if paragraph formatting is lost.

Methods

  • AddNew Method Example

  • Append and CreateParameter Methods Example

  • AppendChunk and GetChunk Methods Example

  • BeginTrans, CommitTrans, and RollbackTrans Methods Example

  • Cancel Method Example

  • Clone Method Example

  • CompareBookmarks Method Example

  • Delete Method Example

  • Execute, Requery, and Clear Methods Example

  • Find Method Example

  • GetRows Method Example

  • GetString Method Example

  • MoveFirst, MoveLast, MoveNext, and MovePrevious Methods Example

  • NextRecordset Method Example

  • Open and Close Methods Example

  • OpenSchema Method Example

  • Refresh Method Example

  • Resync Method Example

  • Save and Open Methods Example

  • Supports Method Example

  • Update and CancelUpdate Methods Example

  • UpdateBatch and CancelBatch Methods Example

Properties

  • AbsolutePage, PageCount, and PageSize Properties Example

  • AbsolutePosition and CursorLocation Properties Example

  • ActiveCommand Property Example

  • ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction Properties Example

  • ActualSize and DefinedSize Properties Example

  • Attributes and Name Properties Example

  • BOF, EOF, and Bookmark Properties Example

  • CacheSize Property Example

  • ConnectionString, ConnectionTimeout, and State Properties Example

  • Count Property Example

  • CursorType, LockType, and EditMode Properties Example

  • Description, HelpContext, HelpFile, NativeError, Number, Source, and SQLState Properties Example

  • Filter and RecordCount Properties Example

  • IsolationLevel and Mode Properties Example

  • Item Property Example

  • MarshalOptions Property Example

  • MaxRecords Property Example

  • NumericScale and Precision Properties Example

  • Optimize Property Example

  • OriginalValue and UnderlyingValue Properties Example

  • Prepared Property Example

  • Provider and DefaultDatabase Properties Example

  • Sort Property Example

  • Source Property Example

  • State Property Example

  • Status Property Example

  • StayInSync Property Example

  • Type Property Example (Fields)

  • Type Property Example (Property)

  • Value Property Example

  • Version Property Example


AllQueries Members (Access)

 Copy code hover
[image]

AllQueries Members (Access)
Send feedback

Published: July 16, 2012

The AllQueries collection contains an AccessObject for each query in the CurrentData or CodeData object.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject,.
Parent | Returns the parent object for the specified object. Read-only.


AcSearchDirection Enumeration (Access)

 Copy code hover
[image]

AcSearchDirection Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the FindRecord method to specify the direction to search.

Name | Value | Description
acDown | 1 | Search all records below the current record.
acSearchAll | 2 | Search all records.
acUp | 0 | Search all records above the current record.


Group Properties, Methods, and Events (ADOX)

 Copy code hover
[image]

Group Properties, Methods, and Events (ADOX)
Send feedback

Properties/Collections

Name Property

Properties Collection

Users Collection

Methods

GetPermissions Method

SetPermissions Method

Events

None.


BoundObjectFrame.MouseDown Event (Access)

 Copy code hover
[image]

BoundObjectFrame.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents a BoundObjectFrame object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
         Shift As Integer, X As Single, _
         Y As Single)
    If Button = acLeftButton Then
        MsgBox "You pressed the left button."
    End If
    If Button = acRightButton Then
        MsgBox "You pressed the right button."
    End If
    If Button = acMiddleButton Then
        MsgBox "You pressed the middle button."
    End If
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Attachment.GridlineTint Property (Access)

 Copy code hover
[image]

Attachment.GridlineTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineTint

expression A variable that represents an Attachment object.

Remarks

The GridlineTint property contains a numeric expression that can be used to lighten the theme color in the GridlineColor property. The default value of the GridlineTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Application.AddToFavorites Method (Access)

 Copy code hover
[image]

Application.AddToFavorites Method (Access)
See also Send feedback

Published: July 16, 2012

The AddToFavorites method adds a hyperlink address to the Favorites folder.

Syntax

expression .AddToFavorites

expression A variable that represents an Application object.

Remarks

When applied to the Application object, the AddToFavorites method adds the name of the current database to the Favorites folder. For example, if you're working in the Northwind sample database, applying the AddToFavorites method to the Application object adds the hyperlink address of the Northwind database to the Favorites folder.

See also

Concepts

Application Object

Other resources

Application Object Members


EmptyCell.GridlineStyleTop Property (Access)

 Copy code hover
[image]

EmptyCell.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleTop

expression A variable that represents an EmptyCell object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


Value Property Example (VB)

 Copy code hover
[image]

Value Property Example (VB)
Send feedback

This example demonstrates the Value property with Field and Property objects by displaying field and property values for the Employees table.

Copy code Copy code

'BeginValueVB
Public Sub Main()
 On Error GoTo ErrorHandler

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

 ' connection and recordset variables
 Dim rstEmployees As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim strSQLEmployees As String
 ' field property variables
 Dim fld As ADODB.Field
 Dim prp As ADODB.Property

 ' Open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open recordset with data from Employees table
 Set rstEmployees = New ADODB.Recordset
 strSQLEmployees = "employee"
 rstEmployees.Open strSQLEmployees, Cnxn, , , adCmdTable
 'rstEmployees.Open strSQLEmployees, Cnxn, adOpenStatic, adLockReadOnly, adCmdTable
 ' the above two lines of code are identical

 Debug.Print "Field values in rstEmployees"

 ' Enumerate the Fields collection of the Employees table
 For Each fld In rstEmployees.Fields
 ' Because Value is the default property of a
 ' Field object, the use of the actual keyword
 ' here is optional.
 Debug.Print " " & fld.Name & " = " & fld.Value
 Next fld

 Debug.Print "Property values in rstEmployees"

 ' Enumerate the Properties collection of the Recordset object
 For Each prp In rstEmployees.Properties
 Debug.Print " " & prp.Name & " = " & prp.Value
 ' because Value is the default property of a Property object
 ' use of the actual Value keyword is optional
 Next prp

 ' clean up
 rstEmployees.Close
 Cnxn.Close
 Set rstEmployees = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstEmployees Is Nothing Then
 If rstEmployees.State = adStateOpen Then rstEmployees.Close
 End If
 Set rstEmployees = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndValueVB


WebBrowserControl.MouseDown Event (Access)

 Copy code hover
[image]

WebBrowserControl.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Version Information

Version Added: Access 2010

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents a WebBrowserControl object.

Parameters

Name | Required/Optional | Data Type | Description
Button | Required | Integer |
Shift | Required | Integer |
X | Required | Single |
Y | Required | Single |

Return Value

nothing

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
 Shift As Integer, X As Single, _
 Y As Single)
 If Button = acLeftButton Then
 MsgBox "You pressed the left button."
 End If
 If Button = acRightButton Then
 MsgBox "You pressed the right button."
 End If
 If Button = acMiddleButton Then
 MsgBox "You pressed the middle button."
 End If
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Cannot change field

 Copy code hover
[image]

Cannot change field <name>. (Error 3720)
Send feedback

This error occurs when trying to change a name or definition of a primary key that is referenced by other foreign keys. To change the definition or name of the columns participating in the primary key, you must first remove all foreign key references to the primary key. This typically happens when using the ALTER TABLE ALTER COLUMN statement.


Append Method (ADOX Groups)

 Copy code hover
[image]

Append Method (ADOX Groups)
Send feedback

Adds a new Group object to the Groups collection.

Syntax

Groups.Append Group

Parameters

  • Group

  • The Group object to append or the name of the group to create and append.

Remarks

The Groups collection of a Catalog represents all of the catalog's group accounts. The Groups collection for a User represents only the group to which the user belongs.

An error will occur if the provider does not support creating groups.

Note Note

Before appending a Group object to the Groups collection of a User object, a Group object with the same Name as the one to be appended must already exist in the Groups collection of the Catalog.


SmartTags.Parent Property (Access)

 Copy code hover
[image]

SmartTags.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a SmartTags object.

See also

Concepts

SmartTags Collection

Other resources

SmartTags Object Members


Table

 Copy code hover
[image]

Table <name> already has an index named <name>. (Error 3375)
Send feedback

You are trying to create an index that already exists.


AcTransformXMLScriptOption Enumeration (Access)

 Copy code hover
[image]

AcTransformXMLScriptOption Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the TransformXML method to specify theaction taken if the XSL file contains scripting code.

Name | Value | Description
acDisableScript | 2 | The script is disabled.
acEnableScript | 0 | The script is enabled.
acPromptScript | 1 | The user is prompted to disable or enable the script.


ToggleButton.GridlineStyleRight Property (Access)

 Copy code hover
[image]

ToggleButton.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified toggle button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleRight

expression A variable that represents a ToggleButton object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


How to: Modify a Table's Design Using Access SQL

 Copy code hover
[image]

How to: Modify a Table's Design Using Access SQL
Send feedback

After you have created and populated a table, you may need to modify the table's design. To do so, use the ALTER TABLE statement. Be aware that altering an existing table's structure may cause you to lose some of the data. For example, changing a field's data type can result in data loss or rounding errors, depending on the data types you are using. It can also break other parts of your application that may refer to the changed field. You should always use extra caution before modifying the structure of an existing table.

With the ALTER TABLE statement, you can add, remove, or change a column (or field), and you can add or remove a constraint. You can also declare a default value for a field; however, you can alter only one field at a time. Suppose that you have an invoicing database, and you want to add a field to the Customers table. To add a field with the ALTER TABLE statement, use the ADD COLUMN clause with the name of the field, its data type, and the size of the data type, if it is required.

VBA Copy code Copy code
ALTER TABLE tblCustomers
   ADD COLUMN Address TEXT(30)

To change the data type or size of a field, use the ALTER COLUMN clause with the name of the field, the desired data type, and the desired size of the data type, if it is required.

VBA Copy code Copy code
ALTER TABLE tblCustomers
   ALTER COLUMN Address TEXT(40)

If you want to change the name of a field, you will have to remove the field and then recreate it. To remove a field, use the DROP COLUMN clause with the field name only.

VBA Copy code Copy code
ALTER TABLE tblCustomers
   DROP COLUMN Address

Note that using this method will eliminate the existing data for the field. To preserve the existing data, you should change the field's name with the table design mode of the Access user interface, or write code to preserve the current data in a temporary table and append it back to the renamed table.

A default value is the value that is entered in a field any time a new record is added to a table and no value is specified for that particular column. To set a default value for a field, use the DEFAULT keyword after declaring the field type in either an ADD COLUMN or ALTER COLUMN clause.

VBA Copy code Copy code
ALTER TABLE tblCustomers
   ALTER COLUMN Address TEXT(40) DEFAULT Unknown

Be aware that the default value is not enclosed in single quotation marks. If it were, the quotation marks would also be inserted into the record. The DEFAULT keyword can also be used in a CREATE TABLE statement.

VBA Copy code Copy code
CREATE TABLE tblCustomers (
   CustomerID INTEGER CONSTRAINT PK_tblCustomers
      PRIMARY KEY,
   [Last Name] TEXT(50) NOT NULL,
   [First Name] TEXT(50) NOT NULL,
   Phone TEXT(10),
   Email TEXT(50),
   Address TEXT(40) DEFAULT Unknown)
Note Note

The DEFAULT statement can be executed only through the Access OLE DB provider and ADO. It will return an error message if used through the Access SQL View user interface.

Constraints

Constraints can be used to establish primary keys and referential integrity, and to restrict values that can be inserted into a field. In general, constraints can be used to preserve the integrity and consistency of the data in your database.

There are two types of constraints: a single-field or field-level constraint, and a multi-field or table-level constraint. Both kinds of constraints can be used in either the CREATE TABLE or the ALTER TABLE statement.

A single-field constraint, also known as a column-level constraint, is declared with the field itself, after the field and data type have been declared. For this example, use the Customers table and create a single-field primary key on the CustomerID field. To add the constraint, use the CONSTRAINT keyword with the name of the field.

VBA Copy code Copy code
ALTER TABLE tblCustomers
   ALTER COLUMN CustomerID INTEGER
   CONSTRAINT PK_tblCustomers PRIMARY KEY

Be aware that the name of the constraint is given. You could use a shortcut for declaring the primary key that omits the CONSTRAINT clause entirely.

VBA Copy code Copy code
ALTER TABLE tblCustomers
   ALTER COLUMN CustomerID INTEGER PRIMARY KEY

However, using the shortcut method will cause Access to randomly generate a name for the constraint, which will make it difficult to reference in code. It is a good idea always to name your constraints.

To drop a constraint, use the DROP CONSTRAINT clause with the ALTER TABLE statement, and supply the name of the constraint.

VBA Copy code Copy code
ALTER TABLE tblCustomers
   DROP CONSTRAINT PK_tblCustomers

Constraints also can be used to restrict the allowable values for a field. You can restrict values to NOT NULL or UNIQUE, or you can define a check constraint, which is a type of business rule that can be applied to a field. Imagine that you want to restrict (or constrain) the values of the first name and last name fields to be unique, meaning that there should never be a combination of first name and last name that is the same for any two records in the table. Because this is a multi-field constraint, it is declared at the table level, not the field level. Use the ADD CONSTRAINT clause and define a multi-field list.

VBA Copy code Copy code
ALTER TABLE tblCustomers
   ADD CONSTRAINT CustomerID UNIQUE
   ([Last Name], [First Name])

A check constraint is a powerful SQL feature that allows you to add data validation to a table by creating an expression that can refer to a single field, or multiple fields across one or more tables. Suppose that you want to make sure that the amounts entered in an invoice record are always greater than $0.00. To do so, use a check constraint by declaring the CHECK keyword and your validation expression in the ADD CONSTRAINT clause of an ALTER TABLE statement.

VBA Copy code Copy code
ALTER TABLE tblInvoices
   ADD CONSTRAINT CheckAmount
   CHECK (Amount > 0)

The expression used to define a check constraint also can refer to more than one field in the same table, or to fields in other tables, and can use any operations that are valid in Microsoft Access SQL, such as SELECT statements, mathematical operators, and aggregate functions. The expression that defines the check constraint can be no more than 64 characters long.

Suppose that you want to check each customer's credit limit before he or she is added to the Customers table. Using an ALTER TABLE statement with the ADD COLUMN and CONSTRAINT clauses, create a constraint that will look up the value in the CreditLimit table to verify the customer's credit limit. Use the following SQL statements to create the tblCreditLimit table, add the CustomerLimit field to the tblCustomers table, add the check constraint to the tblCustomers table, and test the check constraint.

VBA Copy code Copy code
CREATE TABLE tblCreditLimit (
   Limit DOUBLE)

INSERT INTO tblCreditLimit
   VALUES (100)

ALTER TABLE tblCustomers
   ADD COLUMN CustomerLimit DOUBLE

ALTER TABLE tblCustomers
   ADD CONSTRAINT LimitRule
   CHECK (CustomerLimit <= (SELECT Limit
      FROM tblCreditLimit))

UPDATE TABLE tblCustomers
   SET CustomerLimit = 200
   WHERE CustomerID = 1

Be aware that when you execute the UPDATE TABLE statement, you receive a message indicating that the update did not succeed because it violated the check constraint. If you update the CustomerLimit field to a value that is equal to or less than 100, the update will succeed.

Cascading updates and deletions

Constraints also can be used to establish referential integrity between database tables. Having referential integrity means that the data is consistent and uncorrupted. For example, if you deleted a customer record but that customer's shipping record remained in the database, the data would be inconsistent because you now have an orphaned record in the shipping table. Referential integrity is established when you build a relationship between tables. In addition to establishing referential integrity, you can also ensure that the records in the referenced tables stay in sync by using cascading updates and deletions. For example, when the cascading updates and deletes are declared, if you delete the customer record, the customer's shipping record is deleted automatically.

To enable cascading updates and deletions, use the ON UPDATE CASCADE and/or ON DELETE CASCADE keywords in the CONSTRAINT clause of an ALTER TABLE statement. Be aware that they must be applied to the foreign key.

VBA Copy code Copy code
ALTER TABLE tblShipping
   ADD CONSTRAINT FK_tblShipping
   FOREIGN KEY (CustomerID) REFERENCES
      tblCustomers (CustomerID)
   ON UPDATE CASCADE
   ON DELETE CASCADE


OptionButton.AddColon Property (Access)

 Copy code hover
[image]

OptionButton.AddColon Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.

Syntax

expression .AddColon

expression A variable that represents an OptionButton object.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Step 6: Changes are Sent to the Server (RDS Tutorial)

 Copy code hover
[image]

Step 6: Changes are Sent to the Server (RDS Tutorial)
Send feedback

If the Recordset object is edited, any changes (that is, rows that are added, changed, or deleted) can be sent back to the server.

Note Note

The default behavior of RDS can be invoked implicitly with ADO objects and the Microsoft OLE DB Remoting Provider. Queries can return Recordsets, and edited Recordsets can update the data source. This tutorial does not invoke RDS with ADO objects, but this is how it would look if it did:
Copy code Copy code

Dim rs as New ADODB.Recordset
rs.Open "SELECT * FROM Authors","Provider=MS Remote;Data Source=Pubs;" & _
 "Remote Server=http://yourServer;Remote Provider=SQLOLEDB;"
... ' Edit the Recordset.
rs.UpdateBatch ' The equivalent of SubmitChanges.
...

Part AAssume for this case that you have only used the RDS.DataControl and that a Recordset object is now associated with the RDS.DataControl. The SubmitChanges method updates the data source with any changes to the Recordset object if the Server and Connect properties are still set.

Copy code Copy code

Sub RDSTutorial6A()
Dim DC as New RDS.DataControl
Dim RS as ADODB.Recordset
DC.Server = "http://yourServer"
DC.Connect = "DSN=Pubs"
DC.SQL = "SELECT * FROM Authors"
DC.Refresh
...
Set RS = DC.Recordset
 ' Edit the Recordset.
...
DC.SubmitChanges
...

Part BAlternatively, you could update the server with the RDSServer.DataFactory object, specifying a connection and a Recordset object.

Copy code Copy code

Sub RDSTutorial6B()
Dim DS As New RDS.DataSpace
Dim RS As ADODB.Recordset
Dim DC As New RDS.DataControl
Dim DF As Object
Dim blnStatus As Boolean
Set DF = DS.CreateObject("RDSServer.DataFactory", "http://yourServer")
Set RS = DF.Query ("DSN=Pubs", "SELECT * FROM Authors")
DC.SourceRecordset = RS ' Visual controls can now bind to DC.
 ' Edit the Recordset.
blnStatus = DF.SubmitChanges "DSN=Pubs", RS
End Sub

This is the end of the tutorial.


CREATE INDEX Statement (Microsoft Access SQL)

 Copy code hover
[image]

CREATE INDEX Statement (Microsoft Access SQL)
Send feedback

Creates a new index on an existing table.

Note Note

For non-Microsoft Access atabse engine databases, the Microsoft Access database engine does not support the use of CREATE INDEX (except to create a pseudo index on an ODBC linked table) or any of the data definition language (DDL) statements. Use the DAO Create methods instead. For more information see the Remarks section.

Syntax

CREATE [ UNIQUE ] INDEX index ON table (field [ASC|DESC][, field [ASC|DESC], …]) [WITH { PRIMARY | DISALLOW NULL | IGNORE NULL }]

The CREATE INDEX statement has these parts:

Part | Description
index | The name of the index to be created.
table | The name of the existing table that will contain the index.
field | The name of the field or fields to be indexed. To create a single-field index, list the field name in parentheses following the table name. To create a multiple-field index, list the name of each field to be included in the index. To create descending indexes, use the DESC reserved word; otherwise, indexes are assumed to be ascending.

Remarks

To prohibit duplicate values in the indexed field or fields of different records, use the UNIQUE reserved word.

In the optional WITH clause you can enforce data validation rules. You can:

  • Prohibit Null entries in the indexed field or fields of new records by using the DISALLOW NULL option.

  • Prevent records with Null values in the indexed field or fields from being included in the index by using the IGNORE NULL option.

  • Designate the indexed field or fields as the primary key by using the PRIMARY reserved word. This implies that the key is unique, so you can omit the UNIQUE reserved word.

You can use CREATE INDEX to create a pseudo index on a linked table in an ODBC data source, such as Microsoft® SQL Server™, that does not already have an index. You do not need permission or access to the remote server to create a pseudo index, and the remote database is unaware of and unaffected by the pseudo index. You use the same syntax for both linked and native tables. Creating a pseudo-index on a table that would ordinarily be read-only can be especially useful.

You can also use the ALTER TABLE statement to add a single- or multiple-field index to a table, and you can use the ALTER TABLE statement or the DROP statement to remove an index created with ALTER TABLE or CREATE INDEX.

Note Note

Do not use the PRIMARY reserved word when you create a new index on a table that already has a primary key; if you do, an error occurs.

Example

This example creates an index consisting of the fields Home Phone and Extension in the Employees table.

VBA Copy code Copy code
Sub CreateIndexX1()

    Dim dbs As Database

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Create the NewIndex index on the Employees table.
    dbs.Execute "CREATE INDEX NewIndex ON Employees " _
        & "(HomePhone, Extension);"

    dbs.Close

End Sub

This example creates an index on the Customers table using the CustomerID field. No two records can have the same data in the CustomerID field, and no Null values are allowed.

VBA Copy code Copy code
Sub CreateIndexX2()

    Dim dbs As Database

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Create a unique index, CustID, on the
    ' CustomerID field.
    dbs.Execute "CREATE UNIQUE INDEX CustID " _
        & "ON Customers (CustomerID) " _
        & "WITH DISALLOW NULL;"

    dbs.Close

End Sub


ADO API Reference Topics

 Copy code hover
[image]

ADO API Reference Topics
Send feedback

In this section

  • ADO API Reference

  • ADO Objects and Interfaces Reference

  • ADO Collections Reference

  • ADO Properties Reference

  • ADO Dynamic Properties Reference

  • ADO Methods Reference

  • ADO Events Reference

  • ADO Enumerated Constants Reference

  • ADO Code Examples (Access)


WebServices.Application Property (Access)

 Copy code hover
[image]

WebServices.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Version Information

Version Added: Access 2010

Syntax

expression .Application

expression A variable that represents a WebServices object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

WebServices Collection

Other resources

WebServices Object Members


NavigationControl.OnMouseDown Property (Access)

 Copy code hover
[image]

NavigationControl.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnMouseDown

expression A variable that represents a NavigationControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


ADO MD Methods Reference

 Copy code hover
[image]

ADO MD Methods Reference
Send feedback

In this section

  • ADO MD Methods

  • Close Method (ADO MD)

  • Open Method (ADO MD)


You tried to commit or roll back a transaction without first using BeginTrans. (Error 3034)

 Copy code hover
[image]

You tried to commit or roll back a transaction without first using BeginTrans. (Error 3034)
Send feedback

You tried to commit or rollback a transaction that was not started with a BeginTrans statement.


Recordset.ValidationRule Property (DAO)

 Copy code hover
[image]

Recordset.ValidationRule Property (DAO)
Send feedback

Sets or returns a value that validates the data in a field as it's changed or added to a table (Microsoft Access workspaces only).Read/write String.

Syntax

expression .ValidationRule

expression A variable that represents a Recordset object.

Remarks

The settings or return values is a String that describes a comparison in the form of an SQL WHERE clause without the WHERE reserved word. For an object not yet appended to the Fields collection, this property is read/write.

The ValidationRule property determines whether or not a field contains valid data. If the data is not valid, a trappable run-time error occurs. The returned error message is the text of the ValidationText property, if specified, or the text of the expression specified by ValidationRule.

For a Recordset object, use of the ValidationRule property is read-only. For a TableDef object, use of the ValidationRule property depends on the status of the TableDef object, as the following table shows.

TableDef | Usage
Base table | Read/write
Linked table | Read-only

Validation is supported only for databases that use the Microsoft Access database engine.

The string expression specified by the ValidationRule property of a Field object can refer only to that Field. The expression can't refer to user-defined functions, SQL aggregate functions, or queries. To set a Field object's ValidationRule property when its ValidateOnSet property setting is True, the expression must successfully parse (with the field name as an implied operand) and evaluate to True. If its ValidateOnSet property setting is False, the ValidationRule property setting is ignored.

The ValidationRule property of a Recordset or TableDef object can refer to multiple fields in that object. The restrictions noted earlier in this topic for the Field object apply.

For a table-type Recordset object, the ValidationRule property inherits the ValidationRule property setting of the TableDef object that you use to create the table-type Recordset object.

Note Note

If you set the property to a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strRule = "PRICE > " & lngPrice, and lngPrice = 125,50), an error will result when your code attempts to validate any data. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and Microsoft Access SQL only accepts U.S. decimal characters.


Connection Object (ADO)

 Copy code hover
[image]

Connection Object (ADO)
Send feedback

Represents an open connection to a data source.

Remarks

A Connection object represents a unique session with a data source. In the case of a client/server database system, it may be equivalent to an actual network connection to the server. Depending on the functionality supported by the provider, some collections, methods, or properties of a Connection object may not be available.

With the collections, methods, and properties of a Connection object, you can do the following:

  • Configure the connection before opening it with the ConnectionString, ConnectionTimeout, and Mode properties. ConnectionString is the default property of the Connection object.

  • Set the CursorLocation property to client to invoke the Microsoft Cursor Service for OLE DB, which supports batch updates.

  • Set the default database for the connection with the DefaultDatabase property.

  • Set the level of isolation for the transactions opened on the connection with the IsolationLevel property.

  • Specify an OLE DB provider with the Provider property.

  • Establish, and later break, the physical connection to the data source with the Open and Close methods.

  • Execute a command on the connection with the Execute method and configure the execution with the CommandTimeout property.

    Note Note

    To execute a query without using a Command object, pass a query string to the Execute method of a Connection object. However, a Command object is required when you want to persist the command text and re-execute it, or use query parameters.

  • Manage transactions on the open connection, including nested transactions if the provider supports them, with the BeginTrans, CommitTrans, and RollbackTrans methods and the Attributes property.

  • Examine errors returned from the data source with the Errors collection.

  • Read the version from the ADO implementation used with the Version property.

  • Obtain schema information about your database with the OpenSchema method.

You can create Connection objects independently of any other previously defined object.

You can execute commands or stored procedures as if they were native methods on the Connection object, as illustrated below.

Execute a command as a native method of a Connection object

To execute a command, give the command a name using the Command object Name property. Set the Command object's ActiveConnection property to the connection. Then issue a statement where the command name is used as if it were a method on the Connection object, followed by any parameters, then followed by a Recordset object if any rows are returned. Set the Recordset properties to customize the resulting Recordset. For example:

Copy code Copy code
Dim cnn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rst As New ADODB.Recordset
...
cnn.Open "..."
cmd.Name = "yourCommandName"
cmd.ActiveConnection = cnn
...
'Your command name, any parameters, and an optional Recordset.
cnn.yourCommandName "parameter", rst

Execute a stored procedure as a native method of a Connection object

To execute a stored procedure, issue a statement where the stored procedure name is used as if it were a method on the Connection object, followed by any parameters. ADO will make a "best guess" of parameter types. For example:

Copy code Copy code
Dim cnn As New ADODB.Connection
...
'Your stored procedure name and any parameters.
cnn.sp_yourStoredProcedureName "parameter"


Functions (Alphabetical List)

 Copy code hover
[image]

Functions (Alphabetical List)
Send feedback

The following topics describe common functions used in Microsoft Access expressions.

Abs Function

Array Function

Asc Function

Atn Function

Avg Function

CallByName Function

CBool Function

CByte Function

CCur Function

CDate Function

CDbl Function

CDec Function

Choose Function

Chr Function

CInt Function

CLng Function

Command Function

Cos Function

Count Function

CreateObject Function

CSng Function

CStr Function

CurDir Function

CurrentUser Method

CVar Function

CVErr Function

Date Function

DateAdd Function

DateDiff Function

DatePart Function

DateSerial Function

DateValue Function

DAvg Function

Day Function

DCount Method

DDB Function

DDEInitiate Method

DDERequest Method

DFirst Method

Dir Function

DLast Method

DLookup Method

DMax Method

DMin Method

DoEvents Function

DStDev Method

DStDevP Method

DSum Method

DVar Method

DVarP Method

Environ Function

EOF Function

Error Function

EuroConvert Method

Eval Method

Exp Function

FileAttr Function

FileDateTime Function

FileLen Function

Filter Function

Fix Function

Format Function

FormatCurrency Function

FormatDateTime Function

FormatNumber Function

FormatPercent Function

FreeFile Function

FV Function

GetAllSettings Function

GetAttr Function

GetObject Function

GetSetting Function

GUIDFromString Method

Hex Function

Hour Function

HtmlEncode Method

HyperlinkPart Method

IIf Function

IMEStatus Function

Input Function

InputBox Function

InStr Function

InStrRev Function

Int Function

IPmt Function

IRR Function

IsArray Function

IsDate Function

IsEmpty Function

IsError Function

IsMissing Function

IsNull Function

IsNumeric Function

IsObject Function

Join Function

LBound Function

LCase Function

Left Function

Len Function

Loc Function

LOF Function

Log Function

LTrim Function

Max Function

Mid Function

Min Function

Minute Function

MIRR Function

Month Function

MonthName Function

MsgBox Function

Now Function

NPer Function

NPV Function

Nz Method

Oct Function

Partition Function

PlainText Method

Pmt Function

PPmt Function

PV Function

QBColor Function

Rate Function

Replace Function

RGB Function

Right Function

Rnd Function

Round Function

RTrim Function

Second Function

Seek Function

Sgn Function

Shell Function

Sin Function

SLN Function

Space Function

Spc Function

Split Function

Sqr Function

Str Function

StrComp Function

StrConv Function

StDev Function

StDevP Function

String Function

StringFromGUID Method

StrReverse Function

Sum Function

Switch Function

SYD Function

Tab Function

Tan Function

Time Function

Timer Function

TimeSerial Function

TimeValue Function

Trim Function

TypeName Function

UBound Function

UCase Function

Val Function

Var, VarP Functions

VarType Function

Weekday Function

WeekdayName Function

Year Function


NavigationButton.HoverForeColor Property (Access)

 Copy code hover
[image]

NavigationButton.HoverForeColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the text displayed on the control when the user rests the mouse cursor over it. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HoverForeColor

expression A variable that represents a NavigationButton object.

Remarks

The HoverForeColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Recordset2 Properties (DAO)

 Copy code hover
[image]

Recordset2 Properties (DAO)
Send feedback

In this section

  • Recordset2.AbsolutePosition Property (DAO)

  • Recordset2.BatchCollisionCount Property (DAO)

  • Recordset2.BatchCollisions Property (DAO)

  • Recordset2.BatchSize Property (DAO)

  • Recordset2.BOF Property (DAO)

  • Recordset2.Bookmark Property (DAO)

  • Recordset2.Bookmarkable Property (DAO)

  • Recordset2.CacheSize Property (DAO)

  • Recordset2.CacheStart Property (DAO)

  • Recordset2.Connection Property (DAO)

  • Recordset2.DateCreated Property (DAO)

  • Recordset2.EditMode Property (DAO)

  • Recordset2.EOF Property (DAO)

  • Recordset2.Fields Property (DAO)

  • Recordset2.Filter Property (DAO)

  • Recordset2.Index Property (DAO)

  • Recordset2.LastModified Property (DAO)

  • Recordset2.LastUpdated Property (DAO)

  • Recordset2.LockEdits Property (DAO)

  • Recordset2.Name Property (DAO)

  • Recordset2.NoMatch Property (DAO)

  • Recordset2.ParentRecordset Property (DAO)

  • Recordset2.PercentPosition Property (DAO)

  • Recordset2.Properties Property (DAO)

  • Recordset2.RecordCount Property (DAO)

  • Recordset2.RecordStatus Property (DAO)

  • Recordset2.Restartable Property (DAO)

  • Recordset2.Sort Property (DAO)

  • Recordset2.StillExecuting Property (DAO)

  • Recordset2.Transactions Property (DAO)

  • Recordset2.Type Property (DAO)

  • Recordset2.Updatable Property (DAO)

  • Recordset2.UpdateOptions Property (DAO)

  • Recordset2.ValidationRule Property (DAO)

  • Recordset2.ValidationText Property (DAO)


CheckBox.Height Property (Access)

 Copy code hover
[image]

CheckBox.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Syntax

expression .Height

expression A variable that represents a CheckBox object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ApplyFilter Macro Action

 Copy code hover
[image]

ApplyFilter Macro Action
Send feedback

You can use the ApplyFilter action to apply a filter, a query, or an SQL WHERE clause to a table, form, or report to restrict or sort the records in the table, or the records from the underlying table or query of the form or report. For reports, you can use this action only in a macro specified by the report's OnOpen event property.

Note Note

You can use this action to apply an SQL WHERE clause only when applying a server filter. A server filter cannot be applied to a stored procedure's record source.

Setting

The ApplyFilter action has the following arguments.

Action argument

Description

Filter Name

The name of a filter or query that restricts or sorts the records of the table, form, or report. You can enter the name of either an existing query or a filter that has been saved as a query in the Filter Name box in the Action Arguments section of the Macro Builder pane.

Note Note

When you are using this action to apply a server filter, the Filter Name argument must be blank.

Where Condition

A valid SQL WHERE clause (without the word WHERE) or an expression that restricts the records of the table, form, or report.

Note Note

In a Where Condition argument expression, the left side of the expression typically contains a field name from the underlying table or query for the form or report. The right side of the expression typically contains the criteria you want to apply to this field to restrict or sort the records. For example, the criteria can be the name of a control on another form that contains the value you want the records in the first form to match. The name of the control should be fully qualified, for example:

Forms!formname!controlname Field names should be surrounded by double quotation marks and string literals should be surrounded by single quotation marks. The maximum length of the Where Condition argument is 255 characters. If you need to enter a longer SQL WHERE clause, use the ApplyFilter method of the DoCmd object in a Visual Basic for Applications (VBA) module. You can enter SQL WHERE clause statements of up to 32,768 characters in VBA.
Note Note

You can use the Filter Name argument if you have already defined a filter that provides the appropriate data. You can use the Where Condition argument to enter the restriction criteria directly. If you use both arguments, Microsoft Office Access 2007 applies the WHERE clause to the results of the filter. You must use one or both arguments.

Remarks

You can apply a filter or query to a form in Form view or Datasheet view.

The filter and WHERE condition you apply become the setting of the form's or report's Filter or ServerFilter property.

For tables and forms, this action is similar to clicking Apply Filter/Sort or Apply Server Filter on the Records menu. The menu command applies the most recently created filter to the table or form, whereas the ApplyFilter action applies a specified filter or query.

In an Access database, if you point to Filter on the Records menu and then click Advanced Filter/Sort after running the ApplyFilter action, the Advanced Filter/Sort window shows the filter criteria you have selected with this action.

To remove a filter and display all of the records for a table or form in an Office Access 2007 database, you can use the ShowAllRecords action or the Remove Filter/Sort command on the Records menu. To remove a filter in an Access project (.adp), you can return to the Server Filter By Form window and remove all filter criteria and then click Apply Server Filter on the Records menu on the toolbar, or set the ServerFilterByForm property to False (0).

When you save a table or form, Access saves any filter currently defined in that object, but won't apply the filter automatically the next time the object is opened (although it will automatically apply any sort you applied to the object before it was saved). If you want to apply a filter automatically when a form is first opened, specify a macro containing the ApplyFilter action or an event procedure containing the ApplyFilter method of the DoCmd object as the OnOpen event property setting of the form. You can also apply a filter by using the OpenForm or OpenReport action, or their corresponding methods. To apply a filter automatically when a table is first opened, you can open the table by using a macro containing the OpenTable action, followed immediately by the ApplyFilter action.

Example

The following example shows how to use the ApplyFilter action to filter the frmFoods form as it is opened.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

Copy code Copy code
OpenForm
    Form Name sfrmFoods
    View Form
    Filter Name
    Where Condition
    Data Mode
    Window Mode Normal

ApplyFilter
    Filter Name
    Where Condition=[display_name] Link "*cheese*"
    Control Name

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


TextBox.Format Property (Access)

 Copy code hover
[image]

TextBox.Format Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Format property to customize the way numbers, dates, times, and text are displayed and printed. Read/write String.

Syntax

expression .Format

expression A variable that represents a TextBox object.

Remarks

You can use one of the predefined formats or you can create a custom format by using formatting symbols.

The Format property uses different settings for different data types. For information about settings for a specific data type, see one of the following topics:

  • Date/Time Data Type

  • Number and Currency Data Types

  • Text and Memo Data Types

  • Yes/No Data Type

In Visual Basic, enter a string expression that corresponds to one of the predefined formats or enter a custom format.

The Format property affects only how data is displayed. It doesn't affect how data is stored.

Microsoft Access provides predefined formats for Date/Time, Number and Currency, Text and Memo, and Yes/No data types. The predefined formats depend on the country/region specified by double-clicking Regional Options in Windows Control Panel. Microsoft Access displays formats appropriate for the country/region selected. For example, with English (United States) selected on the General tab, 1234.56 in the Currency format appears as $1,234.56, but when English (British) is selected on the General tab, the number appears as £1,234.56.

If you set a field's Format property in table Design view, Microsoft Access uses that format to display data in datasheets. It also applies the field's Format property to new controls on forms and reports.

You can use the following symbols in custom formats for any data type.

Symbol | Meaning
(space) | Display spaces as literal characters.
"ABC" | Display anything inside quotation marks as literal characters.
! | Force left alignment instead of right alignment.
* | Fill available space with the next character.
\ | Display the next character as a literal character. You can also display literal characters by placing quotation marks around them.
[color] | Display the formatted data in the color specified between the brackets. Available colors: Black, Blue, Green, Cyan, Red, Magenta, Yellow, White.

You can't mix custom formatting symbols for the Number and Currency data types with Date/Time, Yes/No, or Text and Memo formatting symbols.

When you have defined an input mask and set the Format property for the same data, the Format property takes precedence when the data is displayed and the input mask is ignored. For example, if you create a Password input mask in table Design view and also set the Format property for the same field, either in the table or in a control on a form, the Password input mask is ignored and the data is displayed according to the Format property.

Example

The following three examples set the Format property by using a predefined format:

VBA Copy code Copy code
Me!Date.Format = "Medium Date"

Me!Time.Format = "Long Time"

Me!Registered.Format = "Yes/No"

The next example sets the Format property by using a custom format. This format displays a date as: Jan 2006.

VBA Copy code Copy code
Forms!Employees!HireDate.Format = "mmm yyyy"

The following example demonstrates a Visual Basic function that formats numeric data by using the Currency format and formats text data entirely in capital letters. The function is called from the OnLostFocus event of an unbound control named TaxRefund.

VBA Copy code Copy code
Function FormatValue() As Integer
    Dim varEnteredValue As Variant

    varEnteredValue = Forms!Survey!TaxRefund.Value
    If IsNumeric(varEnteredValue) = True Then
        Forms!Survey!TaxRefund.Format = "Currency"
    Else
        Forms!Survey!TaxRefund.Format = ">"
    End If
End Function

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Form.InsideWidth Property (Access)

 Copy code hover
[image]

Form.InsideWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InsideWidth property (along with the InsideHeight property) to determine the height and width (in twips) of the window containing a form. Read/write Long.

Syntax

expression .InsideWidth

expression A variable that represents a Form object.

Remarks

If you want to determine the interior dimensions of the form itself, you use the Width property to determine the form width and the sum of the heights of the form's visible sections to determine its height (the Height property applies only to form sections, not to forms). The interior of a form is the region inside the form, excluding the scroll bars and the record selectors.

You can also use the WindowHeight and WindowWidth properties to determine the height and width of the window containing a form.

If a window is maximized, setting these properties doesn't have any effect until the window is restored to its normal size.

Example

The following example shows how to use the InsideHeight and InsideWidth properties to compare the inside height and width of a form with the height and width of the form's window. If the window's dimensions don't equal the size of the form, then the window is resized to match the form's height and width.

VBA Copy code Copy code
Sub ResetWindowSize(frm As Form)
 Dim intWindowHeight As Integer
 Dim intWindowWidth As Integer
 Dim intTotalFormHeight As Integer
 Dim intTotalFormWidth As Integer
 Dim intHeightHeader As Integer
 Dim intHeightDetail As Integer
 Dim intHeightFooter As Integer

 ' Determine form's height.
 intHeightHeader = frm.Section(acHeader).Height
 intHeightDetail = frm.Section(acDetail).Height
 intHeightFooter = frm.Section(acFooter).Height
 intTotalFormHeight = intHeightHeader _
 + intHeightDetail + intHeightFooter
 ' Determine form's width.
 intTotalFormWidth = frm.Width
 ' Determine window's height and width.
 intWindowHeight = frm.InsideHeight
 intWindowWidth = frm.InsideWidth

 If intWindowWidth <> intTotalFormWidth Then
 frm.InsideWidth = intTotalFormWidth
 End If
 If intWindowHeight <> intTotalFormHeight Then
 frm.InsideHeight = intTotalFormHeight
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


NavigationControl.ControlType Property (Access)

 Copy code hover
[image]

NavigationControl.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .ControlType

expression A variable that represents a NavigationControl object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Relations Properties (DAO)

 Copy code hover
[image]

Relations Properties (DAO)
Send feedback

In this section

  • Relations.Count Property (DAO)


NavigationControl.FilterLookup Property (Access)

 Copy code hover
[image]

NavigationControl.FilterLookup Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FilterLookup property to specify whether values appear in a boundtext box control when using the Filter By Form or Server Filter By Form window. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .FilterLookup

expression A variable that represents a NavigationControl object.

Remarks

The FilterLookup property uses the following settings.

Setting | Visual Basic | Description
Never | 0 | The field values aren't displayed. You can specify whether the filtered records can contain null values.
Database Default | 1 | (Default) The field values are displayed according to the settings under Filter lookup options on the Current Database tab of the Access Options dialog box, available by clicking the Microsoft Office Button [image] and the clicking Access Options.
Always | 2 | The field values are always displayed.

You can also set the default for this property by setting a control's DefaultControl property in Visual Basic.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Microsoft OLE DB Provider for ODBC

 Copy code hover
[image]

Microsoft OLE DB Provider for ODBC
Send feedback

To an ADO or RDS programmer, an ideal world would be one in which every data source exposes an OLE DB interface, so that ADO could call directly into the data source. Although increasingly more database vendors are implementing OLE DB interfaces, some data sources are not yet exposed this way. However, virtually all DBMS systems in use today can be accessed through ODBC.

ODBC drivers are available for every major DBMS in use today, including Microsoft SQL Server, Microsoft Access (Microsoft Jet database engine), and Microsoft FoxPro, in addition to non-Microsoft database products such as Oracle.

The Microsoft ODBC Provider, however, allows ADO to connect to any ODBC data source. The provider is free-threaded and Unicode enabled.

The provider supports transactions, although different DBMS engines offer different types of transaction support. For example, Microsoft Access supports nested transactions up to five levels deep.

This is the default provider for ADO, and all provider-dependent ADO properties and methods are supported.

Connection String Parameters

To connect to this provider, set the Provider= argument of the ConnectionString property to:

Copy code Copy code

MSDASQL

Reading the Provider property will return this string as well.

Typical Connection String

A typical connection string for this provider is:

Copy code Copy code

"Provider=MSDASQL;DSN=dsnName;UID=userName;PWD=userPassword;"

The string consists of these keywords:

Keyword | Description
Provider | Specifies the OLE DB Provider for ODBC.
DSN | Specifies the data source name.
UID | Specifies the user name.
PWD | Specifies the user password.
URL | Specifies the URL of a file or directory published in a Web folder.

Because this is the default provider for ADO, if you omit the Provider= parameter from the connection string, ADO will attempt to establish a connection to this provider.

The provider does not support any specific connection parameters in addition to those defined by ADO. However, the provider will pass any non-ADO connection parameters to the ODBC driver manager.

Because you can omit the Provider parameter, you can therefore compose an ADO connection string that is identical to an ODBC connection string for the same data source. Use the same parameter names (DRIVER=, DATABASE=, DSN=, and so on), values, and syntax as you would when composing an ODBC connection string. You can connect with or without a predefined data source name (DSN) or FileDSN.

Syntax with a DSN or FileDSN:

Copy code Copy code
                      "[Provider=MSDASQL;] { DSN=name | FileDSN=filename } ;
[DATABASE=database;] UID=user; PWD=password"

Syntax without a DSN (DSN-less connection):

Copy code Copy code
                      "[Provider=MSDASQL;] DRIVER=driver; SERVER=server;DATABASE=database; UID=user; PWD=password"

If you use a DSN or FileDSN, it must be defined through the ODBC Data Source Administrator in the Windows Control Panel. In Microsoft Windows 2000, the ODBC Administrator is located under Administrative Tools. In previous versions of Windows, the ODBC Administrator icon is named 32-bit ODBC or simply ODBC.

As an alternative to setting a DSN, you can specify the ODBC driver (DRIVER=), such as "SQL Server;" the server name (SERVER=); and the database name (DATABASE=).

You can also specify a user account name (UID=), and the password for the user account (PWD=) in the ODBC-specific parameters or in the standard ADO-defined user and password parameters.

Although a DSN definition already specifies a database, you can specify a database parameter in addition to a DSN to connect to a different database. It is a good idea to always include the database parameter when you use a DSN. This will ensure that you connect to the proper database in the event that another user changed the default database parameter since you last checked the DSN definition.

Provider-Specific Connection Properties

The OLE DB provider for ODBC adds several properties to the Properties collection of the Connection object. The following table lists these properties with the corresponding OLE DB property name in parentheses.

Property Name | Description
Accessible Procedures (KAGPROP_ACCESSIBLEPROCEDURES) | Indicates whether the user has access to stored procedures.
Accessible Tables (KAGPROP_ACCESSIBLETABLES) | Indicates whether the user has permission to execute SELECT statements against the database tables.
Active Statements (KAGPROP_ACTIVESTATEMENTS) | Indicates the number of handles an ODBC driver can support on a connection.
Driver Name (KAGPROP_DRIVERNAME) | Indicates the file name of the ODBC driver.
Driver ODBC Version (KAGPROP_DRIVERODBCVER) | Indicates the version of ODBC that this driver supports.
File Usage (KAGPROP_FILEUSAGE) | Indicates how the driver treats a file in a data source; as a table or as a catalog.
Like Escape Clause (KAGPROP_LIKEESCAPECLAUSE) | Indicates whether the driver supports the definition and use of an escape character for the percent character (%) and underline character (_) in the LIKE predicate of a WHERE clause.
Max Columns in Group By (KAGPROP_MAXCOLUMNSINGROUPBY) | Indicates the maximum number of columns that can be listed in the GROUP BY clause of a SELECT statement.
Max Columns in Index (KAGPROP_MAXCOLUMNSININDEX) | Indicates the maximum number of columns that can be included in an index.
Max Columns in Order By (KAGPROP_MAXCOLUMNSINORDERBY) | Indicates the maximum number of columns that can be listed in the ORDER BY clause of a SELECT statement.
Max Columns in Select (KAGPROP_MAXCOLUMNSINSELECT) | Indicates the maximum number of columns that can be listed in the SELECT portion of a SELECT statement.
Max Columns in Table (KAGPROP_MAXCOLUMNSINTABLE) | Indicates the maximum number of columns allowed in a table.
Numeric Functions (KAGPROP_NUMERICFUNCTIONS) | Indicates which numeric functions are supported by the ODBC driver. For a listing of function names and the associated values used in this bitmask, see Appendix E: Scalar Functions in the ODBC documentation.
Outer Join Capabilities (KAGPROP_OJCAPABILITY) | Indicates the types of OUTER JOINs supported by the provider.
Outer Joins (KAGPROP_OUTERJOINS) | Indicates whether the provider supports OUTER JOINs.
Special Characters (KAGPROP_SPECIALCHARACTERS) | Indicates which characters have special meaning for the ODBC driver.
Stored Procedures (KAGPROP_PROCEDURES) | Indicates whether stored procedures are available for use with this ODBC driver.
String Functions (KAGPROP_STRINGFUNCTIONS) | Indicates which string functions are supported by the ODBC driver. For a listing of function names and the associated values used in this bitmask, see Appendix E: Scalar Functions in the ODBC documentation.
System Functions (KAGPROP_SYSTEMFUNCTIONS) | Indicates which system functions are supported by the ODBC driver. For a listing of function names and the associated values used in this bitmask, see Appendix E: Scalar Functions in the ODBC documentation.
Time/Date Functions (KAGPROP_TIMEDATEFUNCTIONS) | Indicates which time and date functions are supported by the ODBC driver. For a listing of function names and the associated values used in this bitmask, see Appendix E: Scalar Functions in the ODBC documentation.
SQL Grammar Support (KAGPROP_ODBCSQLCONFORMANCE) | Indicates the SQL grammar that the ODBC driver supports.

Provider-Specific Recordset and Command Properties

The OLE DB provider for ODBC adds several properties to the Properties collection of the Recordset and Command objects. The following table lists these properties with the corresponding OLE DB property name in parentheses.

Property Name | Description
Query Based Updates/Deletes/Inserts (KAGPROP_QUERYBASEDUPDATES) | Indicates whether updates, deletions, and insertions can be performed using SQL queries.
ODBC Concurrency Type (KAGPROP_CONCURRENCY) | Indicates the method used to reduce potential problems caused by two users attempting to access the same data from the data source simultaneously.
BLOB accessibility on Forward-Only cursor (KAGPROP_BLOBSONFOCURSOR) | Indicates whether BLOB Fields can be accessed when using a forward-only cursor.
Include SQL_FLOAT, SQL_DOUBLE, and SQL_REAL in QBU WHERE clauses (KAGPROP_INCLUDENONEXACT) | Indicates whether SQL_FLOAT, SQL_DOUBLE, and SQL_REAL values can be included in a QBU WHERE clause.
Position on the last row after insert (KAGPROP_POSITIONONNEWROW) | Indicates that after a new record has been inserted in a table, the last row in the table will be come the current row.
IRowsetChangeExtInfo (KAGPROP_IROWSETCHANGEEXTINFO) | Indicates whether the IRowsetChange interface provides extended information support.
ODBC Cursor Type (KAGPROP_CURSOR) | Indicates the type of cursor used by the Recordset.
Generate a Rowset that can be marshaled (KAGPROP_MARSHALLABLE) | Indicates that the ODBC driver generates a recordset that can be marshaled

Command Text

How you use the Command object largely depends on the data source, and what type of query or command statement it will accept.

ODBC provides a specific syntax for calling stored procedures. For the CommandText property of a Command object, the CommandText argument to the Execute method on a Connection object, or the Source argument to the Open method on a Recordset object, passes in a string with this syntax:

Copy code Copy code
                      "{ [ ? = ] call procedure [ ( ? [, ? [ ,  ]] ) ] }"

Each ? references an object in the Parameters collection. The first ? references Parameters(0), the next ? references Parameters(1), and so on.

The parameter references are optional and depend on the structure of the stored procedure. If you want to call a stored procedure that defines no parameters, your string would look like this:

Copy code Copy code
                      "{
                      call
                      procedure
                       }"

If you have two query parameters, your string would look like this:

Copy code Copy code
                      "{ call
                      procedure
                       ( ?, ? ) }"

If the stored procedure will return a value, the return value is treated as another parameter. If you have no query parameters but you do have a return value, your string would look like this:

Copy code Copy code
                      "{ ? = call
                      procedure
                       }"

Finally, if you have a return value and two query parameters, your string would look like this:

Copy code Copy code
                      "{ ? = call
                      procedure
                      ( ?, ? ) }"

Recordset Behavior

The following tables list the standard ADO methods and properties available on a Recordset object opened with this provider.

For more detailed information about Recordset behavior for your provider configuration, run the Supports method and enumerate the Properties collection of the Recordset to determine whether provider-specific dynamic properties are present.

Availability of standard ADO Recordset properties:

Property | ForwardOnly | Dynamic | Keyset | Static
AbsolutePage | not available | not available | read/write | read/write
AbsolutePosition | not available | not available | read/write | read/write
ActiveConnection | read/write | read/write | read/write | read/write
BOF | read-only | read-only | read-only | read-only
Bookmark | not available | not available | read/write | read/write
CacheSize | read/write | read/write | read/write | read/write
CursorLocation | read/write | read/write | read/write | read/write
CursorType | read/write | read/write | read/write | read/write
EditMode | read-only | read-only | read-only | read-only
Filter | read/write | read/write | read/write | read/write
LockType | read/write | read/write | read/write | read/write
MarshalOptions | read/write | read/write | read/write | read/write
MaxRecords | read/write | read/write | read/write | read/write
PageCount | read/write | not available | read-only | read-only
PageSize | read/write | read/write | read/write | read/write
RecordCount | read/write | not available | read-only | read-only
Source | read/write | read/write | read/write | read/write
State | read-only | read-only | read-only | read-only
Status | read-only | read-only | read-only | read-only

The AbsolutePosition and AbsolutePage properties are write-only when ADO is used with version 1.0 of the Microsoft OLE DB Provider for ODBC.

Availability of standard ADO Recordset methods:

Method | ForwardOnly | Dynamic | Keyset | Static
AddNew | Yes | Yes | Yes | Yes
Cancel | Yes | Yes | Yes | Yes
CancelBatch | Yes | Yes | Yes | Yes
CancelUpdate | Yes | Yes | Yes | Yes
Clone | No | No | Yes | Yes
Close | Yes | Yes | Yes | Yes
Delete | Yes | Yes | Yes | Yes
GetRows | Yes | Yes | Yes | Yes
Move | Yes | Yes | Yes | Yes
MoveFirst | Yes | Yes | Yes | Yes
MoveLast | No | Yes | Yes | Yes
MoveNext | Yes | Yes | Yes | Yes
MovePrevious | No | Yes | Yes | Yes
NextRecordset* | Yes | Yes | Yes | Yes
Open | Yes | Yes | Yes | Yes
Requery | Yes | Yes | Yes | Yes
Resync | No | No | Yes | Yes
Supports | Yes | Yes | Yes | Yes
Update | Yes | Yes | Yes | Yes
UpdateBatch | Yes | Yes | Yes | Yes

*Not supported for Microsoft Access databases.

Dynamic Properties

The Microsoft OLE DB Provider for ODBC inserts several dynamic properties into the Properties collection of the unopened Connection, Recordset, and Command objects.

The tables below are a cross-index of the ADO and OLE DB names for each dynamic property. The OLE DB Programmer's Reference refers to an ADO property name by the term, "Description." You can find more information about these properties in the OLE DB Programmer's Reference. Search for the OLE DB property name in the Index or see Appendix C: OLE DB Properties.

Connection Dynamic Properties

The following properties are added to the Connection object's Properties collection.

ADO Property Name | OLE DB Property Name
Active Sessions | DBPROP_ACTIVESESSIONS
Asynchable Abort | DBPROP_ASYNCTXNABORT
Asynchable Commit | DBPROP_ASYNCTNXCOMMIT
Autocommit Isolation Levels | DBPROP_SESS_AUTOCOMMITISOLEVELS
Catalog Location | DBPROP_CATALOGLOCATION
Catalog Term | DBPROP_CATALOGTERM
Column Definition | DBPROP_COLUMNDEFINITION
Connect Timeout | DBPROP_INIT_TIMEOUT
Current Catalog | DBPROP_CURRENTCATALOG
Data Source | DBPROP_INIT_DATASOURCE
Data Source Name | DBPROP_DATASOURCENAME
Data Source Object Threading Model | DBPROP_DSOTHREADMODEL
DBMS Name | DBPROP_DBMSNAME
DBMS Version | DBPROP_DBMSVER
Extended Properties | DBPROP_INIT_PROVIDERSTRING
GROUP BY Support | DBPROP_GROUPBY
Heterogeneous Table Support | DBPROP_HETEROGENEOUSTABLES
Identifier Case Sensitivity | DBPROP_IDENTIFIERCASE
Initial Catalog | DBPROP_INIT_CATALOG
Isolation Levels | DBPROP_SUPPORTEDTXNISOLEVELS
Isolation Retention | DBPROP_SUPPORTEDTXNISORETAIN
Locale Identifier | DBPROP_INIT_LCID
Location | DBPROP_INIT_LOCATION
Maximum Index Size | DBPROP_MAXINDEXSIZE
Maximum Row Size | DBPROP_MAXROWSIZE
Maximum Row Size Includes BLOB | DBPROP_MAXROWSIZEINCLUDESBLOB
Maximum Tables in SELECT | DBPROP_MAXTABLESINSELECT
Mode | DBPROP_INIT_MODE
Multiple Parameter Sets | DBPROP_MULTIPLEPARAMSETS
Multiple Results | DBPROP_MULTIPLERESULTS
Multiple Storage Objects | DBPROP_MULTIPLESTORAGEOBJECTS
Multi-Table Update | DBPROP_MULTITABLEUPDATE
NULL Collation Order | DBPROP_NULLCOLLATION
NULL Concatenation Behavior | DBPROP_CONCATNULLBEHAVIOR
OLE DB Services | DBPROP_INIT_OLEDBSERVICES
OLE DB Version | DBPROP_PROVIDEROLEDBVER
OLE Object Support | DBPROP_OLEOBJECTS
Open Rowset Support | DBPROP_OPENROWSETSUPPORT
ORDER BY Columns in Select List | DBPROP_ORDERBYCOLUMNSINSELECT
Output Parameter Availability | DBPROP_OUTPUTPARAMETERAVAILABILITY
Password | DBPROP_AUTH_PASSWORD
Pass By Ref Accessors | DBPROP_BYREFACCESSORS
Persist Security Info | DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO
Persistent ID Type | DBPROP_PERSISTENTIDTYPE
Prepare Abort Behavior | DBPROP_PREPAREABORTBEHAVIOR
Prepare Commit Behavior | DBPROP_PREPARECOMMITBEHAVIOR
Procedure Term | DBPROP_PROCEDURETERM
Prompt | DBPROP_INIT_PROMPT
Provider Friendly Name | DBPROP_PROVIDERFRIENDLYNAME
Provider Name | DBPROP_PROVIDERFILENAME
Provider Version | DBPROP_PROVIDERVER
Read-Only Data Source | DBPROP_DATASOURCEREADONLY
Rowset Conversions on Command | DBPROP_ROWSETCONVERSIONSONCOMMAND
Schema Term | DBPROP_SCHEMATERM
Schema Usage | DBPROP_SCHEMAUSAGE
SQL Support | DBPROP_SQLSUPPORT
Structured Storage | DBPROP_STRUCTUREDSTORAGE
Subquery Support | DBPROP_SUBQUERIES
Table Term | DBPROP_TABLETERM
Transaction DDL | DBPROP_SUPPORTEDTXNDDL
User ID | DBPROP_AUTH_USERID
User Name | DBPROP_USERNAME
Window Handle | DBPROP_INIT_HWND

Recordset Dynamic Properties

The following properties are added to the Recordset object's Properties collection.

ADO Property Name | OLE DB Property Name
Access Order | DBPROP_ACCESSORDER
Blocking Storage Objects | DBPROP_BLOCKINGSTORAGEOBJECTS
Bookmark Type | DBPROP_BOOKMARKTYPE
Bookmarkable | DBPROP_IROWSETLOCATE
Change Inserted Rows | DBPROP_CHANGEINSERTEDROWS
Column Privileges | DBPROP_COLUMNRESTRICT
Column Set Notification | DBPROP_NOTIFYCOLUMNSET
Delay Storage Object Updates | DBPROP_DELAYSTORAGEOBJECTS
Fetch Backwards | DBPROP_CANFETCHBACKWARDS
Hold Rows | DBPROP_CANHOLDROWS
IAccessor | DBPROP_IAccessor
IColumnsInfo | DBPROP_IColumnsInfo
IColumnsRowset | DBPROP_IColumnsRowset
IConnectionPointContainer | DBPROP_IConnectionPointContainer
IConvertType | DBPROP_IConvertType
Immobile Rows | DBPROP_IMMOBILEROWS
IRowset | DBPROP_IRowset
IRowsetChange | DBPROP_IRowsetChange
IRowsetIdentity | DBPROP_IRowsetIdentity
IRowsetInfo | DBPROP_IRowsetInfo
IRowsetLocate | DBPROP_IRowsetLocate
IRowsetResynch |
IRowsetUpdate | DBPROP_IRowsetUpdate
ISequentialStream | DBPROP_ISequentialStream
ISupportErrorInfo | DBPROP_ISupportErrorInfo
Literal Bookmarks | DBPROP_LITERALBOOKMARKS
Literal Row Identity | DBPROP_LITERALIDENTITY
Maximum Open Rows | DBPROP_MAXOPENROWS
Maximum Pending Rows | DBPROP_MAXPENDINGROWS
Maximum Rows | DBPROP_MAXROWS
Notification Granularity | DBPROP_NOTIFICATIONGRANULARITY
Notification Phases | DBPROP_NOTIFICATIONPHASES
Objects Transacted | DBPROP_TRANSACTEDOBJECT
Own Changes Visible | DBPROP_OWNUPDATEDELETE
Own Inserts Visible | DBPROP_OWNINSERT
Preserve on Abort | DBPROP_ABORTPRESERVE
Preserve on Commit | DBPROP_COMMITPRESERVE
Quick Restart | DBPROP_QUICKRESTART
Reentrant Events | DBPROP_REENTRANTEVENTS
Remove Deleted Rows | DBPROP_REMOVEDELETED
Report Multiple Changes | DBPROP_REPORTMULTIPLECHANGES
Return Pending Inserts | DBPROP_RETURNPENDINGINSERTS
Row Delete Notification | DBPROP_NOTIFYROWDELETE
Row First Change Notification | DBPROP_NOTIFYROWFIRSTCHANGE
Row Insert Notification | DBPROP_NOTIFYROWINSERT
Row Privileges | DBPROP_ROWRESTRICT
Row Resynchronization Notification | DBPROP_NOTIFYROWRESYNCH
Row Threading Model | DBPROP_ROWTHREADMODEL
Row Undo Change Notification | DBPROP_NOTIFYROWUNDOCHANGE
Row Undo Delete Notification | DBPROP_NOTIFYROWUNDODELETE
Row Undo Insert Notification | DBPROP_NOTIFYROWUNDOINSERT
Row Update Notification | DBPROP_NOTIFYROWUPDATE
Rowset Fetch Position Change Notification | DBPROP_NOTIFYROWSETFETCHPOSISIONCHANGE
Rowset Release Notification | DBPROP_NOTIFYROWSETRELEASE
Scroll Backwards | DBPROP_CANSCROLLBACKWARDS
Skip Deleted Bookmarks | DBPROP_BOOKMARKSKIPPED
Strong Row Identity | DBPROP_STRONGITDENTITY
Unique Rows | DBPROP_UNIQUEROWS
Updatability | DBPROP_UPDATABILITY
Use Bookmarks | DBPROP_BOOKMARKS

Command Dynamic Properties

The following properties are added to the Command object's Properties collection.

ADO Property Name | OLE DB Property Name
Access Order | DBPROP_ACCESSORDER
Blocking Storage Objects | DBPROP_BLOCKINGSTORAGEOBJECTS
Bookmark Type | DBPROP_BOOKMARKTYPE
Bookmarkable | DBPROP_IROWSETLOCATE
Change Inserted Rows | DBPROP_CHANGEINSERTEDROWS
Column Privileges | DBPROP_COLUMNRESTRICT
Column Set Notification | DBPROP_NOTIFYCOLUMNSET
Delay Storage Object Updates | DBPROP_DELAYSTORAGEOBJECTS
Fetch Backwards | DBPROP_CANFETCHBACKWARDS
Hold Rows | DBPROP_CANHOLDROWS
IAccessor | DBPROP_IAccessor
IColumnsInfo | DBPROP_IColumnsInfo
IColumnsRowset | DBPROP_IColumnsRowset
IConnectionPointContainer | DBPROP_IConnectionPointContainer
IConvertType | DBPROP_IConvertType
Immobile Rows | DBPROP_IMMOBILEROWS
IRowset | DBPROP_IRowset
IRowsetChange | DBPROP_IRowsetChange
IRowsetIdentity | DBPROP_IRowsetIdentity
IRowsetInfo | DBPROP_IRowsetInfo
IRowsetLocate | DBPROP_IRowsetLocate
IRowsetResynch |
IRowsetUpdate | DBPROP_IRowsetUpdate
ISequentialStream | DBPROP_ISequentialStream
ISupportErrorInfo | DBPROP_ISupportErrorInfo
Literal Bookmarks | DBPROP_LITERALBOOKMARKS
Literal Row Identity | DBPROP_LITERALIDENTITY
Maximum Open Rows | DBPROP_MAXOPENROWS
Maximum Pending Rows | DBPROP_MAXPENDINGROWS
Maximum Rows | DBPROP_MAXROWS
Notification Granularity | DBPROP_NOTIFICATIONGRANULARITY
Notification Phases | DBPROP_NOTIFICATIONPHASES
Objects Transacted | DBPROP_TRANSACTEDOBJECT
Own Changes Visible | DBPROP_OWNUPDATEDELETE
Own Inserts Visible | DBPROP_OWNINSERT
Preserve on Abort | DBPROP_ABORTPRESERVE
Preserve on Commit | DBPROP_COMMITPRESERVE
Quick Restart | DBPROP_QUICKRESTART
Reentrant Events | DBPROP_REENTRANTEVENTS
Remove Deleted Rows | DBPROP_REMOVEDELETED
Report Multiple Changes | DBPROP_REPORTMULTIPLECHANGES
Return Pending Inserts | DBPROP_RETURNPENDINGINSERTS
Row Delete Notification | DBPROP_NOTIFYROWDELETE
Row First Change Notification | DBPROP_NOTIFYROWFIRSTCHANGE
Row Insert Notification | DBPROP_NOTIFYROWINSERT
Row Privileges | DBPROP_ROWRESTRICT
Row Resynchronization Notification | DBPROP_NOTIFYROWRESYNCH
Row Threading Model | DBPROP_ROWTHREADMODEL
Row Undo Change Notification | DBPROP_NOTIFYROWUNDOCHANGE
Row Undo Delete Notification | DBPROP_NOTIFYROWUNDODELETE
Row Undo Insert Notification | DBPROP_NOTIFYROWUNDOINSERT
Row Update Notification | DBPROP_NOTIFYROWUPDATE
Rowset Fetch Position Change Notification | DBPROP_NOTIFYROWSETFETCHPOSITIONCHANGE
Rowset Release Notification | DBPROP_NOTIFYROWSETRELEASE
Scroll Backwards | DBPROP_CANSCROLLBACKWARDS
Skip Deleted Bookmarks | DBPROP_BOOKMARKSKIP
Strong Row Identity | DBPROP_STRONGIDENTITY
Updatability | DBPROP_UPDATABILITY
Use Bookmarks | DBPROP_BOOKMARKS

See AlsoFor details regarding specific implementation and functional information about the Microsoft OLE DB Provider for ODBC, consult the OLE DB Programmer's Guide or visit the Data Platform Developer Center.


Section.ForceNewPage Property (Access)

 Copy code hover
[image]

Section.ForceNewPage Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ForceNewPage property to specify whether form sections detail, footer) or report sections (header, detail, footer) print on a separate page, rather than on the current page. Read/write Byte.

Syntax

expression .ForceNewPage

expression A variable that represents a Section object.

Remarks

For example, you may have designed the last page of a report as an order form. If the report footer's ForceNewPage property is set to Before Section, the order form is always printed on a new page.

Note Note

The ForceNewPage property does not apply to page headers or page footers.

The ForceNewPage property uses the following settings.

Setting | Visual Basic | Description
None | 0 | (Default) The current section (the section for which you're setting the property) is printed on the current page.
Before Section | 1 | The current section is printed at the top of a new page.
After Section | 2 | The section immediately following the current section is printed at the top of a new page.
Before & After | 3 | The current section is printed at the top of a new page, and the next section is printed at the top of a new page.

Here are some examples of the ForceNewPage property setting.

Section | Sample setting | Description
A group header displaying the year | Before Section | The group header is printed at the top of the page, followed by the detail section, group footer, and page footer.
A report detail section | After Section | The group footer is printed at the top of a new page.
A report header containing the report title and company logo. | After Section | The report title and logo are printed on a separate page at the beginning of the report.

Example

The following example returns the ForceNewPage property setting for the detail section of the Sales By Date report and assigns it to the intGetVal variable.

VBA Copy code Copy code
Dim intGetVal As Integer
intGetVal = Reports![Sales By Year].Section(acDetail).ForceNewPage

See also

Concepts

Section Object

Other resources

Section Object Members


Form.Printer Property (Access)

 Copy code hover
[image]

Form.Printer Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Printer object representing the default printer on the current system. Read/write.

Syntax

expression .Printer

expression A variable that represents a Form object.

Example

The following example makes the first printer in the Printers collection the default printer for the system, and then reports its name, driver information, and port information.

VBA Copy code Copy code
Dim prtDefault As Printer

Set Application.Printer = Application.Printers(0)

Set prtDefault = Application.Printer

With prtDefault
 MsgBox "Device name: " & .DeviceName & vbCr _
 & "Driver name: " & .DriverName & vbCr _
 & "Port: " & .Port
End With

See also

Concepts

Form Object

Other resources

Form Object Members


Database.DesignMasterID Property (DAO)

 Copy code hover
[image]

Database.DesignMasterID Property (DAO)
Send feedback

Sets or returns a 16-byte value that uniquely identifies the Design Master in a replica set (Microsoft Access workspaces only).

Syntax

expression .DesignMasterID

expression A variable that represents a Database object.

Remarks

You should set the DesignMasterID property only if you need to move the current Design Master. Setting this property makes a specific replica in the replica set the Design Master.

Note Note

Never create a second Design Master in a replica set. The existence of a second Design Master can result in the loss of data.

Under extreme circumstances— for example, if the Design Master is erased or corrupted— you can set this property at the current replica. However, setting this property at a replica when there is already another Design Master in the set might partition your replica set into two irreconcilable sets and prevent any further synchronization of data.

If you decide to make a replica the new Design Master for the set, synchronize it with all the replicas in the replica set before setting the DesignMasterID property in the replica. The replica must be open in exclusive mode in order to make it the Design Master.

If you make a replica that is designated read-only into the Design Master, the target replica is made read/write; the old Design Master also remains read/write.

The DesignMasterID property setting is stored in the MSysRepInfo system table.

Example

This example sets the DesignMasterID property to the ReplicaID property setting of another database, making that database the Design Master in the replica set. The old and new Design Masters are synchronized to update the design change. For this code to work, you must create a Design Master and replica, include their names and paths as appropriate, and run this code from a database other than the old or new Design Master.

VBA Copy code Copy code
Sub SetNewDesignMaster(strOldDM as String, _
 strNewDM as String)

 Dim dbsOld As Database
 Dim dbsNew As Database

 ' Open the current Design Master in exclusive mode.
 Set dbsOld = OpenDatabase(strOldDM, True)

 ' Open the database that will become the new
 ' Design Master.
 Set dbsNew = OpenDatabase(strNewDM)

 ' Make the new database the Design Master.
 dbsOld.DesignMasterID = dbsNew.ReplicaID

 ' Synchronize the old Design Master with the new
 ' Design Master, and allow two-way exchanges.
 dbsOld.Synchronize strNewDM, dbRepImpExpChanges
 dbsOld.Close
 dbsNew.Close

End Sub


No such index

 Copy code hover
[image]

No such index <name> on table <name>. (Error 3372)
Send feedback

The specified index does not exist in the specified table. Check your code for a misspelling or other error, or verify the Indexes collection contains the specified index.


CommandButton.QuickStyleMask Property (Access)

 Copy code hover
[image]

CommandButton.QuickStyleMask Property (Access)
Send feedback

Published: July 16, 2012

Gets or sets modifications to the Quick Style that is applied to the specified object. Read/write Long.

Version information

Version Added: Access 2010

Syntax

expression .QuickStyle

expression A variable that represents a CommandButton object.

Remarks

Set the QuickStyleMask property to -1 to remove modifications to the selected Quick Style.

Property value

INT32


CustomControl.Class Property (Access)

 Copy code hover
[image]

CustomControl.Class Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Class property to specify or determine the class name of an embeddedOLE object. Read/write String.

Syntax

expression .Class

expression A variable that represents a CustomControl object.

Remarks

The Class property setting is a string expression supplied by you or Microsoft Access when you create or paste an OLE object.

A class name defines the type of OLE object. For example, Microsoft Excel supports several types of OLE objects, including worksheets and charts. Their class names are "Excel.Sheet" and "Excel.Chart" respectively.

Note Note

To determine the class name of an OLE object, see the documentation for the application supplying the object.

The Class property setting is updated when you copy an object from the Clipboard. For example, if you paste a Microsoft Excel chart from the Clipboard into an OLE object that previously contained a Microsoft Excel worksheet, the Class property setting changes from "Excel.Sheet" to "Excel.Chart". You can paste an object from the Clipboard by using Visual Basic to set the control's Action property to acOLEPaste or acOLEPasteSpecialDlg.

Note Note

The OLEClass property and the Class property are similar but not identical. The OLEClass property setting is a general description of the OLE object whereas the Class property setting is the name used to refer to the OLE object in Visual Basic. Examples of OLEClass property settings are Microsoft Excel Chart, Microsoft Word Document, and Paintbrush Picture.

Example

The following example creates a linked OLE object using an unbound object frame named OLE1 and sizes the control to display the object's entire contents when the user clicks a command button.

VBA Copy code Copy code
Sub Command1_Click
 OLE1.Class = "Excel.Sheet" ' Set class name.
 ' Specify type of object.
 OLE1.OLETypeAllowed = acOLELinked
 ' Specify source file.
 OLE1.SourceDoc = "C:\Excel\Oletext.xls"
 ' Specify data to create link to.
 OLE1.SourceItem = "R1C1:R5C5"
 ' Create linked object.
 OLE1.Action = acOLECreateLink
 ' Adjust control size.
 OLE1.SizeMode = acOLESizeZoom
End Sub

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


TextBox.GridlineStyleRight Property (Access)

 Copy code hover
[image]

TextBox.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified text box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleRight

expression A variable that represents a TextBox object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


NavigationControl Members (Access)

 Copy code hover
[image]

NavigationControl Members (Access)
Send feedback

Published: July 16, 2012

This object represents a navigation control on a form.

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Change | The Change event occurs when the contents of the specified control changes.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Dirty | The Dirty event occurs when the contents of the specified control changes.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.
Undo | Occurs when the user undoes a change.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.
Undo | You can use the Undo method to reset a control or form when its value has been changed.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoTab | You can use the AutoTab property to specify whether an automatic tab occurs when the last character permitted by a text box control's input mask is entered. An automatic tab moves the focus to the next control in the form's tab order. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FilterLookup | You can use the FilterLookup property to specify whether values appear in a boundtext box control when using the Filter By Form or Server Filter By Form window. Read/write Byte.
FormatConditions | You can use the FormatConditions property to return a read-only reference to the FormatConditions collection and its related properties.
GridlineColor | Gets or sets the color of the gridline for the specified list box. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified list box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified text box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified text box. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified text box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified text box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified text box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the text box is anchored horizontally within its layout. Read/write.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
KeyboardLanguage |
Layout | Returns the type of layout for the specified text box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified text box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.
LineSpacing | You can use the LineSpacing property to specify or determine the location of information displayed within a label or text box control. Read/write Integer.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
NumeralShapes |
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
RightPadding | Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.
ScrollBarAlign | You can use the ScrollBarAlign to specify or determine the alignment of a vertical scroll bar. Read/write Byte.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
SelectedTab | Gets the active tab of the navigation control. Read-only NavigationButton.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SmartTags | Returns a SmartTags collection that represents the collection of smart tags that have been added to a control. .
Span | Gets or sets the orientation of the navigation buttons. Read/write AcNavigationSpan.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
SubForm | Gets or sets the name of the SubForm object used to display forms. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
Tabs | Gets the collection of navigation buttons for the specified navigation control. Read-only Children.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.
Value | Determines or specifies the text in the text box. Read/write Variant.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified text box is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


How to: Use Numeric Criteria in Expressions

 Copy code hover
[image]

How to: Use Numeric Criteria in Expressions
Send feedback

To specify numeric criteria for an operation, you supply a numeric value as part of the string expression that forms the criteria argument.

Suppose that you are performing the DLookup function on an Employees table to find the last name of a particular employee, and you want to use a value from the EmployeeID field in the function's criteria argument. You could construct a criteria argument like the following example, which returns the last name of the employee whose EmployeeID is 7:

Copy code Copy code
=DLookup("[LastName]", "Employees", "[EmployeeID] = 7")


Sum Function (Access 2013 custom web app)

 Copy code hover
[image]

Sum Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the sum of all the values in the expression.

Syntax

Sum(NumericExpression)

The Sum function contains the following argument.

Argument name | Description
NumericExpression | An expression identifying the field that contains the numeric data you want to add or an expression that performs a calculation using the data in that field. Operands in NumericExpression can include the name of a table field, a constant, or a function (which can be either intrinsic or user-defined but not one of the other SQL aggregate functions).

Remarks

The Sum function ignores records that contain Null values.

The Sum function can only be used with numeric columns.


ListBox.ItemsSelected Property (Access)

 Copy code hover
[image]

ListBox.ItemsSelected Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ItemsSelected property to return a read-only reference to the hidden ItemsSelected collection. This hidden collection can be used to access data in the selected rows of a multiselect list box control.

Syntax

expression .ItemsSelected

expression A variable that represents a ListBox object.

Remarks

The ItemsSelected collection is unlike other collections in that it is a collection of Variants rather than of objects. Each Variant is an integer index referring to a selected row in a list box or combo box.

Use the ItemsSelected collection in conjunction with the Column property or the ItemData property to retrieve data from selected rows in a list box or combo box. You can list the ItemsSelected collection by using the For Each...Next statement.

For example, if you have an Employees list box on a form, you can list the ItemsSelected collection and use the control's ItemData property to return the value of the bound column for each selected row in the list box.

To enable multiple selection of rows in a list box, set the control's MultiSelect property to Simple or Extended.

The ItemsSelected collection has no methods and two properties, the Count and Item properties.

Example

The following example prints the value of the bound column for each selected row in a Names list box on a Contacts form. To try this example, create the list box and set its BoundColumn property as desired and its MultiSelect property to Simple or Extended. Switch to Form view, select several rows in the list box, and run the following code:

VBA Copy code Copy code
Sub BoundData()
 Dim frm As Form, ctl As Control
 Dim varItm As Variant

 Set frm = Forms!Contacts
 Set ctl = frm!Names
 For Each varItm In ctl.ItemsSelected
 Debug.Print ctl.ItemData(varItm)
 Next varItm
End Sub

The next example uses the same list box control, but prints the values of each column for each selected row in the list box, instead of only the values in the bound column.

VBA Copy code Copy code
Sub AllSelectedData()
 Dim frm As Form, ctl As Control
 Dim varItm As Variant, intI As Integer

 Set frm = Forms!Contacts
 Set ctl = frm!Names
 For Each varItm In ctl.ItemsSelected
 For intI = 0 To ctl.ColumnCount - 1
 Debug.Print ctl.Column(intI, varItm)
 Next intI
 Debug.Print
 Next varItm
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


RDS Methods (Access)

 Copy code hover
[image]

RDS Methods (Access)
Send feedback

In this section

  • RDS Methods

  • Cancel Method (RDS)

  • CancelUpdate Method (RDS)

  • ConvertToString Method (RDS)

  • CreateObject Method (RDS)

  • CreateRecordset Method (RDS)

  • MoveFirst, MoveLast, MoveNext, and MovePrevious Methods (RDS)

  • Query Method (RDS)

  • Refresh Method (RDS)

  • Reset Method (RDS)

  • SubmitChanges Method (RDS)


AllStoredProcedures.Parent Property (Access)

 Copy code hover
[image]

AllStoredProcedures.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents an AllStoredProcedures object.

See also

Concepts

AllStoredProcedures Collection

Other resources

AllStoredProcedures Object Members


ParentRow Property (ADO)

 Copy code hover
[image]

ParentRow Property (ADO)
Send feedback

Sets the container of an OLE DB Row object on an ADORecordConstruction object, so that the parent of the row is turned into an ADO Record object.

Write-only.

Syntax

HRESULT put_ParentRow([in] IUnknown* pParent);

Parameters

  • pParent

  • A container of a row.

Return Values

This property method returns the standard HRESULT values, including S_OK and E_FAIL.

Applies To

ADORecordConstruction


CommandButton.BottomPadding Property (Access)

 Copy code hover
[image]

CommandButton.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the button and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .BottomPadding

expression A variable that represents a CommandButton object.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


OptionGroup Events (Access)

 Copy code hover
[image]

OptionGroup Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.


Controls.Application Property (Access)

 Copy code hover
[image]

Controls.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a Controls object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

Controls Collection

Other resources

Controls Object Members


Form.SelHeight Property (Access)

 Copy code hover
[image]

Form.SelHeight Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SelHeight property to specify or determine the number of selected rows (records) in the current selection rectangle in a table, query, or form datasheet, or the number of selected records in a continuous form. Read/write Long.

Syntax

expression .SelHeight

expression A variable that represents a Form object.

Remarks

The SelHeight property returns a Long Integer value between 0 and the number of records in the datasheet or continuous form. The setting of this property specifies or returns the number of selected rows in the selection rectangle or the number of selected records in the continuous form.

If there's no selection, the value returned by this property will be zero. Setting this property to 0 removes the selection from the datasheet or form.

If you've selected one or more columns in a datasheet (using the column headings), you can't change the setting of the SelHeight property (except to set it to 0).

You can use these properties with the SelTop and SelLeft properties to specify or determine the actual position of the selection rectangle on the datasheet. If there's no selection, then the SelTop and SelLeft properties return the row number and column number of the cell with the focus.

The SelHeight and SelWidth properties contain the position of the lower-right corner of the selection rectangle. The SelTop and SelLeft property values determine the upper-left corner of the selection rectangle.

See also

Concepts

Form Object

Other resources

Form Object Members


DoCmd.Rename Method (Access)

 Copy code hover
[image]

DoCmd.Rename Method (Access)
See also Send feedback

Published: July 16, 2012

The Rename method carries out the Rename action in Visual Basic.

Syntax

expression .Rename(NewName, ObjectType, OldName)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
NewName | Required | Variant | A string expression that's the new name for the object you want to rename. The name must follow the object-naming rules for Microsoft Access objects.
ObjectType | Optional | AcObjectType | A AcObjectType constant that specifies the type of object to rename. The default value is acDefault.
OldName | Optional | Variant | A string expression that's the valid name of an object of the type specified by the ObjectType argument. If you execute Visual Basic code containing the Rename method in a library database, Microsoft Access looks for the object with this name, first in the library database, then in the current database.

Remarks

You can use the Rename method to rename a specified database object.

If you leave the ObjectType and OldName arguments blank (the default constant, acDefault, is assumed for ObjectType), Microsoft Access renames the object selected in the Database window. To select an object in the Database window, you can use the SelectObject method with the In Database Window argument set to Yes (True).

Example

The following example renames the Employees table.

VBA Copy code Copy code
DoCmd.Rename "Old Employees Table", acTable, "Employees"

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Property Properties (DAO)

 Copy code hover
[image]

Property Properties (DAO)
Send feedback

In this section

  • Property.Inherited Property (DAO)

  • Property.Name Property (DAO)

  • Property.Properties Property (DAO)

  • Property.Type Property (DAO)

  • Property.Value Property (DAO)


Rectangle.BackColor Property (Access)

 Copy code hover
[image]

Rectangle.BackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the interior color of the specified object. Read/write Long.

Syntax

expression .BackColor

expression A variable that represents a Rectangle object.

Remarks

The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

To use the BackColor property, the BackStyle property, if available, must be set to Normal.

Example

The following example uses the RGB function to set the , BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


Application.DStDevP Method (Access)

 Copy code hover
[image]

Application.DStDevP Method (Access)
See also Send feedback

Published: July 16, 2012

Estimates the standard deviation across a population in a specified set of records (a domain). .

Syntax

expression .DStDevP(Expr, Domain, Criteria)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Expr | Required | String | An expression that identifies the numeric field on which you want to find the standard deviation. It can be a string expression identifying a field from a table or query, or it can be an expression that performs a calculation on data in that field. In expr, you can include the name of a field in a table, a control on a form, a constant, or a function. If expr includes a function, it can be either built-in or user-defined, but not another domain aggregate or SQL aggregate function.
Domain | Required | String | A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter.
Criteria | Optional | Variant | An optional string expression used to restrict the range of data on which the DStDevP function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the DStDevP function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain; otherwise, the DStDevP function will return a Null.

Return Value

Variant

Remarks

If domain refers to fewer than two records or if fewer than two records satisfy criteria, the DStDevP function returns a Null, indicating that a standard deviation can't be calculated.

You can use the DStDevP function to specify criteria in the Criteria row of a select query. For example, you could create a query on an Orders table and a Products table to display all products for which the freight cost fell above the mean plus the standard deviation for freight cost.

You can use the DStDevP function in a calculated field expression of a query, or in the Update To row of an update query.

Note Note

You can use the DStDev and DStDevP functions or the StDev and StDevP functions in a calculated field expression of a totals query. If you use the DStDev or DStDevP function, values are calculated before data is grouped. If you use the StDev or StDevP function, the data is grouped before values in the field expression are evaluated.

Use the DStDev function in a calculated control when you need to specify criteria to restrict the range of data on which the function is performed.

If you simply want to find the standard deviation across all records in domain, use the StDev or StDevP function.

If the data type of the field from which expr is derived is a number, the DStDevP function returns a Double data type. If you use the DStDevP function in a calculated control, include a data type conversion function in the expression to improve performance.

Example

The following example returns estimates of the standard deviation for a population and a population sample for orders shipped to the United Kingdom. The domain is an Orders table. The criteria argument restricts the resulting set of records to those for which the ShipCountry value is UK.

VBA Copy code Copy code
Dim dblX As Double
Dim dblY As Double

' Sample estimate.
dblX = DStDev("[Freight]", "Orders", "[ShipCountry] = 'UK'")

' Population estimate.
dblY = DStDevP("[Freight]", "Orders", "[ShipCountry] = 'UK'")

The next example calculates the same estimates by using a variable, strCountry, in the criteria argument. Note that single quotation marks (') are included in the string expression, so that when the strings are concatenated, the string literal UK will be enclosed in single quotation marks.

VBA Copy code Copy code
Dim strCountry As String
Dim dblX As Double
Dim dblY As Double

strCountry = "UK"

dblX = DStDev("[Freight]", "Orders", _
    "[ShipCountry] = '" & strCountry & "'")

dblY = DStDevP("[Freight]", "Orders", _
    "[ShipCountry] = '" & strCountry & "'")

The following examples show how to use various types of criteria with the DStDevP function.

Sample code provided by: Community Member Icon The UtterAccess community | About the Contributors

Copy code Copy code
    ' ***************************
    ' Typical Use
    ' Numerical values. Replace "number" with the number to use.
    variable = DStDevP("[FieldName]", "TableName", "[Criteria] = number")

    ' Strings.
    ' Numerical values. Replace "string" with the string to use.
    variable = DStDevP("[FieldName]", "TableName", "[Criteria]= 'string'")

    ' Dates. Replace "date" with the string to use.
    variable = DStDevP("[FieldName]", "TableName", "[Criteria]= #date#")
    ' ***************************

    ' ***************************
    ' Referring to a control on a form
    ' Numerical values
    variable = DStDevP("[FieldName]", "TableName", "[Criteria] = " & Forms!FormName!ControlName)

    ' Strings
    variable = DStDevP("[FieldName]", "TableName", "[Criteria] = '" & Forms!FormName!ControlName & "'")

    ' Dates
    variable = DStDevP("[FieldName]", "TableName", "[Criteria] = #" & Forms!FormName!ControlName & "#")
    ' ***************************

    ' ***************************
    ' Combinations
    ' Multiple types of criteria
    variable = DStDevP("[FieldName]", "TableName", "[Criteria1] = " & Forms![FormName]![Control1] _
             & " AND [Criteria2] = '" & Forms![FormName]![Control2] & "'" _
            & " AND [Criteria3] =#" & Forms![FormName]![Control3] & "#")

    ' Use two fields from a single record.
    variable = DStDevP("[LastName] & ', ' & [FirstName]", "tblPeople", "[PrimaryKey] = 7")

    ' Expressions
    variable = DStDevP("[Field1] + [Field2]", "tableName", "[PrimaryKey] = 7")

    ' Control Structures
    variable = DStDevP("IIf([LastName] Like 'Smith', 'True', 'False')", "tableName", "[PrimaryKey] = 7")
    ' ***************************

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Application Object

Other resources

Application Object Members


Customizing Windows Registry Settings for the Microsoft Access Database Engine

 Copy code hover
[image]

Customizing Windows Registry Settings for the Microsoft Access Database Engine
Send feedback

If your application cannot work correctly with the default functionality of the Microsoft Access database engine, you may have to change the settings in the Microsoft® Windows® Registry to suit your needs. The Windows Registry can also be used to tune the operation of the installable ISAM and ODBC driver.

You can customize the settings in the Windows Registry in four different ways:

Using Regedit.exe to Overwrite the Default Settings

Creating a Portion in Your Application's Registry Tree to Manage the Settings

Using the SetOption Method from DAO

Using the Connection Properties in the Microsoft OLE DB Provider for Access


Clone Method (ADO)

 Copy code hover
[image]

Clone Method (ADO)
Send feedback

Creates a duplicate Recordset object from an existing Recordset object. Optionally, specifies that the clone be read-only.

Syntax

Set rstDuplicate = rstOriginal.Clone (LockType)

Return Value

Returns a Recordset object reference.

Parameters

  • rstDuplicate

  • An object variable that identifies the duplicate Recordset object to be created.

  • rstOriginal

  • An object variable that identifies the Recordset object to be duplicated.

  • LockType

  • Optional. A LockTypeEnum value that specifies either the lock type of the original Recordset, or a read-only Recordset. Valid values are adLockUnspecified or adLockReadOnly.

Remarks

Use the Clone method to create multiple, duplicate Recordset objects, particularly if you want to maintain more than one current record in a given set of records. Using the Clone method is more efficient than creating and opening a new Recordset object with the same definition as the original.

The Filter property of the original Recordset, if any, will not be applied to the clone. Set the Filter property of the new Recordset in order to filter the results. The simplest way to copy any existing Filter value is to assign it directly, like this:

The current record of a newly created clone is set to the first record.

Changes you make to one Recordset object are visible in all of its clones regardless of cursor type. However, after you execute Requery on the original Recordset, the clones will no longer be synchronized to the original.

Closing the original Recordset does not close its copies, nor does closing a copy close the original or any of the other copies.

You can only clone a Recordset object that supports bookmarks. Bookmark values are interchangeable; that is, a bookmark reference from one Recordset object refers to the same record in any of its clones.

Some Recordset events that are triggered will also fire in all Recordset clones. However, because the current record can differ between cloned Recordsets, the events may not be valid for the clone.

For example, if you change a value of a field, a WillChangeField event will occur in the changed Recordset and in all clones. The Fields parameter of the WillChangeField event of a cloned Recordset (where the change was not made) will simply refer to the fields of the current record of the clone, which may be a different record than the current record of the original Recordset where the change occurred.

The following table provided a full listing of all Recordset events and indicates whether they are valid and triggered for any recordset clones generated using the Clone method.

Event | Triggered in clones?
EndOfRecordset | No
FetchComplete | No
FetchProgress | No
FieldChangeComplete | Yes
MoveComplete | No
RecordChangeComplete | Yes
RecordsetChangeComplete | No
WillChangeField | Yes
WillChangeRecord | Yes
WillChangeRecordset | No
WillMove | No


The object cannot be replicated because the database is not replicated. (Error 3485)

 Copy code hover
[image]

The object cannot be replicated because the database is not replicated. (Error 3485)
Send feedback

You cannot replicate an object in a database unless you first replicate the database that contains it. You can replicate the database by:

  • Dragging it into the Microsoft Windows Briefcase.

  • Using DAO programming to set the Replicable property to "T" or the ReplicableBool property to True.

  • Using Microsoft Access.

  • Using the Replication Manager.

All objects in the database are replicated when the database is replicated, unless the KeepLocal property has been set on an object.


TableDef.Fields Property (DAO)

 Copy code hover
[image]

TableDef.Fields Property (DAO)
Send feedback

Returns a Fields collection that represents all stored Field objects for the specified object. Read-only.

Syntax

expression .Fields

expression A variable that represents a TableDef object.


Form.AllowFilters Property (Access)

 Copy code hover
[image]

Form.AllowFilters Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllowFilters property to specify whether records in a form can be filtered. Read/write Boolean.

Syntax

expression .AllowFilters

expression A variable that represents a Form object.

Remarks

Filters are commonly used to view a temporary subset of the records in a database. When you use a filter, you apply criteria to display only records that meet specific conditions. In an Employees form, for example, you can use a filter to display only records of employees with over 5 years of service. You can also use a filter to restrict access to records containing sensitive information, such as financial or medical data.

Note Note

Setting the AllowFilters property to No does not affect the Filter , FilterOn , ServerFilter , or ServerFilterByForm properties. You can still use these properties to set and remove filters. You can also still use the following actions or methods to apply and remove filters.

Actions | Methods
ApplyFilter | ApplyFilter
OpenForm | OpenForm
ShowAllRecords | ShowAllRecords

See also

Concepts

Form Object

Other resources

Form Object Members


ObjectFrame.OLETypeAllowed Property (Access)

 Copy code hover
[image]

ObjectFrame.OLETypeAllowed Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OLETypeAllowed property to specify the type of OLE object a control can contain. Read/write Byte.

Syntax

expression .OLETypeAllowed

expression A variable that represents an ObjectFrame object.

Remarks

The OLETypeAllowed property uses the following settings.

Setting | Constant | Description
Linked | acOLELinked | The control can contain only a linked object.
Embedded | acOLEEmbedded | The control can contain only an embedded object.
Either | acOLEEither | (Default) The control can contain either a linked or an embedded object.
Note Note

For unbound object frames and charts , you can't change the OLETypeAllowed setting after an object is created. For bound object frames, you can change the setting after the object is created. Changing the OLETypeAllowed property setting only affects new objects that you add to the control.

To determine the type of OLE object a control already contains, you can use the OLEType property.

Example

The following example creates a linked OLE object using an unbound object frame named OLE1 and sizes the control to display the object's entire contents when the user clicks a command button.

VBA Copy code Copy code
Sub Command1_Click
 OLE1.Class = "Excel.Sheet" ' Set class name.
 ' Specify type of object.
 OLE1.OLETypeAllowed = acOLELinked
 ' Specify source file.
 OLE1.SourceDoc = "C:\Excel\Oletext.xls"
 ' Specify data to create link to.
 OLE1.SourceItem = "R1C1:R5C5"
 ' Create linked object.
 OLE1.Action = acOLECreateLink
 ' Adjust control size.
 OLE1.SizeMode = acOLESizeZoom
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


OptionButton.SetFocus Method (Access)

 Copy code hover
[image]

OptionButton.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Syntax

expression .SetFocus

expression A variable that represents an OptionButton object.

Return Value

Nothing

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.

Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.

Example

The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:

VBA Copy code Copy code
Forms!Employees!EmployeeID.SetFocus

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


PageBreak Methods (Access)

 Copy code hover
[image]

PageBreak Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.


ListBox.AllowValueListEdits Property (Access)

 Copy code hover
[image]

ListBox.AllowValueListEdits Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the Edit List Items command is available when the user right-clicks a list box. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .AllowValueListEdits

expression A variable that represents a ListBox object.

Remarks

The AllowValueEditLists property determines whether the Edit List Items command is available when the user right-clicks a list box that's bound to a Lookup field.

If the Lookup field is bound to a list of values, then the Edit List Items dialog box is displayed when the user clicks Edit List Items. The user can then add, delete, or edit the items to be displayed in the list box.

If the Lookup field is bound to a table or query, then the form specified by the ListItemsEditForm property is diplayed when the user clicks Edit List Items. The user can use the form to add, delete, or edit the items to be displayed in the list box.

The AllowValueEditLists property is not available for list boxes on a report.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Reports.Parent Property (Access)

 Copy code hover
[image]

Reports.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a Reports object.

See also

Concepts

Reports Collection

Other resources

Reports Object Members


Write Method (ADO)

 Copy code hover
[image]

Write Method (ADO)
Send feedback

Writes binary data to a Stream object.

Syntax

Stream.Write Buffer

Parameters

  • Buffer

  • A Variant that contains an array of bytes to be written.

Remarks

Specified bytes are written to the Stream object without any intervening spaces between each byte.

The current Position is set to the byte following the written data. The Write method does not truncate the rest of the data in a stream. If you want to truncate these bytes, call SetEOS.

If you write past the current EOS position, the Size of the Stream will be increased to contain any new bytes, and EOS will move to the new last byte in the Stream.

Note Note

The Write method is used with binary streams (Type is adTypeBinary). For text streams (Type is adTypeText), use WriteText.


NavigationControl.BackTint Property (Access)

 Copy code hover
[image]

NavigationControl.BackTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackTint

expression A variable that represents a NavigationControl object.

Remarks

The BackTint property contains a numeric expression that can be used to lighten the theme color in the BackColor property. The default value of the BackTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BackColor by 75%.

VBA Copy code Copy code
Me.ctl.BackTint=25

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Cannot append a relation with no fields defined. (Error 3366)

 Copy code hover
[image]

Cannot append a relation with no fields defined. (Error 3366)
Send feedback

You are trying to append a Relation object to a Relations collection, but the Relation object has no fields.

To correctly append a Relation

  1. Use the CreateRelation method to create the Relation object. Set the Table, ForeignTable, and Attributes properties of the Relation object, if you did not specify them as arguments to the CreateRelation method. Use the CreateField method to create a new Field object for each field in the primary and foreign keys of the relationship.

  2. Set the Name (if you did not specify it as an argument to the CreateField method) and ForeignName properties of the Field object or objects to the corresponding Name property settings of the primary key and the foreign key Field objects of each field in the relationship.

  3. Use the Append method to save the Field object or objects in the Fields collection of the Relation object.

  4. Use the Append method to save the Relation object in the Relations collection of the database.


Report.TextHeight Method (Access)

 Copy code hover
[image]

Report.TextHeight Method (Access)
See also Send feedback

Published: July 16, 2012

The TextHeight method returns the height of a text string as it would be printed in the current font of a Report object.

Syntax

expression .TextHeight(Expr)

expression A variable that represents a Report object.

Parameters

Name | Required/Optional | Data Type | Description
Expr | Required | String | The text string for which the text height will be determined.

Return Value

Single

Remarks

You can use the TextHeight method to determine the amount of vertical space a text string will require in the current font when the report is formatted and printed. For example, a text string formatted in 9-point Arial will require a different amount of space than one formatted in 12-point Courier. To determine the current font and font size for text in a report, check the settings for the report's FontName and FontSize properties.

The value returned by the TextHeight method is expressed in terms of the coordinate system in effect for the report, as defined by the Scale method. You can use the ScaleMode property to determine the coordinate system currently in effect for the report.

If the strexpr argument contains embedded carriage returns, the TextHeight method returns the cumulative height of the lines, including the leading space above and below each line. You can use the value returned by the TextHeight method to calculate the necessary space and positioning for multiple lines of text within a report.

Example

The following example uses the TextHeight and TextWidth methods to determine the amount of vertical and horizontal space required to print a text string in the report's current font.

To try this example in Microsoft Access, create a new report. Set the OnPrint property of the Detail section to [Event Procedure]. Enter the following code in the report's module, then switch to Print Preview.

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, _
 PrintCount As Integer)
 ' Set unit of measure to twips (default scale).
 Me.Scalemode = 1
 ' Print name and font size of report font.
 Debug.Print "Report Font: "; Me.FontName
 Debug.Print "Report Font Size: "; Me.FontSize
 ' Print height and width required for text string.
 Debug.Print "Text Height (Twips): "; _
 Me.TextHeight("Product Report")
 Debug.Print "Text Width (Twips): "; _
 Me.TextWidth("Product Report")
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


Rectangle.MouseUp Event (Access)

 Copy code hover
[image]

Rectangle.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents a Rectangle object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was released to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


CustomControl.SpecialEffect Property (Access)

 Copy code hover
[image]

CustomControl.SpecialEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.

Syntax

expression .SpecialEffect

expression A variable that represents a CustomControl object.

Remarks

The SpecialEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | 0 | The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised | 1 | The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken | 2 | The object has a shadow on the top and left and a highlight on the bottom and right.
Etched | 3 | The object has a sunken line surrounding the control.
Shadowed | 4 | The object has a shadow below and to the right of the control.
Chiseled | 5 | The object has a sunken line below the control.

The SpecialEffect property setting affects related property settings for the BorderStyle , BorderColor , and BorderWidth properties. For example, if the SpecialEffect property is set to Raised, the settings for the BorderStyle, BorderColor, and BorderWidth properties are ignored. In addition, changing or setting the BorderStyle, BorderColor, and BorderWidth properties may cause Microsoft Access to change the SpecialEffect property setting to Flat.

Example

The following example sets the appearance of the text box "OrganizationName1" on the "Mailing List" form to raised.

VBA Copy code Copy code
Forms("Mailing List").Controls("OrganizationName1").SpecialEffect = 1

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Recordset2.Cancel Method (DAO)

 Copy code hover
[image]

Recordset2.Cancel Method (DAO)
Send feedback

Syntax

expression .Cancel

expression An expression that returns a Recordset2 object.

Remarks

Use the Cancel method to terminate execution of an asynchronous Execute or OpenConnection method call (that is, the method was invoked with the dbRunAsync option). Cancel will return a run-time error if dbRunAsync was not used in the method you're trying to terminate.


Application.DirtyObject Method (Access)

 Copy code hover
[image]

Application.DirtyObject Method (Access)
See also Send feedback

Published: July 16, 2012

Marks a form or report as dirty.

Version Information

Version Added: Access 2010

Syntax

expression .DirtyObject(ObjectType, ObjectName)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
ObjectType | Required | AcObjectType | Specifies the type of object to mark as dirty. This argument should be set to acForm or acReport.
ObjectName | Required | String | Specifies the name of the object to mark as dirty.

Remarks

The DirtyObject method is useful when you are modifying a form or report in a Web database programmatically. When you do this, Microsoft Access does not automatically detect that the form or report has changed, which may cause you to lose the changes when you save and close the object. If you use the DirtyObject method to specify that the form or report has been changed, then the changes will be saved when you save the form or report.

A run-time error will occur if the form or report specified by the ObjectName argument is not open.

See also

Concepts

Application Object

Other resources

Application Object Members


GoToControl Macro Action

 Copy code hover
[image]

GoToControl Macro Action
Send feedback

You can use the GoToControl action to move the focus to the specified field or control in the current record of the open form, form datasheet, table datasheet, or query datasheet. You can use this action when you want a particular field or control to have the focus. This field or control can then be used for comparisons or FindRecord actions. You can also use this action to navigate in a form according to certain conditions. For example, if the user enters No in a Married control on a health insurance form, the focus can automatically skip the Spouse/partner Name control and move to the next control.

Setting

Note Note

This action is not available for use with data access pages.

The GoToControl action has the following argument.

Action argument

Description

Control Name

The name of the field or control where you want the focus. Enter the field or control name in the Control Name box in the Action Arguments section of the Macro Builder pane. This is a required argument.

Note Note

Enter only the name of the field or control in the Control Name argument, not the fully qualified identifier, such as Forms!Products![Product ID].

Remarks

You cannot use the GoToControl action to move the focus to a control on a hidden form.

Tip Tip

You can use the GoToControl action to move to a subform, which is a type of control. You can then use the GoToRecord action to move to a particular record in the subform. You can also move to a control on a subform by using the GoToControl action to move first to the subform and then to the control on the subform.

To run the GoToControl action in a Visual Basic for Applications (VBA) module, use the GoToControl method of the DoCmd object. You can also use the SetFocus method to move the focus to a control on a form or any of its subforms, or to a field in an open table, query, or form datasheet.

Examples

Set the value of a control by using a macro

The following macro opens the Add Products form from a button on the Suppliers form. It shows the use of the Echo, CloseWindow, OpenForm, SetValue, and GoToControl actions. The SetValue action sets the Supplier ID control on the Products form to the current supplier on the Suppliers form. The GoToControl action then moves the focus to the Category ID field, where you can begin to enter data for the new product. This macro should be attached to the Add Products button on the Suppliers form.

Action | Arguments: Setting | Comment
Echo | Echo On: No | Stop screen updating while the macro is running.
CloseWindow | Object Type: FormObject Name: Product List Save: No | Close Product List form.
OpenForm | Form Name: Products View: FormData Mode: AddWindow Mode: Normal | Open the Products form.
SetValue | Item: [Forms]![Products]![SupplierID] Expression: SupplierID | Set the Supplier ID control to the current supplier on the Suppliers form.
GoToControl | Control Name: CategoryID | Go to the Category ID control.

Validate data by using a macro

The following validation macro checks the postal codes entered in a Suppliers form. It shows the use of the StopMacro, MessageBox, CancelEvent, and GoToControl actions. A conditional expression checks the country/region and postal code entered in a record on the form. If the postal code is not in the right format for the country/region, the macro displays a message box and cancels saving the record. The macro then returns you to the Postal Code control, where you can correct the error. This macro should be attached to the BeforeUpdate property of the Suppliers form.

Condition | Action | Arguments: Setting | Comment
IsNull([CountryRegion]) | StopMacro |  | If CountryRegion is Null, postal code cannot be validated.
[CountryRegion] In ("France","Italy","Spain") And Len([Postal Code]) <> 5 | MessageBox | Message: The postal code must be 5 characters. Beep: YesType: InformationTitle: Postal Code Error | If the postal code is not 5 characters, display a message.
... | CancelEvent |  | Cancel the event.
 | GoToControl | Control Name: PostalCode |
[CountryRegion] In ("Australia","Singapore") And Len([Postal Code]) <> 4 | MessageBox | Message: The postal code must be 4 characters. Beep: YesType: InformationTitle: Postal Code Error | If the postal code is not 4 characters, display a message.
... | CancelEvent |  | Cancel the event.
 | GoToControl | Control Name: PostalCode |
([CountryRegion] = "Canada") And ([Postal Code] Not Like"[A-Z][0-9][A-Z] [0-9][A-Z][0-9]") | MessageBox | Message: The postal code is not valid. Example of Canadian code: H1J 1C3 Beep: YesType: InformationTitle: Postal Code Error | If the postal code is not correct for Canada, display a message. (Example of Canadian code: H1J 1C3)
... | CancelEvent |  | Cancel the event.


DoCmd.RunSavedImportExport Method (Access)

 Copy code hover
[image]

DoCmd.RunSavedImportExport Method (Access)
See also Send feedback

Published: July 16, 2012

Rrun a saved import or export specification.

Version Information

Version Added: Access 2007

Syntax

expression .RunSavedImportExport(SavedImportExportName)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
SavedImportExportName | Required | Variant | The name of a saved import or export specification to run.

Remarks

This method has the same effect as performing the following procedure in Access:

  1. On the External Data tab, click either Saved Imports or Saved Exports.

  2. In the Manage Data Tasks dialog box, on the Saved Imports or Saved Exports tab (depending on your choice in the preceding step), click the specification that you want to run.

  3. Click Run.

Before running the RunSavedImportExport method, make sure that the source and destination files exist, the source data is ready for importing, and that the operation will not accidentally overwrite any data in your destination file.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Field2.CollatingOrder Property (DAO)

 Copy code hover
[image]

Field2.CollatingOrder Property (DAO)
Send feedback

Returns a value that specifies the sequence of the sort order in text for string comparison or sorting (Microsoft Access workspaces only). Read-only Long.

Syntax

expression .CollatingOrder

expression A variable that represents a Field2 object.

Remarks

The return value is a Long value or constant that can be one of the following values.

Constant | Sort order
dbSortGeneral | General (English, French, German, Portuguese, Italian, and Modern Spanish)
dbSortArabic | Arabic
dbSortChineseSimplified | Simplified Chinese
dbSortChineseTraditional | Traditional Chinese
dbSortCyrillic | Russian
dbSortCzech | Czech
dbSortDutch | Dutch
dbSortGreek | Greek
dbSortHebrew | Hebrew
dbSortHungarian | Hungarian
dbSortIcelandic | Icelandic
dbSortJapanese | Japanese
dbSortKorean | Korean
dbSortNeutral | Neutral
dbSortNorwDan | Norwegian or Danish
dbSortPDXIntl | Paradox International
dbSortPDXNor | Paradox Norwegian or Danish
dbSortPDXSwe | Paradox Swedish or Finnish
dbSortPolish | Polish
dbSortSlovenian | Slovenian
dbSortSpanish | Spanish
dbSortSwedFin | Swedish or Finnish
dbSortThai | Thai
dbSortTurkish | Turkish
dbSortUndefined | Undefined or unknown

The availability of the CollatingOrder property depends on the object that contains the Fields collection, as shown in the following table.

If the Fields collection belongs to an | Then CollatingOrder is
Index object | Not supported
QueryDef object | Read-only
Recordset object | Read-only
Relation object | Not supported
TableDef object | Read-only

The CollatingOrder property setting corresponds to the locale argument of the CreateDatabase method when the database was created or the CompactDatabase method when the database was most recently compacted.

The CollatingOrder and Attributes property settings of a Field2 object in a Fields collection of an Index object together determine the sequence and direction of the sort order in an index. However, you can't set a collating order for an individual index— you can only set it for an entire table.


Var Function (Access 2013 custom web app)

 Copy code hover
[image]

Var Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the statistical variance for a population sample represented as a set of values contained in a specified field in a query.

Syntax

Var(NumericExpression)

The Var function contains the following argument.

Argument name | Description
NumericExpression | A text expression identifying the field that contains the numeric data you want to evaluate or an expression that performs a calculation using the data in that field. Operands in NumericExpression can include the name of a table field, a constant, or a function (which can be either intrinsic or user-defined but not one of the other SQL aggregate functions).

Remarks

Var can be used with numeric columns only. Null values are ignored.


IsolationLevel and Mode Properties Example (VJ++)

 Copy code hover
[image]

IsolationLevel and Mode Properties Example (VJ++)
Send feedback

This example uses the Mode property to open an exclusive connection, and the IsolationLevel property to open a transaction that is conducted in isolation of other transactions.

Copy code Copy code

// BeginIsolationLevelJ
import com.ms.wfc.data.*;
import java.io.*;

public class IsolationLevelX
{
 // The main entry point for the application.
 public static void main (String[] args)
 {
 IsolationLevelX();
 System.exit(0);
 }

 // IsolationLevelX Function

 static void IsolationLevelX()
 {
 // Define ADO Objects
 Connection cnn1 = null;
 Recordset rstTitles = null;

 // Assign connection string to variable
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"+
 "Initial Catalog='Pubs';Integrated Security='SSPI';";

 // Declarations
 BufferedReader in =
 new BufferedReader ( new InputStreamReader(System.in));
 String line = null;

 try
 {
 // Open connection and Titles table
 cnn1 = new Connection();

 cnn1.setMode(AdoEnums.ConnectMode.SHAREEXCLUSIVE);
 cnn1.setIsolationLevel(AdoEnums.IsolationLevel.ISOLATED);
 cnn1.open(strCnn);

 rstTitles = new Recordset();
 rstTitles.setCursorType(AdoEnums.CursorType.DYNAMIC);
 rstTitles.setLockType(AdoEnums.LockType.PESSIMISTIC);
 rstTitles.open("Titles", cnn1, AdoEnums.CursorType.DYNAMIC,
 AdoEnums.LockType.PESSIMISTIC);

 cnn1.beginTrans();

 // Display the connection mode
 if (cnn1.getMode() == AdoEnums.ConnectMode.SHAREEXCLUSIVE)
 System.out.println("\n\tConnection mode is exclusive");
 else
 System.out.println("\n\tConnection mode is not exclusive");
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();

 // Display the Isolation level
 if ( cnn1.getIsolationLevel() == AdoEnums.IsolationLevel.ISOLATED)
 System.out.println("\tTransaction is Isolated\n");
 else
 System.out.println("\tTransaction is not Isolated\n");
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();

 // Change the type of psychology titles
 while(!rstTitles.getEOF())
 {

 if(rstTitles.getField("Type").getString().trim().
 equals(new String("psychology")))
 {
 rstTitles.getField("Type").setString("self_help");
 rstTitles.update();
 }
 rstTitles.moveNext();

 }

 // Print current data in recordset
 rstTitles.requery();
 while(!rstTitles.getEOF())
 {
 System.out.println(rstTitles.getField("Title").getString() +
 " - " + rstTitles.getField("Type").getString() );
 rstTitles.moveNext();
 }
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();

 // Restore original data
 cnn1.rollbackTrans();
 }
 catch(AdoException ae)
 {
 // Notify the user of any errors that result from ADO

 // As passing a connection, check for null pointer first
 if(cnn1 !=null)
 {
 PrintProviderError(cnn1);
 }
 else
 {
 System.out.println("Exception:" + ae.getLocalizedMessage());
 }
 }

 // System Read requires this catch
 catch(java.io.IOException je)
 {
 PrintIOError(je);

 }

 finally
 {
 // Cleanup objects before exit.
 if (rstTitles != null)
 if (rstTitles.getState() == 1)
 rstTitles.close();
 if (cnn1 != null)
 if (cnn1.getState() == 1)
 cnn1.close();
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndIsolationLevelJ


TableDefs Object Reference (DAO)

 Copy code hover
[image]

TableDefs Object Reference (DAO)
Send feedback

In this section

  • TableDefs Collection (DAO)

  • TableDefs Members (DAO)

  • TableDefs Properties (DAO)

  • TableDefs Methods (DAO)


Persisting Data

 Copy code hover
[image]

Persisting Data
Send feedback

Portable computing (for example, using laptops) has generated the need for applications that can run in both a connected and disconnected state. ADO has added support for this by giving the developer the ability to save a client cursor Recordset to disk and reload it later.

There are several scenarios in which you could use this type of feature, including the following:

  • Traveling: When taking the application on the road, it is vital to supply the ability to make changes and add new records that can then be reconnected to the database later and committed.

  • Infrequently updated lookups: Often in an application, tables are used as lookups — for example, state tax tables. They are infrequently updated and are read-only. Instead of rereading this data from the server each time the application is started, the application can simply load the data from a locally persisted Recordset.

In ADO, to save and load Recordsets, use the Recordset.Save and Recordset.Open(,,,,adCmdFile) methods on the ADO Recordset object.

You can use the Recordset Save method to persist your ADO Recordset to a file on a disk. (You can also save a Recordset to an ADO Stream object. Stream objects are discussed later in the guide.) Later, you can use the Open method to reopen the Recordset when you are ready to use it. By default, ADO saves the Recordset into the proprietary Microsoft Advanced Data TableGram (ADTG) format. This binary format is specified using the adPersistADTG PersistFormatEnum value. Alternatively, you may choose to save your Recordset out as XML instead using adPersistXML. For more information about saving Recordsets as XML, see Persisting Records in XML Format.

The syntax of the Save method is as follows:

Copy code Copy code
                      recordset.
                      Save
                      Destination, PersistFormat

The first time you save the Recordset, it is optional to specify Destination. If you omit Destination, a new file will be created with a name set to the value of the Source property of the Recordset.

Omit Destination when you subsequently call Save after the first save or a run-time error will occur. If you subsequently call Save with a new Destination, the Recordset is saved to the new destination. However, the new destination and the original destination will both be open.

Save does not close the Recordset or Destination, so you can continue to work with the Recordset and save your most recent changes. Destination remains open until the Recordset is closed, during which time other applications can read but not write to Destination.

For reasons of security, the Save method permits only the use of low and custom security settings from a script executed by Microsoft Internet Explorer. For a more detailed explanation of security issues, see "ADO and RDS Security Issues in Microsoft Internet Explorer" under ActiveX Data Objects (ADO) Technical Articles in Microsoft Data Access Technical Articles.

If the Save method is called while an asynchronous Recordset fetch, execute, or update operation is in progress, Save waits until the asynchronous operation is complete.

Records are saved beginning with the first row of the Recordset. When the Save method is finished, the current row position is moved to the first row of the Recordset.

For best results, set the CursorLocation property to adUseClient with Save. If your provider does not support all of the functionality necessary to save Recordset objects, the Cursor Service will provide that functionality.

When a Recordset is persisted with the CursorLocation property set to adUseServer, the update capability for the Recordset is limited. Typically, only single-table updates, insertions, and deletions are allowed (dependent on provider functionality). The Resync method is also unavailable in this configuration.

Because the Destination parameter can accept any object that supports the OLE DB IStream interface, you can save a Recordset directly to the ASP Response object.

In the following example, the Save and Open methods are used to persist a Recordset and later reopen it:

Copy code Copy code

'BeginPersist
 conn.ConnectionString = _
 "Provider='SQLOLEDB';Data Source='MySqlServer';" _
 & "Integrated Security='SSPI';Initial Catalog='pubs'"
 conn.Open

 conn.Execute "create table testtable (dbkey int " & _
 "primary key, field1 char(10))"
 conn.Execute "insert into testtable values (1, 'string1')"

 Set rst.ActiveConnection = conn
 rst.CursorLocation = adUseClient

 rst.Open "select * from testtable", conn, adOpenStatic, _
 adLockBatchOptimistic

 'Change the row on the client
 rst!field1 = "NewValue"

 'Save to a file--the .dat extension is an example; choose
 'your own extension. The changes will be saved in the file
 'as well as the original data.
 MyFile = Dir("c:\temp\temptbl.dat")
 If MyFile <> "" Then
 Kill "c:\temp\temptbl.dat"
 End If

 rst.Save "c:\temp\temptbl.dat", adPersistADTG
 rst.Close
 Set rst = Nothing

 'Now reload the data from the file
 Set rst = New ADODB.Recordset
 rst.Open "c:\temp\temptbl.dat", , adOpenStatic, _
 adLockBatchOptimistic, adCmdFile

 Debug.Print "After Loading the file from disk"
 Debug.Print " Current Edited Value: " & rst!field1.Value
 Debug.Print " Value Before Editing: " & rst!field1.OriginalValue

 'Note that you can reconnect to a connection and
 'submit the changes to the data source
 Set rst.ActiveConnection = conn
 rst.UpdateBatch
'EndPersist


Application.CurrentWebUser Method (Access)

 Copy code hover
[image]

Application.CurrentWebUser Method (Access)
See also Send feedback

Published: July 16, 2012

Gets information about the current user of a Web database on Microsoft SharePoint Foundation 2010.

Version Information

Version Added: Access 2010

Syntax

expression .CurrentWebUser(DisplayOption)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
DisplayOption | Required | AcWebUserDisplay | Specifies the type of information to return about the user.

Return Value

Variant

Remarks

The CurrentWebUser method returns Null if the database has not been published, or information about the current user cannot be retrieved.

See also

Concepts

Application Object

Other resources

Application Object Members


OptionGroup.DefaultValue Property (Access)

 Copy code hover
[image]

OptionGroup.DefaultValue Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.

Syntax

expression .DefaultValue

expression A variable that represents an OptionGroup object.

Remarks

The DefaultValue property applies to all table fields except those fields with the data type of AutoNumber or OLE Object.

The DefaultValue property specifies text or an expression that's automatically entered in a control or field when a new record is created. For example, if you set the DefaultValue property for a text box control to =Now(), the control displays the current date and time. The maximum length for a DefaultValue property setting is 255 characters.

The DefaultValue property doesn't apply to check box, option button, or toggle buttoncontrols when they are in an option group. It does however apply to the option group itself.

In Visual Basic, use a string expression to set the value of this property. For example, the following code sets the DefaultValue property for a text box control named PaymentMethod to "Cash"

VBA Copy code Copy code
Forms!frmInvoice!PaymentMethod.DefaultValue = """Cash"""
Note Note

To set this property for a field by using Visual Basic, use the ADO DefaultValue property or the DAO DefaultValue property.

The DefaultValue property is applied only when you add a new record. If you change the DefaultValue property, the change isn't automatically applied to existing records.

If you set the DefaultValue property for a form control that's bound to a field that also has a DefaultValue property setting defined in the table, the control setting overrides the table setting.

If you create a control by dragging a field from the field list, the field's DefaultValue property setting, as defined in the table, is applied to the control on the form although the control's DefaultValue property setting will remain blank.

One control can provide the default value for another control. For example, if you set the DefaultValue property for a control to the following expression, the control's default value is set to the DefaultValue property setting for the txtShipTo control.

VBA Copy code Copy code
=Forms!frmInvoice!txtShipTo

If the controls are on the same form, the control that's the source of the default value must appear earlier in the tab order than the control containing the expression.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Rectangle.OnMouseDown Property (Access)

 Copy code hover
[image]

Rectangle.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Syntax

expression .OnMouseDown

expression A variable that represents a Rectangle object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


BoundObjectFrame.TopPadding Property (Access)

 Copy code hover
[image]

BoundObjectFrame.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the object frame and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .TopPadding

expression A variable that represents a BoundObjectFrame object.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


AcSplitFormDatasheet Enumeration (Access)

 Copy code hover
[image]

AcSplitFormDatasheet Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the SplitFormDatasheet property to specify whether the user can edit contents of the datasheet while a form is displayed in Split Form view.

Version Information

Version Added: Access 2007

Name | Value | Description
acDatasheetAllowEdits | 0 | The user can edit the contents of the datasheet.
acDatasheetReadOnly | 1 | The user cannot edit the contents of the datasheet.


RunCode Macro Action

 Copy code hover
[image]

RunCode Macro Action
Send feedback

You can use the RunCode action to call a Visual Basic for Applications (VBA) Function procedure.

Setting

The RunCode action has the following argument.

Action argument

Description

Function Name

The name of the VBA Function procedure to call. Enclose any function arguments in parentheses. Enter the function name in the Function Name box in the Action Arguments section of the Macro Builder pane. This is a required argument.

Note Note

In an Access database (.mdb or .accdb), click the Build button to use the Expression Builder to select a function for this argument. Click the desired function in the list in the Expression Builder.

Remarks

The user-defined Function procedures are stored in Microsoft Access modules.

You must include parentheses, even if the Function procedure doesn't have any arguments, as in the following example:

Copy code Copy code
TestFunction()

Unlike user-defined function names used for event property settings, the function name in the Function Name argument doesn't begin with an equal sign (=).

Access ignores the return value of the function.

Note Note

You can't call a Function procedure from a macro if the function name is the same as the module name.
Tip Tip

To run a Sub procedure or event procedure written in Visual Basic, create a Function procedure that calls the Sub procedure or event procedure. Then use the RunCode action to run the Function procedure.

If you use the RunCode action to call a function, Access looks for the function with the name specified by the Function Name argument in the standard modules for the database. However, when this action runs in response to clicking a menu command on a form or report or in response to an event on a form or report, Access first looks for the function in the form's or report's class module and then in the standard modules. Access doesn't search the class modules that appear in the Modules area of the Navigation Pane for the function specified by the Function Name argument.

This action isn't available in a VBA module. Instead, run the desired Function procedure directly in VBA.


Form.OnMouseDown Property (Access)

 Copy code hover
[image]

Form.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Syntax

expression .OnMouseDown

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

Form Object

Other resources

Form Object Members


ODBC - connection to

 Copy code hover
[image]

ODBC - connection to <name> failed. (Error 3151)
Send feedback

The ODBC connection to the specified ODBC database or table could not be made. If the ODBC database is accessed via a network connection, make sure the network is available, and then try the operation again.


Initializing the Text Data Source Driver

 Copy code hover
[image]

Initializing the Text Data Source Driver
Send feedback

The same database driver is used for both Text Data sources and for HTML data sources.

When you install the Text Data Source database driver, the Setup program writes a set of default values to the Microsoft® Windows® Registry in the Engines and ISAM Formats subkeys. You should not modify these settings directly; use the setup program for your application to add, remove, or change these settings. The following sections describe initialization and ISAM Format settings for the Text Data Source database driver.

Text Data Source Initialization Settings

The Access Connectivity Engine\ISAM Formats\Text folder includes initialization settings for the Acetxt.dll driver, used for external access to text data files. Typical settings for the entries in this folder are shown in the following example.

Copy code Copy code
win32=<path>\ ACETXT.DLL

MaxScanRows=25

FirstRowHasNames=True

CharacterSet= ANSI

Format=CSVDelimited

Extensions= txt,csv,tab,asc

ExportCurrencySymbols=Yes

The Microsoft Access database engine uses the Text folder entries as follows.

Entry

Description

win32

The location of Acetxt.dll. The full path is determined at the time of installation. Values are of type REG_SZ.

MaxScanRows

The number of rows to be scanned when guessing the column types. If set to 0, the entire file will be searched. The default is 25. Values are of type REG_DWORD.

FirstRowHasNames

A binary value that indicates whether the first row of the table contains column names. A value of 01 indicates that, during import, column names are taken from the first row.

CharacterSet

An indicator of how text pages are stored. Possible settings are:

  • ANSI — The ANSI code page of the machine. AnsiToUnicode and UnicodeToAnsi conversions done.

  • OEM — The OEM code page of the machine. OemToUnicode and UnicodeToOem conversions done.

  • Unicode — codepage conversions not done.

  • <decimal number> — The code page number of a specific character set. Conversions to and from Unicode will be done.

The default is ANSI. Values are of type REG_SZ.

Format

Can be any of the following: TabDelimited, CSVDelimited, Delimited (<single character>). The single-character delimiter in the Delimited format can be any single character except a double quotation mark ("). The default is CSVDelimited. Values are of type REG_SZ.

Extensions

The extension of any files to be browsed when looking for text-based data. The default is txt, csv, tab, asc. Values are of type REG_SZ.

ExportCurrencySymbols

A binary value that indicates whether the appropriate currency symbol is included when currency fields are exported. A value of 01 indicates that the symbol is included. A value of 00 indicates that only the numeric data is exported. The default is 01. Values are of type REG_BINARY.

Text Data Source ISAM Formats

The Access Connectivity Engine\ISAM Formats\Text folder contains the following entries.

Entry name | Type | Value
Engine | REG_SZ | Text
ExportFilter | REG_SZ | Text Files (*.txt; *.csv; *.tab; *.asc)
ImportFilter | REG_SZ | Text Files (*.txt; *.csv; *.tab; *.asc)
CanLink | REG_BINARY | 01
OneTablePerFile | REG_BINARY | 01
IsamType | REG_DWORD | 2
IndexDialog | REG_BINARY | 00
CreateDBOnExport | REG_BINARY | 00
ResultTextImport | REG_SZ | Import data from the external file into the current database. Changing data in the current database will not change data in the external file.
ResultTextLink | REG_SZ | Create a table in the current database that is linked to the external file. Changing data in the current database will change data in the external file.
ResultTextExport | REG_SZ | Export data from the current database into a text file. This process will overwrite the data if exported to an existing file.
SupportsLongNames | REG_BINARY | 01
Note Note

When you change Windows Registry settings, you must exit and then restart the database engine for the new settings to take effect.

HTML Import ISAM Formats

The Access Connectivity Engine\ISAM Formats\HTML Import folder contains the following entries.

Entry name | Type | Value
Engine | REG_SZ | Text
ImportFilter | REG_SZ | HTML Files (*.ht*)
CanLink | REG_BINARY | 01
OneTablePerFile | REG_BINARY | 00
IsamType | REG_DWORD | 2
IndexDialog | REG_BINARY | 00
CreateDBOnExport | REG_BINARY | 00
ResultTextImport | REG_SZ | Import data from the external file into the current database. Changing data in the current database will not change data in the external file.
ResultTextLink | REG_SZ | Create a table in the current database that is linked to the external file. Changing data in the current database will change data in the external file.
SupportsLongNames | REG_BINARY | 01
Note Note

When you change Windows Registry settings, you must exit and then restart the database engine for the new settings to take effect.

HTML Export ISAM Formats

The Access Connectivity Engine\ISAM Formats\HTML Export folder contains the following entries.

Entry name | Type | Value
Engine | REG_SZ | Text
ExportFilter | REG_SZ | HTML Files (*.htm)
CanLink | REG_BINARY | 00
OneTablePerFile | REG_BINARY | 01
IsamType | REG_DWORD | 2
IndexDialog | REG_BINARY | 00
CreateDBOnExport | REG_BINARY | 00
ResultTextExport | REG_SZ | Export data from the current database into a text file. This process will overwrite the data if exported to an existing file.
SupportsLongNames | REG_BINARY | 01
Note Note

When you change Windows Registry settings, you must exit and then restart the database engine for the new settings to take effect.

Customizing the Schema.ini File for Text and HTML Data

To read, import, or export text and HTML data, you need to create a Schema.ini file in addition to including the Text ISAM information in the .ini file. Schema.ini contains the specifics of a data source: how the text file is formatted, how it is read at import time, and what the default export format is for files. The following examples show the layout for a fixed-width file, Filename.txt:

Copy code Copy code
[Filename.txt]

ColNameHeader=False

Format=FixedLength

FixedFormat= RaggedEdge

MaxScanRows=25

CharacterSet=OEM

Col1=columnname Char Width 24

Col2=columnname2 Date Width 9

Col3=columnname7 Float Width 10

Col4=columnname8 Integer Width 10
Col5=columnname9 LongChar Width 10

Similarly, the format for a delimited file is specified as follows:

Copy code Copy code
[Delimit.txt]

ColNameHeader=True

Format=Delimited()

MaxScanRows=0

CharacterSet=OEM

Col1=username char width 50

Col2=dateofbirth Date width 9

If you are exporting data into a delimited text file, specify the format for that file as well:

Copy code Copy code
[Export: My Special Export]

ColNameHeader=True

Format=TabDelimited

MaxScanRows=25

CharacterSet=OEM

DateTimeFormat=mm.dd.yy.hh.mm.ss

CurrencySymbol=Dm

CurrencyPosFormat=0

CurrencyDigits=2

CurrencyNegFormat=0

CurrencyThousandSymbol=,

CurrencyDecimalSymbol=.

DecimalSymbol=,

NumberDigits=2

NumberLeadingZeros=0

TextDelimeter="

The My Special Export example refers to a specific export option; you can specify any variation of export options at connect time. This last example also corresponds to a data source name (DSN) that can be optionally passed at connect time. All three format sections can be included in the same .ini file.

The Microsoft Access database engine uses the Schema.ini entries as follows.

Entry | Description
ColNameHeader | Can be set to either True (indicating that the first record of data specifies the column names) or False.
Format | Can be set to one of the following values: TabDelimited, CSVDelimited, Delimited (<single character>), or FixedLength. The delimiter specified for the Delimited file format can be any single character except a double quotation mark (").
FixedFormat | Only used when the Format is FixedLength, this can be set to one of the following values: RaggedEdge or TrueFixedLength. RaggedEdge allows rows to be terminated with a Carriage Return character. TrueFixedLength requires each row to be an exact number of characters, and any Carriage Return characters not at a row boundary are assumed to be embedded in a field. If this setting is not present, the default value is RaggedEdge.
MaxScanRows | Indicates the number of rows to be scanned when guessing the column data types. If this is set to 0, the entire file is searched.
CharacterSet | Can be set to OEM, ANSI, UNICODE, or the decimal number of a valid code page, and indicates the character set of the source file.
DateTimeFormat | Can be set to a format string indicating dates and times. This entry should be specified if all date/time fields in the import/export are handled with the same format. All of the Microsoft Jet database engine formats except AM and PM are supported. In the absence of a format string, the Windows Control Panel short date picture and time options are used.
CurrencySymbol | Indicates the currency symbol to be used for currency values in the text file. Examples include the dollar sign ($) and Dm. If this entry is absent, the default value in the Windows Control Panel is used.
CurrencyPosFormat | Can be set to any of the following values: Currency symbol prefix with no separation ($1) Currency symbol suffix with no separation (1$) Currency symbol prefix with one character separation ($ 1) Currency symbol suffix with one character separation (1 $) If this entry is absent, the default value in the Windows Control Panel is used.
CurrencyDigits | Specifies the number of digits used for the fractional part of a currency amount. If this entry is absent, the default value in the Windows Control Panel is used.
CurrencyNegFormat | Can be one of the following values: ($1) -$1 $-1 $1- (1$) -1$ 1-$ 1$- -1 $ -$ 1 1 $- $ 1- $ -1 1- $ ($ 1) (1 $) The dollar sign is shown for purposes of this example, but it should be replaced with the appropriate CurrencySymbol value in the actual program. If this entry is absent, the default value in the Windows Control Panel is used.
CurrencyThousandSymbol | Indicates the single-character symbol to be used for separating currency values by thousands in the text file. If this entry is absent, the default value in the Windows Control Panel is used.
CurrencyDecimalSymbol | Can be set to any single character that is used to separate the whole from the fractional part of a currency amount. If this entry is absent, the default value in the Windows Control Panel is used.
DecimalSymbol | Can be set to any single character that is used to separate the integer from the fractional part of a number. If this entry is absent, the default value in the Windows Control Panel is used.
NumberDigits | Indicates the number of decimal digits in the fractional portion of a number. If this entry is absent, the default value in the Windows Control Panel is used.
NumberLeadingZeros | Specifies whether a decimal value less than 1 and greater than -1 should contain leading zeros; this value can either be False (no leading zeros) or True.
Col1, Col2, … | Lists the columns in the text file to be read. The format of this entry should be: Coln=columnName type [Width #] columnName: Column names with embedded spaces should be enclosed in quotation marks. type: Can be Bit, Byte, Short, Long, Decimal, Currency, Single, Double, DateTime. Binary, OLE, Text, or Memo. In addition, the following ODBC Text Driver types are supported: Char (same as Text) Float (same as Double) Integer (same as Short) LongChar (same as Memo) Date date format In the case of a Memo type an additional format marker [Attribute Hyperlink] can be used to specify columns that should be active URLs in Microsoft Access. In the case of a Decimal type the additional format markers [Scale #] Precision #] should be used.
TextDelimiter | Can be set to any single character that is used to delimit strings that contain any of the other special characters. E.g. "abc","xyz,pqr","hij" If this entry is not present the default delimiter is a double quote. If this entry is the string "none" then no characters will be treated as delimiters.
Note Note

When you change Schema.ini file settings, you must exit and then restart the database engine for the new settings to take effect.


AccessObjectProperties.Application Property (Access)

 Copy code hover
[image]

AccessObjectProperties.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents an AccessObjectProperties object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

AccessObjectProperties Collection

Other resources

AccessObjectProperties Object Members


OptionButton.Move Method (Access)

 Copy code hover
[image]

OptionButton.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents an OptionButton object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


ObjectFrame.TopPadding Property (Access)

 Copy code hover
[image]

ObjectFrame.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the object frame and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .TopPadding

expression A variable that represents an ObjectFrame object.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


ComboBox.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

ComboBox.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified combo box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthLeft

expression A variable that represents a ComboBox object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


AcDataTransferType Enumeration (Access)

 Copy code hover
[image]

AcDataTransferType Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the type of transfer that you want to make with the TransferDatabase or TransferSpreadsheet method.

Name | Value | Description
acExport | 1 | The data is exported.
acImport | 0 | (Default) The data is imported.
acLink | 2 | The database is linked to the specified data source.

Remarks

Note Note

The acLink transfer type is not supported for Microsoft Access projects (.adp).


CancelRecordChange Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

CancelRecordChange Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

You can use the CancelRecordChange action to cancel the changes applied to a record in a CreateRecord or EditRecord data block before the changes are committed.

Note Note

The CancelRecordChange action is available only in Data Macros.

Remarks

When you call the CancelRecordChange action, the CreateRecord or EditRecord data block is exited immediately.


Application.DLookup Method (Access)

 Copy code hover
[image]

Application.DLookup Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the DLookup function to get the value of a particular field from a specified set of records (a domain).

Syntax

expression .DLookup(Expr, Domain, Criteria)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Expr | Required | String | An expression that identifies the field whose value you want to return. It can be a string expression identifying a field in a table or query, or it can be an expression that performs a calculation on data in that field. In expr, you can include the name of a field in a table, a control on a form, a constant, or a function. If expr includes a function, it can be either built-in or user-defined, but not another domain aggregate or SQL aggregate function.
Domain | Required | String | A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter.
Criteria | Optional | Variant | An optional string expression used to restrict the range of data on which the DLookup function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the DLookup function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain; otherwise, the DLookup function returns a Null.

Return Value

Variant

Remarks

You can use the DLookup function to display the value of a field that isn't in the record source for your form or report. For example, suppose you have a form based on an Order Details table. The form displays the OrderID, ProductID, UnitPrice, Quantity, and Discount fields. However, the ProductName field is in another table, the Products table. You could use the DLookup function in a calculated control to display the ProductName on the same form.

The DLookup function returns a single field value based on the information specified in criteria. Although criteria is an optional argument, if you don't supply a value for criteria, the DLookup function returns a random value in the domain.

If no record satisfies criteria or if domain contains no records, the DLookup function returns a Null.

If more than one field meets criteria, the DLookup function returns the first occurrence. You should specify criteria that will ensure that the field value returned by the DLookup function is unique. You may want to use a primary key value for your criteria, such as [EmployeeID] in the following example, to ensure that the DLookup function returns a unique value:

VBA Copy code Copy code
Dim varX As Variant
varX = DLookup("[LastName]", "Employees", "[EmployeeID] = 1")

Whether you use the DLookup function in a macro or module, a query expression, or a calculated control, you must construct the criteria argument carefully to ensure that it will be evaluated correctly.

You can use the DLookup function to specify criteria in the Criteria row of a query, within a calculated field expression in a query, or in the Update To row in an update query.

You can also use the DLookup function in an expression in a calculated control on a form or report if the field that you need to display isn't in the record source on which your form or report is based. For example, suppose you have an Order Details form based on an Order Details table with a text box called ProductID that displays the ProductID field. To look up ProductName from a Products table based on the value in the text box, you could create another text box and set its ControlSource property to the following expression:

VBA Copy code Copy code
=DLookup("[ProductName]", "Products", "[ProductID] =" _
     & Forms![Order Details]!ProductID)

Tips

  • Although you can use the DLookup function to display a value from a field in a foreign table, it may be more efficient to create a query that contains the fields that you need from both tables and then to base your form or report on that query.

  • You can also use the Lookup Wizard to find values in a foreign table.

Links provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Forms: Populate Controls/Text Boxes Based on Combobox Selection

  • Search all tables/all fields in a database for a value

Example

The following example returns name information from the CompanyName field of the record satisfying criteria. The domain is a Shippers table. The criteria argument restricts the resulting set of records to those for which ShipperID equals 1.

VBA Copy code Copy code
Dim varX As Variant
varX = DLookup("[CompanyName]", "Shippers", "[ShipperID] = 1")

The next example from the Shippers table uses the form control ShipperID to provide criteria for the DLookup function. Note that the reference to the control isn't included in the quotation marks that denote the strings. This ensures that each time the DLookup function is called, Microsoft Access will obtain the current value from the control.

VBA Copy code Copy code
Dim varX As Variant
varX = DLookup("[CompanyName]", "Shippers", "[ShipperID] = " _
    & Forms!Shippers!ShipperID)

The next example uses a variable, intSearch, to get the value.

VBA Copy code Copy code
Dim intSearch As Integer
Dim varX As Variant

intSearch = 1
varX = DLookup("[CompanyName]", "Shippers", _
    "[ShipperID] = " & intSearch)

The following examples show how to use various types of criteria with the DLookup function.

Sample code provided by: Community Member Icon The UtterAccess community | About the Contributors

Copy code Copy code
    ' ***************************
    ' Typical Use
    ' Numerical values. Replace "number" with the number to use.
    variable = DLookup("[FieldName]", "TableName", "[Criteria] = number")

    ' Strings.
    ' Numerical values. Replace "string" with the string to use.
    variable = DLookup("[FieldName]", "TableName", "[Criteria]= 'string'")

    ' Dates. Replace "date" with the string to use.
    variable = DLookup("[FieldName]", "TableName", "[Criteria]= #date#")
    ' ***************************

    ' ***************************
    ' Referring to a control on a form
    ' Numerical values
    variable = DLookup("[FieldName]", "TableName", "[Criteria] = " & Forms!FormName!ControlName)

    ' Strings
    variable = DLookup("[FieldName]", "TableName", "[Criteria] = '" & Forms!FormName!ControlName & "'")

    ' Dates
    variable = DLookup("[FieldName]", "TableName", "[Criteria] = #" & Forms!FormName!ControlName & "#")
    ' ***************************

    ' ***************************
    ' Combinations
    ' Multiple types of criteria
    variable = DLookup("[FieldName]", "TableName", "[Criteria1] = " & Forms![FormName]![Control1] _
             & " AND [Criteria2] = '" & Forms![FormName]![Control2] & "'" _
            & " AND [Criteria3] =#" & Forms![FormName]![Control3] & "#")

    ' Use two fields from a single record.
    variable = DLookup("[LastName] & ', ' & [FirstName]", "tblPeople", "[PrimaryKey] = 7")

    ' Expressions
    variable = DLookup("[Field1] + [Field2]", "tableName", "[PrimaryKey] = 7")

    ' Control Structures
    variable = DLookup("IIf([LastName] Like 'Smith', 'True', 'False')", "tableName", "[PrimaryKey] = 7")
    ' ***************************

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Application Object

Other resources

Application Object Members


Overview of the Access SQL Reference

 Copy code hover
[image]

Overview of the Access SQL Reference
Send feedback

In this section

  • SQL Aggregate Functions (SQL)

  • SQL Expressions

  • SQL Reserved Words

  • SQL Data Types

  • ODBC Scalar Functions

  • Comparison of Microsoft Access SQL and ANSI SQL

  • Equivalent ANSI SQL Data Types

  • Using Wildcard Characters in String Comparisons


PropertyAttributesEnum

 Copy code hover
[image]

PropertyAttributesEnum
Send feedback

Specifies the attributes of a Property object.

Constant | Value | Description
adPropNotSupported | 0 | Indicates that the property is not supported by the provider.
adPropRequired | 1 | Indicates that the user must specify a value for this property before the data source is initialized.
adPropOptional | 2 | Indicates that the user does not need to specify a value for this property before the data source is initialized.
adPropRead | 512 | Indicates that the user can read the property.
adPropWrite | 1024 | Indicates that the user can set the property.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.PropertyAttributes.NOTSUPPORTED

AdoEnums.PropertyAttributes.REQUIRED

AdoEnums.PropertyAttributes.OPTIONAL

AdoEnums.PropertyAttributes.READ

AdoEnums.PropertyAttributes.WRITE


Page.SizeToFit Method (Access)

 Copy code hover
[image]

Page.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents a Page object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

Page Object

Other resources

Page Object Members


ToggleButton.BorderWidth Property (Access)

 Copy code hover
[image]

ToggleButton.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .BorderWidth

expression A variable that represents a ToggleButton object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


SubForm.Requery Method (Access)

 Copy code hover
[image]

SubForm.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified subform by requerying the source of data for the subform.

Syntax

expression .Requery

expression A variable that represents a SubForm object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts .

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate function.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

Example

The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form:

VBA Copy code Copy code
Public Sub RequeryList()

    Dim ctlCombo As Control

    ' Return Control object pointing to a combo box.
    Set ctlCombo = Forms!Employees!ReportsTo

    ' Requery source of data for list box.
    ctlCombo.Requery

End Sub

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


TabControl.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

TabControl.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Syntax

expression .ShortcutMenuBar

expression A variable that represents a TabControl object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

Example

The following example sets the "Suppliers_Toolbar" as the custom shortcut menu to display when the user clicks the right mouse button on the "Suppliers" form.

VBA Copy code Copy code
Forms("Suppliers").ShortcutMenuBar = "Suppliers_Toolbar"

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


RunMenuCommand Macro Action

 Copy code hover
[image]

RunMenuCommand Macro Action
Send feedback

You can use the RunMenuCommand action to run a built-in Microsoft Access command.

Setting

The RunMenuCommand action has the following action argument.

Action argument | Description
Command | The name of the command you want to run. The Command box shows the available built-in commands in Access, in alphabetical order. This is a required argument.

Remarks

You can use the RunMenuCommand action to run an Access command from a custom menu bar, global menu bar, custom shortcut menu, or global shortcut menu.

You can use the RunMenuCommand action in a macro with conditional expressions to run a command depending on certain conditions.

Note Note

Clicking the File tab and then clicking Recent shows the most recently used databases. You can click one of these databases instead of clicking Open. These database items don't appear in the drop-down list box for the Command argument, and aren't available by using the RunMenuCommand action in a macro.

When you convert an Access database from a previous version of Access, some commands may no longer be available. A command may have been renamed, moved to a different menu, or may no longer be available in Access. The DoMenuItem actions for such commands can't be converted to RunMenuCommand actions. When you open the macro, Access will display a RunMenuCommand action with a blank Command argument for such commands. You must edit the macro and enter a valid command argument, or delete the RunMenuCommand action.

To run the RunMenuCommand action in a Visual Basic for Applications (VBA) module, use the RunCommand method of the Application object. (This is equivalent to the RunCommand method of the DoCmd object.)


Relation.Table Property (DAO)

 Copy code hover
[image]

Relation.Table Property (DAO)
Send feedback

Indicates the name of a Relation object's primary table. This should be equal to the Name property setting of a TableDef or QueryDef object (Microsoft Access workspaces only).

Syntax

expression .Table

expression A variable that represents a Relation object.

Remarks

The Table property setting is read/write for a new Relation object not yet appended to a collection and read-only for an existing Relation object in a Relations collection.

Use the Table property with the ForeignTable property to define a Relation object, which represents the relationship between fields in two tables or queries. Set the Table property to the Name property setting of the primary TableDef or QueryDef object, and set the ForeignTable property to the Name property setting of the foreign (referencing) TableDef or QueryDef object. The Attributes property determines the type of relationship between the two objects.

For example, if you had a list of valid part codes (in a field named PartNo) stored in a ValidParts table, you could establish a one-to-many relationship with an OrderItem table such that if a part code were entered into the OrderItem table, it would have to already be in the ValidParts table. If the part code didn't exist in the ValidParts table and you had not set the Attributes property of the Relation object to dbRelationDontEnforce, a trappable error would occur.

In this case, the ValidParts table is the primary table, so the Table property of the Relation object would be set to ValidParts and the ForeignTable property of the Relation object would be set to OrderItem. The Name and ForeignName properties of the Field object in the Relation object's Fields collection would be set to PartNo.

Example

This example shows how the Table, ForeignTable, and ForeignName properties define the terms of a Relation between two tables.

VBA Copy code Copy code
Sub ForeignNameX()

 Dim dbsNorthwind As Database
 Dim relLoop As Relation

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 Debug.Print "Relation"
 Debug.Print " Table - Field"
 Debug.Print " Primary (One) ";
 Debug.Print ".Table - .Fields(0).Name"
 Debug.Print " Foreign (Many) ";
 Debug.Print ".ForeignTable - .Fields(0).ForeignName"

 ' Enumerate the Relations collection of the Northwind
 ' database to report on the property values of
 ' the Relation objects and their Field objects.
 For Each relLoop In dbsNorthwind.Relations
 With relLoop
 Debug.Print
 Debug.Print .Name & " Relation"
 Debug.Print " Table - Field"
 Debug.Print " Primary (One) ";
 Debug.Print .Table & " - " & .Fields(0).Name
 Debug.Print " Foreign (Many) ";
 Debug.Print .ForeignTable & " - " & _
 .Fields(0).ForeignName
 End With
 Next relLoop

 dbsNorthwind.Close

End Sub


Rectangle.DblClick Event (Access)

 Copy code hover
[image]

Rectangle.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Syntax

expression .DblClick(Cancel)

expression A variable that represents a Rectangle object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the DblClick event occurs. Setting the Cancel argument to True (-1) cancels the DblClick event.

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


CommandButton.Enter Event (Access)

 Copy code hover
[image]

CommandButton.Enter Event (Access)
See also Send feedback

Published: July 16, 2012

The Enter event occurs before a control actually receives the focus from a control on the same form or report.

Syntax

expression .Enter

expression A variable that represents a CommandButton object.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when these events occur, set the OnEnter or OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Enter event occurs before the GotFocus event. The Exit event occurs before the LostFocus event.

Unlike the GotFocus and LostFocus events, the Enter and Exit events don't occur when a form receives or loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


What is a Cursor?

 Copy code hover
[image]

What is a Cursor?
Send feedback

Operations in a relational database act on a complete set of rows. The set of rows returned by a SELECT statement consists of all the rows that satisfy the conditions in the WHERE clause of the statement. This complete set of rows returned by the statement is known as the result set. Applications, especially those that are interactive and online, cannot always work effectively with the entire result set as a unit. These applications need a mechanism to work with one row or a small block of rows at a time. Cursors are an extension to result sets that provide that mechanism.

A cursor is implemented by a cursor library. A cursor library is software, often implemented as a part of a database system or a data access API, that is used to manage attributes of data returned from a data source (a result set). These attributes include concurrency management, position in the result set, number of rows returned, and whether or not you can move forward and/or backward through the result set (scrollability).

A cursor keeps track of the position in the result set, and allows you to perform multiple operations row by row against a result set, with or without returning to the original table. In other words, cursors conceptually return a result set based on tables within the databases. The cursor is so named because it indicates the current position in the result set, just as the cursor on a computer screen indicates current position.

It is important to become familiar with the concept of cursors before moving on to learn the specifics of their usage in ADO.

Using cursors, you can:

  • Specify positioning at specific rows in the result set.

  • Retrieve one row or a block of rows based on the current result set position.

  • Modify data in the rows at the current position in the result set.

  • Define different levels of sensitivity to data changes made by other users.

For example, consider an application that displays a list of available products to a potential buyer. The buyer scrolls through the list to see product details and cost, and finally selects a product for purchase. Additional scrolling and selection occurs for the remainder of the list. As far as the buyer is concerned, the products appear one at a time, but the application uses a scrollable cursor to browse up and down through the result set.

You can use cursors in a variety of ways:

  • With no rows at all.

  • With some or all of the rows in a single table.

  • With some or all of the rows from logically joined tables.

  • As read-only or updateable at the cursor or field level.

  • As forward-only or fully scrollable.

  • With the cursor keyset located on the server.

  • Sensitive to underlying table changes caused by other applications (such as membership, sort, inserts, updates, and deletes).

  • Existing on either the server or the client.

Read-only cursors help users browse through the result set, and read/write cursors can implement individual row updates. Complex cursors can be defined with keysets that point back to base table rows. While some cursors are read-only in a forward direction, others can move back and forth and provide a dynamic refresh of the result set based on changes that other applications are making to the database.

Not all applications need to use cursors to access or update data. Some queries simply do not require direct row updating by using a cursor. Cursors should be one of the last techniques you choose to retrieve data — and then you should choose the lowest impact cursor possible. When you create a result set by using a stored procedure, the result set is not updateable using cursor edit or update methods.

Concurrency

In some multi-user applications it is vitally important for the data presented to the end user to be as current as possible. A classic example of such a system is an airline reservation system, where many users might be contending for the same seat on a given flight (and thus, a single record). In a case like this, the application design must handle concurrent operations on a single record.

In other applications, concurrency is not as important. In such cases, the expense involved in keeping the data current at all times cannot be justified.

Position

A cursor also keeps track of the current position in a result set. Think of the cursor position as a pointer to the current record, similar to the way an array index points to the value at that particular location in the array.

Scrollability

The type of cursor employed by your application also affects the ability to move forward and backward through the rows in a result set; this is sometimes called scrollability. The ability to move forward and backward through a result set adds to the complexity of the cursor, and is therefore more expensive to implement. For this reason, you should ask for a cursor with this functionality only when necessary.


ImportExportSpecification.Delete Method (Access)

 Copy code hover
[image]

ImportExportSpecification.Delete Method (Access)
See also Send feedback

Published: July 16, 2012

Deletes the specified ImportExportSpecification object from the ImportExportSpecifications collection.

Version Information

Version Added: Access 2007

Syntax

expression .Delete

expression A variable that represents an ImportExportSpecification object.

See also

Concepts

ImportExportSpecification Object

Other resources

ImportExportSpecification Object Members


NavigationButton.HoverForeShade Property (Access)

 Copy code hover
[image]

NavigationButton.HoverForeShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .HoverForeShade

expression A variable that represents a NavigationButton object.

Remarks

The HoverForeShade property contains a numeric expression that can be used to darken the theme color in the HoverForeColor property. The default value of the HoverForeShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Convert Microsoft Access Tables, Forms, and Reports

 Copy code hover
[image]

Convert Microsoft Access Tables, Forms, and Reports
Send feedback

Several changes introduced by Microsoft Access 2002 might affect the behavior of your version 1.x or 2.0 applications. The following sections provide more information about those changes.

Indexes and Relationships

A Microsoft Access table can contain up to 32 indexes. Very complex tables that are a part of many relationships may exceed the index limit, and you won't be able to convert the database that contains these tables. The Microsoft Access database engine creates indexes on both sides of relationships between tables. If your database won't convert, delete some relationships and try again to convert the database.

The LimitToList Property of Combo Boxes

In Microsoft Access 2002 or later, combo boxes accept Null values when the LimitToList property is set to True (-1), whether or not the list contains Null values. In version 2.0, a combo box that has the LimitToList property set to True won't accept a Null value unless the list contains a Null value. If you want to prevent users from entering a Null value by using a combo box, set the Required property of the field in the table to Yes.

Menus and In-Place Activation of OLE Objects

In order to make additional functionality available to you while activating OLE objects in place, some menu commands may have been moved to a menu that isn't replaced when you activate an OLE server.

Macros in your converted application that use a DoMenuItem action to carry out a version 2.0 menu command when a component is activated won't be affected by the changes. Version 2.0 commands are mapped to their equivalents in later versions of Microsoft Access.

Referencing a Control on a Read-Only Form

In Microsoft Access 2002 or later, you can't use an expression to refer to the value of a control on a read-only form that's bound to an empty record source. In previous versions, the expression returns a Null value. Before you reference a control on a read-only form, you should make sure that the form's record source contains records.

Date Fields and Data Entry

If you enter 3/3 in a field of type Date on a form or a table datasheet, the current year is automatically added in Microsoft Access 2002 or later. However, if you enter 3/3/ in the same field, Microsoft Access returns an error message. You must omit the last date delimiter so that Microsoft Access can translate the date into the proper format.

Buttons Created with the Command Button Wizard

If you used the Command Button Wizard in version 2.0 or 7.0 of Microsoft Access to generate code that called another application, you should delete the button and re-create it by using the Command Button Wizard in Microsoft Access 2002 or later.

Form and Report Class Modules

In versions of Microsoft Access prior to 2002, Form and Report objects have associated class modules even if there's no code behind the object. In Microsoft Access 2002 or later, you can set a form's or report's HasModule property to False. When you set the HasModule property to False, the form or report will take up less disk space and will load faster because it will no longer have an associated class module.

Converted Version 2.0 Report Has Different Margins

You may encounter problems when trying to print or preview a report in Microsoft Access 2002 or later that has been converted from Microsoft Access 2.0 if the report has some margins set to 0. When you convert a Microsoft Access 2.0 report, margins aren't set to 0; they are instead set to the minimum margin that's valid for the default printer. This prevents the report from printing data in the unprintable region of the printer.

To resolve this problem, reduce the column width, column spacing, or number of columns in the report so that the width of the columns plus the width of the default margins is equal to or less than the width of your paper.

Can't Use the Format Property to Distinguish Null Values and Zero-Length Strings

In versions 1.x and 2.0, you can use the Format property of a control to display different values for Null values and zero-length strings (" "). In Microsoft Access 2002 or later, to distinguish between Null values and zero-length strings in a control on a form, set the control's ControlSource property to an expression that tests for the Null value case. For example, to display "Null" or "ZLS" in a control, set its ControlSource property to the following expression:

=IIf(IsNull([MyControl]), "Null", Format([MyControl], "@;ZLS"))


CheckBox.BeforeUpdate Event (Access)

 Copy code hover
[image]

CheckBox.BeforeUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The BeforeUpdate event occurs before changed data in a control or record is updated.

Syntax

expression .BeforeUpdate(Cancel)

expression A variable that represents a CheckBox object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the BeforeUpdate event occurs. Setting the Cancel argument to True (-1) cancels the BeforeUpdate event.

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's BeforeUpdate event does occur.

To run a macro or event procedure when this event occurs, set the BeforeUpdate property to the name of the macro or to [Event Procedure].

This event does not apply to option buttons, check boxes, or toggle buttons in an option group. It applies only to the option group itself.

The BeforeUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB. When the focus leaves the record or if the user clicks Save Record on the Records menu, the entire record is updated, and the data is saved in the database.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

BeforeUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. BeforeUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For forms, you can use the BeforeUpdate event to cancel updating of a record before moving to another record.

If the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

You often use the BeforeUpdate event to validate data, especially when you perform complex validations, such as those that:

  • Involve conditions for more than one value on a form.

  • Display different error messages for different data entered.

  • Can be overridden by the user.

  • Contain references to controls on other forms or contain user-defined functions.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

A run-time error will occur if you attempt to modify the data contained in the control that fired the BeforeUpdate event in the event's procedure.

Example

The following example shows how you can use a BeforeUpdate event procedure to check whether a product name has already been entered in the database. After the user types a product name in the ProductName box, the value is compared to the ProductName field in the Products table. If there is a matching value in the Products table, a message is displayed that informs the user that the product has already been entered.

To try the example, add the following event procedure to a form named Products that contains a text box called ProductName.

VBA Copy code Copy code
Private Sub ProductName_BeforeUpdate(Cancel As Integer)
 If(Not IsNull(DLookup("[ProductName]", _
 "Products", "[ProductName] ='" _
 & Me!ProductName & "'"))) Then
 MsgBox "Product has already been entered in the database."
 Cancel = True
 Me!ProductName.Undo
 End If
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


NavigationButton.GridlineWidthTop Property (Access)

 Copy code hover
[image]

NavigationButton.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthTop

expression A variable that represents a NavigationButton object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


WSParameter.Parent Property (Access)

 Copy code hover
[image]

WSParameter.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Parent

expression A variable that represents a WSParameter object.

See also

Concepts

WSParameter Object

Other resources

WSParameter Object Members


Append Method (ADO)

 Copy code hover
[image]

Append Method (ADO)
Send feedback

Appends an object to a collection. If the collection is Fields, a new Field object may be created before it is appended to the collection.

Syntax

collection.Append object

fields.Append Name, Type, DefinedSize, Attrib, FieldValue

Parameters

  • collection

  • A collection object.

  • fields

  • A Fields collection.

  • object

  • An object variable that represents the object to be appended.

  • Name

  • A String value that contains the name of the new Field object, and must not be the same name as any other object in fields.

  • Type

  • A DataTypeEnum value, whose default value is adEmpty, that specifies the data type of the new field. The following data types are not supported by ADO, and should not be used when appending new fields to a Recordset: adIDispatch, adIUnknown, adVariant.

  • DefinedSize

  • Optional. A Long value that represents the defined size, in characters or bytes, of the new field. The default value for this parameter is derived from Type. Fields with a DefinedSize greater than 255 bytes, and treated as variable length columns. (The default DefinedSize is unspecified.)

  • Attrib

  • Optional. A FieldAttributeEnum value, whose default value is adFldDefault, that specifies attributes for the new field. If this value is not specified, the field will contain attributes derived from Type.

  • FieldValue

  • Optional. A Variant that represents the value for the new field. If not specified, then the field is appended with a null value.

Remarks

Parameters Collection

You must set the Type property of a Parameter object before appending it to the Parameters collection. If you select a variable-length data type, you must also set the Size property to a value greater than zero.

Describing parameters yourself minimizes calls to the provider and consequently improves performance when using stored procedures or parameterized queries. However, you must know the properties of the parameters associated with the stored procedure or parameterized query that you want to call.

Use the CreateParameter method to create Parameter objects with the appropriate property settings and use the Append method to add them to the Parameters collection. This lets you set and return parameter values without having to call the provider for the parameter information. If you are writing to a provider that does not supply parameter information, you must use this method to manually populate the Parameters collection in order to use parameters at all.

Fields Collection

The FieldValue parameter is only valid when adding a Field object to a Record object, not to a Recordset object. With a Record object, you may append fields and provide values at the same time. With a Recordset object, you must create fields while the Recordset is closed, then open the Recordset and assign values to the fields.

Note Note

For new Field objects that have been appended to the Fields collection of a Record object, the Value property must be set before any other Field properties can be specified. First, a specific value for the Value property must have been assigned and Update on the Fields collection called. Then, other properties such as Type or Attributes can be accessed.

Field objects of the following data types (DataTypeEnum) cannot be appended to the Fields collection and will cause an error to occur: adArray, adChapter, adEmpty, adPropVariant, and adUserDefined. Also, the following data types are not supported by ADO: adIDispatch, adIUnknown, and adIVariant. For these types, no error will occur when appended, but usage can produce unpredictable results including memory leaks.

Recordset

If you do not set the CursorLocation property before calling the Append method, CursorLocation will be set to adUseClient (a CursorLocationEnum value) automatically when the Recordset object's Open method is called.

A run-time error will occur if the Append method is called on the Fields collection of an open Recordset, or on a Recordset where the ActiveConnection property has been set. You can only append fields to a Recordset that is not open and has not yet been connected to a data source. This is typically the case when a Recordset object is fabricated with the CreateRecordset method or assigned to an object variable.

Record

A run-time error will not occur if the Append method is called on the Fields collection of an open Record. The new field will be added to the Record object's Fields collection. If the Record was derived from a Recordset, then the new field will not appear in the Recordset object's Fields collection.

A non-existent field can be created and appended to the Fields collection by assigning a value to the field object as if it already existed in the collection. The assignment will trigger the automatic creation and appending of the Field object, then the assignment will be completed.

After appending a Field to a Record object's Fields collection, call the Update method of the Fields collection to save the change.


Failure to connect to the FTP service. (Error 3678)

 Copy code hover
[image]

Failure to connect to the FTP service. (Error 3678)
Send feedback

Unable to open FTP connection. Make sure the internet server and FTP service are running and that your FTP service supports an anonymous connection.


SmartTags Methods (Access)

 Copy code hover
[image]

SmartTags Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Add | Adds a smart tag to a form or control.


Records could not be added to exceptions table. (Error 3619)

 Copy code hover
[image]

Records could not be added to exceptions table. (Error 3619)
Send feedback

A problem was encountered while importing or exporting to an external file. The import/export driver could not add a row to the error table in the Microsoft Access database to report the problem.


AcDisplayAs Enumeration (Access)

 Copy code hover
[image]

AcDisplayAs Enumeration (Access)
Send feedback

Published: July 16, 2012

Use with the DisplayAs property to specify what is displayed in an Attachment control.

Name | Value | Description
acDisplayAsIcon | 1 | The attachment is displayed as the icon for that file type.
acDisplayAsImageIcon | 0 | If the attachment is a supported image format, then the image is displayed. If the attachment is not a supported image format, then the icon for that file type is displayed.
acDisplayAsPaperclip | 2 | A paper clip is displayed.


Label.HorizontalAnchor Property (Access)

 Copy code hover
[image]

Label.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the label is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .HorizontalAnchor

expression A variable that represents a Label object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

Label Object

Other resources

Label Object Members


AcTextFormat Enumeration (Access)

 Copy code hover
[image]

AcTextFormat Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the TextFormat property to specify whether or not rich text is displayed in a Text Box.

Version Information

Version Added: Access 2007

Name | Value | Description
acTextFormatHTMLRichText | 1 | Rich text can be displayed.
acTextFormatPlain | 0 | (Default) Plain text is displayed.


Label.ForeTint Property (Access)

 Copy code hover
[image]

Label.ForeTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .ForeTint

expression A variable that represents a Label object.

Remarks

The ForeTint property contains a numeric expression that can be used to lighten the theme color in the ForeColor property. The default value of the ForeTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the ForeColor property by 75%.

VBA Copy code Copy code
Me.ctl.ForeTint=25

See also

Concepts

Label Object

Other resources

Label Object Members


ComboBox Events (Access)

 Copy code hover
[image]

ComboBox Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Change | The Change event occurs when the contents of the specified control changes.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Dirty | The Dirty event occurs when the contents of the specified control changes.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.
NotInList | The NotInList event occurs when the user enters a value in the text box portion of a combo box that isn't in the combo box list.
Undo | Occurs when the user undoes a change.


OptionGroup.TabStop Property (Access)

 Copy code hover
[image]

OptionGroup.TabStop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.

Syntax

expression .TabStop

expression A variable that represents an OptionGroup object.

Remarks

This property doesn't apply to toggle button controls when they appear in an option group. It applies only to the option group itself.

The TabStop property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) You can move the focus to the control by pressing the TAB key.
No | False | You can't move the focus to the control by pressing the TAB key.

When you create a control on a form, Microsoft Access automatically assigns the control a position in the form's tab order. Each new control is placed last in the tab order. If you want to prevent a control from being available when you tab through the controls in a form, set the control's TabStop property to No.

In Form view, hidden or disabled controls remain in the tab order but are skipped when you move through the controls by pressing TAB, even if their TabStop properties are set to Yes.

As long as a control's Enabled property is set to Yes, you can click the control or use an access key to select it, regardless of its TabStop property setting. For example, you can set the TabStop property of a command button to No to prevent users from selecting the button by pressing TAB. However, they can still click the command button to choose it.

Example

The following example disables the ability to move the focus to the "City" text box on the "Suppliers" form by using the TAB key.

VBA Copy code Copy code
Forms("Suppliers").Controls("City").TabStop = False

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


>= (Greater Than or Equal To) (Access 2013 custom web app)

 Copy code hover
[image]

>= (Greater Than or Equal To) (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Compares two expressions for greater than or equal.

Syntax

expression >= expression

expression Is any valid expression. Both expressions must have implicitly convertible data types. The conversion depends on the rules of data type precedence.

Return Type

Boolean

Remarks

When you compare non-null expressions, the result is TRUE if the left operand has a greater or equal value than the right operand; otherwise, the result is FALSE.


Connection Close Method, Table Type Property Example (VB)

 Copy code hover
[image]

Connection Close Method, Table Type Property Example (VB)
Send feedback

Setting the ActiveConnection property to Nothing should "close" the catalog. Associated collections will be empty. Any objects that were created from schema objects in the catalog will be orphaned. Any properties on those objects that have been cached will still be available, but attempting to read properties that require a call to the provider will fail.

Copy code Copy code

' BeginCloseConnectionVB
Sub Main()
 On Error GoTo CloseConnectionByNothingError

 Dim cnn As New ADODB.Connection
 Dim cat As New ADOX.Catalog
 Dim tbl As ADOX.Table

 cnn.Open "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source= 'c:\Program Files\Microsoft Office\" & _
 "Office\Samples\Northwind.mdb';"
 Set cat.ActiveConnection = cnn
 Set tbl = cat.Tables(0)
 Debug.Print tbl.Type ' Cache tbl.Type info
 Set cat.ActiveConnection = Nothing
 Debug.Print tbl.Type ' tbl is orphaned
 ' Previous line will succeed if this was cached
 Debug.Print tbl.Columns(0).DefinedSize
 ' Previous line will fail if this info has not been cached

 'Clean up
 cnn.Close
 Set cat = Nothing
 Set cnn = Nothing
 Exit Sub

CloseConnectionByNothingError:
 Set cat = Nothing

 If Not cnn Is Nothing Then
 If cnn.State = adStateOpen Then cnn.Close
 End If
 Set cnn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndCloseConnectionVB

Closing a Connection object that was used to "open" the catalog should have the same effect as setting the ActiveConnection property to Nothing.

Copy code Copy code
                      Sub CloseConnection()
 On Error GoTo CloseConnectionError

 Dim cnn As New ADODB.Connection
 Dim cat As New ADOX.Catalog
 Dim tbl As ADOX.Table

 cnn.Open "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source= 'c:\Program Files\Microsoft Office\" & _
 "Office\Samples\Northwind.mdb';"
 Set cat.ActiveConnection = cnn
 Set tbl = cat.Tables(0)
 Debug.Print tbl.Type ' Cache tbl.Type info
 cnn.Close
 Debug.Print tbl.Type ' tbl is orphaned
 ' Previous line will succeed if this was cached
 Debug.Print tbl.Columns(0).DefinedSize
 ' Previous line will fail if this info has not been cached

 'Clean up
 Set cat = Nothing
 Set cnn = Nothing
 Exit Sub

CloseConnectionError:

 Set cat = Nothing

 If Not cnn Is Nothing Then
 If cnn.State = adStateOpen Then cnn.Close
 End If
 Set cnn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndCloseConnection2VB


How to: Extract Data from a Record in a DAO Recordset

 Copy code hover
[image]

How to: Extract Data from a Record in a DAO Recordset
Send feedback

After you have located a particular record or records, you may want to extract data to use in your application instead of modifying the underlying source table.

Copying a Single Field

You can copy a single field of a record to a variable of the appropriate data type. The following example extracts three fields from the first record in a Recordset object.

VBA Copy code Copy code
Dim dbsNorthwind As DAO.Database
Dim rstEmployees As DAO.Recordset
Dim strFirstName As String
Dim strLastName As String
Dim strTitle As String

   Set dbsNorthwind = CurrentDb
   Set rstEmployees = dbsNorthwind.OpenRecordset("Employees")

   rstEmployees.MoveFirst
   strFirstName = rstEmployees!FirstName
   strLastName = rstEmployees!LastName
   strTitle = rstEmployees!Title

Copying Entire Records to an Array

To copy one or more records, you can create a two-dimensional array and copy records one at a time. You increment the first subscript for each field and the second subscript for each record.

A fast way to do this is to use the GetRows method, which returns a two-dimensional array. The first subscript identifies the field and the second identifies the row number, as follows.

VBA Copy code Copy code
varRecords(intField, intRecord)

The following code example uses an SQL statement to retrieve three fields from a table called Employees into a Recordset object. It then uses the GetRows method to retrieve the first three records of the Recordset, and it stores the selected records in a two-dimensional array. It then prints each record, one field at a time, by using the two array indexes to select specific fields and records.

To show how the array indexes are used, the following example uses a separate statement to identify and print each field of each record. In practice, it would be more reliable to use two loops, one nested in the other, and to provide integer variables for the indexes that step through both dimensions of the array.

VBA Copy code Copy code
Sub GetRowsTest()

Dim dbsNorthwind As DAO.Database
Dim rstEmployees As DAO.Recordset
Dim varRecords As Variant
Dim intNumReturned As Integer
Dim intNumColumns As Integer
Dim intColumn As Integer
Dim intRow As Integer
Dim strSQL As String

On Error GoTo ErrorHandler

   Set dbsNorthwind = CurrentDb
   strSQL = "SELECT FirstName, LastName, Title FROM Employees"
   Set rstEmployees = dbsNorthwind.OpenRecordset(SQL, dbOpenSnapshot)

   varRecords = rstEmployees.GetRows(3)
   intNumReturned = UBound(varRecords, 2) + 1
   intNumColumns = UBound(varRecords, 1) + 1

   For intRow = 0 To intNumReturned - 1
      For intColumn = 0 To intNumColumns - 1
         Debug.Print varRecords(intColumn, intRow)
      Next intColumn
   Next intRow

   rstEmployees.Close
   dbsNorthwind.Close

   Set rstEmployees = Nothing
   Set dbsNorthwind = Nothing

Exit Sub

ErrorHandler:
   MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Sub

You can use subsequent calls to the GetRows method if more records are available. Because the array is filled as soon as you call the GetRows method, you can see why this approach is much faster than copying one field at a time.

Notice also that you do not have to declare the Variant as an array, because this is done automatically when the GetRows method returns records. This enables you to use fixed-length array dimensions without knowing how many records or fields will be returned, instead of using variable-length dimensions that take up more memory.

If you are trying to retrieve all the rows by using multiple GetRows calls, use the EOF property to be sure that you are at the end of the Recordset. The GetRows method may return fewer rows than you request. If you request more than the remaining number of rows in a Recordset, for example, the GetRows method returns only the rows that remain. Similarly, if it cannot retrieve a row in the range requested, it does not return that row. For example, if the fifth record cannot be retrieved in a group of 10 records that you are trying to retrieve, the GetRows method returns four records and leaves the current record position on the record that caused a problem, and does not generate a run-time error. This situation may occur if a record in a dynaset was deleted by another user. If it returns fewer records than the number requested and you are not at the end of the file, you need to read each field in the current record to determine what error the GetRows method encountered.

Because the GetRows method always returns all the fields in the Recordset object, you may want to create a query that returns just the fields that you need. This is especially important for OLE Object and Memo fields.


Report.Resize Event (Access)

 Copy code hover
[image]

Report.Resize Event (Access)
See also Send feedback

Published: July 16, 2012

The Resize event occurs when a report is opened and whenever the size of a report changes.

Version Information

Version Added: Access 2007

Syntax

expression .Resize

expression A variable that represents a Report object.

Remarks

To run a macro or event procedure when this event occurs, set the OnResize property to the name of the macro or to [Event Procedure].

This event occurs if you change the size of the report in a macro or event procedure—for example, if you use the MoveSize action in a macro to resize the report.

By running a macro or an event procedure when a Resize event occurs, you can move or resize a control when the report it's on is resized. You can also use a Resize event to recalculate variables or reset properties that may depend on the size of the report.

When you first open a report, the following events occur in this order:

Open → Load → Resize → Activate → Current

Note Note

You need to be careful if you use a MoveSize, Maximize, Minimize, or Restore action (or the corresponding methods of the DoCmd object) in a Resize macro or event procedure. These actions can trigger a Resize event for the report, and thus cause a cascading event.

See also

Concepts

Report Object

Other resources

Report Object Members


CodeProject Members (Access)

 Copy code hover
[image]

CodeProject Members (Access)
Send feedback

Published: July 16, 2012

The CodeProject object refers to the project for the code database of a Microsoft Access project (.adp) or Access database.

Methods

Name | Description
AddSharedImage | Imports the specified image into the database and adds it to the SharedResources collection.
CloseConnection | You can use the CloseConnection method to close the current connection between the CodeProject object in a Microsoft Access project (.adp) or Access database and the database specified in the project's base connection string.
OpenConnection | You can use the OpenConnection method to open an ADO connection to an existing Microsoft Access project (.adp) or Access database as the current Access project or database in the Microsoft Access window.
UpdateDependencyInfo | Updates the dependency information for the database.

Properties

Name | Description
AccessConnection | You can use the AccessConnection property to return a reference to the current Microsoft ActiveX Data Objects (ADO) Connection object and its related properties. Read-only Connection.
AllForms | You can use the AllForms property to reference the AllForms collection and its related properties. Read-only AllForms object.
AllMacros | You can use the AllMacros property to reference the AllMacros collection and its related properties. Read-only AllMacros object.
AllModules | You can use the AllModules property to reference the AllModules collection and its related properties. Read-only AllModules object.
AllReports | You can use the AllReports property to reference the AllReports collection and its related properties. Read-only AllReports object.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BaseConnectionString | You can use the BaseConnectionString property to return the base connection string for the specified object. Read-only String.
Connection | You can use the Connection property to return a reference to the current ActiveX Data Objects (ADO) Connection object and its related properties. Read-only Connection.
FileFormat | Returns an AcFileFormat constant indicating the Microsoft Access version format of the specified project. Read-only.
FullName | Sets or returns the full path (including file name) of a specific object. Read-only String.
ImportExportSpecifications | Returns a ImportExportSpecifications collection that represents the collection of saved import or export operations for the specified object. Read-only.
IsConnected | You can use the IsConnected property to determine if the CodeProject object is currently connected. Read-only Boolean.
IsTrusted | Gets whether or not macros and Visual Basic for Applications (VBA) code have been enabled in the current project. Read-only Boolean.
IsWeb | Gets whether the database is a Web database. Read-only Boolean.
Name | You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.
Parent | Returns the parent object for the specified object. Read-only.
Path | You can use the Path property to determine the location where data is stored for a Microsoft Access project (.adp) or Microsoft Access database. Read-only String.
ProjectType | You can use the ProjectType property to determine the type of project that is currently open. Read-only AcProjectType.
Properties | Returns a reference to a CodeProject object's AccessObjectProperties collection. Read-only.
RemovePersonalInformation | Returns or sets a Boolean indicating whether personal information about the user is stored in the specified project. True if personal information is removed. Read-write.
Resources | Gets the SharedResources collection for the specified object. Read-only SharedResources.
WebSite | Gets the Uniform Resource Locator (URL) of the Web site to which the database has been published. Read-only String.


OptionButton.BorderWidth Property (Access)

 Copy code hover
[image]

OptionButton.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Syntax

expression .BorderWidth

expression A variable that represents an OptionButton object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Printer.RightMargin Property (Access)

 Copy code hover
[image]

Printer.RightMargin Property (Access)
See also Send feedback

Published: July 16, 2012

Along with the TopMargin, LeftMargin, and BottomMargin properties, specifies the margins for a printed page. Read/write Long.

Syntax

expression .RightMargin

expression A variable that represents a Printer object.

See also

Concepts

Printer Object

Other resources

Printer Object Members


DeleteRule Property (ADOX)

 Copy code hover
[image]

DeleteRule Property (ADOX)
Send feedback

Indicates the action performed when a primary key is deleted.

Settings and Return Values

Sets and returns a Long value that can be one of the RuleEnum constants. The default value is adRINone.

Remarks

This property is read-only on Key objects already appended to a collection.


OptionGroup.HelpContextId Property (Access)

 Copy code hover
[image]

OptionGroup.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Syntax

expression .HelpContextId

expression A variable that represents an OptionGroup object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


No current record. (Error 3021)

 Copy code hover
[image]

No current record. (Error 3021)
Send feedback

This error occurs after the unsuccessful application of one of the Find methods or the Seek method, when the underlying Recordset contains no records or the record has been deleted. Move to or select another record, and try the operation again. If the Recordset is empty, you cannot position to a current record. Check the BOF and EOF properties.


Entities.Count Property (Access)

 Copy code hover
[image]

Entities.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Version Information

Version Added: Access 2010

Syntax

expression .Count

expression A variable that represents an Entities object.

See also

Concepts

Entities Collection

Other resources

Entities Object Members


TextBox.DecimalPlaces Property (Access)

 Copy code hover
[image]

TextBox.DecimalPlaces Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DecimalPlaces property to specify the number of decimal places Microsoft Access uses to display numbers. Read/write Byte.

Syntax

expression .DecimalPlaces

expression A variable that represents a TextBox object.

Remarks

The DecimalPlaces property uses the following settings.

Setting | Visual Basic | Description
Auto | 255 | (Default) Numbers appear as specified by the Format property setting.
0 to 15 | 0 to 15 | Digits to the right of the decimal separator appear with the specified number of decimal places; digits to the left of the decimal separator appear as specified by the Format property setting.

You should set the DecimalPlaces property in the table's property sheet. A bound control you create on a form or report inherits the DecimalPlaces property set in the field in the underlying table or query, so you won't have to specify the property individually for every bound control you create.

The DecimalPlaces property setting has no effect if the Format property is blank or is set to General Number.

The DecimalPlaces property affects only the number of decimal places that display, not how many decimal places are stored. To change the way a number is stored you must change the FieldSize property in table Design view.

You can use the DecimalPlaces property to display numbers differently from the Format property setting or from the way they are stored. For example, the Currency setting of the Format property displays only two decimal places ($5.35). To display Currency numbers with four decimal places (for example, $5.3523), set the DecimalPlaces property to 4.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


OpenReport Macro Action

 Copy code hover
[image]

OpenReport Macro Action
Send feedback

You can use the OpenReport action to open a report in Design view or Print Preview, or to send the report directly to the printer. You can also restrict the records that are printed in the report.

Setting

The OpenReport action has the following arguments.

Action argument

Description

Report Name

The name of the report to open. The Report Name box in the Action Arguments section of the Macro Builder pane shows all reports in the current database. This is a required argument. If you run a macro containing the OpenReport action in a library database, Microsoft Access first looks for the report with this name in the library database, and then in the current database.

View

The view in which the report will open. Click Print (print the report immediately), Design, or Print Preview in the View box. The default is Print.

Filter Name

A filter that restricts the report's records. You can enter the name of either an existing query or a filter that was saved as a query. However, the query must include all the fields in the report you are opening or have its OutputAllFields property set to Yes.

Where Condition

A valid SQL WHERE clause (without the word WHERE) or expression that Access uses to select records from the report's underlying table or query. If you select a filter with the Filter Name argument, Access applies this WHERE clause to the results of the filter. To open a report and restrict its records to those specified by the value of a control on a form, use the following expression:
[fieldname] = Forms![formname]![controlname on form]
Replace fieldname with the name of a field in the underlying table or query of the report you want to open. Replace formname and controlname on form with the name of the form and the control on the form that contains the value you want records in the report to match.

Note Note

The maximum length of the Where Condition argument is 255 characters. If you need to enter a more complex SQL WHERE clause longer than this, use the OpenReport method of the DoCmd object in a Visual Basic for Applications (VBA) module instead. You can enter SQL WHERE clause statements of up to 32,768 characters in VBA.

Window Mode

The mode in which the report will open. Click Normal, Hidden, Icon, or Dialog in the Window Mode box. The default is Normal.

Note Note

Some Window Mode argument settings do not apply when using tabbed documents. To switch to overlapping windows:

  1. and then click Options.

  2. In the Access Options dialog box, click Current Database.

  3. In the Application Options section, under Document Window Options, click Overlapping Windows.

  4. Click OK, then close and reopen the database.

Remarks

The Print setting for the View argument prints the report immediately by using the current printer settings, without bringing up the Print dialog box. You can also use the OpenReport action to open and set up a report and then use the PrintOut action to print it. For example, you may want to modify the report or use the PrintOut action to change the printer settings before you print.

The filter and WHERE condition you apply become the setting of the report's Filter property.

The OpenReport action is similar to double-clicking the report in the Navigation Pane, or right-clicking the report in the Navigation Pane and selecting a view or the Print command.

Tips

  • To print similar reports for different sets of data, use a filter or a WHERE clause to restrict the records printed in the report. Then edit the macro to apply a different filter or change the Where Condition argument.

  • You can drag a report from the Navigation Pane to a macro action row. This automatically creates an OpenReport action that opens the report in Report view.

Example

The following example shows how to use the OpenReport action to pass a parameter that filters a report as it is opened. The rptChapters report displays the records for the specified author by passing the item selected in the cboAuthors combo box to the SelectedAuthor parameter.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

Copy code Copy code
OpenReport
    Report Name rptChapters
    View Report
    Filter Name
    Where Condition
    Window Mode Normal

Parameters
    SelectedAuthor =[cboAuthor]

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Attachment.BorderColor Property (Access)

 Copy code hover
[image]

Attachment.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .BorderColor

expression A variable that represents an Attachment object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


TextBox.TopMargin Property (Access)

 Copy code hover
[image]

TextBox.TopMargin Property (Access)
See also Send feedback

Published: July 16, 2012

Along with the LeftMargin, RightMargin, and BottomMargin properties, specifies the location of information displayed within a text box control. Read/write Integer.

Syntax

expression .TopMargin

expression A variable that represents a TextBox object.

Remarks

A control's displayed information location is measured from the control's left, top, right, or bottom border to the left, top, right, or bottom edge of the displayed information. Setting the LeftMargin or TopMargin property to 0 places the displayed information's edge at the very left or top of the control. To use a unit of measurement different from the setting in the regional settings of Windows, specify the unit (for example, cm or in).

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Log file path

 Copy code hover
[image]

Log file path <pathname> is invalid. (Error 3591)
Send feedback

Make sure the file is in the location specified in the Logfile value of the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Access Connectivity Engine\Transporter key in the Microsoft Windows Registry or reconfigure the synchronizer on your computer.

To configure the Synchronizer

  1. Start Replication Manager.

  2. On the Tools menu, click Configure Microsoft Replication Manager.

  3. Follow the instructions in the wizard.


ListBox.ColumnHeads Property (Access)

 Copy code hover
[image]

ListBox.ColumnHeads Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnHeads property to display a single row of column headings for list boxes, combo boxes, and OLE objects that accept column headings. You can also use this property to create a label for each entry in a chart control . What is actually displayed as the first-row column heading depends on the object's RowSourceType property setting. Read/write Boolean.

Syntax

expression .ColumnHeads

expression A variable that represents a ListBox object.

Remarks

The ColumnHeads property uses the following settings.

Setting | Visual Basic | Description
Yes | True | Column headings are enabled and either field captions, field names, or the first row of data items are used as column headings or chart labels.
No | False | (Default) Column headings are not enabled.

For table fields , you can set this property on the Lookup tab of the Field Properties section of table Design view for fields with the DisplayControl property set to Combo Box or List Box.

The RowSourceType property specifies whether field names or the first row of data items are used to create column headings. If the RowSourceType property is set to Table/Query, the field names are used as column headings. If the field has a caption, then the caption is displayed. For example, if a list box has three columns (the ColumnCount property is set to 3) and the RowSourceType property is set to Table/Query, the first three field names (or captions) are used as headings.

If the RowSourceType property is set to Value List, the first row of data items entered in the value list (as the setting of the RowSource property) will be column headings. For example, if a list box has three columns and the RowSourceType property is set to Value List, the first three items in the RowSource property setting are used as column headings.

If you can't select the first row of a list box or combo box in Form view, check to see if the ColumnHeads property is set to Yes.

Headings in combo boxes appear only when displaying the list in the control.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Attachment.Move Method (Access)

 Copy code hover
[image]

Attachment.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents an Attachment object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet view or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Form.Parent Property (Access)

 Copy code hover
[image]

Form.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a Form object.

See also

Concepts

Form Object

Other resources

Form Object Members


Properties Collection (DAO)

 Copy code hover
[image]

Properties Collection (DAO)
Send feedback

A Properties collection contains all the Property objects for a specific instance of an object.

Remarks

Every DAO object except the Connection and Error objects contains a Properties collection, which has certain built-in Property objects. These Property objects (which are often just called properties) uniquely characterize that instance of the object.

In addition to the built-in properties, you can also create and add your own user-defined properties. To add a user-defined property to an existing instance of an object, first define its characteristics with the CreateProperty method, then add it to the collection with the Append method. Referencing a user-defined Property object that has not yet been appended to a Properties collection will cause an error, as will appending a user-defined Property object to a Properties collection containing a Property object of the same name.

You can use the Delete method to remove user-defined properties from the Properties collection, but you can't remove built-in properties.

Note Note

A user-defined Property object is associated only with the specific instance of an object. The property isn't defined for all instances of objects of the selected type.

To refer to a built-in Property object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:

object.Properties(0)

object.Properties("name")

object.Properties![name]

For a built-in property, you can also use this syntax:

object.name

Note Note

For a user-defined property, you must use the full object.Properties("name") syntax.

With the same syntax forms, you can also refer to the Value property of a Property object. The context of the reference will determine whether you are referring to the Property object itself or the Value property of the Property object.

Example

This example creates a user-defined property for the current database, sets its Type and Value properties, and appends it to the Properties collection of the database. Then the example enumerates all properties in the database.

VBA Copy code Copy code
Sub PropertyX()

 Dim dbsNorthwind As Database
 Dim prpNew As Property
 Dim prpLoop As Property

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind
 ' Create and append user-defined property.
 Set prpNew = .CreateProperty()
 prpNew.Name = "UserDefined"
 prpNew.Type = dbText
 prpNew.Value = "This is a user-defined property."
 .Properties.Append prpNew

 ' Enumerate all properties of current database.
 Debug.Print "Properties of " & .Name
 For Each prpLoop In .Properties
 With prpLoop
 Debug.Print " " & .Name
 Debug.Print " Type: " & .Type
 Debug.Print " Value: " & .Value
 Debug.Print " Inherited: " & _
 .Inherited
 End With
 Next prpLoop

 ' Delete new property because this is a
 ' demonstration.
 .Properties.Delete "UserDefined"
 End With

End Sub

This example tries to set the value of a user-defined property. If the property doesn't exist, it uses the CreateProperty method to create and set the value of the new property. The SetProperty procedure is required for this procedure to run.

VBA Copy code Copy code
Sub CreatePropertyX()

 Dim dbsNorthwind As Database
 Dim prpLoop As Property

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 ' Set the Archive property to True.
 SetProperty dbsNorthwind, "Archive", True

 With dbsNorthwind
 Debug.Print "Properties of " & .Name

 ' Enumerate Properties collection of the Northwind
 ' database.
 For Each prpLoop In .Properties
 If prpLoop <> "" Then Debug.Print " " & _
 prpLoop.Name & " = " & prpLoop
 Next prpLoop

 ' Delete the new property since this is a
 ' demonstration.
 .Properties.Delete "Archive"

 .Close
 End With

End Sub

Sub SetProperty(dbsTemp As Database, strName As String, _
 booTemp As Boolean)

 Dim prpNew As Property
 Dim errLoop As Error

 ' Attempt to set the specified property.
 On Error GoTo Err_Property
 dbsTemp.Properties("strName") = booTemp
 On Error GoTo 0

 Exit Sub

Err_Property:

 ' Error 3270 means that the property was not found.
 If DBEngine.Errors(0).Number = 3270 Then
 ' Create property, set its value, and append it to the
 ' Properties collection.
 Set prpNew = dbsTemp.CreateProperty(strName, _
 dbBoolean, booTemp)
 dbsTemp.Properties.Append prpNew
 Resume Next
 Else
 ' If different error has occurred, display message.
 For Each errLoop In DBEngine.Errors
 MsgBox "Error number: " & errLoop.Number & vbCr & _
 errLoop.Description
 Next errLoop
 End
 End If

End Sub


ComboBox.ColumnWidths Property (Access)

 Copy code hover
[image]

ComboBox.ColumnWidths Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnWidths property to specify the width of each column in a multiple-column combo box. Read/write String.

Syntax

expression .ColumnWidths

expression A variable that represents a ComboBox object.

Remarks

The ColumnWidths property holds a value specifying the width of each column in inches or centimeters, depending on the measurement system (U.S. or Metric) selected in the Measurement system box on the Number tab of the Regional Options dialog box of Windows Control Panel. The default setting is 1 inch or 2.54 centimeters. The ColumnWidths property setting must be a value from 0 to 22 inches (55.87 cm) for each column in the list box or combo box.

To separate your column entries, use semicolons (;) as list separators (or the list separator selected in the List separator box on the Number tab of the Regional Options dialog box).

A width of 0 hides a column. Any or all of the ColumnWidths property settings can be blank. You create a blank setting by typing a list separator without a preceding value. Blank values result in Microsoft Access automatically setting a default column width that varies depending on the number of columns and the width of the combo box or list box.

In a combo box, the first visible column is displayed in the text box portion of the control.

In Visual Basic, use a string expression to set the column width values in twips. Column widths are separated by semicolons. To specify a different unit of measurement, include the unit of measure (cm or in). For example, the following string expression specifies three column widths in centimeters.

VBA Copy code Copy code
"6 cm;0;6 cm"

You can also use this property to hide one or more columns.

If you leave the ColumnWidths property setting blank, Microsoft Access sets the width of each column as the overall width of the list box or combo box divided by the number of columns.

If the column widths you set are too wide to be fully displayed within the combo box or list box, the rightmost columns are hidden and a horizontal scroll bar appears.

If you specify the width for some columns but leave the setting for others blank, Microsoft Access divides the remaining width by the number of columns for which you haven't specified a width. The minimum calculated column width is 1,440 twips (1 inch).

For example, the following settings are applied to a 4-inch list box with three columns.

Setting | Description
1.5 in;0;2.5 in | The first column is 1.5 inches, the second column is hidden, and the third column is 2.5 inches.
2 in;;2 in | The first column is 2 inches, the second column is 1 inch (default), and the third column is 2 inches. Because only half of the third column is visible, a horizontal scroll bar appears.
(Blank) | The three columns are the same width (1.33 inches).
Note Note

This property is different than the ColumnWidth property, which specifies the width of a specified column in a datasheet.

Example

The following example show how to create a combo box that is bound to one column while displaying another. Setting the ColumnCount property to 2 specifies that the cboDept combo box will display the first two columns of the data source specified by the RowSource property. Setting the BoundColumn property to 1 specifies that the value stored in the first column will be returned when you inspect the value of the combo box.

The ColumnWidths property specifies the width of the two columns. By setting the width of the first column to 0in., the first column is not displayed in the combo box.

Sample code provided by: MVP Contributor Bill Jelen, MrExcel.com | About the Contributors

Copy code Copy code
Private Sub cboDept_Enter()
    With cboDept
        .RowSource = "SELECT * FROM tblDepartments ORDER BY Department"
        .ColumnCount = 2
        .BoundColumn = 1
        .ColumnWidths = "0in.;1in."
    End With
End Sub

About the Contributors

Holy Macro! Books publishes entertaining books for people who use Microsoft Office. See the complete catalog at MrExcel.com.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Workspace.Databases Property (DAO)

 Copy code hover
[image]

Workspace.Databases Property (DAO)
Send feedback

Returns a Databases collection that represents the open databases in the specified Workspace. Read-only.

Syntax

expression .Databases

expression A variable that represents a Workspace object.


AdditionalData.Name Property (Access)

 Copy code hover
[image]

AdditionalData.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents an AdditionalData object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

AdditionalData Object

Other resources

AdditionalData Object Members


Invalid .inf file. (Error 3168)

 Copy code hover
[image]

Invalid .inf file. (Error 3168)
Send feedback

You tried to access a dBASE table, but its associated .inf file is invalid or has become corrupted. Relink the table, making sure you specify the correct indexes.


TabControl.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

TabControl.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleLeft

expression A variable that represents a TabControl object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


ParameterAttributesEnum

 Copy code hover
[image]

ParameterAttributesEnum
Send feedback

Specifies the attributes of a Parameter object.

Constant | Value | Description
adParamSigned | 16 | Indicates that the parameter accepts signed values.
adParamNullable | 64 | Indicates that the parameter accepts null values.
adParamLong | 128 | Indicates that the parameter accepts long binary data.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.ParameterAttributes.SIGNED

AdoEnums.ParameterAttributes.NULLABLE

AdoEnums.ParameterAttributes.LONG


The language-specific code page was not specified or could not be found. (Error 3649)

 Copy code hover
[image]

The language-specific code page was not specified or could not be found. (Error 3649)
Send feedback

You have attempted to open a database that was created with a language that is not installed on your computer. You should determine what language was specified for this database when it was created and then make sure that language is installed on your system. If the database was created with DAO, the language was specified with the locale argument of the CreateDatabase method. If the database was created with Microsoft Access, the language was specified with the option "New Database Sort Order" on the General tab of the Options dialog box, which is available by clicking Options on the Tools menu.

Languages can be added to your system through the Regional settings of the Control Panel.


NavigationButton.LabelX Property (Access)

 Copy code hover
[image]

NavigationButton.LabelX Property (Access)
See also Send feedback

Published: July 16, 2012

Version Information

Version Added: Access 2010

Syntax

expression .LabelX

expression A variable that represents a NavigationButton object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Records and Provider-Supplied Fields

 Copy code hover
[image]

Records and Provider-Supplied Fields
Send feedback

When a Record object is opened, its source can be the current row of an open Recordset, an absolute URL, or a relative URL in conjunction with an open Connection object.

If the Record is opened from a Recordset, the Record object Fields collection will contain all the fields from the Recordset, plus any fields added by the underlying provider.

The provider may insert additional fields that serve as supplementary characteristics of the Record. As a result, a Record may have unique fields not in the Recordset as a whole or any Record derived from another row of the Recordset.

For example, all rows of a Recordset derived from an e-mail data source might have columns such as From, To, and Subject. A Record derived from that Recordset will have the same fields. However, the Record may also have other fields unique to the particular message represented by that Record, such as Attachment and Cc (carbon copy).

Although the Record object and current row of the Recordset have the same fields, they are different because Record and Recordset objects have different methods and properties.

A field held in common by the Record and Recordset can be modified on either object. However, the field cannot be deleted on the Record object, although the underlying provider may support setting the field to null.

After the Record is opened, you can programmatically add fields. You can also delete fields you have added, but you cannot delete fields from the original Recordset.

You may also open the Record object directly from a URL. In this case, the fields added to the Record depend on the underlying provider. Currently, most providers add a set of fields that describe the entity represented by the Record. If the entity consists of a stream of bytes, such as a simple file, then a Stream object can usually be opened from the Record.

Special Fields for Document Source Providers

A special class of providers, called document source providers, manages folders and documents. When a Record object represents a document or a Recordset object represents a folder of documents, the document source provider populates those objects with a unique set of fields that describe characteristics of the document instead of the actual document itself. Typically, one field contains a reference to the Stream that represents the document.

These fields constitute a resource record or recordset and are listed for the specific providers that support them in Appendix A: Providers.

Two constants index the Fields collection of a resource Record or Recordset to retrieve a pair of commonly used fields. The Field object Value property returns the desired content.

  • The field accessed with the adDefaultStream constant contains a default stream associated with the Record or Recordset object. The provider assigns a default stream to an object.

  • The field accessed with the adRecordURL constant contains the absolute URL that identifies the document.

A document source provider does not support the Properties collection of Record and Field objects. The content of the Properties collection is null for such objects.

A document source provider may add a provider-specific property such as Datasource Type to identify whether it is a document source provider. For more information about how to determine your type of provider, see your provider documentation.

Resource Recordset Columns

A resource recordset consists of the following columns.

Column name | Type | Description
RESOURCE_PARSENAME | AdVarWChar | Read-only. Indicates the URL of the resource.
RESOURCE_PARENTNAME | AdVarWChar | Read-only. Indicates the absolute URL of the parent record.
RESOURCE_ABSOLUTEPARSENAME | AdVarWChar | Read-only. Indicates the absolute URL of the resource, which is the concatenation of PARENTNAME and PARSENAME.
RESOURCE_ISHIDDEN | AdBoolean | True if the resource is hidden. No rows will be returned unless the command that creates the rowset explicitly selects rows where RESOURCE_ISHIDDEN is True.
RESOURCE_ISREADONLY | AdBoolean | True if the resource is read-only. Attempts to open this resource with DBBINDFLAG_WRITE and will fail with DB_E_READONLY. This property may be edited even when the resource has only been opened for reading.
RESOURCE_CONTENTTYPE | AdVarWChar | Indicates the likely use of the document — for example, a lawyer's brief. This may correspond to the Office template used to create the document.""
RESOURCE_CONTENTCLASS | AdVarWChar | Indicates the MIME type of the document, indicating the format such as "text/html".'
RESOURCE_CONTENTLANGUAGE | AdVarWChar | Indicates the language in which the content is stored.
RESOURCE_CREATIONTIME | adFileTime | Read-only. Indicates a FILETIME structure containing the time the resource was created. The time is reported in Coordinated Universal Time (UTC) format.
RESOURCE_LASTACCESSTIME | AdFileTime | Read-only. Indicates a FILETIME structure containing the time that the resource was last accessed. The time is in UTC format. The FILETIME members are zero if the provider does not support this time member.
RESOURCE_LASTWRITETIME | AdFileTime | Read-only. Indicates a FILETIME structure containing the time that the resource was last written. The time is in UTC format. The FILETIME members are zero if the provider does not support this time member.
RESOURCE_STREAMSIZE | asUnsignedBigInt | Read-only. Indicates the size of the resource's default stream, in bytes.
RESOURCE_ISCOLLECTION | AdBoolean | Read-only. True if the resource is a collection, such as a directory. False if the resource is a simple file.
RESOURCE_ISSTRUCTUREDDOCUMENT | AdBoolean | True if the resource is a structured document. False if the resource is not a structured document. It could be a collection or a simple file.
DEFAULT_DOCUMENT | AdVarWChar | Read-only. Indicates that this resource contains a URL to the default simple document of a folder or a structured document. Used when the default stream is requested from a resource. This property is blank for a simple file.
CHAPTERED_CHILDREN | AdChapter | Read-only. Optional. Indicates the chapter of the rowset containing the children of the resource. (The OLE DB Provider for Internet Publishing does not use this column.)
RESOURCE_DISPLAYNAME | AdVarWChar | Read-only. Indicates the display name of the resource.
RESOURCE_ISROOT | AdBoolean | Read-only. True if the resource is the root of a collection or structured document.


CommandButton.AddColon Property (Access)

 Copy code hover
[image]

CommandButton.AddColon Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.

Syntax

expression .AddColon

expression A variable that represents a CommandButton object.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Attachment.Click Event (Access)

 Copy code hover
[image]

Attachment.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Version Information

Version Added: Access 2007

Syntax

expression .Click

expression A variable that represents an Attachment object.

Return Value

nothing

Remarks

  • The Click event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


ListBox.OnLostFocus Property (Access)

 Copy code hover
[image]

ListBox.OnLostFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnLostFocus

expression A variable that represents a ListBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The LostFocus event occurs when the object loses the focus.

The OnLostFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Lost Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Lost Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnLostFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnLostFocus

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Control.VerticalAnchor Property (Access)

 Copy code hover
[image]

Control.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified control is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .VerticalAnchor

expression A variable that represents a Control object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

Control Object

Other resources

Control Object Members


 Copy code hover
[image]

<reserved error alert> (Error 3416)
Send feedback

This error was generated by an application released after this version of the Microsoft Access database engine. Contact Microsoft Product Support Services.


Cannot perform this operation; features in this version are not available in databases with older formats. (Error 3301)

 Copy code hover
[image]

Cannot perform this operation; features in this version are not available in databases with older formats. (Error 3301)
Send feedback

The database was stored in an earlier version of the Microsoft Access database engine that does not support this feature. Either the database needs to be converted to the latest file format or this particular operation needs to be revised to avoid using the unsupported feature.


RelationAttributeEnum Enumeration (DAO)

 Copy code hover
[image]

RelationAttributeEnum Enumeration (DAO)
Send feedback

Used with the Attributes property to determine attributes of a Relation object.

Name | Value | Description
dbRelationDeleteCascade | 4096 | Deletions cascade
dbRelationDontEnforce | 2 | Relationship not enforced (no referential integrity)
dbRelationInherited | 4 | Relationship exists in the database containing the two linked tables
dbRelationLeft | 16777216 | Microsoft Access only. In Design view, display a LEFT JOIN as the default join type.
dbRelationRight | 33554432 | Microsoft Access only. In Design view, display a RIGHT JOIN as the default join type.
dbRelationUnique | 1 | One-to-one relationship
dbRelationUpdateCascade | 256 | Updates cascade


AcResourceType Enumeration (Access)

 Copy code hover
[image]

AcResourceType Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the type of a SharedResource object.

Name | Value | Description
acResourceImage | 1 | Image.
acResourceTheme | 0 | Office theme.


Report.Filter Property (Access)

 Copy code hover
[image]

Report.Filter Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Filter property to specify a subset of records to be displayed when a filter is applied to a form, reportquery, or table. Read/write String.

Syntax

expression .Filter

expression A variable that represents a Report object.

Remarks

If you want to specify a server filter within a Microsoft Access project (.adp) for data located on a server, use the ServerFilter property.

The Filter property is a string expression consisting of a WHERE clause without the WHERE keyword. For example, the following Visual Basic code defines and applies a filter to show only customers from the USA:

VBA Copy code Copy code
Me.Filter = "Country = 'USA'"
Me.FilterOn = True
Note Note

Setting the Filter property has no effect on the ADO Filter property.

You can use the Filter property to save a filter and apply it at a later time. Filters are saved with the objects in which they are created. They are automatically loaded when the object is opened, but they aren't automatically applied.

When a new object is created, it inherits the RecordSource , Filter, OrderBy , and OrderByOn properties of the table or query it was created from.

To apply a saved filter to a form, query, or table, you can click Apply Filter on the toolbar, click Apply Filter/Sort on the Records menu, or use a macro or Visual Basic to set the FilterOn property to True. For reports, you can apply a filter by setting the FilterOn property to Yes in the report's property sheet.

The Apply Filter button indicates the state of the Filter and FilterOn properties. The button remains disabled until there is a filter to apply. If an existing filter is currently applied, the Apply Filter button appears pressed in.

To apply a filter automatically when a form is opened, specify in the OnOpen event property setting of the form either a macro that uses the ApplyFilter action or an event procedure that uses the ApplyFilter method of the DoCmd object.

You can remove a filter by clicking the pressed-in Apply Filter button, clicking Remove Filter/Sort on the Records menu, or using Visual Basic to set the FilterOn property to False.

When the Filter property is set in form Design view, Microsoft Access does not attempt to validate the SQL expression. If the SQL expression is invalid, an error occurs when the filter is applied.

See also

Concepts

Report Object

Other resources

Report Object Members


Syntax error in ALTER TABLE statement. (Error 3293)

 Copy code hover
[image]

Syntax error in ALTER TABLE statement. (Error 3293)
Send feedback

You entered an SQL statement that includes an invalid ALTER TABLE statement.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


Application.Echo Method (Access)

 Copy code hover
[image]

Application.Echo Method (Access)
See also Send feedback

Published: July 16, 2012

The Echo method specifies whether Microsoft Access repaints the display screen.

Syntax

expression .Echo(EchoOn, bstrStatusBarText)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
EchoOn | Required | Integer | True (default) indicates that the screen is repainted.
bstrStatusBarText | Optional | String | A string expression that specifies the text to display in the status bar when repainting is turned on or off.

Remarks

If you are running Visual Basic code that makes a number of changes to objects displayed on the screen, your code may work faster if you turn off screen repainting until the procedure has finished running. You may also want to turn repainting off if your code makes changes that the user should not or does not need to see.

The Echo method does not suppress the display of modal dialog boxes, such as error messages, or pop-up forms, such as property sheets.

Note Note

The Echo method doesn't affect the visibility of the ribbon or the availability of ribbon commands.

If you turn screen repainting off, the screen won't show any changes, even if the user presses CTRL+BREAK or Visual Basic encounters a breakpoint. You may want to create a macro that turns repainting on and then assign the macro to a key or custom menu command. You can then use the key combination or menu command to turn repainting on if it has been turned off in Visual Basic.

If you turn screen repainting off and then try to step through the code, you won't be able to see progress through the code or any other visual cues until repainting is turned back on. However, your code will continue to execute.

Note Note

Do not confuse the Echo method with the Repaint method. The Echo method turns screen repainting on or off. The Repaint method forces an immediate screen repainting.

Example

The following code example uses the Echo method to prevent the screen from being repainted while certain operations are underway. While the procedure opens a form and minimizes it, the user only sees an hourglass icon indicating that processing is taking place, and the screen isn't repainted. When this task is completed, the hourglass changes back to a pointer and screen repainting is turned back on.

VBA Copy code Copy code
Public Sub EchoOff()

 ' Open the Employees form minimized.
 Application.Echo False
 DoCmd.Hourglass True
 DoCmd.OpenForm "Employees", acNormal
 DoCmd.Minimize
 Application.Echo True
 DoCmd.Hourglass False

End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


ComboBox.BeforeUpdate Property (Access)

 Copy code hover
[image]

ComboBox.BeforeUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.

Syntax

expression .BeforeUpdate

expression A variable that represents a ComboBox object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeUpdate event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Link provided by: Community Member Icon Luke Chung, FMS, Inc. | About the Contributors

  • Tips and Techniques for Using and Validating Combo Boxes

Example

The following example specifies that when the BeforeUpdate event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).BeforeUpdate = "[Event Procedure]"

About the Contributors

Luke Chung is the founder and president of FMS, Inc., a leading provider of custom database solutions and developer tools.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


TempVar.Name Property (Access)

 Copy code hover
[image]

TempVar.Name Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the name of the specified TempVar. Read-only String.

Version Information

Version Added: Access 2007

Syntax

expression .Name

expression A variable that represents a TempVar object.

See also

Concepts

TempVar Object

Other resources

TempVar Object Members


Control Object (Access)

 Copy code hover
[image]

Control Object (Access)
See also Send feedback

Published: July 16, 2012

The Control object represents a control on a form, report, or section, within another control, or attached to another control.

Remarks

All controls on a form or report belong to the Controls collection for that Form or Report object. Controls within a particular section belong to the Controls collection for that section. Controls within a tab control or option group control belong to the Controls collection for that control. A label control that is attached to another control belongs to the Controls collection for that control.

When you refer to an individual Control object in the Controls collection, you can refer to the Controls collection either implicitly or explicitly.

VBA Copy code Copy code
' Implicitly refer to NewData control in Controls
' collection.
Me!NewData
VBA Copy code Copy code
' Use if control name contains space.
Me![New Data]
VBA Copy code Copy code
' Performance slightly slower.
Me("NewData")
VBA Copy code Copy code
' Refer to a control by its index in the controls
' collection.
Me(0)
VBA Copy code Copy code
' Refer to a NewData control by using the subform
' Controls collection.
Me.ctlSubForm.Controls!NewData
VBA Copy code Copy code
' Explicitly refer to the NewData control in the
' Controls collection.
Me.Controls!NewData
VBA Copy code Copy code
Me.Controls("NewData")
VBA Copy code Copy code
Me.Controls(0)
Note Note

You can use the Me keyword to represent a Form or Report object within code only if you're referring to the form or report from code within the class module. If you're referring to a form or report from a standard module or a different form's or report's module, you must use the full reference to the form or report.

Each Control object is denoted by a particular intrinsic constant. For example, the intrinsic constant acTextBox is associated with a text box control, and acCommandButton is associated with a command button. The constants for the various Microsoft Access controls are set forth in the control's ControlType property.

To determine the type of an existing control, you can use the ControlType property. However, you don't need to know the specific type of a control in order to use it in code. You can simply represent it with a variable of data type Control.

If you do know the data type of the control to which you are referring, and the control is a built-in Microsoft Access control, you should represent it with a variable of a specific type. For example, if you know that a particular control is a text box, declare a variable of type TextBox to represent it, as shown in the following code.

VBA Copy code Copy code
Dim txt As TextBox
Set txt = Forms!Employees!LastName
Note Note

If a control is an ActiveX control, then you must declare a variable of type Control to represent it; you cannot use a specific type. If you're not certain what type of control a variable will point to, declare the variable as type Control.

The option group control can contain other controls within its Controls collection, including option button, check box, toggle button, and label controls.

The tab control contains a Pages collection, which is a special type of Controls collection. The Pages collection contains Page objects, which are controls. Each Page object in turn contains a Controls collection, which contains all of the controls on that page.

Other Control objects have a Controls collection that can contain an attached label. These controls include the text box, option group, option button, toggle button, check box, combo box, list box, command button, bound object frame, and unbound object frame controls.

See also

Concepts

Access Object Model Reference

Other resources

Control Object Members


There are no MAPI clients installed on this machine. Install a MAPI client, such as Outlook, on this machine. (Error 3804)

 Copy code hover
[image]

There are no MAPI clients installed on this machine. Install a MAPI client, such as Outlook, on this machine. (Error 3804)
Send feedback

Microsoft Outlook/Exchange IISAM uses the Messaging API (MAPI) to obtain folder or address book information. To get MAPI onto your machine you must install one of the Microsoft e-mail clients that uses MAPI, such as Outlook Client, Outlook Express, or Exchange Client. Until you do this, the Outlook/Exchange IISAM cannot work.


TabControl.StatusBarText Property (Access)

 Copy code hover
[image]

TabControl.StatusBarText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.

Syntax

expression .StatusBarText

expression A variable that represents a TabControl object.

Remarks

You set the StatusBarText property by using a string expression up to 255 characters long.

Note Note

The length of the text you can display in the status bar depends on your computer hardware and video display.

You can use the StatusBarText property to provide specific information about a control. For example, when a text box has the focus, a brief instruction can tell the user what kind of data to enter

Note Note

You can also use the ControlTipText property to display a ScreenTip for a control.

If you create a control by dragging a field from the field list, the value in a field's Description property is copied to the StatusBarText property.

Example

The following example sets the status bar text to be displayed when the "Address_TextBox" control in the "Mailing List" form has the focus in Form View.

VBA Copy code Copy code
Forms("Mailing List").Controls("Address_TextBox"). _
 StatusBarText = "Enter the company's mailing address."

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Form.Repaint Method (Access)

 Copy code hover
[image]

Form.Repaint Method (Access)
See also Send feedback

Published: July 16, 2012

The Repaint method completes any pending screen updates for a specified form. When performed on a form, the Repaint method also completes any pending recalculations of the form's controls.

Syntax

expression .Repaint

expression A variable that represents a Form object.

Return Value

Nothing

Remarks

Microsoft Access sometimes waits to complete pending screen updates until it finishes other tasks. With the Repaint method, you can force immediate repainting of the controls on the specified form. You can use the Repaint method:

  • When you change values in a number of fields. Unless you force a repaint, Microsoft Access might not display the changes immediately, especially if other fields, such as those in an expression in a calculated control, depend on values in the changed fields.

  • When you want to make sure that a form displays data in all of its fields. For example, fields containing OLE objects often don't display their data immediately after you open a form.

This method doesn't cause a requery of the database, nor does it show new or changed records in the form's underlying record source. You can use the Requery method to requery the source of data for the form or one of its controls.

Note Note

  • Don't confuse the Repaint method with the Refresh method, or with the Refresh command on the Records menu. The Refresh method and Refresh command show changes you or other users have made to the underlying record source for any of the currently displayed records in forms and datasheets. The Repaint method simply updates the screen when repainting has been delayed while Microsoft Access completes other tasks.

  • The Repaint method differs from the Echo method in that the Repaint method forces a single immediate repaint, while the Echo method turns repainting on or off.

Example

The following example uses the Repaint method to repaint a form when the form receives the focus:

VBA Copy code Copy code
Private Sub Form_Activate()
    Me.Repaint
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Delete Method Example (VB)

 Copy code hover
[image]

Delete Method Example (VB)
Send feedback

This example uses the Delete method to remove a specified record from a Recordset.

Copy code Copy code

'BeginDeleteVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 Dim rstRoySched As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim strSQLRoySched As String

 Dim strMsg As String
 Dim strTitleID As String
 Dim intLoRange As Integer
 Dim intHiRange As Integer
 Dim intRoyalty As Integer

 ' open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' open RoySched table with cursor client-side
 Set rstRoySched = New ADODB.Recordset
 rstRoySched.CursorLocation = adUseClient
 rstRoySched.CursorType = adOpenStatic
 rstRoySched.LockType = adLockBatchOptimistic
 rstRoySched.Open "SELECT * FROM roysched WHERE royalty = 20", strCnxn, , , adCmdText

 ' Prompt for a record to delete
 strMsg = "Before delete there are " & rstRoySched.RecordCount & _
 " titles with 20 percent royalty:" & vbCr & vbCr

 Do While Not rstRoySched.EOF
 strMsg = strMsg & rstRoySched!title_id & vbCr
 rstRoySched.MoveNext
 Loop

 strMsg = strMsg & vbCr & vbCr & "Enter the ID of a record to delete:"
 strTitleID = UCase(InputBox(strMsg))

 If strTitleID = "" Then
 Err.Raise 1, , "You didn't enter any value for the record ID."
 End If

 ' Move to the record and save data so it can be restored
 rstRoySched.Filter = "title_id = '" & strTitleID & "'"

 If rstRoySched.RecordCount < 1 Then
 Err.Raise 1, , "There is no record for the record ID you entered."
 End If

 intLoRange = rstRoySched!lorange
 intHiRange = rstRoySched!hirange
 intRoyalty = rstRoySched!royalty

 ' Delete the record
 rstRoySched.Delete
 rstRoySched.UpdateBatch

 ' Show the results
 rstRoySched.Filter = adFilterNone
 rstRoySched.Requery
 strMsg = ""
 strMsg = "After delete there are " & rstRoySched.RecordCount & _
 " titles with 20 percent royalty:" & vbCr & vbCr
 Do While Not rstRoySched.EOF
 strMsg = strMsg & rstRoySched!title_id & vbCr
 rstRoySched.MoveNext
 Loop
 MsgBox strMsg

 ' Restore the data because this is a demonstration
 rstRoySched.AddNew
 rstRoySched!title_id = strTitleID
 rstRoySched!lorange = intLoRange
 rstRoySched!hirange = intHiRange
 rstRoySched!royalty = intRoyalty
 rstRoySched.UpdateBatch

 ' clean up
 rstRoySched.Close
 Set rstRoySched = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstRoySched Is Nothing Then
 If rstRoySched.State = adStateOpen Then rstRoySched.Close
 End If
 Set rstRoySched = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndDeleteVB


AcCursorOnHover Enumeration (Access)

 Copy code hover
[image]

AcCursorOnHover Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the CursorOnHover property to specify the type of cursor displayed when a user rests the pointer on a button.

Version Information

Version Added: Access 2007

Name | Value | Description
acCursorOnHoverDefault | 0 | The default cursor is displayed.
acCursorOnHoverHyperlinkHand | 1 | The hyperlink hand cursor is displayed.


BoundObjectFrame.VerticalAnchor Property (Access)

 Copy code hover
[image]

BoundObjectFrame.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified object frame is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .VerticalAnchor

expression A variable that represents a BoundObjectFrame object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


DBEngine Object (DAO)

 Copy code hover
[image]

DBEngine Object (DAO)
Send feedback

The DBEngine object is the top level object in the DAO object model.

Remarks

The DBEngine object contains and controls all other objects in the hierarchy of DAO objects. You can't create additional DBEngine objects, and the DBEngine object isn't an element of any collection.

With any type of database or connection, you can:

  • Use the Version property to obtain the DAO version number.

  • Use the LoginTimeout property to obtain or set the ODBC login timeout, and the RegisterDatabase method to provide ODBC information to the Microsoft Access database engine.

  • Use the DefaultPassword and DefaultUser properties to set the user identification and password for the default Workspace object.

  • Use the CreateWorkspace method to create a new Workspace object. You can use optional arguments to override the settings of the DefaultType, DefaultPassword, and DefaultUser properties.

  • Use the OpenDatabase method to open a database in the default Workspace, and use the BeginTrans, Commit, and Rollback methods to control transactions on the default Workspace.

  • Use the Workspaces collection to reference specific Workspace objects.

  • Use the Errors collection to examine data access error details.

Other properties and methods are only available when you use DAO with the Microsoft Access database engine. You can use them to control the Microsoft Access database engine, manipulate its properties, and perform tasks on temporary objects that aren't elements of collections. For example, you can:

  • Use the CreateDatabase method to create a new Microsoft Access database engine Database object.

  • Use the Idle method to enable the Microsoft Access database engine to complete any pending tasks.

  • Use the CompactDatabase and RepairDatabase methods to maintain database files.

  • Use the IniPath and SystemDB properties to specify the location of Microsoft Access database engine Windows Registry information and the Microsoft Access workgroup information file, respectively. The SetOption method allows you override windows registry settings for the Microsoft Access database engine.

After you change the DefaultType and IniPath property settings, only subsequent Workspace objects will reflect these changes.

To refer to a collection that belongs to the DBEngine object, or to refer to a method or property that applies to this object, use this syntax:

[DBEngine.][collection | method | property]

Example

This example enumerates the collections of the DBEngine object.

VBA Copy code Copy code
Sub DBEngineX()

 Dim wrkLoop As Workspace
 Dim prpLoop As Property

 With DBEngine
 Debug.Print "DBEngine Properties"

 ' Enumerate Properties collection of DBEngine,
 ' trapping for properties whose values are
 ' invalid in this context.
 For Each prpLoop In .Properties
 On Error Resume Next
 Debug.Print " " & prpLoop.Name & " = " _
 & prpLoop
 On Error GoTo 0
 Next prpLoop

 Debug.Print "Workspaces collection of DBEngine"

 ' Enumerate Workspaces collection of DBEngine.
 For Each wrkLoop In .Workspaces
 Debug.Print " " & wrkLoop.Name

 ' Enumerate Properties collection of each
 ' Workspace object, trapping for properties
 ' whose values are invalid in this context.
 For Each prpLoop In wrkLoop.Properties
 On Error Resume Next
 Debug.Print " " & prpLoop.Name & _
 " = " & prpLoop
 On Error GoTo 0
 Next prpLoop

 Next wrkLoop

 End With

End Sub


Hyperlink Properties (Access)

 Copy code hover
[image]

Hyperlink Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Address | You can use the Address property to specify or determine the path to an object, document, Web page or other destination for a Hyperlink object associated with a command button, image control, or label control. Read/write String.
EmailSubject | You can use the EmailSubject property to specify or determine return the email subject line of a hyperlink to an object, document, Web page or other destination for a command button, image control, or label control. Read/write String.
ScreenTip | You can use the ScreenTip property to specify or determine the text that is displayed when you move the cursor over a hyperlink control. Read/write String.
SubAddress | You can use the SubAddress property to specify or determine a location within the target document specified by the Address property. Read/write String. .
TextToDisplay | You can use the TextToDisplay property to specify or determine the display text for a hyperlink. Read/write String.


Form.KeyDown Event (Access)

 Copy code hover
[image]

Form.KeyDown Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyDown(KeyCode, Shift)

expression A variable that represents a Form object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyDown property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyDown event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyDown event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyDown event occurs when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

Example

The following example determines whether you have pressed the SHIFT, CTRL, or ALT key.

To try the example, add the following event procedure to a form containing a text box named KeyHandler.

VBA Copy code Copy code
Private Sub KeyHandler_KeyDown(KeyCode As Integer, _
     Shift As Integer)
    Dim intShiftDown As Integer, intAltDown As Integer
    Dim intCtrlDown As Integer

    ' Use bit masks to determine which key was pressed.
    intShiftDown = (Shift And acShiftMask) > 0
    intAltDown = (Shift And acAltMask) > 0
    intCtrlDown = (Shift And acCtrlMask) > 0
    ' Display message telling user which key was pressed.
    If intShiftDown Then MsgBox "You pressed the SHIFT key."
    If intAltDown Then MsgBox "You pressed the ALT key."
    If intCtrlDown Then MsgBox "You pressed the CTRL key."
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Structured Query Language (SQL)

 Copy code hover
[image]

Structured Query Language (SQL)
Send feedback

In this section

  • How to: Create and Delete Tables and Indexes Using Access SQL

  • How to: Define Relationships Between Tables Using Access SQL

  • How to: Group Records in a Result Set Using Access SQL

  • How to: Insert, Update, and Delete Records From a Table Using Access SQL

  • How to: Modify a Table's Design Using Access SQL

  • How to: Perform Joins Using Access SQL

  • How to: Retrieve Records Using Access SQL

  • How to: Use Aggregate Functions to Work with Values in Access SQL


WebService Members (Access)

 Copy code hover
[image]

WebService Members (Access)
Send feedback

Published: July 16, 2012

Represents a Data Service data connection.

Properties

Name | Description
Entities | Gets the collection of entities defined for the spcified Data Service data connection. Read-only Entities.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.


Attachment.Left Property (Access)

 Copy code hover
[image]

Attachment.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .Left

expression A variable that represents an Attachment object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Database.Name Property (DAO)

 Copy code hover
[image]

Database.Name Property (DAO)
Send feedback

Returns the name of the specified object. Read-only String.

Syntax

expression .Name

expression A variable that represents a Database object.


Seek Method (ADO)

 Copy code hover
[image]

Seek Method (ADO)
Send feedback

Searches the index of a Recordset to quickly locate the row that matches the specified values, and changes the current row position to that row.

Syntax

recordset.Seek KeyValues, SeekOption

Parameters

  • KeyValues

  • An array of Variant values. An index consists of one or more columns and the array contains a value to compare against each corresponding column.

  • SeekOption

  • A SeekEnum value that specifies the type of comparison to be made between the columns of the index and the corresponding KeyValues.

Remarks

Use the Seek method in conjunction with the Index property if the underlying provider supports indexes on the Recordset object. Use the Supports (adSeek) method to determine whether the underlying provider supports Seek, and the Supports(adIndex) method to determine whether the provider supports indexes. (For example, the OLE DB Provider for Microsoft Jet supports Seek and Index.)

If Seek does not find the desired row, no error occurs, and the row is positioned at the end of the Recordset. Set the Index property to the desired index before executing this method.

This method is supported only with server-side cursors. Seek is not supported when the Recordset object's CursorLocation property value is adUseClient.

This method can only be used when the Recordset object has been opened with a CommandTypeEnum value of adCmdTableDirect.


BoundObjectFrame.OnMouseDown Property (Access)

 Copy code hover
[image]

BoundObjectFrame.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Syntax

expression .OnMouseDown

expression A variable that represents a BoundObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Database.ReplicaID Property (DAO)

 Copy code hover
[image]

Database.ReplicaID Property (DAO)
Send feedback

Returns a 16-byte value that uniquely identifies a database replica (Microsoft Access workspaces only).

Syntax

expression .ReplicaID

expression A variable that represents a Database object.

Remarks

The return value is a GUID value that uniquely identifies the replica or Design Master.

The Microsoft Access database engine automatically generates this value when you create a new replica.

The ReplicaID property of each replica (and the Design Master) is stored in the MSysReplicas system table.

Example

This example makes a replica from the Design Master of Northwind.mdb, and then returns the replica's ReplicaID, which is automatically created by the Microsoft Access database engine. (If you have not yet created a Design Master of Northwind, refer to the Replicable property, or change the name of the database in the code to an existing Design Master.)

VBA Copy code Copy code
Sub MakeReplicaReplicaIDX()

 Dim dbsNorthwind As Database
 Dim prpReplicaID As Property
 Dim dbsReplica As Database

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 ' Makes a new replica.
 dbsNorthwind.MakeReplica "Nwreplica2.mdb", _
 "second replica"
 dbsNorthwind.Close

 ' Opens the new replica to read its ReplicaID.
 Set dbsReplica = OpenDatabase("Nwreplica2.mdb")

 Debug.Print dbsReplica.ReplicaID
 dbsReplica.Close

End Sub


SQLState Property (ADO)

 Copy code hover
[image]

SQLState Property (ADO)
Send feedback

Indicates the SQL state for a given Error object.

Return Value

Returns a five-character String value that follows the ANSI SQL standard and indicates the error code.

Remarks

Use the SQLState property to read the five-character error code that the provider returns when an error occurs during the processing of an SQL statement. For example, when using the Microsoft OLE DB Provider for ODBC with a Microsoft SQL Server database, SQL state error codes originate from ODBC, based either on errors specific to ODBC or on errors that originate from Microsoft SQL Server, and are then mapped to ODBC errors. These error codes are documented in the ANSI SQL standard, but may be implemented differently by different data sources.


Invalid use of vertical bars. (Error 2437)

 Copy code hover
[image]

Invalid use of vertical bars. (Error 2437)
Send feedback

You entered an expression that has invalid vertical bars (|). Check the expression to make sure you entered it correctly.


ActualSize and DefinedSize Properties Example (JScript)

 Copy code hover
[image]

ActualSize and DefinedSize Properties Example (JScript)
Send feedback

This example uses the ActualSize and DefinedSize properties to display the defined size and actual size of a field. Cut and paste the following code to Notepad or another text editor, and save it as ActualSizeJS.asp.

Copy code Copy code

<!-- BeginActualSizeJS -->
<%@LANGUAGE="JScript" %>
<%// use this meta tag instead of adojavas.inc%>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->
<html>

<head>
 <title>ActualSize and DefinedSize Properties Example (JScript)</title>
<style>
<!--
body {
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 BACKGROUND-COLOR:white;
 COLOR:black;
 }
.thead2 {
 background-color: #800000;
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 font-size: x-small;
 color: white;
 }
.tbody {
 text-align: center;
 background-color: #f7efde;
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 font-size: x-small;
 }
-->
</style>
</head>

<body bgcolor="White">

<h1>ADO ActualSize and DefinedSize Properties (JScript)</h1>
<%
 // connection and recordset variables
 var Cnxn = Server.CreateObject("ADODB.Connection")
 var strCnxn = "Provider='sqloledb';Data Source=" + Request.ServerVariables("SERVER_NAME") + ";" +
 "Initial Catalog='Northwind';Integrated Security='SSPI';";
 var rsSuppliers = Server.CreateObject("ADODB.Recordset");
 // display variables
 var fld, strMessage;

 try
 {
 // open connection
 Cnxn.Open(strCnxn);

 // Open a recordset on the stores table
 rsSuppliers.Open("Suppliers", strCnxn);

 // build table headers
 Response.Write("<table>");
 Response.Write('<tr class="thead2"><th>Field Value</th>');
 Response.Write("<th>Defined Size</th>");
 Response.Write("<th>Actual Size</th></tr>");

 while (!rsSuppliers.EOF)
 {
 // start a new line
 strMessage = '<tr class="tbody">';

 // Display the contents of the chosen field with
 // its defined size and actual size
 fld = rsSuppliers("CompanyName");
 strMessage += '<td align="left">' + fld.Value + "</td>"
 strMessage += "<td>" + fld.DefinedSize + "</td>";
 strMessage += "<td>" + fld.ActualSize + "</td>";

 // end the line
 strMessage += "</tr>";

 // display data
 Response.Write(strMessage);

 // get next record
 rsSuppliers.MoveNext;

 }
 // close the table
 Response.Write("</table>");
 }
 catch (e)
 {
 Response.Write(e.message);
 }
 finally
 {
 // clean up
 if (rsSuppliers.State == adStateOpen)
 rsSuppliers.Close;
 if (Cnxn.State == adStateOpen)
 Cnxn.Close;
 rsSuppliers = null;
 Cnxn = null;
 }
%>

</body>

</html>
<!-- EndActualSizeJS -->


Address Book Data-Binding Object

 Copy code hover
[image]

Address Book Data-Binding Object
Send feedback

The Address Book application uses the RDS.DataControl object to bind data from the SQL Server database to a visual object (in this case, a DHTML table) in the application's client HTML page. The event-driven VBScript program logic uses the RDS.DataControl to:

  • Query the database, send updates to the database, and refresh the data grid.

  • Allow users to move to the first, next, previous, or last record in the data grid.

The following code defines the RDS.DataControl component:

Copy code Copy code

<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
   ID=DC1 Width=1 Height=1>
   <PARAM NAME="SERVER" VALUE="http://<%=Request.ServerVariables("SERVER_NAME")%>">
   <PARAM NAME="CONNECT" VALUE="Provider=sqloledb;
Initial Catalog=AddrBookDb;Integrated Security=SSPI;">
</OBJECT>

The OBJECT tag defines the RDS.DataControl component in the program. The tag includes two types of parameters:

  • Those associated with the generic OBJECT tag.

  • Those specific to the RDS.DataControl object.

Generic OBJECT Tag Parameters

The following table describes the parameters associated with the OBJECT tag.

Parameter | Description
CLASSID | A unique, 128-bit number that identifies the type of embedded object to the system. This identifier is maintained in the local computer's system registry. (For the class IDs of the RDS.DataControl object, see RDS.DataControl Object.)
ID | Defines a document-wide identifier for the embedded object that is used to identify it in code.

RDS.DataControl Tag Parameters

The following table describes the parameters specific to the RDS.DataControl object. (For a complete list of the RDS.DataControl object parameters, and when to implement them, see RDS.DataControl object.)

Parameter | Description
SERVER | If you are using HTTP, the value is the name of the server computer preceded by http:// .
CONNECT | Provides the necessary connection information for the RDS.DataControl to connect to SQL Server.
SQL | Sets or returns the query string used to retrieve the Recordset.


Filter and RecordCount Properties Example (VJ++)

 Copy code hover
[image]

Filter and RecordCount Properties Example (VJ++)
Send feedback

This example uses the Filter property to open a new Recordset based on a specified condition applied to an existing Recordset. It uses the RecordCount property to show the number of records in the two Recordsets. The FilterField function is required for this procedure to run.

Copy code Copy code

// BeginFilterJ
// The WFC class includes the ADO objects.

import com.ms.wfc.data.*;
import java.io.* ;

public class FilterX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 FilterX();
 FilterX2();
 System.exit(0);
 }

 // FilterX function
 static void FilterX()
 {

 // Define ADO Objects.
 Recordset rstPublishers = null;
 Recordset rstPublishersCountry = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String line = null;
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";

 int intPublisherCount;
 String strCountry;
 String strMessage;

 try
 {
 rstPublishers = new Recordset();

 // Open recordset with data from Publishers table.
 rstPublishers.setCursorType(AdoEnums.CursorType.STATIC);
 rstPublishers.open("publishers", strCnn,
 AdoEnums.CursorType.STATIC,
 AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TABLE);

 // Populate the Recordset.
 intPublisherCount = rstPublishers.getRecordCount();

 // Get user input.
 System.out.println("Enter a country to filter on:");
 strCountry = in.readLine().trim();

 if(!strCountry.equals(""))
 {
 // Open a filtered Recordset object.
 rstPublishersCountry =
 FilterField(rstPublishers, "Country", strCountry);
 if(rstPublishersCountry.getRecordCount()==0)
 System.out.println("\nNo publishers from that country.");
 else
 {
 // Print number of records for the original
 // Recordset object and the filtered Recordset
 // object.
 strMessage = "\nOrders in original recordset: " + "\n"
 + intPublisherCount + "\n"
 + "Orders in filtered recordset (Country = '"
 + strCountry + "'): \n"
 + rstPublishersCountry.getRecordCount();
 System.out.println(strMessage);
 }
 rstPublishersCountry.close();
 }
 System.out.println("\n\nPress <Enter> to continue..");
 in.readLine();

 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstPublishers != null)
 {
 PrintProviderError(rstPublishers.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }

 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstPublishers != null)
 if (rstPublishers.getState() == 1)
 rstPublishers.close();
 }

 }

 // FilterField Function

 static Recordset FilterField(Recordset rstTemp,String strField,
 String strFilter)
 {
 // Set a filter on the specified Recordset object and then
 // open a new Recordset object.
 rstTemp.setFilter(strField + " = '" + strFilter + "'");
 return rstTemp;
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }

 // FilterX2 function

 static void FilterX2()
 {

 // Define ADO Objects.
 Recordset rstPublishers = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String line = null;
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";

 try
 {
 rstPublishers = new Recordset();

 // Open recordset with data from Publishers table.
 rstPublishers.setCursorType(AdoEnums.CursorType.STATIC);
 rstPublishers.open("SELECT * FROM publishers " +
 "WHERE Country = 'USA'", strCnn,
 AdoEnums.CursorType.STATIC,
 AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TEXT);

 // Print current data in recordset.
 rstPublishers.moveFirst();
 while(!rstPublishers.getEOF())
 {
 System.out.println(rstPublishers.getField("pub_name").getString()
 +", "
 + rstPublishers.getField("country").getString());
 rstPublishers.moveNext();
 }
 System.out.println("\n\nPress <Enter> to continue..");
 in.readLine();

 // Cleanup objects before exit.
 rstPublishers.close();

 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // Check for null pointer for connection object.
 if (rstPublishers.getActiveConnection()==null)
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 else
 {
 // As passing a Recordset, check for null pointer first.
 if (rstPublishers != null)
 {
 PrintProviderError(rstPublishers.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 }
}
// EndFilterJ


CreateParameter Method (ADO)

 Copy code hover
[image]

CreateParameter Method (ADO)
Send feedback

Creates a new Parameter object with the specified properties.

Syntax

Set parameter = command.CreateParameter (Name, Type, Direction, Size, Value)

Return Value

Returns a Parameter object.

Parameters

  • Name

  • Optional. A String value that contains the name of the Parameter object.

  • Type

  • Optional. A DataTypeEnum value that specifies the data type of the Parameter object.

  • Direction

  • Optional. A ParameterDirectionEnum value that specifies the type of Parameter object.

  • Size

  • Optional. A Long value that specifies the maximum length for the parameter value in characters or bytes.

  • Value

  • Optional. A Variant that specifies the value for the Parameter object.

Remarks

Use the CreateParameter method to create a new Parameter object with a specified name, type, direction, size, and value. Any values you pass in the arguments are written to the corresponding Parameter properties.

This method does not automatically append the Parameter object to the Parameters collection of a Command object. This lets you set additional properties whose values ADO will validate when you append the Parameter object to the collection.

If you specify a variable-length data type in the Type argument, you must either pass a Size argument or set the Size property of the Parameter object before appending it to the Parameters collection; otherwise, an error occurs.

If you specify a numeric data type (adNumeric or adDecimal) in the Type argument, then you must also set the NumericScale and Precision properties.


Initializing the Microsoft Exchange Data Source Driver

 Copy code hover
[image]

Initializing the Microsoft Exchange Data Source Driver
Send feedback

When you install the Microsoft® Exchange Data Source driver, the Setup program writes a set of default values to the Microsoft Windows® Registry in the Engines and ISAM Formats subkeys. You should not modify these settings directly; use the setup program for your application to add, remove, or change these settings. The following sections describe initialization and ISAM Format settings for the Microsoft Exchange Data Source driver.

Microsoft Exchange Data Source Initialization Settings

The Access Connectivity Engine\Engines\Exchange folder includes initialization settings for the Aceexch.dll driver, used for external access to Microsoft Outlook and Microsoft Exchange folders. The only entry in this folder is the following:

Copy code Copy code
win32=<path>\ACEEXCH.DLL

The Microsoft Access database engine uses this setting to indicate the location of Aceexch.dll. The full path is determined at the time of installation. Values are of type REG_SZ.

The results of using the Outlook ISAM format and of using the Exchange client ISAM format are similar. The only difference is that the two different clients use different names for the same columns. The two ISAM formats have been created so that the Microsoft Access database engine can return the column names in the particular style that the user desires.

Microsoft Outlook Client ISAM Formats

The Access Connectivity Engine\ISAM Formats\Outlook 9.0 folder contains the following entries.

Entry name | Type | Value
Engine | REG_SZ | Exchange
ImportFilter | REG_SZ | Outlook()
CanLink | REG_BINARY | 01
OneTablePerFile | REG_BINARY | 00
IsamType | REG_DWORD | 3
IndexDialog | REG_BINARY | 00
CreateDBOnExport | REG_BINARY | 00
SupportsLongNames | REG_BINARY | 01
Note Note

When you change Windows Registry settings, you must exit and then restart the database engine for the new settings to take effect.

Microsoft Exchange Client ISAM Formats

The Access Connectivity Engine\ISAM Formats\Exchange 4.0 folder contains the following entries.

Entry name | Type | Value
Engine | REG_SZ | Exchange
ImportFilter | REG_SZ | Exchange()
CanLink | REG_BINARY | 01
OneTablePerFile | REG_BINARY | 00
IsamType | REG_DWORD | 3
IndexDialog | REG_BINARY | 00
CreateDBOnExport | REG_BINARY | 00
SupportsLongNames | REG_BINARY | 01
Note Note

When you change Windows Registry settings, you must exit and then restart the database engine for the new settings to take effect.

Customizing the Schema.ini File for Outlook and Exchange Data

The Schema.ini file is used by the Outlook and Exchange ISAM in much the same way that it is used by the Text ISAM. Schema.ini contains the specifics of a data source: how the data is formatted, and the names of columns that should be accessed.

It is not necessary to modify the Schema.ini file before data can be read, imported, or exported for Outlook and Exchange. Many of the settings inside the Schema.ini file for Outlook and Exchange are specific to internal tags that MAPI requires. You should not attempt to modify those tag values.


Rectangle.OldBorderStyle Property (Access)

 Copy code hover
[image]

Rectangle.OldBorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.

Syntax

expression .OldBorderStyle

expression A variable that represents a Rectangle object.

Remarks

The OldBorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines
Note Note

  • If the OldBorderStyle property is set to None or Dialog, the form doesn't have Maximize or Minimize buttons, regardless of its MinMaxButtons property setting.

  • If the OldBorderStyle property is set to None, the form doesn't have a Control menu, regardless of its ControlBox property setting.

  • The OldBorderStyle property setting doesn't affect the display of the scroll bars, navigation buttons, the record number box, or record selectors.

Example

The following example demonstrates the effect of changing a control's BorderStyle property, while leaving the OldBorderStyle unaffected. The example concludes with setting the BorderStyle property to its original unedited value.

VBA Copy code Copy code
With Forms("Order Entry").Controls("Zip Code") .BorderStyle = 3 ' Short dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 3, 1.

    .BorderStyle = 2 ' Dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 2, 1

    .BorderStyle = .OldBorderStyle ' Solid (default) border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 1, 1
End With

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


ADOX Code Examples in Microsoft Visual C++

 Copy code hover
[image]

ADOX Code Examples in Microsoft Visual C++
Send feedback

These topics provide sample code to help you understand how to use ADOX. All code examples are written using Microsoft Visual C++.

Note Note

Paste the entire code example, from beginning to end, into your code editor. The example may not run correctly if you use partial examples or if paragraph formatting is lost.

Methods

  • Columns and Tables Append Methods, Name Property Example (VC++)

  • Connection Close Method, Table Type Property Example (VC++)

  • Create Method Example (VC++)

  • GetObjectOwner and SetObjectOwner Methods Example (VC++)

  • GetPermissions and SetPermissions Methods Example (VC++)

  • Groups and Users Append, ChangePassword Methods Example (VC++)

  • Indexes Append Method Example (VC++)

  • Keys Append Method, Key Type, RelatedColumn, RelatedTable, and UpdateRule Properties Example (VC++)

Properties

  • Attributes Property Example (VC++)

  • Catalog ActiveConnection Property Example (VC++)

  • Clustered Property Example (VC++)

  • Command and CommandText Properties Example (VC++)

  • Command Property, Parameters Collection Example (VC++)

  • DateCreated and DateModified Properties Example (VC++)

  • DefinedSize Property Example (VC++)

  • DeleteRule Property Example (VC++)

  • IndexNulls Property Example (VC++)

  • Key Type, RelatedColumn, RelatedTable, UpdateRule Properties, Keys Append Method Example (VC++)

  • Name Property, Columns and Tables Append Methods Example (VC++)

  • NumericScale and Precision Properties Example (VC++)

  • ParentCatalog Property Example (VC++)

  • PrimaryKey and Unique Properties Example (VC++)

  • Table Type Property, Connection Close Method Example (VC++)

Collections

  • Parameters Collection, Command Property Example (VC++)


ObjectFrame.GridlineStyleTop Property (Access)

 Copy code hover
[image]

ObjectFrame.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified frame. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleTop

expression A variable that represents an ObjectFrame object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Section.DisplayWhen Property (Access)

 Copy code hover
[image]

Section.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's sections you want displayed on screen and in print. Read/write Byte.

Syntax

expression .DisplayWhen

expression A variable that represents a Section object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

Section Object

Other resources

Section Object Members


How to: Refer to Tab Control Objects in VBA

 Copy code hover
[image]

How to: Refer to Tab Control Objects in VBA
Send feedback

You can use a tab control to present several pages of information about a single form. A tab control is useful when your form contains information that can be sorted into two or more categories.

In most ways, a tab control works like other controls on a form and can be referred to as a member of a form's Controls collection. For example, to refer to a tab control named TabControl1 on a form named Form1, you can use the following expression:

VBA Copy code Copy code
Form1.Controls!TabControl1

However, because the Controls collection is the default collection of the Form object, you do not have to explicitly refer to the Controls collection. That is, you can omit the reference to the Controls collection from the expression, like this:

VBA Copy code Copy code
Form1!TabControl1

Referring to the Pages Collection

A tab control contains one or more pages. Each page in a tab control is referenced as a member of the tab control's Pages collection. Each page in the Pages collection can be referred to by either its PageIndex property setting (which reflects the page's position in the collection starting with 0), or by the page's Name property setting. There is no default collection for the TabControl object, so when referring to items in the Pages collection by their index value, or to properties of the Pages collection, you must explicitly refer to the Pages collection.

For example, to change the value of the Caption property for the first page of a tab control named TabControl1 by referring to its index value in the Pages collection, you can use the following statement:

VBA Copy code Copy code
TabControl1.Pages(0).Caption = "First Page"

Because each page is a member of the form's Controls collection, you can refer to a page solely by its Name property without referring to the tab control's name or its Pages collection. For example, to change the value of the Caption property of a page with its Name property set to Page1, use the following statement:

VBA Copy code Copy code
Page1.Caption = "First Page"
Note Note

If a user or code changes a page's PageIndex property, the reference to the page's index and the page's position in the page order change. In this case, if you want to maintain an absolute reference to a page, refer to the page's Name property.

The Pages collection has one property, Count, that returns the number of pages in a tab control. Note that this property is not a property of the tab control itself, but of its Pages collection, so you must explicitly refer to the collection. For example, to determine the number of pages in TabControl1, use the following statement:

VBA Copy code Copy code
TabControl1.Pages.Count

Referring to and Changing the Current Page

A tab control's default property is Value, which returns an integer that identifies the current page: 0 for the first page, 1 for the second page, and so on. The Value property is available only in VBA code or in expressions. By reading the Value property at run time, you can determine which page is currently on top. For example, the following statement returns the value for the current page of TabControl1:

VBA Copy code Copy code
TabControl1.Value
Note Note

Because the Value property is the default property for a tab control, you do not have to refer to it explicitly. For this reason, you could omit .Value from the preceding example.

Setting a tab control's Value property at run time changes the focus to the specified page, making it the current page. For example, the following statement moves the focus to the third page of TabControl1:

VBA Copy code Copy code
TabControl1 = 2

This is useful if you set a tab control's Style property to None (which displays no tabs) and want to use command buttons on the form to determine which page has the focus. To use a command button to display a page, add an event procedure to the button's OnClick event that sets the tab control's Value property to the integer that identifies the appropriate page.

By using the Value property with the Pages collection, you can set properties at run time for the page that is on top. For example, you can hide the current page and all of its controls by setting the page's Visible property to False. The following statement hides the current page of TabControl1:

VBA Copy code Copy code
TabControl1.Pages(TabControl1).Visible = False

Each page in a tab control also has a PageIndex property that specifies the position of a page within the Pages collection using the same numbering sequence as the tab control's Value property: 0 for the first page, 1 for the second page, and so on. Setting the value of a page's PageIndex property changes the order in which pages appear in the tab control. For example, if you wanted to make a page named Page1 the second page, you'd use the following statement:

VBA Copy code Copy code
Page1.PageIndex = 1

The PageIndex property is more typically set at design time in a page's property sheet. You can also set the page order by right-clicking the border of a tab control and then clicking Page Order on the shortcut menu.

Referring to Controls on a Tab Control Page

The controls you place on a tab control page are part of the same collection as all controls on the form. For this reason, each control on a tab control page must have a name that is unique with respect to all other controls on the same form. You can refer to controls on a tab control page by using the same syntax for controls on a form without a tab control.

VBA Copy code Copy code
Forms!Employees!HomePhone

Because each control on a form has its own Controls collection, you can also refer to the controls on a tab control as members of its Controls collection. For example, the following code enumerates (lists) all the controls on the tab control of the Employees form.

VBA Copy code Copy code
Sub ListTabControlControls()

   Dim tabCtl As TabControl
   Dim ctlCurrent As Control

On Error GoTo ErrorHandler

   ' Return reference to tab control on Employees form.
   Set tabCtl = Forms!Employees!TabCtl0

   ' List all controls on the tab control in the Debug window.
   For Each ctlCurrent In tabCtl
      Debug.Print ctlCurrent.Name
   Next ctlCurrent

   Set tabCtl = Nothing
   Set ctlCurrent = Nothing

   Exit Sub

ErrorHandler:
   MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Sub

Additionally, each page on a tab control has its own Controls collection. By using a page's Controls collection, you can refer to controls on each page. The following code enumerates the controls for each page of the tab control on the Employees form.

VBA Copy code Copy code
Sub ListPageControls()

   Dim tabCtl As TabControl
   Dim pagCurrent As Page
   Dim ctlCurrent As Control
   Dim intPageNum As Integer

On Error GoTo ErrorHandler

   ' Return reference to tab control on Employees form.
   Set tabCtl = Forms!Employees!TabCtl0

   ' List all controls for each page on the tab control in the
   ' Debug window.
   For Each pagCurrent In tabCtl.Pages
      intPageNum = intPageNum + 1
      Debug.Print "Page " & intPageNum & " Controls:"
      For Each ctlCurrent In pagCurrent.Controls
         Debug.Print ctlCurrent.Name
      Next ctlCurrent
      Debug.Print
   Next pagCurrent

   Set tabCtl = Nothing
   Set ctlCurrent = Nothing
   Set pagCurrent = Nothing

   Exit Sub

ErrorHandler:
   MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Sub


RDS Events

 Copy code hover
[image]

RDS Events
Send feedback
onError (RDS) | Called whenever an error occurs during an operation.
onReadyStateChange (RDS) | Called whenever the value of the ReadyState property changes.


Connection.Database Property (DAO)

 Copy code hover
[image]

Connection.Database Property (DAO)
Send feedback

Syntax

expression .Database

expression A variable that represents a Connection object.

Remarks

On a Connection object, use the Database property to obtain a reference to a Database object that corresponds to the Connection. In DAO, a Connection object and its corresponding Database object are simply two different object variable references to the same object. The Database property of a Connection object and the Connection property of a Database object make it easier to change connections to an ODBC data source through the Microsoft Access database engine to use ODBCDirect.

Example

This example uses the Database property to show how code that used to access ODBC data through the Microsoft Access database engine can be converted to use ODBCDirect Connection objects.

The OldDatabaseCode procedure uses a Microsoft Access database engine-connected data source to access an ODBC database.

VBA Copy code Copy code
Sub OldDatabaseCode()

 Dim wrkMain As Workspace
 Dim dbsPubs As Database
 Dim prpLoop As Property

 ' Create a Workspace object.
 Set wrkMain = CreateWorkspace("", "admin", "", dbUseJet)

 ' Open a Database object based on information in
 ' the connect string.

 'Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set dbsPubs = wrkMain.OpenDatabase("Publishers", _
 dbDriverNoPrompt, False, _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 ' Enumerate the Properties collection of the Database
 ' object.
 With dbsPubs
 Debug.Print "Database properties for " & _
 .Name & ":"

 On Error Resume Next
 For Each prpLoop In .Properties
 If prpLoop.Name = "Connection" Then
 ' Property actually returns a Connection object.
 Debug.Print " Connection[.Name] = " & _
 .Connection.Name
 Else
 Debug.Print " " & prpLoop.Name & " = " & _
 prpLoop
 End If
 Next prpLoop
 On Error GoTo 0

 End With

 dbsPubs.Close
 wrkMain.Close

End Sub

The NewDatabaseCode example opens a Connection object in an ODBCDirect workspace. It then assigns the Database property of the Connection object to an object variable with the same name as the data source in the old procedure. None of the subsequent code has to be changed as long as it doesn't use any features specific to Microsoft Access workspaces.

VBA Copy code Copy code
Sub NewDatabaseCode()

 Dim wrkMain As Workspace
 Dim conPubs As Connection
 Dim dbsPubs As Database
 Dim prpLoop As Property

 ' Create ODBCDirect Workspace object instead of Microsoft
 ' Access Workspace object.
 Set wrkMain = CreateWorkspace("", "admin", "", dbUseODBC)

 ' Open Connection object based on information in
 ' the connect string.
 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conPubs = wrkMain.OpenConnection("Publishers", _
 dbDriverNoPrompt, False, _
 "ODBC;DATABASE=pubs;DSN=Publishers")
 ' Assign the Database property to the same object
 ' variable as in the old code.
 Set dbsPubs = conPubs.Database

 ' Enumerate the Properties collection of the Database
 ' object. From this point on, the code is the same as the
 ' old example.
 With dbsPubs
 Debug.Print "Database properties for " & _
 .Name & ":"

 On Error Resume Next
 For Each prpLoop In .Properties
 If prpLoop.Name = "Connection" Then
 ' Property actually returns a Connection object.
 Debug.Print " Connection[.Name] = " & _
 .Connection.Name
 Else
 Debug.Print " " & prpLoop.Name & " = " & _
 prpLoop
 End If
 Next prpLoop
 On Error GoTo 0

 End With

 dbsPubs.Close
 wrkMain.Close

End Sub


Recordset Members (DAO)

 Copy code hover
[image]

Recordset Members (DAO)
Send feedback

A Recordset object represents the records in a base table or the records that result from running a query.

Methods

Name

Description

AddNew

Creates a new record for an updatable Recordset object.

Cancel

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Cancels execution of a pending asynchronous method call (ODBCDirect workspaces only).

CancelUpdate

Cancels any pending updates for a Recordset object.

Clone

Creates a duplicate Recordset object that refers to the original Recordset object.

Close

Closes an open Recordset.

CopyQueryDef

Returns a QueryDef object that is a copy of the QueryDef used to create the Recordset object represented by the recordset placeholder (Microsoft Access workspaces only). .

Delete

Not supported for this object.

Edit

Copies the current record from an updatable Recordset object to the copy buffer for subsequent editing.

FillCache

Fills all or a part of a local cache for a Recordset object that contains data from a Microsoft Access database engine-connected ODBC data source (Microsoft Access database engine-connected ODBC databases only).

FindFirst

Locates the first record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only).

FindLast

Locates the last record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only).

FindNext

Locates the next record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only). .

FindPrevious

Locates the previous record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only). .

GetRows

Retrieves multiple rows from a Recordset object.

Move

Moves the position of the current record in a Recordset object.

MoveFirst

Moves to the first record in a specified Recordset object and make that record the current record.

MoveLast

Moves to the last record in a specified Recordset object and make that record the current record.

MoveNext

Moves to the next record in a specified Recordset object and make that record the current record.

MovePrevious

Moves to the previous record in a specified Recordset object and make that record the current record.

NextRecordset

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Gets the next set of records, if any, returned by a multi-part select query in an OpenRecordset call, and returns a Boolean value indicating whether one or more additional records are pending (ODBCDirect workspaces only).

OpenRecordset

Creates a new Recordset object and appends it to the Recordsets collection.

Requery

Updates the data in a Recordset object by re-executing the query on which the object is based.

Seek

Locates the record in an indexed table-type Recordset object that satisfies the specified criteria for the current index and makes that record the current record (Microsoft Access workspaces only).

Update

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Saves the contents of the copy buffer to an updatable Recordset object.

Properties

Name

Description

AbsolutePosition

Sets or returns the relative record number of a Recordset object's current record.

BatchCollisionCount

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Returns the number of records that did not complete the last batch update (ODBCDirect workspaces only).

BatchCollisions

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Returns an array of bookmarks indicating the rows that generated collisions in the last batch update operation (ODBCDirect workspaces only).

BatchSize

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Sets or returns the number of statements sent back to the server in each batch (ODBCDirect workspaces only).

BOF

Returns a value that indicates whether the current record position is before the first record in a Recordset object. Read-only Boolean.

Bookmark

Sets or returns a bookmark that uniquely identifies the current record in a Recordset object.

Bookmarkable

Returns a value that indicates whether a Recordset object supports bookmarks, which you can set by using the Bookmark property.

CacheSize

Sets or returns the number of records retrieved from an ODBC data source that will be cached locally. Read/write Long.

CacheStart

Sets or returns a value that specifies the bookmark of the first record in a dynaset-type Recordset object containing data to be locally cached from an ODBC data source (Microsoft Access workspaces only).

Connection

Returns the Connection object that corresponds to the database.

DateCreated

Returns the date and time a base table was created (Microsoft Access workspaces only). Read-only Variant.

EditMode

Returns a value that indicates the state of editing for the current record.

EOF

Returns a value that indicates whether the current record position is after the last record in a Recordset object. Read-only Boolean.

Fields

Returns a Fields collection that represents all stored Field objects for the specified object. Read-only.

Filter

Sets or returns a value that determines the records included in a subsequently opened Recordset object (Microsoft Access workspaces only). Read/write String.

Index

Sets or returns a value that indicates the name of the current Index object in a table-type Recordset object (Microsoft Access workspaces only).

LastModified

Returns a ookmark indicating the most recently added or changed record.

LastUpdated

Returns the date and time of the most recent change made to a base table. Read-only Variant.

LockEdits

Sets or returns a value indicating the type of locking that is in effect while editing.

Name

Returns the name of the specified object. Read-only String.

NoMatch

Indicates whether a particular record was found by using the Seek method or one of the Find methods (Microsoft Access workspaces only).

PercentPosition

Sets or returns a value indicating the approximate location of the current record in the Recordset object based on a percentage of the records in the Recordset.

Properties

Returns the Properties collection of the specified object. Read-only.

RecordCount

Returns the number of records accessed in a Recordset object, or the total number of records in a table-type Recordset object. or TableDef object. Read-only Long.

RecordStatus

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Returns a value indicating the update status of the current record if it is part of a batch update (ODBCDirect workspaces only). Read-only RecordStatusEnum.

Restartable

Returns a value that indicates whether a Recordset object supports the Requery method, which re-executes the query on which the Recordset object is based.

Sort

Sets or returns the sort order for records in a Recordset object (Microsoft Access workspaces only).

StillExecuting

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Indicates whether or not an asynchronous operation (that is, a method called with the dbRunAsync option) has finished executing (ODBCDirect workspaces only).

Transactions

Returns a value that indicates whether an object supports transactions. Read-only Boolean.

Type

The description for this member will appear in the final release of Office 14.

Updatable

Returns a value that indicates whether you can change a DAO object. Read-only Boolean.

UpdateOptions

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Sets or returns a value that indicates how the WHERE clause is constructed for each record during a batch update, and whether the batch update should use an UPDATE statement or a DELETE followed by an INSERT (ODBCDirect workspaces only). Read/write UpdateCriteriaEnum.

ValidationRule

Sets or returns a value that validates the data in a field as it's changed or added to a table (Microsoft Access workspaces only).Read/write String.

ValidationText

Sets or returns a value that specifies the text of the message that your application displays if the value of a Field object doesn't satisfy the validation rule specified by the ValidationRule property setting (Microsoft Access workspaces only). Read-only String.


Report.HelpFile Property (Access)

 Copy code hover
[image]

Report.HelpFile Property (Access)
See also Send feedback

Published: July 16, 2012

The name of a help file associated with a report. Read/write String.

Syntax

expression .HelpFile

expression A variable that represents a Report object.

Example

This example adds a custom command bar with a combo box that tracks stock data. The example also specifies the Help topic to be displayed for the combo box when the user presses SHIFT+F1.

VBA Copy code Copy code
Set myBar = CommandBars _
 .Add(Name:="Custom", Position:=msoBarTop, _
 Temporary:=True)
With myBar
 .Controls.Add Type:=msoControlComboBox, ID:=1
 .Visible = True
End With
With CommandBars("Custom").Controls(1)
 .AddItem "Get Stock Quote", 1
 .AddItem "View Chart", 2
 .AddItem "View Fundamentals", 3
 .AddItem "View News", 4
 .Caption = "Stock Data"
 .DescriptionText = "View Data For Stock"
 .HelpFile = "C:\corphelp\custom.hlp"
 .HelpContextID = 47
End With

See also

Concepts

Report Object

Other resources

Report Object Members


GetRows Method Example (VC++)

 Copy code hover
[image]

GetRows Method Example (VC++)
Send feedback

This example uses the GetRows method to retrieve a specified number of rows from a Recordset and to fill an array with the resulting data. The GetRows method will return less than the desired number of rows in two cases: either if EOF has been reached, or if GetRows tried to retrieve a record that was deleted by another user. The function returns False only if the second case occurs. The GetRowsOK function is required for this procedure to run.

Copy code Copy code

// BeginGetRowsCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <stdio.h>
#include <ole2.h>
#include <conio.h>

// Function Declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void GetRowsX(void);
bool GetRowsOK(_RecordsetPtr pRstTemp,int intNumber,
 _variant_t& avarData);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 GetRowsX();

 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// GetRowsX Function //
// //
///////////////////////////////////////////////////////////

void GetRowsX(void)
{
 HRESULT hr = S_OK;

 // Define string variables.
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstEmployees = NULL;

 try
 {
 // Open recordset with names and hire dates from employee table.
 TESTHR(pRstEmployees.CreateInstance(__uuidof(Recordset)));

 pRstEmployees->Open("SELECT fName, lName, hire_date "
 "FROM Employee ORDER BY lName",strCnn,
 adOpenStatic, adLockReadOnly,adCmdText);

 while (true) //continuous loop
 {
 int intLines = 0;

 // Get user input for number of rows.
 printf("\nEnter number of rows to retrieve (0 to exit): ");
 int intRows;
 scanf("%d", &intRows);

 if (intRows <= 0)
 break;

 //Clear the screen for the next display
 system("cls");

 // If GetRowsOK is successful, print the results,
 // noting if the end of the file was reached.
 _variant_t avarRecords;

 if (GetRowsOK(pRstEmployees, intRows, avarRecords))
 {
 long lUbound;
 HRESULT hr = SafeArrayGetUBound(avarRecords.parray,
 2,&lUbound);

 if (hr == 0)
 {
 if (intRows > lUbound + 1)
 {
 printf("\n(Not enough records in Recordset to "
 "retrieve %d rows)\n", intRows);
 }
 }
 printf("%d records found.", lUbound+1);

 // Print the retrieved data.
 for (int intRecords = 0;intRecords < lUbound+1;
 intRecords++)
 {
 printf("\n ");

 long rgIndices[2];
 rgIndices[0] = 0;
 rgIndices[1] = intRecords;
 _variant_t result;
 result.vt = VT_BSTR;

 hr= SafeArrayGetElement(avarRecords.parray,
 rgIndices, &result);

 if (hr == 0){printf("%s ",(LPCSTR)(_bstr_t)result);}

 rgIndices[0] = 1;

 hr= SafeArrayGetElement(avarRecords.parray,
 rgIndices, &result);

 if (hr == 0){printf("%s, ",(LPCSTR)(_bstr_t)result);}

 rgIndices[0] = 2;

 hr= SafeArrayGetElement(avarRecords.parray,
 rgIndices, &result);

 if (hr == 0){printf("%s",(LPCSTR)(_bstr_t)result);}

 intLines ++;

 if (intLines % 10 == 0)
 {
 printf("\nPress any key to continue...");
 getch();

 intLines = 0;

 //Clear the screen for the next display
 system("cls");
 }
 }
 }
 else
 {
 // Assuming the GetRows error was due to data
 // changes by another user, use Requery to
 // refresh the Recordset and start over.
 printf("GetRows failed--retry?\n");
 char chKey;
 do
 {
 chKey = getch();
 }while(toupper(chKey) != 'Y' && toupper(chKey) != 'N');

 if(toupper(chKey) == 'Y')
 {
 pRstEmployees->Requery(adOptionUnspecified);
 }
 else
 {
 printf("GetRows failed!\n");
 break;
 }
 }

 // Because using GetRows leaves the current
 // record pointer at the last record accessed,
 // move the pointer back to the beginning of the
 // Recordset before looping back for another search.
 pRstEmployees->MoveFirst();
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstEmployees->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 //Clean up objects before exit.
 if (pRstEmployees)
 if (pRstEmployees->State == adStateOpen)
 pRstEmployees->Close();
}

bool GetRowsOK(_RecordsetPtr pRstTemp,int intNumber,
 _variant_t& avarData)
{
 // Store results of GetRows method in array.
 avarData = pRstTemp->GetRows(intNumber);

 // Return False only if fewer than the desired
 // number of rows were returned, but not because the
 // end of the Recordset was reached.
 long lUbound;
 HRESULT hr = SafeArrayGetUBound(avarData.parray,2,&lUbound);
 if (hr == 0)
 {
 if ((intNumber > lUbound + 1) && (!(pRstTemp->EndOfFile)))
 return false;
 else
 return true;
 }
 else
 {
 printf ("\nUnable to Get the Array's Upper Bound\n");
 return false;
 }
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndGetRowsCpp


The attempt to set a column in a partial replica violated a rule governing partial replicas. (Error 3571)

 Copy code hover
[image]

The attempt to set a column in a partial replica violated a rule governing partial replicas. (Error 3571)
Send feedback

You cannot change a primary key of a table in a partial replica unless it has no references to it.


Image.Height Property (Access)

 Copy code hover
[image]

Image.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Syntax

expression .Height

expression A variable that represents an Image object.

Return Value

Integer

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

Image Object

Other resources

Image Object Members


PageBreak.Move Method (Access)

 Copy code hover
[image]

PageBreak.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a PageBreak object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

PageBreak Object

Other resources

PageBreak Object Members


Error opening a Microsoft Excel 5.0 file. (Error 3432)

 Copy code hover
[image]

Error opening a Microsoft Excel 5.0 file. (Error 3432)
Send feedback

An OLE error occurred while opening a Microsoft Excel version 5.0 file.


ComboBox.DisplayWhen Property (Access)

 Copy code hover
[image]

ComboBox.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Syntax

expression .DisplayWhen

expression A variable that represents a ComboBox object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Source Property Example (VJ++)

 Copy code hover
[image]

Source Property Example (VJ++)
Send feedback

This example demonstrates the Source property by opening three Recordset objects based on different data sources.

Copy code Copy code

// BeginSourceJ
import java.io.*;
import com.ms.wfc.data.*;

public class SourceX
{
 // The main entry point of the application.
 public static void main (String[] args)
 {
 SourceX();
 System.exit(0);
 }
 // SourceX Function
 static void SourceX()
 {
 // Define string variables.
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';" +
 "Initial Catalog='Pubs';Integrated Security='SSPI';";
 String strSQL = "SELECT title_ID AS TitleID, title AS Title,"+
 "publishers.pub_id AS PubID, pub_name AS PubName "+
 "FROM publishers INNER JOIN Titles "+
 "ON publishers.pub_id=Titles.pub_id "+
 "ORDER BY Title";

 // Define ADO Objects.
 Connection cnn1 = null;
 Recordset rstTitles = null;
 Recordset rstPublishers = null;
 Recordset rstPublishersDirect = null;
 Recordset rstTitlesPublishers = null;
 Command cmdSQL = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));

 try
 {
 // Open a connection.
 cnn1 = new Connection();
 cnn1.open(strCnn);

 // Open a recordset based on a command object.
 cmdSQL = new Command();
 cmdSQL.setActiveConnection(cnn1);
 cmdSQL.setCommandText("Select title,type,pubdate " +
 "FROM Titles ORDER BY title");

 rstTitles = new Recordset();
 rstTitles = cmdSQL.execute();

 // Open a recordset based on a table.
 rstPublishers = new Recordset();
 rstPublishers.open("publishers", strCnn,
 AdoEnums.CursorType.FORWARDONLY, AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TABLE);

 // Open a recordset based on a table.
 rstPublishersDirect = new Recordset();
 rstPublishersDirect.open("publishers", strCnn,
 AdoEnums.CursorType.FORWARDONLY, AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TABLEDIRECT);

 // Open a recordset based on an SQL String.
 rstTitlesPublishers = new Recordset();

 rstTitlesPublishers.open(strSQL, strCnn,
 AdoEnums.CursorType.FORWARDONLY, AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TEXT);

 // Use Source property to display the source of each recordset.
 System.out.println("\nrstTitles source: \n"+
 rstTitles.getSource());
 System.out.println("\nrstPublishers source: \n"+
 rstPublishers.getSource());
 System.out.println("\nrstPublishersDirect source:\n" +
 rstPublishersDirect.getSource() );
 System.out.println("\nrstTitlesPublishers source: \n" +
 rstTitlesPublishers.getSource());

 System.out.println("\n\nPress <Enter> to continue..");
 in.readLine();
 }
 catch(AdoException ae)
 {
 // Notify the user of any errors that result from ADO.

 // As passing a recordset, check for null pointer first.

 if(rstPublishers != null)
 {
 PrintProviderError(rstPublishers.getActiveConnection());
 }
 else if(rstPublishersDirect != null)
 {
 PrintProviderError(
 rstPublishersDirect.getActiveConnection());
 }
 else if(rstTitles != null)
 {
 PrintProviderError(rstTitles.getActiveConnection());
 }
 else if(rstTitlesPublishers != null)
 {
 PrintProviderError(
 rstTitlesPublishers.getActiveConnection());
 }
 else
 System.out.println("Exception: " + ae.getMessage());

 }
 // System read requires this catch.
 catch(java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstTitles != null)
 if (rstTitles.getState() == 1)
 rstTitles.close();
 if (rstPublishers != null)
 if (rstPublishers.getState() == 1)
 rstPublishers.close();
 if (rstPublishersDirect != null)
 if (rstPublishersDirect.getState() == 1)
 rstPublishersDirect.close();
 if (rstTitlesPublishers != null)
 if (rstTitlesPublishers.getState() == 1)
 rstTitlesPublishers.close();
 if (cnn1 != null)
 if (cnn1.getState() == 1)
 cnn1.close();
 }

 }
 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndSourceJ


0 Database Engine Driver

 Copy code hover
[image]

0 Database Engine Driver
Send feedback

Published: July 16, 2012

When you install the Microsoft® Access database engine database driver, the Setup program writes a set of default values to the Microsoft Windows® Registry in the Engines and ISAM Formats subkeys. You must use the Registry Editor to add, remove, or change these settings. The following sections describe initialization and ISAM Format settings for the Microsoft Access Database Engine database driver.

Microsoft Jet Engine Initialization Settings

The Access Connectivity Engine\Engines folder includes initialization settings for the msjet40.dll database engine, used for access to Microsoft Access databases. Typical initialization settings for the entries in this folder are shown in the following example.

Copy code Copy code
SystemDB = <path>\System.mdb

CompactBYPkey = 1

PrevFormatCompactWithUNICODECompression=1

The Microsoft Access database engine uses the following entries.

Entry

Description

SystemDB

Specifies the full path and file name of the workgroup information file. The default is the appropriate path followed by the file name System.mdb. Values are of type REG_SZ.

CompactByPKey

Specifies that when you compact tables they are copied in primary-key order, if a primary key exists on the table. If no primary key exists on a table, the tables are copied in base-table order. A value of 0 indicates that tables should be compacted in base-table order; a non-zero value indicates that tables should be compacted in primary-key order, if a primary key exists. The default value is non-zero. Values are of type REG_DWORD.

PrevFormatCompactWithUNICODECompression

Microsoft Access database engine databases use the Unicode character set to store textual data. Compressing the Unicode data can significantly improve the performance of the database because of the reduced number of page read/write operations that are needed afterwards. This key determines if databases created by the Microsoft Jet database engine version 3.x or earlier should be created with compressed Unicode or un-compressed Unicode.

Note Note

This setting does not apply to compacting Microsoft Access database engine databases databases. Microsoft Access database engine databases databases will default to keep the compression settings with which they were created.

The Access Connectivity Engine\Engines\ACE folder includes initialization settings for the Ace.dll database engine, used for access to Microsoft Access databases. Typical initialization settings for the entries in this folder are shown in the following example.

Copy code Copy code
FlushTransactionTimeout=500

LockDelay=100

LockRetry=20

MaxBufferSize= 0

MaxLocksPerFile= 9500

PageTimeout=5000

Threads=3

UserCommitSync=Yes

ImplicitCommitSync=No

ExclusiveAsyncDelay=2000

SharedAsyncDelay=0

RecycleLVs=0

PagesLockedToTableLock=0

The Microsoft Access database engine uses the following entries.

Entry

Description

PageTimeout

The length of time between the time when data that is not read-locked is placed in an internal cache and the time when it is invalidated, expressed in milliseconds. The default is 5000 milliseconds or 5 seconds. Values are of type REG_DWORD.

FlushTransactionTimeout

This entry disables both the ExclusiveAsyncDelay and SharedAsyncDelay registry entries. To enable those entries, a value of zero must be entered. FlushTransactionTimeout changes the Microsoft Access database engine's method for doing asynchronous writes to a database file.

LockDelay

This setting works in conjunction with the LockRetry setting in that it causes each LockRetry to wait 100 milliseconds before issuing another lock request. The LockDelay setting was added to prevent bursting that would occur with certain networking operating systems.

MaxLocksPerFile

This setting prevents transactions in the Microsoft Access database engine from exceeding the specified value. If the locks in a transaction attempt to exceed this value, then the transaction is split into two or more parts and partially committed. This setting was added to prevent Netware 3.1 server crashes when the specified Netware lock limit was exceeded, and to improve performance with both Netware and NT.

LockRetry

The number of times to repeat attempts to access a locked page before returning a lock conflict message. The default is 20. Values are of type REG_DWORD.

RecycleLVs

This setting, when enabled, will cause the Microsoft Access database engine to recycle long value (LV) pages (Memo, Long Binary [OLE object], and Binary data types). Values are of type REG_DWORD.

MaxBufferSize

The size of the database engine internal cache, measured in kilobytes (K). MaxBufferSize must be an integer value greater than or equal to 512. The default is based on the following formula: ((TotalRAM in MB - 12 MB) / 4) + 512 KB For example, on a system with 32 MB of RAM, the default buffer size is ((32 MB - 12 MB) / 4) + 512 KB or 5632 KB. To set the value to the default, set the registry key to MaxBufferSize= Values are of type REG_DWORD.

Threads

The number of background threads available to the Microsoft Access database engine. The default is 3. Values are of type REG_DWORD.

UserCommitSync

Specifies whether the system waits for a commit to finish. A value of Yes instructs the system to wait; a value of No instructs the system to perform the commit asynchronously. The default is Yes. Values are of type REG_SZ.

ImplicitCommitSync

Specifies whether the system waits for a commit to finish. A value of No instructs the system to proceed without waiting for the commit to finish; a value of Yes instructs the system to wait for the commit to finish. The default is No. Values are of type REG_SZ.

ExclusiveAsyncDelay

Specifies the length of time, in milliseconds, to defer an asynchronous flush of an exclusive database. The default value is 2000, or 2 seconds. Values are of type REG_DWORD.

SharedAsyncDelay

Specifies the length of time, in milliseconds, to defer an asynchronous flush of a shared database. The default value is 0. Values are of type REG_DWORD.

PagesLockedToTableLock

During bulk operations it is often more efficient to lock a whole table, instead of obtaining locks for each individual page of the table as you try to access it. This setting specifies the number of pages that the Microsoft Access database engine will allow to be locked in any particular transaction before the Access database engine attempts to escalate to an exclusive table lock The default value of 0 indicates that the Access database engine will never automatically change from page locking to table locking.

Note Note

This setting should be used carefully. If a database is needed for multi-user access, then locking a whole table could cause locking conflicts for other users. This would be especially severe if a small number was used for this setting. Even when a larger number was used, such as 25 or 50, the operation for other users might become unpredictable.

Note Note

When you change Windows Registry settings, you must exit and then restart the database engine for the new settings to take effect.


Screen.ActiveDatasheet Property (Access)

 Copy code hover
[image]

Screen.ActiveDatasheet Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ActiveDatasheet property together with the Screen object to identify or refer to the datasheet that has the focus. Read-only Form object.

Syntax

expression .ActiveDatasheet

expression A variable that represents a Screen object.

Remarks

The ActiveDatasheet property setting contains the datasheet object that has the focus at run time.

You can use this property to refer to an active datasheet together with one of its properties or methods. For example, the following code uses the ActiveDatasheet property to reference the top row of the selection in the active datasheet.

VBA Copy code Copy code
TopRow = Screen.ActiveDatasheet.SelTop

Example

The following example uses the ActiveDatasheet property to identify the datasheet cell with the focus, or if more than one cell is selected, the location of the first row and column in the selection.

VBA Copy code Copy code
Public Sub GetSelection()
 ' This procedure demonstrates how to get a pointer to the
 ' current active datasheet.

 Dim objDatasheet As Object
 Dim lngFirstRow As Long
 Dim lngFirstColumn As Long
 Const conNoActiveDatasheet = 2484

 On Error GoTo GetSelection_Err

 Set objDatasheet = Screen.ActiveDatasheet

 lngFirstRow = objDatasheet.SelTop
 lngFirstColumn = objDatasheet.SelLeft
 MsgBox "The first item in this selection is located at " & _
 "Row " & lngFirstRow & ", Column " & _
 lngFirstColumn, vbInformation

GetSelection_Bye:
 Exit Sub
GetSelection_Err:
 If Err = conNoActiveDatasheet Then
 MsgBox "No data sheet is active.", vbExclamation
 Resume GetSelection_Bye
 End If
End Sub

See also

Concepts

Screen Object

Other resources

Screen Object Members


CurrentData.AllDatabaseDiagrams Property (Access)

 Copy code hover
[image]

CurrentData.AllDatabaseDiagrams Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllDatabaseDiagrams property to reference the AllDatabaseDiagrams collection and its related properties. Read-only AllDatabaseDiagrams object.

Syntax

expression .AllDatabaseDiagrams

expression A variable that represents a CurrentData object.

See also

Concepts

CurrentData Object

Other resources

CurrentData Object Members


SmartTagAction Properties (Access)

 Copy code hover
[image]

SmartTagAction Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Name | You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.
Parent | Returns the parent object for the specified object. Read-only.


Image.OnMouseUp Property (Access)

 Copy code hover
[image]

Image.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Syntax

expression .OnMouseUp

expression A variable that represents an Image object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

Image Object

Other resources

Image Object Members


ComboBox Members (Access)

 Copy code hover
[image]

ComboBox Members (Access)
Send feedback

Published: July 16, 2012

This object corresponds to a combo box control. The combo box control combines the features of a text box and a list box. Use a combo box when you want the option of either typing a value or selecting a value from a predefined list.

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Change | The Change event occurs when the contents of the specified control changes.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Dirty | The Dirty event occurs when the contents of the specified control changes.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.
NotInList | The NotInList event occurs when the user enters a value in the text box portion of a combo box that isn't in the combo box list.
Undo | Occurs when the user undoes a change.

Methods

Name | Description
AddItem | Adds a new item to the list of values displayed by the specified combo box control.
Dropdown | You can use the Dropdown method to force the list in the specified combo box to drop down.
Move | Moves the specified object to the coordinates specified by the argument values.
RemoveItem | Removes an item from the list of values displayed by the specified combo box control.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.
Undo | You can use the Undo method to reset a control or form when its value has been changed.

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
AllowAutoCorrect | You can use the AllowAutoCorrect property to specify whetherthe specified control will automatically correct entries made by the user. Read/write Boolean.
AllowValueListEdits | Gets or sets whether the Edit List Items command is available when the user right-clicks a combo box. Read/write Boolean.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoExpand | You can use the AutoExpand property to specify whether Microsoft Access automatically fills the text box portion of a combo box with a value from the combo box list that matches the characters you enter as you type in the combo box. This lets you quickly enter an existing value in a combo box without displaying the list box portion of the combo box. Read/write Boolean.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomMargin | Along with the LeftMargin, RightMargin, and TopMargin properties, specifies the location of information displayed within a text box control. Read/write Integer.
BottomPadding | Gets or sets the amount of space (in inches) between the combo box and its bottom gridline. Read/write Integer.
BoundColumn | When you make a selection from a combo box, the BoundColumn property tells Microsoft Access which column's values to use as the value of the control. If the control is bound to a field, the value in the column specified by the BoundColumn property is stored in the field named in the ControlSource property. Read/write Long.
CanGrow | Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the control contains. Read/write Boolean.
CanShrink | Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the control contains. Read/write Boolean.
Column | You can use the Column property to refer to a specific column, or column and row combination, in a multiple-column combo box or list box. Read-only Variant.
ColumnCount | You can use the ColumnCount property to specify the number of columns displayed in a list box or in the list box portion of a combo box, or sent to OLE objects in a chart control or unbound object frame . Read/write Integer.
ColumnHeads | You can use the ColumnHeads property to display a single row of column headings for list boxes, combo boxes, and OLE objects that accept column headings. You can also use this property to create a label for each entry in a chart control . What is actually displayed as the first-row column heading depends on the object's RowSourceType property setting. Read/write Boolean.
ColumnHidden | You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.
ColumnOrder | You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.
ColumnWidth | You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.
ColumnWidths | You can use the ColumnWidths property to specify the width of each column in a multiple-column combo box. Read/write String.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DecimalPlaces | You can use the DecimalPlaces property to specify the number of decimal places Microsoft Access uses to display numbers. Read/write Byte.
DefaultValue | Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.
DisplayAsHyperlink | Gets or sets an AcDisplayAsHyperlink constant that specifies whether to display the contents of the specified combo box as a hyperlink. Read/write.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontName | You can use the FontName property to specify the font for text in the following situations:
FontSize | You can use the FontSize property to specify the point size for text in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
FontWeight | You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
ForeShade | Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
ForeThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.
ForeTint | Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
Format | You can use the Format property to customize the way numbers, dates, times, and text are displayed and printed. Read/write String.
FormatConditions | You can use the FormatConditions property to return a read-only reference to the FormatConditions collection and its related properties.
GridlineColor | Gets or sets the color of the gridline for the specified combo box. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified combo box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified combo box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified combo box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified combo box. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified combo box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified combo box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified combo box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified combo box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HideDuplicates | You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the combo box is anchored horizontally within its layout. Read/write.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
IMEHold | Language-specific information You can use the IMEHold/Hold KanjiConversionMode property to show whether the Kanji Conversion Mode is maintained when the control loses the focus. Read/write Boolean.
IMEMode |
IMESentenceMode |
InheritValueList | Gets or sets whether a combo box's value list is inherited from its field. Read/write Boolean.
InputMask | You can use the InputMask property to make data entry easier and to control the values users can enter in a combo box control. Read/write String.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsHyperlink | You can use the IsHyperlink property to specify or determine if the data contained in a combo box is a hyperlink. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
ItemData | The ItemData property returns the data in the bound column for the specified row in a combo box. Read-only Variant.
ItemsSelected | You can use the ItemsSelected property to return a read-only reference to the hidden ItemsSelected collection. This hidden collection can be used to access data in the selected rows of a multiselect combo box control.
KeyboardLanguage |
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified combo box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified combo box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftMargin | Along with the TopMargin, RightMargin, and BottomMargin properties, specifies the location of information displayed within a text box control. Read/write Integer. .
LeftPadding | Gets or sets the amount of space (in inches) between the combo box and its left gridline. Read/write Integer.
LimitToList | You can use the LimitToList property to limit a combo box's values to the listed items. Read/write Boolean.
ListCount | You can use the ListCount property to determine the number of rows in the list box portion of a combo box. Read/write Long.
ListIndex | You can use the ListIndex property to determine which item is selected in a combo box. Read/write Long.
ListItemsEditForm | Gets or sets the name of the form that is displayed when the user clicks Edit List Items. Read/write String.
ListRows | You can use the ListRows property to set the maximum number of rows to display in the list box portion of a combo box. Read/write Integer.
ListWidth | You can use the ListWidth property to set the width of the list box portion of a combo box. Read/write String.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
NumeralShapes |
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnChange | Sets or returns the value of the On Change box in the Properties window of one of the objects in the Applies To list. Read/write String.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnDirty | Sets or returns the value of the On Dirty box in the Properties window of a form or report. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnNotInList | Sets or returns the value of the On Not in List box in the Properties window of a combo box. Read/write String.
OnUndo | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the Undo event occurs. Read/write..
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
Recordset | Returns or sets the ADO Recordset or DAO Recordset object representing the record source for the specified object. Read/write Object.
RightMargin | Along with the TopMargin, Left Margin, and BottomMargin properties, specifies the location of information displayed within a combo box control. Read/write Integer.
RightPadding | Gets or sets the amount of space (in inches) between the combo box and its right gridline. Read/write Integer.
RowSource | You can use the RowSource property (along with the RowSourceType property) to tell Microsoft Access how to provide data tothe specified object. Read/write String.
RowSourceType | You can use the RowSourceType property (along with the RowSource property) to tell Microsoft Access how to provide data tothe specified object. Read/write String.
ScrollBarAlign | You can use the ScrollBarAlign to specify or determine the alignment of a vertical scroll bar. Read/write Byte.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
Selected | You can use the Selected property in Visual Basic to determine if an item in a combo box is selected. Read/write Long.
SelLength | The SelLength property specifies or determines the number of characters selected in the text box portion of a combo box. Read/write Integer.
SelStart | The SelStart property specifies or determines the starting point of the selected text or the position of the insertion point if no text is selected. Read/write Integer.
SelText | The SelText property returns a string containing the selected text. Read/write String.
SeparatorCharacters | Gets or sets the separator displayed between values when the combo box is bound to a multi-valued field. Read/write AcSeparatorCharacters.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
ShowOnlyRowSourceValues | Gets or sets whether the combo box can display values that aren't specified by the RowSource property. Read/write Boolean.
SmartTags | Returns a SmartTags collection that represents the collection of smart tags that have been added to a control. .
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Text | You can use the Text property to set or return the text contained in the text box portion of a combo box. Read/write String.
TextAlign | The TextAlign property specifies the text alignment in new controls. Read/write Byte.
ThemeFontIndex | Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopMargin | Along with the LeftMargin, RightMargin, and BottomMargin properties, specifies the location of information displayed within a text box control. Read/write Integer.
TopPadding | Gets or sets the amount of space (in inches) between the combo box and its top gridline. Read/write Integer.
ValidationRule | You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.
ValidationText | Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.
Value | Determines or specifies which value or option in the combo box is selected. Read/write Variant.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified combo box is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


Section.SetTabOrder Method (Access)

 Copy code hover
[image]

Section.SetTabOrder Method (Access)
See also Send feedback

Published: July 16, 2012

Resets the tab order of the controls in the specified Section to their default values.

Version Information

Version Added: Access 2007

Syntax

expression .SetTabOrder

expression A variable that represents a Section object.

See also

Concepts

Section Object

Other resources

Section Object Members


Recordset2.Fields Property (DAO)

 Copy code hover
[image]

Recordset2.Fields Property (DAO)
Send feedback

Returns a Fields collection that represents all stored Field objects for the specified object. Read-only.

Syntax

expression .Fields

expression A variable that represents a Recordset2 object.


The password supplied for the dropbox folder

 Copy code hover
[image]

The password supplied for the dropbox folder <name> is invalid. (Error 3483)
Send feedback

To specify the password, start the Replication Manager.


Page.Visible Property (Access)

 Copy code hover
[image]

Page.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents a Page object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

Page Object

Other resources

Page Object Members


Keys Append Method, Key Type, RelatedColumn, RelatedTable and UpdateRule Properties Example (VB)

 Copy code hover
[image]

Keys Append Method, Key Type, RelatedColumn, RelatedTable and UpdateRule Properties Example (VB)
Send feedback

The following code demonstrates how to create a new foreign key. It assumes two tables (Customers and Orders) exist.

Copy code Copy code

' BeginCreateKeyVB
Sub Main()
 On Error GoTo CreateKeyError

 Dim kyForeign As New ADOX.Key
 Dim cat As New ADOX.Catalog

 ' Connect the catalog
 cat.ActiveConnection = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\Microsoft Office\" & _
 "Office\Samples\Northwind.mdb';"

 ' Define the foreign key
 kyForeign.Name = "CustOrder"
 kyForeign.Type = adKeyForeign
 kyForeign.RelatedTable = "Customers"
 kyForeign.Columns.Append "CustomerId"
 kyForeign.Columns("CustomerId").RelatedColumn = "CustomerId"
 kyForeign.UpdateRule = adRICascade

 ' Append the foreign key
 cat.Tables("Orders").Keys.Append kyForeign

 'Delete the Key as this is a demonstration
 cat.Tables("Orders").Keys.Delete kyForeign.Name

 'Clean up
 Set cat.ActiveConnection = Nothing
 Set cat = Nothing
 Set kyForeign = Nothing
 Exit Sub

CreateKeyError:
 Set cat = Nothing
 Set kyForeign = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If

End Sub
' EndCreateKeyVB


Report.CurrentView Property (Access)

 Copy code hover
[image]

Report.CurrentView Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the CurrentView property to determine how a report is currently displayed. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .CurrentView

expression A variable that represents a Report object.

Remarks

The CurrentView property uses the following settings.

Setting | Report Displayed In:
0 | Design view
5 | Print Preview
6 | Report view
7 | Layout view

Use this property to perform different tasks depending on the current view. For example, an event procedure could determine which view the form is displayed in and perform one task if the form is displayed in Form view or another task if it's displayed in Datasheet view.

See also

Concepts

Report Object

Other resources

Report Object Members


CustomControl.TabStop Property (Access)

 Copy code hover
[image]

CustomControl.TabStop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.

Syntax

expression .TabStop

expression A variable that represents a CustomControl object.

Remarks

This property doesn't apply to toggle button controls when they appear in an option group. It applies only to the option group itself.

The TabStop property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) You can move the focus to the control by pressing the TAB key.
No | False | You can't move the focus to the control by pressing the TAB key.

When you create a control on a form, Microsoft Access automatically assigns the control a position in the form's tab order. Each new control is placed last in the tab order. If you want to prevent a control from being available when you tab through the controls in a form, set the control's TabStop property to No.

In Form view, hidden or disabled controls remain in the tab order but are skipped when you move through the controls by pressing TAB, even if their TabStop properties are set to Yes.

As long as a control's Enabled property is set to Yes, you can click the control or use an access key to select it, regardless of its TabStop property setting. For example, you can set the TabStop property of a command button to No to prevent users from selecting the button by pressing TAB. However, they can still click the command button to choose it.

Example

The following example disables the ability to move the focus to the "City" text box on the "Suppliers" form by using the TAB key.

VBA Copy code Copy code
Forms("Suppliers").Controls("City").TabStop = False

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Validation rules and default values cannot be placed on system or linked tables. (Error 3312)

 Copy code hover
[image]

Validation rules and default values cannot be placed on system or linked tables. (Error 3312)
Send feedback

You are trying to set the DefaultValue, ValidationRule, ValidationText, or Required property on a table, field, or other object that is prohibited by your application. For example, you are setting a property on a system object.


Cannot modify table structure. Another user has the table open. (Error 3422)

 Copy code hover
[image]

Cannot modify table structure. Another user has the table open. (Error 3422)
Send feedback

The Microsoft Access database engine was unable to modify the structure of a table because another user currently has the table open. Wait until the table is closed, and then try making your changes again.


Control.GridlineStyleTop Property (Access)

 Copy code hover
[image]

Control.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified control. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleTop

expression A variable that represents a Control object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

Control Object

Other resources

Control Object Members


Form.DatasheetAlternateBackColor Property (Access)

 Copy code hover
[image]

Form.DatasheetAlternateBackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color displayed on alternate rows of a form's datasheet. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .DatasheetAlternateBackColor

expression A variable that represents a Form object.

See also

Concepts

Form Object

Other resources

Form Object Members


CommandButton.KeyDown Event (Access)

 Copy code hover
[image]

CommandButton.KeyDown Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyDown(KeyCode, Shift)

expression A variable that represents a CommandButton object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyDown property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyDown event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyDown event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyDown event occurs when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

Example

The following example determines whether you have pressed the SHIFT, CTRL, or ALT key.

To try the example, add the following event procedure to a form containing a text box named KeyHandler.

VBA Copy code Copy code
Private Sub KeyHandler_KeyDown(KeyCode As Integer, _
     Shift As Integer)
    Dim intShiftDown As Integer, intAltDown As Integer
    Dim intCtrlDown As Integer

    ' Use bit masks to determine which key was pressed.
    intShiftDown = (Shift And acShiftMask) > 0
    intAltDown = (Shift And acAltMask) > 0
    intCtrlDown = (Shift And acCtrlMask) > 0
    ' Display message telling user which key was pressed.
    If intShiftDown Then MsgBox "You pressed the SHIFT key."
    If intAltDown Then MsgBox "You pressed the ALT key."
    If intCtrlDown Then MsgBox "You pressed the CTRL key."
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


BoundObjectFrame Properties (Access)

 Copy code hover
[image]

BoundObjectFrame Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Action | You can use the Action property in Visual Basic to specify the operation to perform on an OLE object. Read/write Integer.
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoActivate | You can use the AutoActivate property to specify how the user can activate an OLE object. Read/write Integer.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the object frame and its bottom gridline. Read/write Integer.
Class | You can use the Class property to specify or determine the class name of an embeddedOLE object. Read/write String.
ColumnHidden | You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.
ColumnOrder | You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.
ColumnWidth | You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayType | You can use the DisplayType property to specify whether Microsoft Access displays an OLE object's content or an icon. Read/write Boolean.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
GridlineColor | Gets or sets the color of the gridline for the specified object frame. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified frame. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified frame. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified frame. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified frame. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified frame. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified frame. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified frame. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified frame. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the object frame is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified object frame. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified object frame. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the object frame and its left gridline. Read/write Integer.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Object | You can use the Object property in Visual Basic to return a reference to the ActiveX object that is associated with a linked or embedded OLE object in a control. By using this reference, you can access the properties or invoke the methods of the OLE object. Read-only Object.
ObjectPalette | The ObjectPalette property specifies the palette in the application used to create an OLE object. Read/write Variant.
ObjectVerbs | You can use the ObjectVerbs property in Visual Basic to determine the list of verbs an OLE object supports. Read-only String.
ObjectVerbsCount | You can use the ObjectVerbsCount property in Visual Basic to determine the number of verbs supported by an OLE object. Read-only Long.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OLEType | You can use the OLEType property to determine if a control contains an OLE object, and, if so, whether the object is linked or embedded. Read/write Byte.
OLETypeAllowed | You can use the OLETypeAllowed property to specify the type of OLE object a control can contain. Read/write Byte.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnUpdated | Sets or returns the value of the On Updated box in the Properties window of a form or report. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
RightPadding | Gets or sets the amount of space (in inches) between the object frame and its right gridline. Read/write Integer.
Scaling | Controls how the contents of an object frame control are displayed. Read/write Byte.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SizeMode | You can use the SizeMode property to specify how to size a picture or other object in a bound object frame, an unbound object frame, or an image control.
SourceDoc | You can use the SourceDoc property to specify the file to create a link to or to embed when you create a linked object or embedded object by using the Action property in Visual Basic. Read/write String.
SourceItem | You can use the SourceItem property to specify the data within a file to be linked when you create a linked OLE object. Read/write String.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the object frame and its top gridline. Read/write Integer.
UpdateOptions | You can use the UpdateOptions property to specify how a linkedOLE object is updated. Read/write Integer.
Value | Gets of sets the value of the field that the control is bound to. Read/write Variant.
VarOleObject | Gets a pointer to an IOLEObject that represents the memory address of an OLE object. Read-only Variant.
Verb | You can use the Verb property to specify the operation to perform when an OLE object is activated, which is permitted when the control'sAction property is set to acOLEActivate. Read/write Long.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified object frame is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


Control.Undo Method (Access)

 Copy code hover
[image]

Control.Undo Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the Undo method to reset a control or form when its value has been changed.

Syntax

expression .Undo

expression A variable that represents a Control object.

Remarks

For example, you can use the Undo method to clear a change to a record that contains an invalid entry.

If the Undo method is applied to a form, all changes to the current record are lost. If the Undo method is applied to a control, only the control itself is affected.

This method must be applied before the form or control is updated. You may want to include this method in a form's BeforeUpdate event or in a control's Change event.

The Undo method offers an alternative to using the SendKeys statement to send the value of the ESC key in an event procedure.

Example

The following example shows how you can use the Undo method within a control's Change event procedure to force a field named LastName to reset to its original value, if it changed.

VBA Copy code Copy code
Private Sub LastName_Change()
 Me!LastName.Undo
End Sub

The next example uses the Undo method to reset all changes to a form before the form is updated.

VBA Copy code Copy code
Private Sub Form_BeforeUpdate(Cancel As Integer)
 Me.Undo
End Sub

See also

Concepts

Control Object

Other resources

Control Object Members


Left Function (Access 2013 custom web app)

 Copy code hover
[image]

Left Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the left part of a character string with the specified number of characters.

Syntax

Left(TextExpression, Length)

The Left function contains the following arguments.

Argument name | Description
TextExpression | A text expression.
Length | Is a positive integer that specifies how many characters of the TextExpression are returned.


Label.GridlineShade Property (Access)

 Copy code hover
[image]

Label.GridlineShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineShade

expression A variable that represents an Label object.

Remarks

The GridlineShade property contains a numeric expression that can be used to darken the theme color in the GridlineColor property. The default value of the GridlineShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

Label Object

Other resources

Label Object Members


Application.Eval Method (Access)

 Copy code hover
[image]

Application.Eval Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the Eval function to evaluate an expression that results in a text string or a numeric value.

Syntax

expression .Eval(StringExpr)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
StringExpr | Required | String | An expression that evaluates to an alphanumeric text string. For example, stringexpr can be a function that returns a string or a numeric value. Or it can be a reference to a control on a form. The stringexpr argument must evaluate to a string or numeric value; it can't evaluate to a Microsoft Access object.

Return Value

Variant

Remarks

You can construct a string and then pass it to the Eval function as if the string were an actual expression. The Eval function evaluates the string expression and returns its value. For example, Eval("1 + 1") returns 2.

If you pass to the Eval function a string that contains the name of a function, the Eval function returns the return value of the function. For example, Eval("Chr$(65)") returns "A".

Note Note

If you are passing the name of a function to the Eval function, you must include parentheses after the name of the function in the stringexpr argument. For example:

VBA Copy code Copy code
' ShowNames is user-defined function.
Debug.Print Eval("ShowNames()")
VBA Copy code Copy code
Debug.Print Eval("StrComp(""Joe"",""joe"", 1)")
VBA Copy code Copy code
Debug.Print Eval("Date()")

You can use the Eval function in a calculated control on a form or report, or in a macro or module. The Eval function returns a Variant that is either a string or a numeric type.

The argument stringexpr must be an expression that is stored in a string. If you pass to the Eval function a string that doesn't contain a numeric expression or a function name but only a simple text string, a run-time error occurs. For example, Eval("Smith") results in an error.

You can use the Eval function to determine the value stored in the Value property of a control. The following example passes a string containing a full reference to a control to the Eval function. It then displays the current value of the control in a dialog box.

VBA Copy code Copy code
Dim ctl As Control
Dim strCtl As String

Set ctl = Forms!Employees!LastName
strCtl = "Forms!Employees!LastName"
MsgBox ("The current value of " & ctl.Name & " is " & Eval(strCtl))

You can use the Eval function to access expression operators that aren't ordinarily available in Visual Basic. For example, you can't use the SQL operators Between...And or In directly in your code, but you can use them in an expression passed to the Eval function.

The next example determines whether the value of a ShipRegion control on an Orders form is one of several specified state abbreviations. If the field contains one of the abbreviations, intState will be True (-1). Note that you use single quotation marks (') to include a string within another string.

VBA Copy code Copy code
Dim intState As Integer
intState = Eval("Forms!Orders!ShipRegion In " _
 & "('AK', 'CA', 'ID', 'WA', 'MT', 'NM', 'OR')")

Example

The following example assumes that you have a series of 50 functions defined as A1, A2, and so on. This example uses the Eval function to call each function in the series.

VBA Copy code Copy code
Sub CallSeries()

 Dim intI As Integer

 For intI = 1 To 50
 Eval("A" & intI & "()")
 Next intI

End Sub

The next example triggers a Click event as if the user had clicked a button on a form. If the value of the button's OnClick property begins with an equal sign (=), signifying that it s the name of a function, the Eval function calls the function, which is equivalent to triggering the Click event. If the value doesn't begin with an equal sign, then the value must name a macro. The RunMacro method of the DoCmd object runs the named macro.

VBA Copy code Copy code
Dim ctl As Control
Dim varTemp As Variant

Set ctl = Forms!Contacts!HelpButton
If (Left(ctl.OnClick, 1) = "=") Then
 varTemp = Eval(Mid(ctl.OnClick,2))
Else
 DoCmd.RunMacro ctl.OnClick
End If

See also

Concepts

Application Object

Other resources

Application Object Members


CustomControl.Properties Property (Access)

 Copy code hover
[image]

CustomControl.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a CustomControl object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


DoCmd.AddMenu Method (Access)

 Copy code hover
[image]

DoCmd.AddMenu Method (Access)
See also Send feedback

Published: July 16, 2012

The AddMenu method carries out the AddMenu action in Visual Basic.

Syntax

expression .AddMenu(MenuName, MenuMacroName, StatusBarText)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
MenuName | Required | Variant | A string expression that's the valid name of a drop-down menu to add to the custom menu bar or global menu bar. To create an access key so that you can use the keyboard to choose the menu, type an ampersand (&) before the letter you want to be the access key. This letter will be underlined in the menu name on the menu bar.
MenuMacroName | Required | Variant | A string expression that's the valid name of the macro group that contains the macros for the menu's commands. This is a required argument.
StatusBarText | Required | Variant | A string expression that's the text to display in the status bar when the menu is selected.

Remarks

You can use the AddMenu action to create:

  • A custom menu bar for a form or report. The custom menu bar replaces the built-in menu bar for the form or report.

  • A custom shortcut menu for a form, form control, or report. The custom shortcut menu replaces the built-in shortcut menu for the form, form control, or report.

  • A global menu bar. The global menu bar replaces the built-in menu bar for all Microsoft Access windows, except where you've added a custom menu bar for a form or report.

  • A global shortcut menu. The global shortcut menu replaces the built-in shortcut menu for fields in table and query datasheets, forms in Form view, Datasheet view, and Print Preview, and reports in Print Preview, except where you've added a custom shortcut menu for a form, form control, or report.

You must include the menuname and menumacroname arguments in the AddMenu method for custom menu bars and global menu bars. The menuname argument is not required and will be ignored for custom shortcut menus and global shortcut menus.

The statusbartext argument is optional, this argument is ignored for custom shortcut menus and global shortcut menus.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


ImportExportSpecification.Parent Property (Access)

 Copy code hover
[image]

ImportExportSpecification.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only Object.

Version Information

Version Added: Access 2007

Syntax

expression .Parent

expression A variable that represents an ImportExportSpecification object.

See also

Concepts

ImportExportSpecification Object

Other resources

ImportExportSpecification Object Members


SmartTag.Properties Property (Access)

 Copy code hover
[image]

SmartTag.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a SmartTagProperties collection that represents the collection of properties for a particular smart tag. Read-only.

Syntax

expression .Properties

expression A variable that represents a SmartTag object.

See also

Concepts

SmartTag Object

Other resources

SmartTag Object Members


How to: Format Dates as U.S. Dates Regardless of Regional Settings

 Copy code hover
[image]

How to: Format Dates as U.S. Dates Regardless of Regional Settings
Send feedback

When you use Visual Basic for Applications (VBA) to concatenate dates into an SQL string, you must use a standard U.S. date format, regardless of the region that you have set in the Regional Settings tool in Control Panel. This topic contains a custom function that will convert any date into a U.S. date format.

VBA Copy code Copy code
Function MakeUSDate(DateIn As Variant) As String

 ' Do nothing if the value is not a date.
 If Not IsDate(DateIn) Then Exit Function

 ' Convert the date to a U.S. Date format.
 MakeUSDate = "#" & Month(DateIn) & "/" & Day(DateIn) & "/" & Year(DateIn) & "#"
End Function


Container.Documents Property (DAO)

 Copy code hover
[image]

Container.Documents Property (DAO)
Send feedback

Returns a Documents collection that contains all of the documents stored in the specified object. Read-only.

Syntax

expression .Documents

expression A variable that represents a Container object.


ListBox.ValidationRule Property (Access)

 Copy code hover
[image]

ListBox.ValidationRule Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.

Syntax

expression .ValidationRule

expression A variable that represents a ListBox object.

Remarks

Enter an expression for the ValidationRule property setting and text for the ValidationText property setting. The maximum length for the ValidationRule property setting is 2048 characters. The maximum length for the ValidationText property setting is 255 characters.

For controls, you can set the ValidationRule property to any valid expression. For field and record validation rules, the expression can't contain user-defined functions, domain aggregate or aggregate functions, the Eval function, or CurrentUser method, or references to forms, queries, or tables. In addition, field validation rules can't contain references to other fields. For records, expressions can include references to fields in that table.

For table fields and records, you can also set these properties in Visual Basic by using the DAO ValidationRule property.

Microsoft Access automatically validates values based on a field's data type; for example, Microsoft Access doesn't allow text in a numeric field. You can set rules that are more specific by using the ValidationRule property.

If you set the ValidationRule property but not the ValidationText property, Microsoft Access displays a standard error message when the validation rule is violated. If you set the ValidationText property, the text you enter is displayed as the error message.

For example, when a record is added for a new employee, you can enter a ValidationRule property requiring that the value in the employee's StartDate field fall between the company's founding date and the current date. If the date entered isn't in this range, you can display the ValidationText property message: "Start date is incorrect."

If you create a control by dragging a field from the field list, the field's validation rule remains in effect, although it isn't displayed in the control's ValidationRule property box in the property sheet. This is because a field's validation rule is inherited by a control bound to that field.

Control, field, and record validation rules are applied as follows:

  • Validation rules you set for fields and controls are applied when you edit the data and the focus leaves the field or control.

  • Validation rules for records are applied when you move to another record.

  • If you create validation rules for both a field and a control bound to the field, both validation rules are applied when you edit data and the focus leaves the control.

The following table contains expression examples for the ValidationRule and ValidationText properties.

ValidationRule property | ValidationText property
<> 0 | Entry must be a nonzero value.
> 1000 Or Is Null | Entry must be blank or greater than 1000.
Like "A????" | Entry must be 5 characters and begin with the letter "A".
>= #1/1/96# And <#1/1/97# | Entry must be a date in 1996.
DLookup("CustomerID", "Customers", "CustomerID = Forms!Customers!CustomerID") Is Null | Entry must be a unique CustomerID (domain aggregate functions are allowed only for form-level validation).

If you create a validation rule for a field, Microsoft Access doesn't normally allow a Null value to be stored in the field. If you want to allow a Null value, add "Is Null" to the validation rule, as in "<> 8 Or Is Null" and make sure the Required property is set to No.

You can't set field or record validation rules for tables created outside Microsoft Access (for example, dBASE, Paradox, or SQL Server). For these kinds of tables, you can create validation rules for controls only.

Example

The following example creates a validation rule for a field that allows only values over 65 to be entered. If a number less than 65 is entered, a message is displayed. The properties are set by using the SetFieldValidation function.

VBA Copy code Copy code
Dim strTblName As String, strFldName As String
Dim strValidRule As String
Dim strValidText As String, intX As Integer

strTblName = "Customers"
strFldName = "Age"
strValidRule = ">= 65"
strValidText = "Enter a number greater than or equal to 65."
intX = SetFieldValidation(strTblName, strFldName, _
 strValidRule, strValidText)

Function SetFieldValidation(strTblName As String, _
 strFldName As String, strValidRule As String, _
 strValidText As String) As Integer

 Dim dbs As Database, tdf As TableDef, fld As Field

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 Set fld = tdf.Fields(strFldName)
 fld.ValidationRule = strValidRule
 fld.ValidationText = strValidText
End Function

The next example uses the SetTableValidation function to set record-level validation to ensure that the value in the EndDate field comes after the value in the StartDate field.

VBA Copy code Copy code
Dim strTblName As String, strValidRule As String
Dim strValidText As String
Dim intX As Integer

strTblName = "Employees"
strValidRule = "EndDate > StartDate"
strValidText = "Enter an EndDate that is later than the StartDate."
intX = SetTableValidation(strTblName, strValidRule, strValidText)

Function SetTableValidation(strTblName As String, _
 strValidRule As String, strValidText As String) _
 As Integer

 Dim dbs As Database, tdf As TableDef

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 tdf.ValidationRule = strValidRule
 tdf.ValidationText = strValidText
End Function

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


OptionButton.Height Property (Access)

 Copy code hover
[image]

OptionButton.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Syntax

expression .Height

expression A variable that represents an OptionButton object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


OptionButton.StatusBarText Property (Access)

 Copy code hover
[image]

OptionButton.StatusBarText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.

Syntax

expression .StatusBarText

expression A variable that represents an OptionButton object.

Remarks

You set the StatusBarText property by using a string expression up to 255 characters long.

Note Note

The length of the text you can display in the status bar depends on your computer hardware and video display.

You can use the StatusBarText property to provide specific information about a control. For example, when a text box has the focus, a brief instruction can tell the user what kind of data to enter

Note Note

You can also use the ControlTipText property to display a ScreenTip for a control.

If you create a control by dragging a field from the field list, the value in a field's Description property is copied to the StatusBarText property.

Example

The following example sets the status bar text to be displayed when the "Address_TextBox" control in the "Mailing List" form has the focus in Form View.

VBA Copy code Copy code
Forms("Mailing List").Controls("Address_TextBox"). _
 StatusBarText = "Enter the company's mailing address."

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


BOF, EOF, and Bookmark Properties Example (VC++)

 Copy code hover
[image]

BOF, EOF, and Bookmark Properties Example (VC++)
Send feedback

The first function in this example uses the BOF and EOF properties to display a message if a user tries to move past the first or last record of a Recordset. It uses the Bookmark property to let the user flag a record in a Recordset and return to it later.

The second function uses the Bookmark property to place the Bookmark of every other record from a Recordset into an array, and then filters the Recordset using the array.

Copy code Copy code

// BeginBOFCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>
#include "BofEofBookmark.h"

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void BOFX(void);
void BookmarkX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////////////////////////////////
// //
// BOFX Function //
// //
///////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 BOFX();

 //Clear the screen for the next display
 system("cls");

 BookmarkX();

 printf("Press any key to continue...");
 getch();

 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// BOFX Function //
// //
///////////////////////////////////////////////////////////

void BOFX(void)
{
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace
 _RecordsetPtr rstPublishers = NULL;

 //Define Other Variables
 HRESULT hr = S_OK;
 IADORecordBinding *picRs = NULL; //Interface Pointer declared.
 CPublishers Publs;

 bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");
 _bstr_t strMessage;
 _variant_t VarBookmark;
 int intCommand = 0;
 _variant_t TempPublisher;

 try
 {
 // Open recordset with data from Publishers table.
 TESTHR(rstPublishers.CreateInstance(__uuidof(Recordset)));
 rstPublishers->CursorType = adOpenStatic;

 // Use client cursor to enable absolutePosition property.
 rstPublishers->CursorLocation = adUseClient;
 rstPublishers->Open("select pub_id, pub_name from publishers"
 " order by pub_name", strCnn, adOpenStatic,
 adLockBatchOptimistic, adCmdText);

 //Open an IADORecordBinding interface pointer
 //which will be used for Binding Recordset to a class
 TESTHR(rstPublishers->QueryInterface(
 __uuidof(IADORecordBinding), (LPVOID*)&picRs));

 //Bind the Recordset to a C++ Class here
 TESTHR(picRs->BindToRecordset(&Publs));

 rstPublishers->MoveFirst();

 while (true) // Continuous loop.
 {
 // Display information about the current record
 // and get user input
 printf("Publisher:%s \n Record %d of %d\n\n",
 Publs.lP_pubnameStatus == adFldOK ?
 Publs.m_szP_pubname : "<NULL>",
 rstPublishers->AbsolutePosition,
 rstPublishers->RecordCount);
 printf("Enter command:\n ");
 printf("[1 - next / 2 - previous /\n");
 printf(" 3 - set bookmark / 4 - go to bookmark /\n");
 printf(" 5 - quit ]\n");

 scanf("%d", &intCommand);
 if ((intCommand < 1) || (intCommand > 4))
 break; // Out of range entry exits program loop.

 switch(intCommand)
 {
 // Move forward or backward, trapping for BOF or EOF
 case 1:
 rstPublishers->MoveNext();
 if (rstPublishers->EndOfFile)
 {
 printf("\nCannot move past the last record."
 " Try again...\n");
 rstPublishers->MoveLast();
 }
 break;

 case 2:
 rstPublishers->MovePrevious();
 if (rstPublishers->BOF)
 {
 printf("\nCannot move before the first record."
 " Try again...\n");
 rstPublishers->MoveFirst();
 }
 break;

 // store the bookmark of the current record.
 case 3:
 VarBookmark = rstPublishers->Bookmark;
 // Go to the record indicated by the
 // stored bookmark
 break;

 case 4:
 // Check for whether bookmark set for a record
 if (VarBookmark.vt == VT_EMPTY)
 printf("No Bookmark set!\n");
 else
 rstPublishers->Bookmark = VarBookmark;
 break;

 default:
 break;
 }
 }
 }
 catch (_com_error &e)
 {
 printf("Error in BOFx...\n");
 // Notify the user of errors if any.
 _variant_t vtConnect = rstPublishers->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 printf("Error:\n");
 printf("Code = %08lx\n", e.Error());
 printf("Message = %s\n", e.ErrorMessage());
 printf("Source = %s\n", (LPCSTR) e.Source());
 printf("Description = %s\n", (LPCSTR) e.Description());
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 printf("Press any key to continue...");
 getch();
 }

 // Clean up objects before exit.
 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (rstPublishers)
 if (rstPublishers->State == adStateOpen)
 rstPublishers->Close();
}

///////////////////////////////////////////////////////////
// //
// BookmarkX Function //
// //
///////////////////////////////////////////////////////////

void BookmarkX(void)
{
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr rstAuthors = NULL;

 //Define Other Variables
 IADORecordBinding *picRs = NULL; //Interface Pointer declared.
 CAuthors Authrs;
 HRESULT hr = S_OK;
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");
 _variant_t vBookmark;

 // Variable declaration for safe arrays.
 SAFEARRAY FAR* psa;

 // define ARRAY/ VARIANT variant.
 vBookmark.vt = VT_ARRAY|VT_VARIANT;
 SAFEARRAYBOUND rgsabound[1];
 rgsabound[0].lLbound = 0;
 rgsabound[0].cElements = 11;
 long ii = 0;

 try
 {
 rstAuthors.CreateInstance(__uuidof(Recordset));
 // Set The Cursor Location
 rstAuthors->CursorLocation = adUseClient;
 rstAuthors->PutActiveConnection((_variant_t)strCnn);

 // Open Authors table
 TESTHR(rstAuthors->Open("select * from authors",strCnn,
 adOpenStatic,adLockBatchOptimistic,adCmdText));

 //Open an IADORecordBinding interface pointer
 //which we'll use for binding Recordset to a class
 TESTHR(rstAuthors->QueryInterface(__uuidof(IADORecordBinding),
 (LPVOID*)&picRs));

 //Bind the Recordset to a C++ Class here
 TESTHR(picRs->BindToRecordset(&Authrs));

 printf("Number of Records before filtering: %d\n",
 rstAuthors->RecordCount);

 // Create safearrays to store array of variant
 psa = SafeArrayCreate(VT_VARIANT,1,rgsabound);

 // Store bookmark of every other record into an array.
 while ((!rstAuthors->EndOfFile) && (ii < 11))
 {
 SafeArrayPutElement(psa,&ii,&rstAuthors->Bookmark);
 //ii = ii +1;
 ii++;
 rstAuthors->Move(2);
 }

 vBookmark.parray = psa;

 // Filter the Record with the array of bookmarks.
 rstAuthors->put_Filter(vBookmark);
 printf("Number of Records after filtering: %d\n",
 rstAuthors->RecordCount);
 rstAuthors->MoveFirst();

 while (!rstAuthors->EndOfFile)
 {
 printf("%d %s\n",rstAuthors->AbsolutePosition,
 Authrs.lau_lnameStatus == adFldOK ?
 Authrs.m_szau_lname : "<NULL>");
 rstAuthors->MoveNext();
 }
 }
 catch (_com_error &e)
 {
 // Notify the user of errors if any.
 _variant_t vtConnect = rstAuthors->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 printf("Error:\n");
 printf("Code = %08lx\n", e.Error());
 printf("Message = %s\n", e.ErrorMessage());
 printf("Source = %s\n", (LPCSTR) e.Source());
 printf("Description = %s\n", (LPCSTR) e.Description());
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (rstAuthors)
 if (rstAuthors->State == adStateOpen)
 rstAuthors->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;
 long nCount = 0;
 long i = 0;

 if( (pConnection->Errors->Count) > 0)
 {
 nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}
// EndBOFCpp

BofEofBookmark.h

Copy code Copy code

// BeginBOFEOFH
#include "icrsint.h"

//This Class extracts only pubid,lastname and hire_date
class CPublishers : public CADORecordBinding
{
BEGIN_ADO_BINDING(CPublishers)

 //Column title is the 2nd field in the recordset
 ADO_VARIABLE_LENGTH_ENTRY2(1, adVarChar, m_szP_pubid,
 sizeof(m_szP_pubid), lP_pubidStatus, FALSE)

 //Column type is the 3rd field in the recordset
 ADO_VARIABLE_LENGTH_ENTRY2(2, adVarChar, m_szP_pubname,
 sizeof(m_szP_pubname), lP_pubnameStatus, TRUE)

END_ADO_BINDING()

public:
 CHAR m_szP_pubid;
 ULONG lP_pubidStatus;
 CHAR m_szP_pubname[40];
 ULONG lP_pubnameStatus;
};

//This Class extracts only authorlastname

class CAuthors : public CADORecordBinding
{
BEGIN_ADO_BINDING(CAuthors)

 //Column authorlname is the 2nd field in the recordset
 ADO_VARIABLE_LENGTH_ENTRY2(2, adVarChar, m_szau_lname,
 sizeof(m_szau_lname), lau_lnameStatus, FALSE)

END_ADO_BINDING()

public:
 CHAR m_szau_lname[40];
 ULONG lau_lnameStatus;
};
// EndBOFEOFH


SubForm.BorderStyle Property (Access)

 Copy code hover
[image]

SubForm.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Syntax

expression .BorderStyle

expression A variable that represents a SubForm object.

Remarks

For forms, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Stat Method (ADO)

 Copy code hover
[image]

Stat Method (ADO)
Send feedback

Retrieves information about a Stream object.

Syntax

Long stream.Stat(StatStg, StatFlag)

Return Value

A long value indicating the status of the operation.

Parameters

  • StatStg

  • A STATSTG structure that will be filled in with information about the stream. The implementation of the Stat method used by the ADO Stream object does not fill in all of the fields of the structure.

  • StatFlag

  • Specifies that this method does not return some of the members in the STATSTG structure, thus saving a memory allocation operation. Values are taken from the STATFLAG enumeration.

    The STATFLAG enumeration has two values

    Constant

    Value

    STATFLAG_DEFAULT

    0

    STATFLAG_NONAME

    1

Remarks

The version of the Stat method implemented for the ADO Stream object fills in the following fields of the STATSTG structure:

  • pwcsName

  • A string containing the name of the stream, if one is available and the StatFlag value STATFLAG_NONAME was not specified.

  • cbSize

  • Specifies the size in bytes of the stream or byte array.

  • mtime

  • Indicates the last modification time for this storage, stream, or byte array.

  • ctime

  • Indicates the creation time for this storage, stream, or byte array.

  • atime

  • Indicates the last access time for this storage, stream or byte array.

If STATFLAG_NONAME is specified in the StatFlag parameter, the name of the stream is not returned.

If STATFLAG_NONAME was not specified in the StatFlag parameter, and there is no name available for the current stream, this value will be E_NOTIMPL.


Printer.PaperBin Property (Access)

 Copy code hover
[image]

Printer.PaperBin Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets an AcPrintPaperBin constant indicating which paper bin the specified printer should use. Read/write.

Syntax

expression .PaperBin

expression A variable that represents a Printer object.

Example

The following example sets a variety of printer settings for the form specified in the strFormname argument of the procedure.

VBA Copy code Copy code
Sub SetPrinter(strFormname As String)

 DoCmd.OpenForm FormName:=strFormname, view:=acDesign, _
 datamode:=acFormEdit, windowmode:=acHidden

 With Forms(form1).Printer

 .TopMargin = 1440
 .BottomMargin = 1440
 .LeftMargin = 1440
 .RightMargin = 1440

 .ColumnSpacing = 360
 .RowSpacing = 360

 .ColorMode = acPRCMColor
 .DataOnly = False
 .DefaultSize = False
 .ItemSizeHeight = 2880
 .ItemSizeWidth = 2880
 .ItemLayout = acPRVerticalColumnLayout
 .ItemsAcross = 6

 .Copies = 1
 .Orientation = acPRORLandscape
 .Duplex = acPRDPVertical
 .PaperBin = acPRBNAuto
 .PaperSize = acPRPSLetter
 .PrintQuality = acPRPQMedium

 End With

 DoCmd.Close objecttype:=acForm, objectname:=strFormname, _
 Save:=acSaveYes

End Sub

See also

Concepts

Printer Object

Other resources

Printer Object Members


INSERT INTO Statement (Microsoft Access SQL)

 Copy code hover
[image]

INSERT INTO Statement (Microsoft Access SQL)
Send feedback

Adds a record or multiple records to a table. This is referred to as an append query.

Syntax

Multiple-record append query:

INSERT INTO target [(field1[, field2[, …]])] [IN externaldatabase] SELECT [source.]field1[, field2[, …] FROM tableexpression

Single-record append query:

INSERT INTO target [(field1[, field2[, …]])] VALUES (value1[, value2[, …])

The INSERT INTO statement has these parts:

Part | Description
target | The name of the table or query to append records to.
field1, field2 | Names of the fields to append data to, if following a target argument, or the names of fields to obtain data from, if following a source argument.
externaldatabase | The path to an external database. For a description of the path, see the IN clause.
source | The name of the table or query to copy records from.
tableexpression | The name of the table or tables from which records are inserted. This argument can be a single table name or a compound resulting from an INNER JOIN, LEFT JOIN, or RIGHT JOIN operation or a saved query.
value1, value2 | The values to insert into the specific fields of the new record. Each value is inserted into the field that corresponds to the value's position in the list: value1 is inserted into field1 of the new record, value2 into field2, and so on. You must separate values with a comma, and enclose text fields in quotation marks (' ').

Remarks

You can use the INSERT INTO statement to add a single record to a table using the single-record append query syntax as shown above. In this case, your code specifies the name and value for each field of the record. You must specify each of the fields of the record that a value is to be assigned to and a value for that field. When you do not specify each field, the default value or Null is inserted for missing columns. Records are added to the end of the table.

You can also use INSERT INTO to append a set of records from another table or query by using the SELECT … FROM clause as shown above in the multiple-record append query syntax. In this case, the SELECT clause specifies the fields to append to the specified target table.

The source or target table may specify a table or a query. If a query is specified, the Microsoft Access database engine appends records to any and all tables specified by the query.

INSERT INTO is optional but when included, precedes the SELECT statement.

If your destination table contains a primary key, make sure you append unique, non-Null values to the primary key field or fields; if you do not, the Microsoft Access database engine will not append the records.

If you append records to a table with an AutoNumber field and you want to renumber the appended records, do not include the AutoNumber field in your query. Do include the AutoNumber field in the query if you want to retain the original values from the field.

Use the IN clause to append records to a table in another database.

To create a new table, use the SELECT… INTO statement instead to create a make-table query.

To find out which records will be appended before you run the append query, first execute and view the results of a select query that uses the same selection criteria.

An append query copies records from one or more tables to another. The tables that contain the records you append are not affected by the append query.

Instead of appending existing records from another table, you can specify the value for each field in a single new record using the VALUES clause. If you omit the field list, the VALUES clause must include a value for every field in the table; otherwise, the INSERT operation will fail. Use an additional INSERT INTO statement with a VALUES clause for each additional record you want to create.

Links provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Generating sequential numbers for INSERT/UPDATE statements

  • SQL to VBA Formatter

Example

This example selects all records in a hypothetical New Customers table and adds them to the Customers table. When individual columns are not designated, the SELECT table column names must match exactly those in the INSERT INTO table.

VBA Copy code Copy code
Sub InsertIntoX1()

    Dim dbs As Database

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Select all records in the New Customers table
    ' and add them to the Customers table.
    dbs.Execute " INSERT INTO Customers " _
        & "SELECT * " _
        & "FROM [New Customers];"

    dbs.Close

End Sub

This example creates a new record in the Employees table.

VBA Copy code Copy code
Sub InsertIntoX2()

    Dim dbs As Database

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Create a new record in the Employees table. The
    ' first name is Harry, the last name is Washington,
    ' and the job title is Trainee.
    dbs.Execute " INSERT INTO Employees " _
        & "(FirstName,LastName, Title) VALUES " _
        & "('Harry', 'Washington', 'Trainee');"

    dbs.Close

End Sub

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.


CodeProject.Application Property (Access)

 Copy code hover
[image]

CodeProject.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a CodeProject object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


Access Data Access How Do I...

 Copy code hover
[image]

Access Data Access How Do I...
Send feedback

This page links to help on widely used data-access tasks. To view other categories of popular tasks covered in Help, see How Do I… in Access.

Structured Query Language (SQL)

  • How to: Build SQL Statements That Include Variables and Controls

    • Describes how to to construct an SQL statement that includes variables and control values in code.

  • How to: Create and Delete Tables and Indexes Using Access SQL

    • Describes how to use Access SQL to create and delete tables and indexes.

  • How to: Define Relationships Between Tables Using Access SQL

    • Describes how to use Access SQL to define relationships.

  • How to: Group Records in a Result Set Using Access SQL

    • Describes how to use the GORUP BY clause to group related records.

  • How to: Insert, Update, and Delete Records From a Table Using Access SQL

    • Describes how to use Access SQL to add, update, and delete records from a table.

  • How to: Modify a Table's Design Using Access SQL

    • Describes how to modify a table's design using Access SQL.

  • How to: Perform Joins Using Access SQL

    • Describes how to use Access SQL to perform joins.

  • How to: Retrieve Records Using Access SQL

    • Describes how to use Access SQL to retrieve records.

  • How to: Use Aggregate Functions to Work with Values in Access SQL

    • Describes how to use aggregate functions in Access SQL.

Data Access Objects (DAO)

  • How to: Add a Record to a DAO Recordset

    • Describes how to add a new record to a table-type or dynaset-type Recordset.

  • How to: Build SQL Statements That Include Variables and Controls

    • Describes how to construct an SQL statement that includes variables and control values in code.

  • How to: Change Tables Involved in a One-to-Many Relationship in a DAO Recordset

    • Describes how to freely change the values on the "one" side of a one-to-many relationship.

  • How to: Count the Number of Records in a DAO Recordset

    • Describes how to count the umber of records in a Recordset object.

  • How to: Create a DAO Recordset From a Form

    • Describes how to create a Recordset object based on an Access form.

  • How to: Create a DAO Recordset From a Query

    • Describes how to create a Recordset object based on a stored select query.

  • How to: Create a DAO Recordset From a Table In the Current Database

    • Describes how to create a Recordset object for a table in the current database.

  • How to: Create a User-Defined Property

    • Illustrates how to create and set the value of the new uer-defined property.

  • How to: Delete a Record From a DAO Recordset

    • Describes how to delete a record from a DAO recordset.

  • How to: Detect the Limits of a DAO Recordset

    • Describes how to use the BOF and EOF properties to avoid run-time erros when moving through a recordset.

  • How to: Extract Data from a Record in a DAO Recordset

    • Describes several techniques for extracting data from a DAO Recordset.

  • How to: Find a Record in a Dynaset-Type or Snapshot-Type DAO Recordset

    • Describes how to use the Find methods to locate records in a dynaset-type or snapshot-type recordset.

  • How to: Find a Record in a Table-Type DAO Recordset

    • Describes how to use the Seek method to locate a record in a table-type recordset.

  • How to: Find the Current Position in a DAO Recordset

    • Describes how to find the current position in a recordset.

  • How to: Make Bulk Changes to a DAO Recordset

    • Describes how to efficiently make bulk updates to a recordset.

  • How to: Manipulate Multivalued Fields With DAO

    • Describes how to manipulate records in multivalued fields.

  • How to: Mark a Position in a DAO Recordset

    • Describes how to use the Bookmark property to mark a record in a recordset.

  • How to: Modify a Query from a DAO Recordset

    • Describes how to modify a query's parameters using Access SQL.

  • How to: Modify an Existing Record in a DAO Recordset

    • Describes how to use the Edit and Update methods to modify records.

  • How to: Move Through a DAO Recordset

    • Describes how to use the Move methods to navigate a recordset.

  • How to: Read From and Write To a Field in a DAO Recordset

    • Describes how to use the Value property of a field to read or write data to a record.

  • How to: Return a Random Record from a DAO Recordset

    • Describes how to return a random record from a recordset.

  • How to: Set Properties of Data Access Objects in Visual Basic

    • Describes how to set properties for DAO objects.

  • How to: Sort Data in a DAO Recordset

    • Describes how to sort data in a recordset.

  • How to: Synchronize a DAO Recordset's Record with a Form's Current Record

    • Describes how to synchronize a recordset's record with the form's current record.

  • How to: Track Design Changes to a Table-Type DAO Recordset

    • Describes how to determine when a table was created or last updated.

  • How to: Use Transactions in a DAO Recordset

    • Describes how to use transactions in a DAO recordset.

  • How to: Work With Attachments In DAO

    • Describes how to load and save attachments in a recordset.

ActiveX Data Objects (ADO)

  • How to: Bind a Form to an ADO Recordset

    • Describes how to set a form's Recordset property to an open ADO Recordset object.

  • How to: Build SQL Statements That Include Variables and Controls

    • Describes how to construct an SQL statement that includes variables and control values in code.

  • How to: Create an ADO Connection String

    • Describes the components of an ADO connection string.

  • How to: Set Properties of ActiveX Data Objects in Visual Basic

    • Describes how to set properties for ADO objects.

XML

  • How to: Export a Report to XML

    • Describes how to export the contents of a report to an XML file.

  • How to: Export Data, Schema, and Related Tables to XML

    • Describes how to export data and formatting contained in a table to an XML file.

  • How Do I... in Access


SharedResources Properties (Access)

 Copy code hover
[image]

SharedResources Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Object.
Parent | Returns the parent object for the specified object. Read-only.


Report.AutoCenter Property (Access)

 Copy code hover
[image]

Report.AutoCenter Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Boolean indicating whether a report will be centered automatically in the application window when the form is opened. Read/write.

Syntax

expression .AutoCenter

expression A variable that represents a Report object.

Remarks

The AutoCenter property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The report will be centered automatically on opening.
No | False | (Default) The report upper-left corner will be in the same location as when the form was last saved.

You can set this property only in Design view.

Depending on the size and placement of the application window, reports can appear off to one side of the application window, hiding part of the form or report. Centering the report automatically when it's opened makes it easier to view and use.

See also

Concepts

Report Object

Other resources

Report Object Members


Optimize Property Example (VJ++)

 Copy code hover
[image]

Optimize Property Example (VJ++)
Send feedback

This example demonstrates the Field object dynamic Optimize property. The zip field of the Authors table in the Pubs database is not indexed. Setting the Optimize property to True on the zip field authorizes ADO to build an index that improves the performance of the Find method.

Copy code Copy code

// BeginOptimizeJ
import com.ms.wfc.data.*;
import java.io.* ;

public class OptimizeX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 OptimizeX();
 System.exit(0);
 }

 // OptimizeX function

 static void OptimizeX()
 {

 // Define ADO Objects.
 Recordset rstAuthors = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";

 try
 {
 rstAuthors = new Recordset();
 rstAuthors.setCursorLocation(AdoEnums.CursorLocation.CLIENT);
 // Enable index creation.
 rstAuthors.open("SELECT * FROM Authors",
 strCnn,
 AdoEnums.CursorType.STATIC,
 AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TEXT);
 rstAuthors.getField("zip").getProperties().
 getItem("Optimize").setBoolean(true); // Create the index.
 rstAuthors.find("zip = '94595'"); // Find Akiko Yokomoto.
 System.out.println(rstAuthors.getField("au_fname").getString() +
 " " + rstAuthors.getField("au_lname").getString() + " " +
 rstAuthors.getField("address").getString() + " " +
 rstAuthors.getField("city").getString() + " " +
 rstAuthors.getField("state").getString() + " ");
 rstAuthors.getField("zip").getProperties().
 getItem("Optimize").setBoolean(false); // Delete the index.

 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstAuthors != null)
 {
 PrintProviderError(rstAuthors.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstAuthors != null)
 if (rstAuthors.getState() == 1)
 rstAuthors.close();
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndOptimizeJ


TextBox.CanShrink Property (Access)

 Copy code hover
[image]

TextBox.CanShrink Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the section or control contains. Read/write Boolean.

Syntax

expression .CanShrink

expression A variable that represents a TextBox object.

Remarks

The CanShrink property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The section or control shrinks vertically so that the data it contains can be printed or previewed without leaving blank lines.
No | False | (Default) The section or control doesn't shrink.

This property setting is read-only in a macro or Visual Basic in any view but Design view.

You can use this property to control the appearance of printed forms and reports. When you set the property to Yes, the object automatically adjusts so any amount of data can be printed. When a control shrinks, the controls below it move up the page.

If you set a control's CanShrink property to Yes, Microsoft Access does not set the section's CanShrink property to Yes.

Sections shrink vertically across their entire width. For example, suppose a form has two text boxes side by side in a section, and each control has its CanShrink property set to Yes. If one text box contains one line of data and the other text box contains two lines of data, both text boxes will be two lines long because the section is sized across its entire width. To shrink the data independently, you can place two subform or subreport controls side by side, and set their CanShrink property to Yes.

When you use the CanShrink property, remember that:

  • The property settings don't affect the horizontal spacing between controls; they affect only the vertical space the controls occupy.

  • Overlapping controls can't shrink.

  • The height of a large control can prevent controls beside it from shrinking. For example, if several short controls are on the left side of a report's detail section and one tall control, such as an unbound object frame, is on the right side, the controls on the left won't shrink, even if they contain no data.

Note Note

  • The CanShrink property does not apply to form or report page header and page footer sections, although it does apply to controls in such sections.

  • This property affects the display of form sections and controls only when the form is printed or previewed, not when the form is displayed in Form view, Datasheet view, or Design view.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


StreamOpenOptionsEnum

 Copy code hover
[image]

StreamOpenOptionsEnum
Send feedback

Specifies options for opening a Stream object. The values can be combined with an OR operation.

Constant | Value | Description
adOpenStreamAsync | 1 | Opens the Stream object in asynchronous mode.
adOpenStreamFromRecord | 4 | Identifies the contents of the Source parameter to be an already open Record object. The default behavior is to treat Source as a URL that points directly to a node in a tree structure. The default stream associated with that node is opened.
adOpenStreamUnspecified | -1 | Default. Specifies opening the Stream object with default options.

ADO/WFC Equivalent

These constants do not have ADO/WFC equivalents.


How to: Create a DAO Recordset From a Form

 Copy code hover
[image]

How to: Create a DAO Recordset From a Form
Send feedback

You can create a Recordset object based on an Access form. To do so, use the RecordsetClone property of the form. This creates a dynaset-type Recordset that refers to the same underlying query or data as the form. If a form is based on a query, referring to the RecordsetClone property is the equivalent of creating a dynaset with the same query. You can use the RecordsetClone property when you want to apply a method that cannot be used with forms, such as the FindFirst method. The RecordsetClone property provides access to all the methods and properties that you can use with a dynaset.

The following example shows how to assign a Recordset object to the records in the Orders form.

VBA Copy code Copy code
Dim rstOrders As DAO.Recordset

Set rstOrders = Forms!Orders.RecordsetClone

This code always creates the type of Recordset being cloned (the type of Recordset on which the form is based); no other types are available. Note that the Recordset object is declared with the object library qualification. Because Access can use both DAO and ADO, it is better to fully qualify the data access variables by including the object library reference name.


Design

 Copy code hover
[image]

Design
Send feedback

In this section

  • How to: Create Multiple Instances of a Form

  • How to: Synchronize Two Combo Boxes on a Form

  • How to: Use Date and Time Criteria from a Control on a Form


Report.PaintPalette Property (Access)

 Copy code hover
[image]

Report.PaintPalette Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PaintPalette property to specify a palette to be used by a report. Read/write Variant.

Syntax

expression .PaintPalette

expression A variable that represents a Report object.

Remarks

You can set the PaintPalette property by using a macro or Visual Basic . The property setting must be a String data type containing the palette information.

You can set the PaintPalette property by assigning the value of the ObjectPalette property to the PaintPalette property in a macro or Visual Basic, by setting the PaletteSource property (in which case Microsoft Access automatically sets the PaintPalette property to this PaletteSource), or by setting the PaintPalette property of one form or report to the PaintPalette property of another form or report.

For a report, you can set the PaintPalette property in report Design view only.

When you set the PaintPalette property, Microsoft Access makes a copy of the palette that you specify and saves it with the form or report. The palette is then available if you modify that form or report.

Changes to the palette you specified when you set the PaintPalette property don't affect the copy of the palette stored with the form or report. If you want to update the copy of the palette stored with the form or report, you must rerun the code or macro that sets the PaintPalette property or reset the PaletteSource property when the form or report is open.

When you set the PaintPalette property for a form or report, Microsoft Access automatically updates its PaletteSource property. Conversely, when you set the PaletteSource property for a form or report, the PaintPalette property is also updated. For example, when you specify a custom palette with the PaintPalette property, the PaletteSource property setting is changed to (Custom). The PaintPalette property (which is available only in a macro or Visual Basic) is used to set the palette for the form or report. The PaletteSource property gives you a way to set the palette for the form or report in the property sheet by using an existing graphics file.

Note Note

Windows can have only one color palette active at a time. Microsoft Access allows you to have multiple graphics on a form, each using a different color palette. The PaintPalette and PaletteSource properties let you specify which color palette a form should use when displaying graphics.

You can use the ObjectPalette property to make the palette of an application associated with an OLE object, bitmap, or other graphic contained in a control on a form or report available to the PaintPalette property. For example, to make the palette used in Microsoft Graph available when you're designing a form in Microsoft Access, you set the form's PaintPalette property to the ObjectPalette value of an existing chart control.

Example

The ObjectPalette and PaintPalette properties are useful for programmatically altering the color palette in use by an open form at run time. A common use of these properties is to set the current form's PaintPalette property to the palette of a graphic displayed in a control that has the focus.

For example, you can have a form with an ocean picture, showing many shades of blue, and a sunset picture, showing many shades of red. Since Windows only allows one color palette active at a time, one picture will look much better than the other. The following example uses a control's Enter event for setting the form's PaintPalette property to the control's ObjectPalette property so the graphic that has the focus will have an optimal appearance.

VBA Copy code Copy code
Sub OceanPicture_Enter()
 Me.PaintPalette = Me!OceanPicture.ObjectPalette
End Sub

Sub SunsetPicture_Enter()
 Me.PaintPalette = Me!SunsetPicture.ObjectPalette
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


DataFactoryObject (RDSServer)

 Copy code hover
[image]

DataFactoryObject (RDSServer)
Send feedback

In this section

  • DataFactory Object (RDSServer)

  • DataFactoryObject Properties, Methods, and Events (RDS)


Connections Object Reference (DAO)

 Copy code hover
[image]

Connections Object Reference (DAO)
Send feedback

In this section

  • Connections Collection (DAO)

  • Connections Members (DAO)

  • Connections Properties (DAO)

  • Connections Methods (DAO)


MoveFirst, MoveLast, MoveNext, and MovePrevious Methods (ADO)

 Copy code hover
[image]

MoveFirst, MoveLast, MoveNext, and MovePrevious Methods (ADO)
Send feedback

Moves to the first, last, next, or previous record in a specified Recordset object and makes that record the current record.

Syntax

recordset.{ MoveFirst | MoveLast | MoveNext | MovePrevious}

Remarks

Use the MoveFirst method to move the current record position to the first record in the Recordset.

Use the MoveLast method to move the current record position to the last record in the Recordset. The Recordset object must support bookmarks or backward cursor movement; otherwise, the method call will generate an error.

A call to either MoveFirst or MoveLast when the Recordset is empty (both BOF and EOF are True) generates an error.

Use the MoveNext method to move the current record position one record forward (toward the bottom of the Recordset). If the last record is the current record and you call the MoveNext method, ADO sets the current record to the position after the last record in the Recordset (EOF is True). An attempt to move forward when the EOF property is already True generates an error.

In cases where the Recordset has been filtered or sorted and the current record's data is changed, the position may also change. In such cases the MoveNext method works normally, but you should be aware that the position is moved one record forward from the new position, not the old position. For example, changing the data in the current record, such that the record is moved to the end of the sorted Recordset, would mean that calling MoveNext results in ADO setting the current record to the position after the last record in the Recordset (EOF = True).

Use the MovePrevious method to move the current record position one record backward (toward the top of the Recordset). The Recordset object must support bookmarks or backward cursor movement; otherwise, the method call will generate an error. If the first record is the current record and you call the MovePrevious method, ADO sets the current record to the position before the first record in the Recordset (BOF is True). An attempt to move backward when the BOF property is already True generates an error. If the Recordset object does not support either bookmarks or backward cursor movement, the MovePrevious method will generate an error.

If the Recordset is forward only and you want to support both forward and backward scrolling, you can use the CacheSize property to create a record cache that will support backward cursor movement through the Move method. Because cached records are loaded into memory, you should avoid caching more records than is necessary. You can call the MoveFirst method in a forward-only Recordset object; doing so may cause the provider to re-execute the command that generated the Recordset object.


How to: Suspend Code Execution Until a Pop-up Form is Closed

 Copy code hover
[image]

How to: Suspend Code Execution Until a Pop-up Form is Closed
Send feedback

To ensure that code in a form suspends operation until a pop-up form is closed, you must open the pop-up form as a modalwindow. The following example illustrates how to use the OpenForm method to do this.

VBA Copy code Copy code
doCmd.OpenForm FormName:=<Name of form to open>, WindowMode:=acDialog


Enumerations (DAO Reference)

 Copy code hover
[image]

Enumerations (DAO Reference)
Send feedback

In this section

  • CollatingOrderEnum Enumeration (DAO)

  • CommitTransOptionsEnum Enumeration (DAO)

  • CursorDriverEnum Enumeration (DAO)

  • DatabaseTypeEnum Enumeration (DAO)

  • DataTypeEnum Enumeration (DAO)

  • DriverPromptEnum Enumeration (DAO)

  • EditModeEnum Enumeration (DAO)

  • FieldAttributeEnum Enumeration (DAO)

  • IdleEnum Enumeration (DAO)

  • LanguageConstants Enumeration (DAO)

  • LockTypeEnum Enumeration (DAO)

  • ParameterDirectionEnum Enumeration (DAO)

  • PermissionEnum Enumeration (DAO)

  • QueryDefStateEnum Enumeration (DAO)

  • QueryDefTypeEnum Enumeration (DAO)

  • RecordsetOptionEnum Enumeration (DAO)

  • RecordsetTypeEnum Enumeration (DAO)

  • RecordStatusEnum Enumeration (DAO)

  • RelationAttributeEnum Enumeration (DAO)

  • ReplicaTypeEnum Enumeration (DAO)

  • SetOptionEnum Enumeration (DAO)

  • SynchronizeTypeEnum Enumeration (DAO)

  • TableDefAttributeEnum Enumeration (DAO)

  • UpdateCriteriaEnum Enumeration (DAO)

  • UpdateTypeEnum Enumeration (DAO)

  • WorkspaceTypeEnum Enumeration (DAO)


ListBox.GridlineStyleTop Property (Access)

 Copy code hover
[image]

ListBox.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified list box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleTop

expression A variable that represents a ListBox object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Disk failure accessing dropbox folder

 Copy code hover
[image]

Disk failure accessing dropbox folder <name>. (Error 3470)
Send feedback

The disk might have a corrupted sector.


AcProperty Enumeration (Access)

 Copy code hover
[image]

AcProperty Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the SetProperty method to specify which property to set for a control.

Version Information

Version Added: Access 2007

Name | Value | Description
acPropertyBackColor | 8 | Set the BackColor property.
acPropertyCaption | 9 | Set the Caption property.
acPropertyEnabled | 0 | Set the Enabled property.
acPropertyForeColor | 7 | Set the ForeColor property.
acPropertyHeight | 6 | Set the Height property.
acPropertyLeft | 3 | Set the Left property.
acPropertyLocked | 2 | Set the Locked property.
acPropertyTop | 4 | Set the Top property.
acPropertyValue | 10 | Set the Value property.
acPropertyVisible | 1 | Set the Visible property.
acPropertyWidth | 5 | Set the Width property.


QueryDef.Prepare Property (DAO)

 Copy code hover
[image]

QueryDef.Prepare Property (DAO)
Send feedback

Syntax

expression .Prepare

expression A variable that represents a QueryDef object.

Remarks

You can use the Prepare property to either have the server create a temporary stored procedure from your query and then execute it, or just have the query executed directly. By default the Prepare property is set to dbQPrepare. However, you can set this property to dbQUnprepare to prohibit preparing of the query. In this case, the query is executed using the SQLExecDirect API.

Creating a stored procedure can slow down the initial operation, but increases performance of all subsequent references to the query. However, some queries cannot be executed in the form of stored procedures. In these cases, you must set the Prepare property to dbQUnprepare.

If Prepare is set to dbQPrepare, this can be overridden when the query is executed by setting the Execute method's options argument to dbExecDirect.

Note Note

The ODBC SQLPrepare API is called as soon as the DAO SQL property is set. Therefore, if you want to improve performance using the dbQUnprepare option, you must set the Prepare property before setting the SQL property.

Example

This example uses the Prepare property to specify that a query should be executed directly rather than first creating a temporary stored procedure on the server.

VBA Copy code Copy code
Sub PrepareX()

 Dim wrkODBC As Workspace
 Dim conPubs As Connection
 Dim qdfTemp As QueryDef
 Dim rstTemp As Recordset

 ' Create ODBCDirect Workspace object and open Connection
 ' object.
 Set wrkODBC = CreateWorkspace("", _
 "admin", "", dbUseODBC)

 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conPubs = wrkODBC.OpenConnection("Publishers", , , _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 Set qdfTemp = conPubs.CreateQueryDef("")

 With qdfTemp
 ' Because you will only run this query once, specify
 ' the ODBC SQLExecDirect API function. If you do
 ' not set this property before you set the SQL
 ' property, the ODBC SQLPrepare API function will
 ' be called anyway which will nullify any
 ' performance gain.
 .Prepare = dbQUnprepare
 .SQL = "UPDATE roysched " & _
 "SET royalty = royalty * 2 " & _
 "WHERE title_id LIKE 'BU____' OR " & _
 "title_id LIKE 'PC____'"
 .Execute
 End With

 Debug.Print "Query results:"

 ' Open recordset containing modified records.
 Set rstTemp = conPubs.OpenRecordset( _
 "SELECT * FROM roysched " & _
 "WHERE title_id LIKE 'BU____' OR " & _
 "title_id LIKE 'PC____'")

 ' Enumerate recordset.
 With rstTemp
 Do While Not .EOF
 Debug.Print , !title_id, !lorange, _
 !hirange, !royalty
 .MoveNext
 Loop
 .Close
 End With

 conPubs.Close
 wrkODBC.Close


Getting Help from Microsoft Help and Support

 Copy code hover
[image]

Getting Help from Microsoft Help and Support
Send feedback

If you have additional questions, you can find more information about how to resolve problems by accessing the Microsoft Help and Support Web site.

For additional technical resources and information about developing with Microsoft products and technologies, visit the MSDN Online Web site.


DataFactoryObject Properties, Methods, and Events (RDS)

 Copy code hover
[image]

DataFactoryObject Properties, Methods, and Events (RDS)
Send feedback

Properties

None.

Methods

ConvertToString Method (RDS) | Converts a recordset into a MIME64 string.
CreateRecordset Method (RDS) | Creates and returns an empty recordset.
Query Method (RDS) | Execute the request and create an advanced data rowset.
SubmitChanges Method (RDS) | Given a recordset with pending changes, this method submits them to the database identified in the connection string.

Events

None.


The connection string is too long. (Error 3210)

 Copy code hover
[image]

The connection string is too long. (Error 3210)
Send feedback

The connection string in the IN clause of an SQL statement cannot be longer than 255 characters. Correct your entry, and then try the operation again.


Procedure Object (ADOX)

 Copy code hover
[image]

Procedure Object (ADOX)
Send feedback

Represents a stored procedure. When used in conjunction with the ADO Command object, the Procedure object can be used for adding, deleting, or modifying stored procedures.

Remarks

The Procedure object allows you to create a stored procedure without having to know or use the provider's "CREATE PROCEDURE" syntax.

With the properties of a Procedure object, you can:

  • Identify the procedure with the Name property.

  • Specify the ADO Command object that can be used to create or execute the procedure with the Command property.

  • Return date information with the DateCreated and DateModified properties.


Operation is not supported for this type of object. (Error 3251)

 Copy code hover
[image]

Operation is not supported for this type of object. (Error 3251)
Send feedback

You were attempting to execute a method or assign a value to a property that is usually valid for the object, but is not supported in this specific instance. For example, the Edit method is generally valid for Recordset objects, but not for a snapshot-type Recordset. This error could also occur in cases where the operation is not permitted due to the type or status of the object — as when trying to use the MovePrevious method on a forward-only-type Recordset. Some operations are also not supported, depending on if you are accessing a Microsoft Access database engine or an ODBC data source.


DoCmd.TransferSQLDatabase Method (Access)

 Copy code hover
[image]

DoCmd.TransferSQLDatabase Method (Access)
See also Send feedback

Published: July 16, 2012

Transfers the entire specified Microsoft SQL Server database to another SQL Server database.

Syntax

expression .TransferSQLDatabase(Server, Database, UseTrustedConnection, Login, Password, TransferCopyData)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
Server | Required | Variant | The name of the SQL Server to which the database will be transferred.
Database | Required | Variant | The name of the new database on the specified server.
UseTrustedConnection | Optional | Variant | True if the current connection is using a login with system administrator privileges. If this argument is not True, you must specify a login and password in the Login and Password arguments.
Login | Optional | Variant | The name of a login on the destination server with system administrator privileges. If UseTrustedConnection is True, this argument is ignored.
Password | Optional | Variant | The password for the login specified in Login. If UseTrustedConnection is True, this argument is ignored.
TransferCopyData | Optional | Variant | True if all data in the database is transferred to the destination database. If this argument is not True, only the database schema will be transferred.

Remarks

The following conditions must be met or else an error occurs:

  • The current and destination servers are SQL Server version 7.0 or later.

  • The user has system administrator login rights on the destination server.

  • The destination database doesn't already exist on the destination server.

Example

This example transfers the current SQL Server database to a new SQL Server database called Inventory on the server MainOffice. (It is assumed that the user has system administrator privileges on MainOffice.) The data is copied along with the database schema.

VBA Copy code Copy code
DoCmd.TransferCompleteSQLDatabase _
 Server:="MainOffice", _
 Database:="Inventory", _
 UseTrustedConnection:=True, _
 TransferCopyData:=False

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Database.Containers Property (DAO)

 Copy code hover
[image]

Database.Containers Property (DAO)
Send feedback

Returns a Containers collection that represents all of the Container objects in the specifed database. Read-only.

Syntax

expression .Containers

expression A variable that represents a Database object.


Parameter

 Copy code hover
[image]

Parameter <name> specified where a database name is required. (Error 3217)
Send feedback

You created a parameter query that specifies an invalid parameter type. The following example produces this error:

SQL Copy code Copy code
PARAMETERS Param1 Text;

SELECT CustomerID
FROM Customers IN Param1;

Param1 is a text parameter, but the FROM clause requires a database parameter.

Change the parameter type from Text to Database, and then try the operation again.


Application.DMax Method (Access)

 Copy code hover
[image]

Application.DMax Method (Access)
See also Send feedback

Published: July 16, 2012

You can use DMax function to determine maximum value in a specified set of records (a domain).

Syntax

expression .DMax(Expr, Domain, Criteria)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Expr | Required | String | An expression that identifies the field for which you want to find the minimum or maximum value. It can be a string expression identifying a field in a table or query, or it can be an expression that performs calculation on data in that field. In expr, you can include the name of a field in a table, a control on a form, a constant, or a function. If expr includes a function, it can be either built-in or user-defined, but not another domain aggregate or SQL aggregate function.
Domain | Required | String | A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter.
Criteria | Optional | Variant | An optional string expression used to restrict the range of data on which the DMax function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the DMax function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain, otherwise the DMax function returns a Null.

Return Value

Variant

Remarks

For example, you could use the DMax function in calculated controls on a report to display largest order amount for a particular customer.

The DMax function returns the maximum value that satisfy criteria. If expr identifies numeric data, the DMax function returns numeric values. If expr identifies string data, they return the string that is first or last alphabetically.

The DMax function ignores Null values in the field referenced by expr. However, if no record satisfies criteria or if domain contains no records, the DMax function returns a Null.

You can use the DMax function to specify criteria in the Criteria row of a query, in a calculated field expression in a query, or in the Update To row of an update query.

Note Note

You can use the DMax function or the Max function in a calculated field expression of a totals query. If you use the DMax function, values are evaluated before the data is grouped. If you use the Max function, the data is grouped before values in the field expression are evaluated.

Use the DMax function in a calculated control when you need to specify criteria to restrict the range of data on which the function is performed. For example, to display the maximum freight charged for an order shipped to California, set the ControlSource property of a text box to the following expression:

VBA Copy code Copy code
=DMax("[Freight]", "Orders", "[ShipRegion] = 'CA'")

If you simply want to find the minimum or maximum value of all records in domain, use the Min or Max function.

Although you can use the DMin or DMax function to find the minimum or maximum value from a field in a foreign table, it may be more efficient to create a query that contains the fields that you need from both tables and base your form or report on that query.

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Sequential Numbering

Example

The following example returns the lowest and highest values from the Freight field for orders shipped to the United Kingdom. The domain is an Orders table. The criteria argument restricts the resulting set of records to those for which ShipCountry equals UK.

VBA Copy code Copy code
Dim curX As Currency
Dim curY As Currency

curX = DMin("[Freight]", "Orders", "[ShipCountry] = 'UK'")
curY = DMax("[Freight]", "Orders", "[ShipCountry] = 'UK'")

In the next example, the criteria argument includes the current value of a text box called OrderDate. The text box is bound to an OrderDate field in an Orders table. Note that the reference to the control isn't included in the double quotation marks (") that denote the strings. This ensures that each time the DMax function is called, Microsoft Access obtains the current value from the control.

VBA Copy code Copy code
Dim curX As Currency
curX = DMax("[Freight]", "Orders", "[OrderDate] = #" _
    & Forms!Orders!OrderDate & "#")

The following examples show how to use various types of criteria with the DMax function.

Sample code provided by: Community Member Icon The UtterAccess community | About the Contributors

Copy code Copy code
    ' ***************************
    ' Typical Use
    ' Numerical values. Replace "number" with the number to use.
    variable = DMax("[FieldName]", "TableName", "[Criteria] = number")

    ' Strings.
    ' Numerical values. Replace "string" with the string to use.
    variable = DMax("[FieldName]", "TableName", "[Criteria]= 'string'")

    ' Dates. Replace "date" with the string to use.
    variable = DMax("[FieldName]", "TableName", "[Criteria]= #date#")
    ' ***************************

    ' ***************************
    ' Referring to a control on a form
    ' Numerical values
    variable = DMax("[FieldName]", "TableName", "[Criteria] = " & Forms!FormName!ControlName)

    ' Strings
    variable = DMax("[FieldName]", "TableName", "[Criteria] = '" & Forms!FormName!ControlName & "'")

    ' Dates
    variable = DMax("[FieldName]", "TableName", "[Criteria] = #" & Forms!FormName!ControlName & "#")
    ' ***************************

    ' ***************************
    ' Combinations
    ' Multiple types of criteria
    variable = DMax("[FieldName]", "TableName", "[Criteria1] = " & Forms![FormName]![Control1] _
             & " AND [Criteria2] = '" & Forms![FormName]![Control2] & "'" _
            & " AND [Criteria3] =#" & Forms![FormName]![Control3] & "#")

    ' Use two fields from a single record.
    variable = DMax("[LastName] & ', ' & [FirstName]", "tblPeople", "[PrimaryKey] = 7")

    ' Expressions
    variable = DMax("[Field1] + [Field2]", "tableName", "[PrimaryKey] = 7")

    ' Control Structures
    variable = DMax("IIf([LastName] Like 'Smith', 'True', 'False')", "tableName", "[PrimaryKey] = 7")
    ' ***************************

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Application Object

Other resources

Application Object Members


ON (Microsoft Access SQL reserved word)

 Copy code hover
[image]

ON (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The ON keyword is used in these contexts:

INNER JOIN Operation

LEFT JOIN, RIGHT JOIN Operations

CONSTRAINT Clause

GRANT Statement

REVOKE Statement


TabControl Members (Access)

 Copy code hover
[image]

TabControl Members (Access)
Send feedback

Published: July 16, 2012

A tab control contains multiple pages on which you can place other controls, such as text boxes or option buttons. When a user clicks the corresponding tab, that page becomes active.

Events

Name | Description
Change | The Change event occurs when when you move from one page to another page.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BottomPadding | Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontName | You can use the FontName property to specify the font for text in the following situations:
FontSize | You can use the FontSize property to specify the point size for text in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
FontWeight | You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
ForeShade | Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
ForeThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.
ForeTint | Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
Gradient | Gets or sets the gradient fill applied to the specified object. Read/write Long.
GridlineColor | Gets or sets the color of the gridline for the specified list box. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified list box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified text box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified text box. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified text box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified text box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified text box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the tab control is anchored horizontally within its layout. Read/write.
HoverColor | Gets or sets the color displayed on the control when the user rests the mouse cursor over it. Read/write Long.
HoverForeColor | Gets or sets the color of the text displayed on the control when the user rests the mouse cursor over it. Read/write Long.
HoverForeShade | Gets or sets the shade applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.
HoverForeThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverForeColor property of the specified object. Read/write Long.
HoverForeTint | Gets or sets the tint applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.
HoverShade | Gets or sets the shade that is applied to the theme color in the HoverColor property of the specified object. Read/write Single.
HoverThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverColor property of the specified object. Read/write Long.
HoverTint | Gets or sets the tint applied to the theme color in the HoverColor property of the specified object. Read/write Single.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Layout | Returns the type of layout for the specified text box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified text box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.
MultiRow | You can use the MultiRow property to specify or determine whether a tab control can display more than one row of tabs. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnChange | Sets or returns the value of the On Change box in the Properties window of one of the objects in the Applies To list. Read/write String.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
Pages | Returns a Pages collection that represents the pages in the specified TabControl object. Read-only.
Parent | Returns the parent object for the specified object. Read-only.
PressedColor | Gets or sets the color displayed on the control when the user clicks it. Read/write Long.
PressedForeColor | Gets or sets the color of the text displayed on the control when the user clicks it. Read/write Long.
PressedForeShade | Gets or sets the shade applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.
PressedForeThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedForeColor property of the specified object. Read/write Long.
PressedForeTint | Gets or sets the tint applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.
PressedShade | Gets or sets the shade that is applied to the theme color in the PressedColor property of the specified object. Read/write Single.
PressedThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedColor property of the specified object. Read/write Long.
PressedTint | Gets or sets the tint applied to the theme color in the PressedColor property of the specified object. Read/write Single.
Properties | Returns a reference to a control's Properties collection object. Read-only.
RightPadding | Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
Shape | Returns or sets the shape of the specified tab control. Read/write Long.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
Style | You can use the Style property to specify or determine the appearance of tabs on a tab control. Read/write Byte.
TabFixedHeight | You can use the TabFixedHeight property to specify or determine the height of the tabs on a tab control. Read/write Integer.
TabFixedWidth | You can use the TabFixedWidth property to specify or determine the width of the tabs on a tab control. Read/write Integer.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
ThemeFontIndex | Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.
UseTheme | Gets or sets whether the specified object will utilize formatting styles defined in Office Document Themes. Read/write Boolean.
Value | Determines or specifies the selected Page object. Read/write Variant.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified tab control is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


OptionGroup.Properties Property (Access)

 Copy code hover
[image]

OptionGroup.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents an OptionGroup object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Two members of the replica set cannot be synchronized because there is no common point to start the synchronization. (Error 3521)

 Copy code hover
[image]

Two members of the replica set cannot be synchronized because there is no common point to start the synchronization. (Error 3521)
Send feedback

Too much time has passed since these two members of the replica set were last synchronized. The Microsoft Access database engine cannot find a common point of reference to begin applying changes in the content or structure of the database.


ComboBox.Left Property (Access)

 Copy code hover
[image]

ComboBox.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Syntax

expression .Left

expression A variable that represents a ComboBox object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Form.CurrentSectionTop Property (Access)

 Copy code hover
[image]

Form.CurrentSectionTop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use this property to determine the distance in twips from the top edge of the current section to the top edge of the form. Read/write Integer.

Syntax

expression .CurrentSectionTop

expression A variable that represents a Form object.

Remarks

The CurrentSectionTop property setting changes whenever a user scrolls through a form.

For forms whose DefaultView property is set to Single Form, if the user scrolls above the upper-left corner of the section, the property settings are negative values.

For forms whose DefaultView property is set to Continuous Forms, if a section isn't visible, the CurrentSectionTop property is equal to the InsideHeight property of the form.

The CurrentSectionTop property is useful for finding the positions of detail sections displayed in Form view as continuous forms or in Datasheet view. Each detail section has a different CurrentSectionTop property setting, depending on the section's position on the form.

Example

The following example displays the CurrentSectionLeft and CurrentSectionTop property settings for a control on a continuous form. Whenever the user moves to a new record, the property settings for the current section are displayed in the lblStatus label in the form's header.

VBA Copy code Copy code
Private Sub Form_Current()

 Dim intCurTop As Integer
 Dim intCurLeft As Integer

 intCurTop = Me.CurrentSectionTop
 intCurLeft = Me.CurrentSectionLeft
 Me!lblStatus.Caption = intCurLeft & " , " & intCurTop

End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Application.Screen Property (Access)

 Copy code hover
[image]

Application.Screen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Screen property to return a reference the Screen object and its related properties. Read-only.

Syntax

expression .Screen

expression A variable that represents an Application object.

Remarks

Use the Screen object to refer to a particular form, report, or control that has the focus.

Example

The following example demonstrates how to change the cursor to an hourglass and back again to signify that some background activity is occurring.

VBA Copy code Copy code
Application.Screen.MousePointer = 11 ' Hourglass
' Do some background activity.
Application.Screen.MousePointer = 0 ' Back to normal

See also

Concepts

Application Object

Other resources

Application Object Members


WebBrowserControl Object (Access)

 Copy code hover
[image]

WebBrowserControl Object (Access)
See also Send feedback

Published: July 16, 2012

Represents a Web browser control on a form.

Version Information

Version Added: Access 2010

Remarks

Use the ControlSource property to specify the Web page to load in the control.

See also

Concepts

Access Object Model Reference

Other resources

WebBrowserControl Object Members


NavigationButton.QuickStyleMask Property (Access)

 Copy code hover
[image]

NavigationButton.QuickStyleMask Property (Access)
Send feedback

Published: July 16, 2012

Gets or sets modifications to the Quick Style that is applied to the specified object. Read/write Long.

Version information

Version Added: Access 2010

Syntax

expression .QuickStyle

expression A variable that represents a NavigationButton object.

Remarks

Set the QuickStyleMask property to -1 to remove modifications to the selected Quick Style.

Property value

INT32


ObjectFrame.Properties Property (Access)

 Copy code hover
[image]

ObjectFrame.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents an ObjectFrame object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


How to: Apply a Filter When Opening a Form or Report

 Copy code hover
[image]

How to: Apply a Filter When Opening a Form or Report
Send feedback

When you use Microsoft Visual Basic for Applications (VBA) code to open a form or report, you may want to specify which records to display. You can specify the records to display in the form or report in several ways. A common approach is to display a custom dialog box in which the user enters criteria for the underlying query of the form or report. To get the criteria, you refer to the controls in the dialog box. The following sections describe three ways you can use criteria entered in a custom dialog box to filter records.

Using the

The wherecondition argument of the OpenForm or OpenReport method or action is the simplest way to get criteria in situations where a user is providing only one value. For example, you could display a form that prompts users to select an order ID for the invoice they want to print. If you are using an event procedure, you can apply a filter that displays only one record by adding an argument to the OpenReport method, as shown in the following line of code:

Copy code Copy code
DoCmd.OpenReport "Invoice", acViewPreview, , "OrderID = " & OrderID

The "OrderID = " in the filter expression refers to the OrderID field in the Invoice report's underlying query. The OrderID on the right side of the expression refers to the value the user selected from the OrderID list in the dialog box. The expression concatenates the two, causing the report to include only the invoice for the record the user selected.

The wherecondition argument is applied only by the event procedure specified for the OnClick event of the button that runs the OpenForm or OpenReport method. This gives you the flexibility of using any number of different dialog boxes to open the same form or report and applying different sets of criteria depending on what the user wants to do. For example, the user may want to print an invoice for a certain customer or view orders only for a certain product.

You can use the wherecondition argument to set criteria for more than one field, but if you do, the argument setting quickly becomes long and complicated. In those situations, specifying criteria in a query may be easier.

Using a Query as a Filter

A separate query, sometimes called a filter query, can refer to the controls on your dialog box to get its criteria. Using this approach, you filter the records in a form or report by setting the filtername argument of the OpenForm or OpenReport method or action to the name of the filter query you create. The filter query must include all tables in the record source of the form or report you are opening. Additionally, the filter query must either include all the fields in the form or report you are opening, or you must set its OutputAllFields property to Yes.

After you create and save the query to use as a filter, set the filtername argument of the OpenReport method or action to the name of the filter query. The filtername argument applies the specified filter query each time the OpenReport method runs.

Using a query as a filter to set the criteria has advantages similar to using the wherecondition argument of the OpenForm or OpenReport method. A filter query gives you the same flexibility of using more than one dialog box to open the same form or report and applying different sets of criteria depending on what a user wants to do.

Directly Referring to Dialog Box Controls in the Underlying Query of a Form or Report

You can also refer to the dialog box controls directly in the underlying query of a form or report instead of through the arguments of the OpenForm or OpenReport method. Using this approach, the OpenForm or OpenReport method or action requires no wherecondition or filtername argument. Instead, each time you open a form or report, its underlying query looks for the dialog box to get its criteria. However, if a user opens the form or report in the Database window rather than through your dialog box, Access displays a parameter box that prompts the user for the dialog box value.


Check constraints on table

 Copy code hover
[image]

Check constraints on table <name> will not be transferred to this table. Check constraints can only be created via SQL DLL statements. (Error 3805)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for more information.


Chapter Property (ADO)

 Copy code hover
[image]

Chapter Property (ADO)
Send feedback

Gets or sets an OLE DB Chapter object from/on an ADORecordsetConstruction object. When you use put_Chapter to set the Chapter object, a subset of rows is turned into an ADO Recordset object. This sets the current chapter of the Rowset object. Read/write.

Syntax

HRESULT get_Chapter([out, retval] long* plChapter);

HRESULT put_Chapter([in] long lChapter);

Parameters

  • plChapter

  • Pointer to the handle of a chapter.

  • LChapter

  • Handle of a chapter.

Return Values

This property method returns the standard HRESULT values, including S_OK and E_FAIL.

Applies To

ADORecordsetConstruction


ADO Error Codes

 Copy code hover
[image]

ADO Error Codes
Send feedback

In addition to the provider errors returned in the Error objects of the Errors collection, ADO itself can return errors to the exception-handling mechanism of your run-time environment. Use the error trapping mechanism your programming language, such as the On Error statement in Microsoft Visual Basic or the try-catch block in Microsoft Visual C++ or Microsoft Visual J++ to capture ADO errors.

For the list of ADO error codes, see ErrorValueEnum.


Image.SetFocus Method (Access)

 Copy code hover
[image]

Image.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Syntax

expression .SetFocus

expression A variable that represents an Image object.

Return Value

Nothing

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.

Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.

Example

The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:

VBA Copy code Copy code
Forms!Employees!EmployeeID.SetFocus

See also

Concepts

Image Object

Other resources

Image Object Members


Type Property (Table) (ADOX)

 Copy code hover
[image]

Type Property (Table) (ADOX)
Send feedback

Indicates the type of a table.

Return Values

Returns a String value that specifies the type of table; for example, "TABLE", "SYSTEM TABLE", or "GLOBAL TEMPORARY".

Remarks

This property is read-only.


Page.Tag Property (Access)

 Copy code hover
[image]

Page.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents a Page object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

Page Object

Other resources

Page Object Members


ADOX Objects

 Copy code hover
[image]

ADOX Objects
Send feedback

ADOX Object Summary

Object | Description
Catalog | Contains collections that describe the schema catalog of a data source.
Column | Represents a column from a table, index, or key.
Group | Represents a group account that has access permissions within a secured database.
Index | Represents an index from a database table.
Key | Represents a primary, foreign, or unique key field from a database table.
Procedure | Represents a stored procedure.
Table | Represents a database table, including columns, indexes, and keys.
User | Represents a user account that has access permissions within a secured database.
View | Represents a filtered set of records or a virtual table.

Each object can be contained in its corresponding collection. For example, a Table object can be contained in a Tables collection. For more information, see ADOX Collections or a specific collection topic.


Application.LoadPicture Method (Access)

 Copy code hover
[image]

Application.LoadPicture Method (Access)
See also Send feedback

Published: July 16, 2012

The LoadPicture method loads a graphic into an ActiveX control.

Syntax

expression .LoadPicture(FileName)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
FileName | Required | String | The file name of the graphic to be loaded. The graphic can be a bitmap file (.bmp), icon file (.ico), run-length encoded file (.rle), or metafile (.wmf).

Return Value

Object

Remarks

Assign the return value of the LoadPicture method to the Picture property of an ActiveX control to dynamically load a graphic into the control. The following example loads a bitmap into a control called OLECustomControl on an Orders form:

VBA Copy code Copy code
Set Forms!Orders!OLECustomControl.Picture = _
 LoadPicture("Stars.bmp")
Note Note

You can't use the LoadPicture method to set the Picture property of an image control. This method works with ActiveX controls only. To set the Picture property of an image control, simply assign to it a string specifying the file name and path of the desired graphic.

See also

Concepts

Application Object

Other resources

Application Object Members


Rectangle.Name Property (Access)

 Copy code hover
[image]

Rectangle.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a Rectangle object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


Attachment.PictureTiling Property (Access)

 Copy code hover
[image]

Attachment.PictureTiling Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureTiling property to specify whether a background picture is tiled across the entire attachment control. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .PictureTiling

expression A variable that represents an Attachment object.

Remarks

The PictureTiling property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The picture is tiled.
No | False | (Default) The picture isn't tiled.

You can also set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


CodeData.AllTables Property (Access)

 Copy code hover
[image]

CodeData.AllTables Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllTables property to reference the AllTables collection and its related properties. Read-only AllTables object.

Syntax

expression .AllTables

expression A variable that represents a CodeData object.

See also

Concepts

CodeData Object

Other resources

CodeData Object Members


Value Property Example (VC++)

 Copy code hover
[image]

Value Property Example (VC++)
Send feedback

This example demonstrates the Value property with Field and Property objects by displaying field and property values for the Employees table.

Copy code Copy code

// BeginValueCpp
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void ValueX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 ValueX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// ValueX Function //
// //
//////////////////////////////////////////////////////////
void ValueX(void)
{
 HRESULT hr = S_OK;

 // Define string variables.
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstEmployees = NULL;
 FieldsPtr pFldLoop = NULL;
 PropertiesPtr pPrpLoop = NULL;
 _variant_t vtIndex;
 vtIndex.vt = VT_I2;

 try
 {
 // Open recordset with data from Employee table.
 TESTHR(pRstEmployees.CreateInstance(__uuidof(Recordset)));
 pRstEmployees->Open ("employee",strCnn ,
 adOpenForwardOnly, adLockReadOnly, adCmdTable);

 printf("Field values in rstEmployees\n\n");

 // Enumerate the Fields collection of the Employees table.
 pFldLoop = pRstEmployees->GetFields();

 for (int intFields = 0; intFields < (int)pFldLoop->GetCount(); intFields++)
 {
 vtIndex.iVal = intFields;

 // Because Value is the default property of a
 // Field object,the use of the actual keyword
 // here is optional.
 printf(" %s = %s\n\n" ,
 (LPCSTR) pFldLoop->GetItem(vtIndex)->GetName(),
 (LPCSTR) (_bstr_t) pFldLoop->GetItem(vtIndex)->Value);
 }

 printf("Press any key to continue...\n\n");
 getch();
 printf("Property values in rstEmployees\n\n");

 // Enumerate the Properties collection of the Recordset object.
 pPrpLoop = pRstEmployees->GetProperties();
 int intLine = 0;

 for (int intProperties = 0; intProperties < (int)pPrpLoop->
 GetCount(); intProperties++)
 {
 vtIndex.iVal = intProperties;

 // Because Value is the default property of a
 // Property object,the use of the actual keyword
 // here is optional.
 _variant_t propValue = pPrpLoop->GetItem(vtIndex)->Value;
 switch(propValue.vt)
 {

 case (VT_BOOL):
 if(propValue.boolVal)
 {
 printf(" %s = True\n\n",(LPCSTR) pPrpLoop->
 GetItem(vtIndex)->GetName());
 }
 else
 {
 printf(" %s = False\n\n",(LPCSTR) pPrpLoop->
 GetItem(vtIndex)->GetName());
 }
 break;

 case (VT_I4):
 printf(" %s = %d\n\n",(LPCSTR) pPrpLoop->
 GetItem(vtIndex)->GetName(),
 pPrpLoop->GetItem(vtIndex)->Value.lVal);
 break;

 case (VT_EMPTY):
 printf(" %s = \n\n",(LPCSTR) pPrpLoop->
 GetItem(vtIndex)->GetName());
 break;

 default:
 break;
 }

 intLine++;
 if (intLine % 10 == 0)
 {
 printf("\nPress any key to continue...");
 getch();

 //Clear the screen for the next display
 system("cls");
 }
 }
 }
 catch (_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstEmployees->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 if (pRstEmployees)
 if (pRstEmployees->State == adStateOpen)
 pRstEmployees->Close();
}

//////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
//////////////////////////////////////////////////////////
void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

//////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
//////////////////////////////////////////////////////////
void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndValueCpp


ListBox.DisplayWhen Property (Access)

 Copy code hover
[image]

ListBox.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Syntax

expression .DisplayWhen

expression A variable that represents a ListBox object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Form.PivotTableChange Property (Access)

 Copy code hover
[image]

Form.PivotTableChange Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the PivotTableChange event occurs. Read/write.

Syntax

expression .PivotTableChange

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the PivotTableChange event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).PivotTableChange = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


Recordset2.CacheSize Property (DAO)

 Copy code hover
[image]

Recordset2.CacheSize Property (DAO)
Send feedback

Sets or returns the number of records retrieved from an ODBC data source that will be cached locally. Read/write Long.

Syntax

expression .CacheSize

expression A variable that represents a Recordset2 object.

Remarks

The value of the CacheSize property must be between 5 and 1200, but not greater than available memory will allow. A typical value is 100. A setting of 0 turns off caching.

Data caching improves performance if you use Recordset objects to retrieve data from a remote server. A cache is a space in local memory that holds the data most recently retrieved from the server; this is useful if users request the data again while the application is running. When users request data, the Microsoft Access database engine checks the cache for the requested data first rather than retrieving it from the server, which takes more time. The cache only saves data that comes from an ODBC data source.

Any Microsoft Access database engine-connected ODBC data source, such as a linked table, can have a local cache. To create the cache, open a Recordset object from the remote data source, set the CacheSize and CacheStart properties, and then use the FillCache method, or step through the records by using the Move methods.

You can base the CacheSize property setting on the number of records your application can handle at one time. For example, if you're using a Recordset object as the source of the data to be displayed on screen, you could set its CacheSize property to 20 to display 20 records at one time.

The Microsoft Access database engine requests records within the cache range from the cache, and it requests records outside the cache range from the server.

Records retrieved from the cache don't reflect concurrent changes that other users made to the source data.

To force an update of all the cached data, set the CacheSize property of the Recordset object to 0, re-set it to the size of the cache you originally requested, and then use the FillCache method.

Example

This example uses the CreateTableDef and FillCache methods and the CacheSize, CacheStart and SourceTableName properties to enumerate the records in a linked table twice. Then it enumerates the records twice with a 50-record cache. The example then displays the performance statistics for the uncached and cached runs through the linked table.

VBA Copy code Copy code
Sub ClientServerX3()

 Dim dbsCurrent As Database
 Dim tdfRoyalties As TableDef
 Dim rstRemote As Recordset2
 Dim sngStart As Single
 Dim sngEnd As Single
 Dim sngNoCache As Single
 Dim sngCache As Single
 Dim intLoop As Integer
 Dim strTemp As String
 Dim intRecords As Integer

 ' Open a database to which a linked table can be
 ' appended.
 Set dbsCurrent = OpenDatabase("DB1.mdb")

 ' Create a linked table that connects to a Microsoft SQL
 ' Server database.
 Set tdfRoyalties = _
 dbsCurrent.CreateTableDef("Royalties")
 ' Note: The DSN referenced below must be set to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 tdfRoyalties.Connect = _
 "ODBC;DATABASE=pubs;DSN=Publishers"
 tdfRoyalties.SourceTableName = "roysched"
 dbsCurrent.TableDefs.Append tdfRoyalties
 Set rstRemote = _
 dbsCurrent.OpenRecordset("Royalties")

 With rstRemote
 ' Enumerate the Recordset object twice and record
 ' the elapsed time.
 sngStart = Timer

 For intLoop = 1 To 2
 .MoveFirst
 Do While Not .EOF
 ' Execute a simple operation for the
 ' performance test.
 strTemp = !title_id
 .MoveNext
 Loop
 Next intLoop

 sngEnd = Timer
 sngNoCache = sngEnd - sngStart

 ' Cache the first 50 records.
 .MoveFirst
 .CacheSize = 50
 .FillCache
 sngStart = Timer

 ' Enumerate the Recordset object twice and record
 ' the elapsed time.
 For intLoop = 1 To 2
 intRecords = 0
 .MoveFirst
 Do While Not .EOF
 ' Execute a simple operation for the
 ' performance test.
 strTemp = !title_id
 ' Count the records. If the end of the
 ' cache is reached, reset the cache to the
 ' next 50 records.
 intRecords = intRecords + 1
 .MoveNext
 If intRecords Mod 50 = 0 Then
 .CacheStart = .Bookmark
 .FillCache
 End If
 Loop
 Next intLoop

 sngEnd = Timer
 sngCache = sngEnd - sngStart

 ' Display performance results.
 MsgBox "Caching Performance Results:" & vbCr & _
 " No cache: " & Format(sngNoCache, _
 "##0.000") & " seconds" & vbCr & _
 " 50-record cache: " & Format(sngCache, _
 "##0.000") & " seconds"
 .Close
 End With

 ' Delete linked table because this is a demonstration.
 dbsCurrent.TableDefs.Delete tdfRoyalties.Name
 dbsCurrent.Close

End Sub


The two members of the replica set you are attempting to synchronize have the same ReplicaID. (Error 3560)

 Copy code hover
[image]

The two members of the replica set you are attempting to synchronize have the same ReplicaID. (Error 3560)
Send feedback

Synchronize with a different target member of the replica set.


Update/delete conflict - This updated record was deleted at another replica. (Error 3736)

 Copy code hover
[image]

Update/delete conflict - This updated record was deleted at another replica. (Error 3736)
Send feedback

When a record is deleted at one replica, but updated at another replica, the deleted record always wins in the conflict that occurs when the two replicas synchronize. The updated record is logged in the conflict table. To reverse the initial resolution of the conflict, reinsert the conflict record. To accept the current resolution, delete the conflict record.


TextBox.OnEnter Property (Access)

 Copy code hover
[image]

TextBox.OnEnter Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnEnter

expression A variable that represents a TextBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Enter event occurs before a control actually receives the focus from a control on the same form.

The OnEnter value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Enter box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Enter box is blank, the property value is an empty string.

Example

The following example associates the Enter event with the macro "Enter_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnEnter = "Enter_Macro"

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


CheckBox.ControlType Property (Access)

 Copy code hover
[image]

CheckBox.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Syntax

expression .ControlType

expression A variable that represents a CheckBox object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


CustomControl.OLEClass Property (Access)

 Copy code hover
[image]

CustomControl.OLEClass Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OLEClass property to obtain a description of the kind of OLE object contained in a chart control or an unbound object frame. Read-only String.

Syntax

expression .OLEClass

expression A variable that represents a CustomControl object.

Remarks

This property is set automatically in the control's property sheet to a string expression when you click Object on the Insert menu to add an OLE object to a form. The OLEClass property setting is read-only in all views.

Note Note

If you are using Automation (formerly called OLE Automation) and need to specify a name to refer to the OLE object, use the Class property.

The OLEClass property and the Class property are similar but not identical. The OLEClass property setting is a general description of the OLE object whereas the Class property setting is the name used to refer to the OLE object in Visual Basic. Examples of OLEClass property settings are Microsoft Excel Chart, Microsoft Word Document, and Paintbrush Picture.

Example

The following example displays a message indicating the OLE class for the "Customer Picture" unbound object frame on the "Order Entry" form.

VBA Copy code Copy code
MsgBox "The OLE class = " & Forms("Order Entry").Controls("Customer Picture").OLEClass

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


NavigationButton.Application Property (Access)

 Copy code hover
[image]

NavigationButton.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Version Information

Version Added: Access 2010

Syntax

expression .Application

expression A variable that represents a NavigationButton object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


ComboBox.GridlineStyleRight Property (Access)

 Copy code hover
[image]

ComboBox.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified combo box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleRight

expression A variable that represents a ComboBox object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


OptionGroup.HideDuplicates Property (Access)

 Copy code hover
[image]

OptionGroup.HideDuplicates Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.

Syntax

expression .HideDuplicates

expression A variable that represents an OptionGroup object.

Remarks

The HideDuplicates property applies only to controls (check box, combo box, list box, option button, option group, text box, toggle button) on a report.

The HideDuplicates property uses the following settings.

Setting | Description
True | If the value of a control or the data it contains is the same as in the preceding record, the control is hidden.
False | (Default) The control is visible regardless of the value in the preceding record.

The DefaultValue property doesn't apply to check box, option button, or toggle buttoncontrols when they are in an option group. It does however apply to the option group itself.

You can set the HideDuplicates property only in report Design view.

You can use the HideDuplicates property to create a grouped report by using only the detail section rather than a group header and the detail section.

Example

The following example returns the HideDuplicates property setting for the CategoryName text box and assigns the value to the intCurVal variable.

VBA Copy code Copy code
Dim intCurVal As Integer
intCurVal = Me!CategoryName.HideDuplicates

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Printers.Count Property (Access)

 Copy code hover
[image]

Printers.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents a Printers object.

See also

Concepts

Printers Collection

Other resources

Printers Object Members


ComboBox.SpecialEffect Property (Access)

 Copy code hover
[image]

ComboBox.SpecialEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.

Syntax

expression .SpecialEffect

expression A variable that represents a ComboBox object.

Remarks

The SpecialEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | 0 | The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised | 1 | The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken | 2 | The object has a shadow on the top and left and a highlight on the bottom and right.
Etched | 3 | The object has a sunken line surrounding the control.
Shadowed | 4 | The object has a shadow below and to the right of the control.
Chiseled | 5 | The object has a sunken line below the control.

The SpecialEffect property setting affects related property settings for the BorderStyle , BorderColor , and BorderWidth properties. For example, if the SpecialEffect property is set to Raised, the settings for the BorderStyle, BorderColor, and BorderWidth properties are ignored. In addition, changing or setting the BorderStyle, BorderColor, and BorderWidth properties may cause Microsoft Access to change the SpecialEffect property setting to Flat.

Example

The following example sets the appearance of the text box "OrganizationName1" on the "Mailing List" form to raised.

VBA Copy code Copy code
Forms("Mailing List").Controls("OrganizationName1").SpecialEffect = 1

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


How to: Assign a Control a Value From a Table

 Copy code hover
[image]

How to: Assign a Control a Value From a Table
Send feedback

You can use the DLookup function to display the value of a field that is not in the record source for your form or report. For example, suppose you have a form based on an Order Details table. The form displays the OrderID, ProductID, UnitPrice, Quantity, and Discount fields. However, the UnitPrice field is in another table: Products. You could use the DLookup function in a calculated control to display the UnitPrice on the same form when the user selects a product.

The following example populates the UnitPrice text box with the price of the product currently selected in the ProductID combo box.

VBA Copy code Copy code
Private Sub ProductID_AfterUpdate()

 ' Evaluate filter before it is passed to DLookup function.
 strFilter = "ProductID = " & Me!ProductID

 ' Look up product's unit price and assign it to the UnitPrice control.
 Me!UnitPrice = DLookup("UnitPrice", "Products", strFilter)

End Sub

The DLookup function has three arguments. The first specifies the field you are looking up (UnitPrice); the second specifies the table (Products); and the third specifies which value to find (the value for the record where the ProductID is the same as the ProductID on the current record in the Orders subform).


ToggleButton.FontBold Property (Access)

 Copy code hover
[image]

ToggleButton.FontBold Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontBold property to specify whether a font appears in a bold style in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontBold

expression A variable that represents a ToggleButton object.

Remarks

The FontBold property uses the following settings.

Setting | Description
True | The text is bold.
False | (Default) The text isn't bold.

To use the FontBold property on a report, first create a Printevent procedure that prints the desired text.

A font's appearance on screen and in print may differ, depending on your computer and printer.

The FontWeight property, which is available in the property sheet for controls, can also be used to set the line width for a control's text. The FontBold property gives you a quick way to make text bold; the FontWeight property gives you finer control over the line width setting for text. The following table shows the relationship between these properties' settings.

If | Then
FontBold = False | FontWeight = Normal (400)
FontBold = True | FontWeight = Bold (700)
FontWeight < 700 | FontBold = False
FontWeight > = 700 | FontBold = True

Example

The following Print event procedure prints a report title and the current date in a bold style on a report at the coordinates specified by the CurrentX and CurrentY property settings.

VBA Copy code Copy code
Private Sub ReportHeader0_Print(Cancel As Integer, _
 PrintCount As Integer)
 Dim MyDate

 MyDate = Date
 Me.FontBold = True
 ' Print report title in bold.
 Me.Print("Sales Management Report")
 Me.Print(MyDate)
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Image.OnMouseDown Property (Access)

 Copy code hover
[image]

Image.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Syntax

expression .OnMouseDown

expression A variable that represents an Image object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

Image Object

Other resources

Image Object Members


CancelEvent Macro Action

 Copy code hover
[image]

CancelEvent Macro Action
Send feedback

You can use the CancelEvent action to cancel the event that caused Microsoft Access 2013 to run the macro containing this action. The macro name is the setting of an event property such as BeforeUpdate, OnOpen, OnUnload, or OnPrint.

Setting

The CancelEvent action doesn't have any arguments.

Remarks

In a form, you typically use the CancelEvent action in a validation macro with the BeforeUpdate event property. When a user enters data in a control or record, Access runs the macro before adding the data to the database. If the data fails the validation conditions in the macro, the CancelEvent action cancels the update process before it starts.

Often, you use this action with the MessageBox action to indicate that the data has failed the validation conditions and to provide helpful information about the kind of data that should be entered.

The following events can be canceled by the CancelEvent action.

ApplyFilter | Dirty | MouseDown
BeforeDelConfirm | Exit | NoData
BeforeInsert | Filter | Open
BeforeUpdate | Format | Print
DblClick | KeyPress | Unload
Delete |  |
Note Note

You can use the CancelEvent action with the MouseDown event only to cancel the event that occurs when you right-click an object.

If a control's OnDblClick event property setting specifies a macro containing the CancelEvent action, the action cancels the DblClick event.

For events that can be canceled, the default behavior for the event (that is, what Access typically does when the event occurs) occurs after the macro for the event runs. This enables you to cancel the default behavior. For example, when you double-click a word that the insertion point is on in a text box, Access normally selects the word. You can cancel this default behavior in the macro for the DblClick event and perform some other action, such as opening a form containing information about the data in the text box. For events that can't be canceled, the default behavior occurs before the macro runs.

Note Note

If a form's OnUnload event property specifies a macro that carries out a CancelEvent action, you won't be able to close the form. You must either correct the condition that caused the CancelEvent action to be carried out or open the macro and delete the CancelEvent action. If the form is a modal form, you won't be able to open the macro.

To carry out the CancelEvent action in a Visual Basic for Applications (VBA) module, use the CancelEvent method of the DoCmd object.

Example

Validate data by using a macro

The following validation macro checks the postal codes entered in a Suppliers form. It shows the use of the StopMacro, MessageBox, CancelEvent, and GoToControl actions. A conditional expression checks the country/region and postal code entered in a record on the form. If the postal code is not in the right format for the country/region, the macro displays a message box and cancels saving the record. It then returns you to the Postal Code control, where you can correct the error. This macro should be attached to the BeforeUpdate property of the Suppliers form.

Condition | Action | Arguments: Setting | Comment
IsNull([CountryRegion]) | StopMacro |  | If CountryRegion is Null, postal code can't be validated.
[CountryRegion] In ("France","Italy","Spain") And Len([Postal Code]) <> 5 | MessageBox | Message: The postal code must be 5 characters. Beep: Yes Type: Information Title: Postal Code Error | If the postal code isn't 5 characters, display a message.
... | CancelEvent |  | Cancel the event.
 | GoToControl | Control Name: PostalCode |
[CountryRegion] In ("Australia","Singapore") And Len([Postal Code]) <> 4 | MessageBox | Message: The postal code must be 4 characters. Beep: Yes Type: Information Title: Postal Code Error | If the postal code isn't 4 characters, display a message.
... | CancelEvent |  | Cancel the event.
 | GoToControl | Control Name: PostalCode |
([CountryRegion] = "Canada") And ([Postal Code] Not Like"[A-Z][0-9][A-Z] [0-9][A-Z][0-9]") | MessageBox | Message: The postal code is not valid. Example of Canadian code: H1J 1C3 Beep: Yes Type: Information Title: Postal Code Error | If the postal code isn't correct for Canada, display a message. (Example of Canadian code: H1J 1C3)
... | CancelEvent |  | Cancel the event.


Report.Dirty Property (Access)

 Copy code hover
[image]

Report.Dirty Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Dirty property to determine whether the current record has been modified since it was last saved. Read/write Boolean.

Syntax

expression .Dirty

expression A variable that represents a Report object.

Remarks

For example, you may want to ask the user whether changes to a record were intended and, if not, allow the user to move to the next record without saving the changes.

When a record is saved, Microsoft Access sets the Dirty property to False. When a user makes changes to a record, the property is set to True.

Example

The following example enables the btnUndo button when data is changed. The UndoEdits( ) subroutine is called from the AfterUpdate event of text box controls. Clicking the enabled btnUndo button restores the original value of the control by using the OldValue property.

VBA Copy code Copy code
Sub UndoEdits()
 If Me.Dirty Then
 Me!btnUndo.Enabled = True ' Enable button.
 Else
 Me!btnUndo.Enabled = False ' Disable button.
 End If
End Sub

Sub btnUndo_Click()
 Dim ctlC As Control
 ' For each control.
 For Each ctlC in Me.Controls
 If ctlC.ControlType = acTextBox Then
 ' Restore Old Value.
 ctlC.Value = ctlC.OldValue
 End If
 Next ctlC
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


Catalog Object (ADOX)

 Copy code hover
[image]

Catalog Object (ADOX)
Send feedback

Contains collections (Tables, Views, Users, Groups, and Procedures) that describe the schema catalog of a data source.

Remarks

You can modify the Catalog object by adding or removing objects or by modifying existing objects. Some providers may not support all of the Catalog objects or may support only viewing schema information.

With the properties and methods of a Catalog object, you can:

  • Open the catalog by setting the ActiveConnection property to an ADO Connection object or a valid connection string.

  • Create a new catalog with the Create method.

  • Determine the owners of the objects in a Catalog with the GetObjectOwner and SetObjectOwner methods.


Cannot have more than 10 fields in an index. (Error 3277)

 Copy code hover
[image]

Cannot have more than 10 fields in an index. (Error 3277)
Send feedback

You defined an index with more than ten fields. Reduce the number of fields to ten or less.


Cannot perform cascading operation. There must be a related record in table

 Copy code hover
[image]

Cannot perform cascading operation. There must be a related record in table <name>. (Error 3397)
Send feedback

The cascade operation you are attempting violates a referential integrity rule that requires a related record in the indicated table. Check the values you are attempting to update or delete, and fix them so they comply with the referential integrity rule.


AutoCorrect Members (Access)

 Copy code hover
[image]

AutoCorrect Members (Access)
Send feedback

Published: July 16, 2012

The AutoCorrect object represents the AutoCorrect functionality of Microsoft Access.

Properties

Name | Description
DisplayAutoCorrectOptions | Returns or sets a Boolean value that specifies whether the AutoCorrect Options button is displayed for the specified control. The default value is True. Read/write.


ActiveConnection Property (ADO MD)

 Copy code hover
[image]

ActiveConnection Property (ADO MD)
Send feedback

Indicates to which ADO Connection object the current cellset or catalog currently belongs.

Settings and Return Values

Sets or returns a Variant that contains a string defining a connection or Connection object. The default is empty.

Remarks

You can set this property to a valid ADO Connection object or to a valid connection string. When this property is set to a connection string, the provider creates a new Connection object using this definition and opens the connection.

If you use the ActiveConnection argument of the Open method to open a Cellset object, the ActiveConnection property will inherit the value of the argument.

Setting the ActiveConnection property of a Catalog object to Nothing releases the associated data, including data in the CubeDefs collection and any related Dimension, Hierarchy, Level, and Member objects. Closing a Connection object that was used to open a Catalog has the same effect as setting the ActiveConnection property to Nothing.

Changing the default database of the connection referenced by the ActiveConnection property of a Catalog object invalidates the contents of the Catalog.

An error will occur if you attempt to change the ActiveConnection property for an open Cellset object.

Note Note

In Visual Basic, remember to use the Set keyword when setting the ActiveConnection property to a Connection object. If you omit the Set keyword, you will actually be setting the ActiveConnection property equal to the Connection object's default property, ConnectionString. The code will work; however, you will create an additional connection to the data source, which may have negative performance implications.

When using the MSOLAP data provider, set the data source in a connection string to a server name and set the initial catalog to the name of a catalog from the data source. To connect to a cube file that is disconnected from a server, set the location to the full path to the .CUB file. In either case, set the provider to the provider name. For example, the following string connects to a catalog named Bobs Video Store on a server named Servername with the MSOLAP Provider:

Copy code Copy code
"Data Source=Servername;Initial Catalog=Bobs Video Store;Provider=msolap"

The following string connects to a local cube file at the location C:\MSDASDK\samples\oledb\olap\data\bobsvid.cub:

Copy code Copy code
"Location=C:\MSDASDK\samples\oledb\olap\data\bobsvid.cub;Provider=msolap"


Events Access Forms How Do I Topics

 Copy code hover
[image]

Events Access Forms How Do I Topics
Send feedback

In this section

  • How to: Apply a Filter When Opening a Form or Report

  • How to: Cancel an Event

  • How to: Cancel the Deletion of a Record by Using Custom Criteria

  • How to: Change the Filter or Sort Order of a Form or Report

  • How to: Disable PAGE UP and PAGE DOWN Keys in a Form

  • How to: Prompt a User Before Closing a Form

  • How to: Suspend Code Execution Until a Pop-up Form is Closed


EmptyCell.Layout Property (Access)

 Copy code hover
[image]

EmptyCell.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified text box. Read-only AcLayoutType.

Version Information

Version Added: Access 2010

Syntax

expression .Layout

expression A variable that represents an EmptyCell object.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


NavigationControl.Undo Method (Access)

 Copy code hover
[image]

NavigationControl.Undo Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the Undo method to reset a control or form when its value has been changed.

Version Information

Version Added: Access 2010

Syntax

expression .Undo

expression A variable that represents a NavigationControl object.

Remarks

For example, you can use the Undo method to clear a change to a record that contains an invalid entry.

If the Undo method is applied to a form, all changes to the current record are lost. If the Undo method is applied to a control, only the control itself is affected.

This method must be applied before the form or control is updated. You may want to include this method in a form's BeforeUpdate event or in a control's Change event.

The Undo method offers an alternative to using the SendKeys statement to send the value of the ESC key in an event procedure.

Example

The following example shows how you can use the Undo method within a control's Change event procedure to force a field named LastName to reset to its original value, if it changed.

VBA Copy code Copy code
Private Sub LastName_Change()
 Me!LastName.Undo
End Sub

The next example uses the Undo method to reset all changes to a form before the form is updated.

VBA Copy code Copy code
Private Sub Form_BeforeUpdate(Cancel As Integer)
 Me.Undo
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


UpdateBatch and CancelBatch Methods Example (VJ++)

 Copy code hover
[image]

UpdateBatch and CancelBatch Methods Example (VJ++)
Send feedback

This example demonstrates the UpdateBatch method in conjunction with the CancelBatch method.

Copy code Copy code

// BeginUpdateBatchJ
import java.io.*;
import com.ms.wfc.data.*;

public class UpdateBatchX
{
 // The main entry point of the application.
 public static void main (String[] args)
 {
 UpdateBatchX();
 System.exit(0);
 }
 // UpdateBatchX Function

 static void UpdateBatchX()
 {
 // Define ADO Objects.
 Recordset rstTitles = null;

 // Declarations.
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"+
 "Initial Catalog='Pubs';Integrated Security='SSPI';";
 String strTitle;
 String strMessage;
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));

 try
 {
 rstTitles = new Recordset();
 rstTitles.setCursorType(AdoEnums.CursorType.KEYSET);
 rstTitles.setLockType(AdoEnums.LockType.BATCHOPTIMISTIC);
 rstTitles.open("Titles", strCnn, AdoEnums.CursorType.KEYSET,
 AdoEnums.LockType.BATCHOPTIMISTIC,
 AdoEnums.CommandType.TABLE);

 rstTitles.moveFirst();

 // Loop through recordset and ask user if she wants
 // to change the type for the specified table.
 while(!rstTitles.getEOF())
 {
 if(rstTitles.getField("Type").getString().
 trim().equalsIgnoreCase("psychology"))
 {
 strTitle = rstTitles.getField("Title").getString();
 strMessage = "Title: "+ strTitle + "\n" +
 "Change type to self_help?Enter (Y/N)";
 System.out.println(strMessage);
 if(in.readLine().trim().equalsIgnoreCase("Y"))
 rstTitles.getField("type").setString("self_help");
 }
 rstTitles.moveNext();
 }
 // Ask the user if she wants to commit to all the
 // changes made above.
 System.out.println("Save all changes?Enter (Y/N)");
 if(in.readLine().trim().equalsIgnoreCase("Y"))
 rstTitles.updateBatch();
 else
 rstTitles.cancelBatch();

 // Print current data in recordset.
 rstTitles.requery();
 rstTitles.moveFirst();
 while(!rstTitles.getEOF())
 {
 System.out.println(rstTitles.getField("title").getString() +
 " - " + rstTitles.getField("type").getString());
 rstTitles.moveNext();
 }

 // Restore original values because this is a demonstration.
 rstTitles.moveFirst();
 while(!rstTitles.getEOF())
 {
 if(rstTitles.getField("type").getString().
 trim().equalsIgnoreCase("self_help"))
 rstTitles.getField("type").setString("psychology");
 rstTitles.moveNext();
 }
 rstTitles.updateBatch();

 System.out.println("Press <Enter> to continue..");
 in.readLine();

 }
 catch(AdoException ae)
 {
 // Notify the user of any errors that result from ADO.

 // As passing a recordset, check for null pointer first.
 if(rstTitles != null)
 {
 PrintProviderError(rstTitles.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 // System read requires this catch.
 catch(java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstTitles != null)
 if (rstTitles.getState() == 1)
 rstTitles.close();
 }
 }

 // PrintProviderError Function
 static void PrintProviderError(Connection cnn1)
 {
 // Print Provider Errors from Connection Object.
 // ErrItem is an item object in the Connections Errors Collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if ( nCount > 0)
 {
 // Collection ranges from 0 to nCount-1.
 for ( i=0;i<nCount; i++)
 {
 ErrItem = cnn1.getErrors().getItem(i);
 System.out.println("\t Error Number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription());
 }
 }
 }
 // PrintIOError Function
 static void PrintIOError(java.io.IOException je)
 {
 System.out.println("Error: \n");
 System.out.println("\t Source: " + je.getClass() + "\n");
 System.out.println("\t Description: "+ je.getMessage() + "\n");
 }
}
// EndUpdateBatchJ


ComboBox.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

ComboBox.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents a ComboBox object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.BorderThemeColorIndex=2

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ComboBox.SetFocus Method (Access)

 Copy code hover
[image]

ComboBox.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Syntax

expression .SetFocus

expression A variable that represents a ComboBox object.

Return Value

Nothing

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.

Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.

Example

The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:

VBA Copy code Copy code
Forms!Employees!EmployeeID.SetFocus

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


TabControl.FontUnderline Property (Access)

 Copy code hover
[image]

TabControl.FontUnderline Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontUnderline property to specify whether text is underlined in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontUnderline

expression A variable that represents a TabControl object.

Remarks

The FontUnderline property uses the following settings.

Setting | Description
True | The text is underlined.
False | (Default) The text isn't underlined.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


SubForm.BottomPadding Property (Access)

 Copy code hover
[image]

SubForm.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the subform and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .BottomPadding

expression A variable that represents a SubForm object.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


ADO Event Instantiation by Language (ADO)

 Copy code hover
[image]

ADO Event Instantiation by Language (ADO)
Send feedback

In this section

  • Visual Basic

  • Visual C++

  • Visual J++

  • VBScript

  • JScript

  • ADO/WFC


Step 3: Send the Data
Send feedback

Step 3: Send the Data

Now that you have a Recordset, you need to send it to the client by saving it as XML to the ASP Response object. Add the following code to the bottom of XMLResponse.asp:

Copy code Copy code

  Response.ContentType = "text/xml"
  Response.Expires = 0
  Response.Buffer = False

  Response.Write "<?xml version='1.0'?>" & vbNewLine
  adoRec.save Response, adPersistXML
  adoRec.Close
  Set adoRec=Nothing
%>

Notice that the ASP Response object is specified as the destination for the Recordset Save method. The destination of the Save method can be any object that supports the IStream interface, such as an ADO Stream object, or a file name that includes the complete path to which the Recordset is to be saved.

Save and close XMLResponse.asp before going to the next step. Also copy the adovbs.inc file from C:\Program Files\Common Files\System\Ado folder to the same folder where you have the XMLResponse.asp file.

Next Step 4: Receive the Data


ToggleButton.OldValue Property (Access)

 Copy code hover
[image]

ToggleButton.OldValue Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.

Syntax

expression .OldValue

expression A variable that represents a ToggleButton object.

Remarks

The OldValue property contains the unedited data from a bound control and is read-only in all views.

Microsoft Access uses the OldValue property to store the original value of a bound control. When you edit a bound control on a form, your changes aren't saved until you move to another record. The OldValue property contains the unedited version of the underlying data.

You can provide your own undo capability by assigning the OldValue property setting to a control. The following example shows how you can undo any changes to text box controls on a form:

VBA Copy code Copy code
Private Sub btnUndo_Click()

 Dim ctlTextbox As Control

 For Each ctlTextbox in Me.Controls
 If ctlTextbox.ControlType = acTextBox Then
 ctlTextbox.Value = ctl.OldValue
 End If
 Next ctlTextbox

End Sub

If the control hasn't been edited, this code has no effect. When you move to another record, the record source is updated, so the current value and the OldValue property will be the same.

The OldValue property setting has the same data type as the field to which the control is bound.

Example

The following example checks to determine if new data entered in a field is within 10 percent of the value of the original data. If the change is greater than 10 percent, the OldValue property is used to restore the original value. This procedure could be called from the BeforeUpdate event of the control that contains data you want to validate.

VBA Copy code Copy code
Public Sub Validate_Field()

 Dim curNewValue As Currency
 Dim curOriginalValue As Currency
 Dim curChange As Currency
 Dim strMsg As String

 curNewValue = Forms!Products!UnitPrice
 curOriginalValue = Forms!Products!UnitPrice.OldValue
 curChange = Abs(curNewValue - curOriginalValue)

 If curChange > (curOriginalValue * .1) Then
 strMsg = "Change is more than 10% of original unit price. " _
 & "Restoring original unit price."
 MsgBox strMsg, vbExclamation, "Invalid change."
 Forms!Products!UnitPrice = curOriginalValue
 End If

End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


OptionGroup.OldBorderStyle Property (Access)

 Copy code hover
[image]

OptionGroup.OldBorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.

Syntax

expression .OldBorderStyle

expression A variable that represents an OptionGroup object.

Remarks

The OldBorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines
Note Note

  • If the OldBorderStyle property is set to None or Dialog, the form doesn't have Maximize or Minimize buttons, regardless of its MinMaxButtons property setting.

  • If the OldBorderStyle property is set to None, the form doesn't have a Control menu, regardless of its ControlBox property setting.

  • The OldBorderStyle property setting doesn't affect the display of the scroll bars, navigation buttons, the record number box, or record selectors.

Example

The following example demonstrates the effect of changing a control's BorderStyle property, while leaving the OldBorderStyle unaffected. The example concludes with setting the BorderStyle property to its original unedited value.

VBA Copy code Copy code
With Forms("Order Entry").Controls("Zip Code") .BorderStyle = 3 ' Short dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 3, 1.

    .BorderStyle = 2 ' Dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 2, 1

    .BorderStyle = .OldBorderStyle ' Solid (default) border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 1, 1
End With

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


AccessObjectProperties.Item Property (Access)

 Copy code hover
[image]

AccessObjectProperties.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only AccessObjectProperty.

Syntax

expression .Item(Index)

expression A variable that represents an AccessObjectProperties object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

AccessObjectProperties Collection

Other resources

AccessObjectProperties Object Members


Index already exists. (Error 3284)

 Copy code hover
[image]

Index already exists. (Error 3284)
Send feedback

You cannot have two indexes with the same name in a table. Rename one of the indexes.


Application.CreateAdditionalData Method (Access)

 Copy code hover
[image]

Application.CreateAdditionalData Method (Access)
See also Send feedback

Published: July 16, 2012

Creates an AdditionalData object that can be used to add additional tables and queries to the parent table that is being exported by the ExportXML method.

Syntax

expression .CreateAdditionalData

expression A variable that represents an Application object.

Return Value

AdditionalData

Example

The following example exports the contents of the Customers table in the Northwind Traders sample database, along with the contents of the Orders and Orders Details tables, to an XML data file named Customer Orders.xml.

VBA Copy code Copy code
Sub ExportCustomerOrderData()
 Dim objOrderInfo As AdditionalData

 Set objOrderInfo = Application.CreateAdditionalData()

 ' Add the Orders and Order Details tables to the data to be exported.
 objOrderInfo.Add "Orders"
 objOrderInfo.Add "Order Details"

 ' Export the contents of the Customers table. The Orders and Order
 ' Details tables will be included in the XML file.
 Application.ExportXML ObjectType:=acExportTable, DataSource:="Customers", _
 DataTarget:="Customer Orders.xml", _
 AdditionalData:=objOrderInfo
End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


OptionGroup.StatusBarText Property (Access)

 Copy code hover
[image]

OptionGroup.StatusBarText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.

Syntax

expression .StatusBarText

expression A variable that represents an OptionGroup object.

Remarks

You set the StatusBarText property by using a string expression up to 255 characters long.

Note Note

The length of the text you can display in the status bar depends on your computer hardware and video display.

You can use the StatusBarText property to provide specific information about a control. For example, when a text box has the focus, a brief instruction can tell the user what kind of data to enter

Note Note

You can also use the ControlTipText property to display a ScreenTip for a control.

If you create a control by dragging a field from the field list, the value in a field's Description property is copied to the StatusBarText property.

Example

The following example sets the status bar text to be displayed when the "Address_TextBox" control in the "Mailing List" form has the focus in Form View.

VBA Copy code Copy code
Forms("Mailing List").Controls("Address_TextBox"). _
 StatusBarText = "Enter the company's mailing address."

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


CommandButton.Exit Event (Access)

 Copy code hover
[image]

CommandButton.Exit Event (Access)
See also Send feedback

Published: July 16, 2012

The Exit event occurs just before a control loses the focus to another control on the same form or report.

Syntax

expression .Exit(Cancel)

expression A variable that represents a CommandButton object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | Set to True to cancel the event.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when this event occurs, set the OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Exit event occurs before the LostFocus event.

Unlike the LostFocus event, the Exit event does not occur when a form loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Server Property Example (VBScript)

 Copy code hover
[image]

Server Property Example (VBScript)
Send feedback

The following code shows how to set the RDS.DataControl parameter at design time and bind it to a data-aware control using the SQLOLEDB provider. Cut and paste this code into a normal ASP document and name it ServerDesignVBS.asp. ASP script will identify your server.

VBS Copy code Copy code
<!-- BeginServerDesignVBS --><%@ Language=VBScript %>
<html><head>
<meta name="VI60_DefaultClientScript" content=VBScript><meta name="GENERATOR" content="Microsoft Visual Studio 6.0">
<title>Server Property Example (VBScript)</title><style>
<!--body {
font-family: 'Verdana','Arial','Helvetica',sans-serif;BACKGROUND-COLOR:white;
COLOR:black;}
.thead {background-color: #008080;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.thead2 {background-color: #800000;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.tbody {text-align: center;
background-color: #f7efde;font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;}
--></style>
</head>
<body><h1>Server Property Example (VBScript)</h1>
<TABLE DATASRC=#RDS><TR>
<TD> <SPAN DATAFLD="FirstName"></SPAN> </TD><TD> <SPAN DATAFLD="LastName"></SPAN> </TD>
<TD> <SPAN DATAFLD="Title"></SPAN> </TD><TD> <SPAN DATAFLD="Type"></SPAN> </TD>
<TD> <SPAN DATAFLD="Email"></SPAN> </TD></TR>
</TABLE><!-- Remote Data Service with Parameters set at Design Time -->
<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"ID=RDS HEIGHT=1 WIDTH=1>
<PARAM NAME="SQL" VALUE="Select * from Employees"><PARAM NAME="SERVER" VALUE="http://<%=Request.ServerVariables("SERVER_NAME")%>">
<PARAM NAME="CONNECT" VALUE="Provider='sqloledb';Integrated Security='SSPI';Initial Catalog='Northwind'"></OBJECT>
</body></html>
<!-- EndServerDesignVBS -->

The following example shows how to set the necessary parameters of RDS.DataControl at run time. To test this example, cut and paste this code into a normal ASP document and name it ServerRuntimeVBS.asp. ASP script will identify your server.

VBS Copy code Copy code
<!-- BeginServerRuntimeVBS --><%@ Language=VBScript %>
<html><head>
<meta name="VI60_DefaultClientScript" content=VBScript><meta name="GENERATOR" content="Microsoft Visual Studio 6.0">
<title>Server Property Example (VBScript)</title><style>
<!--body {
font-family: 'Verdana','Arial','Helvetica',sans-serif;BACKGROUND-COLOR:white;
COLOR:black;}
.thead {background-color: #008080;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.thead2 {background-color: #800000;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
color: white;}
.tbody {text-align: center;
background-color: #f7efde;font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;}
--></style>
</head>
<body><h1>Server Property Example (VBScript)</h1>
<H2>RDS API Code Examples</H2>
<H3>Remote Data Service Server Property Set at Run Time</H3>
<!-- RDS.DataControl with no parameters set at design time --><OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
ID=RDC HEIGHT=1 WIDTH=1></OBJECT>
<TABLE DATASRC=#RDC><TR>
<TD> <SPAN DATAFLD="FirstName"></SPAN> </TD><TD> <SPAN DATAFLD="LastName"></SPAN> </TD>
<TD> <SPAN DATAFLD="Title"></SPAN> </TD><TD> <SPAN DATAFLD="Type"></SPAN> </TD>
<TD> <SPAN DATAFLD="Email"></SPAN> </TD></TR>
</TABLE>
<HR><Input Size=70 Name="txtServer" Value="HTTP://<%= Request.ServerVariables("SERVER_NAME")%>">
<BR><Input Size=70 Name="txtConnect" Value="Provider='sqloledb';Integrated Security='SSPI';Initial Catalog='Northwind'">
<BR><Input Size=70 Name="txtSQL" Value="Select * from Employees">
<HR><INPUT TYPE=BUTTON NAME="Run" VALUE="Run"><BR>
<Script Language="VBScript"><!--
' Set parameters of RDS.DataControl at Run TimeSub Run_OnClick
RDC.Server = txtServer.ValueRDC.SQL = txtSQL.Value
RDC.Connect = txtConnect.ValueRDC.Refresh
End Sub-->
</Script>
</body></html>
<!-- EndServerRuntimeVBS -->

DataControl Object (RDS) | Server Property (RDS)


Attachment.Locked Property (Access)

 Copy code hover
[image]

Attachment.Locked Property (Access)
See also Send feedback

Published: July 16, 2012

The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .Locked

expression A variable that represents an Attachment object.

Remarks

The default setting of the Locked property is True. This setting allows editing, adding, and deleting data.

Use the Locked property to protect data in a field by making it read-only. For example, you might want a control to only display information without allowing editing, or you might want to lock a control until a specific condition is met.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Form.ScrollBars Property (Access)

 Copy code hover
[image]

Form.ScrollBars Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ScrollBars property to specify whether scroll bars appear on a form. Read/write Byte.

Syntax

expression .ScrollBars

expression A variable that represents a Form object.

Remarks

The ScrollBars property uses the following settings.

Setting | Visual Basic | Description
Neither | 0 | No scroll bars appear on the form.
Horizontal Only | 1 | Horizontal scroll bar appears on the form.
Vertical Only | 2 | Vertical scroll bar appears on the form.
Both | 3 | (Default) Vertical and horizontal scroll bars appear on the form.

If your form is larger than the available display window, you can use the ScrollBars property to allow the user to view the entire form.

You can use the NavigationButtons property to control record navigation.

See also

Concepts

Form Object

Other resources

Form Object Members


BoundObjectFrame.MouseUp Event (Access)

 Copy code hover
[image]

BoundObjectFrame.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents a BoundObjectFrame object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was released to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Report.PictureAlignment Property (Access)

 Copy code hover
[image]

Report.PictureAlignment Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureAlignment property to specify where a background picture will appear in an image control or on a form or report. Read/write Byte.Read/write.

Syntax

expression .PictureAlignment

expression A variable that represents a Report object.

Remarks

The PictureAlignment property uses the following settings.

Setting | Visual Basic | Description
Top Left | 0 | The picture is displayed in the top-left corner of the image control, Form window, or page of a report.
Top Right | 1 | The picture is displayed in the top-right corner of the image control, Form window, or page of a report.
Center | 2 | (Default) The picture is centered in the image control, Form window, or page of a report.
Bottom Left | 3 | The picture is displayed in the bottom-left corner of the image control, Form window, or page of a report.
Bottom Right | 4 | The picture is displayed in the bottom-right corner of the image control, Form window, or page of a report.
Form Center | 5 | (Forms only) The form's picture is centered horizontally in relation to the width of the form and vertically in relation to the height the entire form.

You can also set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

This property can be set in any view.

The Form Center setting aligns a form's picture in the center of the form itself. All other PictureAlignment property settings align a form's picture in relation to the Form window. If you want to make sure that a form's picture is displayed only on the form or tiled across only the form, set the PictureAlignment property to Form Center.

For reports, the picture appears relative to a full page and not in relation to the size of the actual report. If your report is less than a full page and you want a picture to appear at a location not available through the PictureAlignment property settings, use an image control instead.

When you set the PictureTiling property to Yes, tiling of the picture will begin from the PictureAlignment property setting.

Example

The following example displays the picture "Logo.gif" in the top left corner of the "Purchase Order" report.

VBA Copy code Copy code
With Reports("Purchase Order")
 .Picture = "C:\Picture Files\Logo.gif"
 .PictureAlignment = 0
End With

See also

Concepts

Report Object

Other resources

Report Object Members


LockTypeEnum Enumeration (DAO)

 Copy code hover
[image]

LockTypeEnum Enumeration (DAO)
Send feedback

Specifies the type of record locking used when opening a recordset.

Name

Value

Description

dbOptimistic

3

Optimistic concurrency based on record ID. Cursor compares record ID in old and new records to determine if changes have been made since the record was last accessed.

dbOptimisticBatch

5

Enables batch optimistic updates (ODBCDirect workspaces only).

dbOptimisticValue

1

Optimistic concurrency based on record values. Cursor compares data values in old and new records to determine if changes have been made since the record was last accessed (ODBCDirect workspaces only).

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

dbPessimistic

2

Pessimistic concurrency. Cursor uses the lowest level of locking sufficient to ensure that the record can be updated.


Application.DMin Method (Access)

 Copy code hover
[image]

Application.DMin Method (Access)
See also Send feedback

Published: July 16, 2012

You can use DMin function to determine minnimum value in a specified set of records (a domain). .

Syntax

expression .DMin(Expr, Domain, Criteria)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Expr | Required | String | An expression that identifies the field for which you want to find the minimum or maximum value. It can be a string expression identifying a field in a table or query, or it can be an expression that performs calculation on data in that field . In expr, you can include the name of a field in a table, a control on a form, a constant, or a function. If expr includes a function, it can be either built-in or user-defined, but not another domain aggregate or SQL aggregate function.
Domain | Required | String | A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter.
Criteria | Optional | Variant | An optional string expression used to restrict the range of data on which the DMin function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the DMin function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain, otherwise the DMin function returns a Null.

Return Value

Variant

Remarks

For example, you could use the DMin function in calculated controls on a report to display smallest order amount for a particular customer. Or you could use the DMin function in a query expression to display all orders with a discount greater than the minimum possible discount.

The DMin function returns the minimum values that satisfy criteria. If expr identifies numeric data, the DMin function returns numeric values. If expr identifies string data, they return the string that is first or last alphabetically.

The DMin function ignores Null values in the field referenced by expr. However, if no record satisfies criteria or if domain contains no records, the DMin function returns a Null.

You can use the DMin function to specify criteria in the Criteria row of a query, in a calculated field expression in a query, or in the Update To row of an update query.

Note Note

You can use the DMin function or the Min function in a calculated field expression of a totals query. If you use the DMin function, values are evaluated before the data is grouped. If you use the Min function, the data is grouped before values in the field expression are evaluated.

If you simply want to find the minimum or maximum value of all records in domain, use the Min or Max function.

Although you can use the DMin or DMax function to find the minimum or maximum value from a field in a foreign table, it may be more efficient to create a query that contains the fields that you need from both tables and base your form or report on that query.

Example

The following example returns the lowest and highest values from the Freight field for orders shipped to the United Kingdom. The domain is an Orders table. The criteria argument restricts the resulting set of records to those for which ShipCountry equals UK.

VBA Copy code Copy code
Dim curX As Currency
Dim curY As Currency

curX = DMin("[Freight]", "Orders", "[ShipCountry] = 'UK'")
curY = DMax("[Freight]", "Orders", "[ShipCountry] = 'UK'")

In the next example, the criteria expression includes a variable, dteOrderDate. Note that number signs (#) are included in the string expression, so that when the strings are concatenated, they will enclose the date.

VBA Copy code Copy code
Dim dteOrderDate As Date
Dim curX As Currency

dteOrderDate = #03/30/2000#
curX = DMin("[Freight]", "Orders", _
    "[OrderDate] = #" & dteOrderDate & "#")

The following examples show how to use various types of criteria with the DMin function.

Sample code provided by: Community Member Icon The UtterAccess community | About the Contributors

Copy code Copy code
    ' ***************************
    ' Typical Use
    ' Numerical values. Replace "number" with the number to use.
    variable = DMin("[FieldName]", "TableName", "[Criteria] = number")

    ' Strings.
    ' Numerical values. Replace "string" with the string to use.
    variable = DMin("[FieldName]", "TableName", "[Criteria]= 'string'")

    ' Dates. Replace "date" with the string to use.
    variable = DMin("[FieldName]", "TableName", "[Criteria]= #date#")
    ' ***************************

    ' ***************************
    ' Referring to a control on a form
    ' Numerical values
    variable = DMin("[FieldName]", "TableName", "[Criteria] = " & Forms!FormName!ControlName)

    ' Strings
    variable = DMin("[FieldName]", "TableName", "[Criteria] = '" & Forms!FormName!ControlName & "'")

    ' Dates
    variable = DMin("[FieldName]", "TableName", "[Criteria] = #" & Forms!FormName!ControlName & "#")
    ' ***************************

    ' ***************************
    ' Combinations
    ' Multiple types of criteria
    variable = DMin("[FieldName]", "TableName", "[Criteria1] = " & Forms![FormName]![Control1] _
             & " AND [Criteria2] = '" & Forms![FormName]![Control2] & "'" _
            & " AND [Criteria3] =#" & Forms![FormName]![Control3] & "#")

    ' Use two fields from a single record.
    variable = DMin("[LastName] & ', ' & [FirstName]", "tblPeople", "[PrimaryKey] = 7")

    ' Expressions
    variable = DMin("[Field1] + [Field2]", "tableName", "[PrimaryKey] = 7")

    ' Control Structures
    variable = DMin("IIf([LastName] Like 'Smith', 'True', 'False')", "tableName", "[PrimaryKey] = 7")
    ' ***************************

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Application Object

Other resources

Application Object Members


ToggleButton.ValidationText Property (Access)

 Copy code hover
[image]

ToggleButton.ValidationText Property (Access)
See also Send feedback

Published: July 16, 2012

Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.

Syntax

expression .ValidationText

expression A variable that represents a ToggleButton object.

Remarks

Enter an expression for the ValidationRule property setting and text for the ValidationText property setting. The maximum length for the ValidationRule property setting is 2048 characters. The maximum length for the ValidationText property setting is 255 characters.

For controls, you can set the ValidationRule property to any valid expression. For field and record validation rules, the expression can't contain user-defined functions, domain aggregate or aggregate functions, the Eval function, or CurrentUser method, or references to forms, queries, or tables. In addition, field validation rules can't contain references to other fields. For records, expressions can include references to fields in that table.

For table fields and records, you can also set these properties in Visual Basic by using the DAO ValidationRule property.

Note Note

The ValidationRule and ValidationText properties don't apply to check box, option button, or toggle buttoncontrols when they are in an option group. They apply only to the option group itself.

Microsoft Access automatically validates values based on a field's data type; for example, Microsoft Access doesn't allow text in a numeric field. You can set rules that are more specific by using the ValidationRule property.

If you set the ValidationRule property but not the ValidationText property, Microsoft Access displays a standard error message when the validation rule is violated. If you set the ValidationText property, the text you enter is displayed as the error message.

For example, when a record is added for a new employee, you can enter a ValidationRule property requiring that the value in the employee's StartDate field fall between the company's founding date and the current date. If the date entered isn't in this range, you can display the ValidationText property message: "Start date is incorrect."

If you create a control by dragging a field from the field list, the field's validation rule remains in effect, although it isn't displayed in the control's ValidationRule property box in the property sheet. This is because a field's validation rule is inherited by a control bound to that field.

Control, field, and record validation rules are applied as follows:

  • Validation rules you set for fields and controls are applied when you edit the data and the focus leaves the field or control.

  • Validation rules for records are applied when you move to another record.

  • If you create validation rules for both a field and a control bound to the field, both validation rules are applied when you edit data and the focus leaves the control.

The following table contains expression examples for the ValidationRule and ValidationText properties.

ValidationRule property | ValidationText property
<> 0 | Entry must be a nonzero value.
> 1000 Or Is Null | Entry must be blank or greater than 1000.
Like "A????" | Entry must be 5 characters and begin with the letter "A".
>= #1/1/96# And <#1/1/97# | Entry must be a date in 1996.
DLookup("CustomerID", "Customers", "CustomerID = Forms!Customers!CustomerID") Is Null | Entry must be a unique CustomerID (domain aggregate functions are allowed only for form-level validation).

If you create a validation rule for a field, Microsoft Access doesn't normally allow a Null value to be stored in the field. If you want to allow a Null value, add "Is Null" to the validation rule, as in "<> 8 Or Is Null" and make sure the Required property is set to No.

You can't set field or record validation rules for tables created outside Microsoft Access (for example, dBASE, Paradox, or SQL Server). For these kinds of tables, you can create validation rules for controls only.

Example

The following example creates a validation rule for a field that allows only values over 65 to be entered. If a number less than 65 is entered, a message is displayed. The properties are set by using the SetFieldValidation function.

VBA Copy code Copy code
Dim strTblName As String, strFldName As String
Dim strValidRule As String
Dim strValidText As String, intX As Integer

strTblName = "Customers"
strFldName = "Age"
strValidRule = ">= 65"
strValidText = "Enter a number greater than or equal to 65."
intX = SetFieldValidation(strTblName, strFldName, _
 strValidRule, strValidText)

Function SetFieldValidation(strTblName As String, _
 strFldName As String, strValidRule As String, _
 strValidText As String) As Integer

 Dim dbs As Database, tdf As TableDef, fld As Field

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 Set fld = tdf.Fields(strFldName)
 fld.ValidationRule = strValidRule
 fld.ValidationText = strValidText
End Function

The next example uses the SetTableValidation function to set record-level validation to ensure that the value in the EndDate field comes after the value in the StartDate field.

VBA Copy code Copy code
Dim strTblName As String, strValidRule As String
Dim strValidText As String
Dim intX As Integer

strTblName = "Employees"
strValidRule = "EndDate > StartDate"
strValidText = "Enter an EndDate that is later than the StartDate."
intX = SetTableValidation(strTblName, strValidRule, strValidText)

Function SetTableValidation(strTblName As String, _
 strValidRule As String, strValidText As String) _
 As Integer

 Dim dbs As Database, tdf As TableDef

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 tdf.ValidationRule = strValidRule
 tdf.ValidationText = strValidText
End Function

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Format Property - Date/Time Data Type

 Copy code hover
[image]

Format Property - Date/Time Data Type
Send feedback

Published: July 16, 2012

You can set the Format property to predefined date and time formats or use custom formats for the Date/Time data type.

Setting

Predefined Formats

The following table shows the predefined Format property settings for the Date/Time data type.

Setting

Description

General Date

(Default) If the value is a date only, no time is displayed; if the value is a time only, no date is displayed. This setting is a combination of the Short Date and Long Time settings. Examples: 4/3/93, 05:34:00 PM, and 4/3/93 05:34:00 PM.

Long Date

Same as the Long Date setting in the regional settings of Windows. Example: Saturday, April 3, 1993.

Medium Date

Example: 3-Apr-93.

Short Date

Same as the Short Date setting in the regional settings of Windows. Example: 4/3/93.

Caution note Caution

The Short Date setting assumes that dates between 1/1/00 and 12/31/29 are twenty-first century dates (that is, the years are assumed to be 2000 to 2029). Dates between 1/1/30 and 12/31/99 are assumed to be twentieth century dates (that is, the years are assumed to be 1930 to 1999).

Long Time

Same as the setting on the Time tab in the regional settings of Windows. Example: 5:34:23 PM.

Medium Time

Example: 5:34 PM.

Short Time

Example: 17:34.

Custom Formats

You can create custom date and time formats by using the following symbols.

Symbol | Description
: (colon) | Time separator. Separators are set in the regional settings of Windows.
/ | Date separator.
c | Same as the General Date predefined format.
d | Day of the month in one or two numeric digits, as needed (1 to 31).
dd | Day of the month in two numeric digits (01 to 31).
ddd | First three letters of the weekday (Sun to Sat).
dddd | Full name of the weekday (Sunday to Saturday).
ddddd | Same as the Short Date predefined format.
dddddd | Same as the Long Date predefined format.
w | Day of the week (1 to 7).
ww | Week of the year (1 to 53).
m | Month of the year in one or two numeric digits, as needed (1 to 12).
mm | Month of the year in two numeric digits (01 to 12).
mmm | First three letters of the month (Jan to Dec).
mmmm | Full name of the month (January to December).
q | Date displayed as the quarter of the year (1 to 4).
y | Number of the day of the year (1 to 366).
yy | Last two digits of the year (01 to 99).
yyyy | Full year (0100 to 9999).
h | Hour in one or two digits, as needed (0 to 23).
hh | Hour in two digits (00 to 23).
n | Minute in one or two digits, as needed (0 to 59).
nn | Minute in two digits (00 to 59).
s | Second in one or two digits, as needed (0 to 59).
ss | Second in two digits (00 to 59).
ttttt | Same as the Long Time predefined format.
AM/PM | Twelve-hour clock with the uppercase letters "AM" or "PM", as appropriate.
am/pm | Twelve-hour clock with the lowercase letters "am" or "pm", as appropriate.
A/P | Twelve-hour clock with the uppercase letter "A" or "P", as appropriate.
a/p | Twelve-hour clock with the lowercase letter "a" or "p", as appropriate.
AMPM | Twelve-hour clock with the appropriate morning/afternoon designator as defined in the regional settings of Windows.

Custom formats are displayed according to the settings specified in the regional settings of Windows. Custom formats inconsistent with the settings specified in the regional settings of Windows are ignored.

Note Note

If you want to add a comma or other separator to a custom format, enclose the separator in quotation marks as follows: mmm d", "yyyy.

Example

The following are examples of custom date/time formats.

Setting | Display
ddd", "mmm d", "yyyy | Mon, Jun 2, 1997
mmmm dd", "yyyy | June 02, 1997
"This is week number "ww | This is week number 22
"Today is "dddd | Today is Tuesday

You could use a custom format to display "A.D." before or "B.C." after a year depending on whether a positive or negative number is entered. To see this custom format work, create a new table field, set its data type to Number, and enter a format as follows:

"A.D. " #;# " B.C."

Positive numbers are displayed as years with an "A.D." before the year. Negative numbers are displayed as years with a "B.C." after the year.


ComboBox.Name Property (Access)

 Copy code hover
[image]

ComboBox.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a ComboBox object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Line.BorderShade Property (Access)

 Copy code hover
[image]

Line.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents a Line object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

Line Object

Other resources

Line Object Members


Line.ControlType Property (Access)

 Copy code hover
[image]

Line.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Syntax

expression .ControlType

expression A variable that represents a Line object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, nd AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

Line Object

Other resources

Line Object Members


TabControl.DblClick Event (Access)

 Copy code hover
[image]

TabControl.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Syntax

expression .DblClick(Cancel)

expression A variable that represents a TabControl object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the DblClick event occurs. Setting the Cancel argument to True (-1) cancels the DblClick event.

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Recordset2.ValidationRule Property (DAO)

 Copy code hover
[image]

Recordset2.ValidationRule Property (DAO)
Send feedback

Sets or returns a value that validates the data in a field as it's changed or added to a table (Microsoft Access workspaces only).Read/write String.

Syntax

expression .ValidationRule

expression A variable that represents a Recordset2 object.

Remarks

The settings or return values is a String that describes a comparison in the form of an SQL WHERE clause without the WHERE reserved word. For an object not yet appended to the Fields collection, this property is read/write.

The ValidationRule property determines whether or not a field contains valid data. If the data is not valid, a trappable run-time error occurs. The returned error message is the text of the ValidationText property, if specified, or the text of the expression specified by ValidationRule.

For a Recordset object, use of the ValidationRule property is read-only. For a TableDef object, use of the ValidationRule property depends on the status of the TableDef object, as the following table shows.

TableDef | Usage
Base table | Read/write
Linked table | Read-only

Validation is supported only for databases that use the Microsoft Access database engine.

The string expression specified by the ValidationRule property of a Field object can refer only to that Field. The expression can't refer to user-defined functions, SQL aggregate functions, or queries. To set a Field object's ValidationRule property when its ValidateOnSet property setting is True, the expression must successfully parse (with the field name as an implied operand) and evaluate to True. If its ValidateOnSet property setting is False, the ValidationRule property setting is ignored.

The ValidationRule property of a Recordset or TableDef object can refer to multiple fields in that object. The restrictions noted earlier in this topic for the Field object apply.

For a table-type Recordset object, the ValidationRule property inherits the ValidationRule property setting of the TableDef object that you use to create the table-type Recordset object.

Note Note

If you set the property to a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strRule = "PRICE > " & lngPrice, and lngPrice = 125,50), an error will result when your code attempts to validate any data. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and Microsoft Access SQL only accepts U.S. decimal characters.


Stream Object (ADO)

 Copy code hover
[image]

Stream Object (ADO)
Send feedback

Represents a stream of binary data or text.

Remarks

In tree-structured hierarchies such as a file system or an e-mail system, a Record may have a default binary stream of bits associated with it that contains the contents of the file or the e-mail. A Stream object can be used to manipulate fields or records containing these streams of data. A Stream object can be obtained in these ways:

  • From a URL pointing to an object (typically a file) containing binary or text data. This object can be a simple document, a Record object representing a structured document, or a folder.

  • By opening the default Stream object associated with a Record object. You can obtain the default stream associated with a Record object when the Record is opened, to eliminate a round-trip just to open the stream.

  • By instantiating a Stream object. These Stream objects can be used to store data for the purposes of your application. Unlike a Stream associated with a URL, or the default Stream of a Record, an instantiated Stream has no association with an underlying source by default.

With the methods and properties of a Stream object, you can do the following:

  • Open a Stream object from a Record or URL with the Open method.

  • Close a Stream with the Close method.

  • Input bytes or text to a Stream with the Write and WriteText methods.

  • Read bytes from the Stream with the Read and ReadText methods.

  • Write any Stream data still in the ADO buffer to the underlying object with the Flush method.

  • Copy the contents of a Stream to another Stream with the CopyTo method.

  • Control how lines are read from the source file with the SkipLine method and the LineSeparator property.

  • Determine the end of stream position with the EOS property and SetEOS method.

  • Save and restore data in files with the SaveToFile and LoadFromFile methods.

  • Specify the character set used for storing the Stream with the Charset property.

  • Halt an asynchronous Stream operation with the Cancel method.

  • Determine the number of bytes in a Stream with the Size property.

  • Control the current position within a Stream with the Position property.

  • Determine the type of data in a Stream with the Type property.

  • Determine the current state of the Stream (closed, open, or executing) with the State property.

  • Specify the access mode for the Stream with the Mode property.

Note Note

URLs using the http scheme will automatically invoke the Microsoft OLE DB Provider for Internet Publishing. For more information, see Absolute and Relative URLs.


ADO/WFC Syntax Index

 Copy code hover
[image]

ADO/WFC Syntax Index
Send feedback

The ADO Language Reference uses the Microsoft Visual Basic programming language to illustrate ADO method and property syntax. This index is a cross-reference to the ADO Language Reference topics, based on Microsoft Visual J++ and ADO for Windows Foundation Classes (ADO/WFC). When differences in syntax arise, use the function signatures in this index, as opposed to the syntax listings in the language reference topic.

Method and property syntax are listed for the following elements:

ActiveX Data Objects

  • ADO Collections

  • Command object

  • Connection object

  • Error object

  • Field object

  • Parameter object

  • Recordset object

Remote Data Service

  • DataSpace

  • ObjectProxy


TextBox.TabIndex Property (Access)

 Copy code hover
[image]

TextBox.TabIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.

Syntax

expression .TabIndex

expression A variable that represents a TextBox object.

Remarks

You can set the TabIndex property to an integer representing the position of the control within the tab order of the form. Valid settings are 0 for the first tab position, up to the total number of controls minus 1 for the last tab position. For example, if a form has three controls that each have a TabIndex property, valid TabIndex property settings are 0, 1, and 2.

Setting the TabIndex property to an integer less than 0 produces an error.

By default, Microsoft Access assigns a tab order to controls in the order that you create them on a form. Each new control is placed last in the tab order. If you change the setting of a control's TabIndex property to adjust the tab order, Microsoft Access automatically renumbers the TabIndex property setting of other controls to reflect insertions and deletions.

In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the TAB key.

Changing the tab order of other controls on the form doesn't affect what happens when you press a control's access key. For example, if you've created an access key for the label of a text box, the focus will move to the text box whenever you press the label's access key — even if you change the TabIndex property setting for the text box.

If you press an access key for a control such as a label that doesn't have a TabIndex property (and thus isn't in the tab order), the focus moves to the next control in the tab order that can receive the focus.

Example

The following example reverses the tab order of a command button and a text box. Because TextBox1 was created first, it has a TabIndex property setting of 0 and Command1 has a setting of 1.

VBA Copy code Copy code
Sub Form_Click()
 Me!Command1.TabIndex = 0
 Me!TextBox1.TabIndex = 1
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Control.GridlineStyleBottom Property (Access)

 Copy code hover
[image]

Control.GridlineStyleBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the bottom gridline style of the specified control. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleBottom

expression A variable that represents a Control object.

Remarks

The BottomGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

Control Object

Other resources

Control Object Members


NavigationControl.EventProcPrefix Property (Access)

 Copy code hover
[image]

NavigationControl.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .EventProcPrefix

expression A variable that represents a NavigationControl object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Recordset2.Requery Method (DAO)

 Copy code hover
[image]

Recordset2.Requery Method (DAO)
Send feedback

Updates the data in a Recordset object by re-executing the query on which the object is based.

Syntax

expression .Requery(NewQueryDef)

expression A variable that represents a Recordset2 object.

Parameters

Name | Required/Optional | Data Type | Description
NewQueryDef | Optional | Variant | Represents the Name property value of a QueryDef object

Remarks

Use this method to make sure that a Recordset contains the most recent data. This method re-populates the current Recordset by using either the current query parameters or (in a Microsoft Access workspace) the new ones supplied by the newquerydef argument.

If you don't specify a newquerydef argument, the Recordset is re-populated based on the same query definition and parameters used to originally populate the Recordset. Any changes to the underlying data will be reflected during this re-population. If you didn't use a QueryDef to create the Recordset, the Recordset is re-created from scratch.

If you specify the original QueryDef in the newquerydef argument, then the Recordset is requeried using the parameters specified by the QueryDef. Any changes to the underlying data will be reflected during this re-population. To reflect any changes to the query parameter values in the Recordset, you must supply the newquerydef argument.

If you specify a different QueryDef than what was originally used to create the Recordset, the Recordset is re-created from scratch.

When you use Requery, the first record in the Recordset becomes the current record.

You can't use the Requery method on dynaset- or snapshot-type Recordset objects whose Restartable property is set to False. However, if you supply the optional newquerydef argument, the Restartable property is ignored.

If both the BOF and EOF property settings of the Recordset object are True after you use the Requery method, the query didn't return any records and the Recordset contains no data.

Example

This example shows how the Requery method can be used to refresh a query after underlying data has been changed.

VBA Copy code Copy code
Sub RequeryX()

 Dim dbsNorthwind As Database
 Dim qdfTemp As QueryDef
 Dim rstView As Recordset2
 Dim rstChange As Recordset2

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set qdfTemp = dbsNorthwind.CreateQueryDef("", _
 "PARAMETERS ViewCountry Text; " & _
 "SELECT FirstName, LastName, Country FROM " & _
 "Employees WHERE Country = [ViewCountry] " & _
 "ORDER BY LastName")

 qdfTemp.Parameters!ViewCountry = "USA"
 Debug.Print "Data after initial query, " & _
 [ViewCountry] = USA"
 Set rstView = qdfTemp.OpenRecordset
 Do While Not rstView.EOF
 Debug.Print " " & rstView!FirstName & " " & _
 rstView!LastName & ", " & rstView!Country
 rstView.MoveNext
 Loop

 ' Change underlying data.
 Set rstChange = dbsNorthwind.OpenRecordset("Employees")
 rstChange.AddNew
 rstChange!FirstName = "Nina"
 rstChange!LastName = "Roberts"
 rstChange!Country = "USA"
 rstChange.Update

 rstView.Requery
 Debug.Print "Requery after changing underlying data"
 Set rstView = qdfTemp.OpenRecordset
 Do While Not rstView.EOF
 Debug.Print " " & rstView!FirstName & " " & _
 rstView!LastName & ", " & rstView!Country
 rstView.MoveNext
 Loop

 ' Restore original data because this is only a
 ' demonstration.
 rstChange.Bookmark = rstChange.LastModified
 rstChange.Delete
 rstChange.Close

 rstView.Close
 dbsNorthwind.Close

End Sub

This example shows how the Requery method can be used to refresh a query after the query parameters have been changed.

VBA Copy code Copy code
Sub RequeryX2()

 Dim dbsNorthwind As Database
 Dim qdfTemp As QueryDef
 Dim prmCountry As Parameter
 Dim rstView As Recordset2

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set qdfTemp = dbsNorthwind.CreateQueryDef("", _
 "PARAMETERS ViewCountry Text; " & _
 "SELECT FirstName, LastName, Country FROM " & _
 "Employees WHERE Country = [ViewCountry] " & _
 "ORDER BY LastName")
 Set prmCountry = qdfTemp.Parameters!ViewCountry

 qdfTemp.Parameters!ViewCountry = "USA"
 Debug.Print "Data after initial query, " & _
 [ViewCountry] = USA"
 Set rstView = qdfTemp.OpenRecordset
 Do While Not rstView.EOF
 Debug.Print " " & rstView!FirstName & " " & _
 rstView!LastName & ", " & rstView!Country
 rstView.MoveNext
 Loop

 ' Change query parameter.
 qdfTemp.Parameters!ViewCountry = "UK"
 ' QueryDef argument must be included so that the
 ' resulting Recordset reflects the change in the query
 ' parameter.
 rstView.Requery qdfTemp
 Debug.Print "Requery after changing parameter, " & _
 "[ViewCountry] = UK"
 Do While Not rstView.EOF
 Debug.Print " " & rstView!FirstName & " " & _
 rstView!LastName & ", " & rstView!Country
 rstView.MoveNext
 Loop

 rstView.Close
 dbsNorthwind.Close

End Sub


ComboBox.ControlSource Property (Access)

 Copy code hover
[image]

ComboBox.ControlSource Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.

Syntax

expression .ControlSource

expression A variable that represents a ComboBox object.

Remarks

The ControlSource property uses the following settings.

Setting | Description
A field name | The control is bound to a field in a table, query, or SQL statement. Data from the field is displayed in the control. Changes to the data inside the control change the corresponding data in the field. (To make the control read-only, set the Locked property to Yes.) If you click a control bound to a field that has a Hyperlink data type, you jump to the destination specified in the hyperlink address.
An expression | The control displays data generated by an expression. This data can be changed by the user but isn't saved in the database.

For reports, the ControlSource property applies only to report group levels.

Forms and reports act as "windows" into your database. You specify the primary source of data for a form or report by setting its RecordSource property to a table, query, or SQL statement. You can then set the ControlSource property to a field in the source of data or to an expression. If the ControlSource property setting is an expression, the value displayed is read-only and not saved in the database. For example, you can use the following settings.

Sample setting | Description
LastName | For a control, data from the LastName field is displayed in the control. For a report group level, Microsoft Access groups the data on last name.
=Date( ) + 7 | For a control, this expression displays a date seven days from today in the control.
=DatePart("q",ShippedDate) | For a control, this expression displays the quarter of the shipped date. For a report group level, Microsoft Access groups the data on the quarter of the shipped date.

Example

The following example sets the ControlSource property for a text box named AddressPart to a field named City:

VBA Copy code Copy code
Forms!Customers!AddressPart.ControlSource = "City"

The next example sets the ControlSource property for a text box named Expected to the expression =Date() + 7

VBA Copy code Copy code
Me!Expected.ControlSource = "=Date() + 7"

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


SmartTagProperty Object (Access)

 Copy code hover
[image]

SmartTagProperty Object (Access)
See also Send feedback

Published: July 16, 2012

Represents a single instance of a custom property for a smart tag. The SmartTagProperty object is a member of the SmartTagProperties collection.

Remarks

To return a SmartTagProperty object, use the Item method of the SmartTagProperties collection, or use SmartTagProperties (Index), where Index is the number of the property. To return the information related to a custom property for a smart tag, use the Name and Value properties of the SmartTagProperty object.

See also

Concepts

Access Object Model Reference

Other resources

SmartTagProperty Object Members


Relations.Refresh Method (DAO)

 Copy code hover
[image]

Relations.Refresh Method (DAO)
Send feedback

Updates the objects in the specified colletion to reflect the database's current schema.

Syntax

expression .Refresh

expression A variable that represents a Relations object.

Remarks

Use the Refresh method in multiuser environments in which other users may change the database. You may also need to use it on any collections that are indirectly affected by changes to the database. For example, if you change a Users collection, you may need to refresh a Groups collection before using the Groups collection.

A collection is filled with objects the first time it's referred to and won't automatically reflect subsequent changes other users make. If it's likely that another user has changed a collection, use the Refresh method on the collection immediately before carrying out any task in your application that assumes the presence or absence of a particular object in the collection. This will ensure that the collection is as up-to-date as possible. On the other hand, using Refresh can unnecessarily slow performance.


Report.OnPage Property (Access)

 Copy code hover
[image]

Report.OnPage Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Page box in the Properties window of a report. Read/write String.

Syntax

expression .OnPage

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Page event occurs after Microsoft Access formats a page of a report for printing, but before the page is printed.

The OnPage value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Page box in the report's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Page box is blank, the property value is an empty string.

Example

The following example prints the value of the OnPage property in the Immediate window for the "Purchase Order" report.

VBA Copy code Copy code
Debug.Print Reports("Purchase Order").OnPage

See also

Concepts

Report Object

Other resources

Report Object Members


Hierarchies Collection (ADO MD Reference)

 Copy code hover
[image]

Hierarchies Collection (ADO MD Reference)
Send feedback

In this section

  • Hierarchies Collection (ADO MD)

  • Hierarchies Collection Properties, Methods, and Events (ADO MD)


ToggleButton.DblClick Event (Access)

 Copy code hover
[image]

ToggleButton.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Syntax

expression .DblClick(Cancel)

expression A variable that represents a ToggleButton object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the DblClick event occurs. Setting the Cancel argument to True (-1) cancels the DblClick event.

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Form.RecordsetClone Property (Access)

 Copy code hover
[image]

Form.RecordsetClone Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the RecordsetClone property to refer to a form's Recordset object specified by the form's RecordSource property. Read-only.

Syntax

expression .RecordsetClone

expression A variable that represents a Form object.

Remarks

The RecordsetClone property setting is a copy of the underlying query or table specified by the form's RecordSource property. If a form is based on a query, for example, referring to the RecordsetClone property is the equivalent of cloning a Recordset object by using the same query. If you then apply a filter to the form, the Recordset object reflects the filtering.

This property is available only by using Visual Basic and is read-only in all views.

You use the RecordsetClone property to navigate or operate on a form's records independent of the form itself. For example, you can use the RecordsetClone property when you want to use a method, such as the DAO Find methods, that can't be used with forms.

When a new Recordset object is opened, its first record is the current record. If you one of the Find method or one of the Move methods to make any other record in the Recordset object current, you must synchronize the current record in the Recordset object with the form's current record by assigning the value of the DAO Bookmark property to the form's Bookmark property.

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Transfer data from Access to Excel

Example

The following example uses the RecordsetClone property to create a new clone of the Recordset object from the Orders form and then prints the names of the fields in the Immediate window.

VBA Copy code Copy code
Sub Print_Field_Names()
    Dim rst As Recordset, intI As Integer
    Dim fld As Field

    Set rst = Me.RecordsetClone
    For Each fld in rst.Fields
        ' Print field names.
        Debug.Print fld.Name
    Next
End Sub

The next example uses the RecordsetClone property and the Recordset object to synchronize a recordset's record with the form's current record. When a company name is selected from a combo box, the FindFirst method is used to locate the record for that company and the Recordset object's DAO Bookmark property is assigned to the form's Bookmark property, causing the form to display the found record.

VBA Copy code Copy code
Sub SupplierID_AfterUpdate()
    Dim rst As Recordset
    Dim strSearchName As String

    Set rst = Me.RecordsetClone
    strSearchName = Str(Me!SupplierID)
    rst.FindFirst "SupplierID = " & strSearchName
        If rst.NoMatch Then
            MsgBox "Record not found"
        Else
            Me.Bookmark = rst.Bookmark
        End If
    rst.Close
End Sub

You can use the RecordCount property to count the number of records in a Recordset object. The following example shows how you can combine the RecordCount property and the RecordsetClone property to count the records in a form:

VBA Copy code Copy code
Forms!Orders.RecordsetClone.MoveLast
MsgBox "My form contains " _
    & Forms!Orders.RecordsetClone.RecordCount _
    & " records.", vbInformation, "Record Count"

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Form Object

Other resources

Form Object Members


TextBox Object (Access)

 Copy code hover
[image]

TextBox Object (Access)
See also Send feedback

Published: July 16, 2012

This object corresponds to a text box. Text boxes on a form or report display data from a record source.

Remarks

This type of text box is called a bound text box because it's bound to data in a field. Text boxes can also be unbound. For example, you can create an unbound text box to display the results of a calculation, or to accept input from a user. Data in an unbound text box isn't saved with the database.

Control: | Tool:

See also

Concepts

Access Object Model Reference

Other resources

TextBox Object Members


BoundObjectFrame.Action Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Action Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Action property in Visual Basic to specify the operation to perform on an OLE object. Read/write Integer.

Syntax

expression .Action

expression A variable that represents a BoundObjectFrame object.

Remarks

The Action property uses the following settings.

Constant | Description
acOLECreateEmbed (0) | Creates an embedded object. To use this setting, you must first set the control'sOLETypeAllowed property to acOLEEmbedded or acOLEEither. Set the Class property to the type of OLE object you want to create. You can use the SourceDoc property to use an existing file as a template.
acOLECreateLink (1) | Creates a linked OLE object from the contents of a file. To use this setting, you must first set the control's OLETypeAllowed and SourceDoc properties. Set the OLETypeAllowed property to acOLELinked or acOLEEither. The SourceDoc property specifies the file used to create the OLE object. You can also set the control's SourceItem property (for example, to specify a row-and-column range if the object you're creating is a Microsoft Excel worksheet). When you create an OLE object by using this setting, the control displays a metafile graphic image of the file specified by the control's SourceDoc property. If you save the OLE object, only the link information, such as the name of the application that supplied the object and the name of the linked file, is saved because the control contains an image of the data but no source data.
acOLECopy (4) | Copies the object to the Clipboard. When you copy an OLE object to the Clipboard, all the data and link information associated with the object is placed on the Clipboard as well. You can copy both linked and embedded objects onto the Clipboard.
acOLEPaste (5) | Pastes data from the Clipboard to the control. If the paste operation is successful, the control's OLEType property is set to acOLELinked or acOLEEmbedded. If the paste operation isn't successful, the OLEType property is set to acOLENone.
acOLEUpdate (6) | Retrieves the current data from the application that supplied the object and displays that data as a metafile graphic in the control.
acOLEActivate (7) | Opens an OLE object for an operation, such as editing. To use this setting, you must first set the control's Verb property. The Verb property specifies the operation to perform when the OLE object is activated.
acOLEClose (9) | Closes an OLE object and ends the connection with the application that supplied the object. This setting applies to embedded objects only. Using this setting is equivalent to clicking Close on the object's Control menu.
acOLEDelete (10) | Deletes the specified OLE object and frees the associated memory. This setting enables you to explicitly delete an OLE object. Objects are automatically deleted when a form is closed or when the object is updated to a new object. You can't use the Action property to delete a bound OLE object from its underlying table or query.
acOLEInsertObjDlg (14) | Displays the Insert Object dialog box. In Form view or Datasheet view, you display this dialog box to enable the user to create a new object or to link or embed an existing object. You can use the control's OLETypeAllowed property to determine the type of object the user can create (with the constant acOLELinked, acOLEEmbedded, or acOLEEither) by using this dialog box.
acOLEPasteSpecialDlg (15) | Displays the Paste Special dialog box. In Form view or Datasheet view, you display this dialog box to enable the user to paste an object from the Clipboard. The dialog box provides several options, including pasting either a linked or embedded object. You can use the control's OLETypeAllowed property to determine the type of object that can be pasted (with the constant acOLELinked, acOLEEmbedded, or acOLEEither) by using this dialog box.
acOLEFetchVerbs (17) | Updates the list of verbs an OLE object supports. To display the list of verbs, use the ObjectVerbs and ObjectVerbsCount properties.

The Action property isn't available in Design view but can be read or set in other views.

When a control's Enabled property is set to No or its Locked property is set to Yes, you can't use some Action property settings. The following table indicates which settings are allowed or not allowed under these conditions.

Setting | Enabled = No | Locked = Yes
acOLECreateEmbed (0) | Not allowed | Not allowed
acOLECreateLink (1) | Not allowed | Not allowed
acOLECopy (4) | Allowed | Allowed
acOLEPaste (5) | Not allowed | Not allowed
acOLEUpdate (6) | Not allowed | Not allowed
acOLEActivate (7) | Allowed | Allowed
acOLEClose (9) | Not allowed | Allowed
acOLEDelete (10) | Not allowed | Not allowed
acOLEInsertObjDlg (14) | Not allowed | Not allowed
acOLEPasteSpecialDlg (15) | Not allowed | Not allowed
acOLEFetchVerbs (17) | Not allowed | Allowed

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Connection Close Method, Table Type Property Example (VC++)

 Copy code hover
[image]

Connection Close Method, Table Type Property Example (VC++)
Send feedback

Setting the ActiveConnection property to Nothing should "close" the catalog. Associated collections will be empty. Any objects that were created from schema objects in the catalog will be orphaned. Any properties on those objects that have been cached will still be available, but attempting to read properties that require a call to the provider will fail.

Copy code Copy code

// BeginCloseConnectionCpp
#import "c:\Program Files\Common Files\system\ado\msadox.dll" no_namespace
#import "c:\Program Files\Common Files\system\ado\msado15.dll"

#include "iostream.h"
#include "stdio.h"
#include "conio.h"

//Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void CloseConnectionByNothingX(void);
void CloseConnectionX(void);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 CloseConnectionByNothingX();
 CloseConnectionX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// CloseConnectionByNothingX Function //
// //
//////////////////////////////////////////////////////////
void CloseConnectionByNothingX(void)
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.

 _CatalogPtr m_pCatalog = NULL;
 _TablePtr m_pTable = NULL;

 //Define ADODB object pointers
 ADODB::_ConnectionPtr m_pCnn = NULL;

 //Define other variables
 _variant_t vIndex = (short) 0;

 try
 {
 TESTHR(hr = m_pCnn.CreateInstance(__uuidof(ADODB::Connection)));

 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof(Catalog)));

 m_pCnn->Open("Provider='Microsoft.JET.OLEDB.4.0';"
 "Data Source= 'c:\\Program Files\\Microsoft Office\\"
 "Office\\Samples\\Northwind.mdb';","","",NULL);

 m_pCatalog->PutActiveConnection(_variant_t((IDispatch *)m_pCnn));

 m_pTable = m_pCatalog->Tables->GetItem(vIndex);

 // Cache m_pTable.Type info
 cout << m_pTable->Type << endl;

 _variant_t vCnn;
 vCnn.vt = VT_DISPATCH;
 vCnn.pdispVal = NULL;
 m_pCatalog->PutActiveConnection(vCnn);

 // m_pTable is orphaned
 cout << m_pTable->Type << endl;
 // Previous line will succeed if this was cached

 cout << m_pTable->Columns->GetItem(vIndex)->DefinedSize << endl;
 // Previous line will fail if this info has not been cached
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\nError\n\tSource : %s \n\tdescription : %s \n",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }
 catch(...)
 {
 cout << "Error occured in CloseConnectionByNothingX...."<< endl;
 }
}

//////////////////////////////////////////////////////////
// //
// CloseConnectionX Function //
// //
//////////////////////////////////////////////////////////
void CloseConnectionX()
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.

 _CatalogPtr m_pCatalog = NULL;
 _TablePtr m_pTable = NULL;

 //Define ADODB object pointers
 ADODB::_ConnectionPtr m_pCnn = NULL;

 //Define other variables
 _variant_t vIndex = (short) 0;
 try
 {
 TESTHR(hr = m_pCnn.CreateInstance(__uuidof(ADODB::Connection)));
 m_pCnn->Open("Provider='Microsoft.JET.OLEDB.4.0';"
 "Data Source= 'c:\\Program Files\\Microsoft Office\\"
 "Office\\Samples\\Northwind.mdb';","","",NULL);

 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof(Catalog)));
 m_pCatalog->PutActiveConnection(_variant_t((IDispatch *)m_pCnn));

 m_pTable = m_pCatalog->Tables->GetItem(vIndex);

 // Cache m_pTable.Type info
 cout << m_pTable->Type << endl;

 m_pCnn->Close();

 // m_pTable is orphaned
 cout << m_pTable->Type << endl;
 // Previous line will succeed if this was cached

 cout << m_pTable->Columns->GetItem(vIndex)->DefinedSize << endl;
 // Previous line will fail if this info has not been cached
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\nError\n\tSource : %s \n\tdescription : %s \n",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }
 catch(...)
 {
 cout << "Error occured in CloseConnectionX...."<< endl;
 }
}
// EndCloseConnectionCpp


Report.Requery Method (Access)

 Copy code hover
[image]

Report.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying the specified report by requerying the source of data for the control.

Version Information

Version Added: Access 2007

Syntax

expression .Requery

expression A variable that represents a Report object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the report is based.

  • Updates records displayed based on any changes to the Filter property of the report.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the report that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

See also

Concepts

Report Object

Other resources

Report Object Members


Member Object (ADO MD)

 Copy code hover
[image]

Member Object (ADO MD)
Send feedback

Represents a member of a level in a cube, the children of a member of a level, or a member of a position along an axis of a cellset.

Remarks

The properties of a Member differ depending on the context in which it is used. A Member of a Level in a CubeDef has a Children property that returns the Members on the next lower level in the hierarchy from the current Member. For a Member of a Position, the Children collection is always empty. Also, the Type property applies only to Members of a Level.

A Member of Position has two properties — DrilledDown and ParentSameAsPrev — that are useful when displaying the Cellset. An error will occur if these properties are accessed on a Member of a Level.

With the collections and properties of a Member object of a Level, you can do the following:

  • Identify the Member with the Name and UniqueName properties.

  • Return a string to use when displaying the Member with the Caption property.

  • Return a meaningful string that describes a measure or formula Member with the Description property.

  • Determine the nature of the Member with the Type property.

  • Obtain information about the Level of the Member with the LevelDepth and LevelName properties.

  • Obtain related Members in a Hierarchy with the Parent and Children properties.

  • Count the children of a Member with the ChildCount property.

  • Use the standard ADO Properties collection to obtain additional information about the Level object.

With the collections and properties of a Member of a Position along an Axis, you can do the following:

  • Identify the Member with the Name and UniqueName properties.

  • Return a string to use when displaying the Member with the Caption property.

  • Return a meaningful string that describes a measure or formula Member with the Description property.

  • Obtain information about the Level of the Member with the LevelDepth and LevelName properties.

  • Count the children of a Member with the ChildCount property.

  • Use the DrilledDown property to determine whether there is at least one child on the Axis immediately following this Member.

  • Use the ParentSameAsPrev property to determine whether the parent of this Member is the same as the parent of the immediately preceding Member.

  • Use the standard ADO Properties collection to obtain additional information about the Level object.

The Properties collection contains provider-supplied properties. The following table lists properties that might be available. The actual property list may differ depending upon the implementation of the provider. See the documentation for your provider for a more complete list of available properties.

Name | Description
CatalogName | The name of the catalog to which this cube belongs.
ChildrenCardinality | The number of children that the member has.
CubeName | The name of the cube.
Description | A meaningful description of the member.
DimensionUniqueName | The unambiguous name of the dimension.
HierarchyUniqueName | The unambiguous name of the hierarchy.
LevelNumber | The distance between the level and the root of the hierarchy.
LevelUniqueName | The unambiguous name of the level.
MemberCaption | A label or caption associated with the member.
MemberGUID | The GUID of the member.
MemberName | The name of the member.
MemberOrdinal | The ordinal number of the member.
MemberType | The type of the member.
MemberUniqueName | The unambiguous name of the member.
ParentCount | The count of the number of parents that this member has.
ParentLevel | The level number of the member's parent.
ParentUniqueName | The unambiguous name of the member's parent.
SchemaName | The name of the schema to which this cube belongs.


SubForm.CanGrow Property (Access)

 Copy code hover
[image]

SubForm.CanGrow Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the control contains. Read/write Boolean.

Syntax

expression .CanGrow

expression A variable that represents a SubForm object.

Remarks

The CanGrow property uses the following settings.

Setting | Visual Basic | Description
Yes | True (-1) | The section or control grows vertically so that all data it contains can be printed or previewed.
No | False (0) | (Default) The section or control doesn't grow. Data that doesn't fit within the fixed size of the section or control won't be printed or previewed.

This property setting is read-only in a macro or Visual Basic in any view but Design view.

You can use this property to control the appearance of printed forms and reports. When you set the property to Yes, the object automatically adjusts so any amount of data can be printed. When a control grows, the controls below it move down the page.

If you set a control's CanGrow property to Yes, Microsoft Access automatically sets the CanGrow property of the section containing the control to Yes.

Sections grow vertically across their entire width. To grow the data independently, you can place two subform or subreport controls side by side, and set their CanGrow property to Yes.

When you use the CanGrow property, remember that:

  • The property settings don't affect the horizontal spacing between controls; they affect only the vertical space the controls occupy.

  • Overlapping controls can't grow.

Note Note

  • The CanGrow property does not apply to a form or report page header and page footer sections, although it does apply to controls in such sections.

  • This property affects the display of form sections and controls only when the form is printed or previewed, not when the form is displayed in Form view, Datasheet view, or Design view.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


BoundObjectFrame.Name Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a BoundObjectFrame object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


CustomControl.Enabled Property (Access)

 Copy code hover
[image]

CustomControl.Enabled Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.

Syntax

expression .Enabled

expression A variable that represents a CustomControl object.

Remarks

The Enabled property setting is a value that indicates whether the conditional format is enabled or disabled. True enables the conditional format. False disables the conditional format. The default is True.

When the Enabled property is True, the conditional format can be displayed in the Conditional Formatting dialog box.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


AcImeMode Enumeration (Access)

 Copy code hover
[image]

AcImeMode Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the default startup mode for the Japanese Input Method Editor (IME).

Name | Value | Description
acImeModeAlpha | 8 | Activates the IME in half-width Latin mode.
acImeModeAlphaFull | 7 | Activates the IME in full-width Latin mode.
acImeModeDisable | 3 | Disables the IME.
acImeModeHangul | 10 | Activates the IME in half-width Hangul mode.
acImeModeHangulFull | 9 | Activates the IME in full-width Hangul mode.
acImeModeHiragana | 4 | Activates the IME in full-width hiragana mode.
acImeModeKatakana | 5 | Activates the IME in full-width katakana mode.
acImeModeKatakanaHalf | 6 | Activates the IME in half-width katakana mode.
acImeModeNoControl | 0 | Does not change the IME mode.
acImeModeOff | 2 | Disables the IME and activates Latin text entry.
acImeModeOn | 1 | Activates the IME.


Module.ProcCountLines Property (Access)

 Copy code hover
[image]

Module.ProcCountLines Property (Access)
See also Send feedback

Published: July 16, 2012

The ProcCountLines property returns the number of lines in a specified procedure in a standard module or a class module. Read-only Long.

Syntax

expression .ProcCountLines(ProcName, ProcKind)

expression A variable that represents a Module object.

Parameters

Name | Required/Optional | Data Type | Description
ProcName | Required | String | The name of a procedure in the module.
ProcKind | Required | vbext_ProcKind | The type of procedure. See the Remarks section for the possible settings.

Remarks

The ProcKind argument can be one of the following vbext_ProcKind constants:

Constant | Description
vbext_pk_Get | A Property Get procedure.
vbext_pk_Let | A Property Let procedure.
vbext_pk_Proc | A Sub or Function procedure.
vbext_pk_Set | A Property Set procedure.

The procedure begins with any comments and compilation constants that immediately precede the procedure definition, denoted by one of the following:

  • A Sub statement.

  • A Function statement.

  • A Property Get statement.

  • A Property Let statement.

  • A Property Set statement.

The ProcCountLines property returns the number of lines in a procedure, beginning with the line returned by the ProcStartLine property and ending with the line that ends the procedure. The procedure may be ended with End Sub, End Function, or End Property.

Note Note

The ProcCountLines property treats Sub and Function procedures similarly, but distinguishes between each type of Property procedure.

Example

The following example displays a message indicating the number of lines in a given procedure.

VBA Copy code Copy code
Dim strForm As String
Dim strProc As String

strForm = "Products"
strProc = "Form_Activate"

MsgBox "There are " & Forms(strForm).Module.ProcCountLines(strProc, vbext_pk_Proc) & _
 " lines in the " & strProc & " procedure."

See also

Concepts

Module Object

Other resources

Module Object Members


ListBox Members (Access)

 Copy code hover
[image]

ListBox Members (Access)
Send feedback

Published: July 16, 2012

This object corresponds to a list box control. The list box control displays a list of values or alternatives.

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.

Methods

Name | Description
AddItem | Adds a new item to the list of values displayed by the specified list box control.
Move | Moves the specified object to the coordinates specified by the argument values.
RemoveItem | Removes an item from the list of values displayed by the specified list box control.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.
Undo | You can use the Undo method to reset a control or form when its value has been changed.

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
AllowValueListEdits | Gets or sets whether the Edit List Items command is available when the user right-clicks a list box. Read/write Boolean.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.
BoundColumn | When you make a selection from a list box, the BoundColumn property tells Microsoft Access which column's values to use as the value of the control. If the control is bound to a field, the value in the column specified by the BoundColumn property is stored in the field named in the ControlSource property. Read/write Long.
Column | You can use the Column property to refer to a specific column, or column and row combination, in a multiple-column combo box or list box. Read-only Variant.
ColumnCount | You can use the ColumnCount property to specify the number of columns displayed in a list box or in the list box portion of a combo box, or sent to OLE objects in a chart control or unbound object frame . Read/write Integer.
ColumnHeads | You can use the ColumnHeads property to display a single row of column headings for list boxes, combo boxes, and OLE objects that accept column headings. You can also use this property to create a label for each entry in a chart control . What is actually displayed as the first-row column heading depends on the object's RowSourceType property setting. Read/write Boolean.
ColumnHidden | You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.
ColumnOrder | You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.
ColumnWidth | You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.
ColumnWidths | You can use the ColumnWidths property to specify the width of each column in a multiple-column list box. Read/write String.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DefaultValue | Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontName | You can use the FontName property to specify the font for text in the following situations:
FontSize | You can use the FontSize property to specify the point size for text in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
FontWeight | You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
ForeShade | Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
ForeThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.
ForeTint | Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
GridlineColor | Gets or sets the color of the gridline for the specified list box. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified list box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified list box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified list box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified list box. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified list box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified list box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified list box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified list box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HideDuplicates | You can use the HideDuplicates property to hide a control on a report when its value is the same as in the preceding record. Read/write Boolean.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the list box is anchored horizontally within its layout. Read/write.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
IMEHold | Language-specific information You can use the IMEHold/Hold KanjiConversionMode property to show whether the Kanji Conversion Mode is maintained when the control loses the focus. Read/write Boolean.
IMEMode |
IMESentenceMode |
InheritValueList | Gets or sets whether a list box's value list is inherited from its field. Read/write Boolean.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
ItemData | The ItemData property returns the data in the bound column for the specified row in a list box. Read-only Variant.
ItemsSelected | You can use the ItemsSelected property to return a read-only reference to the hidden ItemsSelected collection. This hidden collection can be used to access data in the selected rows of a multiselect list box control.
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified list box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified list box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the list box and its left gridline. Read/write Integer.
ListCount | You can use the ListCount property to determine the number of rows in a list box. Read/write Long.
ListIndex | You can use the ListIndex property to determine which item is selected in a list box. Read/write Long.
ListItemsEditForm | Gets or sets the name of the form that is displayed when the user clicks Edit List Items. Read/write String.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
MultiSelect | You can use the MultiSelect property to specify whether a user can make multiple selections in a list box on a form and how the multiple selections can be made. Read/write Byte.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
NumeralShapes |
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
Recordset | Returns or sets the ADO Recordset or DAO Recordset object representing the record source for the specified object. Read/write Object.
RightPadding | Gets or sets the amount of space (in inches) between the list box and its right gridline. Read/write Integer.
RowSource | You can use the RowSource property (along with the RowSourceType property) to tell Microsoft Access how to provide data tothe specified object. Read/write String.
RowSourceType | You can use the RowSourceType property (along with the RowSource property) to tell Microsoft Access how to provide data tothe specified object. Read/write String.
ScrollBarAlign | You can use the ScrollBarAlign to specify or determine the alignment of a vertical scroll bar. Read/write Byte.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
Selected | You can use the Selected property in Visual Basic to determine if an item in a list box is selected. Read/write Long.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
ShowOnlyRowSourceValues | Gets or sets whether the list box can display values that aren't specified by the RowSource property. Read/write Boolean.
SmartTags | Returns a SmartTags collection that represents the collection of smart tags that have been added to a control. .
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
ThemeFontIndex | Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the list box and its top gridline. Read/write Integer.
ValidationRule | You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.
ValidationText | Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.
Value | Determines or specifies which value or option in the list box is selected. Read/write Variant.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified list box is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


Application.Build Property (Access)

 Copy code hover
[image]

Application.Build Property (Access)
See also Send feedback

Published: July 16, 2012

Returns as a Long representing the build number of the currently installed copy of Microsoft Access. Read-only.

Syntax

expression .Build

expression A variable that represents an Application object.

Example

The following example displays the version and build number of the currently-installed copy of Microsoft Access.

VBA Copy code Copy code
MsgBox "You are currently running Microsoft Access, " _
 & " version " & Application.Version & ", build " _
 & Application.Build & "."

See also

Concepts

Application Object

Other resources

Application Object Members


Recordset2.BOF Property (DAO)

 Copy code hover
[image]

Recordset2.BOF Property (DAO)
Send feedback

Returns a value that indicates whether the current record position is before the first record in a Recordset object. Read-only Boolean.

Syntax

expression .BOF

expression A variable that represents a Recordset2 object.

Remarks

You can use the BOF and EOF properties to determine whether a Recordset object contains records or whether you've gone beyond the limits of a Recordset object when you move from record to record.

The location of the current record pointer determines the BOF and EOF return values.

If either the BOF or EOF property is True, there is no current record.

If you open a Recordset object containing no records, the BOF and EOF properties are set to True, and the Recordset object's RecordCount property setting is 0. When you open a Recordset object that contains at least one record, the first record is the current record and the BOF and EOF properties are False; they remain False until you move beyond the beginning or end of the Recordset object by using the MovePrevious or MoveNext method, respectively. When you move beyond the beginning or end of the recordset, there is no current record or no record exists.

If you delete the last remaining record in the Recordset object, the BOF and EOF properties may remain False until you attempt to reposition the current record.

If you use the MoveLast method on a Recordset object containing records, the last record becomes the current record; if you then use the MoveNext method, the current record becomes invalid and the EOF property is set to True. Conversely, if you use the MoveFirst method on a Recordset object containing records, the first record becomes the current record; if you then use the MovePrevious method, there is no current record and the BOF property is set to True.

Typically, when you work with all the records in a Recordset object, your code will loop through the records by using the MoveNext method until the EOF property is set to True.

If you use the MoveNext method while the EOF property is set to True or the MovePrevious method while the BOF property is set to True, an error occurs.

This table shows which Move methods are allowed with different combinations of the BOF and EOF properties.

 | MoveFirst, MoveLast | MovePrevious, Move < 0 | Move 0 | MoveNext, Move > 0
BOF=True, EOF=False | Allowed | Error | Error | Allowed
BOF=False, EOF=True | Allowed | Allowed | Error | Error
Both True | Error | Error | Error | Error
Both False | Allowed | Allowed | Allowed | Allowed

Allowing a Move method doesn't mean that the method will successfully locate a record. It merely indicates that an attempt to perform the specified Move method is allowed and won't generate an error. The state of the BOF and EOF properties may change as a result of the attempted Move.

An OpenRecordset method internally invokes a MoveFirst method. Therefore, using an OpenRecordset method on an empty set of records sets the BOF and EOF properties to True. (See the following table for the behavior of a failed MoveFirst method.)

All Move methods that successfully locate a record will set both BOF and EOF to False.

In a Microsoft Access workspace, if you add a record to an empty recordset, BOF will become False, but EOF will remain True, indicating that the current position is at the end of recordset.

Any Delete method, even if it removes the only remaining record from a recordset, won't change the setting of the BOF or EOF property.

The following table shows how Move methods that don't locate a record affect the BOF and EOF property settings.

 | BOF | EOF
MoveFirst, MoveLast | True | True
Move 0 | No change | No change
MovePrevious, Move < 0 | True | No change
MoveNext, Move > 0 | No change | True


CurrentProject.RemovePersonalInformation Property (Access)

 Copy code hover
[image]

CurrentProject.RemovePersonalInformation Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Boolean indicating whether personal information about the user is stored in the specified project. True if personal information is removed. Read-write.

Syntax

expression .RemovePersonalInformation

expression A variable that represents a CurrentProject object.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


TextBox.Click Event (Access)

 Copy code hover
[image]

TextBox.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Syntax

expression .Click

expression A variable that represents a TextBox object.

Remarks

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


OptionGroup.ValidationText Property (Access)

 Copy code hover
[image]

OptionGroup.ValidationText Property (Access)
See also Send feedback

Published: July 16, 2012

Use the ValidationText property to specify a message to be displayed to the user when data is entered that violates a ValidationRule setting for a record, field, or control. Read/write String.

Syntax

expression .ValidationText

expression A variable that represents an OptionGroup object.

Remarks

Enter an expression for the ValidationRule property setting and text for the ValidationText property setting. The maximum length for the ValidationRule property setting is 2048 characters. The maximum length for the ValidationText property setting is 255 characters.

For controls, you can set the ValidationRule property to any valid expression. For field and record validation rules, the expression can't contain user-defined functions, domain aggregate or aggregate functions, the Eval function, or CurrentUser method, or references to forms, queries, or tables. In addition, field validation rules can't contain references to other fields. For records, expressions can include references to fields in that table.

For table fields and records, you can also set these properties in Visual Basic by using the DAO ValidationRule property.

Note Note

The ValidationRule and ValidationText properties don't apply to check box, option button, or toggle buttoncontrols when they are in an option group. They apply only to the option group itself.

Microsoft Access automatically validates values based on a field's data type; for example, Microsoft Access doesn't allow text in a numeric field. You can set rules that are more specific by using the ValidationRule property.

If you set the ValidationRule property but not the ValidationText property, Microsoft Access displays a standard error message when the validation rule is violated. If you set the ValidationText property, the text you enter is displayed as the error message.

For example, when a record is added for a new employee, you can enter a ValidationRule property requiring that the value in the employee's StartDate field fall between the company's founding date and the current date. If the date entered isn't in this range, you can display the ValidationText property message: "Start date is incorrect."

If you create a control by dragging a field from the field list, the field's validation rule remains in effect, although it isn't displayed in the control's ValidationRule property box in the property sheet. This is because a field's validation rule is inherited by a control bound to that field.

Control, field, and record validation rules are applied as follows:

  • Validation rules you set for fields and controls are applied when you edit the data and the focus leaves the field or control.

  • Validation rules for records are applied when you move to another record.

  • If you create validation rules for both a field and a control bound to the field, both validation rules are applied when you edit data and the focus leaves the control.

The following table contains expression examples for the ValidationRule and ValidationText properties.

ValidationRule property | ValidationText property
<> 0 | Entry must be a nonzero value.
> 1000 Or Is Null | Entry must be blank or greater than 1000.
Like "A????" | Entry must be 5 characters and begin with the letter "A".
>= #1/1/96# And <#1/1/97# | Entry must be a date in 1996.
DLookup("CustomerID", "Customers", "CustomerID = Forms!Customers!CustomerID") Is Null | Entry must be a unique CustomerID (domain aggregate functions are allowed only for form-level validation).

If you create a validation rule for a field, Microsoft Access doesn't normally allow a Null value to be stored in the field. If you want to allow a Null value, add "Is Null" to the validation rule, as in "<> 8 Or Is Null" and make sure the Required property is set to No.

You can't set field or record validation rules for tables created outside Microsoft Access (for example, dBASE, Paradox, or SQL Server). For these kinds of tables, you can create validation rules for controls only.

Example

The following example creates a validation rule for a field that allows only values over 65 to be entered. If a number less than 65 is entered, a message is displayed. The properties are set by using the SetFieldValidation function.

VBA Copy code Copy code
Dim strTblName As String, strFldName As String
Dim strValidRule As String
Dim strValidText As String, intX As Integer

strTblName = "Customers"
strFldName = "Age"
strValidRule = ">= 65"
strValidText = "Enter a number greater than or equal to 65."
intX = SetFieldValidation(strTblName, strFldName, _
 strValidRule, strValidText)

Function SetFieldValidation(strTblName As String, _
 strFldName As String, strValidRule As String, _
 strValidText As String) As Integer

 Dim dbs As Database, tdf As TableDef, fld As Field

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 Set fld = tdf.Fields(strFldName)
 fld.ValidationRule = strValidRule
 fld.ValidationText = strValidText
End Function

The next example uses the SetTableValidation function to set record-level validation to ensure that the value in the EndDate field comes after the value in the StartDate field.

VBA Copy code Copy code
Dim strTblName As String, strValidRule As String
Dim strValidText As String
Dim intX As Integer

strTblName = "Employees"
strValidRule = "EndDate > StartDate"
strValidText = "Enter an EndDate that is later than the StartDate."
intX = SetTableValidation(strTblName, strValidRule, strValidText)

Function SetTableValidation(strTblName As String, _
 strValidRule As String, strValidText As String) _
 As Integer

 Dim dbs As Database, tdf As TableDef

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 tdf.ValidationRule = strValidRule
 tdf.ValidationText = strValidText
End Function

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


How to: Call Procedures in a Subform or Subreport

 Copy code hover
[image]

How to: Call Procedures in a Subform or Subreport
Send feedback

You can call a procedure in a module associated with a subform or subreport in one of two ways. If the form containing the subform is open in Form view, you can refer to the procedure as a method on the subform. The following example shows how to call the procedure GetProductID in the Orders subform, which is bound to a subform control on the Orders form:

In the Orders Subform class module, enter this code:

Copy code Copy code
Public Function GetProductID() As Variant
 ' Return current productID.
 GetProductID = ProductID
End Function

The following code illustrates how to call the GetProductID procedure.

Copy code Copy code
Forms!Orders![Orders Subform].Form.GetProductID


Report.Open Event (Access)

 Copy code hover
[image]

Report.Open Event (Access)
See also Send feedback

Published: July 16, 2012

The Open occurs before a report is previewed or printed.

Syntax

expression .Open(Cancel, )

expression A variable that represents a Report object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer

Return Value

nothing

Remarks

For example, an Open macro or event procedure can open a custom dialog box in which the user enters the criteria to filter the set of records to display on a form or the date range to include for a report.

When you open a report based on an underlying query, Microsoft Access runs the Open macro or event procedure before it runs the underlying query for the report. This enables the user to specify criteria for the report before it opens — for example, in a custom dialog box you display when the Open event occurs.

If your application can have more than one form loaded at a time, use the Activate and Deactivate events instead of the Open event to display and hide custom toolbars when the focus moves to a different form.

When the Close event occurs, you can open another window or request the user's name to make a log entry indicating who used the form or report.

If you're trying to decide whether to use the Open or Load event for your macro or event procedure, one significant difference is that the Open event can be canceled, but the Load event can't. For example, if you're dynamically building a record source for a form in an event procedure for the form's Open event, you can cancel opening the form if there are no records to display. Similarly, the Unload event can be canceled, but the Close event can't.

Example

The following example shows how to use a Structured Query Language (SQL) statement to establish the data source of a report as it is opened.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Private Sub Report_Open(Cancel As Integer)

    On Error GoTo Error_Handler

    Me.Caption = "My Application"

    DoCmd.OpenForm FormName:="frmReportSelector_MemberList", _
    Windowmode:=acDialog

    'Cancel the report if "cancel" was selected on the dialog form.

    If Forms!frmReportSelector_MemberList!txtContinue = "no" Then
        Cancel = True
        GoTo Exit_Procedure
    End If
    Me.RecordSource = ReplaceWhereClause(Me.RecordSource, _
      Forms!frmReportSelector_MemberList!txtWhereClause)

Exit_Procedure:
    Exit Sub

Error_Handler:
    MsgBox Err.Number & ": " & Err.Description
    Resume Exit_Procedure
    Resume

End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.

See also

Concepts

Report Object

Other resources

Report Object Members


Recordset.FillCache Method (DAO)

 Copy code hover
[image]

Recordset.FillCache Method (DAO)
Send feedback

Fills all or a part of a local cache for a Recordset object that contains data from a Microsoft Access database engine-connected ODBC data source (Microsoft Access database engine-connected ODBC databases only).

Syntax

expression .FillCache(Rows, StartBookmark)

expression A variable that represents a Recordset object.

Parameters

Name | Required/Optional | Data Type | Description
Rows | Optional | Variant | A Variant (Integer subtype) that specifies the number of rows to store in the cache. If you omit this argument, the value is determined by the CacheSize property setting.
StartBookmark | Optional | Variant | A Variant (String subtype) that specifies a bookmark. The cache is filled starting from the record indicated by this bookmark. If you omit this argument, the cache is filled starting from the record indicated by the CacheStart property.

Remarks

Caching improves the performance of an application that retrieves data from a remote server. A cache is space in local memory that holds the data most recently retrieved from the server; this assumes that the data will probably be requested again while the application is running. When a user requests data, the Microsoft Access database engine checks the cache for the data first rather than retrieving it from the server, which takes more time. The cache doesn't save data that doesn't come from an ODBC data source.

Rather than waiting for the cache to be filled with records as they are retrieved, you can use the FillCache method to explicitly fill the cache at any time. This is a faster way to fill the cache because FillCache retrieves several records at once instead of one at a time. For example, while you view each screenful of records, your application uses FillCache to retrieve the next screenful of records for viewing.

Any Microsoft Access database engine-connected ODBC data source that you access with Recordset objects can have a local cache. To create the cache, open a Recordset object from the remote data source, and then set the CacheSize and CacheStart properties of the Recordset.

If rows and startbookmark create a range of records that is partially or entirely outside the range of records specified by the CacheSize and CacheStart properties, the portion of the recordset outside this range is ignored and will not be loaded into the cache.

If FillCache requests more records than the number remaining in the remote data source, the Microsoft Access database engine retrieves only the remaining records, and no error occurs.

Note Note

  • Records retrieved from the cache don't reflect concurrent changes that other users made to the source data.

  • FillCache only retrieves records not already cached. To force an update of all the cached data, set the CacheSize property of the Recordset to 0, reset it to the size of the cache you originally requested, and then use FillCache.

Example

This example uses the CreateTableDef and FillCache methods and the CacheSize, CacheStart and SourceTableName properties to enumerate the records in a linked table twice. Then it enumerates the records twice with a 50-record cache. The example then displays the performance statistics for the uncached and cached runs through the linked table.

VBA Copy code Copy code
Sub ClientServerX3()

   Dim dbsCurrent As Database
   Dim tdfRoyalties As TableDef
   Dim rstRemote As Recordset
   Dim sngStart As Single
   Dim sngEnd As Single
   Dim sngNoCache As Single
   Dim sngCache As Single
   Dim intLoop As Integer
   Dim strTemp As String
   Dim intRecords As Integer

   ' Open a database to which a linked table can be
   ' appended.
   Set dbsCurrent = OpenDatabase("DB1.mdb")

   ' Create a linked table that connects to a Microsoft SQL
   ' Server database.
   Set tdfRoyalties = _
      dbsCurrent.CreateTableDef("Royalties")
   ' Note: The DSN referenced below must be set to
   '       use Microsoft Windows NT Authentication Mode to
   '       authorize user access to the Microsoft SQL Server.
   tdfRoyalties.Connect = _
      "ODBC;DATABASE=pubs;DSN=Publishers"
   tdfRoyalties.SourceTableName = "roysched"
   dbsCurrent.TableDefs.Append tdfRoyalties
   Set rstRemote = _
      dbsCurrent.OpenRecordset("Royalties")

   With rstRemote
      ' Enumerate the Recordset object twice and record
      ' the elapsed time.
      sngStart = Timer

      For intLoop = 1 To 2
         .MoveFirst
         Do While Not .EOF
            ' Execute a simple operation for the
            ' performance test.
            strTemp = !title_id
            .MoveNext
         Loop
      Next intLoop

      sngEnd = Timer
      sngNoCache = sngEnd - sngStart

      ' Cache the first 50 records.
      .MoveFirst
      .CacheSize = 50
      .FillCache
      sngStart = Timer

      ' Enumerate the Recordset object twice and record
      ' the elapsed time.
      For intLoop = 1 To 2
         intRecords = 0
         .MoveFirst
         Do While Not .EOF
            ' Execute a simple operation for the
            ' performance test.
            strTemp = !title_id
            ' Count the records. If the end of the
            ' cache is reached, reset the cache to the
            ' next 50 records.
            intRecords = intRecords + 1
            .MoveNext
            If intRecords Mod 50 = 0 Then
               .CacheStart = .Bookmark
               .FillCache
            End If
         Loop
      Next intLoop

      sngEnd = Timer
      sngCache = sngEnd - sngStart

      ' Display performance results.
      MsgBox "Caching Performance Results:" & vbCr & _
         "  No cache: " & Format(sngNoCache, _
         "##0.000") & " seconds" & vbCr & _
         "  50-record cache: " & Format(sngCache, _
         "##0.000") & " seconds"
      .Close
   End With

   ' Delete linked table because this is a demonstration.
   dbsCurrent.TableDefs.Delete tdfRoyalties.Name
   dbsCurrent.Close

End Sub


QueryDefs Members (DAO)

 Copy code hover
[image]

QueryDefs Members (DAO)
Send feedback

A QueryDefs collection contains all QueryDef objects of a Database object in a Microsoft Access database engine database.

Methods

Name | Description
Append | Adds a new QueryDef to the QueryDefs collection.
Delete | Not supported for this collection.
Refresh | Not supported for this object.

Properties

Name | Description
Count | Returns the number of objects in the specified collection. Read-only.


WebService Object (Access)

 Copy code hover
[image]

WebService Object (Access)
See also Send feedback

Published: July 16, 2012

Represents a Data Service data connection.

Version Information

Version Added: Access 2010

Remarks

Use the Item property of the WebServices collection to return a WebService object.

A Data Service data connection may contain one or more entities. Each entity specifies an external content type. Used throughout the functionality and services offered by Business Connectivity Services, external content types are reusable metadata descriptions of connectivity information and data definitions plus the behaviors you want to apply to a certain category of external data. Use the Entities property to return the entities defined for a Data Service data connection.

See also

Concepts

Access Object Model Reference

Other resources

WebService Object Members


Line.EventProcPrefix Property (Access)

 Copy code hover
[image]

Line.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Syntax

expression .EventProcPrefix

expression A variable that represents a Line object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

Line Object

Other resources

Line Object Members


CursorDriverEnum Enumeration (DAO)

 Copy code hover
[image]

CursorDriverEnum Enumeration (DAO)
Send feedback

Specifies the type of cursor driver.

Name | Value | Description
dbUseClientBatchCursor | 3 | Always uses the FoxPro Cursor Library. This option is required for performing batch updates.
dbUseDefaultCursor | -1 | (Default) Uses server-side cursors if the server supports them; otherwise uses the ODBC Cursor Library.
dbUseNoCursor | 4 | Opens all cursors (that is, Recordset objects) as forward-only type, read-only, with a rowset size of 1. Also known as "cursorless queries."
dbUseODBCCursor | 1 | Always uses the ODBC Cursor Library. This option provides better performance for small result sets, but degrades quickly for larger result sets.
dbUseServerCursor | 2 | Always uses server-side cursors. For most large operations this option provides better performance, but might cause more network traffic.


SmartTagProperties Properties (Access)

 Copy code hover
[image]

SmartTagProperties Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only SmartTagProperty.
Parent | Returns the parent object for the specified object. Read-only.


AdditionalData Methods (Access)

 Copy code hover
[image]

AdditionalData Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Add | Adds an add table or query that will be included when the ExportXML method is called.


Indexed Property

 Copy code hover
[image]

Indexed Property
Send feedback

Published: July 16, 2012

You can use the Indexed property to set a single-field index. An index speeds up queries on the indexed fields as well as sorting and grouping operations. For example, if you search for specific employee names in a LastName field, you can create an index for this field to speed up the search for a specific name.

Setting

The Indexed property uses the following settings.

Setting | Description
No | (Default) No index.
Yes (Duplicates OK) | The index allows duplicates.
Yes (No Duplicates) | The index doesn't allow duplicates.

You can set this property only in the Field Properties section in table Design view. You can set a single-field index by setting the Indexed property in the Field Properties section in table Design view. You can set multiple-field indexes in the Indexes window. To open the Indexes window, on the Design tab, in the Show/Hide group, click Indexes.

If you add a single-field index in the Indexes window, Microsoft Access will set the Indexed property for the field to Yes.

In Visual Basic , use the ADO Append method of the Indexes collection to create an index for a field.

Remarks

Use the Indexed property to find and sort records by using a single field in a table. The field can hold either unique or non-unique values. For example, you can create an index on an EmployeeID field in an Employees table in which each employee ID is unique or you can create an index on a Name field in which some names may be duplicates.

Note Note

You can't index Memo, Hyperlink, or OLE Object data type fields.

You can create as many indexes as you need. The indexes are created when you save the table and are automatically updated when you change or add records. You can add or delete indexes at any time in table Design view.

Tip Tip

You can specify text that is commonly used at the beginning or the end of a field name (such as "ID", "code", or "num") for the AutoIndex On Import/Create option on the Tables/Queries tab, available by clicking Options on the Tools menu. When you import data files that contain this text in their field names, Microsoft Access creates an index for these fields.

If the primary key for a table is a single field, Microsoft Access will automatically set the Indexed property for that field to Yes (No Duplicates).

If you want to create multiple-field indexes, use the Indexes window.


SubForm.VerticalAnchor Property (Access)

 Copy code hover
[image]

SubForm.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified subform is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .VerticalAnchor

expression A variable that represents a SubForm object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Avg Function (Access 2013 custom web app)

 Copy code hover
[image]

Avg Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Calculates the arithmetic mean of a set of values contained in a specified field.

Syntax

Avg(NumericExpression)

The Avg function contains the following argument.

Argument | Description
NumericExpression | A string expression identifying the field that contains the numeric data you want to average or an expression that performs a calculation using the data in that field. Operands in NumericExpression can include the name of a table field, a variable, or a function (which can be either intrinsic or user-defined but not one of the other SQL aggregate functions).

Remarks

The average calculated by Avg is the arithmetic mean (the sum of the values divided by the number of values). You could use Avg, for example, to calculate average freight cost.

The Avg function does not include any Null values in the calculation.


SetEOS Method (ADO)

 Copy code hover
[image]

SetEOS Method (ADO)
Send feedback

Sets the position that is the end of the stream.

Syntax

Stream.SetEOS

Remarks

SetEOS updates the value of the EOS property, by making the current Position the end of the stream. Any bytes or characters following the current position are truncated.

Since Write, WriteText, and CopyTo do not truncate any extra values in existing Stream objects, you can truncate these bytes or characters by setting the new end-of-stream position with SetEOS.

Caution note Caution

If you set EOS to a position before the actual end of the stream, you will lose all data after the new EOS position.


ObjectFrame.RowSourceType Property (Access)

 Copy code hover
[image]

ObjectFrame.RowSourceType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the RowSourceType property (along with the RowSource property) to tell Microsoft Access how to provide data tothe specified object. Read/write String.

Syntax

expression .RowSourceType

expression A variable that represents an ObjectFrame object.

Remarks

The RowSourceType property uses the following settings.

Setting | Description
Table/Query | (Default) The data is from a table, query, or SQL statement specified by the RowSource setting.
Value List | The data is a list of items specified by the RowSource setting.
Field List | The data is a list of field names from a table, query, or SQL statement specified by the RowSource setting.
Note Note

You can also set the RowSourceType property with a user-defined function. The function name is entered without a preceding equal sign (=) and without the trailing pair of parentheses. You must provide specific function code arguments to tell Microsoft Access how to fill the control.

In Visual Basic, set the RowSourceType property by using a string expression with one of these values: "Table/Query", "Value List", or "Field List". You also use a string expression to set the value of the RowSource property. To set the RowSourceType property to a user-defined function, enter the name of the function.

When you have a limited number of values that don't change, you can set the RowSourceType property to Value List and then enter the values that make up the list in the RowSource property.

When you create a user-defined function to insert items into a list box or combo box, Microsoft Access calls the function repeatedly to get the information it needs. User-defined RowSourceType functions must be written in a very specific function format .

Example

The following example sets the RowSourceType property for a combo box to Table/Query, and it sets the RowSource property to a query named EmployeeList.

VBA Copy code Copy code
Forms!Employees!cmboNames.RowSourceType = "Table/Query"
Forms!Employees!cmboNames.RowSource = "EmployeeList"

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


ToggleButton.BorderShade Property (Access)

 Copy code hover
[image]

ToggleButton.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents a ToggleButton object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BorderColor by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Minimizing Log File Space Usage

 Copy code hover
[image]

Minimizing Log File Space Usage
Send feedback

A log file may fill quickly (thus halting the server) if there is a large volume of activity on an SQL Server database. You can set the log file to Truncate on Checkpoint to significantly extend the life of the log file for a database.

To enable Truncate on Checkpoint in Microsoft SQL Server 6.5

  1. Start Microsoft SQL Server Enterprise Manager, open the tree for the Server, and then open the Database Devices tree.

  2. Double-click the name of the database on which this feature will be enabled.

  3. From the Database tab, select Truncate.

  4. From the Options tab, select Truncate Log on Checkpoint, and then click OK.

To enable Truncate on Checkpoint in Microsoft SQL Server 7.0

  1. Start Microsoft SQL Server Enterprise Manager, open the tree for the Server, and then open the Databases tree.

  2. Right-click the name of the database on which this feature will be enabled and choose Properties.

  3. From the Options tab, select Truncate Log on Checkpoint, and then click OK.

For more information about the Truncate on Checkpoint feature, see the Microsoft SQL Server documentation.


ToggleButton.BackShade Property (Access)

 Copy code hover
[image]

ToggleButton.BackShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackShade

expression A variable that represents a ToggleButton object.

Remarks

The BackShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the BackShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens BackColor by 75%.

VBA Copy code Copy code
Me.ctl.BackShade=25

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Disconnecting and Reconnecting the Recordset
Send feedback

Disconnecting and Reconnecting the Recordset

One of the most powerful features found in ADO is the capability to open a client-side Recordset from a data source and then disconnect the Recordset from the data source. Once the Recordset has been disconnected, the connection to the data source can be closed, thereby releasing the resources on the server used to maintain it. You can continue to view and edit the data in the Recordset while it is disconnected and later reconnect to the data source and send your updates in batch mode.

To disconnect a Recordset, open it with a cursor location of adUseClient, and then set the ActiveConnection property equal to Nothing. (C++ users should set the ActiveConnection equal to NULL to disconnect.)

We will use a disconnected Recordset later in this chapter when we discuss Recordset persistence to address a scenario in which we need to have the data in a Recordset available to an application while the client computer is not connected to a network.


ADO MD Code Examples in Visual Basic, Scripting Edition

 Copy code hover
[image]

ADO MD Code Examples in Visual Basic, Scripting Edition
Send feedback

The following examples require Microsoft Active Server Pages (ASP) for Microsoft Internet Information Server 4.0.

Note Note

Paste the entire code example, from beginning to end, into your code editor. The example may not run correctly if partial examples are used or if paragraph formatting is lost.

  • Axis Example

  • Members Example

  • CubeDef Example


AllModules.Count Property (Access)

 Copy code hover
[image]

AllModules.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents an AllModules object.

See also

Concepts

AllModules Collection

Other resources

AllModules Object Members


AllFunctions.Item Property (Access)

 Copy code hover
[image]

AllFunctions.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.

Syntax

expression .Item(var)

expression A variable that represents an AllFunctions object.

Parameters

Name | Required/Optional | Data Type | Description
var | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

AllFunctions Collection

Other resources

AllFunctions Object Members


Form.GridY Property (Access)

 Copy code hover
[image]

Form.GridY Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the GridY property (along with the GridX property) to specify the horizontal and vertical divisions of the alignment grid in form Design view. Read/write Integer.

Syntax

expression .GridY

expression A variable that represents a Form object.

Remarks

Enter an integer between 1 and 64 representing the number of subdivisions per unit of measurement. If the Measurement system box is set to U.S. on the Numbers tab of the Regional Options dialog box of Windows Control Panel, the default setting is 24 for the GridX property (horizontal) and 24 for the GridY property (vertical).

In Visual Basic, you set this property by using a numeric expression.

The GridX and GridY properties provide control over the placement and alignment of objects on a form or report. You can adjust the grid for greater or lesser precision. To see the grid, click Grid on the View menu. If the setting for either the GridX or GridY properties is greater than 24, the grid points disappear from view (although the grid lines are still displayed).

See also

Concepts

Form Object

Other resources

Form Object Members


Recordsets Methods (DAO)

 Copy code hover
[image]

Recordsets Methods (DAO)
Send feedback

In this section

  • Recordsets.Refresh Method (DAO)


Keys Append Method, Key Type, RelatedColumn, RelatedTable and UpdateRule Properties Example (VC++)

 Copy code hover
[image]

Keys Append Method, Key Type, RelatedColumn, RelatedTable and UpdateRule Properties Example (VC++)
Send feedback

The following code demonstrates how to create a new foreign key. It assumes two tables (Customers and Orders) exist.

Copy code Copy code

// BeginCreateKeyCpp
#import "c:\Program Files\Common Files\system\ado\msadox.dll" no_namespace
#import "c:\Program Files\Common Files\system\ado\msado15.dll"

#include "iostream.h"
#include "stdio.h"
#include "conio.h"

//Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void CreateKeyX(void);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 CreateKeyX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// CreateKeyX Function //
// //
//////////////////////////////////////////////////////////
void CreateKeyX(void)
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.
 _KeyPtr m_pKeyForeign = NULL;
 _CatalogPtr m_pCatalog = NULL;

 //Define other variables
 _bstr_t strcnn("Provider='Microsoft.JET.OLEDB.4.0';"
 "Data source = 'c:\\Program Files\\Microsoft Office\\"
 "Office\\Samples\\Northwind.mdb';");
 try
 {
 TESTHR(hr = m_pKeyForeign.CreateInstance(__uuidof(Key)));
 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof (Catalog)));
 m_pCatalog->PutActiveConnection(strcnn);

 // Define the foreign key.
 m_pKeyForeign->Name = "CustOrder";
 m_pKeyForeign->Type = adKeyForeign;
 m_pKeyForeign->RelatedTable = "Customers";
 m_pKeyForeign->Columns->Append("CustomerId",adVarWChar,0);
 m_pKeyForeign->Columns->GetItem("CustomerId")->RelatedColumn =
 "CustomerId";
 m_pKeyForeign->UpdateRule = adRICascade;

 // To pass as column parameter to Key's Apppend method
 _variant_t vOptional;
 vOptional.vt = VT_ERROR;
 vOptional.scode = DISP_E_PARAMNOTFOUND;

 // Append the foreign key.
 m_pCatalog->Tables->GetItem("Orders")->Keys->
 Append(_variant_t((IDispatch *)m_pKeyForeign),
 adKeyPrimary,vOptional,L"",L"");
 printf("Foreign key 'CustOrder' is added.\n");

 // Delete the key as this is a demonstration.
 m_pCatalog->Tables->GetItem("Orders")->Keys->
 Delete(m_pKeyForeign->Name);
 printf("Foreign key 'CustOrder' is deleted.\n");
 }

 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }

 catch(...)
 {
 cout << "Error occured in include files...."<< endl;
 }
}
// EndCreateKeyCpp


Line.BorderColor Property (Access)

 Copy code hover
[image]

Line.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Syntax

expression .BorderColor

expression A variable that represents a Line object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

Line Object

Other resources

Line Object Members


Control Properties (Access)

 Copy code hover
[image]

Control Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BottomPadding | Gets or sets the amount of space (in inches) between the control and its bottom gridline. Read/write Integer.
Column | You can use the Column property to refer to a specific column, or column and row combination, in a multiple-column combo box or list box. Read-only Variant.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
Form | You can use the Form property to refer to a form or to refer to the form associated with a subformcontrol. Read-only Form.
GridlineColor | Gets or sets the color of the gridline for the specified control. Read/write Long.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified control. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified control. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified control. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified control. Read/write Byte.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified control. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified control. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified control. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified control. Read/write Byte.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the control is anchored horizontally within its layout. Read/write.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
ItemData | The ItemData property returns the data in the bound column for the specified row in a combo box or list box. Read-only Variant.
ItemsSelected | You can use the ItemsSelected property to return a read-only reference to the hidden ItemsSelected collection. This hidden collection can be used to access data in the selected rows of a multiselect list box control.
Layout | Returns the type of layout for the specified control. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified control. Read-only Long.
LeftPadding | Gets or sets the amount of space (in inches) between the control and its left gridline. Read/write Integer.
Name | You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.
Object | You can use the Object property in Visual Basic to return a reference to the ActiveX object that is associated with a linked or embedded OLE object in a control. By using this reference, you can access the properties or invoke the methods of the OLE object. Read-only Object.
ObjectVerbs | You can use the ObjectVerbs property in Visual Basic to determine the list of verbs an OLE object supports. Read-only String.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
Pages | Returns a Pages collection that represents the pages in the specified control that supports tabbed pages (for example, a TabControl object). Read-only.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
Report | You can use the Report property to refer to a report or to refer to the report associated with a subreport control. Read-only Report.
RightPadding | Gets or sets the amount of space (in inches) between the control and its right gridline. Read/write Integer.
Selected | You can use the Selected property in Visual Basic to determine if an item is selected. Read/write Long.
SmartTags | Returns a SmartTags collection that represents the collection of smart tags that have been added to a control. .
TopPadding | Gets or sets the amount of space (in inches) between the control and its top gridline. Read/write Integer.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified control is anchored vertically within its layout. Read/write.


Recordset.Type Property (DAO)

 Copy code hover
[image]

Recordset.Type Property (DAO)
Send feedback

Sets or returns a value that indicates the operational type or data type of an object. Read-only Integer.

Syntax

expression .Type

expression A variable that represents a Recordset object.

Remarks

For a Recordset object, the possible settings and return values are as follows.

Constant

Recordset type

dbOpenTable

Table (Microsoft Access workspaces only)

dbOpenDynamic

Dynamic (ODBCDirect workspaces only)

Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

dbOpenDynaset

Dynaset

dbOpenSnapshot

Snapshot

dbOpenForwardOnly

Forward-only


Collections (ADO/WFC Syntax)

 Copy code hover
[image]

Collections (ADO/WFC Syntax)
Send feedback

package com.ms.wfc.data

Parameters

Methods

Copy code Copy code

public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthappend_HV10294078.xml(com.ms.wfc.data.Parameter param)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcoldelete_HV10294294.xml(int n)
public void delete(String s)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthadorefresh_HV10294718.xml()
public Parameter Invalid DDUE based on source, error:link not allowed in code, link filename:mdproitem_HV10294463.xml(int n)
public Parameter getItem(String s)

Properties

Copy code Copy code

public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocount_HV10294234.xml()

Fields

Methods

Copy code Copy code

public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthappend_HV10294078.xml(String name, int type)
public void append(String name, int type, int definedSize)
public void append(String name, int type, int definedSize, int attrib)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcoldeletefield_HV10294293.xml(int n)
public void delete(String s)
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthadorefresh_HV10294718.xml()
public com.ms.wfc.data.Field Invalid DDUE based on source, error:link not allowed in code, link filename:mdproitem_HV10294463.xml(int n)
public com.ms.wfc.data.Field getItem(String s)

Properties

Copy code Copy code

public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocount_HV10294234.xml()

Errors

Methods

Copy code Copy code

public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthclear_HV10294165.xml()
public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthadorefresh_HV10294718.xml()
public com.ms.wfc.data.Error Invalid DDUE based on source, error:link not allowed in code, link filename:mdproitem_HV10294463.xml(int n)
public com.ms.wfc.data.Error getItem(String s)

Properties

Copy code Copy code

public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocount_HV10294234.xml()


ObjectFrame.Name Property (Access)

 Copy code hover
[image]

ObjectFrame.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents an ObjectFrame object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Unrecognized database format

 Copy code hover
[image]

Unrecognized database format <filename>. (Error 3343)
Send feedback

Possible causes:

  • The specified file name is not a Microsoft Access database engine database.

  • The specified file name is a device name, for example, a printer or a console.

  • The database file has invalid header information or an unknown sort order.

  • A commit is pending from another user but the lock file cannot be found.

  • During a commit, you are attempting to write a Long value larger than the 2K maximum page size.

  • The database is damaged. Compact the database and then try opening it again.


Database.CreateTableDef Method (DAO)

 Copy code hover
[image]

Database.CreateTableDef Method (DAO)
Send feedback

Creates a new TableDef object (Microsoft Access workspaces only). .

Syntax

expression .CreateTableDef(Name, Attributes, SourceTableName, Connect)

expression A variable that represents a Database object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Optional | Variant | A Variant (String subtype) that uniquely names the new TableDef object. See the Name property for details on valid TableDef names.
Attributes | Optional | Variant | A constant or combination of constants that indicates one or more characteristics of the new TableDef object. See the Attributes property for more information.
SourceTableName | Optional | Variant | A Variant (String subtype) containing the name of a table in an external database that is the original source of the data. The source string becomes the SourceTableName property setting of the new TableDef object.
Connect | Optional | Variant | A Variant (String subtype) containing information about the source of an open database, a database used in a pass-through query, or a linked table. See the Connect property for more information about valid connection strings.

Return Value

TableDef

Remarks

If you omit one or more of the optional parts when you use the CreateTableDef method, you can use an appropriate assignment statement to set or reset the corresponding property before you append the new object to a collection. After you append the object, you can alter some but not all of its properties. See the individual property topics for more details.

If name refers to an object that is already a member of the collection, or you specify an invalid property in the TableDef or Field object you're appending, a run-time error occurs when you use the Append method. Also, you can't append a TableDef object to the TableDefs collection until you define at least one Field for the TableDef object.

To remove a TableDef object from the TableDefs collection, use the Delete method on the collection.

Example

This example creates a new TableDef object in the Northwind database.

VBA Copy code Copy code
Sub CreateTableDefX()

 Dim dbsNorthwind As Database
 Dim tdfNew As TableDef
 Dim prpLoop As Property

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 ' Create a new TableDef object.
 Set tdfNew = dbsNorthwind.CreateTableDef("Contacts")

 With tdfNew
 ' Create fields and append them to the new TableDef
 ' object. This must be done before appending the
 ' TableDef object to the TableDefs collection of the
 ' Northwind database.
 .Fields.Append .CreateField("FirstName", dbText)
 .Fields.Append .CreateField("LastName", dbText)
 .Fields.Append .CreateField("Phone", dbText)
 .Fields.Append .CreateField("Notes", dbMemo)

 Debug.Print "Properties of new TableDef object " & _
 "before appending to collection:"

 ' Enumerate Properties collection of new TableDef
 ' object.
 For Each prpLoop In .Properties
 On Error Resume Next
 If prpLoop <> "" Then Debug.Print " " & _
 prpLoop.Name & " = " & prpLoop
 On Error GoTo 0
 Next prpLoop

 ' Append the new TableDef object to the Northwind
 ' database.
 dbsNorthwind.TableDefs.Append tdfNew

 Debug.Print "Properties of new TableDef object " & _
 "after appending to collection:"

 ' Enumerate Properties collection of new TableDef
 ' object.
 For Each prpLoop In .Properties
 On Error Resume Next
 If prpLoop <> "" Then Debug.Print " " & _
 prpLoop.Name & " = " & prpLoop
 On Error GoTo 0
 Next prpLoop

 End With

 ' Delete new TableDef object since this is a
 ' demonstration.
 dbsNorthwind.TableDefs.Delete "Contacts"

 dbsNorthwind.Close

End Sub

This example uses the CreateTableDef and FillCache methods and the CacheSize, CacheStart and SourceTableName properties to enumerate the records in a linked table twice. Then it enumerates the records twice with a 50-record cache. The example then displays the performance statistics for the uncached and cached runs through the linked table.

VBA Copy code Copy code
Sub ClientServerX3()

 Dim dbsCurrent As Database
 Dim tdfRoyalties As TableDef
 Dim rstRemote As Recordset
 Dim sngStart As Single
 Dim sngEnd As Single
 Dim sngNoCache As Single
 Dim sngCache As Single
 Dim intLoop As Integer
 Dim strTemp As String
 Dim intRecords As Integer

 ' Open a database to which a linked table can be
 ' appended.
 Set dbsCurrent = OpenDatabase("DB1.mdb")

 ' Create a linked table that connects to a Microsoft SQL
 ' Server database.
 Set tdfRoyalties = _
 dbsCurrent.CreateTableDef("Royalties")
 ' Note: The DSN referenced below must be set to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 tdfRoyalties.Connect = _
 "ODBC;DATABASE=pubs;DSN=Publishers"
 tdfRoyalties.SourceTableName = "roysched"
 dbsCurrent.TableDefs.Append tdfRoyalties
 Set rstRemote = _
 dbsCurrent.OpenRecordset("Royalties")

 With rstRemote
 ' Enumerate the Recordset object twice and record
 ' the elapsed time.
 sngStart = Timer

 For intLoop = 1 To 2
 .MoveFirst
 Do While Not .EOF
 ' Execute a simple operation for the
 ' performance test.
 strTemp = !title_id
 .MoveNext
 Loop
 Next intLoop

 sngEnd = Timer
 sngNoCache = sngEnd - sngStart

 ' Cache the first 50 records.
 .MoveFirst
 .CacheSize = 50
 .FillCache
 sngStart = Timer

 ' Enumerate the Recordset object twice and record
 ' the elapsed time.
 For intLoop = 1 To 2
 intRecords = 0
 .MoveFirst
 Do While Not .EOF
 ' Execute a simple operation for the
 ' performance test.
 strTemp = !title_id
 ' Count the records. If the end of the
 ' cache is reached, reset the cache to the
 ' next 50 records.
 intRecords = intRecords + 1
 .MoveNext
 If intRecords Mod 50 = 0 Then
 .CacheStart = .Bookmark
 .FillCache
 End If
 Loop
 Next intLoop

 sngEnd = Timer
 sngCache = sngEnd - sngStart

 ' Display performance results.
 MsgBox "Caching Performance Results:" & vbCr & _
 " No cache: " & Format(sngNoCache, _
 "##0.000") & " seconds" & vbCr & _
 " 50-record cache: " & Format(sngCache, _
 "##0.000") & " seconds"
 .Close
 End With

 ' Delete linked table because this is a demonstration.
 dbsCurrent.TableDefs.Delete tdfRoyalties.Name
 dbsCurrent.Close

End Sub


AccessObject.CurrentView Property (Access)

 Copy code hover
[image]

AccessObject.CurrentView Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the current view for the specified Microsoft Access object. Read-only AcCurrentView.

Syntax

expression .CurrentView

expression A variable that represents an AccessObject object.

See also

Concepts

AccessObject Object

Other resources

AccessObject Object Members


Append and CreateParameter Methods Example (VC++)

 Copy code hover
[image]

Append and CreateParameter Methods Example (VC++)
Send feedback

This example uses the Append and CreateParameter methods to execute a stored procedure with an input parameter.

Copy code Copy code

// BeginAppendCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include "conio.h"
#include "AppendX.h"

//Function declaration
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void AppendX(VOID);
void PrintProviderError(_ConnectionPtr pConnection);

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////
void main()
{
 HRESULT hr = S_OK;

 if(FAILED(::CoInitialize(NULL)))
 return;

 AppendX();

 //Wait here for the user to see the output.
 printf("\n\nPress any key to continue...");
 getch();
 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// AppendX Function //
// //
///////////////////////////////////////////////////////////
VOID AppendX(VOID)
{

 HRESULT hr = S_OK;

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstByRoyalty = NULL;
 _RecordsetPtr pRstAuthors = NULL;
 _CommandPtr pcmdByRoyalty = NULL;
 _ParameterPtr pprmByRoyalty = NULL;
 _ConnectionPtr pConnection = NULL;

 //Define Other variables
 IADORecordBinding *picRs = NULL; //Interface Pointer declared.(VC++ Extensions)
 CEmployeeRs emprs; //C++ class object

 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 _bstr_t strMessage, strAuthorID;

 int intRoyalty;
 VARIANT vtRoyalty;

 try
 {
 //Open a Connection.
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
 hr = pConnection->Open(strCnn,"","",adConnectUnspecified);
 pConnection->CursorLocation = adUseClient;

 //Open Command Object with one Parameter
 TESTHR(pcmdByRoyalty.CreateInstance(__uuidof(Command)));
 pcmdByRoyalty->CommandText = "byroyalty";
 pcmdByRoyalty->CommandType = adCmdStoredProc;

 //Get parameter value and append parameter
 printf("Enter Royalty: ");
 scanf("%d",&intRoyalty);

 //Define Integer/variant.
 vtRoyalty.vt = VT_I2;
 vtRoyalty.iVal = intRoyalty;
 pprmByRoyalty = pcmdByRoyalty->CreateParameter("percentage",adInteger,adParamInput,sizeof(int),vtRoyalty);
 pcmdByRoyalty->Parameters->Append(pprmByRoyalty);

 pprmByRoyalty->Value = vtRoyalty;

 //Create Recordset by executing the command
 pcmdByRoyalty->ActiveConnection = pConnection;
 pRstByRoyalty = pcmdByRoyalty->Execute(NULL,NULL,adCmdStoredProc);

 //Open the authors table to get author names for display
 TESTHR(pRstAuthors.CreateInstance(__uuidof(Recordset)));

 //You have to explicitly pass the default Cursor type and LockType to the Recordset here
 hr = pRstAuthors->Open("authors",_variant_t((IDispatch*)pConnection,true),adOpenForwardOnly,adLockReadOnly,adCmdTable);

 //Open an IADORecordBinding interface pointer which we'll use for Binding Recordset to a class
 TESTHR(pRstAuthors->QueryInterface(__uuidof(IADORecordBinding),(LPVOID*)&picRs));

 //Bind the Recordset to a C++ Class here
 TESTHR(picRs->BindToRecordset(&emprs));

 //Print current data in the recordset, adding
 //author names from author table.
 printf("Authors with %d percent royalty ",intRoyalty);

 while(!(pRstByRoyalty->EndOfFile))
 {
 strAuthorID = pRstByRoyalty->Fields->Item["au_id"]->Value;
 pRstAuthors->Filter = "au_id = '"+strAuthorID+"'";

 printf("\n" "%s, %s %s",emprs.lau_idStatus == adFldOK ? emprs.m_szau_id : "<NULL>", emprs.lau_fnameStatus == adFldOK ? emprs.m_szau_fname : "<NULL>", emprs.lau_lnameStatus == adFldOK ? emprs.m_szau_lname : "<NULL>");

 pRstByRoyalty->MoveNext();
 }
 }
 catch(_com_error &e)
 {
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 PrintProviderError(pConnection);

 printf("\n Source : %s \n Description : %s \n",(LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }

 // Clean up objects before exit.
 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (pRstByRoyalty)
 if (pRstByRoyalty->State == adStateOpen)
 pRstByRoyalty->Close();
 if (pRstAuthors)
 if (pRstAuthors->State == adStateOpen)
 pRstAuthors->Close();
 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

VOID PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;
 long nCount = 0;
 long i = 0;

 if( (pConnection->Errors->Count) > 0)
 {
 nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\n Error Description: %s\n", pErr->Number,(LPCSTR) pErr->Description);
 }
 }
}
// EndAppendCpp

AppendX.h

Copy code Copy code

// BeginAppendH
#include "icrsint.h"

//This Class extracts only author id,fname,lastname

class CEmployeeRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CEmployeeRs)

 //Column au_id is the 1st field in the recordset

 ADO_VARIABLE_LENGTH_ENTRY2(1, adVarChar, m_szau_id,
 sizeof(m_szau_id), lau_idStatus, TRUE)

 ADO_VARIABLE_LENGTH_ENTRY2(2, adVarChar, m_szau_lname,
 sizeof(m_szau_lname), lau_lnameStatus, TRUE)

 ADO_VARIABLE_LENGTH_ENTRY2(3, adVarChar, m_szau_fname,
 sizeof(m_szau_fname), lau_fnameStatus, TRUE)

END_ADO_BINDING()

public:

 CHAR m_szau_id[20];
 ULONG lau_idStatus;

 CHAR m_szau_fname[40];
 ULONG lau_fnameStatus;

 CHAR m_szau_lname[40];
 ULONG lau_lnameStatus;

};
// EndAppendH


NavigationButton.Glow Property (Access)

 Copy code hover
[image]

NavigationButton.Glow Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the Glow effect applied to the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .Glow

expression A variable that represents a NavigationButton object.

Remarks

The Glow property uses one of the values listed in the following table.

Value | Effect
0 (Default) | None
1 | Blue, 5 pt glow, Accent color 1
2 | Red, 5 pt glow, Accent color 2
3 | Olive Green, 5 pt glow, Accent color 3
4 | Purple, 5 pt glow, Accent color 4
5 | Aqua, 5 pt glow, Accent color 5
6 | Orange, 5 pt glow, Accent color 6
7 | Blue, 8 pt glow, Accent color 1
8 | Red, 8 pt glow, Accent color 2
9 | Olive Green, 8 pt glow, Accent color 3
10 | Purple, 8 pt glow, Accent color 4
11 | Aqua, 8 pt glow, Accent color 5
12 | Orange, 8 pt glow, Accent color 6
13 | Blue, 11 pt glow, Accent color 1
14 | Red, 11 pt glow, Accent color 2
15 | Olive Green, 11 pt glow, Accent color 3
16 | Purple, 11 pt glow, Accent color 4
17 | Aqua, 11 pt glow, Accent color 5
18 | Orange, 11 pt glow, Accent color 6
19 | Blue, 18 pt glow, Accent color 1
20 | Red, 18 pt glow, Accent color 2
21 | Olive Green, 18 pt glow, Accent color 3
22 | Purple, 18 pt glow, Accent color 4
23 | Aqua, 18 pt glow, Accent color 5
24 | Orange, 18 pt glow, Accent color 6

To see the available glow effects and apply a glow through the user interface, first open the form or report in Layout view or Design view by right-clicking the form or report in the Navigation Pane, and then clicking the view you want. Then, click the object to which you want to apply a glow effect. Next, on the Format tab, in the Control Formatting group, click Shape Effects, then click Glow and choose a glow effect. Notice that the glow effects are indexed from left to right, and then top to bottom. So the first item, under No Glow, has the value 0. Then, under Glow, the first row contains glow effects with values from 1 to 6. The second row from 7 to 12, the third row from 13 to 18, and the fourth row from 19 to 24 .

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


TableDef.Attributes Property (DAO)

 Copy code hover
[image]

TableDef.Attributes Property (DAO)
Send feedback

Sets or returns a value that indicates one or more characteristics of a TableDef object. Read/write Long.

Syntax

expression .Attributes

expression A variable that represents a TableDef object.

Remarks

For an object not yet appended to a collection, this property is read/write.

Example

This example displays the Attributes property for Field, Relation, and TableDef objects in the Northwind database.

Copy code Copy code
Sub AttributesX()

 Dim dbsNorthwind As Database
 Dim fldLoop As Field
 Dim relLoop As Relation
 Dim tdfloop As TableDef

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind

 ' Display the attributes of a TableDef object's
 ' fields.
 Debug.Print "Attributes of fields in " & _
 .TableDefs(0).Name & " table:"
 For Each fldLoop In .TableDefs(0).Fields
 Debug.Print " " & fldLoop.Name & " = " & _
 fldLoop.Attributes
 Next fldLoop

 ' Display the attributes of the Northwind database's
 ' relations.
 Debug.Print "Attributes of relations in " & _
 .Name & ":"
 For Each relLoop In .Relations
 Debug.Print " " & relLoop.Name & " = " & _
 relLoop.Attributes
 Next relLoop

 ' Display the attributes of the Northwind database's
 ' tables.
 Debug.Print "Attributes of tables in " & .Name & ":"
 For Each tdfloop In .TableDefs
 Debug.Print " " & tdfloop.Name & " = " & _
 tdfloop.Attributes
 Next tdfloop

 .Close
 End With

End Sub


The database must be opened in exclusive mode before it can be replicated. (Error 3491)

 Copy code hover
[image]

The database must be opened in exclusive mode before it can be replicated. (Error 3491)
Send feedback

You attempted to replicate a database after opening the database in shared mode. Close the database and reopen it in exclusive mode, and then replicate it.


AllViews Members (Access)

 Copy code hover
[image]

AllViews Members (Access)
Send feedback

Published: July 16, 2012

The AllViews collection contains an AccessObject for each view in the CurrentData or CodeData object.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


ObjectFrame.OnUpdated Property (Access)

 Copy code hover
[image]

ObjectFrame.OnUpdated Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Updated box in the Properties window of a form or report. Read/write String.

Syntax

expression .OnUpdated

expression A variable that represents an ObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The OnUpdated value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Updated box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Updated box is blank, the property value is an empty string.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


SmartTagProperty.Value Property (Access)

 Copy code hover
[image]

SmartTagProperty.Value Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the value of the specified object. Read/write Variant.

Syntax

expression .Value

expression A variable that represents a SmartTagProperty object.

Remarks

The Value property returns or sets a control's default property, which is the property that is assumed when you don't explicitly specify a property name.

See also

Concepts

SmartTagProperty Object

Other resources

SmartTagProperty Object Members


NavigationButton.HoverThemeColorIndex Property (Access)

 Copy code hover
[image]

NavigationButton.HoverThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HoverThemeColorIndex

expression A variable that represents a NavigationButton object.

Remarks

The HoverThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 (Default) | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the HoverThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Lower Function (Access 2013 custom web app)

 Copy code hover
[image]

Lower Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns a character expression after converting uppercase character data to lowercase.

Syntax

Lower(TextExpression)

The Lower function contains the following argument.

Argument name | Description
TextExpression | A text expression.


NextRecordset Method (ADO)

 Copy code hover
[image]

NextRecordset Method (ADO)
Send feedback

Clears the current Recordset object and returns the next Recordset by advancing through a series of commands.

Syntax

Set recordset2 = recordset1.NextRecordset(RecordsAffected )

Return Value

Returns a Recordset object. In the syntax model, recordset1 and recordset2 can be the same Recordset object, or you can use separate objects. When using separate Recordset objects, resetting the ActiveConnection property on the original Recordset (recordset1) after NextRecordset has been called will generate an error.

Parameters

  • RecordsAffected

  • Optional. A Long variable to which the provider returns the number of records that the current operation affected.

Note Note

This parameter only returns the number of records affected by an operation; it does not return a count of records from a select statement used to generate the Recordset.

Remarks

Use the NextRecordset method to return the results of the next command in a compound command statement or of a stored procedure that returns multiple results. If you open a Recordset object based on a compound command statement (for example, "SELECT * FROM table1;SELECT * FROM table2") using the Execute method on a Command or the Open method on a Recordset, ADO executes only the first command and returns the results to recordset. To access the results of subsequent commands in the statement, call the NextRecordset method.

As long as there are additional results and the Recordset containing the compound statements is not disconnected or marshaled across process boundaries, the NextRecordset method will continue to return Recordset objects. If a row-returning command executes successfully but returns no records, the returned Recordset object will be open but empty. Test for this case by verifying that the BOF and EOF properties are both True. If a non-row-returning command executes successfully, the returned Recordset object will be closed, which you can verify by testing the State property on the Recordset. When there are no more results, recordset will be set to Nothing.

The NextRecordset method is not available on a disconnected Recordset object, where ActiveConnection has been set to Nothing (in Microsoft Visual Basic) or NULL (in other languages).

If an edit is in progress while in immediate update mode, calling the NextRecordset method generates an error; call the Update or CancelUpdate method first.

To pass parameters for more than one command in the compound statement by filling the Parameters collection, or by passing an array with the original Open or Execute call, the parameters must be in the same order in the collection or array as their respective commands in the command series. You must finish reading all the results before reading output parameter values.

Your OLE DB provider determines when each command command in a compound statement is executed. The Microsoft OLE DB Provider for SQL Server, for example, executes all commands in a batch upon receiving the compound statement. The resulting Recordsets are simply returned when you call NextRecordset.

However, other providers may execute the next command in a statement only after NextRecordset is called. For these providers, if you explicitly close the Recordset object before stepping through the entire command statement, ADO never executes the remaining commands.


How to: Use Numeric Criteria from a Control on a Form

 Copy code hover
[image]

How to: Use Numeric Criteria from a Control on a Form
Send feedback

If you want to change the criteria argument for an operation based on a user's decision, you can specify that the criteria come from a control on a form. For example, you could specify that the criteria argument comes from a text box containing the EmployeeID number.

To specify numeric criteria coming from a control on a form, you can include in the criteria argument an expression that references that control. This control expression should be separate from the string expression, so that Microsoft Access will evaluate the control expression first and concatenate it with the rest of the string expression before performing the appropriate operation.

Suppose that you are performing the DLookup function on an Employees table to find the last name of an employee based on the EmployeeID number. In the following example, the criteria are determined by the current value of the EmployeeID control on the Orders form. The expression referencing the control is evaluated each time the function is called, so that if the value of the control changes, the criteria argument will reflect that change.

Copy code Copy code
=DLookup("[LastName]", "Employees", "[EmployeeID] = " _
    & Forms!Orders!EmployeeID)

If the current value of the EmployeeID field is 7, the criteria argument that is passed to the DLookup function is:

Copy code Copy code
"[EmployeeID] = 7"
Tip Tip

To troubleshoot an expression in the criteria argument, break the expression into smaller components and test each one individually in the Immediate window. When all of the components are working correctly, put them back together one at a time until the complete expression works correctly.

You can also include a variable representing a numeric value in the criteria argument. The variable should be separate from the string expression, so that Microsoft Access will evaluate the variable first and then concatenate it with the rest of the string expression.

The following example shows how to construct a criteria argument that includes a variable:

Copy code Copy code
Dim intNum As Integer
Dim varResult As Variant

intNum = 7
varResult = DLookup("[LastName]", "Employees", _
    "[EmployeeID] = " & intNum)


Create Method (ADOX)

 Copy code hover
[image]

Create Method (ADOX)
Send feedback

Creates a new catalog.

Syntax

Catalog.Create ConnectString

Parameters

  • ConnectString

  • A String value used to connect to the data source.

Remarks

The Create method creates and opens a new ADO Connection to the data source specified in ConnectString. If successful, the new Connection object is assigned to the ActiveConnection property.

An error will occur if the provider does not support creating new catalogs.


Could not find file

 Copy code hover
[image]

Could not find file <name>. (Error 3024)
Send feedback

Possible causes:

  • The specified file does not exist.

  • You misspelled the file name. Check for missing underscores ( _ ) or other punctuation, and make sure you did not enter leading spaces.

  • The network connection has failed or has not been established.


WebBrowserControl.Object Property (Access)

 Copy code hover
[image]

WebBrowserControl.Object Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Object property in Visual Basic to return a reference to the ActiveX object that is associated with a linked or embedded OLE object in a control. By using this reference, you can access the properties or invoke the methods of the OLE object. Read-only Object.

Version Information

Version Added: Access 2010

Syntax

expression .Object

expression A variable that represents a WebBrowserControl object.

Remarks

The Object property returns a reference to an ActiveX object. You can use the Set statement to assign this ActiveX object to an object variable. The type of object reference returned depends on which application created the OLE object.

When you embed or link an OLE object in a Microsoft Access form, you can set properties that determine the type of object and the behavior of the container control. However, you can't directly set or read the OLE object's properties or apply its methods, as you can when performing Automation. The Object property returns a reference to an Automation object that represents the linked or embedded OLE object. By using this reference, you can change the OLE object by setting or reading its properties or applying its methods. For example, Microsoft Excel is an COM component that supports Automation. If you've embedded a Microsoft Excel worksheet in a Microsoft Access form, you can use the Object property to set a reference to the Worksheet object associated with that worksheet. You can then use any of the properties and methods of the Worksheet object.

For information on which properties and methods an ActiveX object supports, see the documentation for the application that was used to create the OLE object.

Example

The following example uses the Object property of an unbound object frame named OLE1. Customer name and address information is inserted in an embedded Microsoft Word document formatted as a form letter with placeholders for the name and address information and boilerplate text in the body of the letter. The procedure replaces the placeholder information for each record and prints the form letter. It doesn't save copies of the printed form letter.

VBA Copy code Copy code
Sub PrintFormLetter_Click()
 Dim objWord As Object
 Dim strCustomer As String, strAddress As String
 Dim strCity As String, strRegion As String

 ' Assign object property of control to variable.
 Set objWord = Me!OLE1.Object.Application.Wordbasic
 ' Assign customer address to variables.
 strCustomer = Me!CompanyName
 strAddress = Me!Address
 strCity = Me!City & ", "
 If Not IsNull(Me!Region) Then
 strRegion = Me!Region
 Else
 strRegion = Me!Country
 End If
 ' Activate ActiveX control.
 Me!OLE1.Action = acOLEActivate
 With objWord
 .StartOfDocument
 ' Go to first placeholder.
 .LineDown 2
 ' Highlight placeholder text.
 .EndOfLine 1
 ' Insert customer name.
 .Insert strCustomer
 ' Go to next placeholder.
 .LineDown
 .StartOfLine
 ' Highlight placeholder text.
 .EndOfLine 1
 ' Insert address.
 .Insert strAddress
 ' Go to last placeholder.
 .LineDown
 .StartOfLine
 ' Highlight placeholder text.
 .EndOfLine 1
 ' Insert City and Region.
 .Insert strCity & strRegion
 .FilePrint
 .FileClose
 End With
 Set objWord = Nothing
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Refresh Method Example (VB)

 Copy code hover
[image]

Refresh Method Example (VB)
Send feedback

This example demonstrates using the Refresh method to refresh the Parameters collection for a stored procedure Command object.

Copy code Copy code

Option Explicit

'BeginRefreshVB
Public Sub Main()
 On Error GoTo ErrorHandler

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection strings

 ' connection and recordset variables
 Dim Cnxn As ADODB.Connection
 Dim cmdByRoyalty As ADODB.Command
 Dim rstByRoyalty As ADODB.Recordset
 Dim rstAuthors As ADODB.Recordset
 Dim strCnxn As String
 Dim strSQLAuthors As String
 ' record variables
 Dim intRoyalty As Integer
 Dim strAuthorID As String
 Dim strRoyalty As String

 ' Open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open a command object for a stored procedure
 ' with one parameter
 Set cmdByRoyalty = New ADODB.Command
 Set cmdByRoyalty.ActiveConnection = Cnxn
 cmdByRoyalty.CommandText = "byroyalty"
 cmdByRoyalty.CommandType = adCmdStoredProc
 cmdByRoyalty.Parameters.Refresh

 ' Get paramater value, execute the command
 ' and store the results in a recordset
 strRoyalty = InputBox("Enter royalty:")
 If strRoyalty = "" Then
 Err.Raise 1, , "You either didn't enter royalty or canceled the input box. Exit the application"
 End If

 intRoyalty = Trim(strRoyalty)
 cmdByRoyalty.Parameters(1) = intRoyalty
 Set rstByRoyalty = cmdByRoyalty.Execute()

 ' Open the Authors table to get author names for display
 Set rstAuthors = New ADODB.Recordset
 strSQLAuthors = "Authors"
 rstAuthors.Open strSQLAuthors, Cnxn, adOpenForwardOnly, adLockPessimistic, adCmdTable

 ' Print current data in the recordset
 ' and add author names
 Debug.Print "Authors with " & intRoyalty & " percent royalty"

 Do Until rstByRoyalty.EOF
 strAuthorID = rstByRoyalty!au_id
 Debug.Print " " & rstByRoyalty!au_id & ", ";
 rstAuthors.Filter = "au_id = '" & strAuthorID & "'"
 Debug.Print rstAuthors!au_fname & " "; rstAuthors!au_lname
 rstByRoyalty.MoveNext
 Loop

 ' clean up
 rstByRoyalty.Close
 rstAuthors.Close
 Cnxn.Close
 Set rstByRoyalty = Nothing
 Set rstAuthors = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstByRoyalty Is Nothing Then
 If rstByRoyalty.State = adStateOpen Then rstByRoyalty.Close
 End If
 Set rstByRoyalty = Nothing

 If Not rstAuthors Is Nothing Then
 If rstAuthors.State = adStateOpen Then rstAuthors.Close
 End If
 Set rstAuthors = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndRefreshVB


Attributes Property (ADOX)

 Copy code hover
[image]

Attributes Property (ADOX)
Send feedback

Describes column characteristics.

Settings and Return Values

Sets or returns a Long value. The value specifies characteristics of the table represented by the Column object and can be a combination of ColumnAttributesEnum constants. The default value is zero (0), which is neither adColFixed nor adColNullable.


DBEngine.CreateDatabase Method (DAO)

 Copy code hover
[image]

DBEngine.CreateDatabase Method (DAO)
Send feedback

Creates a new Database object, saves the database to disk, and returns an opened Database object (Microsoft Access workspaces only). .

Syntax

expression .CreateDatabase(Name, Locale, Option)

expression A variable that represents a DBEngine object.

Parameters

Name

Required/Optional

Data Type

Description

Name

Required

String

A String up to 255 characters long that is the name of the database file that you're creating. It can be the full path and file name. If your network supports it, you can also specify a network path, such as "\\server1\share1\dir1\db1". You can only create Microsoft Access database files with this method.

Locale

Required

String

  • A string expression that specifies a collating order for creating the database, as specified in Settings. You must supply this argument or an error occurs.

  • You can also create a password for the new Database object by concatenating the password string (starting with ";pwd=" ) with a constant in the locale argument, like this:

  • dbLangSpanish & ";pwd=NewPassword"

  • If you want to use the default locale, but specify a password, simply enter a password string for the locale argument:

  • ";pwd=NewPassword"

  • Use strong passwords that combine upper- and lowercase letters, numbers, and symbols. Weak passwords don't mix these elements. Strong password: Y6dh!et5. Weak password: House27. Use a strong password that you can remember so that you don't have to write it down.

Option

Optional

Variant

A constant or combination of constants that indicates one or more options, as specified in Settings. You can combine options by summing the corresponding constants.

Remarks

You can use one of the following constants for the locale argument to specify the CollatingOrder property of text for string comparisons.

Constant | Collating order
dbLangGeneral | English, German, French, Portuguese, Italian, and Modern Spanish
dbLangArabic | Arabic
dbLangChineseSimplified | Simplified Chinese
dbLangChineseTraditional | Traditional Chinese
dbLangCyrillic | Russian
dbLangCzech | Czech
dbLangDutch | Dutch
dbLangGreek | Greek
dbLangHebrew | Hebrew
dbLangHungarian | Hungarian
dbLangIcelandic | Icelandic
dbLangJapanese | Japanese
dbLangKorean | Korean
dbLangNordic | Nordic languages (Microsoft Jet database engine version 1.0 only)
dbLangNorwDan | Norwegian and Danish
dbLangPolish | Polish
dbLangSlovenian | Slovenian
dbLangSpanish | Traditional Spanish
dbLangSwedFin | Swedish and Finnish
dbLangThai | Thai
dbLangTurkish | Turkish

You can use one or more of the following constants in the options argument to specify which version the data format should have and whether or not to encrypt the database.

Constant | Description
dbEncrypt | Creates an encrypted database.
dbVersion10 | Creates a database that uses the Microsoft Jet database engine version 1.0 file format.
dbVersion11 | Creates a database that uses the Microsoft Jet database engine version 1.1 file format.
dbVersion20 | Creates a database that uses the Microsoft Jet database engine version 2.0 file format.
dbVersion30 | Creates a database that uses the Microsoft Jet database engine version 3.0 file format (compatible with version 3.5).
dbVersion40 | Creates a database that uses the Microsoft Jet database engine version 4.0 file format.
dbVersion120 | Creates a database that uses the Microsoft Access database engine version 12.0 file format.

If you omit the encryption constant, CreateDatabase creates an un-encrypted database.

Use the CreateDatabase method to create and open a new, empty database, and return the Database object. You must complete its structure and content by using additional DAO objects. If you want to make a partial or complete copy of an existing database, you can use the CompactDatabase method to make a copy that you can customize.


Connection.Execute Method (DAO)

 Copy code hover
[image]

Connection.Execute Method (DAO)
Send feedback

Runs an action query or executes an SQL statement on the specified object.

Syntax

expression .Execute(Query, Options)

expression A variable that represents a Connection object.

Parameters

Name | Required/Optional | Data Type | Description
Query | Required | String | A String that is an SQL statement or the Name property value of a QueryDef object.
Options | Optional | Variant | A constant or combination of constants that determines the data integrity characteristics of the query, as specified in Settings.

Remarks

You can use the following RecordsetOptionEnumconstants for options.

Constant | Description
dbDenyWrite | Denies write permission to other users (Microsoft Access workspaces only).
dbInconsistent | (Default) Executes inconsistent updates (Microsoft Access workspaces only).
dbConsistent | Executes consistent updates (Microsoft Access workspaces only).
dbSQLPassThrough | Executes an SQL pass-through query. Setting this option passes the SQL statement to an ODBC database for processing (Microsoft Access workspaces only).
dbFailOnError | Rolls back updates if an error occurs (Microsoft Access workspaces only).
dbSeeChanges | Generates a run-time error if another user is changing data you are editing (Microsoft Access workspaces only).
dbRunAsync | Executes the query asynchronously (ODBCDirect Connection and QueryDef objects only).
dbExecDirect | Executes the statement without first calling SQLPrepare ODBC API function (ODBCDirect Connection and QueryDef objects only).
Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

Note Note

The constants dbConsistent and dbInconsistent are mutually exclusive. You can use one or the other, but not both in a given instance of OpenRecordset. Using both dbConsistent and dbInconsistent causes an error.

The Execute method is valid only for action queries. If you use Execute with another type of query, an error occurs. Because an action query doesn't return any records, Execute doesn't return a Recordset. (Executing an SQL pass-through query in an ODBCDirect workspace will not return an error if a Recordset isn't returned.)

Use the RecordsAffected property of the Connection, Database, or QueryDef object to determine the number of records affected by the most recent Execute method. For example, RecordsAffected contains the number of records deleted, updated, or inserted when executing an action query. When you use the Execute method to run a query, the RecordsAffected property of the QueryDef object is set to the number of records affected.

In a Microsoft Access workspace, if you provide a syntactically correct SQL statement and have the appropriate permissions, the Execute method won't fail — even if not a single row can be modified or deleted. Therefore, always use the dbFailOnError option when using the Execute method to run an update or delete query. This option generates a run-time error and rolls back all successful changes if any of the records affected are locked and can't be updated or deleted.

In earlier versions of the Microsoft Jet database engine, SQL statements were automatically embedded in implicit transactions. If part of a statement executed with dbFailOnError failed, the entire statement would be rolled back. To improve performance, these implicit transactions were removed starting with version 3.5. If you are updating older DAO code, be sure to consider using explicit transactions around Execute statements.

For best performance in a Microsoft Access workspace, especially in a multiuser environment, nest the Execute method inside a transaction. Use the BeginTrans method on the current Workspace object, then use the Execute method, and complete the transaction by using the CommitTrans method on the Workspace. This saves changes on disk and frees any locks placed while the query is running.


NavigationButton.LabelAlign Property (Access)

 Copy code hover
[image]

NavigationButton.LabelAlign Property (Access)
See also Send feedback

Published: July 16, 2012

The property specifies the text alignment within attached labels on new controls. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .LabelAlign

expression A variable that represents a NavigationButton object.

Remarks

The LabelAlign property uses the following settings.

Setting | Description
0 | (Default) The label text aligns to the left.
1 | The label text aligns to the left.
2 | The label text is centered.
3 | The label text aligns to the right.
4 | The label text is evenly distributed.

You can set the LabelAlign property by using a control's default control style or the DefaultControl property in Visual Basic.

When created, controls have an attached label (as long as their AutoLabel property is set to Yes). Changes to the LabelAlign default control style setting affect only controls created on the current form or report.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


TabControl.HelpContextId Property (Access)

 Copy code hover
[image]

TabControl.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Syntax

expression .HelpContextId

expression A variable that represents a TabControl object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Fields.Refresh Method (DAO)

 Copy code hover
[image]

Fields.Refresh Method (DAO)
Send feedback

Updates the objects in the specified colletion to reflect the database's current schema.

Syntax

expression .Refresh

expression A variable that represents a Fields object.

Remarks

To determine the position that the Microsoft Access database engine uses for Field objects in the Fields collection of a QueryDef, Recordset, or TableDef object, use the OrdinalPosition property of each Field object. Changing the OrdinalPosition property of a Field object may not change the order of the Field objects in the collection until you use the Refresh method

Use the Refresh method in multiuser environments in which other users may change the database. You may also need to use it on any collections that are indirectly affected by changes to the database. For example, if you change a Users collection, you may need to refresh a Groups collection before using the Groups collection.

A collection is filled with objects the first time it's referred to and won't automatically reflect subsequent changes other users make. If it's likely that another user has changed a collection, use the Refresh method on the collection immediately before carrying out any task in your application that assumes the presence or absence of a particular object in the collection. This will ensure that the collection is as up-to-date as possible. On the other hand, using Refresh can unnecessarily slow performance.

Example

This example uses the Refresh method to update the Fields collection of the Categories table based on changes to the OrdinalPosition data. The order of the Fields in the collection changes only after the Refresh method is used.

VBA Copy code Copy code
Sub RefreshX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim aintPosition() As Integer
 Dim astrFieldName() As String
 Dim intTemp As Integer
 Dim fldLoop As Field

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set tdfEmployees = dbsNorthwind.TableDefs("Categories")

 With tdfEmployees
 ' Display original OrdinalPosition data and store it
 ' in an array.
 Debug.Print _
 "Original OrdinalPosition data in TableDef."
 ReDim aintPosition(0 To .Fields.Count - 1) As Integer
 ReDim astrFieldName(0 To .Fields.Count - 1) As String
 For intTemp = 0 To .Fields.Count - 1
 aintPosition(intTemp) = _
 .Fields(intTemp).OrdinalPosition
 astrFieldName(intTemp) = .Fields(intTemp).Name
 Debug.Print , aintPosition(intTemp), _
 astrFieldName(intTemp)
 Next intTemp

 ' Change OrdinalPosition data.
 For Each fldLoop In .Fields
 fldLoop.OrdinalPosition = _
 100 - fldLoop.OrdinalPosition
 Next fldLoop
 Set fldLoop = Nothing

 ' Print new data.
 Debug.Print "New OrdinalPosition data before Refresh."
 For Each fldLoop In .Fields
 Debug.Print , fldLoop.OrdinalPosition, fldLoop.Name
 Next fldLoop

 .Fields.Refresh

 ' Print new data, showing how the field order has been
 ' changed.
 Debug.Print "New OrdinalPosition data after Refresh."
 For Each fldLoop In .Fields
 Debug.Print , fldLoop.OrdinalPosition, fldLoop.Name
 Next fldLoop

 ' Restore original OrdinalPosition data.
 For intTemp = 0 To .Fields.Count - 1
 .Fields(astrFieldName(intTemp)).OrdinalPosition = _
 aintPosition(intTemp)
 Next intTemp
 End With

 dbsNorthwind.Close

End Sub


Operation.Execute Method (Access)

 Copy code hover
[image]

Operation.Execute Method (Access)
See also Send feedback

Published: July 16, 2012

Executes the specified operation.

Version Information

Version Added: Access 2010

Syntax

expression .Execute(bstrParameters)

expression A variable that represents an Operation object.

Parameters

Name | Required/Optional | Data Type | Description
bstrParameters | Optional | String | Specifies values for the parameters of the operation.

Return Value

Variant

See also

Concepts

Operation Object

Other resources

Operation Object Members


Program flow functions (Access 2013 custom web app)

 Copy code hover
[image]

Program flow functions (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • Choose Function (Access 2013 custom web app)

  • IIf Function (Access 2013 custom web app)


Line.Application Property (Access)

 Copy code hover
[image]

Line.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a Line object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

Line Object

Other resources

Line Object Members


The field cannot be updated because another user or process has locked the corresponding record or table. (Error 3164)

 Copy code hover
[image]

The field cannot be updated because another user or process has locked the corresponding record or table. (Error 3164)
Send feedback

Possible causes:

  • You tried to update a field in a record or table that is currently locked by another user. Wait for the other user to finish working with the record or table, and then try the operation again.

  • In Microsoft Access, you tried to change the value of a control whose Locked property is set to Yes.


Connection Methods (DAO)

 Copy code hover
[image]

Connection Methods (DAO)
Send feedback

In this section

  • Connection.Cancel Method (DAO)

  • Connection.Close Method (DAO)

  • Connection.CreateQueryDef Method (DAO)

  • Connection.Execute Method (DAO)

  • Connection.OpenRecordset Method (DAO)


Table

 Copy code hover
[image]

Table <name> is read-only. (Error 3328)
Send feedback

This error occurs when you try to update a column in a table that another user has opened as read-only.


Module Properties (Access)

 Copy code hover
[image]

Module Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
CountOfDeclarationLines | The CountOfDeclarationLines property returns a Long value indicating the number of lines of code in the Declarations section in a standard module or class module. Read-only Long.
CountOfLines | The CountOfLines property returns a Long value indicating the number of lines of code in a standard module or class module. Read-only Long.
Lines | The Lines property returns a string containing the contents of a specified line or lines in a standard module or a class module. Read-only String.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
ProcBodyLine | The ProcBodyLine property returns the number of the line at which the body of a specified procedure begins in a standard module or a class module. Read-only Long.
ProcCountLines | The ProcCountLines property returns the number of lines in a specified procedure in a standard module or a class module. Read-only Long.
ProcOfLine | The ProcOfLine property returns the name of the procedure that contains a specified line in a standard module or a class module. Read-only string.
ProcStartLine | The ProcStartLine property returns avalue identifying the line at which a specified procedure begins in a standard module or a class module. Read-only Long.
Type | Indicates whether a module is a standard module or a class module. Read-only AcModuleType.


Errors Collection (DAO)

 Copy code hover
[image]

Errors Collection (DAO)
Send feedback

An Errors collection contains all stored Error objects, each of which pertains to a single operation involving DAO.

Remarks

Any operation involving DAO objects can generate one or more errors. As each error occurs, one or more Error objects are placed in the Errors collection of the DBEngine object. When another DAO operation generates an error, the Errors collection is cleared, and the new set of Error objects is placed in the Errors collection. The highest-numbered object in the Errors collection (DBEngine.Errors.Count - 1) corresponds to the error reported by the Microsoft Visual Basic for Applications (VBA) Err object.

DAO operations that don't generate an error have no effect on the Errors collection.

Elements of the Errors collection aren't appended as they typically are with other collections, so the Errors collection doesn't support the Append and Delete methods.

The set of Error objects in the Errors collection describes one error. The first Error object is the lowest level error, the second the next higher level, and so forth. For example, if an ODBC error occurs while trying to open a Recordset object, the first error object contains the lowest level ODBC error; subsequent errors contain the ODBC errors returned by the various layers of ODBC. In this case, the ODBC driver manager, and possibly the driver itself, return separate Error objects. The last Error object contains the DAO error indicating that the object couldn't be opened.

Enumerating the specific errors in the Errors collection enables your error-handling routines to more precisely determine the cause and origin of an error, and take appropriate steps to recover.

Note Note

If you use the New keyword to create an object that causes an error either before or while being placed into the Errors collection, the collection doesn't contain error information about that object, because the new object is not associated with the DBEngine object. However, the error information is available in the VBA Err object.

Example

This example forces an error, traps it, and displays the Description, Number, Source, HelpContext, and HelpFile properties of the resulting Error object.

VBA Copy code Copy code
Sub DescriptionX()

 Dim dbsTest As Database

 On Error GoTo ErrorHandler

 ' Intentionally trigger an error.
 Set dbsTest = OpenDatabase("NoDatabase")

 Exit Sub

ErrorHandler:
 Dim strError As String
 Dim errLoop As Error

 ' Enumerate Errors collection and display properties of
 ' each Error object.
 For Each errLoop In Errors
 With errLoop
 strError = _
 "Error #" & .Number & vbCr
 strError = strError & _
 " " & .Description & vbCr
 strError = strError & _
 " (Source: " & .Source & ")" & vbCr
 strError = strError & _
 "Press F1 to see topic " & .HelpContext & vbCr
 strError = strError & _
 " in the file " & .HelpFile & "."
 End With
 MsgBox strError
 Next

 Resume Next

End Sub


Page.Move Method (Access)

 Copy code hover
[image]

Page.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a Page object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

Page Object

Other resources

Page Object Members


TextBox.OldValue Property (Access)

 Copy code hover
[image]

TextBox.OldValue Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.

Syntax

expression .OldValue

expression A variable that represents a TextBox object.

Remarks

The OldValue property contains the unedited data from a bound control and is read-only in all views.

Microsoft Access uses the OldValue property to store the original value of a bound control. When you edit a bound control on a form, your changes aren't saved until you move to another record. The OldValue property contains the unedited version of the underlying data.

You can provide your own undo capability by assigning the OldValue property setting to a control. The following example shows how you can undo any changes to text box controls on a form:

VBA Copy code Copy code
Private Sub btnUndo_Click()

 Dim ctlTextbox As Control

 For Each ctlTextbox in Me.Controls
 If ctlTextbox.ControlType = acTextBox Then
 ctlTextbox.Value = ctl.OldValue
 End If
 Next ctlTextbox

End Sub

If the control hasn't been edited, this code has no effect. When you move to another record, the record source is updated, so the current value and the OldValue property will be the same.

The OldValue property setting has the same data type as the field to which the control is bound.

Example

The following example checks to determine if new data entered in a field is within 10 percent of the value of the original data. If the change is greater than 10 percent, the OldValue property is used to restore the original value. This procedure could be called from the BeforeUpdate event of the control that contains data you want to validate.

VBA Copy code Copy code
Public Sub Validate_Field()

 Dim curNewValue As Currency
 Dim curOriginalValue As Currency
 Dim curChange As Currency
 Dim strMsg As String

 curNewValue = Forms!Products!UnitPrice
 curOriginalValue = Forms!Products!UnitPrice.OldValue
 curChange = Abs(curNewValue - curOriginalValue)

 If curChange > (curOriginalValue * .1) Then
 strMsg = "Change is more than 10% of original unit price. " _
 & "Restoring original unit price."
 MsgBox strMsg, vbExclamation, "Invalid change."
 Forms!Products!UnitPrice = curOriginalValue
 End If

End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


GoToRecord Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

GoToRecord Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

You can use the GoToRecord action to make the specified record the current record in a view.

Setting

The GoToRecord action has the following arguments.

Action argument | Description
Record | The record to make the current record. Select Previous, Next, First, or Last. The default is Next.


Procedure Properties, Methods, and Events (ADOX)

 Copy code hover
[image]

Procedure Properties, Methods, and Events (ADOX)
Send feedback

Properties

Command Property

DateCreated Property

DateModified Property

Name Property

Methods

None.

Events

None.


DataControl Error Codes

 Copy code hover
[image]

DataControl Error Codes
Send feedback

The following table lists the RDS.DataControl object error codes. The positive decimal translation of the low two bytes, the negative decimal translation of the full error code, and the hexadecimal values are shown.

RDS.DataControl error codes | Number | Description
IDS_AsyncPending | 4107 -2146824175 0x800A1011 | Operation cannot be performed while async operation is pending.
IDS_BadInlineTablegram | 4105 -2146824183 0x800A1009 | Bad inline tablegram.
IDS_CantConnect | 4099 -2146824189 0x800A1003 | Cannot connect to server.
IDS_CantCreateObject | 4100 -2146824188 0x800A1004 | Business object cannot be created.
IDS_CantFindDataspace | 4102 -2146824186 0x800A1006 | Dataspace property is not valid.
IDS_CantInvokeMethod | 4101 -2146824187 0x800A1005 | Method cannot be invoked on business object.
IDS_CrossDomainWarning | 4112 -2146824170 0x800A1016 | This page accesses data on another domain. Do you want to allow this? To avoid this message in Internet Explorer, you can add a secure Web site to your Trusted Sites zone on the Security tab of the Internet Options dialog box.
IDS_InvalidADCClientVersion | 4106 -2146824176 0x800A1010 | Invalid RDS Client Version — Client is newer than server.
IDS_INVALIDARG | 5376 -2147019520 0x80071500 | One or more arguments are invalid.
IDS_InvalidBindings | 4097 -2146824191 0x800A1001 | Error in bindings property.
IDS_InvalidParam | 4110 -2146824172 0x800A1014 | One or more arguments are invalid.
IDS_NOINTERFACE | 5377 -2147019519 0x80071501 | No such interface is supported.
IDS_NotReentrant | 4111 -2146824171 0x800A1015 | Request cannot be executed while the event handler is still processing.
IDS_ObjectNotSafe | 4103 -2146824185 0x800A1007 | Safety settings on this computer prohibit creation of business object.
IDS_RecordsetNotOpen | 4109 -2146824173 0x800A1013 | Recordset is not open.
IDS_ResetInvalidField | 4108 -2146824174 0x800A1012 | Column specified in SortColumn or FilterColumn does not exist.
IDS_RowsetNotUpdateable | 4104 -2146824184 0x800A1008 | Rowset not updateable.
IDS_UnexpectedError | 4351 -2146823937 0x800A10FF | Unexpected error.
IDS_UpdatesFailed | 4098 -2146824190 0x800A1002 | Unable to update database.
IDS_URLMONNotFound | 4119 -2146824169 0x800A1017 | DataControl URL property requires the system file Urlmon.dll, which cannot be found.


How to: Create a DAO Recordset From a Query

 Copy code hover
[image]

How to: Create a DAO Recordset From a Query
Send feedback

You can create a Recordset object based on a stored select query. In the following code example, Current Product List is an existing select query stored in the current database.

VBA Copy code Copy code
Dim dbsNorthwind As DAO.Database
Dim rstProducts As DAO.Recordset

Set dbsNorthwind = CurrentDb
Set rstProducts = dbsNorthwind.OpenRecordset("Current Product List")

If a stored select query does not already exist, the OpenRecordset method also accepts an SQL string instead of the name of a query. The previous example can be rewritten as follows.

VBA Copy code Copy code
Dim dbsNorthwind As DAO.Database
Dim rstProducts As DAO.Recordset
Dim strSQL As String

Set dbsNorthwind = CurrentDb
strSQL = "SELECT * FROM Products WHERE Discontinued = No " & _
         "ORDER BY ProductName"
Set rstProducts = dbsNorthwind.OpenRecordset(strSQL)

The disadvantage of this approach is that the query string must be compiled each time it runs, whereas the stored query is compiled the first time it is saved, which usually results in slightly better performance.


OptionGroup.OnMouseUp Property (Access)

 Copy code hover
[image]

OptionGroup.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Syntax

expression .OnMouseUp

expression A variable that represents an OptionGroup object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


SubForm.TabIndex Property (Access)

 Copy code hover
[image]

SubForm.TabIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.

Syntax

expression .TabIndex

expression A variable that represents a SubForm object.

Remarks

You can set the TabIndex property to an integer representing the position of the control within the tab order of the form. Valid settings are 0 for the first tab position, up to the total number of controls minus 1 for the last tab position. For example, if a form has three controls that each have a TabIndex property, valid TabIndex property settings are 0, 1, and 2.

Setting the TabIndex property to an integer less than 0 produces an error.

By default, Microsoft Access assigns a tab order to controls in the order that you create them on a form. Each new control is placed last in the tab order. If you change the setting of a control's TabIndex property to adjust the tab order, Microsoft Access automatically renumbers the TabIndex property setting of other controls to reflect insertions and deletions.

In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the TAB key.

Changing the tab order of other controls on the form doesn't affect what happens when you press a control's access key. For example, if you've created an access key for the label of a text box, the focus will move to the text box whenever you press the label's access key — even if you change the TabIndex property setting for the text box.

If you press an access key for a control such as a label that doesn't have a TabIndex property (and thus isn't in the tab order), the focus moves to the next control in the tab order that can receive the focus.

Example

The following example reverses the tab order of a command button and a text box. Because TextBox1 was created first, it has a TabIndex property setting of 0 and Command1 has a setting of 1.

VBA Copy code Copy code
Sub Form_Click()
 Me!Command1.TabIndex = 0
 Me!TextBox1.TabIndex = 1
End Sub

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Type Property Example (Field) (VC++)

 Copy code hover
[image]

Type Property Example (Field) (VC++)
Send feedback

This example demonstrates the Type property by displaying the name of the constant that corresponds to the value of the Type property of all the Field objects in the Employees table. The FieldType function is required for this procedure to run.

Copy code Copy code

// BeginTypeFieldCpp
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void TypeX(void);
_bstr_t FieldType(int intType);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 TypeX();

 ::CoUninitialize();
}

///////////////////////////////////////////////
// //
// TypeX Function //
// //
///////////////////////////////////////////////
void TypeX(void)
{
 HRESULT hr = S_OK;

 // Define string variables.
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstEmployees = NULL;
 FieldsPtr pFldLoop = NULL;

 try
 {
 // Open recordset with data from Employee table.
 TESTHR(pRstEmployees.CreateInstance(__uuidof(Recordset)));
 pRstEmployees->Open ("employee",strCnn,
 adOpenForwardOnly, adLockReadOnly, adCmdTable);

 printf("Fields in Employee Table:\n\n");

 // Enumerate the Fields collection of the Employees table.
 pFldLoop = pRstEmployees->GetFields();
 int intLine = 0;
 for (int intFields = 0; intFields < (int)pFldLoop->
 GetCount(); intFields++)
 {
 _variant_t Index;
 Index.vt = VT_I2;
 Index.iVal = intFields;
 printf(" Name: %s\n" ,
 (LPCSTR) pFldLoop->GetItem(Index)->GetName());
 printf(" Type: %s\n\n",
 (LPCTSTR)FieldType(pFldLoop->GetItem(Index)->Type));
 intLine++;
 if(intLine % 5 == 0)
 {
 printf("Press any key to continue...");
 getch();
 system("cls");
 }
 }
 }
 catch (_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstEmployees->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 if (pRstEmployees)
 if (pRstEmployees->State == adStateOpen)
 pRstEmployees->Close();
}

///////////////////////////////////////////////
// //
// FieldType Function //
// //
///////////////////////////////////////////////
_bstr_t FieldType(int intType)
{
 _bstr_t strType;
 switch(intType)
 {
 case adChar:
 strType = "adChar";
 break;
 case adVarChar:
 strType = "adVarChar";
 break;
 case adSmallInt:
 strType = "adSmallInt";
 break;
 case adUnsignedTinyInt:
 strType = "adUnsignedTinyInt";
 break;
 case adDBTimeStamp:
 strType = "adDBTimeStamp";
 break;
 default:
 break;
 }
 return strType;
}

///////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////
void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

///////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////
void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndTypeFieldCpp


Form.CurrentView Property (Access)

 Copy code hover
[image]

Form.CurrentView Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the CurrentView property to determine how a form is currently displayed. Read/write Integer.

Syntax

expression .CurrentView

expression A variable that represents a Form object.

Remarks

The CurrentView property uses the following settings.

Setting | Form Displayed In:
0 | Design view
1 | Form view
2 | Datasheet view

Use this property to perform different tasks depending on the current view. For example, an event procedure could determine which view the form is displayed in and perform one task if the form is displayed in Form view or another task if it's displayed in Datasheet view.

Example

The following example uses the GetCurrentView subroutine to determine whether a form is in Form or Datasheet view. If it's in Form view, a message to the user is displayed in a text box on the form; if it's in Datasheet view, the same message is displayed in a message box.

VBA Copy code Copy code
GetCurrentView Me, "Please contact system administrator."

Sub GetCurrentView(frm As Form, strDisplayMsg As String)
 Const conFormView = 1
 Const conDataSheet = 2
 Dim intView As Integer
 intView = frm.CurrentView
 Select Case intView
 Case conFormView
 frm!MessageTextBox.SetFocus
 ' Display message in text box.
 frm!MessageTextBox = strDisplayMsg
 Case conDataSheet
 ' Display message in message box.
 MsgBox strDisplayMsg
 End Select
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Data Shaping Summary (ADO)

 Copy code hover
[image]

Data Shaping Summary (ADO)
Send feedback

In this section

  • Data Shaping Summary

  • Data Shaping

  • Reshaping

  • Grandchild Aggregates

  • Parameterized Commands with Intervening COMPUTE Commands

  • Persisting Hierarchical Recordsets


Attachment.Dirty Event (Access)

 Copy code hover
[image]

Attachment.Dirty Event (Access)
See also Send feedback

Published: July 16, 2012

The Dirty event occurs when the content of the specified control changes.

Version Information

Version Added: Access 2007

Syntax

expression .Dirty(Cancel, )

expression A variable that represents an Attachment object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the Dirty event occurs. Setting the Cancel argument to True (-1) cancels the Dirty event.

Remarks

Examples of this event include entering a character directly in the text box or combo box or changing the control's Text property setting by using a macro or Visual Basic.

  • Modifying a record within a form by using a macro or Visual Basic doesn't trigger this event. You must type the data directly into the record or set the control's Text property.

  • This event applies only to bound forms, not an unbound form or report.

To run a macro or event procedure when this event occurs, set the OnDirty property to the name of the macro or to [Event Procedure].

Canceling the Dirty event will cause the changes to the current record to be rolled back. It is equivalent to pressing the ESC key.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


ListBox.Column Property (Access)

 Copy code hover
[image]

ListBox.Column Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Column property to refer to a specific column, or column and row combination, in a multiple-column combo box or list box. Read-only Variant.

Syntax

expression .Column(Index, Row)

expression A variable that represents a ListBox object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Long | A long integer that can range from 0 to the setting of the ColumnCount property minus one.
Row | Optional | Variant | An integer that can range from 0 to the setting of the ListCount property minus 1.

Remarks

Use 0 to refer to the first column, 1 to refer to the second column, and so on. Use 0 to refer to the first row, 1 to refer to the second row, and so on. For example, in a list box containing a column of customer IDs and a column of customer names, you could refer to the customer name in the second column and fifth row as:

VBA Copy code Copy code
Forms!Contacts!Customers.Column(1, 4)

You can use the Column property to assign the contents of a combo box or list box to another control, such as a text box. For example, to set the ControlSource property of a text box to the value in the second column of a list box, you could use the following expression:

VBA Copy code Copy code
=Forms!Customers!CompanyName.Column(1)

If the user has made no selection when you refer to a column in a combo box or list box, the Column property setting will be Null. You can use the IsNull function to determine if a selection has been made, as in the following example:

VBA Copy code Copy code
If IsNull(Forms!Customers!Country)
 Then MsgBox "No selection."
End If
Note Note

To determine how many columns a combo box or list box has, you can inspect the ColumnCount property setting.

Example

The following example uses the Column property and the ColumnCount property to print the values of a list box selection.

VBA Copy code Copy code
Public Sub Read_ListBox()

 Dim intNumColumns As Integer
 Dim intI As Integer
 Dim frmCust As Form

 Set frmCust = Forms!frmCustomers
 If frmCust!lstCustomerNames.ItemsSelected.Count > 0 Then

 ' Any selection?
 intNumColumns = frmCust!lstCustomerNames.ColumnCount
 Debug.Print "The list box contains "; intNumColumns; _
 IIf(intNumColumns = 1, " column", " columns"); _
 " of data."

 Debug.Print "The current selection contains:"
 For intI = 0 To intNumColumns - 1
 ' Print column data.
 Debug.Print frmCust!lstCustomerNames.Column(intI)
 Next intI
 Else
 Debug.Print "You haven't selected an entry in the " _
 & "list box."
 End If

 Set frmCust = Nothing

End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


ToggleButton.Tag Property (Access)

 Copy code hover
[image]

ToggleButton.Tag Property (Access)
See also Send feedback

Published: July 16, 2012

Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.

Syntax

expression .Tag

expression A variable that represents a ToggleButton object.

Remarks

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

Example

The following example uses the Tag property to display custom messages about controls on a form. When a control has the focus, descriptive text is displayed in a label control called lblMessage. You specify the text for the message by setting the Tag property for each control to a short text string. When a control receives the focus, its Tag property is assigned to the label control's Caption property. This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

VBA Copy code Copy code
Sub Form_Load()
 Dim frmMessageForm As Form

 Set frmMessageForm = Forms!Form1

 frmMessageForm!lblMessage.Caption = "" ' Clear text.
 frmMessageForm!txtDescription.Tag = "Help text for the text box."
 frmMessageForm!cmdButton.Tag = "Help text for the command button."
End Sub

Sub txtDescription_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub

Sub txtDescription_LostFocus()
 Me!lblMessage.Caption = ""
End Sub

Sub cmdButton_GotFocus()
 ' Tag property setting as caption.
 Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub

Sub cmdButton_LostFocus()
 Me.lblMessage.Caption = " "
End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


SearchDirectionEnum

 Copy code hover
[image]

SearchDirectionEnum
Send feedback

Specifies the direction of a record search within a Recordset.

Constant | Value | Description
adSearchBackward | -1 | Searches backward, stopping at the beginning of the Recordset. If a match is not found, the record pointer is positioned at BOF.
adSearchForward | 1 | Searches forward, stopping at the end of the Recordset. If a match is not found, the record pointer is positioned at EOF.

ADO/WFC Equivalent

Package: com.ms.wfc.data

Constant

AdoEnums.SearchDirection.BACKWARD

AdoEnums.SearchDirection.FORWARD


ObjectFrame.LostFocus Event (Access)

 Copy code hover
[image]

ObjectFrame.LostFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The LostFocus event occurs when the specified object loses the focus.

Syntax

expression .LostFocus

expression A variable that represents an ObjectFrame object.

Remarks

To run a macro or event procedure when these events occur, set the OnLostFocus property to the name of the macro or to [Event Procedure].

This events occurs when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The LostFocus event differs from the Exit event in that the LostFocus event occurs every time a control loses the focus. The Exit event occurs only before a control loses the focus to another control on the same form. The LostFocus event occurs after the Exit event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


CustomControl.Object Property (Access)

 Copy code hover
[image]

CustomControl.Object Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Object property in Visual Basic to return a reference to the ActiveX object that is associated with a linked or embedded OLE object in a control. By using this reference, you can access the properties or invoke the methods of the OLE object. Read-only Object.

Syntax

expression .Object

expression A variable that represents a CustomControl object.

Remarks

The Object property returns a reference to an ActiveX object. You can use the Set statement to assign this ActiveX object to an object variable. The type of object reference returned depends on which application created the OLE object.

When you embed or link an OLE object in a Microsoft Access form, you can set properties that determine the type of object and the behavior of the container control. However, you can't directly set or read the OLE object's properties or apply its methods, as you can when performing Automation. The Object property returns a reference to an Automation object that represents the linked or embedded OLE object. By using this reference, you can change the OLE object by setting or reading its properties or applying its methods. For example, Microsoft Excel is an COM component that supports Automation. If you've embedded a Microsoft Excel worksheet in a Microsoft Access form, you can use the Object property to set a reference to the Worksheet object associated with that worksheet. You can then use any of the properties and methods of the Worksheet object.

For information on which properties and methods an ActiveX object supports, see the documentation for the application that was used to create the OLE object.

Example

The following example uses the Object property of an unbound object frame named OLE1. Customer name and address information is inserted in an embedded Microsoft Word document formatted as a form letter with placeholders for the name and address information and boilerplate text in the body of the letter. The procedure replaces the placeholder information for each record and prints the form letter. It doesn't save copies of the printed form letter.

VBA Copy code Copy code
Sub PrintFormLetter_Click()
 Dim objWord As Object
 Dim strCustomer As String, strAddress As String
 Dim strCity As String, strRegion As String

 ' Assign object property of control to variable.
 Set objWord = Me!OLE1.Object.Application.Wordbasic
 ' Assign customer address to variables.
 strCustomer = Me!CompanyName
 strAddress = Me!Address
 strCity = Me!City & ", "
 If Not IsNull(Me!Region) Then
 strRegion = Me!Region
 Else
 strRegion = Me!Country
 End If
 ' Activate ActiveX control.
 Me!OLE1.Action = acOLEActivate
 With objWord
 .StartOfDocument
 ' Go to first placeholder.
 .LineDown 2
 ' Highlight placeholder text.
 .EndOfLine 1
 ' Insert customer name.
 .Insert strCustomer
 ' Go to next placeholder.
 .LineDown
 .StartOfLine
 ' Highlight placeholder text.
 .EndOfLine 1
 ' Insert address.
 .Insert strAddress
 ' Go to last placeholder.
 .LineDown
 .StartOfLine
 ' Highlight placeholder text.
 .EndOfLine 1
 ' Insert City and Region.
 .Insert strCity & strRegion
 .FilePrint
 .FileClose
 End With
 Set objWord = Nothing
End Sub

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


SCHEMA (Microsoft Access SQL reserved word)

 Copy code hover
[image]

SCHEMA (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The SCHEMA keyword is used in these contexts:

GRANT Statement

REVOKE Statement


Field2.FieldSize Property (DAO)

 Copy code hover
[image]

Field2.FieldSize Property (DAO)
Send feedback

Returns the number of bytes used in the database (rather than in memory) of a Memo or Long Binary Field2 object in the Fields collection of a Recordset object.

Syntax

expression .FieldSize

expression A variable that represents a Field2 object.

Remarks

You can use FieldSize with the AppendChunk and GetChunk methods to manipulate large fields.

Because the size of a Long Binary or Memo field can exceed 64K, you should assign the value returned by FieldSize to a variable large enough to store a Long variable.

To determine the size of a Field2 object other than Memo and Long Binary types, use the Size property.

  • If the database server or ODBC driver does not support server-side cursors.

  • If you are using the ODBC cursor library (that is, the DefaultCursorDriver property is set to dbUseODBC, or to dbUseDefault when the server does not support server-side cursors).

  • If you are using a cursorless query (that is, the DefaultCursorDriver property is set to dbUseNoCursor).

The FieldSize property and the VBA Len() or LenB() functions may return different values as the length of the same string. Strings are stored in a Microsoft Access database in multi-byte character set (MBCS) form, but exposed through VBA in Unicode format. As a result, the Len() function will always return the number of characters, LenB will always return the number of characters X 2 (Unicode uses two bytes for each character), but FieldSize will return some value in between if the string has any MBCS characters. For example, given a string consisting of three normal characters and two MBCS characters, Len() will return 5, LenB() will return 10, and FieldSize will return 7, the sum of 1 for each normal character and 2 for each MBCS character.

Example

This example uses the FieldSize property to list the number of bytes used by the Memo and Long Binary Field objects in two different tables.

VBA Copy code Copy code
Sub FieldSizeX()

 Dim dbsNorthwind As Database
 Dim rstCategories As Recordset
 Dim rstEmployees As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstCategories = _
 dbsNorthwind.OpenRecordset("Categories", _
 dbOpenDynaset)
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", _
 dbOpenDynaset)

 Debug.Print _
 "Field sizes from records in Categories table"

 With rstCategories
 Debug.Print " CategoryName - " & _
 "Description (bytes) - Picture (bytes)"

 ' Enumerate the Categories Recordset and print the size
 ' in bytes of the picture field for each record.
 Do While Not .EOF
 Debug.Print " " & !CategoryName & " - " & _
 !Description.FieldSize & " - " & _
 !Picture.FieldSize
 .MoveNext
 Loop

 .Close
 End With

 Debug.Print "Field sizes from records in Employees table"

 With rstEmployees
 Debug.Print " LastName - Notes (bytes) - " & _
 "Photo (bytes)"

 ' Enumerate the Employees Recordset and print the size
 ' in bytes of the picture field for each record.
 Do While Not .EOF
 Debug.Print " " & !LastName & " - " & _
 !Notes.FieldSize & " - " & !Photo.FieldSize
 .MoveNext
 Loop

 .Close
 End With

 dbsNorthwind.Close

End Sub

This example uses the AppendChunk and GetChunk methods to fill an OLE object field with data from another record, 32K at a time. In a real application, one might use a procedure like this to copy an employee record (including the employee's photo) from one table to another. In this example, the record is simply being copied back to same table. Note that all the chunk manipulation takes place within a single AddNew-Update sequence.

VBA Copy code Copy code
Sub AppendChunkX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset
 Dim rstEmployees2 As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 ' Open two recordsets from the Employees table.
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", _
 dbOpenDynaset)
 Set rstEmployees2 = rstEmployees.Clone

 ' Add a new record to the first Recordset and copy the
 ' data from a record in the second Recordset.
 With rstEmployees
 .AddNew
 !FirstName = rstEmployees2!FirstName
 !LastName = rstEmployees2!LastName
 CopyLargeField rstEmployees2!Photo, !Photo
 .Update

 ' Delete new record because this is a demonstration.
 .Bookmark = .LastModified
 .Delete
 .Close
 End With

 rstEmployees2.Close
 dbsNorthwind.Close

End Sub

Function CopyLargeField(fldSource As Field2, _
 fldDestination As Field2)

 ' Set size of chunk in bytes.
 Const conChunkSize = 32768

 Dim lngOffset As Long
 Dim lngTotalSize As Long
 Dim strChunk As String

 ' Copy the photo from one Recordset to the other in 32K
 ' chunks until the entire field is copied.
 lngTotalSize = fldSource.FieldSize
 Do While lngOffset < lngTotalSize
 strChunk = fldSource.GetChunk(lngOffset, conChunkSize)
 fldDestination.AppendChunk strChunk
 lngOffset = lngOffset + conChunkSize
 Loop

End Function


ListBox.BackThemeColorIndex Property (Access)

 Copy code hover
[image]

ListBox.BackThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackThemeColorIndex

expression A variable that represents a ListBox object.

Remarks

The BackThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BackThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Background Color to the Text 2 color by setting the BackThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BackThemeColorIndex=2

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


NavigationControl.BackColor Property (Access)

 Copy code hover
[image]

NavigationControl.BackColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the interior color of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackColor

expression A variable that represents a NavigationControl object.

Remarks

The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

To use the BackColor property, the BackStyle property, if available, must be set to Normal.

Example

The following example uses the RGB function to set the , BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


AllModules.Parent Property (Access)

 Copy code hover
[image]

AllModules.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents an AllModules object.

See also

Concepts

AllModules Collection

Other resources

AllModules Object Members


Attachment.Enabled Property (Access)

 Copy code hover
[image]

Attachment.Enabled Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .Enabled

expression A variable that represents an Attachment object.

Remarks

The Enabled property setting is a value that indicates whether the conditional format is enabled or disabled. True enables the conditional format. False disables the conditional format. The default is True.

When the Enabled property is True, the conditional format can be displayed in the Conditional Formatting dialog box.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


ComboBox.ForeTint Property (Access)

 Copy code hover
[image]

ComboBox.ForeTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .ForeTint

expression A variable that represents a ComboBox object.

Remarks

The ForeTint property contains a numeric expression that can be used to lighten the theme color in the ForeColor property. The default value of the ForeTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the ForeColor property by 75%.

VBA Copy code Copy code
Me.ctl.ForeTint=25

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


How to: Change Tables Involved in a One-to-Many Relationship in a DAO Recordset

 Copy code hover
[image]

How to: Change Tables Involved in a One-to-Many Relationship in a DAO Recordset
Send feedback

Dynaset-type Recordset objects can be based on a multiple-table query containing tables with a one-to-many relationship. For example, suppose you want to create a multiple-table query that combines fields from the Orders and Order Details tables. Generally speaking, you cannot change values in the Orders table because it is on the "one" side of the relationship. Depending on your application, however, you may want to be able to make changes to the Orders table.

To make it possible to freely change the values on the "one" side of a one-to-many relationship, use the dbInconsistent constant of the OpenRecordset method to create an inconsistent dynaset. For example.

VBA Copy code Copy code
 Set rstTotalSales = dbs.OpenRecordset("Sales Totals" ,,dbInconsistent)

When you update an inconsistent dynaset, you can easily destroy the referential integrity of the data in the dynaset. You must take care to understand how the data is related across the one-to-many relationship and to update the values on both sides in a way that preserves data integrity.

The dbInconsistent constant is available only for dynaset-type Recordset objects. It is ignored for table, snapshot, and forward-only-type Recordset objects, but no compile or run-time error is returned if the dbInconsistent constant is used with those types of Recordset objects.

Even with an inconsistent Recordset, some fields may not be updatable. For example, you cannot change the value of an AutoNumber field, and a Recordset based on certain linked tables may not be updatable.


Count Function (Access 2013 custom web app)

 Copy code hover
[image]

Count Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the number of records in a query or table.

Syntax

Count(Expression)

The Count function contains the following argument.

Argument name | Description
Expression | A string expression identifying the field that contains the data you want to count or an expression that performs a calculation using the data in the field. Operands in Expression can include the name of a table field or function (which can be either intrinsic or user-defined but not other SQL aggregate functions). You can count any kind of data, including text.

Remarks

You can use Count to count the number of records in an underlying query. For example, you could use Count to count the number of orders shipped to a particular country or region.

Count(*) returns the number of items in a group. This includes NULL values and duplicates.


UndoRecord Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

UndoRecord Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Discards changes to the current record.

Remarks

The UndoRecord action is equivalent to using the Cancel button in the action bar discard changes.


ComboBox.Undo Event (Access)

 Copy code hover
[image]

ComboBox.Undo Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when the user undoes a change.

Syntax

expression .Undo(Cancel, )

expression A variable that represents a ComboBox object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | Set this argument to True to cancel the undo operation and leave the control or form in its edited state.

Remarks

The Undo event for controls occurs whenever the user returns a control to its original state by clicking the Undo Field/Record button on the command bar, clicking the Undo button, pressing the ESC key, or calling the Undo method of the specified control. The control needs to have focus in all three cases. The event does not occur if the user clicks the Undo Typing button on the command bar.

Example

The following example demonstrates the syntax for a subroutine that traps the Undo event for a form.

VBA Copy code Copy code
Private Sub Form_Undo(Cancel As Integer)
 Dim intResponse As Integer
 Dim strPrompt As String

 strPrompt = "Cancel the undo operation?"

 intResponse = MsgBox(strPrompt, vbYesNo)

 If intResponse = vbYes Then
 Cancel = True
 Else
 Cancel = False
 End If
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ComboBox.BackShade Property (Access)

 Copy code hover
[image]

ComboBox.BackShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackShade

expression A variable that represents a ComboBox object.

Remarks

The BackShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the BackShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackShade=25

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


TabControl.SizeToFit Method (Access)

 Copy code hover
[image]

TabControl.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents a TabControl object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Field2.AllowZeroLength Property (DAO)

 Copy code hover
[image]

Field2.AllowZeroLength Property (DAO)
Send feedback

Sets or returns a value that indicates whether a zero-length string ("") is a valid setting for the Value property of the Field2 object with a Text or Memo data type (Microsoft Access workspaces only).

Syntax

expression .AllowZeroLength

expression A variable that represents a Field2 object.

Remarks

For an object not yet appended to the Fields collection, this property is read/write.

Once appended to a Fields collection, the availability of the AllowZeroLength property depends on the object that contains the Fields collection, as shown in the following table.

If the Fields collection belongs to an | Then AllowZeroLength is
Index object | Not supported
QueryDef object | Read-only
Recordset object | Read-only
Relation object | Not supported
TableDef object | Read/write

You can use this property along with the Required, ValidateOnSet, or ValidationRule property to validate a value in a field.

Example

In this example, the AllowZeroLength property allows the user to set the value of a Field2 to an empty string. In this situation, the user can distinguish between a record where data is not known and a record where the data does not apply.

Copy code Copy code
Sub AllowZeroLengthX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim fldTemp As Field
 Dim rstEmployees As Recordset
 Dim strMessage As String
 Dim strInput As String

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set tdfEmployees = dbsNorthwind.TableDefs("Employees")
 ' Create a new Field object and append it to the Fields
 ' collection of the Employees table.
 Set fldTemp = tdfEmployees.CreateField("FaxPhone", _
 dbText, 24)
 fldTemp.AllowZeroLength = True
 tdfEmployees.Fields.Append fldTemp

 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees")

 With rstEmployees
 ' Get user input.
 .Edit
 strMessage = "Enter fax number for " & _
 !FirstName & " " & !LastName & "." & vbCr & _
 "[? - unknown, X - has no fax]"
 strInput = UCase(InputBox(strMessage))
 If strInput <> "" Then
 Select Case strInput
 Case "?"
 !FaxPhone = Null
 Case "X"
 !FaxPhone = ""
 Case Else
 !FaxPhone = strInput
 End Select

 .Update

 ' Print report.
 Debug.Print "Name - Fax number"
 Debug.Print !FirstName & " " & !LastName & " - ";

 If IsNull(!FaxPhone) Then
 Debug.Print "[Unknown]"
 Else
 If !FaxPhone = "" Then
 Debug.Print "[Has no fax]"
 Else
 Debug.Print !FaxPhone
 End If
 End If

 Else
 .CancelUpdate
 End If

 .Close
 End With

 ' Delete new field because this is a demonstration.
 tdfEmployees.Fields.Delete fldTemp.Name
 dbsNorthwind.Close

End Sub


Rectangle.Move Method (Access)

 Copy code hover
[image]

Rectangle.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a Rectangle object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


TextBox.Dirty Event (Access)

 Copy code hover
[image]

TextBox.Dirty Event (Access)
See also Send feedback

Published: July 16, 2012

The Dirty event occurs when the contents of the specified control changes.

Syntax

expression .Dirty(Cancel)

expression A variable that represents a TextBox object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the Dirty event occurs. Setting the Cancel argument to True (-1) cancels the Dirty event.

Remarks

Examples of this event include entering a character directly in the text box or combo box or changing the control's Text property setting by using a macro or Visual Basic.

  • Modifying a record within a form by using a macro or Visual Basic doesn't trigger this event. You must type the data directly into the record or set the control's Text property.

  • This event applies only to bound forms, not an unbound form or report.

To run a macro or event procedure when this event occurs, set the OnDirty property to the name of the macro or to [Event Procedure].

By running a macro or event procedure when a Dirty event occurs, you can determine if the record can be changed. You can also display a message and ask for edit permission.

Changing the data in a record by using the keyboard causes keyboard events to occur in addition to control events like the Dirty event. For example, if you move to a new record and type an ANSI character in a text box in the record, the following events occur in this order:

KeyDown > KeyPress > BeforeInsert > Dirty > KeyUp

The BeforeUpdate and AfterUpdate events for a record occur after you have entered the new or changed data in the record and moved to another record (or clicked Save Record on the Records menu), and therefore after the Dirty event for the record.

Canceling the Dirty event will cause the changes to the current record to be rolled back. It is equivalent to pressing the ESC key.

Example

The following example enables the btnUndo button when data is changed. The UndoEdits( ) subroutine is called from the Dirty event of text box controls. Clicking the enabled btnUndo button restores the original value of the control by using the OldValue property.

VBA Copy code Copy code
Private Sub Form_Dirty()
 If Me.Dirty Then
 Me!btnUndo.Enabled = True ' Enable button.
 Else
 Me!btnUndo.Enabled = False ' Disable button.
 End If
End Sub

Sub btnUndo_Click()
 Dim ctlC As Control
 ' For each control.
 For Each ctlC in Me.Controls
 If ctlC.ControlType = acTextBox Then
 ' Restore Old Value.
 ctlC.Value = ctlC.OldValue
 End If
 Next ctlC
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


WebBrowserControl.GridlineShade Property (Access)

 Copy code hover
[image]

WebBrowserControl.GridlineShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineShade

expression A variable that represents an WebBrowserControl object.

Remarks

The GridlineShade property contains a numeric expression that can be used to darken the theme color in the GridlineColor property. The default value of the GridlineShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Reports.Item Property (Access)

 Copy code hover
[image]

Reports.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only Report.

Syntax

expression .Item(Index)

expression A variable that represents a Reports object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

Reports Collection

Other resources

Reports Object Members


Prepared Property Example (VB)

 Copy code hover
[image]

Prepared Property Example (VB)
Send feedback

This example demonstrates the Prepared property by opening two Command objects — one prepared and one not prepared.

Copy code Copy code

'BeginPreparedVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 Dim Cnxn As ADODB.Connection
 Dim cmd1 As ADODB.Command
 Dim cmd2 As ADODB.Command

 Dim strCnxn As String
 Dim strCmd As String
 Dim sngStart As Single
 Dim sngEnd As Single
 Dim sngNotPrepared As Single
 Dim sngPrepared As Single
 Dim intLoop As Integer

 ' Open a connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Set Cnxn = New ADODB.Connection
 Cnxn.Open strCnxn

 ' Create two command objects for the same
 ' command - one prepared and one not prepared
 strCmd = "SELECT title, type FROM Titles ORDER BY type"

 Set cmd1 = New ADODB.Command
 Set cmd1.ActiveConnection = Cnxn
 cmd1.CommandText = strCmd

 Set cmd2 = New ADODB.Command
 Set cmd2.ActiveConnection = Cnxn
 cmd2.CommandText = strCmd
 cmd2.Prepared = True

 ' Set a timer, then execute the unprepared
 ' command 20 times
 sngStart = Timer
 For intLoop = 1 To 20
 cmd1.Execute
 Next intLoop
 sngEnd = Timer
 sngNotPrepared = sngEnd - sngStart

 ' Reset the timer, then execute the prepared
 ' command 20 times
 sngStart = Timer
 For intLoop = 1 To 20
 cmd2.Execute
 Next intLoop
 sngEnd = Timer
 sngPrepared = sngEnd - sngStart

 ' Display performance results
 MsgBox "Performance Results:" & vbCr & _
 " Not Prepared: " & Format(sngNotPrepared, _
 "##0.000") & " seconds" & vbCr & _
 " Prepared: " & Format(sngPrepared, _
 "##0.000") & " seconds"

 ' clean up
 Cnxn.Close
 Set Cnxn = Nothing
 Set cmd1 = Nothing
 Set cmd2 = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 Set cmd1 = Nothing
 Set cmd2 = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndPreparedVB


Connections Methods (DAO)

 Copy code hover
[image]

Connections Methods (DAO)
Send feedback

In this section

  • Connections.Refresh Method (DAO)


CustomControl.ObjectPalette Property (Access)

 Copy code hover
[image]

CustomControl.ObjectPalette Property (Access)
See also Send feedback

Published: July 16, 2012

The ObjectPalette property specifies the palette in the application used to create an OLE object. Read/write Variant.

Syntax

expression .ObjectPalette

expression A variable that represents a CustomControl object.

Remarks

Microsoft Access sets the value of the ObjectPalette property to a String data type containing the palette information. You can use this setting to set the value of the PaintPalette property for a form or report.

If the application associated with the OLE object doesn't have an associated palette, the ObjectPalette property is set to an zero-length string.

The setting of the ObjectPalette property makes the palette of the application associated with the OLE object contained in a control available to the PaintPalette property of a form or report. For example, to make the palette used in Microsoft Graph available when you're designing a form in Microsoft Access, you set the form's PaintPalette property to the ObjectPalette value of an existing chart control.

Note Note

Windows can have only one color palette active at a time. Microsoft Access allows you to have multiple graphics on a form, each using a different color palette. The PaintPalette and PaletteSource properties let you specify which color palette a form should use when displaying graphics.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Chapter 1: ADO Fundamentals

 Copy code hover
[image]

Chapter 1: ADO Fundamentals
Send feedback

This chapter is an introduction to the ADO library. It discusses what you can do with ADO, reviews the objects in the ADO hierarchy, and presents a simple ADO application that uses many of the ADO objects to retrieve, edit, and update data from a data source. Finally, this chapter covers two issues that are important to understand for writing ADO applications: OLE DB providers and errors.


SubForm.Width Property (Access)

 Copy code hover
[image]

SubForm.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents a SubForm object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Operations Members (Access)

 Copy code hover
[image]

Operations Members (Access)
Send feedback

Published: July 16, 2012

Represents the collection of operations defined for an Entity.

Properties

Name | Description
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Object.
Parent | Returns the parent object for the specified object. Read-only.


BoundObjectFrame.Properties Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a BoundObjectFrame object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


NumericScale and Precision Properties Example (VC++)

 Copy code hover
[image]

NumericScale and Precision Properties Example (VC++)
Send feedback

This example demonstrates the NumericScale and Precision properties of the Column object. This code displays their value for the Order Details table of the Northwind database.

Copy code Copy code

// BeginNumericScalePrecCpp
#import "c:\Program Files\Common Files\system\ado\msadox.dll" no_namespace
#import "c:\Program Files\Common Files\system\ado\msado15.dll"

#include "iostream.h"
#include "stdio.h"
#include "conio.h"

//Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void NumericScalePrecX(void);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 NumericScalePrecX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// NumericScalePrecX Function //
// //
//////////////////////////////////////////////////////////
void NumericScalePrecX(void)
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.
 _CatalogPtr m_pCatalog = NULL;
 _TablePtr m_pTable = NULL;
 _ColumnPtr m_pColumn = NULL;

 //Define ADODB object pointers
 ADODB::_ConnectionPtr m_pCnn = NULL;

 //Declare string variables
 _bstr_t strCnn("Provider='Microsoft.JET.OLEDB.4.0';"
 "Data Source='c:\\Program Files\\Microsoft Office\\"
 "Office\\Samples\\Northwind.mdb';");
 try
 {
 TESTHR(hr = m_pCnn.CreateInstance(__uuidof(ADODB::Connection)));

 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof (Catalog)));

 // Connect the catalog.
 m_pCnn->Open (strCnn, "", "", NULL);

 m_pCatalog->PutActiveConnection(variant_t((IDispatch *)m_pCnn));

 // Retrieve the Order Details table
 m_pTable = m_pCatalog->Tables->GetItem("Order Details");

 // Display numeric scale and precision of
 // small integer fields.
 _variant_t vIndex;
 for (long lIndex=0; lIndex < m_pTable->Columns->Count; lIndex++)
 {
 vIndex = lIndex ;
 m_pColumn = m_pTable->Columns->GetItem(vIndex);
 if(m_pColumn->Type == adSmallInt)
 {
 cout << "Column: " << m_pColumn->GetName() << endl;
 cout << "Numeric scale: " << (_bstr_t) m_pColumn->
 GetNumericScale() << endl;
 cout << "Precision: " << m_pColumn->GetPrecision() <<
 endl;
 }
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }
 catch(...)
 {
 cout << "Error occured in NumericScalePrecX...."<< endl;
 }
}
// EndNumericScalePrecCpp


Data Definition Language

 Copy code hover
[image]

Data Definition Language
Send feedback

In this section

  • ADD USER Statement (Microsoft Access SQL)

  • ALTER TABLE Statement (Microsoft Access SQL)

  • ALTER USER or DATABASE Statement (Microsoft Access SQL)

  • CONSTRAINT Clause (Microsoft Access SQL)

  • CREATE INDEX Statement (Microsoft Access SQL)

  • CREATE PROCEDURE Statement (Microsoft Access SQL)

  • CREATE TABLE Statement (Microsoft Access SQL)

  • CREATE USER or GROUP Statement (Microsoft Access SQL)

  • CREATE VIEW Statement (Microsoft Access SQL)

  • DROP Statement (Microsoft Access SQL)

  • DROP USER or GROUP Statement (Microsoft Access SQL)

  • GRANT Statement (Microsoft Access SQL)

  • REVOKE Statement (Microsoft Access SQL)


AccessObjectProperty Members (Access)

 Copy code hover
[image]

AccessObjectProperty Members (Access)
Send feedback

Published: July 16, 2012

An AccessObjectProperty object represents a built-in or user-defined characteristic of an AccessObject object.

Properties

Name | Description
Name | You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.
Value | Determines or specifies the value of a built-in property of an AccessObject object. Read/write Variant.


Recordset2.OpenRecordset Method (DAO)

 Copy code hover
[image]

Recordset2.OpenRecordset Method (DAO)
Send feedback

Creates a new Recordset object and appends it to the Recordsets collection.

Syntax

expression .OpenRecordset(Type, Options)

expression A variable that represents a Recordset2 object.

Parameters

Name

Required/Optional

Data Type

Description

Name

Required

String

The source of the records for the new Recordset. The source can be a table name, a query name, or an SQL statement that returns records. For table-type Recordset objects in Microsoft Access database engine databases, the source can only be a table name.

Type

Optional

Variant

A RecordsetTypeEnum constant that indicates the type of Recordset to open.

Note Note

If you open a Recordset in a Microsoft Access workspace and you don't specify a type, OpenRecordset creates a table-type Recordset, if possible. If you specify a linked table or query, OpenRecordset creates a dynaset-type Recordset.

Options

Optional

Variant

A combination of RecordsetOptionEnum constants that specify characteristics of the new Recordset.

Note Note

The constants dbConsistent and dbInconsistent are mutually exclusive, and using both causes an error. Supplying a lockedits argument when options uses the dbReadOnly constant also causes an error.

LockEdit

Optional

Variant

A LockTypeEnum constant that determines the locking for the Recordset.

Note Note

You can use dbReadOnly in either the options argument or the lockedits argument, but not both. If you use it for both arguments, a run-time error occurs.

Return Value

Recordset

Remarks

Typically, if the user gets this error while updating a record, your code should refresh the contents of the fields and retrieve the newly modified values. If the error occurs while deleting a record, your code could display the new record data to the user and a message indicating that the data has recently changed. At this point, your code can request a confirmation that the user still wants to delete the record.

You should also use the dbSeeChanges constant if you open a Recordset in a Microsoft Access database engine-connected ODBC workspace against a Microsoft SQL Server 6.0 (or later) table that has an IDENTITY column, otherwise an error may result.

Opening more than one Recordset on an ODBC data source may fail because the connection is busy with a prior OpenRecordset call. One way around this is to fully populate the Recordset by using the MoveLast method as soon as the Recordset is opened.

Closing a Recordset with the Close method automatically deletes it from the Recordsets collection.

Note Note

If source refers to an SQL statement composed of a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strSQL = "PRICE > " & lngPrice, and lngPrice = 125,50), an error occurs when you try to open the Recordset. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and SQL only accepts U.S. decimal characters.


DBEngine.Rollback Method (DAO)

 Copy code hover
[image]

DBEngine.Rollback Method (DAO)
Send feedback

Ends the current transaction and restores the databases in the Workspace object to the state they were in when the current transaction began.

Syntax

expression .Rollback

expression A variable that represents a DBEngine object.

Remarks

The transaction methods BeginTrans, CommitTrans, and Rollback manage transaction processing during a session defined by a Workspace object. You use these methods with a Workspace object when you want to treat a series of changes made to the databases in a session as one unit.

Typically, you use transactions to maintain the integrity of your data when you must both update records in two or more tables and ensure changes are completed (committed) in all tables or none at all (rolled back). For example, if you transfer money from one account to another, you might subtract an amount from one and add the amount to another. If either update fails, the accounts no longer balance. Use the BeginTrans method before updating the first record, and then, if any subsequent update fails, you can use the Rollback method to undo all of the updates. Use the CommitTrans method after you successfully update the last record.

Note Note

Within one Workspace object, transactions are always global to the Workspace and aren't limited to only one Connection or Database object. If you perform operations on more than one connection or database within a Workspace transaction, resolving the transaction (that is, using the CommitTrans or Rollback method) affects all operations on all connections and databases within that workspace.

After you use CommitTrans, you can't undo changes made during that transaction unless the transaction is nested within another transaction that is itself rolled back. If you nest transactions, you must resolve the current transaction before you can resolve a transaction at a higher level of nesting.

If you want to have simultaneous transactions with overlapping, non-nested scopes, you can create additional Workspace objects to contain the concurrent transactions.

If you close a Workspace object without resolving any pending transactions, the transactions are automatically rolled back.

If you use the CommitTrans or Rollback method without first using the BeginTrans method, an error occurs.

Some ISAM databases used in a Microsoft Access workspace may not support transactions, in which case the Transactions property of the Database object or Recordset object is False. To make sure the database supports transactions, check the value of the Transactions property of the Database object before using the BeginTrans method. If you are using a Recordset object based on more than one database, check the Transactions property of the Recordset object. If a Recordset is based entirely on Microsoft Access database engine tables, you can always use transactions. Recordset objects based on tables created by other database products, however, may not support transactions. For example, you can't use transactions in a Recordset based on a Paradox table. In this case, the Transactions property is False. If the Database or Recordset doesn't support transactions, the methods are ignored and no error occurs.

You can't nest transactions if you are accessing ODBC data sources through the Microsoft Access database engine.

In ODBC workspaces, when you use CommitTrans your cursor may no longer be valid. Use the Requery method to view the changes in the Recordset, or close and re-open the Recordset.

  • You can often improve the performance of your application by breaking operations that require disk access into transaction blocks. This buffers your operations and may significantly reduce the number of times a disk is accessed.

  • In a Microsoft Access workspace, transactions are logged in a file kept in the directory specified by the TEMP environment variable on the workstation. If the transaction log file exhausts the available storage on your TEMP drive, the database engine triggers a run-time error. At this point, if you use CommitTrans, an indeterminate number of operations are committed, but the remaining uncompleted operations are lost, and the operation has to be restarted. Using a Rollback method releases the transaction log and rolls back all operations in the transaction.

  • Closing a clone Recordset within a pending transaction will cause an implicit Rollback operation.


ToggleButton.Left Property (Access)

 Copy code hover
[image]

ToggleButton.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Syntax

expression .Left

expression A variable that represents a ToggleButton object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Report.CurrentRecord Property (Access)

 Copy code hover
[image]

Report.CurrentRecord Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the CurrentRecord property to identify the current record in the recordset being viewed. Read/write Long.

Syntax

expression .CurrentRecord

expression A variable that represents a Report object.

See also

Concepts

Report Object

Other resources

Report Object Members


ComboBox.InputMask Property (Access)

 Copy code hover
[image]

ComboBox.InputMask Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InputMask property to make data entry easier and to control the values users can enter in a combo box control. Read/write String.

Syntax

expression .InputMask

expression A variable that represents a ComboBox object.

Remarks

Input masks are helpful for data-entry operations such as an input mask for a Phone Number field that shows you exactly how to enter a new number: (___) ___-____. It is often easier to use the Input Mask Wizard to set the property for you.

The InputMask property can contain up to three sections separated by semicolons (;).

Section | Description
First | Specifies the input mask itself; for example, !(999) 999-9999. For a list of characters you can use to define the input mask, see the following table.
Second | Specifies whether Microsoft Access stores the literal display characters in the table when you enter data. If you use 0 for this section, all literal display characters (for example, the parentheses in a phone number input mask) are stored with the value; if you enter 1 or leave this section blank, only characters typed into the control are stored.
Third | Specifies the character that Microsoft Access displays for the space where you should type a character in the input mask. For this section, you can use any character; to display an empty string, use a space enclosed in quotation marks (" ").

In Visual Basic you use a string expression to set this property. For example, the following specifies an input mask for a text box control used for entering a phone number:

VBA Copy code Copy code
Forms!Customers!Telephone.InputMask = "(###) ###-####"

When you create an input mask, you can use special characters to require that certain data be entered (for example, the area code for a phone number) and that other data be optional (such as a telephone extension). These characters specify the type of data, such as a number or character, that you must enter for each character in the input mask.

You can define an input mask by using the following characters.

Character | Description
0 | Digit (0 to 9, entry required, plus [+] and minus [-] signs not allowed).
9 | Digit or space (entry not required, plus and minus signs not allowed).
# | Digit or space (entry not required; spaces are displayed as blanks while in Edit mode, but blanks are removed when data is saved; plus and minus signs allowed).
L | Letter (A to Z, entry required).
? | Letter (A to Z, entry optional).
A | Letter or digit (entry required).
a | Letter or digit (entry optional).
& | Any character or a space (entry required).
C | Any character or a space (entry optional).
. , : ; - / | Decimal placeholder and thousand, date, and time separators. (The actual character used depends on the settings in the Regional Settings Properties dialog box in Windows Control Panel).
< | Causes all characters to be converted to lowercase.
> | Causes all characters to be converted to uppercase.
! | Causes the input mask to display from right to left, rather than from left to right. Characters typed into the mask always fill it from left to right. You can include the exclamation point anywhere in the input mask.
\ | Causes the character that follows to be displayed as the literal character (for example, \A is displayed as just A).
Note Note

Setting the InputMask property to the word "Password" creates a password-entry control. Any character typed in the control is stored as the character but is displayed as an asterisk (*). You use the Password input mask to prevent displaying the typed characters on the screen.

When you type data in a field for which you've defined an input mask, the data is always entered in Overtype mode. If you use the BACKSPACE key to delete a character, the character is replaced by a blank space.

If you move text from a field for which you've defined an input mask onto the Clipboard, the literal display characters are copied, even if you have specified that they not be saved with data.

Note Note

Only characters that you type directly in a control or combo box are affected by the input mask. Microsoft Access ignores any input masks when you import data, run an action query, or enter characters in a control by setting the control's Text property in Visual Basic or by using the SetValue action in a macro.

When you've defined an input mask and set the Format property for the same field, the Format property takes precedence when the data is displayed. This means that even if you've saved an input mask, the input mask is ignored when data is formatted and displayed. The data in the underlying table itself isn't changed; the Format property affects only how the data is displayed.

The following table shows some useful input masks and the type of values you can enter in them.

Input mask | Sample values
(000) 000-0000 | (206) 555-0248
(999) 999-9999 | (206) 555-0248
 | ( ) 555-0248
(000) AAA-AAAA | (206) 555-TELE
#999 | -20
 | 2000
>L????L?000L0 | GREENGR339M3
 | MAY R 452B7
>L0L 0L0 | T2F 8M4
00000-9999 | 98115-
 | 98115-3007
>L<?????????????? | Maria
 | Brendan
SSN 000-00-0000 | SSN 555-55-5555
>LL00000-0000 | DB51392-0493

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


PageSize Property (ADO)

 Copy code hover
[image]

PageSize Property (ADO)
Send feedback

Indicates how many records constitute one page in the Recordset.

Settings and Return Values

Sets or returns a Long value that indicates how many records are on a page. The default is 10.

Remarks

Use the PageSize property to determine how many records make up a logical page of data. Establishing a page size allows you to use the AbsolutePage property to move to the first record of a particular page. This is useful in Web server scenarios when you want to allow the user to page through data, viewing a certain number of records at a time.

This property can be set at any time, and its value will be used for calculating the location of the first record of a particular page.


Label.MouseUp Event (Access)

 Copy code hover
[image]

Label.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents a Label object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was released to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

Label Object

Other resources

Label Object Members


Application.References Property (Access)

 Copy code hover
[image]

Application.References Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the References property to access the References collection and its related properties, methods, and events. Read-only References collection.

Syntax

expression .References

expression A variable that represents an Application object.

Remarks

The References collection corresponds to the list of references in the References dialog box, available by clicking References on the Tools menu. Each Reference object represents one selected reference in the list. References that appear in the References dialog box but haven't been selected aren't in the References collection.

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Display List of References - Both Good and Broken

Example

The following example displays a message indicating the number of boxes checked in the References dialog box.

VBA Copy code Copy code
MsgBox "There are " & Application.References.Count & " references."

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Application Object

Other resources

Application Object Members


OptionGroup.Left Property (Access)

 Copy code hover
[image]

OptionGroup.Left Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Left property to specify an object's location on a form or report. Read/write Integer.

Syntax

expression .Left

expression A variable that represents an OptionGroup object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips

For reports, you can set these properties only by using a macro or event procedure in Visual Basic while the report is in Print Preview or being printed.

For reports, the Left property setting is the amount the current section is offset from the left of the page. This property is expressed in twips. You can use this property to specify how far down the page you want a section to print in the section's Format event procedure.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the NextRecord and PrintSection properties are set to False (0). The section doesn't advance to the next record, and the next section isn't printed.

VBA Copy code Copy code
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

 Const conLeftMargin = 1880

 ' Don't advance to next record or print next section
 ' if Left property setting is less than 1880 twips.
 If Me.Left < conLeftMargin Then
 Me.NextRecord = False
 Me.PrintSection = False
 End If

End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Before Change Macro Event

 Copy code hover
[image]

Before Change Macro Event
Send feedback

The Before Change event occurs when a record changes, but before the change is committed.

Note Note

The Before Change event is available only in Data Macros.

Remarks

Use the Before Change event to perform any actions that you want to occur before a record is changed. The Before Change is commonly used to perform validation and to raise custom error messages.

You can use the Updated("Field Name") function to determine whether a field has changed. The following code example shows how to use an If statement to determine whether the PaidInFull field has been changed.

Copy code Copy code
If  Updated("PaidInFull")   Then

    /* Perform actions based on changes to the field.   */

End If

Use the IsInsert property to determine whether the Before Change event was triggered by a new record being created or a change to an existing record. They IsInsert property contains True if the event was triggered by a new record, False if the event was triggered by a change to en existing record.

The following code example shows the syntax for using the IsInsert property.

Copy code Copy code
If   [IsInsert] = True   Then

   /*  Actions for validating a new record go here.       */

Else

   /* Actions for processing a changed record go here.    */

End If

You can use access a the previous value in a field by using the following syntax.

Copy code Copy code
[Old].[Field Name]

For example, to access the previous value of the QuantityInStock field, use the following syntax.

Copy code Copy code
[Old].[QuantityInStock]

The previous values are deleted permanently when the Before Change event ends.

You can cancel the Before Change event by using the RaiseError action. When an error is raised the changes contained in the Before Change event are discarded.

The following table lists macro commands that can be used in theBefore Change event.

Command Type | Command
Program Flow | Comment Macro Statement
Program Flow | Group Macro Statement
Program Flow | If...Then...Else Macro Block
Data Block | LookupRecord Macro Action
Data Action | ClearMacroError Macro Action
Data Action | OnError Macro Action
Data Action | RaiseError Macro Action
Data Action | SetField Macro Action
Data Action | SetLocalVar Macro Action
Data Action | StopMacro Macro Action

To create a Data Macro that captures the Before Change event, use the following steps:

  1. Open the table for which you want to capture the Before Change event.

  2. On the Table tab, in the Before Events group, click Before Change.

An empty data macro is displayed in the macro designer.

Example

The following code example uses the Before Change event to validate the Status fields. An error is raised if an inappropriate value is contained in the Resolution field.

Click here to view a copy of the macro that you can paste into Macro Designer.

Copy code Copy code

/* Check to ensure that if the bug is resloved that the user has selected a resolution      */
If   [Status]="3 - Resolved" And IsNull([Resolution])   Then

     RaiseError
             Error Number   1
        Error Description   You must select a resolution.
End If

/* Check to ensure that if a bug is closed that the user has selected a resolution first     */
If   [Status]="4 - Closed" And IsNull([Resolution])   Then

      RaiseError
             Error Number   2
        Error Description   An issue must be resolved before it can be closed.
End If

If   [Status]<>"3 - Resolved" And [Status]<>"4 - Closed"   Then

      SetField
             Name   Resolution
            Value   =Null
End If

To view this example in the macro designer, use the following steps.

  1. Open the table for which you want to capture the Before Change event.

  2. On the Table tab, in the Before Events group, click Before Change.

  3. Select the code in the following code example and then press CTRL+C to copy it to the Clipboard.

  4. Activate the macro designer window and then press CTRL+V.

XML Copy code Copy code
<DataMacros xmlns="http://schemas.microsoft.com/office/accessservices/2009/04/application">
  <DataMacro Event="BeforeChange">
    <Statements>
      <Comment>Check to ensure that if the bug is resloved that the user has selected a resolution </Comment>
      <ConditionalBlock>
        <If>
          <Condition>[Status]="3 - Resolved" And IsNull([Resolution])</Condition>
          <Statements>
            <Action Name="RaiseError">
              <Argument Name="Number">1</Argument>
              <Argument Name="Description">You must select a resolution.</Argument>
            </Action>
          </Statements>
        </If>
      </ConditionalBlock>
      <Comment>Check to ensure that if a bug is closed that the user has selected a resolution first </Comment>
      <ConditionalBlock>
        <If>
          <Condition>[Status]="4 - Closed" And IsNull([Resolution])</Condition>
          <Statements>
            <Action Name="RaiseError">
              <Argument Name="Number">2</Argument>
              <Argument Name="Description">An issue must be resolved before it can be closed.</Argument>
            </Action>
          </Statements>
        </If>
      </ConditionalBlock>
      <ConditionalBlock>
        <If>
          <Condition>[Status]&lt;&gt;"3 - Resolved" And [Status]&lt;&gt;"4 - Closed"</Condition>
          <Statements>
            <Action Name="SetField">
              <Argument Name="Field">Resolution</Argument>
              <Argument Name="Value">Null</Argument>
            </Action>
          </Statements>
        </If>
      </ConditionalBlock>
    </Statements>
  </DataMacro>
</DataMacros>

The following example shows how to use the RaiseError action to cancel the Before Change data macro event. When the AssignedTo field is updated, a LookupRecord data block is used to determine whether the assigned technician is currently assigned to an open service request. If this is true, then the Before Change event is cancelled and the record is not updated.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

Copy code Copy code
/* Get the name of the technician  */
Look Up A Record In tblTechnicians
    Where Condition =[tblTechnicians].[ID]=[tblServiceRequests].[AssignedTo]
SetLocalVar
    Name TechName
    Expression [tblTechnicians].[FirstName] & " " & [tblTechnicians].[LastName]
/* End LookUpRecord  */

If Updated("AssignedTo") Then
    Look Up A Record In tblServiceRequests
        Where Condition SR.[AssignedTo]=tblServiceRequests[AssignedTo] And
            SR.[ID]<>tblServiceRequests.[ID] And IsNull(SR.[ActualCompletionDate])
        Alias SR
        RaiseError
            Error Number 1234
            Error Description ="Cannot assign a request to the specified technician: " & [TechName]

End If

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Description, HelpContext, HelpFile, NativeError, Number, Source, and SQLState Properties Example (VJ++)

 Copy code hover
[image]

Description, HelpContext, HelpFile, NativeError, Number, Source, and SQLState Properties Example (VJ++)
Send feedback

This example triggers an error, traps it, and displays the Description, HelpContext, HelpFile, NativeError, Number, Source, and SQLState properties of the resulting Error object.

Copy code Copy code
// BeginDescriptionJ
// The WFC class includes the ADO objects.

import com.ms.wfc.data.*;
import java.io.* ;

public class DescriptionX
{
   // The main entry point for the application.

   public static void main (String[] args)
   {
      DescriptionX();
      System.exit(0);
   }

   // DescriptionX function

   static void DescriptionX()
   {
      // Declarations.
      BufferedReader in = new
         BufferedReader(new InputStreamReader(System.in));

      // Define ADO Objects.
      Connection cnConn1 = null;

      try
      {
         // Intentionally trigger an error.
         cnConn1 = new Connection();
         cnConn1.open("nothing");
      }
      catch( AdoException ae )
      {
         // Notify user of any errors that result from ADO.
         PrintProviderError(cnConn1);
      }

      try
      {
         System.out.println("\nPress <Enter> key to continue.");
         in.readLine();
      }
      // System read requires this catch.
      catch( java.io.IOException je)
      {
         PrintIOError(je);
      }

   }

   // PrintProviderError Function

   static void PrintProviderError( Connection Cnn1 )
   {
      // Print Provider errors from Connection object.
      // ErrItem is an item object in the Connections Errors collection.
      com.ms.wfc.data.Error  ErrItem = null;
      long nCount = 0;
      int  i      = 0;

      nCount = Cnn1.getErrors().getCount();

      // If there are any errors in the collection, print them.
      if( nCount > 0);
      {
         // Collection ranges from 0 to nCount - 1
         for (i = 0; i< nCount; i++)
         {
            ErrItem = Cnn1.getErrors().getItem(i);
            System.out.println("\t Error number: " + ErrItem.getNumber()
               + "\t" + ErrItem.getDescription() );
         }
      }

   }

   // PrintIOError Function

   static void PrintIOError( java.io.IOException je)
   {
      System.out.println("Error \n");
      System.out.println("\tSource = " + je.getClass() + "\n");
      System.out.println("\tDescription = " + je.getMessage() + "\n");
   }
}
// EndDescriptionJ


ListBox.AddItem Method (Access)

 Copy code hover
[image]

ListBox.AddItem Method (Access)
See also Send feedback

Published: July 16, 2012

Adds a new item to the list of values displayed by the specified list box control.

Syntax

expression .AddItem(Item, Index)

expression A variable that represents a ListBox object.

Parameters

Name | Required/Optional | Data Type | Description
Item | Required | String | The display text for the new item.
Index | Optional | Variant | The position of the item in the list. If this argument is omitted, the item is added to the end of the list.

Remarks

The RowSourceType property of the specified control must be set to "Value List".

This method is only valid for list box or combo box controls on forms.

List item numbers start from zero. If the value of the Item argument doesn't correspond to an existing item number, an error occurs.

For multiple-column lists, use semicolons to delimit the strings for each column (for example, "1010;red;large" for a three-column list). If the Item argument contains fewer strings than columns in the control, items will be added starting with the left-most column. If the Item argument contains more strings than columns in the control, the extra strings are ignored.

Use the RemoveItem method to remove items from the list of values.

Example

This example adds an item to the end of the list in a list box control. For the function to work, you must pass it a ListBox object representing a list box control on a form and a String value representing the text of the item to be added.

VBA Copy code Copy code
Function AddItemToEnd(ctrlListBox As ListBox, _
 ByVal strItem As String)

 ctrlListBox.AddItem Item:=strItem

End Function

This example adds an item to the beginning of the list in a combo box control. For the function to work, you must pass it a ComboBox object representing a combo box control on a form and a String value representing the text of the item to be added.

VBA Copy code Copy code
Function AddItemToBeginning(ctrlComboBox As ComboBox, _
 ByVal strItem As String)

 ctrlComboBox.AddItem Item:=strItem, Index:=0

End Function

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Parameter Object (ADO) Reference

 Copy code hover
[image]

Parameter Object (ADO) Reference
Send feedback

In this section

  • Parameter Object (ADO)

  • Parameter Properties, Methods, and Events (ADO)


Using the Command Object (Access)

 Copy code hover
[image]

Using the Command Object (Access)
Send feedback

After connecting to a data source, you need to execute requests against it to obtain result sets. ADO encapsulates this type of command functionality in the Command object.

You can use the Command object to request any type of operation from the provider, assuming that the provider can interpret the command string properly. A common operation for data providers is to query a database and return records in a Recordset object. Recordsets will be discussed later in this and other chapters; for now, think of them as tools to hold and view result sets. As with many ADO objects, depending on the functionality of the provider, some Command object collections, methods, or properties might generate errors when referenced.

It is not always necessary to create a Command object to execute a command against a data source. You can use the Execute method on the Connection object or the Open method on the Recordset object. However, you should use a Command object if you need to reuse a command in your code or if you need to pass detailed parameter information with your command. These scenarios are covered in more detail later in this chapter.

Note Note

Certain Commands can return a result set as a binary stream or as a single Record rather than as a Recordset, if this is supported by the provider. Also, some Commands are not intended to return any result set at all (for example, a SQL Update query). This chapter will cover the most typical scenario, however: executing Commands that return results into a Recordset object. For more information about returning results into Records or Streams, see Chapter 10: Records and Streams.


Label Properties (Access)

 Copy code hover
[image]

Label Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomMargin | Along with the LeftMargin, RightMargin, and TopMargin properties, specifies the location of information displayed within a label control. Read/write Integer.
BottomPadding | Gets or sets the amount of space (in inches) between the label and its bottom gridline. Read/write Integer.
Caption | Gets or sets the text that appears in the control. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontName | You can use the FontName property to specify the font for text in the following situations:
FontSize | You can use the FontSize property to specify the point size for text in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
FontWeight | You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
ForeShade | Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
ForeThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.
ForeTint | Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
GridlineColor | Gets or sets the color of the gridline for the specified label. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified label. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified label. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified label. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified label. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified label. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified label. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified label. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified label. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the label is anchored horizontally within its layout. Read/write.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
HyperlinkAddress | You can use the HyperlinkAddress property to specify or determine the path to an object, document, Web page or other destination for a hyperlink associated with a the specified control. Read/write String.
HyperlinkSubAddress | You can use the HyperlinkSubAddress property to specify or determine a location within the target document specified by the HyperlinkAddress property. Read/write String.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Layout | Returns the type of layout for the specified label. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified label. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftMargin | Along with the TopMargin, RightMargin, and BottomMargin properties, specifies the location of information displayed within a label control. Read/write Integer. .
LeftPadding | Gets or sets the amount of space (in inches) between the label and its left gridline. Read/write Integer.
LineSpacing | You can use the LineSpacing property to specify or determine the location of information displayed within a label or text box control. Read/write Integer.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
NumeralShapes |
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
RightMargin | Along with the TopMargin, Left Margin, and BottomMargin properties, specifies the location of information displayed within a label control. Read/write Integer.
RightPadding | Gets or sets the amount of space (in inches) between the label and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SmartTags | Returns a SmartTags collection that represents the collection of smart tags that have been added to a control. .
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
TextAlign | The TextAlign property specifies the text alignment in new controls. Read/write Byte.
ThemeFontIndex | Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopMargin | Along with the LeftMargin, RightMargin, and BottomMargin properties, specifies the location of information displayed within a label control. Read/write Integer.
TopPadding | Gets or sets the amount of space (in inches) between the label and its top gridline. Read/write Integer.
Vertical | You can use the Vertical property to set a form control for vertical display and editing or set a report control for vertical display and printing. Read/write Boolean.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified label is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


OptionButton.Locked Property (Access)

 Copy code hover
[image]

OptionButton.Locked Property (Access)
See also Send feedback

Published: July 16, 2012

The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.

Syntax

expression .Locked

expression A variable that represents an OptionButton object.

Remarks

The default setting of the Locked property is True. This setting allows editing, adding, and deleting data.

Use the Locked property to protect data in a field by making it read-only. For example, you might want a control to only display information without allowing editing, or you might want to lock a control until a specific condition is met.

Example

The following example toggles the Enabled property of a command button and the Enabled and Locked properties of a control, depending on the type of employee displayed in the current record. If the employee is a manager, then the SalaryDetails button is enabled and the PersonalInfo control is unlocked and enabled.

VBA Copy code Copy code
Sub Form_Current()
 If Me!EmployeeType = "Manager" Then
 Me!SalaryDetails.Enabled = True
 Me!PersonalInfo.Enabled = True
 Me!PersonalInfo.Locked = False
 Else
 Me!SalaryDetails.Enabled = False
 Me!PersonalInfo.Enabled = False
 Me!PersonalInfo.Locked = True
 End If
End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Failure to load a DLL. (Error 3462)

 Copy code hover
[image]

Failure to load a DLL. (Error 3462)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


Report.CloseButton Property (Access)

 Copy code hover
[image]

Report.CloseButton Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether the Close button on a form is enabled. Read/write Boolean.

Syntax

expression .CloseButton

expression A variable that represents a Report object.

Remarks

The CloseButton property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) The Close button is enabled.
No | False | The Close button is disabled and the Close command isn't available on the Control menu.

You can set the CloseButton property only in form Design view.

If you set the CloseButton property to No, the Close button remains visible but appears dimmed (grayed), and you must provide some other way to close the form — for example, a command button or custom menu command that runs a macro or event procedure that closes the form.

You can also close the form by pressing ALT+F4.

See also

Concepts

Report Object

Other resources

Report Object Members


Page.IsVisible Property (Access)

 Copy code hover
[image]

Page.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Syntax

expression .IsVisible

expression A variable that represents a Page object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

Page Object

Other resources

Page Object Members


The disk drive you are attempting to access is unreadable. (Error 3465)

 Copy code hover
[image]

The disk drive you are attempting to access is unreadable. (Error 3465)
Send feedback

If you are attempting to access a floppy disk, make sure the door to the disk drive is closed. If you are attempting to access a hard disk, the disk might have a corrupted sector.


TabControl.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

TabControl.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthLeft

expression A variable that represents a TabControl object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Relations.Append Method (DAO)

 Copy code hover
[image]

Relations.Append Method (DAO)
Send feedback

Adds a new Relation to the Relations collection.

Syntax

expression .Append(Object)

expression A variable that represents a Relations object.

Parameters

Name | Required/Optional | Data Type | Description
Object | Required | Object | An object variable that represents the field being appended to the collection.

Remarks

The appended object becomes a persistent object, stored on disk, until you delete it by using the Delete method.

The addition of a new object occurs immediately, but you should use the Refresh method on any other collections that may be affected by changes to the database structure.

If the object you're appending isn't complete (such as when you haven't appended any Field objects to a Fields collection of an Index object before it's appended to an Indexes collection) or if the properties set in one or more subordinate objects are incorrect, using the Append method causes an error. For example, if you haven't specified a field type and then try to append the Field object to the Fields collection in a TableDef object, using the Append method triggers a run-time error.


SaveToFile Method (ADO)

 Copy code hover
[image]

SaveToFile Method (ADO)
Send feedback

Saves the binary contents of a Stream to a file.

Syntax

Stream.SaveToFile FileName, SaveOptions

Parameters

  • FileName

  • A String value that contains the fully-qualified name of the file to which the contents of the Stream will be saved. You can save to any valid local location, or any location you have access to via a UNC value.

  • SaveOptions

  • A SaveOptionsEnum value that specifies whether a new file should be created by SaveToFile, if it does not already exist. Default value is adSaveCreateNotExists. With these options you can specify that an error occurs if the specified file does not exist. You can also specify that SaveToFile overwrites the current contents of an existing file.

Note Note

If you overwrite an existing file (when adSaveCreateOverwrite is set), SaveToFile truncates any bytes from the original existing file that follow the new EOS.

Remarks

SaveToFile may be used to copy the contents of a Stream object to a local file. There is no change in the contents or properties of the Stream object. The Stream object must be open before calling SaveToFile.

This method does not change the association of the Stream object to its underlying source. The Stream object will still be associated with the original URL or Record that was its source when opened.

After a SaveToFile operation, the current position (Position) in the stream is set to the beginning of the stream (0).


Reserved error

 Copy code hover
[image]

Reserved error <Item>; there is no message for this error. (Error 3000)
Send feedback

An unexpected error occurred. The specified code identifies the conditions under which this error can occur. Please contact Microsoft Product Support Services for more information.


How to: Filter a view by using a macro in an Access 2013 app

 Copy code hover
[image]

How to: Filter a view by using a macro in an Access 2013 app
Send feedback

Learn how to filter a view in an Access app by using the RequeryRecords macro action and a data macro.

Applies to:

In this article
Introduction
Prerequisites for building an app with Access
Create the app
Plan the customizations
Customize the app
Conclusion
Additional resources

Related videos
Watch the How to: Filter a view in access using a data macro video

Introduction

The default list view in an Access app enables you to filter the issues on values that are contained in the fields. There may be instances where you'd like to filter a view based on a set of conditions instead of by matching a value. To do that you must create a macro. This article shows you how to create a macro that filter a view to display tasks that are past due or due in the next 7 days.

Prerequisites for building an app with Access

To follow the steps in this example, you need:

  • Access 2013

  • A SharePoint 2013 development environment

Note Note

  • For more information about setting up your SharePoint development environment, see Start: Set up the development environment for SharePoint 2013.

  • For more information about obtaining Access 2013 and SharePoint 2013, see Downloads.

Create the app

Suppose you want to create an Access app that tracks tasks for your business. Before you start creating the tables and view, you should search for a schema template.

To create the task tracking app

  1. Open Access and choose Custom web app.

  2. Enter a name and the web location for your app. You can also choose a location from the Locations list and choose Create.

  3. Type tasks into the Search box and then press ENTER.

    A list of templates that might be useful for tracking tasks is displayed in Figure 1.

    Figure 1. Templates that match the search for tasks

    Templates that match the search for issues

  4. Choose Tasks.

Access creates a set of tables and views.

Enter several sample tasks and employees in your app. To do this, choose Launch App to open the app in your web browser. Enter a value in the Due Date field for each task. Return to Access when you're done.

Plan the customizations

You now have an app that contains several tasks. The default view enables you to search for any tasks using items that are stored in the fields displayed in the view. For example, you can search for high-priority issues or issues in progress. Suppose you want to prioritize your work by displaying active issues that are due in the coming week. To do this, you should create a user interface (UI) macro.

The UI macro command that you can use to filter the view is the RequeryRecords Macro Action (Access 2013 custom web app). The RequeryRecords macro action filters the view based on the Where argument, which is provided in the form of a SQL WHERE clause. To filter the view, you must supply several facts in a specific format to filter the view.

The relevant facts are:

  • The field or fields to compare

  • How to refer to today's date

  • How to refer to a particular day relative to today's date

  • How to determine which on tasks are in progress

The Due Date field provides information about when a task is due. The Status field provides status information about each task. To refer to a field in a macro, use the format [TableName].[FieldName]. Use [Tasks].[Due Date] to refer to the Due Date field and [Tasks].[Status] to refer to the Status field.

The Today Function (Access 2013 custom web app) function returns today's date. The DateAdd Function (Access 2013 custom web app) function can be used to calculate a date that's a certain number of days after a specified date.

The Status field contains several possible values. A value of Completed indicates that the task is no longer active.

These facts can be combined into the following SQL WHERE clause.

SQL Copy code Copy code
[Tasks].[Due Date]<DateAdd(Day,7,Today()) AND [Tasks].[Status]<>"Completed"

This SQL WHERE clause is used in the macro to filter the view to display active issues that are due in the next 7 days or are past due.

To run the UI macro, it must be attached to an item or an event that occurs in the view. The Action Bar is a convenient place to add a custom command to the view. The Action Bar is a customizable toolbar that appears at the top of each view. By default, the Action Bar contains buttons to add, edit, save, delete, and cancel edits. You can add buttons that perform custom actions, such as filtering the view.

If the view contains records that meet the specified criteria, then RequeryRecords filters the view. However, if the view doesn't contain any records that meet the criteria, than a new, blank record is displayed. If you don't want a blank record to be displayed if no tasks are due in the next week, then you must find a method to check the tasks before you call the RequeryRecords macro action. To do this, create a data macro to check for records that meet the criteria.

The UI macro will call the data macro, which will try to find a task that's due in the next week. If the data macro finds the task then customize the app.

Customize the app

Now that you've determined the customizations, implement them. The data macro should be created first. Some data macros are attached directly to tables. However, this data macro is a stand-alone data macro.

To create the data macro

  1. Open the app in Access.

  2. In the Create group, choose Advanced, and then choose Data Macro.

    A blank data macro is opened in macro Design View.

  3. From the Add New Action list box, choose LookupRecord.

  4. In the Look Up A Record In list box, choose Tasks.

  5. In the Where Condition box, enter [Tasks].[Due Date]<DateAdd(Day,7,Today()) AND [Tasks].[Status]<>"Completed".

  6. Choose SetReturnVar from the Add New Action list box.

    Note Note

    You'll see two Add New Action list boxes, one within the LookupRecord block, and another outside the LookupRecord block. You should choose the Add New Action list box within the LookupRecord block, as shown in Figure 1.
    Figure 1. Add New Action list box

    Add New Action dropdown

  7. In the Name box, enter TaskFound.

  8. In the Expression box, enter "Yes".

  9. Choose Save. Enter TasksDueSoon in the Macro Name box and then choose OK.

    The macro should resemble the macro shown in Figure 2.

    Figure 2. TasksDueSoon data macro

    TasksDueSoon data macro

  10. Close macro Design View.

Now, we're ready to add a custom button to the Action Bar.

To add a custom button to the Action Bar

  1. Choose the Tasks table. This chooses the Tasks List form.

  2. In the View selector, choose List, choose the Settings/Action icon, and then choose Edit.

    The view is opened in Design View.

  3. Now, we're ready to add a custom button to the Action Bar. To do this, choose Add custom action as shown in Figure 3.

    Figure 3. Add custom action button

    Add custom action button

    The new action is displayed as a button with a star icon as shown in Figure 4.

    Figure 4. New Action Bar button

    New Action Bar button

  4. Choose the custom Action Bar Button, and then choose the Data icon.

    The Data dialog box appears.

  5. In the Control Name box, enter FilterTasks.

  6. In the Tooltip box, enter Display tasks past due or due in the next week.

Now, we're ready to create the UI macro that will filter the view.

To create the UI macro to filter the view

  1. In the Data dialog box, choose On Click as shown in Figure 5.

    Figure 5. Data dialog box

    Data dialog box

    A blank UI macro is opened in macro Design View.

  2. From the Add New Action list box, choose RunDataMacro.

  3. In the Macro Name box, enter TasksDueSoon.

    In the SetLocalVar box, enter FilterRecords.

    The RunDataMacro action calls the TasksDueSoon data macro we created earlier and stores its result in a variable named FilterRecords.

  4. From the Add New Action list box, choose If.

  5. In the If box, enter [FilterRecords]="Yes".

  6. From the Add New Action list box, choose RequeryRecords.

    Note Note

    You'll see two Add New Action list boxes, one within the If block, and another outside the If block. You should choose the Add New Action list box within the If block, as shown in Figure 6.
    Figure 6. Add New Action list box

    Add New Action dropdown

  7. In the Where box, enter [Tasks].[Due Date]<DateAdd(Day,7,Today()) AND [Tasks].[Status]<>"Completed".

  8. In the Order By box, enter [Due Date].

  9. Choose the Add Else link that appears to the right side of the Add New Action box as shown in Figure 7.

    Figure 7. Add Else link

    Add Else link

    An Else clause is added to the If block.

  10. From the Add New Action list box, choose MessageBox.

  11. In the Message box, enter No tasks are overdue or due in the next 7 days!.

  12. Choose Save.

    The macro should resemble the macro shown in Figure 8.

    Figure 8. UI macro to filter the view

    UI macro to filter the view

  13. Close macro Design View.

At this point, we've created the UI macro that filters the Tasks List view to display the urgent tasks. It wouldn't be polite to leave the view in a filtered state without providing a method to remove the filter. To do this, add another Action Bar button and UI Macro.

To add an Action Bar Button to remove the filter

  1. Choose Add custom action.

    The new action is displayed as a button with a star icon

  2. Choose the custom Action Bar button, and then choose the Data icon.

    The Data dialog box appears.

  3. In the Control Name box, enter RemoveFilter.

  4. In the Tooltip box, enter Remove all filter applied to the view.

Now, we're ready to create the UI macro that will remove the filter form the view.

To create the UI macro to remove the filter from the view

  1. In the Data dialog box, choose On Click.

    A blank UI macro is opened in macro Design View.

  2. From the Add New Action list box, choose RequeryRecords.

    This time, we'll leave the Where and Order By boxes empty. Then the RequeryRecords action is called without any parameters, all filters are removed from the view.

  3. Choose Save.

  4. Close macro Design View.

  5. Close the Tasks List view. Choose Yes when you are prompted to save your changes.

Now, we're ready to text the customization. Choose Launch App to open the app in your web browser and then choose the custom FilterTasks Action Bar button. Any tasks past due or due in the next 7 days are displayed. A message is displayed if the app contains no urgent tasks.

Conclusion

You can use the RequeryRecords macro action in a UI macro to filter the view based on the criteria that you choose. Depending on the behavior that you want, you may want to create a data macro to verify that a record meets the criteria before you use the RequeryRecords macro action.

Additional resources

  • What's new for Access 2013 developers


Label.LeftPadding Property (Access)

 Copy code hover
[image]

Label.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the label and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .LeftPadding

expression A variable that represents a Label object.

See also

Concepts

Label Object

Other resources

Label Object Members


HAVING clause

 Copy code hover
[image]

HAVING clause <name> without grouping or aggregation. (Error 3091)
Send feedback

This error occurs when the query evaluates the identifiers in the SELECT statement. The error occurs because a GROUP BY clause is not specified before the HAVING clause or because the column referenced in the HAVING clause is not in an AGGREGATE function. For example this error would occur with SELECT col1 FROM table1 HAVING col1 > 20. If the statement was changed to SELECT col1 FROM table1 GROUP BY col1 HAVING col1 > 20, then the statement would be valid. Alternatively, the following would be valid SELECT col1, count(col2) FROM table1 GROUP BY col1 HAVING count(col1) > 20.


MaxRecords Property Example (VJ++)

 Copy code hover
[image]

MaxRecords Property Example (VJ++)
Send feedback

This example uses the MaxRecords property to open a Recordset containing the 10 most expensive titles in the Titles table.

Copy code Copy code

// BeingMaxRecordsJ
import java.io.*;
import com.ms.wfc.data.*;

public class MaxRecordsX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 MaxRecordsX();
 System.exit(0);
 }
 // MaxRecordsX Function

 static void MaxRecordsX()
 {
 // Define ADO Objects
 Recordset rstTemp = null;

 try
 {
 // Declarations
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));

 // Open recordset containing the 10 most expensive
 // titles in the Titles table.
 String strCnn = " Provider='sqloledb';Data Source='MySqlServer';"+
 " Initial Catalog='Pubs';Integrated Security='SSPI';";
 rstTemp = new Recordset();
 rstTemp.setMaxRecords(10);
 rstTemp.open("select title,price from Titles" +
 " order by price desc", strCnn,AdoEnums.CursorType.FORWARDONLY,
 AdoEnums.LockType.READONLY, AdoEnums.CommandType.TEXT);

 // Display the contents of the recordset.
 System.out.println("Top Ten Titles by Price:\n");
 while (!rstTemp.getEOF())
 {
 System.out.println(" "+ rstTemp.getField("title").getString() +
 " - " + rstTemp.getField("Price").getString());
 rstTemp.moveNext();
 }

 System.out.println("\n\nPress <Enter> to continue..");
 in.readLine();
 }

 catch(AdoException ae)
 {
 // Notify the user of any errors that result from ADO.

 // As passing a connection, check for null pointer first.
 if (rstTemp!=null)
 {
 PrintProviderError(rstTemp.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getLocalizedMessage());
 }
 }

 // System read requires this catch.
 catch(java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstTemp != null)
 if (rstTemp.getState() == 1)
 rstTemp.close();
 }
}
 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndMaxRecordsJ


Printer.BottomMargin Property (Access)

 Copy code hover
[image]

Printer.BottomMargin Property (Access)
See also Send feedback

Published: July 16, 2012

Along with the TopMargin, RightMargin, and LeftMargin properties, specifies the margins for a printed page. Read/write Long.

Syntax

expression .BottomMargin

expression A variable that represents a Printer object.

See also

Concepts

Printer Object

Other resources

Printer Object Members


Relation.Attributes Property (DAO)

 Copy code hover
[image]

Relation.Attributes Property (DAO)
Send feedback

Sets or returns a value that indicates one or more characteristics of a Relation object. Read/write Long.

Syntax

expression .Attributes

expression A variable that represents a Relation object.

Remarks

For an object not yet appended to a collection, this property is read/write.

Example

This example displays the Attributes property for Field, Relation, and TableDef objects in the Northwind database.

Copy code Copy code
Sub AttributesX()

 Dim dbsNorthwind As Database
 Dim fldLoop As Field
 Dim relLoop As Relation
 Dim tdfloop As TableDef

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind

 ' Display the attributes of a TableDef object's
 ' fields.
 Debug.Print "Attributes of fields in " & _
 .TableDefs(0).Name & " table:"
 For Each fldLoop In .TableDefs(0).Fields
 Debug.Print " " & fldLoop.Name & " = " & _
 fldLoop.Attributes
 Next fldLoop

 ' Display the attributes of the Northwind database's
 ' relations.
 Debug.Print "Attributes of relations in " & _
 .Name & ":"
 For Each relLoop In .Relations
 Debug.Print " " & relLoop.Name & " = " & _
 relLoop.Attributes
 Next relLoop

 ' Display the attributes of the Northwind database's
 ' tables.
 Debug.Print "Attributes of tables in " & .Name & ":"
 For Each tdfloop In .TableDefs
 Debug.Print " " & tdfloop.Name & " = " & _
 tdfloop.Attributes
 Next tdfloop

 .Close
 End With

End Sub


ListBox.Selected Property (Access)

 Copy code hover
[image]

ListBox.Selected Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Selected property in Visual Basic to determine if an item in a list box is selected. Read/write Long.

Syntax

expression .Selected(lRow)

expression A variable that represents a ListBox object.

Parameters

Name | Required/Optional | Data Type | Description
lRow | Required | Long | The item in the list box. The first item is represented by a zero (0), the second by a one (1), and so on.

Remarks

The Selected property is a zero-based array that contains the selected state of each item in a list box.

Setting | Description
True | The list box item is selected.
False | The list box item isn't selected.

This property is available only at run time.

When a list box control's MultiSelect property is set to None, only one item can have its Selected property set to True. When a list box control's MultiSelect property is set to Simple or Extended, any or all of the items can have their Selected property set to True. A multiple-selection list box bound to a field will always have a Value property equal to Null. You use the Selected property or the ItemsSelected collection to retrieve information about which items are selected.

You can use the Selected property to select items in a list box by using Visual Basic. For example, the following expression selects the fifth item in the list:

VBA Copy code Copy code
Me!Listbox.Selected(4) = True

Example

The following example uses the Selected property to move selected items in the lstSource list box to the lstDestination list box. The lstDestination list box's RowSourceType property is set to Value List and the control's RowSource property is constructed from all the selected items in the lstSource control. The lstSource list box's MultiSelect property is set to Extended. The CopySelected( ) procedure is called from the cmdCopyItem command button.

VBA Copy code Copy code
Private Sub cmdCopyItem_Click()
 CopySelected Me
End Sub

Public Sub CopySelected(ByRef frm As Form)

 Dim ctlSource As Control
 Dim ctlDest As Control
 Dim strItems As String
 Dim intCurrentRow As Integer

 Set ctlSource = frm!lstSource
 Set ctlDest = frm!lstDestination

 For intCurrentRow = 0 To ctlSource.ListCount - 1
 If ctlSource.Selected(intCurrentRow) Then
 strItems = strItems & ctlSource.Column(0, _
 intCurrentRow) & ";"
 End If
 Next intCurrentRow

 ' Reset destination control's RowSource property.
 ctlDest.RowSource = ""
 ctlDest.RowSource = strItems

 Set ctlSource = Nothing
 Set ctlDest = Nothing

End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


HelloData Details

 Copy code hover
[image]

HelloData Details
Send feedback

The HelloData application steps through the basic operations of a typical ADO application: getting, examining, editing, and updating data. When you start the application, click the first button, Get Data. This will run the GetData() subroutine.

GetData

GetData places a valid connection string into a module-level variable, m_sConnStr. For more information about connection strings, see Creating the Connection String.

Assign an error handler using a Visual Basic OnError statement. For more information about error handling in ADO, see Chapter 6: Error Handling. A new Connection object is created, and the CursorLocation property is set to adUseClient because the HelloData example creates a disconnected Recordset. This means that once the data has been fetched from the data source, the physical connection with the data source is broken, but you can still work with the data that is cached locally in your Recordset object.

After the connection has been opened, assign a SQL string to a variable (sSQL). Then instantiate a new Recordset object, m_oRecordset1 . In the next line of code, open the Recordset over the existing Connection, passing in . In the next line of code, open the Recordset over the existing Connection, passing in sSQL as the source of the Recordset. You assist ADO in making the determination that the SQL string you have passed as the source for the Recordset is a textual definition of a command by passing adCmdText in the final argument to the Recordset Open method. This line also sets the LockType and CursorType associated with the Recordset.

The next line of code sets the MarshalOptions property equal to adMarshalModifiedOnly. MarshalOptions indicates which records should be marshaled to the middle tier (or Web server). For more information about marshaling, see the COM documentation. When using adMarshalModifiedOnly with a client-side cursor (CursorLocation = adUseClient), only records that have been modified on the client are written back to the middle tier. Setting MarshalOptions to adMarshalModifiedOnly can improve performance because fewer rows are marshaled.

Next, disconnect the Recordset by setting its ActiveConnection property equal to Nothing. For more information, see Disconnecting and Reconnecting the Recordset in Chapter 5: Updating and Persisting Data.

Close the connection to the data source and destroy the existing Connection object, thereby releasing the resources it consumed.

The final step is to set the Recordset as the DataSource for the Microsoft DataBound Grid Control on the form so that you can easily display the data from the Recordset on the form.

Click the second button, Examine Data. This runs the ExamineData subroutine.

ExamineData

ExamineData uses various methods and properties of the Recordset object to display information about the data in the Recordset. It reports the number of records by using the RecordCount property. It loops through the Recordset and prints the value of the AbsolutePosition property in the display text box on the form. Also while in the loop, the value of the Bookmark property for the third record is placed into a variant variable, vBookmark, for later use.

The routine navigates directly back to the third record using the bookmark variable that it stored earlier. The routine calls the WalkFields subroutine, which loops through the Fields collection of the Recordset and displays details about each Field in the collection.

Finally, ExamineData uses the Filter property of the Recordset to screen for only those records with a CategoryId equal to 2. The result of applying this filter is immediately visible in the display grid on the form.

For more information about the functionality shown in the ExamineData subroutine, see Chapter 3: Examining Data.

Next, click the third button, Edit Data. This will run the EditData subroutine.

EditData

When the code enters the EditData subroutine, the Recordset is still filtered on CategoryId equal to 2, so only those items that meet the filter criteria are visible. It first loops through the Recordset and increases the price of each visible item in the Recordset by 10 percent. The value of the Price field is changed by setting the Value property for that field equal to a new, valid amount.

Remember that the Recordset is disconnected from the data source. The changes made in EditData are made only to the locally cached copy of the data. For more information, see Chapter 4: Editing Data.

The changes will not be made on the data source until you click the fourth button, Update Data. This will run the UpdateData subroutine.

UpdateData

UpdateData first removes the filter that has been applied to the Recordset. The code removes and resets as the DataSource for the Microsoft Bound DataGrid on the form so that the unfiltered Recordset appears in the grid.

The code then checks to see whether you can move backward in the Recordset by using the Supports method with the adMovePrevious argument.

The routine moves to the first record using the MoveFirst method and displays the field's original and current values, using the OriginalValue and Value properties of the Field object. These properties, along with the UnderlyingValue property (not used here), are discussed in Chapter 5: Updating and Persisting Data.

Next, a new Connection object is created and used to reestablish a connection to the data source. You reconnect the Recordset to the data source by setting the new Connection as the ActiveConnection for the Recordset. To send the updates to the server, the code calls UpdateBatch on the Recordset.

If the batch update succeeds, a module-level flag variable, , is set to True. This will remind you later to clean up all changes made to the database.

Finally, the code moves back to the first record in the Recordset and displays the original and current values. The values are the same after the call to UpdateBatch.

For more detailed information about updating data, including what to do when data on the server changes while your Recordset is disconnected, see Chapter 5: Updating and Persisting Data.

Form_Unload

The Form_Unload subroutine is important for several reasons. First, because this is a sample application, Form_Unload cleans up the changes made to the database before the application exits. Second, the code shows how a command can be executed directly from an open Connection object using the Execute method. Finally, it shows an example of executing a non-row-returning query (an UPDATE query) against the data source.


Accessing Rows in a Hierarchical Recordset

 Copy code hover
[image]

Accessing Rows in a Hierarchical Recordset
Send feedback

The following example shows the steps necessary to access rows in a hierarchical Recordset:

  1. Recordset objects from the authors and titleauthor tables are related by author ID.

  2. The outer loop displays each author's first and last name, state, and identification.

  3. The appended Recordset for each row is retrieved from the Fields collection and assigned to rstTitleAuthor.

  4. The inner loop displays four fields from each row in the appended Recordset.

(The StayInSync property is set to FALSE for purposes of illustration — so you can see the chapter change explicitly in each iteration of the outer loop. However, the example will be more efficient if the assignment in step 3 is moved before the first line in step 2, so that the assignment is performed only once. Then set the StayInSync property to TRUE, so that rstTitleAuthor will implicitly and automatically change to the corresponding chapter whenever rst moves to a new row.)

Example

Copy code Copy code

Sub datashape()
 Dim cnn As New ADODB.Connection
 Dim rst As New ADODB.Recordset
 Dim rstTitleAuthor As New ADODB.Recordset

 cnn.Provider = "MSDataShape"
 cnn.Open "Data Provider=MSDASQL;" & _
 "Data Source=SRV;" & _
 "User Id=MyUserName;Password=MyPassword;Database=Pubs"
' STEP 1
 rst.StayInSync = FALSE
 rst.Open "SHAPE {select * from authors} " & _
 "APPEND ({select * from titleauthor} " & _
 "RELATE au_id TO au_id) AS chapTitleAuthor", _
 cnn
' STEP 2
 While Not rst.EOF
 Debug.Print rst("au_fname"), rst("au_lname"), _
 rst("state"), rst("au_id")
' STEP 3
 Set rstTitleAuthor = rst("chapTitleAuthor").Value
' STEP 4
 While Not rstTitleAuthor.EOF
 Debug.Print rstTitleAuthor(0), rstTitleAuthor(1), _
 rstTitleAuthor(2), rstTitleAuthor(3)
 rstTitleAuthor.MoveNext
 Wend
 rst.MoveNext
 Wend
End Sub


Invalid Database object. (Error 3263)

 Copy code hover
[image]

Invalid Database object. (Error 3263)
Send feedback

The Database object specified is not the result of the OpenDatabase method, or it has been modified and is no longer valid.


CommandButton.BackTint Property (Access)

 Copy code hover
[image]

CommandButton.BackTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackTint

expression A variable that represents a CommandButton object.

Remarks

The BackTint property contains a numeric expression that can be used to lighten the theme color in the BackColor property. The default value of the BackTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackTint=25

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Line.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

Line.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents a Line object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.BorderThemeColorIndex=2

See also

Concepts

Line Object

Other resources

Line Object Members


ObjectFrame.Object Property (Access)

 Copy code hover
[image]

ObjectFrame.Object Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Object property in Visual Basic to return a reference to the ActiveX object that is associated with a linked or embedded OLE object in a control. By using this reference, you can access the properties or invoke the methods of the OLE object. Read-only Object.

Syntax

expression .Object

expression A variable that represents an ObjectFrame object.

Remarks

The Object property returns a reference to an ActiveX object. You can use the Set statement to assign this ActiveX object to an object variable. The type of object reference returned depends on which application created the OLE object.

When you embed or link an OLE object in a Microsoft Access form, you can set properties that determine the type of object and the behavior of the container control. However, you can't directly set or read the OLE object's properties or apply its methods, as you can when performing Automation. The Object property returns a reference to an Automation object that represents the linked or embedded OLE object. By using this reference, you can change the OLE object by setting or reading its properties or applying its methods. For example, Microsoft Excel is an COM component that supports Automation. If you've embedded a Microsoft Excel worksheet in a Microsoft Access form, you can use the Object property to set a reference to the Worksheet object associated with that worksheet. You can then use any of the properties and methods of the Worksheet object.

For information on which properties and methods an ActiveX object supports, see the documentation for the application that was used to create the OLE object.

Example

The following example uses the Object property of an unbound object frame named OLE1. Customer name and address information is inserted in an embedded Microsoft Word document formatted as a form letter with placeholders for the name and address information and boilerplate text in the body of the letter. The procedure replaces the placeholder information for each record and prints the form letter. It doesn't save copies of the printed form letter.

VBA Copy code Copy code
Sub PrintFormLetter_Click()
 Dim objWord As Object
 Dim strCustomer As String, strAddress As String
 Dim strCity As String, strRegion As String

 ' Assign object property of control to variable.
 Set objWord = Me!OLE1.Object.Application.Wordbasic
 ' Assign customer address to variables.
 strCustomer = Me!CompanyName
 strAddress = Me!Address
 strCity = Me!City & ", "
 If Not IsNull(Me!Region) Then
 strRegion = Me!Region
 Else
 strRegion = Me!Country
 End If
 ' Activate ActiveX control.
 Me!OLE1.Action = acOLEActivate
 With objWord
 .StartOfDocument
 ' Go to first placeholder.
 .LineDown 2
 ' Highlight placeholder text.
 .EndOfLine 1
 ' Insert customer name.
 .Insert strCustomer
 ' Go to next placeholder.
 .LineDown
 .StartOfLine
 ' Highlight placeholder text.
 .EndOfLine 1
 ' Insert address.
 .Insert strAddress
 ' Go to last placeholder.
 .LineDown
 .StartOfLine
 ' Highlight placeholder text.
 .EndOfLine 1
 ' Insert City and Region.
 .Insert strCity & strRegion
 .FilePrint
 .FileClose
 End With
 Set objWord = Nothing
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Attachment.Application Property (Access)

 Copy code hover
[image]

Attachment.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .

expression A variable that represents an Attachment object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Could not read definitions; no read definitions permission for table or query

 Copy code hover
[image]

Could not read definitions; no read definitions permission for table or query <name>. (Error 3110)
Send feedback

You must have read definitions permission for the specified table or query to read its definition. To change your permission assignments, see your system administrator or the table or query's creator.


EmptyCell Methods (Access)

 Copy code hover
[image]

EmptyCell Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.


You cannot change the data master attribute for the replica set. It allows data changes only at the Design Master. (Error 3594)

 Copy code hover
[image]

You cannot change the data master attribute for the replica set. It allows data changes only at the Design Master. (Error 3594)
Send feedback

Whether a replicated database allows users to change data only at the Design Master or at all replicas is determined when the database is first converted into a Design Master. After the database has been converted, the single or multiple data master attribute cannot be changed.


Missing ), ], or Item. (Error 2436)

 Copy code hover
[image]

Missing ), ], or Item. (Error 2436)
Send feedback

You entered an expression that is missing a closing parenthesis, bracket, or vertical bar. Check the expression to make sure you entered it correctly.


Record(s) cannot be read; no read permission on

 Copy code hover
[image]

Record(s) cannot be read; no read permission on <name>. (Error 3112)
Send feedback

You must have read permission for the specified table or query to view its data. To change your permission assignments, see your system administrator or the table or query's creator.


Workspace.OpenDatabase Method (DAO)

 Copy code hover
[image]

Workspace.OpenDatabase Method (DAO)
Send feedback

Opens a specified database in a Workspace object and returns a reference to the Database object that represents it.

Syntax

expression .OpenDatabase(Name, Options, ReadOnly, Connect)

expression A variable that represents a Workspace object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Required | String | the name of an existing Microsoft Access database engine database file, or the data source name (DSN) of an ODBC data source. See the Name property for more information about setting this value.
Options | Optional | Variant | Sets various options for the database, as specified in Remarks.
ReadOnly | Optional | Variant | True if you want to open the database with read-only access, or False (default) if you want to open the database with read/write access.
Connect | Optional | Variant | Specifies various connection information, including passwords.

Return Value

Database

Remarks

You can use the following values for the options argument.

Setting | Description
True | Opens the database in exclusive mode.
False | (Default) Opens the database in shared mode.

When you open a database, it is automatically added to the Databases collection.

Some considerations apply when you use dbname:

  • If it refers to a database that is already open for access by another user, an error occurs.

  • If it doesn't refer to an existing database or valid ODBC data source name, an error occurs.

  • If it's a zero-length string ("") and connect is "ODBC;" , a dialog box listing all registered ODBC data source names is displayed so the user can select a database.

To close a database, and thus remove the Database object from the Databases collection, use the Close method on the object.

Note Note

When you access a Microsoft access database engine-connected ODBC data source, you can improve your application's performance by opening a Database object connected to the ODBC data source, rather than by linking individual TableDef objects to specific tables in the ODBC data source.

Example

This example uses the OpenDatabase method to open one Microsoft Access database and two Microsoft Access database engine-connected ODBC databases.

VBA Copy code Copy code
Sub OpenDatabaseX()

 Dim wrkAcc As Workspace
 Dim dbsNorthwind As Database
 Dim dbsPubs As Database
 Dim dbsPubs2 As Database
 Dim dbsLoop As Database
 Dim prpLoop As Property

 ' Create Microsoft Access Workspace object.
 Set wrkAcc = CreateWorkspace("", "admin", "", dbUseJet)

 ' Open Database object from saved Microsoft Access database
 ' for exclusive use.
 MsgBox "Opening Northwind..."
 Set dbsNorthwind = wrkAcc.OpenDatabase("Northwind.mdb", _
 True)

 ' Open read-only Database object based on information in
 ' the connect string.
 MsgBox "Opening pubs..."

 ' Note: The DSN referenced below must be set to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set dbsPubs = wrkAcc.OpenDatabase("Publishers", _
 dbDriverNoPrompt, True, _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 ' Open read-only Database object by entering only the
 ' missing information in the ODBC Driver Manager dialog
 ' box.
 MsgBox "Opening second copy of pubs..."
 Set dbsPubs2 = wrkAcc.OpenDatabase("Publishers", _
 dbDriverCompleteRequired, True, _
 "ODBC;DATABASE=pubs;DSN=Publishers;")

 ' Enumerate the Databases collection.
 For Each dbsLoop In wrkAcc.Databases
 Debug.Print "Database properties for " & _
 dbsLoop.Name & ":"

 On Error Resume Next
 ' Enumerate the Properties collection of each Database
 ' object.
 For Each prpLoop In dbsLoop.Properties
 If prpLoop.Name = "Connection" Then
 ' Property actually returns a Connection object.
 Debug.Print " Connection[.Name] = " & _
 dbsLoop.Connection.Name
 Else
 Debug.Print " " & prpLoop.Name & " = " & _
 prpLoop
 End If
 Next prpLoop
 On Error GoTo 0

 Next dbsLoop

 dbsNorthwind.Close
 dbsPubs.Close
 dbsPubs2.Close
 wrkAcc.Close

End Sub


Image.VerticalAnchor Property (Access)

 Copy code hover
[image]

Image.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified image is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .VerticalAnchor

expression A variable that represents an Image object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

Image Object

Other resources

Image Object Members


Section.InSelection Property (Access)

 Copy code hover
[image]

Section.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents a Section object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

Section Object

Other resources

Section Object Members


CurrentProject.IsWeb Property (Access)

 Copy code hover
[image]

CurrentProject.IsWeb Property (Access)
See also Send feedback

Published: July 16, 2012

Gets whether the database is a Web database. Read-only Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .IsWeb

expression A variable that represents a CurrentProject object.

Remarks

The IsWeb property contains True if the database is a Web database.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


Error when evaluating the partial filter expression. (Error 3588)

 Copy code hover
[image]

Error when evaluating the partial filter expression. (Error 3588)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


SubForm.Name Property (Access)

 Copy code hover
[image]

SubForm.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a SubForm object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Properties Object Reference (DAO)

 Copy code hover
[image]

Properties Object Reference (DAO)
Send feedback

In this section

  • Properties Collection (DAO)

  • Properties Members (DAO)

  • Properties Properties (DAO)

  • Properties Methods (DAO)


ObjectFrame Methods (Access)

 Copy code hover
[image]

ObjectFrame Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.


Section.KeepTogether Property (Access)

 Copy code hover
[image]

Section.KeepTogether Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the KeepTogether property for a section to print a form or report section all on one page. For example, you might have a group of related information that you don't want printed across two pages. The KeepTogether property applies only to form and report sections (except page headers and page footers). Read/write Boolean.

Syntax

expression .KeepTogether

expression A variable that represents a Section object.

Remarks

The KeepTogether property for a section uses the following settings.

Setting | Visual Basic | Description
Yes | True | Microsoft Access starts printing the section at the top of the next page if it can't print the entire section on the current page.
No | False | (Default) Microsoft Access prints as much of the section as possible on the current page and prints the rest on the next page.

You can set the KeepTogether property for a section only in form Design view or report Design view.

Usually, when a page break occurs while a section is being printed, Microsoft Access continues printing the section on the next page. By using the section's KeepTogether property, you can print the section all on one page. If a section is longer than one page, Microsoft Access starts printing it on the next page and continues on the following page.

If the KeepTogether property for a group is set to Whole Group or With First Detail and the KeepTogether property for a section is set to No, the KeepTogether property setting for the section is ignored.

See also

Concepts

Section Object

Other resources

Section Object Members


Rectangle.OnMouseUp Property (Access)

 Copy code hover
[image]

Rectangle.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Syntax

expression .OnMouseUp

expression A variable that represents a Rectangle object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


Form.KeyUp Event (Access)

 Copy code hover
[image]

Form.KeyUp Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyUp(KeyCode, Shift)

expression A variable that represents a Form object.

Parameters

Name

Required/Optional

Data Type

Description

KeyCode

Required

Integer

A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the intrinsic constants shown in the Object Browser. You can prevent an object from receiving a keystroke by setting KeyCode to 0.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys at the time of the event. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

Remarks

To run a macro or event procedure when these events occur, set the OnKeyUp property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyUp event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyUp event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

See also

Concepts

Form Object

Other resources

Form Object Members


OptionButton.AfterUpdate Event (Access)

 Copy code hover
[image]

OptionButton.AfterUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The AfterUpdate event occurs after changed data in a control or record is updated.

Syntax

expression .AfterUpdate

expression A variable that represents an OptionButton object.

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's AfterUpdate event does occur.

To run a macro or event procedure when this event occurs, set the AfterUpdate property to the name of the macro or to [Event Procedure].

This event does not apply to option buttons, check boxes, or toggle buttons in an option group. It applies only to the option group itself.

The AfterUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

AfterUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. AfterUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For bound controls, the OldValue property isn't set to the updated value until after the AfterUpdate event for the form occurs. Even if the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


 Copy code hover
[image]

<= (Less Than or Equal To) (Access 2013 custom web app)
Send feedback

Compares two expressions. When you compare non-null expressions, the result is TRUE if the left operand has a value lower than or equal to the right operand; otherwise, the result is FALSE.

Syntax

expression <= expression

expression Is any valid expression. Both expressions must have implicitly convertible data types. The conversion depends on the rules of data type precedence.

Return Type

Boolean


Application.MenuBar Property (Access)

 Copy code hover
[image]

Application.MenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies a custom menu to display for a Microsoft Access database. Read/write String.

Syntax

expression .MenuBar

expression A variable that represents an Application object.

Remarks

When opening a database in Microsoft Access 2013 that was created in an earlier version of Microsoft Access, the specified menu bar will be displayed differently depending on the curent settings of the AllowFullMenus and AllowBuiltInToolbars properties. If the AllowFullMenus and AllowBuiltInToolbars properties are set to False, the specified menu bar will replace the ribbon as the default set of commands available to the user. If the AllowFullMenus or AllowBuiltInToolbars property is set to True, then the specified menu bar is displayed on the ribbon Add-Ins tab.

See also

Concepts

Application Object

Other resources

Application Object Members


Recordset2.FindNext Method (DAO)

 Copy code hover
[image]

Recordset2.FindNext Method (DAO)
Send feedback

Locates the next record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only). .

Syntax

expression .FindNext(Criteria)

expression A variable that represents a Recordset2 object.

Parameters

Name | Required/Optional | Data Type | Description
Criteria | Required | String | A String used to locate the record. It is like the WHERE clause in an SQL statement, but without the word WHERE.

Remarks

If you want to include all the records in your search — not just those that meet a specific condition — use the Move methods to move from record to record. To locate a record in a table-type Recordset, use the Seek method.

If a record matching the criteria isn't located, the current record pointer is unknown, and the NoMatch property is set to True. If recordset contains more than one record that satisfies the criteria, FindFirst locates the first occurrence, FindNext locates the next occurrence, and so on.

Each of the Find methods begins its search from the location and in the direction specified in the following table.

Find method | Begins searching at | Search direction
FindFirst | Beginning of recordset | End of recordset
FindLast | End of recordset | Beginning of recordset
FindNext | Current record | End of recordset
FindPrevious | Current record | Beginning of recordset

Using one of the Find methods isn't the same as using a Move method, however, which simply makes the first, last, next, or previous record current without specifying a condition. You can follow a Find operation with a Move operation.

Always check the value of the NoMatch property to determine whether the Find operation has succeeded. If the search succeeds, NoMatch is False. If it fails, NoMatch is True and the current record isn't defined. In this case, you must position the current record pointer back to a valid record.

Using the Find methods with Microsoft Access database engine-connected ODBC-accessed recordsets can be inefficient. You may find that rephrasing your criteria to locate a specific record is faster, especially when working with large recordsets.

When working with Microsoft Access database engine-connected ODBC databases and large dynaset-type Recordset objects, you might discover that using the Find methods or using the Sort or Filter property is slow. To improve performance, use SQL queries with customized ORDER BY or WHERE clauses, parameter queries, or QueryDef objects that retrieve specific indexed records.

You should use the U.S. date format (month-day-year) when you search for fields containing dates, even if you're not using the U.S. version of the Microsoft Access database engine; otherwise, the data may not be found. Use the Visual Basic Format function to convert the date. For example:

VBA Copy code Copy code
rstEmployees.FindFirst "HireDate > #" _
    & Format(mydate, 'm-d-yy' ) & "#"

If criteria is composed of a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strSQL = "PRICE > " & lngPrice, and lngPrice = 125,50), an error occurs when you try to call the method. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and Microsoft Access SQL only accepts U.S. decimal characters.

Note Note

  • For best performance, the criteria should be in either the form "field = value" where field is an indexed field in the underlying base table, or "field LIKE prefix" where field is an indexed field in the underlying base table and prefix is a prefix search string (for example, "ART*" ).

  • In general, for equivalent types of searches, the Seek method provides better performance than the Find methods. This assumes that table-type Recordset objects alone can satisfy your needs.


Label.ForeColor Property (Access)

 Copy code hover
[image]

Label.ForeColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ForeColor property to specify the color for text in a control. Read/write Long.

Syntax

expression .ForeColor

expression A variable that represents a Label object.

Remarks

You can use this property for controls on forms or reports to make them easy to read or to convey a special meaning. For example, you can change the color of the text in the UnitsInStock control when its value falls below the reorder level.

You can also use this property on reports to create special visual effects when you print with a color printer. When used on a report, this property specifies the printing and drawing color for the Print , Line , and Circle methods.

The ForeColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors for text in controls.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set the Circle property only by using a macro or a Visual Basic event procedure specified in a section's OnPrint event property setting.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

Label Object

Other resources

Label Object Members


ComboBox.SelText Property (Access)

 Copy code hover
[image]

ComboBox.SelText Property (Access)
See also Send feedback

Published: July 16, 2012

The SelText property returns a string containing the selected text. Read/write String.

Syntax

expression .SelText

expression A variable that represents a ComboBox object.

Remarks

If no text is selected, the SelText property contains a Null value.

The SelText property uses a string expression that contains the text selected in the control. If the control contains selected text when this property is set, the selected text is replaced by the new SelText setting.

To set or return this property for a control, the control must have the focus. To move the focus to a control, use the SetFocus method.

Example

The following example uses two event procedures to search for text specified by a user. The text to search is set in the form's Load event procedure. The Click event procedure for the Find button (which the user clicks to start the search) prompts the user for the text to search for and selects the text in the text box if the search is successful.

VBA Copy code Copy code
Sub Form_Load()
 Dim ctlTextToSearch As Control
 Set ctlTextToSearch = Forms!Form1!TextBox1
 ctlTextToSearch.SetFocus ' SetFocus to text box.
 ctlTextToSearch.SelText = "This company places large orders " _
 & "twice a year for garlic, oregano, chilies and cumin."
End Sub

Sub Find_Click()
 Dim strSearch As String, intWhere As Integer
 Dim ctlTextToSearch As Control
 ' Get search string from user.
 With Me!Textbox1
 strSearch = InputBox("Enter text to find:")
 ' Find string in text.
 intWhere = InStr(.Value, strSearch)
 If intWhere Then
 ' If found.
 .SetFocus
 .SelStart = intWhere - 1
 .SelLength = Len(strSearch)
 Else
 ' Notify user.
 MsgBox "String not found."
 End If
 End With
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Properties Methods (DAO)

 Copy code hover
[image]

Properties Methods (DAO)
Send feedback

In this section

  • Properties.Append Method (DAO)

  • Properties.Delete Method (DAO)

  • Properties.Refresh Method (DAO)


CommandButton Events (Access)

 Copy code hover
[image]

CommandButton Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.


Connection.Updatable Property (DAO)

 Copy code hover
[image]

Connection.Updatable Property (DAO)
Send feedback

Returns a value that indicates whether you can change a DAO object. Read-only Boolean.Read-only.

Syntax

expression .Updatable

expression An expression that returns a Connection object.


CommandButton.OnKeyUp Property (Access)

 Copy code hover
[image]

CommandButton.OnKeyUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Up box in the Properties window. Read/write String.

Syntax

expression .OnKeyUp

expression A variable that represents a CommandButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyUp event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyUp

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


TabControl.ControlType Property (Access)

 Copy code hover
[image]

TabControl.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Syntax

expression .ControlType

expression A variable that represents a TabControl object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


TextBox.SetFocus Method (Access)

 Copy code hover
[image]

TextBox.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Syntax

expression .SetFocus

expression A variable that represents a TextBox object.

Return Value

Nothing

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.

Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.

Example

The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:

VBA Copy code Copy code
Forms!Employees!EmployeeID.SetFocus

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Find Method Example (VC++)

 Copy code hover
[image]

Find Method Example (VC++)
Send feedback

This example uses the Recordset object's Find method to locate and count the number of business titles in the Pubs database. The example assumes the underlying provider does not support similar functionality.

Copy code Copy code

// BeginFindCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>
#include "FindX.h"

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void FindX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 FindX();

 //Wait here for the user to see the output.
 printf("Press any key to continue...");
 getch();
 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// FindX Function //
// //
//////////////////////////////////////////////////////////

void FindX(void)
{
 HRESULT hr = S_OK;

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _ConnectionPtr pConnection = NULL;
 _RecordsetPtr pRstTitles = NULL;
 IADORecordBinding *picRs = NULL; //Interface Pointer declared.
 CTitlesRs titlers; //C++ class object

 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 // Open connection.
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
 pConnection->Open (strCnn, "", "", adConnectUnspecified);

 // Open title Table
 TESTHR(pRstTitles.CreateInstance(__uuidof(Recordset)));

 pRstTitles->Open("SELECT title_id FROM titles",
 _variant_t((IDispatch *)pConnection),
 adOpenStatic, adLockReadOnly, adCmdText);

 // The default parameters are sufficient to search forward
 // through a Recordset.

 pRstTitles->Find ("title_id LIKE 'BU%'",0,adSearchForward,"");

 //Open an IADORecordBinding interface pointer which
 //we'll use for Binding Recordset to a class
 TESTHR(pRstTitles->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 //Bind the Recordset to a C++ Class here
 TESTHR(picRs->BindToRecordset(&titlers));

 // Skip the current record to avoid finding the same
 // row repeatedly. The bookmark is redundant because Find
 // searches from the current position.
 int count = 0;

 //Continue if last find succeeded.
 while (!(pRstTitles->EndOfFile))
 {
 printf("Title ID: %s\n",titlers.lt_titleidStatus == adFldOK ?
 titlers.m_szt_titleid : "<NULL>");
 count++; //Count the last title found.

 _variant_t mark = pRstTitles->Bookmark; //Note current pos.
 pRstTitles->Find("title_id LIKE 'BU%'", 1, adSearchForward,
 mark);
 }
 printf("The number of business titles is %d\n",count);
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 PrintProviderError(pConnection);
 PrintComError(e);
 }

 // Clean up objects before exit.
 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (pRstTitles)
 if (pRstTitles->State == adStateOpen)
 pRstTitles->Close();
 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

//////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
//////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,
 (LPCSTR)pErr->Description);
 }
 }
}

//////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
//////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndFindCpp

FindX.h

Copy code Copy code

// BeginFindH
#include "icrsint.h"

//This Class extracts only titleId from Titles table.
class CTitlesRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CTitlesRs)

 // Column title_id is the 1st field in the recordset
 // from Titles table.
 ADO_VARIABLE_LENGTH_ENTRY2(1, adVarChar, m_szt_titleid,
 sizeof(m_szt_titleid), lt_titleidStatus, FALSE)

END_ADO_BINDING()

public:
 CHAR m_szt_titleid[150];
 ULONG lt_titleidStatus;
};
// EndFindH


ADO MD Collections

 Copy code hover
[image]

ADO MD Collections
Send feedback
Axes | Contains the Axis objects that define a cellset.
CubeDefs | Contains the CubeDef objects that represent a cube from a multidimensional catalog.
Dimensions | Contains the Dimension objects that make up a cube.
Hierarchies | Contains the set Hierarchy objects from a dimension.
Levels | Contains the Level objects that make up a hierarchy.
Members | Contains the Member objects from a level or a position along an axis.
Positions | Contains the Position objects that define a point on an axis.


BoundObjectFrame.StatusBarText Property (Access)

 Copy code hover
[image]

BoundObjectFrame.StatusBarText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.

Syntax

expression .StatusBarText

expression A variable that represents a BoundObjectFrame object.

Remarks

You set the StatusBarText property by using a string expression up to 255 characters long.

Note Note

The length of the text you can display in the status bar depends on your computer hardware and video display.

You can use the StatusBarText property to provide specific information about a control. For example, when a text box has the focus, a brief instruction can tell the user what kind of data to enter

Note Note

You can also use the ControlTipText property to display a ScreenTip for a control.

If you create a control by dragging a field from the field list, the value in a field's Description property is copied to the StatusBarText property.

Example

The following example sets the status bar text to be displayed when the "Address_TextBox" control in the "Mailing List" form has the focus in Form View.

VBA Copy code Copy code
Forms("Mailing List").Controls("Address_TextBox"). _
 StatusBarText = "Enter the company's mailing address."

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


MarshalOptions Property (ADO)

 Copy code hover
[image]

MarshalOptions Property (ADO)
Send feedback

Indicates which records are to be marshaled back to the server.

Settings And Return Values

Sets or returns a MarshalOptionsEnum value. The default value is adMarshalAll.

Remarks

When using a client-side Recordset, records that have been modified on the client are written back to the middle tier or Web server through a technique called marshaling, the process of packaging and sending interface method parameters across thread or process boundaries. Setting the MarshalOptions property can improve performance when modified remote data is marshaled for updating back to the middle tier or Web server.

Remote Data Service UsageThis property is used only on a client-side Recordset.


DoCmd.FindRecord Method (Access)

 Copy code hover
[image]

DoCmd.FindRecord Method (Access)
See also Send feedback

Published: July 16, 2012

The FindRecord method carries out the FindRecord action in Visual Basic.

Syntax

expression .FindRecord(FindWhat, Match, MatchCase, Search, SearchAsFormatted, OnlyCurrentField, FindFirst)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
FindWhat | Required | Variant | An expression that evaluates to text, a number, or a date. The expression contains the data to search for.
Match | Optional | AcFindMatch | A AcFindMatch constant that specifies where to search for the match. The dcefault value is acEntire.
MatchCase | Optional | Variant | Use True for a case-sensitive search and False for a search that's not case-sensitive. If you leave this argument blank, the default (False) is assumed.
Search | Optional | AcSearchDirection | an AcSearchDirection constant that specifies the direction to search. The default value is acSearchAll.
SearchAsFormatted | Optional | Variant | Use True to search for data as it's formatted and False to search for data as it's stored in the database. If you leave this argument blank, the default (False) is assumed.
OnlyCurrentField | Optional | AcFindField | A AcFindField constant that specifies whther to search all fields, or only the current field. The default value is acCurrent.
FindFirst | Optional | Variant | Use True to start the search at the first record. Use False to start the search at the record following the current record. If you leave this argument blank, the default (True) is assumed.

Remarks

When a procedure calls the FindRecord method, Access searches for the specified data in the records (the order of the search is determined by the setting of the Search argument). When Access finds the specified data, the data is selected in the record.

The FindRecord method does not return a value indicating its success or failure. To determine whether a value exists in a recordset, use the FindFirst, FindNext, FindPrevious or FindLast method of the Recordset object. These methods set the value of the NoMatch property to True if the spcified value is not found.

Example

The following example finds the first occurrence in the records of the name Smith in the current field. It doesn't find occurrences of smith or Smithson.

VBA Copy code Copy code
DoCmd.FindRecord "Smith",, True,, True

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


SmartTagProperties.Item Property (Access)

 Copy code hover
[image]

SmartTagProperties.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only SmartTagProperty.

Syntax

expression .Item(Index)

expression A variable that represents a SmartTagProperties object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

SmartTagProperties Collection

Other resources

SmartTagProperties Object Members


AbsolutePosition and CursorLocation Properties Example (JScript)

 Copy code hover
[image]

AbsolutePosition and CursorLocation Properties Example (JScript)
Send feedback

This example demonstrates how the AbsolutePosition property can track the progress of a loop that enumerates all the records of a Recordset. It uses the CursorLocation property to enable the AbsolutePosition property by setting the cursor to a client cursor. Cut and paste the following code to Notepad or another text editor, and save it as AbsolutePositionJS.asp.

Copy code Copy code

<!-- BeginAbsolutePositionJS -->
<%@LANGUAGE="JScript" %>
<%// use this meta tag instead of adojavas.inc%>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->

<html>

<head>
<title>AbsolutePosition and CursorLocation Properties Example (JScript)</title>
<style>
<!--
BODY {
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 BACKGROUND-COLOR:white;
 COLOR:black;
 }
.thead2 {
 background-color: #800000;
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 font-size: x-small;
 color: white;
 }
.tbody {
 text-align: center;
 background-color: #f7efde;
 font-family: 'Verdana','Arial','Helvetica',sans-serif;
 font-size: x-small;
 }
-->
</style>
</head>

<body>
<h1>AbsolutePosition and CursorLocation Properties Example (JScript)</h1>
<%
 // connection and recordset variables
 var strCnxn = "Provider='sqloledb';Data Source=" + Request.ServerVariables("SERVER_NAME") + ";" +
 "Initial Catalog='Northwind';Integrated Security='SSPI';";
 var rsEmployee = Server.CreateObject("ADODB.Recordset");
 // display string
 var strMessage;

 try
 {
 // Open a recordset on the Employee table using
 // a client-side cursor to enable AbsolutePosition property.
 rsEmployee.CursorLocation = adUseClient;
 rsEmployee.Open("employees", strCnxn, adOpenStatic, adLockOptimistic, adCmdTable);

 // Write beginning of table to the document.
 Response.Write('<table border="0" align="center">');
 Response.Write('<tr class="thead2">');
 Response.Write("<th>AbsolutePosition</th><th>Name</th><th>Hire Date</th></tr>");

 while (!rsEmployee.EOF)
 {
 strMessage = "";

 // Start a new table row.
 strMessage = '<tr class="tbody">';

 // First column in row contains AbsolutePosition value.
 strMessage += "<td>" + rsEmployee.AbsolutePosition + " of " + rsEmployee.RecordCount + "</td>"

 // First and last name are in first column.
 strMessage += "<td>" + rsEmployee.Fields("FirstName") + " ";
 strMessage += rsEmployee.Fields("LastName") + " " + "</td>";

 // Hire date in second column.
 strMessage += "<td>" + rsEmployee.Fields("HireDate") + "</td>";

 // End the row.
 strMessage += "</tr>";

 // Write line to document.
 Response.Write(strMessage);

 // Get next record.
 rsEmployee.MoveNext;
 }

 // Finish writing document.
 Response.Write("</table>");
 }
 catch (e)
 {
 Response.Write(e.message);
 }
 finally
 {
 // 'clean up
 if (rsEmployee.State == adStateOpen)
 rsEmployee.Close;
 rsEmployee = null;
 }
%>

</html>
<!-- EndAbsolutePositionJS -->


OptionGroup.OldValue Property (Access)

 Copy code hover
[image]

OptionGroup.OldValue Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.

Syntax

expression .OldValue

expression A variable that represents an OptionGroup object.

Remarks

The OldValue property contains the unedited data from a bound control and is read-only in all views.

Microsoft Access uses the OldValue property to store the original value of a bound control. When you edit a bound control on a form, your changes aren't saved until you move to another record. The OldValue property contains the unedited version of the underlying data.

You can provide your own undo capability by assigning the OldValue property setting to a control. The following example shows how you can undo any changes to text box controls on a form:

VBA Copy code Copy code
Private Sub btnUndo_Click()

 Dim ctlTextbox As Control

 For Each ctlTextbox in Me.Controls
 If ctlTextbox.ControlType = acTextBox Then
 ctlTextbox.Value = ctl.OldValue
 End If
 Next ctlTextbox

End Sub

If the control hasn't been edited, this code has no effect. When you move to another record, the record source is updated, so the current value and the OldValue property will be the same.

The OldValue property setting has the same data type as the field to which the control is bound.

Example

The following example checks to determine if new data entered in a field is within 10 percent of the value of the original data. If the change is greater than 10 percent, the OldValue property is used to restore the original value. This procedure could be called from the BeforeUpdate event of the control that contains data you want to validate.

VBA Copy code Copy code
Public Sub Validate_Field()

 Dim curNewValue As Currency
 Dim curOriginalValue As Currency
 Dim curChange As Currency
 Dim strMsg As String

 curNewValue = Forms!Products!UnitPrice
 curOriginalValue = Forms!Products!UnitPrice.OldValue
 curChange = Abs(curNewValue - curOriginalValue)

 If curChange > (curOriginalValue * .1) Then
 strMsg = "Change is more than 10% of original unit price. " _
 & "Restoring original unit price."
 MsgBox strMsg, vbExclamation, "Invalid change."
 Forms!Products!UnitPrice = curOriginalValue
 End If

End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Errors.Refresh Method (DAO)

 Copy code hover
[image]

Errors.Refresh Method (DAO)
Send feedback

Updates the objects in the specified colletion to reflect the database's current schema.

Syntax

expression .Refresh

expression A variable that represents an Errors object.

Remarks

Use the Refresh method in multiuser environments in which other users may change the database. You may also need to use it on any collections that are indirectly affected by changes to the database. For example, if you change a Users collection, you may need to refresh a Groups collection before using the Groups collection.

A collection is filled with objects the first time it's referred to and won't automatically reflect subsequent changes other users make. If it's likely that another user has changed a collection, use the Refresh method on the collection immediately before carrying out any task in your application that assumes the presence or absence of a particular object in the collection. This will ensure that the collection is as up-to-date as possible. On the other hand, using Refresh can unnecessarily slow performance.


TabControl.Pages Property (Access)

 Copy code hover
[image]

TabControl.Pages Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a Pages collection that represents the pages in the specified TabControl object. Read-only.

Syntax

expression .Pages

expression A variable that represents a TabControl object.

Example

The following example displays a message indicating the number of tabbed pages on tab control TabCtl1.

VBA Copy code Copy code
MsgBox "Number of pages in TabCtl1:" & TabCtl1.Pages.Count

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction Properties Example (VB)

 Copy code hover
[image]

ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction Properties Example (VB)
Send feedback

This example uses the ActiveConnection, CommandText, CommandTimeout, CommandType, Size, and Direction properties to execute a stored procedure.

Copy code Copy code

'BeginActiveConnectionVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 'recordset, command and connection variables
 Dim Cnxn As ADODB.Connection
 Dim cmdByRoyalty As ADODB.Command
 Dim prmByRoyalty As ADODB.Parameter
 Dim rstByRoyalty As ADODB.Recordset
 Dim rstAuthors As ADODB.Recordset
 Dim strCnxn As String
 Dim strSQLAuthors As String
 Dim strSQLByRoyalty As String
 'record variables
 Dim intRoyalty As Integer
 Dim strAuthorID As String

 ' Define a command object for a stored procedure
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 Set cmdByRoyalty = New ADODB.Command
 Set cmdByRoyalty.ActiveConnection = Cnxn
 ' Set the criteria
 strSQLByRoyalty = "byroyalty"
 cmdByRoyalty.CommandText = strSQLByRoyalty
 cmdByRoyalty.CommandType = adCmdStoredProc
 cmdByRoyalty.CommandTimeout = 15

 ' Define the stored procedure's input parameter
 intRoyalty = Trim(InputBox("Enter royalty:"))
 Set prmByRoyalty = New ADODB.Parameter
 prmByRoyalty.Type = adInteger
 prmByRoyalty.Size = 3
 prmByRoyalty.Direction = adParamInput
 prmByRoyalty.Value = intRoyalty

 cmdByRoyalty.Parameters.Append prmByRoyalty

 ' Create a recordset by executing the command.
 Set rstByRoyalty = cmdByRoyalty.Execute()

 ' Open the Authors Table to get author names for display
 Set rstAuthors = New ADODB.Recordset
 strSQLAuthors = "Authors"

 'rstAuthors.Open strSQLAuthors, strCnxn, , , adCmdTable
 rstAuthors.Open strSQLAuthors, strCnxn, adOpenForwardOnly, adLockReadOnly, adCmdTable
 'the above two lines of code are identical as the default values for
 'CursorType and LockType arguments match those shown

 ' Print the recordset and add author names from Table
 Debug.Print "Authors with " & intRoyalty & _
 " percent royalty"

 Do Until rstByRoyalty.EOF
 strAuthorID = rstByRoyalty!au_id
 Debug.Print , rstByRoyalty!au_id & ", ";
 rstAuthors.Filter = "au_id = '" & strAuthorID & "'"
 Debug.Print rstAuthors!au_fname & " " & _
 rstAuthors!au_lname
 rstByRoyalty.MoveNext
 Loop

 ' clean up
 rstAuthors.Close
 rstByRoyalty.Close
 Cnxn.Close
 Set rstAuthors = Nothing
 Set rstByRoyalty = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstAuthors Is Nothing Then
 If rstAuthors.State = adStateOpen Then rstAuthors.Close
 End If
 Set rstAuthors = Nothing

 If Not rstByRoyalty Is Nothing Then
 If rstByRoyalty.State = adStateOpen Then rstByRoyalty.Close
 End If
 Set rstByRoyalty = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndActiveConnectionVB


ODBC Scalar Functions

 Copy code hover
[image]

ODBC Scalar Functions
Send feedback

Microsoft® Access SQL supports the use of the ODBC defined syntax for scalar functions. For example, the query:

SELECT DAILYCLOSE, DAILYCHANGE FROM DAILYQUOTE WHERE {fn ABS(DAILYCHANGE)} > 5

Would return all rows where the absolute value of the change in the price of a stock was greater than five.

A subset of the ODBC defined scalar functions is supported. The following table lists the functions that are supported.

For a description of the arguments and a complete explanation of the escape syntax for including functions in a SQL statement, see the ODBC documentation.

String Functions

ASCII | LENGTH | RTRIM
CHAR | LOCATE | SPACE
CONCAT | LTRIM | SUBSTRING
LCASE | RIGHT | UCASE
LEFT |  |

Numeric Functions

ABS | FLOOR | SIN
ATAN | LOG | SQRT
CEILING | POWER | TAN
COS | RAND | MOD
EXP | SIGN |

Time & Date Functions

CURDATE | DAYOFYEAR | MONTH
CURTIME | YEAR | WEEK
NOW | HOUR | QUARTER
DAYOFMONTH | MINUTE | MONTHNAME
DAYOFWEEK | SECOND | DAYNAME

Data Type Conversion

CONVERT

String literals can be converted to the following data types: SQL_FLOAT, SQL_DOUBLE, SQL_NUMERIC, SQL_INTEGER, SQL_REAL, SQL_SMALLINT, SQL_VARCHAR and SQL_DATETIME.


Properties.Delete Method (DAO)

 Copy code hover
[image]

Properties.Delete Method (DAO)
Send feedback

Deletes the specified Property object from the Properties collection.

Syntax

expression .Delete(Name)

expression A variable that represents a Properties object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Required | String | The name of the property to delete.


OptionButton.DisplayWhen Property (Access)

 Copy code hover
[image]

OptionButton.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Syntax

expression .DisplayWhen

expression A variable that represents an OptionButton object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Rectangle.BorderShade Property (Access)

 Copy code hover
[image]

Rectangle.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents a Rectangle object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens BorderColor by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


ConvertToString Method (RDS)

 Copy code hover
[image]

ConvertToString Method (RDS)
Send feedback

Converts a Recordset to a MIME string that represents the recordset data.

Syntax

DataFactory.ConvertToString(Recordset)

Parameters

  • DataFactory

  • An object variable that represents an RDSServer.DataFactory object.

  • Recordset

  • An object variable that represents a Recordset object.

Remarks

With .asp files, use ConvertToString to embed the Recordset in an HTML page generated on the server to transport it to a client computer.

ConvertToString first loads the Recordset into the Cursor Service tables, and then generates a stream in MIME format.

On the client, Remote Data Service can convert the MIME string back into a fully functioning Recordset. It works well for handling fewer than 400 rows of data with no more than 1024 bytes width per row. You shouldn't use it for streaming BLOB data and large result sets over HTTP. No wire compression is performed on the string, so very large data sets will take considerable time to transport over HTTP when compared to the wire-optimized tablegram format defined and deployed by Remote Data Service as its native transport protocol format.

Note Note

If you are using Active Server Pages to embed the resulting MIME string in a client HTML page, be aware that versions of VBScript earlier than version 2.0 limit the string's size to 32K. If this limit is exceeded, an error is returned. Keep the query scope relatively small when using MIME embedding via .asp files. To fix this, download the latest version of VBScript from the Microsoft Download Center.


Cannot update. Database or object is read-only. (Error 3027)

 Copy code hover
[image]

Cannot update. Database or object is read-only. (Error 3027)
Send feedback

You tried to save changes in a database that was opened for read-only access.

The database is read-only for one of these reasons:

  • You used the OpenDatabase method and opened the database for read-only access.

  • In Microsoft Visual Basic, you are using the Data control, and you set the ReadOnly property to True.

  • The database file is defined as read-only in the operating system or by your network.

  • The database file is stored on read-only media.

  • In a network environment, you do not have write privileges for the database file.

  • When working with a secured database, the database or one of its objects (such as a field or table) may be set to read-only. You may not have permission to access this data with your user name and password.

Close the database, resolve the read-only condition, and then reopen the file for read/write access.


Cannot include Memo or OLE Object when you select unique values

 Copy code hover
[image]

Cannot include Memo or OLE Object when you select unique values <statement>. (Error 3114)
Send feedback

Remove the DISTINCT reserved word or the Memo or OLE Object field from the statement.


SubForm.LabelX Property (Access)

 Copy code hover
[image]

SubForm.LabelX Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelX

expression A variable that represents a SubForm object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


OptionButton.LayoutID Property (Access)

 Copy code hover
[image]

OptionButton.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified option button. Read-only Long.

Version Information

Version Added: Access 2007

Syntax

expression .LayoutID

expression A variable that represents an OptionButton object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


5 Database Engine Driver (1 of 2)

 Copy code hover
[image]

5 Database Engine Driver (1 of 2)
Send feedback

Published: July 16, 2012

When you install the Microsoft® Jet version 3.5 Engine database driver, the Setup program writes a set of default values to the Microsoft Windows® Registry in the Engines and ISAM Formats subkeys. You must use the Registry Editor to add, remove, or change these settings. The following sections describe initialization and ISAM Format settings for the Microsoft Jet Engine database driver.

Microsoft Jet Engine Initialization Settings

The Access Connectivity Engine\Engines\Jet 3.x folder includes initialization settings for the Acer3x.dll driver, used for access to Microsoft Access 97 worksheets. Typical initialization settings for the entries in this folder are shown in the following example.

Copy code Copy code
win32=<path>\ Acer3x.dll

FlushTransactionTimeout=500

LockDelay=100

LockRetry=20

MaxBufferSize= 0

MaxLocksPerFile= 9500

PageTimeout=5000

Threads=3

UserCommitSync=Yes

ImplicitCommitSync=No

ExclusiveAsyncDelay=2000

SharedAsyncDelay=0

RecycleLVs=0

SortMemorySource=0

The Microsoft Access database engine uses the following entries.

Entry

Description

win32

Location of the database engine driver (.dll). The path is determined at the time of installation. Values are of type REG_SZ.

PageTimeout

The length of time between the time when data that is not read-locked is placed in an internal cache and when it is invalidated, expressed in milliseconds. The default is 5000 milliseconds or 5 seconds. Values are of type REG_DWORD.

FlushTransactionTimeout

This entry disables both the ExclusiveAsyncDelay and SharedAsyncDelay registry entries. To enable those entries, a value of zero must be entered. FlushTransactionTimeout changes the Microsoft Jet database engine's method for doing asynchronous writes to a database file. Previously, the Microsoft Jet database engine would use either the ExclusiveAsyncDelay or SharedAsyncDelay to determine how long it would wait before forcing asynchronous writes. FlushTransactionTimeout changes that behavior by having a value that will start asynchronous writes only after the specified amount of time has expired and no pages have been added to the cache. The only exception to this is if the cache exceeds the MaxBufferSize, at which point the cache will start asynchronous writing regardless if the time has expired. Microsoft Jet 3.5 database engine will wait 500 milliseconds of non-activity or until the cache size is exceeded before starting asynchronous writes.

LockDelay

This setting works in conjunction with the LockRetry setting in that it causes each LockRetry to wait 100 milliseconds before issuing another lock request. The LockDelay setting was added to prevent "bursting" that would occur with certain networking operating systems.

MaxLocksPerFile

This setting prevents transactions in Microsoft Jet from exceeding the specified value. If the locks in a transaction attempts to exceed this value, then the transaction is split into two or more parts and partially committed. This setting was added to prevent Netware 3.1 server crashes when the specified Netware lock limit was exceeded and to improve performance with both Netware and NT.

LockRetry

The number of times to repeat attempts to access a locked page before returning a lock conflict message. The default is 20. Values are of type REG_DWORD.

RecycleLVs

This setting, when enabled, will cause Microsoft Jet to recycle long value (LV) pages (Memo, Long Binary [OLE object], and Binary data types). Microsoft Jet 3.0 would not recycle those types of pages until the last user closed the database. If the RecyleLVs setting is enabled, Microsoft Jet 3.5 will start to recycle most LV pages when the database is expanded (that is, when groups of pages are added).

Note Note

By enabling this feature, users will notice a performance degradation when manipulating long value data types. Microsoft Access 97 automatically enables and disables this feature when manipulating modules, forms, and reports, thus eliminating the need to turn it on when modifying those objects. The default value is 0. Values are of type REG_DWORD.

MaxBufferSize

The size of the database engine internal cache, measured in kilobytes (K). MaxBufferSize must be an integer value greater than or equal to 512. The default is based on the following formula: ((TotalRAM in MB - 12 MB) / 4) + 512 KB For example, on a system with 32 MB of RAM, the default buffer size is ((32 MB - 12 MB) / 4) + 512 KB or 5632 KB. To set the value to the default, set the registry key to MaxBufferSize= Values are of type REG_DWORD.

Threads

The number of background threads available to the Microsoft Jet database engine. The default is 3. Values are of type REG_DWORD.

UserCommitSync

Specifies whether the system waits for a commit to finish. A value of Yes instructs the system to wait; a value of No instructs the system to perform the commit asynchronously. The default is Yes. Values are of type REG_DWORD.

ImplicitCommitSync

Specifies whether the system waits for a commit to finish. A value of No instructs the system to proceed without waiting for the commit to finish; a value of Yes instructs the system to wait for the commit to finish. The default is No. Values are of type REG_DWORD.

ExclusiveAsyncDelay

Specifies the length of time, in milliseconds, to defer an asynchronous flush of an exclusive database. The default value is 2000 or 2 seconds. Values are of type REG_DWORD.

SharedAsyncDelay

Specifies the length of time, in milliseconds, to defer an asynchronous flush of a shared database. The default value is 0. Values are of type REG_DWORD.

SortMemorySource

Specifies how Microsoft Jet obtains the memory that is used for sort keys. A value of 0 indicates that memory should be taken from the heap. A value of 1 indicates that memory should be taken from global memory using the malloc function call.

Microsoft Jet Engine ISAM Formats

The Jet\4.0\ISAM Formats\Jet 3.x folder contains the following entries.

Entry name | Type | Value
Engine | REG_SZ | Jet 3.x
OneTablePerFile | REG_BINARY | 00
IndexDialog | REG_BINARY | 00
CreateDBOnExport | REG_BINARY | 00
IsamType | REG_DWORD | 0
Note Note

When you change Windows Registry settings, you must exit and then restart the database engine for the new settings to take effect.


PermissionEnum Enumeration (DAO)

 Copy code hover
[image]

PermissionEnum Enumeration (DAO)
Send feedback

Used with the Permissions property to specify the type of permissions.

Name | Value | Description
dbSecCreate | 1 | The user can create new documents (not valid for Document objects).
dbSecDBAdmin | 8 | The user can replicate a database and change the database password (not valid for Document objects).
dbSecDBCreate | 1 | The user can create new databases. This option is valid only on the Databases container in the workgroup information file (Systen.mdw). This constant is not valid for Document objects.
dbSecDBExclusive | 4 | The user has exclusive access to the database.
dbSecDBOpen | 2 | The user can open the database.
dbSecDelete | 65536 | The user can delete the object.
dbSecDeleteData | 128 | The user can delete records.
dbSecFullAccess | 1048575 | The user has full access to the object.
dbSecInsertData | 32 | The user can add records.
dbSecNoAccess | 0 | The user does not have access to the object (not valid for Document objects).
dbSecReadDef | 4 | The user can read the table definition, including column and index information.
dbSecReadSec | 131072 | The user can read the object's security-related information.
dbSecReplaceData | 64 | The user can modify records.
dbSecRetrieveData | 20 | The user can retrieve data from the Document object.
dbSecWriteDef | 65548 | The user can modify or delete the table definition, including column and index information.
dbSecWriteOwner | 524288 | The user can change the Owner property setting.
dbSecWriteSec | 262144 | The user can alter access permissions.


Synchronizer looked for a system event but did not find one to report to the client. (Error 3534)

 Copy code hover
[image]

Synchronizer looked for a system event but did not find one to report to the client. (Error 3534)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


Advanced Programming Concepts

 Copy code hover
[image]

Advanced Programming Concepts
Send feedback

In this section

  • Scoping and Object-Naming Compatibility

  • Custom Methods and Properties

  • Improvements in Compilation Performance

  • Macro Actions and Methods of the DoCmd Object

  • Using Enumerated Constants in Microsoft Access 2002 and Later

  • Comparison of Data Types

  • Call Procedures in a Subform or Subreport

  • Program with Class Modules


OptionButton.GridlineStyleTop Property (Access)

 Copy code hover
[image]

OptionButton.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified option button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleTop

expression A variable that represents an OptionButton object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


ComboBox.RowSourceType Property (Access)

 Copy code hover
[image]

ComboBox.RowSourceType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the RowSourceType property (along with the RowSource property) to tell Microsoft Access how to provide data tothe specified object. Read/write String.

Syntax

expression .RowSourceType

expression A variable that represents a ComboBox object.

Remarks

The RowSourceType property uses the following settings.

Setting | Description
Table/Query | (Default) The data is from a table, query, or SQL statement specified by the RowSource setting.
Value List | The data is a list of items specified by the RowSource setting.
Field List | The data is a list of field names from a table, query, or SQL statement specified by the RowSource setting.
Note Note

You can also set the RowSourceType property with a user-defined function. The function name is entered without a preceding equal sign (=) and without the trailing pair of parentheses. You must provide specific function code arguments to tell Microsoft Access how to fill the control.

In Visual Basic, set the RowSourceType property by using a string expression with one of these values: "Table/Query", "Value List", or "Field List". You also use a string expression to set the value of the RowSource property. To set the RowSourceType property to a user-defined function, enter the name of the function.

When you have a limited number of values that don't change, you can set the RowSourceType property to Value List and then enter the values that make up the list in the RowSource property.

When you create a user-defined function to insert items into a list box or combo box, Microsoft Access calls the function repeatedly to get the information it needs. User-defined RowSourceType functions must be written in a very specific function format .

Example

The following example sets the RowSourceType property for a combo box to Table/Query, and it sets the RowSource property to a query named EmployeeList.

VBA Copy code Copy code
Forms!Employees!cmboNames.RowSourceType = "Table/Query"
Forms!Employees!cmboNames.RowSource = "EmployeeList"

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


EmptyCell.BackTint Property (Access)

 Copy code hover
[image]

EmptyCell.BackTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackTint

expression A variable that represents an EmptyCell object.

Remarks

The BackTint property contains a numeric expression that can be used to lighten the theme color in the BackColor property. The default value of the BackTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackTint=25

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


Containers Properties (DAO)

 Copy code hover
[image]

Containers Properties (DAO)
Send feedback

In this section

  • Containers.Count Property (DAO)


WebBrowserControl.KeyUp Event (Access)

 Copy code hover
[image]

WebBrowserControl.KeyUp Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Version Information

Version Added: Access 2010

Syntax

expression .KeyUp(KeyCode, Shift)

expression A variable that represents a WebBrowserControl object.

Parameters

Name | Required/Optional | Data Type | Description
KeyCode | Required | Integer |
Shift | Required | Integer |

Return Value

nothing

Remarks

To run a macro or event procedure when these events occur, set the OnKeyUp property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyUp event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyUp event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Locating the Current Record (ADO)

 Copy code hover
[image]

Locating the Current Record (ADO)
Send feedback

In this section

  • Locating the Current Record

  • Counting Rows

  • The Limits of a Recordset


Index.Clustered Property (DAO)

 Copy code hover
[image]

Index.Clustered Property (DAO)
Send feedback

Sets or returns a value that indicates whether an Index object represents a clustered index for a table (Microsoft Access workspaces only). Read/write Boolean.

Syntax

expression .Clustered

expression An expression that returns a Index object.

Remarks

The setting or return value is a Boolean data type that is True if the Index object represents a clustered index.

Some IISAM desktop database formats use clustered indexes. A clustered index consists of one or more nonkey fields that, taken together, arrange all records in a table in a predefined order. A clustered index provides efficient access to records in a table in which the index values may not be unique.

The Clustered property is read/write for a new Index object not yet appended to a collection and read-only for an existing Index object in an Indexes collection.

Note Note

  • Microsoft Access database engine databases ignore the Clustered property because the Microsoft Access database engine doesn't support clustered indexes.

  • For ODBC data sources the Clustered property always returns False; it does not detect whether or not the ODBC data source has a clustered index.


No database specified in connection string or IN clause. (Error 3321)

 Copy code hover
[image]

No database specified in connection string or IN clause. (Error 3321)
Send feedback

The Microsoft Access database engine is unable to connect to an external ISAM database because you have not specified the name of the database to connect to. When connecting to an external source of data, you must specify a database name.

Possible causes:

  • The connection string in the FROM clause of the SELECT statement is missing the parameter, DATABASE=.

  • The IN clause of the SELECT statement includes a database type argument (indicating to select the data from an external database) but it is missing a database name argument.


Cannot specify fixed column heading

 Copy code hover
[image]

Cannot specify fixed column heading <value> in a crosstab query more than once. (Error 3104)
Send feedback

When you create a crosstab query with fixed column headings, the values you specify must be unique. Change one or more of the duplicate column headings, and then try the operation again.


ListBox.DefaultValue Property (Access)

 Copy code hover
[image]

ListBox.DefaultValue Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.

Syntax

expression .DefaultValue

expression A variable that represents a ListBox object.

Remarks

The DefaultValue property applies to all table fields except those fields with the data type of AutoNumber or OLE Object.

The DefaultValue property specifies text or an expression that's automatically entered in a control or field when a new record is created. For example, if you set the DefaultValue property for a text box control to =Now(), the control displays the current date and time. The maximum length for a DefaultValue property setting is 255 characters.

In Visual Basic, use a string expression to set the value of this property. For example, the following code sets the DefaultValue property for a text box control named PaymentMethod to "Cash"

VBA Copy code Copy code
Forms!frmInvoice!PaymentMethod.DefaultValue = """Cash"""
Note Note

To set this property for a field by using Visual Basic, use the ADO DefaultValue property or the DAO DefaultValue property.

The DefaultValue property is applied only when you add a new record. If you change the DefaultValue property, the change isn't automatically applied to existing records.

If you set the DefaultValue property for a form control that's bound to a field that also has a DefaultValue property setting defined in the table, the control setting overrides the table setting.

If you create a control by dragging a field from the field list, the field's DefaultValue property setting, as defined in the table, is applied to the control on the form although the control's DefaultValue property setting will remain blank.

One control can provide the default value for another control. For example, if you set the DefaultValue property for a control to the following expression, the control's default value is set to the DefaultValue property setting for the txtShipTo control.

VBA Copy code Copy code
=Forms!frmInvoice!txtShipTo

If the controls are on the same form, the control that's the source of the default value must appear earlier in the tab order than the control containing the expression.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


ComboBox.AddItem Method (Access)

 Copy code hover
[image]

ComboBox.AddItem Method (Access)
See also Send feedback

Published: July 16, 2012

Adds a new item to the list of values displayed by the specified combo box control.

Syntax

expression .AddItem(Item, Index)

expression A variable that represents a ComboBox object.

Parameters

Name | Required/Optional | Data Type | Description
Item | Required | String | The display text for the new item.
Index | Optional | Variant | The position of the item in the list. If this argument is omitted, the item is added to the end of the list.

Remarks

The RowSourceType property of the specified control must be set to "Value List".

This method is only valid for list box or combo box controls on forms.

List item numbers start from zero. If the value of the Item argument doesn't correspond to an existing item number, an error occurs.

For multiple-column lists, use semicolons to delimit the strings for each column (for example, "1010;red;large" for a three-column list). If the Item argument contains fewer strings than columns in the control, items will be added starting with the left-most column. If the Item argument contains more strings than columns in the control, the extra strings are ignored.

Use the RemoveItem method to remove items from the list of values.

Example

This example adds an item to the end of the list in a list box control. For the function to work, you must pass it a ListBox object representing a list box control on a form and a String value representing the text of the item to be added.

VBA Copy code Copy code
Function AddItemToEnd(ctrlListBox As ListBox, _
 ByVal strItem As String)

 ctrlListBox.AddItem Item:=strItem

End Function

This example adds an item to the beginning of the list in a combo box control. For the function to work, you must pass it a ComboBox object representing a combo box control on a form and a String value representing the text of the item to be added.

VBA Copy code Copy code
Function AddItemToBeginning(ctrlComboBox As ComboBox, _
 ByVal strItem As String)

 ctrlComboBox.AddItem Item:=strItem, Index:=0

End Function

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Cannot set this property once the object is part of a collection. (Error 3268)

 Copy code hover
[image]

Cannot set this property once the object is part of a collection. (Error 3268)
Send feedback

An attempt was made to change the value of a property of an object (TableDef, Field, and so on) that is already appended to a collection.


CurrentProject.AllReports Property (Access)

 Copy code hover
[image]

CurrentProject.AllReports Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllReports property to reference the AllReports collection and its related properties. Read-only AllReports object.

Syntax

expression .AllReports

expression A variable that represents a CurrentProject object.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


NavigationButton.LostFocus Event (Access)

 Copy code hover
[image]

NavigationButton.LostFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The LostFocus event occurs when the specified object loses the focus.

Version Information

Version Added: Access 2010

Syntax

expression .LostFocus

expression A variable that represents a NavigationButton object.

Return Value

nothing

Remarks

To run a macro or event procedure when these events occur, set the OnLostFocus property to the name of the macro or to [Event Procedure].

This events occurs when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The LostFocus event differs from the Exit event in that the LostFocus event occurs every time a control loses the focus. The Exit event occurs only before a control loses the focus to another control on the same form. The LostFocus event occurs after the Exit event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


PageBreak.Name Property (Access)

 Copy code hover
[image]

PageBreak.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a PageBreak object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

PageBreak Object

Other resources

PageBreak Object Members


Level Object (ADO MD)

 Copy code hover
[image]

Level Object (ADO MD)
Send feedback

Contains a set of members, each of which has the same rank within a hierarchy.

Remarks

With the collections and properties of a Level object, you can do the following:

  • Identify the Level with the Name and UniqueName properties.

  • Return a string to use when displaying the Level with the Caption property.

  • Return a meaningful string that describes the Level with the Description property.

  • Return the Member objects that make up the Level with the Members collection.

  • Return the number of levels from the root of the Level with the Depth property.

  • Use the standard ADO Properties collection to obtain additional information about the Level object.

The Properties collection contains provider-supplied properties. The following table lists properties that might be available. The actual property list may differ depending upon the implementation of the provider. See the documentation for your provider for a more complete list of available properties.

Name | Description
CatalogName | The name of the catalog to which this cube belongs.
CubeName | The name of the cube.
Description | A meaningful description of the level.
DimensionUniqueName | The unambiguous name of the dimension.
HierarchyUniqueName | The unambiguous name of the hierarchy.
LevelCaption | A label or caption associated with the level.
LevelCardinality | The number of members in the level.
LevelGUID | The GUID of the level.
LevelName | Name of the level.
LevelNumber | The distance between the level and the root of the hierarchy.
LevelType | The type of level.
LevelUniqueName | The unambiguous name of the level.
SchemaName | The name of the schema to which this cube belongs.


Form.SelLeft Property (Access)

 Copy code hover
[image]

Form.SelLeft Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SelLeft property to specify or determine which column (field) is leftmost in the current selection rectangle. Read/write Long.

Syntax

expression .SelLeft

expression A variable that represents a Form object.

Remarks

The SelLeft property returns a value between 1 and the number of columns in the datasheet.

If there's no selection, the value returned by these properties is the row and column of the cell with the focus. If you've selected one or more records in the datasheet (using the record selectors), you can't change the setting of the SelLeft property.

You can use these properties with the SelHeight and SelWidth properties to specify or determine the actual size of the selection rectangle. The SelTop and SelLeft properties determine the position of the upper-left corner of the selection rectangle. The SelHeight and SelWidth properties determine the lower-right corner of the selection rectangle.

Example

The following example shows how to use the SelHeight, SelWidth, SelTop, and SelLeft properties to determine the position and size of a selection rectangle in datasheet view. The SetHeightWidth procedure assigns the height and width of the current selection rectangle to the variables lngNumRows, lngNumColumns, lngTopRow, and lngLeftColumn, and displays those values in a message box.

VBA Copy code Copy code
Public Sub SetHeightWidth(ByRef frm As Form)

 Dim lngNumRows As Long
 Dim lngNumColumns As Long
 Dim lngTopRow As Long
 Dim lngLeftColumn As Long
 Dim strMsg As String

 ' Form is in Datasheet view.
 If frm.CurrentView = 2 Then

 ' Number of rows selected.
 lngNumRows = frm.SelHeight

 ' Number of columns selected.
 lngNumColumns = frm.SelWidth

 ' Topmost row selected.
 lngTopRow = frm.SelTop

 ' Leftmost column selected.
 lngLeftColumn = frm.SelLeft

 ' Display message.
 strMsg = "Number of rows: " & lngNumRows & vbCrLf
 strMsg = strMsg & "Number of columns: " _
 & lngNumColumns & vbCrLf
 strMsg = strMsg & "Top row: " & lngTopRow & vbCrLf
 strMsg = strMsg & "Left column: " & lngLeftColumn
 MsgBox strMsg, vbInformation
 End If

End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


TabControl.IsVisible Property (Access)

 Copy code hover
[image]

TabControl.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Syntax

expression .IsVisible

expression A variable that represents a TabControl object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


AdditionalData.Item Property (Access)

 Copy code hover
[image]

AdditionalData.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only AdditionalData.

Syntax

expression .Item(Index)

expression A variable that represents an AdditionalData object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

AdditionalData Object

Other resources

AdditionalData Object Members


Image.OnClick Property (Access)

 Copy code hover
[image]

Image.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Syntax

expression .OnClick

expression A variable that represents an Image object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

Image Object

Other resources

Image Object Members


ComboBox.OnKeyPress Property (Access)

 Copy code hover
[image]

ComboBox.OnKeyPress Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Press box in the Properties window. Read/write String.

Syntax

expression .OnKeyPress

expression A variable that represents a ComboBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyPress event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyPress value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Press box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Press box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyPress property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyPress

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


EmptyCell.Top Property (Access)

 Copy code hover
[image]

EmptyCell.Top Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Top property to specify an object's location on a form or report. Read/write Integer. .

Version Information

Version Added: Access 2010

Syntax

expression .Top

expression A variable that represents an EmptyCell object.

Remarks

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


NavigationControl.OldValue Property (Access)

 Copy code hover
[image]

NavigationControl.OldValue Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.

Version Information

Version Added: Access 2010

Syntax

expression .OldValue

expression A variable that represents a NavigationControl object.

Remarks

The OldValue property contains the unedited data from a bound control and is read-only in all views.

Microsoft Access uses the OldValue property to store the original value of a bound control. When you edit a bound control on a form, your changes aren't saved until you move to another record. The OldValue property contains the unedited version of the underlying data.

You can provide your own undo capability by assigning the OldValue property setting to a control. The following example shows how you can undo any changes to text box controls on a form:

VBA Copy code Copy code
Private Sub btnUndo_Click()

 Dim ctlTextbox As Control

 For Each ctlTextbox in Me.Controls
 If ctlTextbox.ControlType = acTextBox Then
 ctlTextbox.Value = ctl.OldValue
 End If
 Next ctlTextbox

End Sub

If the control hasn't been edited, this code has no effect. When you move to another record, the record source is updated, so the current value and the OldValue property will be the same.

The OldValue property setting has the same data type as the field to which the control is bound.

Example

The following example checks to determine if new data entered in a field is within 10 percent of the value of the original data. If the change is greater than 10 percent, the OldValue property is used to restore the original value. This procedure could be called from the BeforeUpdate event of the control that contains data you want to validate.

VBA Copy code Copy code
Public Sub Validate_Field()

 Dim curNewValue As Currency
 Dim curOriginalValue As Currency
 Dim curChange As Currency
 Dim strMsg As String

 curNewValue = Forms!Products!UnitPrice
 curOriginalValue = Forms!Products!UnitPrice.OldValue
 curChange = Abs(curNewValue - curOriginalValue)

 If curChange > (curOriginalValue * .1) Then
 strMsg = "Change is more than 10% of original unit price. " _
 & "Restoring original unit price."
 MsgBox strMsg, vbExclamation, "Invalid change."
 Forms!Products!UnitPrice = curOriginalValue
 End If

End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Type Property Example (Property) (VC++)

 Copy code hover
[image]

Type Property Example (Property) (VC++)
Send feedback

This example demonstrates the Type property. It is a model of a utility for listing the names and types of a collection, like Properties, Fields, etc.

We do not need to open the Recordset to access its Properties collection; they come into existence when the Recordset object is instantiated. However, setting the CursorLocation property to adUseClient adds several dynamic properties to the Recordset object's Properties collection, making the example a little more interesting. For sake of illustration, we explicitly use the Item property to access each Property object.

Copy code Copy code

// BeginTypePropertyCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include<conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void TypeX();
void PrintComError(_com_error &e);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 TypeX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// TypeX Function //
// //
//////////////////////////////////////////////////////////
void TypeX()
{
 HRESULT hr = S_OK;

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace
 _RecordsetPtr pRst = NULL;
 PropertyPtr pProperty = NULL;

 //Define Other Variables
 _bstr_t strMsg;
 _variant_t vIndex;
 int intLineCnt = 0;

 try
 {
 TESTHR(pRst.CreateInstance (__uuidof(Recordset)));

 // Set the Recordset Cursor Location
 pRst->CursorLocation = adUseClient;

 for (short iIndex = 0; iIndex <= (pRst->Properties->
 GetCount() - 1);iIndex++)
 {
 vIndex = iIndex;
 pProperty = pRst->Properties->GetItem(vIndex);

 int propType = (int)pProperty->GetType();
 switch(propType)
 {
 case adBigInt:
 strMsg = "adBigInt";
 break;
 case adBinary:
 strMsg = "adBinary";
 break;
 case adBoolean:
 strMsg = "adBoolean";
 break;
 case adBSTR:
 strMsg = "adBSTR";
 break;
 case adChapter:
 strMsg = "adChapter";
 break;
 case adChar:
 strMsg = "adChar";
 break;
 case adCurrency:
 strMsg = "adCurrency";
 break;
 case adDate:
 strMsg = "adDate";
 break;
 case adDBDate:
 strMsg = "adDBDate";
 break;
 case adDBTime:
 strMsg = "adDBTime";
 break;
 case adDBTimeStamp:
 strMsg = "adDBTimeStamp";
 break;
 case adDecimal:
 strMsg = "adDecimal";
 break;
 case adDouble:
 strMsg = "adDouble";
 break;
 case adEmpty:
 strMsg = "adEmpty";
 break;
 case adError:
 strMsg = "adError";
 break;
 case adFileTime:
 strMsg = "adFileTime";
 break;
 case adGUID:
 strMsg = "adGUID";
 break;
 case adIDispatch:
 strMsg = "adIDispatch";
 break;
 case adInteger:
 strMsg = "adInteger";
 break;
 case adIUnknown:
 strMsg = "adIUnknown";
 break;
 case adLongVarBinary:
 strMsg = "adLongVarBinary";
 break;
 case adLongVarChar:
 strMsg = "adLongVarChar";
 break;
 case adLongVarWChar:
 strMsg = "adLongVarWChar";
 break;
 case adNumeric:
 strMsg = "adNumeric";
 break;
 case adPropVariant:
 strMsg = "adPropVariant";
 break;
 case adSingle:
 strMsg = "adSingle";
 break;
 case adSmallInt:
 strMsg = "adSmallInt";
 break;
 case adTinyInt:
 strMsg = "adTinyInt";
 break;
 case adUnsignedBigInt:
 strMsg = "adUnsignedBigInt";
 break;
 case adUnsignedInt:
 strMsg = "adUnsignedInt";
 break;
 case adUnsignedSmallInt:
 strMsg = "adUnsignedSmallInt";
 break;
 case adUnsignedTinyInt:
 strMsg = "adUnsignedTinyInt";
 break;
 case adUserDefined:
 strMsg = "adUserDefined";
 break;
 case adVarBinary:
 strMsg = "adVarBinary";
 break;
 case adVarChar:
 strMsg = "adVarChar";
 break;
 case adVariant:
 strMsg = "adVariant";
 break;
 case adVarNumeric:
 strMsg = "adVarNumeric";
 break;
 case adVarWChar:
 strMsg = "adVarWChar";
 break;
 case adWChar:
 strMsg = "adWChar";
 break;
 default:
 strMsg = "*UNKNOWN*";
 break;
 }

 intLineCnt++;
 if (intLineCnt%20 == 0)
 {
 printf("\nPress any key to continue...\n");
 getch();
 }
 printf ("Property %d : %s,Type = %s\n",iIndex,
 (LPCSTR)pProperty->GetName(),(LPCSTR)strMsg);
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 PrintComError(e);
 }
}

//////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
//////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{

 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndTypePropertyCpp


Form.SplitFormOrientation Property (Access)

 Copy code hover
[image]

Form.SplitFormOrientation Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the position of the datasheet relative to the form when the form is displayed in Split Form view. Read/write AcSplitFormOrientation.

Version Information

Version Added: Access 2007

Syntax

expression .SplitFormOrientation

expression A variable that represents a Form object.

See also

Concepts

Form Object

Other resources

Form Object Members


CommandButton.OnKeyPress Property (Access)

 Copy code hover
[image]

CommandButton.OnKeyPress Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Press box in the Properties window. Read/write String.

Syntax

expression .OnKeyPress

expression A variable that represents a CommandButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyPress event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyPress value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Press box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Press box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyPress property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyPress

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Form.BeforeInsert Event (Access)

 Copy code hover
[image]

Form.BeforeInsert Event (Access)
See also Send feedback

Published: July 16, 2012

The BeforeInsert event occurs when the user types the first character in a new record, but before the record is actually created.

Syntax

expression .BeforeInsert(Cancel )

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the BeforeInsert event occurs. Setting the Cancel argument to True (-1) cancels the BeforeInsert event.

Remarks

Note Note

Setting the value of a control by using a macro or Visual Basic doesn't trigger these events.

To run a macro or event procedure when these events occur, set the BeforeInsert or AfterInsert property to the name of the macro or to [Event Procedure].

You can use an AfterInsert event procedure or macro to requery a recordset whenever a new record is added.

The BeforeInsert and AfterInsert events are similar to the BeforeUpdate and AfterUpdate events. These events occur in the following order:

BeforeInsert → BeforeUpdate → AfterUpdate → AfterInsert.

The following table summarizes the interaction between these events.

Event | Occurs when
BeforeInsert | User types the first character in a new record.
BeforeUpdate | User updates the record.
AfterUpdate | Record is updated.
AfterInsert | Record updated is a new record.

If the first character in a new record is typed into a text box or combo box, the BeforeInsert event occurs before the Change event.

Example

This example shows how you can use a BeforeInsert event procedure to verify that the user wants to create a new record, and an AfterInsert event procedure to requery the record source for the Employees form after a record has been added.

To try the example, add the following event procedure to a form named Employees that is based on a table or query. Switch to form Datasheet view and try to insert a record.

VBA Copy code Copy code
Private Sub Form_BeforeInsert(Cancel As Integer)
 If MsgBox("Insert new record here?", _
 vbOKCancel) = vbCancel Then
 Cancel = True
 End If
End Sub

Private Sub Form_AfterInsert()
 Forms!Employees.Requery
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


ObjectFrame.RowSource Property (Access)

 Copy code hover
[image]

ObjectFrame.RowSource Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the RowSource property (along with the RowSourceType property) to tell Microsoft Access how to provide data tothe specified object. Read/write String.

Syntax

expression .RowSource

expression A variable that represents an ObjectFrame object.

Remarks

For example, to display rows of data in a list box from a query named CustomerList, set the list box's RowSourceType property to Table/Query and its RowSource property to the query named CustomerList.

The RowSource property setting depends on the RowSourceType property setting.

For this RowSourceType setting | Enter this RowSource setting
Table/Query | A table name, query name, or SQL statement.
Value List | A list of items with semicolons (;) as separators.
Field List | A table name, query name, or SQL statement.

If the RowSourceType property is set to a user-defined function, the RowSource property can be left blank.

For table fields, you can set these properties on the Lookup tab in the Field Properties section of table Design view for fields with the DisplayControl property set to Combo Box or List Box.

Microsoft Access sets these properties automatically when you select Lookup Wizard as the data type for a field in table Design view.

In Visual Basic, set the RowSourceType property by using a string expression with one of these values: "Table/Query", "Value List", or "Field List". You also use a string expression to set the value of the RowSource property. To set the RowSourceType property to a user-defined function, enter the name of the function.

When you have a limited number of values that don't change, you can set the RowSourceType property to Value List and then enter the values that make up the list in the RowSource property.

Example

The following example sets the RowSourceType property for a combo box to Table/Query, and it sets the RowSource property to a query named EmployeeList.

VBA Copy code Copy code
Forms!Employees!cmboNames.RowSourceType = "Table/Query"
Forms!Employees!cmboNames.RowSource = "EmployeeList"

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


RDS Code Examples in Microsoft Visual C++

 Copy code hover
[image]

RDS Code Examples in Microsoft Visual C++
Send feedback

Use the following code examples to learn how to use RDS properties when writing in Microsoft Visual C++.

Note Note

Paste the entire code example, from beginning to end, into your code editor. The example may not run correctly if partial examples are used or if paragraph formatting is lost.

  • Handler Property Example

  • InternetTimeout Property Example


ListBox.Application Property (Access)

 Copy code hover
[image]

ListBox.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a ListBox object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


TextBox.ScrollBars Property (Access)

 Copy code hover
[image]

TextBox.ScrollBars Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ScrollBars property to specify whether scroll bars appear on a text box control. Read/write Byte.

Syntax

expression .ScrollBars

expression A variable that represents a TextBox object.

Remarks

The ScrollBars property uses the following settings.

Setting | Visual Basic | Description
None | 0 | (Default) No scroll bars appear on the text box.
Vertical | 2 | Vertical scroll bar appears on the text box.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ObjectFrame.OnMouseDown Property (Access)

 Copy code hover
[image]

ObjectFrame.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Syntax

expression .OnMouseDown

expression A variable that represents an ObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


References Members (Access)

 Copy code hover
[image]

References Members (Access)
Send feedback

Published: July 16, 2012

The References collection contains Reference objects representing each reference that's currently set.

Events

Name | Description
ItemAdded | The ItemAdded event occurs when a reference is added to the project from Visual Basic.
ItemRemoved | The ItemRemoved event occurs when a reference is removed from the project.

Methods

Name | Description
AddFromFile | The AddFromFile method creates a reference to a type library in a specified file. .
AddFromGuid | The AddFromGUID method creates a Reference object based on the GUID that identifies a type library. Reference object.
Item | The Item method returns a specific member of a collection either by position or by key. Reference object.
Remove | The Remove method removes a Reference object from the References collection.

Properties

Name | Description
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Parent | Returns the parent object for the specified object. Read-only.


The disk drive you are attempting to write to is full. (Error 3575)

 Copy code hover
[image]

The disk drive you are attempting to write to is full. (Error 3575)
Send feedback

The disk drive does not have enough space to complete the operation. Delete unneeded files from the disk to create sufficient space for the operation. Make space available on the disk larger than the file you are attempting to save.


A different operation is preventing this operation from being executed. (Error 3667)

 Copy code hover
[image]

A different operation is preventing this operation from being executed. (Error 3667)
Send feedback

This error usually means that an asynchronous operation is already busy on the object and that no other operation will be allowed until the asynchronous operation is complete or cancelled.


AcSplitFormOrientation Enumeration (Access)

 Copy code hover
[image]

AcSplitFormOrientation Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the SplitFormOrientation property to specify the orientation of the datasheet in relation to the form while in Split Form view.

Version Information

Version Added: Access 2007

Name | Value | Description
acDatasheetOnBottom | 1 | The datasheet is displayed below the form.
acDatasheetOnLeft | 2 | The datasheet is displayed to the left of the form.
acDatasheetOnRight | 3 | The datasheet is displayed to the right of the form.
acDatasheetOnTop | 0 | The datasheet is displayed above the form.


ADO Java Class Wrappers

 Copy code hover
[image]

ADO Java Class Wrappers
Send feedback

This code declares an instance of the ADO Recordset class wrapper and initializes it, all on the same line of code. Further, it declares variables for each of the arguments in the Open method, especially for LockType and CursorType (because Java doesn't support enumerated types). It opens and closes the Recordset object. Setting Rs1 to NULL merely schedules that variable to be released when Java performs its systematic and intermittent release of unused objects.

Copy code Copy code

public static void main( String args[])
{
 msado15._Recordset Rs1 = new msado15.Recordset();
 Variant Source = new Variant( "SELECT * FROM Authors" );
 Variant Connect = new Variant( "DSN=AdoDemo;UID=admin;PWD=;" );
 int LockType = msado15.CursorTypeEnum.adOpenForwardOnly;
 int CursorType = msado15.LockTypeEnum.adLockReadOnly;
 int Options = -1;

 Rs1.Open( Source, Connect, LockType, CursorType, Options );
 Rs1.Close();
 Rs1 = null;

 System.out.println( "Success!\n" );
}


AcDefReportView Enumeration (Access)

 Copy code hover
[image]

AcDefReportView Enumeration (Access)
Send feedback

Published: July 16, 2012

Use with the DefaultView property to set or return the opening view of a report.

Name | Value | Description
acDefViewPreview | 0 | The report opens in Print Preview.
acDefViewReportBrowse | 1 | The report opens in Report view.


Form.Resize Event (Access)

 Copy code hover
[image]

Form.Resize Event (Access)
See also Send feedback

Published: July 16, 2012

The Resize event occurs when a form is opened and whenever the size of a form changes.

Syntax

expression .Resize

expression A variable that represents a Form object.

Remarks

To run a macro or event procedure when this event occurs, set the OnResize property to the name of the macro or to [Event Procedure].

This event occurs if you change the size of the form in a macro or event procedure— for example, if you use the MoveSize action in a macro to resize the form.

By running a macro or an event procedure when a Resize event occurs, you can move or resize a control when the form it's on is resized. You can also use a Resize event to recalculate variables or reset properties that may depend on the size of the form.

When you first open a form, the following events occur in this order:

Open → Load → Resize → Activate → Current

Note Note

You need to be careful if you use a MoveSize, Maximize, Minimize, or Restore action (or the corresponding methods of the DoCmd object) in a Resize macro or event procedure. These actions can trigger a Resize event for the form, and thus cause a cascading event.

Example

The following example shows how a Resize event procedure can be used to repaint a form when it is maximized. When the user clicks a command button labeled "Maximize," the form is maximized and the Resize event is triggered.

To try the example, add the following event procedures to a form named Contacts that contains a command button named Maximize:

VBA Copy code Copy code
Private Sub Maximize_Click()
 DoCmd.Maximize
End Sub

Private Sub Form_Resize()
 Forms!Contacts.Repaint
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


How to: Bind a Form to an ADO Recordset

 Copy code hover
[image]

How to: Bind a Form to an ADO Recordset
Send feedback

To bind a Microsoft Access form to a recordset, you must set the form's Recordset property to an open ADO Recordset object. A form must meet two general requirements for the form to be updatable when it is bound to an ADO recordset. The general requirements are:

  • The underlying ADO recordset must be updatable via ADO.

  • The recordset must contain one or more fields that are uniquely indexed, such as a table's primary key.

VBA Copy code Copy code
 Private Sub Form_Open(Cancel As Integer)
 Dim cn As ADODB.Connection
 Dim rs As ADODB.Recordset

 'Use the ADO connection that Access uses
 Set cn = CurrentProject.AccessConnection
 'Create an instance of the ADO Recordset class,
 'and set its properties
 Set rs = New ADODB.Recordset
 With rs
 Set .ActiveConnection = cn
 .Source = "SELECT * FROM Customers"
 .LockType = adLockOptimistic
 .CursorType = adOpenKeyset
 .Open
 End With
 'Set the form's Recordset property to the ADO recordset
 Set Me.Recordset = rs
 Set rs = Nothing
 Set cn = Nothing
 End Sub


OriginalValue and UnderlyingValue Properties Example (VB)

 Copy code hover
[image]

OriginalValue and UnderlyingValue Properties Example (VB)
Send feedback

This example demonstrates the OriginalValue and UnderlyingValue properties by displaying a message if a record's underlying data has changed during a Recordset batch update.

Copy code Copy code

'BeginOriginalValueVB
Public Sub Main()
 On Error GoTo ErrorHandler

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

 Dim Cnxn As ADODB.Connection
 Dim rstTitles As ADODB.Recordset
 Dim fldType As ADODB.Field
 Dim strCnxn As String
 Dim strSQLTitles As String

 ' Open connection.
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open recordset for batch update
 ' using object refs to set properties
 Set rstTitles = New ADODB.Recordset
 Set rstTitles.ActiveConnection = Cnxn
 rstTitles.CursorType = adOpenKeyset
 rstTitles.LockType = adLockBatchOptimistic
 strSQLTitles = "titles"
 rstTitles.Open strSQLTitles

 ' Set field object variable for Type field
 Set fldType = rstTitles!Type

 ' Change the type of psychology titles
 Do Until rstTitles.EOF
 If Trim(fldType) = "psychology" Then
 fldType = "self_help"
 End If
 rstTitles.MoveNext
 Loop

 ' Similate a change by another user by updating
 ' data using a command string
 Cnxn.Execute "UPDATE Titles SET type = 'sociology' " & _
 "WHERE type = 'psychology'"

 'Check for changes
 rstTitles.MoveFirst
 Do Until rstTitles.EOF
 If fldType.OriginalValue <> fldType.UnderlyingValue Then
 MsgBox "Data has changed!" & vbCr & vbCr & _
 " Title ID: " & rstTitles!title_id & vbCr & _
 " Current value: " & fldType & vbCr & _
 " Original value: " & _
 fldType.OriginalValue & vbCr & _
 " Underlying value: " & _
 fldType.UnderlyingValue & vbCr
 End If
 rstTitles.MoveNext
 Loop

 ' Cancel the update because this is a demonstration
 rstTitles.CancelBatch

 ' Restore original values
 Cnxn.Execute "UPDATE Titles SET type = 'psychology' " & _
 "WHERE type = 'sociology'"

 ' clean up
 rstTitles.Close
 Cnxn.Close
 Set rstTitles = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstTitles Is Nothing Then
 If rstTitles.State = adStateOpen Then rstTitles.Close
 End If
 Set rstTitles = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndOriginalValueVB


Form.OnConnect Property (Access)

 Copy code hover
[image]

Form.OnConnect Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the OnConnect event occurs. Read/write.

Syntax

expression .OnConnect

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the OnConnect event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).OnConnect = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


Line.Section Property (Access)

 Copy code hover
[image]

Line.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Syntax

expression .Section

expression A variable that represents a Line object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

Line Object

Other resources

Line Object Members


Customization File Logs Section

 Copy code hover
[image]

Customization File Logs Section
Send feedback

The logs section contains a log file entry, which specifies the name of a file that records errors during the operation of the DataFactory.

Syntax

A log file entry is of the form:

Copy code Copy code
                      err=
                      FileName

Part | Description
err | A literal string that indicates this is a log file entry.
FileName | A complete path and file name. The typical file name is c:\msdfmap.log.

The log file will contain the user name, HRESULT, date, and time of each error.


TabControl.Style Property (Access)

 Copy code hover
[image]

TabControl.Style Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Style property to specify or determine the appearance of tabs on a tab control. Read/write Byte.

Syntax

expression .Style

expression A variable that represents a TabControl object.

Remarks

The Style property uses the following settings.

Setting | Visual Basic | Description
Tabs | 0 | (Default) Tabs appear as tabs.
Buttons | 1 | Tabs appear as buttons.
None | 2 | No tabs appear in the control.

You can also set the default for this property by setting a control's DefaultControl property in Visual Basic.

You can set the Style property in any view.

When the tab control's Style property is set to Tabs or Buttons, the appearance of the tabs is determined by the TabFixedHeight , TabFixedWidth , and MultiRow properties.

You could set the tab control's Style property to None if you wanted complete control over when a user could move between tabs. In prior versions of Microsoft Access, wizard dialogs were created by using multiple-page forms. You can now use a tab control create your own wizard with each page of the wizard contained on a separate page of a tab control with its Style property set to None.

Example

The following example causes tabs to appear as buttons on the tab control named "TabCtl1" on the "Mailing List" form.

VBA Copy code Copy code
Forms("Mailing List").Controls("TabCtl1").Style = 1

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Application.InstantiateTemplate Method (Access)

 Copy code hover
[image]

Application.InstantiateTemplate Method (Access)
See also Send feedback

Published: July 16, 2012

Opens a new database and applies the specified template.

Version Information

Version Added: Access 2010

Syntax

expression .InstantiateTemplate(Path)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Path | Required | String | The full path and filename of the template to apply to the new database.

See also

Concepts

Application Object

Other resources

Application Object Members


ObjectFrame.BorderShade Property (Access)

 Copy code hover
[image]

ObjectFrame.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents an ObjectFrame object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens BorderColor by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


CommandButton Methods (Access)

 Copy code hover
[image]

CommandButton Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.


TextBox.BeforeUpdate Property (Access)

 Copy code hover
[image]

TextBox.BeforeUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.

Syntax

expression .BeforeUpdate

expression A variable that represents a TextBox object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeUpdate event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the BeforeUpdate event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).BeforeUpdate = "[Event Procedure]"

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


CheckBox.DblClick Event (Access)

 Copy code hover
[image]

CheckBox.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Syntax

expression .DblClick(Cancel)

expression A variable that represents a CheckBox object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the DblClick event occurs. Setting the Cancel argument to True (-1) cancels the DblClick event.

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Size Property (ADO Stream)

 Copy code hover
[image]

Size Property (ADO Stream)
Send feedback

Indicates the size of the stream in number of bytes.

Return Values

Returns a Long value that specifies the size of the stream in number of bytes. The default value is the size of the stream, or -1 if the size of the stream is not known.

Remarks

Size can be used only with open Stream objects.

Note Note

Any number of bits can be stored in a Stream object, limited only by system resources. If the Stream contains more bits than can be represented by a Long value, Size is truncated and therefore does not accurately represent the length of the Stream.


NavigationButton.PictureType Property (Access)

 Copy code hover
[image]

NavigationButton.PictureType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .PictureType

expression A variable that represents a NavigationButton object.

Remarks

The PictureType property uses the following settings.

Setting | Description
0 | (Default) The picture is embedded in the object and becomes part of the database file.
1 | The picture is linked to the object. Microsoft Access stores a pointer to the location of the picture on the disk.

This property can be set only in form Design view or report Design view.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

When this property is set to 0, the size of the database increases by the size of the picture file and, with some .wmf files, the size may increase as much as twice the size of the picture file. When this property is set to 1, there is no increase in the size of the database because Microsoft Access only saves a pointer to the picture's location on the disk.

Note Note

If a linked file is moved to another location on the disk, you must re-establish the link by using the object's Picture property.

For embedded pictures, the object's PictureData property stores the individual bits that make up a picture's image. For linked pictures, this property stores the path to the picture's file.

You can modify a linked picture by using a separate application and changes to the picture will appear the next time the object containing that picture is displayed in the database.

Example

The following example links the picture in the "Customer Photo" image control on the "Order Entry" form to the picture on the disk. The picture is not part of the database file.

VBA Copy code Copy code
Forms("Order Entry").Controls("Customer Photo").PictureType = 1

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Page.ControlType Property (Access)

 Copy code hover
[image]

Page.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Syntax

expression .ControlType

expression A variable that represents a Page object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

Page Object

Other resources

Page Object Members


Form.Application Property (Access)

 Copy code hover
[image]

Form.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a Form object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

Form Object

Other resources

Form Object Members


LIKE (Access 2013 custom web app)

 Copy code hover
[image]

LIKE (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Determines whether a specific character string matches a specified pattern. A pattern can include regular characters and wildcard characters. During pattern matching, regular characters must exactly match the characters specified in the character string. However, wildcard characters can be matched with arbitrary fragments of the character string. Using wildcard characters makes the LIKE operator more flexible than using the = and != string comparison operators.

Syntax

Expression [ NOT ] LIKE Pattern [ ESCAPE EscapeChar]

The LIKE operator contains the following arguments

Argument name | Required | Description
Expression | Yes | A valid expression.
Pattern | Yes | The specific string of characters to search for in Expression. Can include wildcard characters. Refer to the Remarks for a list of valid wildcard characters.
EscapeChar | No | A character that is put in front of a wildcard character to indicate that the wildcard should be interpreted as a regular character and not as a wildcard. EscapeChar is a character expression that has no default and must evaluate to only one character.

Remarks

The following table contains the wildcard characters that are valid for use in the Pattern argument.

Wildcard character | Description | Example
% | Any string of zero or more characters. | WHERE title LIKE '%computer%' finds all book titles with the word 'computer' anywhere in the book title.
_ (underscore) | Any single character. | WHERE au_fname LIKE '_ean' finds all four-letter first names that end with ean (Dean, Sean, and so on).
[] | Any single character within the specified range ([a-f]) or set ([abcdef]). | WHERE au_lname LIKE '[C-P]arsen' finds author last names ending with arsen and starting with any single character between C and P, for example Carsen, Larsen, Karsen, and so on.
[^] | Any single character not within the specified range ([^a-f]) or set ([^abcdef]). | WHERE au_lname LIKE 'de[^l]%' all author last names starting with de and where the following letter is not l.

When you perform string comparisons by using LIKE, all characters in the pattern string are significant. This includes leading or trailing spaces. If a comparison in a query is to return all rows with a string LIKE 'abc ' (abc followed by a single space), a row in which the value of that column is abc (abc without a space) is not returned. However, trailing blanks, in the expression to which the pattern is matched, are ignored. If a comparison in a query is to return all rows with the string LIKE 'abc' (abc without a space), all rows that start with abc and have zero or more trailing blanks are returned.

If any one of the arguments is not of a string data type, it is converted to a string data type, if it is possible.


Form.GotFocus Event (Access)

 Copy code hover
[image]

Form.GotFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The GotFocus event occurs when the specified object receives the focus.

Syntax

expression .GotFocus

expression A variable that represents a Form object.

Remarks

To run a macro or event procedure when these events occur, set the OnGotFocus property to the name of the macro or to [Event Procedure].

These events occur when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The GotFocus event differs from the Enter event in that the GotFocus event occurs every time a control receives the focus. For example, suppose the user clicks a check box on a form, then clicks a report, and finally clicks the check box on the form to bring it to the foreground. The GotFocus event occurs both times the check box receives the focus. In contrast, the Enter event occurs only the first time the user clicks the check box. The GotFocus event occurs after the Enter event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Document Methods (DAO)

 Copy code hover
[image]

Document Methods (DAO)
Send feedback

In this section

  • Document.CreateProperty Method (DAO)


ListBox.OnGotFocus Property (Access)

 Copy code hover
[image]

ListBox.OnGotFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnGotFocus

expression A variable that represents a ListBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The GotFocus event occurs when the object receives the focus.

The OnGotFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Got Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Got Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnGotFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnGotFocus

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


ComboBox.ScrollBarAlign Property (Access)

 Copy code hover
[image]

ComboBox.ScrollBarAlign Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ScrollBarAlign to specify or determine the alignment of a vertical scroll bar. Read/write Byte.

Syntax

expression .ScrollBarAlign

expression A variable that represents a ComboBox object.

Remarks

The ScrollBarAlign property uses the following settings.

Setting | Visual Basic | Description
System | 0 | Vertical scroll bar is placed on the left if the form or report Orientation property is right to left; and on the right if the form or report Orientation property is left to right.
Right | 1 | Aligns vertical scroll bar on the right side of the control.
Left | 2 | Aligns vertical scroll bar on the left side of the control.

For combo and list boxes, ScrollBarAlign also controls the placement of the box button above the scroll bar.

Example

The following example aligns the vertical scroll bar on the left side of the "Country" combo box in the "International Shipping" form.

VBA Copy code Copy code
Forms("International Shipping").Controls("Country").ScrollBarAlign = 2

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Version Property Example (VC++)

 Copy code hover
[image]

Version Property Example (VC++)
Send feedback

This example uses the Version property of a Connection object to display the current ADO version. It also uses several dynamic properties to show:

  • the current DBMS name and version.

  • OLE DB version.

  • provider name and version.

  • ODBC version.

  • ODBC driver name and version.

Copy code Copy code

// BeginVersionCpp
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void VersionX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 VersionX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// VersionX Function //
// //
//////////////////////////////////////////////////////////
void VersionX(void)
{
 HRESULT hr = S_OK;

 // Define string variables.
 _bstr_t strCnn("driver={SQL Server};server='MySqlServer';"
 "user id='MyUserId';password='MyPassword';database='pubs';");

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _ConnectionPtr pConnection = NULL;

 try
 {
 // Open connection.
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
 pConnection->Open (strCnn, "", "", adConnectUnspecified);

 printf("ADO Version : %s\n\n",(LPCSTR) pConnection->Version);
 printf("DBMS Name : %s\n\n",(LPCSTR) (_bstr_t)
 pConnection->Properties->GetItem("DBMS Name")->Value);
 printf("DBMS Version : %s\n\n",(LPCSTR) (_bstr_t)
 pConnection->Properties->GetItem("DBMS Version")->Value);
 printf("OLE DB Version : %s\n\n",(LPCSTR) (_bstr_t)
 pConnection->Properties->GetItem("OLE DB Version")->Value);
 printf("Provider Name : %s\n\n",(LPCSTR) (_bstr_t)
 pConnection->Properties->GetItem("Provider Name")->Value);
 printf("Provider Version : %s\n\n",(LPCSTR) (_bstr_t)
 pConnection->Properties->GetItem("Provider Version")->Value);
 printf("Driver Name : %s\n\n",(LPCSTR) (_bstr_t)
 pConnection->Properties->GetItem("Driver Name")->Value);
 printf("Driver Version : %s\n\n",(LPCSTR) (_bstr_t)
 pConnection->Properties->GetItem("Driver Version")->Value);
 printf("Driver ODBC Version : %s\n\n",(LPCSTR) (_bstr_t)
 pConnection->Properties->GetItem("Driver ODBC Version")->Value);

 }

 catch (_com_error &e)
 {
 // Notify the user of errors if any.
 PrintProviderError(pConnection);
 PrintComError(e);
 }

 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

//////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
//////////////////////////////////////////////////////////
void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("Error number: %x\t%s\n", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

//////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
//////////////////////////////////////////////////////////
void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndVersionCpp


SetFilter Macro Action

 Copy code hover
[image]

SetFilter Macro Action
Send feedback

You can use the SetFilter action to apply a filter to the records in the active datasheet, form, report, or table.

Setting

The SetFilter action has the following arguments.

Action argument | Description
Filter Name | If provided, the name of a query or of a filter saved as a query. This argument or the WhereCondition argument is required in a client database. In a Web database, this argument is not available.
Where Condition | If provided, a SQL WHERE clause that restricts the records in the datasheet, form, report, or table. In a Web database, this argument is required.
Control Name | If provided, the name of the control that corresponds to the subform or subreport to be filtered. If empty, the current object is filtered.

Remarks

In a web database, the Where Condition argument cannot begin with an equal sign (=).

When you run this action, the filter is applied to the table, form, report or datasheet (for example, query result) that is active and has the focus.

The Filter property of the active object is used to save the WhereCondition argument and apply it at a later time. Filters are saved with the objects in which they are created. They are automatically loaded when the object is opened, but they are not automatically applied.

In a client database, to automatically apply a filter when the object is opened, set the FilterOnLoad property to True.

In a web database, to automatically apply a filter when the object is opened, add the SetFilter action to a macro, and add the macro to the object's OnLoad event.

Example

The following example shows how to use the SetFilter action to filter the form in which the macro is defined.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

Copy code Copy code
OpenForm
    Form Name sfrmFoods
    View Form
    Filter Name
    Where Condition
    Data Mode
    Window Mode Normal

SetFilter
    Filter Name
    Where Condtion =[display_name] Like "*cheese*"
    Control Name

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Rectangle.IsVisible Property (Access)

 Copy code hover
[image]

Rectangle.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Syntax

expression .IsVisible

expression A variable that represents a Rectangle object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


DoCmd.SelectObject Method (Access)

 Copy code hover
[image]

DoCmd.SelectObject Method (Access)
See also Send feedback

Published: July 16, 2012

The SelectObject method carries out the SelectObject action in Visual Basic.

Syntax

expression .SelectObject(ObjectType, ObjectName, InNavigationPane)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
ObjectType | Required | AcObjectType | A AcObjectType constant that specifies the type of object you want to select.
ObjectName | Optional | Variant | A string expression that's the valid name of an object of the type selected by the objecttype argument. This is a required argument, unless you specify True (-1) for the InNavigationPane argument.
InNavigationPane | Optional | Variant | Use True to select the object in the Database window. Use False (0) to select an object that's already open. If you leave this argument blank, the default (False) is assumed.

Remarks

You can use the SelectObject method to select a specified database object.

The SelectObject action works with any Access object that can receive the focus. This action gives the specified object the focus and shows the object if it's hidden.

Example

The following example selects the form Customers in the Database window:

VBA Copy code Copy code
DoCmd.SelectObject acForm, "Customers", True

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


TabControl.Height Property (Access)

 Copy code hover
[image]

TabControl.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Syntax

expression .Height

expression A variable that represents a TabControl object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Application.CurrentDb Method (Access)

 Copy code hover
[image]

Application.CurrentDb Method (Access)
See also Send feedback

Published: July 16, 2012

The CurrentDb method returns an object variable of type Database that represents the database currently open in the Microsoft Access window.

Syntax

expression .CurrentDb

expression A variable that represents an Application object.

Return Value

Database

Remarks

Note Note

In Microsoft Access the CurrentDb method establishes a hidden reference to the Microsoft Office 12.0 Access Conectivity Engine object library in a Microsoft Access database.

In order to manipulate the structure of your database and its data from Visual Basic, you must use Data Access Objects (DAO). The CurrentDb method provides a way to access the current database from Visual Basic code without having to know the name of the database. Once you have a variable that points to the current database, you can also access and manipulate other objects and collections in the DAO hierarchy.

You can use the CurrentDb method to create multiple object variables that refer to the current database. In the following example, the variables dbsA and dbsB both refer to the current database:

VBA Copy code Copy code
Dim dbsA As Database, dbsB As Database
Set dbsA = CurrentDb
Set dbsB = CurrentDb
Note Note

In previous versions of Microsoft Access, you may have used the syntax DBEngine.Workspaces(0).Databases(0) or DBEngine(0)(0) to return a pointer to the current database. In Microsoft Access 2000, you should use the CurrentDb method instead. The CurrentDb method creates another instance of the current database, while the DBEngine(0)(0) syntax refers to the open copy of the current database. The CurrentDb method enables you to create more than one variable of type Database that refers to the current database. Microsoft Access still supports the DBEngine(0)(0) syntax, but you should consider making this modification to your code in order to avoid possible conflicts in a multiuser database.

If you need to work with another database at the same time that the current database is open in the Microsoft Access window, use the OpenDatabase method of a Workspace object. The OpenDatabase method doesn't actually open the second database in the Microsoft Access window; it simply returns a Database variable representing the second database. The following example returns a pointer to the current database and to a database called Contacts.mdb:

VBA Copy code Copy code
Dim dbsCurrent As Database, dbsContacts As Database
Set dbsCurrent = CurrentDb
Set dbsContacts = DBEngine.Workspaces(0).OpenDatabase("Contacts.mdb")

See also

Concepts

Application Object

Other resources

Application Object Members


Unable to retrieve the specified Registry parameter for the Synchronizer. (Error 3494)

 Copy code hover
[image]

Unable to retrieve the specified Registry parameter for the Synchronizer. (Error 3494)
Send feedback

You need to reconfigure the Synchronizer on your computer.

To configure the Synchronizer

  1. Start Replication Manager.

  2. On the Tools menu, click Configure Microsoft Replication Manager.

  3. Follow the instructions in the wizard.


Control.BottomPadding Property (Access)

 Copy code hover
[image]

Control.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the control and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .BottomPadding

expression A variable that represents a Control object.

See also

Concepts

Control Object

Other resources

Control Object Members


Page.Height Property (Access)

 Copy code hover
[image]

Page.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Syntax

expression .Height

expression A variable that represents a Page object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

Page Object

Other resources

Page Object Members


EmptyCell.Application Property (Access)

 Copy code hover
[image]

EmptyCell.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents an EmptyCell object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


Form.Section Property (Access)

 Copy code hover
[image]

Form.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Section property to identify a section of a form and provide access to the properties of that section. Read-only Section object.

Syntax

expression .Section(Index)

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | The section number or name.

Remarks

The Section property corresponds to a particular section. You can use the following constants listed below. It is recommended that you use the constants to make your code easier to read.

Setting | Constant | Description
0 | acDetail | Form detail section
1 | acHeader | Form header section
2 | acFooter | Form footer section
3 | acPageHeader | Form page header section
4 | acPageFooter | Form page footer section

For forms and reports, the Section property is an array of all existing sections in the form specified by the section number. For example, Section(0) refers to a form's detail section and Section(3) refers to a form's page header section.

You can also refer to a section by name. The following statements refer to the Detail0 section for the Customers form and are equivalent.

VBA Copy code Copy code
Forms!Customers.Section(acDetail).Visible
VBA Copy code Copy code
Forms!Customers.Section(0).Visible
VBA Copy code Copy code
Forms!Customers.Detail0.Visible

For forms and reports, you must combine the Section property with other properties that apply to form or report sections.

Example

The following example shows how to refer to the Visible property of the page header section of the Customers form.

VBA Copy code Copy code
Forms!Customers.Section(acPageHeader).Visible
Forms!Customers.Section(3).Visible

See also

Concepts

Form Object

Other resources

Form Object Members


Handling Errors in VBScript

 Copy code hover
[image]

Handling Errors in VBScript
Send feedback

There is little difference between the methods used in Visual Basic and those used with VBScript. The primary difference is that VBScript does not support the concept of error handling by continuing execution at a label. In other words, you cannot use On Error GoTo in VBScript. Instead, use in VBScript. Instead, use On Error Resume Next and then check both Err.Number and the Count property of the Errors collection, as shown in the following example:

Copy code Copy code

<!-- BeginErrorExampleVBS -->
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Error Handling Example (VBScript)</TITLE>
</HEAD>
<BODY>

<h1>Error Handling Example (VBScript)</h1>

<%
 Dim errLoop
 Dim strError

 On Error Resume Next

 ' Intentionally trigger an error.
 Set cnn1 = Server.CreateObject("ADODB.Connection")
 cnn1.Open "nothing"

 If cnn1.Errors.Count > 0 Then
 ' Enumerate Errors collection and display
 ' properties of each Error object.
 For Each errLoop In cnn1.Errors
 strError = "Error #" & errLoop.Number & "<br>" & _
 " " & errLoop.Description & "<br>" & _
 " (Source: " & errLoop.Source & ")" & "<br>" & _
 " (SQL State: " & errLoop.SQLState & ")" & "<br>" & _
 " (NativeError: " & errLoop.NativeError & ")" & "<br>"
 If errLoop.HelpFile = "" Then
 strError = strError & _
 " No Help file available" & _
 "<br><br>"
 Else
 strError = strError & _
 " (HelpFile: " & errLoop.HelpFile & ")" & "<br>" & _
 " (HelpContext: " & errLoop.HelpContext & ")" & _
 "<br><br>"
 End If
 Response.Write ("<p>" & strError & "</p>")
 Next
 End If
%>

</BODY>
</HTML>
<!-- EndErrorExampleVBS -->


Report Methods (Access)

 Copy code hover
[image]

Report Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Circle | The Circle method draws a circle, an ellipse, or an arc on a Report object when the Print event occurs.
Line | The Line method draws lines and rectangles on a Report object when the Print event occurs.
Move | Moves the specified object to the coordinates specified by the argument values.
Print | The Print method prints text on a Report object using the current color and font.
PSet | The PSet method sets a point on a Report object to a specified color when the Print event occurs.
Requery | The Requery method updates the data underlying the specified report by requerying the source of data for the control.
Scale | The Scale method defines the coordinate system for a Report object.
TextHeight | The TextHeight method returns the height of a text string as it would be printed in the current font of a Report object.
TextWidth | The TextWidth method returns the width of a text string as it would be printed in the current font of a Report object.


Module.Type Property (Access)

 Copy code hover
[image]

Module.Type Property (Access)
See also Send feedback

Published: July 16, 2012

Indicates whether a module is a standard module or a class module. Read-only AcModuleType.

Syntax

expression .Type

expression A variable that represents a Module object.

Example

The following example determines whether a Module object represents a standard module or a class module:

VBA Copy code Copy code
Function CheckModuleType(strModuleName As String) As Integer
 Dim mdl As Module

 ' Open module to include in Modules collection.
 DoCmd.OpenModule strModuleName
 ' Return reference to Module object.
 Set mdl = Modules(strModuleName)
 ' Check Type property.
 If mdl.Type = acClassModule Then
 ' Insert comment.
 mdl.InsertLines 1, "' Class module."
 CheckModuleType = acClassModule
 Else
 ' Insert comment.
 mdl.InsertLines 1, "' Standard module."
 CheckModuleType = acStandardModule
 End If
End Function

See also

Concepts

Module Object

Other resources

Module Object Members


Recordset2.Move Method (DAO)

 Copy code hover
[image]

Recordset2.Move Method (DAO)
Send feedback

Moves the position of the current record in a Recordset object.

Syntax

expression .Move(Rows, StartBookmark)

expression A variable that represents a Recordset2 object.

Parameters

Name | Required/Optional | Data Type | Description
Rows | Required | Long | The number of rows the position will move. If rows is greater than 0, the position is moved forward (toward the end of the file). If rows is less than 0, the position is moved backward (toward the beginning of the file).
StartBookmark | Optional | Variant | A value identifying a bookmark. If you specify startbookmark, the move begins relative to this bookmark. Otherwise, Move begins from the current record.

Remarks

If you use Move to position the current record pointer before the first record, the current record pointer moves to the beginning of the file. If the Recordset contains no records and its BOF property is True, using this method to move backward causes an error.

If you use Move to position the current record pointer after the last record, the current record pointer position moves to the end of the file. If the Recordset contains no records and its EOF property is True, then using this method to move forward causes an error.

If either the BOF or EOF property is True and you attempt to use the Move method without a valid bookmark, a run-time error occurs.

Note Note

  • When you use Move on a forward-only-type Recordset object, the rows argument must be a positive integer and bookmarks aren't allowed. This means you can only move forward.

  • To make the first, last, next, or previous record in a Recordset the current record, use either the MoveFirst, MoveLast, MoveNext, or MovePrevious method.

  • Using Move with rows equal to 0 is an easy way to retrieve the underlying data for the current record. This is useful if you want to make sure that the current record has the most recent data from the base tables. It will also cancel any pending Edit or AddNew calls.

Example

This example uses the Move method to position the record pointer based on user input.

VBA Copy code Copy code
Sub MoveX()

   Dim dbsNorthwind As Database
   Dim rstSuppliers As Recordset2
   Dim varBookmark As Variant
   Dim strCommand As String
   Dim lngMove As Long

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   Set rstSuppliers = _
      dbsNorthwind.OpenRecordset("SELECT CompanyName, " & _
      "City, Country FROM Suppliers ORDER BY CompanyName", _
      dbOpenDynaset)

   With rstSuppliers
      ' Populate recordset.
      .MoveLast
      .MoveFirst

      Do While True
         ' Display information about current record and ask
         ' how many records to move.
         strCommand = InputBox( _
            "Record " & (.AbsolutePosition + 1) & " of " & _
            .RecordCount & vbCr & "Company: " & _
            !CompanyName & vbCr & "Location: " & !City & _
            ", " & !Country & vbCr & vbCr & _
            "Enter number of records to Move " & _
            "(positive or negative).")

         If strCommand = "" Then Exit Do

         ' Store bookmark in case the Move doesn't work.
         varBookmark = .Bookmark

         ' Move method requires parameter of data type Long.
         lngMove = CLng(strCommand)
         .Move lngMove

         ' Trap for BOF or EOF.
         If .BOF Then
            MsgBox "Too far backward! " & _
               "Returning to current record."
            .Bookmark = varBookmark
         End If
         If .EOF Then
            MsgBox "Too far forward! " & _
               "Returning to current record."
            .Bookmark = varBookmark
         End If
      Loop
      .Close
   End With

   dbsNorthwind.Close

End Sub


Spreadsheet is full. (Error 3437)

 Copy code hover
[image]

Spreadsheet is full. (Error 3437)
Send feedback

You tried to add new records to a Lotus 1-2-3 or Microsoft Excel version 3.0 or version 4.0 file, but the file is full. Files of these types can hold a maximum of 16,384 records.


An attempt was made to import or link an empty text file. To import or link a text file, the file must contain data. (Error 3440)

 Copy code hover
[image]

An attempt was made to import or link an empty text file. To import or link a text file, the file must contain data. (Error 3440)
Send feedback

You attempted to import or link an empty text file. To import or link a text file, the file must contain data.


Label.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

Label.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified label. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthLeft

expression A variable that represents a Label object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Label Object

Other resources

Label Object Members


EOMonth Function (Access 2013 custom web app)

 Copy code hover
[image]

EOMonth Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the last day of the month before or specified number of months.

Syntax

EOMonth(Date, NumberOfMonth)

The EOMonth contains the following arguments.

Argument name | Description
Date | The start date in Date/Time format, or in an accepted text representation of a date.
NumberOfMonth | A number representing the number of months before or after the Date.

Remarks

If Date is not a valid date, EOMonth returns an error.

If Date plus NumberOfMonth yields an invalid date, EOMonth returns an error.


All valid nicknames for replicas are already in use. (Error 3555)

 Copy code hover
[image]

All valid nicknames for replicas are already in use. (Error 3555)
Send feedback

You have reached the maximum number of replicas (32,768) allowed in a replica set. Start a new replica set.


References.AddFromGuid Method (Access)

 Copy code hover
[image]

References.AddFromGuid Method (Access)
See also Send feedback

Published: July 16, 2012

The AddFromGUID method creates a Reference object based on the GUID that identifies a type library. Reference object.

Syntax

expression .AddFromGuid(Guid, Major, Minor)

expression A variable that represents a References object.

Parameters

Name | Required/Optional | Data Type | Description
Guid | Required | String | A GUID that identifies a type library.
Major | Required | Long | The major version number of the reference.
Minor | Required | Long | The minor version number of the reference.

Return Value

Reference

Remarks

The GUID property returns the GUID for a specified Reference object. If you've stored the value of the GUID property, you can use it to re-create a reference that's been broken.

Example

The following example re-creates a reference to the Microsoft Scripting Runtime version 1.0, based on its GUID on the user's system.

VBA Copy code Copy code
References.AddFromGuid "{420B2830-E718-11CF-893D-00A0C9054228}", 1, 0

See also

Concepts

References Collection

Other resources

References Object Members


What's new for Access 2013 developers

 Copy code hover
[image]

What's new for Access 2013 developers
Send feedback

Published: July 16, 2012

Learn about the features in Access 2013 that make it easy to create, deploy, and manage collaborative web-based applications on premise or in the cloud.

In this article
Introduction
New application model
Views
Programmability in Access apps
Publishing your Access app
Conclusion
Additional Resources

Introduction

Access 2013 features a new application model that is designed for one purpose―to simplify web development much like earlier versions of Access with Windows development. Access 2013 enables subject matter experts to quickly create an application that can be used to run their business. By using Microsoft SharePoint 2013 to host the front end of the app and Microsoft SQL Server 2012 as its data storage technology, Access 2013 significantly improves the manageability and scalability of Access applications. Compatibility with Microsoft Office 365 and SQL Azure significantly expand the reach of Access applications.

New application model

In an on-premise environment, Access 2013 apps are hosted by SharePoint 2013 while the data is stored in SQL Server 2012. SharePoint 2013 provides authentication, authorization, and security for Access 2013 apps. The back-end tables, views, macros, and queries are stored in a SQL Server 2012 database.

Figure 1 provides an overview of Access 2013 architecture.

Figure 1. Access 2013 architecture

Access 2013 architecture

When a new Access application is created, Access Services in SharePoint Server 2013 creates a new Application database that stores the data, view, queries and macros contained in the app. The Access Services 2013 System database can be configured to create new Application databases on a separate SQL Server 2012 server.

Using SQL Server 2012 to store data provides manageability and scalability previously unknown to Access applications. Gone are the days when an Access application would have to be redesigned and reimplemented in a more powerful environment.

An Access 2013 app is online the moment it's created. You can decide to share the app with other users, deploy to the private corporate catalog, or deploy to the Office Store.

Views

Views (known as "forms" in Access desktop databases) provide the means by which users will interact with your Access app. Views in Access 2013 apps contain a common set of user interface elements that enable rapid creation of new apps.

Access 2013 is designed to enable you to create functional views with little intervention. When you create a new table, Access automatically creates two views. Figure 2 shows a new table with the automatically-created views.

Figure 2. New table with two views

New table with two views

Views are organized by the tables they're bound to in the Tile Pane. By default, each table is represented by a tile in the Tile Pane. Figure 3 shows the Orders table selected in the Tile Pane.

Figure 3. The Tile Pane

You can rearrange the tables in the Tile Pane. You can change the name displayed on a tile, which doesn't rename its underlying table. However, deleting the tile deletes the table.

You can hide tiles that you don't want to be displayed in the web browser. When you hide a tile, you can still edit the underlying table and views in Access. Although the user can't access the views of hidden tiles directly, you can use the ChangeView or OpenPopup macro actions to display a view associated with a hidden tile. Figure 4 shows that the Related Issues and Issue Comments tiles have been hidden.

Figure 4. Hidden tiles in the view designer

Hidden tiles in the view designer

Once a tile is selected, the View Selector opens the particular view that you want to work with. Figure 5 shows that the Orders Datasheet view is selected.

Figure 5. Orders Datasheet view is active

Orders Datasheet view is active

You can remove the default views and add custom views to any tile.

View Types

There are four kinds of views that you can create in yourAccess 2013 app: List Details, Datasheet, Summary, and Blank.

List Details is one of the views Access automatically generates when you create a table. The main feature that distinguishes a list view is the list pane that appears on the left side of the view. The list pane is used to filter and navigate the records contained in the view.

The list pane can display up to three items from each record by setting its Primary, Secondary, and Thumbnail properties. Figure 6 shows that the list pane in the Employees List view is configured to display the FullName and Job Title fields.

Figure 6. List Details view

List Details view

The search box, located at the top of the list pane, filters the view by searching all values in the view.

Datasheet is the other kind of view Access automatically generates when you create a table. Datasheet views are useful for those who find it easier to enter, sort, and filter data in a spreadsheet-like manner. Figure 7 shows that the Orders Datasheet view is filtered to display the orders that have not yet shipped.

Figure 7. A filtered Datasheet view

A filtered Datasheet view

Summary views can be used to group records based on a field and optionally calculate a sum or average. The field to group by displays its values in a list view. When a group is selected, the record contained in the group is displayed in a related items control. The related items control can be configured to display up to four fields that have information about the record. A popup view can be specified if you want to drill down on the item. Figure 8 shows the Issues By Status view, a Summary view that groups the Issues table by the Status field.

Figure 8. A Summary view

A Summary view

Blank views are, as you might expect, blank when you create them. Blank views are useful for creating popup view that will contain a single record when you open it. Alternatively, you could use a Blank view to create a custom switchboard for the user to navigate your app.

Customizing a view

The Access 2013 view designer doesn't provide the pixel-perfect approach offered when you design forms in client databases. The view and its controls in Access 2013 apps support a smaller set of controls, properties and events.

The view designer is laid out as a table grid. As you add, move, and resize a control on a view, it snaps to the invisible grid. To configure a control property, select the control. One or more icons are displayed next to the control. Selecting an icon displays a popup that contains a category of properties. Access displays only the properties that are relevant in the current context. Figure 9 shows the Data properties for the ProjectComboBox control.

Figure 9. Property popup

When bound to a data source, List Detail, Datasheet, and Blank views contain an Action Bar. The Action Bar is a customizable toolbar that appears at the top of each view. By default, the Action Bar contains buttons to add, edit, save, delete, and cancel edits. You can add buttons that perform custom actions. You can also delete the default buttons, or hide the Action Bar altogether.

New controls

Access 2013 apps support two controls that are new to Access; the AutoComplete control and the Related Items control.

The AutoComplete control displays a list of records that match what you're typing into the box. Figure 10 shows an AutoComplete control bound to a list of employees.

Figure 10. AutoComplete control

As you type, the AutoComplete control displays up to eight matching records. The AutoComplete control is a good alternative to the Combo Box control when the list of items is long.

The Related Items control displays a set of records from tables related to the view's underlying table. Figure 11 shows a related items control on a view. The control is configured to have two tabs. The first tab displays issues opened by the selected employee. The second tab displays issues assigned to the selected employee

Figure 11. Related Items control

Related Items control

To edit the items in a Related Items tab, you must assign a view to its Popup view property. The specified view will open in a popup window when you choose an item.

Programmability in Access apps

Programmability in Access 2013 apps is provided by a custom macro language authored in the Access client. There are two kinds of macros, user interface (UI) macros and data macros. UI macros can perform actions that affect the user interface of your app, whereas data macros can work directly with the records contained in the app.

User Interface macros

UI macros let you perform actions such as opening another view, applying a filter, or creating a new record. "Embedded" UI macros are attached directly to user interface objects such as command buttons, combo boxes, or the Action Bar button object, whereas "standalone" UI macros are contained in macro objects.

Table 1 lists the events that you can attach a UI macro to in a control or view.

Table 1. Events supported in UI macros

Event Type | When it occurs
After Update | Occurs after you type data into a control or choose data from a control.
On Click | Occurs when a control is selected.
On Current | Occurs when the user moves to a different record in the view.
On Load | Occurs when a view is opened.

Table 2 lists the events supported by each control.

Table 2. Events supported by each control

Control or object type | Supported events
Action Bar Button | On Click
AutoComplete | After Update, On Click
Button | On Click
Check Box | After Update
Combo Box | After Update
Hyperlink | After Update, On Click
Image | On Click
Label | On Click
Multiline Textbox | After Update, On Click
Text Box | After Update, On Click
View | On Current, On Load

Reuse standalone UI macros by calling them from other macros, helping you avoid duplicate code. Standalone UI macros are visible in the Navigation Pane, under Macros. However, you can't run them directly from the Navigation Pane. Use the RunMacro action to run a standalone UI macro from an embedded UI macro.

Data macros

Data macros provide a method for implementing business rules at the data layer. Unlike UI macros, data macros can create, edit, and delete records.

"Embedded" data macros are attached to a table event. "Standalone" data macros are contained in macro objects.

Table 3 lists the events that you can attach a data macro to in a table.

Table 3. Events supported in data macros

Event type | When it occurs
On Insert | Occurs after a new record is added to the table.
On Update | Occurs after an existing record is changed.
On Delete | Occurs after a record is deleted

Figure 12 shows a data macro embedded in the On Update event of the Issues table. The data macro verifies that a resolution is selected when an issue is resolved or closed.

Figure 12. Data macro embedded in the On Update event

Data macro embedded in the On Update event

If no resolution is selected, the RaiseError macro action is used to display an error message to the user and the record is not saved.

Standalone data macros can be called from UI macros and data macros by using the RunDataMacro action. Standalone data macros can contain one or more parameters. In the data macro, use the SetReturnVar action to set a return value that the calling macro can use to determine what to do next.

Publishing your Access app

Access 2013 provides the ability for users to discover solutions directly from a private corporate catalog on SharePoint 2013 or the Office Store hosted on Office.com. The Office Store provides a convenient location for developers to upload new Access web apps aimed at both consumers and businesses. As a developer, when you upload your app to the Office Store, Microsoft runs some validation checks on it. If all tests are passed, the app package is wrapped into a file and signed by Microsoft.

Conclusion

Access 2013 introduces a new application model that enables subject matter experts to quickly create and share applications that can be used to run their business. A new interactive view designer makes it easy for users who have little or no programming experience to build apps. By using SharePoint 2013 to host the app and SQL Server 2012 to store data, Access apps are more manageable and scalable than ever. Compatibility with Office 365 and SQL Azure significantly expand the reach of Access apps.

Additional Resources

How to: Create and customize a web app in Access 2013

What's New for Office 2013 Developers


Operation Members (Access)

 Copy code hover
[image]

Operation Members (Access)
Send feedback

Published: July 16, 2012

Represents an operation defined for an Entity.

Methods

Name | Description
Execute | Executes the specified operation.

Properties

Name | Description
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
WSParameters | Gets the collection of parameters defined for the specified operation. Read-only WSParameters.


Form.Count Property (Access)

 Copy code hover
[image]

Form.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Integer.

Syntax

expression .Count

expression A variable that represents a Form object.

See also

Concepts

Form Object

Other resources

Form Object Members


You tried to lock table

 Copy code hover
[image]

You tried to lock table <table> while opening it, but the table cannot be locked because it is currently in use. Wait a moment, and then try the operation again. (Error 3009)
Send feedback

Either another user has an exclusive lock on the table that you are trying to access in a shared mode or another user has a shared lock on the table that you are trying to open exclusively. The user name that is returned will show who currently has the lock.


Recordset Object Reference (DAO)

 Copy code hover
[image]

Recordset Object Reference (DAO)
Send feedback

In this section

  • Recordset Object (DAO)

  • Recordset Members (DAO)

  • Recordset Properties (DAO)

  • Recordset Methods (DAO)


ListBox.HelpContextId Property (Access)

 Copy code hover
[image]

ListBox.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Syntax

expression .HelpContextId

expression A variable that represents a ListBox object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


CommandButton.GridlineWidthTop Property (Access)

 Copy code hover
[image]

CommandButton.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthTop

expression A variable that represents a CommandButton object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Cannot open a form whose underlying query contains a user-defined function that attempts to set or get the form's RecordsetClone property. (Error 3252)

 Copy code hover
[image]

Cannot open a form whose underlying query contains a user-defined function that attempts to set or get the form's RecordsetClone property. (Error 3252)
Send feedback

This error can occur in Microsoft Access if you execute a query that includes a user-defined function in its output and then create a form based on that query.


CheckBox.AfterUpdate Event (Access)

 Copy code hover
[image]

CheckBox.AfterUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The AfterUpdate event occurs after changed data in a control or record is updated.

Syntax

expression .AfterUpdate

expression A variable that represents a CheckBox object.

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's AfterUpdate event does occur.

To run a macro or event procedure when this event occurs, set the AfterUpdate property to the name of the macro or to [Event Procedure].

This event does not apply to option buttons, check boxes, or toggle buttons in an option group. It applies only to the option group itself.

The AfterUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

AfterUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. AfterUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For bound controls, the OldValue property isn't set to the updated value until after the AfterUpdate event for the form occurs. Even if the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


BoundObjectFrame.ColumnHidden Property (Access)

 Copy code hover
[image]

BoundObjectFrame.ColumnHidden Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.

Syntax

expression .ColumnHidden

expression A variable that represents a BoundObjectFrame object.

Remarks

For example, you might want to hide a CustomerAddress field that's too wide so you can view the CustomerName and PhoneNumber fields.

Note Note

The ColumnHidden property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

Hiding a column with the ColumnHidden property in Datasheet view doesn't hide fields from the same column in Form view. Similarly, setting a control's Visible property to False in Form view doesn't hide the corresponding column in Datasheet view.

Note Note

To set or change this property for a table or query by using Visual Basic, you must use a column's Properties collection. For details on using the Properties collection, see Properties .

You can display a field in a query even though the column for the field is hidden in table Datasheet view. You can use values from a hidden column as the criteria for a filter even though the column remains hidden after the filter is applied.

Setting a field's ColumnWidth property to 0, or resizing the field to a zero width in Datasheet view, causes Microsoft Access to set the corresponding ColumnHidden property to True. Unhiding a column restores the ColumnWidthColumnWidth property to the value it had before the field was hidden.

Note Note

The ColumnHidden property is not available in Design view.

Example

The following example hides the ProductID field in Datasheet view of the Products form.

VBA Copy code Copy code
Forms!Products!ProductID.ColumnHidden = -1

The next example also hides the ProductID field in Datasheet view of the Products table.

VBA Copy code Copy code
Public Sub SetColumnHidden()

 Dim dbs As DAO.Database
 Dim fld As DAO.Field
 Dim prp As DAO.Property
 Const conErrPropertyNotFound = 3270

 ' Turn off error trapping.
 On Error Resume Next

 Set dbs = CurrentDb

 ' Set field property.
 Set fld = dbs.TableDefs!Products.Fields!ProductID
 fld.Properties("ColumnHidden") = True

 ' Error may have occurred when value was set.
 If Err.Number <> 0 Then
 If Err.Number <> conErrPropertyNotFound Then
 On Error GoTo 0
 MsgBox "Couldn't set property 'ColumnHidden' " & _
 "on field '" & fld.Name & "'", vbCritical
 Else
 On Error GoTo 0
 Set prp = fld.CreateProperty("ColumnHidden", dbLong, True)
 fld.Properties.Append prp
 End If
 End If

 Set prp = Nothing
 Set fld = Nothing
 Set dbs = Nothing

End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


CustomControl.Verb Property (Access)

 Copy code hover
[image]

CustomControl.Verb Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Verb property to specify the operation to perform when an OLE object is activated, which is permitted when the control'sAction property is set to acOLEActivate. Read/write Long.

Syntax

expression .Verb

expression A variable that represents a CustomControl object.

Remarks

You can set the Verb property by specifying an Integer data type value indicating the position of a verb in the list of verbs returned by the ObjectVerbs property. You can set the Verb property to 1 to specify the first verb in the list, you can set it to 2 to specify the second verb in the list, and so on.

If you don't use the ObjectVerbs property to identify a specific verb, you can set the Verb property to one of the following values to indicate the operation to perform. These values specify the standard verbs supported by all objects.

Constant | Description
acOLEVerbPrimary | Performs the default operation for the object.
acOLEVerbShow | Activates the object for editing.
acOLEVerbOpen | Opens the object in a separate application window.
acOLEVerbHide | For embedded objects, hides the application that was used to create the object.

With some applications' objects, you can use these additional values.

Constant | Description
acOLEVerbInPlaceUIActivate | Activates the object for editing within the control. The menus and toolbars of the OLE server become available in the OLE container.
acOLEVerbInPlaceActivate | Activates the object within the control. The menus and toolbars of the OLE server aren't available in the OLE container.

Each object supports its own set of verbs. For example, many objects support the verbs Edit and Play. You can use the ObjectVerbs and ObjectVerbsCount properties to find out which verbs are supported by an object.

Microsoft Access automatically uses an object's default verb if the user double-clicks an object for which the AutoActivate property is set to Double-Click.

Example

The following example activates the control "OLEUnbound0" in the form "frmOperations" by opening up the OLE object in its own application window for editing. In this case, "OLEUnbound0" contains a new bitmap image, which is linked to the Microsoft Paint program.

VBA Copy code Copy code
With Forms.Item("frmOperations").Controls.Item("OLEUnbound0")
 .Action = acOLEActivate
 .Verb = acOLEVerbOpen
End With

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


MaxRecords Property Example (VB)

 Copy code hover
[image]

MaxRecords Property Example (VB)
Send feedback

This example uses the MaxRecords property to open a Recordset containing the 10 most expensive titles in the Titles table.

Copy code Copy code

'BeginMaxRecordsVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 Dim rstTitles As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim strSQLTitles As String

 ' Open a connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open recordset containing the 10 most expensive
 ' titles in the Titles table
 Set rstTitles = New ADODB.Recordset
 rstTitles.MaxRecords = 10

 strSQLTitles = "SELECT Title, Price FROM Titles ORDER BY Price DESC"
 rstTitles.Open strSQLTitles, strCnxn, adOpenStatic, adLockReadOnly, adCmdText

 ' Display the contents of the recordset
 Debug.Print "Top Ten Titles by Price:"

 Do Until rstTitles.EOF
 Debug.Print " " & rstTitles!Title & " - " & rstTitles!Price
 rstTitles.MoveNext
 Loop

 ' clean up
 rstTitles.Close
 Cnxn.Close
 Set rstTitles = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstTitles Is Nothing Then
 If rstTitles.State = adStateOpen Then rstTitles.Close
 End If
 Set rstTitles = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndMaxRecordsVB


Form.Dirty Event (Access)

 Copy code hover
[image]

Form.Dirty Event (Access)
See also Send feedback

Published: July 16, 2012

The Dirty event occurs when the contents of the specified control changes.

Syntax

expression .Dirty(Cancel, )

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the Dirty event occurs. Setting the Cancel argument to True (-1) cancels the Dirty event.

Remarks

Examples of this event include entering a character directly in the text box or combo box or changing the control's Text property setting by using a macro or Visual Basic.

  • Modifying a record within a form by using a macro or Visual Basic doesn't trigger this event. You must type the data directly into the record or set the control's Text property.

  • This event applies only to bound forms, not an unbound form or report.

To run a macro or event procedure when this event occurs, set the OnDirty property to the name of the macro or to [Event Procedure].

By running a macro or event procedure when a Dirty event occurs, you can determine if the record can be changed. You can also display a message and ask for edit permission.

Changing the data in a record by using the keyboard causes keyboard events to occur in addition to control events like the Dirty event. For example, if you move to a new record and type an ANSI character in a text box in the record, the following events occur in this order:

KeyDown > KeyPress > BeforeInsert > Dirty > KeyUp

The BeforeUpdate and AfterUpdate events for a record occur after you have entered the new or changed data in the record and moved to another record (or clicked Save Record on the Records menu), and therefore after the Dirty event for the record.

Canceling the Dirty event will cause the changes to the current record to be rolled back. It is equivalent to pressing the ESC key.

Example

The following example enables the btnUndo button when data is changed. The UndoEdits( ) subroutine is called from the Dirty event of text box controls. Clicking the enabled btnUndo button restores the original value of the control by using the OldValue property.

VBA Copy code Copy code
Private Sub Form_Dirty()
 If Me.Dirty Then
 Me!btnUndo.Enabled = True ' Enable button.
 Else
 Me!btnUndo.Enabled = False ' Disable button.
 End If
End Sub

Sub btnUndo_Click()
 Dim ctlC As Control
 ' For each control.
 For Each ctlC in Me.Controls
 If ctlC.ControlType = acTextBox Then
 ' Restore Old Value.
 ctlC.Value = ctlC.OldValue
 End If
 Next ctlC
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Report.Module Property (Access)

 Copy code hover
[image]

Report.Module Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Module property to specify a report module. Read-only Module object.

Syntax

expression .Module

expression A variable that represents a Report object.

Remarks

The Module property also returns a reference to a specified Module object.

Use the Module property to access the properties and methods of a Module object associated with a Form or Report object.

The setting of the HasModule property of a form or report determines whether it has an associated module. If the HasModule property is False, the form or report does not have an associated module. When you refer to the Module property of that form or report while in design view, Microsoft Access creates the associated module and sets the HasModule property to True. If you refer to the Module property of a form or report at run-time and the object has its HasModule property set to False, an error will occur.

You could use this property with any of the properties and methods of the module object.

Example

The following example uses the Module property to insert the Beep method in a form's Open event.

VBA Copy code Copy code
Dim strFormOpenCode As String
Dim mdl As Module

Set mdl = Forms!MyForm.Module
strFormOpenCode = "Sub Form_Open(Cancel As Integer)" _
 & vbCrLf & "Beep" & vbCrLf & "End Sub"
 With mdl
 .InsertText strFormOpenCode
 End With

See also

Concepts

Report Object

Other resources

Report Object Members


Could not open file

 Copy code hover
[image]

Could not open file <name>. (Error 3176)
Send feedback

The specified text or spreadsheet file could not be opened. The specified file specification may be invalid, another user may be accessing the file, or you may not have read privileges for the file. Wait for the other user to finish using the file and then try the operation again, or contact your system administrator or network administrator.


CommandButton.VerticalAnchor Property (Access)

 Copy code hover
[image]

CommandButton.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified button is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .VerticalAnchor

expression A variable that represents a CommandButton object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Printer.TopMargin Property (Access)

 Copy code hover
[image]

Printer.TopMargin Property (Access)
See also Send feedback

Published: July 16, 2012

Along with the LeftMargin, RightMargin, and BottomMargin properties, specifies the margins for a printed page. Read/write Long.

Syntax

expression .TopMargin

expression A variable that represents a Printer object.

See also

Concepts

Printer Object

Other resources

Printer Object Members


ObjectFrame.ObjectVerbs Property (Access)

 Copy code hover
[image]

ObjectFrame.ObjectVerbs Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ObjectVerbs property in Visual Basic to determine the list of verbs an OLE object supports. Read-only String.

Syntax

expression .ObjectVerbs(Index)

expression A variable that represents an ObjectFrame object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Long | An element in the array of supported verbs. This is a zero-based index, meaning zero (0) represents the first verb in the array, one (1) represents the second verb in the array, and so on.

Remarks

This property setting isn't available in Design view.

You can use the ObjectVerbs property with the ObjectVerbsCount property to display a list of the verbs supported by an OLE object. The ObjectVerbs property uses this list of verbs to determine which operation to perform when an OLE object is activated (when the Action property is set to acOLEActivate).

The Verb property setting is the position of a particular verb in the list of verbs returned by the ObjectVerbs property. For example, 1 specifies the first verb in the list (the Visual Basic command ObjectVerbs(0), or the first verb in the ObjectVerbs property array), 2 specifies the second verb in the list (the Visual Basic command ObjectVerbs(1), or the second verb in the ObjectVerbs property array), and so on.

The first verb in the ObjectVerbs property array, called by the Visual Basic command ObjectVerbs(0), is the default verb. If the Verb property hasn't been set, this verb specifies the operation performed when the OLE object is activated.

The list of verbs an object supports varies, depending on the state of the object. To update the list of verbs an object supports, set the control'sAction property to acOLEFetchVerbs. Be sure to update the list of verbs before presenting it to the user.

Example

The following example returns the verbs supported by the OLE object in the OLE1 control and displays each verb in a message box.

VBA Copy code Copy code
Sub GetVerbList(frm As Form, OLE1 As Control)
 Dim intX As Integer, intNumVerbs As Integer
 Dim strVerbList As String

 ' Update verb list.
 With frm!OLE1
 .Action = acOLEFetchVerbs
 intNumVerbs = .ObjectVerbsCount
 For intX = 0 To intNumVerbs - 1
 strVerbList = strVerbList & .ObjectVerbs(intX) & "; "
 Next intX
 End With

 ' Display verbs in message box.
 MsgBox Left(strVerbList, Len(strVerbList) - 2)
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


ObjectFrame.BottomPadding Property (Access)

 Copy code hover
[image]

ObjectFrame.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the object frame and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .BottomPadding

expression A variable that represents an ObjectFrame object.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Image.PictureAlignment Property (Access)

 Copy code hover
[image]

Image.PictureAlignment Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureAlignment property to specify where a background picture will appear in an image control or on a form or report. Read/write Byte.Read/write.

Syntax

expression .PictureAlignment

expression A variable that represents an Image object.

Remarks

The PictureAlignment property uses the following settings.

Setting | Visual Basic | Description
Top Left | 0 | The picture is displayed in the top-left corner of the image control, Form window, or page of a report.
Top Right | 1 | The picture is displayed in the top-right corner of the image control, Form window, or page of a report.
Center | 2 | (Default) The picture is centered in the image control, Form window, or page of a report.
Bottom Left | 3 | The picture is displayed in the bottom-left corner of the image control, Form window, or page of a report.
Bottom Right | 4 | The picture is displayed in the bottom-right corner of the image control, Form window, or page of a report.
Form Center | 5 | (Forms only) The form's picture is centered horizontally in relation to the width of the form and vertically in relation to the height the entire form.

You can also set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

This property can be set in any view.

The Form Center setting aligns a form's picture in the center of the form itself. All other PictureAlignment property settings align a form's picture in relation to the Form window. If you want to make sure that a form's picture is displayed only on the form or tiled across only the form, set the PictureAlignment property to Form Center.

For reports, the picture appears relative to a full page and not in relation to the size of the actual report. If your report is less than a full page and you want a picture to appear at a location not available through the PictureAlignment property settings, use an image control instead.

When you set the PictureTiling property to Yes, tiling of the picture will begin from the PictureAlignment property setting.

Example

The following example displays the picture "Logo.gif" in the top left corner of the "Purchase Order" report.

VBA Copy code Copy code
With Reports("Purchase Order")
 .Picture = "C:\Picture Files\Logo.gif"
 .PictureAlignment = 0
End With

See also

Concepts

Image Object

Other resources

Image Object Members


BoundObjectFrame.BackThemeColorIndex Property (Access)

 Copy code hover
[image]

BoundObjectFrame.BackThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackThemeColorIndex

expression A variable that represents a BoundObjectFrame object.

Remarks

The BackThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BackThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Background Color to the Text 2 color by setting the BackThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BackThemeColorIndex=2

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Form.OnDirty Property (Access)

 Copy code hover
[image]

Form.OnDirty Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dirty box in the Properties window of a form or report. Read/write String.

Syntax

expression .OnDirty

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Dirty event occurs when the contents of a form or the text portion of a combo box changes. It also occurs when you move from one page to another page in a tab control.

The OnClose value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dirty box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dirty box is blank, the property value is an empty string.

See also

Concepts

Form Object

Other resources

Form Object Members


CheckBox Methods (Access)

 Copy code hover
[image]

CheckBox Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.
Undo | You can use the Undo method to reset a control or form when its value has been changed.


Procedures Collection (ADOX)

 Copy code hover
[image]

Procedures Collection (ADOX)
Send feedback

Contains all Procedure objects of a catalog.

Remarks

The Append method for a Procedures collection is unique for ADOX. You can:

  • Add a new procedure to the collection with the Append method.

The remaining properties and methods are standard to ADO collections. You can:

  • Access a procedure in the collection with the Item property.

  • Return the number of procedures contained in the collection with the Count property.

  • Remove a procedure from the collection with the Delete method.

  • Update the objects in the collection to reflect the current database's schema with the Refresh method.


NavigationButton Members (Access)

 Copy code hover
[image]

NavigationButton Members (Access)
Send feedback

Published: July 16, 2012

This object represents a navigation button in a navigation control on a form.

Events

Name | Description
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Properties

Name | Description
AddColon | Specifies whether a colon (:) follows the text in labels for new controls. Read/write Boolean.
Alignment | Gets or sets how the specified button's caption and picture are aligned. Read/write Byte.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
AutoRepeat | You can use the AutoRepeat property to specify whether an event procedure or macro runs repeatedly while a command button on a form remains pressed in. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
Bevel | Gets or sets the bevel effect applied to the specified object. Read/write Long.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.
Caption | Gets or sets the text that appears in the control. Read/write String.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
CursorOnHover | Gets or sets the type of mouse cursor displayed when the user rests the pointer on a button. Read/write AcCursorOnHover.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontName | You can use the FontName property to specify the font for text in the following situations:
FontSize | You can use the FontSize property to specify the point size for text in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
FontWeight | You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
ForeShade | Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
ForeThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.
ForeTint | Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
Glow | Gets or sets the Glow effect applied to the specified object. Read/write Long.
Gradient | Gets or sets the gradient fill applied to the specified object. Read/write Long.
GridlineColor | Gets or sets the color of the gridline for the specified list box. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified list box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified text box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified text box. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified text box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified text box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified text box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the text box is anchored horizontally within its layout. Read/write.
HoverColor | Gets or sets the color displayed on the control when the user rests the mouse cursor over it. Read/write Long.
HoverForeColor | Gets or sets the color of the text displayed on the control when the user rests the mouse cursor over it. Read/write Long.
HoverForeShade | Gets or sets the shade applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.
HoverForeThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverForeColor property of the specified object. Read/write Long.
HoverForeTint | Gets or sets the tint applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.
HoverShade | Gets or sets the shade that is applied to the theme color in the HoverColor property of the specified object. Read/write Single.
HoverThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverColor property of the specified object. Read/write Long.
HoverTint | Gets or sets the tint applied to the theme color in the HoverColor property of the specified object. Read/write Single.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
HyperlinkAddress | You can use the HyperlinkAddress property to specify or determine the path to an object, document, Web page or other destination for a hyperlink associated with a the specified control. Read/write String.
HyperlinkSubAddress | You can use the HyperlinkSubAddress property to specify or determine a location within the target document specified by the HyperlinkAddress property. Read/write String.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified text box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified text box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
NavigationTargetName | Gets or sets the name of the form or report to be displayed when the user click the specified navigation button. Read/write String.
NavigationWhereClause | Gets or sets the filter criteria applied when opening the form or report associated with the specified navigation button. Read/write String.
ObjectPalette | The ObjectPalette property specifies the palette in the application used to create A bitmap or other graphic that is loaded into the specified control by using the Picture property. Read/write Variant.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnPush | Sets or returns the value of the On Click box in the Properties window of a command button. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
ParentTab | Gets the top-level navigation button associated with the specified navigation button. Read-only NavigationButton.
Picture | You can use the Picture property to specify a bitmap or other type of graphic to be displayed on the specified control. Read/write String.
PictureCaptionArrangement | Gets or sets how the specified button's caption is arranged in relation to its picture. Read/write AcPictureCaptionArrangement.
PictureData | You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.
PictureType | You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.
PressedColor | Gets or sets the color displayed on the control when the user clicks it. Read/write Long.
PressedForeColor | Gets or sets the color of the text displayed on the control when the user clicks it. Read/write Long.
PressedForeShade | Gets or sets the shade applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.
PressedForeThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedForeColor property of the specified object. Read/write Long.
PressedForeTint | Gets or sets the tint applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.
PressedShade | Gets or sets the shade that is applied to the theme color in the PressedColor property of the specified object. Read/write Single.
PressedThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedColor property of the specified object. Read/write Long.
PressedTint | Gets or sets the tint applied to the theme color in the PressedColor property of the specified object. Read/write Single.
Properties | Returns a reference to a control's Properties collection object. Read-only.
QuickStyle | Gets or sets the Quick Style that is applied to the specified object. Read/write Long.
QuickStyleMask | Gets or sets modifications to the Quick Style that is applied to the specified object. Read/write Long.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
RightPadding | Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
Shadow | Gets or sets the Shadow effect applied to the specified object. Read/write Long.
Shape | Returns or sets the shape of the specifiednavigation button. Read/write Long.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SoftEdges | Gets or sets the Soft Edges effect applied to the specified object. Read/write Long.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
ThemeFontIndex | Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.
Transparent | You can use the Transparent property to specify whether a command button is solid or transparent. Read/write Boolean.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified text box is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


FormatCondition.FontBold Property (Access)

 Copy code hover
[image]

FormatCondition.FontBold Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontBold property to specify whether a font appears in a bold style in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontBold

expression A variable that represents a FormatCondition object.

Remarks

The FontBold property uses the following settings.

Setting | Description
True | The text is bold.
False | (Default) The text isn't bold.

To use the FontBold property on a report, first create a Printevent procedure that prints the desired text.

A font's appearance on screen and in print may differ, depending on your computer and printer.

The FontWeight property, which is available in the property sheet for controls, can also be used to set the line width for a control's text. The FontBold property gives you a quick way to make text bold; the FontWeight property gives you finer control over the line width setting for text. The following table shows the relationship between these properties' settings.

If | Then
FontBold = False | FontWeight = Normal (400)
FontBold = True | FontWeight = Bold (700)
FontWeight < 700 | FontBold = False
FontWeight > = 700 | FontBold = True

Example

The following Print event procedure prints a report title and the current date in a bold style on a report at the coordinates specified by the CurrentX and CurrentY property settings.

VBA Copy code Copy code
Private Sub ReportHeader0_Print(Cancel As Integer, _
 PrintCount As Integer)
 Dim MyDate

 MyDate = Date
 Me.FontBold = True
 ' Print report title in bold.
 Me.Print("Sales Management Report")
 Me.Print(MyDate)
End Sub

See also

Concepts

FormatCondition Object

Other resources

FormatCondition Object Members


NavigationControl.DisplayWhen Property (Access)

 Copy code hover
[image]

NavigationControl.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .DisplayWhen

expression A variable that represents a NavigationControl object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


How to: Modify an Existing Record in a DAO Recordset

 Copy code hover
[image]

How to: Modify an Existing Record in a DAO Recordset
Send feedback

You can modify existing records in a table-type or dynaset-type Recordset object by using the Edit and Update methods.

To modify an existing record in a table-type or dynaset-type Recordset object:

  1. Go to the record that you want to change.

  2. Use the Edit method to prepare the current record for editing.

  3. Make the necessary changes to the record.

  4. Use the Update method to save the changes to the current record.

The following code example shows how to change the job titles for all sales representatives in a table called Employees.

VBA Copy code Copy code
Dim dbsNorthwind As DAO.Database
Dim rstEmployees As DAO.Recordset

   Set dbsNorthwind = CurrentDb
   Set rstEmployees = dbsNorthwind.OpenRecordset("Employees")

   rstEmployees.MoveFirst
   Do Until rstEmployees.EOF
      If rstEmployees!Title = "Sales Representative" Then
         rstEmployees.Edit
         rstEmployees!Title = "Account Executive"
         rstEmployees.Update
      End If
      rstEmployees.MoveNext
   Loop
Note Note

If you do not use the Edit method before you try to change a value in the current record, a run-time error occurs. If you edit the current record and then move to another record or close the Recordset object without first using the Update method, your changes are lost without warning. For example, omitting the Update method from the preceding example results in no changes being made to the Employees table.

You can also terminate the Edit method and any pending transactions without saving changes by using the CancelUpdate method. While you can terminate the Edit method just by moving off the current record, this is not practical when the current record is the first or last record in the Recordset, or when it is a new record. It is generally simpler to use the CancelUpdate method.


OptionButton.KeyPress Event (Access)

 Copy code hover
[image]

OptionButton.KeyPress Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Syntax

expression .KeyPress(KeyAscii)

expression A variable that represents an OptionButton object.

Parameters

Name | Required/Optional | Data Type | Description
KeyAscii | Required | Integer | Returns a numeric ANSI key code. The KeyAscii argument is passed by reference; changing it sends a different character to the object. Setting the KeyAscii argument to 0 cancels the keystroke so that the object doesn't recognize that a key was pressed.

Remarks

To run a macro or event procedure when this event occurs, set the OnKeyPress property to the name of the macro or to [Event Procedure].

The object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down an ANSI key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

A KeyPress event can involve any printable keyboard character, the CTRL key combined with a character from the standard alphabet or a special character, and the ENTER or BACKSPACE key. You can use the KeyDown and KeyUp event procedures to handle any keystroke not recognized by the KeyPress event, such as function keys, navigation keys, and any combinations of these with keyboard modifiers (ALT, SHIFT, or CTRL keys). Unlike the KeyDown and KeyUp events, the KeyPress event doesn't indicate the physical state of the keyboard; instead, it indicates the ANSI character that corresponds to the pressed key or key combinations.

KeyPress interprets the uppercase and lowercase of each character as separate key codes and, therefore, as two separate characters.

Note Note

The BACKSPACE key is part of the ANSI character set, but the DEL key isn't. If you delete a character in a control by using the BACKSPACE key, you cause a KeyPress event; if you use the DEL key, you don't.

The KeyDown and KeyPress events occur when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

For example, if you go to a new record and type a character in the first control in the record, the following events occur:

Current (for the new record)

ß

Enter (for the first control in the new record)

ß

GotFocus (for the control)

ß

KeyDown (for the control)

ß

KeyPress (for the control)

ß

BeforeInsert (for the new record in the form)

ß

Change (for the control if it's a text box or combo box)

ß

KeyUp (for the control)

Example

The following example converts text entered in a text box to uppercase as the text is typed in, one character at a time.

To try the example, add the following event procedure to a form that contains a text box named ShipRegion.

VBA Copy code Copy code
Private Sub ShipRegion_KeyPress(KeyAscii As Integer)
 Dim strCharacter As String

 ' Convert ANSI value to character string.
 strCharacter = Chr(KeyAscii)
 ' Convert character to upper case, then to ANSI value.
 KeyAscii = Asc(UCase(strCharacter))
End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect. (Error 3141)

 Copy code hover
[image]

The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect. (Error 3141)
Send feedback

You entered an SQL statement that has an invalid SELECT statement.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


BoundObjectFrame Members (Access)

 Copy code hover
[image]

BoundObjectFrame Members (Access)
Send feedback

Published: July 16, 2012

A bound object frame object displays a picture, chart, or any OLE object stored in a table in a Microsoft Access database. For example, if you store pictures of your employees in a table in Microsoft Access, you can use a bound object frame to display these pictures on a form or report.

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.
Updated | The Updated event occurs when an OLE object's data has been modified.

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Properties

Name | Description
Action | You can use the Action property in Visual Basic to specify the operation to perform on an OLE object. Read/write Integer.
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoActivate | You can use the AutoActivate property to specify how the user can activate an OLE object. Read/write Integer.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the object frame and its bottom gridline. Read/write Integer.
Class | You can use the Class property to specify or determine the class name of an embeddedOLE object. Read/write String.
ColumnHidden | You can use the ColumnHidden property to show or hide a specified column in Datasheet view. Read/write Boolean.
ColumnOrder | You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.
ColumnWidth | You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayType | You can use the DisplayType property to specify whether Microsoft Access displays an OLE object's content or an icon. Read/write Boolean.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
GridlineColor | Gets or sets the color of the gridline for the specified object frame. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified frame. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified frame. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified frame. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified frame. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified frame. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified frame. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified frame. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified frame. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the object frame is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified object frame. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified object frame. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the object frame and its left gridline. Read/write Integer.
Locked | The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Object | You can use the Object property in Visual Basic to return a reference to the ActiveX object that is associated with a linked or embedded OLE object in a control. By using this reference, you can access the properties or invoke the methods of the OLE object. Read-only Object.
ObjectPalette | The ObjectPalette property specifies the palette in the application used to create an OLE object. Read/write Variant.
ObjectVerbs | You can use the ObjectVerbs property in Visual Basic to determine the list of verbs an OLE object supports. Read-only String.
ObjectVerbsCount | You can use the ObjectVerbsCount property in Visual Basic to determine the number of verbs supported by an OLE object. Read-only Long.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OLEType | You can use the OLEType property to determine if a control contains an OLE object, and, if so, whether the object is linked or embedded. Read/write Byte.
OLETypeAllowed | You can use the OLETypeAllowed property to specify the type of OLE object a control can contain. Read/write Byte.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnUpdated | Sets or returns the value of the On Updated box in the Properties window of a form or report. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
RightPadding | Gets or sets the amount of space (in inches) between the object frame and its right gridline. Read/write Integer.
Scaling | Controls how the contents of an object frame control are displayed. Read/write Byte.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SizeMode | You can use the SizeMode property to specify how to size a picture or other object in a bound object frame, an unbound object frame, or an image control.
SourceDoc | You can use the SourceDoc property to specify the file to create a link to or to embed when you create a linked object or embedded object by using the Action property in Visual Basic. Read/write String.
SourceItem | You can use the SourceItem property to specify the data within a file to be linked when you create a linked OLE object. Read/write String.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the object frame and its top gridline. Read/write Integer.
UpdateOptions | You can use the UpdateOptions property to specify how a linkedOLE object is updated. Read/write Integer.
Value | Gets of sets the value of the field that the control is bound to. Read/write Variant.
VarOleObject | Gets a pointer to an IOLEObject that represents the memory address of an OLE object. Read-only Variant.
Verb | You can use the Verb property to specify the operation to perform when an OLE object is activated, which is permitted when the control'sAction property is set to acOLEActivate. Read/write Long.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified object frame is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


Application.ColumnHistory Method (Access)

 Copy code hover
[image]

Application.ColumnHistory Method (Access)
See also Send feedback

Published: July 16, 2012

Gets the history of values that have been stored in a Memo field.

Version Information

Version Added: Access 2007

Syntax

expression .ColumnHistory(TableName, ColumnName, queryString)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
TableName | Required | String | The name of the table that contains the Append Only field.
ColumnName | Required | String | The name of the field to display the history for.
queryString | Required | String | A String used to locate the record. It is like the WHERE clause in an SQL statement, but without the word WHERE.

Return Value

String

Remarks

A Memo field's AppendOnly property must be set to True in order for Access to store the change history for the field.

Example

The following example prints the salary history of employee number 147 to the Immediate window.

VBA Copy code Copy code
Sub colhist()
 Dim sHistory As String

 sHistory = Application.ColumnHistory("Employees", "Salary", "ID=147")
 Debug.Print sHistory
End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


Cannot delete this field. It is part of one or more relationships. (Error 3303)

 Copy code hover
[image]

Cannot delete this field. It is part of one or more relationships. (Error 3303)
Send feedback

You are trying to delete a field for which relationships have been defined in the database. To delete the field, you must first delete its relationships.


Report.Hwnd Property (Access)

 Copy code hover
[image]

Report.Hwnd Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the hWnd property to determine the handle (a unique Long Integer value) assigned by Microsoft Windows to the current window. Read/write Long.

Syntax

expression .Hwnd

expression A variable that represents a Report object.

Remarks

You can use this property in Visual Basic when making calls to Windows application programming interface (API) functions or other external routines that require the hWnd property as an argument. Many Windows functions require the hWnd property value of the current window as one of the arguments.

Note Note

Because the value of this property can change while a program is running, don't store the hWnd property value in a public variable.

Example

The following example uses the hWnd property with the Windows API IsZoomed function to determine if a window is maximized.

VBA Copy code Copy code
' Enter on single line in Declarations section of Module window.
Declare Function IsZoomed Lib "user32" (ByVal hWnd As Long) As Long

Sub Form_Activate()
 Dim intWindowHandle As Long
 intWindowHandle = Screen.ActiveForm.hWnd
 If Not IsZoomed(intWindowHandle) Then
 DoCmd.Maximize
 End If
End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


Database.Recordsets Property (DAO)

 Copy code hover
[image]

Database.Recordsets Property (DAO)
Send feedback

Returns a Recordsets collection that contains all of the open recordsets in the for the specified database. Read-only.

Syntax

expression .Recordsets

expression A variable that represents a Database object.


WebBrowserControl.LayoutID Property (Access)

 Copy code hover
[image]

WebBrowserControl.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified text box. Read-only Long.

Version Information

Version Added: Access 2010

Syntax

expression .LayoutID

expression A variable that represents a WebBrowserControl object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Handling Errors in Other Languages (ADO)

 Copy code hover
[image]

Handling Errors in Other Languages (ADO)
Send feedback

In this section

  • Handling Errors in JScript

  • Handling Errors In Other Languages

  • Handling Errors in VBScript

  • Handling Errors in Visual C++


In the fixed width specification

 Copy code hover
[image]

In the fixed width specification <name>, column <column> does not specify a width. (Error 3444)
Send feedback

No column width parameter is specified in the text file specification for the Text ISAM is invalid.


Application.NewAccessProject Method (Access)

 Copy code hover
[image]

Application.NewAccessProject Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the NewAccessProject method to create and open a new Microsoft Access project (.adp) as the current Access project in the Microsoft Access window.

Syntax

expression .NewAccessProject(filepath, Connect)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
filepath | Required | String | the name of the new Access project, including the path name and the file name extension.
Connect | Optional | Variant | The connection string for the Access project. See the ADO ConnectionString property for details about this string.

Return Value

Nothing

Remarks

The NewAccessProject method enables you to create a new Access project from within Microsoft Access or another application through Automation, formally called OLE Automation. For example, you can use the NewAccessProject method from Microsoft Excel to create a new Access project in the Access window. Once you have created an instance of Microsoft Access from another application, you must also create a new Access project. This Access project opens in the Microsoft Access window.

If the Access project identified by projname already exists, an error occurs.

The new Access project is opened under the Admin user account .

Note Note

To open an Access database, use the NewCurrentDatabase method of the Application object.

See also

Concepts

Application Object

Other resources

Application Object Members


Document.DateCreated Property (DAO)

 Copy code hover
[image]

Document.DateCreated Property (DAO)
Send feedback

Returns the date and time that an object was created. Read-only Variant.

Syntax

expression .DateCreated

expression A variable that represents a Document object.


Label.GridlineWidthRight Property (Access)

 Copy code hover
[image]

Label.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified label. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthRight

expression A variable that represents a Label object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Label Object

Other resources

Label Object Members


CommandButton.OnLostFocus Property (Access)

 Copy code hover
[image]

CommandButton.OnLostFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnLostFocus

expression A variable that represents a CommandButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The LostFocus event occurs when the object loses the focus.

The OnLostFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Lost Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Lost Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnLostFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnLostFocus

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


WebServices Properties (Access)

 Copy code hover
[image]

WebServices Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Object.
Parent | Returns the parent object for the specified object. Read-only.


ImportExportSpecifications.Count Property (Access)

 Copy code hover
[image]

ImportExportSpecifications.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Version Information

Version Added: Access 2007

Syntax

expression .Count

expression A variable that represents an ImportExportSpecifications object.

See also

Concepts

ImportExportSpecifications Collection

Other resources

ImportExportSpecifications Object Members


Cannot place this validation expression on this field. (Error 3313)

 Copy code hover
[image]

Cannot place this validation expression on this field. (Error 3313)
Send feedback

You are trying to set validation properties on a field (such as an AutoNumber or OLE Object field) that does not allow this type of property. Use a different field to validate data or, if you have not added data to the table, redefine the data type for the field.


ComboBox.OnChange Property (Access)

 Copy code hover
[image]

ComboBox.OnChange Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Change box in the Properties window of one of the objects in the Applies To list. Read/write String.

Syntax

expression .OnChange

expression A variable that represents a ComboBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Change event occurs when the contents of a text box or the text portion of a combo box changes. It also occurs when you move from one page to another page in a tab control.

The OnChange value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Change box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Change box is blank, the property value is an empty string.

Example

The following example prints the value of the OnChange property in the Immediate window for the "Address" text box on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("Address").OnChange

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


BoundObjectFrame.BorderColor Property (Access)

 Copy code hover
[image]

BoundObjectFrame.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Syntax

expression .BorderColor

expression A variable that represents a BoundObjectFrame object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Move Method Example (VB)

 Copy code hover
[image]

Move Method Example (VB)
Send feedback

This example uses the Move method to position the record pointer based on user input.

Copy code Copy code

'BeginMoveVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 ' connection and recordset variables
 Dim rstAuthors As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim strSQLAuthors As String
 ' record variables
 Dim varBookmark As Variant
 Dim strCommand As String
 Dim lngMove As Long

 ' Open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open recordset from Authors table
 Set rstAuthors = New ADODB.Recordset
 rstAuthors.CursorLocation = adUseClient
 ' Use client cursor to allow use of AbsolutePosition property
 strSQLAuthors = "SELECT au_id, au_fname, au_lname, city, state FROM Authors ORDER BY au_lname"
 rstAuthors.Open strSQLAuthors, strCnxn, adOpenStatic, adLockOptimistic, adCmdText

 rstAuthors.MoveFirst

 Do
 ' Display information about current record and
 ' ask how many records to move

 strCommand = InputBox( _
 "Record " & rstAuthors.AbsolutePosition & _
 " of " & rstAuthors.RecordCount & vbCr & _
 "Author: " & rstAuthors!au_fname & _
 " " & rstAuthors!au_lname & vbCr & _
 "Location: " & rstAuthors!city & _
 ", " & rstAuthors!State & vbCr & vbCr & _
 "Enter number of records to Move " & _
 "(positive or negative).")

 ' this is for exiting the loop
 'lngMove = CLng(strCommand)

 lngMove = CLng(Val(strCommand))
 If lngMove = 0 Then
 MsgBox "You either entered a non-number or canceled the input box. Exit the application."
 Exit Do
 End If

 ' Store bookmark in case the Move goes too far
 ' forward or backward
 varBookmark = rstAuthors.Bookmark

 ' Move method requires parameter of data type Long
 rstAuthors.Move lngMove

 ' Trap for BOF or EOF
 If rstAuthors.BOF Then
 MsgBox "Too far backward! Returning to current record."
 rstAuthors.Bookmark = varBookmark
 End If
 If rstAuthors.EOF Then
 MsgBox "Too far forward! Returning to current record."
 rstAuthors.Bookmark = varBookmark
 End If
 Loop

 ' clean up
 rstAuthors.Close
 Cnxn.Close
 Set rstAuthors = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstAuthors Is Nothing Then
 If rstAuthors.State = adStateOpen Then rstAuthors.Close
 End If
 Set rstAuthors = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndMoveVB


CheckBox.TopPadding Property (Access)

 Copy code hover
[image]

CheckBox.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the check box and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .TopPadding

expression A variable that represents a CheckBox object.

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Table is not open. (Error 3160)

 Copy code hover
[image]

Table is not open. (Error 3160)
Send feedback

You tried to perform an operation on a table that has not been opened. Open the table, and then try the operation again.


Report.GridY Property (Access)

 Copy code hover
[image]

Report.GridY Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the GridY property (along with the GridX property) to specify the horizontal and vertical divisions of the alignment grid in report Design view. Read/write Integer.

Syntax

expression .GridY

expression A variable that represents a Report object.

Remarks

Enter an integer between 1 and 64 representing the number of subdivisions per unit of measurement. If the Measurement system box is set to U.S. on the Numbers tab of the Regional Options dialog box of Windows Control Panel, the default setting is 24 for the GridX property (horizontal) and 24 for the GridY property (vertical).

In Visual Basic, you set this property by using a numeric expression.

The GridX and GridY properties provide control over the placement and alignment of objects on a form or report. You can adjust the grid for greater or lesser precision. To see the grid, click Grid on the View menu. If the setting for either the GridX or GridY properties is greater than 24, the grid points disappear from view (although the grid lines are still displayed).

See also

Concepts

Report Object

Other resources

Report Object Members


Cannot delete this index or table. It is either the current index or is used in a relationship. (Error 3281)

 Copy code hover
[image]

Cannot delete this index or table. It is either the current index or is used in a relationship. (Error 3281)
Send feedback

If the index or table is used in a relationship, you must delete the relationship before you can delete the index or table. If the index is specified as the current index by the Index property, you must set the property to a different index before you can delete the index.


CommandButton.ObjectPalette Property (Access)

 Copy code hover
[image]

CommandButton.ObjectPalette Property (Access)
See also Send feedback

Published: July 16, 2012

The ObjectPalette property specifies the palette in the application used to create A bitmap or other graphic that is loaded into the specified control by using the Picture property. Read/write Variant.

Syntax

expression .ObjectPalette

expression A variable that represents a CommandButton object.

Remarks

Microsoft Access sets the value of the ObjectPalette property to a String data type containing the palette information. You can use this setting to set the value of the PaintPalette property for a form or report.

If the application associated with the bitmap or other graphic doesn't have an associated palette, the ObjectPalette property is set to an zero-length string.

The ObjectPalette property is read-only in Form Design view, Form view, and Report Design view. This property setting is unavailable in other views.

The setting of the ObjectPalette property makes the palette of the application associated with the OLE object contained in a control available to the PaintPalette property of a form or report. For example, to make the palette used in Microsoft Graph available when you're designing a form in Microsoft Access, you set the form's PaintPalette property to the ObjectPalette value of an existing chart control.

Note Note

Windows can have only one color palette active at a time. Microsoft Access allows you to have multiple graphics on a form, each using a different color palette. The PaintPalette and PaletteSource properties let you specify which color palette a form should use when displaying graphics.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Form.RecordSourceQualifier Property (Access)

 Copy code hover
[image]

Form.RecordSourceQualifier Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating the SQL Server owner name of the record source for the specified form. Read/write.

Syntax

expression .RecordSourceQualifier

expression A variable that represents a Form object.

See also

Concepts

Form Object

Other resources

Form Object Members


Without Administrator permission, replica priority must be in the range 0 -

 Copy code hover
[image]

Without Administrator permission, replica priority must be in the range 0 - <number>. (Error 3772)
Send feedback

Without Administrator permission, replica priority must be in the range of 0 and the number of the priority from which the new replica is being created.


NavigationControl.SmartTags Property (Access)

 Copy code hover
[image]

NavigationControl.SmartTags Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a SmartTags collection that represents the collection of smart tags that have been added to a control. .

Version Information

Version Added: Access 2010

Syntax

expression .SmartTags

expression A variable that represents a NavigationControl object.

Remarks

Note Note

Unlike the SmartTags collections in Microsoft Excel and Microsoft Word, the SmartTags collection in Microsoft Access is zero-based. Therefore, the code control.SmartTags(0) returns the first smart tag for the specified control.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Containers Members (DAO)

 Copy code hover
[image]

Containers Members (DAO)
Send feedback
Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.A Connections collection contains the current Connection objects of a Workspace object. (ODBCDirect workspaces only).

Methods

Name | Description
Refresh | Not supported for the Connections collection.

Properties

Name | Description
Count | Returns the number of Connection objects in the Connections collection.


Report.DblClick Event (Access)

 Copy code hover
[image]

Report.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an report within the double-click time limit of the system.

Syntax

expression .DblClick(Cancel)

expression A variable that represents a Report object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the DblClick event occurs. Setting the Cancel argument to True (-1) cancels the DblClick event.

Remarks

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

See also

Concepts

Report Object

Other resources

Report Object Members


ObjectFrame.VarOleObject Property (Access)

 Copy code hover
[image]

ObjectFrame.VarOleObject Property (Access)
See also Send feedback

Published: July 16, 2012

Gets a pointer to an IOLEObject that represents the memory address of an OLE object. Read-only Variant.

Version Information

Version Added: Access 2010

Syntax

expression .VarOleObject

expression A variable that represents an ObjectFrame object.

Remarks

Note Note

The VarOleObject property is compatible with 32-bit and 64-bit OLE objects. It replaces the LpOLEObject, which was available in earlier versions of Microsoft Access.

You can use the VarOleObject property to refer to the address of the active OLE object. If no object is displayed, the setting is 0.

This property setting is not available in Design view and is read-only in other views.

In the OLE dynamic link libraries (DLLs), many function calls require the address of the OLE object as an argument. You can pass the value specified by the VarOleObject property when you make application programming interface (API) calls to the OLE DLLs.

If an API call is made to a function that performs a callback to the control, the results are unpredictable.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


TabControl.TabFixedWidth Property (Access)

 Copy code hover
[image]

TabControl.TabFixedWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabFixedWidth property to specify or determine the width of the tabs on a tab control. Read/write Integer.

Syntax

expression .TabFixedWidth

expression A variable that represents a TabControl object.

Remarks

The TabFixedWidth property setting is a value that represents the width of tabs in the unit of measurement specified in the Regional Options dialog box in Windows Control Panel. If you set this property to zero, the tabs automatically adjust to the width of the tab contents.

You can also set the default for this property by setting a control's DefaultControl property in Visual Basic.

Tthis property uses an Integer value representing the width of the tabs in twips and can be set in any view.

Note Note

To use a unit of measurement different from the setting in the Regional Options dialog box in Windows Control Panel, specify the unit, such as cm or in (for example, 5 cm or 3 in).

You can't change the color of a tab control. If the tabs don't cover the width of the tab control, the area behind the tabs is displayed. If you place a tab control on an object with a different color than the tab control, you should make sure that the tabs cover the control's background area.

Example

The following example sets the width of each tab in the tab control "TabCtl1" on the "Mailing List" form to 2000 twips.

VBA Copy code Copy code
Forms("Mailing List").Controls("TabCtl1").TabFixedWidth = 2000

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


State Property Example (VB)

 Copy code hover
[image]

State Property Example (VB)
Send feedback

This example uses the State property to display a message while asynchronous connections are opening and asynchronous commands are executing.

Copy code Copy code

'BeginStateVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 Dim Cnxn1 As ADODB.Connection
 Dim Cnxn2 As ADODB.Connection
 Dim cmdChange As ADODB.Command
 Dim cmdRestore As ADODB.Command
 Dim strCnxn As String
 Dim strSQL As String

 ' Open two asynchronous connections, displaying
 ' a message while connecting
 Set Cnxn1 = New ADODB.Connection
 Set Cnxn2 = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"

 Cnxn1.Open strCnxn, , , adAsyncConnect
 Do Until Cnxn1.State <> adStateConnecting
 Debug.Print "Opening first connection...."
 Loop

 Cnxn2.Open strCnxn, , , adAsyncConnect
 Do Until Cnxn2.State <> adStateConnecting
 Debug.Print "Opening second connection...."
 Loop

 ' Create two command objects
 Set cmdChange = New ADODB.Command
 cmdChange.ActiveConnection = Cnxn1
 strSQL = "UPDATE Titles SET type = 'self_help' WHERE type = 'psychology'"
 cmdChange.CommandText = strSQL

 Set cmdRestore = New ADODB.Command
 cmdRestore.ActiveConnection = Cnxn2
 strSQL = "UPDATE Titles SET type = 'psychology' WHERE type = 'self_help'"
 cmdRestore.CommandText = strSQL

 ' Executing the commands, displaying a message
 ' while they are executing
 cmdChange.Execute , , adAsyncExecute
 Do Until cmdChange.State <> adStateExecuting
 Debug.Print "Change command executing...."
 Loop

 cmdRestore.Execute , , adAsyncExecute
 Do Until cmdRestore.State <> adStateExecuting
 Debug.Print "Restore command executing...."
 Loop

 ' clean up
 Cnxn1.Close
 Cnxn2.Close
 Set Cnxn1 = Nothing
 Set Cnxn2 = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not Cnxn1 Is Nothing Then
 If Cnxn1.State = adStateOpen Then Cnxn1.Close
 End If
 Set Cnxn1 = Nothing

 If Not Cnxn2 Is Nothing Then
 If Cnxn2.State = adStateOpen Then Cnxn2.Close
 End If
 Set Cnxn2 = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndStateVB


Recordset2.GetRows Method (DAO)

 Copy code hover
[image]

Recordset2.GetRows Method (DAO)
Send feedback

Retrieves multiple rows from a Recordset object.

Syntax

expression .GetRows(NumRows)

expression A variable that represents a Recordset2 object.

Parameters

Name | Required/Optional | Data Type | Description
NumRows | Optional | Variant | The number of rows to retrieve.

Return Value

Variant

Remarks

Use the GetRows method to copy records from a Recordset. GetRows returns a two-dimensional array. The first subscript identifies the field and the second identifies the row number. For example, intField represents the field, and intRecord identifies the row number:

avarRecords(intField, intRecord)

To get the first field value in the second row returned, use code like the following:

field1 = avarRecords(0,1)

To get the second field value in the first row, use code like the following:

field2 = avarRecords(1,0)

The avarRecords variable automatically becomes a two-dimensional array when GetRows returns data.

If you request more rows than are available, then GetRows returns only the number of available rows. You can use the Visual Basic for Applications UBound function to determine how many rows GetRows actually retrieved, because the array is sized to fit the number of returned rows. For example, if you returned the results into a Variant called varA, you could use the following code to determine how many rows were actually returned:

numReturned = UBound(varA,2) + 1

You need to use "+ 1" because the first row returned is in the 0 element of the array. The number of rows that you can retrieve is constrained by the amount of available memory. You shouldn't use GetRows to retrieve an entire table into an array if it is large.

Because GetRows returns all fields of the Recordset into the array, including Memo and Long Binary fields, you might want to use a query that restricts the fields returned.

After you call GetRows, the current record is positioned at the next unread row. That is, GetRows has the same effect on the current record as Move numrows.

If you are trying to retrieve all the rows by using multiple GetRows calls, use the EOF property to be sure that you're at the end of the Recordset. GetRows returns less than the number requested if it's at the end of the Recordset, or if it can't retrieve a row in the range requested. For example, if you're trying to retrieve 10 records, but you can't retrieve the fifth record, GetRows returns four records and makes the fifth record the current record. This will not generate a run-time error. This might occur if another user deletes a record in a dynaset-type Recordset. See the example for a demonstration of how to handle this.

Example

This example uses the GetRows method to retrieve a specified number of rows from a Recordset and to fill an array with the resulting data. The GetRows method will return fewer than the desired number of rows in two cases: either if EOF has been reached, or if GetRows tried to retrieve a record that was deleted by another user. The function returns False only if the second case occurs. The GetRowsOK function is required for this procedure to run.

VBA Copy code Copy code
Sub GetRowsX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset2
 Dim strMessage As String
 Dim intRows As Integer
 Dim avarRecords As Variant
 Dim intRecord As Integer

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = dbsNorthwind.OpenRecordset( _
 "SELECT FirstName, LastName, Title " & _
 "FROM Employees ORDER BY LastName", dbOpenSnapshot)

 With rstEmployees
 Do While True
 ' Get user input for number of rows.
 strMessage = "Enter number of rows to retrieve."
 intRows = Val(InputBox(strMessage))

 If intRows <= 0 Then Exit Do

 ' If GetRowsOK is successful, print the results,
 ' noting if the end of the file was reached.
 If GetRowsOK(rstEmployees, intRows, _
 avarRecords) Then
 If intRows > UBound(avarRecords, 2) + 1 Then
 Debug.Print "(Not enough records in " & _
 "Recordset to retrieve " & intRows & _
 " rows.)"
 End If
 Debug.Print UBound(avarRecords, 2) + 1 & _
 " records found."

 ' Print the retrieved data.
 For intRecord = 0 To UBound(avarRecords, 2)
 Debug.Print " " & _
 avarRecords(0, intRecord) & " " & _
 avarRecords(1, intRecord) & ", " & _
 avarRecords(2, intRecord)
 Next intRecord
 Else
 ' Assuming the GetRows error was due to data
 ' changes by another user, use Requery to
 ' refresh the Recordset and start over.
 If .Restartable Then
 If MsgBox("GetRows failed--retry?", _
 vbYesNo) = vbYes Then
 .Requery
 Else
 Debug.Print "GetRows failed!"
 Exit Do
 End If
 Else
 Debug.Print "GetRows failed! " & _
 "Recordset not Restartable!"
 Exit Do
 End If
 End If

 ' Because using GetRows leaves the current record
 ' pointer at the last record accessed, move the
 ' pointer back to the beginning of the Recordset
 ' before looping back for another search.
 .MoveFirst
 Loop
 End With

 rstEmployees.Close
 dbsNorthwind.Close

End Sub

Function GetRowsOK(rstTemp As Recordset2, _
 intNumber As Integer, avarData As Variant) As Boolean

 ' Store results of GetRows method in array.
 avarData = rstTemp.GetRows(intNumber)
 ' Return False only if fewer than the desired number of
 ' rows were returned, but not because the end of the
 ' Recordset was reached.
 If intNumber > UBound(avarData, 2) + 1 And _
 Not rstTemp.EOF Then
 GetRowsOK = False
 Else
 GetRowsOK = True
 End If

End Function


ComboBox.Width Property (Access)

 Copy code hover
[image]

ComboBox.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents a ComboBox object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Parameter (ADO/WFC Syntax)

 Copy code hover
[image]

Parameter (ADO/WFC Syntax)
Send feedback

package com.ms.wfc.data

Constructor

Copy code Copy code

public Invalid DDUE based on source, error:link not allowed in code, link filename:mdobjparameter_HV10294590.xml()
public Parameter(String name)
public Parameter(String name, int type)
public Parameter(String name, int type, int dir)
public Parameter(String name, int type, int dir, int size)
public Parameter(String name, int type, int dir, int size, Object value)

Methods

Copy code Copy code

public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthappchunk_HV10294090.xml(byte[] bytes)
public void appendChunk(char[] chars)
public void appendChunk(String chars)

Properties

Copy code Copy code

public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdproattributes_HV10294098.xml()
public void setAttributes(int attr)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprodirection_HV10294320.xml()
public void setDirection(int dir)
public String Invalid DDUE based on source, error:link not allowed in code, link filename:mdproname_HV10294535.xml()
public void setName(String name)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdpronumericscale_HV10294551.xml()
public void setNumericScale(int scale)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdproprecision_HV10294615.xml()
public void setPrecision(int prec)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprosize_HV10294779.xml()
public void setSize(int size)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprotype_HV10294866.xml()
public void setType(int type)
public com.ms.com.Variant Invalid DDUE based on source, error:link not allowed in code, link filename:mdprovalue_HV10294920.xml()
public void setValue(Object v)
public AdoProperties Invalid DDUE based on source, error:link not allowed in code, link filename:mdcolproperties_HV10294633.xml()

Parameter Accessor Methods

The Value property of a Parameter object gets or sets the content of that object. The content is represented as a VARIANT, a type of object that can be assigned a value and any of several data types.

ADO/WFC implements the Value property with the getValue method, which returns a VARIANT object; and the setValue method, which takes a VARIANT as an argument. VARIANTs are highly efficient in certain languages, such as Microsoft Visual Basic. However, you can attain better performance in Microsoft Visual J++ by using native Java data types.

In addition to the Value property, ADO/WFC provides accessor methods that use Java data types to get and set the content of Parameter objects. Most of these methods have names of the form get DataType or set DataType.

There is one noteworthy exception: There is no getNull property; instead, there is an isNull property that returns a Boolean value indicating whether the field is null.

Copy code Copy code

public boolean getBoolean()
public void setBoolean(boolean v)
public byte getByte()
public void setByte(byte v)
public double getDouble()
public void setDouble(double v)
public float getFloat()
public void setFloat(float v)
public int getInt()
public void setInt(int v)
public long getLong()
public void setLong(long v)
public short getShort()
public void setShort(short v)
public String getString()
public void setString(String v)
public boolean isNull()
public void setNull()


Table

 Copy code hover
[image]

Table <name> is exclusively locked by user <name> on machine <name>. (Error 3189)
Send feedback

You cannot access the specified table because it is exclusively locked by another user. Contact the other user, or wait for the other user to release the lock, and then try the operation again.


SubForm.Height Property (Access)

 Copy code hover
[image]

SubForm.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Syntax

expression .Height

expression A variable that represents a SubForm object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Form.ChartSpace Property (Access)

 Copy code hover
[image]

Form.ChartSpace Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a ChartSpace object. Read-only.

Syntax

expression .ChartSpace

expression A variable that represents a Form object.

Remarks

You must set a reference to the Microsoft Office Web Components type library in order to use this property.

Example

This example reports the version of Microsoft Office Web Components in use for the specified form.

VBA Copy code Copy code
Dim objChartSpace As ChartSpace

Set objChartSpace = Forms(0).ChartSpace

MsgBox "Current version of Office Web Components: " _
 & objChartSpace.Version

See also

Concepts

Form Object

Other resources

Form Object Members


Cannot create relationship. Referenced table

 Copy code hover
[image]

Cannot create relationship. Referenced table <name> does not have a primary key. (Error 3373)
Send feedback

The table you have referenced in the CONSTRAINT clause does not have a primary key. To create the relationship, you must either create a primary key in the referenced table, or specifically reference one or more uniquely indexed fields to use in the relationship.


OptionButton.LabelY Property (Access)

 Copy code hover
[image]

OptionButton.LabelY Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .LabelY

expression A variable that represents an OptionButton object.

Remarks

If the orientation is left to right for a form or report, LabelX and LabelY behavior matches standard Microsoft Access left-to-right orientation. For more information about orientation, see the Orientation property.

If orientation is right to left, the origin of the coordinate system for LabelX and LabelY is the upper right corner of the attached control. A negative number for LabelX places the label to the right of the control. A negative number for LabelY places the label above the control.

For General and Right alignment when orientation is RTL, LabelX and LabelY specify the location of the upper-right corner of the label relative to the upper-right corner of the label's attached control. For Left and Center alignment, LabelX and LabelY specify the location of the upper-left corner and top center, respectively, of the label relative to the upper-right corner of the label's attached control.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Chapter 6: Error Handlinge (ADO)

 Copy code hover
[image]

Chapter 6: Error Handlinge (ADO)
Send feedback

In this section

  • Chapter 6: Error Handling

  • ADO Errors

  • ADO Error Reference

  • Provider Errors

  • Field-Related Error Information

  • Recordset-Related Error Information

  • Anticipating Errors

  • Handling Errors in Other Languages (ADO)


NavigationControl.Parent Property (Access)

 Copy code hover
[image]

NavigationControl.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Parent

expression A variable that represents a NavigationControl object.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Form.DatasheetFontName Property (Access)

 Copy code hover
[image]

Form.DatasheetFontName Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DatasheetFontName property to specify the font used to display and print field names and data in Datasheet view. Read/write String.

Syntax

expression .DatasheetFontName

expression A variable that represents a Form object.

Remarks

The DatasheetFontName property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

This property is only available in Visual Basic within a Microsoft Access database.

For the DatasheetFontName property, the font names you can specify depend on the fonts installed on your system and for your printer. If you specify a font that your system can't display or that isn't installed, Microsoft Windows will substitute a similar font.

The following table contains the properties that don't exist in the DAO Properties collection of until you set them by using the Formatting (Datasheet) toolbar or you can add them in an Access database by using the CreateProperty method and append it to the DAO Properties collection.

DatasheetFontItalic * | DatasheetForeColor *
DatasheetFontHeight * | DatasheetBackColor
DatasheetFontName * | DatasheetGridlinesColor
DatasheetFontUnderline * | DatasheetGridlinesBehavior
DatasheetFontWeight * | DatasheetCellsEffect
Note Note

When you add or set any property listed with an asterisk, Microsoft Access automatically adds all the properties listed with an asterisk to the Properties collection of the database.

See also

Concepts

Form Object

Other resources

Form Object Members


CustomControl.Locked Property (Access)

 Copy code hover
[image]

CustomControl.Locked Property (Access)
See also Send feedback

Published: July 16, 2012

The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.

Syntax

expression .Locked

expression A variable that represents a CustomControl object.

Remarks

The default setting of the Locked property is True. This setting allows editing, adding, and deleting data.

Use the Locked property to protect data in a field by making it read-only. For example, you might want a control to only display information without allowing editing, or you might want to lock a control until a specific condition is met.

Example

The following example toggles the Enabled property of a command button and the Enabled and Locked properties of a control, depending on the type of employee displayed in the current record. If the employee is a manager, then the SalaryDetails button is enabled and the PersonalInfo control is unlocked and enabled.

VBA Copy code Copy code
Sub Form_Current()
 If Me!EmployeeType = "Manager" Then
 Me!SalaryDetails.Enabled = True
 Me!PersonalInfo.Enabled = True
 Me!PersonalInfo.Locked = False
 Else
 Me!SalaryDetails.Enabled = False
 Me!PersonalInfo.Enabled = False
 Me!PersonalInfo.Locked = True
 End If
End Sub

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


CurrentProject Object (Access)

 Copy code hover
[image]

CurrentProject Object (Access)
See also Send feedback

Published: July 16, 2012

The CurrentProject object refers to the project for the current Microsoft Access project (.adp) or Access database.

Remarks

The CurrentProject object has several collections that contain specific AccessObject objects within the current database. The following table lists the name of each collection and the types of objects it contains.

Collections | Object type
AllForms | All forms
AllReports | All reports
AllMacros | All macros
AllModules | All modules
Note Note

The collections in the preceding table contain all of the respective objects in the database regardless if they are opened or closed.

For example, an AccessObject object representing a form is a member of the AllForms collection, which is a collection of AccessObject objects within the current database. Within the AllForms collection, individual members of the collection are indexed beginning with zero. You can refer to an individual AccessObject object in the AllForms collection either by referring to the form by name, or by referring to its index within the collection. If you want to refer to a specific object in the AllForms collection, it's better to refer to it by name because a item's collection index may change. If the object name includes a space, the name must be surrounded by brackets ([ ]).

Syntax | Example
AllForms!formname | AllForms!OrderForm
AllForms![form name] | AllForms![Order Form]
AllForms("formname") | AllForms("OrderForm")
AllForms(formname) | AllForms(0)

Example

The following example prints some current property settings of the CurrentProject object and then sets an option to display hidden objects within the application:

VBA Copy code Copy code
Sub ApplicationInformation()
 ' Print name and type of current object.
 Debug.Print Application.CurrentProject.FullName
 Debug.Print Application.CurrentProject.ProjectType
 ' Set Hidden Objects option under Show on View Tab
 'of the Options dialog box.
 Application.SetOption "Show Hidden Objects", True
End Sub

The next example shows how to use the CurrentProject object using Automation from another Microsoft Office application. First, from the other application, create a reference to Microsoft Access by clicking References on the Tools menu in the Module window. Select the check box next to Microsoft Access Object Library. Then enter the following code in a Visual Basic module within that application and call the GetAccessData procedure.

The example passes a database name and report name to a procedure that creates a new instance of the Application class, opens the database, and verifies that the specified report exists using the CurrentProject object and AllReports collection.

VBA Copy code Copy code
Sub GetAccessData()
' Declare object variable in declarations section of a module
 Dim appAccess As Access.Application
 Dim strDB As String
 Dim strReportName As String

 strDB = "C:\Program Files\Microsoft "_
 & "Office\Office11\Samples\Northwind.mdb"
 strReportName = InputBox("Enter name of report to be verified", _
 "Report Verification")
 VerifyAccessReport strDB, strReportName
End Sub

Sub VerifyAccessReport(strDB As String, _
 strReportName As String)
 ' Return reference to Microsoft Access
 ' Application object.
 Set appAccess = New Access.Application
 ' Open database in Microsoft Access.
 appAccess.OpenCurrentDatabase strDB
 ' Verify report exists.
 On Error Goto ErrorHandler
 appAccess.CurrentProject.AllReports(strReportName)
 MsgBox "Report " & strReportName & _
 " verified within Northwind database."
 appAccess.CloseCurrentDatabase
 Set appAccess = Nothing
Exit Sub
ErrorHandler:
 MsgBox "Report " & strReportName & _
 " does not exist within Northwind database."
 appAccess.CloseCurrentDatabase
 Set appAccess = Nothing
End Sub

See also

Concepts

Access Object Model Reference

Other resources

CurrentProject Object Members


Step 2: Get the Data
Send feedback

Step 2: Get the Data

In this step, you will write the code to open an ADO Recordset and prepare to send it to the client. Open the file XMLResponse.asp with a text editor, such as Windows Notepad, and insert the following code:

Copy code Copy code

<%@ language="VBScript" %>

<!-- #include file='adovbs.inc' -->

<%
  Dim strSQL, strCon
  Dim adoRec
  Dim adoCon
  Dim xmlDoc

  ' You will need to change "slqServer" below to the name of the SQL
  ' server machine to which you want to connect.
  strCon = "Provider=sqloledb;Data Source=sqlServer;Initial Catalog=Pubs;Integrated Security=SSPI;"
  Set adoCon = server.createObject("ADODB.Connection")
  adoCon.Open strCon

  strSQL = "SELECT Title, Price FROM Titles ORDER BY Price"
  Set adoRec = Server.CreateObject("ADODB.Recordset")
  adoRec.Open strSQL, adoCon, adOpenStatic, adLockOptimistic, adCmdText

Be sure to change the value of the Data Source parameter in parameter in strCon to the name of your Microsoft SQL Server computer.

Keep the file open and go on to the next step.

Next Step 3: Send the Data


Step 1: Specify a Server Program (RDS Tutorial)

 Copy code hover
[image]

Step 1: Specify a Server Program (RDS Tutorial)
Send feedback

In the most general case, use the RDS.DataSpace object CreateObject method to specify the default server program, RDSServer.DataFactory, or your own custom server program (business object). A server program is instantiated on the server, and a reference to the server program, or proxy, is returned.

This tutorial uses the default server program:

Copy code Copy code

Sub RDSTutorial1()
 Dim DS as New RDS.DataSpace
 Dim DF as Object
 Set DF = DS.CreateObject("RDSServer.DataFactory", "http://yourServer")
...


CommandButton.Glow Property (Access)

 Copy code hover
[image]

CommandButton.Glow Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the Glow effect applied to the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .Glow

expression A variable that represents a CommandButton object.

Remarks

The Glow property contains a numeric expression that represents the glow effect applied to the specified object. The default value of the Glow property is 0, which does not apply a glow effect. The values are listed in the following table.

Value | Effect
0 | None
1 | Blue, 5 pt glow, Accent color 1
2 | Red, 5 pt glow, Accent color 2
3 | Olive Green, 5 pt glow, Accent color 3
4 | Purple, 5 pt glow, Accent color 4
5 | Aqua, 5 pt glow, Accent color 5
6 | Orange, 5 pt glow, Accent color 6
7 | Blue, 8 pt glow, Accent color 1
8 | Red, 8 pt glow, Accent color 2
9 | Olive Green, 8 pt glow, Accent color 3
10 | Purple, 8 pt glow, Accent color 4
11 | Aqua, 8 pt glow, Accent color 5
12 | Orange, 8 pt glow, Accent color 6
13 | Blue, 11 pt glow, Accent color 1
14 | Red, 11 pt glow, Accent color 2
15 | Olive Green, 11 pt glow, Accent color 3
16 | Purple, 11 pt glow, Accent color 4
17 | Aqua, 11 pt glow, Accent color 5
18 | Orange, 11 pt glow, Accent color 6
19 | Blue, 18 pt glow, Accent color 1
20 | Red, 18 pt glow, Accent color 2
21 | Olive Green, 18 pt glow, Accent color 3
22 | Purple, 18 pt glow, Accent color 4
23 | Aqua, 18 pt glow, Accent color 5
24 | Orange, 18 pt glow, Accent color 6

To see the available glow effects and apply a glow through the user interface, first open the form or report in Layout view or Design view by right-clicking the form or report in the Navigation Pane, and then clicking the view you want. Then, click the object to which you want to apply a glow effect. Next, on the Format tab, in the Control Formatting group, click Shape Effects, then click Glow and choose a glow effect. Notice that the glow effects are indexed from left to right, and then top to bottom. So the first item, under No Glow, has the value 0. Then, under Glow, the first row contains glow effects with values from 1 to 6. The second row from 7 to 12, the third row from 13 to 18, and the fourth row from 19 to 24 .

This property is not surfaced in the property sheet.

Example

The following code example sets the glow effect to Aqua, 11 pt glow, Accent color 5.

VBA Copy code Copy code
Me.ctl.Glow = 17

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Report.FontItalic Property (Access)

 Copy code hover
[image]

Report.FontItalic Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontItalic property to specify whether text is italic in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontItalic

expression A variable that represents a Report object.

Remarks

The FontItalic property uses the following settings.

Setting | Description
True | The text is italic.
False | (Default) The text isn't italic.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

Report Object

Other resources

Report Object Members


Section.CanShrink Property (Access)

 Copy code hover
[image]

Section.CanShrink Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the section or control contains. Read/write Boolean.

Syntax

expression .CanShrink

expression A variable that represents a Section object.

Remarks

The CanShrink property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The section or control shrinks vertically so that the data it contains can be printed or previewed without leaving blank lines.
No | False | (Default) The section or control doesn't shrink.

This property setting is read-only in a macro or Visual Basic in any view but Design view.

You can use this property to control the appearance of printed forms and reports. When you set the property to Yes, the object automatically adjusts so any amount of data can be printed. When a control shrinks, the controls below it move up the page.

If you set a control's CanShrink property to Yes, Microsoft Access does not set the section's CanShrink property to Yes.

Sections shrink vertically across their entire width. For example, suppose a form has two text boxes side by side in a section, and each control has its CanShrink property set to Yes. If one text box contains one line of data and the other text box contains two lines of data, both text boxes will be two lines long because the section is sized across its entire width. To shrink the data independently, you can place two subform or subreport controls side by side, and set their CanShrink property to Yes.

When you use the CanShrink property, remember that:

  • The property settings don't affect the horizontal spacing between controls; they affect only the vertical space the controls occupy.

  • Overlapping controls can't shrink.

  • The height of a large control can prevent controls beside it from shrinking. For example, if several short controls are on the left side of a report's detail section and one tall control, such as an unbound object frame, is on the right side, the controls on the left won't shrink, even if they contain no data.

Note Note

  • The CanShrink property does not apply to form or report page header and page footer sections, although it does apply to controls in such sections.

  • This property affects the display of form sections and controls only when the form is printed or previewed, not when the form is displayed in Form view, Datasheet view, or Design view.

See also

Concepts

Section Object

Other resources

Section Object Members


Workspace.CommitTrans Method (DAO)

 Copy code hover
[image]

Workspace.CommitTrans Method (DAO)
Send feedback

Ends the current transaction and saves the changes.

Syntax

expression .CommitTrans(Options)

expression A variable that represents a Workspace object.

Parameters

Name | Required/Optional | Data Type | Description
Option | Optional | Long | In a Microsoft Access workspace, you can include the dbForceOSFlush constant with CommitTrans. This forces the database engine to immediately flush all updates to disk, instead of caching them temporarily. Without using this option, a user could get control back immediately after the application program calls CommitTrans, turn the computer off, and not have the data written to disk. While using this option may affect your application's performance, it is useful in situations where the computer could be shut off before cached updates are saved to disk.

Remarks

The transaction methods BeginTrans, CommitTrans, and Rollback manage transaction processing during a session defined by a Workspace object. You use these methods with a Workspace object when you want to treat a series of changes made to the databases in a session as one unit.

Typically, you use transactions to maintain the integrity of your data when you must both update records in two or more tables and ensure changes are completed (committed) in all tables or none at all (rolled back). For example, if you transfer money from one account to another, you might subtract an amount from one and add the amount to another. If either update fails, the accounts no longer balance. Use the BeginTrans method before updating the first record, and then, if any subsequent update fails, you can use the Rollback method to undo all of the updates. Use the CommitTrans method after you successfully update the last record.

Note Note

Within one Workspace object, transactions are always global to the Workspace and aren't limited to only one Connection or Database object. If you perform operations on more than one connection or database within a Workspace transaction, resolving the transaction (that is, using the CommitTrans or Rollback method) affects all operations on all connections and databases within that workspace.

After you use CommitTrans, you can't undo changes made during that transaction unless the transaction is nested within another transaction that is itself rolled back. If you nest transactions, you must resolve the current transaction before you can resolve a transaction at a higher level of nesting.

If you want to have simultaneous transactions with overlapping, non-nested scopes, you can create additional Workspace objects to contain the concurrent transactions.

If you close a Workspace object without resolving any pending transactions, the transactions are automatically rolled back.

If you use the CommitTrans or Rollback method without first using the BeginTrans method, an error occurs.

Some ISAM databases used in a Microsoft Access workspace may not support transactions, in which case the Transactions property of the Database object or Recordset object is False. To make sure the database supports transactions, check the value of the Transactions property of the Database object before using the BeginTrans method. If you are using a Recordset object based on more than one database, check the Transactions property of the Recordset object. If a Recordset is based entirely on Microsoft Access database engine tables, you can always use transactions. Recordset objects based on tables created by other database products, however, may not support transactions. For example, you can't use transactions in a Recordset based on a Paradox table. In this case, the Transactions property is False. If the Database or Recordset doesn't support transactions, the methods are ignored and no error occurs.

You can't nest transactions if you are accessing ODBC data sources through the Microsoft Access database engine.

In ODBC workspaces, when you use CommitTrans your cursor may no longer be valid. Use the Requery method to view the changes in the Recordset, or close and re-open the Recordset.

Note Note

  • You can often improve the performance of your application by breaking operations that require disk access into transaction blocks. This buffers your operations and may significantly reduce the number of times a disk is accessed.

  • In a Microsoft Access workspace, transactions are logged in a file kept in the directory specified by the TEMP environment variable on the workstation. If the transaction log file exhausts the available storage on your TEMP drive, the database engine triggers a run-time error. At this point, if you use CommitTrans, an indeterminate number of operations are committed, but the remaining uncompleted operations are lost, and the operation has to be restarted. Using a Rollback method releases the transaction log and rolls back all operations in the transaction.

  • Closing a clone Recordset within a pending transaction will cause an implicit Rollback operation.

Example

The following example shows how to use a transaction in a Data Access Objects (DAO) workspace.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Public Sub TransferFunds()
    Dim wrk As DAO.Workspace
    Dim dbC As DAO.Database
    Dim dbX As DAO.Database

    Set wrk = DBEngine(0)
    Set dbC = CurrentDb
    Set dbX = wrk.OpenDatabase("e:\books\acc2007vba\myDB.accdb")

    On Error GoTo trans_Err

    'Begin the transaction

    wrk.BeginTrans

    'Withdraw funds from one account table
    dbC.Execute "INSERT INTO tblAccounts ( Amount, Txn, TxnDate ) SELECT -20, 'DEBIT', Date()", dbFailOnError

    'Deposit funds into another account table
    dbX.Execute "INSERT INTO tblAccounts ( Amount, Txn, TxnDate ) SELECT 20, 'CREDIT', Date()", dbFailOnError

    'Commit the transaction
    wrk.CommitTrans dbForceOSFlush

trans_Exit:
    'Clean up
    wrk.Close
    Set dbC = Nothing
    Set dbX = Nothing
    Set wrk = Nothing
    Exit Sub

trans_Err:
    'Roll back the transaction
    wrk.Rollback
    Resume trans_Exit

End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


NavigationControl.KeyPress Event (Access)

 Copy code hover
[image]

NavigationControl.KeyPress Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Version Information

Version Added: Access 2010

Syntax

expression .KeyPress(KeyAscii, )

expression A variable that represents a NavigationControl object.

Parameters

Name | Required/Optional | Data Type | Description
KeyAscii | Required | Integer |

Return Value

nothing

Remarks

To run a macro or event procedure when this event occurs, set the OnKeyPress property to the name of the macro or to [Event Procedure].

The object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down an ANSI key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

A KeyPress event can involve any printable keyboard character, the CTRL key combined with a character from the standard alphabet or a special character, and the ENTER or BACKSPACE key. You can use the KeyDown and KeyUp event procedures to handle any keystroke not recognized by the KeyPress event, such as function keys, navigation keys, and any combinations of these with keyboard modifiers (ALT, SHIFT, or CTRL keys). Unlike the KeyDown and KeyUp events, the KeyPress event doesn't indicate the physical state of the keyboard; instead, it indicates the ANSI character that corresponds to the pressed key or key combinations.

KeyPress interprets the uppercase and lowercase of each character as separate key codes and, therefore, as two separate characters.

Note Note

The BACKSPACE key is part of the ANSI character set, but the DEL key isn't. If you delete a character in a control by using the BACKSPACE key, you cause a KeyPress event; if you use the DEL key, you don't.

The KeyDown and KeyPress events occur when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

For example, if you go to a new record and type a character in the first control in the record, the following events occur:

Current (for the new record)

ß

Enter (for the first control in the new record)

ß

GotFocus (for the control)

ß

KeyDown (for the control)

ß

KeyPress (for the control)

ß

BeforeInsert (for the new record in the form)

ß

Change (for the control if it's a text box or combo box)

ß

KeyUp (for the control)

Example

The following example converts text entered in a text box to uppercase as the text is typed in, one character at a time.

To try the example, add the following event procedure to a form that contains a text box named ShipRegion.

VBA Copy code Copy code
Private Sub ShipRegion_KeyPress(KeyAscii As Integer)
 Dim strCharacter As String

 ' Convert ANSI value to character string.
 strCharacter = Chr(KeyAscii)
 ' Convert character to upper case, then to ANSI value.
 KeyAscii = Asc(UCase(strCharacter))
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


ObjectFrame.AutoActivate Property (Access)

 Copy code hover
[image]

ObjectFrame.AutoActivate Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AutoActivate property to specify how the user can activate an OLE object. Read/write Integer.

Syntax

expression .AutoActivate

expression A variable that represents an ObjectFrame object.

Remarks

The AutoActivate property uses the following settings.

Setting | Constant | Description
Manual | acOLEActivateManual (0) | The OLE object isn't activated when it receives the focus or when the user double-clicks the control. You can activate an OLE object only by using Visual Basic to set the control's Action property to acOLEActivate.
GetFocus | acOLEActivateGetFocus (1) | (For unbound object frame and chart controls only) If the control contains an OLE object, the application that supplied the object is activated when the control receives the focus.
Double-Click | acOLEActivateDoubleClick (2) | (Default) If the control contains an OLE object, the application that supplied the object is activated when the user double-clicks the control or presses CTRL+ENTER when the control has the focus.

The AutoActivate property can be set only in Design view.

Some OLE objects can be activated from within the control. When such an object is activated, the object can be edited (or some other operation can be performed) from inside the boundaries of the control. This feature is called in-place activation. If an object supports in-place activation, see the documentation for the application that was used to create the object for information about using this feature.

With Visual Basic, you can determine if a control contains an object by checking the setting of its OLEType property.

Note Note

If you set a control's AutoActivate property to Double-Click and specify a DblClick event for the control, the DblClick event occurs before the object is activated.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


TableDef.Properties Property (DAO)

 Copy code hover
[image]

TableDef.Properties Property (DAO)
Send feedback

Returns the Properties collection of the specified object. Read-only.

Syntax

expression .Properties

expression A variable that represents a TableDef object.


Form.Refresh Method (Access)

 Copy code hover
[image]

Form.Refresh Method (Access)
See also Send feedback

Published: July 16, 2012

The Refresh method immediately updates the records in the underlying record source for a specified form or datasheet to reflect changes made to the data by you and other users in a multiuser environment.

Syntax

expression .Refresh

expression A variable that represents a Form object.

Return Value

Nothing

Remarks

Using the Refresh method is equivalent to clicking Refresh on the Home tab.

Microsoft Access refreshes records automatically, based on the Refresh Interval setting on the Advanced tab of the Access Options dialog box, available by clicking the Microsoft Office button [image] and then clicking Access Options. ODBC data sources are refreshed based on the ODBC Refresh Interval setting on the Advanced tab of the Access Options dialog box. You can use the Refresh method to view changes that have been made to the current set of records in a form or datasheet since the record source underlying the form or datasheet was last refreshed.

In a Microsoft Access database, the Refresh method shows only changes made to records in the current set. Since the Refresh method doesn't actually requery the database, the current set won't include records that have been added or exclude records that have been deleted since the database was last requeried. Nor will it exclude records that no longer satisfy the criteria of the query or filter. To requery the database, use the Requery method. When the record source for a form is requeried, the current set of records will accurately reflect all data in the record source.

In a Microsoft Access project (.adp), the Refresh method requeries the database and displays any new or changed records or removes deleted records from the table on which the form is based. The form is also updated to display records based on any changes to the Filter property of the form.

Note Note

  • It's often faster to refresh a form or datasheet than to requery it. This is especially true if the initial query was slow to run.

  • Don't confuse the Refresh method with the Repaint method, which repaints the screen with any pending visual changes.

Example

The following example uses the Refresh method to update the records in the underlying record source for the form Customers whenever the form receives the focus:

VBA Copy code Copy code
Private Sub Form_Activate()
    Me.Refresh
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Page.PictureData Property (Access)

 Copy code hover
[image]

Page.PictureData Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.

Syntax

expression .PictureData

expression A variable that represents a Page object.

Remarks

The PictureData property setting is the PictureData property of another control, form, or report.

You can use this property to display different background pictures in a form, depending on actions taken by the user. For example, you might open a Customers form using a different background picture depending on whether the form is opened for data entry or for browsing.

You can also use the PictureData property together with the Timer event and the TimerInterval property to perform simple animation on a form.

Example

The following example uses three image controls to animate a butterfly image across a form. The Hidden1 image control contains a picture of a butterfly with its wings up and the Hidden2 image control contains a picture of the same butterfly with its wings down. Both image controls have their Visible property set to False. The TimerInterval property is set to 200. Each time the Timer event occurs, the picture in the image control Visible1 is changed by using the PictureData property of the hidden image controls, and the visible image control is moved 200 twips to the right. The visible image control is moved back to the left side of the form when its Left property value is greater than the width of the form stored in the public variable gfrmWidth. The value of gfrmWidth is set to Me.Width in the form's open event.

VBA Copy code Copy code
Private Sub Form_Timer()

 Static intPic As Integer

 Select Case intPic
 Case Is = 1
 Me!Visible1.PictureData = Me!Hidden1.PictureData
 Case Is = 2
 Me!Visible1.PictureData = Me!Hidden2.PictureData
 Case Else
 End Select

 If intPic = 2 Then intPic = 0
 intPic = intPic + 1
 If (Me!Visible1.Left > gfrmWidth) Then Me!Visible1.Left = 0
 Me!Visible1.Left = Me!Visible1.Left + 200

End Sub

See also

Concepts

Page Object

Other resources

Page Object Members


Report.MouseUp Event (Access)

 Copy code hover
[image]

Report.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents a Report object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was released to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a report to occur, press the mouse button in a blank area on the report. To cause a MouseUp event for a report section to occur, press the mouse button in a blank area of the report section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a report or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

Report Object

Other resources

Report Object Members


ReadyState Property (RDS)

 Copy code hover
[image]

ReadyState Property (RDS)
Send feedback

Indicates the progress of a DataControl object as it retrieves data into its Recordset object.

Settings and Return Values

Sets or returns one of the following values.

Value | Description
adcReadyStateLoaded | The current query is still executing and no rows have been fetched. The DataControl object's Recordset is not available for use.
adcReadyStateInteractive | An initial set of rows retrieved by the current query has been stored in the DataControl object's Recordset and are available for use. The remaining rows are still being fetched.
adcReadyStateComplete | All rows retrieved by the current query have been stored in the DataControl object's Recordset and are available for use. This state will also exist if an operation aborted due to an error, or if the Recordset object is not initialized.
Note Note

Each client-side executable file that uses these constants must provide declarations for them. You can cut and paste the constant declarations you want from the file Adcvbs.inc, located in the C:\Program Files\Common Files\System\MSADC folder.

Remarks

Use the onReadyStateChange event to monitor changes in the ReadyState property during an asynchronous query operation. This is more efficient than periodically checking the value of the property.

If an error occurs during an asynchronous operation, the ReadyState property changes to adcReadyStateComplete, the State property changes from adStateExecuting to adStateClosed, and the Recordset object Value property remains Nothing.


Missing destination field name in UPDATE statement

 Copy code hover
[image]

Missing destination field name in UPDATE statement <statement>. (Error 3106)
Send feedback

Enter a destination field name in the specified statement, and then try the operation again.


TextBox.Parent Property (Access)

 Copy code hover
[image]

TextBox.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a TextBox object.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


FormatCondition.Type Property (Access)

 Copy code hover
[image]

FormatCondition.Type Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the value of a FormatCondition object type. Read-only AcFormatConditionType.

Syntax

expression .Type

expression A variable that represents a FormatCondition object.

See also

Concepts

FormatCondition Object

Other resources

FormatCondition Object Members


ActiveCommand Property Example (VJ++)

 Copy code hover
[image]

ActiveCommand Property Example (VJ++)
Send feedback

This example demonstrates the ActiveCommand property.

A subroutine is given a Recordset object whose ActiveCommand property is used to display the command text and parameter that created the Recordset.

Copy code Copy code

// BeginActiveCommandJ
import com.ms.wfc.data.*;
import java.io.* ;

public class ActiveCommandX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 ActiveCommandX();
 System.exit(0);
 }

 // ActiveCommandX function

 static void ActiveCommandX()
 {
 // Define ADO Objects.
 Connection cnConn1 = null;
 Command cmd = null;
 Recordset rstAuthors = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";
 String strName;

 try
 {
 System.out.println("Enter an author's name (e.g., Ringer): ");
 strName = in.readLine().trim();
 cmd = new Command();
 cmd.setCommandText("SELECT * FROM authors WHERE au_lname = ?");
 cmd.getParameters().append(cmd.createParameter("LastName",
 AdoEnums.DataType.CHAR,
 AdoEnums.ParameterDirection.INPUT, 20, strName));
 cnConn1 = new Connection();
 cnConn1.open(strCnn);
 cmd.setActiveConnection(cnConn1);
 rstAuthors = cmd.execute(null,AdoEnums.CommandType.TEXT);
 ActiveCommandXprint(rstAuthors);
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstAuthors != null)
 {
 PrintProviderError(rstAuthors.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstAuthors != null)
 if (rstAuthors.getState() == 1)
 rstAuthors.close();
 // Cleanup objects before exit.
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 }
 }

 // ActiveCommandXprint function
 static void ActiveCommandXprint(Recordset rstp)
 {
 // Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String strName;

 try
 {
 strName = rstp.getActiveCommand().getParameters().
 getItem("LastName").getValue().toString();
 System.out.println("\nCommand text = '" +
 rstp.getActiveCommand().getCommandText() + "'");
 System.out.println("Parameter = '" + strName + "'");
 if(rstp.getBOF())
 {
 System.out.println("Name = '" + strName + "', not found.");
 }
 else
 {
 System.out.println("Name = '" +
 rstp.getField("au_fname").getString() + " " +
 rstp.getField("au_lname").getString() +
 "', author ID = '" +
 rstp.getField("au_id").getString() + "'");
 }
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstp != null)
 {
 PrintProviderError(rstp.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 //.PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}

// EndActiveCommandJ


Screen.MousePointer Property (Access)

 Copy code hover
[image]

Screen.MousePointer Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the MousePointer property together with the Screen object to specify or determine the type of mouse pointer currently displayed. Read/write Integer.

Syntax

expression .MousePointer

expression A variable that represents a Screen object.

Remarks

The setting for the MousePointer property is an Integer value representing one of the following pointers.

Setting | Description
0 | (Default) The shape is determined by Microsoft Access
1 | Normal Select (Arrow)
3 | Text Select (I-Beam)
7 | Vertical Resize (Size N, S)
9 | Horizontal Resize (Size E, W)
11 | Busy (Hourglass)
Note Note

Setting the MousePointer property to an integer other than one that appears in the preceding table will cause the property to be set to 0.

The MousePointer property affects the appearance of the mouse pointer over the entire screen. Some custom controls have a MousePointer property that, if set, will specify how the mouse pointer is displayed when it's positioned over the control.

You could use the MousePointer property to indicate that your application is busy by setting the property to 11 to display an hourglass icon. You can also read the MousePointer property to determine what's being displayed. This could be useful if you wanted to prevent a user from clicking a command button while the mouse pointer is displaying an hourglass icon.

Setting the MousePointer property to 11 is the same as passing the True (-1) argument to the Hourglass method of the DoCmd object. Conversely, passing the True argument to the Hourglass method also sets the MousePointer property to 11.

Example

The following example changes the mouse pointer to an hourglass.

VBA Copy code Copy code
Screen.MousePointer = 11

See also

Concepts

Screen Object

Other resources

Screen Object Members


AcFormView Enumeration (Access)

 Copy code hover
[image]

AcFormView Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the view when opeing a form.

Name | Value | Description
acDesign | 1 | The form opens in Design view.
acFormDS | 3 | The form opens in Datasheet view.
acFormPivotChart | 5 | The form opens in PivotChart view.
acFormPivotTable | 4 | The form opens in PivotTable view.
acLayout | 6 | The form opens in Layout view.
acNormal | 0 | (Default) The form opens in Form view.
acPreview | 2 | The form opens in Print Preview.


Cannot execute data definition statements on linked data sources. (Error 3611)

 Copy code hover
[image]

Cannot execute data definition statements on linked data sources. (Error 3611)
Send feedback

The Microsoft Access database engine cannot create an index on a linked ISAM table, or on an ODBC table that already has a unique index.


SetDisplayedCategories Macro Action

 Copy code hover
[image]

SetDisplayedCategories Macro Action
Send feedback

You can use the SetDisplayedCategories action to specify which categories are displayed under Navigate to Category in the title bar of the Navigation Pane. For example, if you want to prevent users from switching the Navigation Pane so that it displays objects sorted by Created Date, you can use this action to hide that option in the title bar's drop-down list.

Setting

The SetDisplayedCategories action has the following arguments.

Action argument | Description
Show | Select Yes to show the category or categories. Select No to hide them.
Category | Enter or select the name of the category you want to show or hide. Leave blank to show or hide all categories.

Remarks

  • The caption in the title bar of the Navigation pane indicates which filter, if any, is currently active. Click anywhere in the bar to display the drop-down list. The items that this macro action controls are listed under Navigate to Category.

  • This action only enables or disables the display of the specified category or categories; it does not perform any switching of the Navigation Pane display. For example, if you are displaying objects sorted by Creation Date and you use the SetDisplayedCategories action to disable the Creation Date option, Access does not switch the Navigation Pane to another category.

  • To run the SetDisplayedCategories action in a VBA module, use the SetDisplayedCategories method of the DoCmd object.


Violates the rules for partial replicas. (Error 3590)

 Copy code hover
[image]

Violates the rules for partial replicas. (Error 3590)
Send feedback

You cannot update a column in a table in a partial replica when another table references that column. Most likely, this is an update RI case, where the related table information does not exist in the partial replica. Make sure you follow all relationships to related tables when defining your Partial Filters.


Operation not supported on linked tables. (Error 3057)

 Copy code hover
[image]

Operation not supported on linked tables. (Error 3057)
Send feedback

Import data from the table, and then try the operation again.


Item Property Example (VB)

 Copy code hover
[image]

Item Property Example (VB)
Send feedback

This example demonstrates how the Item property accesses members of a collection. The example opens the Authors table of the Pubs database with a parameterized command.

The parameter in the command issued against the database is accessed from the Command object's Parameters collection by index and name. The fields of the returned Recordset are then accessed from that object's Fields collection by index and name.

Copy code Copy code

'BeginItemVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 Dim Cnxn As ADODB.Connection
 Dim rstAuthors As ADODB.Recordset
 Dim cmd As ADODB.Command
 Dim prm As ADODB.Parameter
 Dim fld As ADODB.Field
 Dim strCnxn As String

 Dim ix As Integer
 Dim limit As Long
 Dim Column(0 To 8) As Variant

 Set Cnxn = New ADODB.Connection
 Set rstAuthors = New ADODB.Recordset
 Set cmd = New ADODB.Command

 'Set the array with the Authors table field (column) names
 Column(0) = "au_id"
 Column(1) = "au_lname"
 Column(2) = "au_fname"
 Column(3) = "phone"
 Column(4) = "address"
 Column(5) = "city"
 Column(6) = "state"
 Column(7) = "zip"
 Column(8) = "contract"

 cmd.CommandText = "SELECT * FROM Authors WHERE state = ?"
 Set prm = cmd.CreateParameter("ItemXparm", adChar, adParamInput, 2, "CA")
 cmd.Parameters.Append prm
 ' set connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn
 cmd.ActiveConnection = Cnxn
 ' open recordset
 rstAuthors.Open cmd, , adOpenStatic, adLockReadOnly
 'Connection and CommandType are omitted because
 'a Command object is provided

 Debug.Print "The Parameters collection accessed by index..."
 Set prm = cmd.Parameters.Item(0)
 Debug.Print "Parameter name = '"; prm.Name; "', value = '"; prm.Value; "'"
 Debug.Print

 Debug.Print "The Parameters collection accessed by name..."
 Set prm = cmd.Parameters.Item("ItemXparm")
 Debug.Print "Parameter name = '"; prm.Name; "', value = '"; prm.Value; "'"
 Debug.Print

 Debug.Print "The Fields collection accessed by index..."

 rstAuthors.MoveFirst
 limit = rstAuthors.Fields.Count - 1
 For ix = 0 To limit
 Set fld = rstAuthors.Fields.Item(ix)
 Debug.Print "Field "; ix; ": Name = '"; fld.Name; _
 "', Value = '"; fld.Value; "'"
 Next ix

 Debug.Print

 Debug.Print "The Fields collection accessed by name..."

 rstAuthors.MoveFirst
 For ix = 0 To 8
 Set fld = rstAuthors.Fields.Item(Column(ix))
 Debug.Print "Field name = '"; fld.Name; "', Value = '"; fld.Value; "'"
 Next ix

 ' clean up
 rstAuthors.Close
 Cnxn.Close
 Set rstAuthors = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstAuthors Is Nothing Then
 If rstAuthors.State = adStateOpen Then rstAuthors.Close
 End If
 Set rstAuthors = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 Set cmd = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If

End Sub
'EndItemVB


RepaintObject Macro Action

 Copy code hover
[image]

RepaintObject Macro Action
Send feedback

You can use the RepaintObject action to complete any pending screen updates for a specified database object or for the active database object, if none is specified. Such updates include any pending recalculations for the object's controls.

Setting

The RepaintObject action has the following arguments.

Action argument | Description
Object Type | The type of object to repaint. Click Table, Query, Form, Report, Macro, Module, Data Access Page, Server View, Diagram, Stored Procedure, or Function in the Object Type box in the Action Arguments section of the Macro Builder pane. Leave this argument blank to select the active object.
Object Name | The name of the object to repaint. The Object Name box shows all objects in the database of the type selected by the Object Type argument. If you leave the Object Type argument blank, leave this argument blank also.

Remarks

Microsoft Access waits to complete pending screen updates until it finishes other pending tasks. With this action, you can force immediate repainting of the controls in the specified object. You can use this action:

  • When you use the SetValue action to change values in a number of controls. Access might not show the changes immediately, especially if other controls (such as calculated controls) depend on values in the changed controls.

  • When you want to make sure that the form you are viewing displays data in all of its controls. For example, controls containing OLE objects don't display their data immediately after you open a form.

Note Note

  • This action doesn't cause a requery of the database, so it doesn't show new and changed records or remove deleted records from the object's underlying table or query. Use the Requery action to requery the source of the object or one of its controls. Use the ShowAllRecords action to display the most recent records and remove any applied filters.

  • The RepaintObject action doesn't have the same effect as clicking Refresh in the Records group on the Home tab, which shows any changes you or other users have made to the currently displayed records in forms and datasheets.

To run the RepaintObject action in a Visual Basic for Applications (VBA) module, use the RepaintObject method of the DoCmd object.


Can be present only in version 1.0 format. (Error 3334)

 Copy code hover
[image]

Can be present only in version 1.0 format. (Error 3334)
Send feedback

You are attempting to use a feature that is no longer supported in the current version of the application.


Record (ADO for Visual C++ Syntax)

 Copy code hover
[image]

Record (ADO for Visual C++ Syntax)
Send feedback

Methods

Cancel(void) Close(void) CopyRecord(BSTR Source, BSTR Destination, BSTR UserName, BSTR Password, CopyRecordOptionsEnum Options, VARIANT_BOOL Async, BSTR *pbstrNewURL) DeleteRecord(BSTR Source, VARIANT_BOOL Async) GetChildren(_ADORecordset **ppRSet) MoveRecord(BSTR Source, BSTR Destination, BSTR UserName, BSTR Password, MoveRecordOptionsEnum Options, VARIANT_BOOL Async, BSTR *pbstrNewURL) Open(VARIANT Source, VARIANT ActiveConnection, ConnectModeEnum Mode, RecordCreateOptionsEnum CreateOptions, RecordOpenOptionsEnum Options, BSTR UserName, BSTR Password)

Properties

            get_ActiveConnection(VARIANT *pvar)

put_ActiveConnection(BSTR bstrConn)

putref_ActiveConnection(_ADOConnection *Con)

get_Fields(ADOFields **ppFlds)

get_Mode(ConnectModeEnum *pMode)

put_Mode(ConnectModeEnum Mode)

get_ParentURL(BSTR *pbstrParentURL)

get_RecordType(RecordTypeEnum *pType)

get_Source(VARIANT *pvar)

put_Source(BSTR Source)

putref_Source(IDispatch *Source)

get_State(ObjectStateEnum *pState)


MacroError.Number Property (Access)

 Copy code hover
[image]

MacroError.Number Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the current error number. Read-only Long.

Version Information

Version Added: Access 2007

Syntax

expression .Number

expression A variable that represents a MacroError object.

Remarks

When an error occurs in a macro, information about the error is stored in the MacroError object. If you have not used the OnError action to suppress error messages, the macro stops and the error information is displayed in a standard error message. However, if you have used the OnError action to suppress error messages, you may want to use the information stored in the MacroError object in a condition or a custom error message.

After an error has been handled, the information in the MacroError object is out of date, so it is a good idea to clear the object using the ClearMacroError action. This resets the error number in the MacroError object back to zero, and clears any other information about the error that is stored in the object, such as the error description, macro name, action name, condition, and arguments. This way, you can inspect the MacroError object again later to see if another error has occurred.

See also

Concepts

MacroError Object

Other resources

MacroError Object Members


Groups and Users Append, ChangePassword Methods Example (VB)

 Copy code hover
[image]

Groups and Users Append, ChangePassword Methods Example (VB)
Send feedback

This example demonstrates the Append method of Groups, as well as the Append method of Users by adding a new Group and a new User to the system. The new Group is appended to the Groups collection of the new User. Consequently, the new User is added to the Group. Also, the ChangePassword method is used to specify the User password.

Copy code Copy code

' BeginGroupVB
Sub Main()
 On Error GoTo GroupXError

 Dim cat As ADOX.Catalog
 Dim usrNew As ADOX.User
 Dim usrLoop As ADOX.User
 Dim grpLoop As ADOX.Group

 Set cat = New ADOX.Catalog

 cat.ActiveConnection = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\" & _
 "Microsoft Office\Office\Samples\Northwind.mdb';" & _
 "jet oledb:system database=" & _
 "'c:\Program Files\Microsoft Office\Office\system.mdw'"

 With cat
 'Create and append new group with a string.
 .Groups.Append "Accounting"

 ' Create and append new user with an object.
 Set usrNew = New ADOX.User
 usrNew.Name = "Pat Smith"
 usrNew.ChangePassword "", "Password1"
 .Users.Append usrNew

 ' Make the user Pat Smith a member of the
 ' Accounting group by creating and adding the
 ' appropriate Group object to the user's Groups
 ' collection. The same is accomplished if a User
 ' object representing Pat Smith is created and
 ' appended to the Accounting group Users collection
 usrNew.Groups.Append "Accounting"

 ' Enumerate all User objects in the
 ' catalog's Users collection.
 For Each usrLoop In .Users
 Debug.Print " " & usrLoop.Name
 Debug.Print " Belongs to these groups:"
 ' Enumerate all Group objects in each User
 ' object's Groups collection.
 If usrLoop.Groups.Count <> 0 Then
 For Each grpLoop In usrLoop.Groups
 Debug.Print " " & grpLoop.Name
 Next grpLoop
 Else
 Debug.Print " [None]"
 End If
 Next usrLoop

 ' Enumerate all Group objects in the default
 ' workspace's Groups collection.
 For Each grpLoop In .Groups
 Debug.Print " " & grpLoop.Name
 Debug.Print " Has as its members:"
 ' Enumerate all User objects in each Group
 ' object's Users collection.
 If grpLoop.Users.Count <> 0 Then
 For Each usrLoop In grpLoop.Users
 Debug.Print " " & usrLoop.Name
 Next usrLoop
 Else
 Debug.Print " [None]"
 End If
 Next grpLoop

 ' Delete new User and Group objects because this
 ' is only a demonstration.
 ' These two line are commented out because the sub "OwnersX" uses
 ' the group "Accounting".
' .Users.Delete "Pat Smith"
' .Groups.Delete "Accounting"

 End With

 'Clean up
 Set cat.ActiveConnection = Nothing
 Set cat = Nothing
 Set usrNew = Nothing
 Exit Sub

GroupXError:

 Set cat = Nothing
 Set usrNew = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndGroupVB


AllReports.Count Property (Access)

 Copy code hover
[image]

AllReports.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents an AllReports object.

Example

For example, if you want to determine the number of forms currently open or existing on the database, you would use the following code strings

VBA Copy code Copy code
' Determine the number of open forms.

forms.count

' Determine the number of forms (open or closed)
' in the current database.

currentproject.allforms.count

See also

Concepts

AllReports Collection

Other resources

AllReports Object Members


NavigationControl.GridlineWidthTop Property (Access)

 Copy code hover
[image]

NavigationControl.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthTop

expression A variable that represents a NavigationControl object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


StayInSync Property Example (VJ++)

 Copy code hover
[image]

StayInSync Property Example (VJ++)
Send feedback

This example demonstrates how the StayInSync property facilitates accessing rows in a hierarchical Recordset.

The outer loop displays each author's first and last name, state, and identification. The appended Recordset for each row is retrieved from the Fields collection and automatically assigned to rstTitleAuthor by the StayInSync property whenever the parent Recordset moves to a new row. The inner loop displays four fields from each row in the appended recordset.

Copy code Copy code

// BeginStayInSyncJ
import com.ms.wfc.data.*;
import java.io.* ;
import com.ms.com.*;

public class StayInSyncX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 StayInSyncX();
 System.exit(0);
 }

 // StayInSyncX function

 static void StayInSyncX()
 {

 // Define ADO Objects.
 Connection cnConn1 = null;
 Recordset rstAuthors = null;
 Recordset rstTitleAuthor = null;

 // Declarations.
 BufferedReader in = new
 BufferedReader (new InputStreamReader(System.in));
 String strCnn = "Provider=MSDataShape;" +
 "Data Provider='sqloledb';Data Source='MySqlServer';" +
 "Initial Catalog='Pubs';Integrated Security='SSPI';";

 try
 {
 cnConn1 = new Connection();
 cnConn1.open(strCnn);
 rstAuthors = new Recordset();
 rstAuthors.setStayInSync(true);
 rstAuthors.open("SHAPE {select * from Authors} " +
 "APPEND ({select * from titleauthor}" +
 "RELATE au_id TO au_id) AS chapTitleAuthor",
 cnConn1,
 AdoEnums.CursorType.STATIC,
 AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TEXT);

 Variant varRstTitleAuthor = rstAuthors.getFields().
 getItem("chapTitleAuthor").getValue();
 rstTitleAuthor =new Recordset(varRstTitleAuthor.toObject());
 int intCount =0;
 while(!rstAuthors.getEOF())
 {
 System.out.println("\n" +
 rstAuthors.getField("au_fname").getString() + " " +
 rstAuthors.getField("au_lname").getString() + " " +
 rstAuthors.getField("state").getString() + " " +
 rstAuthors.getField("au_id").getString());
 while(!rstTitleAuthor.getEOF())
 {
 System.out.println(rstTitleAuthor.getField(0).
 getString() + " " +
 rstTitleAuthor.getField(1).getString() + " " +
 rstTitleAuthor.getField(2).getString() + " " +
 rstTitleAuthor.getField(3).getString());
 rstTitleAuthor.moveNext();
 }
 if(++intCount % 5 == 0)
 {
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 }
 rstAuthors.moveNext();
 }

 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstAuthors != null)
 {
 PrintProviderError(rstAuthors.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstTitleAuthor != null)
 if (rstTitleAuthor.getState() == 1)
 rstTitleAuthor.close();
 if (rstAuthors != null)
 if (rstAuthors.getState() == 1)
 rstAuthors.close();
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 }
 }

 // PrintProviderError Function
 static void PrintProviderError(Connection cnn1)
 {
 // Print Provider Errors from Connection Object.
 // ErrItem is an item object in the Connections Errors Collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if ( nCount > 0)
 {
 // Collection ranges from 0 to nCount-1.
 for ( i=0;i<nCount; i++)
 {
 ErrItem = cnn1.getErrors().getItem(i);
 System.out.println("\t Error Number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription());
 }
 }
 }
 // PrintIOError Function
 static void PrintIOError(java.io.IOException je)
 {
 System.out.println("Error: \n");
 System.out.println("\t Source: " + je.getClass() + "\n");
 System.out.println("\t Description: "+ je.getMessage() + "\n");
 }
}
// EndStayInSyncJ


RelatedTable Property (ADOX)

 Copy code hover
[image]

RelatedTable Property (ADOX)
Send feedback

Indicates the name of the related table.

Settings and Return Values

Sets and returns a String value.

Remarks

The default value is an empty string ("").

If the key is a foreign key, then RelatedTable is the name of the table that contains the key.


Label.DisplayWhen Property (Access)

 Copy code hover
[image]

Label.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Syntax

expression .DisplayWhen

expression A variable that represents a Label object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

Label Object

Other resources

Label Object Members


OptionButton.IsVisible Property (Access)

 Copy code hover
[image]

OptionButton.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Syntax

expression .IsVisible

expression A variable that represents an OptionButton object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


ComboBox.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

ComboBox.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Syntax

expression .ShortcutMenuBar

expression A variable that represents a ComboBox object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

Example

The following example sets the "Suppliers_Toolbar" as the custom shortcut menu to display when the user clicks the right mouse button on the "Suppliers" form.

VBA Copy code Copy code
Forms("Suppliers").ShortcutMenuBar = "Suppliers_Toolbar"

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


NextRecordset Method Example (VC++)

 Copy code hover
[image]

NextRecordset Method Example (VC++)
Send feedback

This example uses the NextRecordset method to view the data in a recordset that uses a compound command statement made up of three separate SELECT statements.

Copy code Copy code

// BeginNextRecordsetCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <stdio.h>
#include <ole2.h>
#include <conio.h>
#include <stdlib.h>

//Function Declaration.
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void NextRecordsetX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 NextRecordsetX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////
// //
// NextRecordsetX Function //
// //
//////////////////////////////////////////////////

void NextRecordsetX(void)
{
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstCompound = NULL;

 // Define Other Variables
 HRESULT hr = S_OK;
 _variant_t index;
 index.vt = VT_I2;

 // Assign connection string to a variable.
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 // Open recordset from Authors table.
 TESTHR(pRstCompound.CreateInstance(__uuidof(Recordset)));

 // Pass the Cursor type and Lock type to the Recordset.
 pRstCompound->Open("SELECT * FROM authors; SELECT * FROM stores;"
 "SELECT * FROM jobs", strCnn, adOpenForwardOnly,
 adLockReadOnly, adCmdText);

 // Display results from each SELECT statement.
 int intCount = 1;
 while(!(pRstCompound==NULL))
 {
 printf("\n\nContents of recordset #%d\n", intCount);

 while(!pRstCompound->EndOfFile)
 {
 index.iVal = 0;
 printf("%s\t", (LPCSTR)(_bstr_t)pRstCompound-> GetFields()->GetItem(& index)->Value);
 index.iVal = 1;
 printf("%s\n", (LPCSTR)(_bstr_t)pRstCompound-> Fields->GetItem(& index)->Value);

 pRstCompound->MoveNext();

 int intLine = intLine + 1;
 if (intLine % 22 == 0)
 {
 printf("\nPress any key to continue...");
 getch();

 //Clear the screen for the next display.
 system("cls");
 }
 }
 long lngRec = 0;
 pRstCompound = pRstCompound->
 NextRecordset((VARIANT *)lngRec);

 printf("\nPress any key to continue...");
 getch();
 intCount = intCount + 1;
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstCompound->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 if (pRstCompound)
 if (pRstCompound->State == adStateOpen)
 pRstCompound->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,
 (LPCSTR) pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndNextRecordsetCpp


Appendix C: Programming with ADO (ADO)

 Copy code hover
[image]

Appendix C: Programming with ADO (ADO)
Send feedback

In this section

  • Appendix C: Programming with ADO

  • Using ADO with Microsoft Visual Basic

  • Using ADO with Scripting Languages Topics

  • Using ADO with Microsoft Visual C++ Topics

  • Using ADO with Microsoft Visual J++ Topics


CreateRecord Data Block

 Copy code hover
[image]

CreateRecord Data Block
Send feedback

You can use the CreateRecord data block to create a new record in the specified table.

Note Note

The CreateRecord data block is available only in Data Macros.

Setting

The CreateRecord data block has the following arguments.

Argument | Required | Description
Create a Record In | Yes | The name of the table to create the new record in.
Alias | No | An string that identifies the record. You can use the record's alias to identify

Remarks

The record created by CreateRecord automatically becomes the current record.

After CreateRecord statement, you can insert a block of commands that will execute before the new record is committed. The following actions are available in a CreateRecord data block.

CancelRecordChange Macro Action

Comment Macro Statement

Group Macro Statement

If...Then...Else Macro Statement

SetField Macro Action

SetLocalVar Macro Action

After the CreateRecord action creates a record, use the SetField action to specify a value of a field in the new record.

You can use an If...Then...Else statment to perform operations based on a condition.

To cancel the creation of a record, use the CancelRecordChange action. This prevents the changes from being committed and exits the CreateRecord data block.

Once the new record is committed, you can use the LastCreateRecordIdentity local variable to work with the record. For example, use the following syntax to refer to the AssignedTo field of the most recently created record.

Copy code Copy code
[LastCreateRecordIdentity].[AssignedTo]

The CreateRecord data block can only be used in the After Insert, After Update, and After Update data macro events.


Workspaces.Refresh Method (DAO)

 Copy code hover
[image]

Workspaces.Refresh Method (DAO)
Send feedback

Not supported for this object.

Syntax

expression .Refresh

expression A variable that represents a Workspaces object.

Remarks

You can't use the Refresh method with collections that aren't persistent, such as Connections, Databases, Recordsets, Workspaces, or the QueryDefs collection of a Connection object.


CustomControl.OldBorderStyle Property (Access)

 Copy code hover
[image]

CustomControl.OldBorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.

Syntax

expression .OldBorderStyle

expression A variable that represents a CustomControl object.

Remarks

The OldBorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines
Note Note

  • If the OldBorderStyle property is set to None or Dialog, the form doesn't have Maximize or Minimize buttons, regardless of its MinMaxButtons property setting.

  • If the OldBorderStyle property is set to None, the form doesn't have a Control menu, regardless of its ControlBox property setting.

  • The OldBorderStyle property setting doesn't affect the display of the scroll bars, navigation buttons, the record number box, or record selectors.

Example

The following example demonstrates the effect of changing a control's BorderStyle property, while leaving the OldBorderStyle unaffected. The example concludes with setting the BorderStyle property to its original unedited value.

VBA Copy code Copy code
With Forms("Order Entry").Controls("Zip Code") .BorderStyle = 3 ' Short dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 3, 1.

    .BorderStyle = 2 ' Dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 2, 1

    .BorderStyle = .OldBorderStyle ' Solid (default) border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 1, 1
End With

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


WebBrowserControl.DblClick Event (Access)

 Copy code hover
[image]

WebBrowserControl.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Version Information

Version Added: Access 2010

Syntax

expression .DblClick(Cancel, )

expression A variable that represents a WebBrowserControl object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer |

Return Value

nothing

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


ComboBox.LostFocus Event (Access)

 Copy code hover
[image]

ComboBox.LostFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The LostFocus event occurs when the specified object loses the focus.

Syntax

expression .LostFocus

expression A variable that represents a ComboBox object.

Remarks

To run a macro or event procedure when these events occur, set the OnLostFocus property to the name of the macro or to [Event Procedure].

This events occurs when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The LostFocus event differs from the Exit event in that the LostFocus event occurs every time a control loses the focus. The Exit event occurs only before a control loses the focus to another control on the same form. The LostFocus event occurs after the Exit event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Missing destination field name in SELECT INTO statement

 Copy code hover
[image]

Missing destination field name in SELECT INTO statement <statement>. (Error 3105)
Send feedback

Enter a destination field name in the specified statement, and then try the operation again.


onError Event (RDS)

 Copy code hover
[image]

onError Event (RDS)
Send feedback

The onError event is called whenever an error occurs during an operation.

Syntax

onError SCode, Description, Source, CancelDisplay

Parameters

  • SCode

  • An integer that indicates the status code of the error.

  • Description

  • A String that indicates a description of the error.

  • Source

  • A String that indicates the query or command that caused the error.

  • CancelDisplay

  • A Boolean value, which if set to True, that prevents the error from being displayed in a dialog box.


TabControl.PressedForeTint Property (Access)

 Copy code hover
[image]

TabControl.PressedForeTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .PressedForeTint

expression A variable that represents a TabControl object.

Remarks

The PressedForeTint property contains a numeric expression that can be used to lighten the theme color in the PressedForeColor property. The default value of the PressedForeTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Concurrent schema changes caused the create replica operation to fail. Try again. (Error 3763)

 Copy code hover
[image]

Concurrent schema changes caused the create replica operation to fail. Try again. (Error 3763)
Send feedback

During the create replica operation new objects that did not allow the operation to continue succesfully may have been created in the source replica. Try again.


DoCmd.Hourglass Method (Access)

 Copy code hover
[image]

DoCmd.Hourglass Method (Access)
See also Send feedback

Published: July 16, 2012

The Hourglass method carries out the Hourglass action in Visual Basic.

Syntax

expression .Hourglass(HourglassOn)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
HourglassOn | Required | Variant | Use True (-1) to display the hourglass icon (or another icon you've chosen). Use False (0) to display the normal mouse pointer.

Remarks

You can use the Hourglass method to change the mouse pointer to an image of an hourglass (or another icon you've chosen) while a procedure is running. This method can provide a visual indication that the procedure is running. This is especially useful when a procedure takes a long time to run.

You often use this method if you've turned echo off by using the Echo method. When echo is off, Microsoft Access suspends screen updates until the macro is finished.

Microsoft Access automatically resets the HourglassOn argument to False when the procedure finishes running.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


ToggleButton.TripleState Property (Access)

 Copy code hover
[image]

ToggleButton.TripleState Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TripleState property to specify how the specified control will display Null values. Read/write Boolean.

Syntax

expression .TripleState

expression A variable that represents a ToggleButton object.

Remarks

The Null property uses the following settings.

Setting | Description
True | The control will cycle through states for Yes, No, and Null values. The control appears dimmed (grayed) when its Value property is set to Null.
False | (Default) The control will cycle through states for Yes and No values. Null values display as if they were No values.

This property can be set in any view.

Example

The following example displays a message describing in detail the state of a check box named "Check1" on the form "frmOperations".

VBA Copy code Copy code
Dim strTripleState As String

strTripleState = Forms.Item("frmOperations").Controls.Item("Check1").TripleState

Select Case strTripleState
 Case True
 MsgBox "For Check1, TripleState = " & strTripleState & _
 ". The control will cycle through states for Yes, No, " & _
 "and Null values. The control appears dimmed (grayed) " & _
 "when its Value property is set to Null."
 Case False
 MsgBox "For Check1, TripleState = " & strTripleState & _
 ". The control will cycle through states for Yes and No " & _
 "values. Null values display as if they were No values."
 Case Else
 MsgBox "Can't determine the TripleState property for Check1."
End Select

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Namespaces
Send feedback

Namespaces

The XML persistence format in ADO uses the following four namespaces.

Prefix | Description
s | Refers to the "XML-Data" namespace containing the elements and attributes that define the schema of the current Recordset.
dt | Refers to the data type definitions specification.
rs | Refers to the namespace containing elements and attributes specific to ADO Recordset properties and attributes.
z | Refers to the schema of the current rowset.

A client should not add its own tags to these namespaces, as defined by the specification. For example, a client should not define a namespace as "urn:schemas-microsoft-com:rowset" and then write out something such as "rs:MyOwnTag." To learn more about namespaces, see XML Namespaces.

Note Note

The ID for the schema tag must be "RowsetSchema," and the namespace used to refer to the schema of the current rowset must point to "#RowsetSchema."

Note that the prefix of the namespace, that part to the right of the colon and to the left of the equal sign, is arbitrary.

Copy code Copy code

xmlns:rs="urn:schemas-microsoft-com:rowset"

The user can define this to be any name as long as this name is consistently used throughout the XML document. ADO always writes out "s," "rs," "dt," and "z," but these prefix names are not hard-coded into the loading component.

Namespaces

The XML persistence format in ADO uses the following four namespaces.

Prefix | Description
s | Refers to the "XML-Data" namespace containing the elements and attributes that define the schema of the current Recordset.
dt | Refers to the data type definitions specification.
rs | Refers to the namespace containing elements and attributes specific to ADO Recordset properties and attributes.
z | Refers to the schema of the current rowset.

A client should not add its own tags to these namespaces, as defined by the specification. For example, a client should not define a namespace as "urn:schemas-microsoft-com:rowset" and then write out something such as "rs:MyOwnTag." To learn more about namespaces, see XML Namespaces.

Note Note

The ID for the schema tag must be "RowsetSchema," and the namespace used to refer to the schema of the current rowset must point to "#RowsetSchema."

Note that the prefix of the namespace, that part to the right of the colon and to the left of the equal sign, is arbitrary.

Copy code Copy code

xmlns:rs="urn:schemas-microsoft-com:rowset"

The user can define this to be any name as long as this name is consistently used throughout the XML document. ADO always writes out "s," "rs," "dt," and "z," but these prefix names are not hard-coded into the loading component.


Field.VisibleValue Property (DAO)

 Copy code hover
[image]

Field.VisibleValue Property (DAO)
Send feedback

Syntax

expression .VisibleValue

expression A variable that represents a Field object.

Remarks

This property contains the value of the field that is currently in the database on the server. During an optimistic batch update, a collision may occur where a second client modified the same field and record in between the time the first client retrieved the data and the first client's update attempt. When this happens, the value that the second client set will be accessible through this property.


Service Providers and Components

 Copy code hover
[image]

Service Providers and Components
Send feedback

Service providers are components that extend the functionality of data providers by implementing extended interfaces that are not natively supported by the data store.

Microsoft Data Access provides a component architecture that allows individual, specialized components to implement discrete sets of database functionality, or "services," on top of less capable stores. Thus, rather than forcing each data store to provide its own implementation of extended functionality or forcing generic applications to implement database functionality internally, service components provide a common implementation that any application can use when accessing any data store. The fact that some functionality is implemented natively by the data store and some through generic components is transparent to the application.

For example, a cursor engine, such as the Microsoft Cursor Service for OLE DB, is a service component that can consume data from a sequential, forward-only data store to produce scrollable data. Other service providers commonly used by ADO include the Microsoft OLE DB Persistence Provider (for saving data to a file), the Microsoft Data Shaping Service for OLE DB (for hierarchical Recordsets), and the Microsoft OLE DB Remoting Provider (for invoking data providers on a remote computer).

For more information about service and data providers, see Appendix A: Providers.


BoundObjectFrame.Locked Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Locked Property (Access)
See also Send feedback

Published: July 16, 2012

The Locked property specifies whether you can edit data in a control in Form view. Read/write Boolean.

Syntax

expression .Locked

expression A variable that represents a BoundObjectFrame object.

Remarks

The default setting of the Locked property is False. The BoundObjectFrame control functions normally but doesn't allow editing, adding, or deleting data.

Use the Locked property to protect data in a field by making it read-only. For example, you might want a control to only display information without allowing editing, or you might want to lock a control until a specific condition is met.

Example

The following example toggles the Enabled property of a command button and the Enabled and Locked properties of a control, depending on the type of employee displayed in the current record. If the employee is a manager, then the SalaryDetails button is enabled and the PersonalInfo control is unlocked and enabled.

VBA Copy code Copy code
Sub Form_Current()
 If Me!EmployeeType = "Manager" Then
 Me!SalaryDetails.Enabled = True
 Me!PersonalInfo.Enabled = True
 Me!PersonalInfo.Locked = False
 Else
 Me!SalaryDetails.Enabled = False
 Me!PersonalInfo.Enabled = False
 Me!PersonalInfo.Locked = True
 End If
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Connections.Refresh Method (DAO)

 Copy code hover
[image]

Connections.Refresh Method (DAO)
Send feedback

Not supported for the Connections collection.

You can't use the Refresh method with collections that aren't persistent, such as Connections, Databases, Recordsets, Workspaces, or the QueryDefs collection of a Connection object.


WebBrowserControl.Visible Property (Access)

 Copy code hover
[image]

WebBrowserControl.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .Visible

expression A variable that represents a WebBrowserControl object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Comparison Operators (Access 2013 custom web app)

 Copy code hover
[image]

Comparison Operators (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • < (Less Than) (Access 2013 custom web app)

  • <= (Less Than or Equal To) (Access 2013 custom web app)

  • <> (Not Equal To) (Access 2013 custom web app)

  • = (Equals) (Access 2013 custom web app)

  • > (Greater Than) (Access 2013 custom web app)

  • >= (Greater Than or Equal To) (Access 2013 custom web app)

  • BETWEEN (Access 2013 custom web app)

  • IN (Access 2013 custom web app)

  • LIKE (Access 2013 custom web app)


GroupLevel.Application Property (Access)

 Copy code hover
[image]

GroupLevel.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a GroupLevel object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

GroupLevel Object

Other resources

GroupLevel Object Members


AcOpenDataMode Enumeration (Access)

 Copy code hover
[image]

AcOpenDataMode Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the data entry mode when opening a table, query, stored procedure, view, or user-defined function.

Name | Value | Description
acAdd | 0 | The user can add new records but can't view or edit existing records.
acEdit | 1 | The user can view or edit existing records and add new records.
acReadOnly | 2 | The user can only view records.


User Interface Commands

 Copy code hover
[image]

User Interface Commands
Send feedback

In this section

  • AddMenu Macro Action

  • BrowseTo Macro Action

  • LockNavigationPane Macro Action

  • MessageBox Macro Action

  • NavigateTo Macro Action

  • SetDisplayedCategories Macro Action

  • SetMenuItem Macro Action

  • ShowToolbar Macro Action


WebBrowserControl Events (Access)

 Copy code hover
[image]

WebBrowserControl Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeNavigate2 | Occurs before navigation occurs in the given WebBrowserControl.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Change | The Change event occurs when the contents of the specified control changes.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Dirty | The Dirty event occurs when the contents of the specified control changes.
DocumentComplete | Occurs when a document is completely loaded and initialized.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.
NavigateError | Occurs when an error occurs during navigation.
ProgressChange | Occurs when the progress of a download operation is updated.
Updated | The Updated event occurs when an OLE object's data has been modified.


Characters found after end of SQL statement. (Error 3142)

 Copy code hover
[image]

Characters found after end of SQL statement. (Error 3142)
Send feedback

You entered data after using a semicolon (;) in the SQL statement. For example, "SELECT * FROM table1; garbage" will generate this error. To prevent this error, remove any characters following the semicolon (;).


Connections Members (DAO)

 Copy code hover
[image]

Connections Members (DAO)
Send feedback
Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.A Connections collection contains the current Connection objects of a Workspace object. (ODBCDirect workspaces only).

Methods

Name | Description
Refresh | Not supported for the Connections collection.

Properties

Name | Description
Count | Returns the number of Connection objects in the Connections collection.


TabControl.Change Event (Access)

 Copy code hover
[image]

TabControl.Change Event (Access)
See also Send feedback

Published: July 16, 2012

The Change event occurs when when you move from one page to another page.

Syntax

expression .Change

expression A variable that represents a TabControl object.

Remarks

Note Note

Setting the value of a control by using a macro or Visual Basic doesn't trigger this event for the control. You must type the data directly into the control, or set the control's Text property.

To run a macro or event procedure when this event occurs, set the OnChange property to the name of the macro or to [Event Procedure].

By running a macro or event procedure when a Change event occurs, you can coordinate data display among controls. You can also display data or a formula in one control and the results in another control.

KeyDown → KeyPress → BeforeInsert → Change → KeyUp

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


AccessObject.Name Property (Access)

 Copy code hover
[image]

AccessObject.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.

Syntax

expression .Name

expression A variable that represents an AccessObject object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

AccessObject Object

Other resources

AccessObject Object Members


DoCmd.TransferText Method (Access)

 Copy code hover
[image]

DoCmd.TransferText Method (Access)
See also Send feedback

Published: July 16, 2012

The TransferText method carries out the TransferText action in Visual Basic.

Syntax

expression .TransferText(TransferType, SpecificationName, TableName, FileName, HasFieldNames, HTMLTableName, CodePage)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
TransferType | Optional | AcTextTransferType | The type of transfer you want to make. You can import data from, export data to, or link to data in delimited or fixed-width text files or HTML files. The default value is acImportDelim. Only acImportDelim, acImportFixed, acExportDelim, acExportFixed, or acExportMerge transfer types are supported in a Microsoft Access project (.adp).
SpecificationName | Optional | Variant | A string expression that's the name of an import or export specification you've created and saved in the current database. For a fixed-width text file, you must either specify an argument or use a schema.ini file, which must be stored in the same folder as the imported, linked, or exported text file. To create a schema file, you can use the text import/export wizard to create the file. For delimited text files and Microsoft Word mail merge data files, you can leave this argument blank to select the default import/export specifications.
TableName | Optional | Variant | A string expression that's the name of the Microsoft Access table you want to import text data to, export text data from, or link text data to, or the Microsoft Access query whose results you want to export to a text file.
FileName | Optional | Variant | A string expression that's the full name, including the path, of the text file you want to import from, export to, or link to.
HasFieldNames | Optional | Variant | Use True (-1) to use the first row of the text file as field names when importing, exporting, or linking. Use False (0) to treat the first row of the text file as normal data. If you leave this argument blank, the default (False) is assumed. This argument is ignored for Microsoft Word mail merge data files, which must always contain the field names in the first row.
HTMLTableName | Optional | Variant | A string expression that's the name of the table or list in the HTML file that you want to import or link. This argument is ignored unless the TransferType argument is set to acImportHTML or acLinkHTML. If you leave this argument blank, the first table or list in the HTML file is imported or linked. The name of the table or list in the HTML file is determined by the text specified by the <CAPTION> tag, if there's a <CAPTION> tag. If there's no <CAPTION> tag, the name is determined by the text specified by the <TITLE> tag. If more than one table or list has the same name, Microsoft Access distinguishes them by adding a number to the end of each table or list name; for example, Employees1 and Employees2.
CodePage | Optional | Variant | A Long value indicating the character set of the code page.

Remarks

You can use the TransferText method to import or export text between the current Microsoft Access database or Access project (.adp) and a text file. You can also link the data in a text file to the current Access database. With a linked text file, you can view the text data with Access while still allowing complete access to the data from your word processing program. You can also import from, export to, and link to a table or list in an HTML file (*.html).

You can export the data in Access select queries to text files. Access exports the result set of the query, treating it just like a table.

Example

The following example exports the data from the Microsoft Access table External Report to the delimited text file April.doc by using the specification Standard Output:

VBA Copy code Copy code
DoCmd.TransferText acExportDelim, "Standard Output", _
    "External Report", "C:\Txtfiles\April.doc"

The following code shows how to create a new Microsoft Word document and perform a mail merge with the data stored in the Customers table.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Public Sub DoMailMerge(strFileSavePath As String)

    ' Create new Word App, add a document and set it visible
    Dim wdApp As New Word.Application
    wdApp.Documents.Add
    wdApp.Visible = True

    ' Open the data set from this database
    wdApp.ActiveDocument.MailMerge.OpenDataSource _
        Name:=Application.CurrentProject.FullName, _
        OpenExclusive:=False, _
        LinkToSource:=True, _
        Connection:="TABLE Customers", _
        SQLStatement:="SELECT Customers.* FROM Customers;"

    ' Add fields to the mail merge document
    Dim oSel As Object
    Set oSel = wdApp.Selection
    With wdApp.ActiveDocument.MailMerge.Fields

        oSel.TypeText vbNewLine & vbNewLine
        .Add oSel.range, "First_Name"
        oSel.TypeText " "
        .Add oSel.range, "Last_Name"
        oSel.TypeText vbNewLine
        .Add oSel.range, "Company"
        oSel.TypeText vbNewLine
        .Add oSel.range, "Address"
        oSel.TypeText vbNewLine
        .Add oSel.range, "City"
        oSel.TypeText ", "
        .Add oSel.range, "State"
        oSel.TypeText " "
        .Add oSel.range, "Zip"
        oSel.TypeText vbNewLine
        oSel.TypeParagraph
        oSel.TypeText "Dear "
        .Add oSel.range, "First_Name"
        oSel.TypeText ","
        oSel.TypeText vbNewLine
        oSel.TypeParagraph
        oSel.TypeText "We have created this mail just for you..."
        oSel.TypeText vbNewLine
        oSel.TypeText vbNewLine
        oSel.TypeText "Sincerely," & vbNewLine & "John Q. Public"
        oSel.TypeText vbFormFeed

    End With

    ' Execute the mail merge and save the document
    wdApp.ActiveDocument.MailMerge.Execute
    wdApp.ActiveDocument.SaveAs strFileSavePath

    ' Close everything and Cleanup Variables
    Set oSel = Nothing
    wdApp.ActiveDocument.Close False
    Set wdApp = Nothing

End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Indexes Methods (DAO)

 Copy code hover
[image]

Indexes Methods (DAO)
Send feedback

In this section

  • Indexes.Append Method (DAO)

  • Indexes.Delete Method (DAO)

  • Indexes.Refresh Method (DAO)


Operation.Name Property (Access)

 Copy code hover
[image]

Operation.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .Name

expression A variable that represents an Operation object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

Operation Object

Other resources

Operation Object Members


AllowZeroLength Property

 Copy code hover
[image]

AllowZeroLength Property
Send feedback

Published: July 16, 2012

You can use the AllowZeroLength property to specify whether a zero-length string(" ") is a valid entry in a table field.

Note Note

The AllowZeroLength property applies only to Text, Memo, and Hyperlink table fields.

Setting

The AllowZeroLength property uses the following settings.

Setting | Visual Basic | Description
Yes | True | A zero-length string is a valid entry. This is the default value when creating a field in the Access user interface.
No | False | A zero-length string is an invalid entry. This is the default value when creating a field programmatically.
Note Note

To access a field's AllowZeroLength property by using Visual Basic, use the DAO AllowZeroLength property or the ADO Column.Properties("Set OLEDB:Allow Zero Length") property.

Remarks

If you want Microsoft Access to store a zero-length string instead of a Null value when you leave a field blank, set both the AllowZeroLength and Required properties to Yes.

The following table shows the results of combining the settings of the AllowZeroLength and Required properties.

AllowZeroLength | Required | User's Action | Value Stored
No | No | Presses ENTER Presses SPACEBAR Enters a zero-length string | Null Null (not allowed)
Yes | No | Presses ENTER Presses SPACEBAR Enters a zero-length string | Null Null Zero-length string
No | Yes | Presses ENTER Presses SPACEBAR Enters a zero-length string | (not allowed) (not allowed) (not allowed)
Yes | Yes | Presses ENTER Presses SPACEBAR Enters a zero-length string | (not allowed) Zero-length string Zero-length string
Note Note

You can use the Format property to distinguish between the display of a Null value and a zero-length string. For example, the string "None" can be displayed when a zero-length string is entered.

The AllowZeroLength property works independently of the Required property. The Required property determines only whether a Null value is valid for the field. If the AllowZeroLength property is set to Yes, a zero-length string will be a valid value for the field regardless of the setting of the Required property.


Form.Close Event (Access)

 Copy code hover
[image]

Form.Close Event (Access)
See also Send feedback

Published: July 16, 2012

The Close event occurs when a form is closed and removed from the screen.

Syntax

expression .Close

expression A variable that represents a Form object.

Return Value

nothing

Remarks

To run a macro or event procedure when this event occurs, set the OnClose property to the name of the macro or to [Event Procedure].

The Close event occurs after the Unload event, which is triggered after the form is closed but before it is removed from the screen.

When you close a form, the following events occur in this order:

Unload → Deactivate → Close

When the Close event occurs, you can open another window or request the user's name to make a log entry indicating who used the form or report.

The Unload event can be canceled, but the Close event can't.

See also

Concepts

Form Object

Other resources

Form Object Members


Attachment.LayoutID Property (Access)

 Copy code hover
[image]

Attachment.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified attachment. Read-only Long.

Version Information

Version Added: Access 2007

Syntax

expression .LayoutID

expression A variable that represents an Attachment object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


EmptyCell.BackShade Property (Access)

 Copy code hover
[image]

EmptyCell.BackShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackShade

expression A variable that represents an EmptyCell object.

Remarks

The BackShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the BackShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackShade=25

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


CheckBox.Undo Method (Access)

 Copy code hover
[image]

CheckBox.Undo Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the Undo method to reset a control or form when its value has been changed.

Syntax

expression .Undo

expression A variable that represents a CheckBox object.

Remarks

For example, you can use the Undo method to clear a change to a record that contains an invalid entry.

If the Undo method is applied to a form, all changes to the current record are lost. If the Undo method is applied to a control, only the control itself is affected.

This method must be applied before the form or control is updated. You may want to include this method in a form's BeforeUpdate event or in a control's Change event.

The Undo method offers an alternative to using the SendKeys statement to send the value of the ESC key in an event procedure.

Example

The following example shows how you can use the Undo method within a control's Change event procedure to force a field named LastName to reset to its original value, if it changed.

VBA Copy code Copy code
Private Sub LastName_Change()
 Me!LastName.Undo
End Sub

The next example uses the Undo method to reset all changes to a form before the form is updated.

VBA Copy code Copy code
Private Sub Form_BeforeUpdate(Cancel As Integer)
 Me.Undo
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Report.ServerFilter Property (Access)

 Copy code hover
[image]

Report.ServerFilter Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ServerFilter property to specify a subset of records to be displayed when a server filter is applied to a report within a Microsoft Access project (.adp) or database. Read/write String.

Syntax

expression .ServerFilter

expression A variable that represents a Report object.

Remarks

The ServerFilter property is a string expression consisting of a WHERE clause without the WHERE keyword. For example, the following Visual Basic code defines and applies a filter to show only customers from the USA:

VBA Copy code Copy code
Me.ServerFilter = "Country = 'USA'"
Me.Refresh

To set the ServerFilter property, you must first either:

  • Set the property value in the form's property sheet.

  • Set the property in Visual Basic by typing

    Copy code Copy code
    Forms(0).ServerFilter = "fieldname = value"

Note Note

Setting the ServerFilter property has no effect on the ADO Filter property.

You can use the ServerFilter property to save a filter and apply it at a later time. Filters are saved with the objects in which they are created. They are automatically loaded when the object is opened, but they aren't automatically applied.

To apply a saved filter to a form, you can click Apply Server Filter on the toolbar, click Apply Filter/Sort on the Records menu, or use a macro or Visual Basic to set the ServerFilterByForm property to True.

The Apply Server Filter button indicates the state of the ServerFilter and ServerFilterByForm properties. The button remains disabled until there is a filter to apply. If an existing filter is currently applied, the Apply Server Filter button appears pressed in.

To apply a filter automatically when a form is opened, specify in the OnOpen event property setting of the form either a macro that uses the ApplyFilter action or an event procedure that uses the ApplyFilter method of the DoCmd object. In either case, the form opens in the Server Filter By Form window.

You can only remove a server filter by using Visual Basic to set the ServerFilterByForm property to False or clear all filter criteria in the Server Filter By Form window and then click Apply Server Filter.

When the ServerFilter property is set in form Design view, Microsoft Access does not attempt to validate the SQL expression. If the SQL expression is invalid, an error occurs when the filter is applied.

Note Note

  • When a new object is created, it inherits the RecordSource, Filter, ServerFilter, OrderBy, and OrderByOn properties of the table or query it was created from.

  • The ServerFilter property setting is ignored if the form's record source is a stored procedure.

See also

Concepts

Report Object

Other resources

Report Object Members


Label.BorderThemeColorIndex Property (Access)

 Copy code hover
[image]

Label.BorderThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BorderThemeColorIndex

expression A variable that represents a Label object.

Remarks

The BorderThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BorderThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Border Color to the Text 2 color by setting the BorderThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.BorderThemeColorIndex=2

See also

Concepts

Label Object

Other resources

Label Object Members


Recordset.Close Method (DAO)

 Copy code hover
[image]

Recordset.Close Method (DAO)
Send feedback

Closes an open Recordset.

Syntax

expression .Close

expression A variable that represents a Recordset object.

Remarks

If the Recordset object is already closed when you use Close, a run-time error occurs.

If you try to close a Connection object while it has any open Recordset objects, the Recordset objects will be closed and any pending updates or edits will be canceled. Similarly, if you try to close a Workspace object while it has any open Connection objects, those Connection objects will be closed, which will close their Recordset objects.

An alternative to the Close method is to set the value of an object variable to Nothing (Set dbsTemp = Nothing).


AcPictureCaptionArrangement Enumeration (Access)

 Copy code hover
[image]

AcPictureCaptionArrangement Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the PictureCaptionArrangement property to determine how a button's caption is arranged in relation to its picture.

Version Information

Version Added: Access 2007

Name | Value | Description
acBottom | 3 | The caption appears below the picture.
acGeneral | 1 | The caption uses the General alignment setting.
acLeft | 4 | The caption appears to the left of the picture.
acNoPictureCaption | 0 | The caption is not displayed.
acRight | 5 | The caption appears to the right of the picture.
acTop | 2 | The caption appears above the picture.


Pages Object (Access)

 Copy code hover
[image]

Pages Object (Access)
See also Send feedback

Published: July 16, 2012

The Pages collection contains all Page objects in a tab control.

Remarks

The Pages collection is a special kind of Controls collection belonging to the tab control. It contains Page objects, which are controls. The Pages collection differs from a typical Controls collection in that you can add and remove Page objects by using methods of the Pages collection.

To add a new Page object to the Pages collection from Visual Basic, use the Add method of the Pages collection. To remove an existing Page object, use the Remove method of the Pages collection. To count the number of Page objects in the Pages collection, use the Count property of the Pages collection.

You can also use the CreateControl method to add a Page object to the Pages collection of a tab control. To do this, you must specify the name of the tab control for the Parent argument of the CreateControl function. The ControlType property constant for a Page object is acPage.

You can enumerate through the Pages collection by using the For Each...Next statement.

Individual Page objects in the Pages collection are indexed beginning with zero.

See also

Concepts

Access Object Model Reference

Other resources

Pages Object Members


WebService.Name Property (Access)

 Copy code hover
[image]

WebService.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .Name

expression A variable that represents a WebService object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

WebService Object

Other resources

WebService Object Members


Control.HorizontalAnchor Property (Access)

 Copy code hover
[image]

Control.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the control is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .HorizontalAnchor

expression A variable that represents a Control object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

Control Object

Other resources

Control Object Members


Controls Members (Access)

 Copy code hover
[image]

Controls Members (Access)
Send feedback

Published: July 16, 2012

The Controls collection contains all of the controls on a form, report, or subform, within another control, or attached to another control. The Controls collection is a member of a Form , Report , and SubForm objects.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Object.
Parent | Returns the parent object for the specified object. Read-only.


Control.Parent Property (Access)

 Copy code hover
[image]

Control.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a Control object.

See also

Concepts

Control Object

Other resources

Control Object Members


User Object (ADOX)

 Copy code hover
[image]

User Object (ADOX)
Send feedback

Represents a user account that has access permissions within a secured database.

Remarks

The Users collection of a Catalog represents all the catalog's users. The Users collection for a Group represents only the users of the specific group.

With the properties, collections, and methods of a User object, you can:

  • Identify the user with the Name property.

  • Change the password for a user with the ChangePassword method.

  • Determine whether a user has read, write, or delete permissions with the GetPermissions and SetPermissions methods.

  • Access the groups to which a user belongs with the Groups collection.

  • Access provider-specific properties with the Properties collection.


Image.HyperlinkAddress Property (Access)

 Copy code hover
[image]

Image.HyperlinkAddress Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the HyperlinkAddress property to specify or determine the path to an object, document, Web page or other destination for a hyperlink associated with a the specified control. Read/write String.

Syntax

expression .HyperlinkAddress

expression A variable that represents an Image object.

Remarks

The HyperlinkAddress property is a string expression representing the path to a file (UNC path) or Web page (URL).

Note Note

When you set the HyperlinkAddress property, you automatically specify the Address property for the Hyperlink object associated with the control.

Note Note

When you create a hyperlink by using the Insert Hyperlink dialog box, Microsoft Access automatically sets the HyperlinkAddress property and HyperlinkSubAddress to the location specified in the Type the file or Web page name box. The HyperlinkSubAddress property can also be set to the location specified in the Select an object in this database box.

If you copy a hyperlink from another application and paste it into a form or report, Microsoft Access creates a label control with its Caption property, HyperlinkAddress property, and HyperlinkSubAddress property automatically set.

When you move the cursor over a command button, image control, or label control whose HyperlinkAddress property is set, the cursor changes to an upward-pointing hand. Clicking the control displays the object or Web page specified by the link.

To open objects in the current database, leave the HyperlinkAddress property blank and specify the object type and object name you want to open in the HyperlinkSubAddress property by using the syntax "objecttype objectname". If you want to open an object contained in another Microsoft Access database, enter the database path and file name in the HyperlinkAddress property and specify the database object to open by using the HyperlinkSubAddress property.

The HyperlinkAddress property can contain an absolute or a relative path to a target document. An absolute path is a fully qualified URL or UNC path to a document. A relative path is a path related to the base path specified in the Hyperlink Base setting in the Properties dialog box (available by clicking Database Properties on the File menu) or to the current database path. If Microsoft Access can't resolve the HyperlinkAddress property setting to a valid URL or UNC path, it will assume you've specified a path relative to the base path contained in the Hyperlink Base setting or the current database path.

Note Note

When you follow a hyperlink to another Microsoft Access database object, the database Startup properties are applied. For example, if the destination database has a Display form set, that form is displayed when the database opens.

The following table contains examples of HyperlinkAddress and HyperlinkSubAddress property settings.

HyperlinkAddress | HyperlinkSubAddress | Description
http://www.microsoft.com/ |  | The Microsoft home page on the Web.
C:\Program Files\Microsoft Office\Office\Samples\Cajun.htm |  | The Cajun Delights page in the Access sample applications subdirectory.
C:\Program Files\Microsoft Office\Office\Samples\Cajun.htm | NewProducts | The "NewProducts" Name tag in the Cajun Delights page.
C:\Personal\MyResume.doc | References | The bookmark named "References" in the Microsoft Word document "MyResume.doc".
C:\Finance\First Quarter.xls | Sheet1!TotalSales | The range named "TotalSales" in the Microsoft Excel spreadsheet "First Quarter.xls".
C:\Presentation\NewPlans.ppt | 10 | The 10th slide in the Microsoft PowerPoint document "NewPlans.ppt".

See also

Concepts

Image Object

Other resources

Image Object Members


The replication property you are attempting to delete is read-only and cannot be removed. (Error 3607)

 Copy code hover
[image]

The replication property you are attempting to delete is read-only and cannot be removed. (Error 3607)
Send feedback

Check to be sure you are deleting the correct property.


Control.ObjectVerbs Property (Access)

 Copy code hover
[image]

Control.ObjectVerbs Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ObjectVerbs property in Visual Basic to determine the list of verbs an OLE object supports. Read-only String.

Syntax

expression .ObjectVerbs(Index)

expression A variable that represents a Control object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Long | An element in the array of supported verbs. This is a zero-based index, meaning zero (0) represents the first verb in the array, one (1) represents the second verb in the array, and so on.

Remarks

This property setting isn't available in Design view.

You can use the ObjectVerbs property with the ObjectVerbsCount property to display a list of the verbs supported by an OLE object. The ObjectVerbs property uses this list of verbs to determine which operation to perform when an OLE object is activated (when the Action property is set to acOLEActivate).

The Verb property setting is the position of a particular verb in the list of verbs returned by the ObjectVerbs property. For example, 1 specifies the first verb in the list (the Visual Basic command ObjectVerbs(0), or the first verb in the ObjectVerbs property array), 2 specifies the second verb in the list (the Visual Basic command ObjectVerbs(1), or the second verb in the ObjectVerbs property array), and so on.

The first verb in the ObjectVerbs property array, called by the Visual Basic command ObjectVerbs(0), is the default verb. If the Verb property hasn't been set, this verb specifies the operation performed when the OLE object is activated.

The list of verbs an object supports varies, depending on the state of the object. To update the list of verbs an object supports, set the control'sAction property to acOLEFetchVerbs. Be sure to update the list of verbs before presenting it to the user.

Example

The following example returns the verbs supported by the OLE object in the OLE1 control and displays each verb in a message box.

VBA Copy code Copy code
Sub GetVerbList(frm As Form, OLE1 As Control)
 Dim intX As Integer, intNumVerbs As Integer
 Dim strVerbList As String

 ' Update verb list.
 With frm!OLE1
 .Action = acOLEFetchVerbs
 intNumVerbs = .ObjectVerbsCount
 For intX = 0 To intNumVerbs - 1
 strVerbList = strVerbList & .ObjectVerbs(intX) & "; "
 Next intX
 End With

 ' Display verbs in message box.
 MsgBox Left(strVerbList, Len(strVerbList) - 2)
End Sub

See also

Concepts

Control Object

Other resources

Control Object Members


The disk for dropbox folder

 Copy code hover
[image]

The disk for dropbox folder <name> is full. (Error 3469)
Send feedback

There is not enough space on the dropbox folder's disk drive to complete the operation. Delete unneeded files from the disk to create sufficient space for the operation.


DoCmd.RunDataMacro Method (Access)

 Copy code hover
[image]

DoCmd.RunDataMacro Method (Access)
See also Send feedback

Published: July 16, 2012

Use the RunDataMacro method to run a named data macro from Visual Basic.

Version Information

Version Added: Access 2010

Syntax

expression .RunDataMacro(MacroName)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
MacroName | Required | Variant | Name of the saved macro. The name must include the name of the table to which the data macro is attached (for example, "Comments.AddComment").

Remarks

Use the RunDataMacro method to reuse a named data macro in Visual Basic code.

If the data macro requires parameters, you must first create them using the SetParameter method prior to calling the RunDataMacro method. Each call to SetParameter creates a single named parameter.

Example

The following code example creates two parameters for use by the AddComment data macro. The two parameters are named prmComment and prmRelatedID, respectively. The value of the txtComment textbox is stored in the prmComment parameter. The value of the txtId textbox is stored in the prmRelatedID parameter. The "Comments.AddComment" data macro is then run.

VBA Copy code Copy code
Private Sub cmdAddComment_Click()
DoCmd.SetParameter "prmComment", Me.txtComment
DoCmd.SetParameter "prmRelatedID", Me.txtId
DoCmd.RunDataMacro "Comments.AddComment"
End Sub

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


NavigationControl.SubForm Property (Access)

 Copy code hover
[image]

NavigationControl.SubForm Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the name of the SubForm object used to display forms. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .SubForm

expression A variable that represents a NavigationControl object.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


QueryDef.CreateProperty Method (DAO)

 Copy code hover
[image]

QueryDef.CreateProperty Method (DAO)
Send feedback

Creates a new user-defined Property object (Microsoft Access workspaces only).

Syntax

expression .CreateProperty(Name, Type, Value, DDL)

expression A variable that represents a QueryDef object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Optional | Variant | A String that uniquely names the new Property object. See the Name property for details on valid Property names.
Type | Optional | Variant | A constant that defines the data type of the new Property object. See the Type property for valid data types.
Value | Optional | Variant | A Variant containing the initial property value. See the Value property for details.
DDL | Optional | Variant | A Variant (Boolean subtype) that indicates whether or not the Property is a DDL object. The default is False. If DDL is True, users can't change or delete this Property object unless they have dbSecWriteDef permission.

Return Value

Property

Remarks

You can create a user-defined Property object only in the Properties collection of an object that is persistent.

If you omit one or more of the optional parts when you use CreateProperty, you can use an appropriate assignment statement to set or reset the corresponding property before you append the new object to a collection. After you append the object, you can alter some but not all of its property settings. See the Name, Type, and Value property topics for more details.

If name refers to an object that is already a member of the collection, a run-time error occurs when you use the Append method.

To remove a user-defined Property object from the collection, use the Delete method on the Properties collection. You can't delete built-in properties.

Note Note

If you omit the DDL argument, it defaults to False (non-DDL). Because no corresponding DDL property is exposed, you must delete and re-create a Property object you want to change from DDL to non-DDL.


CurrentData Properties (Access)

 Copy code hover
[image]

CurrentData Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
AllDatabaseDiagrams | You can use the AllDatabaseDiagrams property to reference the AllDatabaseDiagrams collection and its related properties. Read-only AllDatabaseDiagrams object.
AllFunctions | You can use the AllFunctions property to reference the AllFunctions collection and its related properties. Read-only AllFunctions object.
AllQueries | You can use the AllQueries property to reference the AllQueries collection and its related properties. Read-only AllQueries object.
AllStoredProcedures | You can use the AllStoredProcedures property to reference the AllStoredProcedures collection and its related properties. Read-only AllStoredProcedures object.
AllTables | You can use the AllTables property to reference the AllTables collection and its related properties. Read-only AllTables object.
AllViews | You can use the AllViews property to reference the AllViews collection and its related properties. Read-only AllViews object.


Control.GridlineWidthLeft Property (Access)

 Copy code hover
[image]

Control.GridlineWidthLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the left gridline for the specified control. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthLeft

expression A variable that represents a Control object.

Remarks

The LeftGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Control Object

Other resources

Control Object Members


Duplicate output alias

 Copy code hover
[image]

Duplicate output alias <name>. (Error 3062)
Send feedback

You tried to execute an SQL statement that has more than one alias with the same name. The following statement, for example, would produce this error:

SQL Copy code Copy code
SELECT LastName AS Name, FirstName AS Name FROM Employees;

Rename one or more of the aliases, and then try the operation again.


How to: Work With Attachments In DAO

 Copy code hover
[image]

How to: Work With Attachments In DAO
Send feedback

In DAO, Attachment fields function just like other multi-valued fields. The field that contains the attachment contains a recordset that is a child to the table's recordset. There are two new DAO methods, LoadFromFile and SaveToFile, that deal exclusively with attachments.

Add an Attachment to a Record

The LoadFromFile method loads a file from disk and adds the file as an attachment to the specified record. The following code example shows the syntax of the LoadFromFile method.

VBA Copy code Copy code
Recordset.Fields("FileData").LoadFromFile(<filename>)
Note Note

The FileData field is reserved internally by the Access database engine to store the binary attachment data.

The following code example uses the LoadFromFile method to load an employee's picture from disk.

VBA Copy code Copy code
   '  Instantiate the parent recordset.
   Set rsEmployees = db.OpenRecordset("Employees")

   … Code to move to desired employee

   ' Activate edit mode.
   rsEmployees.Edit

   ' Instantiate the child recordset.
   Set rsPictures = rsEmployees.Fields("Pictures").Value

   ' Add a new attachment.
   rsPictures.AddNew
   rsPictures.Fields("FileData").LoadFromFile "EmpPhoto39392.jpg"
   rsPictures.Update

   ' Update the parent record
   rsEmployees.Update

Save an Attachment to Disk

The following code example shows how to use the SaveToFile method to save all of the attachments for a specific employee to disk.

VBA Copy code Copy code
'  Instantiate the parent recordset.
   Set rsEmployees = db.OpenRecordset("Employees")

   … Code to move to desired employee

   ' Instantiate the child recordset.
   Set rsPictures = rsEmployees.Fields("Pictures").Value

   '  Loop through the attachments.
   While Not rsPictures.EOF

      '  Save current attachment to disk in the "My Documents" folder.
      rsPictures.Fields("FileData").SaveToFile _
                  "C:\Documents and Settings\Username\My Documents"
      rsPictures.MoveNext
   Wend


Form.Bookmark Property (Access)

 Copy code hover
[image]

Form.Bookmark Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Bookmark property with forms to set a bookmark that uniquely identifies a particular record in the form's underlying table, query, or SQL statement. Read/write Variant.

Syntax

expression .Bookmark

expression A variable that represents a Form object.

Remarks

Note Note

You get or set the form's Bookmark property separately from the ADO Bookmark or DAO Bookmark property of the underlying table or query.

When a bound form is opened in Form view, each record is assigned a unique bookmark. In Visual Basic, you can save the bookmark for the current record by assigning the value of the form's Bookmark property to a string variable. To return to a saved record after moving to a different record, set the form's Bookmark property to the value of the saved string variable. You can use the StrComp function to compare a Variant or string variable to a bookmark, or when comparing a bookmark against a bookmark. The third argument for the StrComp function must be set to a value of zero.

Note Note

Bookmarks are not saved with the records they represent and are only valid while the form is open. They are re-created by Microsoft Access each time a bound form is opened.

There is no limit to the number of bookmarks you can save if each is saved with a unique string variable.

The Bookmark property is only available for the form's current record. To save a bookmark for a record other than the current record, move to the desired record and assign the value of the Bookmark property to a string variable that identifies this record.

You can use bookmarks in any form that is based entirely on Microsoft Access tables. However, other database products may not support bookmarks. For example, you can't use bookmarks in a form based on a linked table that has no primary index.

Requerying a form invalidates any bookmarks set on records in the form. However, clicking Refresh on the Records menu doesn't affect bookmarks.

Since Microsoft Access creates a unique bookmark for each record in a form's recordset when a form is opened, a form's bookmark will not work on another recordset, even when the two recordsets are based on the same table, query, or SQL statement. For example, suppose you open a form bound to the Customers table. If you then open the Customers table by using Visual Basic and use the ADO Seek or DAO Seek method to locate a specific record in the table, you can't set the form's Bookmark property to the current table record. To perform this kind of operation you can use the ADO Find method or DAO Find methods with the form's RecordsetClone property.

An error occurs if you set the Bookmark property to a string variable and then try to return to that record after the record has been deleted.

The value of the Bookmark property isn't the same as a record number.

Example

To test the following example with the Northwind sample database, you need to add a command button named cmdFindContactName to the Suppliers form, and then add the following code to the button's Click event. When the button is clicked, the user is asked to enter a portion of the contact name to find. If the name is found, the form's Bookmark property is set to the Recordset object's DAO Bookmark property, which moves the form's current record to the found name.

VBA Copy code Copy code
Private Sub cmdFindContactName_Click()

 Dim rst As DAO.Recordset
 Dim strCriteria As String

 strCriteria = "[ContactName] Like '*" & InputBox("Enter the " _
 & "first few letters of the name to find") & "*'"

 Set rst = Me.RecordsetClone
 rst.FindFirst strCriteria
 If rst.NoMatch Then
 MsgBox "No entry found.", vbInformation
 Else
 Me.Bookmark = rst.Bookmark
 End If

 Set rst = Nothing

End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Database.CreateRelation Method (DAO)

 Copy code hover
[image]

Database.CreateRelation Method (DAO)
Send feedback

Creates a new Relation object (Microsoft Access workspaces only). .

Syntax

expression .CreateRelation(Name, Table, ForeignTable, Attributes)

expression A variable that represents a Database object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Optional | Variant | A Variant (String subtype) that uniquely names the new Relation object. See the Name property for details on valid Relation names.
Table | Optional | Variant | A Variant (String subtype) that names the primary table in the relation. If the table doesn't exist before you append the Relation object, a run-time error occurs.
ForeignTable | Optional | Variant | A Variant (String subtype) that names the foreign table in the relation. If the table doesn't exist before you append the Relation object, a run-time error occurs.
Attributes | Optional | Variant | A constant or combination of constants that contains information about the relationship type. See the Attributes property for details.

Return Value

Relation

Remarks

The Relation object provides information to the Microsoft Access database engine about the relationship between fields in two TableDef or QueryDef objects. You can implement referential integrity by using the Attributes property.

If you omit one or more of the optional parts when you use the CreateRelation method, you can use an appropriate assignment statement to set or reset the corresponding property before you append the new object to a collection. After you append the object, you can't alter any of its property settings. See the individual property topics for more details.

Before you can use the Append method on a Relation object, you must append the appropriate Field objects to define the primary and foreign key relationship tables.

If name refers to an object that is already a member of the collection or if the Field object names provided in the subordinate Fields collection are invalid, a run-time error occurs when you use the Append method.

You can't establish or maintain a relationship between a replicated table and a local table.

To remove a Relation object from the Relations collection, use the Delete method on the collection.

Example

This example uses the CreateRelation method to create a Relation between the Employees TableDef and a new TableDef called Departments. This example also demonstrates how creating a new Relation will also create any necessary Indexes in the foreign table (the DepartmentsEmployees Index in the Employees table).

VBA Copy code Copy code
Sub CreateRelationX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim tdfNew As TableDef
 Dim idxNew As Index
 Dim relNew As Relation
 Dim idxLoop As Index

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind
 ' Add new field to Employees table.
 Set tdfEmployees = .TableDefs!Employees
 tdfEmployees.Fields.Append _
 tdfEmployees.CreateField("DeptID", dbInteger, 2)

 ' Create new Departments table.
 Set tdfNew = .CreateTableDef("Departments")

 With tdfNew
 ' Create and append Field objects to Fields
 ' collection of the new TableDef object.
 .Fields.Append .CreateField("DeptID", dbInteger, 2)
 .Fields.Append .CreateField("DeptName", dbText, 20)

 ' Create Index object for Departments table.
 Set idxNew = .CreateIndex("DeptIDIndex")
 ' Create and append Field object to Fields
 ' collection of the new Index object.
 idxNew.Fields.Append idxNew.CreateField("DeptID")
 ' The index in the primary table must be Unique in
 ' order to be part of a Relation.
 idxNew.Unique = True
 .Indexes.Append idxNew
 End With

 .TableDefs.Append tdfNew

 ' Create EmployeesDepartments Relation object, using
 ' the names of the two tables in the relation.
 Set relNew = .CreateRelation("EmployeesDepartments", _
 tdfNew.Name, tdfEmployees.Name, _
 dbRelationUpdateCascade)

 ' Create Field object for the Fields collection of the
 ' new Relation object. Set the Name and ForeignName
 ' properties based on the fields to be used for the
 ' relation.
 relNew.Fields.Append relNew.CreateField("DeptID")
 relNew.Fields!DeptID.ForeignName = "DeptID"
 .Relations.Append relNew

 ' Print report.
 Debug.Print "Properties of " & relNew.Name & _
 " Relation"
 Debug.Print " Table = " & relNew.Table
 Debug.Print " ForeignTable = " & _
 relNew.ForeignTable
 Debug.Print "Fields of " & relNew.Name & " Relation"

 With relNew.Fields!DeptID
 Debug.Print " " & .Name
 Debug.Print " Name = " & .Name
 Debug.Print " ForeignName = " & .ForeignName
 End With

 Debug.Print "Indexes in " & tdfEmployees.Name & _
 " TableDef"
 For Each idxLoop In tdfEmployees.Indexes
 Debug.Print " " & idxLoop.Name & _
 ", Foreign = " & idxLoop.Foreign
 Next idxLoop

 ' Delete new objects because this is a demonstration.
 .Relations.Delete relNew.Name
 .TableDefs.Delete tdfNew.Name
 tdfEmployees.Fields.Delete "DeptID"
 .Close
 End With

End Sub


FormatCondition.Expression2 Property (Access)

 Copy code hover
[image]

FormatCondition.Expression2 Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Expression2 property to return the values of a conditional format within a FormatCondition object. Read-only String.

Syntax

expression .Expression2

expression A variable that represents a FormatCondition object.

Remarks

The Expression2 property returns a Variant value or expression associated with the second part of the conditional format when the Operator property of the FormatCondition object is acBetween or acNotBetween, otherwise, the Expression2 property is null.

See also

Concepts

FormatCondition Object

Other resources

FormatCondition Object Members


OptionGroup.Controls Property (Access)

 Copy code hover
[image]

OptionGroup.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Syntax

expression .Controls

expression A variable that represents an OptionGroup object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Form.MouseMove Event (Access)

 Copy code hover
[image]

Form.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents a Form object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Append Method (ADOX Columns)

 Copy code hover
[image]

Append Method (ADOX Columns)
Send feedback

Adds a new Column object to the Columns collection.

Syntax

Columns. Append Column [,Type] [,DefinedSize]

Parameters

  • Column

  • The Column object to append or the name of the column to create and append.

  • Type

  • Optional. A Long value that specifies the data type of the column. The Type parameter corresponds to the Type property of a Column object.

  • DefinedSize

  • Optional. A Long value that specifies the size of the column. The DefinedSize parameter corresponds to the DefinedSize property of a Column object.

Note Note

An error will occur when appending a Column to the Columns collection of an Index if the Column does not exist in a Table that is already appended to the Tables collection.


Properties.Parent Property (Access)

 Copy code hover
[image]

Properties.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a Properties object.

See also

Concepts

Properties Collection

Other resources

Properties Members


Index Members (DAO)

 Copy code hover
[image]

Index Members (DAO)
Send feedback

Index objects specify the order of records accessed from database tables and whether or not duplicate records are accepted, providing efficient access to data. For external databases, Index objects describe the indexes established for external tables (Microsoft Access workspaces only).

Methods

Name | Description
CreateField | Creates a new Field object (Microsoft Access workspaces only).
CreateProperty | Creates a new user-defined Property object (Microsoft Access workspaces only).

Properties

Name | Description
Clustered | Sets or returns a value that indicates whether an Index object represents a clustered index for a table (Microsoft Access workspaces only). Read/write Boolean.
DistinctCount | Returns a value that indicates the number of unique values for the Index object that are included in the associated table (Microsoft Access workspaces only).
Fields | Returns a Fields collection that represents all stored Field objects for the specified object. Read/write.
Foreign | Returns a value that indicates whether an Index object represents a foreign key in a table (Microsoft Access workspaces only). .
IgnoreNulls | Sets or returns a value that indicates whether records that have Null values in their index fields have index entries (Microsoft Access workspaces only).
Name | Returns or sets the name of the specified object. Read/write String if the object has not been appended to a collection. Read-only String if the object has been appended to a collection.
Primary | Sets or returns a value that indicates whether an Index object represents a primary key index for a table (Microsoft Access workspaces only).
Properties | Returns the Properties collection of the specified object. Read-only.
Required | Sets or returns a value that indicates whether a Field object requires a non-Null value.
Unique | Sets or returns a value that indicates whether an Index object represents a unique (key) index for a table (Microsoft Access workspaces only).


NavigationButton.IsVisible Property (Access)

 Copy code hover
[image]

NavigationButton.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .IsVisible

expression A variable that represents a NavigationButton object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data. (Error 3163)

 Copy code hover
[image]

The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data. (Error 3163)
Send feedback

The field into which you tried to insert or paste data is not large enough to hold the data. Try inserting or pasting less data.


Invalid SQL syntax - expected a database privilege, such as CREATEDB or CONNECT (Error 3786)

 Copy code hover
[image]

Invalid SQL syntax - expected a database privilege, such as CREATEDB or CONNECT (Error 3786)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for more information.


Report.OnOpen Property (Access)

 Copy code hover
[image]

Report.OnOpen Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Open box in the Properties window of a form or report. Read/write String.

Syntax

expression .OnOpen

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Open event occurs when a form is opened, but before the first record is displayed. For reports, the event occurs before a report is previewed or printed.

The OnOpen value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Open box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Open box is blank, the property value is an empty string.

See also

Concepts

Report Object

Other resources

Report Object Members


Handler Property Example (VB)

 Copy code hover
[image]

Handler Property Example (VB)
Send feedback

This example demonstrates the RDS DataControl object Handler property. (See DataFactory Customization for more details.)

Assume that the following sections in the parameter file, Msdfmap.ini, are located on the server:

Copy code Copy code

[connect AuthorDataBase]
Access=ReadWrite
Connect="DSN=Pubs"
[sql AuthorById]
SQL="SELECT * FROM Authors WHERE au_id = ?"

Your code looks like the following. The command assigned to the SQL property will match the AuthorById identifier and will retrieve a row for author Michael O'Leary. The DataControl object Recordset property is assigned to a disconnected Recordset object purely as a coding convenience.

Visual Basic Copy code Copy code
'BeginHandlerVBPublic Sub Main()
On Error GoTo ErrorHandlerDim dc As New DataControl
Dim rst As ADODB.Recordsetdc.Handler = "MSDFMAP.Handler"
dc.ExecuteOptions = 1dc.FetchOptions = 1
dc.Server = "http://MyServer"dc.Connect = "Data Source=AuthorDataBase"
dc.SQL = "AuthorById('267-41-2394')"dc.Refresh 'Retrieve the record
Set rst = dc.Recordset 'Use another Recordset as a convenienceDebug.Print "Author is '" & rst!au_fname & " " & rst!au_lname & "'"
' clean upIf rst.State = adStateOpen Then rst.Close
Set rst = NothingSet dc = Nothing
Exit SubErrorHandler:
' clean upIf Not rst Is Nothing Then
If rst.State = adStateOpen Then rst.CloseEnd If
Set rst = NothingSet dc = Nothing
If Err <> 0 ThenMsgBox Err.Source & "-->" & Err.Description, , "Error"
End IfEnd Sub
'EndHandlerVB


EmptyCell.LeftPadding Property (Access)

 Copy code hover
[image]

EmptyCell.LeftPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .LeftPadding

expression A variable that represents an EmptyCell object.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


Recordsets.Refresh Method (DAO)

 Copy code hover
[image]

Recordsets.Refresh Method (DAO)
Send feedback

Not supported for this object.

Syntax

expression .Refresh

expression A variable that represents a Recordsets object.

Remarks

You can't use the Refresh method with collections that aren't persistent, such as Connections, Databases, Recordsets, Workspaces, or the QueryDefs collection of a Connection object.


OptionButton.OnEnter Property (Access)

 Copy code hover
[image]

OptionButton.OnEnter Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnEnter

expression A variable that represents an OptionButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Enter event occurs before a control actually receives the focus from a control on the same form.

The OnEnter value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Enter box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Enter box is blank, the property value is an empty string.

Example

The following example associates the Enter event with the macro "Enter_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnEnter = "Enter_Macro"

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


TextBox.ValidationRule Property (Access)

 Copy code hover
[image]

TextBox.ValidationRule Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String.

Syntax

expression .ValidationRule

expression A variable that represents a TextBox object.

Remarks

Enter an expression for the ValidationRule property setting and text for the ValidationText property setting. The maximum length for the ValidationRule property setting is 2048 characters. The maximum length for the ValidationText property setting is 255 characters.

For controls, you can set the ValidationRule property to any valid expression. For field and record validation rules, the expression can't contain user-defined functions, domain aggregate or aggregate functions, the Eval function, or CurrentUser method, or references to forms, queries, or tables. In addition, field validation rules can't contain references to other fields. For records, expressions can include references to fields in that table.

For table fields and records, you can also set these properties in Visual Basic by using the DAO ValidationRule property.

Microsoft Access automatically validates values based on a field's data type; for example, Microsoft Access doesn't allow text in a numeric field. You can set rules that are more specific by using the ValidationRule property.

If you set the ValidationRule property but not the ValidationText property, Microsoft Access displays a standard error message when the validation rule is violated. If you set the ValidationText property, the text you enter is displayed as the error message.

For example, when a record is added for a new employee, you can enter a ValidationRule property requiring that the value in the employee's StartDate field fall between the company's founding date and the current date. If the date entered isn't in this range, you can display the ValidationText property message: "Start date is incorrect."

If you create a control by dragging a field from the field list, the field's validation rule remains in effect, although it isn't displayed in the control's ValidationRule property box in the property sheet. This is because a field's validation rule is inherited by a control bound to that field.

Control, field, and record validation rules are applied as follows:

  • Validation rules you set for fields and controls are applied when you edit the data and the focus leaves the field or control.

  • Validation rules for records are applied when you move to another record.

  • If you create validation rules for both a field and a control bound to the field, both validation rules are applied when you edit data and the focus leaves the control.

The following table contains expression examples for the ValidationRule and ValidationText properties.

ValidationRule property | ValidationText property
<> 0 | Entry must be a nonzero value.
> 1000 Or Is Null | Entry must be blank or greater than 1000.
Like "A????" | Entry must be 5 characters and begin with the letter "A".
>= #1/1/96# And <#1/1/97# | Entry must be a date in 1996.
DLookup("CustomerID", "Customers", "CustomerID = Forms!Customers!CustomerID") Is Null | Entry must be a unique CustomerID (domain aggregate functions are allowed only for form-level validation).

If you create a validation rule for a field, Microsoft Access doesn't normally allow a Null value to be stored in the field. If you want to allow a Null value, add "Is Null" to the validation rule, as in "<> 8 Or Is Null" and make sure the Required property is set to No.

You can't set field or record validation rules for tables created outside Microsoft Access (for example, dBASE, Paradox, or SQL Server). For these kinds of tables, you can create validation rules for controls only.

Example

The following example creates a validation rule for a field that allows only values over 65 to be entered. If a number less than 65 is entered, a message is displayed. The properties are set by using the SetFieldValidation function.

VBA Copy code Copy code
Dim strTblName As String, strFldName As String
Dim strValidRule As String
Dim strValidText As String, intX As Integer

strTblName = "Customers"
strFldName = "Age"
strValidRule = ">= 65"
strValidText = "Enter a number greater than or equal to 65."
intX = SetFieldValidation(strTblName, strFldName, _
 strValidRule, strValidText)

Function SetFieldValidation(strTblName As String, _
 strFldName As String, strValidRule As String, _
 strValidText As String) As Integer

 Dim dbs As Database, tdf As TableDef, fld As Field

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 Set fld = tdf.Fields(strFldName)
 fld.ValidationRule = strValidRule
 fld.ValidationText = strValidText
End Function

The next example uses the SetTableValidation function to set record-level validation to ensure that the value in the EndDate field comes after the value in the StartDate field.

VBA Copy code Copy code
Dim strTblName As String, strValidRule As String
Dim strValidText As String
Dim intX As Integer

strTblName = "Employees"
strValidRule = "EndDate > StartDate"
strValidText = "Enter an EndDate that is later than the StartDate."
intX = SetTableValidation(strTblName, strValidRule, strValidText)

Function SetTableValidation(strTblName As String, _
 strValidRule As String, strValidText As String) _
 As Integer

 Dim dbs As Database, tdf As TableDef

 Set dbs = CurrentDb
 Set tdf = dbs.TableDefs(strTblName)
 tdf.ValidationRule = strValidRule
 tdf.ValidationText = strValidText
End Function

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Rectangle.BackStyle Property (Access)

 Copy code hover
[image]

Rectangle.BackStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.

Syntax

expression .BackStyle

expression A variable that represents a Rectangle object.

Remarks

The BackStyle property uses the following settings.

Setting | Visual Basic | Description
Normal | 1 | (Default for all controls except option group) The control has its interior color set by the BackColor property.
Transparent | 0 | (Default for option group) The control is transparent. The color of the form or report behind the control is visible.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

If the Transparent button on the Back Color button palette is selected, the BackStyle property is set to Transparent; otherwise the BackStyle property is set to Normal.

To make a command button invisible, set its Transparent property to Yes.

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


Text file specification field separator matches decimal separator or text delimiter. (Error 3441)

 Copy code hover
[image]

Text file specification field separator matches decimal separator or text delimiter. (Error 3441)
Send feedback

Two or more of the following delimiters settings used by the Text ISAM are the same:

  • TxtDelimiter

  • NumberDecimalSymbol

  • CurrencyDecimalSymbol

  • Format


Keys Collection (ADOX) Reference

 Copy code hover
[image]

Keys Collection (ADOX) Reference
Send feedback

In this section

  • Keys Collection (ADOX)

  • Keys Collection Properties, Methods, and Events (ADOX)


CommandButton.GridlineThemeColorIndex Property (Access)

 Copy code hover
[image]

CommandButton.GridlineThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineThemeColorIndex

expression A variable that represents a CommandButton object.

Remarks

The GridlineThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 (Default) | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the GridlineThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


OptionButton.RightPadding Property (Access)

 Copy code hover
[image]

OptionButton.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the option button and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .RightPadding

expression A variable that represents an OptionButton object.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


DependencyInfo.Dependants Property (Access)

 Copy code hover
[image]

DependencyInfo.Dependants Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a DependencyObjects collection that represents the objects that depend upon the specified AccessObject object. Read-only.

Syntax

expression .Dependants

expression A variable that represents a DependencyInfo object.

Remarks

To return the collection of objects that an AccessObject object depends upon, use the Dependencies property of the DependencyInfo object.

See also

Concepts

DependencyInfo Object

Other resources

DependencyInfo Object Members


BoundObjectFrame.IsVisible Property (Access)

 Copy code hover
[image]

BoundObjectFrame.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Syntax

expression .IsVisible

expression A variable that represents a BoundObjectFrame object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


OptionButton.LostFocus Event (Access)

 Copy code hover
[image]

OptionButton.LostFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The LostFocus event occurs when the specified object loses the focus.

Syntax

expression .LostFocus

expression A variable that represents an OptionButton object.

Remarks

To run a macro or event procedure when these events occur, set the OnLostFocus property to the name of the macro or to [Event Procedure].

This events occurs when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The LostFocus event differs from the Exit event in that the LostFocus event occurs every time a control loses the focus. The Exit event occurs only before a control loses the focus to another control on the same form. The LostFocus event occurs after the Exit event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Printers Members (Access)

 Copy code hover
[image]

Printers Members (Access)
Send feedback

Published: July 16, 2012

The Printers collection contains Printer objects representing all the printers available on the current system.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Printer.
Parent | Returns the parent object for the specified object. Read-only.


Invalid connection string in pass-through query. (Error 3305)

 Copy code hover
[image]

Invalid connection string in pass-through query. (Error 3305)
Send feedback

The connection string for a pass-through query should begin with .


Report.Toolbar Property (Access)

 Copy code hover
[image]

Report.Toolbar Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies a custom toolbar to display for a report. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .Toolbar

expression A variable that represents a Report object.

Remarks

When opening a report in Microsoft Access 2013 that's part of a database that was created in an earlier version of Microsoft Access, the specified toolbar will be displayed differently depending on the current settings of the AllowFullMenus and AllowBuiltInToolbars properties. If the AllowFullMenus and AllowBuiltInToolbars properties are set to False, the specified toolbar will replace the ribbon as the default set of commands available to the user. If the AllowFullMenus or AllowBuiltInToolbars property is set to True, then the specified toolbar is displayed on the ribbon Add-Ins tab.

See also

Concepts

Report Object

Other resources

Report Object Members


WebBrowserControl Properties (Access)

 Copy code hover
[image]

WebBrowserControl Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlSource | You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
GridlineColor | Gets or sets the color of the gridline for the specified list box. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified list box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified text box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified text box. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified text box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified text box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified text box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the text box is anchored horizontally within its layout. Read/write.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
Layout | Returns the type of layout for the specified text box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified text box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.
LocationURL | Gets the Uniform Resource Locator (URL) of the current document. Read-only String.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Object | You can use the Object property in Visual Basic to return a reference to the ActiveX object that is associated with a linked or embedded OLE object in a control. By using this reference, you can access the properties or invoke the methods of the OLE object. Read-only Object.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnBeforeNavigate | Gets or sets the value of the On Before Navigate box in the property sheet os a Web Browser control. Read/write String.
OnDocumentComplete | Gets or sets the value of the On Document Complete box in the property sheet os a Web Browser control. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnNavigateError | Gets or sets the value of the On Navigate Error box in the property sheet os a Web Browser control. Read/write String.
OnProgressChange | Gets or sets the value of the On Progress Change box in the property sheet os a Web Browser control. Read/write String.
OnUpdated | Sets or returns the value of the On Updated box in the Properties window of a form or report. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Progress | Specifies the amount of total progress of a download operation. Read-only Long.
Properties | Returns a reference to a control's Properties collection object. Read-only.
ReadyState | Gets the status of the specified Web Browser control. Read-only AcWebBrowserState.
RightPadding | Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.
ScrollBars | You can use the ScrollBars property to specify whether scroll bars appear on a text box control. Read/write Byte.
ScrollLeft | Gets or sets the distance, in pixels, between the left edge of the WebBrowser object and the leftmost portion of the content currently visible in the control. Read/write Long.
ScrollTop | Gets or sets the distance, in pixels, between the top edge of the WebBrowser object and the topmost portion of the content currently visible in the control. Read/write Long.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.
Transform | Read/write
Value | Determines or specifies the text in the text box. Read/write Variant.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified text box is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


Cannot use '*' in crosstab query. (Error 3123)

 Copy code hover
[image]

Cannot use '*' in crosstab query. (Error 3123)
Send feedback

You tried to execute a query that groups or totals fields selected with an asterisk ( * ). Choose specific fields, and then try the operation again.


Stream (ADO for Visual C++ Syntax)

 Copy code hover
[image]

Stream (ADO for Visual C++ Syntax)
Send feedback

Methods

            Cancel(void)

Close(void)

CopyTo(_ADOStream *DestStream, LONG CharNumber = -1)

Flush(void)

LoadFromFile(BSTR FileName)

Open(VARIANT Source, ConnectModeEnum Mode, StreamOpenOptionsEnum Options,

         BSTR UserName, BSTR Password)

Read(long NumBytes, VARIANT *pVal)

ReadText(long NumChars, BSTR *pbstr)

SaveToFile(BSTR FileName, SaveOptionsEnum Options =adSaveCreateNotExist)

SetEOS(void)

SkipLine(void)

Write(VARIANT Buffer)

WriteText(BSTR Data, StreamWriteEnum Options =adWriteChar)

Properties

            get_Charset(BSTR *pbstrCharset)

put_Charset(BSTR Charset)

get_EOS(VARIANT_BOOL *pEOS)

get_LineSeparator(LineSeparatorEnum *pLS)

put_LineSeparator(LineSeparatorEnum LineSeparator)

get_Mode(ConnectModeEnum *pMode)

put_Mode(ConnectModeEnum Mode)

get_Position(LONG *pPos)

put_Position(LONG Position)

get_Size(LONG *pSize)

get_State(ObjectStateEnum *pState)

get_Type(StreamTypeEnum *pType)

put_Type(StreamTypeEnum Type)


WebBrowserControl.GridlineStyleRight Property (Access)

 Copy code hover
[image]

WebBrowserControl.GridlineStyleRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the right gridline style of the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleRight

expression A variable that represents a WebBrowserControl object.

Remarks

The RightGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Form Members (Access)

 Copy code hover
[image]

Form Members (Access)
Send feedback

Published: July 16, 2012

A Form object refers to a particular Microsoft Access form.

Events

Name | Description
Activate | The Activate event occurs when a form receives the focus and becomes the active window.
AfterDelConfirm | The AfterDelConfirm event occurs after the user confirms the deletions and the records are actually deleted or when the deletions are canceled.
AfterFinalRender | Occurs after all elements in the specified PivotChart view have been rendered.
AfterInsert | The AfterInsert event occurs after a new record is added.
AfterLayout | Occurs after all charts in the specfied PivotChart view have been laid out, but before they have been rendered.
AfterRender | Occurs after the object represented by the chartObject argument has been rendered.
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
ApplyFilter | Occurs when a filter is applied to a form.
BeforeDelConfirm | The BeforeDelConfirm event occurs after the user deletes to the buffer one or more records, but before Microsoft Access displays a dialog box asking the user to confirm the deletions.
BeforeInsert | The BeforeInsert event occurs when the user types the first character in a new record, but before the record is actually created.
BeforeQuery | Occurs when the specified PivotTable view queries its data source.
BeforeRender | Occurs before any object in the specified PivotChart view has been rendered.
BeforeScreenTip | Occurs before a ScreenTip is displayed for an element in a PivotChart view or PivotTable view.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
Close | The Close event occurs when a form is closed and removed from the screen.
CommandBeforeExecute | Occurs before a specified command is executed. Use this event when you want to impose certain restrictions before a particular command is executed.
CommandChecked | Occurs when the specified Microsoft Office Web Component determines whether the specified command is checked.
CommandEnabled | Occurs when the specified Microsoft Office Web Component determines whether the specified command is enabled.
CommandExecute | Occurs after the specified command is executed. Use this event when you want to execute a set of commands after a particular command is executed.
Current | Occurs when the focus moves to a record, making it the current record, or when the form is refreshed or requeried.
DataChange | Occurs when certain properties are changed or when certain methods are executed in the specified PivotTable view.
DataSetChange | Occurs whenever the specified PivotTable view is data-bound and the data set changes — for example, when a filter operation takes place. This event also occurs when initial data is available from the data source.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Deactivate | The Deactivate event occurs when a form loses the focus to a Table, Query, Form, Report, Macro, or Module window, or to the Database window.
Delete | Occurs when the user performs some action, such as pressing the DEL key, to delete a record, but before the record is actually deleted.
Dirty | The Dirty event occurs when the contents of the specified control changes.
Error | The Error event occurs when a run-time error is produced in Microsoft Access when a form has the focus.
Filter | Occurs when the user opens a filter window by clicking Filter by Form, Advanced Filter/Sort, or Server Filter By Form.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
Load | Occurs when a form is opened and its records are displayed.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.
MouseWheel | Occurs when the user rolls the mouse wheel in Form View, Split Form View, Datasheet View, Layout View, PivotChart View, or PivotTable View.
OnConnect | Occurs when the specified PivotTable view connects to a data source.
OnDisconnect | Occurs when the specified PivotTable view disconnects from a data source.
Open | The Open event occurs when a form is opened, but before the first record is displayed.
PivotTableChange | Occurs whenever the specified PivotTable view field, field set, or total is added or deleted.
Query | Occurs whenever the specified PivotTable view query becomes necessary. The query may not occur immediately; it may be delayed until the new data is displayed.
Resize | The Resize event occurs when a form is opened and whenever the size of a form changes.
SelectionChange | Occurs whenever the user makes a new selection in a PivotChart view or PivotTable view.
Timer | The Timer event occurs for a form at regular intervals as specified by the form's TimerInterval property.
Undo | Occurs when the user undoes a change.
Unload | The Unload event occurs after a form is closed but before it's removed from the screen. When the form is reloaded, Microsoft Access redisplays the form and reinitializes the contents of all its controls.
ViewChange | Occurs whenever the specified PivotChart view or PivotTable view is redrawn.

Methods

Name | Description
GoToPage | The GoToPage method moves the focus to the first control on a specified page in the active form.
Move | Moves the specified object to the coordinates specified by the argument values.
Recalc | The Recalc method immediately updates all calculated controls on a form.
Refresh | The Refresh method immediately updates the records in the underlying record source for a specified form or datasheet to reflect changes made to the data by you and other users in a multiuser environment.
Repaint | The Repaint method completes any pending screen updates for a specified form. When performed on a form, the Repaint method also completes any pending recalculations of the form's controls.
Requery | The Requery method updates the data underlying a specified form by requerying the source of data for the form.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
Undo | You can use the Undo method to reset a control or form when its value has been changed.

Properties

Name | Description
ActiveControl | You can use the ActiveControl property together with the Screen object to identify or refer to the control that has the focus. Read-only Control object.
AfterDelConfirm | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the AfterDelConfirm event occurs. Read/write.
AfterFinalRender | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the AfterFinalRender event occurs. Read/write.
AfterInsert | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the AfterInsert event occurs. Read/write.
AfterLayout | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the AfterLayout event occurs. Read/write.
AfterRender | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the AfterRender event occurs. Read/write.
AfterUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.
AllowAdditions | You can use the AllowAdditions property to specify whether a user can add a record when using a form. Read/write Boolean.
AllowDatasheetView | Returns or sets a Boolean indicating whether the specified form may be viewed in Datasheet View. True if Datasheet View is allowed. Read/write.
AllowDeletions | You can use the AllowDeletions property to specify whether a user can delete a record when using a form. Read/write Boolean.
AllowEdits | You can use the AllowEdits property to specify whether a user can edit saved records when using a form. Read/write Boolean.
AllowFilters | You can use the AllowFilters property to specify whether records in a form can be filtered. Read/write Boolean.
AllowFormView | Returns or sets a Boolean indicating whether the specified form may be viewed in Form View. True if Form View is allowed. Read/write.
AllowLayoutView | Gets or sets whether the specified form can be used in Layout View. Read/write Boolean.
AllowPivotChartView | Returns or sets a Boolean indicating whether the specified form may be viewed in PivotChart View. True if PivotChart View is allowed. Read/write.
AllowPivotTableView | Returns or sets a Boolean indicating whether the specified form may be viewed in PivotTable View. True if PivotTable View is allowed. Read/write.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoCenter | Returns or sets a Boolean indicating whether a form will be centered automatically in the application window when the form is opened. Read/write.
AutoResize | Returns or sets a Boolean indicating whether a Form window opens automatically sized to display complete records. Read/write.
BeforeDelConfirm | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the BeforeDelConfirm event occurs. Read/write.
BeforeInsert | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the BeforeInsert event occurs. Read/write.
BeforeQuery | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the BeforeQuery event occurs. Read/write.
BeforeRender | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the BeforeRender event occurs. Read/write.
BeforeScreenTip | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the BeforeScreenTip event occurs. Read/write.
BeforeUpdate | Returns or sets which macro, event procedure, or user-defined function runs when the BeforeUpdate event occurs. Read/write String.
Bookmark | You can use the Bookmark property with forms to set a bookmark that uniquely identifies a particular record in the form's underlying table, query, or SQL statement. Read/write Variant.
BorderStyle | Specifies the type of border and border elements (title bar, Control menu, Minimize and Maximize buttons, or Close button) to use for the form. You typically use different border styles for normal forms, pop-up forms, and custom dialog boxes. Read/write Byte.
Caption | Gets or sets the text that appears in the title bar in Form view. Read/write String.
ChartSpace | Returns a ChartSpace object. Read-only.
CloseButton | Specifies whether the Close button on a form is enabled. Read/write Boolean.
CommandBeforeExecute | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the CommandBeforeExecute event occurs. Read/write.
CommandChecked | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the CommandChecked event occurs. Read/write.
CommandEnabled | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the CommandEnabled event occurs. Read/write.
CommandExecute | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the CommandExecute event occurs. Read/write.
ControlBox | Specifies whether a form has a Control menu in Form view and Datasheet view. Read/write Boolean.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Integer.
CurrentRecord | You can use the CurrentRecord property to identify the current record in the recordset being viewed on a form. Read/write Long.
CurrentSectionLeft | You can use this property to determine the distance in twips from the left side of the current section to the left side of the form. Read/write Integer.
CurrentSectionTop | You can use this property to determine the distance in twips from the top edge of the current section to the top edge of the form. Read/write Integer.
CurrentView | You can use the CurrentView property to determine how a form is currently displayed. Read/write Integer.
Cycle | You can use the Cycle property to specify what happens when you press the TAB key and the focus is in the last control on a bound form. Read/write Byte.
DataChange | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the DataChange event occurs. Read/write.
DataEntry | You can use the DataEntry property to specify whether a bound form opens to allow data entry only. The Data Entry property doesn't determine whether records can be added; it only determines whether existing records are displayed. Read/write Boolean.
DataSetChange | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the DataSetChange event occurs. Read/write.
DatasheetAlternateBackColor | Gets or sets the color displayed on alternate rows of a form's datasheet. Read/write Long.
DatasheetBackColor | You can use the DatasheetBackColor property in Visual Basic to specify or determine the background color of an entire table, query, or form in Datasheet view within a Microsoft Access database. Read/write Long.
DatasheetBorderLineStyle | Returns or sets a Byte indicating the line style to use for the border of the specified datasheet. Read/write.
DatasheetCellsEffect | You can use the DatasheetCellsEffect property to specify whether special effects are applied to cells in a datasheet. Read/write Byte.
DatasheetColumnHeaderUnderlineStyle | Returns or sets a Byte indicating the line style to use for the bottom edge of the column headers on the specified datasheet. Read/write.
DatasheetFontHeight | You can use the DatasheetFontHeight property to specify the font point size used to display and print field names and data in Datasheet view. Read/write Integer.
DatasheetFontItalic | You can use the DatasheetFontItalic property to specify an italicized appearance for field names and data in Datasheet view. Read/write Boolean.
DatasheetFontName | You can use the DatasheetFontName property to specify the font used to display and print field names and data in Datasheet view. Read/write String.
DatasheetFontUnderline | You can use the DatasheetFontUnderline property to specify an underlined appearance for field names and data in Datasheet view. Read/write Boolean.
DatasheetFontWeight | You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.
DatasheetForeColor | You can use the DatasheetForeColor property in Visual Basic to specify or determine the color of all text in a table, query, or form in Datasheet view within an Access database. Read/write Long.
DatasheetGridlinesBehavior | You can use the DatasheetGridlinesBehavior property to specify which gridlines will appear in Datasheet view. Read/write Byte.
DatasheetGridlinesColor | You can use the DatasheetGridlinesColor property to specify the color of gridlines in a datasheet. Read/write Long.
DefaultControl | The DefaultControl property returns a Control object with which you can set the default properties for a particular type of control on a particular form. Read-only.
DefaultView | You can use the DefaultView property to specify the opening view of a form. Read/write Byte.
Dirty | You can use the Dirty property to determine whether the current record has been modified since it was last saved. Read/write Boolean.
DisplayOnSharePointSite | Gets or sets whether the specified form can be made available as a view on a Microsoft SharePoint Foundation site. Read/write Byte.
DividingLines | You can use the DividingLines property to specify whether dividing lines will separate sections on a form or records displayed on a continuous form. Read/write Boolean.
FastLaserPrinting | You can use the FastLaserPrinting property to specify whether lines and rectangles are replaced by text character lines — similar to the underscore (_) and vertical bar (|) characters — when you print a form using most laser printers. Replacing lines and rectangles with text character lines can make printing much faster. Read/write Boolean.
FetchDefaults | Returns or sets a Boolean indicating whether Microsoft Access shows default values for new rows on the specified form before the row is saved. True if Access shows the default values for new rows on the specified form. Read/write.
Filter | You can use the Filter property to specify a subset of records to be displayed when a filter is applied to a form, reportquery, or table. Read/write String.
FilterOn | You can use the FilterOn property to specify or determine whether the Filter property for a form or report is applied. Read/write Boolean.
FilterOnLoad | Gets or sets whether the filter specified by the Filter property is applied when the form is loaded. Read/write Boolean.
FitToScreen | Gets or sets whether the width of the form is reduced to fit the width of the screen. Read/write Boolean.
Form | You can use the Form property to refer to a form or to refer to the form associated with a subformcontrol. Read-only Form.
FrozenColumns | You can use the FrozenColumns property to determine how many columns in a datasheet are frozen. Read/write Integer.
GridX | You can use the GridX property (along with the GridY property) to specify the horizontal and vertical divisions of the alignment grid in form Design view. Read/write Integer.
GridY | You can use the GridY property (along with the GridX property) to specify the horizontal and vertical divisions of the alignment grid in form Design view. Read/write Integer.
HasModule | You can use the HasModule property to specify or determine whether a form or report has a class module. Read/write Boolean.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HelpFile | The name of a help file associated with a form. Read/write String.
HorizontalDatasheetGridlineStyle | Returns or sets a Byte indicating the line style to use for horizontal gridlines on the specified datasheet. Read/write.
Hwnd | You can use the hWnd property to determine the handle (a unique Long Integer value) assigned by Microsoft Windows to the current window. Read/write Long.
InputParameters | You can use the InputParameters property to specify or determine the input parameters that are passed to a SQL statement in the RecordSource property of a form or report or a stored procedure when used as the record source within a Microsoft Access project (.adp). Read/write String.
InsideHeight | You can use the InsideHeight property (along with the InsideWidth property) to determine the height and width (in twips) of the window containing a form. Read/write Long.
InsideWidth | You can use the InsideWidth property (along with the InsideHeight property) to determine the height and width (in twips) of the window containing a form. Read/write Long.
KeyPreview | You can use the KeyPreview property to specify whether the form-level keyboard event procedures are invoked before a control's keyboard event procedures. Read/write Boolean.
LayoutForPrint | You can use the LayoutForPrint property to specify whether the form uses printer or screen fonts. Read/write Boolean.
MaxRecButton | You can use the MaxRecButton property to specify or determine if the maximum record limit button is available on the navigation bar of a form in Datasheet view or Form view. Read/write Boolean.
MaxRecords | Specifies the maximum number of records by a query or view. Read/write Long.
MenuBar | Specifies a custom menu to display for a form. Read/write String.
MinMaxButtons | You can use the MinMaxButtons property to specify whether the Maximize and Minimize buttons will be visible on a form. Read/write Byte.
Modal | You can use the Modal property to specify whether a form opens as a modal window. When a form opens as a modal window, you must close the window before you can move the focus to another object. Read/write Boolean.
Module | You can use the Module property to specify a form module. Read-only Module object.
MouseWheel | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the MouseWheel event occurs. Read/write.
Moveable | Returns or sets a Boolean indicating whether the specified form can be moved by the user; True if it can be moved. Read/write.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
NavigationButtons | You can use the NavigationButtons property to specify whether navigation buttons and a record number box are displayed on a form. Read/write Boolean.
NavigationCaption | Gets or sets the text that appears to the left of the form's navigation buttons. Read/write String.
NewRecord | You can use the NewRecord property to determine whether the current record is a new record. Read-only Integer.
OnActivate | Sets or returns the value of the On Activate box in the Properties window of a form or report. Read/write String.
OnApplyFilter | Sets or returns the value of the On Apply Filter box in the Properties window of a form. Read/write String.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnClose | Sets or returns the value of the On Close box in the Properties window of a form or report. Read/write String.
OnConnect | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the OnConnect event occurs. Read/write.
OnCurrent | Sets or returns the value of the On Current box in the Properties window of a form. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnDeactivate | Sets or returns the value of the On Deactivate box in the Properties window of a form or report. Read/write String.
OnDelete | Sets or returns the value of the On Delete box in the Properties window of a form. Read/write String.
OnDirty | Sets or returns the value of the On Dirty box in the Properties window of a form or report. Read/write String.
OnDisconnect | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the OnDisconnect event occurs. Read/write.
OnError | Sets or returns the value of the OnError box in the Properties window of a form or report. Read/write String.
OnFilter | Sets or returns the value of the On Filter box in the Properties window of a form. Read/write String.
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnInsert | Sets or returns the value of the Before Insert box in the Properties window of a form. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLoad | Sets or returns the value of the On Load box in the Properties window of a form. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnOpen | Sets or returns the value of the On Open box in the Properties window of a form or report. Read/write String.
OnResize | Sets or returns the value of the On Resize box in the Properties window of a form. Read/write String.
OnTimer | Sets or returns the value of the On Timer box in the Properties window of a form. Read/write String.
OnUndo | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the Undo event occurs. Read/write..
OnUnload | Sets or returns the value of the On Unload box in the Properties window of a form. Read/write String.
OpenArgs | Determines the string expression specified by the OpenArgs argument of the OpenForm method that opened a form. Read/write Variant.
OrderBy | You can use the OrderBy property to specify how you want to sort records in a form. Read/write String.
OrderByOn | You can use the OrderByOn property to specify whether an object's OrderBy property setting is applied. Read/write Boolean.
OrderByOnLoad | Gets or sets whether the sorting specified by the OrderBy property is applied when the form is loaded. Read/write Boolean.
Orientation | You can use the Orientation property to specify or determine the view orientation. Read/write Byte.
Page | The Page property specifies the current page number when a form is being printed. Read/write Long.
Pages | You can use the Pages property to return information needed to print page numbers in a form. Read/write Integer.
Painting | You can use the Painting property to specify whether a form is repainted. Read/write Boolean.
PaintPalette | You can use the PaintPalette property to specify a palette to be used by a form. Read/write Variant.
PaletteSource | You can use the PaletteSource property to specify the palette for a form. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Picture | You can use the Picture property to specify a bitmap or other type of graphic to be used as a background picture on a form. Read/write String.
PictureAlignment | You can use the PictureAlignment property to specify where a background picture will appear in an image control or on a form or report. Read/write Byte.Read/write.
PictureData | You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.
PicturePalette | You can use the PicturePalette property to specify a palette to be used by a form. Read/write Variant.
PictureSizeMode | You can use the PictureSizeMode property to specify how a picture for a form or report is sized. Read/write Byte.
PictureTiling | You can use the PictureTiling property to specify whether a background picture is tiled across the entire image control, Form window, form, or page of a report. Read/write Boolean.
PictureType | You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.
PivotTable | Returns a PivotTable object representing a PivotTable View on a form. Read-only.
PivotTableChange | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the PivotTableChange event occurs. Read/write.
PopUp | Specifies whether a form opens as a pop-up window. Read/write Boolean.
Printer | Returns or sets a Printer object representing the default printer on the current system. Read/write.
Properties | Returns a reference to a control's Properties collection object. Read-only.
PrtDevMode | You can use the PrtDevMode property to set or return printing device mode information specified for a form or report in the Print dialog box. Read/write Variant.
PrtDevNames | You can use the PrtDevNames property to set or return information about the printer selected in the Print dialog box for a form or report. Read/write Variant.
PrtMip | You can use the PrtMip property in Visual Basic to set or return the device mode information specified for a form or report in the Print dialog box.
Query | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the Query event occurs. Read/write.
RecordLocks | You can use the RecordLocks property to determine how records are locked and what happens when two users try to edit the same record at the same time. Read/write.
RecordSelectors | You can use the RecordSelectors property to specify whether a form displays record selectors in Form view. Read/write Boolean.
Recordset | Returns or sets the ADO Recordset or DAO Recordset object representing the record source for the specified object. Read/write Object.
RecordsetClone | You can use the RecordsetClone property to refer to a form's Recordset object specified by the form's RecordSource property. Read-only.
RecordsetType | You can use the RecordsetType property to specify what kind of recordset is made available to a form. Read/write Byte.
RecordSource | You can use the RecordSource property to specify the source of the data for a form. Read/write String.
RecordSourceQualifier | Returns or sets a String indicating the SQL Server owner name of the record source for the specified form. Read/write.
ResyncCommand | You can use the ResyncCommand property to specify or determine the SQL statement or stored procedure that will be used in an updateable snapshot of a table. Read/write String.
RibbonName | Gets or set the name of the customized ribbon to be displayed when the specified form is loaded. Read/write String.
RowHeight | You can use the RowHeight property to specify the height of all rows in Datasheet view. Read/write Integer.
ScrollBars | You can use the ScrollBars property to specify whether scroll bars appear on a form. Read/write Byte.
Section | You can use the Section property to identify a section of a form and provide access to the properties of that section. Read-only Section object.
SelectionChange | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the SelectionChange event occurs. Read/write.
SelHeight | You can use the SelHeight property to specify or determine the number of selected rows (records) in the current selection rectangle in a table, query, or form datasheet, or the number of selected records in a continuous form. Read/write Long.
SelLeft | You can use the SelLeft property to specify or determine which column (field) is leftmost in the current selection rectangle. Read/write Long.
SelTop | You can use the SelTop property to specify or determine which row (record) is topmost in the current selection rectangle in a table, query, or form datasheet, or which selected record is topmost in a continuous form.Read/write Long.
SelWidth | You can use the SelWidth property to specify or determine the number of selected columns (fields) in the current selection rectangle. Read/write Long.
ServerFilter | You can use the ServerFilter property to specify a subset of records to be displayed when a server filter is applied to a form within a Microsoft Access project (.adp) or database. Read/write String.
ServerFilterByForm | You can use the ServerFilterByForm property to specify or determine whether a form is opened in the Server Filter By Form window. Read/write Boolean.
ShortcutMenu | You can use the ShortcutMenu property to specify whether a shortcut menu is displayed when you right-click an object on a form. For example, you might want to disable a shortcut menu to prevent the user from changing the form's underlying record source by using one of the filtering commands on the form's shortcut menu. Read/write Boolean.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SplitFormDatasheet | Gets or sets whether the user can edit records in the datasheet when a form is displayed in Split Form view. Read/write AcSplitFormDatasheet.
SplitFormOrientation | Gets or sets the position of the datasheet relative to the form when the form is displayed in Split Form view. Read/write AcSplitFormOrientation.
SplitFormPrinting | Gets or sets whether the contents of the form or the datasheet are printed when printing a form displayed in Split Form view. Read/write AcSplitFormPrinting.
SplitFormSize | Gets or sets the size in twips of the form when it's displayed in Split Form view. Read/write Long.
SplitFormSplitterBar | Gets or sets whether the splitter bar is available when the form is displayed in Split Form mode. Read/write Boolean.
SplitFormSplitterBarSave | Gets or sets whether the location of the splitter bar is saved when a form that's displayed in Split Form mode is closed. Read/write Boolean.
SubdatasheetExpanded | You can use the SubdatasheetExpanded property to specify or determine the saved state of all subdatasheets within a table or query. Read/write Boolean.
SubdatasheetHeight | You can use the SubdatasheetHeight property to specify or determine the default display height of a subdatasheet when expanded. Read/write Integer.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
TimerInterval | You can use the TimerInterval property to specify the interval, in milliseconds, between Timer events on a form. Read/write Long.
Toolbar | Specifies a custom toolbar to display for a form. Read/write String.
UniqueTable | Specifies the table to be updateable when A form is bound to a multiple table view or stored procedure within a Microsoft Access project (.adp).
UseDefaultPrinter | Returns or sets a Boolean indicating whether the specified form uses the default printer for the system; True if the form or report uses the default printer. Read/write.
VerticalDatasheetGridlineStyle | Returns or sets a Byte indicating the line style to use for vertical gridlines on the specified datasheet. Read/write.
ViewChange | Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the ViewChange event occurs. Read/write.
ViewsAllowed | You can use the ViewsAllowed property to specify whether users can switch between Datasheet view and Form view by clicking the Form View or Datasheet View command on the View menu or by clicking the arrow next to the View button and clicking Form View or Datasheet View. Read/write Byte.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.
WindowHeight | Returns the height of a form in twips. Read-only Integer.
WindowLeft | Returns an Integer indicating the screen position in twips of the left edge of a form relative to the left edge of the Microsoft Access window. Read-only.
WindowTop | Returns an Integer indicating the screen position in twips of the top edge of a form relative to the top of the Microsoft Access window. Read-only.
WindowWidth | Returns the height of a form in twips. Read-only Integer.


Report.FitToPage Property (Access)

 Copy code hover
[image]

Report.FitToPage Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the width of the specified report is sized to automatically fit the page. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .FitToPage

expression A variable that represents a Report object.

Remarks

The default value is True for new reports, and False for reports created in earlier versions of Access.

See also

Concepts

Report Object

Other resources

Report Object Members


ConvertToString Method Example (VBScript)

 Copy code hover
[image]

ConvertToString Method Example (VBScript)
Send feedback

The following example shows how to convert a Recordset into a MIME-encoded string using the RDSServer.DataFactory ConvertToString method. It then shows how the string can be converted back into a Recordset. Cut and paste the following code to Notepad or another text editor and save it as ConvertToString.htm.

VBS Copy code Copy code
<!-- BeginConvertToStringVBS --><HTML>
<HEAD><TITLE>ConvertToString Example</TITLE><HEAD><BODY>
<SCRIPT LANGUAGE=VBSCRIPT>Sub ConvertToStringX()
Dim objRs, objDF, strServer, vStringConst adcExecSync = 1
Const adcFetchUpFront = 1
' Replace value below with your server name to use without ASP.strServer = "http://<%=Request.ServerVariables("SERVER_NAME")%>">
Set objDF = RDS1.CreateObject("RDSServer.DataFactory", strServer)Set objRs = objDF.Query(txtConnect.Value,txtQueryRecordset.Value)
' convert Recordset to MIME encoded stringvString = objDF.ConvertToString(objRs)
' display MIME string for demo purposestxtRS.value = vString
' convert MIME string back to useable ADO Recordset' using RDS.DataControl
RDC1.SQL = vString
RDC1.ExecuteOptions = adcExecSyncRDC1.FetchOptions = adcFetchUpFront
RDC1.Refresh
MsgBox "RecordCount = " & RDC1.Recordset.RecordCountEnd Sub
</SCRIPT>
Connect String:<INPUT TYPE=Text NAME=txtConnect SIZE=50
VALUE="Provider=sqloledb;Initial Catalog=pubs;Integrated Security='SSPI';"><BR>
Query:<INPUT TYPE=Text NAME=txtQueryRecordset SIZE=50
VALUE="select * from authors"><BR>
<INPUT TYPE=Button VALUE="ConvertToString" OnClick="ConvertToStringX()"><BR>
MIME Encoded RS: <BR><TEXTAREA NAME=txtRS ROWS=15 COLS=50 WRAP=virtual></TEXTAREA>
<!-- RDS.DataSpace ID RDS1 --><OBJECT ID="RDS1" WIDTH=1 HEIGHT=1
CLASSID="CLSID:BD96C556-65A3-11D0-983A-00C04FC29E36"></OBJECT>
<!-- RDS.DataControl ID RDC1 --><OBJECT ID="RDC1" WIDTH=1 HEIGHT=1
CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"></OBJECT>
</BODY></HTML>
<!-- EndConvertToStringVBS -->


Report.DateGrouping Property (Access)

 Copy code hover
[image]

Report.DateGrouping Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DateGrouping property to specify how you want to group dates in a report. Read/write Byte.

Syntax

expression .DateGrouping

expression A variable that represents a Report object.

Remarks

For example, using the US Defaults setting will cause the week to begin on Sunday. If you set a Date/Time field's GroupOn property to Week, the report will group dates from Sunday to Saturday.

The DateGrouping property uses the following settings.

Setting | Visual Basic | Description
US Defaults | 0 | Microsoft Access uses the U.S. settings for the first day of the week (Sunday) and the first week of the year (starts on January 1).
Use System Settings | 1 | (Default) Microsoft Access uses settings based on the locale selected in the Regional Options dialog box in Windows Control Panel.
Note Note

The DateGrouping property setting applies to the entire report, not to a particular group in the report.

You can set the DateGrouping property only in report Design view or in the Open event procedure of a report.

The sort order used in a report isn't affected by the DateGrouping property setting.

See also

Concepts

Report Object

Other resources

Report Object Members


OptionButton.OnLostFocus Property (Access)

 Copy code hover
[image]

OptionButton.OnLostFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnLostFocus

expression A variable that represents an OptionButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The LostFocus event occurs when the object loses the focus.

The OnLostFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Lost Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Lost Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnLostFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnLostFocus

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Error Object (DAO)

 Copy code hover
[image]

Error Object (DAO)
Send feedback

Error object contains details about data access errors, each of which pertains to a single operation involving DAO.

Remarks

Any operation involving DAO can generate one or more errors. For example, a call to an ODBC server might result in an error from the database server, an error from ODBC, and a DAO error. As each such error occurs, an Error object is placed in the Errors collection of the DBEngine object. A single event can therefore result in several Error objects appearing in the Errors collection.

When a subsequent DAO operation generates an error, the Errors collection is cleared, and one or more new Error objects are placed in the Errors collection. DAO operations that don't generate an error have no effect on the Errors collection.

The set of Error objects in the Errors collection describes one error. The first Error object is the lowest level error (the originating error), the second the next higher level error, and so forth. For example, if an ODBC error occurs while trying to open a Recordset object, the first Error object— Errors(0)— contains the lowest level ODBC error; subsequent errors contain the ODBC errors returned by the various layers of ODBC. In this case, the ODBC driver manager, and possibly the driver itself, return separate Error objects. The last Error object— Errors.Count-1— contains the DAO error indicating that the object couldn't be opened.

Enumerating the specific errors in the Errors collection enables your error-handling routines to more precisely determine the cause and origin of an error, and take appropriate steps to recover. You can read the Error object's properties to obtain specific details about each error, including:

  • The Description property, which contains the text of the error alert that will be displayed on the screen if the error is not trapped.

  • The Number property, which contains the Long integer value of the error constant.

  • The Source property, which identifies the object that raised the error. This is particularly useful when you have several Error objects in the Errors collection following a request to an ODBC data source.

  • The HelpFile and HelpContext properties, which indicate the appropriate Microsoft Windows Help file and Help topic, respectively, (if any exist) for the error.

    Note Note

    When programming in Microsoft Visual Basic for Applications (VBA), if you use the New keyword to create an object that subsequently causes an error before that object has been appended to a collection, the DBEngine object's Errors collection won't contain an entry for that object's error, because the new object is not associated with the DBEngine object. However, the error information is available in the VBA Err object. Your VBA error-handling code should examine the Errors collection whenever you anticipate a data access error. If you are writing a centralized error handler, test the VBA Err object to determine if the error information in the Errors collection is valid. If the Number property of the last element of the Errors collection (DBEngine.Errors.Count - 1) and the value of the Err object match, you can then use a series of Select Case statements to identify the particular DAO error or errors that occurred. If they do not match, use the Refresh method on the Errors collection.

Example

This example forces an error, traps it, and displays the Description, Number, Source, HelpContext, and HelpFile properties of the resulting Error object.

VBA Copy code Copy code
Sub DescriptionX()

   Dim dbsTest As Database

   On Error GoTo ErrorHandler

   ' Intentionally trigger an error.
   Set dbsTest = OpenDatabase("NoDatabase")

   Exit Sub

ErrorHandler:
   Dim strError As String
   Dim errLoop As Error

   ' Enumerate Errors collection and display properties of
   ' each Error object.
   For Each errLoop In Errors
      With errLoop
         strError = _
            "Error #" & .Number & vbCr
         strError = strError & _
            "  " & .Description & vbCr
         strError = strError & _
            "  (Source: " & .Source & ")" & vbCr
         strError = strError & _
            "Press F1 to see topic " & .HelpContext & vbCr
         strError = strError & _
            "  in the file " & .HelpFile & "."
      End With
      MsgBox strError
   Next

   Resume Next

End Sub


Hyperlink.EmailSubject Property (Access)

 Copy code hover
[image]

Hyperlink.EmailSubject Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the EmailSubject property to specify or determine return the email subject line of a hyperlink to an object, document, Web page or other destination for a command button, image control, or label control. Read/write String.

Syntax

expression .EmailSubject

expression A variable that represents a Hyperlink object.

Remarks

When you move the cursor over a command button, image control, or label control whose HyperlinkAddress property is set, the cursor changes to an upward-pointing hand. Clicking the control displays the object or Web page specified by the link.

To open objects in the current database, leave the HyperlinkAddress property blank and specify the object type and object name you want to open in the HyperlinkSubAddress property by using the syntax "objecttype objectname". If you want to open an object contained in another Microsoft Access database, enter the database path and file name in the HyperlinkAddress property and specify the database object to open by using the HyperlinkSubAddress property.

The HyperlinkAddress property can contain an absolute or a relative path to a target document. An absolute path is a fully qualified URL or UNC path to a document. A relative path is a path related to the base path specified in the Hyperlink Base setting in the DatabaseName Properties dialog box (available by clicking Database Properties on the File menu) or to the current database path. If Microsoft Access can't resolve the HyperlinkAddress property setting to a valid URL or UNC path, it will assume you've specified a path relative to the base path contained in the Hyperlink Base setting or the current database path.

Note Note

When you follow a hyperlink to another Microsoft Access database object, the database Startup properties are applied. For example, if the destination database has a Display form set, that form is displayed when the database opens.

Note Note

When you create a hyperlink by using the Insert Hyperlink dialog box, Microsoft Access automatically sets the EmailSubject property to the location specified in the Subject box of the E-Mail Address tab.

See also

Concepts

Hyperlink Object

Other resources

Hyperlink Object Members


AllDatabaseDiagrams Properties (Access)

 Copy code hover
[image]

AllDatabaseDiagrams Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


BoundObjectFrame.Requery Method (Access)

 Copy code hover
[image]

BoundObjectFrame.Requery Method (Access)
See also Send feedback

Published: July 16, 2012

The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.

Syntax

expression .Requery

expression A variable that represents a BoundObjectFrame object.

Remarks

You can use this method to ensure that a form or control displays the most recent data.

The Requery method does one of the following:

  • Reruns the query on which the form or control is based.

  • Displays any new or changed records or removes deleted records from the table on which the form or control is based.

  • Updates records displayed based on any changes to the Filter property of the form.

Controls based on a query or table include:

  • List boxes and combo boxes.

  • Subform controls.

  • OLE objects, such as charts .

  • Controls for which the ControlSource property setting includes domain aggregate functions or SQL aggregate function.

If you specify any other type of control for the object specified by expression, the record source for the form is requeried.

If the object specified by expression isn't bound to a field in a table or query, the Requery method forces a recalculation of the control.

If you omit the object specified by expression, the Requery method requeries the underlying data source for the form or control that has the focus. If the control that has the focus has a record source or row source, it will be requeried; otherwise, the control's data will simply be refreshed.

If a subform control has the focus, this method only requeries the record source for the subform, not the parent form.

Note Note

  • The Requery method updates the data underlying a form or control to reflect records that are new to or deleted from the record source since it was last queried. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new or deleted records in the record source. The Repaint method simply repaints the specified form and its controls.

  • The Requery method doesn't pass control to the operating system to allow Windows to continue processing messages. Use the DoEvents function if you need to relinquish temporary control to the operating system.

  • The Requery method is faster than the Requery action. When you use the Requery action, Microsoft Access closes the query and reloads it from the database. When you use the Requery method, Microsoft Access reruns the query without closing and reloading it.

Example

The following example uses the Requery method to requery the data from the EmployeeList list box on an Employees form:

VBA Copy code Copy code
Public Sub RequeryList()

    Dim ctlCombo As Control

    ' Return Control object pointing to a combo box.
    Set ctlCombo = Forms!Employees!ReportsTo

    ' Requery source of data for list box.
    ctlCombo.Requery

End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


RecordCount Property (ADO)

 Copy code hover
[image]

RecordCount Property (ADO)
Send feedback

Indicates the number of records in a Recordset object.

Return Value

Returns a Long value that indicates the number of records in the Recordset.

Remarks

Use the RecordCount property to find out how many records are in a Recordset object. The property returns -1 when ADO cannot determine the number of records or if the provider or cursor type does not support RecordCount. Reading the RecordCount property on a closed Recordset causes an error.

If the Recordset object supports approximate positioning or bookmarks — that is, Supports (adApproxPosition) or Supports (adBookmark), respectively, return True — this value will be the exact number of records in the Recordset, regardless of whether it has been fully populated. If the Recordset object does not support approximate positioning, this property may be a significant drain on resources because all records will have to be retrieved and counted to return an accurate RecordCount value.

The cursor type of the Recordset object affects whether the number of records can be determined. The RecordCount property will return -1 for a forward-only cursor; the actual count for a static or keyset cursor; and either -1 or the actual count for a dynamic cursor, depending on the data source.


How to: Retrieve a List of Installed Printers

 Copy code hover
[image]

How to: Retrieve a List of Installed Printers
Send feedback

You use the Printers property of the Application object to return the Printers 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.

VBA Copy code Copy code
Sub ShowPrinters()
    Dim strCount As String
    Dim strMsg As String
    Dim prtLoop As Printer

    On Error GoTo ShowPrinters_Err

    If Printers.Count > 0 Then
        ' Get count of installed printers.
        strMsg = "Printers installed: " & Printers.Count & vbCrLf & vbCrLf

        ' Enumerate printer system properties.
        For Each prtLoop In Application.Printers
            With prtLoop
                strMsg = strMsg _
                    & "Device name: " & .DeviceName & vbCrLf _
                    & "Driver name: " & .DriverName & vbCrLf _
                    & "Port: " & .Port & vbCrLf & vbCrLf
            End With
        Next prtLoop

    Else
        strMsg = "No printers are installed."
    End If

    ' Display printer information.
    MsgBox Prompt:=strMsg, Buttons:=vbOKOnly, Title:="Installed Printers"

ShowPrinters_End:
    Exit Sub

ShowPrinters_Err:
    MsgBox Prompt:=Err.Description, Buttons:=vbCritical & vbOKOnly, _
        Title:="Error Number " & Err.Number & " Occurred"
    Resume ShowPrinters_End

End Sub


Section.AutoHeight Property (Access)

 Copy code hover
[image]

Section.AutoHeight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether a section's height is adjusted automatically when controls are resized. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .AutoHeight

expression A variable that represents a Section object.

See also

Concepts

Section Object

Other resources

Section Object Members


ObjectFrame.OldBorderStyle Property (Access)

 Copy code hover
[image]

ObjectFrame.OldBorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.

Syntax

expression .OldBorderStyle

expression A variable that represents an ObjectFrame object.

Remarks

The OldBorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines
Note Note

  • If the OldBorderStyle property is set to None or Dialog, the form doesn't have Maximize or Minimize buttons, regardless of its MinMaxButtons property setting.

  • If the OldBorderStyle property is set to None, the form doesn't have a Control menu, regardless of its ControlBox property setting.

  • The OldBorderStyle property setting doesn't affect the display of the scroll bars, navigation buttons, the record number box, or record selectors.

Example

The following example demonstrates the effect of changing a control's BorderStyle property, while leaving the OldBorderStyle unaffected. The example concludes with setting the BorderStyle property to its original unedited value.

VBA Copy code Copy code
With Forms("Order Entry").Controls("Zip Code") .BorderStyle = 3 ' Short dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 3, 1.

    .BorderStyle = 2 ' Dashed border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 2, 1

    .BorderStyle = .OldBorderStyle ' Solid (default) border.

    MsgBox "BorderStyle = " & .BorderStyle & vbCrLf & _
        "OldBorderStyle = " & .OldBorderStyle  ' Prints 1, 1
End With

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Report.ScaleMode Property (Access)

 Copy code hover
[image]

Report.ScaleMode Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ScaleMode property in Visual Basic to specify the unit of measurement for coordinates on a page when the Circle , Line , Pset , or Print method is used while a report is previewed or printed, or its output is saved to a file. Read/write Integer.

Syntax

expression .ScaleMode

expression A variable that represents a Report object.

Remarks

The ScaleMode property uses the following settings.

Setting | Description
0 | Custom values used by one or more of the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties
1 | (Default) Twips
2 | Points
3 | Pixels
4 | Characters (horizontal = 120 twips per unit; vertical = 240 twips per unit)
5 | Inches
6 | Millimeters
7 | Centimeters

You can set the ScaleMode property by using a macro or a Visual Basic event procedure specified by a section's OnPrint property setting.

By using the related ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties, you can create a custom coordinate system with both positive and negative coordinates. All four properties interact with the ScaleMode property in the following ways:

  • Setting any other Scale property to any value automatically sets the ScaleMode property to 0.

  • Setting the ScaleMode property to a number greater than 0 changes the ScaleHeight and ScaleWidth property settings to the new unit of measurement and sets the ScaleLeft and ScaleTop properties to 0. Also, the CurrentX and CurrentY property settings change to reflect the new coordinates of the current point.

See also

Concepts

Report Object

Other resources

Report Object Members


Module Object (Access)

 Copy code hover
[image]

Module Object (Access)
See also Send feedback

Published: July 16, 2012

A Module object refers to a standard module or a class module.

Remarks

Microsoft Access includes class modules that are not associated with any object, and form modules and report modules, which are associated with a form or report.

To determine whether a Module object represents a standard module or a class module from code, check the Module object's Type property.

The Modules collection contains all open Module objects, regardless of their type. Modules in the Modules collection can be compiled or uncompiled.

To return a reference to a particular standard or class Module object in the Modules collection, use any of the following syntax forms.

Syntax | Description
Modules!modulename | The modulename argument is the name of the Module object.
Modules("modulename") | The modulename argument is the name of the Module object.
Modules(index) | The index argument is the numeric position of the object within the collection.

The following example returns a reference to a standard Module object and assigns it to an object variable:

VBA Copy code Copy code
Dim mdl As Module
Set mdl = Modules![Utility Functions]

Note that the brackets enclosing the name of the Module object are necessary only if the name of the Module includes spaces.

The next example returns a reference to a form Module object and assigns it to an object variable:

VBA Copy code Copy code
Dim mdl As Module
Set mdl = Modules!Form_Employees

To refer to a specific form or report module, you can also use the Form or Report object's Module property:

VBA Copy code Copy code
Forms!formname.Module

The following example also returns a reference to the Module object associated with an Employees form and assigns it to an object variable:

VBA Copy code Copy code
Dim mdl As Module
Set mdl = Forms!Employees.Module

Once you've returned a reference to a Module object, you can set or read its properties and apply its methods.

See also

Concepts

Access Object Model Reference

Other resources

Module Object Members


How to: Display and Use the File Dialog Box

 Copy code hover
[image]

How to: Display and Use the File Dialog Box
Send feedback

The FileDialog object allows you to display the file dialog box used by Microsoft Access and to determine what files were selected by the user. The SelectedItems property of the FileDialog object contains the paths to the files selected by the user. By using a For...Each loop, you can enumerate this collection and display each file.

The following example adds the files selected by the user to a list box named FileList.

Note Note

This example requires a reference to the Microsoft Office 12.0 Object Library.
VBA Copy code Copy code
Private Sub cmdFileDialog_Click()

'Requires reference to Microsoft Office 12.0 Object Library.

   Dim fDialog As Office.FileDialog
   Dim varFile As Variant

   'Clear listbox contents.
   Me.FileList.RowSource = ""

   'Set up the File Dialog.
   Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
   With fDialog
      'Allow user to make multiple selections in dialog box.
      .AllowMultiSelect = True

      'Set the title of the dialog box.
      .Title = "Please select one or more files"

      'Clear out the current filters, and add our own.
      .Filters.Clear
      .Filters.Add "Access Databases", "*.MDB; *.ACCDB"
      .Filters.Add "Access Projects", "*.ADP"
      .Filters.Add "All Files", "*.*"

      'Show the dialog box. If the .Show method returns True, the
      'user picked at least one file. If the .Show method returns
      'False, the user clicked Cancel.
      If .Show = True Then
         'Loop through each file selected and add it to the list box.
         For Each varFile In .SelectedItems
            Me.FileList.AddItem varFile
         Next
      Else
         MsgBox "You clicked Cancel in the file dialog box."
      End If
   End With
End Sub


BoundObjectFrame.SetFocus Method (Access)

 Copy code hover
[image]

BoundObjectFrame.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Syntax

expression .SetFocus

expression A variable that represents a BoundObjectFrame object.

Return Value

Nothing

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.

Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.

Example

The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:

VBA Copy code Copy code
Forms!Employees!EmployeeID.SetFocus

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


NavigationButton.FontItalic Property (Access)

 Copy code hover
[image]

NavigationButton.FontItalic Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontItalic property to specify whether text is italic in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .FontItalic

expression A variable that represents a NavigationButton object.

Remarks

The FontItalic property uses the following settings.

Setting | Description
True | The text is italic.
False | (Default) The text isn't italic.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


CodeProject.RemovePersonalInformation Property (Access)

 Copy code hover
[image]

CodeProject.RemovePersonalInformation Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a Boolean indicating whether personal information about the user is stored in the specified project. True if personal information is removed. Read-write.

Syntax

expression .RemovePersonalInformation

expression A variable that represents a CodeProject object.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


Using ADO for Internet Publishing (ADO)

 Copy code hover
[image]

Using ADO for Internet Publishing (ADO)
Send feedback

In this section

  • Using ADO for Internet Publishing

  • The OLE DB Provider for Internet Publishing

  • Internet Publishing Scenario Topics


Field.SourceField Property (DAO)

 Copy code hover
[image]

Field.SourceField Property (DAO)
Send feedback

Returns a value that indicates the name of the field that is the original source of the data for a Field object. Read-only String.

Syntax

expression .SourceField

expression A variable that represents a Field object.

Remarks

For a Field object, use of the SourceField and SourceTable properties depends on the object that contains the Fields collection that the Field object is appended to, as shown in the following table.

Object appended to | Usage
Index | Not supported
QueryDef | Read-only
Recordset | Read-only
Relation | Not supported
TableDef | Read-only

These properties indicate the original field and table names associated with a Field object. For example, you could use these properties to determine the original source of the data in a query field whose name is unrelated to the name of the field in the underlying table.


NavigationButton.FontUnderline Property (Access)

 Copy code hover
[image]

NavigationButton.FontUnderline Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontUnderline property to specify whether text is underlined in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .FontUnderline

expression A variable that represents a NavigationButton object.

Remarks

The FontUnderline property uses the following settings.

Setting | Description
True | The text is underlined.
False | (Default) The text isn't underlined.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


CopyDatabaseFile Macro Action

 Copy code hover
[image]

CopyDatabaseFile Macro Action
Send feedback

You can use the CopyDatabaseFile action to make a copy of the current Microsoft SQL Server 7.0 or later database connected to your Access project. Microsoft Access 2013 detaches the current database and then attaches it to the destination server. For more information about detaching and attaching a database, see the SQL Server documentation.

Note 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.

Setting

The CopyDatabaseFile action has the following arguments.

Action argument

Description

Database File Name

The name of the new Master Data File. The default path for the file is the current location of the Access project file (.adp).

Overwrite Existing File

Specifies whether or not to replace an existing file with the same name. If set to Yes and the filename already exists, the file is overwritten. If set to No and the filename already exists, the file is not overwritten and the action fails. If the file does not already exist, this setting is ignored. The default is Yes.

Disconnect All Users

Specifies whether or not Access should force users off the database. If set to Yes, any users that are connected to the current database are disconnected so that the copy database operation can proceed. If set to No and one or more users are connected to the database, the copy database operation fails. The default is No.

Caution note Caution

Disconnecting users from a database without adequate warning can lead to data loss.

Remarks

The copy operation is synchronous, so you can't perform other operations until the copy of the database is complete.

The CopyDatabaseFile action not only copies data, data definitions, and database objects, but also copies extended properties, such as default values, text constraints, and lookup values.

Requirements for copying a database:

  • You must disconnect all applications and users before you copy the database file.

  • All objects and views except the Navigation Pane must be closed.

  • The current database must not be replicated.

  • The source server database must be Microsoft SQL Server version 7.0 or later, or SQL Server 2000 Desktop Engine running on a local computer.

  • The SQL Server database on the source server must be a single file database.

  • You must be a member of the sysadmin role on both the source and destination SQL Server computers.

To run the CopyDatabaseFile action in a Visual Basic for Applications module, use the CopyDatabaseFile method of the DoCmd object.


Field2.DataUpdatable Property (DAO)

 Copy code hover
[image]

Field2.DataUpdatable Property (DAO)
Send feedback

Returns a value that indicates whether the data in the field represented by a Field2 object is updatable.

Syntax

expression .DataUpdatable

expression A variable that represents a Field2 object.

Remarks

Use this property to determine whether you can change the Value property setting of a Field2 object. This property is always False on a Field2 object whose Attributes property is dbAutoIncrField.

You can use the DataUpdatable property on Field2 objects that are appended to the Fields collection of QueryDef, Recordset, and Relation objects, but not the Fields collection of Index or TableDef objects.

Example

This example demonstrates the DataUpdatable property using the first field from six different Recordsets. The DataOutput function is required for this procedure to run.

VBA Copy code Copy code
Sub DataUpdatableX()

 Dim dbsNorthwind As Database
 Dim rstNorthwind As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")

 With dbsNorthwind
 ' Open and print report about a table-type Recordset.
 Set rstNorthwind = .OpenRecordset("Employees")
 DataOutput rstNorthwind

 ' Open and print report about a dynaset-type Recordset.
 Set rstNorthwind = .OpenRecordset("Employees", _
 dbOpenDynaset)
 DataOutput rstNorthwind

 ' Open and print report about a snapshot-type Recordset.
 Set rstNorthwind = .OpenRecordset("Employees", _
 dbOpenSnapshot)
 DataOutput rstNorthwind

 ' Open and print report about a forward-only-type Recordset.
 Set rstNorthwind = .OpenRecordset("Employees", _
 dbOpenForwardOnly)
 DataOutput rstNorthwind

 ' Open and print report about a Recordset based on
 ' a select query.
 Set rstNorthwind = _
 .OpenRecordset("Current Product List")
 DataOutput rstNorthwind

 ' Open and print report about a Recordset based on a
 ' select query that calculates totals.
 Set rstNorthwind = .OpenRecordset("Order Subtotals")
 DataOutput rstNorthwind

 .Close
 End With

End Sub

Function DataOutput(rstTemp As Recordset)

 With rstTemp
 Debug.Print "Recordset: " & .Name & ", ";
 Select Case .Type
 Case dbOpenTable
 Debug.Print "dbOpenTable"
 Case dbOpenDynaset
 Debug.Print "dbOpenDynaset"
 Case dbOpenSnapshot
 Debug.Print "dbOpenSnapshot"
 Case dbOpenForwardOnly
 Debug.Print "dbOpenForwardOnly"
 End Select
 Debug.Print " Field: " & .Fields(0).Name & ", " & _
 "DataUpdatable = " & .Fields(0).DataUpdatable
 Debug.Print
 .Close
 End With

End Function


XML

 Copy code hover
[image]

XML
Send feedback

In this section

  • How to: Export a Report to XML

  • How to: Export Data, Schema, and Related Tables to XML


The Role of ADO in Microsoft Data Access

 Copy code hover
[image]

The Role of ADO in Microsoft Data Access
Send feedback

The Microsoft Data Access Components (MDAC) provide data access that is independent of data stores, tools, and languages. It provides a high-level, easy-to-use interface, and a low-level, high-performance interface to practically any data store available. You can use this flexibility to integrate diverse data stores and use your choice of tools, applications, and platform services to create the right solutions for your needs. These technologies provide the basic framework for general-purpose data access in Microsoft Windows operating systems.

There are three primary technologies in MDAC. ActiveX Data Objects (ADO) is a high-level, easy-to-use interface to OLE DB. OLE DB is a low-level, high-performance interface to a variety of data stores. ADO and OLE DB both can work with relational (tabular) and nonrelational (hierarchical or stream) data. Finally, Open Database Connectivity (ODBC) is another low-level, high-performance interface that is designed specifically for relational data stores.

ADO provides a layer of abstraction between your client or middle-tier application and the low-level OLE DB interfaces. ADO uses a small set of Automation objects to provide a simple and efficient interface to OLE DB. This interface makes ADO the perfect choice for developers in higher level languages, such as Visual Basic and even VBScript, who want to access data without having to learn the intricacies of COM and OLE DB.


WebBrowserControl.GridlineStyleTop Property (Access)

 Copy code hover
[image]

WebBrowserControl.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineStyleTop

expression A variable that represents a WebBrowserControl object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Databases Object Reference (DAO)

 Copy code hover
[image]

Databases Object Reference (DAO)
Send feedback

In this section

  • Databases Collection (DAO)

  • Databases Members (DAO)

  • Databases Properties (DAO)

  • Databases Methods (DAO)


Attachment.ColumnOrder Property (Access)

 Copy code hover
[image]

Attachment.ColumnOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .ColumnOrder

expression A variable that represents an Attachment object.

Remarks

Note Note

The ColumnOrder property isn't available in Design view.

The ColumnOrder property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

In other views, the property setting is 0 unless you explicitly change the order of one or more fields in Datasheet view (either by dragging the fields to new positions or by changing their ColumnOrder property settings). Fields to the right of the moved field's new position will have a property setting of 0 in views other than Datasheet view.

The order of the fields in Datasheet view doesn't affect the order of the fields in table Design view or Form view.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


CubeDefs Collection Properties, Methods, and Events (ADO MD)

 Copy code hover
[image]

CubeDefs Collection Properties, Methods, and Events (ADO MD)
Send feedback

Properties

Count Property

Item Property

Methods

Refresh Method

Events

None.


ADO for Visual C++ Syntax Index for COM

 Copy code hover
[image]

ADO for Visual C++ Syntax Index for COM
Send feedback

This index is a cross-reference to the ADO Language Reference based on Microsoft Visual C++.

If you use the #import directive in your application, a header file will be generated that will enable you to use syntax similar to Microsoft Visual Basic. Property names of the form get_PropertyName and put_PropertyName can be treated as if they were declared simply as PropertyName. A property can then be treated like a data member instead of a function.

All of the methods, properties, and events are functions that return an HRESULT, which you can test to determine if the function executed successfully.

Method and property syntax in Visual C++ is listed for the following elements:

  • Collections

  • Command object

  • Connection object

  • Error object

  • Field object

  • Parameter object

  • Record object

  • Recordset object

  • Stream object


Attachment.InSelection Property (Access)

 Copy code hover
[image]

Attachment.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Version Information

Version Added: Access 2007

Syntax

expression .InSelection

expression A variable that represents an Attachment object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Form.SelectionChange Property (Access)

 Copy code hover
[image]

Form.SelectionChange Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the SelectionChange event occurs. Read/write.

Syntax

expression .SelectionChange

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the SelectionChange event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).SelectionChange = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


Section.Click Event (Access)

 Copy code hover
[image]

Section.Click Event (Access)
See also Send feedback

Published: July 16, 2012

The Click event occurs when the user presses and then releases a mouse button over an object.

Syntax

expression .Click

expression A variable that represents a Section object.

Remarks

  • This event applies to a control containing a hyperlink.

To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

For a control, this event occurs when the user:

  • Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

Typically, you attach a Clickevent procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

See also

Concepts

Section Object

Other resources

Section Object Members


Invalid property value. (Error 3271)

 Copy code hover
[image]

Invalid property value. (Error 3271)
Send feedback

Possible causes:

  • The setting for the Value property of the Parameter object is too long or is otherwise incorrect.

  • The Index object name is a zero-length string (" "). You must enter a name for the Index object when appending the object to the Indexes collection.

  • The Workspace object name is a zero-length string. You must enter a name for the Workspace object when appending the object to a Workspaces collection.


Page.MouseUp Event (Access)

 Copy code hover
[image]

Page.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents a Page object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was released to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

Page Object

Other resources

Page Object Members


WebBrowserControl.Parent Property (Access)

 Copy code hover
[image]

WebBrowserControl.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Version Information

Version Added: Access 2010

Syntax

expression .Parent

expression A variable that represents a WebBrowserControl object.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Attachment.BorderWidth Property (Access)

 Copy code hover
[image]

Attachment.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .BorderWidth

expression A variable that represents an Attachment object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Connection Properties, Methods, and Events (ADO)

 Copy code hover
[image]

Connection Properties, Methods, and Events (ADO)
Send feedback

Properties/Collections

Attributes Property

CommandTimeout Property

ConnectionString Property

ConnectionTimeout Property

CursorLocation Property

DefaultDatabase Property

Errors Collection

IsolationLevel Property

Mode Property

Properties Collection

Provider Property

State Property

Version Property

Methods

BeginTrans, CommitTrans, and RollbackTrans Methods

Cancel Method

Close Method

Execute Method (ADO Connection)

Open Method (ADO Connection)

OpenSchema Method

Events

BeginTransComplete, CommitTransComplete, and RollbackTransComplete Events

ConnectComplete and Disconnect Events

ExecuteComplete Event

InfoMessage Event

WillConnect Event

WillExecute Event


Section.WillContinue Property (Access)

 Copy code hover
[image]

Section.WillContinue Property (Access)
See also Send feedback

Published: July 16, 2012

Determines if the current section will continue on the following page. Read/write Boolean.

Syntax

expression .WillContinue

expression A variable that represents a Section object.

Remarks

You can use this property to determine whether to show or hide certain controls, depending on the value of the property. For example, you may have a hidden label in a page header containing the text "Continued on next page". If the value of the WillContinue property is True, you can make the hidden label visible.

Example

The following example displays a message box indicating whether the page header for the report "Product Summary" will continue on the following page.

VBA Copy code Copy code
MsgBox Reports("Product Summary").Section("PageHeaderSection").WillContinue

See also

Concepts

Section Object

Other resources

Section Object Members


Application.UserControl Property (Access)

 Copy code hover
[image]

Application.UserControl Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the UserControl property to determine whether the current Microsoft Access application was started by the user or by another application with Automation, formerly called OLE Automation. Read/write Boolean.

Syntax

expression .UserControl

expression A variable that represents an Application object.

Remarks

The UserControl property uses the following settings.

Setting | Description
True | The current application was started by the user.
False | The current application was started by another application with Automation.

This property is read-only in all views when user starts the Access application. If Microsoft Access is started by OLE Automation, the UserControl property can be set in Visual Basic.

When an application is launched by the user, the Visible and UserControl properties of the Application object are both set to True. When the UserControl property is set to True, it isn't possible to set the Visible property of the object to False.

When an Application object is created by using Automation, the Visible and UserControl properties of the object are both set to False.

Example

The following example displays a message indicating whether Access was started by the user.

VBA Copy code Copy code
MsgBox "The user started Access:  " & Application.UserControl

See also

Concepts

Application Object

Other resources

Application Object Members


Relations.Delete Method (DAO)

 Copy code hover
[image]

Relations.Delete Method (DAO)
Send feedback

Deletes the specified Relation from the Relations collection.

Syntax

expression .Delete(Name)

expression A variable that represents a Relations object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Required | String | The name of the relation to delete.

Remarks

The Delete method is supported only when the Relation object is a new, unappended object.


TextBox.Name Property (Access)

 Copy code hover
[image]

TextBox.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a TextBox object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Field2.Size Property (DAO)

 Copy code hover
[image]

Field2.Size Property (DAO)
Send feedback

Sets or returns a value that indicates the maximum size, in bytes, of a Field2 object.

Syntax

expression .Size

expression A variable that represents a Field2 object.

Remarks

For an object not yet appended to the Fields collection, this property is read/write.

For fields (other than Memo type fields) that contain character data, the Size property indicates the maximum number of characters that the field can hold. For numeric fields, the Size property indicates how many bytes of storage are required.

Use of the Size property depends on the object that contains the Fields collection to which the Field2 object is appended, as shown in the following table.

Object appended to | Usage
Index | Not supported
QueryDef | Read-only
Recordset | Read-only
Relation | Not supported
TableDef | Read-only

When you create a Field2 object with a data type other than Text, the Type property setting automatically determines the Size property setting; you don't need to set it. For a Field2 object with the Text data type, however, you can set Size to any integer up to the maximum text size (255 for Microsoft Access database engine databases). If you do not set the size, the field will be as large as the database allows.

For Long Binary and Memo Field2 objects, Size is always set to 0. Use the FieldSize property of the Field2 object to determine the size of the data in a specific record. The maximum size of a Long Binary or Memo field is limited only by your system resources or the maximum size that the database allows.

Example

This example demonstrates the Size property by enumerating the names and sizes of the Field2 objects in the Employees table.

VBA Copy code Copy code
Sub SizeX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim fldNew As Field2
 Dim fldLoop As Field2

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set tdfEmployees = dbsNorthwind.TableDefs!Employees

 With tdfEmployees

 ' Create and append a new Field object to the
 ' Employees table.
 Set fldNew = .CreateField("FaxPhone")
 fldNew.Type = dbText
 fldNew.Size = 20
 .Fields.Append fldNew

 Debug.Print "TableDef: " & .Name
 Debug.Print " Field.Name - Field.Type - Field.Size"

 ' Enumerate Fields collection; print field names,
 ' types, and sizes.
 For Each fldLoop In .Fields
 Debug.Print " " & fldLoop.Name & " - " & _
 fldLoop.Type & " - " & fldLoop.Size
 Next fldLoop

 ' Delete new field because this is a demonstration.
 .Fields.Delete fldNew.Name

 End With

 dbsNorthwind.Close

End Sub


Section.MouseDown Event (Access)

 Copy code hover
[image]

Section.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents a Section object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
         Shift As Integer, X As Single, _
         Y As Single)
    If Button = acLeftButton Then
        MsgBox "You pressed the left button."
    End If
    If Button = acRightButton Then
        MsgBox "You pressed the right button."
    End If
    If Button = acMiddleButton Then
        MsgBox "You pressed the middle button."
    End If
End Sub

See also

Concepts

Section Object

Other resources

Section Object Members


Object is not a collection. (Error 3272)

 Copy code hover
[image]

Object is not a collection. (Error 3272)
Send feedback

You have referred to an object as though it were a collection. For example, a statement such as qrySales.Refresh or or qrySales(2) causes this error.


Could not update; currently locked by user

 Copy code hover
[image]

Could not update; currently locked by user <name> on machine <name>. (Error 3260)
Send feedback

You tried to update data that is located on a page that is currently locked.

Possible causes:

  • You tried to save a query being used by someone else. To save your query, wait for the other user to finish or enter a different name, and then try the operation again.

  • You tried to use the Edit method on a data page containing a record that is already open or locked.


AppIcon Property

 Copy code hover
[image]

AppIcon Property
Send feedback

Published: July 16, 2012

You can use the AppIcon property to specify the name of the bitmap (.bmp) or icon (.ico) file that contains the application's icon. For example, you can use the AppIcon property to specify a .bmp file that contains a picture of an automobile to represent an automotive parts application.

Setting

The AppIcon property is a string expression that's a valid bitmap or icon file name (including the path).

The easiest way to set this property is by using the Application Icon option in the Access Options dialog box, available by clicking the click the Microsoft Office Button [image] and then clicking the Current Database category. You can also set this property by using a macro or Visual Basic .

To set the AppIcon property by using a macro or Visual Basic, you must first either set the property in the Access Options dialog box once or create the property in the following ways:

  • In a Microsoft Access database , you can add it by using the CreateProperty method and append it to the Properties collection of the Database object.

  • In a Microsoft Access project (.adp), you can add it to the AccessObjectProperties collection of the CurrentProject object by using the Add method.

You must also use the RefreshTitleBar method to make any changes visible immediately.

Remarks

If you are distributing your application, it's recommended that the .bmp or .ico file containing the icon reside in the same directory as your Microsoft Access application.

If the AppIcon property isn't set or is invalid, the Microsoft Access icon is displayed.

This property setting takes effect immediately after it's set in code (as long as the code includes the RefreshTitleBar method) or the Access Options dialog box is closed.

Example

The following example shows how to change the AppIcon and AppTitle properties in a Microsoft Access database. If the properties haven't already been set or created, you must create them and append them to the Properties collection by using the CreateProperty method.

Copy code Copy code
Sub cmdAddProp_Click()
 Dim intX As Integer
 Const DB_Text As Long = 10
 intX = AddAppProperty("AppTitle", DB_Text, "My Custom Application")
 intX = AddAppProperty("AppIcon", DB_Text, "C:\Windows\Cars.bmp")
 CurrentDb.Properties("UseAppIconForFrmRpt") = 1
 Application.RefreshTitleBar
End Sub

Function AddAppProperty(strName As String, _
 varType As Variant, varValue As Variant) As Integer
 Dim dbs As Object, prp As Variant
 Const conPropNotFoundError = 3270

 Set dbs = CurrentDb
 On Error GoTo AddProp_Err
 dbs.Properties(strName) = varValue
 AddAppProperty = True

AddProp_Bye:
 Exit Function

AddProp_Err:
 If Err = conPropNotFoundError Then
 Set prp = dbs.CreateProperty(strName, varType, varValue)
 dbs.Properties.Append prp
 Resume
 Else
 AddAppProperty = False
 Resume AddProp_Bye
 End If
End Function


Form.RibbonName Property (Access)

 Copy code hover
[image]

Form.RibbonName Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or set the name of the customized ribbon to be displayed when the specified form is loaded. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .RibbonName

expression A variable that represents a Form object.

Remarks

For more information about how to display a customized ribbon when loading a form, see How to: Apply a Filter When Opening a Form or Report.

See also

Concepts

Form Object

Other resources

Form Object Members


NavigationButton Properties (Access)

 Copy code hover
[image]

NavigationButton Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
AddColon | Specifies whether a colon (:) follows the text in labels for new controls. Read/write Boolean.
Alignment | Gets or sets how the specified button's caption and picture are aligned. Read/write Byte.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
AutoRepeat | You can use the AutoRepeat property to specify whether an event procedure or macro runs repeatedly while a command button on a form remains pressed in. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
Bevel | Gets or sets the bevel effect applied to the specified object. Read/write Long.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.
Caption | Gets or sets the text that appears in the control. Read/write String.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
CursorOnHover | Gets or sets the type of mouse cursor displayed when the user rests the pointer on a button. Read/write AcCursorOnHover.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontName | You can use the FontName property to specify the font for text in the following situations:
FontSize | You can use the FontSize property to specify the point size for text in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
FontWeight | You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
ForeShade | Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
ForeThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.
ForeTint | Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
Glow | Gets or sets the Glow effect applied to the specified object. Read/write Long.
Gradient | Gets or sets the gradient fill applied to the specified object. Read/write Long.
GridlineColor | Gets or sets the color of the gridline for the specified list box. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified list box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified text box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified text box. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified text box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified text box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified text box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the text box is anchored horizontally within its layout. Read/write.
HoverColor | Gets or sets the color displayed on the control when the user rests the mouse cursor over it. Read/write Long.
HoverForeColor | Gets or sets the color of the text displayed on the control when the user rests the mouse cursor over it. Read/write Long.
HoverForeShade | Gets or sets the shade applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.
HoverForeThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverForeColor property of the specified object. Read/write Long.
HoverForeTint | Gets or sets the tint applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.
HoverShade | Gets or sets the shade that is applied to the theme color in the HoverColor property of the specified object. Read/write Single.
HoverThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverColor property of the specified object. Read/write Long.
HoverTint | Gets or sets the tint applied to the theme color in the HoverColor property of the specified object. Read/write Single.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
HyperlinkAddress | You can use the HyperlinkAddress property to specify or determine the path to an object, document, Web page or other destination for a hyperlink associated with a the specified control. Read/write String.
HyperlinkSubAddress | You can use the HyperlinkSubAddress property to specify or determine a location within the target document specified by the HyperlinkAddress property. Read/write String.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified text box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified text box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
NavigationTargetName | Gets or sets the name of the form or report to be displayed when the user click the specified navigation button. Read/write String.
NavigationWhereClause | Gets or sets the filter criteria applied when opening the form or report associated with the specified navigation button. Read/write String.
ObjectPalette | The ObjectPalette property specifies the palette in the application used to create A bitmap or other graphic that is loaded into the specified control by using the Picture property. Read/write Variant.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnPush | Sets or returns the value of the On Click box in the Properties window of a command button. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
ParentTab | Gets the top-level navigation button associated with the specified navigation button. Read-only NavigationButton.
Picture | You can use the Picture property to specify a bitmap or other type of graphic to be displayed on the specified control. Read/write String.
PictureCaptionArrangement | Gets or sets how the specified button's caption is arranged in relation to its picture. Read/write AcPictureCaptionArrangement.
PictureData | You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.
PictureType | You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.
PressedColor | Gets or sets the color displayed on the control when the user clicks it. Read/write Long.
PressedForeColor | Gets or sets the color of the text displayed on the control when the user clicks it. Read/write Long.
PressedForeShade | Gets or sets the shade applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.
PressedForeThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedForeColor property of the specified object. Read/write Long.
PressedForeTint | Gets or sets the tint applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.
PressedShade | Gets or sets the shade that is applied to the theme color in the PressedColor property of the specified object. Read/write Single.
PressedThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedColor property of the specified object. Read/write Long.
PressedTint | Gets or sets the tint applied to the theme color in the PressedColor property of the specified object. Read/write Single.
Properties | Returns a reference to a control's Properties collection object. Read-only.
QuickStyle | Gets or sets the Quick Style that is applied to the specified object. Read/write Long.
QuickStyleMask | Gets or sets modifications to the Quick Style that is applied to the specified object. Read/write Long.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
RightPadding | Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
Shadow | Gets or sets the Shadow effect applied to the specified object. Read/write Long.
Shape | Returns or sets the shape of the specifiednavigation button. Read/write Long.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SoftEdges | Gets or sets the Soft Edges effect applied to the specified object. Read/write Long.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
ThemeFontIndex | Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.
Transparent | You can use the Transparent property to specify whether a command button is solid or transparent. Read/write Boolean.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified text box is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


CustomControl.IsVisible Property (Access)

 Copy code hover
[image]

CustomControl.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Syntax

expression .IsVisible

expression A variable that represents a CustomControl object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


You have written a subquery that can return more than one field without using the EXISTS reserved word in the main query's FROM clause. Revise the SELECT statement of the subquery to request only one field. (Error 3306)

 Copy code hover
[image]

You have written a subquery that can return more than one field without using the EXISTS reserved word in the main query's FROM clause. Revise the SELECT statement of the subquery to request only one field. (Error 3306)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for more information.


TabControl.MouseMove Event (Access)

 Copy code hover
[image]

TabControl.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents a TabControl object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


TextBox.BorderWidth Property (Access)

 Copy code hover
[image]

TextBox.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Syntax

expression .BorderWidth

expression A variable that represents a TextBox object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


How to: Build SQL Statements That Include Variables and Controls

 Copy code hover
[image]

How to: Build SQL Statements That Include Variables and Controls
Send feedback

When working with Data Access Objects (DAO) or ActiveX Data Objects (ADO), you may need to construct an SQL statement in code. This is sometimes referred to as taking your SQL code "inline." For example, if you are creating a new QueryDef object, you must set its SQL property to a valid SQL string. But if you are using an ADO Recordset object, you must set its Source property to a valid SQL string.

To construct an SQL statement, create a query in the query design grid, switch to SQL view, and copy and paste the corresponding SQL statement into your code.

Often a query must be based on values that the user supplies, or values that change in different situations. If this is the case, you need to include variables or control values in your query. The Microsoft Access database engine processes all SQL statements, but not variables or controls. Therefore, you must construct your SQL statement so that Access first determines these values and then concatenates them into the SQL statement that is passed to the Microsoft Access database engine.

Building SQL Statements with DAO

The following example shows how to create a QueryDef object with a simple SQL statement. This query returns all orders from an Orders table that were placed after March 31, 2006.

Copy code Copy code
Public Sub GetOrders()

   Dim dbs As DAO.Database
   Dim qdf As DAO.QueryDef
   Dim strSQL As String

   Set dbs = CurrentDb
   strSQL = "SELECT * FROM Orders WHERE OrderDate >#3-31-2006#;"
   Set qdf = dbs.CreateQueryDef("SecondQuarter", strSQL)

End Sub

The next example creates the same QueryDef object by using a value stored in a variable. Be aware that the number signs (#) that denote the date values must be included in the string so that they are concatenated with the date value.

Copy code Copy code
Dim dbs As Database, qdf As QueryDef, strSQL As String
Dim dteStart As Date
dteStart = #3-31-2006#
Set dbs = CurrentDb
strSQL = "SELECT * FROM Orders WHERE OrderDate" _
    & "> #" & dteStart & "#;"
Set qdf = dbs.CreateQueryDef("SecondQuarter", strSQL)

The following example creates a QueryDef object by using a value in a control called OrderDate on an Orders form. Be aware that you provide the full reference to the control, and that you include the number signs (#) that denote the date within the string.

Copy code Copy code
Dim dbs As Database, qdf As QueryDef, strSQL As String
Set dbs = CurrentDb
strSQL = "SELECT * FROM Orders WHERE OrderDate" _
    & "> #" & Forms!Orders!OrderDate & "#;"
Set qdf = dbs.CreateQueryDef("SecondQuarter", strSQL)

Building SQL Statements with ADO

In this section, you will build the same statements as in the previous section, but this time using ADO as the data access method.

The following code example shows how to create a QueryDef object with a simple SQL statement. This query returns all orders from an Orders table that were placed after March 31, 2006.

Copy code Copy code
Dim dbs As Database, qdf As QueryDef, strSQL As String
Set dbs = CurrentDb
strSQL = "SELECT * FROM Orders WHERE OrderDate >#3-31-2006#;"
Set qdf = dbs.CreateQueryDef("SecondQuarter", strSQL)

The next example creates the same QueryDef object by using a value stored in a variable. Be aware that the number signs (#) that denote the date values must be included in the string so that they are concatenated with the date value.

Copy code Copy code
Dim dbs As Database, qdf As QueryDef, strSQL As String
Dim dteStart As Date
dteStart = #3-31-2006#
Set dbs = CurrentDb
strSQL = "SELECT * FROM Orders WHERE OrderDate" _
    & "> #" & dteStart & "#;"
Set qdf = dbs.CreateQueryDef("SecondQuarter", strSQL)

The following code example creates a QueryDef object by using a value in a control called OrderDate on an Orders form. Be aware that it provides the full reference to the control, and that it includes the number signs that denote the date within the string.

Copy code Copy code
Dim dbs As Database, qdf As QueryDef, strSQL As String
Set dbs = CurrentDb
strSQL = "SELECT * FROM Orders WHERE OrderDate" _
    & "> #" & Forms!Orders!OrderDate & "#;"
Set qdf = dbs.CreateQueryDef("SecondQuarter", strSQL)


Application.DVar Method (Access)

 Copy code hover
[image]

Application.DVar Method (Access)
See also Send feedback

Published: July 16, 2012

Estimates the variance across a sample in a specified set of records (a domain).

Syntax

expression .DVar(Expr, Domain, Criteria)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
Expr | Required | String | An expression that identifies the numeric field on which you want to find the variance. It can be a string expression identifying a field from a table or query, or it can be an expression that performs a calculation on data in that field . In expr, you can include the name field in a table, a control on a form, a constant, or a function. If expr includes a function, it can be either built-in or user-defined, but not another domain aggregate or SQL aggregate function. Any field included in expr must be a numeric field.
Domain | Required | String | A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter.
Criteria | Optional | Variant | An optional string expression used to restrict the range of data on which the DVar function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the DVar function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain; otherwise the DVar function returns a Null.

Return Value

Variant

Remarks

For example, you could use the DVar function to calculate the variance across a set of students' test scores.

If domain refers to fewer than two records or if fewer than two records satisfy criteria, the DVar functions return a Null, indicating that a variance can't be calculated.

Whether you use the DVar function in a macro, module, query expression, or calculated control, you must construct the criteria argument carefully to ensure that it will be evaluated correctly.

You can use the DVar function to specify criteria in the Criteria row of a select query, in a calculated field expression in a query, or in the Update To row of an update query.

Note Note

You can use the DVar function or the Var function in a calculated field expression in a totals query. If you use the DVar function, values are calculated before data is grouped. If you use the Var function, the data is grouped before values in the field expression are evaluated.

Use the DVar function in a calculated control when you need to specify criteria to restrict the range of data on which the function is performed. For example, to display a variance for orders to be shipped to California, set the ControlSource property of a text box to the following expression:

VBA Copy code Copy code
=DVar("[Freight]", "Orders", "[ShipRegion] = 'CA'")

If you simply want to find the standard deviation across all records in domain, use the Var or VarP function.

Example

The following example returns estimates of the variance for a population and a population sample for orders shipped to the United Kingdom. The domain is an Orders table. The criteria argument restricts the resulting set of records to those for which ShipCountry equals UK.

VBA Copy code Copy code
Dim dblX As Double
Dim dblY As Double

' Sample estimate.
dblX = DVar("[Freight]", "Orders", "[ShipCountry] = 'UK'")

' Population estimate.
dblY = DVarP("[Freight]", "Orders", "[ShipCountry] = 'UK'")

The next example returns estimates by using a variable, strCountry, in the criteria argument. Note that single quotation marks (') are included in the string expression, so that when the strings are concatenated, the string literal UK will be enclosed in single quotation marks.

VBA Copy code Copy code
Dim strCountry As String|
Dim dblX As Double

strCountry = "UK"

dblX = DVar("[Freight]", "Orders", "[ShipCountry] = '" _
    & strCountry & "'")

The following examples show how to use various types of criteria with the DVar function.

Sample code provided by: Community Member Icon The UtterAccess community | About the Contributors

Copy code Copy code
    ' ***************************
    ' Typical Use
    ' Numerical values. Replace "number" with the number to use.
    variable = DVar("[FieldName]", "TableName", "[Criteria] = number")

    ' Strings.
    ' Numerical values. Replace "string" with the string to use.
    variable = DVar("[FieldName]", "TableName", "[Criteria]= 'string'")

    ' Dates. Replace "date" with the string to use.
    variable = DVar("[FieldName]", "TableName", "[Criteria]= #date#")
    ' ***************************

    ' ***************************
    ' Referring to a control on a form
    ' Numerical values
    variable = DVar("[FieldName]", "TableName", "[Criteria] = " & Forms!FormName!ControlName)

    ' Strings
    variable = DVar("[FieldName]", "TableName", "[Criteria] = '" & Forms!FormName!ControlName & "'")

    ' Dates
    variable = DVar("[FieldName]", "TableName", "[Criteria] = #" & Forms!FormName!ControlName & "#")
    ' ***************************

    ' ***************************
    ' Combinations
    ' Multiple types of criteria
    variable = DVar("[FieldName]", "TableName", "[Criteria1] = " & Forms![FormName]![Control1] _
             & " AND [Criteria2] = '" & Forms![FormName]![Control2] & "'" _
            & " AND [Criteria3] =#" & Forms![FormName]![Control3] & "#")

    ' Use two fields from a single record.
    variable = DVar("[LastName] & ', ' & [FirstName]", "tblPeople", "[PrimaryKey] = 7")

    ' Expressions
    variable = DVar("[Field1] + [Field2]", "tableName", "[PrimaryKey] = 7")

    ' Control Structures
    variable = DVar("IIf([LastName] Like 'Smith', 'True', 'False')", "tableName", "[PrimaryKey] = 7")
    ' ***************************

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Application Object

Other resources

Application Object Members


MoveFirst, MoveLast, MoveNext, and MovePrevious Methods Example (VBScript)

 Copy code hover
[image]

MoveFirst, MoveLast, MoveNext, and MovePrevious Methods Example (VBScript)
Send feedback

This example uses the MoveFirst, MoveLast, MoveNext, and MovePrevious methods to move the record pointer of a Recordset based on the supplied command.

Cut and paste the following code into Notepad or another text editor, and save it as MoveFirstVBS.asp. You can view the result in any browser.

VBS Copy code Copy code

<!-- BeginMoveFirstVBS -->
<%@ Language=VBScript %>
<%' use this meta tag instead of adovbs.inc%>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->
<HTML>
<HEAD>
<TITLE>ADO MoveNext, MovePrevious, MoveLast, MoveFirst Methods</TITLE>

<SCRIPT LANGUAGE="VBScript">
<!--
   Sub cmdDown_OnClick
      'Set Values in Form Input Boxes and Submit Form
      Document.form.MoveAction.Value = "MovePrev"
      Document.Form.Submit
   End Sub

   Sub cmdUp_OnClick
      Document.form.MoveAction.Value = "MoveNext"
      Document.Form.Submit
   End Sub

   Sub cmdFirst_OnClick
      Document.form.MoveAction.Value = "MoveFirst"
      Document.Form.Submit
   End Sub

   Sub cmdLast_OnClick
      Document.form.MoveAction.Value = "MoveLast"
      Document.Form.Submit
   End Sub
//-->
</SCRIPT>
</HEAD>

<body bgcolor="white">
<h1 align="center">ADO MoveNext, MovePrevious <br> MoveLast & MoveFirst Methods</h1>
<% ' to integrate/test this code replace the
   ' Data Source value in the Connection string%>
<%
   ' connection and recordset variables
   Dim Cnxn, strCnxn
   Dim rsEmployees, strSQLEmployees

   ' open connection
    Set Cnxn = Server.CreateObject("ADODB.Connection")
    strCnxn = "Provider='sqloledb';Data Source=" & _
            Request.ServerVariables("SERVER_NAME") & ";" & _
            "Integrated Security='SSPI';Initial Catalog='Northwind';"
    Cnxn.Open strCnxn

    ' create and open Recordset using object refs
   Set rsEmployees = Server.CreateObject("ADODB.Recordset")
   strSQLEmployees = "Employees"

   rsEmployees.ActiveConnection = Cnxn
   rsEmployees.CursorLocation = adUseClient
   rsEmployees.CursorType = adOpenKeyset
   rsEmployees.LockType = adLockOptimistic
   rsEmployees.Source = strSQLEmployees
   rsEmployees.Open

   rsEmployees.MoveFirst

   If Not IsEmpty(Request.Form("MoveAction")) Then
      strAction = Request.Form("MoveAction")
      varPosition  = Request.Form("Position")

      rsEmployees.AbsolutePosition = varPosition

      Select Case strAction

        Case "MoveNext"

         rsEmployees.MoveNext
         If rsEmployees.EOF Then
            rsEmployees.MoveLast
            strMessage = "Can't move beyond the last record."
         End If

        Case "MovePrev"

         rsEmployees.MovePrevious
         If rsEmployees.BOF Then
            rsEmployees.MoveFirst
            strMessage = "Can't move beyond the first record."
         End If

        Case "MoveLast"

         rsEmployees.MoveLast

        Case "MoveFirst"

         rsEmployees.MoveFirst

      End Select
   End If

%>

<!-- Display Current Record Number and Recordset Size -->
<h2>Record Number <%=rsEmployees.AbsolutePosition%> of <%=rsEmployees.RecordCount%></H2>
<hr>
<table cellpadding=5 border=0>
<!-- BEGIN column header row for Customer Table-->
<tr>
   <th>Name</th>
   <th>Hire Date</th>
</tr>

<!--Display ADO Data from Customer Table-->
<tr>
  <td><%= rsEmployees("LastName") & ", " %>
      <%= rsEmployees("FirstName") & " " %></td>
  <td><%= rsEmployees("HireDate")%></td>
</tr>
<tr>
  <td colspan=2><%=strMessage%></td>
</tr>
</table>

<hr>

<form Name="Form" Method="Post" Action="MoveFirstVbs.asp">
<Input Type=Button Name=cmdDown Value="<">
<Input Type=Button Name=cmdUp Value=">">
<BR>
<H3>Click Direction Arrows to Use MovePrevious or MoveNext</H3>
<Input Type=Button Name=cmdFirst Value="First Record">
<Input Type=Button Name=cmdLast Value="Last Record">

<!-- Use Hidden Form Fields to record values to send to Server -->

<input Type="Hidden" Size="4" Name="MoveAction" Value="Move">
<input Type="Hidden" Size="4" Name="Position" Value="<%= rsEmployees.AbsolutePosition%>">
</form>

<HR>
</BODY>

<%
    ' clean up
    If rsEmployees.State = adStateOpen then
        rsEmployees.Close
    End If
    If Cnxn.State = adStateOpen then
        Cnxn.Close
    End If
%>
</HTML>
<!-- EndMoveFirstVBS -->


Page.SetFocus Method (Access)

 Copy code hover
[image]

Page.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Syntax

expression .SetFocus

expression A variable that represents a Page object.

Return Value

Nothing

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.

Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.

Example

The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:

VBA Copy code Copy code
Forms!Employees!EmployeeID.SetFocus

See also

Concepts

Page Object

Other resources

Page Object Members


The record cannot be deleted or changed because table

 Copy code hover
[image]

The record cannot be deleted or changed because table <name> includes related records. (Error 3200)
Send feedback

You tried to perform an operation that would have violated referential integrity rules for related tables. For example, this error occurs if you try to delete or change a record in the "one" table in a one-to-many relationship when there are related records in the "many" table.

If you want to delete or change the record, first delete the related records from the "many" table.


CodeData.AllFunctions Property (Access)

 Copy code hover
[image]

CodeData.AllFunctions Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllFunctions property to reference the AllFunctions collection and its related properties. Read-only AllFunctions object.

Syntax

expression .AllFunctions

expression A variable that represents a CodeData object.

See also

Concepts

CodeData Object

Other resources

CodeData Object Members


CommandButton Properties (Access)

 Copy code hover
[image]

CommandButton Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
AddColon | Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.
Alignment | Gets or sets how the specified button's caption and picture are aligned. Read/write Byte.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoLabel | Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.
AutoRepeat | You can use the AutoRepeat property to specify whether an event procedure or macro runs repeatedly while a command button on a form remains pressed in. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
Bevel | Gets or sets the bevel effect applied to the specified object. Read/write Long.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the button and its bottom gridline. Read/write Integer.
Cancel | You can use the Cancel property to specify whether a command button is also the Cancel button on a form. Read/write Boolean.
Caption | Gets or sets the text that appears in the control. Read/write String.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
CursorOnHover | Gets or sets the type of mouse cursor displayed when the user rests the pointer on a button. Read/write AcCursorOnHover.
Default | You can use the Default property to specify whether a command button is the default button on a form. Read/write Boolean.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
Enabled | You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
FontBold | You can use the FontBold property to specify whether a font appears in a bold style in the following situations:
FontItalic | You can use the FontItalic property to specify whether text is italic in the following situations:
FontName | You can use the FontName property to specify the font for text in the following situations:
FontSize | You can use the FontSize property to specify the point size for text in the following situations:
FontUnderline | You can use the FontUnderline property to specify whether text is underlined in the following situations:
FontWeight | You can use the DatasheetFontWeight property to specify the line width of the font used to display and print characters for field names and data in Datasheet view. Read/write Integer.
ForeColor | You can use the ForeColor property to specify the color for text in a control. Read/write Long.
ForeShade | Gets or sets the shade that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
ForeThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.
ForeTint | Gets or sets the tint that is applied to the theme color in the ForeColor property of the specified object. Read/write Single.
Glow | Gets or sets the Glow effect applied to the specified object. Read/write Long.
Gradient | Gets or sets the gradient fill applied to the specified object. Read/write Long.
GridlineColor | Gets or sets the color of the gridline for the specified command button. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified button. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified button. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified button. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified button. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified button. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified button. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified button. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified button. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the button is anchored horizontally within its layout. Read/write.
HoverColor | Gets or sets the color displayed on the control when the user rests the mouse cursor over it. Read/write Long.
HoverForeColor | Gets or sets the color of the text displayed on the control when the user rests the mouse cursor over it. Read/write Long.
HoverForeShade | Gets or sets the shade applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.
HoverForeThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverForeColor property of the specified object. Read/write Long.
HoverForeTint | Gets or sets the tint applied to the theme color in the HoverForeColor property of the specified object. Read/write Single.
HoverShade | Gets or sets the shade that is applied to the theme color in the HoverColor property of the specified object. Read/write Single.
HoverThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the HoverColor property of the specified object. Read/write Long.
HoverTint | Gets or sets the tint applied to the theme color in the HoverColor property of the specified object. Read/write Single.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
HyperlinkAddress | You can use the HyperlinkAddress property to specify or determine the path to an object, document, Web page or other destination for a hyperlink associated with a the specified control. Read/write String.
HyperlinkSubAddress | You can use the HyperlinkSubAddress property to specify or determine a location within the target document specified by the HyperlinkAddress property. Read/write String.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
LabelAlign | The property specifies the text alignment within attached labels on new controls. Read/write Byte.
LabelX |
LabelY |
Layout | Returns the type of layout for the specified button. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified button. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the button and its left gridline. Read/write Integer.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
ObjectPalette | The ObjectPalette property specifies the palette in the application used to create A bitmap or other graphic that is loaded into the specified control by using the Picture property. Read/write Variant.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnEnter | Sets or returns the value of the On Enter box in the Properties window of specified object. Read/write String. .
OnExit | Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .
OnGotFocus | Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.
OnKeyDown | Sets or returns the value of the On Key Down box in the Properties window. Read/write String.
OnKeyPress | Sets or returns the value of the On Key Press box in the Properties window. Read/write String.
OnKeyUp | Sets or returns the value of the On Key Up box in the Properties window. Read/write String.
OnLostFocus | Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnPush | Sets or returns the value of the On Click box in the Properties window of a command button. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Picture | You can use the Picture property to specify a bitmap or other type of graphic to be displayed on the specified control. Read/write String.
PictureCaptionArrangement | Gets or sets how the specified button's caption is arranged in relation to its picture. Read/write AcPictureCaptionArrangement.
PictureData | You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.
PictureType | You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.
PressedColor | Gets or sets the color displayed on the control when the user clicks it. Read/write Long.
PressedForeColor | Gets or sets the color of the text displayed on the control when the user clicks it. Read/write Long.
PressedForeShade | Gets or sets the shade applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.
PressedForeThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedForeColor property of the specified object. Read/write Long.
PressedForeTint | Gets or sets the tint applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.
PressedShade | Gets or sets the shade that is applied to the theme color in the PressedColor property of the specified object. Read/write Single.
PressedThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the PressedColor property of the specified object. Read/write Long.
PressedTint | Gets or sets the tint applied to the theme color in the PressedColor property of the specified object. Read/write Single.
Properties | Returns a reference to a control's Properties collection object. Read-only.
QuickStyle | Gets or sets the Quick Style that is applied to the specified object. Read/write Long.
QuickStyleMask | Gets or sets modifications to the Quick Style that is applied to the specified object. Read/write Long.
ReadingOrder | You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.
RightPadding | Gets or sets the amount of space (in inches) between the button and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
Shadow | Gets or sets the Shadow effect applied to the specified object. Read/write Long.
Shape | Returns or sets the shape of the specified button. Read/write Long.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SoftEdges | Gets or sets the Soft Edges effect applied to the specified object. Read/write Long.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
TabIndex | You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.
TabStop | You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
ThemeFontIndex | Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the button and its top gridline. Read/write Integer.
Transparent | You can use the Transparent property to specify whether a command button is solid or transparent. Read/write Boolean.
UseTheme | Gets or sets whether the specified object will utilize formatting styles defined in Office Document Themes. Read/write Boolean.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified button is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


AcDefView Enumeration (Access)

 Copy code hover
[image]

AcDefView Enumeration (Access)
Send feedback

Published: July 16, 2012

Use with the DefaultView property to set or return the opening view of a form.

Name | Value | Description
acDefViewContinuous | 1 | The form displays multiple records (as many as will fit in the current window), each in its own copy of the form's detail section.
acDefViewDatasheet | 2 | Displays the form fields arranged in rows and columns like a spreadsheet.
acDefViewPivotChart | 4 | Displays the form as a PivotChart.
acDefViewPivotTable | 3 | Displays the form as a PivotTable.
acDefViewSingle | 0 | (Default) Displays one record at a time.
acDefViewSplitForm | 5 | Displays the form in Split Form view.


The database you are attempting to replicate cannot be converted. (Error 3487)

 Copy code hover
[image]

The database you are attempting to replicate cannot be converted. (Error 3487)
Send feedback

Only databases created with version 3.0 or later of the Microsoft Jet database engine can be replicated. Although you can open the database by using an installable ISAM, you cannot convert it to a replicable form. If the database was created by using an earlier version of Microsoft Jet, convert the format to the newer version. If the database is in another format, export the data to a new Microsoft Access database and retry.


Unique Table, Unique Schema, Unique Catalog Properties--Dynamic (ADO)

 Copy code hover
[image]

Unique Table, Unique Schema, Unique Catalog Properties--Dynamic (ADO)
Send feedback

Enables you to closely control modifications to a particular base table in a Recordset that was formed by a JOIN operation on multiple base tables.

  • Unique Table specifies the name of the base table upon which updates, insertions, and deletions are allowed.

  • Unique Schema specifies the schema, or name of the owner of the table.

  • Unique Catalog specifies the catalog, or name of the database containing the table.

Settings and Return Values

Sets or returns a String value that is the name of a table, schema, or catalog.

Remarks

The desired base table is uniquely identified by its catalog, schema, and table names. When the Unique Table property is set, the values of the Unique Schema or Unique Catalog properties are used to find the base table. It is intended, but not required, that either or both the Unique Schema and Unique Catalog properties be set before the Unique Table property is set.

The primary key of the Unique Table is treated as the primary key of the entire Recordset. This is the key that is used for any method requiring a primary key.

While Unique Table is set, the Delete method affects only the named table. The AddNew, Resync, Update, and UpdateBatch methods affect any appropriate underlying base tables of the Recordset.

Unique Table must be specified before doing any custom resynchronizations. If Unique Table has not been specified, the Resync Command property will have no effect.

A run-time error results if a unique base table cannot be found.

These dynamic properties are all appended to the Recordset object Properties collection when the CursorLocation property is set to adUseClient.


OR (Access 2013 custom web app)

 Copy code hover
[image]

OR (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Combines two conditions. Returns TRUE when either of the two conditions is true.

Syntax

BooleanExpression Or BooleanExpression

The Or operator uses the following argument.

Argument name | Description
BooleanExpression | Any valid expression that returns TRUE or FALSE.

Remarks

When more than one logical operator is used in a statement, Or operators are evaluated after And operators. However, you can change the order of evaluation by using parentheses.

The following table shows the result of the Or operator.

 | TRUE | FALSE
TRUE | TRUE | TRUE
FALSE | TRUE | FALSE


Records in table

 Copy code hover
[image]

Records in table <name> would have no record on the 'one' side. (Error 3333)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for more information.


Using the Connection Object (Access)

 Copy code hover
[image]

Using the Connection Object (Access)
Send feedback

A Connection object represents a unique session with a data source. In the case of a client/server database system, it can be equivalent to an actual network connection to the server. Depending on the functionality supported by the provider, some collections, methods, or properties of a Connection object might not be available.

Before opening a Connection object, you must define certain information about the data source and type of connection. The ConnectionString parameter of the Connection object Open method — or the ConnectionString property on the Connection object — usually contains most of this information. A connection string is a string of characters that defines a variable number of arguments. The arguments — some required by ADO, but others provider-specific — contain information that the Connection object must have to carry out its work. The arguments that make up the ConnectionString parameter are separated with semicolons (;).

Note Note

You can also specify an ODBC Data Source Name (DSN) or a Data Link (UDL) file in a connection string. For more information about DSNs, see Data Sources in Part 1 of the ODBC Programmer's Reference. For more information about UDLs, see Data Link API Overview in the OLE DB Programmer's Reference.


Report.HasData Property (Access)

 Copy code hover
[image]

Report.HasData Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the HasData property to determine if a report is bound to an empty recordset. Read/write Long.

Syntax

expression .HasData

expression A variable that represents a Report object.

Remarks

The HasData property is set by Microsoft Access. The value of this property can be read only while printing or while in Print Preview.

The HasData property uses the following settings.

Value | Description
-1 | The object has data.
0 | The object doesn't have data.
1 | The object is unbound.

You can use this property to determine whether to hide a subreport that has no data. For example, the following expression hides the subreport control when its report has no data.

VBA Copy code Copy code
Me!SubReportControl.Visible = Me!SubReportControl.Report.HasData

See also

Concepts

Report Object

Other resources

Report Object Members


VIEW (Microsoft Access SQL reserved word)

 Copy code hover
[image]

VIEW (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The VIEW keyword is used in these contexts:

CREATE VIEW Statement

DROP Statement


Invalid Internet address. (Error 3651)

 Copy code hover
[image]

Invalid Internet address. (Error 3651)
Send feedback

You have requested an Internet address which is not valid or not available. Check the address, and if it is valid, try again later.


Report.Controls Property (Access)

 Copy code hover
[image]

Report.Controls Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the Controls collection of a form, subform, report or section. Read-only Controls.

Syntax

expression .Controls

expression A variable that represents a Report object.

Remarks

Use the Controls property to refer to one of the controls on a form, subform, report, or section within or attached to another control. For example, the first code syntax below returns the number of controls located on Form1. The second references the name of a property within a control.

VBA Copy code Copy code
Forms("Form1").Controls.Count

Forms("Form1").Controls("Textbox1").Properties(5).Name

See also

Concepts

Report Object

Other resources

Report Object Members


Section.CanGrow Property (Access)

 Copy code hover
[image]

Section.CanGrow Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the control contains. Read/write Boolean.

Syntax

expression .CanGrow

expression A variable that represents a Section object.

Remarks

The CanGrow property uses the following settings.

Setting | Visual Basic | Description
Yes | True (-1) | The section or control grows vertically so that all data it contains can be printed or previewed.
No | False (0) | (Default) The section or control doesn't grow. Data that doesn't fit within the fixed size of the section or control won't be printed or previewed.

This property setting is read-only in a macro or Visual Basic in any view but Design view.

You can use this property to control the appearance of printed forms and reports. When you set the property to Yes, the object automatically adjusts so any amount of data can be printed. When a control grows, the controls below it move down the page.

If you set a control's CanGrow property to Yes, Microsoft Access automatically sets the CanGrow property of the section containing the control to Yes.

Sections grow vertically across their entire width. To grow the data independently, you can place two subform or subreport controls side by side, and set their CanGrow property to Yes.

When you use the CanGrow property, remember that:

  • The property settings don't affect the horizontal spacing between controls; they affect only the vertical space the controls occupy.

  • Overlapping controls can't grow.

Note Note

  • The CanGrow property does not apply to a form or report page header and page footer sections, although it does apply to controls in such sections.

  • This property affects the display of form sections and controls only when the form is printed or previewed, not when the form is displayed in Form view, Datasheet view, or Design view.

See also

Concepts

Section Object

Other resources

Section Object Members


Grandchild Aggregates

 Copy code hover
[image]

Grandchild Aggregates
Send feedback

The chapter column created in a clause of a shape command may be given a chapter-alias name (typically with the AS keyword). You may identify any column in any chapter of the shaped Recordset with a fully qualified name identifying the child containing the column. For example, if the parent chapter, chap1, contains a child chapter, chap2, that has an amount column, amt, then the qualified name would be chap1.chap2.amt. The qualified name may then be used as an argument to one of the aggregate functions (SUM, AVG, MAX, MIN, COUNT, STDEV, or ANY).


Report.MouseWheel Property (Access)

 Copy code hover
[image]

Report.MouseWheel Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the MouseWheel event occurs. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .MouseWheel

expression A variable that represents a Report object.

Remarks

Valid values for this property are "macroname", where macroname is the name of the macro; "[Event Procedure]", which indicates the event procedure associated with the BeforeInsert event for the specified object; or "=functionname()", where functionname is the name of a user-defined function.

See also

Concepts

Report Object

Other resources

Report Object Members


How to: Create Alternating Row Colors on a Report

 Copy code hover
[image]

How to: Create Alternating Row Colors on a Report
Send feedback

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 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.

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

    Me.Section("Detail").AlternateBackColor = RGB(240, 240, 240)

End Sub


DBEngine.SetOption Method (DAO)

 Copy code hover
[image]

DBEngine.SetOption Method (DAO)
Send feedback

Temporarily overrides values for the Microsoft Access database engine keys in the Windows Registry (Microsoft Access workspaces only).

Syntax

expression .SetOption(Option, Value)

expression An expression that returns a DBEngine object.

Parameters

Name | Required/Optional | Data Type | Description
Option | Required | Long | A constant as described in Remarks.
Value | Required | Variant | The value that you want to set option to.

Remarks

Each constant refers to the corresponding registry key in the path HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Access Connectivity Engine\Engines\ACE (that is, dbSharedAsyncDelay corresponds to the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Access Connectivity Engine\Engines\ACE\SharedAsyncDelay, and so on).

Constant | Description
dbPageTimeout | The PageTimeout key
dbSharedAsyncDelay | The SharedAsyncDelay key
dbExclusiveAsyncDelay | The ExclusiveAsyncDelay key
dbLockRetry | The LockRetry key
dbUserCommitSync | The UserCommitSync key
dbImplicitCommitSync | The ImplicitCommitSync key
dbMaxBufferSize | The MaxBufferSize key
dbMaxLocksPerFile | The MaxLocksPerFile key
dbLockDelay | The LockDelay key
dbRecycleLVs | The RecycleLVs key
dbFlushTransactionTimeout | The FlushTransactionTimeout key

Use the SetOption method to override registry values at run-time. New values established with the SetOption method remain in effect until changed again by another SetOption call, or until the DBEngine object is closed.


OptionButton.OldValue Property (Access)

 Copy code hover
[image]

OptionButton.OldValue Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.

Syntax

expression .OldValue

expression A variable that represents an OptionButton object.

Remarks

The OldValue property contains the unedited data from a bound control and is read-only in all views.

Microsoft Access uses the OldValue property to store the original value of a bound control. When you edit a bound control on a form, your changes aren't saved until you move to another record. The OldValue property contains the unedited version of the underlying data.

You can provide your own undo capability by assigning the OldValue property setting to a control. The following example shows how you can undo any changes to text box controls on a form:

VBA Copy code Copy code
Private Sub btnUndo_Click()

 Dim ctlTextbox As Control

 For Each ctlTextbox in Me.Controls
 If ctlTextbox.ControlType = acTextBox Then
 ctlTextbox.Value = ctl.OldValue
 End If
 Next ctlTextbox

End Sub

If the control hasn't been edited, this code has no effect. When you move to another record, the record source is updated, so the current value and the OldValue property will be the same.

The OldValue property setting has the same data type as the field to which the control is bound.

Example

The following example checks to determine if new data entered in a field is within 10 percent of the value of the original data. If the change is greater than 10 percent, the OldValue property is used to restore the original value. This procedure could be called from the BeforeUpdate event of the control that contains data you want to validate.

VBA Copy code Copy code
Public Sub Validate_Field()

 Dim curNewValue As Currency
 Dim curOriginalValue As Currency
 Dim curChange As Currency
 Dim strMsg As String

 curNewValue = Forms!Products!UnitPrice
 curOriginalValue = Forms!Products!UnitPrice.OldValue
 curChange = Abs(curNewValue - curOriginalValue)

 If curChange > (curOriginalValue * .1) Then
 strMsg = "Change is more than 10% of original unit price. " _
 & "Restoring original unit price."
 MsgBox strMsg, vbExclamation, "Invalid change."
 Forms!Products!UnitPrice = curOriginalValue
 End If

End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Syntax error (missing operator). (Error 2434)

 Copy code hover
[image]

Syntax error (missing operator). (Error 2434)
Send feedback

The expression or statement is missing an operator.


Try_Convert Function (Access 2013 custom web app)

 Copy code hover
[image]

Try_Convert Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Converts a value to a specified data type or returns Null if the conversion is not valid.

Syntax

Try_Convert (DataType, Expression)

The Try_Convert function contains the following arguments.

Argument name | Description
DataType | The data type into which to convert Expression.
Expression | The value to be converted.

Remarks

Try_Convert takes the value passed to it and tries to convert it to the specified DataType. If the conversion succeeds, Try_Convert returns the value as the specified DataType; if an error occurs, null is returned. However if you request a conversion that is explicitly not permitted, then Try_Convert fails with an error.


Rectangle Object (Access)

 Copy code hover
[image]

Rectangle Object (Access)
See also Send feedback

Published: July 16, 2012

This object corresponds to a rectangle control. The rectangle control displays a rectangle on a form or report.

Remarks

Control: | Tool:

You can move a rectangle and the controls in it as a single unit by dragging the mouse pointer diagonally across the entire rectangle to select all of the controls. The entire selection can then be moved to a new position.

See also

Concepts

Access Object Model Reference

Other resources

Rectangle Object Members


OptionGroup.AfterUpdate Event (Access)

 Copy code hover
[image]

OptionGroup.AfterUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The AfterUpdate event occurs after changed data in a control or record is updated.

Syntax

expression .AfterUpdate

expression A variable that represents an OptionGroup object.

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's AfterUpdate event does occur.

To run a macro or event procedure when this event occurs, set the AfterUpdate property to the name of the macro or to [Event Procedure].

This event does not apply to option buttons, check boxes, or toggle buttons in an option group. It applies only to the option group itself.

The AfterUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

AfterUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. AfterUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For bound controls, the OldValue property isn't set to the updated value until after the AfterUpdate event for the form occurs. Even if the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


WebBrowserControl.OnDocumentComplete Property (Access)

 Copy code hover
[image]

WebBrowserControl.OnDocumentComplete Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the value of the On Document Complete box in the property sheet os a Web Browser control. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnDocumentComplete

expression A variable that represents a WebBrowserControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


FormattedValue Property (ADO MD)

 Copy code hover
[image]

FormattedValue Property (ADO MD)
Send feedback

Indicates the formatted display of a cell value.

Return Values

Returns a String and is read-only.

Remarks

Use the FormattedValue property to obtain the formatted display value of the Value property of a Cell object. For example, if the value of a cell was 1056.87, and this value represented a dollar amount, FormattedValue would be $1,056.87.


This is not a valid name. Make sure it is a valid parameter or alias name, that it does not include invalid characters or punctuation, and that the name is not too long. (Error 3125)

 Copy code hover
[image]

This is not a valid name. Make sure it is a valid parameter or alias name, that it does not include invalid characters or punctuation, and that the name is not too long. (Error 3125)
Send feedback

The specified name does not follow standard naming conventions or is not a valid parameter or alias name. Check your entry to make sure you have not included invalid characters or punctuation and that the name is not too long.


TextBox.OnChange Property (Access)

 Copy code hover
[image]

TextBox.OnChange Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Change box in the Properties window of one of the objects in the Applies To list. Read/write String.

Syntax

expression .OnChange

expression A variable that represents a TextBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Change event occurs when the contents of a text box or the text portion of a combo box changes. It also occurs when you move from one page to another page in a tab control.

The OnChange value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Change box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Change box is blank, the property value is an empty string.

Example

The following example prints the value of the OnChange property in the Immediate window for the "Address" text box on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("Address").OnChange

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


FormatConditions.Delete Method (Access)

 Copy code hover
[image]

FormatConditions.Delete Method (Access)
See also Send feedback

Published: July 16, 2012

Deletes the specified object.

Syntax

expression .Delete

expression A variable that represents a FormatConditions object.

See also

Concepts

FormatConditions Collection

Other resources

FormatConditions Object Members


How to: Count the Number of Records in a DAO Recordset

 Copy code hover
[image]

How to: Count the Number of Records in a DAO Recordset
Send feedback

You may want to know the number of records in a Recordset object. For example, you may want to create a form that shows how many records are in each of the tables in a database. Or you may want to change the appearance of a form or report based on the number of records it includes.

The RecordCount property contains the number of records in a table-type Recordset or the total number of records accessed in a dynaset- or snapshot-type Recordset. A Recordset object with no records has a RecordCount property value of 0.

Note Note

The value of the RecordCount property equals the number of records that have actually been accessed. For example, when you first create a dynaset or snapshot, you have accessed (or visited) only one record. If you check the RecordCount property immediately after creating the dynaset or snapshot (assuming it has at least one record), the value is 1. To visit all the records, use the MoveLast method immediately after opening the Recordset, then use MoveFirst to return to the first record. This is not done automatically because it may be slow, especially for large result sets.

When you open a table-type Recordset object, you effectively visit all of the records in the underlying table, and the value of the RecordCount property equals the number of records in the table as soon as the Recordset is opened. Canceled transactions may make the value of the RecordCount property out-of-date in some multiuser situations. Compacting the database restores the table's record count to the correct value.

The following code example creates a snapshot-type Recordset object, and then determines the number of records in the Recordset.

VBA Copy code Copy code
Function FindRecordCount(strSQL As String) As Long

Dim dbsNorthwind As DAO.Database
Dim rstRecords As DAO.Recordset

On Error GoTo ErrorHandler

   Set dbsNorthwind = CurrentDb

   Set rstRecords = dbsNorthwind.OpenRecordset(strSQL)

   If rstRecords.EOF Then
      FindRecordCount = 0
   Else
      rstRecords.MoveLast
      FindRecordCount = rstRecords.RecordCount
   End If

   rstRecords.Close
   dbsNorthwind.Close

   Set rstRecords = Nothing
   Set dbsNorthwind = Nothing

Exit Function

ErrorHandler:
   MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Function

As your application deletes records in a dynaset-type Recordset, the value of the RecordCount property decreases. However, in a multiuser environment, records deleted by other users are not reflected in the value of the RecordCount property until the current record is positioned on a deleted record. At that time, the setting of the RecordCount property decreases by one. Using the Requery method on a Recordset, followed by the MoveLast method, sets the RecordCount property to the current total number of records in the Recordset.

A snapshot-type Recordset object is static and the value of its RecordCount property does not change when you add or delete records in the snapshot's underlying table.


Recordset.Properties Property (DAO)

 Copy code hover
[image]

Recordset.Properties Property (DAO)
Send feedback

Returns the Properties collection of the specified object. Read-only.

Syntax

expression .Properties

expression A variable that represents a Recordset object.


CustomControl.RightPadding Property (Access)

 Copy code hover
[image]

CustomControl.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .RightPadding

expression A variable that represents a CustomControl object.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


CheckBox.OnGotFocus Property (Access)

 Copy code hover
[image]

CheckBox.OnGotFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Got Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnGotFocus

expression A variable that represents a CheckBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The GotFocus event occurs when the object receives the focus.

The OnGotFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Got Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Got Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnGotFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnGotFocus

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


User Input

 Copy code hover
[image]

User Input
Send feedback

In this section

  • How to: Add a Value to a Bound Combo Box

  • How to: Determine Whether The Current Record is a New Record In a Form

  • How to: Display a Custom Dialog Box When the User Deletes a Record

  • How to: Perform Simple Data Validation Checks When Editing a Record in a Form

  • How to: Prompt a User Before Saving a Record

  • How to: Use User Input to Build Filter Criteria


Page.Application Property (Access)

 Copy code hover
[image]

Page.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a Page object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

Page Object

Other resources

Page Object Members


ImportExportSpecification Properties (Access)

 Copy code hover
[image]

ImportExportSpecification Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Description | Gets or sets a String that describes the specified ImportExportSpecification object. Read/write.
Name | Gets or sets the name of the specified ImportExportSpecification object. Read/write String.
Parent | Returns the parent object for the specified object. Read-only Object.
XML | Gets or sets the Extensible Markup Language (XML) string that defines an ImportExportSpecification object. Read/write String.


DefinedSize Property Example (VC++)

 Copy code hover
[image]

DefinedSize Property Example (VC++)
Send feedback

This example demonstrates the DefinedSize property of a Column. The code will redefine the size of the FirstName column of the Employees table of the Northwind database. Then, the change in the values of the FirstName Field of a Recordset based on the Employees table is displayed. Note that by default, the FirstName field becomes padded with spaces after you redefine the DefinedSize property.

Copy code Copy code

// BeginDefinedSizeCpp
#import "c:\Program Files\Common Files\system\ado\msadox.dll" no_namespace
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" rename("EOF", "EndOfFile")

#include "iostream.h"
#include "stdio.h"
#include "conio.h"

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void DefinedSizeX(void);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 DefinedSizeX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// DefinedSizeX Function //
// //
//////////////////////////////////////////////////////////
void DefinedSizeX(void)
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.
 _CatalogPtr m_pCatNorthwind = NULL;
 _ColumnPtr m_pColFirstName = NULL;
 _ColumnPtr m_pColNewFirstName = NULL;

 // Define ADODB object pointers
 ADODB::_RecordsetPtr m_pRstEmployees = NULL;

 // Define string variables.
 _bstr_t strCnn("Provider='Microsoft.JET.OLEDB.4.0';data source="
 "'c:\\Program Files\\Microsoft Office\\Office\\Samples\\"
 "Northwind.mdb';");
 _bstr_t aryFirstName[10];

 try
 {
 // Open a Recordset for the Employees table.
 TESTHR(hr = m_pRstEmployees.CreateInstance(
 __uuidof(ADODB::Recordset)));
 TESTHR(hr = m_pCatNorthwind.CreateInstance(__uuidof (Catalog)));
 TESTHR(hr = m_pColNewFirstName.CreateInstance(__uuidof(Column)));

 m_pRstEmployees->Open("Employees",strCnn,ADODB::adOpenKeyset,
 ADODB::adLockReadOnly,ADODB::adCmdTable);

 long lngSize = m_pRstEmployees->RecordCount;
 aryFirstName[lngSize];

 // Open a catalog for the Northwind database,
 // using same connection as rstEmployees.
 m_pCatNorthwind->PutActiveConnection(m_pRstEmployees->
 GetActiveConnection());

 // Loop through the recordset displaying the contents,
 // of the FirstName field, the field's defined size,
 // and its actual size.
 // Also store FirstName values in aryFirstName array.
 m_pRstEmployees->MoveFirst();
 printf("\nOriginal Defined Size and Actual Size");
 int iCount=0;
 while (!(m_pRstEmployees->EndOfFile))
 {
 printf("\nEmployee Name:");
 printf("%s ",(LPSTR)(_bstr_t)m_pRstEmployees->Fields->
 GetItem("FirstName")->Value);
 printf("%s\n",(LPSTR)(_bstr_t)m_pRstEmployees->Fields->
 GetItem("LastName")->Value);
 printf(" FirstName Defined size: %d\n",m_pRstEmployees->
 Fields->GetItem("FirstName")->DefinedSize) ;
 printf(" FirstName Actual size: %d\n",m_pRstEmployees->
 Fields->GetItem("FirstName")->ActualSize);
 aryFirstName[iCount] = (_bstr_t) m_pRstEmployees->Fields->
 GetItem("FirstName")->Value;
 m_pRstEmployees->MoveNext();
 iCount++;
 if(iCount%5==0)
 {
 printf("Press any key to continue...");
 getch();
 system("cls");
 }
 }
 m_pRstEmployees->Close();

 // Redefine the DefinedSize of FirstName in the catalog.
 m_pColFirstName = m_pCatNorthwind->Tables->GetItem("Employees")->
 Columns->GetItem("FirstName");
 m_pColNewFirstName->Name = m_pColFirstName->Name;
 m_pColNewFirstName->Type = m_pColFirstName->Type;
 m_pColNewFirstName->DefinedSize =
 (m_pColFirstName->DefinedSize) + 1;

 // Append new FirstName column to catalog.
 m_pCatNorthwind->Tables->GetItem("Employees")->Columns->
 Delete(m_pColFirstName->Name);
 m_pCatNorthwind->Tables->GetItem("Employees")->Columns->
 Append(_variant_t((IDispatch*)m_pColNewFirstName,true),
 adVarWChar,m_pColNewFirstName->DefinedSize);

 // Open Employee table in Recordset for updating.
 m_pRstEmployees->Open("Employees",m_pCatNorthwind->
 GetActiveConnection(),ADODB::adOpenKeyset,
 ADODB::adLockOptimistic,ADODB::adCmdTable);

 // Loop through the recordset displaying the contents
 // of the FirstName field,the field's defined size,
 // and its actual size.
 // Also restore FirstName values from aryFirstName.
 printf("Press any key to continue...");
 getch();
 system("cls");
 m_pRstEmployees->MoveFirst();
 printf("\n\nNew Defined Size and Actual Size");
 iCount=0;
 while (!(m_pRstEmployees->EndOfFile))
 {
 m_pRstEmployees->Fields->GetItem("FirstName")->Value =
 aryFirstName[iCount];
 printf("\nEmployee Name: ");
 printf("%s ",(LPSTR) (_bstr_t)m_pRstEmployees->Fields->
 GetItem("FirstName")->Value);
 printf("%s\n",(LPSTR)(_bstr_t)m_pRstEmployees->Fields->
 GetItem("LastName")->Value);
 printf(" FirstName Defined size: %d\n",m_pRstEmployees->
 Fields->GetItem("FirstName")->DefinedSize );
 printf(" FirstName Actual size: %d\n",m_pRstEmployees->
 Fields->GetItem("FirstName")->ActualSize );
 m_pRstEmployees->MoveNext();
 iCount++;
 if(iCount%5==0)
 {
 printf("Press any key to continue...");
 getch();
 system("cls");
 }
 }
 m_pRstEmployees->Close();

 // Restore original FirstName column to catalog
 m_pCatNorthwind->Tables->GetItem("Employees")->Columns->
 Delete(m_pColNewFirstName->Name);

 m_pCatNorthwind->Tables->GetItem("Employees")->Columns->
 Append(_variant_t((IDispatch*)m_pColFirstName,true),
 adVarWChar,m_pColFirstName->DefinedSize);

 // Restore original FirstName values to Employees table.
 m_pRstEmployees->Open("Employees",m_pCatNorthwind->
 GetActiveConnection(),ADODB::adOpenKeyset,
 ADODB::adLockOptimistic,ADODB::adCmdTable);

 m_pRstEmployees->MoveFirst();
 iCount = 0;
 while(!(m_pRstEmployees->EndOfFile))
 {
 m_pRstEmployees->Fields->GetItem("FirstName")->Value =
 aryFirstName[iCount];
 m_pRstEmployees->MoveNext();
 iCount++;
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }
 catch(...)
 {
 cout << "Error occured in DefinedSizeX...."<< endl;
 }

 if (m_pRstEmployees)
 if (m_pRstEmployees->State == 1)
 m_pRstEmployees->Close();

 m_pCatNorthwind = NULL;
}
// EndDefinedSizeCpp


CheckBox.OnKeyDown Property (Access)

 Copy code hover
[image]

CheckBox.OnKeyDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Down box in the Properties window. Read/write String.

Syntax

expression .OnKeyDown

expression A variable that represents a CheckBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyDown event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyDown

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


ListBox.Recordset Property (Access)

 Copy code hover
[image]

ListBox.Recordset Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets the ADO Recordset or DAO Recordset object representing the record source for the specified object. Read/write Object.

Syntax

expression .Recordset

expression A variable that represents a ListBox object.

Remarks

The Recordset property returns the recordset object that provides the data being browsed in a form, report, list box control, or combo box control. If a form is based on a query, for example, referring to the Recordset property is the equivalent of cloning a Recordset object by using the same query. However, unlike using the RecordsetClone property, changing which record is current in the recordset returned by the form's Recordset property also sets the current record of the form.

The read/write behavior of the Recordset property is determined by the type of recordset (ADO or DAO) and the type of data (Access or SQL) contained in the recordset identified by the property.

Recordset type | Based on SQL data | Based on data stored by the Access database engine
ADO | Read/Write | Read/Write
DAO | N/A | Read/Write

The following example opens a form, opens a recordset, and then binds the form to the recordset by setting the form's Recordset property to the newly created Recordset object.

VBA Copy code Copy code
Global rstSuppliers As ADODB.Recordset
Sub MakeRW()
    DoCmd.OpenForm "Suppliers"
    Set rstSuppliers = New ADODB.Recordset
    rstSuppliers.CursorLocation = adUseClient
    rstSuppliers.Open "Select * From Suppliers", _
         CurrentProject.Connection, adOpenKeyset, adLockOptimistic
    Set Forms("Suppliers").Recordset = rstSuppliers
End Sub

Use the Recordset property:

  • To use methods with the Recordset object that aren't directly supported on forms. For example, you can use the Recordset property with the ADO Find or DAO Find methods in a custom dialog for finding a record.

  • To wrap a transaction (which can be rolled back) around a set of edits that affect multiple forms.

Changing a form's Recordset property may also change the RecordSource, RecordsetType, and RecordLocks properties. Also, some data-related properties may be overridden, for example, the Filter, FilterOn, OrderBy, and OrderByOn properties.

Calling the Requery method of a form's recordset (for example, Forms(0).Recordset.Requery) can cause the form to become unbound. To refresh the data in a form bound to a recordset, set the RecordSource property of the form to itself (Forms(0).RecordSource = Forms(0).RecordSource).

  • To bind multiple forms to a common data set. This allows synchronization of multiple forms. For example,

VBA Copy code Copy code
   Set Me.Recordset = Forms!Form1.Recordset

When a form is bound to a recordset, an error occurs if you use the Filter by Form command.

Example

The following example uses the Recordset property to create a new copy of the Recordset object from the current form and then prints the names of the fields in the Debug window.

VBA Copy code Copy code
Sub Print_Field_Names()
    Dim rst As DAO.Recordset, intI As Integer
    Dim fld As Field

    Set rst = Me.Recordset
    For Each fld in rst.Fields
        ' Print field names.
        Debug.Print fld.Name
    Next
End Sub

The next example uses the Recordset property and the Recordset object to synchronize a recordset with the form's current record. When a company name is selected from a combo box, the FindFirst method is used to locate the record for that company, causing the form to display the found record.

VBA Copy code Copy code
Sub SupplierID_AfterUpdate()
    Dim rst As DAO.Recordset
    Dim strSearchName As String

    Set rst = Me.Recordset
    strSearchName = CStr(Me!SupplierID)
    rst.FindFirst "SupplierID = " & strSearchName
    If rst.NoMatch Then
        MsgBox "Record not found"
    End If
    rst.Close
End Sub

The following code helps to determine what type of recordset is returned by the Recordset property under different conditions.

VBA Copy code Copy code
Sub CheckRSType()
    Dim rs as Object

    Set rs=Forms(0).Recordset
    If TypeOf rs Is DAO.Recordset Then
        MsgBox "DAO Recordset"
    ElseIf TypeOf rs is ADODB.Recordset Then
        MsgBox "ADO Recordset"
    End If
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


CurrentData.AllStoredProcedures Property (Access)

 Copy code hover
[image]

CurrentData.AllStoredProcedures Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllStoredProcedures property to reference the AllStoredProcedures collection and its related properties. Read-only AllStoredProcedures object.

Syntax

expression .AllStoredProcedures

expression A variable that represents a CurrentData object.

See also

Concepts

CurrentData Object

Other resources

CurrentData Object Members


ToggleButton.HoverColor Property (Access)

 Copy code hover
[image]

ToggleButton.HoverColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color displayed on the control when the user rests the mouse cursor over it. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HoverColor

expression A variable that represents a ToggleButton object.

Remarks

The HoverColor property contains a numeric expression that represents the value of the text color in the control.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom colors.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Line.InSelection Property (Access)

 Copy code hover
[image]

Line.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents a Line object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

Line Object

Other resources

Line Object Members


CheckBox.AfterUpdate Property (Access)

 Copy code hover
[image]

CheckBox.AfterUpdate Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets which macro, event procedure, or user-defined function runs when the AfterUpdate event occurs. Read/write String.

Syntax

expression .AfterUpdate

expression A variable that represents a CheckBox object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the AfterUpdate event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the AfterUpdate event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).AfterUpdate = "[Event Procedure]"

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Table

 Copy code hover
[image]

Table <name> already exists. (Error 3010)
Send feedback

You tried to create or rename a table with a name that already exists in this database. Choose another name, and then try the operation again.

In a multiuser database, this error can also occur if you delete a table, another user creates a table with the same name, and then you try to roll back the deletion of your table. To restore your table, the other user must first delete or rename the new table before you try the rollback operation again.


Configuring RDS on Windows 2000

 Copy code hover
[image]

Configuring RDS on Windows 2000
Send feedback

If you experience difficulties getting RDS to function properly after upgrading to Windows 2000, follow the steps below to troubleshoot the issue.

  1. Make sure that the World Wide Web Publishing Service is running first by navigating to http://server using Internet Explorer. If you are unable to access the web server this way, go to a command prompt and enter the following command, "NET START W3SVC".

  2. From the Start menu, select Run. Type msdfmap.ini and click OK to open the msdfmap.ini file in Notepad. Check the [CONNECT DEFAULT] section, and if the ACCESS parameter is set to NOACCESS, change it to READONLY.

  3. Using the RegEdit utility, navigate to "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DataFactory\HandlerInfo" and make sure HandlerRequired is set to 0 and DefaultHandler is "" (Null string).

    Note Note

    If you make any changes to this section of the registry, you must stop and restart the World Wide Web Publishing Service by entering the following commands at a command prompt: "NET STOP W3SVC" and "NET START W3SVC".

  4. Using the RegEdit utility, navigate in the registry to "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\ADCLaunch" and verify that there is a key called RDSServer.Datafactory. If not, create it.

  5. Using Internet Services Manager, go to the Default Web Site and view the properties of the MSADC virtual root. Inspect the Directory Security/IP Address and Domain Name Restrictions. If the "Access is Denied" is checked then select "Granted".

Be sure to try rebooting the server if the changes to do not appear to solve the problem at first.


DoCmd.SearchForRecord Method (Access)

 Copy code hover
[image]

DoCmd.SearchForRecord Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SearchForRecord method to search for a specific record in a table, query, form, or report.

Syntax

expression .SearchForRecord(ObjectType, ObjectName, Record, WhereCondition)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
ObjectType | Optional | AcDataObjectType | An AcDataObjectType constant that specifies the type of database object in which you are searching. The default value is acActiveDataObject.
ObjectName | Optional | Variant | The name of the database object that contains the record to search for.
Record | Optional | AcRecord | An AcRecord constant that specifies the starting point and direction of the search. The default value is acFirst.
WhereCondition | Optional | Variant | A string used to locate the record. It is like the WHERE clause in an SQL statement, but without the word WHERE.

Remarks

  • In cases where more than one record matches the criteria in the WhereCondition argument, the following factors determine which record is found:

    • The Record argument setting.

    • The sort order of the records. For example, if the Record argument is set to acFirst, changing the sort order of the records might change which record is found.

  • The object specified in the ObjectName argument must be open before this action is run. Otherwise, an error occurs.

  • If the criteria in the WhereCondition argument are not met, no error occurs and the focus remains on the current record.

  • When searching for the previous or next record, the search does not "wrap" when it reaches the end of the data. If there are no further records that match the criteria, no error occurs and the focus remains on the current record. To confirm that a match was found, you can enter a condition for the next action, and make the condition the same as the criteria in the WhereCondition argument.

  • The SearchForRecord method is similar to the FindRecord method, but SearchForRecord has more powerful search features. The FindRecord method is primarily used for finding strings, and it duplicates the functionality of the Find dialog box. The SearchForRecord method uses criteria that are more like those of a filter or an SQL query. The following list demonstrates some things you can do with the SearchForRecord method:

    • You can use complex criteria in the WhereCondition argument, such as Description = "Beverages" and CategoryID = 11

    • You can refer to fields that are in the record source of a form or report but are not displayed on the form or report. In the preceding example, neither Description nor CategoryID must be displayed on the form or report for the criteria to work.

    • You can use logical operators, such as <, >, AND, OR, and BETWEEN. The FindRecord method only matches strings that equal, start with, or contain the string being searched for.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


FormatCondition.FontItalic Property (Access)

 Copy code hover
[image]

FormatCondition.FontItalic Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontItalic property to specify whether text is italic in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontItalic

expression A variable that represents a FormatCondition object.

Remarks

The FontItalic property uses the following settings.

Setting | Description
True | The text is italic.
False | (Default) The text isn't italic.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

FormatCondition Object

Other resources

FormatCondition Object Members


Report.OnActivate Property (Access)

 Copy code hover
[image]

Report.OnActivate Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Activate box in the Properties window of a form or report. Read/write String.

Syntax

expression .OnActivate

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Activate event occurs when the form or report receives the focus and becomes the active window.

The OnActivate value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Activate box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Activate box is blank, the property value is an empty string.

Example

The following example associates the Activate event with the macro "Activate_Macro" for the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").OnActivate = "Activate_Macro"

See also

Concepts

Report Object

Other resources

Report Object Members


NavigationControl.Layout Property (Access)

 Copy code hover
[image]

NavigationControl.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified text box. Read-only AcLayoutType.

Version Information

Version Added: Access 2010

Syntax

expression .Layout

expression A variable that represents a NavigationControl object.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


ObjectFrame.OLEType Property (Access)

 Copy code hover
[image]

ObjectFrame.OLEType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OLEType property to determine if a control contains an OLE object, and, if so, whether the object is linked or embedded. Read/write Byte.

Syntax

expression .OLEType

expression A variable that represents an ObjectFrame object.

Remarks

The OLEType property uses the following settings.

Setting | Constant | Description
Linked | acOLELinked | The control contains a linked object. All the object's data is managed by the application that created it.
Embedded | acOLEEmbedded | The control contains an embedded object. All the object's data is managed by Microsoft Access.
None | acOLENone | The control doesn't contain an OLE object.

When creating an OLE object, use the OLETypeAllowed property to determine what type of object a control can contain.

Example

The following example illustrates how to display the Insert Object dialog box and how to display an error message if the Cancel button in the Insert Object dialog box is clicked.

VBA Copy code Copy code
Sub InsertObject_Click()
 Dim conUserCancelled As Integer

 ' Error message returned when user cancels.
 conUserCancelled = 2001
 On Error GoTo ButtonErr
 If OLE1.OLEType = acOLENone Then
 ' No OLE object created.
 ' Display Insert Object dialog box.
 OLE1.Action = acOLEInsertObjDlg
 End If
 Exit Sub

ButtonErr:
 If Err = conUserCancelled Then ' Display message.
 MsgBox "You clicked the Cancel button; " _
 & "no object was created."
 End If
 Resume Next
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Page.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

Page.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Syntax

expression .ShortcutMenuBar

expression A variable that represents a Page object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

Example

The following example sets the "Suppliers_Toolbar" as the custom shortcut menu to display when the user clicks the right mouse button on the "Suppliers" form.

VBA Copy code Copy code
Forms("Suppliers").ShortcutMenuBar = "Suppliers_Toolbar"

See also

Concepts

Page Object

Other resources

Page Object Members


DataSpace Object (RDS) (ADO)

 Copy code hover
[image]

DataSpace Object (RDS) (ADO)
Send feedback

In this section

  • DataSpace Object (RDS)

  • DataSpace Properties, Methods, and Events (RDS)


Too many active users. (Error 3239)

 Copy code hover
[image]

Too many active users. (Error 3239)
Send feedback

In a multiuser environment, Microsoft Access database engine databases support up to 255 concurrent users. Wait for one or more users to stop using the system, and then try the operation again.


CurrentProject.FileFormat Property (Access)

 Copy code hover
[image]

CurrentProject.FileFormat Property (Access)
See also Send feedback

Published: July 16, 2012

Returns an AcFileFormat constant indicating the Microsoft Access version format of the specified project. Read-only.

Syntax

expression .FileFormat

expression A variable that represents a CurrentProject object.

Remarks

Use the ConvertAccessProject method to convert an Access project from one version to another.

Example

This example evaluates the current project and displays a message indicating to which version of Microsoft Access its file format corresponds.

VBA Copy code Copy code
Dim strFormat As String

Select Case CurrentProject.FileFormat
 Case acFileFormatAccess2
 strFormat = "Microsoft Access 2"
 Case acFileFormatAccess95
 strFormat = "Microsoft Access 95"
 Case acFileFormatAccess97
 strFormat = "Microsoft Access 97"
 Case acFileFormatAccess2000
 strFormat = "Microsoft Access 2000"
 Case acFileFormatAccess2002
 strFormat = "Access 2002 - 2003"
 Case acFileFormatAccess12
 strFormat = "Microsoft Access 2007"
End Select

MsgBox "This is a " & strFormat & " project."

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


Invalid Century setting in the Xbase key of the Windows Registry. (Error 3227)

 Copy code hover
[image]

Invalid Century setting in the Xbase key of the Windows Registry. (Error 3227)
Send feedback

There is an invalid Century setting in the Xbase key of the Microsoft Windows Registry.

To fix the Century setting

  1. Exit your application.

  2. Start the Registry Editor, navigate to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Access Connectivity Engine\Engines\Xbase key, and select the Century value.

  3. On the Edit menu, click Modify.

  4. Correct the Century data in the Value data box.

  5. Restart your application, and then try the operation again.


Updating Data (ADO)

 Copy code hover
[image]

Updating Data (ADO)
Send feedback

In this section

  • Updating Data

  • Immediate Mode

  • Transaction Processing

  • Batch Mode (ADO)


Application.Modules Property (Access)

 Copy code hover
[image]

Application.Modules Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Modules property to access the Modules collection and its related properties. Read-only Modules object.

Syntax

expression .Modules

expression A variable that represents an Application object.

Remarks

Use the properties of the Modules collection in Visual Basic to refer to all open standard modules and class modules.

Example

The following example uses the Module property to insert the Beep method in a form's Open event.

VBA Copy code Copy code
Dim strFormOpenCode As String
Dim mdl As Module

Set mdl = Forms!MyForm.Module
strFormOpenCode = "Sub Form_Open(Cancel As Integer)" _
 & vbCrLf & "Beep" & vbCrLf & "End Sub"
 With mdl
 .InsertText strFormOpenCode
 End With

See also

Concepts

Application Object

Other resources

Application Object Members


BoundObjectFrame.Updated Event (Access)

 Copy code hover
[image]

BoundObjectFrame.Updated Event (Access)
See also Send feedback

Published: July 16, 2012

The Updated event occurs when an OLE object's data has been modified.

Syntax

expression .Updated(Code)

expression A variable that represents a BoundObjectFrame object.

Remarks

To run a macro or event procedure when this event occurs, set the OnUpdated property to the name of the macro or to [Event Procedure].

You can use this event to determine if an object's data has been changed since it was last saved.

The Updated event occurs when the data in an OLE object has been modified. This update can come from the application in which the object was created or from one of the linked copies of this object. As a result, this event is asynchronous with other Microsoft Access control events.

Note Note

The Updated event and the BeforeUpdate and AfterUpdate events for bound and unbound object frames are not related. The Updated event occurs when an OLE object's data is changed, and the BeforeUpdate and AfterUpdate events occur when data is updated. Although not related, all three events usually occur when an OLE object's data is changed. The Updated event generally occurs before the BeforeUpdate and AfterUpdate events; however, this may not happen every time.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Required Providers for Data Shaping

 Copy code hover
[image]

Required Providers for Data Shaping
Send feedback

Data shaping typically requires two providers. The service provider, Data Shaping Service for OLE DB, supplies the data shaping functionality, and a data provider, such as the OLE DB Provider for SQL Server, supplies rows of data to populate the shaped Recordset.

The name of the service provider (MSDataShape) can be specified as the value of the Connection object Provider property or the connection string keyword "Provider=MSDataShape;".

The name of the data provider can be specified as the value of the Data Provider dynamic property, which is added to the Connection object Properties collection by the Data Shaping Service for OLE DB, or the connection string keyword "Data Provider=provider".

No data provider is required if the Recordset is not populated (for example, as in a fabricated Recordset where columns are created with the NEW keyword). In that case, specify "Data Provider=none;".

Example

Copy code Copy code

Dim cnn As New ADODB.Connection
cnn.Provider = "MSDataShape"
cnn.Open "Data Provider=SQLOLEDB;Integrated Security=SSPI;Database=Northwind"


Workspaces Object Reference (DAO)

 Copy code hover
[image]

Workspaces Object Reference (DAO)
Send feedback

In this section

  • Workspaces Collection (DAO)

  • Workspaces Members (DAO)

  • Workspaces Properties (DAO)

  • Workspaces Methods (DAO)


Control.OldValue Property (Access)

 Copy code hover
[image]

Control.OldValue Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.

Syntax

expression .OldValue

expression A variable that represents a Control object.

Remarks

The OldValue property contains the unedited data from a bound control and is read-only in all views.

Microsoft Access uses the OldValue property to store the original value of a bound control. When you edit a bound control on a form, your changes aren't saved until you move to another record. The OldValue property contains the unedited version of the underlying data.

You can provide your own undo capability by assigning the OldValue property setting to a control. The following example shows how you can undo any changes to text box controls on a form:

VBA Copy code Copy code
Private Sub btnUndo_Click()

 Dim ctlTextbox As Control

 For Each ctlTextbox in Me.Controls
 If ctlTextbox.ControlType = acTextBox Then
 ctlTextbox.Value = ctl.OldValue
 End If
 Next ctlTextbox

End Sub

If the control hasn't been edited, this code has no effect. When you move to another record, the record source is updated, so the current value and the OldValue property will be the same.

The OldValue property setting has the same data type as the field to which the control is bound.

Example

The following example checks to determine if new data entered in a field is within 10 percent of the value of the original data. If the change is greater than 10 percent, the OldValue property is used to restore the original value. This procedure could be called from the BeforeUpdate event of the control that contains data you want to validate.

VBA Copy code Copy code
Public Sub Validate_Field()

 Dim curNewValue As Currency
 Dim curOriginalValue As Currency
 Dim curChange As Currency
 Dim strMsg As String

 curNewValue = Forms!Products!UnitPrice
 curOriginalValue = Forms!Products!UnitPrice.OldValue
 curChange = Abs(curNewValue - curOriginalValue)

 If curChange > (curOriginalValue * .1) Then
 strMsg = "Change is more than 10% of original unit price. " _
 & "Restoring original unit price."
 MsgBox strMsg, vbExclamation, "Invalid change."
 Forms!Products!UnitPrice = curOriginalValue
 End If

End Sub

See also

Concepts

Control Object

Other resources

Control Object Members


ComboBox.LayoutID Property (Access)

 Copy code hover
[image]

ComboBox.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified combo box. Read-only Long.

Version Information

Version Added: Access 2007

Syntax

expression .LayoutID

expression A variable that represents a ComboBox object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


NavigationControl.Undo Event (Access)

 Copy code hover
[image]

NavigationControl.Undo Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when the user undoes a change.

Version Information

Version Added: Access 2010

Syntax

expression .Undo(Cancel, )

expression A variable that represents a NavigationControl object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer |

Return Value

nothing

Remarks

The Undo event for controls occurs whenever the user returns a control to its original state by clicking the Undo Field/Record button on the command bar, clicking the Undo button, pressing the ESC key, or calling the Undo method of the specified control. The control needs to have focus in all three cases. The event does not occur if the user clicks the Undo Typing button on the command bar.

Example

The following example demonstrates the syntax for a subroutine that traps the Undo event for a form.

VBA Copy code Copy code
Private Sub Form_Undo(Cancel As Integer)
 Dim intResponse As Integer
 Dim strPrompt As String

 strPrompt = "Cancel the undo operation?"

 intResponse = MsgBox(strPrompt, vbYesNo)

 If intResponse = vbYes Then
 Cancel = True
 Else
 Cancel = False
 End If
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Pass-through query with ReturnsRecords property set to True did not return any records. (Error 3325)

 Copy code hover
[image]

Pass-through query with ReturnsRecords property set to True did not return any records. (Error 3325)
Send feedback

A pass-through query did not return any records even though the ReturnsRecords property is set to True. If a pass-through query does not return records, set the ReturnsRecords property to False.


Form.GridX Property (Access)

 Copy code hover
[image]

Form.GridX Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the GridX property (along with the GridY property) to specify the horizontal and vertical divisions of the alignment grid in form Design view. Read/write Integer.

Syntax

expression .GridX

expression A variable that represents a Form object.

Remarks

Enter an integer between 1 and 64 representing the number of subdivisions per unit of measurement. If the Measurement system box is set to U.S. on the Numbers tab of the Regional Options dialog box of Windows Control Panel, the default setting is 24 for the GridX property (horizontal) and 24 for the GridY property (vertical).

In Visual Basic, you set this property by using a numeric expression.

The GridX and GridY properties provide control over the placement and alignment of objects on a form or report. You can adjust the grid for greater or lesser precision. To see the grid, click Grid on the View menu. If the setting for either the GridX or GridY properties is greater than 24, the grid points disappear from view (although the grid lines are still displayed).

See also

Concepts

Form Object

Other resources

Form Object Members


AcExportXMLOtherFlags Enumeration (Access)

 Copy code hover
[image]

AcExportXMLOtherFlags Enumeration (Access)
Send feedback

Published: July 16, 2012

Use with the ExportXML method to specify other behaviors associated with exporting to XML.

Name | Value | Description
acEmbedSchema | 1 | Writes schema information into the document specified by the DataTarget argument; this value takes precedence over the SchemaTarget argument.
acExcludePrimaryKeyAndIndexes | 2 | Does not export primary key and index schema properties.
acExportAllTableAndFieldProperties | 32 | The exported schema contains porperties of the table and its fields.
acLiveReportSource | 8 | Creates a live link to a remote Microsoft SQL Server 2000 database. Valid only when you are exporting reports that are bound to a Microsoft SQL Server 2000 database.
acPersistReportML | 16 | Persists the exported object's ReportML information.
acRunFromServer | 4 | Creates an Active Server Pages (ASP) wrapper; otherwise, default is an HTML wrapper. Applies only when you are exporting reports.


ODBCTimeout Property

 Copy code hover
[image]

ODBCTimeout Property
Send feedback

Published: July 16, 2012

You can use the ODBCTimeout property to specify the number of seconds Microsoft Access waits before a time-out error occurs when a query is run on an Open Database Connectivity (ODBC) database.

Setting

The ODBCTimeout property is an Integer value representing the number of seconds Microsoft Access waits. The default is 60 seconds. When this property is set to 0, no time-out error occurs.

You can set this property by using the query's property sheet or Data Access Objects (DAO) in Visual Basic code.

Remarks

When you're using an ODBC database, such as Microsoft SQL Server, there may be delays due to network traffic or heavy use of the ODBC server. The ODBCTimeout property lets you specify how long Microsoft Access waits for a network connection before a time-out error occurs.


Cannot open any more files. (Error 3025)

 Copy code hover
[image]

Cannot open any more files. (Error 3025)
Send feedback

You have reached the limit on the number of files that can be opened at one time. Close one or more files, and then try the operation again.


Cannot open any more databases. (Error 3048)

 Copy code hover
[image]

Cannot open any more databases. (Error 3048)
Send feedback

You have reached the limit on the number of databases that can be opened at one time. Close one or more databases and try the operation again.


References.Remove Method (Access)

 Copy code hover
[image]

References.Remove Method (Access)
See also Send feedback

Published: July 16, 2012

The Remove method removes a Reference object from the References collection.

Syntax

expression .Remove(Reference)

expression A variable that represents a References object.

Parameters

Name | Required/Optional | Data Type | Description
Reference | Required | Reference | The Reference object that represents the reference you wish to remove.

Remarks

To determine the name of the Reference object you wish to remove, check the Project/Library box in the Object Browser. The names of all references that are currently set appear there. These names correspond to the value of the Name property of a Reference object.

See also

Concepts

References Collection

Other resources

References Object Members


NumericScale Property (ADOX)

 Copy code hover
[image]

NumericScale Property (ADOX)
Send feedback

Indicates the scale of a numeric value in the column.

Settings and Return Values

Sets and returns a Byte value that is the scale of data values in the column when the Type property is adNumeric or adDecimal. NumericScale is ignored for all other data types.

Remarks

The default value is zero (0).

NumericScale is read-only for Column objects already appended to a collection.


ComboBox.AllowAutoCorrect Property (Access)

 Copy code hover
[image]

ComboBox.AllowAutoCorrect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllowAutoCorrect property to specify whetherthe specified control will automatically correct entries made by the user. Read/write Boolean.

Syntax

expression .AllowAutoCorrect

expression A variable that represents a ComboBox object.

Remarks

The AllowAutoCorrect property uses the following settings.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


NavigationButton.StatusBarText Property (Access)

 Copy code hover
[image]

NavigationButton.StatusBarText Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .StatusBarText

expression A variable that represents a NavigationButton object.

Remarks

You set the StatusBarText property by using a string expression up to 255 characters long.

Note Note

The length of the text you can display in the status bar depends on your computer hardware and video display.

You can use the StatusBarText property to provide specific information about a control. For example, when a text box has the focus, a brief instruction can tell the user what kind of data to enter

Note Note

You can also use the ControlTipText property to display a ScreenTip for a control.

If you create a control by dragging a field from the field list, the value in a field's Description property is copied to the StatusBarText property.

Example

The following example sets the status bar text to be displayed when the "Address_TextBox" control in the "Mailing List" form has the focus in Form View.

VBA Copy code Copy code
Forms("Mailing List").Controls("Address_TextBox"). _
 StatusBarText = "Enter the company's mailing address."

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


CommandButton.SetFocus Method (Access)

 Copy code hover
[image]

CommandButton.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Syntax

expression .SetFocus

expression A variable that represents a CommandButton object.

Return Value

Nothing

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.

Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.

Example

The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:

VBA Copy code Copy code
Forms!Employees!EmployeeID.SetFocus

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


ObjectFrame.Scaling Property (Access)

 Copy code hover
[image]

ObjectFrame.Scaling Property (Access)
See also Send feedback

Published: July 16, 2012

Controls how the contents of an object frame control are displayed. Read/write Byte.

Syntax

expression .Scaling

expression A variable that represents an ObjectFrame object.

Remarks

The Scaling property corresponds to the Size Mode box in the object frame's Properties window. This property accepts the following values.

  • 0 (Clip) If the object exceeds the control's boundaries, the object is clipped at the boundaries of the control.

  • 1 (Stretch) If the object does not exceed the control's boundaries, the object is stretched to the edges of the control's boundary.

  • 2 (Zoom) The object is zoomed in or out to fit the control's boundaries. This is different from the Stretch setting, in that the object is not necessarily distorted to touch all boundaries of the control. In other words, the object may touch the horizontal edges of the control, but not necessarily the vertical edges of the control, and vice versa.

Example

The following example sets the size mode of the OLE control "Customer Picture" on the "Order Entry" form to zoomed.

VBA Copy code Copy code
Forms("Order Entry").Controls("Customer Picture").Scaling = 2

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


OptionGroup.ControlType Property (Access)

 Copy code hover
[image]

OptionGroup.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Syntax

expression .ControlType

expression A variable that represents an OptionGroup object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


ParentURL Property (ADO)

 Copy code hover
[image]

ParentURL Property (ADO)
Send feedback

Indicates an absolute URL string that points to the parent Record of the current Record object.

Return Value

Returns a String value that indicates the URL of the parent Record.

Remarks

The ParentURL property depends upon the source used to open the Record object. For example, the Record may be opened with a source containing a relative path name of a directory referenced by the ActiveConnection property.

Suppose "second" is a folder contained under "first". Open the Record object with the following:

Copy code Copy code
record.ActiveConnection = "http://first"
record.Open "second"

Now, the value of the ParentURL property is ParentURL property is "http://first" , the same as ActiveConnection.

The source may also be an absolute URL such as, "http://first/second" . The ParentURL property is then "http://first" , the level above . The ParentURL property is then "http://first" , the level above "second" .

This property may be a null value if:

  • There is no parent for the current object; for example, if the Record object represents the root of a directory.

  • The Record object represents an entity that cannot be specified with a URL.

This property is read-only.

Note Note

This property is only supported by document source providers, such as the Microsoft OLE DB Provider for Internet Publishing. For more information, see Records and Provider-Supplied Fields.
Note Note

URLs using the http scheme will automatically invoke the Microsoft OLE DB Provider for Internet Publishing. For more information, see Absolute and Relative URLs.
Note Note

If the current record contains a data record from an ADO Recordset, accessing the ParentURL property causes a run-time error, indicating that no URL is possible.


Index.Required Property (DAO)

 Copy code hover
[image]

Index.Required Property (DAO)
Send feedback

Sets or returns a value that indicates whether a Field object requires a non-Null value.

Syntax

expression .Required

expression A variable that represents an Index object.

Remarks

Note Note

When you can set this property for either an Index object or a Field object, set it for the Field object. The validity of the property setting for a Field object is checked before that of an Index object.

The availability of the Required property depends on the object that contains the Fields collection, as shown in the following table.

If the Fields collection belongs to a | Then Required is
Index object | Not supported
QueryDef object | Read-only
Recordset object | Read-only
Relation object | Not supported
TableDef object | Read/write


Form.CommandChecked Event (Access)

 Copy code hover
[image]

Form.CommandChecked Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when the specified Microsoft Office Web Component determines whether the specified command is checked.

Syntax

expression .CommandChecked(Command, Checked)

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Command | Required | Variant | The command that has been verified as being checked.
Checked | Required | Object | Set the Value property of this object to False to uncheck the command.

Return Value

nothing

Remarks

The OCCommandId, ChartCommandIdEnum, and PivotCommandId constants contain lists of the supported commands for each of the Microsoft Office Web Components.

Example

The following example demonstrates the syntax for a subroutine that traps the CommandChecked event.

VBA Copy code Copy code
Private Sub Form_CommandChecked( _
 ByVal Command As Variant, ByVal Checked As Object) Dim intResponse As Integer
 Dim strPrompt As String

 strPrompt = "Uncheck the command?"

 intResponse = MsgBox(strPrompt, vbYesNo)

 If intResponse = vbYes Then
 Checked.Value = False
 Else
 Checked.Value = True
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Recordset2.FindPrevious Method (DAO)

 Copy code hover
[image]

Recordset2.FindPrevious Method (DAO)
Send feedback

Locates the previous record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only). .

Syntax

expression .FindPrevious(Criteria)

expression A variable that represents a Recordset2 object.

Parameters

Name | Required/Optional | Data Type | Description
Criteria | Required | String | A String used to locate the record. It is like the WHERE clause in an SQL statement, but without the word WHERE.

Remarks

If you want to include all the records in your search — not just those that meet a specific condition — use the Move methods to move from record to record. To locate a record in a table-type Recordset, use the Seek method.

If a record matching the criteria isn't located, the current record pointer is unknown, and the NoMatch property is set to True. If recordset contains more than one record that satisfies the criteria, FindFirst locates the first occurrence, FindNext locates the next occurrence, and so on.

Each of the Find methods begins its search from the location and in the direction specified in the following table.

Find method | Begins searching at | Search direction
FindFirst | Beginning of recordset | End of recordset
FindLast | End of recordset | Beginning of recordset
FindNext | Current record | End of recordset
FindPrevious | Current record | Beginning of recordset

Using one of the Find methods isn't the same as using a Move method, however, which simply makes the first, last, next, or previous record current without specifying a condition. You can follow a Find operation with a Move operation.

Always check the value of the NoMatch property to determine whether the Find operation has succeeded. If the search succeeds, NoMatch is False. If it fails, NoMatch is True and the current record isn't defined. In this case, you must position the current record pointer back to a valid record.

Using the Find methods with Microsoft Access database engine-connected ODBC-accessed recordsets can be inefficient. You may find that rephrasing your criteria to locate a specific record is faster, especially when working with large recordsets.

When working with Microsoft Access database engine-connected ODBC databases and large dynaset-type Recordset objects, you might discover that using the Find methods or using the Sort or Filter property is slow. To improve performance, use SQL queries with customized ORDER BY or WHERE clauses, parameter queries, or QueryDef objects that retrieve specific indexed records.

You should use the U.S. date format (month-day-year) when you search for fields containing dates, even if you're not using the U.S. version of the Microsoft Access database engine; otherwise, the data may not be found. Use the Visual Basic Format function to convert the date. For example:

VBA Copy code Copy code
rstEmployees.FindFirst "HireDate > #" _
    & Format(mydate, 'm-d-yy' ) & "#"

If criteria is composed of a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strSQL = "PRICE > " & lngPrice, and lngPrice = 125,50), an error occurs when you try to call the method. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and Microsoft Access SQL only accepts U.S. decimal characters.

Note Note

  • For best performance, the criteria should be in either the form "field = value" where field is an indexed field in the underlying base table, or "field LIKE prefix" where field is an indexed field in the underlying base table and prefix is a prefix search string (for example, "ART*" ).

  • In general, for equivalent types of searches, the Seek method provides better performance than the Find methods. This assumes that table-type Recordset objects alone can satisfy your needs.


WebBrowserControl.Move Method (Access)

 Copy code hover
[image]

WebBrowserControl.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Version Information

Version Added: Access 2010

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a WebBrowserControl object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant |
Top | Optional | Variant |
Width | Optional | Variant |
Height | Optional | Variant |

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Synchronizer cannot find a specific version number in the MSysSchChange table. (Error 3523)

 Copy code hover
[image]

Synchronizer cannot find a specific version number in the MSysSchChange table. (Error 3523)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


SmartTag Object (Access)

 Copy code hover
[image]

SmartTag Object (Access)
See also Send feedback

Published: July 16, 2012

Represents a smart tag that has been added to a control on a form or report. The SmartTag object is a member of the SmartTags collection.

Remarks

To return a single SmartTag object, use the Item method of the SmartTags collection, or use SmartTags (Index), where Index represents the number of the smart tag.

Note Note

Unlike the SmartTags collections in Microsoft Excel and Microsoft Word, the SmartTags collection in Microsoft Access is zero-based. Therefore, the code control.SmartTags(0) returns the first smart tag for the specified control.

To return the collection of actions available for the smart tag, use the SmartTagActions property. To perform a smart tag action, use the Execute method of the SmartTagAction object.

See also

Concepts

Access Object Model Reference

Other resources

SmartTag Object Members


Index or primary key cannot contain a Null value. (Error 3058)

 Copy code hover
[image]

Index or primary key cannot contain a Null value. (Error 3058)
Send feedback

Possible causes:

  • You tried to add a new record but did not enter a value in the field that contains the primary key.

  • You tried to add a Null value to a primary key field.

  • You executed a query that tried to put a Null value in a primary key field.

What Is a Primary Key?

A primary key is a field or set of fields in your table that provide Microsoft Access with a unique identifier for every row. In a relational database, such as an Access database, you divide your information into separate, subject-based tables. You then use table relationships and primary keys to tell Access how to bring the information back together again. Access uses primary key fields to quickly associate data from multiple tables and combine that data in a meaningful way.

Often, a unique identification number, such as an ID number or a serial number or code, serves as a primary key in a table. For example, you might have a Customers table where each customer has a unique customer ID number. The customer ID field is the primary key.

An example of a poor choice for a primary key would be a name or address. Both contain information that might change over time.

Access ensures that every record has a value in the primary key field, and that the value is always unique.

What Is a Null?

A Null is a value you can enter in a field or use in expressions or queries to indicate missing or unknown data. In Microsoft Visual Basic, the Null keyword indicates a Null value. Some fields, such as primary key fields, cannot contain Null.

Solution

To solve this problem, you must enter a value in the primary key field before moving to another record.


Form.ShortcutMenu Property (Access)

 Copy code hover
[image]

Form.ShortcutMenu Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenu property to specify whether a shortcut menu is displayed when you right-click an object on a form. For example, you might want to disable a shortcut menu to prevent the user from changing the form's underlying record source by using one of the filtering commands on the form's shortcut menu. Read/write Boolean.

Syntax

expression .ShortcutMenu

expression A variable that represents a Form object.

Remarks

The default value is True.

This property controls the displaying of the shortcut menus for a form and for any of its controls. If the ShortcutMenu property is set to False, shortcut menus aren't displayed when you right-click a form or any of its controls.

If you're developing a wizard, you might want to hide shortcut menus on your wizard forms to prevent the user from viewing or using them. This is especially true for forms that display choices. For example, the ShortcutMenu property for the Startup form in the Northwind sample database is set to No. This prevents users from displaying shortcut menus for the form or controls on the form.

Example

The following example disables the shortcut menus for the Invoice form and its controls:

VBA Copy code Copy code
Forms!Invoice.ShortcutMenu = False

See also

Concepts

Form Object

Other resources

Form Object Members


ListBox.Undo Method (Access)

 Copy code hover
[image]

ListBox.Undo Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the Undo method to reset a control or form when its value has been changed.

Syntax

expression .Undo

expression A variable that represents a ListBox object.

Remarks

For example, you can use the Undo method to clear a change to a record that contains an invalid entry.

If the Undo method is applied to a form, all changes to the current record are lost. If the Undo method is applied to a control, only the control itself is affected.

This method must be applied before the form or control is updated. You may want to include this method in a form's BeforeUpdate event or in a control's Change event.

The Undo method offers an alternative to using the SendKeys statement to send the value of the ESC key in an event procedure.

Example

The following example shows how you can use the Undo method within a control's Change event procedure to force a field named LastName to reset to its original value, if it changed.

VBA Copy code Copy code
Private Sub LastName_Change()
 Me!LastName.Undo
End Sub

The next example uses the Undo method to reset all changes to a form before the form is updated.

VBA Copy code Copy code
Private Sub Form_BeforeUpdate(Cancel As Integer)
 Me.Undo
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


ColumnAttributesEnum

 Copy code hover
[image]

ColumnAttributesEnum
Send feedback

Specifies characteristics of a Column.

Constant | Value | Description
adColFixed | 1 | The column is a fixed length.
adColNullable | 2 | The column may contain null values.


SubForm.LayoutID Property (Access)

 Copy code hover
[image]

SubForm.LayoutID Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the unique identifier for the layout that contains the specified subform. Read-only Long.

Version Information

Version Added: Access 2007

Syntax

expression .LayoutID

expression A variable that represents a SubForm object.

Remarks

The LayoutID property returns 0 (zero) if the specified control is not part of a layout.

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


CommandButton.TabStop Property (Access)

 Copy code hover
[image]

CommandButton.TabStop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.

Syntax

expression .TabStop

expression A variable that represents a CommandButton object.

Remarks

This property doesn't apply to toggle button controls when they appear in an option group. It applies only to the option group itself.

The TabStop property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) You can move the focus to the control by pressing the TAB key.
No | False | You can't move the focus to the control by pressing the TAB key.

When you create a control on a form, Microsoft Access automatically assigns the control a position in the form's tab order. Each new control is placed last in the tab order. If you want to prevent a control from being available when you tab through the controls in a form, set the control's TabStop property to No.

In Form view, hidden or disabled controls remain in the tab order but are skipped when you move through the controls by pressing TAB, even if their TabStop properties are set to Yes.

As long as a control's Enabled property is set to Yes, you can click the control or use an access key to select it, regardless of its TabStop property setting. For example, you can set the TabStop property of a command button to No to prevent users from selecting the button by pressing TAB. However, they can still click the command button to choose it.

Example

The following example disables the ability to move the focus to the "City" text box on the "Suppliers" form by using the TAB key.

VBA Copy code Copy code
Forms("Suppliers").Controls("City").TabStop = False

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


CREATE VIEW Statement (Microsoft Access SQL)

 Copy code hover
[image]

CREATE VIEW Statement (Microsoft Access SQL)
Send feedback

Creates a new view.

Note Note

The Microsoft Access database engine does not support the use of CREATE VIEW, or any of the DDL statements, with non-Microsoft Access database engine databases.

Syntax

CREATE VIEW view [(field1[, field2[, …]])] AS selectstatement

The CREATE VIEW statement has these parts:

Part | Description
view | The name of the view to be created.
field1, field2 | The name of field or fields for the corresponding fields specified in selectstatement.
selectstatement | A SQL SELECT statement. For more information, see SELECT Statement.

Remarks

The SELECT statement that defines the view cannot be a SELECT INTO statement.

The SELECT statement that defines the view cannot contain any parameters.

The name of the view cannot be the same as the name of an existing table.

If the query defined by the SELECT statement is updatable, then the view is also updatable. Otherwise, the view is read-only.

If any two fields in the query defined by the SELECT statement have the same name, the view definition must include a field list specifying unique names for each of the fields in the query.


Pages.Item Property (Access)

 Copy code hover
[image]

Pages.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only Page.

Syntax

expression .Item(Index)

expression A variable that represents a Pages object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

Pages Collection

Other resources

Pages Object Members


SubmitChanges Method (RDS)

 Copy code hover
[image]

SubmitChanges Method (RDS)
Send feedback

Submits pending changes of the locally cached and updatable Recordset to the data source specified in the Connect property or the URL property.

Syntax

DataControl.SubmitChanges

DataFactory.SubmitChanges Connection, Recordset

Parameters

  • DataControl

  • An object variable that represents an RDS.DataControl object.

  • DataFactory

  • An object variable that represents an RDSServer.DataFactory object.

  • Connection

  • A String value that represents the connection created with the RDS.DataControl object's Connect property.

  • Recordset

  • An object variable that represents a Recordset object.

Remarks

The Connect, Server, and SQL properties must be set before you can use the SubmitChanges method with the RDS.DataControl object.

If you call the CancelUpdate method after you have called SubmitChanges for the same Recordset object, the CancelUpdate call fails because the changes have already been committed.

Only the changed records are sent for modification, and either all of the changes succeed or all of them fail together.

You can use SubmitChanges only with the default RDSServer.DataFactory object. Custom business objects can't use this method.

If the URL property has been set, SubmitChanges will submit changes to the location specified by the URL.


TextBox.TabStop Property (Access)

 Copy code hover
[image]

TextBox.TabStop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.

Syntax

expression .TabStop

expression A variable that represents a TextBox object.

Remarks

This property doesn't apply to toggle button controls when they appear in an option group. It applies only to the option group itself.

The TabStop property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) You can move the focus to the control by pressing the TAB key.
No | False | You can't move the focus to the control by pressing the TAB key.

When you create a control on a form, Microsoft Access automatically assigns the control a position in the form's tab order. Each new control is placed last in the tab order. If you want to prevent a control from being available when you tab through the controls in a form, set the control's TabStop property to No.

In Form view, hidden or disabled controls remain in the tab order but are skipped when you move through the controls by pressing TAB, even if their TabStop properties are set to Yes.

As long as a control's Enabled property is set to Yes, you can click the control or use an access key to select it, regardless of its TabStop property setting. For example, you can set the TabStop property of a command button to No to prevent users from selecting the button by pressing TAB. However, they can still click the command button to choose it.

Example

The following example disables the ability to move the focus to the "City" text box on the "Suppliers" form by using the TAB key.

VBA Copy code Copy code
Forms("Suppliers").Controls("City").TabStop = False

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


NavigationButton.BorderShade Property (Access)

 Copy code hover
[image]

NavigationButton.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents a NavigationButton object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Object has no value. (Error 2427)

 Copy code hover
[image]

Object has no value. (Error 2427)
Send feedback

You entered an expression containing an identifier for an object that has no value. (Objects may have a default property value or return a default method.)

Check the expression to make sure you entered it correctly.


Section.OnPaint Property (Access)

 Copy code hover
[image]

Section.OnPaint Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Paint box in the Properties window of a form or report. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnPaint

expression A variable that represents a Section object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Paint event occurs when the section is redrawn.

The OnPaint value will be one of the following, depending on the selection in the Choose Builder window (accessed by clicking the Build button next to the On Paint box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Paint box is blank, the property value is an empty string.

See also

Concepts

Section Object

Other resources

Section Object Members


NavigationControl.ReadingOrder Property (Access)

 Copy code hover
[image]

NavigationControl.ReadingOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .ReadingOrder

expression A variable that represents a NavigationControl object.

Remarks

The ReadingOrder property uses the following settings.

Setting | Visual Basic | Description
Context | 0 | Reading order is determined by the language of the first character entered. If a right-to-left language character is entered first, reading order is right to left. If a left-to-right language character is entered first, reading order is left to right.
Left-to-Right | 1 | Sets the reading order to left to right.
Right-to-Left | 2 | Sets the reading order to right to left.

Example

The following example sets the reading order to right to left for the "Address" text box on the "International Shipping" form.

VBA Copy code Copy code
Forms("International Shipping").Controls("Address").ReadingOrder = 2

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


EmptyCell Properties (Access)

 Copy code hover
[image]

EmptyCell Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BottomPadding | Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
GridlineColor | Gets or sets the color of the gridline for the specified list box. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified list box. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified text box. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified text box. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified text box. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified text box. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified text box. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the text box is anchored horizontally within its layout. Read/write.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Layout | Returns the type of layout for the specified text box. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified text box. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the text box and its left gridline. Read/write Integer.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
RightPadding | Gets or sets the amount of space (in inches) between the text box and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
StatusBarText | You can use the StatusBarText property to specify the text that is displayed in the status bar when a control is selected. Read/write String.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified text box is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


After Delete Macro Event

 Copy code hover
[image]

After Delete Macro Event
Send feedback

The After Delete event occurs after a record is deleted.

Note Note

The After Delete event is available only in Data Macros.

Remarks

Use the After Delete event to perform any actions that you want to occur when a record is deleted. Common uses for the After Delete include enforcing business rules, workflows, updating an aggregate total, and sending notifications.

When the After Delete event occurs, the values contained in the deleted record are still available. You may want to use a deleted value to increment or decrement a total, create an audit trail, or compare to an existing value in a WhereCondition argument.

You can use the Updated("Field Name") function to determine whether a field has changed. The following code example shows how to use an If staement to determine determine whether the PaidInFull field has been changed.

Copy code Copy code

If  Updated("PaidInFull")   Then

    /* Perform actions based on changes to the field.   */

End If

You can use access a value in the deleted record by using the following syntax.

Copy code Copy code
[Old].[Field Name]

For example, to access the value of the QuantityInStock field in the deleted record, use the following syntax.

Copy code Copy code
[Old].[QuantityInStock]

The values contained in the deleted record are deleted permanently when the After Delete event ends.

The following macro commands can be used in the After Delete event.

Command Type | Command
Program Flow | Comment Macro Statement
Program Flow | Group Macro Statement
Program Flow | If...Then...Else Macro Block
Data Block | CreateRecord Macro Action
Data Block | EditRecord Macro Action
Data Block | ForEachRecord Macro Action
Data Block | LookupRecord Data Block
Data Action | CancelRecordChange Macro Action
Data Action | ClearMacroError Macro Action
Data Action | DeleteRecord Macro Action
Data Action | ExitForEachRecord Macro Action
Data Action | LogEvent Macro Action
Data Action | OnError Macro Action
Data Action | RaiseError Macro Action
Data Action | RunDataMacro Macro Action
Data Action | SendEmail Macro Action
Data Action | SetField Macro Action
Data Action | SetLocalVar Macro Action
Data Action | StopAllMacros Macro Action
Data Action | StopMacro Macro Action

To create a Data Macro that captures the After Delete event, use the following steps.

  1. Open the table for which you want to capture the After Delete event.

  2. On the Table tab, in the After Events group, click After Delete.

An empty Data Macro is displayed in the macro designer.

Example

The following code example uses the After Delete event to perform some processing when a record is deleted from the Donations table. When a record is deleted, the amount of the donation is subracted form the DonationsReceived field in the DonationsReceived table and the TotalDonatedField in the Donors table.

Click here to view a copy of the macro that you can paste into Macro Designer.

To view this example in the macro designer, use the following steps.

  1. Open the table for which you want to capture the After Delete event.

  2. On the Table tab, in the After Events group, click After Delete.

  3. Select the code listed below and then press CTRL+C to copy it to the Clipboard.

  4. Activate the macro designer window and then press CTRL+V.

Copy code Copy code
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<DataMacros xmlns="http://schemas.microsoft.com/office/accessservices/2009/04/application">
  <DataMacro Event="AfterDelete">
    <Statements>
      <Comment>Initialize a variable and assign the old</Comment>
      <Action Name="SetLocalVar">
        <Argument Name="Name">varAmount</Argument>
        <Argument Name="Value">[Old].[Amount]</Argument>
      </Action>
      <ConditionalBlock>
        <If>
          <Condition>Not (IsNull([Old].[CampaignID]))</Condition>
          <Statements>
            <ForEachRecord>
              <Data>
                <Reference>Campaigns</Reference>
                <WhereCondition>[ID]=[Old].[CampaignID]</WhereCondition>
              </Data>
              <Statements>
                <EditRecord>
                  <Data />
                  <Statements>
                    <Action Collapsed="true" Name="SetField">
                      <Argument Name="Field">[DonationsReceived]</Argument>
                      <Argument Name="Value">[DonationsReceived]-[varAmount]</Argument>
                    </Action>
                  </Statements>
                </EditRecord>
              </Statements>
            </ForEachRecord>
          </Statements>
        </If>
      </ConditionalBlock>
      <ConditionalBlock>
        <If>
          <Condition>Not (IsNull([Old].[DonorID]))</Condition>
          <Statements>
            <ForEachRecord>
              <Data>
                <Reference>Donors</Reference>
                <WhereCondition>[ID]=[Old].[DonorID]</WhereCondition>
              </Data>
              <Statements>
                <EditRecord>
                  <Data />
                  <Statements>
                    <Action Name="SetField">
                      <Argument Name="Field">[TotalDonated]</Argument>
                      <Argument Name="Value">[TotalDonated]-[varAmount]</Argument>
                    </Action>
                  </Statements>
                </EditRecord>
              </Statements>
            </ForEachRecord>
          </Statements>
        </If>
      </ConditionalBlock>
    </Statements>
  </DataMacro>
</DataMacros>

SetLocalVar
                Name    varAmount
          Expression   =[Old].[Amount]

If   Not(IsNull([Old].[CampaignID]]))   Then

     For Each Record In     Campaigns
        Where Condition     =[ID]=[Old].[CampaignID]
                  Alias
        EditRecord
                  Alias
              SetField   ([DonationsReceived], [DonationsReceived] - [varAmount])
        End EditRecord

End If

If   Not(IsNull([Old].[DonorID]]))   Then

     For Each Record In    Donors
        Where Condition     =[ID]=[Old].[DonorID]
                  Alias
        EditRecord
                  Alias

          SetField
                         Name   [TotalDonated]
                        Value   =[TotalDonated]-[varAmount]
        End EditRecord
End If


SharedResource Properties (Access)

 Copy code hover
[image]

SharedResource Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Type | Gets the type of the SharedResource object. Read-only AcResourceType.


WebBrowserControl.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

WebBrowserControl.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineWidthBottom

expression A variable that represents a WebBrowserControl object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Forms.Application Property (Access)

 Copy code hover
[image]

Forms.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents a Forms object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

Forms Collection

Other resources

Forms Object Members


ComboBox.OldValue Property (Access)

 Copy code hover
[image]

ComboBox.OldValue Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.

Syntax

expression .OldValue

expression A variable that represents a ComboBox object.

Remarks

The OldValue property contains the unedited data from a bound control and is read-only in all views.

Microsoft Access uses the OldValue property to store the original value of a bound control. When you edit a bound control on a form, your changes aren't saved until you move to another record. The OldValue property contains the unedited version of the underlying data.

You can provide your own undo capability by assigning the OldValue property setting to a control. The following example shows how you can undo any changes to text box controls on a form:

VBA Copy code Copy code
Private Sub btnUndo_Click()

 Dim ctlTextbox As Control

 For Each ctlTextbox in Me.Controls
 If ctlTextbox.ControlType = acTextBox Then
 ctlTextbox.Value = ctl.OldValue
 End If
 Next ctlTextbox

End Sub

If the control hasn't been edited, this code has no effect. When you move to another record, the record source is updated, so the current value and the OldValue property will be the same.

The OldValue property setting has the same data type as the field to which the control is bound.

Example

The following example checks to determine if new data entered in a field is within 10 percent of the value of the original data. If the change is greater than 10 percent, the OldValue property is used to restore the original value. This procedure could be called from the BeforeUpdate event of the control that contains data you want to validate.

VBA Copy code Copy code
Public Sub Validate_Field()

 Dim curNewValue As Currency
 Dim curOriginalValue As Currency
 Dim curChange As Currency
 Dim strMsg As String

 curNewValue = Forms!Products!UnitPrice
 curOriginalValue = Forms!Products!UnitPrice.OldValue
 curChange = Abs(curNewValue - curOriginalValue)

 If curChange > (curOriginalValue * .1) Then
 strMsg = "Change is more than 10% of original unit price. " _
 & "Restoring original unit price."
 MsgBox strMsg, vbExclamation, "Invalid change."
 Forms!Products!UnitPrice = curOriginalValue
 End If

End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


OptionButton.InSelection Property (Access)

 Copy code hover
[image]

OptionButton.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents an OptionButton object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


TabControl.Section Property (Access)

 Copy code hover
[image]

TabControl.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Syntax

expression .Section

expression A variable that represents a TabControl object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


ComboBox.Change Event (Access)

 Copy code hover
[image]

ComboBox.Change Event (Access)
See also Send feedback

Published: July 16, 2012

The Change event occurs when the contents of the specified control changes.

Syntax

expression .Change

expression A variable that represents a ComboBox object.

Remarks

Examples of this event include entering a character directly in the text box or combo box or changing the control's Text property setting by using a macro or Visual Basic.

Note Note

Setting the value of a control by using a macro or Visual Basic doesn't trigger this event for the control. You must type the data directly into the control, or set the control's Text property.

To run a macro or event procedure when this event occurs, set the OnChange property to the name of the macro or to [Event Procedure].

By running a macro or event procedure when a Change event occurs, you can coordinate data display among controls. You can also display data or a formula in one control and the results in another control.

The Change event doesn't occur when a value changes in a calculated control.

Note Note

A Change event can cause a cascading event. This occurs when a macro or event procedure that runs in response to the control's Change event alters the control's contents — for example, by changing a property setting that determines the control's value, such as the Text property for a text box. To prevent a cascading event:

  • If possible, avoid attaching a Change macro or event procedure to a control that alters the control's contents.

  • Avoid creating two or more controls having Change events that affect each other — for example, two text boxes that update each other.

Changing the data in a text box or combo box by using the keyboard causes keyboard events to occur in addition to control events like the Change event. For example, if you move to a new record and type an ANSI character in a text box in the record, the following events occur in this order:

KeyDown → KeyPress → BeforeInsert → Change → KeyUp

The BeforeUpdate and AfterUpdate events for the text box or combo box control occur after you have entered the new or changed data in the control and moved to another control (or clicked Save Record on the Records menu), and therefore after all of the Change events for the control.

In combo boxes for which the LimitToList property is set to Yes, the NotInList event occurs after you enter a value that isn't in the list and attempt to move to another control or save the record. It occurs after all the Change events for the combo box. In this case, the BeforeUpdate and AfterUpdate events for the combo box don't occur, because Microsoft Access doesn't accept a value that is not in the list.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ObjectFrame.OLEClass Property (Access)

 Copy code hover
[image]

ObjectFrame.OLEClass Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OLEClass property to obtain a description of the kind of OLE object contained in a chart control or an unbound object frame. Read-only String.

Syntax

expression .OLEClass

expression A variable that represents an ObjectFrame object.

Remarks

This property is set automatically in the control's property sheet to a string expression when you click Object on the Insert menu to add an OLE object to a form. The OLEClass property setting is read-only in all views.

Note Note

If you are using Automation (formerly called OLE Automation) and need to specify a name to refer to the OLE object, use the Class property.

The OLEClass property and the Class property are similar but not identical. The OLEClass property setting is a general description of the OLE object whereas the Class property setting is the name used to refer to the OLE object in Visual Basic. Examples of OLEClass property settings are Microsoft Excel Chart, Microsoft Word Document, and Paintbrush Picture.

Example

The following example displays a message indicating the OLE class for the "Customer Picture" unbound object frame on the "Order Entry" form.

VBA Copy code Copy code
MsgBox "The OLE class = " & Forms("Order Entry").Controls("Customer Picture").OLEClass

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Label.HyperlinkAddress Property (Access)

 Copy code hover
[image]

Label.HyperlinkAddress Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the HyperlinkAddress property to specify or determine the path to an object, document, Web page or other destination for a hyperlink associated with a the specified control. Read/write String.

Syntax

expression .HyperlinkAddress

expression A variable that represents a Label object.

Remarks

The HyperlinkAddress property is a string expression representing the path to a file (UNC path) or Web page (URL).

Note Note

When you set the HyperlinkAddress property, you automatically specify the Address property for the Hyperlink object associated with the control.

Note Note

When you create a hyperlink by using the Insert Hyperlink dialog box, Microsoft Access automatically sets the HyperlinkAddress property and HyperlinkSubAddress to the location specified in the Type the file or Web page name box. The HyperlinkSubAddress property can also be set to the location specified in the Select an object in this database box.

If you copy a hyperlink from another application and paste it into a form or report, Microsoft Access creates a label control with its Caption property, HyperlinkAddress property, and HyperlinkSubAddress property automatically set.

When you move the cursor over a command button, image control, or label control whose HyperlinkAddress property is set, the cursor changes to an upward-pointing hand. Clicking the control displays the object or Web page specified by the link.

To open objects in the current database, leave the HyperlinkAddress property blank and specify the object type and object name you want to open in the HyperlinkSubAddress property by using the syntax "objecttype objectname". If you want to open an object contained in another Microsoft Access database, enter the database path and file name in the HyperlinkAddress property and specify the database object to open by using the HyperlinkSubAddress property.

The HyperlinkAddress property can contain an absolute or a relative path to a target document. An absolute path is a fully qualified URL or UNC path to a document. A relative path is a path related to the base path specified in the Hyperlink Base setting in the Properties dialog box (available by clicking Database Properties on the File menu) or to the current database path. If Microsoft Access can't resolve the HyperlinkAddress property setting to a valid URL or UNC path, it will assume you've specified a path relative to the base path contained in the Hyperlink Base setting or the current database path.

Note Note

When you follow a hyperlink to another Microsoft Access database object, the database Startup properties are applied. For example, if the destination database has a Display form set, that form is displayed when the database opens.

The following table contains examples of HyperlinkAddress and HyperlinkSubAddress property settings.

HyperlinkAddress | HyperlinkSubAddress | Description
http://www.microsoft.com/ |  | The Microsoft home page on the Web.
C:\Program Files\Microsoft Office\Office\Samples\Cajun.htm |  | The Cajun Delights page in the Access sample applications subdirectory.
C:\Program Files\Microsoft Office\Office\Samples\Cajun.htm | NewProducts | The "NewProducts" Name tag in the Cajun Delights page.
C:\Personal\MyResume.doc | References | The bookmark named "References" in the Microsoft Word document "MyResume.doc".
C:\Finance\First Quarter.xls | Sheet1!TotalSales | The range named "TotalSales" in the Microsoft Excel spreadsheet "First Quarter.xls".
C:\Presentation\NewPlans.ppt | 10 | The 10th slide in the Microsoft PowerPoint document "NewPlans.ppt".

See also

Concepts

Label Object

Other resources

Label Object Members


CodeProject.OpenConnection Method (Access)

 Copy code hover
[image]

CodeProject.OpenConnection Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the OpenConnection method to open an ADO connection to an existing Microsoft Access project (.adp) or Access database as the current Access project or database in the Microsoft Access window.

Syntax

expression .OpenConnection(BaseConnectionString, UserID, Password)

expression A variable that represents a CodeProject object.

Parameters

Name | Required/Optional | Data Type | Description
BaseConnectionString | Optional | Variant | A string expression that is the base connection string of the database.
UserID | Optional | Variant | A string expression that is the name of the existing Access project, including the path name and the file name extension. If your network supports it, you can also specify a network path in the following form: \\Server\Share\Folder\Filename.adp
Password | Optional | Variant | If you don't supply the filename extension, .adp is appended to the filename. You can use this method or the OpenCurrentDatabase method to open .adp files.

Remarks

The OpenConnection method is similar to the Open method of an ADO Connection object. This method establishes the physical connection to the data source. After this method successfully completes, the connection is live, the Connection and BaseConnectionString properties are set, and the Database window or data access page should be repopulated with data from the new connection. All parameters of this method are optional. If no base connection string is supplied, then the connection is re-established using the previous base connection string (but the user must call CloseConnection before calling OpenConnection again). In the case of an Access project, the BaseConnectionString property can only specify the SQL Server OLE DB Provider.

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


DBEngine.RegisterDatabase Method (DAO)

 Copy code hover
[image]

DBEngine.RegisterDatabase Method (DAO)
Send feedback

Enters connection information for an ODBC data source in the Windows Registry. The ODBC driver needs connection information when the ODBC data source is opened during a session.

Syntax

expression .RegisterDatabase(Dsn, Driver, Silent, Attributes)

expression A variable that represents a DBEngine object.

Parameters

Name | Required/Optional | Data Type | Description
Dsn | Required | String | the name used in the OpenDatabase method. It refers to a block of descriptive information about the data source. For example, if the data source is an ODBC remote database, it could be the name of the server.
Driver | Required | String | The name of the ODBC driver. This isn't the name of the ODBC driver DLL file.
Silent | Required | Boolean | True if you don't want to display the ODBC driver dialog boxes that prompt for driver-specific information; or False if you want to display the ODBC driver dialog boxes. If silent is True, attributes must contain all the necessary driver-specific information or the dialog boxes are displayed anyway.
Attributes | Required | String | A list of keywords to be added to the Windows Registry. The keywords are in a carriage-return-delimited string.

Remarks

If the database is already registered (connection information is already entered) in the Windows Registry when you use the RegisterDatabase method, the connection information is updated.

If the RegisterDatabase method fails for any reason, no changes are made to the Windows Registry, and an error occurs.

For more information about ODBC drivers such as SQL Server, see the Help file provided with the driver.

Example

This example uses the RegisterDatabase method to register a Microsoft SQL Server data source named Publishers in the Windows Registry.

VBA Copy code Copy code
Sub RegisterDatabaseX()

 Dim dbsRegister As Database
 Dim strDescription As String
 Dim strAttributes As String
 Dim errLoop As Error

 ' Build keywords string.
 strDescription = InputBox( "Enter a description " & _
 "for the database to be registered.")
 strAttributes = "Database=pubs" & _
 vbCr & "Description=" & strDescription & _
 vbCr & "OemToAnsi=No" & _
 vbCr & "Server=Server1"

 ' Update Windows Registry.
 On Error GoTo Err_Register
 DBEngine.RegisterDatabase "Publishers", "SQL Server", _
 True, strAttributes
 On Error GoTo 0

 MsgBox "Use regedit.exe to view changes: " & _
 "HKEY_CURRENT_USER\" & _
 "Software\ODBC\ODBC.INI"

 Exit Sub

Err_Register:

 ' Notify user of any errors that result from
 ' the invalid data.
 If DBEngine.Errors.Count > 0 Then
 For Each errLoop In DBEngine.Errors
 MsgBox "Error number: " & errLoop.Number & _
 vbCr & errLoop.Description
 Next errLoop
 End If

 Resume Next

End Sub


ObjectFrame.Verb Property (Access)

 Copy code hover
[image]

ObjectFrame.Verb Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Verb property to specify the operation to perform when an OLE object is activated, which is permitted when the control'sAction property is set to acOLEActivate. Read/write Long.

Syntax

expression .Verb

expression A variable that represents an ObjectFrame object.

Remarks

You can set the Verb property by specifying an Integer data type value indicating the position of a verb in the list of verbs returned by the ObjectVerbs property. You can set the Verb property to 1 to specify the first verb in the list, you can set it to 2 to specify the second verb in the list, and so on.

If you don't use the ObjectVerbs property to identify a specific verb, you can set the Verb property to one of the following values to indicate the operation to perform. These values specify the standard verbs supported by all objects.

Constant | Description
acOLEVerbPrimary | Performs the default operation for the object.
acOLEVerbShow | Activates the object for editing.
acOLEVerbOpen | Opens the object in a separate application window.
acOLEVerbHide | For embedded objects, hides the application that was used to create the object.

With some applications' objects, you can use these additional values.

Constant | Description
acOLEVerbInPlaceUIActivate | Activates the object for editing within the control. The menus and toolbars of the OLE server become available in the OLE container.
acOLEVerbInPlaceActivate | Activates the object within the control. The menus and toolbars of the OLE server aren't available in the OLE container.

Each object supports its own set of verbs. For example, many objects support the verbs Edit and Play. You can use the ObjectVerbs and ObjectVerbsCount properties to find out which verbs are supported by an object.

Microsoft Access automatically uses an object's default verb if the user double-clicks an object for which the AutoActivate property is set to Double-Click.

Example

The following example activates the control "OLEUnbound0" in the form "frmOperations" by opening up the OLE object in its own application window for editing. In this case, "OLEUnbound0" contains a new bitmap image, which is linked to the Microsoft Paint program.

VBA Copy code Copy code
With Forms.Item("frmOperations").Controls.Item("OLEUnbound0")
 .Action = acOLEActivate
 .Verb = acOLEVerbOpen
End With

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


TabControl.BackShade Property (Access)

 Copy code hover
[image]

TabControl.BackShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackShade

expression A variable that represents a TabControl object.

Remarks

The BackShade property contains a numeric expression that can be used to darken the theme color in the BackColor property. The default value of the BackShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens BackColor by 75%.

VBA Copy code Copy code
Me.ctl.BackShade=25

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Form.Error Event (Access)

 Copy code hover
[image]

Form.Error Event (Access)
See also Send feedback

Published: July 16, 2012

The Error event occurs when a run-time error is produced in Microsoft Access when a form has the focus.

Syntax

expression .Error(DataErr, Response)

expression A variable that represents a Form object.

Parameters

Name

Required/Optional

Data Type

Description

DataErr

Required

Integer

The error code returned by the Err object when an error occurs. You can use the DataErr argument with the Error function to map the number to the corresponding error message.

Response

Required

Integer

The setting determines whether or not an error message is displayed. The Response argument can be one of the following intrinsic constants.

  • acDataErrContinue Ignore the error and continue without displaying the default Microsoft Access error message. You can supply a custom error message in place of the default error message.

  • acDataErrDisplay (Default) Display the default Microsoft Access error message.

Remarks

This includes Microsoft Access database engine errors, but not run-time errors in Visual Basic or errors from ADO.

To run a macro or event procedure when this event occurs, set the OnError property to the name of the macro or to [Event Procedure].

By running an event procedure or a macro when an Error event occurs, you can intercept a Microsoft Access error message and display a custom message that conveys a more specific meaning for your application.

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Handling Access Errors with VBA

Example

The following example shows how you can replace a default error message with a custom error message. When Microsoft Access returns an error message indicating it has found a duplicate key (error code 3022), this event procedure displays a message that gives more application-specific information to users.

To try the example, add the following event procedure to a form that is based on a table with a unique employee ID number as the key for each record.

VBA Copy code Copy code
Private Sub Form_Error(DataErr As Integer, Response As Integer)
    Const conDuplicateKey = 3022
    Dim strMsg As String

    If DataErr = conDuplicateKey Then
        Response = acDataErrContinue
        strMsg = "Each employee record must have a unique " _
            & "employee ID number. Please recheck your data."
        MsgBox strMsg
    End If
End Sub

The following example shows how you can replace a default error message with a custom error message.

Sample code provided by: MVP Contributor Bill Jelen, MrExcel.com | About the Contributors

Copy code Copy code
Private Sub Form_Error(DataErr As Integer, Response As Integer)
    Select Case DataErr
        Case 2113
            MsgBox "Only numbers are acceptable in this box", vbCritical, "Call 1-800-123-4567"
            Response = acDataErrContinue
        Case 2237
            MsgBox "You can only choose from the dropdown box"
            Response = acDataErrContinue
        Case 3022
            MsgBox "You entered a value that exists already in another record"
            Response = acDataErrContinue
            SSN.Value = SSN.OldValue
        Case 3314
            MsgBox "The DOH is required, so you cannot leave this field empty"
            Response = acDataErrContinue
        Case Else
            Response = acDataErrDisplay
    End Select
    ActiveControl.Undo
End Sub

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

Holy Macro! Books publishes entertaining books for people who use Microsoft Office. See the complete catalog at MrExcel.com.

See also

Concepts

Form Object

Other resources

Form Object Members


Try_Parse Function (Access 2013 custom web app)

 Copy code hover
[image]

Try_Parse Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Parses a text value to the specified data type in the culture of the application or returns Null if the conversion is not valid.

Syntax

Try_Parse(TextExpression, DataType)

The Try_Parse function contains the following arguments.

Argument name | Description
TextExpression | A text expression representing the formatted value to parse into the specified data type.
DataType | The data type into which to parse TextExpression.

Remarks

Use Try_Parse only for converting from string to date/time and number types. For general type conversions, continue to use Convert.


Creating a Portion in Your Application's Registry Tree to Manage the Settings

 Copy code hover
[image]

Creating a Portion in Your Application's Registry Tree to Manage the Settings
Send feedback

Published: July 16, 2012

To customize the Microsoft® Windows® Registry settings, you can create a Microsoft Access database engine portion in your application's registry tree to manage the settings for the Microsoft Access database engine. The easiest way to accomplish this is to export the existing Microsoft Access database engine key and then import it into your application's tree with the Regedit.exe Export and Import commands. You can then alter the values in your new registry tree. If you have supplied any values in the Engines subfolder, the Microsoft Access database engine loads those settings when the application starts. Any values not entered in your client application's registry tree are loaded from shadow settings.

For your application to load the appropriate portion of the Windows Registry key you must specify the location with the DAO INIPath property. Your application must set the INIPath property before executing any other DAO code. The scope of this setting is limited to your application and cannot be changed without restarting your application.

Note Note

Although creating a Microsoft Access database engine portion in your application's registry is more flexible than overwriting the Microsoft Access database engine default entries, it requires that you maintain the registry tree. Every time changes are required in the default settings, you will need to edit the Registry.


Database Properties (DAO)

 Copy code hover
[image]

Database Properties (DAO)
Send feedback

In this section

  • Database.CollatingOrder Property (DAO)

  • Database.Connect Property (DAO)

  • Database.Connection Property (DAO)

  • Database.Containers Property (DAO)

  • Database.DesignMasterID Property (DAO)

  • Database.Name Property (DAO)

  • Database.Properties Property (DAO)

  • Database.QueryDefs Property (DAO)

  • Database.QueryTimeout Property (DAO)

  • Database.RecordsAffected Property (DAO)

  • Database.Recordsets Property (DAO)

  • Database.Relations Property (DAO)

  • Database.ReplicaID Property (DAO)

  • Database.TableDefs Property (DAO)

  • Database.Transactions Property (DAO)

  • Database.Updatable Property (DAO)

  • Database.Version Property (DAO)


BoundObjectFrame.Value Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Value Property (Access)
See also Send feedback

Published: July 16, 2012

Gets of sets the value of the field that the control is bound to. Read/write Variant.

Syntax

expression .Value

expression A variable that represents a BoundObjectFrame object.

Remarks

The Value property for a bound object frame or a bound chart control is set to the value of the field that the control is bound to. Since these fields normally contain OLE objects or chart objects, which are stored as binary data, this value is usually meaningless.

The Value property returns or sets a control's default property, which is the property that is assumed when you don't explicitly specify a property name.

Note Note

The Value property is not the same as the DefaultValue property, which specifies the value that a property is assigned when a new record is created.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


CursorType, LockType, and EditMode Properties Example (VC++)

 Copy code hover
[image]

CursorType, LockType, and EditMode Properties Example (VC++)
Send feedback

This example demonstrates setting the CursorType and LockType properties before opening a Recordset. It also shows the value of the EditMode property under various conditions. The EditModeOutput function is required for this procedure to run.

Copy code Copy code

// BeginEditModeCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>

// Function declaration
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void EditModeX(void);
void EditModeOutput(char *, int);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 EditModeX();

 // Wait here for the user to see the output
 printf("\n\nPress any key to continue...");
 getch();

 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// EditModeX Function //
// //
///////////////////////////////////////////////////////////
void EditModeX(void)
{
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRstEmployees = NULL;
 _ConnectionPtr pConnection = NULL;

 HRESULT hr = S_OK;

 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 // Open a connection
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
 hr = pConnection->Open(strCnn,"","",adConnectUnspecified);

 // Open recordset with data from employee table
 TESTHR(pRstEmployees.CreateInstance(__uuidof(Recordset)));

 pRstEmployees->CursorLocation = adUseClient;
 pRstEmployees->CursorType = adOpenStatic;
 pRstEmployees->LockType = adLockBatchOptimistic;

 pRstEmployees->Open("employee",
 _variant_t((IDispatch *) pConnection,true),
 adOpenStatic,adLockBatchOptimistic,adCmdTable);

 // Show the EditMode property under different editing states.
 pRstEmployees->AddNew ();
 pRstEmployees->Fields->Item["emp_id"]->Value =
 (_bstr_t)("T-T55555M");
 pRstEmployees->Fields->Item["fname"]->Value =
 (_bstr_t)("temp_fname");
 pRstEmployees->Fields->Item["lname"]->Value =
 (_bstr_t)("temp_lname");
 EditModeOutput("After AddNew: ", pRstEmployees->EditMode);

 pRstEmployees->UpdateBatch(adAffectCurrent);
 EditModeOutput("After Update: ", pRstEmployees->EditMode);

 pRstEmployees->Fields->Item["fname"]->Value = (_bstr_t)("test");
 EditModeOutput("After Edit: ", pRstEmployees->EditMode);

 // Delete new record because this is a demonstration.
 pConnection->Execute("DELETE FROM employee WHERE emp_id = "
 "'T-T55555M'", NULL, adCmdText);
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 PrintProviderError(pConnection);
 PrintComError(e);
 }

 // Clean up objects before exit.
 if (pRstEmployees)
 if (pRstEmployees->State == adStateOpen)
 pRstEmployees->Close();
 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

///////////////////////////////////////////////////////////
// //
// EditModeOutput() Function //
// //
///////////////////////////////////////////////////////////
void EditModeOutput(char *strTemp, int intEditMode)
{
 // Print report based on the value of the EditMode property.
 printf("\n%s", strTemp);
 printf("\n EditMode = ");

 switch (intEditMode)
 {
 case adEditNone :
 printf("adEditNone");
 break;
 case adEditInProgress :
 printf("adEditInProgress");
 break;
 case adEditAdd :
 printf("adEditAdd");
 break;
 }
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;
 // Collection ranges from 0 to nCount -1.
 for(long i = 0; i < nCount; i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\n\t Error number: %x\t%s\n", pErr->Number,
 (LPCSTR)pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print Com errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}

// EndEditModeCpp


BoundObjectFrame.Verb Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Verb Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Verb property to specify the operation to perform when an OLE object is activated, which is permitted when the control'sAction property is set to acOLEActivate. Read/write Long.

Syntax

expression .Verb

expression A variable that represents a BoundObjectFrame object.

Remarks

You can set the Verb property by specifying an Integer data type value indicating the position of a verb in the list of verbs returned by the ObjectVerbs property. You can set the Verb property to 1 to specify the first verb in the list, you can set it to 2 to specify the second verb in the list, and so on.

If you don't use the ObjectVerbs property to identify a specific verb, you can set the Verb property to one of the following values to indicate the operation to perform. These values specify the standard verbs supported by all objects.

Constant | Description
acOLEVerbPrimary | Performs the default operation for the object.
acOLEVerbShow | Activates the object for editing.
acOLEVerbOpen | Opens the object in a separate application window.
acOLEVerbHide | For embedded objects, hides the application that was used to create the object.

With some applications' objects, you can use these additional values.

Constant | Description
acOLEVerbInPlaceUIActivate | Activates the object for editing within the control. The menus and toolbars of the OLE server become available in the OLE container.
acOLEVerbInPlaceActivate | Activates the object within the control. The menus and toolbars of the OLE server aren't available in the OLE container.

Each object supports its own set of verbs. For example, many objects support the verbs Edit and Play. You can use the ObjectVerbs and ObjectVerbsCount properties to find out which verbs are supported by an object.

Microsoft Access automatically uses an object's default verb if the user double-clicks an object for which the AutoActivate property is set to Double-Click.

Example

The following example activates the control "OLEUnbound0" in the form "frmOperations" by opening up the OLE object in its own application window for editing. In this case, "OLEUnbound0" contains a new bitmap image, which is linked to the Microsoft Paint program.

VBA Copy code Copy code
With Forms.Item("frmOperations").Controls.Item("OLEUnbound0")
 .Action = acOLEActivate
 .Verb = acOLEVerbOpen
End With

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Required Client Settings

 Copy code hover
[image]

Required Client Settings
Send feedback

Published: July 16, 2012

Specify the following settings to use a custom DataFactory handler.

  • Specify "Provider=MS Remote" in the Connection object Provider property or the Connection object connection string "Provider=" keyword.

  • Set the CursorLocation property to adUseClient.

  • Specify the name of the handler to use in the RDS.DataControl object's Handler property, or the Recordset object's connection string "Handler=" keyword. (You cannot set the handler in the Connection object connect string.)

RDS provides a default handler on the server named MSDFMAP.Handler. (The default customization file is named MSDFMAP.INI.)

Example

Assume that the following sections in MSDFMAP.INI and the data source name, AdvWorks, have been previously defined:

Copy code Copy code

[connect CustomerDataBase]
Access=ReadWrite
Connect="DSN=AdvWorks"

[sql CustomerById]
SQL="SELECT * FROM Customers WHERE CustomerID = ?"

The following code snippets are written in Visual Basic:

RDS.DataControl Version

Copy code Copy code

Dim dc as New RDS.DataControl
Set dc.Handler = "MSDFMAP.Handler"
Set dc.Server = "http://yourServer"
Set dc.Connect = "Data Source=CustomerDatabase"
Set dc.SQL = "CustomerById(4)"
dc.Refresh

Recordset Version

Copy code Copy code

Dim rs as New ADODB.Recordset
rs.CursorLocation = adUseClient

Specify either the Handler property or keyword; the Provider property or keyword; and the CustomerById and CustomerDatabase identifiers. Then open the Recordset object.

Copy code Copy code

rs.Open "CustomerById(4)", "Handler=MSDFMAP.Handler;" & _
   "Provider=MS Remote;Data Source=CustomerDatabase;" & _
   "Remote Server=http://yourServer"


UpdateRule Property (ADOX)

 Copy code hover
[image]

UpdateRule Property (ADOX)
Send feedback

Indicates the action performed when a primary key is updated.

Settings and Return Values

Sets and returns a Long value that can be one of the RuleEnum constants. The default value is adRINone.

Remarks

This property is read-only on Key objects already appended to the collection.


There is no field named

 Copy code hover
[image]

There is no field named <name> in table <name>. (Error 3381)
Send feedback

The specified table does not contain the specified field. Check the spelling of the field name. You should also check to see if the field name exists in the Fields collection.


QueryDefStateEnum Enumeration (DAO)

 Copy code hover
[image]

QueryDefStateEnum Enumeration (DAO)
Send feedback

Used with the Prepare property to specify the method used to specify how a query should be prepared.

Name | Value | Description
dbQPrepare | 1 | (Default) The statement is prepared (that is, the ODBC SQLPrepare API is called).
dbQUnprepare | 2 | The statement is not prepared (that is, the ODBC SQLExecDirect API is called).


SmartTagActions.Item Property (Access)

 Copy code hover
[image]

SmartTagActions.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only SmartTagAction.

Syntax

expression .Item(Index)

expression A variable that represents a SmartTagActions object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

SmartTagActions Collection

Other resources

SmartTagActions Object Members


ExitForEachRecord Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

ExitForEachRecord Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Use the ExitForEachRecord action to immediately exit a ForEachRecord data block.

Note Note

The ExitForEachRecord action is available only in Data Macros.


In Operator (Microsoft Access SQL)

 Copy code hover
[image]

In Operator (Microsoft Access SQL)
Send feedback

Published: July 16, 2012

Determines whether the value of an expression is equal to any of several values in a specified list.

Syntax

expr [Not] In(value1, value2, …)

Remarks

The In operator syntax has these parts:

Part | Description
expr | Expression identifying the field that contains the data you want to evaluate.
value1, value2 | Expression or list of expressions against which you want to evaluate expr.

If expr is found in the list of values, the In operator returns True; otherwise, it returns False. You can include the Not logical operator to evaluate the opposite condition (that is, whether expr is not in the list of values).

For example, you can use In to determine which orders are shipped to a set of specified regions:

SQL Copy code Copy code
SELECT *
FROM Orders
WHERE ShipRegion In ('Avon','Glos','Som')

Example

The following example uses the Orders table in the Northwind.mdb database to create a query that includes all orders shipped to Lancashire and Essex and the dates shipped.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

VBA Copy code Copy code
Sub InX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Select records from the Orders table that
    ' have a ShipRegion value of Lancashire or Essex.
    Set rst = dbs.OpenRecordset("SELECT " _
        & "CustomerID, ShippedDate FROM Orders " _
        & "WHERE ShipRegion In " _
        & "('Lancashire','Essex');")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of
    ' the Recordset.
    EnumFields rst, 12

    dbs.Close

End Sub


NavigationButton.NavigationWhereClause Property (Access)

 Copy code hover
[image]

NavigationButton.NavigationWhereClause Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the filter criteria applied when opening the form or report associated with the specified navigation button. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .NavigationWhereClause

expression A variable that represents a NavigationButton object.

Remarks

Use the NavigationWhereClaue property to specify a subset of records to be displayed whent he user clicks the navigation button.

The NavigationWhereClaue property is a string expression consisting of a WHERE clause without the WHERE keyword.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


TextBox.Undo Event (Access)

 Copy code hover
[image]

TextBox.Undo Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when the user undoes a change.

Syntax

expression .Undo(Cancel, )

expression A variable that represents a TextBox object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | Set this argument to True to cancel the undo operation and leave the control or form in its edited state.

Remarks

The Undo event for controls occurs whenever the user returns a control to its original state by clicking the Undo Field/Record button on the command bar, clicking the Undo button, pressing the ESC key, or calling the Undo method of the specified control. The control needs to have focus in all three cases. The event does not occur if the user clicks the Undo Typing button on the command bar.

Example

The following example demonstrates the syntax for a subroutine that traps the Undo event for a form.

VBA Copy code Copy code
Private Sub Form_Undo(Cancel As Integer)
 Dim intResponse As Integer
 Dim strPrompt As String

 strPrompt = "Cancel the undo operation?"

 intResponse = MsgBox(strPrompt, vbYesNo)

 If intResponse = vbYes Then
 Cancel = True
 Else
 Cancel = False
 End If
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Form.TimerInterval Property (Access)

 Copy code hover
[image]

Form.TimerInterval Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TimerInterval property to specify the interval, in milliseconds, between Timer events on a form. Read/write Long.

Syntax

expression .TimerInterval

expression A variable that represents a Form object.

Remarks

The TimerInterval property setting is a Long Integer value between 0 and 2,147,483,647.

You can set this property by using the form's property sheet, a macro, or Visual Basic.

Note Note

When using Visual Basic, you set the TimerInterval property in the form's Load event.

To run Visual Basic code at intervals specified by the TimerInterval property, put the code in the form's Timer event procedure. For example, to requery records every 30 seconds, put the code to requery the records in the form's Timer event procedure, and then set the TimerInterval property to 30000.

Link provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Delay Event/Actions for Set Time Interval

Example

The following example shows how to create a flashing button on a form by displaying and hiding an icon on the button. The form's Load event procedure sets the form's TimerInterval property to 1000 so the icon display is toggled once every second.

VBA Copy code Copy code
Sub Form_Load()
    Me.TimerInterval = 1000
End Sub

Sub Form_Timer()
    Static intShowPicture As Integer
    If intShowPicture Then
        ' Show icon.
        Me!btnPicture.Picture = "C:\Icons\Flash.ico"
    Else
        ' Don't show icon.
        Me!btnPicture.Picture = ""
    End If
    intShowPicture = Not intShowPicture
End Sub

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

Form Object

Other resources

Form Object Members


Attachment.GridlineColor Property (Access)

 Copy code hover
[image]

Attachment.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified attachment. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineColor

expression A variable that represents an Attachment object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Label.Layout Property (Access)

 Copy code hover
[image]

Label.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified label. Read-only AcLayoutType.

Version Information

Version Added: Access 2007

Syntax

expression .Layout

expression A variable that represents a Label object.

See also

Concepts

Label Object

Other resources

Label Object Members


Section.Parent Property (Access)

 Copy code hover
[image]

Section.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a Section object.

See also

Concepts

Section Object

Other resources

Section Object Members


SubForm.SetFocus Method (Access)

 Copy code hover
[image]

SubForm.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Syntax

expression .SetFocus

expression A variable that represents a SubForm object.

Return Value

Nothing

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.

Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.

Example

The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:

VBA Copy code Copy code
Forms!Employees!EmployeeID.SetFocus

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Calling the Windows API (Differences in String Function Operations)

 Copy code hover
[image]

Calling the Windows API (Differences in String Function Operations)
Send feedback

Published: July 16, 2012

The memory storage formats for text differ between Visual Basic for Applications (VBA) code and Access Basic code. (Access Basic was used in early versions of Microsoft Access.) Text is stored in ANSI format within Access Basic code and in Unicode format in Visual Basic. This topic discusses one potential issue when handling strings in the current version of Microsoft Access. For more information, see Differences in String Function Operations.

In several Windows API functions, the byte length of a string has a special meaning. For example, the following program returns a folder set up in Windows. In Microsoft Access, LeftB(Buffer, ret) does not return the correct string. This is because, in spite of the fact that it shows the byte length of an ANSI string, the LeftB function processes Unicode strings. In this case, use the InStr function so that only the character string, without nulls, is returned.

Copy code Copy code
Private Declare Function GetWindowsDirectory Lib "kernel32" _
 Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, _
 ByVal nSize As Long) As Long

Private Sub Command1_Click()
 Buffer$ = Space(255)
 ret = GetWindowsDirectory(Buffer$, 255)
 ' WinDir = LeftB(Buffer, ret) '<--- Incorrect code"

 WinDir = Left(Buffer$, InStr(Buffer$, Chr(0)) - 1)
 '<--Correct code"
 Print WinDir
End Sub


Line.SizeToFit Method (Access)

 Copy code hover
[image]

Line.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents a Line object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

Line Object

Other resources

Line Object Members


AcLayoutType Enumeration (Access)

 Copy code hover
[image]

AcLayoutType Enumeration (Access)
Send feedback

Published: July 16, 2012

Insert introduction here.

Section Heading

Insert section body here.

Subsection Heading

Insert subsection body here.


DateCreated Property (ADOX)

 Copy code hover
[image]

DateCreated Property (ADOX)
Send feedback

Indicates the date the object was created.

Return Values

Returns a Variant value specifying the date created. The value is null if DateCreated is not supported by the provider.

Remarks

The DateCreated property is null for newly appended objects. After appending a new View or Procedure, you must call the Refresh method of the Views or Procedures collection to obtain values for the DateCreated property.


Type Property Example (Field) (VJ++)

 Copy code hover
[image]

Type Property Example (Field) (VJ++)
Send feedback

This example demonstrates the Type property by displaying the name of the constant that corresponds to the value of the Type property of all the Field objects in the Employees table. The FieldType function is required for this procedure to run.

Copy code Copy code

// BeginFieldTypeJ
import java.io.*;
import com.ms.wfc.data.*;

public class TypeFieldX
{

 // The main entry point of the application.

 public static void main (String[] args)
 {
 TypeFieldX();
 System.exit(0);
 }

 // TypeFieldX Function
 static void TypeFieldX()
 {
 // Define ADO Objects.
 Recordset rstEmployees = null;
 Field fldLoop = null;

 // Declarations.
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"+
 "Initial Catalog='Pubs';Integrated Security='SSPI';";
 int intLoop;
 int intRecordCount = 0;
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));

 try
 {
 // Open the Recordset with data from Employees table.
 rstEmployees = new Recordset();
 rstEmployees.open("employee", strCnn,
 AdoEnums.CursorType.FORWARDONLY, AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TABLE);

 System.out.println("Fields in the Employees table:\n");

 // Enumerate fields collection of Employees table.
 for(intLoop = 0;intLoop <
 rstEmployees.getFields().getCount();intLoop++)
 {
 intRecordCount++;
 // Loop needed for display of records
 if((intRecordCount % 6)==0)
 {
 System.out.println("Press <Enter> to continue..");
 in.readLine();
 }

 fldLoop = rstEmployees.getFields().getItem(intLoop);
 System.out.println(" Name:" + fldLoop.getName() + "\n"+
 " Type:" + FieldType(fldLoop.getType()) + "\n");

 }
 System.out.println("Press <Enter> to continue");
 in.readLine();
 }
 catch(AdoException ae)
 {
 // Notify the user of any errors that result from ADO.

 // As passing a Recordset, check for the null pointer first.
 if(rstEmployees != null)
 {
 PrintProviderError(rstEmployees.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 // System read requires this catch.
 catch(java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstEmployees != null)
 if (rstEmployees.getState() == 1)
 rstEmployees.close();
 }
 }
 // FieldType Function
 static String FieldType( int intType )
 {
 String strLoop = null;

 switch(intType)
 {
 case AdoEnums.DataType.CHAR:
 strLoop = "adChar";
 break;
 case AdoEnums.DataType.VARCHAR:
 strLoop ="adVarChar";
 break;
 case AdoEnums.DataType.SMALLINT:
 strLoop = "adSmallInt";
 break;
 case AdoEnums.DataType.UNSIGNEDTINYINT:
 strLoop = "adUnsignedTinyInt" ;
 break;
 case AdoEnums.DataType.DBTIMESTAMP:
 strLoop = "adDBTimeStamp";
 break;
 default:
 break;
 }

 return strLoop;
 }

 // PrintProviderError Function
 static void PrintProviderError(Connection cnn1)
 {
 // Print Provider Errors from Connection Object.
 // ErrItem is an item object in the Connections Errors Collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if ( nCount > 0)
 {
 // Collection ranges from 0 to nCount-1.
 for ( i=0;i<nCount; i++)
 {
 ErrItem = cnn1.getErrors().getItem(i);
 System.out.println("\t Error Number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription());
 }
 }
 }
 // PrintIOError Function
 static void PrintIOError(java.io.IOException je)
 {
 System.out.println("Error: \n");
 System.out.println("\t Source: " + je.getClass() + "\n");
 System.out.println("\t Description: "+ je.getMessage() + "\n");
 }
}
// EndFieldTypeJ


ToggleButton.GridlineWidthRight Property (Access)

 Copy code hover
[image]

ToggleButton.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified toggle button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthRight

expression A variable that represents a ToggleButton object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


The system object used by a process still exists after the process has stopped. (Error 3533)

 Copy code hover
[image]

The system object used by a process still exists after the process has stopped. (Error 3533)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


Form.MouseWheel Event (Access)

 Copy code hover
[image]

Form.MouseWheel Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when the user rolls the mouse wheel in Form View, Split Form View, Datasheet View, Layout View, PivotChart View, or PivotTable View.

Syntax

expression .MouseWheel(Page, Count)

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Page | Required | Boolean | True if the page was changed.
Count | Required | Long | The number of lines by which the view was scrolled with the mouse wheel.

Example

The following example demonstrates the syntax for a subroutine that traps the MouseWheel event.

VBA Copy code Copy code
Private Sub Form_MouseWheel( _
 ByVal Page As Boolean, ByVal Count As Long)
 If Page = True Then
 MsgBox "You've moved to another page."
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Property Object (ADO)

 Copy code hover
[image]

Property Object (ADO)
Send feedback

Represents a dynamic characteristic of an ADO object that is defined by the provider.

Remarks

ADO objects have two types of properties: built-in and dynamic.

Built-in properties are those properties implemented in ADO and immediately available to any new object, using the syntax. They do not appear as Property objects in an object's Properties collection, so although you can change their values, you cannot modify their characteristics.

Dynamic properties are defined by the underlying data provider, and appear in the Properties collection for the appropriate ADO object. For example, a property specific to the provider may indicate if a Recordset object supports transactions or updating. These additional properties will appear as Property objects in that Recordset object's Properties collection. Dynamic properties can be referenced only through the collection, using the MyObject.Properties(0) or or MyObject.Properties("Name") syntax.

You cannot delete either kind of property.

A dynamic Property object has four built-in properties of its own:

  • The Name property is a string that identifies the property.

  • The Type property is an integer that specifies the property data type.

  • The Value property is a variant that contains the property setting. Value is the default property for a Property object.

  • The Attributes property is a long value that indicates characteristics of the property specific to the provider.


Registering a Custom Business Object

 Copy code hover
[image]

Registering a Custom Business Object
Send feedback

Published: July 16, 2012

To successfully launch a custom business object (.dll or .exe) through the Web server, the business object's ProgID must be entered into the registry as explained in this procedure. This RDS feature protects the security of your Web server by running only sanctioned executables.

Note Note

For MDAC 2.0 and later, the default business object, RDSServer.DataFactory, is not registered by default during MDAC installation. However, if RDSServer.DataFactory was registered as safe for execution on the computer prior to the installation, the registry entry is maintained for the new installation.

To register a custom business object

  1. Click Start and then click Run.

  2. Type RegEdit and click OK.

  3. In the Registry Editor, navigate to the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\W3SVC\Parameters\ADCLaunch registry key.

  4. Select the ADCLaunch key, and then from the Edit menu, point to New and click Key.

  5. Type the ProgID of your custom business object and click Enter. Leave the Value entry blank.


Section Properties (Access)

 Copy code hover
[image]

Section Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
AlternateBackColor | Gets or sets the background color to display on alternate rows of the specified section. Read/write Long.
AlternateBackShade | Gets or sets the shade applied to the theme color in the AlternateBackColor property of the section. Read/write Single.
AlternateBackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the AlternateBackColor property of the section. Read/write Long.
AlternateBackTint | Gets or sets the tint applied to the theme color in the AlternateBackColor property of the section. Read/write Single.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
AutoHeight | Gets or sets whether a section's height is adjusted automatically when controls are resized. Read/write Boolean.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
CanGrow | Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the control contains. Read/write Boolean.
CanShrink | Gets or sets whether the specified control automatically adjusts vertically to print or preview all the data the section or control contains. Read/write Boolean.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's sections you want displayed on screen and in print. Read/write Byte.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
ForceNewPage | You can use the ForceNewPage property to specify whether form sections detail, footer) or report sections (header, detail, footer) print on a separate page, rather than on the current page. Read/write Byte.
HasContinued | You can use the HasContinued property to determine if part of the current section begins on the previous page. Read/write Boolean.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
KeepTogether | You can use the KeepTogether property for a section to print a form or report section all on one page. For example, you might have a group of related information that you don't want printed across two pages. The KeepTogether property applies only to form and report sections (except page headers and page footers). Read/write Boolean.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
NewRowOrCol | You can use the NewRowOrCol property to specify whether a section and its associated data is printed in a new row or column within a multiple-column report or multiple-column form. Read/write Byte.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnFormat | Sets or returns the value of the On Format box in the Properties window of a report section. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
OnPaint | Sets or returns the value of the On Paint box in the Properties window of a form or report. Read/write String.
OnPrint | Sets or returns the value of the On Print box in the Properties window of a report section. Read/write String.
OnRetreat | Sets or returns the value of the On Retreat box in the Properties window of a report section. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Properties | Returns a reference to a control's Properties collection object. Read-only.
RepeatSection | You can use the RepeatSection property to specify whether a group header is repeated on the next page or column when a group spans more than one page or column. Read/write Boolean.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
WillContinue | Determines if the current section will continue on the following page. Read/write Boolean.


Cannot synchronize a partial replica with another partial replica. (Error 3648)

 Copy code hover
[image]

Cannot synchronize a partial replica with another partial replica. (Error 3648)
Send feedback

The database you are trying to synchronize with is a partial replica. You cannot synchronize a partial replica with another partial replica, because the other partial replica may not contain all records that satisfy your partial replica's filter.


SourceConnectStr, SourceDatabase Properties

 Copy code hover
[image]

SourceConnectStr, SourceDatabase Properties
Send feedback

Published: July 16, 2012

You can use these properties to access external data when you can't link the external tables to your database.

  • The SourceConnectStr property specifies the name of the application used to create an external database.

  • The SourceDatabase property specifies the external database in which the source tables or queries for a query reside.

Note Note

The SourceConnectStr and SourceDatabase properties apply to all queries except data-definition, pass-through, and union queries.

Setting

You use a string expression to set the value of the SourceConnectStr and SourceDatabase properties.

You can set these properties in the query's property sheet or in SQL view of the Query window. In the SQL statement, the properties correspond to the IN clause.

Note Note

If you are accessing multiple database sources, use the Source property instead of the SourceConnectStr and SourceDatabase properties.

Remarks

You must use the SourceConnectStr and SourceDatabase properties to access tables from external databases that were created in applications that don't use linked tables.

The following are examples of these property settings:

  • For a Microsoft Access database, the SourceDatabase property setting is the path and database name (for example, C:\Accounts\Customers). Microsoft Access adds the file name extension automatically. The SourceConnectStr property doesn't have a value for a Microsoft Access database.

  • For a database created by a product such as Paradox, the SourceDatabase property setting is the path (for example, C:\Pdoxdata). The SourceConnectStr property setting is the specifier for the database type (for example, Paradox 3.x;). For a list of specifiers, see the DAO Connect property.

  • The following example uses dBASE IV tables in the C:\Dbdata directory as the source of data for the query.

    Copy code Copy code
    SELECT Customer.COMPANYNAM, Orders.ORDERID, Orders.ORDERDATE
FROM Customer INNER JOIN Orders
ON Customer.CUSTOMERID = Orders.CUSTOMERID
IN 'C:\Dbdata'[dBASE IV;];

  • For an Open Database Connectivity (ODBC) database, the SourceConnectStr property setting is the name of the source database and any additional information required by the product, such as a logon identification (ID) and password. For example, for a Microsoft SQL Server database the setting might be:

    Copy code Copy code
    ODBC;DSN=salessrv;UID=jace;PWD=password;DATABASE=sales;

The SourceDatabase property doesn't have a value for an ODBC database.


No such relationship

 Copy code hover
[image]

No such relationship <name> on table <name>. (Error 3377)
Send feedback

The relationship you specified does not exist in this database. Check to see if the name you specified exists in the Relations collection.


Report Events (Access)

 Copy code hover
[image]

Report Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
Activate | The Activate event occurs when a report receives the focus and becomes the active window.
ApplyFilter | Occurs when a filter is applied to a report.
Click | The Click event occurs when the user presses and then releases a mouse button over a report.
Close | The Close event occurs when a report is closed and removed from the screen.
Current | Occurs when the focus moves to a record, making it the current record, or when the report is refreshed or requeried.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an report within the double-click time limit of the system.
Deactivate | The Deactivate event occurs when a report loses the focus to a Table, Query, Form, Report, Macro, or Module window, or to the Database window.
Error | The Error event occurs when a run-time error is produced in Microsoft Access when a report has the focus.
Filter | Occurs when the user opens a filter window by clicking Advanced Filter/Sort.
GotFocus | The GotFocus event occurs when the report receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a report has the focus. This event also occurs if you send a keystroke to a report by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a report has the focus. This event also occurs if you send an ANSI keystroke to a report by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a report has the focus. This event also occurs if you send a keystroke to a report by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
Load | Occurs when a report is opened and its records are displayed.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.
MouseWheel | Occurs when the user rolls the mouse wheel in Report view or Layout view.
NoData | The NoData event occurs after Microsoft Access formats a report for printing that has no data (the report is bound to an empty recordset), but before the report is printed. You can use this event to cancel printing of a blank report.
Open | The Open occurs before a report is previewed or printed.
Page | The Page event occurs after Microsoft Access formats a page of a report for printing, but before the page is printed. You can use this event to draw a border around the page, or add other graphic elements to the page.
Resize | The Resize event occurs when a report is opened and whenever the size of a report changes.
Timer | The Timer event occurs for a report at regular intervals as specified by the report's TimerInterval property.
Unload | The Unload event occurs after a report is closed but before it's removed from the screen.


RepaintObject, ShowAllRecords, Requery, and Refresh Action/Method Comparison

 Copy code hover
[image]

RepaintObject, ShowAllRecords, Requery, and Refresh Action/Method Comparison
Send feedback

Published: July 16, 2012

The following table provides a brief comparison of the RepaintObject action, RepaintObject method, Repaint method, ShowAllRecords action, ShowAllRecords method, Requery action, DoCmd.Requery method, Refresh method, and Requery method.

Action or Method

Description

RepaintObject action
DoCmd.RepaintObject, Repaint method

Use the RepaintObject action, RepaintObject method or Repaint method to repaint controls in the specified object. They don't requery the database or display new records.

ShowAllRecords action
ShowAllRecords method

Use the ShowAllRecords action to requery and display the most recent records and remove any applied filters, which the Requery action doesn't do.

Requery action
DoCmd.Requery method

Use the Requery action or method to requery the source of the object or one of its controls. The Requery action or method does one of the following: Reruns the query on which the control or object is based. Displays any new or changed records, and removes any deleted records from the table on which the control or object is based.

Refresh method

Use the Refresh method to immediately update the records in the underlying record source for a specified form or datasheet to reflect changes made to the data by you and other users in a multiuser environment. The Refresh method shows only changes that have been made to the current set of records; it doesn't reflect new records or deleted records in the record source.

Requery method

  • Use the Requery method to update the data underlying a form or control to reflect records that are new to or have been deleted from the record source since it was last requeried. If you want to requery a control that isn't on the active object, you must use this method, not the Requery action or its corresponding DoCmd.Requery method.


XML Security Considerations
Send feedback

XML Security Considerations

The ADO Save and Open methods on the Recordset object are not considered safe operations to run in Internet Explorer. Thus, if these methods are used in a script code that is running in an application or control that is hosted in a browser, the security configuration of the browser will have an effect on its behavior.

Internet Explorer 5 provides security restrictions for such operations by default in the Internet zones. Under that configuration, the Recordset cannot make any access to the local file system on the client or access any data sources outside the domain of the server from which the page has been downloaded. Specifically, when running inside the browser host, a Recordset can be saved back to a file only if it is on the same server from which the page was downloaded. Similarly, you can open a Recordset by loading it from a file only if that file is on the same server from which the page was downloaded.

For more information about security in Internet Explorer, see the technical article "ADO and RDS Security Issues in Microsoft Internet Explorer."


CommandButton.GridlineColor Property (Access)

 Copy code hover
[image]

CommandButton.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified command button. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineColor

expression A variable that represents a CommandButton object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Application.Parent Property (Access)

 Copy code hover
[image]

Application.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents an Application object.

See also

Concepts

Application Object

Other resources

Application Object Members


Number of query values and destination fields are not the same. (Error 3346)

 Copy code hover
[image]

Number of query values and destination fields are not the same. (Error 3346)
Send feedback

The INSERT INTO (append) query either does not have enough destination fields or it has more fields in the VALUES or SELECT list than there are fields in the destination table. Select a matching number of fields.


Report.OnTimer Property (Access)

 Copy code hover
[image]

Report.OnTimer Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Timer box in the Properties window of a form. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .OnTimer

expression A variable that represents a Report object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Timer event occurs for a report at regular intervals as specified by the report's TimerInterval property.

The OnTimer value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Timer box in the report's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Timer box is blank, the property value is an empty string.

See also

Concepts

Report Object

Other resources

Report Object Members


Cannot find table or constraint. (Error 3371)

 Copy code hover
[image]

Cannot find table or constraint. (Error 3371)
Send feedback

The table or relationship you specified does not exist. Specify a valid table or constraint name.


ADOX Code Example Topics

 Copy code hover
[image]

ADOX Code Example Topics
Send feedback

In this section

  • ADOX Code Examples

  • ADOX Code Examples in Microsoft Visual Basic Topics

  • ADOX Code Examples in Microsoft Visual C++ Topics


Module.ProcStartLine Property (Access)

 Copy code hover
[image]

Module.ProcStartLine Property (Access)
See also Send feedback

Published: July 16, 2012

The ProcStartLine property returns avalue identifying the line at which a specified procedure begins in a standard module or a class module. Read-only Long.

Syntax

expression .ProcStartLine(ProcName, ProcKind)

expression A variable that represents a Module object.

Parameters

Name | Required/Optional | Data Type | Description
ProcName | Required | String | The name of a procedure in the module.
ProcKind | Required | vbext_ProcKind | The type of procedure. See the Remarks section for the possible settings.

Remarks

The ProcKind argument can be one of the following vbext_ProcKind constants:

Constant | Description
vbext_pk_Get | A Property Get procedure.
vbext_pk_Let | A Property Let procedure.
vbext_pk_Proc | A Sub or Function procedure.
vbext_pk_Set | A Property Set procedure.

A procedure begins with any comments and compilation constants that immediately precede the procedure definition, denoted by one of the following:

  • A Sub statement.

  • A Function statement.

  • A Property Get statement.

  • A Property Let statement.

  • A Property Set statement.

The ProcStartLine property returns the number of the line on which the specified procedure begins. The beginning of the procedure may include comments or compilation constants that precede the procedure definition.

To determine the line on which the procedure definition begins, use the ProcBodyLine property. This property returns the number of the line that begins with a Sub, Function, Property Get, Property Let, or Property Set statement.

The ProcStartLine and ProcBodyLine properties can have the same value, if the procedure definition is the first line of the procedure. If the procedure definition isn't the first line of the procedure, the ProcBodyLine property will have a greater value than the ProcStartLine property.

It may be easier to determine where a procedure begins if you have the Procedure Separator option selected. With this option selected, there is a line between the end of a procedure and the beginning of the next procedure. The first line of code (or blank line) below the procedure separator is the first line of the following procedure, which is the line returned by the ProcStartLine property. The Procedure Separator option is located on the Editor tab of the Options dialog box, available by clicking Options on the Tools menu.

Note Note

The ProcCountLines property treats Sub and Function procedures similarly, but distinguishes between each type of Property procedure.

Example

The following example displays a message indicating where a particular procedure starts in a particular form module.

VBA Copy code Copy code
Dim strForm As String
Dim strProc As String

strForm = "Products"
strProc = "Form_Activate"

MsgBox "The procedure " & strProc & " starts on line " & _
 Forms(strForm).Module.ProcStartLine(strProc, vbext_pk_Proc) & "."

See also

Concepts

Module Object

Other resources

Module Object Members


Indexes Object Reference (DAO)

 Copy code hover
[image]

Indexes Object Reference (DAO)
Send feedback

In this section

  • Indexes Collection (DAO)

  • Indexes Members (DAO)

  • Indexes Properties (DAO)

  • Indexes Methods (DAO)


ADO Code Examples

 Copy code hover
[image]

ADO Code Examples
Send feedback

Use the following code examples to learn how to use the ADO objects, methods, properties, and events.

Note Note

Paste the entire code example into your code editor. The example may not run correctly if partial examples are used or if paragraph formatting is lost.

  • ADO Code Examples in Microsoft Visual Basic

  • ADO Code Examples in Microsoft Visual Basic Scripting Edition

  • ADO Code Examples in Microsoft Visual C++

  • ADO Code Examples in Microsoft Visual J++

  • ADO Code Examples in Microsoft JScript


EmptyCell.IsVisible Property (Access)

 Copy code hover
[image]

EmptyCell.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Version Information

Version Added: Access 2010

Syntax

expression .IsVisible

expression A variable that represents an EmptyCell object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


BoundObjectFrame.DisplayWhen Property (Access)

 Copy code hover
[image]

BoundObjectFrame.DisplayWhen Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.

Syntax

expression .DisplayWhen

expression A variable that represents a BoundObjectFrame object.

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks) on a form.

The DisplayWhen property uses the following settings.

Setting | Visual Basic | Description
Always | 0 | (Default) The object appears in Form view and when printed.
Print Only | 1 | The object is hidden in Form view but appears when printed.
Screen Only | 2 | The object appears in Form view but not when printed.

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls you don't want printed. You can also cancel the Format or Print event for a report section to prevent the section from being printed.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


WebBrowserControl.Progress Property (Access)

 Copy code hover
[image]

WebBrowserControl.Progress Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies the amount of total progress of a download operation. Read-only Long.

Version Information

Version Added: Access 2010

Syntax

expression .Progress

expression A variable that represents a WebBrowserControl object.

Remarks

The Progress property contains -1 when the download operation is complete.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


WebBrowserControl.SetFocus Method (Access)

 Copy code hover
[image]

WebBrowserControl.SetFocus Method (Access)
See also Send feedback

Published: July 16, 2012

The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.

Version Information

Version Added: Access 2010

Syntax

expression .SetFocus

expression A variable that represents a WebBrowserControl object.

Remarks

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.

In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.

Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.

You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.

You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.

You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (-1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.

You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.

Example

The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:

VBA Copy code Copy code
Forms!Employees!EmployeeID.SetFocus

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Recordset.Seek Method (DAO)

 Copy code hover
[image]

Recordset.Seek Method (DAO)
Send feedback

Locates the record in an indexed table-type Recordset object that satisfies the specified criteria for the current index and makes that record the current record (Microsoft Access workspaces only).

Syntax

expression .Seek(Comparison, Key1, Key2, Key3, Key4, Key5, Key6, Key7, Key8, Key9, Key10, Key11, Key12, Key13)

expression A variable that represents a Recordset object.

Parameters

Name | Required/Optional | Data Type | Description
Comparison | Required | String | One of the following string expressions: <, <=, =, >=, or >.
Key1, Key2...Key13 | Required | Variant | One or more values corresponding to fields in the Recordset object's current index, as specified by its Index property setting. You can use up to 13 key arguments.

Remarks

You must set the current index with the Index property before you use Seek. If the index identifies a nonunique key field, Seek locates the first record that satisfies the criteria.

The Seek method searches through the specified key fields and locates the first record that satisfies the criteria specified by comparison and key1. Once found, it makes that record current and sets the NoMatch property to False. If the Seek method fails to locate a match, the NoMatch property is set to True, and the current record is undefined.

If comparison is equal (=), greater than or equal (>=), or greater than (>), Seek starts at the beginning of the index and searches forward.

If comparison is less than (<) or less than or equal (<=), Seek starts at the end of the index and searches backward. However, if there are duplicate index entries at the end of the index, Seek starts at an arbitrary entry among the duplicates and then searches backward.

You must specify values for all fields defined in the index. If you use Seek with a multiple-column index, and you don't specify a comparison value for every field in the index, then you cannot use the equal (=) operator in the comparison. That's because some of the criteria fields (key2, key3, and so on) will default to Null, which will probably not match. Therefore, the equal operator will work correctly only if you have a record which is all null except the key you're looking for. It's recommended that you use the greater than or equal (>=) operator instead.

The key1 argument must be of the same field data type as the corresponding field in the current index. For example, if the current index refers to a number field (such as Employee ID), key1 must be numeric. Similarly, if the current index refers to a Text field (such as Last Name), key1 must be a string.

There doesn't have to be a current record when you use Seek.

You can use the Indexes collection to enumerate the existing indexes.

To locate a record in a dynaset- or snapshot-type Recordset that satisfies a specific condition that is not covered by existing indexes, use the Find methods. To include all records, not just those that satisfy a specific condition, use the Move methods to move from record to record.

You can't use the Seek method on a linked table because you can't open linked tables as table-type Recordset objects. However, if you use the OpenDatabase method to directly open an installable ISAM (non-ODBC) database, you can use Seek on tables in that database.

Example

This example demonstrates the Seek method by allowing the user to search for a product based on an ID number.

VBA Copy code Copy code
Sub SeekX()

   Dim dbsNorthwind As Database
   Dim rstProducts As Recordset
   Dim intFirst As Integer
   Dim intLast As Integer
   Dim strMessage As String
   Dim strSeek As String
   Dim varBookmark As Variant

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   ' You must open a table-type Recordset to use an index,
   ' and hence the Seek method.
   Set rstProducts = _
      dbsNorthwind.OpenRecordset("Products", dbOpenTable)

   With rstProducts
      ' Set the index.
      .Index = "PrimaryKey"

      ' Get the lowest and highest product IDs.
      .MoveLast
      intLast = !ProductID
      .MoveFirst
      intFirst = !ProductID

      Do While True
         ' Display current record information and ask user
         ' for ID number.
         strMessage = "Product ID: " & !ProductID & vbCr & _
            "Name: " & !ProductName & vbCr & vbCr & _
            "Enter a product ID between " & intFirst & _
            " and " & intLast & "."
         strSeek = InputBox(strMessage)

         If strSeek = "" Then Exit Do

         ' Store current bookmark in case the Seek fails.
         varBookmark = .Bookmark

         .Seek "=", Val(strSeek)

         ' Return to the current record if the Seek fails.
         If .NoMatch Then
            MsgBox "ID not found!"
            .Bookmark = varBookmark
         End If
      Loop

      .Close
   End With

   dbsNorthwind.Close

End Sub

This example uses the NoMatch property to determine whether a Seek and a FindFirst were successful, and if not, to give appropriate feedback. The SeekMatch and FindMatch procedures are required for this procedure to run.

VBA Copy code Copy code
Sub NoMatchX()

   Dim dbsNorthwind As Database
   Dim rstProducts As Recordset
   Dim rstCustomers As Recordset
   Dim strMessage As String
   Dim strSeek As String
   Dim strCountry As String
   Dim varBookmark As Variant

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   ' Default is dbOpenTable; required if Index property will
   ' be used.
   Set rstProducts = dbsNorthwind.OpenRecordset("Products")

   With rstProducts
      .Index = "PrimaryKey"

      Do While True
         ' Show current record information; ask user for
         ' input.
         strMessage = "NoMatch with Seek method" & vbCr & _
            "Product ID: " & !ProductID & vbCr & _
            "Product Name: " & !ProductName & vbCr & _
            "NoMatch = " & .NoMatch & vbCr & vbCr & _
            "Enter a product ID."
         strSeek = InputBox(strMessage)
         If strSeek = "" Then Exit Do

         ' Call procedure that seeks for a record based on
         ' the ID number supplied by the user.
         SeekMatch rstProducts, Val(strSeek)
      Loop

      .Close
   End With

   Set rstCustomers = dbsNorthwind.OpenRecordset( _
      "SELECT CompanyName, Country FROM Customers " & _
      "ORDER BY CompanyName", dbOpenSnapshot)

   With rstCustomers

      Do While True
         ' Show current record information; ask user for
         ' input.
         strMessage = "NoMatch with FindFirst method" & _
            vbCr & "Customer Name: " & !CompanyName & _
            vbCr & "Country: " & !Country & vbCr & _
            "NoMatch = " & .NoMatch & vbCr & vbCr & _
            "Enter country on which to search."
         strCountry = Trim(InputBox(strMessage))
         If strCountry = "" Then Exit Do

         ' Call procedure that finds a record based on
         ' the country name supplied by the user.
         FindMatch rstCustomers, _
            "Country = '" & strCountry & "'"
      Loop

      .Close
   End With

   dbsNorthwind.Close

End Sub

Sub SeekMatch(rstTemp As Recordset, _
   intSeek As Integer)

   Dim varBookmark As Variant
   Dim strMessage As String

   With rstTemp
      ' Store current record location.
      varBookmark = .Bookmark
      .Seek "=", intSeek

      ' If Seek method fails, notify user and return to the
      ' last current record.
      If .NoMatch Then
         strMessage = _
            "Not found! Returning to current record." & _
            vbCr & vbCr & "NoMatch = " & .NoMatch
         MsgBox strMessage
         .Bookmark = varBookmark
      End If

   End With

End Sub

Sub FindMatch(rstTemp As Recordset, _
   strFind As String)

   Dim varBookmark As Variant
   Dim strMessage As String

   With rstTemp
      ' Store current record location.
      varBookmark = .Bookmark
      .FindFirst strFind

      ' If Find method fails, notify user and return to the
      ' last current record.
      If .NoMatch Then
         strMessage = _
            "Not found! Returning to current record." & _
            vbCr & vbCr & "NoMatch = " & .NoMatch
         MsgBox strMessage
         .Bookmark = varBookmark
      End If

   End With

End Sub

The following example shows how to use the Seek method to find a record in a linked table.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Sub TestSeek()
    ' Get the path to the external database that contains
    ' the tblCustomers table we're going to search.
    Dim strMyExternalDatabase
    Dim dbs    As DAO.Database
    Dim dbsExt As DAO.Database
    Dim rst    As DAO.Recordset
    Dim tdf    As DAO.TableDef

    Set dbs = CurrentDb()
    Set tdf = dbs.TableDefs("tblCustomers")
    strMyExternalDatabase = Mid(tdf.Connect, 11)

    'Open the database that contains the table that is linked
    Set dbsExt = OpenDatabase(strMyExternalDatabase)

    'Open a table-type recordset against the external table
    Set rst = dbsExt.OpenRecordset("tblCustomers", dbOpenTable)

    'Specify which index to search on
    rst.Index = "PrimaryKey"

    'Specify the criteria
    rst.Seek "=", 123

    'Check the result
    If rst.NoMatch Then
        MsgBox "Record not found."
    Else
        MsgBox "Customer name: " & rst!CustName
    End If

    rst.Close
    dbs.Close
    dbsExt.Close
    Set rst = Nothing
    Set tdf = Nothing
    Set dbs = Nothing

End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


ObjectFrame.OldValue Property (Access)

 Copy code hover
[image]

ObjectFrame.OldValue Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.

Syntax

expression .OldValue

expression A variable that represents an ObjectFrame object.

Remarks

The OldValue property contains the unedited data from a bound control and is read-only in all views.

Microsoft Access uses the OldValue property to store the original value of a bound control. When you edit a bound control on a form, your changes aren't saved until you move to another record. The OldValue property contains the unedited version of the underlying data.

You can provide your own undo capability by assigning the OldValue property setting to a control. The following example shows how you can undo any changes to text box controls on a form:

VBA Copy code Copy code
Private Sub btnUndo_Click()

 Dim ctlTextbox As Control

 For Each ctlTextbox in Me.Controls
 If ctlTextbox.ControlType = acTextBox Then
 ctlTextbox.Value = ctl.OldValue
 End If
 Next ctlTextbox

End Sub

If the control hasn't been edited, this code has no effect. When you move to another record, the record source is updated, so the current value and the OldValue property will be the same.

The OldValue property setting has the same data type as the field to which the control is bound.

Example

The following example checks to determine if new data entered in a field is within 10 percent of the value of the original data. If the change is greater than 10 percent, the OldValue property is used to restore the original value. This procedure could be called from the BeforeUpdate event of the control that contains data you want to validate.

VBA Copy code Copy code
Public Sub Validate_Field()

 Dim curNewValue As Currency
 Dim curOriginalValue As Currency
 Dim curChange As Currency
 Dim strMsg As String

 curNewValue = Forms!Products!UnitPrice
 curOriginalValue = Forms!Products!UnitPrice.OldValue
 curChange = Abs(curNewValue - curOriginalValue)

 If curChange > (curOriginalValue * .1) Then
 strMsg = "Change is more than 10% of original unit price. " _
 & "Restoring original unit price."
 MsgBox strMsg, vbExclamation, "Invalid change."
 Forms!Products!UnitPrice = curOriginalValue
 End If

End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


OLE DB Providers

 Copy code hover
[image]

OLE DB Providers
Send feedback

The ADO Programmer's Guide Introduction discusses the relationship between ADO and the rest of the Microsoft Data Access architecture. OLE DB defines a set of COM interfaces to provide applications with uniform access to data that is stored in diverse information sources. This approach allows a data source to share its data through the interfaces that support the amount of DBMS functionality appropriate to the data source. By design, the high-performance architecture of OLE DB is based on its use of a flexible, component-based services model. Rather than having a prescribed number of intermediary layers between the application and the data, OLE DB requires only as many components as are needed to accomplish a particular task.

For example, suppose a user wants to run a query. Consider the following scenarios:

  • The data resides in a relational database for which there currently exists an ODBC driver but no native OLE DB provider: The application uses ADO to talk to the OLE DB Provider for ODBC, which then loads the appropriate ODBC driver. The driver passes the SQL statement to the DBMS, which retrieves the data.

  • The data resides in Microsoft SQL Server for which there is a native OLE DB provider: The application uses ADO to talk directly to the OLE DB Provider for Microsoft SQL Server. No intermediaries are required.

  • The data resides in Microsoft Exchange Server, for which there is an OLE DB provider but which does not expose an engine to process SQL queries: The application uses ADO to talk to the OLE DB Provider for Microsoft Exchange and calls upon an OLE DB query processor component to handle the querying.

  • The data resides in the Microsoft NTFS file system in the form of documents: Data is accessed by using a native OLE DB provider over Microsoft Indexing Service, which indexes the content and properties of documents in the file system to enable efficient content searches.

In all of the preceding examples, the application can query the data. The user's needs are met with a minimum number of components. In each case, additional components are used only if needed, and only the required components are invoked. This demand-loading of reusable and shareable components greatly contributes to high performance when OLE DB is used.

Providers fall into two categories: those providing data and those providing services. A data provider owns its own data and exposes it in tabular form to your application. A service provider encapsulates a service by producing and consuming data, augmenting features in your ADO applications. A service provider may also be further defined as a service component, which must work in conjunction with other service providers or components.

ADO provides a consistent, higher level interface to the various OLE DB providers.


Recordset2.Close Method (DAO)

 Copy code hover
[image]

Recordset2.Close Method (DAO)
Send feedback

Closes an open Recordset.

Syntax

expression .Close

expression A variable that represents a Recordset2 object.

Remarks

If the Recordset object is already closed when you use Close, a run-time error occurs.

If you try to close a Connection object while it has any open Recordset objects, the Recordset objects will be closed and any pending updates or edits will be canceled. Similarly, if you try to close a Workspace object while it has any open Connection objects, those Connection objects will be closed, which will close their Recordset objects.

An alternative to the Close method is to set the value of an object variable to Nothing (Set dbsTemp = Nothing).


Recordset.CancelUpdate Method (DAO)

 Copy code hover
[image]

Recordset.CancelUpdate Method (DAO)
Send feedback

Cancels any pending updates for a Recordset object.

Syntax

expression .CancelUpdate(UpdateType)

expression A variable that represents a Recordset object.

Parameters

Name

Required/Optional

Data Type

Description

UpdateType

Optional

Long

Set to one of the UpdateTypeEnum values.

Note Note

The dbUpdateRegular and dbUpdateBatch values are valid only if batch updating is enabled.

Remarks

You can use the CancelUpdate method to cancel any pending updates resulting from an Edit or AddNew operation. For example, if a user invokes the Edit or AddNew method and hasn't yet invoked the Update method, CancelUpdate cancels any changes made after Edit or AddNew was invoked.

Check the EditMode property of the Recordset to determine if there is a pending operation that can be canceled.

Note Note

Using the CancelUpdate method has the same effect as moving to another record without using the Update method, except that the current record doesn't change, and various properties, such as BOF and EOF, aren't updated.

Example

This example shows how the CancelUpdate method is used with the AddNew method.

VBA Copy code Copy code
Sub CancelUpdateX()

   Dim dbsNorthwind As Database
   Dim rstEmployees As Recordset
   Dim intCommand As Integer

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   Set rstEmployees = dbsNorthwind.OpenRecordset( _
      "Employees", dbOpenDynaset)

   With rstEmployees
      .AddNew
      !FirstName = "Kimberly"
      !LastName = "Bowen"
      intCommand = MsgBox("Add new record for " & _
         !FirstName & " " & !LastName & "?", vbYesNo)
      If intCommand = vbYes Then
         .Update
         MsgBox "Record added."
         ' Delete new record because this is a
         ' demonstration.
         .Bookmark = .LastModified
         .Delete
      Else
         .CancelUpdate
         MsgBox "Record not added."
      End If
   End With

   dbsNorthwind.Close

End Sub

This example shows how the CancelUpdate method is used with the Edit method.

VBA Copy code Copy code
Sub CancelUpdateX2()

   Dim dbsNorthwind As Database
   Dim rstEmployees As Recordset
   Dim strFirst As String
   Dim strLast As String
   Dim intCommand As Integer

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   Set rstEmployees = dbsNorthwind.OpenRecordset( _
      "Employees", dbOpenDynaset)

   With rstEmployees
      strFirst = !FirstName
      strLast = !LastName
      .Edit
      !FirstName = "Cora"
      !LastName = "Edmonds"
      intCommand = MsgBox("Replace current name with " & _
         !FirstName & " " & !LastName & "?", vbYesNo)
      If intCommand = vbYes Then
         .Update
         MsgBox "Record modified."
         ' Restore data because this is a demonstration.
         .Bookmark = .LastModified
         .Edit
         !FirstName = strFirst
         !LastName = strLast
         .Update
      Else
         .CancelUpdate
         MsgBox "Record not modified."
      End If
      .Close
   End With

   dbsNorthwind.Close

End Sub


ListBox.OnKeyUp Property (Access)

 Copy code hover
[image]

ListBox.OnKeyUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Up box in the Properties window. Read/write String.

Syntax

expression .OnKeyUp

expression A variable that represents a ListBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyUp event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyUp

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


ConnectionTimeout Property (ADO)

 Copy code hover
[image]

ConnectionTimeout Property (ADO)
Send feedback

Indicates how long to wait while establishing a connection before terminating the attempt and generating an error.

Settings and Return Values

Sets or returns a Long value that indicates, in seconds, how long to wait for the connection to open. Default is 15.

Remarks

Use the ConnectionTimeout property on a Connection object if delays from network traffic or heavy server use make it necessary to abandon a connection attempt. If the time from the ConnectionTimeout property setting elapses prior to the opening of the connection, an error occurs and ADO cancels the attempt. If you set the property to zero, ADO will wait indefinitely until the connection is opened. Make sure the provider to which you are writing code supports the ConnectionTimeout functionality.

The ConnectionTimeout property is read/write when the connection is closed and read-only when it is open.


MoveRecord Method (ADO)

 Copy code hover
[image]

MoveRecord Method (ADO)
Send feedback

Moves the entity represent by a Record to another location.

Syntax

Record.MoveRecord (Source, Destination, UserName, Password, Options, Async)

Parameters

  • Source

  • Optional. A String value that contains a URL identifying the Record to be moved. If Source is omitted or specifies an empty string, the object represented by this Record is moved. For example, if the Record represents a file, the contents of the file are moved to the location specified by Destination.

  • Destination

  • Optional. A String value that contains a URL specifying the location where Source will be moved.

  • UserName

  • Optional. A String value that contains the user ID that, if needed, authorizes access to Destination.

  • Password

  • Optional. A String that contains the password that, if needed, verifies UserName.

  • Options

  • Optional. A MoveRecordOptionsEnum value whose default value is adMoveUnspecified. Specifies the behavior of this method.

  • Async

  • Optional. A Boolean value that, when True, specifies this operation should be asynchronous .

Return Value

A String value. Typically, the value of Destination is returned. However, the exact value returned is provider-dependent.

Remarks

The values of Source and Destination must not be identical; otherwise, a run-time error occurs. At least the server, path, and resource names must differ.

For files moved using the Internet Publishing Provider, this method updates all hypertext links in files being moved unless otherwise specified by Options. This method fails if Destination identifies an existing object (for example, a file or directory), unless adMoveOverWrite is specified.

Note Note

Use the adMoveOverWrite option judiciously. For example, specifying this option when moving a file to a directory will delete the directory and replace it with the file.

Certain attributes of the Record object, such as the ParentURL property, will not be updated after this operation completes. Refresh the Record object's properties by closing the Record, then re-opening it with the URL of the location where the file or directory was moved.

If this Record was obtained from a Recordset, the new location of the moved file or directory will not be reflected immediately in the Recordset. Refresh the Recordset by closing and re-opening it.

Note Note

URLs using the http scheme will automatically invoke the Microsoft OLE DB Provider for Internet Publishing. For more information, see Absolute and Relative URLs.


Screen.ActiveReport Property (Access)

 Copy code hover
[image]

Screen.ActiveReport Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ActiveReport property together with the Screen object to identify or refer to the report that has the focus. Read-only Report object.

Syntax

expression .ActiveReport

expression A variable that represents a Screen object.

Remarks

This property setting contains a reference to the Report object that has the focus at run time.

You can use the ActiveReport property to refer to an active report together with one of its properties or methods. The following example displays the Name property setting of the active report.

VBA Copy code Copy code
Dim rptCurrentReport As Report
Set rptCurrentReport = Screen.ActiveReport
MsgBox "Current report is " & rptCurrentReport.Name

If no report has the focus when you use the ActiveReport property, an error occurs.

See also

Concepts

Screen Object

Other resources

Screen Object Members


Depth Property (ADO MD)

 Copy code hover
[image]

Depth Property (ADO MD)
Send feedback

Indicates the number of levels between the Level and the root of the hierarchy.

Return Values

Returns an integer, and is read-only.

Remarks

A Level at the root of a hierarchy has a Depth value of zero (0).


Append and CreateParameter Methods Example (VJ++)

 Copy code hover
[image]

Append and CreateParameter Methods Example (VJ++)
Send feedback

This example uses the Append and CreateParameter methods to execute a stored procedure with an input parameter.

Copy code Copy code

// BeginAppendJ
import com.ms.wfc.data.*;
import java.io.*;
import com.ms.com.*;

public class AppendX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 AppendX();
 }

 // AppendX function

 static void AppendX()
 {
 // Define ADO Objects.
 Connection cnConn1 = null;
 Command cmdByRoyalty = null;
 Parameter prmByRoyalty = null;
 Recordset rstByRoyalty = null;
 Recordset rstAuthors = null;

 //Declarations.
 String strCnn;
 String strAuthorID;
 String strFName;
 String strLName;
 int intRoyalty ;
 BufferedReader in =
 new BufferedReader (new InputStreamReader (System.in));
 String line = null;
 Variant varRoyalty;

 try
 {
 // Open a connection.

 strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";
 cnConn1 = new Connection();
 cnConn1.open(strCnn);
 cnConn1.setCursorLocation(AdoEnums.CursorLocation.CLIENT);

 // Open command object with one parameter.
 cmdByRoyalty = new Command();
 cmdByRoyalty.setCommandText("byRoyalty");
 cmdByRoyalty.setCommandType(AdoEnums.CommandType.STOREDPROC);

 //Get parameter value and append parameter.
 System.out.println ("\nEnter Royalty : ");
 line = in.readLine().trim();
 intRoyalty = Integer.parseInt(line);
 varRoyalty = new Variant(intRoyalty);
 prmByRoyalty = cmdByRoyalty.createParameter ("percentage",
 AdoEnums.DataType.INTEGER,
 AdoEnums.ParameterDirection.INPUT,4,varRoyalty);

 cmdByRoyalty.getParameters().append(prmByRoyalty);
 prmByRoyalty.setValue(varRoyalty);

 // Create a recordset by executing the command.
 cmdByRoyalty.setActiveConnection(cnConn1);
 rstByRoyalty = cmdByRoyalty.execute();

 // Open the Authors table to get author names for display.
 rstAuthors = new Recordset ();
 rstAuthors.open("authors", cnConn1,
 AdoEnums.CursorType.FORWARDONLY,
 AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TABLE );

 // Print current data in the recordset,
 // adding author names from Authors table.
 System.out.println("\nAuthors with " + intRoyalty +
 " percent royalty");
 while (!rstByRoyalty.getEOF())
 {
 strAuthorID = rstByRoyalty.getField("au_id").getString();
 rstAuthors.setFilter("au_id ='" + strAuthorID + "'");
 strFName = rstAuthors.getField("au_fname").getString();
 strLName = rstAuthors.getField("au_lname").getString();
 System.out.println("\t" + strAuthorID + ", " + strFName
 + " " + strLName);
 rstByRoyalty.moveNext();
 }
 System.out.println("\n\nPress <Enter> key to continue.");
 line = in.readLine();

 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // Check for null pointer for connection object.
 if(rstByRoyalty.getActiveConnection()==null)
 System.out.println("Exception: " + ae.getMessage());
 // As passing a Recordset, check for null pointer first.
 if (rstByRoyalty != null)
 {
 PrintProviderError(rstByRoyalty.getActiveConnection());
 }
 if (rstAuthors != null)
 {
 if (rstAuthors.getActiveConnection()==null)
 System.out.println("Exception: " + ae.getMessage());
 else
 PrintProviderError(rstAuthors.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // This catch is required if input string cannot be converted to
 // Integer data type.
 catch( java.lang.NumberFormatException ne)
 {
 System.out.println("\nException: Integer Number required.");
 System.exit(0);
 }
 // System Read requires this catch.
 catch( java.io.IOException je )
 {
 PrintIOError(je);
 }
 finally
 {
 // Cleanup objects before exit.
 if (rstByRoyalty != null)
 if (rstByRoyalty.getState() == 1)
 rstByRoyalty.close();
 if (rstAuthors != null)
 if (rstAuthors.getState() == 1)
 rstAuthors.close();
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 System.exit(0);//required here only.
 }

 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 //.PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}

// EndAppendJ


CursorType, LockType, and EditMode Properties Example (VB)

 Copy code hover
[image]

CursorType, LockType, and EditMode Properties Example (VB)
Send feedback

This example demonstrates setting the CursorType and LockType properties before opening a Recordset. It also shows the value of the EditMode property under various conditions. The EditModeOutput function is required for this procedure to run.

Copy code Copy code

'BeginEditModeVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 ' recordset variables
 Dim rstEmployees As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim SQLEmployees As String

 ' open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' set recordset properties through object refs
 ' instead of through arguments to Open method
 Set rstEmployees = New ADODB.Recordset
 Set rstEmployees.ActiveConnection = Cnxn
 rstEmployees.CursorLocation = adUseClient
 rstEmployees.CursorType = adOpenStatic
 rstEmployees.LockType = adLockBatchOptimistic

 ' open recordset with data from Employee table
 SQLEmployees = "employee"
 rstEmployees.Open SQLEmployees, , , , adCmdTable

 ' Show the EditMode property under different editing states
 rstEmployees.AddNew
 rstEmployees!emp_id = "T-T55555M"
 rstEmployees!fname = "temp_fname"
 rstEmployees!lname = "temp_lname"
 'call function below
 'to output results to debug window
 EditModeOutput "After AddNew:", rstEmployees.EditMode
 rstEmployees.UpdateBatch
 EditModeOutput "After UpdateBatch:", rstEmployees.EditMode
 rstEmployees!fname = "test"
 EditModeOutput "After Edit:", rstEmployees.EditMode
 rstEmployees.Close

 ' Delete new record because this is a demonstration
 Cnxn.Execute "DELETE FROM employee WHERE emp_id = 'T-T55555M'"

 ' clean up
 Cnxn.Close
 Set rstEmployees = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstEmployees Is Nothing Then
 If rstEmployees.State = adStateOpen Then rstEmployees.Close
 End If
 Set rstEmployees = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If

End Sub

Public Function EditModeOutput(strTemp As String, _
 intEditMode As Integer)

 ' Print report based on the value of the EditMode
 ' property
 Debug.Print strTemp
 Debug.Print " EditMode = ";

 Select Case intEditMode
 Case adEditNone
 Debug.Print "adEditNone"
 Case adEditInProgress
 Debug.Print "adEditInProgress"
 Case adEditAdd
 Debug.Print "adEditAdd"
 End Select

End Function
'EndEditModeVB


Application.CurrentWebUserGroups Method (Access)

 Copy code hover
[image]

Application.CurrentWebUserGroups Method (Access)
See also Send feedback

Published: July 16, 2012

Gets the collection of Microsoft SharePoint Foundation 2010 groups of which the user is a member.

Version Information

Version Added: Access 2010

Syntax

expression .CurrentWebUserGroups(DisplayOption)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
DisplayOption | Required | AcWebUserGroupsDisplay | Specifies the type of information to return about the user's groups.

Return Value

Variant

Remarks

The CurrentWebUserGroups method returns Null if the user is not a member of any groups.

See also

Concepts

Application Object

Other resources

Application Object Members


TabControl.OnKeyUp Property (Access)

 Copy code hover
[image]

TabControl.OnKeyUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Up box in the Properties window. Read/write String.

Syntax

expression .OnKeyUp

expression A variable that represents a TabControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyUp event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyUp

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


OptionButton.GotFocus Event (Access)

 Copy code hover
[image]

OptionButton.GotFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The GotFocus event occurs when the specified object receives the focus.

Syntax

expression .GotFocus

expression A variable that represents an OptionButton object.

Remarks

To run a macro or event procedure when these events occur, set the OnGotFocus property to the name of the macro or to [Event Procedure].

These events occur when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The GotFocus event differs from the Enter event in that the GotFocus event occurs every time a control receives the focus. For example, suppose the user clicks a check box on a form, then clicks a report, and finally clicks the check box on the form to bring it to the foreground. The GotFocus event occurs both times the check box receives the focus. In contrast, the Enter event occurs only the first time the user clicks the check box. The GotFocus event occurs after the Enter event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Image.Layout Property (Access)

 Copy code hover
[image]

Image.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified image. Read-only AcLayoutType.

Version Information

Version Added: Access 2007

Syntax

expression .Layout

expression A variable that represents an Image object.

See also

Concepts

Image Object

Other resources

Image Object Members


OptionGroup.Height Property (Access)

 Copy code hover
[image]

OptionGroup.Height Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the height of the specified object in twips. Read/write Integer.

Syntax

expression .Height

expression A variable that represents an OptionGroup object.

Remarks

For report controls, you can set the Height property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

Microsoft Access automatically sets the Height property when you create or size a control or when you size a window in form Design View or report Design view.

The height of controls is measured from the center of their borders so controls with different border widths align correctly.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


ADO NumericScale and Precision Properties Example (VC++)

 Copy code hover
[image]

ADO NumericScale and Precision Properties Example (VC++)
Send feedback

This example uses the NumericScale and Precision properties to display the numeric scale and precision of fields in the Discounts table of the Pubs database.

Copy code Copy code

// BeginNumericScaleCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void NumericScaleX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

///////////////////////////////////////////////////////////
// //
// Main Function //
// //
///////////////////////////////////////////////////////////

void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 NumericScaleX();

 ::CoUninitialize();
}

///////////////////////////////////////////////////////////
// //
// NumericScaleX Function //
// //
///////////////////////////////////////////////////////////

void NumericScaleX(void)
{
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace
 _RecordsetPtr pRstDiscounts = NULL;
 FieldsPtr fldTemp = NULL;

 //Define Other Variables
 HRESULT hr = S_OK;
 _variant_t Index;
 Index.vt = VT_I2;

 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 try
 {
 // Open recordset.
 TESTHR(pRstDiscounts.CreateInstance(__uuidof(Recordset)));
 pRstDiscounts->Open("discounts", strCnn, adOpenForwardOnly,
 adLockReadOnly, adCmdTable);

 // Display numeric scale and precision of
 // numeric and small integer fields.
 fldTemp = pRstDiscounts->GetFields();

 for (int intLoop=0;intLoop < (int)fldTemp->GetCount();intLoop++)
 {
 Index.iVal = intLoop;

 if ((fldTemp->GetItem(Index)->Type == adNumeric)
 || (fldTemp->GetItem(Index)->Type == adSmallInt))
 {
 printf("Field: %s\n" ,(LPCSTR)fldTemp->
 GetItem(Index)->GetName());
 printf("Numeric scale: %d\n", fldTemp->
 GetItem(Index)->GetNumericScale());
 printf("Precision: %d\n", fldTemp->
 GetItem(Index)->GetPrecision());
 }
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstDiscounts->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 if (pRstDiscounts)
 if (pRstDiscounts->State == adStateOpen)
 pRstDiscounts->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;

 // Collection ranges from 0 to nCount -1.
 for(long i = 0;i < nCount;i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,
 pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////

void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print COM errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndNumericScaleCpp


CustomControl.BorderStyle Property (Access)

 Copy code hover
[image]

CustomControl.BorderStyle Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies how a control's border appears.Read/write Byte.

Syntax

expression .BorderStyle

expression A variable that represents a CustomControl object.

Remarks

For controls, the BorderStyle property uses the following settings.

Setting | Visual Basic | Description
Transparent | 0 | (Default only for label, chart, and subreport) Transparent
Solid | 1 | (Default) Solid line
Dashes | 2 | Dashed line
Short dashes | 3 | Dashed line with short dashes
Dots | 4 | Dotted line
Sparse dots | 5 | Dotted line with dots spaced far apart
Dash dot | 6 | Line with a dash-dot combination
Dash dot dot | 7 | Line with a dash-dot-dot combination
Double solid | 8 | Double solid lines

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border style is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderStyle property changes the SpecialEffect property setting to Flat.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


NavigationButton.ForeThemeColorIndex Property (Access)

 Copy code hover
[image]

NavigationButton.ForeThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the ForeColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ForeThemeColorIndex

expression A variable that represents a NavigationButton object.

Remarks

The ForeThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the ForeThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Fore Color to the Text 2 color by setting the ForeThemeColorIndex property.

VBA Copy code Copy code
Me.ctl.ForeThemeColorIndex=2

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Recordset2.Clone Method (DAO)

 Copy code hover
[image]

Recordset2.Clone Method (DAO)
Send feedback

Creates a duplicate Recordset object that refers to the original Recordset2 object.

Syntax

expression .Clone

expression A variable that represents a Recordset2 object.

Return Value

Recordset

Remarks

Use the Clone method to create multiple, duplicate Recordset objects. Each recordset can have its own current record. Using Clone by itself doesn't change the data in the objects or in their underlying structures. When you use the Clone method, you can share bookmarks between two or more Recordset2 objects because their bookmarks are interchangeable.

You can use the Clone method when you want to perform an operation on a recordset that requires multiple current records. This is faster and more efficient than opening a second recordset. When you create a recordset with the Clone method, it initially lacks a current record. To make a record current before you use the recordset clone, you must set the Bookmark property or use one of the Move methods, one of the Find methods, or the Seek method.

Using the Close method on either the original or duplicate object doesn't affect the other object. For example, using Close on the original recordset doesn't close the clone.

Note Note

  • Closing a clone recordset within a pending transaction will cause an implicit Rollback operation.

  • When you clone a table-type Recordset object in a Microsoft Access workspace, the Index property setting is not cloned on the new copy of the recordset. You must copy the Index property setting manually.

Example

This example uses the Clone method to create copies of a recordset and then lets the user position the record pointer of each copy independently.

VBA Copy code Copy code
Sub CloneX()

   Dim dbsNorthwind As Database
   Dim arstProducts(1 To 3) As Recordset2
   Dim intLoop As Integer
   Dim strMessage As String
   Dim strFind As String

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   ' If the following SQL statement will be used often,
   ' creating a permanent QueryDef will result in better
   ' performance.
   Set arstProducts(1) = dbsNorthwind.OpenRecordset( _
      "SELECT ProductName FROM Products " & _
      "ORDER BY ProductName", dbOpenSnapshot)

   ' Create two clones of the original Recordset.
   Set arstProducts(2) = arstProducts(1).Clone
   Set arstProducts(3) = arstProducts(1).Clone

   Do While True

      ' Loop through the array so that on each pass, the
      ' user is searching a different copy of the same
      ' Recordset.
      For intLoop = 1 To 3

         ' Ask for search string while showing where the
         ' current record pointer is for each Recordset.
         strMessage = _
            "Recordsets from Products table:" & vbCr & _
            "  1 - Original - Record pointer at " & _
            arstProducts(1)!ProductName & vbCr & _
            "  2 - Clone - Record pointer at " & _
            arstProducts(2)!ProductName & vbCr & _
            "  3 - Clone - Record pointer at " & _
            arstProducts(3)!ProductName & vbCr & _
            "Enter search string for #" & intLoop & ":"
         strFind = Trim(InputBox(strMessage))
         If strFind = "" Then Exit Do

         ' Find the search string; if there's no match, jump
         ' to the last record.
         With arstProducts(intLoop)
            .FindFirst "ProductName >= '" & strFind & "'"
            If .NoMatch Then .MoveLast
         End With

      Next intLoop

   Loop

   arstProducts(1).Close
   arstProducts(2).Close
   arstProducts(3).Close
   dbsNorthwind.Close

End Sub


NOT (Access 2013 custom web app)

 Copy code hover
[image]

NOT (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Negates a Boolean input.

Syntax

[Not ] BooleanExpression

The Not operator contains the following arguments.

Argument name | Description
BooleanExpression | A valid Boolean expression.

Remarks

The following table shows the results of comparing TRUE and FALSE values using the Not operator.

 | Not
TRUE | False
FALSE | True


TextBox.NumeralShapes Property (Access)

 Copy code hover
[image]

TextBox.NumeralShapes Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .NumeralShapes

expression A variable that represents a TextBox object.

Remarks

The NumeralShapes property uses the following settings.

Setting | Visual Basic | Description
System | 0 | Numeral shapes determined by the Numeral Shapes system setting.
Arabic | 1 | Arabic digit shapes will be used to display and print numerals.
National | 2 | National digit shapes will be used to display and print numerals.
Context | 3 | Numeral shapes determined by Unicode context rules for adjacent text.

Example

The following example changes the NumeralShapes property for the selected control to 0 (numeral shapes will be determined by the Numeral Shapes system setting).

VBA Copy code Copy code
Public Sub ChangeNumeralShapes(ctl As Control)
 ctl.NumeralShapes = 0
End Sub

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ListBox.AddColon Property (Access)

 Copy code hover
[image]

ListBox.AddColon Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether a colon follows the text in labels for new controls. Read/write Boolean.

Syntax

expression .AddColon

expression A variable that represents a ListBox object.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


ObjectFrame.BorderTint Property (Access)

 Copy code hover
[image]

ObjectFrame.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Syntax

expression .BorderTint

expression A variable that represents an ObjectFrame object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens BorderColor by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


TabControl.GridlineThemeColorIndex Property (Access)

 Copy code hover
[image]

TabControl.GridlineThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineThemeColorIndex

expression A variable that represents a TabControl object.

Remarks

The GridlineThemeColorIndex property uses one of the values listed in the following table.

Value | Description
0 | Text 1
1 (Default) | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the GridlineThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Line.HorizontalAnchor Property (Access)

 Copy code hover
[image]

Line.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the line is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .HorizontalAnchor

expression A variable that represents a Line object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

Line Object

Other resources

Line Object Members


Refresh Method (ADO)

 Copy code hover
[image]

Refresh Method (ADO)
Send feedback

Updates the objects in a collection to reflect objects available from, and specific to, the provider.

Syntax

collection.Refresh

Remarks

The Refresh method accomplishes different tasks depending on the collection from which you call it.

Parameters

Using the Refresh method on a Command object's Parameters collection retrieves provider-side parameter information for the stored procedure or parameterized query specified in the Command object. The collection will be empty for providers that do not support stored procedure calls or parameterized queries.

You should set the ActiveConnection property of the Command object to a valid Connection object, the CommandText property to a valid command, and the CommandType property to adCmdStoredProc before calling the Refresh method.

If you access the Parameters collection before calling the Refresh method, ADO will automatically call the method and populate the collection for you.

Note Note

If you use the Refresh method to obtain parameter information from the provider and it returns one or more variable-length data type Parameter objects, ADO may allocate memory for the parameters based on their maximum potential size, which will cause an error during execution. You should explicitly set the Size property for these parameters before calling the Execute method to prevent errors.

Fields

Using the Refresh method on the Fields collection has no visible effect. To retrieve changes from the underlying database structure, you must use either the Requery method or, if the Recordset object does not support bookmarks, the MoveFirst method.

Properties

Using the Refresh method on a Properties collection of some objects populates the collection with the dynamic properties that the provider exposes. These properties provide information about functionality specific to the provider, beyond the built-in properties ADO supports.


TextBox.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

TextBox.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified text box. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleLeft

expression A variable that represents a TextBox object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Catalog Object (ADOX) Reference

 Copy code hover
[image]

Catalog Object (ADOX) Reference
Send feedback

In this section

  • Catalog Object (ADOX)

  • Catalog Properties, Methods, and Events (ADOX)


OptionGroup.Section Property (Access)

 Copy code hover
[image]

OptionGroup.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Syntax

expression .Section

expression A variable that represents an OptionGroup object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


Image.BorderTint Property (Access)

 Copy code hover
[image]

Image.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderTint

expression A variable that represents an Image object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

Image Object

Other resources

Image Object Members


OptionGroup.OnDblClick Property (Access)

 Copy code hover
[image]

OptionGroup.OnDblClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.

Syntax

expression .OnDblClick

expression A variable that represents an OptionGroup object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The DblClick event occurs when a user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

The OnDblClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Dbl Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Dbl Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_DblClick" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnDblClick = "" Then
 .OnDblClick = "[Event Procedure]"
 End If
End With

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


UPDATE (Microsoft Access SQL reserved word)

 Copy code hover
[image]

UPDATE (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The UPDATE keyword is used in these contexts:

UPDATE Statement

CREATE PROCEDURE Statement

GRANT Statement

REVOKE Statement


ODBCConnectStr Property

 Copy code hover
[image]

ODBCConnectStr Property
Send feedback

Published: July 16, 2012

You can use the ODBCConnectStr property in an SQL pass-through query to specify the Open Database Connectivity (ODBC) connection string for the query.

Note Note

The ODBCConnectStr property applies only to pass-through queries.

Setting

Enter the ODBC connection string that defines the connection to the SQL database you want to use.

You can set this property by using the query's property sheet or Visual Basic .

You can also use the ODBC Connection String Builder to create the ODBC connection string for this property. This builder establishes a connection to the SQL database server and then ends the connection after the ODBC connection string is created.

Remarks

The default setting for this property is the string "ODBC;", which Microsoft Access restores if you delete an existing setting. When the ODBCConnectStr property is set to "ODBC;", Microsoft Access will prompt you for a connection string whenever the query is used but won't store the connect string. You must enter a connection string in the ODBCConnectStr property box if you want Microsoft Access to store the connection string.

Tip Tip

If you know the full connection string for the SQL database, enter it in the ODBCConnectStr property box. This way you will avoid the need to enter the connection string in the ODBC connection dialog box each time you use the query.

The connection string is different for different types of ODBC data sources. For example, to connect to the Human Resources data source on the HRSRVR server (a Microsoft SQL Server) by using the logon identification (ID) Smith and the password Sesame, you can use the following connection string.

Copy code Copy code
ODBC;DSN=Human Resources;SERVER=HRSRVR;UID=Smith;PWD=Sesame;


Report.PrtMip Property (Access)

 Copy code hover
[image]

Report.PrtMip Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the PrtMip property in Visual Basic to set or return the device mode information specified for a form or report in the Print dialog box.

Syntax

expression .PrtMip

expression A variable that represents a Report object.

Remarks

The PrtMip property setting is a 28-byte structure that maps to settings on the Margins tab for a form or report in the Page Setup dialog box.

The PrtMip property has the following members.

Member | Description
LeftMargin, RightMargin, TopMargin, BottomMargin | A Long that specifies the distance between the edge of the page and the item to be printed in twips.
DataOnly | A Long that specifies the elements to be printed. When True, prints only the data in a table or query in Datasheet view, form, or report, and suppresses labels, control borders, grid lines, and display graphics such as lines and boxes. When False, prints data, labels, and graphics.
ItemsAcross | A Long that specifies the number of columns across for multiple-column reports or labels. This member is equivalent to the value of the Number of Columns box under Grid Settings on the Columns tab of the Page Setup dialog box.
RowSpacing | A Long that specifies the horizontal space between detail sections in units of 1/20 of a point.
ColumnSpacing | A Long that specifies the vertical space between detail sections in twips.
DefaultSize | A Long. When True, uses the size of the detail section in Design view. When False, uses the values specified by the ItemSizeWidth and ItemSizeHeight members.
ItemSizeWidth | A Long that specifies the width of the detail section in twips. This member is equivalent to the value of the Width box under Column Size on the Columns tab of the Page Setup dialog box.
ItemSizeHeight | A Long that specifies the height of the detail section twips. This member is equivalent to the value of the Height box under Column Size on the Columns tab of the Page Setup dialog box.
ItemLayout | A Long that specifies horizontal (1953) or vertical (1954) layout of columns. This member is equivalent to Across, then Down or Down, then Across respectively under Column Layout on the Columns tab of the Page Setup dialog box.
FastPrint | Reserved.
Datasheet | Reserved.

The PrtMip property setting is read/write in Design view and read-only in other views.

Example

The following PrtMip property example demonstrates how to set up the report with two horizontal columns.

VBA Copy code Copy code
Private Type str_PRTMIP
 strRGB As String * 28
End Type

Private Type type_PRTMIP
 xLeftMargin As Long
 yTopMargin As Long
 xRightMargin As Long
 yBotMargin As Long
 fDataOnly As Long
 xWidth As Long
 yHeight As Long
 fDefaultSize As Long
 cxColumns As Long
 yColumnSpacing As Long
 xRowSpacing As Long
 rItemLayout As Long
 fFastPrint As Long
 fDatasheet As Long
End Type

Public Sub PrtMipCols(ByVal strName As String)

 Dim PrtMipString As str_PRTMIP
 Dim PM As type_PRTMIP
 Dim rpt As Report
 Const PM_HORIZONTALCOLS = 1953
 Const PM_VERTICALCOLS = 1954

 ' Open the report.
 DoCmd.OpenReport strName, acDesign
 Set rpt = Reports(strName)
 PrtMipString.strRGB = rpt.PrtMip
 LSet PM = PrtMipString

 ' Create two columns.
 PM.cxColumns = 2

 ' Set 0.25 inch between rows.
 PM.xRowSpacing = 0.25 * 1440

 ' Set 0.5 inch between columns.
 PM.yColumnSpacing = 0.5 * 1440
 PM.rItemLayout = PM_HORIZONTALCOLS

 ' Update property.
 LSet PrtMipString = PM
 rpt.PrtMip = PrtMipString.strRGB

 Set rpt = Nothing

End Sub

The next PrtMip property example shows how to set all margins to 1 inch.

VBA Copy code Copy code
Public Sub SetMarginsToDefault(ByVal strName As String)

 Dim PrtMipString As str_PRTMIP
 Dim PM As type_PRTMIP
 Dim rpt As Report

 ' Open the report.
 DoCmd.OpenReport strName, acDesign
 Set rpt = Reports(strName)
 PrtMipString.strRGB = rpt.PrtMip
 LSet PM = PrtMipString

 ' Set margins.
 PM.xLeftMargin = 1 * 1440
 PM.yTopMargin = 1 * 1440
 PM.xRightMargin = 1 * 1440
 PM.yBotMargin = 1 * 1440

 ' Update property.
 LSet PrtMipString = PM
 rpt.PrtMip = PrtMipString.strRGB

 Set rpt = Nothing

End Sub

See also

Concepts

Report Object

Other resources

Report Object Members


Sort Property (ADO)

 Copy code hover
[image]

Sort Property (ADO)
Send feedback

Indicates one or more field names on which the Recordset is sorted, and whether each field is sorted in ascending or descending order.

Settings and Return Values

Sets or returns a String value that indicates the field names in the Recordset on which to sort. Each name is separated by a comma, and is optionally followed by a blank and the keyword, ASC, which sorts the field in ascending order, or DESC, which sorts the field in descending order. By default, if no keyword is specified, the field is sorted in ascending order.

Remarks

This property requires the CursorLocation property to be set to adUseClient. A temporary index will be created for each field specified in the Sort property if an index does not already exist.

The sort operation is efficient because data is not physically rearranged, but is simply accessed in the order specified by the index.

Setting the Sort property to an empty string will reset the rows to their original order and delete temporary indexes. Existing indexes will not be deleted.

Suppose a Recordset contains three fields named firstName, middleInitial, and lastName. Set the Sort property to the string, "lastName DESC, firstName ASC", which will order the Recordset by last name in descending order, then by first name in ascending order. The middle initial is ignored.

No field can be named "ASC" or "DESC" because those names conflict with the keywords ASC and DESC. Give a field with a conflicting name an alias by using the AS keyword in the query that returns the Recordset.


TempVar Properties (Access)

 Copy code hover
[image]

TempVar Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Name | Gets the name of the specified TempVar. Read-only String.
Value | Gets or sets the value of the specified TempVar. Read/write Variant.


Application.LanguageSettings Property (Access)

 Copy code hover
[image]

Application.LanguageSettings Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the LanguageSettings property to return a read-only reference to the current LanguageSettings object and its related properties.

Syntax

expression .LanguageSettings

expression A variable that represents an Application object.

Remarks

Once you establish a reference to the LanguageSettings object, you can access all the properties and methods of the object. You can set a reference to the LanguageSettings object by clicking References on the Tools menu while in module Design view. Then set a reference to the Microsoft Office Object Library in the References dialog box by selecting the appropriate check box. Microsoft Access can set this reference for you if you use a Microsoft Office Object Library constant to set a LanguageSettings object's property or as an argument to a LanguageSettings object's method.

Example

The following example displays a message indicating the language Access uses for Help on the user's machine. A listing of all the available languages and their identification numbers is available in the Visual Basic Editor by selecting Object Browser from the View menu, typing the word MsoLanguageID in the Search Text box, and clicking the Search button.

VBA Copy code Copy code
Dim mli As MsoLanguageID
mli = Application.LanguageSettings.LanguageID(msoLanguageIDHelp)
MsgBox "The language ID used for Access Help is " & mli

See also

Concepts

Application Object

Other resources

Application Object Members


Invalid TOP argument in select query. (Error 3308)

 Copy code hover
[image]

Invalid TOP argument in select query. (Error 3308)
Send feedback

An invalid parameter appeared in the TOP clause of a SELECT statement. The value placed after the TOP reserved word must be a positive integer. If the PERCENT reserved word is also used, the integer cannot be greater than 100.


Printer.PaperSize Property (Access)

 Copy code hover
[image]

Printer.PaperSize Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets an AcPrintPaperSize constant indicating the paper size to use when printing. Read/write.

Syntax

expression .PaperSize

expression A variable that represents a Printer object.

Example

The following example sets a variety of printer settings for the form specified in the strFormname argument of the procedure.

VBA Copy code Copy code
Sub SetPrinter(strFormname As String)

 DoCmd.OpenForm FormName:=strFormname, view:=acDesign, _
 datamode:=acFormEdit, windowmode:=acHidden

 With Forms(form1).Printer

 .TopMargin = 1440
 .BottomMargin = 1440
 .LeftMargin = 1440
 .RightMargin = 1440

 .ColumnSpacing = 360
 .RowSpacing = 360

 .ColorMode = acPRCMColor
 .DataOnly = False
 .DefaultSize = False
 .ItemSizeHeight = 2880
 .ItemSizeWidth = 2880
 .ItemLayout = acPRVerticalColumnLayout
 .ItemsAcross = 6

 .Copies = 1
 .Orientation = acPRORLandscape
 .Duplex = acPRDPVertical
 .PaperBin = acPRBNAuto
  .PaperSize = acPRPSLetter
 .PrintQuality = acPRPQMedium

 End With

 DoCmd.Close objecttype:=acForm, objectname:=strFormname, _
 Save:=acSaveYes

End Sub

See also

Concepts

Printer Object

Other resources

Printer Object Members


Database functions (Access 2013 custom web app)

 Copy code hover
[image]

Database functions (Access 2013 custom web app)
Send feedback

In this section

  • UserDisplayName Function (Access 2013 custom web app)

  • UserEmailAddress Function (Access 2013 custom web app)

  • Update Function (Access 2013 custom web app)


CheckBox.TripleState Property (Access)

 Copy code hover
[image]

CheckBox.TripleState Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TripleState property to specify how the specified control will display Null values. Read/write Boolean.

Syntax

expression .TripleState

expression A variable that represents a CheckBox object.

Remarks

The Null property uses the following settings.

Setting | Description
True | The control will cycle through states for Yes, No, and Null values. The control appears dimmed (grayed) when its Value property is set to Null.
False | (Default) The control will cycle through states for Yes and No values. Null values display as if they were No values.

This property can be set in any view.

Example

The following example displays a message describing in detail the state of a check box named "Check1" on the form "frmOperations".

VBA Copy code Copy code
Dim strTripleState As String

strTripleState = Forms.Item("frmOperations").Controls.Item("Check1").TripleState

Select Case strTripleState
 Case True
 MsgBox "For Check1, TripleState = " & strTripleState & _
 ". The control will cycle through states for Yes, No, " & _
 "and Null values. The control appears dimmed (grayed) " & _
 "when its Value property is set to Null."
 Case False
 MsgBox "For Check1, TripleState = " & strTripleState & _
 ". The control will cycle through states for Yes and No " & _
 "values. Null values display as if they were No values."
 Case Else
 MsgBox "Can't determine the TripleState property for Check1."
End Select

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


BoundObjectFrame.Layout Property (Access)

 Copy code hover
[image]

BoundObjectFrame.Layout Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the type of layout for the specified object frame. Read-only AcLayoutType.

Version Information

Version Added: Access 2007

Syntax

expression .Layout

expression A variable that represents a BoundObjectFrame object.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Image.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

Image.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified image control. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthBottom

expression A variable that represents an Image object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Image Object

Other resources

Image Object Members


WebBrowserControl.BorderWidth Property (Access)

 Copy code hover
[image]

WebBrowserControl.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .BorderWidth

expression A variable that represents a WebBrowserControl object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


CurrentProject.CloseConnection Method (Access)

 Copy code hover
[image]

CurrentProject.CloseConnection Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the CloseConnection method to close the current connection between the CurrentProject object in a Microsoft Access project (.adp) or Access database and the database specified in the project's base connection string.

Syntax

expression .CloseConnection

expression A variable that represents a CurrentProject object.

Return Value

Nothing

Remarks

The CloseConnection method closes the current connection of the Access project, database, or data source control, frees the ADO Connection object, and sets the Connection property to Null. The BaseConnectionString property is left unchanged. Users are prevented from calling datasourcecontrol.Connection.Close and must use this method instead.

The CloseConnection method is useful when you have opened a Microsoft Access database from another application through Automation.

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


WebBrowserControl.Section Property (Access)

 Copy code hover
[image]

WebBrowserControl.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .Section

expression A variable that represents a WebBrowserControl object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


CONTAINER (Microsoft Access SQL reserved word)

 Copy code hover
[image]

CONTAINER (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The CONTAINER keyword is used in these contexts:

GRANT Statement

REVOKE Statement


OptionGroup.MouseDown Event (Access)

 Copy code hover
[image]

OptionGroup.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents an OptionGroup object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Example

The following example shows how you can find out which mouse button caused a MouseDown event.

To try the example, add the following event procedure to a form:

VBA Copy code Copy code
Private Sub Form_MouseDown(Button As Integer, _
         Shift As Integer, X As Single, _
         Y As Single)
    If Button = acLeftButton Then
        MsgBox "You pressed the left button."
    End If
    If Button = acRightButton Then
        MsgBox "You pressed the right button."
    End If
    If Button = acMiddleButton Then
        MsgBox "You pressed the middle button."
    End If
End Sub

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


FROM Clause (Microsoft Access SQL)

 Copy code hover
[image]

FROM Clause (Microsoft Access SQL)
Send feedback

Published: July 16, 2012

Specifies the tables or queries that contain the fields listed in the SELECT statement.

Syntax

SELECT fieldlist FROM tableexpression [IN externaldatabase]

A SELECT statement containing a FROM clause has these parts:

Part | Description
fieldlist | The name of the field or fields to be retrieved along with any field-name aliases, SQL aggregate functions, selection predicates (ALL, DISTINCT, DISTINCTROW, or TOP), or other SELECT statement options.
tableexpression | An expression that identifies one or more tables from which data is retrieved. The expression can be a single table name, a saved query name, or a compound resulting from an INNER JOIN, LEFT JOIN, or RIGHT JOIN.
externaldatabase | The full path of an external database containing all the tables in tableexpression.

Remarks

FROM is required and follows any SELECT statement.

The order of the table names in tableexpression is not important.

For improved performance and ease of use, it is recommended that you use a linked table instead of an IN clause to retrieve data from an external database.

The following example shows how you can retrieve data from the Employees table:

SQL Copy code Copy code
SELECT LastName, FirstName
FROM Employees;

Example

Some of the following examples assume the existence of a hypothetical Salary field in an Employees table. Note that this field does not actually exist in the Northwind database Employees table.

This example creates a dynaset-type Recordset based on an SQL statement that selects the LastName and FirstName fields of all records in the Employees table. It calls the EnumFields procedure, which prints the contents of a Recordset object to the Debug window.

VBA Copy code Copy code
Sub SelectX1()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Select the last name and first name values of all
    ' records in the Employees table.
    Set rst = dbs.OpenRecordset("SELECT LastName, " _
        & "FirstName FROM Employees;")

    ' Populate the recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset.
    EnumFields rst,12

    dbs.Close

End Sub

This example counts the number of records that have an entry in the PostalCode field and names the returned field Tally.

VBA Copy code Copy code
Sub SelectX2()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Count the number of records with a PostalCode
    ' value and return the total in the Tally field.
    Set rst = dbs.OpenRecordset("SELECT Count " _
        & "(PostalCode) AS Tally FROM Customers;")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of
    ' the Recordset. Specify field width = 12.
    EnumFields rst, 12

    dbs.Close

End Sub

This example shows the number of employees and the average and maximum salaries.

VBA Copy code Copy code
Sub SelectX3()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Count the number of employees, calculate the
    ' average salary, and return the highest salary.
    Set rst = dbs.OpenRecordset("SELECT Count (*) " _
        & "AS TotalEmployees, Avg(Salary) " _
        & "AS AverageSalary, Max(Salary) " _
        & "AS MaximumSalary FROM Employees;")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of
    ' the Recordset. Pass the Recordset object and
    ' desired field width.
    EnumFields rst, 17

    dbs.Close

End Sub

The Sub procedure EnumFields is passed a Recordset object from the calling procedure. The procedure then formats and prints the fields of the Recordset to the Debug window. The variable is the desired printed field width. Some fields may be truncated.

VBA Copy code Copy code
Sub EnumFields(rst As Recordset, intFldLen As Integer)

    Dim lngRecords As Long, lngFields As Long
    Dim lngRecCount As Long, lngFldCount As Long
    Dim strTitle As String, strTemp As String

    ' Set the lngRecords variable to the number of
    ' records in the Recordset.
    lngRecords = rst.RecordCount

    ' Set the lngFields variable to the number of
    ' fields in the Recordset.
    lngFields = rst.Fields.Count

    Debug.Print "There are " & lngRecords _
        & " records containing " & lngFields _
        & " fields in the recordset."
    Debug.Print

    ' Form a string to print the column heading.
    strTitle = "Record  "
    For lngFldCount = 0 To lngFields - 1
        strTitle = strTitle _
        & Left(rst.Fields(lngFldCount).Name _
        & Space(intFldLen), intFldLen)
    Next lngFldCount

    ' Print the column heading.
    Debug.Print strTitle
    Debug.Print

    ' Loop through the Recordset; print the record
    ' number and field values.
    rst.MoveFirst

    For lngRecCount = 0 To lngRecords - 1
        Debug.Print Right(Space(6) & _
            Str(lngRecCount), 6) & "  ";

        For lngFldCount = 0 To lngFields - 1
            ' Check for Null values.
            If IsNull(rst.Fields(lngFldCount)) Then
                strTemp = "<null>"
            Else
                ' Set strTemp to the field contents.
                Select Case _
                    rst.Fields(lngFldCount).Type
                    Case 11
                        strTemp = ""
                    Case dbText, dbMemo
                        strTemp = _
                            rst.Fields(lngFldCount)
                    Case Else
                        strTemp = _
                            str(rst.Fields(lngFldCount))
                End Select
            End If

            Debug.Print Left(strTemp _
                & Space(intFldLen), intFldLen);
        Next lngFldCount

        Debug.Print

        rst.MoveNext

    Next lngRecCount

End Sub


Attachment.OldValue Property (Access)

 Copy code hover
[image]

Attachment.OldValue Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.

Version Information

Version Added: Access 2007

Syntax

expression .OldValue

expression A variable that represents an Attachment object.

Remarks

The OldValue property contains the unedited data from a bound control and is read-only in all views.

Microsoft Access uses the OldValue property to store the original value of a bound control. When you edit a bound control on a form, your changes aren't saved until you move to another record. The OldValue property contains the unedited version of the underlying data.

You can provide your own undo capability by assigning the OldValue property setting to a control.

If the control hasn't been edited, this code has no effect. When you move to another record, the record source is updated, so the current value and the OldValue property will be the same.

The OldValue property setting has the same data type as the field to which the control is bound.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


CommandButton.GridlineWidthRight Property (Access)

 Copy code hover
[image]

CommandButton.GridlineWidthRight Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the right gridline for the specified button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthRight

expression A variable that represents a CommandButton object.

Remarks

The RightGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Recordset.BatchSize Property (DAO)

 Copy code hover
[image]

Recordset.BatchSize Property (DAO)
Send feedback

Syntax

expression .BatchSize

expression A variable that represents a Recordset object.

Remarks

The BatchSize property determines the batch size used when sending statements to the server in a batch update. The value of the property determines the number of statements sent to the server in one command buffer. By default, 15 statements are sent to the server in each batch. This property can be changed at any time. If a database server doesn't support statement batching, you can set this property to 1, causing each statement to be sent separately.

Example

This example uses the BatchSize and UpdateOptions properties to control aspects of any batch updating for the specified Recordset object.

Copy code Copy code
Sub BatchSizeX()

 Dim wrkMain As Workspace
 Dim conMain As Connection
 Dim rstTemp As Recordset

 Set wrkMain = CreateWorkspace("ODBCWorkspace", _
 "admin", "", dbUseODBC)
 ' This DefaultCursorDriver setting is required for
 ' batch updating.
 wrkMain.DefaultCursorDriver = dbUseClientBatchCursor

 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conMain = wrkMain.OpenConnection("Publishers", _
 dbDriverNoPrompt, False, _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 ' The following locking argument is required for
 ' batch updating.
 Set rstTemp = conMain.OpenRecordset( _
 "SELECT * FROM roysched", dbOpenDynaset, 0, _
 dbOptimisticBatch)

 With rstTemp
 ' Increase the number of statements sent to the server
 ' during a single batch update, thereby reducing the
 ' number of times an update would have to access the
 ' server.
 .BatchSize = 25

 ' Change the UpdateOptions property so that the WHERE
 ' clause of any batched statements going to the server
 ' will include any updated columns in addition to the
 ' key column(s). Also, any modifications to records
 ' will be made by deleting the original record
 ' and adding a modified version rather than just
 ' modifying the original record.
 .UpdateOptions = dbCriteriaModValues + _
 dbCriteriaDeleteInsert

 ' Engage in batch updating using the new settings
 ' above.
 ' ...

 .Close
 End With

 conMain.Close
 wrkMain.Close

End Sub


Line.Properties Property (Access)

 Copy code hover
[image]

Line.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a Line object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

Line Object

Other resources

Line Object Members


Circular reference caused by

 Copy code hover
[image]

Circular reference caused by <query reference>. (Error 3102)
Send feedback

You tried to execute a query that depends on itself for data. For example, this error occurs if you execute either of the following queries:

Query1

SQL Copy code Copy code
SELECT * FROM Employees, Query2;

Query2

SQL Copy code Copy code
SELECT * FROM Query1;

Redesign the queries to eliminate the dependency.


How to: Detect the Limits of a DAO Recordset

 Copy code hover
[image]

How to: Detect the Limits of a DAO Recordset
Send feedback

In a Recordset object, if you try to move beyond the beginning or ending record, a run-time error occurs. For example, if you try to use the MoveNext method when you are already at the last record of the Recordset, a trappable error occurs. For this reason, it is helpful to know the limits of the Recordset object.

The BOF property indicates whether the current position is at the beginning of the Recordset. If BOF is True, the current position is before the first record in the Recordset. The BOF property is also True if there are no records in the Recordset when it is opened. Similarly, the EOF property is True if the current position is after the last record in the Recordset, or if there are no records.

The following code example shows how to use the BOF and EOF properties to detect the beginning and end of a Recordset object. This code fragment creates a table-type Recordset based on the Orders table from the current database. It moves through the records, first from the beginning of the Recordset to the end, and then from the end of the Recordset to the beginning.

VBA Copy code Copy code
Dim dbsNorthwind As DAO.Database
Dim rstOrders As DAO.Recordset

   Set dbsNorthwind = CurrentDb
   Set rstOrders = dbsNorthwind.OpenRecordset("Orders")

   ' Do until ending of file.
   Do Until rstOrders.EOF
      '
      ' Manipulate the data.
      '
      rstOrders.MoveNext            ' Move to the next record.
   Loop

   rstOrders.MoveLast               ' Move to the last record.

   ' Do until beginning of file.
   Do Until rstOrders.BOF
      '
      ' Manipulate the data.
      '
      rstOrders.MovePrevious        ' Move to the previous record.
   Loop

Be aware that there is no current record immediately following the first loop. The BOF and EOF properties both have the following characteristics.

  • If the Recordset contains no records when you open it, both BOF and EOF are True.

  • When BOF or EOF is True, the property remains True until you move to an existing record, at which time the value of BOF or EOF becomes False.

  • When BOF or EOF is False, and the only record in a Recordset is deleted, the property remains False until you try to move to another record, at which time both BOF and EOF become True.

  • At the moment you create or open a Recordset that contains at least one record, the first record is the current record, and both BOF and EOF are False.

  • If the first record is the current record when you use the MovePrevious method, BOF is set to True. If you use MovePrevious while BOF is True, a run-time error occurs. When this happens, BOF remains True and there is no current record.

  • Similarly, moving past the last record in the Recordset changes the value of the EOF property to True. If you use the MoveNext method while EOF is True, a run-time error occurs. When this happens, EOF remains True and there is no current record.


TableDef.OpenRecordset Method (DAO)

 Copy code hover
[image]

TableDef.OpenRecordset Method (DAO)
Send feedback

Creates a new Recordset object and appends it to the Recordsets collection.

Syntax

expression .OpenRecordset(Type, Options)

expression A variable that represents a TableDef object.

Parameters

Name

Required/Optional

Data Type

Description

Name

Required

String

The source of the records for the new Recordset. The source can be a table name, a query name, or an SQL statement that returns records. For table-type Recordset objects in Microsoft Access database engine databases, the source can only be a table name.

Type

Optional

Variant

A RecordsetTypeEnum constant that indicates the type of Recordset to open.

Note Note

If you open a Recordset in a Microsoft Access workspace and you don't specify a type, OpenRecordset creates a table-type Recordset, if possible. If you specify a linked table or query, OpenRecordset creates a dynaset-type Recordset.

Options

Optional

Variant

A combination of RecordsetOptionEnum constants that specify characteristics of the new Recordset.

Note Note

The constants dbConsistent and dbInconsistent are mutually exclusive, and using both causes an error. Supplying a lockedits argument when options uses the dbReadOnly constant also causes an error.

LockEdit

Optional

Variant

A LockTypeEnum constant that determines the locking for the Recordset.

Note Note

You can use dbReadOnly in either the options argument or the lockedits argument, but not both. If you use it for both arguments, a run-time error occurs.

Return Value

Recordset

Remarks

Typically, if the user gets this error while updating a record, your code should refresh the contents of the fields and retrieve the newly modified values. If the error occurs while deleting a record, your code could display the new record data to the user and a message indicating that the data has recently changed. At this point, your code can request a confirmation that the user still wants to delete the record.

You should also use the dbSeeChanges constant if you open a Recordset in a Microsoft Access database engine-connected ODBC workspace against a Microsoft SQL Server 6.0 (or later) table that has an IDENTITY column, otherwise an error may result.

Opening more than one Recordset on an ODBC data source may fail because the connection is busy with a prior OpenRecordset call. One way around this is to fully populate the Recordset by using the MoveLast method as soon as the Recordset is opened.

Closing a Recordset with the Close method automatically deletes it from the Recordsets collection.

Note Note

If source refers to an SQL statement composed of a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strSQL = "PRICE > " & lngPrice, and lngPrice = 125,50), an error occurs when you try to open the Recordset. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and SQL only accepts U.S. decimal characters.


CHECK Constraint

 Copy code hover
[image]

CHECK Constraint <name> does not exist. (Error 3755)
Send feedback

This error occurs when, using the ALTER TABLE ALTER COLUMN syntax, you try to DROP a CHECK constraint that does not exist. This error also can occur when attempting to use the Microsoft Access Database Engine OLE DB Provider to obtain information on a CHECK constraint that does not exist.


ADO Event Instantiation by Language

 Copy code hover
[image]

ADO Event Instantiation by Language
Send feedback

Each programming language creates instances of ADO events differently. All of the following examples create a ConnectComplete event handler.

  • Visual Basic

  • Visual C++

  • Visual J++

  • VBScript

  • JScript

  • ADO/WFC


Criteria Expressions

 Copy code hover
[image]

Criteria Expressions
Send feedback

In this section

  • How to: Calculate Fields in Domain Aggregate Functions

  • How to: Include Quotation Marks in String Expressions

  • How to: Sort Records in Case-Sensitive ( ASCII) Order

  • How to: Use Multiple Fields in Criteria Expressions

  • How to: Use Numeric Criteria in Expressions

  • How to: Use Numeric Criteria from a Control on a Form

  • How to: Use Textual Criteria Expressions

  • How to: Use Textual Criteria from a Control on a Form


Shape Compute Clause

 Copy code hover
[image]

Shape Compute Clause
Send feedback

A shape COMPUTE clause generates a parent Recordset, whose columns consist of a reference to the child Recordset; optional columns whose contents are chapter, new, or calculated columns, or the result of executing aggregate functions on the child Recordset or a previously shaped Recordset; and any columns from the child Recordset listed in the optional BY clause.

Syntax

Copy code Copy code

SHAPE child-command [AS] child-alias
   COMPUTE child-alias [[AS] name], [appended-column-list]
   [BY grp-field-list]

Description

The parts of this clause are as follows:

  • child-command

  • Consists of one of the following:

    • A query command within curly braces ("{}") that returns a child Recordset object. The command is issued to the underlying data provider, and its syntax depends on the requirements of that provider. This will typically be the SQL language, although ADO does not require any particular query language.

    • The name of an existing shaped Recordset.

    • Another shape command.

    • The TABLE keyword, followed by the name of a table in the data provider.

  • child-alias

  • An alias used to refer to the Recordset returned by the child-command. The child-alias is required in the list of columns in the COMPUTE clause and defines the relation between the parent and child Recordset objects.

  • appended-column-list

  • A list in which each element defines a column in the generated parent. Each element contains either a chapter column, a new column, a calculated column, or a value resulting from an aggregate function on the child Recordset.

  • grp-field-list

  • A list of columns in the parent and child Recordset objects that specifies how rows should be grouped in the child. For each column in the grp-field-list, there is a corresponding column in the child and parent Recordset objects. For each row in the parent Recordset, the grp-field-list columns have unique values, and the child Recordset referenced by the parent row consists solely of child rows whose grp-field-list columns have the same values as the parent row.

If the BY clause is included, the child Recordset's rows will be grouped based on the columns in the COMPUTE clause. The parent Recordset will contain one row for each group of rows in the child Recordset.

If the BY clause is omitted, the entire child Recordset is treated as a single group and the parent Recordset will contain exactly one row. That row will reference the entire child Recordset. Omitting the BY clause allows you to compute "grand total" aggregates over the entire child Recordset.

For example:

VBA Copy code Copy code
SHAPE {select * from Orders} AS orders
   COMPUTE orders, SUM(orders.OrderAmount) as TotalSales

Regardless of which way the parent Recordset is formed (using COMPUTE or using APPEND), it will contain a chapter column that is used to relate it to a child Recordset. If you wish, the parent Recordset may also contain columns that contain aggregates (SUM, MIN, MAX, and so on) over the child rows. Both the parent and the child Recordset may contain columns that contain an expression on the row in the Recordset, as well as columns that are new and initially empty.

Operation

The child-command is issued to the provider, which returns a child Recordset.

The COMPUTE clause specifies the columns of the parent Recordset, which may be a reference to the child Recordset, one or more aggregates, a calculated expression, or new columns. If there is a BY clause, the columns it defines are also appended to the parent Recordset. The BY clause specifies how the rows of the child Recordset are grouped.

For example, assume you have a table — Demographics — consisting of State, City, and Population fields (the population figures are solely for illustration).

State | City | Population
WA | Seattle | 700,000
OR | Medford | 200,000
OR | Portland | 400,000
CA | Los Angeles | 800,000
CA | San Diego | 600,000
WA | Tacoma | 500,000
OR | Corvallis | 300,000

Now, issue this shape command:

VBA Copy code Copy code

rst.Open  "SHAPE {select * from demographics} AS rs "  & _
          "COMPUTE rs, SUM(rs.population) BY state", _
           objConnection

This command opens a shaped Recordset with two levels. The parent level is a generated Recordset with an aggregate column (SUM(rs.population) ), a column referencing the child Recordset (rs ), and a column for grouping the child Recordset (state ). The child level is the Recordset returned by the query command (), a column referencing the child Recordset (rs ), and a column for grouping the child Recordset (state ). The child level is the Recordset returned by the query command (select * from demographics ).

The child Recordset detail rows will be grouped by state, but otherwise in no particular order. That is, the groups will not be in alphabetical or numerical order. If you want the parent Recordset to be ordered, you can use the Recordset Sort method to order the parent Recordset.

You can now navigate the opened parent Recordset and access the child detail Recordset objects. For more information, see Accessing Rows in a Hierarchical Recordset.

Resultant Parent and Child Detail Recordsets

Parent

SUM (rs.Population) | rs | State
1,300,000 | Reference to child1 | CA
1,200,000 | Reference to child2 | WA
1,100,000 | Reference to child3 | OR

Child1

State | City | Population
CA | Los Angeles | 800,000
CA | San Diego | 600,000

Child2

State | City | Population
WA | Seattle | 700,000
WA | Tacoma | 500,000

Child3

State | City | Population
OR | Medford | 200,000
OR | Portland | 400,000
OR | Corvallis | 300,000


CommandButton.RightPadding Property (Access)

 Copy code hover
[image]

CommandButton.RightPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the button and its right gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .RightPadding

expression A variable that represents a CommandButton object.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Application.CreateControl Method (Access)

 Copy code hover
[image]

Application.CreateControl Method (Access)
See also Send feedback

Published: July 16, 2012

The CreateControl method creates a control on a specified open form. For example, suppose you are building a custom wizard that allows users to easily construct a particular form. You can use the CreateControl method in your wizard to add the appropriate controls to the form.

Syntax

expression .CreateControl(FormName, ControlType, Section, Parent, ColumnName, Left, Top, Width, Height)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
FormName | Required | String | The name of the open form or report on which you want to create the control.
ControlType | Required | AcControlType | An AcControlType constant that represents the type of control you want to create.
Section | Optional | AcSection | An AcSection constant that identifying the section that will contain the new control.
Parent | Optional | Variant | The name of the parent control of an attached control. For controls that have no parent control, use a zero-length string for this argument, or omit it.
ColumnName | Optional | Variant | The name of the field to which the control will be bound, if it is to be a data-bound control.
Left,Top | Optional | Variant | The coordinates for the upper-left corner of the control in twips.
Width, Height | Optional | Variant | Numeric expressions indicating the width and height of the control in twips.

Return Value

Control

Remarks

You can use the CreateControl and CreateReportControl methods in a custom wizard to create controls on a form or report. Both methods return a Control object.

You can use the CreateControl and CreateReportControl methods only in form Design view or report Design view, respectively.

You use the parent argument to identify the relationship between a main control and a subordinate control. For example, if a text box has an attached label, the text box is the main (or parent) control and the label is the subordinate (or child) control. When you create the label control, set its parent argument to a string identifying the name of the parent control. When you create the text box, set its parent argument to a zero-length string.

You also set the parent argument when you create check boxes, option buttons, or toggle buttons. An option group is the parent control of any check boxes, option buttons, or toggle buttons that it contains. The only controls that can have a parent control are a label, check box, option button, or toggle button. All of these controls can also be created independently, without a parent control.

Set the columnname argument according to the type of control you are creating and whether or not it will be bound to a field in a table. The controls that may be bound to a field include the text box, list box, combo box, option group, and bound object frame. Additionally, the toggle button, option button, and check box controls may be bound to a field if they are not contained in an option group.

If you specify the name of a field for the columnname argument, you create a control that is bound to that field. All of the control's properties are then automatically set to the settings of any corresponding field properties. For example, the value of the control's ValidationRule property will be the same as the value of that property for the field.

Note Note

If your wizard creates controls on a new or existing form or report, it must first open the form or report in Design view.

To remove a control from a form or report, use the DeleteControl and DeleteReportControl statements.

Example

The following example first creates a new form based on an Orders table. It then uses the CreateControl method to create a text box control and an attached label control on the form.

VBA Copy code Copy code
Sub NewControls()
 Dim frm As Form
 Dim ctlLabel As Control, ctlText As Control
 Dim intDataX As Integer, intDataY As Integer
 Dim intLabelX As Integer, intLabelY As Integer

 ' Create new form with Orders table as its record source.
 Set frm = CreateForm
 frm.RecordSource = "Orders"
 ' Set positioning values for new controls.
 intLabelX = 100
 intLabelY = 100
 intDataX = 1000
 intDataY = 100
 ' Create unbound default-size text box in detail section.
 Set ctlText = CreateControl(frm.Name, acTextBox, , "", "", _
 intDataX, intDataY)
 ' Create child label control for text box.
 Set ctlLabel = CreateControl(frm.Name, acLabel, , _
 ctlText.Name, "NewLabel", intLabelX, intLabelY)
 ' Restore form.
 DoCmd.Restore
End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


ObjectFrame.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

ObjectFrame.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified frame. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthBottom

expression A variable that represents an ObjectFrame object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


ComboBox.Undo Method (Access)

 Copy code hover
[image]

ComboBox.Undo Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the Undo method to reset a control or form when its value has been changed.

Syntax

expression .Undo

expression A variable that represents a ComboBox object.

Remarks

For example, you can use the Undo method to clear a change to a record that contains an invalid entry.

If the Undo method is applied to a form, all changes to the current record are lost. If the Undo method is applied to a control, only the control itself is affected.

This method must be applied before the form or control is updated. You may want to include this method in a form's BeforeUpdate event or in a control's Change event.

The Undo method offers an alternative to using the SendKeys statement to send the value of the ESC key in an event procedure.

Example

The following example shows how you can use the Undo method within a control's Change event procedure to force a field named LastName to reset to its original value, if it changed.

VBA Copy code Copy code
Private Sub LastName_Change()
 Me!LastName.Undo
End Sub

The next example uses the Undo method to reset all changes to a form before the form is updated.

VBA Copy code Copy code
Private Sub Form_BeforeUpdate(Cancel As Integer)
 Me.Undo
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ODBC - update on a linked table

 Copy code hover
[image]

ODBC - update on a linked table <table> failed. (Error 3157)
Send feedback

Using an ODBC connection, you tried to update data in an ODBC database; that update could not be completed.

Possible causes:

  • The update would have caused a rule violation.

  • The ODBC database is read-only, or you do not have permission to update data in that database. Resolve the read-only condition, or see your system administrator or the person who created the database to obtain the necessary permissions.

  • The ODBC database is on a network drive and the network is not connected. Make sure the network is available, and then try the operation again.


Application.CloseCurrentDatabase Method (Access)

 Copy code hover
[image]

Application.CloseCurrentDatabase Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the CloseCurrentDatabase method to close the current database (either a Microsoft Access database or an Access project (.adp) from another application that has opened a database through Automation.

Syntax

expression .CloseCurrentDatabase

expression A variable that represents an Application object.

Return Value

Nothing

Remarks

For example, you might use this method from Microsoft Excel to close the database currently open in the Microsoft Access window before opening another database.

The CloseCurrentDatabase method is useful when you have opened a Microsoft Access database from another application through Automation. Once you have created an instance of Microsoft Access from another application, you must also create a new database or specify an existing database to open. This database opens in the Microsoft Access window.

If you use the CloseCurrentDatabase method to close the database that is open in the current instance of Microsoft Access, you can then open a different database without having to create another instance of Microsoft Access.

Example

The following example opens a Microsoft Access database from another application through Automation, creates a new form and saves it, then closes the database.

You can enter this code in a Visual Basic module in any application that can act as a COM component. For example, you might run the following code from Microsoft Excel or Microsoft Visual Basic.

When the variable pointing to the Application object goes out of scope, the instance of Microsoft Access that it represents closes as well. Therefore, you should declare this variable at the module level.

VBA Copy code Copy code
' Enter following in Declarations section of module.
Dim appAccess As Access.Application

Sub CreateForm()
 Const strConPathToSamples = "C:\Program Files\Microsoft Office\Office12\Samples\"

 Dim frm As Form, strDB As String

 ' Initialize string to database path.
 strDB = strConPathToSamples & "Northwind.mdb"
 ' Create new instance of Microsoft Access.
 Set appAccess = CreateObject("Access.Application")
 ' Open database in Microsoft Access window.
 appAccess.OpenCurrentDatabase strDB
 ' Create new form.
 Set frm = appAccess.CreateForm
 ' Save new form.
 appAccess.DoCmd.Save , "NewForm1"
 ' Close currently open database.
 appAccess.CloseCurrentDatabase
 Set AppAccess = Nothing
End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


INDEX (Microsoft Access SQL reserved word)

 Copy code hover
[image]

INDEX (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The INDEX keyword is used in these contexts:

CREATE INDEX Statement

DROP Statement

GRANT Statement

REVOKE Statement


You cannot make changes to the design of the database at this replica. (Error 3452)

 Copy code hover
[image]

You cannot make changes to the design of the database at this replica. (Error 3452)
Send feedback

Changes to the design of a replicated database can be made only at the Design Master. The replica you are attempting to change is not the Design Master for the replica set. Locate the Design Master and make your changes there.


EmptyCell.HelpContextId Property (Access)

 Copy code hover
[image]

EmptyCell.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HelpContextId

expression A variable that represents an EmptyCell object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


ListBox.AutoLabel Property (Access)

 Copy code hover
[image]

ListBox.AutoLabel Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.

Syntax

expression .AutoLabel

expression A variable that represents a ListBox object.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


DROP (Microsoft Access SQL reserved word)

 Copy code hover
[image]

DROP (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The DROP keyword is used in these contexts:

ALTER TABLE Statement

DROP Statement

DROP USER or GROUP Statement

GRANT Statement

REVOKE Statement


ComboBox.Dropdown Method (Access)

 Copy code hover
[image]

ComboBox.Dropdown Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the Dropdown method to force the list in the specified combo box to drop down.

Syntax

expression .Dropdown

expression A variable that represents a ComboBox object.

Return Value

Nothing

Remarks

For example, you can use this method to cause a combo box listing vendor codes to drop down when the vendor code control receives the focus during data entry.

If the specified combo box control doesn't have the focus, an error occurs. The use of this method is identical to pressing the F4 key when the control has the focus.

Example

The following example shows how you can use the Dropdown method within the GotFocus event procedure to force a combo box named SupplierID to drop down when it receives the focus.

VBA Copy code Copy code
Private Sub SupplierID_GotFocus()
 Me!SupplierID.Dropdown
End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


ListBox.BoundColumn Property (Access)

 Copy code hover
[image]

ListBox.BoundColumn Property (Access)
See also Send feedback

Published: July 16, 2012

When you make a selection from a list box, the BoundColumn property tells Microsoft Access which column's values to use as the value of the control. If the control is bound to a field, the value in the column specified by the BoundColumn property is stored in the field named in the ControlSource property. Read/write Long.

Syntax

expression .BoundColumn

expression A variable that represents a ListBox object.

Remarks

The BoundColumn property uses the following settings.

Setting | Description
0 | The ListIndex property value, rather than the column value, is stored in the current record. The ListIndex property value of the first row is 0, the second row is 1, and so on. Microsoft Access sets the ListIndex property when an item is selected from a list box or the list box portion of a combo box. Setting the BoundColumn property to 0 and using the ListIndex property value of the control might be useful if, for example, you are only interested in storing a sequence of numbers.
1 or greater | (Default is 1) The value in the specified column becomes the control's value. If the control is bound to a field, then this setting is stored in that field in the current record. The BoundColumn property can't be set to a value larger than the setting of the ColumnCount property.

For table fields , you can set this property on the Lookup tab in the Field Properties section of table Design view for fields with the DisplayControl property set to Combo Box or List Box.

In Visual Basic, set the BoundColumn property by using a number or a numeric expression equal to a value from 0 to the setting of the ColumnCount property.

Note Note

If the bound column is not the same as the leftmost visible column in the control (or if you set the BoundColumn property to 0), the LimitToList property is set to Yes.

Microsoft Access uses zero-based numbers to refer to columns in the Column property. That is, the first column is referenced by using the expression Column(0); the second column is referenced by using the expression Column(1); and so on. However, the BoundColumn property uses 1-based numbers to refer to the columns. This means that if the BoundColumn property is set to 1, you could access the value stored in that column by using the expression Column(0).

If the AutoExpand property is set to Yes, Microsoft Access automatically fills in a value in the text box portion of the combo box that matches a value in the combo box list as you type.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Cannot set value. (Error 2448)

 Copy code hover
[image]

Cannot set value. (Error 2448)
Send feedback

You are trying to assign a value to an object that is read-only or does not have a value.


DeleteRecord Data Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

DeleteRecord Data Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

You can use the DeleteRecord action to delete a record.

Setting

The DeleteRecord action has the following arguments.

Argument | Description
Record Alias | A string that identifies the record to delete. If the Alias argument is not specified, then the current record is deleted.

Remarks

You can use the LastCreateRecordIdentity local variable to work with last record created in a CreateRecord data block. For example, use the following syntax to refer to the most recently created record:

Copy code Copy code
[LastCreateRecordIdentity]


Specify the table containing the records you want to delete. (Error 3128)

 Copy code hover
[image]

Specify the table containing the records you want to delete. (Error 3128)
Send feedback

You tried to execute a delete query but the query does not specify the name of the table containing the records you want to delete.

Possible cause:

  • You did not type an asterisk for each table in the ALL, DISTINCT, DISTINCTROW predicates. Instead, you typed field names (for example, Customers.Address instead of Customers.* ).


TempVars Properties (Access)

 Copy code hover
[image]

TempVars Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | Gets the number of TempVar objects in the TempVars collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only TempVar.
Parent | Returns the parent object for the specified object. Read-only Object.


Label.ReadingOrder Property (Access)

 Copy code hover
[image]

Label.ReadingOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write Byte.

Syntax

expression .ReadingOrder

expression A variable that represents a Label object.

Remarks

The ReadingOrder property uses the following settings.

Setting | Visual Basic | Description
Context | 0 | Reading order is determined by the language of the first character entered. If a right-to-left language character is entered first, reading order is right to left. If a left-to-right language character is entered first, reading order is left to right.
Left-to-Right | 1 | Sets the reading order to left to right.
Right-to-Left | 2 | Sets the reading order to right to left.

Example

The following example sets the reading order to right to left for the "Address" text box on the "International Shipping" form.

VBA Copy code Copy code
Forms("International Shipping").Controls("Address").ReadingOrder = 2

See also

Concepts

Label Object

Other resources

Label Object Members


ListBox.Enabled Property (Access)

 Copy code hover
[image]

ListBox.Enabled Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.

Syntax

expression .Enabled

expression A variable that represents a ListBox object.

Remarks

The Enabled property setting is a value that indicates whether the conditional format is enabled or disabled. True enables the conditional format. False disables the conditional format. The default is True.

When the Enabled property is True, the conditional format can be displayed in the Conditional Formatting dialog box.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Data Actions

 Copy code hover
[image]

Data Actions
Send feedback

In this section

  • CancelRecordChange Macro Action

  • ClearMacroError Macro Action

  • ExitForEachRecord Macro Action

  • LogEvent Macro Action

  • OnError Macro Action

  • RaiseError Macro Action

  • SendEmail Macro Action

  • SetField Macro Action

  • SetLocalVar Macro Action

  • SetReturnVar Macro Action


AcSeparatorCharacters Enumeration (Access)

 Copy code hover
[image]

AcSeparatorCharacters Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the SeparatorCharacters property to specify the separator displayed between values in combo boxes that are linked to multi-valued fields.

Version Information

Version Added: Access 2007

Name | Value | Description
acSeparatorCharactersComma | 3 | A comma (,) is used as the separator character.
acSeparatorCharactersNewLine | 1 | Each value appears on its own line.
acSeparatorCharactersSemiColon | 2 | A semicolon (;) is used as the separator character.
acSeparatorCharactersSystemSeparator | 0 | The List separator setting in the Regional and Language Options in Windows Control Panel is used as the separator character.


Dealing with Failed Updates
Send feedback

Dealing with Failed Updates

When an update concludes with errors, how you resolve the errors depends on the nature and severity of the errors and the logic of your application. However, if the database is shared with other users, a typical error is that someone else modifies the field before you do. This type of error is called a conflict. ADO detects this situation and reports an error.

If there are update errors, they will be trapped in an error-handling routine. Filter the Recordset with the adFilterConflictingRecords constant so that only the conflicting rows are visible. In this example, the error-resolution strategy is merely to print the author's first and last names (au_fname and au_lname).

The code to alert the user to the update conflict looks like this:

Copy code Copy code

objRs.Filter = adFilterConflictingRecords
objRs.MoveFirst
Do While Not objRst.EOF
   Debug.Print "Conflict: Name =  "; objRs!au_fname; " "; objRs!au_lname
   objRs.MoveNext
Loop


BoundObjectFrame.BorderWidth Property (Access)

 Copy code hover
[image]

BoundObjectFrame.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Syntax

expression .BorderWidth

expression A variable that represents a BoundObjectFrame object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


CommandButton.GridlineStyleTop Property (Access)

 Copy code hover
[image]

CommandButton.GridlineStyleTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the top gridline style of the specified button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleTop

expression A variable that represents a CommandButton object.

Remarks

The TopGridlineStyle property uses the following settings.

Setting | Gridline type
0 (default) | Transparent
1 | Solid
2 | Dashes
3 | Short Dashes
4 | Dots
5 | Sparse Dots
6 | Dash Dot
7 | Dash Dot Dot

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Image.Parent Property (Access)

 Copy code hover
[image]

Image.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents an Image object.

See also

Concepts

Image Object

Other resources

Image Object Members


Workspace.IsolateODBCTrans Property (DAO)

 Copy code hover
[image]

Workspace.IsolateODBCTrans Property (DAO)
Send feedback

Sets or returns a value that indicates whether multiple transactiond that involve the same Microsoft Access database engine-connected ODBC data source are isolated (Microsoft Access workspaces only).

Syntax

expression .IsolateODBCTrans

expression A variable that represents a Workspace object.

Remarks

In some situations, you need to have multiple simultaneous transactions pending on the same ODBC connection. To do this, you need to open a separate Workspace for each transaction. Although each Workspace can have its own ODBC connection to the database, this slows system performance. Because transaction isolation isn't usually required, ODBC connections from multiple Workspace objects opened by the same user are shared by default.

Some ODBC servers, such as Microsoft SQL Server, don't allow simultaneous transactions on a single connection. If you need to have more than one transaction at a time pending against such a database, set the IsolateODBCTrans property to True on each Workspace as soon as you open it. This forces a separate ODBC connection for each Workspace.


A cancel was performed on the operation. (Error 3642)

 Copy code hover
[image]

A cancel was performed on the operation. (Error 3642)
Send feedback

A query has been interrupted by the data source. Some of the matching rows have not been returned. Try submitting the query again.


CustomControl.ObjectVerbsCount Property (Access)

 Copy code hover
[image]

CustomControl.ObjectVerbsCount Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ObjectVerbsCount property in Visual Basic to determine the number of verbs supported by an OLE object. Read-only Long.

Syntax

expression .ObjectVerbsCount

expression A variable that represents a CustomControl object.

Remarks

The ObjectVerbsCount property setting is a value that specifies the number of elements in the ObjectVerbs property array.

This property setting isn't available in Design view.

The list of verbs an OLE object supports may vary, depending on the state of the object. To update the list of supported verbs, set the control'sAction property to acOLEFetchVerbs.

Example

The following example returns the verbs supported by the OLE object in the OLE1 control and displays each verb in a message box.

VBA Copy code Copy code
Sub GetVerbList(frm As Form, OLE1 As Control)
 Dim intX As Integer, intNumVerbs As Integer
 Dim strVerbList As String

 ' Update verb list.
 With frm!OLE1
 .Action = acOLEFetchVerbs
 intNumVerbs = .ObjectVerbsCount
 For intX = 0 To intNumVerbs - 1
 strVerbList = strVerbList & .ObjectVerbs(intX) & "; "
 Next intX
 End With

 ' Display verbs in message box.
 MsgBox Left(strVerbList, Len(strVerbList) - 2)
End Sub

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


ListBox.OnKeyPress Property (Access)

 Copy code hover
[image]

ListBox.OnKeyPress Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Press box in the Properties window. Read/write String.

Syntax

expression .OnKeyPress

expression A variable that represents a ListBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyPress event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyPress value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Press box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Press box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyPress property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyPress

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Custom date and time formats for the Format function (Access 2013 custom web app)

 Copy code hover
[image]

Custom date and time formats for the Format function (Access 2013 custom web app)
Send feedback

Published: August 15, 2012

Learn how to control how a date or time is displayed by creating a custom formatting.

Applies to:

Format Specifications

The following table lists characters you can use with the Format Function (Access 2013 custom web app) function to create custom date and time formats.

Format specification | Description
(:) | Time separator. In some locales, other characters may be used to represent the time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character that is used as the time separator in formatted output is determined by your application's current culture value.
(/) | Date separator. In some locales, other characters may be used to represent the date separator. The date separator separates the day, month, and year when date values are formatted. The actual character that is used as the date separator in formatted output is determined by your application's current culture.
(%) | Used to indicate that the following character should be read as a single-letter format without regard to any trailing letters. Also used to indicate that a single-letter format is read as a user-defined format. See what follows for additional details.
d | Displays the day as a number without a leading zero (for example, 1). Use %d if this is the only character in your user-defined numeric format.
dd | Displays the day as a number with a leading zero (for example, 01).
ddd | Displays the day as an abbreviation (for example, Sun).
dddd | Displays the day as a full name (for example, Sunday).
M | Displays the month as a number without a leading zero (for example, January is represented as 1). Use %M if this is the only character in your user-defined numeric format.
MM | Displays the month as a number with a leading zero (for example, 01/12/01).
MMM | Displays the month as an abbreviation (for example, Jan).
MMMM | Displays the month as a full month name (for example, January).
gg | Displays the period/era string (for example, A.D.).
h | Displays the hour as a number without leading zeros using the 12-hour clock (for example, 1:15:15 PM). Use %h if this is the only character in your user-defined numeric format.
hh | Displays the hour as a number with leading zeros using the 12-hour clock (for example, 01:15:15 PM).
H | Displays the hour as a number without leading zeros using the 24-hour clock (for example, 1:15:15). Use %H if this is the only character in your user-defined numeric format.
HH | Displays the hour as a number with leading zeros using the 24-hour clock (for example, 01:15:15).
m | Displays the minute as a number without leading zeros (for example, 12:1:15). Use %m if this is the only character in your user-defined numeric format.
mm | Displays the minute as a number with leading zeros (for example, 12:01:15).
s | Displays the second as a number without leading zeros (for example, 12:15:5). Use %s if this is the only character in your user-defined numeric format.
ss | Displays the second as a number with leading zeros (for example, 12:15:05).
f | Displays fractions of seconds. For example ff displays hundredths of seconds, whereas ffff displays ten-thousandths of seconds. You may use up to seven f symbols in your user-defined format. Use %f if this is the only character in your user-defined numeric format.
t | Uses the 12-hour clock and displays an uppercase A for any hour before noon; displays an uppercase P for any hour between noon and 11:59 P.M. Use %t if this is the only character in your user-defined numeric format.
tt | For locales that use a 12-hour clock, displays an uppercase AM with any hour before noon; displays an uppercase PM with any hour between noon and 11:59 P.M. For locales that use a 24-hour clock, displays nothing.
y | Displays the year number (0-9) without leading zeros. Use %y if this is the only character in your user-defined numeric format.
yy | Displays the year in two-digit numeric format with a leading zero, if applicable.
yyy | Displays the year in four-digit numeric format.
yyyy | Displays the year in four-digit numeric format.
 | Displays the timezone offset without a leading zero (for example, -8). Use %z if this is the only character in your user-defined numeric format.
z | Displays the timezone offset with a leading zero (for example, -08).
zz | Displays the timezone offset with a leading zero (for example, -08)
zzz | Displays the full timezone offset (for example, -08:00)

Remarks

Formatting strings are case-sensitive. Different formatting can be obtained by using a different case. For example, when formatting a date value with the string "D" you get the date in the long format (according to your current locale). However, if you change the case to "d" you get the date in the short format. Also, unexpected results or an error might occur if the intended formatting does not match the case of any defined format string.

Additional Resources

Format Function (Access 2013 custom web app)

Custom numeric formats for the Format function (Access 2013 custom web app)


ToggleButton.OnLostFocus Property (Access)

 Copy code hover
[image]

ToggleButton.OnLostFocus Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Lost Focus box in the Properties window of the specified object. Read/write String.

Syntax

expression .OnLostFocus

expression A variable that represents a ToggleButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The LostFocus event occurs when the object loses the focus.

The OnLostFocus value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Lost Focus box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Lost Focus box is blank, the property value is an empty string.

Example

The following example prints the value of the OnLostFocus property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnLostFocus

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


String Operators (Access 2013 custom web app)

 Copy code hover
[image]

String Operators (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • + (String Concatenation Operator) (Access 2013 custom web app)


AccessObjectProperties.Count Property (Access)

 Copy code hover
[image]

AccessObjectProperties.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents an AccessObjectProperties object.

See also

Concepts

AccessObjectProperties Collection

Other resources

AccessObjectProperties Object Members


Form.ViewChange Property (Access)

 Copy code hover
[image]

Form.ViewChange Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the ViewChange event occurs. Read/write.

Syntax

expression .ViewChange

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the ViewChange event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).ViewChange = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


CommandButton.TabIndex Property (Access)

 Copy code hover
[image]

CommandButton.TabIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.

Syntax

expression .TabIndex

expression A variable that represents a CommandButton object.

Remarks

You can set the TabIndex property to an integer representing the position of the control within the tab order of the form. Valid settings are 0 for the first tab position, up to the total number of controls minus 1 for the last tab position. For example, if a form has three controls that each have a TabIndex property, valid TabIndex property settings are 0, 1, and 2.

Setting the TabIndex property to an integer less than 0 produces an error.

By default, Microsoft Access assigns a tab order to controls in the order that you create them on a form. Each new control is placed last in the tab order. If you change the setting of a control's TabIndex property to adjust the tab order, Microsoft Access automatically renumbers the TabIndex property setting of other controls to reflect insertions and deletions.

In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the TAB key.

Changing the tab order of other controls on the form doesn't affect what happens when you press a control's access key. For example, if you've created an access key for the label of a text box, the focus will move to the text box whenever you press the label's access key — even if you change the TabIndex property setting for the text box.

If you press an access key for a control such as a label that doesn't have a TabIndex property (and thus isn't in the tab order), the focus moves to the next control in the tab order that can receive the focus.

Example

The following example reverses the tab order of a command button and a text box. Because TextBox1 was created first, it has a TabIndex property setting of 0 and Command1 has a setting of 1.

VBA Copy code Copy code
Sub Form_Click()
 Me!Command1.TabIndex = 0
 Me!TextBox1.TabIndex = 1
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


CommitTransOptionsEnum Enumeration (DAO)

 Copy code hover
[image]

CommitTransOptionsEnum Enumeration (DAO)
Send feedback

Insert introduction here.

Section Heading

Insert section body here.

Subsection Heading

Insert subsection body here.


DoCmd.CancelEvent Method (Access)

 Copy code hover
[image]

DoCmd.CancelEvent Method (Access)
See also Send feedback

Published: July 16, 2012

The CancelEvent method carries out the CancelEvent action in Visual Basic.

Syntax

expression .CancelEvent

expression A variable that represents a DoCmd object.

Remarks

You can use the CancelEvent method to cancel the event that caused Microsoft Access to run the procedure containing this method.

The CancelEvent method has an effect only when it's run as the result of an event. This method cancels the event.

In a form, you typically use the CancelEvent action in a validation macro with the BeforeUpdate event property. When a user enters data in a control or record, Access runs the macro before adding the data to the database. If the data fails the validation conditions in the macro, the CancelEvent action cancels the update process before it starts.

All events that can be canceled in Visual Basic have a Cancel argument. You can use this argument instead of the CancelEvent method to cancel the event. The KeyPress event and MouseDown event (for right-clicking only) can be canceled only in macros, not event procedures, so you must use the CancelEvent action in a macro to cancel these events.

Note Note

You can use the CancelEvent method with the MouseDown event only to cancel the event that occurs when you right-click an object.

For events that can be canceled, the default behavior for the event (that is, what Access typically does when the event occurs) occurs after the procedure for the event runs. This enables you to cancel the default behavior. For example, when you double-click a word that the insertion point is on in a text box, Access normally selects the word. You can cancel this default behavior in the procedure for the DblClick event and perform some other action, such as opening a form containing information about the data in the text box. For events that can't be canceled, the default behavior occurs before the procedure runs.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Label.Hyperlink Property (Access)

 Copy code hover
[image]

Label.Hyperlink Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.

Syntax

expression .Hyperlink

expression A variable that represents a Label object.

Example

The CreateHyperlink procedure in the following example sets the hyperlink properties for a command button, label, or image control to the address and subaddress values passed to the procedure. The address setting is an optional argument, because a hyperlink to an object in the current database uses only the subaddress setting, To try this example, create a form with two text box controls (txtAddress and txtSubAddress) and a command button (cmdFollowLink) and paste the following into the Declarations section of the form's module:

VBA Copy code Copy code
Private Sub cmdFollowLink_Click()
 CreateHyperlink Me!cmdFollowLink, Me!txtSubAddress, _
 Me!txtAddress
End Sub

Sub CreateHyperlink(ctlSelected As Control, _
 strSubAddress As String, Optional strAddress As String)
 Dim hlk As Hyperlink
 Select Case ctlSelected.ControlType
 Case acLabel, acImage, acCommandButton
 Set hlk = ctlSelected.Hyperlink
 With hlk
 If Not IsMissing(strAddress) Then
 .Address = strAddress
 Else
 .Address = ""
 End If
 .SubAddress = strSubAddress
 .Follow
 .Address = ""
 .SubAddress = ""
 End With
 Case Else
 MsgBox "The control '" & ctlSelected.Name _
 & "' does not support hyperlinks."
 End Select
End Sub

See also

Concepts

Label Object

Other resources

Label Object Members


One of the binding parameters is incorrect. (Error 3645)

 Copy code hover
[image]

One of the binding parameters is incorrect. (Error 3645)
Send feedback

A data type or binding type in the binding structure passed to GetRows or GetRowsEx was an invalid value, or the maximum field length is invalid for the indicated data type.

Check your binding structure.


Form.DividingLines Property (Access)

 Copy code hover
[image]

Form.DividingLines Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the DividingLines property to specify whether dividing lines will separate sections on a form or records displayed on a continuous form. Read/write Boolean.

Syntax

expression .DividingLines

expression A variable that represents a Form object.

Remarks

The default value is True.

This property can be set in any view.

See also

Concepts

Form Object

Other resources

Form Object Members


Position Object (ADO MD)

 Copy code hover
[image]

Position Object (ADO MD)
Send feedback

Represents a set of one or more members of different dimensions that defines a point along an axis.

Remarks

With the properties and collections of a Position object you can do the following:

  • Use the Ordinal property to return the ordinal position of the Position along the Axis.

  • Use the Members collection to return the members that make up the position along the Axis.


NextRecordset Method Example (VB)

 Copy code hover
[image]

NextRecordset Method Example (VB)
Send feedback

This example uses the NextRecordset method to view the data in a recordset that uses a compound command statement made up of three separate SELECT statements.

Copy code Copy code

'BeginNextRecordsetVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 ' connection and recordset variables
 Dim rstCompound As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim SQLCompound As String

 Dim intCount As Integer

 ' Open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open compound recordset
 Set rstCompound = New ADODB.Recordset
 SQLCompound = "SELECT * FROM Authors; " & _
 "SELECT * FROM stores; " & _
 "SELECT * FROM jobs"
 rstCompound.Open SQLCompound, Cnxn, adOpenStatic, adLockReadOnly, adCmdText

 ' Display results from each SELECT statement
 intCount = 1
 Do Until rstCompound Is Nothing
 Debug.Print "Contents of recordset #" & intCount

 Do Until rstCompound.EOF
 Debug.Print , rstCompound.Fields(0), rstCompound.Fields(1)
 rstCompound.MoveNext
 Loop

 Set rstCompound = rstCompound.NextRecordset
 intCount = intCount + 1
 Loop

 ' clean up
 Cnxn.Close
 Set rstCompound = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstCompound Is Nothing Then
 If rstCompound.State = adStateOpen Then rstCompound.Close
 End If
 Set rstCompound = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndNextRecordsetVB


Section.OnPrint Property (Access)

 Copy code hover
[image]

Section.OnPrint Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Print box in the Properties window of a report section. Read/write String.

Syntax

expression .OnPrint

expression A variable that represents a Section object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Print event occurs after data in a report section is formatted for printing, but before the section is printed.

The OnPrint value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Print box in the report section's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Print box is blank, the property value is an empty string.

Example

The following example prints the value of the OnPrint property in the Immediate window for the "GroupHeader0" section in the "Purchase Order" report.

VBA Copy code Copy code
Debug.Print Reports("Purchase Order").Section("GroupHeader0").OnPrint

See also

Concepts

Section Object

Other resources

Section Object Members


CONSTRAINT Clause (Microsoft Access SQL)

 Copy code hover
[image]

CONSTRAINT Clause (Microsoft Access SQL)
Send feedback

A constraint is similar to an index, although it can also be used to establish a relationship with another table.

You use the CONSTRAINT clause in ALTER TABLE and CREATE TABLE statements to create or delete constraints. There are two types of CONSTRAINT clauses: one for creating a constraint on a single field and one for creating a constraint on more than one field.

Note Note

The Microsoft Access database engine does not support the use of CONSTRAINT, or any of the data definition language (DDL) statements, with non-Microsoft Access database engine databases. Use the DAO Create methods instead.

Syntax

Single-field constraint:

CONSTRAINT name {PRIMARY KEY | UNIQUE | NOT NULL | REFERENCES foreigntable [(foreignfield1, foreignfield2)] [ON UPDATE CASCADE | SET NULL] [ON DELETE CASCADE | SET NULL]}

Multiple-field constraint:

CONSTRAINT name {PRIMARY KEY (primary1[, primary2 [, …]]) | UNIQUE (unique1[, unique2 [, …]]) | NOT NULL (notnull1[, notnull2 [, …]]) | FOREIGN KEY [NO INDEX] (ref1[, ref2 [, …]]) REFERENCES foreigntable [(foreignfield1 [, foreignfield2 [, …]])] [ON UPDATE CASCADE | SET NULL] [ON DELETE CASCADE | SET NULL]}

The CONSTRAINT clause has these parts:

Part | Description
name | The name of the constraint to be created.
primary1, primary2 | The name of the field or fields to be designated the primary key.
unique1, unique2 | The name of the field or fields to be designated as a unique key.
notnull1, notnull2 | The name of the field or fields that are restricted to non-Null values.
ref1, ref2 | The name of a foreign key field or fields that refer to fields in another table.
foreigntable | The name of the foreign table containing the field or fields specified by foreignfield.
foreignfield1, foreignfield2 | The name of the field or fields in foreigntable specified by ref1, ref2. You can omit this clause if the referenced field is the primary key of foreigntable.

Remarks

You use the syntax for a single-field constraint in the field-definition clause of an ALTER TABLE or CREATE TABLE statement immediately following the specification of the field's data type.

You use the syntax for a multiple-field constraint whenever you use the reserved word CONSTRAINT outside a field-definition clause in an ALTER TABLE or CREATE TABLE statement.

Using CONSTRAINT you can designate a field as one of the following types of constraints:

  • You can use the UNIQUE reserved word to designate a field as a unique key. This means that no two records in the table can have the same value in this field. You can constrain any field or list of fields as unique. If a multiple-field constraint is designated as a unique key, the combined values of all fields in the index must be unique, even if two or more records have the same value in just one of the fields.

  • You can use the PRIMARY KEY reserved words to designate one field or set of fields in a table as a primary key. All values in the primary key must be unique and not Null, and there can be only one primary key for a table.

    Note Note

    Do not set a PRIMARY KEY constraint on a table that already has a primary key; if you do, an error occurs.

  • You can use the FOREIGN KEY reserved words to designate a field as a foreign key. If the foreign table's primary key consists of more than one field, you must use a multiple-field constraint definition, listing all of the referencing fields, the name of the foreign table, and the names of the referenced fields in the foreign table in the same order that the referencing fields are listed. If the referenced field or fields are the foreign table's primary key, you do not have to specify the referenced fields. By default the database engine behaves as if the foreign table's primary key is the referenced fields. Foreign key constraints define specific actions to be performed when a corresponding primary key value is changed:

  • You can specify actions to be performed on the foreign table based on a corresponding action performed on a primary key in the table on which the CONSTRAINT is defined. For example, consider the following definition for the table Customers:

    SQL Copy code Copy code
    CREATE TABLE Customers (CustId INTEGER PRIMARY KEY, CLstNm NCHAR VARYING (50))

    Consider the following definition of the table Orders, which defines a foreign key relationship referencing the primary key of the Customers table:

    SQL Copy code Copy code
    CREATE TABLE Orders (OrderId INTEGER PRIMARY KEY, CustId INTEGER, OrderNotes NCHAR VARYING (255), CONSTRAINT FKOrdersCustId FOREIGN KEY (CustId) REFERENCES Customers ON UPDATE CASCADE ON DELETE CASCADE

    Both an ON UPDATE CASCADE and an ON DELETE CASCADE clause are defined on the foreign key. The ON UPDATE CASCADE clause means that if a customer's identifier (CustId) is updated in the Customer table, the update will be cascaded through the Orders table. Each order containing a corresponding customer identifier value will be updated automatically with the new value. The ON DELETE CASCADE clause means that if a customer is deleted from the Customer table, all rows in the Orders table containing the same customer identifier value will also be deleted. Consider the following different definition of the table Orders, using the SET NULL action instead of the CASCADE action:

    SQL Copy code Copy code
    CREATE TABLE Orders (OrderId INTEGER PRIMARY KEY, CustId INTEGER, OrderNotes NCHAR VARYING (255), CONSTRAINT FKOrdersCustId FOREIGN KEY (CustId) REFERENCES Customers ON UPDATE SET NULL ON DELETE SET NULL

    The ON UPDATE SET NULL clause means that if a customer's identifier (CustId) is updated in the Customer table, the corresponding foreign key values in the Orders table will automatically be set to NULL. Similarly, the ON DELETE SET NULL clause means that if a customer is deleted from the Customer table, all corresponding foreign keys in the Orders table will automatically be set to NULL.

To prevent the automatic creation of indexes for foreign keys, the modifier NO INDEX can be used. This form of foreign key definition should be used only in cases where the resulting index values would be frequently duplicated. Where the values in a foreign key index are frequently duplicated, using an index can be less efficient than simply performing a table scan. Maintaining this type of index, with rows inserted and deleted from the table, degrades performance and does not provide any benefit.

Example

This example creates a new table called ThisTable with two text fields.

VBA Copy code Copy code
 Sub CreateTableX1()
Dim dbs As Database

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Create a table with two text fields.
    dbs.Execute "CREATE TABLE ThisTable " _
        & "(FirstName CHAR, LastName CHAR);"

    dbs.Close

End Sub

This example creates a new table called MyTable with two text fields, a Date/Time field, and a unique index made up of all three fields.

VBA Copy code Copy code
Sub CreateTableX2()

    Dim dbs As Database

    ' Modify this line to include the path to Northwind
    ' on your computer.

    Set dbs = OpenDatabase("Northwind.mdb")

    ' Create a table with three fields and a unique
    ' index made up of all three fields.
    dbs.Execute "CREATE TABLE MyTable " _
        & "(FirstName CHAR, LastName CHAR, " _
        & "DateOfBirth DATETIME, " _
        & "CONSTRAINT MyTableConstraint UNIQUE " _
        & "(FirstName, LastName, DateOfBirth));"

    dbs.Close

End Sub

This example creates a new table with two text fields and an Integer field. The SSN field is the primary key.

VBA Copy code Copy code
Sub CreateTableX3()

     Dim dbs As Database

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Create a table with three fields and a primary
    ' key.
    dbs.Execute "CREATE TABLE NewTable " _
        & "(FirstName CHAR, LastName CHAR, " _
        & "SSN INTEGER CONSTRAINT MyFieldConstraint " _
        & "PRIMARY KEY);"

    dbs.Close

End Sub


NavigationButton Methods (Access)

 Copy code hover
[image]

NavigationButton Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.


Property.Properties Property (DAO)

 Copy code hover
[image]

Property.Properties Property (DAO)
Send feedback

Returns the Properties collection of the specified object. Read-only.

Syntax

expression .Properties

expression A variable that represents a Property object.


ComboBox.BorderWidth Property (Access)

 Copy code hover
[image]

ComboBox.BorderWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.

Syntax

expression .BorderWidth

expression A variable that represents a ComboBox object.

Remarks

The BorderWidth property uses the following settings.

Setting | Visual Basic | Description
Hairline | 0 | (Default) The narrowest border possible on your system.
1 pt to 6 pt | 1 to 6 | The width as indicated in points.

You can set the default for this property by using the control's default control style or the DefaultControl property in Visual Basic.

To use the BorderWidth property, the SpecialEffect property must be set to Flat or Shadowed and the BorderStyle property must not be set to Transparent. If the SpecialEffect property is set to any other value and/or the BorderStyle property is set to Transparent, and you set the BorderWidth property, the SpecialEffect property is automatically reset to Flat and the BorderStyle property is automatically reset to Solid.

The exact border width depends on your computer and printer. On some systems, the hairline and 1-point widths appear the same.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Page Methods (Access)

 Copy code hover
[image]

Page Methods (Access)
Send feedback

Published: July 16, 2012

This object has the following methods:

Methods

Name | Description
Move | Moves the specified object to the coordinates specified by the argument values.
Requery | The Requery method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
SetFocus | The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.
SetTabOrder | Resets the tab order of the controls in the specified Page to their default values.
SizeToFit | You can use the SizeToFit method to size a control so it fits the text or image that it contains.


NavigationControl.DblClick Event (Access)

 Copy code hover
[image]

NavigationControl.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Version Information

Version Added: Access 2010

Syntax

expression .DblClick(Cancel, )

expression A variable that represents a NavigationControl object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer |

Return Value

nothing

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


OptionGroup.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

OptionGroup.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Syntax

expression .ShortcutMenuBar

expression A variable that represents an OptionGroup object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

Example

The following example sets the "Suppliers_Toolbar" as the custom shortcut menu to display when the user clicks the right mouse button on the "Suppliers" form.

VBA Copy code Copy code
Forms("Suppliers").ShortcutMenuBar = "Suppliers_Toolbar"

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


SubForm.Form Property (Access)

 Copy code hover
[image]

SubForm.Form Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Form property to refer to a form or to refer to the form associated with a subformcontrol. Read-only Form.

Syntax

expression .Form

expression A variable that represents a SubForm object.

Remarks

This property refers to a form object. It is read-only in all views.

This property is typically used to refer to the form or report contained in a subform control. For example, the following code uses the Form property to access the OrderID control on a subform contained in the OrderDetails subform control.

VBA Copy code Copy code
Dim intOrderID As Integer
intOrderID = Forms!Orders!OrderDetails.Form!OrderID

The next example calls a function from a property sheet by using the Form property to refer to the active form that contains the control named CustomerID.

VBA Copy code Copy code
=MyFunction(Form!CustomerID)

When you use the Form property in this manner, you are referring to the active form, and the name of the form isn't necessary.

The next example is the Visual Basic equivalent of the preceding example.

VBA Copy code Copy code
X = MyFunction(Forms!Customers!CustomerID)
Note Note

When you use the Forms collection, you must specify the name of the form.

Example

The following example uses the Form property to refer to a control on a subform.

VBA Copy code Copy code
Dim curTotalAmount As Currency

curTotalAmount = Forms!Orders!OrderDetails.Form!TotalAmount

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Failure to write to the Synchronizer log file. (Error 3471)

 Copy code hover
[image]

Failure to write to the Synchronizer log file. (Error 3471)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


Adding Records (ADO)

 Copy code hover
[image]

Adding Records (ADO)
Send feedback

In this section

  • Adding Records

  • Adding Multiple Fields

  • Determining Edit Mode

  • Using AddNew in Immediate and Batch Modes


Cannot join on Memo or OLE Object

 Copy code hover
[image]

Cannot join on Memo or OLE Object <name>. (Error 3118)
Send feedback

You cannot join Memo or OLE Object fields. The field you use to logically tie two or more tables together must be some other data type, such as text or integer.


Label.SizeToFit Method (Access)

 Copy code hover
[image]

Label.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents a Label object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

Label Object

Other resources

Label Object Members


ADO Code Examples in Microsoft Visual Basic Scripting Edition (Access)

 Copy code hover
[image]

ADO Code Examples in Microsoft Visual Basic Scripting Edition (Access)
Send feedback

In this section

  • ADO Code Examples in Microsoft Visual Basic Scripting Edition

  • AddNew Method Example (VBScript)

  • Clone Method Example (VBScript)

  • Delete Method Example (VBScript)

  • Execute, Requery, and Clear Methods Example (VBScript)

  • Move Method Example (VBScript)

  • MoveFirst, MoveLast, MoveNext, and MovePrevious Methods Example (VBScript)

  • Open and Close Methods Example (VBScript)


Form.WindowLeft Property (Access)

 Copy code hover
[image]

Form.WindowLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Returns an Integer indicating the screen position in twips of the left edge of a form relative to the left edge of the Microsoft Access window. Read-only.

Syntax

expression .WindowLeft

expression A variable that represents a Form object.

Remarks

Use the Move method to change the position of a form.

Example

The following example returns the screen position of the top and left edges of the first form in the current project.

VBA Copy code Copy code
With Forms(0)

 MsgBox "The form is " & .WindowLeft _
 & " twips from the left edge of the Access window and " _
 & .WindowTop _
 & " twips from the top edge of the Access window."

End With

See also

Concepts

Form Object

Other resources

Form Object Members


Optimize Property Example (VC++)

 Copy code hover
[image]

Optimize Property Example (VC++)
Send feedback

This example demonstrates the Field object dynamic Optimize property. The zip field of the Authors table in the Pubs database is not indexed. Setting the Optimize property to True on the zip field authorizes ADO to build an index that improves the performance of the Find method.

Copy code Copy code

// BeginOptimizeCpp
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void OptimizeX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 OptimizeX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// OptimizeX Function //
// //
//////////////////////////////////////////////////////////
void OptimizeX(void)
{
 HRESULT hr = S_OK;

 // Define string variables.
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");
 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _RecordsetPtr pRst = NULL;

 try
 {
 TESTHR(pRst.CreateInstance(__uuidof(Recordset)));

 // Enable Index creation.
 pRst->CursorLocation = adUseClient;
 pRst->Open ("SELECT * FROM authors", strCnn,
 adOpenStatic, adLockReadOnly, adCmdText);

 // Create the index
 pRst->Fields->GetItem("zip")->Properties->
 GetItem("Optimize")->PutValue("True");

 // Find Akiko Yokomoto
 pRst->Find("zip = '94595'",1,adSearchForward);
 printf("\n%s %s %s %s %s\n",
 (LPSTR) (_bstr_t) pRst->Fields->GetItem("au_fname")->Value,
 (LPSTR) (_bstr_t) pRst->Fields->GetItem("au_lname")->Value,
 (LPSTR) (_bstr_t) pRst->Fields->GetItem("address")->Value,
 (LPSTR) (_bstr_t) pRst->Fields->GetItem("city")->Value,
 (LPSTR) (_bstr_t) pRst->Fields->GetItem("state")->Value);

 // Delete the index
 pRst->Fields->GetItem("zip")->Properties->
 GetItem("Optimize")->PutValue("False");
 }
 catch (_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRst->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 if (pRst)
 if (pRst->State == adStateOpen)
 pRst->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////
void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;

 // Collection ranges from 0 to nCount -1.
 for(long i = 0;i < nCount;i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,
 pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////
void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print COM errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndOptimizeCpp


WebBrowserControl.BottomPadding Property (Access)

 Copy code hover
[image]

WebBrowserControl.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .BottomPadding

expression A variable that represents a WebBrowserControl object.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Form.ServerFilterByForm Property (Access)

 Copy code hover
[image]

Form.ServerFilterByForm Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ServerFilterByForm property to specify or determine whether a form is opened in the Server Filter By Form window. Read/write Boolean.

Syntax

expression .ServerFilterByForm

expression A variable that represents a Form object.

Remarks

The default value is False.

You can remove a filter by using Visual Basic to set the ServerFilterByForm property to False.

Note Note

The ServerFilterByForm property setting is ignored if the form's record source is a stored procedure.

Example

The following example enables the "Order Lookup" form to be opened in a Microsoft Access Data Project in the Server Filter By Form window.

VBA Copy code Copy code
Forms("Order Lookup").ServerFilterByForm = True

See also

Concepts

Form Object

Other resources

Form Object Members


Unknown function name. (Error 2425)

 Copy code hover
[image]

Unknown function name. (Error 2425)
Send feedback

You entered an expression with a function name that cannot be recognized. Make sure the function exists, or check the expression to make sure you entered it correctly.


Documents Methods (DAO)

 Copy code hover
[image]

Documents Methods (DAO)
Send feedback

In this section

  • Documents.Refresh Method (DAO)


WebBrowserControl.ControlSource Property (Access)

 Copy code hover
[image]

WebBrowserControl.ControlSource Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.

Syntax

expression .ControlSource

expression A variable that represents a WebBrowserControl object.

Remarks

The ControlSource property uses the following settings.

Setting | Description
A field name | The control is bound to a field in a table, query, or SQL statement. Data from the field is displayed in the control. Changes to the data inside the control change the corresponding data in the field. (To make the control read-only, set the Locked property to Yes.) If you click a control bound to a field that has a Hyperlink data type, you jump to the destination specified in the hyperlink address.
An expression | The control displays data generated by an expression. This data can be changed by the user but isn't saved in the database.
Note Note

The ControlSource property doesn't apply to check box, option button, or toggle button controls in an option group. It applies only to the option group itself.

You can also set the ControlSource property for a text box by typing a field name or expression directly in the text box in form Design view or report Design view.

For reports, the ControlSource property applies only to report group levels.

Forms and reports act as "windows" into your database. You specify the primary source of data for a form or report by setting its RecordSource property to a table, query, or SQL statement. You can then set the ControlSource property to a field in the source of data or to an expression. If the ControlSource property setting is an expression, the value displayed is read-only and not saved in the database. For example, you can use the following settings.

Sample setting | Description
LastName | For a control, data from the LastName field is displayed in the control. For a report group level, Microsoft Access groups the data on last name.
=Date( ) + 7 | For a control, this expression displays a date seven days from today in the control.
=DatePart("q",ShippedDate) | For a control, this expression displays the quarter of the shipped date. For a report group level, Microsoft Access groups the data on the quarter of the shipped date.

Example

The following example sets the ControlSource property for a text box named AddressPart to a field named City:

VBA Copy code Copy code
Forms!Customers!AddressPart.ControlSource = "City"

The next example sets the ControlSource property for a text box named Expected to the expression =Date() + 7

VBA Copy code Copy code
Me!Expected.ControlSource = "=Date() + 7"

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Form.OpenArgs Property (Access)

 Copy code hover
[image]

Form.OpenArgs Property (Access)
See also Send feedback

Published: July 16, 2012

Determines the string expression specified by the OpenArgs argument of the OpenForm method that opened a form. Read/write Variant.

Syntax

expression .OpenArgs

expression A variable that represents a Form object.

Remarks

This property is available only by using a macro or by using Visual Basic with the OpenForm method of the DoCmd object. This property setting is read-only in all views.

To use the OpenArgs property, open a form by using the OpenForm method of the DoCmd object and set the OpenArgs argument to the desired string expression. The OpenArgs property setting can then be used in code for the form, such as in an Open event procedure. You can also refer to the property setting in a macro, such as an Open macro, or an expression, such as an expression that sets the ControlSource property for a control on the form.

For example, suppose that the form you open is a continuous-form list of clients. If you want the focus to move to a specific client record when the form opens, you can set the OpenArgs property to the client's name, and then use the FindRecord action in an Open macro to move the focus to the record for the client with the specified name.

Example

The following example uses the OpenArgs property to open the Employees form to a specific employee record and demonstrates how the OpenForm method sets the OpenArgs property. You can run this procedure as appropriate — for example, when the AfterUpdate event occurs for a custom dialog box used to enter new information about an employee.

VBA Copy code Copy code
Sub OpenToCallahan()
    DoCmd.OpenForm "Employees", acNormal, , , acReadOnly, _
     , "Callahan"
End Sub

Sub Form_Open(Cancel As Integer)
    Dim strEmployeeName As String
    ' If OpenArgs property contains employee name, find
    ' corresponding employee record and display it on form. For
    ' example,if the OpenArgs property contains "Callahan",
    ' move to first "Callahan" record.
    strEmployeeName = Forms!Employees.OpenArgs
    If Len(strEmployeeName) > 0 Then
        DoCmd.GoToControl "LastName"
        DoCmd.FindRecord strEmployeeName, , True, , True, , True
    End If
End Sub

The following example shows how to use the OpenArgs property to prevent a form from being opened from the Navigation Pane.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Private Sub Form_Open(Cancel As Integer)

If Me.OpenArgs() <> "Valid User" Then
    MsgBox "You are not authorized to use this form!", _
        vbExclamation + vbOKOnly, "Invalid Access"
    Cancel = True
End If
End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.

See also

Concepts

Form Object

Other resources

Form Object Members


BoundObjectFrame.GotFocus Event (Access)

 Copy code hover
[image]

BoundObjectFrame.GotFocus Event (Access)
See also Send feedback

Published: July 16, 2012

The GotFocus event occurs when the specified object receives the focus.

Syntax

expression .GotFocus

expression A variable that represents a BoundObjectFrame object.

Remarks

To run a macro or event procedure when these events occur, set the OnGotFocus property to the name of the macro or to [Event Procedure].

These events occur when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

A control can receive the focus only if its Visible and Enabled properties are set to Yes. A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.

You can specify what happens when a form or control receives the focus by running a macro or an event procedure when the GotFocus event occurs. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user through your application by displaying brief instructions or messages in a text box. You can also provide visual cues by enabling, disabling, or displaying controls that depend on the control with the focus.

Note Note

To customize the order in which the focus moves from control to control on a form when you press the TAB key, set the tab order or specify access keys for the controls.

The GotFocus event differs from the Enter event in that the GotFocus event occurs every time a control receives the focus. For example, suppose the user clicks a check box on a form, then clicks a report, and finally clicks the check box on the form to bring it to the foreground. The GotFocus event occurs both times the check box receives the focus. In contrast, the Enter event occurs only the first time the user clicks the check box. The GotFocus event occurs after the Enter event.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form, the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

When you switch between two open forms, the Deactivate event occurs for the first form, and the Activate event occurs for the second form. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

Example

The following example displays a message in a label when the focus moves to an option button.

To try the example, add the following event procedures to a form named Contacts that contains an option button named OptionYes and a label named LabelYes.

VBA Copy code Copy code
Private Sub OptionYes_GotFocus()
 Me!LabelYes.Caption = "Option button 'Yes' has the focus."
End Sub

Private Sub OptionYes_LostFocus()
 Me!LabelYes.Caption = "" ' Clear caption.
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


TabControl.BackStyle Property (Access)

 Copy code hover
[image]

TabControl.BackStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.

Syntax

expression .BackStyle

expression A variable that represents a TabControl object.

Remarks

The BackStyle property uses the following settings.

Setting | Visual Basic | Description
Normal | 1 | (Default for all controls except option group) The control has its interior color set by the BackColor property.
Transparent | 0 | (Default for option group) The control is transparent. The color of the form or report behind the control is visible.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

If the Transparent button on the Back Color button palette is selected, the BackStyle property is set to Transparent; otherwise the BackStyle property is set to Normal.

To make a command button invisible, set its Transparent property to Yes.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


CommandButton.MouseMove Event (Access)

 Copy code hover
[image]

CommandButton.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents a CommandButton object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


 Copy code hover
[image]

<Table-level validation text>. (Error 3316)
Send feedback

A table-level validation rule was violated. Validation rules restrict what you can enter in a given field, and also help ensure that you enter the proper types or amounts of data.


TabControl.TabStop Property (Access)

 Copy code hover
[image]

TabControl.TabStop Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabStop property to specify whether you can use the TAB key to move the focus to a control. Read/write Boolean.

Syntax

expression .TabStop

expression A variable that represents a TabControl object.

Remarks

This property doesn't apply to toggle button controls when they appear in an option group. It applies only to the option group itself.

The TabStop property uses the following settings.

Setting | Visual Basic | Description
Yes | True | (Default) You can move the focus to the control by pressing the TAB key.
No | False | You can't move the focus to the control by pressing the TAB key.

When you create a control on a form, Microsoft Access automatically assigns the control a position in the form's tab order. Each new control is placed last in the tab order. If you want to prevent a control from being available when you tab through the controls in a form, set the control's TabStop property to No.

In Form view, hidden or disabled controls remain in the tab order but are skipped when you move through the controls by pressing TAB, even if their TabStop properties are set to Yes.

As long as a control's Enabled property is set to Yes, you can click the control or use an access key to select it, regardless of its TabStop property setting. For example, you can set the TabStop property of a command button to No to prevent users from selecting the button by pressing TAB. However, they can still click the command button to choose it.

Example

The following example disables the ability to move the focus to the "City" text box on the "Suppliers" form by using the TAB key.

VBA Copy code Copy code
Forms("Suppliers").Controls("City").TabStop = False

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Control.Hyperlink Property (Access)

 Copy code hover
[image]

Control.Hyperlink Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.

Syntax

expression .Hyperlink

expression A variable that represents a Control object.

Example

The CreateHyperlink procedure in the following example sets the hyperlink properties for a command button, label, or image control to the address and subaddress values passed to the procedure. The address setting is an optional argument, because a hyperlink to an object in the current database uses only the subaddress setting, To try this example, create a form with two text box controls (txtAddress and txtSubAddress) and a command button (cmdFollowLink) and paste the following into the Declarations section of the form's module:

VBA Copy code Copy code
Private Sub cmdFollowLink_Click()
 CreateHyperlink Me!cmdFollowLink, Me!txtSubAddress, _
 Me!txtAddress
End Sub

Sub CreateHyperlink(ctlSelected As Control, _
 strSubAddress As String, Optional strAddress As String)
 Dim hlk As Hyperlink
 Select Case ctlSelected.ControlType
 Case acLabel, acImage, acCommandButton
 Set hlk = ctlSelected.Hyperlink
 With hlk
 If Not IsMissing(strAddress) Then
 .Address = strAddress
 Else
 .Address = ""
 End If
 .SubAddress = strSubAddress
 .Follow
 .Address = ""
 .SubAddress = ""
 End With
 Case Else
 MsgBox "The control '" & ctlSelected.Name _
 & "' does not support hyperlinks."
 End Select
End Sub

See also

Concepts

Control Object

Other resources

Control Object Members


ReturnVars.Application Property (Access)

 Copy code hover
[image]

ReturnVars.Application Property (Access)
Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Version Information

Version Added: Access 2010

Syntax

expression .Application

expression A variable that represents a RetunVars object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties.


Invalid Deleted setting in the Xbase key of the Windows Registry. (Error 3208)

 Copy code hover
[image]

Invalid Deleted setting in the Xbase key of the Windows Registry. (Error 3208)
Send feedback

There is an invalid Deleted setting in the Xbase key of the Microsoft Windows Registry.

To fix the Deleted setting

  1. Exit your application.

  2. Start the Registry Editor, navigate to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Access Connectivity Engine\Engines\Xbase key, and select the Deleted value.

  3. On the Edit menu, click Modify.

  4. Correct the Deleted data in the Value data box.

  5. Restart your application, and then try the operation again.


Screen Properties (Access)

 Copy code hover
[image]

Screen Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
ActiveControl | You can use the ActiveControl property together with the Screen object to identify or refer to the control that has the focus. Read-only Control object.
ActiveDatasheet | You can use the ActiveDatasheet property together with the Screen object to identify or refer to the datasheet that has the focus. Read-only Form object.
ActiveForm | You can use the ActiveForm property together with the Screen object to identify or refer to the form that has the focus. Read-only Form object.
ActiveReport | You can use the ActiveReport property together with the Screen object to identify or refer to the report that has the focus. Read-only Report object.
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
MousePointer | You can use the MousePointer property together with the Screen object to specify or determine the type of mouse pointer currently displayed. Read/write Integer.
Parent | Returns the parent object for the specified object. Read-only.
PreviousControl | You can use the PreviousControl property with the Screen object to return a reference to the control that last received the focus. Read-only.


Column Object (ADOX) Reference

 Copy code hover
[image]

Column Object (ADOX) Reference
Send feedback

In this section

  • Column Object (ADOX)

  • Column Properties, Methods, and Events (ADOX)


Source Property (ADO Record)

 Copy code hover
[image]

Source Property (ADO Record)
Send feedback

Indicates the data source or object represented by the Record.

Settings and Return Values

Sets or returns a Variant value that indicates the entity represented by the Record.

Remarks

The Source property returns the Source argument of the Record object Open method. It can contain an absolute or relative URL string. An absolute URL can be used without setting the ActiveConnection property to directly open the Record object. An implicit Connection object is created in this case.

The Source property can also contain a reference to an already open Recordset, which opens a Record object representing the current row in the Recordset.

The Source property could also contain a reference to a Command object which returns a single row of data from the provider.

If the ActiveConnection property is also set, then the Source property must point to some object that exists within the scope of that connection. For example, in tree-structured namespaces, if the Source property contains an absolute URL, it must point to a node that exists inside the scope of the node identified by the URL in the connection string. If the Source property contains a relative URL, then it is validated within the context set by the ActiveConnection property.

The Source property is read/write while the Record object is closed, and is read-only while the Record object is open.

Note Note

URLs using the http scheme will automatically invoke the Microsoft OLE DB Provider for Internet Publishing. For more information, see Absolute and Relative URLs.


CompareBookmarks Method Example (VJ++)

 Copy code hover
[image]

CompareBookmarks Method Example (VJ++)
Send feedback

This example demonstrates the CompareBookmarks method. The relative value of bookmarks is seldom needed unless a particular bookmark is somehow special.

Designate a random row of a Recordset derived from the Authors table as the target of a search. Then display the position of each row relative to that target.

Copy code Copy code

// BeginCompareBookmarksJ
import com.ms.wfc.data.*;
import java.io.* ;
import com.ms.com.*;

public class CompareBookmarksX //
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 CompareBookmarksX();
 System.exit(0);
 }

 // CompareBookmarksX function

 static void CompareBookmarksX()
 {
 // Define ADO Objects.
 Recordset rstAuthors = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';" +
 "Initial Catalog='Pubs';Integrated Security='SSPI';";
 int intCount;
 Variant varTarget = null;
 int intResult;
 String strAns;
 int intDisplaySize = 15;

 try
 {
 rstAuthors = new Recordset();
 rstAuthors.open("SELECT * FROM authors",
 strCnn,
 AdoEnums.CursorType.STATIC,
 AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TEXT);
 intCount = rstAuthors.getRecordCount();
 System.out.println("Rows in the Recordset = " +
 Integer.toString(intCount));

 // Exit if an empty recordset.
 if(intCount == 0)
 System.exit(0);

 // Randomize.
 intCount = (int)(intCount * Math.random());
 // Get position between 0 and count-1.
 System.out.println("\nRandomly chosen row position = " +
 Integer.toString(intCount)+ "\n");
 rstAuthors.move(intCount,new Integer(AdoEnums.Bookmark.FIRST)); // Move row to random position.
 varTarget = (Variant)rstAuthors.getBookmark();
 // Remember the mystery row.
 intCount = 0;
 rstAuthors.moveFirst();

 // Loop through recordset.
 while(!rstAuthors.getEOF())
 {
 intResult = rstAuthors.compareBookmarks
 ((Variant)rstAuthors.getBookmark(), varTarget);
 if(intResult == AdoEnums.Compare.NOTEQUAL)
 System.out.println("Row " +
 Integer.toString(intCount) +
 ": Bookmarks are not equal.");
 else if(intResult == AdoEnums.Compare.NOTCOMPARABLE)
 System.out.println("Row " +
 Integer.toString(intCount) +
 ": Bookmarks are not comparable.");
 else
 {
 switch(intResult)
 {
 case AdoEnums.Compare.LESSTHAN :
 strAns = "less than";
 break;
 case AdoEnums.Compare.EQUAL :
 strAns = "equal to";
 break;
 case AdoEnums.Compare.GREATERTHAN :
 strAns = "greater than";
 break;
 default :
 strAns = "in error comparing to";
 break;
 }
 System.out.println("Row position " +
 Integer.toString(intCount) +
 " is " + strAns + " the target.");
 }
 if(intCount % intDisplaySize == 0 && intCount > 0)
 {
 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 }
 intCount++;
 rstAuthors.moveNext();
 }

 System.out.println("\nPress <Enter> to continue..");
 in.readLine();
 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstAuthors != null)
 {
 PrintProviderError(rstAuthors.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstAuthors != null)
 if (rstAuthors.getState() == 1)
 rstAuthors.close();
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}

// EndCompareBookmarksJ


Microsoft OLE DB Remoting Provider (ADO Service Provider)

 Copy code hover
[image]

Microsoft OLE DB Remoting Provider (ADO Service Provider)
Send feedback

The Microsoft OLE DB Remoting Provider enables a local user on a client machine to invoke data providers on a remote machine. Specify the data provider parameters for the remote machine as you would if you were a local user on the remote machine. Then specify the parameters used by the Remoting Provider to access the remote machine. The resulting effect is that you will access the remote machine as if you were a local user.

Provider Keyword

To invoke the OLE DB Remoting Provider, specify the following keyword and value in the connection string. (Note the blank space in the provider name.)

Copy code Copy code

"Provider=MS Remote"

Additional Keywords

When this service provider is invoked, the following additional keywords are relevant.

Keyword | Description
Data Source | Specifies the name of the remote data source. It is passed to the OLE DB Remoting Provider for processing. This keyword is equivalent to the RDS.DataControl object's Connect property.

Dynamic Properties

When this service provider is invoked, the following dynamic properties are added to the Connection object's Properties collection.

Dynamic Property Name

Description

DFMode

Indicates the DataFactory Mode. A string that specifies the desired version of the DataFactory object on the server. Set this property before opening a connection to request a particular version of the DataFactory. If the requested version is not available, an attempt will be made to use the preceding version. If there is no preceding version, an error will occur. If DFMode is less than the available version, an error will occur. This property is read-only after a connection is made. Can be one of the following valid string values:

  • "25" — Version 2.5 (Default)

  • "21" — Version 2.1

  • "20" — Version 2.0

  • "15" — Version 1.5

Command Properties

Indicates values that will be added to the string of command (rowset) properties sent to the server by the MS Remote provider. The default value for this string is vt_empty.

Current DFMode

Indicates the actual version number of the DataFactory on the server. Check this property to see if the version requested in the DFMode property was honored. Can be one of the following valid Long integer values:

  • 25 — Version 2.5 (Default)

  • 21 — Version 2.1

  • 20 — Version 2.0

  • 15 — Version 1.5

Adding "DFMode=20;" to your connection string when using the MSRemote provider can improve your server's performance when updating data. With this setting, the RDSServer.DataFactory object on the server uses a less resource-intensive mode. However, the following features are not available in this configuration:

  • Using parameterized queries.

  • Getting parameter or column information before calling the Execute method.

  • Setting Transact Updates to True.

  • Getting row status.

  • Calling the Resync method.

  • Refreshing (explicitly or automatically) via the Update Resync property.

  • Setting Command or Recordset properties.

  • Using adCmdTableDirect.

Handler

Indicates the name of a server-side customization program (or handler) that extends the functionality of the RDSServer.DataFactory, and any parameters used by the handler, all separated by commas (","). A String value.

Internet Timeout

Indicates the maximum number of milliseconds to wait for a request to travel to and from the server. (The default is 5 minutes.)

Remote Provider

Indicates the name of the data provider to be used on the remote server.

Remote Server

Indicates the server name and communication protocol to be used by this connection. This property is equivalent to the RDS.DataControl object Server property.

Transact Updates

When set to True, this value indicates that when UpdateBatch is performed on the server, it will be done inside a transaction. The default value for this Boolean dynamic property is False.

You may also set writable dynamic properties by specifying their names as keywords in the connection string. For example, set the Internet Timeout dynamic property to five seconds by specifying:

Copy code Copy code

Dim cn as New ADODB.Connection
cn.Open "Provider=MS Remote;Internet Timeout=5000"

You may also set or retrieve a dynamic property by specifying its name as the index to the Properties property. For example, get and print the current value of the Internet Timeout dynamic property, and then set a new value, like this:

Copy code Copy code

Debug.Print cn.Properties("Internet Timeout")
cn.Properties("Internet Timeout") = 5000

Remarks

In ADO 2.0, the OLE DB Remoting Provider could only be specified in the ActiveConnection parameter of the Recordset object Open method. Starting with ADO 2.1, the provider may also be specified in the ConnectionString parameter of the Connection object Open method.

The equivalent of the RDS.DataControl object SQL property is not available. The Recordset object Open method Source argument is used instead.

Specifying "...;Remote Provider=MS Remote;..." would create a four-tier scenario.Scenarios beyond three tiers have not been tested and should not be needed.

Example

This example performs a query on the authors table of the pubs database on a server named, YourServer. The names of the remote data source and remote server are provided in the Connection object Open method, and the SQL query is specified in the Recordset object Open method. A Recordset object is returned, edited, and used to update the data source.

Copy code Copy code

Dim rs as New ADODB.Recordset
Dim cn as New ADODB.Connection
cn.Open  "Provider=MS Remote;Data Source=pubs;" & _
         "Remote Server=http://YourServer"
rs.Open "SELECT * FROM authors", cn
...                'Edit the recordset
rs.UpdateBatch     'Equivalent of RDS SubmitChanges
...


CursorType Property (ADO)

 Copy code hover
[image]

CursorType Property (ADO)
Send feedback

Indicates the type of cursor used in a Recordset object.

Settings and Return Values

Sets or returns a CursorTypeEnum value. The default value is adOpenForwardOnly.

Remarks

Use the CursorType property to specify the type of cursor that should be used when opening the Recordset object.

Only a setting of adOpenStatic is supported if the CursorLocation property is set to adUseClient. If an unsupported value is set, then no error will result; the closest supported CursorType will be used instead.

If a provider does not support the requested cursor type, it may return another cursor type. The CursorType property will change to match the actual cursor type in use when the Recordset object is open. To verify specific functionality of the returned cursor, use the Supports method. After you close the Recordset, the CursorType property reverts to its original setting.

The following chart shows the provider functionality (identified by Supports method constants) required for each cursor type.

For a Recordset of this CursorType | The Supports method must return True for all of these constants
adOpenForwardOnly | none
adOpenKeyset | adBookmark, adHoldRecords, adMovePrevious, adResync
adOpenDynamic | adMovePrevious
adOpenStatic | adBookmark, adHoldRecords, adMovePrevious, adResync
Note Note

Although Supports(adUpdateBatch) may be true for dynamic and forward-only cursors, for batch updates you should use either a keyset or static cursor. Set the LockType property to adLockBatchOptimistic and the CursorLocation property to adUseClient to enable the Cursor Service for OLE DB, which is required for batch updates.

The CursorType property is read/write when the Recordset is closed and read-only when it is open.

Remote Data Service UsageWhen used on a client-side Recordset object, the CursorType property can be set only to adOpenStatic.


Could not open Paradox.net. (Error 3172)

 Copy code hover
[image]

Could not open Paradox.net. (Error 3172)
Send feedback

Possible causes:

  • The ParadoxNetPath value in the \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Access Connectivity Engine\Engines\Paradox Registry key is not valid. This error occurs if you are using the Paradox external database, and the ParadoxNetPath value points to a nonexistent directory. Exit the application, correct the invalid entry, and try the operation again.

  • The ParadoxNetPath Registry value points to a network drive, and you are not connected to that network drive. Make sure the network drive is available, and then try the operation again.


ListBox.BorderShade Property (Access)

 Copy code hover
[image]

ListBox.BorderShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderShade

expression A variable that represents a ListBox object.

Remarks

The BorderShade property contains a numeric expression that can be used to darken the theme color in the BorderColor property. The default value of the BorderShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example darkens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderShade=25

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


CheckBox.MouseMove Event (Access)

 Copy code hover
[image]

CheckBox.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents a CheckBox object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


MarshalOptions Property Example (VB)

 Copy code hover
[image]

MarshalOptions Property Example (VB)
Send feedback

This example uses the MarshalOptions property to specify what rows are sent back to the server — All Rows or only Modified Rows.

Copy code Copy code

'BeginMarshalOptionsVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 Dim rstEmployees As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim strSQLEmployees As String

 Dim strOldFirst As String
 Dim strOldLast As String
 Dim strMessage As String
 Dim strMarshalAll As String
 Dim strMarshalModified As String

 ' Open connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Set Cnxn = New ADODB.Connection
 Cnxn.Open strCnxn

 ' open recordset with names from Employees table
 ' and set some properties through object refs
 Set rstEmployees = New ADODB.Recordset
 rstEmployees.CursorType = adOpenKeyset
 rstEmployees.LockType = adLockOptimistic
 rstEmployees.CursorLocation = adUseClient

 strSQLEmployees = "SELECT fname, lname FROM Employee ORDER BY lname"

 rstEmployees.Open strSQLEmployees, Cnxn, , , adCmdText
 ' empty properties have been set above

 ' Store original data
 strOldFirst = rstEmployees!fname
 strOldLast = rstEmployees!lname

 ' Change data in edit buffer
 rstEmployees!fname = "Linda"
 rstEmployees!lname = "Kobara"

 ' Show contents of buffer and get user input
 strMessage = "Edit in progress:" & vbCr & _
 " Original data = " & strOldFirst & " " & _
 strOldLast & vbCr & " Data in buffer = " & _
 rstEmployees!fname & " " & rstEmployees!lname & vbCr & vbCr & _
 "Use Update to replace the original data with " & _
 "the buffered data in the Recordset?"
 strMarshalAll = "Would you like to send all the rows " & _
 "in the recordset back to the server?"
 strMarshalModified = "Would you like to send only " & _
 "modified rows back to the server?"

 If MsgBox(strMessage, vbYesNo) = vbYes Then
 If MsgBox(strMarshalAll, vbYesNo) = vbYes Then
 rstEmployees.MarshalOptions = adMarshalAll
 rstEmployees.Update
 ElseIf MsgBox(strMarshalModified, vbYesNo) = vbYes Then
 rstEmployees.MarshalOptions = adMarshalModifiedOnly
 rstEmployees.Update
 End If
 End If

 ' sShow the resulting data
 MsgBox "Data in recordset = " & rstEmployees!fname & " " & _
 rstEmployees!lname

 ' restore original data because this is a demonstration
 If Not (strOldFirst = rstEmployees!fname And _
 strOldLast = rstEmployees!lname) Then
 rstEmployees!fname = strOldFirst
 rstEmployees!lname = strOldLast
 rstEmployees.Update
 End If

 ' clean up
 rstEmployees.Close
 Cnxn.Close
 Set rstEmployees = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstEmployees Is Nothing Then
 If rstEmployees.State = adStateOpen Then rstEmployees.Close
 End If
 Set rstEmployees = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndMarshalOptionsVB


Format Property - Number and Currency Data Types

 Copy code hover
[image]

Format Property - Number and Currency Data Types
Send feedback

Published: July 16, 2012

You can set the Format property to predefined number formats or custom number formats for the Number and Currency data types.

Setting

Predefined Formats

The following table shows the predefined Format property settings for numbers.

Setting | Description
General Number | (Default) Display the number as entered.
Currency | Use the thousand separator; follow the settings specified in the regional settings of Windows for negative amounts, decimal and currency symbols, and decimal places.
Euro | Use the euro symbol ( [image] ), regardless of the currency symbol specified in the regional settings of Windows.
Fixed | Display at least one digit; follow the settings specified in the regional settings of Windows for negative amounts, decimal and currency symbols, and decimal places.
Standard | Use the thousand separator; follow the settings specified in the regional settings of Windows for negative amounts, decimal symbols, and decimal places.
Percent | Multiply the value by 100 and append a percent sign (%); follow the settings specified in the regional settings of Windows for negative amounts, decimal symbols, and decimal places.
Scientific | Use standard scientific notation.

Custom Formats

Custom number formats can have one to four sections with semicolons (;) as the list separator. Each section contains the format specification for a different type of number.

Section | Description
First | The format for positive numbers.
Second | The format for negative numbers.
Third | The format for zero values.
Fourth | The format for Null values.

For example, you could use the following custom Currency format:

Copy code Copy code
$#,##0.00[Green];($#,##0.00)[Red];"Zero";"Null"

This number format contains four sections separated by semicolons and uses a different format for each section.

If you use multiple sections but don't specify a format for each section, entries for which there is no format will either display nothing or default to the formatting of the first section.

You can create custom number formats by using the following symbols.

Symbol | Description
. (period) | Decimal separator. Separators are set in the regional settings in Windows.
, (comma) | Thousand separator.
0 | Digit placeholder. Display a digit or 0.
# | Digit placeholder. Display a digit or nothing.
$ | Display the literal character "$".
% | Percentage. The value is multiplied by 100 and a percent sign is appended.
E- or e- | Scientific notation with a minus sign (-) next to negative exponents and nothing next to positive exponents. This symbol must be used with other symbols, as in 0.00E-00 or 0.00E00.
E+ or e+ | Scientific notation with a minus sign (-) next to negative exponents and a plus sign (+) next to positive exponents. This symbol must be used with other symbols, as in 0.00E+00.

Remarks

You can use the DecimalPlaces property to override the default number of decimal places for the predefined format specified for the Format property.

The predefined currency and euro formats follow the settings in the regional settings of Windows. You can override these by entering your own currency format.

Examples

The following are examples of the predefined number formats.

Setting | Data | Display
General Number | 3456.789 -3456.789 $213.21 | 3456.789 -3456.789 $213.21
Currency | 3456.789 -3456.789 | $3,456.79 ($3,456.79)
Fixed | 3456.789 -3456.789 3.56645 | 3456.79 -3456.79 3.57
Standard | 3456.789 | 3,456.79
Percent | 3 0.45 | 300% 45%
Scientific | 3456.789 -3456.789 | 3.46E+03 -3.46E+03

The following are examples of custom number formats.

Setting | Description
0;(0);;"Null" | Display positive values normally; display negative values in parentheses; display the word "Null" if the value is Null.
+0.0;-0.0;0.0 | Display a plus (+) or minus (-) sign with positive or negative numbers; display 0.0 if the value is zero.


Image Properties (Access)

 Copy code hover
[image]

Image Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
BackColor | Gets or sets the interior color of the specified object. Read/write Long.
BackShade | Gets or sets the shade applied to the theme color in the BackColor property of the specified object. Read/write Single.
BackStyle | You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.
BackThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.
BackTint | Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.
BorderColor | You can use the BorderColor property to specify the color of a control's border. Read/write Long.
BorderShade | Gets or sets the shade that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderStyle | Specifies how a control's border appears.Read/write Byte.
BorderThemeColorIndex | Gets or sets a value that represents a color in the applied color theme associated with the BorderColor property of the specified object. Read/write Long.
BorderTint | Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.
BorderWidth | You can use the BorderWidth property to specify the width of a control's border. Read/write Byte.
BottomPadding | Gets or sets the amount of space (in inches) between the image control and its bottom gridline. Read/write Integer.
Controls | Returns the Controls collection of a form, subform, report or section. Read-only Controls.
ControlTipText | You can use the ControlTipText property to specify the text that appears in a ScreenTip when you hold the mouse pointer over a control. Read/write String.
ControlType | You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.
DisplayWhen | You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. Read/write Byte.
EventProcPrefix | Gets or sets the prefix portion of an event procedure name. Read/write String.
GridlineColor | Gets or sets the color of the gridline for the specified image control. Read/write Long.
GridlineShade | Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineStyleBottom | Gets or sets the bottom gridline style of the specified image control. Read/write Byte.
GridlineStyleLeft | Gets or sets the width of the bottom gridline for the specified image. Read/write Byte.
GridlineStyleRight | Gets or sets the right gridline style of the specified image control. Read/write Byte.
GridlineStyleTop | Gets or sets the top gridline style of the specified image control. Read/write Byte.
GridlineThemeColorIndex | Gets or sets the theme color index that represents a color in the applied color theme associated with the GridlineColor property of the specified object. Read/write Long.
GridlineTint | Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.
GridlineWidthBottom | Gets or sets the width of the bottom gridline for the specified image control. Read/write Byte.
GridlineWidthLeft | Gets or sets the width of the left gridline for the specified image control. Read/write Byte.
GridlineWidthRight | Gets or sets the width of the right gridline for the specified image control. Read/write Byte.
GridlineWidthTop | Gets or sets the width of the top gridline for the specified image control. Read/write Byte.
Height | Gets or sets the height of the specified object in twips. Read/write Integer.
HelpContextId | The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.
HorizontalAnchor | Gets or sets an AcHorizontalAnchor constant that indicates how the image is anchored horizontally within its layout. Read/write.
Hyperlink | You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.
HyperlinkAddress | You can use the HyperlinkAddress property to specify or determine the path to an object, document, Web page or other destination for a hyperlink associated with a the specified control. Read/write String.
HyperlinkSubAddress | You can use the HyperlinkSubAddress property to specify or determine a location within the target document specified by the HyperlinkAddress property. Read/write String.
ImageHeight | You can use the ImageHeight property to determine the height in twips of the picture in an image control. Read/write Long.
ImageWidth | You can use the ImageWidth property to determine the width in twips of a picture in an image control. Read/write Long.
InSelection | You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.
IsVisible | You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.
Layout | Returns the type of layout for the specified image. Read-only AcLayoutType.
LayoutID | Returns the unique identifier for the layout that contains the specified image. Read-only Long.
Left | You can use the Left property to specify an object's location on a form or report. Read/write Integer.
LeftPadding | Gets or sets the amount of space (in inches) between the image control and its left gridline. Read/write Integer.
Name | You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.
ObjectPalette | The ObjectPalette property specifies the palette in the application used to create A bitmap or other graphic that is loaded into the specified control by using the Picture property. Read/write Variant.
OldBorderStyle | You can use this property to set or returns the unedited value of the BorderStyle property for a form or control. This property is useful if you need to revert to an unedited or preferred border style. Read/write Byte.
OldValue | You can use the OldValue property to determine the unedited value of a bound control. Read-only Variant.
OnClick | Sets or returns the value of the On Click box in the Properties window. Read/write String.
OnDblClick | Sets or returns the value of the On Dbl Click box in the Properties window. Read/write String.
OnMouseDown | Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.
OnMouseMove | Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.
OnMouseUp | Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.
Parent | Returns the parent object for the specified object. Read-only.
Picture | You can use the Picture property to specify a bitmap or other type of graphic to be displayed on the specified control. Read/write String.
PictureAlignment | You can use the PictureAlignment property to specify where a background picture will appear in an image control or on a form or report. Read/write Byte.Read/write.
PictureData | You can use the PictureData property to copy the picture to another object that supports the Picture property. Read/write Variant.
PictureTiling | You can use the PictureTiling property to specify whether a background picture is tiled across the entire image control, Form window, form, or page of a report. Read/write Boolean.
PictureType | You can use the PictureType property to specify whether Microsoft Access stores an object's picture as a linked or an embedded object. Read/write Byte.
Properties | Returns a reference to a control's Properties collection object. Read-only.
RightPadding | Gets or sets the amount of space (in inches) between the image control and its right gridline. Read/write Integer.
Section | You can identify these controls by the section of a form or report where the control appears. Read/write Integer.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
SizeMode | You can use the SizeMode property to specify how to size a picture or other object in a bound object frame, an unbound object frame, or an image control.
SpecialEffect | You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.
Tag | Stores extra information about a form, report, section, or control needed by a Microsoft Access application. Read/write String.
Top | You can use the Top property to specify an object's location on a form or report. Read/write Integer. .
TopPadding | Gets or sets the amount of space (in inches) between the image control and its top gridline. Read/write Integer.
VerticalAnchor | Gets or sets an AcVerticalAnchor constant that indicates how the specified image is anchored vertically within its layout. Read/write.
Visible | Returns or sets whether the object is visible. Read/write Boolean.
Width | Gets or sets the width of the specified object in twips. Read/write Integer.


Index.IgnoreNulls Property (DAO)

 Copy code hover
[image]

Index.IgnoreNulls Property (DAO)
Send feedback

Sets or returns a value that indicates whether records that have Null values in their index fields have index entries (Microsoft Access workspaces only).

Syntax

expression .IgnoreNulls

expression A variable that represents an Index object.

Remarks

This property is read/write for a new Index object not yet appended to a collection and read-only for an existing Index object in an Indexes collection.

To speed up the process of searching for records, you can define an index for a field. If you allow null entries in an indexed field and expect many of the entries to be null, you can set the IgnoreNulls property for the Index object to True to reduce the amount of storage space that the index uses.

The IgnoreNulls property setting and the Required property setting together determine whether a record with a null index value has an index entry.

If IgnoreNulls is | And Required is | Then
True | False | A null value is allowed in the index field; no index entry added.
False | False | A null value is allowed in the index field; index entry added.
True or False | True | A null value isn't allowed in the index field; no index entry added.

Example

This example sets the IgnoreNulls property of a new Index to True or False based on user input, and then demonstrates the effect on a Recordset with a record whose key field contains a Null value.

VBA Copy code Copy code
Sub IgnoreNullsX()

 Dim dbsNorthwind As Database
 Dim tdfEmployees As TableDef
 Dim idxNew As Index
 Dim rstEmployees As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set tdfEmployees = dbsNorthwind!Employees

 With tdfEmployees
 ' Create a new Index object.
 Set idxNew = .CreateIndex("NewIndex")
 idxNew.Fields.Append idxNew.CreateField("Country")

 ' Set the IgnoreNulls property of the new Index object
 ' based on the user's input.
 Select Case MsgBox("Set IgnoreNulls to True?", _
 vbYesNoCancel)
 Case vbYes
 idxNew.IgnoreNulls = True
 Case vbNo
 idxNew.IgnoreNulls = False
 Case Else
 dbsNorthwind.Close
 End
 End Select

 ' Append the new Index object to the Indexes
 ' collection of the Employees table.
 .Indexes.Append idxNew
 .Indexes.Refresh
 End With

 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees")

 With rstEmployees
 ' Add a new record to the Employees table.
 .AddNew
 !FirstName = "Gary"
 !LastName = "Haarsager"
 .Update

 ' Use the new index to set the order of the records.
 .Index = idxNew.Name
 .MoveFirst

 Debug.Print "Index = " & .Index & _
 ", IgnoreNulls = " & idxNew.IgnoreNulls
 Debug.Print " Country - Name"

 ' Enumerate the Recordset. The value of the
 ' IgnoreNulls property will determine if the newly
 ' added record appears in the output.
 Do While Not .EOF
 Debug.Print " " & _
 IIf(IsNull(!Country), "[Null]", !Country) & _
 " - " & !FirstName & " " & !LastName
 .MoveNext
 Loop

 ' Delete new record because this is a demonstration.
 .Index = ""
 .Bookmark = .LastModified
 .Delete
 .Close
 End With

 ' Delete new Index because this is a demonstration.
 tdfEmployees.Indexes.Delete idxNew.Name
 dbsNorthwind.Close

End Sub


ADO Event Handler Summary

 Copy code hover
[image]

ADO Event Handler Summary
Send feedback

Two ADO objects can raise events: the Connection object and the Recordset object. The ConnectionEvent family pertains to operations on the Connection object, and the RecordsetEvent family pertains to operations on the Recordset object.

  • Connection Events: Events are issued when a transaction on a connection begins, is committed, or is rolled back; when a Command executes; when a warning occurs during a Connection Event operation; or when a Connection starts or ends.

  • Recordset Events: Events are issued around asynchronous fetch operations as well as when you navigate through the rows of a Recordset object, change a field in a row of a Recordset, change a row in a Recordset, open a Recordset with a server-side cursor, close a Recordset, or make any change whatsoever in the Recordset.

The following tables summarize the events and their descriptions.

ConnectionEvent | Description
BeginTransComplete, CommitTransComplete, RollbackTransComplete | Transaction Management — Notification that the current transaction on the connection has started, committed, or rolled back.
WillConnect, ConnectComplete, Disconnect | Connection Management — Notification that the current connection will start, has started, or has ended.
WillExecute, ExecuteComplete | Command Execution Management — Notification that the execution of the current command on the connection will start or has ended.
InfoMessage | Informational — Notification that there is additional information about the current operation.
RecordsetEvent | Description
FetchProgress, FetchComplete | Retrieval Status — Notification of the progress of a data retrieval operation, or that the retrieval operation has completed. These events are only available if the Recordset was opened using a client-side cursor.
WillChangeField, FieldChangeComplete | Field Change Management — Notification that the value of the current field will change, or has changed.
WillMove, MoveComplete, EndOfRecordset | Navigation Management — Notification that the current row position in a Recordset will change, has changed, or has reached the end of the Recordset.
WillChangeRecord, RecordChangeComplete | Row Change Management — Notification that something in the current row of the Recordset will change, or has changed.
WillChangeRecordset, RecordsetChangeComplete | Recordset Change Management — Notification that something in the current Recordset will change, or has changed.


AcImportXMLOption Enumeration (Access)

 Copy code hover
[image]

AcImportXMLOption Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the action to take when using the ImportXML method to import data from an XML file.

Name | Value | Description
acAppendData | 2 | Imports the data into an existing table.
acStructureAndData | 1 | Imports the data into a new table based on the structure of the specified XML file.
acStructureOnly | 0 | Creates a new table based on the struture of the specified XML file.


Control.GridlineWidthBottom Property (Access)

 Copy code hover
[image]

Control.GridlineWidthBottom Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified control. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthBottom

expression A variable that represents a Control object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Control Object

Other resources

Control Object Members


Recordset2.StillExecuting Property (DAO)

 Copy code hover
[image]

Recordset2.StillExecuting Property (DAO)
Send feedback

Syntax

expression .StillExecuting

expression A variable that represents a Recordset2 object.

Remarks

Use the StillExecuting property to determine if the most recently called asynchronous Execute or OpenConnection method (that is, a method executed with the dbRunAsync option) is complete. While the StillExecuting property is True, any returned object cannot be accessed.

Once the StillExecuting property returns False, following the OpenConnection call that returns the associated Connection object, the object can be referenced. So long as StillExecuting remains True, the object may not be referenced, other than to read the StillExecuting property.

Use the Cancel method to terminate execution of a task in progress.


CacheSize Property Example (VJ++)

 Copy code hover
[image]

CacheSize Property Example (VJ++)
Send feedback

This example uses the CacheSize property to show the difference in performance for an operation performed with and without a 30-record cache.

Copy code Copy code

// BeginCacheSizeJ
import com.ms.wfc.data.*;
import java.io.* ;

public class CacheSizeX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 CacheSizeX();
 System.exit(0);
 }

 // CacheSizeX function

 static void CacheSizeX()
 {

 // Define ADO Objects.
 Recordset rstRoySched = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader (new InputStreamReader(System.in));
 String line = null;
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";

 long timeStart;
 long timeEnd;
 float timeNoCache;
 float timeCache;
 int intLoop;
 String strTemp;

 try
 {
 // Open the RoySched table.
 rstRoySched = new Recordset();
 rstRoySched.open("roysched", strCnn,
 AdoEnums.CursorType.FORWARDONLY,
 AdoEnums.LockType.READONLY,
 AdoEnums.CommandType.TABLE);

 // Enumerate the Recordset object twice and record
 // the elapsed time.

 timeStart = System.currentTimeMillis();
 for ( intLoop = 0; intLoop < 2; intLoop++)
 {
 rstRoySched.moveFirst();
 while (!rstRoySched.getEOF())
 {
 // Execute a simple operation for the
 // performance test.
 strTemp = rstRoySched.getField("title_id").getString();
 rstRoySched.moveNext();
 }

 }

 timeEnd = System.currentTimeMillis();
 timeNoCache =(float)(timeEnd - timeStart)/1000f;

 // Cache records in groups of 30 records.
 rstRoySched.moveFirst();
 rstRoySched.setCacheSize(30);
 timeStart = System.currentTimeMillis();

 // Enumerate the Recordset object twice and record
 // the elapsed time.
 for ( intLoop = 0; intLoop < 2; intLoop++)
 {
 rstRoySched.moveFirst();
 while (!rstRoySched.getEOF())
 {
 // Execute a simple operation for the
 // performance test.

 strTemp = rstRoySched.getField("title_id").getString();
 rstRoySched.moveNext();
 }

 }

 timeEnd = System.currentTimeMillis();
 timeCache = (float)(timeEnd - timeStart)/1000f;

 // Display performance results.
 System.out.println("\nCaching Performance Results:");
 System.out.println("\n\tNo Cache: " + timeNoCache + " seconds");
 System.out.println("\n\t30-record cache: " + timeCache +
 " seconds");
 System.out.println("\n\nPress <Enter> to continue..");
 in.readLine();

 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // Check for null pointer for connection object.
 if (rstRoySched.getActiveConnection()==null)
 System.out.println("Exception: " + ae.getMessage());

 // As passing a Recordset, check for null pointer first.
 if (rstRoySched != null)
 {
 PrintProviderError(rstRoySched.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // System read requires this catch.
 catch( java.io.IOException je)
 {
 PrintIOError(je);
 }
 finally
 {
 // Cleanup objects before exit.
 if (rstRoySched != null)
 if (rstRoySched.getState() == 1)
 rstRoySched.close();
 }

 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}

// EndCacheSizeJ


ListBox.MouseMove Event (Access)

 Copy code hover
[image]

ListBox.MouseMove Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseMove event occurs when the user moves the mouse.

Syntax

expression .MouseMove(Button, Shift, X, Y)

expression A variable that represents a ListBox object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseMove event applies only to forms, form sections, and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

Note Note

  • Moving a form can trigger a MouseMove event even if the mouse is stationary. MouseMove events are generated when the form moves underneath the pointer. If a macro or event procedure moves a form in response to a MouseMove event, the event can cascade (that is, continually generate MouseMove events).

  • If two controls are very close together, and you move the mouse pointer quickly over the space between them, the MouseMove event may not occur for the space (for example, this might be the MouseMove event for the form section). In such cases, you may need to respond to the MouseMove event in the contiguous control, as well as in the form section.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

VBA Copy code Copy code
Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


TabControl.BackTint Property (Access)

 Copy code hover
[image]

TabControl.BackTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackTint

expression A variable that represents a TabControl object.

Remarks

The BackTint property contains a numeric expression that can be used to lighten the theme color in the BackColor property. The default value of the BackTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens BackColor by 75%.

VBA Copy code Copy code
Me.ctl.BackTint=25

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


ComboBox.IMESentenceMode Property (Access)

 Copy code hover
[image]

ComboBox.IMESentenceMode Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .IMESentenceMode

expression A variable that represents a ComboBox object.

Remarks

The IMESentenceMode property uses the following settings.

Setting | Description | Visual Basic
Normal | (Default) Set IME Sentence Mode to "Normal" mode. | 0
Plural | Set IME Sentence Mode to "Plural" mode. | 1
Speaking | Set IME Sentence Mode to "Speaking" mode. | 2
No Conversion | Doesn't set IME Sentence Mode. | 3

Normal mode

Use this mode when creating a literary Japanese document.

Plural mode

Use this mode when entering name or address data. In this mode, two additional dictionaries are available. The "Biographical/Geographical Dictionary" contains names not covered in the normal dictionary and the "Postal Code Dictionary", useful in creating addresses. (Factory setting.)

Speaking mode

Use this mode when entering data that contains conversational language.

No Conversion

In this mode, inputted characters are settled without conversion.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


AllViews Object (Access)

 Copy code hover
[image]

AllViews Object (Access)
See also Send feedback

Published: July 16, 2012

The AllViews collection contains an AccessObject for each view in the CurrentData or CodeData object.

Remarks

The CurrentData or CodeData object has an AllViews collection containing AccessObject objects that describe instances of all views specified by CurrentData or CodeData. For example, you can enumerate the AllViews collection in Visual Basic to set or return the values of properties of individual AccessObject objects in the collection.

You can refer to an individual AccessObject object in the AllViews collection either by referring to the object by name, or by referring to its index within the collection. If you want to refer to a specific object in the AllViews collection, it's better to refer to the view by name because a view's collection index may change.

The AllViews collection is indexed beginning with zero. If you refer to a view by its index, the first view is AllViews(0), the second table is AllViews(1), and so on.

Note Note

  • The AllViews collection only contains AccessObject objects within a Microsoft Access project (.adp). A Microsoft Access database does not contain any views, see the AllQueries collection.

  • To list all open views in the project, use the IsLoaded property of each AccessObject object in the AllViews collection. You can then use the Name property of each individual AccessObject object to return the name of a view.

  • You can't add or delete an AccessObject object from the AllViews collection.

Example

The following example prints the name of each open AccessObject object in the AllViews collection.

VBA Copy code Copy code
Sub AllViews()
    Dim obj As AccessObject, dbs As Object
    Set dbs = Application.CurrentData
    ' Search for open AccessObject objects in AllViews collection.
    For Each obj In dbs.AllViews
        If obj.IsLoaded = True Then
            ' Print name of obj.
            Debug.Print obj.Name
        End If
    Next obj
End Sub

See also

Concepts

Access Object Model Reference

Other resources

AllViews Object Members


Chapter 10: Records and Streams (ADO)

 Copy code hover
[image]

Chapter 10: Records and Streams (ADO)
Send feedback

In this section

  • Chapter 10: Records and Streams

  • Streams and Persistence

  • Records and Provider-Supplied Fields

  • Absolute and Relative URLs

  • Using ADO for Internet Publishing (ADO)


Application.DeleteControl Method (Access)

 Copy code hover
[image]

Application.DeleteControl Method (Access)
See also Send feedback

Published: July 16, 2012

The DeleteControl method deletes a specified control from a form.

Syntax

expression .DeleteControl(FormName, ControlName)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
FormName | Required | String | The name of the form containing the control you want to delete.
ControlName | Required | String | The name of the control you want to delete.

Return Value

Nothing

Remarks

For example, suppose you have a procedure that must be run the first time each user logs onto your database. You can set the OnClick property of a button on the form to this procedure. Once the user has logged on and run the procedure, you can use the DeleteControl method to dynamically remove the command button from the form.

The DeleteControl method is available only in form Design view or report Design view, respectively.

Note Note

If you are building a wizard that deletes a control from a form or report, your wizard must open the form or report in Design view before it can delete the control.

Example

The following example creates a form with a command button and displays a message that asks if the user wants to delete the command button. If the user clicks Yes, the command button is deleted.

VBA Copy code Copy code
Sub DeleteCommandButton()
 Dim frm As Form, ctlNew As Control
 Dim strMsg As String, intResponse As Integer, _
 intDialog As Integer

 ' Create new form and get pointer to it.
 Set frm = CreateForm
 ' Create new command button.
 Set ctlNew = CreateControl(frm.Name, acCommandButton)
 ' Restore form.
 DoCmd.Restore
 ' Set caption.
 ctlNew.Caption = "New Command Button"
 ' Size control.
 ctlNew.SizeToFit
 ' Prompt user to delete control.
 strMsg = "About to delete " & ctlNew.Name &". Continue?"
 ' Define buttons to be displayed in dialog box.
 intDialog = vbYesNo + vbCritical + vbDefaultButton2
 intResponse = MsgBox(strMsg, intDialog)
 If intResponse = vbYes Then
 ' Delete control.
 DeleteControl frm.Name, ctlNew.Name
 End If
End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


Modules Object (Access)

 Copy code hover
[image]

Modules Object (Access)
See also Send feedback

Published: July 16, 2012

The Modules collection contains all open standard modules and class modules in a Microsoft Access database.

Remarks

All open modules are included in the Modules collection, whether they are uncompiled, are compiled, are in break mode, or contain the code that's running.

To determine whether an individual Module object represents a standard module or a class module, check the Module object's Type property.

The Modules collection belongs to the Microsoft Access Application object.

Individual Module objects in the Modules collection are indexed beginning with zero.

Example

The following example illustrates how to use the Modules collection to loop through the open modules. The example prints the name if each open module in the Immediate window.

VBA Copy code Copy code

Sub PrintOpenModuleNames()
 Dim i As Integer
 Dim modOpenModules As Modules

 Set modOpenModules = Application.Modules

 For i = 0 To modOpenModules.Count - 1

 Debug.Print modOpenModules(i).Name

 Next
End Sub

See also

Concepts

Access Object Model Reference

Other resources

Modules Object Members


CustomControl.Enter Event (Access)

 Copy code hover
[image]

CustomControl.Enter Event (Access)
See also Send feedback

Published: July 16, 2012

The Enter event occurs before a control actually receives the focus from a control on the same form or report.

Syntax

expression .Enter

expression A variable that represents a CustomControl object.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when these events occur, set the OnEnter or OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Enter event occurs before the GotFocus event. The Exit event occurs before the LostFocus event.

Unlike the GotFocus and LostFocus events, the Enter and Exit events don't occur when a form receives or loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


Chapter 9: Data Shaping

 Copy code hover
[image]

Chapter 9: Data Shaping
Send feedback

Data shaping provides a way to query a data source and return a Recordset that represents a parent-child relationship between two or more logical entities (a hierarchy). A classic example of a hierarchical relationship is customers and orders. For every customer in a database, there can be zero or more orders. Regular SQL provides a means of retrieving the data using JOIN syntax, but this can be inefficient and unwieldy because redundant parent data is repeated in each record returned for a given parent-child relationship. Data shaping can relate a single parent record in the parent Recordset to multiple child records in the child Recordset, avoiding the redundancy of a JOIN. Most people find the parent-child multiple Recordset programming model more natural and easier to work with than the single Recordset JOIN model.

The data shaping syntax also provides other capabilities. Developers can create new Recordset objects without an underlying data source by using the NEW keyword to describe the fields of the parent and child Recordsets. The new Recordset object can be populated with data and persistently stored. Developers can also perform various calculations or aggregations (for example, SUM, AVG, and MAX) on child fields. Data shaping can also create a parent Recordset from a child Recordset by grouping records in the child and placing one row in the parent for each group in the child.

See the following topics to learn more about data shaping:

  • Data Shaping Summary

  • Required Providers for Data Shaping

  • Shape Commands in General

  • Shape APPEND Clause

  • Shape COMPUTE Clause

  • Fabricating Hierarchical Recordsets

  • Accessing Rows in a Hierarchical Recordset

  • Formal Shape Grammar

  • Visual Basic for Applications Functions


Section.Paint Event (Access)

 Copy code hover
[image]

Section.Paint Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when the specified section is redrawn.

Version Information

Version Added: Access 2007

Syntax

expression .Paint

expression A variable that represents a Section object.

Example

The following example shows how to set the BackColor property of a control based on its value.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Private Sub SetControlFormatting()
    If (Me.AvgOfRating >= 8) Then
        Me.AvgOfRating.BackColor = vbGreen
    ElseIf (Me.AvgOfRating >= 5) Then
        Me.AvgOfRating.BackColor = vbYellow
    Else
        Me.AvgOfRating.BackColor = vbRed
    End If
End Sub

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    ' size the width of the rectangle
    Dim lngOffset As Long
    lngOffset = (Me.boxInside.Left - Me.boxOutside.Left) * 2
    Me.boxInside.Width = (Me.boxOutside.Width * (Me.AvgOfRating / 10)) - lngOffset

    ' do conditional formatting for the control in print preview
    SetControlFormatting
End Sub

Private Sub Detail_Paint()
    ' do conditional formatting for the control in report view
    SetControlFormatting
End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.

See also

Concepts

Section Object

Other resources

Section Object Members


Section.OnMouseMove Property (Access)

 Copy code hover
[image]

Section.OnMouseMove Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Move box in the Properties window. Read/write String.

Syntax

expression .OnMouseMove

expression A variable that represents a Section object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseMove event occurs when the user moves the mouse over the object.

The OnMouseMove value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Move box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Move box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseMove property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseMove

See also

Concepts

Section Object

Other resources

Section Object Members


CommandButton.AutoLabel Property (Access)

 Copy code hover
[image]

CommandButton.AutoLabel Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies whether labels are automatically created and attached to new controls. Read/write Boolean.

Syntax

expression .AutoLabel

expression A variable that represents a CommandButton object.

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


CodeProject.FileFormat Property (Access)

 Copy code hover
[image]

CodeProject.FileFormat Property (Access)
See also Send feedback

Published: July 16, 2012

Returns an AcFileFormat constant indicating the Microsoft Access version format of the specified project. Read-only.

Syntax

expression .FileFormat

expression A variable that represents a CodeProject object.

Remarks

Use the ConvertAccessProject method to convert an Access project from one version to another.

Example

This example evaluates the current project and displays a message indicating to which version of Microsoft Access its file format corresponds.

VBA Copy code Copy code
Dim strFormat As String

Select Case CurrentProject.FileFormat
 Case acFileFormatAccess2
 strFormat = "Microsoft Access 2"
 Case acFileFormatAccess95
 strFormat = "Microsoft Access 95"
 Case acFileFormatAccess97
 strFormat = "Microsoft Access 97"
 Case acFileFormatAccess2000
 strFormat = "Microsoft Access 2000"
 Case acFileFormatAccess2002
 strFormat = "Access 2002 - 2003"
 Case acFileFormatAccess12
 strFormat = "Microsoft Access 2007"
End Select

MsgBox "This is a " & strFormat & " project."

See also

Concepts

CodeProject Object

Other resources

CodeProject Object Members


Application.CodeData Property (Access)

 Copy code hover
[image]

Application.CodeData Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the CodeData property to access the CodeData object and its related collections. Read-only CodeData object.

Syntax

expression .CodeData

expression A variable that represents an Application object.

Remarks

Use the CodeData property to refer to one of the following code database collections together with one of its properties or methods.

See also

Concepts

Application Object

Other resources

Application Object Members


TableDefs.Refresh Method (DAO)

 Copy code hover
[image]

TableDefs.Refresh Method (DAO)
Send feedback

Updates the objects in the specified colletion to reflect the database's current schema.

Syntax

expression .Refresh

expression A variable that represents a TableDefs object.

Remarks

To determine the position that the Microsoft Access database engine uses for Field objects in the Fields collection of a QueryDef, Recordset, or TableDef object, use the OrdinalPosition property of each Field object. Changing the OrdinalPosition property of a Field object may not change the order of the Field objects in the collection until you use the Refresh method

Use the Refresh method in multiuser environments in which other users may change the database. You may also need to use it on any collections that are indirectly affected by changes to the database. For example, if you change a Users collection, you may need to refresh a Groups collection before using the Groups collection.

A collection is filled with objects the first time it's referred to and won't automatically reflect subsequent changes other users make. If it's likely that another user has changed a collection, use the Refresh method on the collection immediately before carrying out any task in your application that assumes the presence or absence of a particular object in the collection. This will ensure that the collection is as up-to-date as possible. On the other hand, using Refresh can unnecessarily slow performance.


Refresh Method Example (VJ++)

 Copy code hover
[image]

Refresh Method Example (VJ++)
Send feedback

This example demonstrates using the Refresh method to refresh the Parameters collection for a stored procedure Command object.

Copy code Copy code

// BeginRefreshJ
import com.ms.wfc.data.*;
import java.io.*;

public class RefreshX
{
 // The main entry point for the application.

 public static void main (String[] args)
 {
 RefreshX();
 System.exit(0);
 }

 // RefreshX function

 static void RefreshX()
 {
 // Define ADO Objects.
 Connection cnConn1 = null;
 Command cmdByRoyalty = null;
 Recordset rstByRoyalty = null;
 Recordset rstAuthors = null;

 //Declarations.
 String strAuthorID;
 String strFName;
 String strLName;
 int intRoyalty ;
 BufferedReader in =
 new BufferedReader (new InputStreamReader (System.in));
 String line = null;

 try
 {
 // Open a connection.
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';"
 + "Initial Catalog='Pubs';Integrated Security='SSPI';";

 cnConn1 = new Connection();
 cnConn1.open(strCnn);

 // Open a command object for a stored procedure
 // with one parameter.
 cmdByRoyalty = new Command();
 cmdByRoyalty.setActiveConnection(cnConn1);
 cmdByRoyalty.setCommandText("byRoyalty");
 cmdByRoyalty.setCommandType(AdoEnums.CommandType.STOREDPROC);
 cmdByRoyalty.getParameters().refresh();

 // Get Parameter value and execute the command
 // storing the results in the recordset.
 System.out.println ("\nEnter Royalty : ");
 line = in.readLine().trim();
 intRoyalty = Integer.parseInt(line);
 cmdByRoyalty.getParameters().getItem(1).setInt(intRoyalty);

 // Create a recordset by executing the command.
 rstByRoyalty = cmdByRoyalty.execute();

 // Open the Authors table to get author names for display.
 rstAuthors = new Recordset ();
 rstAuthors.open(
 "Authors",strCnn,AdoEnums.CursorType.FORWARDONLY,
 AdoEnums.LockType.READONLY, AdoEnums.CommandType.TABLE );

 // Print current data in the recordset,
 // adding author names from Authors table.
 System.out.println("\nAuthors with " + intRoyalty +
 " percent royalty");
 while (!rstByRoyalty.getEOF())
 {
 strAuthorID = rstByRoyalty.getField("au_id").getString();
 rstAuthors.setFilter("au_id ='" + strAuthorID + "'");
 strFName = rstAuthors.getField("au_fname").getString();
 strLName = rstAuthors.getField("au_lname").getString();
 System.out.println("\t" + strAuthorID + ", " + strFName
 + " " + strLName);
 rstByRoyalty.moveNext();
 }
 System.out.println("\n\nPress <Enter> key to continue..");
 line = in.readLine();

 }
 catch( AdoException ae )
 {
 // Notify user of any errors that result from ADO.

 // As passing a Recordset, check for null pointer first.
 if (rstByRoyalty != null)
 {
 PrintProviderError(rstByRoyalty.getActiveConnection());
 }
 else if (rstAuthors != null)
 {
 PrintProviderError(rstAuthors.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }

 // This catch is required if input string cannot be converted to
 // Integer data type.
 catch ( java.lang.NumberFormatException ne)
 {
 System.out.println("\nException: Integer Input required.");
 }
 // System Read requires this catch.
 catch( java.io.IOException je )
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstByRoyalty != null)
 if (rstByRoyalty.getState() == 1)
 rstByRoyalty.close();
 if (rstAuthors != null)
 if (rstAuthors.getState() == 1)
 rstAuthors.close();
 if (cnConn1 != null)
 if (cnConn1.getState() == 1)
 cnConn1.close();
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndRefreshJ


How to: Find a Record in a Dynaset-Type or Snapshot-Type DAO Recordset

 Copy code hover
[image]

How to: Find a Record in a Dynaset-Type or Snapshot-Type DAO Recordset
Send feedback

You can use the Find methods to locate a record in a dynaset-type or snapshot-type Recordset object. DAO provides the following Find methods:

  • The FindFirst method finds the first record that satisfies the specified criteria.

  • The FindLast method finds the last record that satisfies the specified criteria.

  • The FindNext method finds the next record that satisfies the specified criteria.

  • The FindPrevious method finds the previous record that satisfies the specified criteria.

When you use the Find methods, you specify the search criteria, which is typically an expression that equates a field name with a specific value.

You can locate the matching records in reverse order by finding the last occurrence with the FindLast method and then using the FindPrevious method instead of the FindNext method.

DAO sets the NoMatch property to True when a Find method fails and the current record position is undefined. There may be a current record, but there is no way to tell which one. To return to the previous current record following a failed Find method, use a bookmark.

The NoMatch property is False when the operation succeeds. In this case, the current record position is the record found by one of the Find methods.

The following example illustrates how you can use the FindNext method to find all orders in the Orders table that have no corresponding records in the Order Details table. The function searches for missing orders and, if it finds one, it adds the value in the OrderID field to the array aryOrders().

VBA Copy code Copy code
Function FindOrders() As Variant

Dim dbsNorthwind As DAO.Database
Dim rstOrders As DAO.Recordset
Dim rstOrderDetails As DAO.Recordset
Dim strSQL As String
Dim intIndex As Integer
Dim aryOrders() As Long

On Error GoTo ErrorHandler

   Set dbsNorthwind = CurrentDb

   ' Open recordsets on the Orders and OrderDetails tables. If there are
   ' no records in either table, exit the function.
   strSQL = "SELECT * FROM Orders ORDER BY OrderID"
   Set rstOrders = dbsNorthwind.OpenRecordset(strSQL, dbOpenSnapshot)
   If rstOrders.EOF Then Exit Function

   strSQL = "SELECT * FROM [Order Details] ORDER BY OrderID"
   Set rstOrderDetails = dbsNorthwind.OpenRecordset(strSQL, _
                         dbOpenSnapshot)

   ' For the first record in Orders, find the first matching record
   ' in OrderDetails. If no match, redimension the array of order IDs and
   ' add the order ID to the array.
   intIndex = 1
   rstOrderDetails.FindFirst "OrderID = " & rstOrders![OrderID]
   If rstOrderDetails.NoMatch Then
      ReDim Preserve aryOrders (1 To intIndex)
      aryOrders (intIndex) = rstOrders![OrderID]
      rstOrders.MoveNext
   End If

   ' The first match has already been found, so use the FindNext method to
   ' find the next record that satisfies the criteria.
   Do Until rstOrders.EOF
      rstOrderDetails.FindNext "OrderID = " & rstOrders![OrderID]
      If rstOrderDetails.NoMatch Then
         intIndex = intIndex + 1
         ReDim Preserve aryOrders (1 To intIndex)
         aryOrders (intIndex) = rstOrders![OrderID]
      End If
      rstOrders.MoveNext
   Loop

   FindOrders = aryOrders

   rstOrders.Close
   rstOrderDetails.Close
   dbsNorthwind.Close

   Set rstOrders = Nothing
   Set rstOrderDetails = Nothing
   Set dbsNorthwind = Nothing

Exit Function

ErrorHandler:
   MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Function


Attachment.BackTint Property (Access)

 Copy code hover
[image]

Attachment.BackTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BackColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BackTint

expression A variable that represents an Attachment object.

Remarks

The BackTint property contains a numeric expression that can be used to lighten the theme color in the BackColor property. The default value of the BackTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BackColor property by 75%.

VBA Copy code Copy code
Me.ctl.BackTint=25

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


QueryDef Methods (DAO)

 Copy code hover
[image]

QueryDef Methods (DAO)
Send feedback

In this section

  • QueryDef.Cancel Method (DAO)

  • QueryDef.Close Method (DAO)

  • QueryDef.CreateProperty Method (DAO)

  • QueryDef.Execute Method (DAO)

  • QueryDef.OpenRecordset Method (DAO)


AcExportXMLObjectType Enumeration (Access)

 Copy code hover
[image]

AcExportXMLObjectType Enumeration (Access)
Send feedback

Published: July 16, 2012

Use with the ExportXML method to specify the type of object to export.

Name | Value | Description
acExportForm | 2 | Form
acExportFunction | 10 | User-defined function (Microsoft Access project only)
acExportQuery | 1 | Query
acExportReport | 3 | Report
acExportServerView | 7 | Server view (Microsoft Access project only)
acExportStoredProcedure | 9 | Stored procedure (Microsoft Access project only)
acExportTable | 0 | Table


This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables. (Error 3071)

 Copy code hover
[image]

This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables. (Error 3071)
Send feedback

Possible causes:

  • You typed an expression that has invalid syntax. For example, an operand or operator may be missing, you may have typed an invalid character or comma, or you may have typed text without enclosing it with quotation marks ( " ). Check the expression to make sure you typed it correctly.

  • You typed an expression that is too complex. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning some parts to variables.


UnderlyingValue Property (ADO)

 Copy code hover
[image]

UnderlyingValue Property (ADO)
Send feedback

Indicates a Field object's current value in the database.

Return Value

Returns a Variant value that indicates the value of the Field.

Remarks

Use the UnderlyingValue property to return the current field value from the database. The field value in the UnderlyingValue property is the value that is visible to your transaction and may be the result of a recent update by another transaction. This may differ from the OriginalValue property, which reflects the value that was originally returned to the Recordset.

This is similar to using the Resync method, but the UnderlyingValue property returns only the value for a specific field from the current record. This is the same value that the Resync method uses to replace the Value property.

When you use this property with the OriginalValue property, you can resolve conflicts that arise from batch updates.

Record

For Record objects, this property will be empty for fields added before Update is called.


Failure to write because destination disk is full. (Error 3559)

 Copy code hover
[image]

Failure to write because destination disk is full. (Error 3559)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


AllTables.Count Property (Access)

 Copy code hover
[image]

AllTables.Count Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Count property to determine the number of items in a specified collection. Read-only Long.

Syntax

expression .Count

expression A variable that represents an AllTables object.

See also

Concepts

AllTables Collection

Other resources

AllTables Object Members


You tried to assign the Null value to a variable that is not a Variant data type. (Error 3162)

 Copy code hover
[image]

You tried to assign the Null value to a variable that is not a Variant data type. (Error 3162)
Send feedback

You tried to assign a Null value to a variable that is not a Variant data type. Use the Dim statement to declare the variable as a Variant, and then try the operation again.


DataMember Property (ADO)

 Copy code hover
[image]

DataMember Property (ADO)
Send feedback

Indicates the name of the data member that will be retrieved from the object referenced by the DataSource property.

Settings and Return Values

Sets or returns a String value. The name is not case sensitive.

Remarks

This property is used to create data-bound controls with the Data Environment. The Data Environment maintains collections of data (data sources) containing named objects (data members) that will be represented as a Recordset object.

The DataMember and DataSource properties must be used in conjunction.

The DataMember property determines which object specified by the DataSource property will be represented as a Recordset object. The Recordset object must be closed before this property is set. An error is generated if the DataMember property isn't set before the DataSource property, or if the DataMember name isn't recognized by the object specified in the DataSource property.

Usage

Copy code Copy code
Dim rs as New ADODB.Recordset
rs.DataMember = "Command"     'Name of the rowset to bind to
Set rs.DataSource = myDE      'Name of the object containing an IRowset


How to: Cancel an Event

 Copy code hover
[image]

How to: Cancel an Event
Send feedback

Under some circumstances, you may want to include code in an event procedure that cancels the associated event. For example, you may want to include code that cancels the Open event in an Open event procedure for a form, preventing the form from opening if certain conditions are not met.

You can cancel the following events:

ApplyFilter

BeforeDelConfirm

BeforeInsert

BeforeRender

BeforeUpdate

CommandBeforeExecute

DblClick

Delete

Dirty

Exit

Filter

NoData

Open

Undo

Unload

You cancel an event by by setting an event procedure's Cancel argument to True.


Application Properties (Access)

 Copy code hover
[image]

Application Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Assistance | Returns an IAssistance object that represents the Microsoft Office Help Viewer. Read-only.
AutoCorrect | Returns an AutoCorrect object that represents the AutoCorrect settings for Microsoft Access. Read-only.
AutomationSecurity | Returns or sets an MsoAutomationSecurity constant that represents the security mode that Microsoft Access uses when it is programmatically opening files. Read/write. .
BrokenReference | Returns a Boolean indicating whether the current database has any broken references to databases or type libraries. True if there are any broken references. Read-only.
Build | Returns as a Long representing the build number of the currently installed copy of Microsoft Access. Read-only.
CodeContextObject | You can use the CodeContextObject property to determine the object in which a macro or Visual Basic code is executing. Read-only Object.
CodeData | You can use the CodeData property to access the CodeData object and its related collections. Read-only CodeData object.
CodeProject | You can use the CodeProject property to access the CodeProject object and its related collections, properties, and methods. Read-only CodeProject object.
COMAddIns | You can use the COMAddIns property to return a reference to the current COMAddIns collection object and its related properties. Read-only COMAddIns object.
CommandBars | You can use the CommandBars property to return a reference to the CommandBars collection object. Read-only CommandBars object.
CurrentData | You can use the CurrentData property to access the CurrentData object and its related collections. Read-only CurrentData object.
CurrentObjectName | You can use the CurrentObjectName property with the Application object to determine the name of the active database object. The active database object is the object that has the focus or in which code is running. Read-only String.
CurrentObjectType | You can use the CurrentObjectType property together with the Application object to determine the type of the active database object (table, query, form, report, macro, module, server view, database diagram, or stored procedure). The active database object is the object that has the focus or in which code is running. Read-only AcObjectType.
CurrentProject | You can use the CurrentProject property to access the CurrentProject object and its related collections, properties, and methods. Read-only CurrentProject object.
DBEngine | You can use the DBEngine property in Visual Basic to access the current DBEngine object and its related properties. Read-only DBEngine.
DoCmd | You can use the DoCmd property to access the read-only DoCmd object and its related methods. Read-only DoCmd.
FeatureInstall | You can use the FeatureInstall property to specify or determine how Microsoft Access handles calls to methods and properties that require features not yet installed. Read/write MsoFeatureInstall.
FileDialog | Returns a FileDialog object which represents a single instance of a file dialog box. Read-only.
Forms | You can use the Forms property to return a read-only reference to the Forms collection and its related properties.
IsCompiled | The IsCompiled property returns a Boolean value indicating whether the Visual Basic project is in a compiled state. Read-only Boolean.
LanguageSettings | You can use the LanguageSettings property to return a read-only reference to the current LanguageSettings object and its related properties.
MacroError | Returns a MacroError object that contains information about the latest error to occur in a macro. Read-only.
MenuBar | Specifies a custom menu to display for a Microsoft Access database. Read/write String.
Modules | You can use the Modules property to access the Modules collection and its related properties. Read-only Modules object.
Name | You can use the Name property to determine the string expression that identifies the name of an object. Read-only String.
NewFileTaskPane | Returns a NewFile object that represents a document listed on the New File task pane. Read-only NewFile object.
Parent | Returns the parent object for the specified object. Read-only.
Printer | Returns or sets a Printer object representing the default printer on the current system. Read/write.
Printers | Returns the Printers collection representing all the available printers on the current system. Read-only Printers collection.
ProductCode | You can use the ProductCode property to determine the Microsoft Access 2013 globally unique identifier (GUID). Read-only String.
References | You can use the References property to access the References collection and its related properties, methods, and events. Read-only References collection.
Reports | You can use the Reports property to access the read-only Reports collection and its related properties.
ReturnVars | Returns the ReturnVars collection representing all the available ReturnVar variables. Read-only ReturnVars collection.
Screen | You can use the Screen property to return a reference the Screen object and its related properties. Read-only.
ShortcutMenuBar | You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.
TempVars | Returns the collection of TempVar objects. Read-only TempVars.
UserControl | You can use the UserControl property to determine whether the current Microsoft Access application was started by the user or by another application with Automation, formerly called OLE Automation. Read/write Boolean.
VBE | You can use the VBE property to return a reference to the current VBE object and its related properties. The VBE property of the Application object represents the Microsoft Visual Basic for Applications editor. Read-only VBE object.
Version | Returns a String indicating the version number of the currently installed copy of Microsoft Access 2013. Read-only.
Visible | Returns or sets whether a Microsoft Access application is minimized. Read/write Boolean.
WebServices | Gets the collection of installed Data Service data connections. Read-only WebServices.


OptionGroup.BackStyle Property (Access)

 Copy code hover
[image]

OptionGroup.BackStyle Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BackStyle property to specify whether a control will be transparent. Read/write Byte.

Syntax

expression .BackStyle

expression A variable that represents an OptionGroup object.

Remarks

The BackStyle property uses the following settings.

Setting | Visual Basic | Description
Normal | 1 | (Default for all controls except option group) The control has its interior color set by the BackColor property.
Transparent | 0 | (Default for option group) The control is transparent. The color of the form or report behind the control is visible.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

If the Transparent button on the Back Color button palette is selected, the BackStyle property is set to Transparent; otherwise the BackStyle property is set to Normal.

To make a command button invisible, set its Transparent property to Yes.

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


NavigationControl.GridlineShade Property (Access)

 Copy code hover
[image]

NavigationControl.GridlineShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineShade

expression A variable that represents an NavigationControl object.

Remarks

The GridlineShade property contains a numeric expression that can be used to darken the theme color in the GridlineColor property. The default value of the GridlineShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


How to: Hide the Ribbon When Access Starts

 Copy code hover
[image]

How to: Hide the Ribbon When Access Starts
Send feedback

By default, Microsoft Access does not provide a method for hiding the ribbon. This topic describes how to load a customized ribbon that hides all of the built-in tabs.

To load the customized ribbon when Access starts, you should store its settings in a table named USysRibbons.

The USysRibbons table must be created using specific column names in order for the ribbon customizations to be implemented. The following table lists the settings to use when creating the USysRibbons table.

Column Name | Data Type | Description
RibbonName | Text | Contains the name of the custom ribbon to be associated with this customization.
RibbonXML | Memo | Contains the Ribbon Extensibility XML (RibbonX) that defines the ribbon customization.

The following table lists the ribbon customization settings to store in the USysRibbons table.

Column Name | Value
RibbonName | HideTheRibbon
RibbonXML | <CustomUI xmlns="http://schemas.microsoft.com/office/2006/01/CustomUI"> <ribbon startFromScratch="true"/></CustomUI>

Applying a Custom Ribbon When Access Starts

To apply a custom ribbon so that it is available when the application starts, use the following procedure:

  1. Follow the process described previously to make the customized ribbon available to the application.

  2. Close and then restart the application.

  3. Click the Microsoft Office Button [image] and then click Access Options.

  4. Click the Current Database option and then, in the Ribbon and Toolbar Options section, click the Ribbon Name list and select HideTheRibbon.

  5. Close and then restart the application.

Note Note

For more information about the ribbon UI in other Office applications, see Overview of the Office Fluent Ribbon.


Registering Business Objects on the Client for Use with DCOM

 Copy code hover
[image]

Registering Business Objects on the Client for Use with DCOM
Send feedback

Custom business objects need to ensure that the client side can map their program name (ProgId) to an identifier (CLSID) that can be used over DCOM. For this reason, the ProgID of the DCOM object must be in the client-side registry and map to the class ID of the server-side business object. For the other supported protocols (HTTP, HTTPS, and in-process), this is not necessary.

For example, if you expose a server-side business object called MyBObj with a specific class ID, for instance, "{00112233-4455-6677-8899-00AABBCCDDEE}", make sure that the following entries are added to the client-side registry:

Copy code Copy code

[HKEY_CLASSES_ROOT]
\MyBObj
 \Clsid
 (Default) "{00112233-4455-6677-8899-00AABBCCDDEE}"


Field.AppendChunk Method (DAO)

 Copy code hover
[image]

Field.AppendChunk Method (DAO)
Send feedback

Appends data from a string expression to a Memo or Long Binary Field object in a Recordset.

Syntax

expression .AppendChunk(Val)

expression A variable that represents a Field object.

Parameters

Name | Required/Optional | Data Type | Description
Val | Required | Variant | A Variant (String subtype) expression or variable containing the data you want to append to the Field object.

Remarks

You can use the AppendChunk and GetChunk methods to access subsets of data in a Memo or Long Binary field.

You can also use these methods to conserve string space when you work with Memo and Long Binary fields. Certain operations (copying, for example) involve temporary strings. If string space is limited, you may need to work with chunks of a field instead of the entire field.

If there is no current record when you use AppendChunk, an error occurs.

Note Note

The initial AppendChunk operation (after an Edit or AddNew call) will simply place the data in the field, overwriting any existing data. Subsequent AppendChunk calls within the same Edit or AddNew session will then add to the existing data.

Example

This example uses the AppendChunk and GetChunk methods to fill an OLE object field with data from another record, 32K at a time. In a real application, one might use a procedure like this to copy an employee record (including the employee's photo) from one table to another. In this example, the record is simply being copied back to same table. Note that all the chunk manipulation takes place within a single AddNew-Update sequence.

Copy code Copy code
Sub AppendChunkX()

   Dim dbsNorthwind As Database
   Dim rstEmployees As Recordset
   Dim rstEmployees2 As Recordset

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   ' Open two recordsets from the Employees table.
   Set rstEmployees = _
      dbsNorthwind.OpenRecordset("Employees", _
      dbOpenDynaset)
   Set rstEmployees2 = rstEmployees.Clone

   ' Add a new record to the first Recordset and copy the
   ' data from a record in the second Recordset.
   With rstEmployees
      .AddNew
      !FirstName = rstEmployees2!FirstName
      !LastName = rstEmployees2!LastName
      CopyLargeField rstEmployees2!Photo, !Photo
      .Update

      ' Delete new record because this is a demonstration.
      .Bookmark = .LastModified
      .Delete
      .Close
   End With

   rstEmployees2.Close
   dbsNorthwind.Close

End Sub

Function CopyLargeField(fldSource As Field, _
   fldDestination As Field)

   ' Set size of chunk in bytes.
   Const conChunkSize = 32768

   Dim lngOffset As Long
   Dim lngTotalSize As Long
   Dim strChunk As String

   ' Copy the photo from one Recordset to the other in 32K
   ' chunks until the entire field is copied.
   lngTotalSize = fldSource.FieldSize
   Do While lngOffset < lngTotalSize
      strChunk = fldSource.GetChunk(lngOffset, conChunkSize)
      fldDestination.AppendChunk strChunk
      lngOffset = lngOffset + conChunkSize
   Loop

End Function


Seek Method and Index Property Example (VC++)

 Copy code hover
[image]

Seek Method and Index Property Example (VC++)
Send feedback

This example uses the Recordset object's Seek method and Index property in conjunction with a given Employee ID, to locate the employee's name in the Employees table of the Nwind.mdb database.

Copy code Copy code

// BeginSeekCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <stdio.h>
#include <ole2.h>
#include <conio.h>
#include <string.h>
#include "SeekX.h"

//Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void SeekX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);
inline char* mygets(char* strDest, int n)
{
 char strExBuff[10];
 char* pstrRet = fgets(strDest, n, stdin);

 if (pstrRet == NULL)
 return NULL;

 if (!strrchr(strDest, '\n'))
 // Exhaust the input buffer.
 do
 {
 fgets(strExBuff, sizeof(strExBuff), stdin);
 }while (!strrchr(strExBuff, '\n'));
 else
 // Replace '\n' with '\0'
 strDest[strrchr(strDest, '\n') - strDest] = '\0';

 return pstrRet;
}

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 SeekX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// SeekX Function //
// //
//////////////////////////////////////////////////////////
void SeekX()
{
 HRESULT hr = S_OK;

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.

 _RecordsetPtr pRstEmp = NULL;

 IADORecordBinding *picRs = NULL; // Interface Pointer declared
 CEmployeeRs EmpRs; //C++ class object

 //Definitions of other variables
 _bstr_t strPrompt("Enter an EmployeeID (e.g., 1 to 9)");
 char strEmpId[2];

 try
 {
 TESTHR(pRstEmp.CreateInstance(__uuidof(Recordset)));
 pRstEmp->CursorLocation = adUseServer;
 pRstEmp->Open("employees", "Provider='Microsoft.Jet.OLEDB.4.0';"
 "Data Source='C:\\Program Files\\Microsoft Office\\Office\\"
 "Samples\\Northwind.mdb';",
 adOpenKeyset,adLockReadOnly,adCmdTableDirect);

 //Open an IADORecordBinding interface pointer which
 //we'll use for binding Recordset to a Class
 TESTHR(pRstEmp->QueryInterface(
 __uuidof(IADORecordBinding), (LPVOID*)&picRs));

 //Bind the Recordset to a C++ Class
 TESTHR(picRs->BindToRecordset(&EmpRs));

 //Does this provider support Seek and Index?
 if (pRstEmp->Supports(adIndex) && pRstEmp->Supports(adSeek))
 {
 pRstEmp->Index = "PrimaryKey";

 //Display all the employees.
 pRstEmp->MoveFirst();
 while (!pRstEmp->EndOfFile)
 {
 printf("%d : %s %s\n",
 EmpRs.le_empidStatus == adFldOK ?
 EmpRs.m_ie_empid : 0,
 EmpRs.le_fnameStatus == adFldOK ?
 EmpRs.m_sze_fname : "<NULL>",
 EmpRs.le_lnameStatus == adFldOK ?
 EmpRs.m_sze_lname : "<NULL>");

 pRstEmp->MoveNext();
 }
 //Prompt the user for an EmployeeID between 1 and 9.
 do
 {
 pRstEmp->MoveFirst();
 printf("\n\n%s\t",(LPCSTR) strPrompt);
 mygets(strEmpId, 2);

 //Quit if strEmpID is a zero-length string
 //(CANCEL, null, etc.)
 char *strTemp = strtok(strEmpId," \t");
 if (strTemp == NULL) break;
 if (strlen(strTemp) == 1 && atoi(strTemp) >= 1 &&
 atoi(strTemp) <= 9)
 {
 _variant_t strEmployeeId(strTemp);
 pRstEmp->Seek(strEmployeeId, adSeekAfterEQ);
 if (pRstEmp->EndOfFile)
 {
 printf("Employee not found.\n");
 }
 else
 {
 printf("%d : Employee='%s %s'\n",
 EmpRs.le_empidStatus == adFldOK ?
 EmpRs.m_ie_empid : 0,
 EmpRs.le_fnameStatus == adFldOK ?
 EmpRs.m_sze_fname : "<NULL>",
 EmpRs.le_lnameStatus == adFldOK ?
 EmpRs.m_sze_lname : "<NULL>");
 }
 }
 }
 while(true);
 }
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 // Pass a connection pointer accessed from the Recordset.
 _variant_t vtConnect = pRstEmp->GetActiveConnection();

 // GetActiveConnection returns connect string if connection
 // is not open, else returns Connection object.
 switch(vtConnect.vt)
 {
 case VT_BSTR:
 PrintComError(e);
 break;
 case VT_DISPATCH:
 PrintProviderError(vtConnect);
 break;
 default:
 printf("Errors occured.");
 break;
 }
 }

 // Clean up objects before exit.
 //Release the IADORecordset Interface here
 if (picRs)
 picRs->Release();

 if (pRstEmp)
 if (pRstEmp->State == adStateOpen)
 pRstEmp->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////
void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;

 // Collection ranges from 0 to nCount -1.
 for(long i = 0;i < nCount;i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,
 pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////
void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print COM errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndSeekCpp

SeekX.h

Copy code Copy code

// BeginSeekH
#include "icrsint.h"

// This Class extracts only EmployeeId,FirstName and LastName
// from employees table
class CEmployeeRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CEmployeeRs)

 // Column hiredate is the 1st field in the table.
 ADO_VARIABLE_LENGTH_ENTRY2(1, adInteger,m_ie_empid,
 sizeof(m_ie_empid), le_empidStatus, FALSE)

 // Column LastName is the 2nd field in the table.
 ADO_VARIABLE_LENGTH_ENTRY2(2, adVarChar, m_sze_lname,
 sizeof(m_sze_lname), le_lnameStatus, FALSE)

 // Column FirstName is the 3rd field in the table.
 ADO_VARIABLE_LENGTH_ENTRY2(2, adVarChar, m_sze_fname,
 sizeof(m_sze_fname), le_fnameStatus, FALSE)
END_ADO_BINDING()

public:
 INT m_ie_empid;
 ULONG le_empidStatus;
 CHAR m_sze_fname[11];
 ULONG le_fnameStatus;
 CHAR m_sze_lname[21];
 ULONG le_lnameStatus;
};
// EndSeekH


DependencyObjects Object (Access)

 Copy code hover
[image]

DependencyObjects Object (Access)
See also Send feedback

Published: July 16, 2012

Represents the collection of AccessObject objects that a DependencyInfo object contains.

Remarks

To return a DependencyObjects collection, use the Dependants or Dependencies property of the DependencyInfo object.

To return a single AccessObject object, use the Item method of the DependencyObjects collection.

See also

Concepts

Access Object Model Reference

Other resources

DependencyObjects Object Members


ImportExportSpecification Members (Access)

 Copy code hover
[image]

ImportExportSpecification Members (Access)
Send feedback

Published: July 16, 2012

Represents a saved import or export operation.

Methods

Name | Description
Delete | Deletes the specified ImportExportSpecification object from the ImportExportSpecifications collection.
Execute | Executes the specfied import or export specification.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Description | Gets or sets a String that describes the specified ImportExportSpecification object. Read/write.
Name | Gets or sets the name of the specified ImportExportSpecification object. Read/write String.
Parent | Returns the parent object for the specified object. Read-only Object.
XML | Gets or sets the Extensible Markup Language (XML) string that defines an ImportExportSpecification object. Read/write String.


Rectangle.HorizontalAnchor Property (Access)

 Copy code hover
[image]

Rectangle.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the rectangle is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .HorizontalAnchor

expression A variable that represents a Rectangle object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


Internet is too slow. (Error 3650)

 Copy code hover
[image]

Internet is too slow. (Error 3650)
Send feedback

There has been a failure due to Internet transmission speed.


How to: Add "(All)" to a Combo Box or List Box

 Copy code hover
[image]

How to: Add "(All)" to a Combo Box or List Box
Send feedback

When you use a list box or combo box to enter selection criteria, you might want to be able to specify all records. The AddAllToList procedure illustrates how to add an (All) entry at the top of a combo box.

To utilize the AddAllToList procedure, you must set the RowSourceType property of the combo box or list box to AddAllToList.

You can specify a different item than (All) to add to the list by setting the Tag property of the combo box or list box. For example, you can add <None> to the top of the list by setting the value of the Tag property to 1;<None>.

VBA Copy code Copy code
Function AddAllToList(ctl As Control, lngID As Long, lngRow As Long, _
lngCol As Long, intCode As Integer) As Variant

Static dbs As Database, rst As Recordset
Static lngDisplayID As Long
Static intDisplayCol As Integer
Static strDisplayText As String
Dim intSemiColon As Integer

On Error GoTo Err_AddAllToList
Select Case intCode
Case acLBInitialize
' See if function is already in use.
If lngDisplayID <> 0 Then
MsgBox "AddAllToList is already in use by another control!"
AddAllToList = False

Exit Function
End If

' Parse the display column and display text from Tag property.
intDisplayCol = 1
strDisplayText = "(All)"
If ctl.Tag <> "" Then
intSemiColon = InStr(ctl.Tag, ";")
If intSemiColon = 0 Then
intDisplayCol = Val(ctl.Tag)
Else
intDisplayCol = Val(Left(ctl.Tag, intSemiColon - 1))
strDisplayText = Mid(ctl.Tag, intSemiColon + 1)

End If
End If

' Open the recordset defined in the RowSource property.
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(ctl.RowSource, dbOpenSnapshot)

' Record and return the lngID for this function.
lngDisplayID = Timer
AddAllToList = lngDisplayID

Case acLBOpen
AddAllToList = lngDisplayID

Case acLBGetRowCount
' Return number of rows in recordset.
On Error Resume Next

rst.MoveLast
AddAllToList = rst.RecordCount + 1

Case acLBGetColumnCount
' Return number of fields (columns) in recordset.
AddAllToList = rst.Fields.Count

Case acLBGetColumnWidth
AddAllToList = -1

Case acLBGetValue
If lngRow = 0 Then
If lngCol = intDisplayCol - 1 Then
AddAllToList = strDisplayText
Else
AddAllToList = Null
End If
Else

rst.MoveFirst
rst.Move lngRow - 1
AddAllToList = rst(lngCol)
End If
Case acLBEnd
lngDisplayID = 0
rst.Close
End Select

Bye_AddAllToList:
Exit Function

Err_AddAllToList:
MsgBox Err.Description, vbOKOnly + vbCritical, "AddAllToList"
AddAllToList = False
Resume Bye_AddAllToList
End Function


ToggleButton.Glow Property (Access)

 Copy code hover
[image]

ToggleButton.Glow Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the Glow effect applied to the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .Glow

expression A variable that represents a ToggleButton object.

Remarks

The Glow property contains a numeric expression that represents the glow effect applied to the specified object. The default value of the Glow property is 0, which does not apply a glow effect. The values are listed in the following table.

Value | Effect
0 | None
1 | Blue, 5 pt glow, Accent color 1
2 | Red, 5 pt glow, Accent color 2
3 | Olive Green, 5 pt glow, Accent color 3
4 | Purple, 5 pt glow, Accent color 4
5 | Aqua, 5 pt glow, Accent color 5
6 | Orange, 5 pt glow, Accent color 6
7 | Blue, 8 pt glow, Accent color 1
8 | Red, 8 pt glow, Accent color 2
9 | Olive Green, 8 pt glow, Accent color 3
10 | Purple, 8 pt glow, Accent color 4
11 | Aqua, 8 pt glow, Accent color 5
12 | Orange, 8 pt glow, Accent color 6
13 | Blue, 11 pt glow, Accent color 1
14 | Red, 11 pt glow, Accent color 2
15 | Olive Green, 11 pt glow, Accent color 3
16 | Purple, 11 pt glow, Accent color 4
17 | Aqua, 11 pt glow, Accent color 5
18 | Orange, 11 pt glow, Accent color 6
19 | Blue, 18 pt glow, Accent color 1
20 | Red, 18 pt glow, Accent color 2
21 | Olive Green, 18 pt glow, Accent color 3
22 | Purple, 18 pt glow, Accent color 4
23 | Aqua, 18 pt glow, Accent color 5
24 | Orange, 18 pt glow, Accent color 6

To see the available glow effects and apply a glow through the user interface, first open the form or report in Layout view or Design view by right-clicking the form or report in the Navigation Pane, and then clicking the view you want. Then, click the object to which you want to apply a glow effect. Next, on the Format tab, in the Control Formatting group, click Shape Effects, then click Glow and choose a glow effect. Notice that the glow effects are indexed from left to right, and then top to bottom. So the first item, under No Glow, has the value 0. Then, under Glow, the first row contains glow effects with values from 1 to 6. The second row from 7 to 12, the third row from 13 to 18, and the fourth row from 19 to 24 .

This property is not surfaced in the property sheet.

Example

The following code example sets the glow effect to Aqua, 11 pt glow, Accent color 5.

VBA Copy code Copy code
Me.ctl.Glow = 17

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


BoundObjectFrame.TabIndex Property (Access)

 Copy code hover
[image]

BoundObjectFrame.TabIndex Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TabIndex property to specify a control's place in the tab order on a form or report. Read/write Integer.

Syntax

expression .TabIndex

expression A variable that represents a BoundObjectFrame object.

Remarks

You can set the TabIndex property to an integer representing the position of the control within the tab order of the form. Valid settings are 0 for the first tab position, up to the total number of controls minus 1 for the last tab position. For example, if a form has three controls that each have a TabIndex property, valid TabIndex property settings are 0, 1, and 2.

Setting the TabIndex property to an integer less than 0 produces an error.

By default, Microsoft Access assigns a tab order to controls in the order that you create them on a form. Each new control is placed last in the tab order. If you change the setting of a control's TabIndex property to adjust the tab order, Microsoft Access automatically renumbers the TabIndex property setting of other controls to reflect insertions and deletions.

In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the TAB key.

Changing the tab order of other controls on the form doesn't affect what happens when you press a control's access key. For example, if you've created an access key for the label of a text box, the focus will move to the text box whenever you press the label's access key — even if you change the TabIndex property setting for the text box.

If you press an access key for a control such as a label that doesn't have a TabIndex property (and thus isn't in the tab order), the focus moves to the next control in the tab order that can receive the focus.

Example

The following example reverses the tab order of a command button and a text box. Because TextBox1 was created first, it has a TabIndex property setting of 0 and Command1 has a setting of 1.

VBA Copy code Copy code
Sub Form_Click()
 Me!Command1.TabIndex = 0
 Me!TextBox1.TabIndex = 1
End Sub

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


ObjectFrame.ColumnHeads Property (Access)

 Copy code hover
[image]

ObjectFrame.ColumnHeads Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnHeads property to display a single row of column headings for list boxes, combo boxes, and OLE objects that accept column headings. You can also use this property to create a label for each entry in a chart control . What is actually displayed as the first-row column heading depends on the object's RowSourceType property setting. Read/write Boolean.

Syntax

expression .ColumnHeads

expression A variable that represents an ObjectFrame object.

Remarks

The ColumnHeads property uses the following settings.

Setting | Visual Basic | Description
Yes | True | Column headings are enabled and either field captions, field names, or the first row of data items are used as column headings or chart labels.
No | False | (Default) Column headings are not enabled.

For table fields , you can set this property on the Lookup tab of the Field Properties section of table Design view for fields with the DisplayControl property set to Combo Box or List Box.

The RowSourceType property specifies whether field names or the first row of data items are used to create column headings. If the RowSourceType property is set to Table/Query, the field names are used as column headings. If the field has a caption, then the caption is displayed. For example, if a list box has three columns (the ColumnCount property is set to 3) and the RowSourceType property is set to Table/Query, the first three field names (or captions) are used as headings.

If the RowSourceType property is set to Value List, the first row of data items entered in the value list (as the setting of the RowSource property) will be column headings. For example, if a list box has three columns and the RowSourceType property is set to Value List, the first three items in the RowSource property setting are used as column headings.

If you can't select the first row of a list box or combo box in Form view, check to see if the ColumnHeads property is set to Yes.

Headings in combo boxes appear only when displaying the list in the control.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Cannot insert data with action query. (Error 3084)

 Copy code hover
[image]

Cannot insert data with action query. (Error 3084)
Send feedback

You tried to run an append query using an action query for the input. Replace the action query with a select query and then try the operation again.


NavigationButton.OnExit Property (Access)

 Copy code hover
[image]

NavigationButton.OnExit Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .

Version Information

Version Added: Access 2010

Syntax

expression .OnExit

expression A variable that represents a NavigationButton object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Exit event occurs just before a control loses the focus to another control on the same form.

The OnExit value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Exit box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Exit box is blank, the property value is an empty string.

Example

The following example associates the Exit event with the macro "Exit_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnExit = "Exit_Macro"

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


ComboBox.SelLength Property (Access)

 Copy code hover
[image]

ComboBox.SelLength Property (Access)
See also Send feedback

Published: July 16, 2012

The SelLength property specifies or determines the number of characters selected in the text box portion of a combo box. Read/write Integer.

Syntax

expression .SelLength

expression A variable that represents a ComboBox object.

Remarks

The SelLength property uses an Integer in the range 0 to the total number of characters in the text box portion of a combo box.

To set or return this property for a control, the control must have the focus. To move the focus to a control, use the SetFocus method.

Setting the SelLength property to a number less than 0 produces a run-time error.

Example

The following example uses two event procedures to search for text specified by a user. The text to search is set in the form's Load event procedure. The Click event procedure for the Find button (which the user clicks to start the search) prompts the user for the text to search for and selects the text in the text box if the search is successful.

VBA Copy code Copy code
Private Sub Form_Load()

 Dim ctlTextToSearch As Control
 Set ctlTextToSearch = Forms!Form1!Textbox1

 ' SetFocus to text box.
 ctlTextToSearch.SetFocus
 ctlTextToSearch.Text = "This company places large orders twice " & _
 "a year for garlic, oregano, chilies and cumin."
 Set ctlTextToSearch = Nothing

End Sub

Public Sub Find_Click()

 Dim strSearch As String
 Dim intWhere As Integer
 Dim ctlTextToSearch As Control

 ' Get search string from user.
 With Me!Textbox1
 strSearch = InputBox("Enter text to find:")

 ' Find string in text.
 intWhere = InStr(.Value, strSearch)
 If intWhere Then
 ' If found.
 .SetFocus
 .SelStart = intWhere - 1
 .SelLength = Len(strSearch)
 Else
 ' Notify user.
 MsgBox "String not found."
 End If
 End With

End Sub

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Connection Object (DAO)

 Copy code hover
[image]

Connection Object (DAO)
Send feedback
Note Note

ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine.

A Connection object represents a connection to an ODBC database (ODBCDirect workspaces only).

Remarks

A Connection is a non-persistent object that represents a connection to a remote database. The Connection object is only available in ODBCDirect workspaces (that is, a Workspace object created with the type option set to dbUseODBC).

Note Note

Code written for earlier versions of DAO can continue to use the Database object for backward compatibility, but if the new features of a Connection are desired, you should revise code to use the Connection object. To help with code conversion, you can obtain a Connection object reference from a Database by reading the Connection property of the Database object. Conversely, you can obtain a Database object reference from the Connection object's Database property.


Property Object Reference (DAO)

 Copy code hover
[image]

Property Object Reference (DAO)
Send feedback

In this section

  • Property Object (DAO)

  • Property Members (DAO)

  • Property Properties (DAO)


The ORDER BY expression

 Copy code hover
[image]

The ORDER BY expression <expression> includes fields that are not selected by the query. Only those fields requested in the first query can be included in an ORDER BY expression. (Error 3351)
Send feedback

In a union query, you have included fields in an ORDER BY expression that are not specified by the query. Only those fields requested in the first query can be included in an ORDER BY expression.


Database.QueryDefs Property (DAO)

 Copy code hover
[image]

Database.QueryDefs Property (DAO)
Send feedback

Returns a QueryDefs collection that contains all of the QueryDef objects of the specified database. Read-only.

Syntax

expression .QueryDefs

expression A variable that represents a Database object.


Resync Method (ADO)

 Copy code hover
[image]

Resync Method (ADO)
Send feedback

Refreshes the data in the current Recordset object, or Fields collection of a Record object, from the underlying database.

Syntax

Recordset.Resync AffectRecords, ResyncValues

Record. Fields.Resync ResyncValues

Parameters

  • AffectRecords

  • Optional. An AffectEnum value that determines how many records the Resync method will affect. The default value is adAffectAll. This value is not available with the Resync method of the Fields collection of a Record object.

  • ResyncValues

  • Optional. A ResyncEnum value that specifies whether underlying values are overwritten. The default value is adResyncAllValues.

Remarks

Recordset

Use the Resync method to resynchronize records in the current Recordset with the underlying database. This is useful if you are using either a static or forward-only cursor, but you want to see any changes in the underlying database.

If you set the CursorLocation property to adUseClient, Resync is only available for non-read-only Recordset objects.

Unlike the Requery method, the Resync method does not re-execute the Recordset object's underlying command. New records in the underlying database will not be visible.

If the attempt to resynchronize fails because of a conflict with the underlying data (for example, a record has been deleted by another user), the provider returns warnings to the Errors collection and a run-time error occurs. Use the Filter property (adFilterConflictingRecords) and the Status property to locate records with conflicts.

If the Unique Table and Resync Command dynamic properties are set, and the Recordset is the result of executing a JOIN operation on multiple tables, then the Resync method will execute the command given in the Resync Command property only on the table named in the Unique Table property.

Fields

Use the Resync method to resynchronize the values of the Fields collection of a Record object with the underlying data source. The Count property is not affected by this method.

If ResyncValues is set to adResyncAllValues (the default value), then the UnderlyingValue, Value, and OriginalValue properties of Field objects in the collection are synchronized. If ResyncValues is set to adResyncUnderlyingValues, only the UnderlyingValue property is synchronized.

The value of the Status property for each Field object at the time of the call also affects the behavior of Resync. For Field objects with Status values of adFieldPendingUnknown or adFieldPendingInsert, Resync has no effect. For Status values of adFieldPendingChange or adFieldPendingDelete, Resync synchronizes data values for fields that still exist at the data source.

Resync will not modify Status values of Field objects unless an error occurs when Resync is called. For example, if the field no longer exists, the provider will return an appropriate Status value for the Field object, such as adFieldDoesNotExist. Returned Status values may be logically combined within the value of the Status property.


Attachment.ControlType Property (Access)

 Copy code hover
[image]

Attachment.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .ControlType

expression A variable that represents an Attachment object.

Remarks

The ControlType property setting is an AcControlType constant that specifies the control type.

Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Workspaces Methods (DAO)

 Copy code hover
[image]

Workspaces Methods (DAO)
Send feedback

In this section

  • Workspaces.Append Method (DAO)

  • Workspaces.Delete Method (DAO)

  • Workspaces.Refresh Method (DAO)


WebBrowserControl.HelpContextId Property (Access)

 Copy code hover
[image]

WebBrowserControl.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .HelpContextId

expression A variable that represents a WebBrowserControl object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


ToggleButton.GridlineWidthTop Property (Access)

 Copy code hover
[image]

ToggleButton.GridlineWidthTop Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the top gridline for the specified toggle button. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineWidthTop

expression A variable that represents a ToggleButton object.

Remarks

The TopGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Form.DisplayOnSharePointSite Property (Access)

 Copy code hover
[image]

Form.DisplayOnSharePointSite Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets whether the specified form can be made available as a view on a Microsoft SharePoint Foundation site. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .DisplayOnSharePointSite

expression A variable that represents a Form object.

Remarks

The DisplayOnSharePointSite property uses the following settings.

Setting | Description
Do Not Display | Do not make the form an available view.
Follow Table Setting | (Default) Make the form available as a view if the form's parent table is configured to be displayed as a view.

See also

Concepts

Form Object

Other resources

Form Object Members


Recordset2.CancelUpdate Method (DAO)

 Copy code hover
[image]

Recordset2.CancelUpdate Method (DAO)
Send feedback

Cancels any pending updates for a Recordset object.

Syntax

expression .CancelUpdate(UpdateType)

expression A variable that represents a Recordset2 object.

Parameters

Name

Required/Optional

Data Type

Description

UpdateType

Optional

Long

Set to one of the UpdateTypeEnum values.

Note Note

The dbUpdateRegular and dbUpdateBatch values are valid only if batch updating is enabled.

Remarks

You can use the CancelUpdate method to cancel any pending updates resulting from an Edit or AddNew operation. For example, if a user invokes the Edit or AddNew method and hasn't yet invoked the Update method, CancelUpdate cancels any changes made after Edit or AddNew was invoked.

Check the EditMode property of the Recordset to determine if there is a pending operation that can be canceled.

Note Note

Using the CancelUpdate method has the same effect as moving to another record without using the Update method, except that the current record doesn't change, and various properties, such as BOF and EOF, aren't updated.

Example

This example shows how the CancelUpdate method is used with the AddNew method.

VBA Copy code Copy code
Sub CancelUpdateX()

   Dim dbsNorthwind As Database
   Dim rstEmployees As Recordset2
   Dim intCommand As Integer

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   Set rstEmployees = dbsNorthwind.OpenRecordset( _
      "Employees", dbOpenDynaset)

   With rstEmployees
      .AddNew
      !FirstName = "Kimberly"
      !LastName = "Bowen"
      intCommand = MsgBox("Add new record for " & _
         !FirstName & " " & !LastName & "?", vbYesNo)
      If intCommand = vbYes Then
         .Update
         MsgBox "Record added."
         ' Delete new record because this is a
         ' demonstration.
         .Bookmark = .LastModified
         .Delete
      Else
         .CancelUpdate
         MsgBox "Record not added."
      End If
   End With

   dbsNorthwind.Close

End Sub

This example shows how the CancelUpdate method is used with the Edit method.

VBA Copy code Copy code
Sub CancelUpdateX2()

   Dim dbsNorthwind As Database
   Dim rstEmployees As Recordset
   Dim strFirst As String
   Dim strLast As String
   Dim intCommand As Integer

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   Set rstEmployees = dbsNorthwind.OpenRecordset( _
      "Employees", dbOpenDynaset)

   With rstEmployees
      strFirst = !FirstName
      strLast = !LastName
      .Edit
      !FirstName = "Cora"
      !LastName = "Edmonds"
      intCommand = MsgBox("Replace current name with " & _
         !FirstName & " " & !LastName & "?", vbYesNo)
      If intCommand = vbYes Then
         .Update
         MsgBox "Record modified."
         ' Restore data because this is a demonstration.
         .Bookmark = .LastModified
         .Edit
         !FirstName = strFirst
         !LastName = strLast
         .Update
      Else
         .CancelUpdate
         MsgBox "Record not modified."
      End If
      .Close
   End With

   dbsNorthwind.Close

End Sub


ListBox.ListItemsEditForm Property (Access)

 Copy code hover
[image]

ListBox.ListItemsEditForm Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the name of the form that is displayed when the user clicks Edit List Items. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .ListItemsEditForm

expression A variable that represents a ListBox object.

Remarks

The AllowValueEditLists property determines whether the Edit List Items command is available when the user right-clicks a list box that's bound to a Lookup field.

If the Lookup field is bound to a table or query, then the form specified by the ListItemsEditForm property is displayed when the user clicks Edit List Items. The user can use the form to add, delete, or edit the items to be displayed in the list box.

The ListItemsEditForm property is not available for list boxes on a report.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Too many crosstab column headers

 Copy code hover
[image]

Too many crosstab column headers <value>. (Error 3205)
Send feedback

You executed an SQL statement that tried to create too many columns. The specified value is the column that produced this error.

You can reduce the number of columns by adding additional conditions to the WHERE clause or, if there is no WHERE clause, add one.


Setting References

 Copy code hover
[image]

Setting References
Send feedback

In this section

  • Set References to Type Libraries

  • Set a Reference to a Visual Basic Project in Another Microsoft Access Database or Project


Page.Parent Property (Access)

 Copy code hover
[image]

Page.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a Page object.

See also

Concepts

Page Object

Other resources

Page Object Members


Internet login failure. (Error 3652)

 Copy code hover
[image]

Internet login failure. (Error 3652)
Send feedback

The server did not recognize the login information you entered.


BOF, EOF Properties (ADO)

 Copy code hover
[image]

BOF, EOF Properties (ADO)
Send feedback

  • BOF — Indicates that the current record position is before the first record in a Recordset object.

  • EOF — Indicates that the current record position is after the last record in a Recordset object.

Return Value

The BOF and EOF properties return Boolean values.

Remarks

Use the BOF and EOF properties to determine whether a Recordset object contains records or whether you've gone beyond the limits of a Recordset object when you move from record to record.

The BOF property returns True (-1) if the current record position is before the first record and False (0) if the current record position is on or after the first record.

The EOF property returns True if the current record position is after the last record and False if the current record position is on or before the last record.

If either the BOF or EOF property is True, there is no current record.

If you open a Recordset object containing no records, the BOF and EOF properties are set to True (see the RecordCount property for more information about this state of a Recordset). When you open a Recordset object that contains at least one record, the first record is the current record and the BOF and EOF properties are False.

If you delete the last remaining record in the Recordset object, the BOF and EOF properties may remain False until you attempt to reposition the current record.

This table shows which Move methods are allowed with different combinations of the BOF and EOF properties.

 | MoveFirst, MoveLast | MovePrevious, Move < 0 | Move 0 | MoveNext, Move > 0
BOF=True, EOF=False | Allowed | Error | Error | Allowed
BOF=False, EOF=True | Allowed | Allowed | Error | Error
Both True | Error | Error | Error | Error
Both False | Allowed | Allowed | Allowed | Allowed

Allowing a Move method doesn't guarantee that the method will successfully locate a record; it only means that calling the specified Move method won't generate an error.

The following table shows what happens to the BOF and EOF property settings when you call various Move methods but are unable to successfully locate a record.

 | BOF | EOF
MoveFirst, MoveLast | Set to True | Set to True
Move 0 | No change | No change
MovePrevious, Move < 0 | Set to True | No change
MoveNext, Move > 0 | No change | Set to True


Section.OnClick Property (Access)

 Copy code hover
[image]

Section.OnClick Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Click box in the Properties window. Read/write String.

Syntax

expression .OnClick

expression A variable that represents a Section object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Click event occurs when a user presses and releases the left mouse button over an object.

The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Click box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Click box is blank, the property value is an empty string.

Example

The following example associates the Click event with the "OK_Click" event procedure for the button named "OK" on the "Order Entry" form, if there is currently no association.

VBA Copy code Copy code
With Forms("Order Entry").Controls("OK")
 If .OnClick = "" Then
 .OnClick = "[Event Procedure]"
 End If
End With

See also

Concepts

Section Object

Other resources

Section Object Members


ComplexType.Fields Property (DAO)

 Copy code hover
[image]

ComplexType.Fields Property (DAO)
Send feedback

Returns a Fields collection that represents all stored Field objects for the specified object. Read-only.

Syntax

expression .Fields

expression A variable that represents a ComplexType object.


SubForm.Exit Event (Access)

 Copy code hover
[image]

SubForm.Exit Event (Access)
See also Send feedback

Published: July 16, 2012

The Exit event occurs just before a control loses the focus to another control on the same form or report.

Syntax

expression .Exit(Cancel)

expression A variable that represents a SubForm object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | Set to True to cancel the event.

Remarks

This event does not apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

To run a macro or event procedure when this event occurs, set the OnExit property to the name of the macro or to [Event Procedure].

Because the Enter event occurs before the focus moves to a particular control, you can use an Enter macro or event procedure to display instructions; for example, you could use a macro or event procedure to display a small form or message box identifying the type of data the control typically contains, or giving instructions on how to use the control.

The Exit event occurs before the LostFocus event.

Unlike the LostFocus event, the Exit event does not occur when a form loses the focus. For example, suppose you select a check box on a form, and then click a report. The Enter and GotFocus events occur when you select the check box. Only the LostFocus event occurs when you click the report. The Exit event doesn't occur (because the focus is moving to a different window). If you select the check box on the form again to bring it to the foreground, the GotFocus event occurs, but not the Enter event (because the control had the focus when the form was last active). The Exit event occurs only when you click another control on the form.

If you move the focus to a control on a form, and that control doesn't have the focus on that form, the Exit and LostFocus events for the control that does have the focus on the form occur before the Enter and GotFocus events for the control you moved to.

If you use the mouse to move the focus from a control on a main form to a control on a subform of that form (a control that doesn't already have the focus on the subform), the following events occur:

Exit (for the control on the main form)

ß

LostFocus (for the control on the main form)

ß

Enter (for the subform control)

ß

Exit (for the control on the subform that had the focus)

ß

LostFocus (for the control on the subform that had the focus)

ß

Enter (for the control on the subform that the focus moved to)

ß

GotFocus (for the control on the subform that the focus moved to)

If the control you move to on the subform previously had the focus, neither its Enter event nor its GotFocus event occurs, but the Enter event for the subform control does occur. If you move the focus from a control on a subform to a control on the main form, the Exit and LostFocus events for the control on the subform don't occur, just the Exit event for the subform control and the Enter and GotFocus events for the control on the main form.

Note Note

You often use the mouse or a key such as TAB to move the focus to another control. This causes mouse or keyboard events to occur in addition to the events discussed in this topic.

Example

In the following example, two event procedures are attached to the LastName text box. The Enter event procedure displays a message specifying what type of data the user can enter in the text box. The Exit event procedure displays a dialog box asking the user if changes should be saved before the focus moves to another control. If the user clicks the Cancel button, the Cancel argument is set to True (-1), which moves the focus to the text box without saving changes. If the user chooses the OK button, the changes are saved, and the focus moves to another control.

To try the example, add the following event procedure to a form that contains a text box named LastName.

VBA Copy code Copy code
Private Sub LastName_Enter()
 MsgBox "Enter your last name."
End Sub

Private Sub LastName_Exit(Cancel As Integer)
 Dim strMsg As String

 strMsg = "You entered '" & Me!LastName _
 & "' as your last name." & _
 vbCrLf & "Is this correct?"
 If MsgBox(strMsg, vbYesNo) = vbNo Then
 Cancel = True ' Cancel exit.
 Else
 Exit Sub ' Save changes and exit.
 End If
End Sub

See also

Concepts

SubForm Object

Other resources

SubForm Object Members


Properties Members (Access)

 Copy code hover
[image]

Properties Members (Access)
Send feedback

Published: July 16, 2012

The Properties collection contains all of the built-in properties in an instance of an open form, report, or control. These properties uniquely characterize that instance of the object.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | Returns the number of objects in the specified collection. Read-only.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Object.
Parent | Returns the parent object for the specified object. Read-only.


TableDefs.Append Method (DAO)

 Copy code hover
[image]

TableDefs.Append Method (DAO)
Send feedback

Adds a new TableDef to the TableDefs collection.

Syntax

expression .Append(Object)

expression A variable that represents a TableDefs object.

Parameters

Name | Required/Optional | Data Type | Description
Object | Required | Object | An object variable that represents the field being appended to the collection.

Remarks

The appended object becomes a persistent object, stored on disk, until you delete it by using the Delete method.

The addition of a new object occurs immediately, but you should use the Refresh method on any other collections that may be affected by changes to the database structure.

If the object you're appending isn't complete (such as when you haven't appended any Field objects to a Fields collection of an Index object before it's appended to an Indexes collection) or if the properties set in one or more subordinate objects are incorrect, using the Append method causes an error. For example, if you haven't specified a field type and then try to append the Field object to the Fields collection in a TableDef object, using the Append method triggers a run-time error.


TextBox.FontItalic Property (Access)

 Copy code hover
[image]

TextBox.FontItalic Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontItalic property to specify whether text is italic in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontItalic

expression A variable that represents a TextBox object.

Remarks

The FontItalic property uses the following settings.

Setting | Description
True | The text is italic.
False | (Default) The text isn't italic.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ObjectFrame.SizeToFit Method (Access)

 Copy code hover
[image]

ObjectFrame.SizeToFit Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeToFit method to size a control so it fits the text or image that it contains.

Syntax

expression .SizeToFit

expression A variable that represents an ObjectFrame object.

Remarks

For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

You can apply the SizeToFit method to controls only in form Design view or report Design view.

The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

Note Note

Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

Example

The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

VBA Copy code Copy code
Sub SizeNewControl()
 Dim frm As Form, ctl As Control

 ' Create new form.
 Set frm = CreateForm
 ' Create new command button.
 Set ctl = CreateControl(frm.Name, _
 acCommandButton, , , , 500, 500)
 ' Restore form.
 DoCmd.Restore
 ' Set control's Caption property.
 ctl.Caption = "Extremely Long Control Caption"
 ' Size control to fit caption.
 ctl.SizeToFit
End Sub

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Database.CreateProperty Method (DAO)

 Copy code hover
[image]

Database.CreateProperty Method (DAO)
Send feedback

Creates a new user-defined Property object (Microsoft Access workspaces only). .

Syntax

expression .CreateProperty(Name, Type, Value, DDL)

expression A variable that represents a Database object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Optional | Variant | A String that uniquely names the new Property object. See the Name property for details on valid Property names.
Type | Optional | Variant | A constant that defines the data type of the new Property object. See the Type property for valid data types.
Value | Optional | Variant | A Variant containing the initial property value. See the Value property for details.
DDL | Optional | Variant | A Variant (Boolean subtype) that indicates whether or not the Property is a DDL object. The default is False. If DDL is True, users can't change or delete this Property object unless they have dbSecWriteDef permission.

Return Value

Property

Remarks

You can create a user-defined Property object only in the Properties collection of an object that is persistent.

If you omit one or more of the optional parts when you use CreateProperty, you can use an appropriate assignment statement to set or reset the corresponding property before you append the new object to a collection. After you append the object, you can alter some but not all of its property settings. See the Name, Type, and Value property topics for more details.

If name refers to an object that is already a member of the collection, a run-time error occurs when you use the Append method.

To remove a user-defined Property object from the collection, use the Delete method on the Properties collection. You can't delete built-in properties.

Note Note

If you omit the DDL argument, it defaults to False (non-DDL). Because no corresponding DDL property is exposed, you must delete and re-create a Property object you want to change from DDL to non-DDL.

Example

This example tries to set the value of a user-defined property. If the property doesn't exist, it uses the CreateProperty method to create and set the value of the new property. The SetProperty procedure is required for this procedure to run.

VBA Copy code Copy code
Sub CreatePropertyX()

   Dim dbsNorthwind As Database
   Dim prpLoop As Property

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   ' Set the Archive property to True.
   SetProperty dbsNorthwind, "Archive", True

   With dbsNorthwind
      Debug.Print "Properties of " & .Name

      ' Enumerate Properties collection of the Northwind
      ' database.
      For Each prpLoop In .Properties
         If prpLoop <> "" Then Debug.Print "  " & _
            prpLoop.Name & " = " & prpLoop
      Next prpLoop

      ' Delete the new property since this is a
      ' demonstration.
      .Properties.Delete "Archive"

      .Close
   End With

End Sub

Sub SetProperty(dbsTemp As Database, strName As String, _
   booTemp As Boolean)

   Dim prpNew As Property
   Dim errLoop As Error

   ' Attempt to set the specified property.
   On Error GoTo Err_Property
   dbsTemp.Properties("strName") = booTemp
   On Error GoTo 0

   Exit Sub

Err_Property:

   ' Error 3270 means that the property was not found.
   If DBEngine.Errors(0).Number = 3270 Then
      ' Create property, set its value, and append it to the
      ' Properties collection.
      Set prpNew = dbsTemp.CreateProperty(strName, _
         dbBoolean, booTemp)
      dbsTemp.Properties.Append prpNew
      Resume Next
   Else
      ' If different error has occurred, display message.
      For Each errLoop In DBEngine.Errors
         MsgBox "Error number: " & errLoop.Number & vbCr & _
            errLoop.Description
      Next errLoop
      End
   End If

End Sub


Anticipating Errors

 Copy code hover
[image]

Anticipating Errors
Send feedback

Error prevention is at least as important as error handling. This final section contains a short list of precautions your application can take to help make errors less likely to occur.

Check the state of objects by checking the value in the State property before trying to perform an operation using those objects. For example, if your application uses a global Connection, check its State property to see if it is already open before calling the Open method.

  • Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, the provider, ADO, or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty.

Check the data before you try to write any data to the data store. The easiest way to do so is to handle the WillMove event or the WillUpdateRecordset event. For a more complete discussion of handling ADO events, see Chapter 7: Handling ADO Events.

Make sure that Recordset objects are not beyond the boundaries of the Recordset before attempting to move the record pointer. If you try to MoveNext when EOF is True or MovePrev when BOF is True, an error will occur. If you perform any of the Move methods when both EOF and BOF are True, an error will be generated.

Errors also will occur if you try to perform operations such as Seek and Find on an empty Recordset.


Connection Object Reference (DAO)

 Copy code hover
[image]

Connection Object Reference (DAO)
Send feedback

In this section

  • Connection Object (DAO)

  • Connection Members (DAO)

  • Connection Properties (DAO)

  • Connection Methods (DAO)


Form.Query Event (Access)

 Copy code hover
[image]

Form.Query Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs whenever the specified PivotTable view query becomes necessary. The query may not occur immediately; it may be delayed until the new data is displayed.

Syntax

expression .Query

expression A variable that represents a Form object.

Example

The following example demonstrates the syntax for a subroutine that traps the Query event.

VBA Copy code Copy code
Private Sub Form_Query()
 MsgBox "A query has become necessary."
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


More About Recordset Persistence

 Copy code hover
[image]

More About Recordset Persistence
Send feedback

The ADO Recordset object supports storing a Recordset object's contents in a file using its Save method. The persistently stored file may exist on a local drive, network server, or as a URL on a Web site. Later, the file can be restored with either the Recordset object's Open method or the Connection object's Execute method.

In addition, the GetString method converts a Recordset object to a form in which the columns and rows are delimited with characters you specify.

To persist a Recordset, begin by converting it to a form that can be stored in a file. Recordset objects can be stored in the proprietary Advanced Data TableGram (ADTG) format or the open Extensible Markup Language (XML) format. ADTG examples are shown below. For more information about XML persistence, see Persisting Records in XML format.

Save any pending changes in the persisted file. Doing this allows you to issue a query that returns a Recordset object, edits the Recordset, saves it and the pending changes, later restores the Recordset, and then updates the data source with the saved pending changes.

For information about persistently storing Stream objects, see Streams and Persistence in Chapter 10.

For an example of Recordset persistence, see the XML Recordset Persistence Scenario.

Example

Save a Recordset:

Copy code Copy code

Dim rs as New ADODB.Recordset
rs.Save "c:\yourFile.adtg", adPersistADTG

Open a persisted file with Recordset.Open:

Copy code Copy code

Dim rs as New ADODB.Recordset
rs.Open "c:\yourFile.adtg", "Provider='MSPersist'",,,adCmdFile

Optionally, if the Recordset does not have an active connection, you can accept all the defaults and simply code the following:

Copy code Copy code

Dim rs as New ADODB.Recordset
rs.Open "c:\yourFile.adtg"

Open a persisted file with Connection.Execute:

Copy code Copy code

Dim conn as New ADODB.Connection
Dim rs as ADODB.Recordset
conn.Open "Provider='MSPersist'"
Set rs = conn.execute("c:\yourFile.adtg")

Open a persisted file with RDS.DataControl:

In this case, the Server property is not set.

Copy code Copy code

Dim dc as New RDS.DataControl
dc.Connection = "Provider='MSPersist'"
dc.SQL = "c:\yourFile.adtg"
dc.Refresh


Restrict Data to a Subset of Records

 Copy code hover
[image]

Restrict Data to a Subset of Records
Send feedback

When working with records you will often need to restrict your data to a specific set of records. Some procedures take a criteria argument that enables you to specify what data should be returned. For example, you specify the criteria argument to restrict which records are returned when you use domain aggregate functions . You may also specify criteria when you use the Find method of a Recordset object, set the Filter or ServerFilter property of a form, or construct a SQL Statement. Although each of these operations involves a different syntax, you construct the criteria expression in a similar manner for each.

For example, you can use the DSum function, a domain aggregate function, to find the sum total of all freight costs in the Orders table. You could create a calculated control by entering the following expression in the ControlSource property:

Copy code Copy code
=DSum("[Freight]", "Orders")

If you specify the optional criteria argument, the DSum function will be performed on a subset of domain. For example, you could find the sum total of all freight costs in the Orders table for only those orders being shipped to California:

Copy code Copy code
=DSum("[Freight]", "Orders", "[ShipRegion] = 'CA'")

When you supply a criteria argument, Microsoft Access first evaluates any expressions included in the argument to form a string expression. Then the string expression is passed to the domain function. The string expression is equivalent to an SQL WHERE clause, without the word WHERE.

You can specify numeric, textual, or date/time criteria. No matter what type of criteria you specify, the criteria argument is always converted to a string before being passed to the domain aggregate function. Therefore, you must make certain that after any expressions have been evaluated, all parts of the argument are concatenated into a single string, the whole of which is enclosed in double quotation marks (").

Use caution when constructing criteria to ensure that the string will be properly concatenated.

The following list of topics outlines the different ways in which you can specify criteria:

Numeric Criteria Expressions

Textual Criteria Expressions

Date and Time Criteria Expressions

Change Numeric Criteria from a Control on a Form

Change Textual Criteria from a Control on a Form

Change Date and Time Criteria from a Control on a Form

Multiple Fields in Criteria Expressions


GUID not allowed in Find method criteria expression. (Error 3614)

 Copy code hover
[image]

GUID not allowed in Find method criteria expression. (Error 3614)
Send feedback

The criteria expression in a Find method cannot reference a GUID.


BoundObjectFrame.ControlSource Property (Access)

 Copy code hover
[image]

BoundObjectFrame.ControlSource Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.

Syntax

expression .ControlSource

expression A variable that represents a BoundObjectFrame object.

Remarks

The ControlSource property uses the following settings.

Setting | Description
A field name | The control is bound to a field in a table, query, or SQL statement. Data from the field is displayed in the control. Changes to the data inside the control change the corresponding data in the field. (To make the control read-only, set the Locked property to Yes.) If you click a control bound to a field that has a Hyperlink data type, you jump to the destination specified in the hyperlink address.
An expression | The control displays data generated by an expression. This data can be changed by the user but isn't saved in the database.

For reports, the ControlSource property applies only to report group levels.

Forms and reports act as "windows" into your database. You specify the primary source of data for a form or report by setting its RecordSource property to a table, query, or SQL statement. You can then set the ControlSource property to a field in the source of data or to an expression. If the ControlSource property setting is an expression, the value displayed is read-only and not saved in the database. For example, you can use the following settings.

Sample setting | Description
LastName | For a control, data from the LastName field is displayed in the control. For a report group level, Microsoft Access groups the data on last name.
=Date( ) + 7 | For a control, this expression displays a date seven days from today in the control.
=DatePart("q",ShippedDate) | For a control, this expression displays the quarter of the shipped date. For a report group level, Microsoft Access groups the data on the quarter of the shipped date.

Example

The following example sets the ControlSource property for a text box named AddressPart to a field named City:

VBA Copy code Copy code
Forms!Customers!AddressPart.ControlSource = "City"

The next example sets the ControlSource property for a text box named Expected to the expression =Date() + 7

VBA Copy code Copy code
Me!Expected.ControlSource = "=Date() + 7"

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Form.Module Property (Access)

 Copy code hover
[image]

Form.Module Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Module property to specify a form module. Read-only Module object.

Syntax

expression .Module

expression A variable that represents a Form object.

Remarks

The Module property also returns a reference to a specified Module object.

Use the Module property to access the properties and methods of a Module object associated with a Form or Report object.

The setting of the HasModule property of a form or report determines whether it has an associated module. If the HasModule property is False, the form or report does not have an associated module. When you refer to the Module property of that form or report while in design view, Microsoft Access creates the associated module and sets the HasModule property to True. If you refer to the Module property of a form or report at run-time and the object has its HasModule property set to False, an error will occur.

You could use this property with any of the properties and methods of the module object.

Example

The following example uses the Module property to insert the Beep method in a form's Open event.

VBA Copy code Copy code
Dim strFormOpenCode As String
Dim mdl As Module

Set mdl = Forms!MyForm.Module
strFormOpenCode = "Sub Form_Open(Cancel As Integer)" _
 & vbCrLf & "Beep" & vbCrLf & "End Sub"
 With mdl
 .InsertText strFormOpenCode
 End With

See also

Concepts

Form Object

Other resources

Form Object Members


OptionButton.Visible Property (Access)

 Copy code hover
[image]

OptionButton.Visible Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets whether the object is visible. Read/write Boolean.

Syntax

expression .Visible

expression A variable that represents an OptionButton object.

Remarks

To hide an object when printing, use the DisplayWhen property.

You can use the Visible property to hide a control on a form or report by including the property in a macro or event procedure that runs when the Current event occurs. For example, you can show or hide a congratulatory message next to a salesperson's monthly sales total in a sales report, depending on the sales total.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


EmptyCell.SpecialEffect Property (Access)

 Copy code hover
[image]

EmptyCell.SpecialEffect Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SpecialEffect property to specify whether special formatting will apply to the specified object. Read/write Byte.

Version Information

Version Added: Access 2010

Syntax

expression .SpecialEffect

expression A variable that represents an EmptyCell object.

Remarks

The SpecialEffect property uses the following settings.

Setting | Visual Basic | Description
Flat | 0 | The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised | 1 | The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken | 2 | The object has a shadow on the top and left and a highlight on the bottom and right.
Etched | 3 | The object has a sunken line surrounding the control.
Shadowed | 4 | The object has a shadow below and to the right of the control.
Chiseled | 5 | The object has a sunken line below the control.

The SpecialEffect property setting affects related property settings for the BorderStyle , BorderColor , and BorderWidth properties. For example, if the SpecialEffect property is set to Raised, the settings for the BorderStyle, BorderColor, and BorderWidth properties are ignored. In addition, changing or setting the BorderStyle, BorderColor, and BorderWidth properties may cause Microsoft Access to change the SpecialEffect property setting to Flat.

Note Note

When you set the SpecialEffect property of a text box to Shadowed, the vertical height of the text display area is reduced. You can adjust the Height property of the text box to increase the size of the text display area.

Example

The following example sets the appearance of the text box "OrganizationName1" on the "Mailing List" form to raised.

VBA Copy code Copy code
Forms("Mailing List").Controls("OrganizationName1").SpecialEffect = 1

See also

Concepts

EmptyCell Object

Other resources

EmptyCell Object Members


RunDataMacro Macro Action (Access 2013 custom web app)

 Copy code hover
[image]

RunDataMacro Macro Action (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

You can use the RunDataMacro action to run a standalone data macro.

Setting

The RunDataMacro action has the following argument.

Action argument | Description
Macro Name | The name of the data macro to run.

Remarks

When you select the data macro that you want to run in the macro designer, Access determines if the data macro requires parameters. If the data macro requires parameters, text boxes appear where you can type in the arguments.

When you run a macro that contains the RunDataMacro action and it reaches the RunDataMacro action, Access runs the called data macro. When the called data macro has finished, Access returns to the original macro and runs the next action.


WebBrowserControl.TopPadding Property (Access)

 Copy code hover
[image]

WebBrowserControl.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .TopPadding

expression A variable that represents a WebBrowserControl object.

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Functions (Category List)

 Copy code hover
[image]

Functions (Category List)
Send feedback

The following list contains topics that describe common functions used in Microsoft Access expressions.

ActiveX

CreateObject Function

GetObject Function

Application

Command Function

Shell Function

Arrays

Array Function

Filter Function

Join Function

LBound Function

Split Function

UBound Function

Conversion

Asc Function

CBool Function

CByte Function

CCur Function

CDate Function

CDbl Function

CDec Function

Chr Function

CInt Function

CLng Function

CSng Function

CStr Function

CVar Function

Day Function

EuroConvert Method

FormatCurrency Function

FormatDateTime Function

FormatNumber Function

FormatPercent Function

GUIDFromString Method

Hex Function

Nz Method

Oct Function

Str Function

StringFromGUID Method

Type Conversion Functions

Val Function

Database

CurrentUser Method

DDEInitiate Method

DDERequest Method

Eval Method

HyperlinkPart Method

Partition Function

Date/Time

Date Function

DateAdd Function

DateDiff Function

DatePart Function

DateSerial Function

DateValue Function

Day Function

Hour Function

Minute Function

Month Function

MonthName Function

Now Function

Second Function

Time Function

Timer Function

TimeSerial Function

TimeValue Function

Weekday Function

WeekdayName Function

Year Function

Domain Aggregate

DAvg Function

DCount Method

DFirst Method

DLast Method

DLookup Method

DMax Method

DMin Method

DStDev Method

DStDevP Method

DSum Method

DVar Method

DVarP Method

Error Handling

CVErr Function

Error Function

IsError Function

File Input/Output

EOF Function

FreeFile Function

Input Function

Loc Function

LOF Function

Seek Function

File Management

CurDir Function

Dir Function

FileAttr Function

FileDateTime Function

FileLen Function

GetAttr Function

Financial

DDB Function

FV Function

IPmt Function

IRR Function

MIRR Function

NPer Function

NPV Function

Pmt Function

PPmt Function

PV Function

Rate Function

SLN Function

SYD Function

Inspection

Environ Function

GetAllSettings Function

GetSetting Function

IsArray Function

IsDate Function

IsEmpty Function

IsError Function

IsMissing Function

IsNull Function

IsNumeric Function

IsObject Function

TypeName Function

VarType Function

Math

Abs Function

Atn Function

Cos Function

Exp Function

Fix Function

Int Function

Log Function

Rnd Function

Round Function

Sgn Function

Sin Function

Sqr Function

StDev Function

StDevP Function

Tan Function

Messages

InputBox Function

MsgBox Function

Miscellaneous

CallByName Function

IMEStatus Function

QBColor Function

RGB Function

Spc Function

Tab Function

Program Flow

Choose Function

DoEvents Function

IIf Function

Switch Function

SQL Aggregate

Avg Function

Count Function

Max Function

Min Function

StDev Function

StDevP Function

Sum Function

Var Function

VarP Function

Text

Format Function

HtmlEncode Method

InStr Function

InStrRev Function

LCase Function

Left Function

Len Function

LTrim Function

Mid Function

PlainText Method

Replace Function

Right Function

RTrim Function

Space Function

StrComp Function

StrConv Function

String Function

StrReverse Function

Trim Function

UCase Function


Form.DefaultControl Property (Access)

 Copy code hover
[image]

Form.DefaultControl Property (Access)
See also Send feedback

Published: July 16, 2012

The DefaultControl property returns a Control object with which you can set the default properties for a particular type of control on a particular form. Read-only.

Syntax

expression .DefaultControl(ControlType)

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
ControlType | Required | Long | An AcControlType constant that indicates the type of control for which default property settings are to be set.

Remarks

The DefaultControl property enables you to set a control's default properties from code. Once you have set the default properties for a particular type of control, each subsequently created control of that type will have the same default values.

For example, if you set the FontSize property of the default command button to 12, each new command button will have a font size of 12 points.

Not all of a control's properties are available as default properties. The default properties available for a control depend on the type of control.

The DefaultControl property returns a Control object of the type specified by the controltype argument. This Control object doesn't represent an actual control on a form, but rather a default control that is a template for all subsequently created controls of that type. You set the default control properties for the Control object returned by the DefaultControl property in the same manner that you would set properties for an individual control on a form.

The DefaultControl property can be used only in form Design view or report Design view. If you try to apply this property to a form or report that is not in Design view, a run-time error will result.

If you try to set a property that can't be set as a default property with the DefaultControl property, a run-time error will result. To determine which properties can be default properties, list the Properties collection of the Control object returned by the DefaultControl property.

Example

The following example creates a new form and uses the DefaultControl property to return a Control object representing the default command button. The procedure sets some of the default properties for the command button, then creates a new command button on the form.

VBA Copy code Copy code
Sub SetDefaultProperties()
 Dim frm As Form, ctlDefault As Control, ctlNew As Control

 ' Create new form.
 Set frm = CreateForm
 ' Return Control object representing default command button.
 Set ctlDefault = frm.DefaultControl(acCommandButton)
 ' Set some default properties.
 With ctlDefault
 .FontWeight = 700
 .FontSize = 12
 .Width = 3000
 .Height = 1000
 End With
 ' Create new command button.
 Set ctlNew = CreateControl(frm.Name, acCommandButton, , , , 500, 500)
 ' Set control's caption.
 ctlNew.caption = "New Command Button"
 ' Restore form.
 DoCmd.Restore
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


Report.Width Property (Access)

 Copy code hover
[image]

Report.Width Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the specified object in twips. Read/write Integer.

Syntax

expression .Width

expression A variable that represents a Report object.

Remarks

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormat event property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

See also

Concepts

Report Object

Other resources

Report Object Members


Pages.Add Method (Access)

 Copy code hover
[image]

Pages.Add Method (Access)
See also Send feedback

Published: July 16, 2012

The Add method adds a new Pageobject to the Pages collection of a tab control.

Syntax

expression .Add(Before)

expression A variable that represents a Pages object.

Parameters

Name | Required/Optional | Data Type | Description
Before | Optional | Variant | An Integer that specifies the index of the Page object before which the new Page object should be added. The index of the Page object corresponds to the value of the PageIndex property for that Page object. If you omit this argument, the new Page object is added to the end of the collection.

Return Value

Page

Remarks

The first Page object in the Pages collection corresponds to the leftmost page in the tab control and has an index of 0. The second Page object is immediately to the right of the first page and has an index of 1, and so on for all the Page objects in the tab control.

If you specify 0 for the Before argument, the new Page object is added before the first Page object in the Pages collection. The new Page object then becomes the first Page object in the collection, with an index of 0.

You can add a Page object to the Pages collection of a tab control only when the form is in Design view.

Example

The following example adds a page to a tab control on a form that's in Design view. To try this example, create a new form named Form1 with a tab control named TabCtl0. Paste the following code into a standard module and run it:

VBA Copy code Copy code
Function AddPage() As Boolean
 Dim frm As Form
 Dim tbc As TabControl, pge As Page

 On Error GoTo Error_AddPage
 Set frm = Forms!Form1
 Set tbc = frm!TabCtl0
 tbc.Pages.Add
 AddPage = True

Exit_AddPage:
 Exit Function

Error_AddPage:
 MsgBox Err & ": " & Err.Description
 AddPage = False
 Resume Exit_AddPage
End Function

See also

Concepts

Pages Collection

Other resources

Pages Object Members


QueryDef.DateCreated Property (DAO)

 Copy code hover
[image]

QueryDef.DateCreated Property (DAO)
Send feedback

Returns the date and time that an object was created (Microsoft Access workspaces only). Read-only Variant.

Syntax

expression .DateCreated

expression A variable that represents a QueryDef object.

Remarks

DateCreated and LastUpdated return the date and time that the object was created or last updated. In a multiuser environment, users should get these settings directly from the file server to avoid discrepancies in the DateCreated and LastUpdated property settings.


QueryDef.Name Property (DAO)

 Copy code hover
[image]

QueryDef.Name Property (DAO)
Send feedback

Returns or sets the name of the specified object. Read/write String.

Syntax

expression .Name

expression A variable that represents a QueryDef object.

Remarks

The maximum length for the name of a QueryDef object is 64 characters.


Resync Method Example (VJ++)

 Copy code hover
[image]

Resync Method Example (VJ++)
Send feedback

This example demonstrates using the Resync method to refresh data in a static recordset.

Copy code Copy code

// BeginResyncJ
import java.io.*;
import com.ms.wfc.data.*;

public class ResyncX
{
 // The main entry point of the application.
 public static void main (String[] args)
 {
 ResyncX();
 System.exit(0);
 }
 static void ResyncX()
 {
 // Define ADO Objects.
 Recordset rstTitles = null;

 // Declarations.
 BufferedReader in =
 new BufferedReader(new InputStreamReader(System.in));
 String strCnn = "Provider='sqloledb';Data Source='MySqlServer';" +
 "Initial Catalog='Pubs';Integrated Security='SSPI';";

 try
 {
 // Open recordset for Titles table.
 rstTitles = new Recordset();
 rstTitles.setCursorLocation(AdoEnums.CursorLocation.CLIENT);
 rstTitles.setCursorType(AdoEnums.CursorType.STATIC);
 rstTitles.setLockType(AdoEnums.LockType.BATCHOPTIMISTIC);
 rstTitles.open("Titles", strCnn, AdoEnums.CursorType.STATIC,
 AdoEnums.LockType.BATCHOPTIMISTIC,
 AdoEnums.CommandType.TABLE);

 // Change the type of the first title in the recordset.
 rstTitles.getField("type").setString("database");

 // Display the results of the change.
 System.out.println("\n\n\tBefore resync:\n" + "\tTitle - " +
 rstTitles.getField("title").getString() +
 "\n\tType - " + rstTitles.getField("type").getString());

 // Resync with database and redisplay the results.
 rstTitles.resync();
 System.out.println("\n\n\tAfter resync:\n" + "\tTitle - " +
 rstTitles.getField("title").getString() +
 "\n\tType - " +
 rstTitles.getField("type").getString()+"\n");
 rstTitles.cancelBatch();

 System.out.println("\tPress <Enter> to continue..");
 in.readLine();

 }
 catch(AdoException ae)
 {
 // Notify user of any errors that result from ADO.

 // As passing a recordset, check for null pointer first.
 if(rstTitles != null)
 {
 PrintProviderError(rstTitles.getActiveConnection());
 }
 else
 {
 System.out.println("Exception: " + ae.getMessage());
 }
 }
 // System read requires this catch.
 catch(java.io.IOException je)
 {
 PrintIOError(je);
 }

 finally
 {
 // Cleanup objects before exit.
 if (rstTitles != null)
 if (rstTitles.getState() == 1)
 rstTitles.close();
 }
 }

 // PrintProviderError Function

 static void PrintProviderError( Connection Cnn1 )
 {
 // Print Provider errors from Connection object.
 // ErrItem is an item object in the Connections Errors collection.
 com.ms.wfc.data.Error ErrItem = null;
 long nCount = 0;
 int i = 0;

 nCount = Cnn1.getErrors().getCount();

 // If there are any errors in the collection, print them.
 if( nCount > 0);
 {
 // Collection ranges from 0 to nCount - 1
 for (i = 0; i< nCount; i++)
 {
 ErrItem = Cnn1.getErrors().getItem(i);
 System.out.println("\t Error number: " + ErrItem.getNumber()
 + "\t" + ErrItem.getDescription() );
 }
 }

 }

 // PrintIOError Function

 static void PrintIOError( java.io.IOException je)
 {
 System.out.println("Error \n");
 System.out.println("\tSource = " + je.getClass() + "\n");
 System.out.println("\tDescription = " + je.getMessage() + "\n");
 }
}
// EndResyncJ


AcWebUserGroupsDisplay Enumeration (Access)

 Copy code hover
[image]

AcWebUserGroupsDisplay Enumeration (Access)
Send feedback

Published: July 16, 2012

Specifies the type of information to return about the group membership of the current user of a Web database.

Version Information

Version Added: Access 2010

Name | Value | Description
acWebUserGroupID | 0 | The identifiers of the groups.
acWebUserGroupName | 1 | The names of the groups.


Form.KeyPreview Property (Access)

 Copy code hover
[image]

Form.KeyPreview Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the KeyPreview property to specify whether the form-level keyboard event procedures are invoked before a control's keyboard event procedures. Read/write Boolean.

Syntax

expression .KeyPreview

expression A variable that represents a Form object.

Remarks

The KeyPreview property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The form receives keyboard events first, then the active control receives keyboard events.
No | False | (Default) Only the active control receives keyboard events.

You can set the KeyPreview property in any view

You can use the KeyPreview property to create a keyboard-handling procedure for a form. For example, when an application uses function keys, setting the KeyPreview property to True allows you to process keystrokes at the form level rather than writing code for each control that might receive keystroke events.

To handle keyboard events only at the form level and prevent controls from receiving keyboard events, set the KeyAscii argument to 0 in the form's KeyPress event procedure, and set the KeyCode argument to 0 in the form's KeyDown and KeyUp event procedures.

If a form has no visible or enabled controls, it automatically receives all keyboard events.

Example

In the following example, the KeyPreview property is set to True in the form's Load event procedure. This causes the form to receive keyboard events before they are received by any control. The form KeyDown event then checks the KeyCode argument value to determine if the F2, F3, or F4 keys were pushed.

VBA Copy code Copy code
Private Sub Form_Load()
 Me.KeyPreview = True
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
 Select Case KeyCode
 Case vbKeyF2
 ' Process F2 key events.
 Case vbKeyF3
 ' Process F3 key events.
 Case vbKeyF4
 ' Process F4 key events.
 Case Else
 End Select
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


ListBox.HorizontalAnchor Property (Access)

 Copy code hover
[image]

ListBox.HorizontalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcHorizontalAnchor constant that indicates how the list box is anchored horizontally within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .HorizontalAnchor

expression A variable that represents a ListBox object.

Remarks

The default value is acHorizontalAnchorLeft.

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Cannot repeat table name

 Copy code hover
[image]

Cannot repeat table name <name> in FROM clause. (Error 3074)
Send feedback

You cannot list the table name more than once. Remove the extra occurrences of the table name or use an alias. If you are trying to join a table to itself, use an alias to change the second reference to the table.


Label.ControlType Property (Access)

 Copy code hover
[image]

Label.ControlType Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ControlType property in Visual Basic to determine the type of a control on a form or report. Read/write Byte.

Syntax

expression .ControlType

expression A variable that represents a Label object.

Remarks

The ControlType property setting is an intrinsic constant that specifies the control type.

Constant | Control
acBoundObjectFrame | Bound object frame
acCheckBox | Check box
acComboBox | Combo box
acCommandButton | Command button
acCustomControl | ActiveX (custom) control
acImage | Image
acLabel | Label
acLine | Line
acListBox | List box
acObjectFrame | Unbound object frame or Chart
acOptionButton | Option button
acOptionGroup | Option group
acPage | Page
acPageBreak | Page break
acRectangle | Rectangle
acSubform | Subform/subreport
acTabCtl | Tab
acTextBox | Text box
acToggleButton | Toggle button Toggle button
Note Note

The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

The ControlType property is useful not only for checking for a specific control type in code, but also for changing the type of control to another type. For example, you can change a text box to a combo box by setting the ControlType property for the text box to acComboBox while in form Design view.

You can use the ControlType property to change characteristics of similar controls on a form according to certain conditions. For example, if you don't want users to edit existing data in text boxes, you can set the SpecialEffect property for all text boxes to Flat and set the form's AllowEdits property to No. (The SpecialEffect property doesn't affect whether data can be edited; it's used here to provide a visual cue that the control behavior has changed.)

The ControlType property is also used to specify the type of control to create when you are using the CreateControl method.

Example

The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls' SpecialEffect property is set to Shadowed and the text box controls' SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit variable is toggled to allow editing of the underlying data.

VBA Copy code Copy code
Sub ToggleControl(frm As Form)
 Dim ctl As Control
 Dim intI As Integer, intCanEdit As Integer
 Const conTransparent = 0
 Const conWhite = 16777215
 For Each ctl in frm.Controls
 With ctl
 Select Case .ControlType
 Case acLabel
 If .SpecialEffect = acEffectShadow Then
 .SpecialEffect = acEffectNormal
 .BorderStyle = conTransparent
 intCanEdit = True
 Else
 .SpecialEffect = acEffectShadow
 intCanEdit = False
 End If
 Case acTextBox
 If .SpecialEffect = acEffectNormal Then
 .SpecialEffect = acEffectSunken
 .BackColor = conWhite
 Else
 .SpecialEffect = acEffectNormal
 .BackColor = frm.Detail.BackColor
 End If
 End Select
 End With
 Next ctl
 If intCanEdit = IFalse Then
 With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 Else
 With frm
 .AllowAdditions = True
 .AllowDeletions = True
 .AllowEdits = True
 End With
 End If
End Sub

See also

Concepts

Label Object

Other resources

Label Object Members


ObjectFrame.GridlineTint Property (Access)

 Copy code hover
[image]

ObjectFrame.GridlineTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineTint

expression A variable that represents an ObjectFrame object.

Remarks

The GridlineTint property contains a numeric expression that can be used to lighten the theme color in the GridlineColor property. The default value of the GridlineTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


TableDef.ReplicaFilter Property (DAO)

 Copy code hover
[image]

TableDef.ReplicaFilter Property (DAO)
Send feedback

Sets or returns a value on a TableDef object within a partial replica that indicates which subset of records is replicated to that table from a full replica. (Microsoft Access workspaces only).

Syntax

expression .ReplicaFilter

expression A variable that represents a TableDef object.

Remarks

The setting or return value is a String or Boolean that indicates which subset of records is replicated, as specified in the following table:

Value | Description
A string | A criteria that a record in the partial replica table must satisfy in order to be replicated from the full replica.
True | Replicates all records.
False | (Default) Doesn't replicate any records.

This property is similar to an SQL WHERE clause (without the word WHERE), but you cannot specify subqueries, aggregate functions (such as Count), or user-defined functions within the criteria.

You can only synchronize data between a full replica and a partial replica. You can't synchronize data between two partial replicas. Also, with partial replication you can set restrictions on which records are replicated, but you can't indicate which fields are replicated.

Usually, you reset a replica filter when you want to replicate a different set of records. For example, when a sales representative temporarily takes over another sales representative's region, the database application can temporarily replicate data for both regions and then return to the previous filter. In this scenario, the application resets the ReplicaFilter property and then repopulates the partial replica.

If your application changes replica filters, you should follow these steps:

  1. Use the Synchronize method to synchronize your full replica with the partial replica in which the filters are being changed.

  2. Use the ReplicaFilter property to make the desired changes to the replica filter.

  3. Use the PopulatePartial method to remove all records from the partial replica and transfer all records from the full replica that meet the new replica filter criteria.

To remove a filter, set the ReplicaFilter property to False. If you remove all filters and invoke the PopulatePartial method, no records will appear in any replicated tables in the partial replica.

Note Note

If a replica filter has changed, and the Synchronize method is invoked without first invoking PopulatePartial, a trappable error occurs.

Example

The following example uses the ReplicaFilter property to replicate only customer records from the California region.

VBA Copy code Copy code
Sub ReplicaFilterX()

 ' This example assumes the current open database
 ' is the replica.
 Dim tdfCustomers As TableDef
 Dim strFilter As String
 Dim dbsTemp As Database

 Set dbsTemp = OpenDatabase("Northwind.mdb")
 Set tdfCustomers = dbsTemp.TableDefs("Customers")

 ' Synchronize with full replica
 ' before setting replica filter.
 dbsTemp.Synchronize "C:\SALES\FY96.MDB"

 strFilter = "Region = 'CA'"
 tdfCustomers.ReplicaFilter = strFilter
 dbsTemp.PopulatePartial "C:\SALES\FY96.MDB"

 ' Now remove the replica filter (for example purposes
 ' only).
 tdfCustomers.ReplicaFilter = False
 ' Repopulate the database.
 dbsTemp.PopulatePartial "C:\SALES\DATA96.MDB"

End Sub


AllDatabaseDiagrams Members (Access)

 Copy code hover
[image]

AllDatabaseDiagrams Members (Access)
Send feedback

Published: July 16, 2012

The AllDatabaseDiagrams collection contains an AccessObject for each database diagram in the CurrentData or CodeData object.

Properties

Name | Description
Application | You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only AccessObject.
Parent | Returns the parent object for the specified object. Read-only.


Types of Cursors (ADO)

 Copy code hover
[image]

Types of Cursors (ADO)
Send feedback

In this section

  • Types of Cursors

  • Forward-Only Cursors

  • Dynamic Cursors

  • Static Cursors

  • Keyset Cursors


Record in table

 Copy code hover
[image]

Record in table <name> was deleted by another user. (Error 3329)
Send feedback

The row that you are trying to edit has been deleted by another user. This behavior can be prevented by having all users in the database use pessimistic locking.


Attachment.EventProcPrefix Property (Access)

 Copy code hover
[image]

Attachment.EventProcPrefix Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the prefix portion of an event procedure name. Read/write String.

Version Information

Version Added: Access 2007

Syntax

expression .EventProcPrefix

expression A variable that represents an Attachment object.

Remarks

For example, if you have a command button with an event procedure named Details_Click, the EventProcPrefix property returns the string "Details".

Microsoft Access adds the prefix portion of an event procedure name to the event name with an underscore character (_).

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


ConnectionEvents (Visual C++ Syntax Index with #import)

 Copy code hover
[image]

ConnectionEvents (Visual C++ Syntax Index with #import)
Send feedback

Events

Copy code Copy code

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtinfomessage_HV10294445.xml( struct Error * pError, enum
 EventStatusEnum * adStatus, struct _Connection * pConnection );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtbegintranscomplete_HV10294112.xml( long TransactionLevel,
 struct Error * pError, enum EventStatusEnum * adStatus, struct
 _Connection * pConnection );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtbegintranscomplete_HV10294112.xml( struct Error *
 pError, enum EventStatusEnum * adStatus, struct _Connection *pConnection );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtbegintranscomplete_HV10294112.xml( struct Error *
 pError, enum EventStatusEnum * adStatus, struct _Connection *pConnection );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillexecuteevent_HV10294954.xml( BSTR * Source, enum
 CursorTypeEnum * CursorType,
 enum LockTypeEnum * LockType, long * Options, enum EventStatusEnum *
 adStatus, struct _Command * pCommand, struct _Recordset * pRecordset,
 struct _Connection * pConnection );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtexecutecomplete_HV10294351.xml( long RecordsAffected, struct
 Error * pError, enum EventStatusEnum * adStatus, struct _Command
 * pCommand, struct _Recordset * pRecordset, struct _Connection *pConnection );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtwillconnectevent_HV10294953.xml( BSTR * ConnectionString, BSTR *
 UserID, BSTR * Password, long * Options, enum EventStatusEnum *
 adStatus, struct _Connection * pConnection );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtconnectconnectionevents_HV10294210.xml( struct Error *
 pError, enum EventStatusEnum * adStatus, struct _Connection *pConnection );

HRESULT Invalid DDUE based on source, error:link not allowed in code, link filename:mdevtconnectconnectionevents_HV10294210.xml( enum EventStatusEnum *
 adStatus, struct _Connection * pConnection );


Application.DefaultWorkspaceClone Method (Access)

 Copy code hover
[image]

Application.DefaultWorkspaceClone Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the DefaultWorkspaceClone method to create a new Workspace object without requiring the user to log on again. For example, if you need to conduct two sets of transactions simultaneously in separate workspaces, you can use the DefaultWorkspaceClone method to create a second Workspace object with the same user name and password without prompting the user for this information again.

Syntax

expression .DefaultWorkspaceClone

expression A variable that represents an Application object.

Return Value

Workspace

Remarks

Note Note

In Microsoft Access, the DefaultWorkspaceClone method is included in this version of Microsoft Access only for compatibility with previous versions using Data Access Object (DAO) language.

The DefaultWorkspaceClone method creates a clone of the default Workspace object in Microsoft Access. The properties of the Workspace object clone have settings identical to those of the default Workspace object, except for the Name property setting. For the default Workspace object, the value of the Name property is always #Default Workspace#. For the cloned Workspace object, it is #CloneAccess#.

The UserName property of the default Workspace object indicates the name under which the current user logged on. The Workspace object clone is equivalent to the Workspace object that would be created if the same user logged on again with the same password.

See also

Concepts

Application Object

Other resources

Application Object Members


Form.BeforeRender Property (Access)

 Copy code hover
[image]

Form.BeforeRender Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the BeforeRender event occurs. Read/write.

Syntax

expression .BeforeRender

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the BeforeRender event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).BeforeRender = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


ObjectFrame.LinkChildFields Property (Access)

 Copy code hover
[image]

ObjectFrame.LinkChildFields Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the LinkChildFields property (along with the LinkMasterFields property) together to specify how Microsoft Access links records in a form or report to records in a subform, subreport, or embedded object, such as a chart. If these properties are set, Microsoft Access automatically updates the related record in the subform when you change to a new record in a main form. Read/write String.

Syntax

expression .LinkChildFields

expression A variable that represents an ObjectFrame object.

Remarks

You can set the LinkChildFields and LinkMasterFields properties for the subform, subreport, or embedded object as follows:

  • The LinkChildFields property. Enter the name of one or more linking fields in the subform, subreport, or embedded object.

  • The LinkMasterFields property. Enter the name of one or more linking fields or controls in the main form or report.

You can use the Subform/Subreport Field Linker to set these properties by clicking the Build button to the right of the property box in the property sheet.

The properties can only be set in Design view or during the Open event of a form or report.

The fields or controls you use to set these properties don't need to have the same names, but they must contain the same kind of data and have the same or a compatible data type and field size. For example, an AutoNumber field is compatible with a Number field if the FieldSize property for the Number field is set to Long Integer.

You can use the name of a control (including the name of a calculated control) to set the LinkMasterFields property, but you can't use the name of a control to set the LinkChildFields property. If you want to use a calculated value as the link for a subform, subreport, or embedded object, define a calculated field in the child object's underlying query and set the LinkChildFields property to the field.

When you specify more than one field or control name for these property settings, you must enter the same number of fields or controls for each property setting and separate the names with a semicolon (;).

When you create a subform or subreport by dragging a form or report from the Database window onto another form or report or by using the Form Wizard, Microsoft Access automatically sets the LinkChildFields and LinkMasterFields properties under the following conditions:

  • Both the main form or report and the child object are based on tables, and a relationship between those tables has been defined with the Relationships command. Microsoft Access uses the fields that relate the two tables as the linking fields.

  • The main form or report is based on a table with a primary key, and the subform or subreport is based on a table or query that contains a field with the same name and the same or a compatible data type as the primary key. Microsoft Access uses the primary key from the main object's underlying table and the identically named field from the child object's underlying table or query as the linking fields.

Note Note

The linking fields don't have to be included in the main object or in the child object. As long as they are contained in the objects' underlying tables or queries, you can use the fields to link the objects. When you use a wizard, Microsoft Access automatically includes the linking fields.

See also

Concepts

ObjectFrame Object

Other resources

ObjectFrame Object Members


Field2.SourceField Property (DAO)

 Copy code hover
[image]

Field2.SourceField Property (DAO)
Send feedback

Returns a value that indicates the name of the field that is the original source of the data for a Field2 object. Read-only String.

Syntax

expression .SourceField

expression A variable that represents a Field2 object.

Remarks

For a Field2 object, use of the SourceField and SourceTable properties depends on the object that contains the Fields collection that the Field2 object is appended to, as shown in the following table.

Object appended to | Usage
Index | Not supported
QueryDef | Read-only
Recordset | Read-only
Relation | Not supported
TableDef | Read-only

These properties indicate the original field and table names associated with a Field2 object. For example, you could use these properties to determine the original source of the data in a query field whose name is unrelated to the name of the field in the underlying table.


Form.OnError Property (Access)

 Copy code hover
[image]

Form.OnError Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the OnError box in the Properties window of a form or report. Read/write String.

Syntax

expression .OnError

expression A variable that represents a Form object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Error event occurs when a run-time error is produced in Microsoft Access when a form or report has the focus. This includes Microsoft Jet database engine errors, but not run-time errors in Visual Basic.

The OnError value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the OnError box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the OnError box is blank, the property value is an empty string.

Example

The following example associates the Error event with the macro "Error_Handler_Macro" for the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").OnError = "Error_Handler_Macro"

See also

Concepts

Form Object

Other resources

Form Object Members


Image.InSelection Property (Access)

 Copy code hover
[image]

Image.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents an Image object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

Image Object

Other resources

Image Object Members


BoundObjectFrame.BorderTint Property (Access)

 Copy code hover
[image]

BoundObjectFrame.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderTint

expression A variable that represents a BoundObjectFrame object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens the BorderColor property by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


UPDATEIDENTITY (Microsoft Access SQL reserved word)

 Copy code hover
[image]

UPDATEIDENTITY (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The UPDATEIDENTITY keyword is used in these contexts:

GRANT Statement

REVOKE Statement


GetString Method (ADO)

 Copy code hover
[image]

GetString Method (ADO)
Send feedback

Returns the Recordset as a string.

Syntax

Variant = recordset.GetString(StringFormat, NumRows, ColumnDelimiter, RowDelimiter, NullExpr)

Return Value

Returns the Recordset as a string-valued Variant (BSTR).

Parameters

  • StringFormat

  • A StringFormatEnum value that specifies how the Recordset should be converted to a string. The RowDelimiter, ColumnDelimiter, and NullExpr parameters are used only with a StringFormat of adClipString.

  • NumRows

  • Optional. The number of rows to be converted in the Recordset. If NumRows is not specified, or if it is greater than the total number of rows in the Recordset, then all the rows in the Recordset are converted.

  • ColumnDelimiter

  • Optional. A delimiter used between columns, if specified, otherwise the TAB character.

  • RowDelimiter

  • Optional. A delimiter used between rows, if specified, otherwise the CARRIAGE RETURN character.

  • NullExpr

  • Optional. An expression used in place of a null value, if specified, otherwise the empty string.

Remarks

Row data, but no schema data, is saved to the string. Therefore, a Recordset cannot be reopened using this string.

This method is equivalent to the RDO GetClipString method.


ADOX Code Examples in Microsoft Visual Basic Topics

 Copy code hover
[image]

ADOX Code Examples in Microsoft Visual Basic Topics
Send feedback

In this section

  • ADOX Code Examples in Microsoft Visual Basic

  • Attributes Property Example (VB)

  • Catalog ActiveConnection Property Example (VB)

  • Clustered Property Example (VB)

  • Columns and Tables Append Methods, Name Property Example (VB)

  • Command and CommandText Properties Example (VB)

  • Connection Close Method, Table Type Property Example (VB)

  • Create Method Example (VB)

  • DateCreated and DateModified Properties Example (VB)

  • DefinedSize Property Example (VB)

  • DeleteRule Property Example (VB)

  • GetObjectOwner and SetObjectOwner Methods Example (VB)

  • GetPermissions and SetPermissions Methods Example (VB)

  • Groups and Users Append, ChangePassword Methods Example (VB)

  • Indexes Append Method Example (VB)

  • IndexNulls Property Example (VB)

  • Keys Append Method, Key Type, RelatedColumn, RelatedTable and UpdateRule Properties Example (VB)

  • NumericScale and Precision Properties Example (VB)

  • Parameters Collection, Command Property Example (VB)

  • ParentCatalog Property Example (VB)

  • PrimaryKey and Unique Properties Example (VB)

  • Procedures Append Method Example (VB)

  • Procedures Delete Method Example (VB)

  • Procedures Refresh Method Example (VB)

  • SortOrder Property Example (VB)

  • Views and Fields Collections Example (VB)

  • Views Append Method Example (VB)

  • Views Collection, CommandText Property Example (VB)

  • Views Delete Method Example (VB)

  • Views Refresh Method Example (VB)


NavigationButton.PressedShade Property (Access)

 Copy code hover
[image]

NavigationButton.PressedShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade that is applied to the theme color in the PressedColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .PressedShade

expression A variable that represents a NavigationButton object.

Remarks

The PressedShade property contains a numeric expression that can be used to darken the theme color in the PressedColor property. The default value of the PressedShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


AccessObjectProperties.Parent Property (Access)

 Copy code hover
[image]

AccessObjectProperties.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents an AccessObjectProperties object.

See also

Concepts

AccessObjectProperties Collection

Other resources

AccessObjectProperties Object Members


Report.LayoutForPrint Property (Access)

 Copy code hover
[image]

Report.LayoutForPrint Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the LayoutForPrint property to specify whether the report uses printer or screen fonts. Read/write Boolean.

Syntax

expression .LayoutForPrint

expression A variable that represents a Report object.

Remarks

When you choose a font in Microsoft Access, you are choosing either a screen font or a printer font, depending on the setting of the LayoutForPrint property. Remember that printer fonts and screen fonts can differ, and characters on screen may not look exactly like those displayed on the printed page.

Screen fonts are the images of letters, numbers, and symbols that are installed on your system to be displayed on the screen. If you installed a printer, additional screen fonts may have been installed automatically.

Printer fonts are the letters, numbers, and symbols that are produced when you print a report. The available fonts are those fonts that were installed as part of your printer's setup, and depend on your printer.

If you design a report on a system with a different printer than the one you will use to print, Microsoft Access displays a message when you print the report to let you know that it was designed for another kind of printer. If you print the report anyway, your printer may substitute different fonts. Similarly, Microsoft Access may substitute fonts if you change the LayoutForPrint property setting. For example, you might design a report with LayoutForPrint set to No, then change the setting to Yes. You can reselect the font for each control to specify the appearance of the report.

See also

Concepts

Report Object

Other resources

Report Object Members


RDS Objects

 Copy code hover
[image]

RDS Objects
Send feedback
DataControl (RDS) | Binds a data query Recordset to one or more controls (for example, a text box, grid control, or combo box) to display the Recordset data on a Web page.
DataFactory (RDSServer) | Implements methods that provide read/write data access to specified data sources for client-side applications.
DataSpace (RDS) | Creates client-side proxies to custom business objects located on the middle tier.


Rectangle.VerticalAnchor Property (Access)

 Copy code hover
[image]

Rectangle.VerticalAnchor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets an AcVerticalAnchor constant that indicates how the specified rectangle is anchored vertically within its layout. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .VerticalAnchor

expression A variable that represents a Rectangle object.

Remarks

The default value is acVerticalAnchorTop.

See also

Concepts

Rectangle Object

Other resources

Rectangle Object Members


DeleteRecord and MoveRecord Methods Example (VB)

 Copy code hover
[image]

DeleteRecord and MoveRecord Methods Example (VB)
Send feedback

This example demonstrates how to copy, move, edit, and delete the contents of a text file published to a Web folder. Other properties and methods used include GetChildren, ParentURL, Source, and Flush.

Copy code Copy code

'BeginDeleteRecordVB

'Note:
' IIS must be running for this sample to work. To
' use this sample you must:
'
' 1. create folders named "test" and "test2"
' in the root web folder of http://MyServer
'
' 2. Create a text file named "test2.txt" in the
' "test" folder.
' 3. Replace "MyServer" with the appropriate web
' server name.

Public Sub Main()
 On Error GoTo ErrorHandler

 ' connection and recordset variables
 Dim rsDestFolder As ADODB.Recordset
 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String

 ' file as record variables
 Dim rcFile As ADODB.Record
 Dim rcDestFile As ADODB.Record
 Dim rcDestFolder As ADODB.Record
 Dim objStream As Stream

 ' file variables
 Dim strFile As String
 Dim strDestFile As String
 Dim strDestFolder As String

 ' instantiate variables
 Set rsDestFolder = New ADODB.Recordset
 Set rcDestFolder = New ADODB.Record
 Set rcFile = New ADODB.Record
 Set rcDestFile = New ADODB.Record
 Set objStream = New ADODB.Stream

 ' open a record on a text file
 Set Cnxn = New ADODB.Connection
 strCnxn = "url=http://MyServer/"
 Cnxn.Open strCnxn
 strFile = "test/test2.txt"
 rcFile.Open strFile, Cnxn, adModeReadWrite, adOpenIfExists Or adCreateNonCollection
 Debug.Print Cnxn

 ' edit the contents of the text file
 objStream.Open rcFile, , adOpenStreamFromRecord

 Debug.Print "Source: " & strCnxn & rcFile.Source
 Debug.Print "Original text: " & objStream.ReadText

 objStream.Position = 0
 objStream.WriteText "Newer Text. "
 objStream.Position = 0

 Debug.Print "New text: " & objStream.ReadText

 ' reset the stream object
 objStream.Flush
 objStream.Close
 rcFile.Close

 ' reopen record to see new contents of text file
 rcFile.Open strFile, Cnxn, adModeReadWrite, adOpenIfExists Or adCreateNonCollection
 objStream.Open rcFile, adModeReadWrite, adOpenStreamFromRecord

 Debug.Print "Source: " & strCnxn & rcFile.Source
 Debug.Print "Edited text: " & objStream.ReadText

 ' copy the file to another folder
 strDestFile = "test2/test1.txt"
 rcFile.CopyRecord "", "http://MyServer/" & strDestFile, "", "", adCopyOverWrite

 ' delete the original file
 rcFile.DeleteRecord

 ' move the file from the subfolder back to original location
 strDestFolder = "test2/"
 rcDestFolder.Open strDestFolder, Cnxn ', adOpenIfExists 'Or adCreateCollection
 Set rsDestFolder = rcDestFolder.GetChildren
 rsDestFolder.MoveFirst

 ' position current record at on the correct file
 Do While Not (rsDestFolder.EOF Or rsDestFolder(0) = "test1.txt")
 rsDestFolder.MoveNext
 Loop

 ' open a record on the correct row of the recordset
 rcDestFile.Open rsDestFolder, Cnxn

 ' do the move
 rcDestFile.MoveRecord "", "http://MyServer/" & strFile, "", "", adMoveOverWrite

 ' clean up
 rsDestFolder.Close
 Cnxn.Close
 Set rsDestFolder = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rsDestFolder Is Nothing Then
 If rsDestFolder.State = adStateOpen Then rsDestFolder.Close
 End If
 Set rsDestFolder = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndDeleteRecordVB


ListBox.OnKeyDown Property (Access)

 Copy code hover
[image]

ListBox.OnKeyDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Down box in the Properties window. Read/write String.

Syntax

expression .OnKeyDown

expression A variable that represents a ListBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyDown event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyDown

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Access was denied while accessing dropbox folder

 Copy code hover
[image]

Access was denied while accessing dropbox folder <name>. (Error 3468)
Send feedback

Check your permissions for the dropbox folder.


Recordset2.Transactions Property (DAO)

 Copy code hover
[image]

Recordset2.Transactions Property (DAO)
Send feedback

Returns a value that indicates whether an object supports transactions. Read-only Boolean.

Syntax

expression .Transactions

expression A variable that represents a Recordset2 object.

Remarks

In a Microsoft Access workspace, you can also use the Transactions property with dynaset- or table-type Recordset objects. Snapshot- and forward-only-type Recordset objects always return False.

If a dynaset- or table-type Recordset is based on a Microsoft Access database engine table, the Transactions property is True and you can use transactions. Other database engines may not support transactions. For example, you can't use transactions in a dynaset-type Recordset object based on a Paradox table.

Check the Transactions property before using the BeginTrans method on the Recordset object's Workspace object to make sure that transactions are supported. Using the BeginTrans, CommitTrans, or Rollback methods on an unsupported object has no effect.

Example

This example demonstrates the Transactions property in Microsoft Access workspaces.

VBA Copy code Copy code
Sub TransactionsX()

 Dim wrkAcc As Workspace
 Dim dbsNorthwind As Database
 Dim conPubs As Connection
 Dim rstTemp As Recordset

 Set wrkAcc = CreateWorkspace("", "admin", "", dbUseJet)
 Set dbsNorthwind = wrkAcc.OpenDatabase("Northwind.mdb")

 ' Open two different Recordset objects and display the
 ' Transactions property of each.

 Debug.Print "Opening Microsoft Access table-type " & _
 "recordset..."
 Set rstTemp = dbsNorthwind.OpenRecordset( _
 "Employees", dbOpenTable)
 Debug.Print " Transactions = " & rstTemp.Transactions

 Debug.Print "Opening forward-only-type " & _
 "recordset where the source is an SQL statement..."
 Set rstTemp = dbsNorthwind.OpenRecordset( _
 "SELECT * FROM Employees", dbOpenForwardOnly)
 Debug.Print " Transactions = " & rstTemp.Transactions

 rstTemp.Close
 dbsNorthwind.Close
 conPubs.Close
 wrkAcc.Close
End Sub


OptionButton.TripleState Property (Access)

 Copy code hover
[image]

OptionButton.TripleState Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the TripleState property to specify how the specified control will display Null values. Read/write Boolean.

Syntax

expression .TripleState

expression A variable that represents an OptionButton object.

Remarks

The Null property uses the following settings.

Setting | Description
True | The control will cycle through states for Yes, No, and Null values. The control appears dimmed (grayed) when its Value property is set to Null.
False | (Default) The control will cycle through states for Yes and No values. Null values display as if they were No values.

This property can be set in any view.

Example

The following example displays a message describing in detail the state of a check box named "Check1" on the form "frmOperations".

VBA Copy code Copy code
Dim strTripleState As String

strTripleState = Forms.Item("frmOperations").Controls.Item("Check1").TripleState

Select Case strTripleState
 Case True
 MsgBox "For Check1, TripleState = " & strTripleState & _
 ". The control will cycle through states for Yes, No, " & _
 "and Null values. The control appears dimmed (grayed) " & _
 "when its Value property is set to Null."
 Case False
 MsgBox "For Check1, TripleState = " & strTripleState & _
 ". The control will cycle through states for Yes and No " & _
 "values. Null values display as if they were No values."
 Case Else
 MsgBox "Can't determine the TripleState property for Check1."
End Select

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Optimize Property Example (VB)

 Copy code hover
[image]

Optimize Property Example (VB)
Send feedback

This example demonstrates the Field objects dynamic Optimize property. The zip field of the Authors table in the Pubs database is not indexed. Setting the Optimize property to True on the zip field authorizes ADO to build an index that improves the performance of the Find method.

Copy code Copy code

'BeginOptimizeVB
Public Sub Main()
 On Error GoTo ErrorHandler

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

 ' recordset and connection variables
 Dim Cnxn As ADODB.Connection
 Dim rstAuthors As ADODB.Recordset
 Dim strCnxn As String
 Dim strSQLAuthors As String

 ' Open connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Set Cnxn = New ADODB.Connection
 Cnxn.Open strCnxn

 ' open recordset client-side to enable index creation
 Set rstAuthors = New ADODB.Recordset
 rstAuthors.CursorLocation = adUseClient
 strSQLAuthors = "SELECT * FROM Authors"
 rstAuthors.Open strSQLAuthors, Cnxn, adOpenStatic, adLockReadOnly, adCmdText
 ' Create the index
 rstAuthors!zip.Properties("Optimize") = True
 ' Find Akiko Yokomoto
 rstAuthors.Find "zip = '94595'"

 ' show results
 Debug.Print rstAuthors!au_fname & " " & rstAuthors!au_lname & " " & _
 rstAuthors!address & " " & rstAuthors!city & " " & rstAuthors!State
 rstAuthors!zip.Properties("Optimize") = False 'Delete the index

 ' clean up
 rstAuthors.Close
 Cnxn.Close
 Set rstAuthors = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstAuthors Is Nothing Then
 If rstAuthors.State = adStateOpen Then rstAuthors.Close
 End If
 Set rstAuthors = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndOptimizeVB


CommandButton.IsVisible Property (Access)

 Copy code hover
[image]

CommandButton.IsVisible Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the IsVisible property in to determine whether a control on a report is visible. Read/write Boolean.

Syntax

expression .IsVisible

expression A variable that represents a CommandButton object.

Remarks

Note Note

You can set the IsVisible property only in the Print event of a report section that contains the control.

You can use the IsVisible property together with the HideDuplicates property to determine when a control on a report is visible and show or hide other controls as a result. For example, you could hide a line control when a text box control is hidden because it contains duplicate values.

Example

The following example uses the IsVisible property of a text box to control the display of a line control on a report. T

Paste the following code into the Declarations section of the report module, and then view the report to see the line formatting controlled by the IsVisible property:

VBA Copy code Copy code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
 If Me!CategoryID.IsVisible Then
 Me!Line0.Visible = True
 Else
 Me!Line0.Visible = False
 End If
End Sub

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Syntax error in INSERT INTO statement. (Error 3134)

 Copy code hover
[image]

Syntax error in INSERT INTO statement. (Error 3134)
Send feedback

You entered an SQL statement that has an invalid INSERT INTO statement.

Possible causes:

  • A reserved word or argument name is misspelled or missing.

  • Punctuation is incorrect.


Label.GridlineColor Property (Access)

 Copy code hover
[image]

Label.GridlineColor Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the color of the gridline for the specified label. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineColor

expression A variable that represents a Label object.

Remarks

The GridlineColor property setting is a numeric expression that corresponds to the color you want to use for a control's gridline.

You can use the Color Builder to set this property by clicking the Build button to the right of the property box in the property sheet. Using the Color Builder enables you to define custom border colors for controls.

See also

Concepts

Label Object

Other resources

Label Object Members


Failure to do open file using FTP service. (Error 3679)

 Copy code hover
[image]

Failure to do open file using FTP service. (Error 3679)
Send feedback

Unable to open a file in the internet server. Make sure the server is running and the FTP share folder is configured properly with read/write access.


TableDef.RecordCount Property (DAO)

 Copy code hover
[image]

TableDef.RecordCount Property (DAO)
Send feedback

Returns the total number of records in a TableDef object. Read-only Long.

Syntax

expression .RecordCount

expression A variable that represents a TableDef object.

Remarks

A Recordset or TableDef object with no records has a RecordCount property setting of 0.

When you work with linkedTableDef objects, the RecordCount property setting is always -1.


ToggleButton.ColumnOrder Property (Access)

 Copy code hover
[image]

ToggleButton.ColumnOrder Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnOrder property to specify the order of the columns in Datasheet view. Read/write Integer.

Syntax

expression .ColumnOrder

expression A variable that represents a ToggleButton object.

Remarks

To set or change this property for a table or query by using Visual Basic, you must use a column's Properties collection. For details on using the Properties collection, see Properties .

Note Note

The ColumnOrder property isn't available in Design view.

The ColumnOrder property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

In Datasheet view, a field's ColumnOrder property setting is determined by the field's position. For example, the field in the leftmost column in Datasheet view has a ColumnOrder property setting of 1, the next field has a setting of 2, and so on. Changing a field's ColumnOrder property resets the property for that field and every field to the left of its original position in Datasheet view.

In other views, the property setting is 0 unless you explicitly change the order of one or more fields in Datasheet view (either by dragging the fields to new positions or by changing their ColumnOrder property settings). Fields to the right of the moved field's new position will have a property setting of 0 in views other than Datasheet view.

The order of the fields in Datasheet view doesn't affect the order of the fields in table Design view or Form view.

Example

The following example displays the ProductName and QuantityPerUnit fields in the first two columns in Datasheet view of the Products form.

VBA Copy code Copy code
Forms!Products!ProductName.ColumnOrder = 1
Forms!Products!QuantityPerUnit.ColumnOrder = 2

The next example displays the ProductName and QuantityPerUnit fields in the first two columns of the Products table in Datasheet view. To set the ColumnOrder property, the example uses the SetFieldProperty procedure. If this procedure is run while the table is open, changes will not be displayed until it is closed and reopened.

VBA Copy code Copy code
Public Sub SetColumnOrder()

 Dim dbs As DAO.Database
 Dim tdf As DAO.TableDef

 Set dbs = CurrentDb
 Set tdf = dbs!Products

 ' Call the procedure to set the ColumnOrder property.
 SetFieldProperty tdf!ProductName, "ColumnOrder", dbLong, 2
 SetFieldProperty tdf!QuantityPerUnit, "ColumnOrder", dbLong, 3

 Set tdf = Nothing
 Set dbs = Nothing

End Sub

Private Sub SetFieldProperty(ByRef fld As DAO.Field, _
 ByVal strPropertyName As String, _
 ByVal intPropertyType As Integer, _
 ByVal varPropertyValue As Variant)
 ' Set field property without producing nonrecoverable run-time error.

 Const conErrPropertyNotFound = 3270
 Dim prp As Property

 ' Turn off error handling.
 On Error Resume Next

 fld.Properties(strPropertyName) = varPropertyValue

 ' Check for errors in setting the property.
 If Err <> 0 Then
 If Err <> conErrPropertyNotFound Then
 On Error GoTo 0
 MsgBox "Couldn't set property '" & strPropertyName & _
 "' on field '" & fld.Name & "'", vbCritical
 Else
 On Error GoTo 0
 Set prp = fld.CreateProperty(strPropertyName, intPropertyType, _
 varPropertyValue)
 fld.Properties.Append prp
 End If
 End If

 Set prp = Nothing

End Sub

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


SynchronizeTypeEnum Enumeration (DAO)

 Copy code hover
[image]

SynchronizeTypeEnum Enumeration (DAO)
Send feedback

Used with the Synchronize method to determine the type of synchronization to apply to two replicas.

Name | Value | Description
dbRepExportChanges | 1 | Sends changes from current database to target database.
dbRepImpExpChanges | 4 | Sends and receives data in a bidirectional exchange.
dbRepImportChanges | 2 | Receives changes from target database.
dbRepSyncInternet | 16 | Sends and receives data in a bidirectional exchange.


TabControl.InSelection Property (Access)

 Copy code hover
[image]

TabControl.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents a TabControl object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Invalid argument. (Error 3001)

 Copy code hover
[image]

Invalid argument. (Error 3001)
Send feedback

You tried to perform an operation that involves a routine in a DLL, and one of the arguments to the routine is invalid. Check your entry to make sure you have specified the correct arguments, and then try the operation again.

This error also occurs when you attempt to use mutually exclusive constants in an argument to a method, such as specifying both dbConsistent and dbInconsistent in the options argument to the OpenRecordset method.


Open Method (ADO Stream)

 Copy code hover
[image]

Open Method (ADO Stream)
Send feedback

Opens a Stream object to manipulate streams of binary or text data.

Syntax

Stream. Open Source, Mode, OpenOptions, UserName, Password

Parameters

  • Source

  • Optional. A Variant value that specifies the source of data for the Stream. Source may contain an absolute URL string that points to an existing node in a well-known tree structure, like an e-mail or file system. A URL should be specified using the URL keyword ("URL=scheme://server/folder"). Alternately, Source may contain a reference to an already open Record object, which opens the default stream associated with the Record. If Source is not specified, a Stream is instantiated and opened, associated with no underlying source by default. For more information about URL schemes and their associated providers, see Absolute and Relative URLs.

  • Mode

  • Optional. A ConnectModeEnum value that specifies the access mode for the resultant Stream (for example, read/write or read-only). Default value is adModeUnknown. See the Mode property for more information about access modes. If Mode is not specified, it is inherited by the source object. For example, if the source Record is opened in read-only mode, the Stream will also be opened in read-only mode by default.

  • OpenOptions

  • Optional. A StreamOpenOptionsEnum value. Default value is adOpenStreamUnspecified.

  • UserName

  • Optional. A String value that contains the user identification that, if needed, accesses the Stream object.

  • Password

  • Optional. A String value that contains the password that, if needed, accesses the Stream object.

Remarks

When a Record object is passed in as the source parameter, the UserID and Password parameters are not used because access to the Record object is already available. Similarly, the Mode of the Record object is transferred to the Stream object.When Source is not specified, the Stream opened contains no data and has a Size of zero (0). To avoid losing any data that is written to this Stream when the Stream is closed, save the Stream with the CopyTo or SaveToFile methods, or save it to another memory location.

An OpenOptions value of adOpenStreamFromRecord identifies the contents of the Source parameter to be an already open Record object. The default behavior is to treat Source as a URL that points directly to a node in a tree structure, such as a file. The default stream associated with that node is opened.

While the Stream is not open, it is possible to read all the read-only properties of the Stream. If a Stream is opened asynchronously, all subsequent operations (other than checking the State and other read-only properties) are blocked until the Open operation is completed.

In addition to the options discussed above, by not specifying Source, you can simply instantiate a Stream object in memory without associating it with an underlying source. You can dynamically add data to the stream simply by writing binary or text data to the Stream with Write or WriteText, or by loading data from a file with LoadFromFile.


ADO MD Code Examples

 Copy code hover
[image]

ADO MD Code Examples
Send feedback

Use the following code examples to learn how to use the ADO MD objects, methods, and properties. These examples are a subset of the sample applications installed with Microsoft SQL Server OLAP Services for SQL Server 7.0.

These examples use the MSOLAP OLE DB provider, and run against a Microsoft SQL Server OLAP Services local host. However, these examples are intended to show fundamental ADO MD programming techniques, and should be easily adapted to other data sources or providers.

  • ADO MD Code Examples in Visual Basic

  • ADO MD Code Examples in Visual Basic, Scripting Edition


TextBox.IMEMode Property (Access)

 Copy code hover
[image]

TextBox.IMEMode Property (Access)
See also Send feedback

Published: July 16, 2012

Syntax

expression .IMEMode

expression A variable that represents a TextBox object.

Remarks

The IMEMode property uses the following settings.

Setting | Description | Visual Basic
No Control | Kanji Conversion Mode not set (default). | 0
On | Turns on Kanji Conversion Mode. | 1
Off | Turns off Kanji Conversion Mode. | 2
Disable | Disables Kanji Conversion Mode. | 3
Hiragana | Sets full pitch hiragana | 4
Full pitch Katakana | Sets full pitch katakana. | 5
Half pitch Katakana | Sets half pitch katakana. | 6
Full pitch Alpha/Num | Sets full pitch letters/numbers. | 7
Half pitch Alpha/Num | Sets half pitch letters/numbers. | 8
HangulFull | Sets full pitch hangul. | 9
Hangul | Sets half pitch hangul. | 10

You can specify the Kanji Conversion Mode when the focus shifts to control by setting the IMEMode property. If set to No Control (default) the setting before the focus shifted to that control is used. For any other setting, the Kanji Conversion Mode setting for that control is used. For example, if the IMEMode property is set to Off, the Kanji Conversion Mode is turned off, and if the IMEMode property is set to On, the Kanji Conversion Mode is turned on. The Kanji Conversion Mode automatically changes each time the focus shifts between controls.

Note Note

If set to Disable, the Kanji Conversion Mode settings cannot be changed. If any other setting is used, the Kanji Conversion Mode can be changed, but when the focus changes, the settings are lost. If you want to save the settings before the control loses the focus, set the IMEHold/HoldKanjiConversionMode property.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Step 4: Populate the Details Text Box
Send feedback

Step 4: Populate the Details Text Box

To populate the Details text box

Create a new subroutine named recFields and insert the following code:

Copy code Copy code

Sub recFields(r As Record, l As ListBox, t As TextBox)
    Dim f As Field
    Dim s As Stream
    Set s = New Stream
    Dim str As String

    For Each f In r.Fields
        l.AddItem f.Name & ": " & f.Value
    Next
    t.Text = ""
    If r!RESOURCE_CONTENTCLASS = "text/plain" Then
        s.Open r, adModeRead, adOpenStreamFromRecord
        str = s.ReadText(1)
        s.Position = 0
        If Asc(Mid(str, 1, 1)) = 63 Then '//63 = "?"
            s.Charset = "ascii"
            s.Type = adTypeText
        End If
        t.Text = s.ReadText(adReadAll)
    End If
End Sub

This code populates lstDetails with the fields and values of the simple record passed to recFields. If the resource is a text file, a text Stream is opened from the resource record. The code determines if the character set is ASCII and copies the Stream contents into txtDetails.


Report.NoData Event (Access)

 Copy code hover
[image]

Report.NoData Event (Access)
See also Send feedback

Published: July 16, 2012

The NoData event occurs after Microsoft Access formats a report for printing that has no data (the report is bound to an empty recordset), but before the report is printed. You can use this event to cancel printing of a blank report.

Syntax

expression .NoData(Cancel)

expression A variable that represents a Report object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines whether to print the report. Setting the Cancel argument to True (-1) prevents the report from printing. You can also use the CancelEvent method of the DoCmd object to cancel printing the report.

Remarks

To run a macro or event procedure when this event occurs, set the OnNoData property to the name of the macro or to [Event Procedure].

If the report isn't bound to a table or query (by using the report's RecordSource property), the NoData event doesn't occur.

This event occurs after the Format events for the report, but before the first Print event.

This event doesn't occur for subreports. If you want to hide controls on a subreport when the subreport has no data, so that the controls don't print in this case, you can use the HasData property in a macro or event procedure that runs when the Format or Print event occurs.

The NoData event occurs before the first Page event for the report.

Example

The following example shows how to cancel printing a report when it has no data. A message box notifying the user that the printing has been canceled is also displayed.

To try this example, add the following event procedure to a report. Try running the report when it contains no data.

VBA Copy code Copy code
Private Sub Report_NoData(Cancel As Integer)
    MsgBox "The report has no data." & _
         chr(13) & "Printing is canceled. " & _
         chr(13) & "Check the data source for the " & _
         chr(13) & "report. Make sure you entered " & _
         chr(13) & "the correct criteria (for " & _
         chr(13) & "example, a valid range of " & _
         chr(13) & "dates),." vbOKOnly + vbInformation
    Cancel = True
End Sub

The following example shows how to use the NoData event of a report to prevent the report form opening when there is no data to be displayed.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Private Sub Report_NoData(Cancel As Integer)

    'Add code here that will be executed if no data
    'was returned by the Report's RecordSource
    MsgBox "No customers ordered this product this month. " & _
        "The report will now close."
    Cancel = True

End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.

See also

Concepts

Report Object

Other resources

Report Object Members


Procedures Append Method Example (VB)

 Copy code hover
[image]

Procedures Append Method Example (VB)
Send feedback

The following code demonstrates how to use a Command object and the Procedures collection Append method to create a new procedure in the underlying data source.

Copy code Copy code

' BeginCreateProcedureVB
Sub Main()
 On Error GoTo CreateProcedureError

 Dim cnn As New ADODB.Connection
 Dim cmd As New ADODB.Command
 Dim prm As ADODB.Parameter
 Dim cat As New ADOX.Catalog

 ' Open the Connection
 cnn.Open _
 "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\Microsoft Office\" & _
 "Office\Samples\Northwind.mdb';"

 ' Create the parameterized command (Microsoft Jet specific)
 Set cmd.ActiveConnection = cnn
 cmd.CommandText = "PARAMETERS [CustId] Text;" & _
 "Select * From Customers Where CustomerId = [CustId]"

 ' Open the Catalog
 Set cat.ActiveConnection = cnn

 ' Create the new Procedure
 cat.Procedures.Append "CustomerById", cmd

 'Clean
 cnn.Close
 Set cat = Nothing
 Set cmd = Nothing
 Set cnn = Nothing
 Exit Sub

CreateProcedureError:
 Set cat = Nothing
 Set cmd = Nothing

 If Not cnn Is Nothing Then
 If cnn.State = adStateOpen Then cnn.Close
 End If
 Set cnn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndCreateProcedureVB


ImportExportSpecification.Description Property (Access)

 Copy code hover
[image]

ImportExportSpecification.Description Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a String that describes the specified ImportExportSpecification object. Read/write.

Version Information

Version Added: Access 2007

Syntax

expression .Description

expression A variable that represents an ImportExportSpecification object.

Remarks

The maximum number of characters that can be used for the Description property is 255.

See also

Concepts

ImportExportSpecification Object

Other resources

ImportExportSpecification Object Members


INTO (Microsoft Access SQL reserved word)

 Copy code hover
[image]

INTO (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The INTO keyword is used in these contexts:

INSERT INTO Statement

SELECT …INTO Statement


Recordset2.BatchSize Property (DAO)

 Copy code hover
[image]

Recordset2.BatchSize Property (DAO)
Send feedback

Syntax

expression .BatchSize

expression A variable that represents a Recordset2 object.

Remarks

The BatchSize property determines the batch size used when sending statements to the server in a batch update. The value of the property determines the number of statements sent to the server in one command buffer. By default, 15 statements are sent to the server in each batch. This property can be changed at any time. If a database server doesn't support statement batching, you can set this property to 1, causing each statement to be sent separately.

Example

This example uses the BatchSize and UpdateOptions properties to control aspects of any batch updating for the specified Recordset object.

Copy code Copy code
Sub BatchSizeX()

 Dim wrkMain As Workspace
 Dim conMain As Connection
 Dim rstTemp As Recordset2

 Set wrkMain = CreateWorkspace("ODBCWorkspace", _
 "admin", "", dbUseODBC)
 ' This DefaultCursorDriver setting is required for
 ' batch updating.
 wrkMain.DefaultCursorDriver = dbUseClientBatchCursor

 ' Note: The DSN referenced below must be configured to
 ' use Microsoft Windows NT Authentication Mode to
 ' authorize user access to the Microsoft SQL Server.
 Set conMain = wrkMain.OpenConnection("Publishers", _
 dbDriverNoPrompt, False, _
 "ODBC;DATABASE=pubs;DSN=Publishers")

 ' The following locking argument is required for
 ' batch updating.
 Set rstTemp = conMain.OpenRecordset( _
 "SELECT * FROM roysched", dbOpenDynaset, 0, _
 dbOptimisticBatch)

 With rstTemp
 ' Increase the number of statements sent to the server
 ' during a single batch update, thereby reducing the
 ' number of times an update would have to access the
 ' server.
 .BatchSize = 25

 ' Change the UpdateOptions property so that the WHERE
 ' clause of any batched statements going to the server
 ' will include any updated columns in addition to the
 ' key column(s). Also, any modifications to records
 ' will be made by deleting the original record
 ' and adding a modified version rather than just
 ' modifying the original record.
 .UpdateOptions = dbCriteriaModValues + _
 dbCriteriaDeleteInsert

 ' Engage in batch updating using the new settings
 ' above.
 ' ...

 .Close
 End With

 conMain.Close
 wrkMain.Close

End Sub


ToggleButton.LabelAlign Property (Access)

 Copy code hover
[image]

ToggleButton.LabelAlign Property (Access)
See also Send feedback

Published: July 16, 2012

The property specifies the text alignment within attached labels on new controls. Read/write Byte.

Syntax

expression .LabelAlign

expression A variable that represents a ToggleButton object.

Remarks

The LabelAlign property uses the following settings.

Setting | Description
0 | (Default) The label text aligns to the left.
1 | The label text aligns to the left.
2 | The label text is centered.
3 | The label text aligns to the right.
4 | The label text is evenly distributed.

You can set the LabelAlign property by using a control's default control style or the DefaultControl property in Visual Basic.

When created, controls have an attached label (as long as their AutoLabel property is set to Yes). Changes to the LabelAlign default control style setting affect only controls created on the current form or report.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


AllForms.Parent Property (Access)

 Copy code hover
[image]

AllForms.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents an AllForms object.

Remarks

You can use the Parent property to determine which form or report is currently the parent when you have a subform or subreport that has been inserted in multiple forms or reports.

For example, you might insert an OrderDetails subform into both a form and a report. The following example uses the Parent property to refer to the OrderID field, which is present on the main form and report. You can enter this expression in a bound control on the subform.

VBA Copy code Copy code
=Parent!OrderID

See also

Concepts

AllForms Collection

Other resources

AllForms Object Members


CubeDef Properties, Methods, and Events (ADO MD)

 Copy code hover
[image]

CubeDef Properties, Methods, and Events (ADO MD)
Send feedback

Properties/Collections

Description Property

Dimensions Collection

Name Property

Properties Collection

Events

None.


DoCmd.Minimize Method (Access)

 Copy code hover
[image]

DoCmd.Minimize Method (Access)
See also Send feedback

Published: July 16, 2012

The Minimize method carries out the Minimize action in Visual Basic.

Syntax

expression .Minimize

expression A variable that represents a DoCmd object.

Remarks

You can use this method to remove a window from the screen while leaving the object open. You can also use this method to open an object without displaying its window. To display the object, use the SelectObject method with either the Maximize or Restore method. The Restore method restores a minimized window to its previous size.

This method cannot be applied to module windows in the Visual Basic Editor (VBE). For information about how to affect module windows see the WindowState property topic.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


Chapter 12: RDS Tutorial

 Copy code hover
[image]

Chapter 12: RDS Tutorial
Send feedback

This tutorial illustrates using the RDS programming model to query and update a data source. First, it describes the steps necessary to accomplish this task. Then the tutorial is repeated in Microsoft® Visual Basic Scripting Edition and Microsoft® Visual J++®, featuring ADO for Windows Foundation Classes (ADO/WFC).

This tutorial is coded in different languages for two reasons:

  • The documentation for RDS assumes the reader codes in Visual Basic. This makes the documentation convenient for Visual Basic programmers, but less useful for programmers who use other languages.

  • If you are uncertain about a particular RDS feature and you know a little of another language, you might be able to resolve your question by looking for the same feature expressed in another language.

How the Tutorial is Presented

This tutorial is based on the RDS programming model. It discusses each step of the programming model individually. In addition, it illustrates each step with a fragment of Visual Basic code.

The code example is repeated in other languages with minimal discussion. Each step in a given programming language tutorial is marked with the corresponding step in the programming model and descriptive tutorial. Use the number of the step to refer to the discussion in the descriptive tutorial.

The RDS programming model is stated below. Use it as a roadmap as you proceed through the tutorial.

RDS Programming Model with Objects

  • Specify the program to be invoked on the server, and obtain a way (proxy) to refer to it from the client.

  • Invoke the server program. Pass parameters to the server program that identifies the data source and the command to issue.

  • The server program obtains a Recordset object from the data source, typically by using ADO. Optionally, the Recordset object is processed on the server.

  • The server program returns the final Recordset object to the client application.

  • On the client, the Recordset object is optionally put into a form that can be easily used by visual controls.

  • Changes to the Recordset object are sent back to the server and used to update the data source.


TextBox.OnUndo Property (Access)

 Copy code hover
[image]

TextBox.OnUndo Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the Undo event occurs. Read/write..

Syntax

expression .OnUndo

expression A variable that represents a TextBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the Undo event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the Undo event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).OnUndo = "[Event Procedure]"

The following example specifies that when the Undo event occurs in any text box on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Dim ctlLoop As Control

For Each ctlLoop In Forms(0).Controls
 If ctlLoop.Type = acTextBox Then
 ctlLoop.OnUndo = "[Event Procedure]"
 End If
Next ctlLoop

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


ListBox.Hyperlink Property (Access)

 Copy code hover
[image]

ListBox.Hyperlink Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a control's hyperlink. Read-only.

Syntax

expression .Hyperlink

expression A variable that represents a ListBox object.

Example

The CreateHyperlink procedure in the following example sets the hyperlink properties for a command button, label, or image control to the address and subaddress values passed to the procedure. The address setting is an optional argument, because a hyperlink to an object in the current database uses only the subaddress setting, To try this example, create a form with two text box controls (txtAddress and txtSubAddress) and a command button (cmdFollowLink) and paste the following into the Declarations section of the form's module:

VBA Copy code Copy code
Private Sub cmdFollowLink_Click()
 CreateHyperlink Me!cmdFollowLink, Me!txtSubAddress, _
 Me!txtAddress
End Sub

Sub CreateHyperlink(ctlSelected As Control, _
 strSubAddress As String, Optional strAddress As String)
 Dim hlk As Hyperlink
 Select Case ctlSelected.ControlType
 Case acLabel, acImage, acCommandButton
 Set hlk = ctlSelected.Hyperlink
 With hlk
 If Not IsMissing(strAddress) Then
 .Address = strAddress
 Else
 .Address = ""
 End If
 .SubAddress = strSubAddress
 .Follow
 .Address = ""
 .SubAddress = ""
 End With
 Case Else
 MsgBox "The control '" & ctlSelected.Name _
 & "' does not support hyperlinks."
 End Select
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


GetString Method Example (VB)

 Copy code hover
[image]

GetString Method Example (VB)
Send feedback

This example demonstrates the GetString method.

Assume you are debugging a data access problem and want a quick, simple way of printing the current contents of a small Recordset.

Copy code Copy code

'BeginGetStringVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 ' connection variables
 Dim Cnxn As ADODB.Connection
 Dim rstAuthors As ADODB.Recordset
 Dim strCnxn As String
 Dim strSQLAuthors As String
 Dim varOutput As Variant

 ' specific variables
 Dim strPrompt As String
 Dim strState As String

 ' open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' get user input
 strPrompt = "Enter a state (CA, IN, KS, MD, MI, OR, TN, UT): "
 strState = Trim(InputBox(strPrompt, "GetString Example"))

 ' open recordset
 Set rstAuthors = New ADODB.Recordset
 strSQLAuthors = "SELECT au_fname, au_lname, address, city FROM Authors " & _
 "WHERE state = '" & strState & "'"
 rstAuthors.Open strSQLAuthors, Cnxn, adOpenStatic, adLockReadOnly, adCmdText

 If Not rstAuthors.EOF Then
 ' Use all defaults: get all rows, TAB as column delimiter,
 ' CARRIAGE RETURN as row delimiter, EMPTY-string as null delimiter
 varOutput = rstAuthors.GetString(adClipString)
 ' print output
 Debug.Print "State = '" & strState & "'"
 Debug.Print "Name Address City" & vbCr
 Debug.Print varOutput
 Else
 Debug.Print "No rows found for state = '" & strState & "'" & vbCr
 End If

 ' clean up
 rstAuthors.Close
 Cnxn.Close
 Set rstAuthors = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstAuthors Is Nothing Then
 If rstAuthors.State = adStateOpen Then rstAuthors.Close
 End If
 Set rstAuthors = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndGetStringVB


Database Methods (DAO)

 Copy code hover
[image]

Database Methods (DAO)
Send feedback

In this section

  • Database.Close Method (DAO)

  • Database.CreateProperty Method (DAO)

  • Database.CreateQueryDef Method (DAO)

  • Database.CreateRelation Method (DAO)

  • Database.CreateTableDef Method (DAO)

  • Database.Execute Method (DAO)

  • Database.MakeReplica Method (DAO)

  • Database.NewPassword Method (DAO)

  • Database.OpenRecordset Method (DAO)

  • Database.PopulatePartial Method (DAO)

  • Database.Synchronize Method (DAO)


Database.PopulatePartial Method (DAO)

 Copy code hover
[image]

Database.PopulatePartial Method (DAO)
Send feedback

Synchronizes any changes in a partial replica with the full replica, clears all records in the partial replica, and then repopulates the partial replica based on the current replica filters. (Microsoft Access database engine databases only.).

Syntax

expression .PopulatePartial(DbPathName)

expression A variable that represents a Database object.

Parameters

Name | Required/Optional | Data Type | Description
DbPathName | Required | String | The path and name of the full replica from which to populate records.

Remarks

When you synchronize a partial replica with a full replica, it is possible to create "orphaned" records in the partial replica. For example, suppose you have a Customers table with its ReplicaFilter set to "Region = 'CA'". If a user changes a customer's region from CA to NY in the partial replica, and then a synchronization occurs via the Synchronize method, the change is propagated to the full replica but the record containing NY in the partial replica is orphaned because it now doesn't meet the replica filter criteria.

To solve the problem of orphaned records, you can use the PopulatePartial method. The PopulatePartial method is similar to the Synchronize method, but it synchronizes any changes with the full replica, removes all records in the partial replica, and then repopulates the partial replica based on the current replica filters. Even if your replica filters have not changed, PopulatePartial will always clear all records in the partial replica and repopulate it based on the current filters.

Generally, you should use the PopulatePartial method when you create a partial replica and whenever you change your replica filters. If your application changes replica filters, you should follow these steps:

  1. Synchronize your full replica with the partial replica in which the filters are being changed.

  2. Use the ReplicaFilter and PartialReplica properties to make the desired changes to the replica filter.

  3. Call the PopulatePartial method to remove all records from the partial replica and transfer all records from the full replica that meet the new replica filter criteria.

If a replica filter has changed, and the Synchronize method is invoked without first invoking PopulatePartial, a trappable error occurs.

The PopulatePartial method can only be invoked on a partial replica that has been opened for exclusive access. Furthermore, you can't call the PopulatePartial method from code running within the partial replica itself. Instead, open the partial replica exclusively from the full replica or another database, then call PopulatePartial.

Note Note

Although PopulatePartial performs a one-way synchronization before clearing and repopulating the partial replica, it is still a good idea to call Synchronize before calling PopulatePartial. This is because if the call to Synchronize fails, a trappable error occurs. You can use this error to decide whether or not to proceed with the PopulatePartial method (which removes all records in the partial replica). If PopulatePartial is called by itself and an error occurs while records are being synchronized, records in the partial replica will still be cleared, which may not be the desired result.

Example

The following example uses the PopulatePartial method after changing a replica filter.

VBA Copy code Copy code
Sub PopulatePartialX()

 Dim tdfCustomers As TableDef
 Dim strFilter As String
 Dim dbsTemp As Database

 ' Open the partial replica in exclusive mode.
 Set dbsTemp = OpenDatabase("F:\SALES\FY96CA.MDB", True)

 With dbsTemp
 Set tdfCustomers = .TableDefs("Customers")

 ' Synchronize with full replica
 ' before setting replica filter.
 .Synchronize "C:\SALES\FY96.MDB"

 strFilter = "Region = 'CA'"
 tdfCustomers.ReplicaFilter = strFilter

 ' Populate records from the full replica.
 .PopulatePartial "C:\SALES\FY96.MDB"

 .Close
 End With

End Sub


Line.Parent Property (Access)

 Copy code hover
[image]

Line.Parent Property (Access)
See also Send feedback

Published: July 16, 2012

Returns the parent object for the specified object. Read-only.

Syntax

expression .Parent

expression A variable that represents a Line object.

See also

Concepts

Line Object

Other resources

Line Object Members


DoCmd.SingleStep Method (Access)

 Copy code hover
[image]

DoCmd.SingleStep Method (Access)
See also Send feedback

Published: July 16, 2012

Pauses macro execution and opens the Macro Single Step dialog box.

Version Information

Version Added: Access 2007

Syntax

expression .SingleStep

expression A variable that represents a DoCmd object.

Remarks

The SingleStep method will not stop the execution of or assist in debugging Visual Basic for Applications (VBA) code. Use the Stop statement to pause execution of VBA code.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


AllowBypassKey Property

 Copy code hover
[image]

AllowBypassKey Property
Send feedback

Published: July 16, 2012

You can use the AllowBypassKey property to specify whether or not the SHIFT key is enabled for bypassing the startup properties and the AutoExec macro. For example, you can set the AllowBypassKey property to False to prevent a user from bypassing the startup properties and the AutoExec macro.

Setting

The AllowBypassKey property uses the following settings.

Setting | Description
True | Enable the SHIFT key to allow the user to bypass the startup properties and the AutoExec macro.
False | Disable the SHIFT key to prevent the user from bypassing the startup properties and the AutoExec macro.

You can set this property by using a macro or Visual Basic .

To set the AllowBypassKey property by using a macro or Visual Basic, you must create the property in the following ways:

  • In a Microsoft Access database, you can add it by using the CreateProperty method and append it to the Properties collection of the Database object.

  • In a Microsoft Access project (.adp), you can add it to the AccessObjectProperties collection of the CurrentProject object by using the Add method.

Remarks

You should make sure the AllowBypassKey property is set to True when debugging an application.

This property's setting doesn't take effect until the next time the application database opens.

Example

The following example shows a procedure named SetBypassProperty that passes the name of the property to be set, its data type, and its desired setting. The general purpose procedure ChangeProperty attempts to set the AllowBypassKey property and, if the property isn't found, uses the CreateProperty method to append it to the Properties collection. This is necessary because this property doesn't appear in the Properties collection until its been added.

Copy code Copy code
Sub SetBypassProperty()
Const DB_Boolean As Long = 1
    ChangeProperty "AllowBypassKey", DB_Boolean, False
End Sub

Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
    Dim dbs As Object, prp As Variant
    Const conPropNotFoundError = 3270

    Set dbs = CurrentDb
    On Error GoTo Change_Err
    dbs.Properties(strPropName) = varPropValue
    ChangeProperty = True

Change_Bye:
    Exit Function

Change_Err:
    If Err = conPropNotFoundError Then    ' Property not found.
        Set prp = dbs.CreateProperty(strPropName, _
            varPropType, varPropValue)
        dbs.Properties.Append prp
        Resume Next
    Else
        ' Unknown error.
        ChangeProperty = False
        Resume Change_Bye
    End If
End Function


Failure to read from an internet handle. Try the operation again. (Error 3675)

 Copy code hover
[image]

Failure to read from an internet handle. Try the operation again. (Error 3675)
Send feedback

An internet error occurred when reading a file or reading a response from an internet operation.


Could not save record; currently locked by another user. (Error 3158)

 Copy code hover
[image]

Could not save record; currently locked by another user. (Error 3158)
Send feedback

You tried to save a record that is on a database page currently locked by another user. To save your changes, wait for the other user to finish working with the record, and then try the operation again.


Numeric Criteria from a Control on a Form

 Copy code hover
[image]

Numeric Criteria from a Control on a Form
Send feedback

If you want to change the criteria argument for an operation based on a user's decision, you can specify that the criteria comes from a control on a form. For example, you could specify that the criteria argument comes from a text box containing the EmployeeID number.

To specify numeric criteria coming from a control on a form, you can include in the criteria argument an expression that references that control. This control expression should be separate from the string expression, so that Microsoft Access will evaluate control expression first and concatenate it with the rest of the string expression before performing the appropriate operation.

Suppose that you are performing the DLookup function on an Employees table to find the last name of an employee based on the EmployeeID number. In the following example, the criteria is determined by the current value of the EmployeeID control on the Orders form. The expression referencing the control is evaluated each time the function is called, so that if the value of the control changes, the criteria argument will reflect that change.

Copy code Copy code
=DLookup("[LastName]", "Employees", "[EmployeeID] = " _
 & Forms!Orders!EmployeeID)

If the current value of the EmployeeID field is 7, the criteria argument that is passed to the DLookup function is:

Copy code Copy code
"[EmployeeID] = 7"
Tip Tip

To troubleshoot an expression in the criteria argument, break the expression into smaller components and test each individually in the Immediate window. When all of the components are working correctly, put them back together one at a time until the complete expression works correctly.

You can also include a variable representing a numeric value in the criteria argument. The variable should be separate from the string expression, so that Microsoft Access will evaluate the variable first and then concatenate it with the rest of the string expression.

The following example shows how to construct a criteria argument that includes a variable:

Copy code Copy code
Dim intNum As Integer
Dim varResult As Variant

intNum = 7
varResult = DLookup("[LastName]", "Employees", _
 "[EmployeeID] = " & intNum)


OptionGroup.InSelection Property (Access)

 Copy code hover
[image]

OptionGroup.InSelection Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.

Syntax

expression .InSelection

expression A variable that represents an OptionGroup object.

Remarks

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.

Example

The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

VBA Copy code Copy code
? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
 strControlName As String) As Boolean
 Dim intI As Integer, ctl As Control
 If frm.CurrentView <> 0 Then
 ' Form is not in Design view.
 Exit Function
 Else
 For intI = 0 To frm.Count - 1
 Set ctl = frm(intI)
 If ctl.InSelection = True Then
 ' Is desired control selected?
 If UCase(ctl.Name) = UCase(strControlName) Then
 IsControlSelected = True
 Exit Function
 End If
 Else
 IsControlSelected = False
 End If
 Next intI
 End If
End Function

See also

Concepts

OptionGroup Object

Other resources

OptionGroup Object Members


TextBox.DefaultValue Property (Access)

 Copy code hover
[image]

TextBox.DefaultValue Property (Access)
See also Send feedback

Published: July 16, 2012

Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.

Syntax

expression .DefaultValue

expression A variable that represents a TextBox object.

Remarks

The DefaultValue property applies to all table fields except those fields with the data type of AutoNumber or OLE Object.

The DefaultValue property specifies text or an expression that's automatically entered in a control or field when a new record is created. For example, if you set the DefaultValue property for a text box control to =Now(), the control displays the current date and time. The maximum length for a DefaultValue property setting is 255 characters.

In Visual Basic, use a string expression to set the value of this property. For example, the following code sets the DefaultValue property for a text box control named PaymentMethod to "Cash"

VBA Copy code Copy code
Forms!frmInvoice!PaymentMethod.DefaultValue = """Cash"""
Note Note

To set this property for a field by using Visual Basic, use the ADO DefaultValue property or the DAO DefaultValue property.

The DefaultValue property is applied only when you add a new record. If you change the DefaultValue property, the change isn't automatically applied to existing records.

If you set the DefaultValue property for a form control that's bound to a field that also has a DefaultValue property setting defined in the table, the control setting overrides the table setting.

If you create a control by dragging a field from the field list, the field's DefaultValue property setting, as defined in the table, is applied to the control on the form although the control's DefaultValue property setting will remain blank.

One control can provide the default value for another control. For example, if you set the DefaultValue property for a control to the following expression, the control's default value is set to the DefaultValue property setting for the txtShipTo control.

VBA Copy code Copy code
=Forms!frmInvoice!txtShipTo

If the controls are on the same form, the control that's the source of the default value must appear earlier in the tab order than the control containing the expression.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Label.HelpContextId Property (Access)

 Copy code hover
[image]

Label.HelpContextId Property (Access)
See also Send feedback

Published: July 16, 2012

The HelpContextID property specifies the context ID of a topic in the custom Help file specified by the HelpFile property setting. Read/write Long.

Syntax

expression .HelpContextId

expression A variable that represents a Label object.

Remarks

Note Note

If you enter the context ID of the Help file topic as a positive number, the help topic will display in a "full" help topic window. If you add a minus sign ("-") in front of the context ID, the help topic will be displayed in a "pop-up" window. It is important to note the context ID does not have to have a negative number when authored in Microsoft Help Workshop. You must add the minus sign when setting the property to make the topic display in the pop-up window.

You can create a custom Help file to document forms, reports, or applications you create with Microsoft Access.

When you press the F1 key in Form view, Microsoft Access calls the Microsoft Help Workshop or Microsoft HTML Help Workshop application, loads the custom Help file specified by the HelpFile property setting for the form or report, and displays the Help topic specified by the HelpContextID property setting.

If a control's HelpContextID property setting is 0 (the default), Microsoft Access uses the form's HelpContextID and HelpFile properties to identify the Help topic to display. If you press F1 in a view other than Form view or if the HelpContextID property setting for both the form and the control is 0, a Microsoft Access Help topic is displayed.

See also

Concepts

Label Object

Other resources

Label Object Members


CurrentData.AllViews Property (Access)

 Copy code hover
[image]

CurrentData.AllViews Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the AllViews property to reference the AllViews collection and its related properties. Read-only AllViews object.

Syntax

expression .AllViews

expression A variable that represents a CurrentData object.

See also

Concepts

CurrentData Object

Other resources

CurrentData Object Members


ParentCatalog Property Example (VC++)

 Copy code hover
[image]

ParentCatalog Property Example (VC++)
Send feedback

The following code demonstrates how to use the ParentCatalog property to access a provider-specific property prior to appending a table to a catalog. The property is AutoIncrement, which creates an AutoIncrement field in a Microsoft Jet database.

Copy code Copy code

// BeginCreateAutoIncrColumnCpp
#import "c:\Program Files\Common Files\system\ado\msadox.dll" no_namespace
#import "c:\Program Files\Common Files\system\ado\msado15.dll"

#include "iostream.h"
#include "stdio.h"
#include "conio.h"

//Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void CreateAutoIncrColumnX(void);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 CreateAutoIncrColumnX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// CreateAutoIncrColumnX Function //
// //
//////////////////////////////////////////////////////////
void CreateAutoIncrColumnX(void)
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.
 _CatalogPtr m_pCatalog = NULL;
 _TablePtr m_pTable = NULL;

 // Define ADODB object pointers.
 ADODB::_ConnectionPtr m_pCnn = NULL;

 //Define string variables
 _bstr_t strCnn("Provider='Microsoft.JET.OLEDB.4.0';"
 "Data Source='c:\\Program Files\\Microsoft Office\\"
 "Office\\Samples\\Northwind.mdb';");
 try
 {
 TESTHR(hr = m_pCnn.CreateInstance(__uuidof(ADODB::Connection)));

 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof (Catalog)));

 TESTHR(hr = m_pTable.CreateInstance(__uuidof (Table)));

 // Connect the catalog.
 m_pCnn->Open (strCnn, "", "", NULL);

 m_pCatalog->PutActiveConnection(variant_t((IDispatch *)m_pCnn));

 m_pTable->Name="MyContacts";
 m_pTable->ParentCatalog = m_pCatalog;

 // Create fields and append them to the new Table object.
 m_pTable->Columns->Append("ContactId", adInteger,0);

 // Make the ContactId column and auto incrementing column
 m_pTable->Columns->GetItem("ContactId")->Properties->
 GetItem("AutoIncrement")->Value = true;
 m_pTable->Columns->Append("CustomerID", adVarWChar,0);
 m_pTable->Columns->Append("FirstName", adVarWChar,0);
 m_pTable->Columns->Append("LastName", adVarWChar,0);
 m_pTable->Columns->Append("Phone", adVarWChar, 20);
 m_pTable->Columns->Append("Notes", adLongVarWChar,0);
 m_pCatalog->Tables->Append(_variant_t((IDispatch*)m_pTable));

 // Refresh the database.
 m_pCatalog->Tables->Refresh();

 printf("Table 'MyContacts' is added.\n");

 // Delete new table, since this is only an example
 m_pCatalog->Tables->Delete("MyContacts");

 printf("Table 'MyContacts' is deleted.\n");
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }
 catch(...)
 {
 cout << "Error occured in CreateAutoIncrColumnX...."<< endl;
 }

 m_pCatalog = NULL;
}
// EndCreateAutoIncrColumnCpp


Step 3: Server Obtains a Recordset (RDS Tutorial)

 Copy code hover
[image]

Step 3: Server Obtains a Recordset (RDS Tutorial)
Send feedback

The server program uses the connect string and command text to query the data source for the desired rows. ADO is typically used to retrieve this Recordset, although other Microsoft data access interfaces, such as OLE DB, could be used.

A custom server program might look like this:

Copy code Copy code

Public Function ServerProgram(cn as String, qry as String) as Object
Dim rs as New ADODB.Recordset
 rs.CursorLocation = adUseClient
 rs.Open qry, cn
 rs.ActiveConnection = Nothing
 Set ServerProgram = rs
End Function


CustomControl.ObjectVerbs Property (Access)

 Copy code hover
[image]

CustomControl.ObjectVerbs Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ObjectVerbs property in Visual Basic to determine the list of verbs an OLE object supports. Read-only String.

Syntax

expression .ObjectVerbs(Index)

expression A variable that represents a CustomControl object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Long | An element in the array of supported verbs. This is a zero-based index, meaning zero (0) represents the first verb in the array, one (1) represents the second verb in the array, and so on.

Remarks

This property setting isn't available in Design view.

You can use the ObjectVerbs property with the ObjectVerbsCount property to display a list of the verbs supported by an OLE object. The ObjectVerbs property uses this list of verbs to determine which operation to perform when an OLE object is activated (when the Action property is set to acOLEActivate).

The Verb property setting is the position of a particular verb in the list of verbs returned by the ObjectVerbs property. For example, 1 specifies the first verb in the list (the Visual Basic command ObjectVerbs(0), or the first verb in the ObjectVerbs property array), 2 specifies the second verb in the list (the Visual Basic command ObjectVerbs(1), or the second verb in the ObjectVerbs property array), and so on.

The first verb in the ObjectVerbs property array, called by the Visual Basic command ObjectVerbs(0), is the default verb. If the Verb property hasn't been set, this verb specifies the operation performed when the OLE object is activated.

The list of verbs an object supports varies, depending on the state of the object. To update the list of verbs an object supports, set the control'sAction property to acOLEFetchVerbs. Be sure to update the list of verbs before presenting it to the user.

Example

The following example returns the verbs supported by the OLE object in the OLE1 control and displays each verb in a message box.

VBA Copy code Copy code
Sub GetVerbList(frm As Form, OLE1 As Control)
 Dim intX As Integer, intNumVerbs As Integer
 Dim strVerbList As String

 ' Update verb list.
 With frm!OLE1
 .Action = acOLEFetchVerbs
 intNumVerbs = .ObjectVerbsCount
 For intX = 0 To intNumVerbs - 1
 strVerbList = strVerbList & .ObjectVerbs(intX) & "; "
 Next intX
 End With

 ' Display verbs in message box.
 MsgBox Left(strVerbList, Len(strVerbList) - 2)
End Sub

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


CheckBox Events (Access)

 Copy code hover
[image]

CheckBox Events (Access)
Send feedback

Published: July 16, 2012

This object has the following events:

Events

Name | Description
AfterUpdate | The AfterUpdate event occurs after changed data in a control or record is updated.
BeforeUpdate | The BeforeUpdate event occurs before changed data in a control or record is updated.
Click | The Click event occurs when the user presses and then releases a mouse button over an object.
DblClick | The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.
Enter | The Enter event occurs before a control actually receives the focus from a control on the same form or report.
Exit | The Exit event occurs just before a control loses the focus to another control on the same form or report.
GotFocus | The GotFocus event occurs when the specified object receives the focus.
KeyDown | The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyPress | The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
KeyUp | The KeyUp event occurs when the user releases a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.
LostFocus | The LostFocus event occurs when the specified object loses the focus.
MouseDown | The MouseDown event occurs when the user presses a mouse button.
MouseMove | The MouseMove event occurs when the user moves the mouse.
MouseUp | The MouseUp event occurs when the user releases a mouse button.


TableDef.LastUpdated Property (DAO)

 Copy code hover
[image]

TableDef.LastUpdated Property (DAO)
Send feedback

Returns the date and time of the most recent change made to an object. Read-only Variant.

Syntax

expression .LastUpdated

expression A variable that represents a TableDef object.

Remarks

DateCreated and LastUpdated return the date and time that the object was created or last updated. In a multiuser environment, users should get these settings directly from the file server to avoid discrepancies in the DateCreated and LastUpdated property settings.


Macro function reference (Access 2013 custom web app)

 Copy code hover
[image]

Macro function reference (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

In this section

  • Data blocks (Access 2013 custom web app)

  • Data actions (Access 2013 custom web app)

  • Data entry operations (Access 2013 custom web app)

  • Database objects (Access 2013 custom web app)

  • Filter/query/search (Access 2013 custom web app)

  • Macro commands (Access 2013 custom web app)

  • Program flow (Access 2013 custom web app)

  • User interface commands (Access 2013 custom web app)


Invalid SQL syntax - expected a procedure name. (Error 3781)

 Copy code hover
[image]

Invalid SQL syntax - expected a procedure name. (Error 3781)
Send feedback

This error occurs when trying to create or drop a procedure using SQL DDL's CREATE PROCEDURE or DROP PROCEDURE syntax. It occurs if a valid name is not specified. For example, the following statement would generate the error: DROP PROCEDURE.


FilterColumn Property (RDS)

 Copy code hover
[image]

FilterColumn Property (RDS)
Send feedback

Indicates the column on which to evaluate the filter criteria.

Syntax

DataControl.FilterColumn = String

Parameters

  • DataControl

  • An object variable that represents an RDS.DataControl object.

  • String

  • A String value that specifies the column on which to evaluate the filter criteria. The filter criteria are specified in the FilterCriterion property.

Remarks

The SortColumn, SortDirection, FilterValue, FilterCriterion, and FilterColumn properties provide sorting and filtering functionality on the client-side cache. The sorting functionality orders records by values from one column. The filtering functionality displays a subset of records based on find criteria, while the full Recordset is maintained in the cache. The Reset method will execute the criteria and replace the current Recordset with an updatable Recordset.


Data Entry Operations

 Copy code hover
[image]

Data Entry Operations
Send feedback

In this section

  • DeleteRecord Macro Action


Attachment.Section Property (Access)

 Copy code hover
[image]

Attachment.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .Section

expression A variable that represents an Attachment object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


Field

 Copy code hover
[image]

Field <name> already exists in table <name>. (Error 3380)
Send feedback

You have entered the same field name twice. Rewrite your code, giving each field a unique name. You should also check to see if the field name exists in the Fields collection.


AcDisplayAsHyperlink Enumeration (Access)

 Copy code hover
[image]

AcDisplayAsHyperlink Enumeration (Access)
Send feedback

Published: July 16, 2012

Used with the DisplayAsHyperlink property to specify whether to display the contents of a text box or combo box as a hyperlink.

Version Information

Version Added: Access 2007

Name | Value | Description
acDisplayAsHyperlinkAlways | 1 | Always display the contents of the control as a hyperlink.
acDisplayAsHyperlinkIfHlink | 0 | Display the contents of the control as a hyperlink only when its contents are in the form of a Uniform Resource Locator (URL).
acDisplayAsHyperlinkOnScreenOnly | 2 | Display the contents of the control as a hyperlink only on the screen.


NavigationButton.ThemeFontIndex Property (Access)

 Copy code hover
[image]

NavigationButton.ThemeFontIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the font index that represents a font in the applied theme associated with the FontName property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .ThemeFontIndex

expression A variable that represents a NavigationButton object.

Remarks

The ThemeFontIndex property uses one of the values listed in the following table.

Value | Description
0 | Header font
1 (Default) | Detail font

If no theme is applied, the ThemeFontIndex property contains -1.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


NavigationControl.BottomPadding Property (Access)

 Copy code hover
[image]

NavigationControl.BottomPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the list box and its bottom gridline. Read/write Integer.

Version Information

Version Added: Access 2010

Syntax

expression .BottomPadding

expression A variable that represents a NavigationControl object.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Ordinal Property (ADO MD Position)

 Copy code hover
[image]

Ordinal Property (ADO MD Position)
Send feedback

Uniquely identifies a position along an axis.

Return Values

Returns a Long integer and is read-only.

Remarks

The Ordinal of a Position object corresponds to the index of the Position within the Positions collection.

A cell can quickly be retrieved using the Ordinal of the Position along each axis with the Item property of the Cellset object.


OptionButton.ColumnWidth Property (Access)

 Copy code hover
[image]

OptionButton.ColumnWidth Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ColumnWidth property to specify the width of a column in Datasheet view. Read/write Integer.

Syntax

expression .ColumnWidth

expression A variable that represents an OptionButton object.

Remarks

In Visual Basic , the ColumnWidth property setting is an Integer value that represents the column width in twips. You can specify a width or use one of the following predefined settings.

Setting | Description
0 | Hides the column.
-1 | (Default) Sizes the column to the default width.
Note Note

The ColumnWidth property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

Setting this property to 0, or resizing the field to a zero width in Datasheet view, sets the field's ColumnHidden property to True (-1) and hides the field in Datasheet view.

Setting a field's ColumnHidden property to False (0) restores the field's ColumnWidth property to the value it had before the field was hidden. For example, if the ColumnWidth property was -1 prior to the field being hidden by setting the property to 0, changing the field's ColumnHidden property to False resets the ColumnWidth to -1.

The ColumnWidth property for a field isn't available when the field's ColumnHidden property is set to True.

Example

This example takes effect in Datasheet view of the open Customers form. It sets the row height to 450 twips and sizes the column to fit the size of the visible text.

VBA Copy code Copy code
Forms![Customers].RowHeight = 450
Forms![Customers]![Address].ColumnWidth = -2

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


ExecuteOptions Property (RDS)

 Copy code hover
[image]

ExecuteOptions Property (RDS)
Send feedback

Indicates whether asynchronous execution is enabled.

Settings and Return Values

Sets or returns one of the following values.

Constant | Description
adcExecSync | Executes the next refresh of the Recordset synchronously.
adcExecAsync | Default. Executes the next refresh of the Recordset asynchronously.
Note Note

Each client-side executable file that uses these constants must provide declarations for them. You can cut and paste the constant declarations that you want from the file Adcvbs.inc, located in the C:\Program Files\Common Files\System\MSADC folder.

Remarks

If ExecuteOptions is set to adcExecAsync, then this asynchronously executes the next Refresh call on the RDS.DataControl object's Recordset.

If you try to call Reset, Refresh, SubmitChanges, CancelUpdate, or Recordset while another asynchronous operation that might change the RDS.DataControl object's Recordset is executing, an error occurs.

If an error occurs during an asynchronous operation, the RDS.DataControl object's ReadyState value changes from adcReadyStateLoaded to adcReadyStateComplete, and the Recordset property value remains Nothing.


Submacro Macro Statement

 Copy code hover
[image]

Submacro Macro Statement
Send feedback

The Submacro statement defines a seperate macro in the Macro Designer window.

Setting

The Submacro action has the following arguments.

Argument | Required | Description
Name | Yes | A string that appears as the name of the macro.

Example

The following macro demonstrates the use of the OnError action. In this example, the OnError action specifies that Access run a custom error handling macro named ErrorHandler when an error occurs. When an error occurs, the CatchErrors submacro is called. If the error number is 2102, a specific message is displayed and macro execution is halted. Otherwise, a message describing the error is displayed and the macro is paused so that you can perform additional troubleshooting. The ErrorHandler macro displays a message box that refers to the MacroError object to display information about the error.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

Copy code Copy code
/* MACRO: mcrThrowErrors                                  */
/* PURPOSE: Error handling using macros in Access 2010    */

OnError
    Go to Macro Name
    Macro Name CatchErrors

OpenForm
    Form Name frmSamples
    View Form
    Filter Name
    Where Condition
    Data Mode
    Window Mode Normal

MessageBox
    Message This message appears after the OpenForm action
    Beep Yes
    Type None
    Title

/* SUBMACRO: CatchErrors                                   */

SubMacro: CatchErrors
    If [MacroError].[Number]=2101 Then
        MessageBox
            Message Cannot find the specified form!
            Beep Yes
            Type Critical
            Title
        StopMacro

    Else
        MessageBox
            Message =[MacroErro].[Description]
            Beep Yes
            Type None
            Title Unhandled Error

        SingleStep
    End If

End SubMacro

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


Syntax error in date. (Error 2421)

 Copy code hover
[image]

Syntax error in date. (Error 2421)
Send feedback

Date syntax is incorrect. This error occurs if you specify an invalid date. For example, 9/31/94 is invalid (September has only 30 days).


Image.TopPadding Property (Access)

 Copy code hover
[image]

Image.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the image control and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .TopPadding

expression A variable that represents an Image object.

See also

Concepts

Image Object

Other resources

Image Object Members


Levels Collection Properties, Methods, and Events (ADO MD)

 Copy code hover
[image]

Levels Collection Properties, Methods, and Events (ADO MD)
Send feedback

Properties

Count Property

Item Property

Methods

Refresh Method

Events

None.


Printer Object (Access)

 Copy code hover
[image]

Printer Object (Access)
See also Send feedback

Published: July 16, 2012

A Printer object corresponds to a printer available on your system.

Remarks

A Printer object is a member of the Printers collection.

To return a reference to a particular Printer object in the Printers collection, use any of the following syntax forms.

Syntax | Description
Printers!devicename | The devicename argument is the name of the Printer object as returned by the DeviceName property.
Printers("devicename") | The devicename argument is the name of the Printer object as returned by the DeviceName property.
Printers(index) | The index argument is the numeric position of the object within the collection. The valid range is from 0 to Printers.Count-1.

You can use the properties of the Printer object to set the printing characteristics for any of the printers available on your system.

Use the ColorMode , Copies , Duplex , Orientation , PaperBin , PaperSize , and PrintQuality properties to specify print settings for a particular printer.

Use the LeftMargin , RightMargin, TopMargin , BottomMargin , ColumnSpacing , RowSpacing , DataOnly , DefaultSize , ItemLayout , ItemsAcross , ItemSizeHeight , and ItemSizeWidth properties to specify how Microsoft Access should format the appearance of data on printed pages.

Use the DeviceName , DriverName , and Port properties to return system information about a particular printer.

Example

The following example displays system information about the first printer in the Printers collection.

VBA Copy code Copy code
Dim prtFirst As Printer

Set prtFirst = Application.Printers(0)

With prtFirst
 MsgBox "Device name: " & .DeviceName & vbCr _
 & "Driver name: " & .DriverName & vbCr _
 & "Port: " & .Port
End With

See also

Concepts

Access Object Model Reference

Other resources

Printer Object Members


You must use the dbSeeChanges option with OpenRecordset when accessing a SQL Server table that has an IDENTITY column. (Error 3622)

 Copy code hover
[image]

You must use the dbSeeChanges option with OpenRecordset when accessing a SQL Server table that has an IDENTITY column. (Error 3622)
Send feedback

The server-generated IDENTITY values cannot be reflected at the client side unless you use the DAO property dbSeeChanges.


Handler Property Example (VJ++)

 Copy code hover
[image]

Handler Property Example (VJ++)
Send feedback

This example demonstrates the RDS DataControl object Handler property. (See DataFactory Customization for more details.)

Assume the following sections in the parameter file, Msdfmap.ini, located on the server:

Copy code Copy code

[connect AuthorDataBase]
Access=ReadWrite
Connect="DSN=Pubs"
[sql AuthorById]
SQL="SELECT * FROM Authors WHERE au_id = ?"

Your code looks like the following. The command assigned to the SQL property will match the AuthorById identifier and will retrieve a row for author Michael O'Leary. Although the Connect property in your code specifies the Northwind data source, that data source will be overwritten by the Msdfmap.ini connect section. The DataControl object's Recordset property is assigned to a disconnected Recordset object purely as a coding convenience.

Copy code Copy code
// BeginHandlerJimport com.ms.wfc.data.*;
import com.ms.wfc.data.rds.*;import java.io.* ;
public class HandlerX{
// The main entry point for the application.public static void main (String[] args)
{HandlerX();
System.exit(0);}
// HandlerX functionstatic void HandlerX()
{// Define ADO Objects.
Recordset rstAuthors = null;// Declarations.
BufferedReader in =new BufferedReader (new InputStreamReader(System.in));
int intCount = 0;int intDisplaysize = 15;
try{
IBindMgr dc = (IBindMgr) new DataControl();dc.setServer("MyServer");
dc.setConnect("Data Source=Northwind");dc.setSQL("AuthorById(267-41-2394)");
dc.Refresh(); // Retrieve the record.// Use another recordset as a convenience.
rstAuthors = (Recordset)dc.getRecordset();System.out.println("Author is '" +
rstAuthors.getField("au_fname").getString() +" " +
rstAuthors.getField("au_lname").getString() +"'");
System.out.println("\nPress <Enter> to continue..");in.readLine();
}catch( AdoException ae )
{// Notify user of any errors that result from ADO.
// As passing a Recordset, check for null pointer first.if (rstAuthors != null)
{PrintProviderError(rstAuthors.getActiveConnection());
}else
{System.out.println("Exception: " + ae.getMessage());
}}
// System read requires this catch.catch( java.io.IOException je)
{PrintIOError(je);
}catch(java.lang.UnsatisfiedLinkError e)
{System.out.println("Exception: " + e.getMessage());
}catch(java.lang.NullPointerException ne)
{System.out.println(
"Exception: Attempt to use null where an object is required.");}
finally{
// Cleanup objects before exit.if (rstAuthors != null)
if (rstAuthors.getState() == 1)rstAuthors.close();
}}
// PrintProviderError Functionstatic void PrintProviderError( Connection Cnn1 )
{// Print Provider errors from Connection object.
// ErrItem is an item object in the Connection's Errors collection.com.ms.wfc.data.Error ErrItem = null;
long nCount = 0;int i = 0;
nCount = Cnn1.getErrors().getCount();// If there are any errors in the collection, print them.
if( nCount > 0);{
// Collection ranges from 0 to nCount - 1for (i = 0; i< nCount; i++)
{ErrItem = Cnn1.getErrors().getItem(i);
System.out.println("\t Error number: " + ErrItem.getNumber()+ "\t" + ErrItem.getDescription() );
}}
}// PrintIOError Function
static void PrintIOError( java.io.IOException je){
System.out.println("Error \n");System.out.println("\tSource = " + je.getClass() + "\n");
System.out.println("\tDescription = " + je.getMessage() + "\n");}
}


FormatCondition.Expression1 Property (Access)

 Copy code hover
[image]

FormatCondition.Expression1 Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Expression1 property to return the values of a conditional format within a FormatCondition object. Read-only String.

Syntax

expression .Expression1

expression A variable that represents a FormatCondition object.

Remarks

The Expression1 property returns a Variant value or expression associated with the first part of the conditional format.

See also

Concepts

FormatCondition Object

Other resources

FormatCondition Object Members


Application.Forms Property (Access)

 Copy code hover
[image]

Application.Forms Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Forms property to return a read-only reference to the Forms collection and its related properties.

Syntax

expression .Forms

expression A variable that represents an Application object.

Remarks

The properties of the Forms collection in Visual Basic refer to forms that are currently open.

See also

Concepts

Application Object

Other resources

Application Object Members


Entity Object (Access)

 Copy code hover
[image]

Entity Object (Access)
See also Send feedback

Published: July 16, 2012

Represents an entity defined in a Data Service data connection.

Version Information

Version Added: Access 2010

Remarks

Use the Item property of the Entitiesto return an Entity object.

Use the Operations property to returnt he operations defined for the specified entity.

A Data Service data connection may contain one or more entities. Each entity specifies an external content type. Used throughout the functionality and services offered by Business Connectivity Services, external content types are reusable metadata descriptions of connectivity information and data definitions plus the behaviors you want to apply to a certain category of external data.

For more information about external content types, see What Are External Content Types?.

See also

Concepts

Access Object Model Reference

Other resources

Entity Object Members


FieldEnum

 Copy code hover
[image]

FieldEnum
Send feedback

Specifies the special fields referenced in a Record object's Fields collection.

Remarks

These constants provide a "shortcut" to accessing special fields associated with a Record. Retrieve the Field object from the Fields collection, and then obtain its contents with the Field object's Value property.

Constant | Value | Description
adDefaultStream | -1 | References the field containing the default Stream object associated with a Record.
adRecordURL | -2 | References the field containing the absolute URL string for the current Record.


ToggleButton.HoverTint Property (Access)

 Copy code hover
[image]

ToggleButton.HoverTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the HoverColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .HoverTint

expression A variable that represents a ToggleButton object.

Remarks

The HoverTint property contains a numeric expression that can be used to lighten the theme color in the HoverColor property. The default value of the HoverTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Position Object (ADO MD Reference)

 Copy code hover
[image]

Position Object (ADO MD Reference)
Send feedback

In this section

  • Position Object (ADO MD)

  • Position Properties, Methods, and Events (ADO MD)


ComboBox.Section Property (Access)

 Copy code hover
[image]

ComboBox.Section Property (Access)
See also Send feedback

Published: July 16, 2012

You can identify these controls by the section of a form or report where the control appears. Read/write Integer.

Syntax

expression .Section

expression A variable that represents a ComboBox object.

Remarks

For controls, you can use the Section property to determine which section of a form or report a control is in.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Module.CountOfDeclarationLines Property (Access)

 Copy code hover
[image]

Module.CountOfDeclarationLines Property (Access)
See also Send feedback

Published: July 16, 2012

The CountOfDeclarationLines property returns a Long value indicating the number of lines of code in the Declarations section in a standard module or class module. Read-only Long.

Syntax

expression .CountOfDeclarationLines

expression A variable that represents a Module object.

Remarks

Lines in a module are numbered beginning with 1.

The value of the CountOfDeclarationLines property is equal to the line number of the last line of the Declarations section. You can use this property to determine where the Declarations section ends and the body of the module begins.

Example

The following example counts the number of lines and declaration lines in each standard module in the Modules collection. Note that the Modules collection contains only modules that are open in the module editor.

VBA Copy code Copy code
Public Sub ModuleLineTotal(ByVal strModuleName As String)

 Dim mdl As Module

 ' Open module to include in Modules collection.
 DoCmd.OpenModule strModuleName

 ' Return reference to Module object.
 Set mdl = Modules(strModuleName)

 ' Print number of lines in module.
 Debug.Print "Number of lines: ", mdl.CountOfLines

 ' Print number of declaration lines.
 Debug.Print "Number of declaration lines: ", _
 mdl.CountOfDeclarationLines

End Sub

See also

Concepts

Module Object

Other resources

Module Object Members


Recordset.MoveLast Method (DAO)

 Copy code hover
[image]

Recordset.MoveLast Method (DAO)
Send feedback

Moves to the last record in a specified Recordset object and make that record the current record.

Syntax

expression .MoveLast(Options)

expression A variable that represents a Recordset object.

Parameters

Name | Required/Optional | Data Type | Description
Options | Optional | Long | Set to dbRunAsync to rune the call to MoveLast asynchronously.

Remarks

Use the Move methods to move from record to record without applying a condition.

If you edit the current record, be sure you use the Update method to save the changes before you move to another record. If you move to another record without updating, your changes are lost without warning.

When you open a Recordset, the first record is current and the BOF property is False. If the Recordset contains no records, the BOF property is True, and there is no current record.

If the first or last record is already current when you use MoveFirst or MoveLast, the current record doesn't change.

If recordset refers to a table-type Recordset (Microsoft Access workspaces only), movement follows the current index. You can set the current index by using the Index property. If you don't set the current index, the order of returned records is undefined.

Note Note

You can use the MoveLast method to fully populate a dynaset- or snapshot-type Recordset to provide the current number of records in the Recordset. However, if you use MoveLast in this way, you can slow down your application's performance. You should only use MoveLast to get a record count if it is absolutely necessary to obtain an accurate record count on a newly opened Recordset. If you use the dbRunAsync constant with MoveLast, the method call is asynchronous. You can use the StillExecuting property to determine when the Recordset is fully populated, and you can use the Cancel method to terminate execution of the asynchronous MoveLast method call.

You can't use the MoveFirst, MoveLast, and MovePrevious methods on a forward-only-type Recordset object.

To move the position of the current record in a Recordset object a specific number of records forward or backward, use the Move method.


Form.InputParameters Property (Access)

 Copy code hover
[image]

Form.InputParameters Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the InputParameters property to specify or determine the input parameters that are passed to a SQL statement in the RecordSource property of a form or report or a stored procedure when used as the record source within a Microsoft Access project (.adp). Read/write String.

Syntax

expression .InputParameters

expression A variable that represents a Form object.

Remarks

When used with a RecordSource property:

An example InputParameters property string used with a SQL statement in the RecordSource property would use the following syntax.

state char=[Forms]![formname]![StateList], salesyear smallint=[Forms]![formname]![Enter year of interest]

This would result in the state parameter being set to the current value of the StateList control, and the user getting prompted for the salesyear parameter. If there were any other parameters that were not in this list, they would get default values assigned.

The query should be executed with one ? marker for each non-default parameter in the InputParameters list.

A refresh or requery command (via menu, keyboard, or Navigation Bar) in Access should trigger a reexecute of the query. Users can do this in code by calling the standard Recordset.Requery method. If the value of a parameter is bound to a control on the form, the current value of the control is used at requery time. The query is not automatically reexecuted when the value of the control changes.

When used with a stored procedure:

An example InputParameters property string used with stored procedure would be:

@state char=[Forms]![formname]![StateList], @salesyear smallint=[Forms]![formname]![Enter year of interest]

This would result in the @state parameter being set to the current value of the StateList control, and the user getting prompted for the @salesyear parameter. If there were any other parameters to the stored proc that were not in this list, they would get default values assigned.

The stored procedure should be executed using a command string containing the {call } syntax with one ? marker for each non-default parameter in the InputParameters list.

A refresh or requery command (via menu, keyboard, or Navigation Bar) in Access should trigger a reexecute of the stored procedure. Users can do this in code by calling the standard Recordset.Requery method. If the value of a parameter is bound to a control on the form, the current value of the control is used at requery time. The stored procedure is not automatically reexecuted when the value of the control changes.

This builder dialog is invoked when a stored procedure is first selected as the record source of a form if the stored procedure has any parameters. After initial creation of the InputParameters string, this same dialog is used as a builder for changing the string. In this case however the list of parameters comes from what already exists in the string.

Parameter values are also settable in code using the ActiveX Data Object's (ADO) Command and Parameter objects. If the result returns a result set, a form can be bound to it by setting the form's Recordset property. ADO coding is the only way to handle stored procedures that do not return result sets such as action queries, those that return output parameters, or those that return multiple result sets.

See also

Concepts

Form Object

Other resources

Form Object Members


ComplexType Object (DAO)

 Copy code hover
[image]

ComplexType Object (DAO)
Send feedback

Represents a multi-valued field.

Version Information

Version Added: Access 2007

Remarks

Use the Fields property to return the Fields collection for the ComplexType object.


ADOX API Reference Topics

 Copy code hover
[image]

ADOX API Reference Topics
Send feedback

In this section

  • ADOX API Reference

  • ADOX Objects Reference

  • ADOX Collections Reference

  • ADOX Properties Reference

  • ADOX Methods Reference

  • ADOX Enumerated Constants Reference

  • ADOX Code Example Topics


CREATE TABLE Statement (Microsoft Access SQL)

 Copy code hover
[image]

CREATE TABLE Statement (Microsoft Access SQL)
Send feedback

Creates a new table.

Note Note

The Microsoft Access database engine does not support the use of CREATE TABLE, or any of the DDL statements, with non-Microsoft Access database engine databases. Use the DAO Create methods instead.

Syntax

CREATE [TEMPORARY] TABLE table (field1 type [(size)] [NOT NULL] [WITH COMPRESSION | WITH COMP] [index1] [, field2 type [(size)] [NOT NULL] [index2] [, …]] [, CONSTRAINT multifieldindex [, …]])

The CREATE TABLE statement has these parts:

Part | Description
table | The name of the table to be created.
field1, field2 | The name of field or fields to be created in the new table. You must create at least one field.
type | The data type of field in the new table.
size | The field size in characters (Text and Binary fields only).
index1, index2 | A CONSTRAINT clause defining a single-field index. For more information on how to create this index, see CONSTRAINT Clause.
multifieldindex | A CONSTRAINT clause defining a multiple-field index. For more information on how to create this index, see CONSTRAINT Clause.

Remarks

Use the CREATE TABLE statement to define a new table and its fields and field constraints. If NOT NULL is specified for a field, then new records are required to have valid data in that field.

A CONSTRAINT clause establishes various restrictions on a field, and can be used to establish the primary key. You can also use the CREATE INDEX statement to create a primary key or additional indexes on existing tables.

You can use NOT NULL on a single field or within a named CONSTRAINT clause that applies to either a single field or to a multiple-field named CONSTRAINT. However, you can apply the NOT NULL restriction only once to a field. Attempting to apply this restriction more than once results in a run-time error.

When a TEMPORARY table is created it is visible only within the session in which it was created. It is automatically deleted when the session is terminated. Temporary tables can be accessed by more than one user.

The WITH COMPRESSION attribute can be used only with the CHARACTER and MEMO (also known as TEXT) data types and their synonyms.

The WITH COMPRESSION attribute was added for CHARACTER columns because of the change to the Unicode character representation format. Unicode characters uniformly require two bytes for each character. For existing Microsoft® Jet databases that contain predominately character data, this could mean that the database file would nearly double in size when converted to the Microsoft Access database engine format. However, Unicode representation of many character sets, those formerly denoted as Single-Byte Character Sets (SBCS) can easily be compressed to a single byte. If you define a CHARACTER column with this attribute, data will automatically be compressed as it is stored and uncompressed when retrieved from the column.

MEMO columns can also be defined to store data in a compressed format. However, there is a limitation. Only instances of MEMO columns that, when compressed, will fit within 4096 bytes or less, will be compressed. All other instances of MEMO columns will remain uncompressed. This means that within a given table, for a given MEMO column, some data may be compressed and some data may not be compressed.

Example

This example creates a new table called ThisTable with two text fields.

VBA Copy code Copy code
Sub CreateTableX1()

    Dim dbs As Database

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Create a table with two text fields.
    dbs.Execute "CREATE TABLE ThisTable " _
        & "(FirstName CHAR, LastName CHAR);"

    dbs.Close

End Sub

This example creates a new table called MyTable with two text fields, a Date/Time field, and a unique index made up of all three fields.

VBA Copy code Copy code
Sub CreateTableX2()

    Dim dbs As Database

    ' Modify this line to include the path to Northwind
    ' on your computer.

    Set dbs = OpenDatabase("Northwind.mdb")

    ' Create a table with three fields and a unique
    ' index made up of all three fields.
    dbs.Execute "CREATE TABLE MyTable " _
        & "(FirstName CHAR, LastName CHAR, " _
        & "DateOfBirth DATETIME, " _
        & "CONSTRAINT MyTableConstraint UNIQUE " _
        & "(FirstName, LastName, DateOfBirth));"

    dbs.Close

End Sub

This example creates a new table with two text fields and an Integer field. The SSN field is the primary key.

VBA Copy code Copy code
Sub CreateTableX3()

     Dim dbs As Database

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Create a table with three fields and a primary
    ' key.
    dbs.Execute "CREATE TABLE NewTable " _
        & "(FirstName CHAR, LastName CHAR, " _
        & "SSN INTEGER CONSTRAINT MyFieldConstraint " _
        & "PRIMARY KEY);"

    dbs.Close

End Sub


Attachment.KeyPress Event (Access)

 Copy code hover
[image]

Attachment.KeyPress Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Version Information

Version Added: Access 2007

Syntax

expression .KeyPress(KeyAscii, )

expression A variable that represents an Attachment object.

Parameters

Name | Required/Optional | Data Type | Description
KeyAscii | Required | Integer | Returns a numeric ANSI key code. The KeyAscii argument is passed by reference; changing it sends a different character to the object. Setting the KeyAscii argument to 0 cancels the keystroke so that the object doesn't recognize that a key was pressed.

Remarks

Note Note

The KeyPress event applies only to forms and controls on a form, not controls on a report.

To run a macro or event procedure when this event occurs, set the OnKeyPress property to the name of the macro or to [Event Procedure].

The object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down an ANSI key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, and then the KeyUp event occurs.

A KeyPress event can involve any printable keyboard character, the CTRL key combined with a character from the standard alphabet or a special character, and the ENTER or BACKSPACE key. You can use the KeyDown and KeyUp event procedures to handle any keystroke not recognized by the KeyPress event, such as function keys, navigation keys, and any combinations of these with keyboard modifiers (ALT, SHIFT, or CTRL keys). Unlike the KeyDown and KeyUp events, the KeyPress event doesn't indicate the physical state of the keyboard; instead, it indicates the ANSI character that corresponds to the pressed key or key combinations.

KeyPress interprets the uppercase and lowercase of each character as separate key codes and, therefore, as two separate characters.

Note Note

The BACKSPACE key is part of the ANSI character set, but the DEL key isn't. If you delete a character in a control by using the BACKSPACE key, you cause a KeyPress event; if you use the DEL key, you don't.

The KeyDown and KeyPress events occur when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

For example, if you go to a new record and type a character in the first control in the record, the following events occur:

Current (for the new record)

ß

Enter (for the first control in the new record)

ß

GotFocus (for the control)

ß

KeyDown (for the control)

ß

KeyPress (for the control)

ß

BeforeInsert (for the new record in the form)

ß

Change (for the control if it's a text box or combo box)

ß

KeyUp (for the control)

See also

Concepts

Attachment Object

Other resources

Attachment Object Members


AllForms.Application Property (Access)

 Copy code hover
[image]

AllForms.Application Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Application property to access the active Microsoft Access Application object and its related properties. Read-only Application object.

Syntax

expression .Application

expression A variable that represents an AllForms object.

Remarks

The Application property is set by Microsoft Access and is read-only in all views.

Each Microsoft Access object has an Application property that returns the current Application object. You can use this property to access any of the object's properties. For example, you could refer to the menu bar for the Application object from the current form by using the following syntax:

VBA Copy code Copy code
Me.Application.MenuBar

See also

Concepts

AllForms Collection

Other resources

AllForms Object Members


Index.CreateField Method (DAO)

 Copy code hover
[image]

Index.CreateField Method (DAO)
Send feedback

Creates a new Field object (Microsoft Access workspaces only).

Syntax

expression .CreateField(Name, Type, Size)

expression A variable that represents an Index object.

Parameters

Name | Required/Optional | Data Type | Description
Name | Optional | Variant | A String that uniquely names the new Field object. See the Name property for details on valid Field names.
Type | Optional | Variant | Argument not supported for this object.
Size | Optional | Variant | Argument not supported for this object.

Return Value

Field

Remarks

You can use the CreateField method to create a new field, as well as specify the name, data type, and size of the field. If you omit one or more of the optional parts when you use CreateField, you can use an appropriate assignment statement to set or reset the corresponding property before you append the new object to a collection. After you append the new object, you can alter some but not all of its property settings. See the individual property topics for more details.

The type and size arguments apply only to Field objects in a TableDef object. These arguments are ignored when a Field object is associated with an Index or Relation object.

If name refers to an object that is already a member of the collection, a run-time error occurs when you use the Append method.

To remove a Field object from a Fields collection, use the Delete method on the collection. You can't delete a Field object from a TableDef object's Fields collection after you create an index that references the field.


Update Method (ADO)

 Copy code hover
[image]

Update Method (ADO)
Send feedback

Saves any changes you make to the current row of a Recordset object, or the Fields collection of a Record object.

Syntax

recordset.Update Fields, Values

record. Fields.Update

Parameters

  • Fields

  • Optional. A Variant that represents a single name, or a Variant array that represents names or ordinal positions of the field or fields you wish to modify.

  • Values

  • Optional. A Variant that represents a single value, or a Variant array that represents values for the field or fields in the new record.

Remarks

Recordset

Use the Update method to save any changes you make to the current record of a Recordset object since calling the AddNew method or since changing any field values in an existing record. The Recordset object must support updates.

To set field values, do one of the following:

  • Assign values to a Field object's Value property and call the Update method.

  • Pass a field name and a value as arguments with the Update call.

  • Pass an array of field names and an array of values with the Update call.

When you use arrays of fields and values, there must be an equal number of elements in both arrays. Also, the order of field names must match the order of field values. If the number and order of fields and values do not match, an error occurs.

If the Recordset object supports batch updating, you can cache multiple changes to one or more records locally until you call the UpdateBatch method. If you are editing the current record or adding a new record when you call the UpdateBatch method, ADO will automatically call the Update method to save any pending changes to the current record before transmitting the batched changes to the provider.

If you move from the record you are adding or editing before calling the Update method, ADO will automatically call Update to save the changes. You must call the CancelUpdate method if you want to cancel any changes made to the current record or discard a newly added record.

The current record remains current after you call the Update method.

Record

The Update method finalizes additions, deletions, and updates to fields in the Fields collection of a Record object.

For example, fields deleted with the Delete method are marked for deletion immediately but remain in the collection. The Update method must be called to actually delete these fields from the provider's collection.


ActualSize and DefinedSize Properties Example (VB)

 Copy code hover
[image]

ActualSize and DefinedSize Properties Example (VB)
Send feedback

This example uses the ActualSize and DefinedSize properties to display the defined size and actual size of a field.

Copy code Copy code

'BeginActualSizeVB

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

Public Sub Main()
 On Error GoTo ErrorHandler

 'recordset and connection variables
 Dim rstStores As ADODB.Recordset
 Dim SQLStores As String
 Dim strCnxn As String
 'record variables
 Dim strMessage As String

 ' Open a recordset for the Stores table
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Northwind';Integrated Security='SSPI';"
 Set rstStores = New ADODB.Recordset

 SQLStores = "Suppliers"
 rstStores.Open SQLStores, strCnxn, adOpenForwardOnly, adLockReadOnly, adCmdTable
 'the above two lines of code are identical as the default values for
 'CursorType and LockType arguments match those indicated

 ' Loop through the recordset displaying the contents
 ' of the store_name field, the field's defined size,
 ' and its actual size.
 rstStores.MoveFirst

 Do Until rstStores.EOF
 strMessage = "Company name: " & rstStores!CompanyName & _
 vbCrLf & "Defined size: " & _
 rstStores!CompanyName.DefinedSize & _
 vbCrLf & "Actual size: " & _
 rstStores!CompanyName.ActualSize & vbCrLf

 MsgBox strMessage, vbOKCancel, "ADO ActualSize Property (Visual Basic)"
 rstStores.MoveNext
 Loop

 ' clean up
 rstStores.Close
 Set rstStores = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstStores Is Nothing Then
 If rstStores.State = adStateOpen Then rstStores.Close
 End If
 Set rstStores = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndActualSizeVB


ADO/WFC Programming

 Copy code hover
[image]

ADO/WFC Programming
Send feedback

For Microsoft Visual J++ 6.0, ADO has been extended to work with Windows Foundation Classes (WFC) in the following ways. First, a set of Java classes has been implemented that extends the ADO interfaces and creates notifications interesting to the Java programmer; the Java classes also expose functions that return Java types to the user. To improve performance, the Java class directly accesses the native data types in the OLE DB rowset object, and returns them to the Java programmer as Java types without first converting them to and from a variant. ADO has also been extended to work with event notifications in the WFC framework.

ADO for Windows Foundation Classes (ADO/WFC) supports all the standard ADO methods, properties, objects, and events. However, operations that require a variant as a parameter and show excellent performance in a language such as Microsoft Visual Basic, display lesser performance in a language such as Visual J++. For that reason, ADO/WFC also provides accessor functions on the Field object that take native Java data types instead of the variant data type.

For more detailed information within the ADO documentation about ADO/WFC packages, see the ADO/WFC Syntax Index.

Referencing the Library

To import the ADO/WFC data classes into your project, include the following line in your code:

Copy code Copy code

import com.ms.wfc.data.*;


ComboBox.Selected Property (Access)

 Copy code hover
[image]

ComboBox.Selected Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Selected property in Visual Basic to determine if an item in a combo box is selected. Read/write Long.

Version Information

Version Added: Access 2007

Syntax

expression .Selected(lRow)

expression A variable that represents a ComboBox object.

Parameters

Name | Required/Optional | Data Type | Description
lRow | Required | Long | The item in the combo box. The first item is represented by a zero (0), the second by a one (1), and so on.

Remarks

The Selected property is a zero-based array that contains the selected state of each item in a combo box.

Setting | Description
True | The combo box item is selected.
False | The combo box item is not selected.

This property is available only at run time.

You can use the Selected property to select items in a combo box by using Visual Basic. For example, the following expression selects the fifth item in the list:

VBA Copy code Copy code
Me!Combobox.Selected(4) = True

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


Query

 Copy code hover
[image]

Query <name> is corrupt. (Error 3340)
Send feedback

You have referenced an undefined query name. Check the queries listed in the QueryDefs collection to make sure you referenced a valid query name.


CodeData Object (Access)

 Copy code hover
[image]

CodeData Object (Access)
See also Send feedback

Published: July 16, 2012

The CodeData object refers to objects stored within the code database by the source (server) application.

Remarks

The CodeData object has several collections that contain specific object types within the code database. The following table lists the name of each collection defined by the database and the types of objects it contains.

Collections | Object type | Available in Access database | Available in Access Project (.adp)
AllTables | All tables | Yes | Yes
AllFunctions | All functions | No | Yes
AllQueries | All queries | Yes | Yes
AllViews | All views | No | Yes
AllStoredProcedures | All stored procedures | No | Yes
AllDatabaseDiagrams | All database diagrams | No | Yes
Note Note

The collections in the preceding table contain all of the respective objects in the database regardless if they are opened or closed.

For example, an AccessObject representing a table is a member of the AllTables collection, which is a collection of AccessObject objects within the current database. Within the AllTables collection, individual tables are indexed beginning with zero. You can refer to an individual AccessObject object in the AllTables collection either by referring to the table by name, or by referring to its index within the collection. If you want to refer to a specific item in the AllTables collection, it's better to refer to it by name because the item's index may change. If the object name includes a space, the name must be surrounded by brackets ([ ]).

Syntax | Example
AllTables!tablename | AllTables!OrderTable
AllTables![table name] | AllTables![Order Table]
AllTables("tablename") | AllTables("OrderTable")
AllTables(index) | AllTables(0)

See also

Concepts

Access Object Model Reference

Other resources

CodeData Object Members


NavigationControl.OnMouseUp Property (Access)

 Copy code hover
[image]

NavigationControl.OnMouseUp Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Up box in the Properties window. Read/write String.

Version Information

Version Added: Access 2010

Syntax

expression .OnMouseUp

expression A variable that represents a NavigationControl object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseUp event occurs when the user releases a mouse button.

The OnMouseUp value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Up box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Up box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseUp property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseUp

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


You attempted to open a database that is already opened by user

 Copy code hover
[image]

You attempted to open a database that is already opened by user <name> on machine <name>. Try again when the database is available. (Error 3704)
Send feedback

This error occurs if the database is opened exclusively and is not shared. This error occurs if a user creates a new database in DAO, ADO, or Microsoft Access and does not close the database. Other users can open the database, but they will get the above error message.


The action query

 Copy code hover
[image]

The action query <name> cannot be used as a row source. (Error 3069)
Send feedback

You cannot use the name of an action query here. Instead, use the name of a select query. To run an action query, use the Execute method instead of the name of an action query as input to the FROM clause.


ImportExportSpecification.Execute Method (Access)

 Copy code hover
[image]

ImportExportSpecification.Execute Method (Access)
See also Send feedback

Published: July 16, 2012

Executes the specfied import or export specification.

Version Information

Version Added: Access 2007

Syntax

expression .Execute(OverwritePrompt)

expression A variable that represents an ImportExportSpecification object.

Parameters

Name | Required/Optional | Data Type | Description
OverwritePrompt | Optional | Variant | Specifies whether to notify the user when an export operation would overwrite an existing file. The default value is True.

See also

Concepts

ImportExportSpecification Object

Other resources

ImportExportSpecification Object Members


Form.AfterDelConfirm Property (Access)

 Copy code hover
[image]

Form.AfterDelConfirm Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the AfterDelConfirm event occurs. Read/write.

Syntax

expression .AfterDelConfirm

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

Example

The following example specifies that when the AfterDelConfirm event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).After DelConfirm = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


Cannot find the .dll

 Copy code hover
[image]

Cannot find the .dll <name>. (Error 3463)
Send feedback

Make sure that the specified dynamic-link library is in your path or reinstall Replication Manager (or your application).


Report.MouseDown Event (Access)

 Copy code hover
[image]

Report.MouseDown Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseDown event occurs when the user presses a mouse button.

Syntax

expression .MouseDown(Button, Shift, X, Y)

expression A variable that represents a Report object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseDown event for a report to occur, press the mouse button in a blank area on the report. To cause a MouseDown event for a report section to occur, press the mouse button in a blank area of the report section.

The following apply to MouseDown events:

  • If a mouse button is pressed while the pointer is over a report or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

Report Object

Other resources

Report Object Members


Catalog Example (VB)

 Copy code hover
[image]

Catalog Example (VB)
Send feedback

This Visual Basic project creates a new cube using MDX. Then, it documents the structure of a cube in a Microsoft Word document.

Copy code Copy code

Sub cmdCreateDocForCube_Click()
 On Error GoTo Error_cmdCreateDocForCube_Click

 Dim cn As ADODB.Connection
 Dim s As String
 Dim strProvider As String
 Dim strDataSource As String
 Dim strSourceDSN As String
 Dim strSourceDSNSuffix As String
 Dim strCreateCube As String
 Dim strInsertInto As String

 '*-----------------------------------------------------------------------
 '* The following code builds a cube file then documents the properties
 '* with an OLE Connection to Word 8.0
 '*-----------------------------------------------------------------------

 '*-----------------------------------------------------------------------
 '* Add Provider to the connection string.
 '*-----------------------------------------------------------------------
 strProvider = "PROVIDER=MSOLAP"

 '*-----------------------------------------------------------------------
 '* Add DataSource, the name of the file we will create.
 '*-----------------------------------------------------------------------

 strDataSource = "DATA SOURCE=c:\DocumentCube.cub"

 '*-----------------------------------------------------------------------
 '* Add Source DSN, the connection string for where the data comes from.
 '* We need to quote the value so it is parsed as one value.
 '* This can either be an ODBC connection string or an OLE DB connection
 '* string. (As returned by the Data Source Locator component.)
 '*-----------------------------------------------------------------------
 strSourceDSN = "SOURCE_DSN=FoodMart 2000"

 '*-----------------------------------------------------------------------
 '* Add CREATE CUBE. This defines the structure of the cube, but not the
 '* data in it. The BNF for is documented in the OLE DB for OLAP
 '* Programmer's Reference. Note that we can quote names with either
 '* double quotes or square brackets.
 '*-----------------------------------------------------------------------
 strCreateCube = "CREATECUBE=CREATE CUBE Sample( "
 strCreateCube = strCreateCube & "DIMENSION [Product],"
 strCreateCube = strCreateCube & "LEVEL [All Products] TYPE ALL,"
 strCreateCube = strCreateCube & "LEVEL [Product Family] ,"
 strCreateCube = strCreateCube & "LEVEL [Product Department] ,"
 strCreateCube = strCreateCube & "LEVEL [Product Category] ,"
 strCreateCube = strCreateCube & "LEVEL [Product Subcategory] ,"
 strCreateCube = strCreateCube & "LEVEL [Brand Name] ,"
 strCreateCube = strCreateCube & "LEVEL [Product Name] ,"
 strCreateCube = strCreateCube & "DIMENSION [Store],"
 strCreateCube = strCreateCube & "LEVEL [All Stores] TYPE ALL,"
 strCreateCube = strCreateCube & "LEVEL [Store Country] ,"
 strCreateCube = strCreateCube & "LEVEL [Store State] ,"
 strCreateCube = strCreateCube & "LEVEL [Store City] ,"
 strCreateCube = strCreateCube & "LEVEL [Store Name] ,"
 strCreateCube = strCreateCube & "DIMENSION [Store Type],"
 strCreateCube = strCreateCube & _
 "LEVEL [All Store Type] TYPE ALL,"
 strCreateCube = strCreateCube & "LEVEL [Store Type] ,"
 strCreateCube = strCreateCube & "DIMENSION [Time] TYPE TIME,"
 strCreateCube = strCreateCube & "HIERARCHY [Column],"
 strCreateCube = strCreateCube & "LEVEL [All Time] TYPE ALL,"
 strCreateCube = strCreateCube & "LEVEL [Year] TYPE YEAR,"
 strCreateCube = strCreateCube & "LEVEL [Quarter] TYPE QUARTER,"
 strCreateCube = strCreateCube & "LEVEL [Month] TYPE MONTH,"
 strCreateCube = strCreateCube & "LEVEL [Week] TYPE WEEK,"
 strCreateCube = strCreateCube & "LEVEL [Day] TYPE DAY,"
 strCreateCube = strCreateCube & "HIERARCHY [Formula],"
 strCreateCube = strCreateCube & _
 "LEVEL [All Formula Time] TYPE ALL,"
 strCreateCube = strCreateCube & "LEVEL [Year] TYPE YEAR,"
 strCreateCube = strCreateCube & "LEVEL [Quarter] TYPE QUARTER,"
 strCreateCube = strCreateCube & _
 "LEVEL [Month] TYPE MONTH OPTIONS (SORTBYKEY) ,"
 strCreateCube = strCreateCube & "DIMENSION [Warehouse],"
 strCreateCube = strCreateCube & _
 "LEVEL [All Warehouses] TYPE ALL,"
 strCreateCube = strCreateCube & "LEVEL [Country] ,"
 strCreateCube = strCreateCube & "LEVEL [State Province] ,"
 strCreateCube = strCreateCube & "LEVEL [City] ,"
 strCreateCube = strCreateCube & "LEVEL [Warehouse Name] ,"
 strCreateCube = strCreateCube & "MEASURE [Store Invoice] "
 strCreateCube = strCreateCube & "Function Sum "
 strCreateCube = strCreateCube & "Format '#.#',"
 strCreateCube = strCreateCube & "MEASURE [Supply Time] "
 strCreateCube = strCreateCube & "Function Sum "
 strCreateCube = strCreateCube & "Format '#.#',"
 strCreateCube = strCreateCube & "MEASURE [Warehouse Cost] "
 strCreateCube = strCreateCube & "Function Sum "
 strCreateCube = strCreateCube & "Format '#.#',"
 strCreateCube = strCreateCube & "MEASURE [Warehouse Sales] "
 strCreateCube = strCreateCube & "Function Sum "
 strCreateCube = strCreateCube & "Format '#.#',"
 strCreateCube = strCreateCube & "MEASURE [Units Shipped] "
 strCreateCube = strCreateCube & "Function Sum "
 strCreateCube = strCreateCube & "Format '#.#',"
 strCreateCube = strCreateCube & "MEASURE [Units Ordered] "
 strCreateCube = strCreateCube & "Function Sum "
 strCreateCube = strCreateCube & "Format '#.#')"
 '*-----------------------------------------------------------------------
 '* Add INSERT INTO. This defines where the data comes from, and how it
 '* maps into the already-defined cube structure. Note that the SELECT
 '* clause might just be passed through to the relational database.
 '* So I could pass in a stored procedure, for example. If we needed to,
 '* we could quote this whole thing. Note that the columns in the SELECT
 '* can be in any order. One merely has to adjust the ordering of the
 '* list of level/measure names to match the SELECT ordering.
 '*-----------------------------------------------------------------------
 strInsertInto = strInsertInto & _
 "INSERTINTO=INSERT INTO Sample( " & _
 "Product.[Product Family], Product.[Product Department],"
 strInsertInto = strInsertInto & _
 "Product.[Product Category], Product.[Product Subcategory],"
 strInsertInto = strInsertInto & _
 "Product.[Brand Name], Product.[Product Name],"
 strInsertInto = strInsertInto & _
 "Store.[Store Country], Store.[Store State], Store.[Store City],"
 strInsertInto = strInsertInto & _
 "Store.[Store Name], [Store Type].[Store Type], [Time].[Column],"
 strInsertInto = strInsertInto & _
 "[Time].Formula.Year, [Time].Formula.Quarter, " & _
 "[Time].Formula.Month.[Key],"
 strInsertInto = strInsertInto & _
 "[Time].Formula.Month.Name, Warehouse.Country, " & _
 "Warehouse.[State Province],"
 strInsertInto = strInsertInto & _
 "Warehouse.City, Warehouse.[Warehouse Name], " & _
 "Measures.[Store Invoice],"
 strInsertInto = strInsertInto & _
 "Measures.[Supply Time], Measures.[Warehouse Cost], " & _
 "Measures.[Warehouse Sales],"
 strInsertInto = strInsertInto & _
 "Measures.[Units Shipped], Measures.[Units Ordered] )"
 '*-----------------------------------------------------------------------
 '* Add some options to the INSERT INTO if we need to. These can control
 '* if the SELECT clause is analyzed or just passed through, and if the
 '* storage mode is MOLAP or ROLAP (DEFER_DATA).
 '* strInsertInto = strInsertInto & " OPTIONS ATTEMPT_ANALYSIS"
 '*-----------------------------------------------------------------------

 '*-----------------------------------------------------------------------
 '* Add the SELECT clause of the INSERT INTO statement. Note that it is
 '* merely concatenated onto the end of the INSERT INTO statement. OLAP
 '* Services will pass this through to the source database if unable to
 '* parse it. Note that for OLAP Services to analyze the SELECT clause,
 '* each column must be qualified with the table name.
 '*-----------------------------------------------------------------------

 strInsertInto = strInsertInto & _
 "SELECT product_class.product_family AS Col1,"
 strInsertInto = strInsertInto & _
 "product_class.product_department AS Col2,"
 strInsertInto = strInsertInto & "product_class.product_category AS Col3,"
 strInsertInto = strInsertInto & _
 "product_class.product_subcategory AS Col4,"
 strInsertInto = strInsertInto & "product.brand_name AS Col5,"
 strInsertInto = strInsertInto & "product.product_name AS Col6,"
 strInsertInto = strInsertInto & "store.store_country AS Col7,"
 strInsertInto = strInsertInto & "store.store_state AS Col8,"
 strInsertInto = strInsertInto & "store.store_city AS Col9,"
 strInsertInto = strInsertInto & "store.store_name AS Col10,"
 strInsertInto = strInsertInto & "store.store_type AS Col11,"
 strInsertInto = strInsertInto & "time_by_day.the_date AS Col12,"
 strInsertInto = strInsertInto & "time_by_day.the_year AS Col13,"
 strInsertInto = strInsertInto & "time_by_day.quarter AS Col14,"
 strInsertInto = strInsertInto & "time_by_day.month_of_year AS Col15,"
 strInsertInto = strInsertInto & "time_by_day.the_month AS Col16,"
 strInsertInto = strInsertInto & "warehouse.warehouse_country AS Col17,"
 strInsertInto = strInsertInto & _
 "warehouse.warehouse_state_province AS Col18,"
 strInsertInto = strInsertInto & "warehouse.warehouse_city AS Col19,"
 strInsertInto = strInsertInto & "warehouse.warehouse_name AS Col20,"
 strInsertInto = strInsertInto & _
 "inventory_fact_1997.store_invoice AS Col21,"
 strInsertInto = strInsertInto & _
 "inventory_fact_1997.supply_time AS Col22,"
 strInsertInto = strInsertInto & _
 "inventory_fact_1997.warehouse_cost AS Col23,"
 strInsertInto = strInsertInto & _
 "inventory_fact_1997.warehouse_sales AS Col24,"
 strInsertInto = strInsertInto & _
 "inventory_fact_1997.units_shipped AS Col25,"
 strInsertInto = strInsertInto & _
 "inventory_fact_1997.units_ordered AS Col26 "
 strInsertInto = strInsertInto & _
 "From [inventory_fact_1997], [product], [product_class], " & _
 "[time_by_day], [store], [warehouse] "
 strInsertInto = strInsertInto & _
 "Where [inventory_fact_1997].[product_id] = [product]." & _
 "[product_id] And "
 strInsertInto = strInsertInto & _
 "[product].[product_class_id] = [product_class]." & _
 "[product_class_id] And "
 strInsertInto = strInsertInto & _
 "[inventory_fact_1997].[time_id] = [time_by_day].[time_id] And "
 strInsertInto = strInsertInto & _
 "[inventory_fact_1997].[store_id] = [store].[store_id] And "
 strInsertInto = strInsertInto & _
 "[inventory_fact_1997].[warehouse_id] = [warehouse].[warehouse_id]"

 '*-----------------------------------------------------------------------
 '* Create the cube by passing connection string to Open.
 '*-----------------------------------------------------------------------

 Set cn = New ADODB.Connection
 s = strProvider & ";" & strDataSource & ";" & strSourceDSN & ";" & _
 strCreateCube & ";" & strInsertInto & ";"
 Screen.MousePointer = vbHourglass
 cn.Open s

 '*-----------------------------------------------------------------------
 '* Cube file is written to hard drive a Word Document can be produced by
 '* automating Word with VB
 '*-----------------------------------------------------------------------

 Dim cat As New ADOMD.Catalog
 Dim cdf As ADOMD.CubeDef
 Dim i As Integer
 Dim di As Integer
 Dim hi As Integer
 Dim le As Integer
 Dim mem As Integer
 Dim docWord As Word.Document
 Dim rngCurrent As Word.Range
 Dim SenCount As Integer
 Dim strServer As String
 Dim strSource As String
 Dim strCubeName As String
 Dim appWord As Object
 '*-----------------------------------------------------------------------
 '* Connection is made to cube file
 '*-----------------------------------------------------------------------
 cat.ActiveConnection = "DATA SOURCE=c:\DocumentCube.cub;Provider=msolap;"

 '*-----------------------------------------------------------------------
 '* Cube Definition is set to Name of Cube in cube file
 '*-----------------------------------------------------------------------
 Set cdf = cat.CubeDefs("Sample")

 '*-----------------------------------------------------------------------
 '* Object is created to hold Word
 '*-----------------------------------------------------------------------
 Set appWord = CreateObject("Word.Application")

 '*-----------------------------------------------------------------------
 '* Create the document variable
 '*-----------------------------------------------------------------------
 Set docWord = appWord.Documents.Add()

 Set rngCurrent = docWord.Content

 SenCount = 0

 '*-----------------------------------------------------------------------
 '* Cube Title and Header written to Document
 '*-----------------------------------------------------------------------
 With rngCurrent
 .InsertAfter "Report for Sample Cube"
 .InsertAfter vbCrLf
 SenCount = SenCount + 1
 docWord.Paragraphs(SenCount).Range.Bold = True
 docWord.Paragraphs(SenCount).Range.Underline = wdUnderlineSingle
 docWord.Paragraphs(SenCount).Range.Italic = False
 docWord.Paragraphs(SenCount).Range.Font.Size = 18

 '*-----------------------------------------------------------------------
 '* Properties of Cube are written to Document
 '*-----------------------------------------------------------------------
 Debug.Print "Properties of Cube are written to Document"
 For i = 0 To cdf.Properties.Count - 1
 .InsertAfter "(" & i & ") " & cdf.Properties(i).Name & ": " & _
 cdf.Properties(i).Value
 .InsertAfter vbCrLf
 SenCount = SenCount + 1
 docWord.Paragraphs(SenCount).Range.Bold = False
 docWord.Paragraphs(SenCount).Range.Italic = True
 docWord.Paragraphs(SenCount).Range.Font.Size = 8
 Next i

 '*-----------------------------------------------------------------------
 '* Dimension Name(s) written to Document
 '*-----------------------------------------------------------------------
 Debug.Print "Dimension Name(s) written to Document"
 For di = 0 To cdf.Dimensions.Count - 1
 .InsertAfter "Dimension: " & cdf.Dimensions(di).Name
 .InsertAfter vbCrLf
 SenCount = SenCount + 1
 docWord.Paragraphs(SenCount).Range.Bold = True
 docWord.Paragraphs(SenCount).Range.Italic = False
 docWord.Paragraphs(SenCount).Range.Font.Size = 14

 '*-----------------------------------------------------------------------
 '* Properties of Dimension are written to Document
 '*-----------------------------------------------------------------------
 Debug.Print "Properties of Dimension are written to Document"
 For i = 0 To cdf.Dimensions(di).Properties.Count - 1
 .InsertAfter "(" & i & ") " & _
 cdf.Dimensions(di).Properties(i).Name & ": " & _
 cdf.Dimensions(di).Properties(i).Value
 .InsertAfter vbCrLf
 SenCount = SenCount + 1
 docWord.Paragraphs(SenCount).Range.Bold = False
 docWord.Paragraphs(SenCount).Range.Italic = True
 docWord.Paragraphs(SenCount).Range.Font.Size = 8
 Next i

 '*-----------------------------------------------------------------------
 '* Hierarchy Name(s) written to Document
 '*-----------------------------------------------------------------------
 Debug.Print "Hierarchy Name(s) written to Document"
 For hi = 0 To cdf.Dimensions(di).Hierarchies.Count - 1
 .InsertAfter vbTab & "Hierarchy: " & _
 cdf.Dimensions(di).Hierarchies(hi).Name
 .InsertAfter vbCrLf
 SenCount = SenCount + 1
 docWord.Paragraphs(SenCount).Range.Bold = True
 docWord.Paragraphs(SenCount).Range.Italic = False
 docWord.Paragraphs(SenCount).Range.Font.Size = 12

 '*-----------------------------------------------------------------------
 '* Properties of Hierarchy are written to Document
 '*-----------------------------------------------------------------------
 Debug.Print "Properties of Hierarchy are written to Document"
 For i = 0 To cdf.Dimensions(di).Hierarchies(hi).Properties.Count - 1
 .InsertAfter vbTab & "(" & i & ") " & _
 cdf.Dimensions(di).Hierarchies(hi).Properties(i).Name & _
 ": " & cdf.Dimensions(di).Hierarchies(hi).Properties(i).Value
 .InsertAfter vbCrLf
 SenCount = SenCount + 1
 docWord.Paragraphs(SenCount).Range.Bold = False
 docWord.Paragraphs(SenCount).Range.Italic = True
 docWord.Paragraphs(SenCount).Range.Font.Size = 8
 Next i

 '*-----------------------------------------------------------------------
 '* Level Name(s) written to Document
 '*-----------------------------------------------------------------------
 Debug.Print "Level Name(s) written to Document"
 For le = 0 To cdf.Dimensions(di).Hierarchies(hi).Levels.Count - 1
 .InsertAfter vbTab & vbTab & "Level: " & _
 cdf.Dimensions(di).Hierarchies(hi).Levels(le).Name & _
 " with a Member Count of: " & _
 cdf.Dimensions(di).Hierarchies(hi).Levels(le).Members.Count
 .InsertAfter vbCrLf
 SenCount = SenCount + 1
 docWord.Paragraphs(SenCount).Range.Bold = True
 docWord.Paragraphs(SenCount).Range.Italic = False
 docWord.Paragraphs(SenCount).Range.Font.Size = 10

 '*-----------------------------------------------------------------------
 '* Properties of Level are written to Document
 '*-----------------------------------------------------------------------
 Debug.Print "Properties of Level are written to Document"
 For i = 0 To _
 cdf.Dimensions(di).Hierarchies(hi).Levels(le).Properties.Count - 1
 .InsertAfter vbTab & vbTab & "(" & i & ") " & _
 cdf.Dimensions(di).Hierarchies(hi).Levels(le).Properties(i).Name & ": " & _
 cdf.Dimensions(di).Hierarchies(hi).Levels(le).Properties(i).Value
 .InsertAfter vbCrLf
 SenCount = SenCount + 1
 docWord.Paragraphs(SenCount).Range.Bold = False
 docWord.Paragraphs(SenCount).Range.Italic = True
 docWord.Paragraphs(SenCount).Range.Font.Size = 8
 Next i

 Next le
 Next hi
 Next di

 '*-----------------------------------------------------------------------
 '* Set Word Document to visible
 '*-----------------------------------------------------------------------
 Debug.Print "Set Word Document to visible"
 appWord.Visible = True
 End With

 Screen.MousePointer = vbDefault

 '*-----------------------------------------------------------------------
 '* Set Word Object to nothing to drop OLE connection
 '*-----------------------------------------------------------------------
 Set appWord = Nothing
Exit Sub

Error_cmdCreateDocForCube_Click:
 cn.Cancel
 Set cn = Nothing
 Screen.MousePointer = vbDefault
 MsgBox Err.Description
End Sub


Form.Query Property (Access)

 Copy code hover
[image]

Form.Query Property (Access)
See also Send feedback

Published: July 16, 2012

Returns or sets a String indicating which macro, event procedure, or user-defined function runs when the Query event occurs. Read/write.

Syntax

expression .Query

expression A variable that represents a Form object.

Remarks

Valid values for this property are "macroname" where macroname is the name of macro, "[Event Procedure]" which indicates the event procedure associated with the BeforeInsert event for the specified object, or "=functionname()" where functionname is the name of a user-defined function.

This property corresponds to the On Query property that is displayed in a form's property sheet.

Example

The following example specifies that when the Query event occurs on the first form of the current project, the associated event procedure should run.

VBA Copy code Copy code
Forms(0).Query = "[Event Procedure]"

See also

Concepts

Form Object

Other resources

Form Object Members


Page.Name Property (Access)

 Copy code hover
[image]

Page.Name Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Name property to specify or determine the string expression that identifies the name of an object. Read/write String.

Syntax

expression .Name

expression A variable that represents a Page object.

Remarks

A valid name must conform to the standard naming conventions for Microsoft Access. For Microsoft Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters.

The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object.

For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control you add to a form is a text box, its Name property setting is Text1

For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box.

You can't use "Form" or "Report" to name a control or section.

Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports or data access pages can have the same name. A control and a section on the same form can't share the same name.

See also

Concepts

Page Object

Other resources

Page Object Members


Section.MouseUp Event (Access)

 Copy code hover
[image]

Section.MouseUp Event (Access)
See also Send feedback

Published: July 16, 2012

The MouseUp event occurs when the user releases a mouse button.

Syntax

expression .MouseUp(Button, Shift, X, Y)

expression A variable that represents a Section object.

Parameters

Name

Required/Optional

Data Type

Description

Button

Required

Integer

The button that was released to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton The bit mask for the left mouse button.

  • acRightButton The bit mask for the right mouse button.

  • acMiddleButton The bit mask for the middle mouse button.

Shift

Required

Integer

The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:

  • acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask The bit mask for the CTRL key.

  • acAltMask The bit mask for the ALT key.

X

Required

Single

The x coordinate for the current location of the mouse pointer, in twips.

Y

Required

Single

The y coordinate for the current location of the mouse pointer, in twips.

Remarks

  • The MouseUp event applies only to forms, form sections , and controls on a form, not controls on a report.

  • This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].

You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

To cause a MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.

The following apply to MouseUp events:

  • If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

To respond to an event caused by moving the mouse, you use a MouseMove event.

See also

Concepts

Section Object

Other resources

Section Object Members


How to: Synchronize Two Combo Boxes on a Form

 Copy code hover
[image]

How to: Synchronize Two Combo Boxes on a Form
Send feedback

This topic illustrates how to synchronize two combo boxes so that when you select an item in the first combo box, the selection limits the choices in the second combo box. For example, you may want the products displayed in a combo box to be limited to the category selected in another combo box.

In this example, the second combo box is filled with the results of an SQL statement. This SQL statement finds all the products that have a CategoryID that matches the category selected in the first combo box.

Whenever a category is selected in the first combo box, its AfterUpdate event procedure sets the second combo box's RowSourceType property. This refreshes the list of available products in the second combo box. Without this procedure, the contents of the second combo box would not change.

VBA Copy code Copy code
Private Sub cboCategories_AfterUpdate()

    ' Update the row source of the cboProducts combo box
    ' when the user makes a selection in the cboCategories
    ' combo box.
    Me.cboProducts.RowSource = "SELECT ProductName FROM" & _
                            " tblProducts WHERE CategoryID = " & Me.cboCategories & _
                            " ORDER BY ProductName"

    Me.cboProducts = Me.cboProducts.ItemData(0)
End Sub


What's New in ADO

 Copy code hover
[image]

What's New in ADO
Send feedback

The following new features and enhanced documentation are included in the ADO 2.5 release. This list covers ADO, ADO MD, and ADOX.

New Features

Records and Streams

This release of ADO introduces the Record object, which can represent and manage things like directories and files in a file system, and folders and messages in an e-mail system. A Record can also represent a row in a Recordset, although Record and Recordset objects have different methods and properties.

The new Stream object provides the means to read, write, and manage the binary stream of bytes or text that comprise a file or message stream.

URL Usage

This release also introduces the use of Uniform Resource Locators (URLs), as an alternative to connection strings and command text, to name data store objects. URLs may be used with the existing Connection and Recordset objects, as well as with the new Record and Stream objects.

With this release, ADO supports OLE DB providers that recognize their own URL schemes. For example, the OLE DB Provider for Internet Publishing , which accesses the Windows 2000 file system, recognizes the existing HTTP scheme.

Special Fields for Document Source Providers

A special class of providers, called document source providers, manage folders and documents. When a Record object represents a document, or a Recordset object represents a folder of documents, the document source provider populates those objects with a unique set of fields that describe characteristics of the document. These fields constitute a resource Record or Recordset.

New Reference Topics

The following new properties are included in this release.

Property | Description
Charset | Indicates the character set into which the contents of a text Stream object should be translated.
EOS | Indicates whether the current position is at the end of the stream.
LineSeparator | Indicates the binary character to be used as the line separator in text Stream objects.
Mode | Indicates the available permissions for modifying data in a Connection, Record, or Stream object.
ParentURL | Indicates an absolute URL string that points to the parent Record of the current Record object.
Position | Indicates the current position within a Stream object.
RecordType | Indicates the type of Record object.
Size | Indicates the size of the stream in number of bytes.
Source | Indicates the entity represented by the Record object.
State | Indicates for all applicable objects whether the state of the object is open or closed. Indicates for all applicable objects executing an asynchronous method, whether the current state of the object is connecting, executing, or retrieving.
Type | Indicates the type of data contained in the Stream object (binary or text).

The following new methods are included in this release.

Method | Description
CopyRecord | Copies a file or directory, and its contents, to another location.
CopyTo | Copies the specified number of characters or bytes (depending on Type) in the Stream object to another Stream object.
DeleteRecord | Deletes a file or directory, and all its subdirectories.
Flush | Forces the contents of the Stream object remaining in the ADO buffer to the underlying object with which the Stream object is associated.
GetChildren | Returns a Recordset whose rows represent the files and subdirectories in the directory represented by this Record.
LoadFromFile | Loads the contents of an existing file into a Stream object.
MoveRecord | Moves a file, or a directory and its contents, to another location.
Open | Opens an existing Record object, or creates a new file or directory.
Open | Opens a Stream object to manipulate streams of binary or text data.
Read | Reads a specified number of bytes from a binary Stream object.
ReadText | Reads specified number of characters from a text Stream object.
SaveToFile | Saves the binary contents of a Stream to a file.
SetEOS | Sets the position that is the end of the stream.
SkipLine | Skips one entire line when reading a text Stream object.
Write | Writes binary data to a Stream object.
WriteText | Writes a specified text string to a Stream object.

New and Enhanced Documentation

Code Example Topics

The examples have been expanded to contain code examples written in Microsoft Visual C++® and Microsoft Visual J++®. You can copy and paste these code examples into your editor.

Provider Topics

A new topic is included that explains how to use ADO with the OLE DB Provider for Internet Publishing.

Programming with ADO

This new section contains tips and tricks for using ADO with various programming languages. It contains the existing syntax indexes for the Visual C++ Extensions for ADO and ADO/WFC, as well as new information specific to developers using Microsoft Visual Basic®, Microsoft Visual Basic® Scripting Edition, Microsoft JScript®, Microsoft Visual C++, or Microsoft Visual J++.


ODBC - could not find DLL

 Copy code hover
[image]

ODBC - could not find DLL <name>. (Error 3154)
Send feedback

Using an ODBC connection, you tried to perform an operation that requires the specified DLL.

Possible causes:

  • The DLL file is on a network drive and the network is not connected. Make sure the network is available, and then try the operation again.

  • The DLL file was not installed properly. Reinstall the ODBC driver, and then try the operation again.


BoundObjectFrame.OnKeyPress Property (Access)

 Copy code hover
[image]

BoundObjectFrame.OnKeyPress Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Key Press box in the Properties window. Read/write String.

Syntax

expression .OnKeyPress

expression A variable that represents a BoundObjectFrame object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The KeyPress event occurs when a user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

The OnKeyPress value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Press box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Key Press box is blank, the property value is an empty string.

Example

The following example prints the value of the OnKeyPress property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnKeyPress

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


Control.Pages Property (Access)

 Copy code hover
[image]

Control.Pages Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a Pages collection that represents the pages in the specified control that supports tabbed pages (for example, a TabControl object). Read-only.

Syntax

expression .Pages

expression A variable that represents a Control object.

Example

The following example displays a message indicating the number of tabbed pages on tab control TabCtl1.

VBA Copy code Copy code
MsgBox "Number of pages in TabCtl1:" & TabCtl1.Pages.Count

See also

Concepts

Control Object

Other resources

Control Object Members


Procedures Refresh Method Example (VB)

 Copy code hover
[image]

Procedures Refresh Method Example (VB)
Send feedback

The following code shows how to refresh the Procedures collection of a Catalog. This is required before Procedure objects from the Catalog can be accessed.

Copy code Copy code

' BeginProceduresRefreshVB
Sub Main()
 On Error GoTo ProcedureRefreshError

 Dim cat As New ADOX.Catalog

 ' Open the Catalog
 cat.ActiveConnection = _
 "Provider='Microsoft.Jet.OLEDB.4.0';" & _
 "Data Source='c:\Program Files\" & _
 "Microsoft Office\Office\Samples\Northwind.mdb';"

 ' Refresh the Procedures collection
 cat.Procedures.Refresh

 'Clean up
 Set cat.ActiveConnection = Nothing
 Set cat = Nothing
 Exit Sub

ProcedureRefreshError:
 Set cat = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
' EndProceduresRefreshVB


Indexes Append Method Example (VC++)

 Copy code hover
[image]

Indexes Append Method Example (VC++)
Send feedback

The following code demonstrates how to create a new index. The index is on two columns in the table.

Copy code Copy code

// BeginCreateIndexCpp
#import "c:\Program Files\Common Files\system\ado\msadox.dll" no_namespace

#include "iostream.h"
#include "stdio.h"
#include "conio.h"

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void CreateIndexX(void);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 CreateIndexX();

 ::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// CreateIndexX Function //
// //
//////////////////////////////////////////////////////////
void CreateIndexX(void)
{
 HRESULT hr = S_OK;

 // Define ADOX object pointers.
 // Initialize pointers on define.
 // These are in the ADOX:: namespace.
 _TablePtr m_pTable = NULL;
 _IndexPtr m_pIndex = NULL;
 _CatalogPtr m_pCatalog = NULL;

 //Define other variables
 _bstr_t strcnn("Provider='Microsoft.JET.OLEDB.4.0';"
 "Data source = 'c:\\Program Files\\Microsoft Office\\"
 "Office\\Samples\\Northwind.mdb';");
 try
 {
 TESTHR(hr = m_pTable.CreateInstance(__uuidof(Table)));
 TESTHR(hr = m_pIndex.CreateInstance(__uuidof(Index)));
 TESTHR(hr = m_pCatalog.CreateInstance(__uuidof (Catalog)));

 // Open the catalog.
 m_pCatalog->PutActiveConnection(strcnn);

 // Define the table and append it to the catalog.
 m_pTable->Name = "MyTable";
 m_pTable->Columns->Append("Column1",adInteger,0);
 m_pTable->Columns->Append("Column2",adInteger,0);
 m_pTable->Columns->Append("Column3",adVarWChar,50);
 m_pCatalog->Tables->Append(_variant_t((IDispatch *)m_pTable));
 printf("Table 'MyTable' is appended.\n");

 // Define a multi-column index.
 m_pIndex->Name = "multicolidx";
 m_pIndex->Columns->Append("Column1",adInteger,0);
 m_pIndex->Columns->Append("Column2",adInteger,0);

 // Append the index to the table.
 m_pTable->Indexes->Append(_variant_t((IDispatch *)m_pIndex));
 printf("Index 'multicolidx' is appended.\n");

 // Delete the table.
 m_pCatalog->Tables->Delete("MyTable");
 printf("Table 'MyTable' is deleted.\n");
 }
 catch(_com_error &e)
 {
 // Notify the user of errors if any.
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 printf("\n\tSource : %s \n\tdescription : %s \n ",
 (LPCSTR)bstrSource,(LPCSTR)bstrDescription);
 }
 catch(...)
 {
 cout << "Error occured in CreateIndexX...."<< endl;
 }
}
// EndCreateIndexCpp


Form.LayoutForPrint Property (Access)

 Copy code hover
[image]

Form.LayoutForPrint Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the LayoutForPrint property to specify whether the form uses printer or screen fonts. Read/write Boolean.

Syntax

expression .LayoutForPrint

expression A variable that represents a Form object.

Remarks

When you choose a font in Microsoft Access, you are choosing either a screen font or a printer font, depending on the setting of the LayoutForPrint property. Remember that printer fonts and screen fonts can differ, and characters on screen may not look exactly like those displayed on the printed page.

Screen fonts are the images of letters, numbers, and symbols that are installed on your system to be displayed on the screen. If you installed a printer, additional screen fonts may have been installed automatically.

Printer fonts are the letters, numbers, and symbols that are produced when you print a form. The available fonts are those fonts that were installed as part of your printer's setup, and depend on your printer.

If you design a form on a system with a different printer than the one you will use to print, Microsoft Access displays a message when you print the form to let you know that it was designed for another kind of printer. If you print the form anyway, your printer may substitute different fonts. Similarly, Microsoft Access may substitute fonts if you change the LayoutForPrint property setting. For example, you might design a form with LayoutForPrint set to No, then change the setting to Yes. You can reselect the font for each control to specify the appearance of the form.

See also

Concepts

Form Object

Other resources

Form Object Members


Data Section
Send feedback

Data Section

The data section defines the data of the rowset along with any pending updates, insertions, or deletions. The data section may contain zero or more rows. It may only contain data from one rowset where the row is defined by the schema. Also, as noted before, columns without any data may be omitted. If an attribute or subelement is used in the data section and that construct has not been defined in the schema section, it is silently ignored.

String

Reserved XML characters in text data must be replaced with appropriate character entities. For example, in the company name "Joe's Garage," the single quote character must be replaced by an entity. The actual row would look like:

Copy code Copy code

<z:row CompanyName="Joe&apos;s Garage"/>

The following characters are reserved in XML and must be replaced by character entities: {',",&,<,>}.

Binary

Binary data is bin.hex encoded (that is, one byte maps to two characters, one character per nibble).

DateTime

The variant VT_DATE format is not directly supported by XML-Data data types. The correct format for dates with both a data and time component is yyyy-mm-ddThh:mm:ss.

For more information about date formats specified by XML, refer to W3C XMLData Note.

When the XML-Data specification defines two equivalent data types (for example, i4 == int), ADO will write out the friendly name but read in both.

Managing Pending Changes

A Recordset can be opened in immediate or batch update mode. When opened in batch update mode with client-side cursors, all changes made to the Recordset are in a pending state until the UpdateBatch method is called. Pending changes are also persisted when the Recordset is saved. In XML, they are represented by the use of the "update" elements defined in urn:schemas-microsoft-com:rowset. In addition, if a rowset can be updated, the updatable property must be set to true in the definition of the row. For example, to define that the Shippers table contains pending changes, the row definition would look like the following:

Copy code Copy code

<s:ElementType name="row" content="eltOnly" updatable="true">
  <s:attribute type="ShipperID"/>
  <s:attribute type="CompanyName"/>
  <s:attribute type="Phone"/>
  <s:extends type="rs:rowbase"/>
</s:ElementType>

This tells the Persistence Provider to surface data so that ADO can construct an updatable Recordset object.

The following sample data shows how insertions, changes, and deletions look in the persisted file:

Copy code Copy code

<rs:data>
  <z:row ShipperID="2" CompanyName="United Package"
    Phone="(503) 555-3199"/>
<rs:update>
  <rs:original>
    <z:row ShipperID="3" CompanyName="Federal Shipping"
      Phone="(503) 555-9931"/>
  </rs:original>
  <z:row Phone="(503) 552-7134"/>
</rs:update>
<rs:insert>
  <z:row ShipperID="12" CompanyName="Lightning Shipping"
    Phone="(505) 111-2222"/>
  <z:row ShipperID="13" CompanyName="Thunder Overnight"
    Phone="(505) 111-2222"/>
  <z:row ShipperID="14" CompanyName="Blue Angel Air Delivery"
    Phone="(505) 111-2222"/>
</rs:insert>
<rs:delete>
  <z:row ShipperID="1" CompanyName="Speedy Express" Phone="(503) 555-9831"/>
</rs:delete>
</rs:data>

An update always contains the entire original row data followed by the changed row data. The changed row may contain all of the columns or only those columns that have actually changed. In the previous example, the row for Shipper 2 is not changed, while only the Phone column has changed values for Shipper 3 and is therefore the only column included in the changed row. The inserted rows for Shippers 12, 13, and 14 are batched together under one rs:insert tag. Note that deleted rows may also be batched together, although this is not shown above.


ComboBox.BackThemeColorIndex Property (Access)

 Copy code hover
[image]

ComboBox.BackThemeColorIndex Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets a value that represents a color in the applied color theme associated with the BackColor property of the specified object. Read/write Long.

Version Information

Version Added: Access 2010

Syntax

expression .BackThemeColorIndex

expression A variable that represents a ComboBox object.

Remarks

The BackThemeColorIndex property contains one of the index values listed in the following table.

Index Value | Description
0 | Text 1
1 | Background 1
2 | Text 2
3 | Background 2
4 | Accent 1
5 | Accent 2
6 | Accent 3
7 | Accent 4
8 | Accent 5
9 | Accent 6
10 | Hyperlink
11 | Followed Hyperlink

If no theme is applied, the BackThemeColorIndex property contains -1.

This property is not surfaced in the property sheet.

Example

The following code example sets the Background Color to the Text 2 color by setting the BackThemeColorIndex property.

VBA Copy code Copy code
Me.FormHeader.BackThemeColorIndex=2

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


OptionButton.BorderColor Property (Access)

 Copy code hover
[image]

OptionButton.BorderColor Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the BorderColor property to specify the color of a control's border. Read/write Long.

Syntax

expression .BorderColor

expression A variable that represents an OptionButton object.

Remarks

The BorderColor property setting is a numeric expression that corresponds to the color you want to use for a control's border.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

A control's border color is visible only when its SpecialEffect property is set to Flat or Shadowed. If the SpecialEffect property is set to something other than Flat or Shadowed, setting the BorderColor property changes the SpecialEffect property setting to Flat.

Example

The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

VBA Copy code Copy code
Sub Form_Current()
 Dim curAmntDue As Currency, lngBlack As Long
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long

 If Not IsNull(Me!txtPastDue.Value) Then
 curAmntDue = Me!txtPastDue.Value
 Else
 Exit Sub
 End If
 lngRed = RGB(255, 0, 0)
 lngBlack = RGB(0, 0, 0)
 lngYellow = RGB(255, 255, 0)
 lngWhite = RGB(255, 255, 255)
 If curAmntDue > 100 Then
 Me!txtPastDue.BorderColor = lngRed
 Me!txtPastDue.ForeColor = lngRed
 Me!txtPastDue.BackColor = lngYellow
 Else
 Me!txtPastDue.BorderColor = lngBlack
 Me!txtPastDue.ForeColor = lngBlack
 Me!txtPastDue.BackColor = lngWhite
 End If
End Sub

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


CheckBox.OnExit Property (Access)

 Copy code hover
[image]

CheckBox.OnExit Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Exit box in the Properties window of specified object. Read/write String. .

Syntax

expression .OnExit

expression A variable that represents a CheckBox object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The Exit event occurs just before a control loses the focus to another control on the same form.

The OnExit value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Exit box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Exit box is blank, the property value is an empty string.

Example

The following example associates the Exit event with the macro "Exit_Macro" for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Forms("Order Entry").Controls("OK").OnExit = "Exit_Macro"

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members


Control.Move Method (Access)

 Copy code hover
[image]

Control.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents a Control object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

Control Object

Other resources

Control Object Members


CurrentProject.Properties Property (Access)

 Copy code hover
[image]

CurrentProject.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a CurrentProject object's AccessObjectProperties collection. Read-only.

Syntax

expression .Properties

expression A variable that represents a CurrentProject object.

Remarks

The AccessObjectProperties collection object is the collection of all the properties related to a CurrentProject object. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the AccessObjectProperties collection's Count property minus 1

See also

Concepts

CurrentProject Object

Other resources

CurrentProject Object Members


Recordset2.EditMode Property (DAO)

 Copy code hover
[image]

Recordset2.EditMode Property (DAO)
Send feedback

Returns a value that indicates the state of editing for the current record.

Syntax

expression .EditMode

expression A variable that represents a Recordset2 object.

Remarks

The return value is a Long that indicates the state of editing. The value can be one of the EditModeEnum constants.

The EditMode property is useful when an editing process is interrupted, for example, by an error during validation. You can use the value of the EditMode property to determine whether you should use the Update or CancelUpdate method.

You can also check to see if the LockEdits property setting is True and the EditMode property setting is dbEditInProgress to determine whether the current page is locked.

Example

This example shows the value of the EditMode property under various conditions. The EditModeOutput function is required for this procedure to run.

VBA Copy code Copy code
Sub EditModeX()

 Dim dbsNorthwind As Database
 Dim rstEmployees As Recordset2

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set rstEmployees = _
 dbsNorthwind.OpenRecordset("Employees", _
 dbOpenDynaset)

 ' Show the EditMode property under different editing
 ' states.
 With rstEmployees
 EditModeOutput "Before any Edit or AddNew:", .EditMode
 .Edit
 EditModeOutput "After Edit:", .EditMode
 .Update
 EditModeOutput "After Update:", .EditMode
 .AddNew
 EditModeOutput "After AddNew:", .EditMode
 .CancelUpdate
 EditModeOutput "After CancelUpdate:", .EditMode
 .Close
 End With

 dbsNorthwind.Close

End Sub

Function EditModeOutput(strTemp As String, _
 intEditMode As Integer)

 ' Print report based on the value of the EditMode
 ' property.
 Debug.Print strTemp
 Debug.Print " EditMode = ";

 Select Case intEditMode
 Case dbEditNone
 Debug.Print "dbEditNone"
 Case dbEditInProgress
 Debug.Print "dbEditInProgress"
 Case dbEditAdd
 Debug.Print "dbEditAdd"
 End Select

End Function


ADOX Code Examples in Microsoft Visual C++ Topics

 Copy code hover
[image]

ADOX Code Examples in Microsoft Visual C++ Topics
Send feedback

In this section

  • ADOX Code Examples in Microsoft Visual C++

  • Attributes Property Example (VC++)

  • Catalog ActiveConnection Property Example (VC++)

  • Clustered Property Example (VC++)

  • Columns and Tables Append Methods, Name Property Example (VC++)

  • Command and CommandText Properties Example (VC++)

  • Connection Close Method, Table Type Property Example (VC++)

  • Create Method Example (VC++)

  • DateCreated and DateModified Properties Example (VC++)

  • DefinedSize Property Example (VC++)

  • DeleteRule Property Example (VC++)

  • GetObjectOwner and SetObjectOwner Methods Example (VC++)

  • GetPermissions and SetPermissions Methods Example (VC++)

  • GetString Method Example (VC++)

  • Groups and Users Append, ChangePassword Methods Example (VC++)

  • Indexes Append Method Example (VC++)

  • IndexNulls Property Example (VC++)

  • Keys Append Method, Key Type, RelatedColumn, RelatedTable and UpdateRule Properties Example (VC++)

  • NumericScale and Precision Properties Example (VC++)

  • Parameters Collection, Command Property Example (VC++)

  • ParentCatalog Property Example (VC++)

  • PrimaryKey and Unique Properties Example (VC++)


ODBC - delete on a linked table

 Copy code hover
[image]

ODBC - delete on a linked table <table> failed. (Error 3156)
Send feedback

Using an ODBC connection, you tried to delete data from an ODBC database; the deletion could not be completed.

Possible causes:

  • The deletion would have caused a rule violation.

  • The ODBC database is read-only, or you do not have permission to delete data in that database. Resolve the read-only condition, or see your system administrator or the person who created the database to obtain the necessary permissions.

  • The ODBC database is on a network drive and the network is not connected. Make sure the network is available, and then try the operation again.


Pages Properties (Access)

 Copy code hover
[image]

Pages Properties (Access)
Send feedback

Published: July 16, 2012

This object has the following properties:

Properties

Name | Description
Count | You can use the Count property to determine the number of items in a specified collection. Read-only Long.
Item | The Item property returns a specific member of a collection either by position or by index. Read-only Page.


TextBox.TopPadding Property (Access)

 Copy code hover
[image]

TextBox.TopPadding Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the amount of space (in inches) between the text box and its top gridline. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .TopPadding

expression A variable that represents a TextBox object.

See also

Concepts

TextBox Object

Other resources

TextBox Object Members


Cannot group on fields selected with '*'. (Error 3121)

 Copy code hover
[image]

Cannot group on fields selected with '*'. (Error 3121)
Send feedback

You tried to execute a SELECT statement that groups or totals all fields from all tables, selected with an asterisk ( * ).

Possible cause:

  • You created an SQL statement that includes an aggregate function or GROUP BY clause that refers to a field you selected with an asterisk. This error occurs, for example, if you enter the following SQL statement:

    SQL Copy code Copy code
    SELECT * FROM Orders GROUP BY ShipVia;


Refresh Method Example (VC++)

 Copy code hover
[image]

Refresh Method Example (VC++)
Send feedback

This example demonstrates using the Refresh method to refresh the Parameters collection for a stored procedure Command object.

Copy code Copy code

// BeginRefreshCpp
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>
#include "RefreshX.h"

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void RefreshX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);
inline char* mygets(char* strDest, int n)
{
 char strExBuff[10];
 char* pstrRet = fgets(strDest, n, stdin);

 if (pstrRet == NULL)
 return NULL;

 if (!strrchr(strDest, '\n'))
 // Exhaust the input buffer.
 do
 {
 fgets(strExBuff, sizeof(strExBuff), stdin);
 }while (!strrchr(strExBuff, '\n'));
 else
 // Replace '\n' with '\0'
 strDest[strrchr(strDest, '\n') - strDest] = '\0';

 return pstrRet;
}

//////////////////////////////
// //
// Main Function //
// //
//////////////////////////////
void main()
{
 if(FAILED(::CoInitialize(NULL)))
 return;

 RefreshX();

 ::CoUninitialize();
}

////////////////////////////////////////////
// //
// RefreshX Function //
// //
////////////////////////////////////////////

void RefreshX(void)
{
 HRESULT hr = S_OK;

 // Define string variables.
 _bstr_t strCnn("Provider='sqloledb';Data Source='MySqlServer';"
 "Initial Catalog='pubs';Integrated Security='SSPI';");

 // Define ADO object pointers.
 // Initialize pointers on define.
 // These are in the ADODB:: namespace.
 _ConnectionPtr pConnection = NULL;
 _CommandPtr pCmdByRoyalty = NULL;
 _RecordsetPtr pRstByRoyalty = NULL;
 _RecordsetPtr pRstAuthors = NULL;
 IADORecordBinding *picRs = NULL; //Interface Pointer declared.
 CAuthorsRs authorsrs; //C++ class object

 try
 {
 // Open connection.
 TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
 pConnection->Open (strCnn, "", "", adConnectUnspecified);

 // Open a command object for a stored procedure,
 // with one parameter.
 TESTHR(pCmdByRoyalty.CreateInstance(__uuidof(Command)));
 pCmdByRoyalty->ActiveConnection = pConnection;
 pCmdByRoyalty->CommandText = "byroyalty";
 pCmdByRoyalty->CommandType = adCmdStoredProc;
 pCmdByRoyalty->Parameters->Refresh();

 // Get parameter value and execute the command,
 // storing the results in a recordset.
 char *strRoyalty;
 char strTemp[5];
 do
 {
 printf("\n\nEnter royalty : ");
 mygets(strTemp, 5);

 strRoyalty = strtok(strTemp," \t");
 if(strRoyalty == NULL)
 {
 exit(1);
 }

 // if the input is not numeric then notify the user.
 if(!atoi(strRoyalty))
 {
 printf("\nExpecting numeric value...");
 continue;
 }
 }while(!atoi(strRoyalty));

 _variant_t vtroyal;
 vtroyal.vt = VT_I2;
 vtroyal.iVal = atoi(strRoyalty);
 _variant_t Index;
 Index.vt = VT_I2;
 Index.iVal = 1;
 pCmdByRoyalty->GetParameters()->GetItem(Index)->
 PutValue(vtroyal);
 pRstByRoyalty = pCmdByRoyalty->
 Execute(NULL,NULL,adCmdStoredProc);

 // Open the Authors table to get author names for display.
 TESTHR(pRstAuthors.CreateInstance(__uuidof(Recordset)));
 pRstAuthors->Open ("authors",
 _variant_t((IDispatch *) pConnection, true),
 adOpenForwardOnly, adLockReadOnly, adCmdTable);

 //Open an IADORecordBinding interface pointer which we'll use for
 //Binding Recordset to a class.
 TESTHR(pRstAuthors->QueryInterface(
 __uuidof(IADORecordBinding),(LPVOID*)&picRs));

 //Bind the Recordset to a C++ Class here.
 TESTHR(picRs->BindToRecordset(&authorsrs));

 // Print current data in the recordset,adding
 // author names from Authors table.
 printf("\n\nAuthors with %s percent royalty\n\n",strRoyalty);
 while(!(pRstByRoyalty->EndOfFile))
 {
 _bstr_t strAuthorID = pRstByRoyalty->Fields->GetItem(
 "au_id")->Value;

 printf(" %s",(LPCSTR) (_bstr_t) pRstByRoyalty->Fields->
 GetItem("au_id")->Value);

 pRstAuthors->Filter = "au_id ='"+strAuthorID+"'";
 printf(", %s %s\n\n",authorsrs.lau_fnameStatus == adFldOK ?
 authorsrs.m_szau_fname : "<NULL>",
 authorsrs.lau_lnameStatus == adFldOK ?
 authorsrs.m_szau_lname : "<NULL>");
 pRstByRoyalty->MoveNext();
 }
 }
 catch (_com_error &e)
 {
 PrintProviderError(pConnection);
 PrintComError(e);
 }

 if (pRstByRoyalty)
 if (pRstByRoyalty->State == adStateOpen)
 pRstByRoyalty->Close();
 if (pRstAuthors)
 if (pRstAuthors->State == adStateOpen)
 pRstAuthors->Close();
 if (pConnection)
 if (pConnection->State == adStateOpen)
 pConnection->Close();
}

///////////////////////////////////////////////////////////
// //
// PrintProviderError Function //
// //
///////////////////////////////////////////////////////////
void PrintProviderError(_ConnectionPtr pConnection)
{
 // Print Provider Errors from Connection object.
 // pErr is a record object in the Connection's Error collection.
 ErrorPtr pErr = NULL;

 if( (pConnection->Errors->Count) > 0)
 {
 long nCount = pConnection->Errors->Count;

 // Collection ranges from 0 to nCount -1.
 for(long i = 0;i < nCount;i++)
 {
 pErr = pConnection->Errors->GetItem(i);
 printf("\t Error number: %x\t%s", pErr->Number,
 pErr->Description);
 }
 }
}

///////////////////////////////////////////////////////////
// //
// PrintComError Function //
// //
///////////////////////////////////////////////////////////
void PrintComError(_com_error &e)
{
 _bstr_t bstrSource(e.Source());
 _bstr_t bstrDescription(e.Description());

 // Print COM errors.
 printf("Error\n");
 printf("\tCode = %08lx\n", e.Error());
 printf("\tCode meaning = %s\n", e.ErrorMessage());
 printf("\tSource = %s\n", (LPCSTR) bstrSource);
 printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
// EndRefreshCpp

RefreshX.h

Copy code Copy code

// BeginRefreshH
#include "icrsint.h"

//This Class extracts lname,fname from authors table.
class CAuthorsRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CAuthorsRs)
 // Column lname is the 2nd field in the recordset
 ADO_VARIABLE_LENGTH_ENTRY2(2, adVarChar, m_szau_lname,
 sizeof(m_szau_lname), lau_lnameStatus, TRUE)
 // Column fname is the 3rd field in the recordset.
 ADO_VARIABLE_LENGTH_ENTRY2(3, adVarChar, m_szau_fname,
 sizeof(m_szau_fname), lau_fnameStatus, TRUE)

END_ADO_BINDING()

public:
 CHAR m_szau_fname[21];
 ULONG lau_fnameStatus;
 CHAR m_szau_lname[41];
 ULONG lau_lnameStatus;
};
// EndRefreshH


Application.OpenCurrentDatabase Method (Access)

 Copy code hover
[image]

Application.OpenCurrentDatabase Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the OpenCurrentDatabase method to open an existing Microsoft Access database as the current database.

Syntax

expression .OpenCurrentDatabase(filepath, Exclusive, bstrPassword)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
filepath | Required | String | The name of an existing database file, including the path name and the file name extension.
Exclusive | Optional | Boolean | Specifies whether you want to open the database in exclusive mode. The default value is False, which specifies that the database should be opened in shared mode.
bstrPassword | Optional | String | The password to open the specified database.

Return Value

Nothing

Remarks

You can use this method to open a database from another application that is controlling Microsoft Access through Automation, formerly called OLE Automation. For example, you can use the OpenCurrentDatabase method from Microsoft Excel to open the Northwind.mdb sample database in the Microsoft Access window. Once you have created an instance of Microsoft Access from another application, you must also create a new database or specify a particular database to open. This database opens in the Microsoft Access window.

If you have already opened a database and wish to open another database in the Microsoft Access window, you can use the CloseCurrentDatabase method to close the first database before opening another.

Note Note

Use the OpenAccessProject method to open an existing Microsoft Access project (.adp) as the current database.

Note Note

Don't confuse the OpenCurrentDatabase method with the ActiveX Data Objects (ADO) Open method or the Data Access Object (DAO) OpenDatabase method. The OpenCurrentDatabase method opens a database in the Microsoft Access window. The DAO OpenDatabase method returns a Database object variable, which represents a particular database but don't actually open that database in the Microsoft Access window.

Example

The following example opens a Microsoft Access database from another application through Automation and then opens a form in that database.

You can enter this code in a Visual Basic module in any application that can act as a COM component. For example, you might run the following code from Microsoft Excel, Microsoft Visual Basic, or Microsoft Access.

When the variable pointing to the Application object goes out of scope, the instance of Microsoft Access that it represents closes as well. Therefore, you should declare this variable at the module level.

VBA Copy code Copy code
' Include the following in Declarations section of module.
Dim appAccess As Access.Application

Sub DisplayForm()

 Dim strDB as String

 ' Initialize string to database path.
 Const strConPathToSamples = "C:\Program " _
 & "Files\Microsoft Office\Office11\Samples\"

 strDB = strConPathToSamples & "Northwind.mdb"
 ' Create new instance of Microsoft Access.
 Set appAccess = _
 CreateObject("Access.Application")
 ' Open database in Microsoft Access window.
 appAccess.OpenCurrentDatabase strDB
 ' Open Orders form.
 appAccess.DoCmd.OpenForm "Orders"
End Sub

See also

Concepts

Application Object

Other resources

Application Object Members


Command (ADO/WFC Syntax)

 Copy code hover
[image]

Command (ADO/WFC Syntax)
Send feedback

package com.ms.wfc.data

Constructor

Copy code Copy code

public Invalid DDUE based on source, error:link not allowed in code, link filename:mdobjcommand_HV10294191.xml()
public Command(String commandtext)

Methods

Copy code Copy code

public void Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthadocancel_HV10294125.xml()
public com.ms.wfc.data.Parameter Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcreateparam_HV10294243.xml(String
 Name, int Type, int Direction, int Size, Object Value)
public Recordset Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcmdexecute_HV10294344.xml()
public Recordset execute(Object[] parameters)
public Recordset execute(Object[] parameters, int options)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdmthcmdexecute_HV10294344.xml(Object[] parameters)
public int executeUpdate(Object[] parameters, int options)
public int executeUpdate()

The executeUpdate method is a special case method that calls the underlying ADO execute method with certain parameters. The executeUpdate method does not support the return of a Recordset object, so the execute method's options parameter is modified with AdoEnums.ExecuteOptions.NORECORDS. After the execute method completes, its updated RecordsAffected parameter is passed back to the executeUpdate method, which is finally returned as an int.

Properties

Copy code Copy code

public com.ms.wfc.data.Connection Invalid DDUE based on source, error:link not allowed in code, link filename:mdproactivecon_HV10293988.xml()
public void setActiveConnection(com.ms.wfc.data.Connection con)
public void setActiveConnection(String conString)
public String Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocommandtext_HV10294195.xml()
public void setCommandText(String command)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocommandtimeout_HV10294196.xml()
public void setCommandTimeout(int timeout)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprocommandtype_HV10294197.xml()
public void setCommandType(int type)
public String Invalid DDUE based on source, error:link not allowed in code, link filename:mdproname_HV10294535.xml()
public void setName(String name)
public boolean Invalid DDUE based on source, error:link not allowed in code, link filename:mdproprepared_HV10294617.xml()
public void setPrepared(boolean prepared)
public int Invalid DDUE based on source, error:link not allowed in code, link filename:mdprostate_HV10294804.xml()
public com.ms.wfc.data.Parameter Invalid DDUE based on source, error:link not allowed in code, link filename:mdobjparameter_HV10294590.xml(int n)
public com.ms.wfc.data.Parameter getParameter(String n)
public com.ms.wfc.data.Parameters Invalid DDUE based on source, error:link not allowed in code, link filename:mdcolparameters_HV10294594.xml()
public AdoProperties Invalid DDUE based on source, error:link not allowed in code, link filename:mdcolproperties_HV10294633.xml()


Synchronizer could not access the message database. (Error 3525)

 Copy code hover
[image]

Synchronizer could not access the message database. (Error 3525)
Send feedback

The message database is not available for use by the Synchronizer. The database file may be in use by another program or user (users should not open Synchronizer message databases). Close any application that might be using the database.


The number of columns in the two selected tables or queries of a union query do not match. (Error 3307)

 Copy code hover
[image]

The number of columns in the two selected tables or queries of a union query do not match. (Error 3307)
Send feedback

The two tables or queries joined by the UNION operation must generate the same number of columns. Remove columns from the SELECT statement that has too many columns or include more columns in the SELECT statement that has too few.

Note Note

You can include constants instead of columns in the SELECT statement that has too few columns. For example, the following union query generates three columns from the first SELECT statement but one column and two constants in the second SELECT statement. The query returns all countries in the Employees and Regions tables. From the Employees table, the query also returns the first and last name of an employee. If the country value is from the Regions table, however, the query returns Null in the First Name and Last Name columns.
SQL Copy code Copy code
SELECT Country, FirstName, LastName FROM Employees
UNION SELECT Country, NULL, NULL FROM Regions;


Failed to send a message. (Error 3519)

 Copy code hover
[image]

Failed to send a message. (Error 3519)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


Application.OpenAccessProject Method (Access)

 Copy code hover
[image]

Application.OpenAccessProject Method (Access)
See also Send feedback

Published: July 16, 2012

You can use the OpenAccessProject method to open an existing Microsoft Access project (.adp) as the current Access project in the Microsoft Access window.

Syntax

expression .OpenAccessProject(filepath, Exclusive)

expression A variable that represents an Application object.

Parameters

Name | Required/Optional | Data Type | Description
filepath | Required | String | The name of the existing Access project, including the path name and the file name extension.
Exclusive | Optional | Boolean | Specifies whether you want to open the Access project in exclusive mode. The default value is False, which specifies that the Access project should be opened in shared mode.

Return Value

Nothing

Remarks

The OpenAccessProject method enables you to open an existing project from within Microsoft Access or another application through Automation, formally called OLE Automation. For example, you can use the OpenAccessProject method from Microsoft Excel to open the Northwind.adp sample database in the Microsoft Access window. Once you have created an instance of Microsoft Access from another application, you must also create a new Access project or specify a particular Access project to open. This Access project opens in the Microsoft Access window.

If you have already opened a project and wish to open another project in the Microsoft Access window, you can use the CloseCurrentDatabase method to close the first Access project before opening another.

Note Note

To open an Access database, use the OpenCurrentDatabase method of the Application object.

See also

Concepts

Application Object

Other resources

Application Object Members


GroupLevel Object (Access)

 Copy code hover
[image]

GroupLevel Object (Access)
See also Send feedback

Published: July 16, 2012

You can use the GroupLevel property in Visual Basic to refer to the group level you are grouping or sorting on in a report.

Remarks

The GroupLevel property setting is an array in which each entry identifies a group level. To refer to a group level, use this syntax:

GroupLevel(n)

The number n is the group level, starting with 0. The first field or expression you group on is group level 0, the second is group level 1, and so on. You can have up to 10 group levels (0 to 9).

The following sample settings show how you use the GroupLevel property to refer to a group level.

Group level | Refers to
GroupLevel(0) | The first field or expression you sort or group on.
GroupLevel(1) | The second field or expression you sort or group on.
GroupLevel(2) | The third field or expression you sort or group on.

You can use this property only by using Visual Basic to set the SortOrder , GroupOn , GroupInterval , KeepTogether , and ControlSource properties. You set these properties in the Open event procedure of a report.

In reports, you can group or sort on more than one field or expression. Each field or expression you group or sort on is a group level.

You specify the fields and expressions to sort and group on by using the CreateGroupLevel method.

If a group is already defined for a report (the GroupLevel property is set to 0), then you can use the ControlSource property to change the group level in the report's Open event procedure. For example, the following code changes the ControlSource property to a value contained in the txtPromptYou text box on the open form named SortForm:

VBA Copy code Copy code
Private Sub Report_Open(Cancel As Integer)
 Me.GroupLevel(0).ControlSource _
 = Forms!SortForm!txtPromptYou
End Sub

See also

Concepts

Access Object Model Reference

Other resources

GroupLevel Object Members


The search key was not found in any record. (Error 3709)

 Copy code hover
[image]

The search key was not found in any record. (Error 3709)
Send feedback

This error occurs when an ISAM SEEK is being executed and there are no matching values in the index.


Form.Undo Event (Access)

 Copy code hover
[image]

Form.Undo Event (Access)
See also Send feedback

Published: July 16, 2012

Occurs when the user undoes a change.

Syntax

expression .Undo(Cancel)

expression A variable that represents a Form object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | Set this argument to True to cancel the undo operation and leave the control or form in its edited state.

Remarks

The Undo event for controls occurs whenever the user returns a control to its original state by clicking the Undo Field/Record button on the command bar, clicking the Undo button, pressing the ESC key, or calling the Undo method of the specified control. The control needs to have focus in all three cases. The event does not occur if the user clicks the Undo Typing button on the command bar.

The Undo event for forms occurs whenever the user returns a form to its original state by clicking the Undo button, pressing the ESC key, or calling the Undo method of the specified form.

Example

The following example demonstrates the syntax for a subroutine that traps the Undo event for a form.

VBA Copy code Copy code
Private Sub Form_Undo(Cancel As Integer)
 Dim intResponse As Integer
 Dim strPrompt As String

 strPrompt = "Cancel the undo operation?"

 intResponse = MsgBox(strPrompt, vbYesNo)

 If intResponse = vbYes Then
 Cancel = True
 Else
 Cancel = False
 End If
End Sub

See also

Concepts

Form Object

Other resources

Form Object Members


DBEngine.BeginTrans Method (DAO)

 Copy code hover
[image]

DBEngine.BeginTrans Method (DAO)
Send feedback

Begins a new transaction. Read/write Database.

Syntax

expression .BeginTrans

expression A variable that represents a DBEngine object.

Remarks

The transaction methods BeginTrans, CommitTrans, and Rollback manage transaction processing during a session defined by a Workspace object. You use these methods with a Workspace object when you want to treat a series of changes made to the databases in a session as one unit.

Typically, you use transactions to maintain the integrity of your data when you must both update records in two or more tables and ensure changes are completed (committed) in all tables or none at all (rolled back). For example, if you transfer money from one account to another, you might subtract an amount from one and add the amount to another. If either update fails, the accounts no longer balance. Use the BeginTrans method before updating the first record, and then, if any subsequent update fails, you can use the Rollback method to undo all of the updates. Use the CommitTrans method after you successfully update the last record.

Note Note

Within one Workspace object, transactions are always global to the Workspace and aren't limited to only one Connection or Database object. If you perform operations on more than one connection or database within a Workspace transaction, resolving the transaction (that is, using the CommitTrans or Rollback method) affects all operations on all connections and databases within that workspace.

After you use CommitTrans, you can't undo changes made during that transaction unless the transaction is nested within another transaction that is itself rolled back. If you nest transactions, you must resolve the current transaction before you can resolve a transaction at a higher level of nesting.

If you want to have simultaneous transactions with overlapping, non-nested scopes, you can create additional Workspace objects to contain the concurrent transactions.

If you close a Workspace object without resolving any pending transactions, the transactions are automatically rolled back.

If you use the CommitTrans or Rollback method without first using the BeginTrans method, an error occurs.

Some ISAM databases used in a Microsoft Access workspace may not support transactions, in which case the Transactions property of the Database object or Recordset object is False. To make sure the database supports transactions, check the value of the Transactions property of the Database object before using the BeginTrans method. If you are using a Recordset object based on more than one database, check the Transactions property of the Recordset object. If a Recordset is based entirely on Microsoft Access database engine tables, you can always use transactions. Recordset objects based on tables created by other database products, however, may not support transactions. For example, you can't use transactions in a Recordset based on a Paradox table. In this case, the Transactions property is False. If the Database or Recordset doesn't support transactions, the methods are ignored and no error occurs.

You can't nest transactions if you are accessing ODBC data sources through the Microsoft Access database engine.

In ODBC workspaces, when you use CommitTrans your cursor may no longer be valid. Use the Requery method to view the changes in the Recordset, or close and re-open the Recordset.

Note Note

  • You can often improve the performance of your application by breaking operations that require disk access into transaction blocks. This buffers your operations and may significantly reduce the number of times a disk is accessed.

  • In a Microsoft Access workspace, transactions are logged in a file kept in the directory specified by the TEMP environment variable on the workstation. If the transaction log file exhausts the available storage on your TEMP drive, the database engine triggers a run-time error. At this point, if you use CommitTrans, an indeterminate number of operations are committed, but the remaining uncompleted operations are lost, and the operation has to be restarted. Using a Rollback method releases the transaction log and rolls back all operations in the transaction.

  • Closing a clone Recordset within a pending transaction will cause an implicit Rollback operation.


BoundObjectFrame.AfterUpdate Event (Access)

 Copy code hover
[image]

BoundObjectFrame.AfterUpdate Event (Access)
See also Send feedback

Published: July 16, 2012

The AfterUpdate event occurs after changed data in a control or record is updated.

Syntax

expression .AfterUpdate

expression A variable that represents a BoundObjectFrame object.

Remarks

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's AfterUpdate event does occur.

To run a macro or event procedure when this event occurs, set the AfterUpdate property to the name of the macro or to [Event Procedure].

The AfterUpdate event is triggered when a control or record is updated. Within a record, changed data in each control is updated when the control loses the focus or when the user presses ENTER or TAB.

When you enter new or changed data in a control on a form and then move to another record or save the record by clicking Save Record on the Records menu, the AfterUpdate event for the form occur immediately after the AfterUpdate event for the control. When you move to a different record, the Exit and LostFocus events for the control occur, followed by the Current event for the record you moved to, and the Enter and GotFocus events for the first control in this record. To run the AfterUpdate macro or event procedure without running the Exit and LostFocus macros or event procedures, save the record by using the Save Record command on the Records menu.

AfterUpdate macros and event procedures run only if you change the data in a control. This event does not occur when a value changes in a calculated control. AfterUpdate macros and event procedures for a form run only if you change the data in one or more controls in the record.

For bound controls, the OldValue property isn't set to the updated value until after the AfterUpdate event for the form occurs. Even if the user enters a new value in the control, the OldValue property setting isn't changed until the data is saved (the record is updated). If you cancel an update, the value of the OldValue property replaces the existing value in the control.

Note Note

To perform simple validations, or more complex validations such as requiring a value in a field or validating more than one control on a form, you can use the ValidationRule property for controls and the ValidationRule and Required properties for fields and records in tables.

See also

Concepts

BoundObjectFrame Object

Other resources

BoundObjectFrame Object Members


ListBox.DblClick Event (Access)

 Copy code hover
[image]

ListBox.DblClick Event (Access)
See also Send feedback

Published: July 16, 2012

The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Syntax

expression .DblClick(Cancel)

expression A variable that represents a ListBox object.

Parameters

Name | Required/Optional | Data Type | Description
Cancel | Required | Integer | The setting determines if the DblClick event occurs. Setting the Cancel argument to True (-1) cancels the DblClick event.

Remarks

On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. For a control, it occurs when the user double-clicks a control or its label in Form view. The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • This event doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button, the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.

If you double-click any other control besides a command button, the second Click event doesn't occur.

Example

The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

VBA Copy code Copy code
Private Sub EmployeeID_DblClick(Cancel As Integer)
 DoCmd.OpenForm "Employees", , , _
 "EmployeeID = Forms!Orders!EmployeeID"
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


Workspace.Properties Property (DAO)

 Copy code hover
[image]

Workspace.Properties Property (DAO)
Send feedback

Returns the Properties collection of the specified object. Read-only.

Syntax

expression .Properties

expression A variable that represents a Workspace object.


ComboBox.TopMargin Property (Access)

 Copy code hover
[image]

ComboBox.TopMargin Property (Access)
See also Send feedback

Published: July 16, 2012

Along with the LeftMargin, RightMargin, and BottomMargin properties, specifies the location of information displayed within a text box control. Read/write Integer.

Version Information

Version Added: Access 2007

Syntax

expression .TopMargin

expression A variable that represents a ComboBox object.

Remarks

A control's displayed information location is measured from the control's left, top, right, or bottom border to the left, top, right, or bottom edge of the displayed information. Setting the LeftMargin or TopMargin property to 0 places the displayed information's edge at the very left or top of the control. To use a unit of measurement different from the setting in the regional settings of Windows, specify the unit (for example, cm or in).

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

See also

Concepts

ComboBox Object

Other resources

ComboBox Object Members


How to: Create a Database Template Programmatically

 Copy code hover
[image]

How to: Create a Database Template Programmatically
Send feedback

The SaveAsTemplate method enables you to convert an existing Access database file to a database template (*.accdt) format file that can be featured on the Getting Started with Microsoft Office Access page.

Syntax

expression .SaveAsTemplate(TemplateLocation, TemplateName, PreviewImage, Description, Category, Keywords, Identifier, Reserved)

expression A variable that represents a TemplateCreator object.

The following table describes the arguments of the SaveAsTemplate method.

Name | Required/Optional | Data Type | Description
TemplateLocation | Required | String | The full path and file name of the database template to create.For the template to appear on the Getting Started with Microsoft Office Access page, it must be saved to Microsoft\Templates subfolder of the user's Application Data folder. In Windows XP, the default location of the Application Data folder is C:\Documents and Settings\User Name\Application Data, where User Name is the name of the user who is currently logged on.In Windows Vista, the default location of the Application Data folder is C:\Users\User Name\AppData\Roaming, where User Name is the name of the user who is currently logged on.You can use the Environ function to determine the current location of the user's Application Data folder. The following code illustrates how to do this. strTemplateLocation = Environ("AppData") & "\Microsoft\Templates\"
TemplateName | Optional | String | The name of the database that is created when the user opens the template.
PreviewImage | Optional | String | An image file to be used as a preview for the database template on the Getting Started with Microsoft Office Access page.
Description | Optional | String | A description to be displayed when the user selects the database template in the Getting Started with Microsoft Office Access page.
Category | Optional | String | The Template Category under which the database template will appear on the Getting Started with Microsoft Office Access page.
Keywords | Optional | String | Keywords to be added to the template's file properties.
Identifier | Optional | String |
Reserved | Optional | String |

Usage

You must instantiate the TemplateCreator object before you call the SaveAsTemplate method. Instantiating the TemplateCreator object requires a different technique from instantiating the built-in objects in Access. To instantiate the TemplateCreator object, you must use the COMAddins collection.

The following code illustrates how to instantiate the AccessDeveloperExtensions object through the COMAddins collection.

VBA Copy code Copy code
Set objTemplate = Application.COMAddIns("AccessAddIn.ADE").Object.TemplateObject

The following example creates a new template named Asset Tracker and assigns it to the Departmental data category on the Getting Started with Microsoft Office Access page.

VBA Copy code Copy code
    Dim objTemplate As TemplateCreator
    Dim strTemplateLocation As String

    ' The database template must be saved to this location to appear on the
    ' Getting Started with Microsoft Office Access page.
    strTemplateLocation = Environ("AppData") & "\Microsoft\Templates\"

    ' Instantiate a TemplateObject object.
    Set objTemplate = Application.COMAddIns("AccessAddIn.ADE").Object.TemplateObject

    ' Create the database template.
    objTemplate.SaveAsTemplate TemplateLocation:=strTemplateLocation & "AssetTracker.accdt", _
                               TemplateName:="Asset Tracker", _
                               Category:="Departmental Data"

You must set a reference to the Access Developer Extensions type library in order to use the SaveAsTemplate method. To do this, follow these steps:

  1. On the Tools menu, click References.

  2. Select the Microsoft Office Access Developer Extensions Type Library 1.0 check box, and then click OK.


RunDataMacro Macro Action

 Copy code hover
[image]

RunDataMacro Macro Action
Send feedback

You can use the RunDataMacro action to run a named data macro.

Setting

The RunDataMacro action has the following argument.

Action argument | Description
Name | The name of the data macro to run.

Remarks

You can use the RunDataMacro action in macros, named data macros, and the following macro events: After Delete Macro Event, After Insert Macro Event and After Update Macro Event.

The name of the data macro must include the table to which it is attached (for example, Comments.AddComment, not just AddComment).

When you select the data macro that you want to run in the macro designer, Access determines if the data macro requires parameters. If the data macro requires parameters, text boxes appear where you can type in the arguments.

When you run a macro that contains the RunDataMacro action and it reaches the RunDataMacro action, Access runs the called data macro. When the called data macro has finished, Access returns to the original macro and runs the next action.

Example

The following example shows how to pass a parameter to a named data macro. The dmGetCurrentServiceRequest data macro of the tblServiceRequests table is called by using the RunDataMacro action. When the dmGetCurrentServiceRequest is finished, the CurrentServiceRequest variable returned form the data macro is written to the txtCurrentSR text box.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

Copy code Copy code
RunDataMacro
    Macro Name tblServiceRequests.dmGetCurrentServiceRequest

Parameters
    prmAssignedTo =[ID]

SetProperty
    Control Name txtCurrentSR
    Property Value
    Value =[ReturnVars]![CurrentServiceRequest]

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


GROUP BY Clause (Microsoft Access SQL)

 Copy code hover
[image]

GROUP BY Clause (Microsoft Access SQL)
Send feedback

Published: July 16, 2012

Combines records with identical values in the specified field list into a single record. A summary value is created for each record if you include an SQL aggregate function, such as Sum or Count, in the SELECT statement.

Syntax

SELECT fieldlist FROM table WHERE criteria [GROUP BY groupfieldlist]

A SELECT statement containing a GROUP BY clause has these parts:

Part | Description
fieldlist | The name of the field or fields to be retrieved along with any field-name aliases, SQL aggregate functions, selection predicates (ALL, DISTINCT, DISTINCTROW, or TOP), or other SELECT statement options.
table | The name of the table from which records are retrieved. For more information, see the FROM clause.
criteria | Selection criteria. If the statement includes a WHERE clause, the Microsoft Access database engine groups values after applying the WHERE conditions to the records.
groupfieldlist | The names of up to 10 fields used to group records. The order of the field names in groupfieldlist determines the grouping levels from the highest to the lowest level of grouping.

Remarks

GROUP BY is optional.

Summary values are omitted if there is no SQL aggregate function in the SELECT statement.

Null values in GROUP BY fields are grouped and are not omitted. However, Null values are not evaluated in any SQL aggregate function.

Use the WHERE clause to exclude rows you do not want grouped, and use the HAVING clause to filter records after they have been grouped.

Unless it contains Memo or OLE Object data, a field in the GROUP BY field list can refer to any field in any table listed in the FROM clause, even if the field is not included in the SELECT statement, provided the SELECT statement includes at least one SQL aggregate function. The Microsoft® Jet database engine cannot group on Memo or OLE Object fields.

All fields in the SELECT field list must either be included in the GROUP BY clause or be included as arguments to an SQL aggregate function.

Example

This example creates a list of unique job titles and the number of employees with each title.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

Copy code Copy code
Sub GroupByX1()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' For each title, count the number of employees
    ' with that title.
    Set rst = dbs.OpenRecordset("SELECT Title, " _
        & "Count([Title]) AS Tally " _
        & "FROM Employees GROUP BY Title;")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 25

    dbs.Close

End Sub

For each unique job title, this example calculates the number of employees in Washington who have that title.

Copy code Copy code
Sub GroupByX2()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' For each title, count the number of employees
    ' with that title. Only include employees in the
    ' Washington region.
    Set rst = dbs.OpenRecordset("SELECT Title, " _
        & "Count(Title) AS Tally " _
        & "FROM Employees WHERE Region = 'WA' " _
        & "GROUP BY Title;")

    ' Populate the Recordset.
    rst.MoveLast

    ' Call EnumFields to print the contents of the
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 25

    dbs.Close

End Sub


Could not find Synchronizer in the MSysTranspAddress table. (Error 3518)

 Copy code hover
[image]

Could not find Synchronizer in the MSysTranspAddress table. (Error 3518)
Send feedback

This is an unexpected error. Please contact Microsoft Product Support Services for further information.


WillMove and MoveComplete Events (ADO)

 Copy code hover
[image]

WillMove and MoveComplete Events (ADO)
Send feedback

The WillMove event is called before a pending operation changes the current position in the Recordset. The MoveComplete event is called after the current position in the Recordset changes.

Syntax

WillMove adReason, adStatus, pRecordset

MoveComplete adReason, pError, adStatus, pRecordset

Parameters

  • adReason

  • An EventReasonEnum value that specifies the reason for this event. Its value can be adRsnMoveFirst, adRsnMoveLast, adRsnMoveNext, adRsnMovePrevious, adRsnMove, or adRsnRequery.

  • pError

  • An Error object. It describes the error that occurred if the value of adStatus is adStatusErrorsOccurred; otherwise it is not set.

  • adStatus

  • EventStatusEnum

    When WillMove is called, this parameter is set to adStatusOK if the operation that caused the event was successful. It is set to adStatusCantDeny if this event cannot request cancellation of the pending operation.

    When MoveComplete is called, this parameter is set to adStatusOK if the operation that caused the event was successful, or to adStatusErrorsOccurred if the operation failed.

    Before WillMove returns, set this parameter to adStatusCancel to request cancellation of the pending operation or set this parameter to adStatusUnwantedEvent to prevent subsequent notications.

    Before MoveComplete returns, set this parameter to adStatusUnwantedEvent to prevent subsequent notifications.

  • pRecordset

  • A Recordset object. The Recordset for which this event occurred.

Remarks

A WillMove or MoveComplete event may occur due to the following Recordset operations: Open, Move, MoveFirst, MoveLast, MoveNext, MovePrevious, AddNew, and Requery. These events may occur because of the following properties: Filter, Index, Bookmark, AbsolutePage, and AbsolutePosition. These events also occur if a child Recordset has Recordset events connected and the parent Recordset is moved.

You must set the adStatus parameter to adStatusUnwantedEvent for each possible adReason value in order to completely stop event notification for any event that includes an adReason parameter.


DoCmd.SetWarnings Method (Access)

 Copy code hover
[image]

DoCmd.SetWarnings Method (Access)
See also Send feedback

Published: July 16, 2012

The SetWarnings method carries out the SetWarnings action in Visual Basic.

Syntax

expression .SetWarnings(WarningsOn)

expression A variable that represents a DoCmd object.

Parameters

Name | Required/Optional | Data Type | Description
WarningsOn | Required | Variant | Use True (-1) to turn on the display of system messages and False (0) to turn it off.

Remarks

You can use the SetWarnings method to turn system messages on or off.

If you turn the display of system messages off in Visual Basic, you must turn it back on, or it will remain off, even if the user presses CTRL+BREAK or Visual Basic encounters a breakpoint. You may want to create a macro that turns the display of system messages on and then assign that macro to a key combination or a custom menu command. You could then use the key combination or menu command to turn the display of system messages on if it has been turned off in Visual Basic.

Sample code provided by: Community Member Icon The UtterAccess community | About the Contributors

  • Calling Action Queries

Example

The following example turns the display of system messages off:

VBA Copy code Copy code
DoCmd.SetWarnings False

About the Contributors

UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

See also

Concepts

DoCmd Object

Other resources

DoCmd Object Members


EditRecord Data Block

 Copy code hover
[image]

EditRecord Data Block
Send feedback

You can use the EditRecord data block to change the values contained in an existing record.

Note Note

The EditRecord data block is available only in Data Macros.

Setting

The EditRecord data block has the following arguments.

Argument | Description
Alias | A string that identifies the record to edit. If the Alias argument is not specified, then the current record is edited.

Remarks

After EditRecord statement, you can insert a block of commands that will execute before the changes to the record are comitted. The following actions are available in a EditRecord data block.

CancelRecordChange Macro Action

Comment Macro Statement

Group Macro Statement

If...Then...Else Macro Statement

SetField Macro Action

SetLocalVar Macro Action

Use the SetField action to specify the new values of a field in the edited record.

You can use an If...Then...Else statment to perform operations based on a condition.

To cancel the editing of a record, use the CancelRecordChange action. This prevents the changes from being committed and exits the EditRecord data block.

You can use the LastCreateRecordIdentity local variable to work with last record created in a CreateRecord data block. For example, use the following syntax to refer to the AssignedTo field of the most recently created record:

Copy code Copy code
[LastCreateRecordIdentity].[AssignedTo]

The CreateRecord data block can only be used in the After Insert, After Update, and After Update data macro events.


WSParameters.Item Property (Access)

 Copy code hover
[image]

WSParameters.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only Object.

Version Information

Version Added: Access 2010

Syntax

expression .Item(Index)

expression A variable that represents a WSParameters object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant |

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

WSParameters Collection

Other resources

WSParameters Object Members


Cannot create partial replica of a workgroup information file. (Error 3635)

 Copy code hover
[image]

Cannot create partial replica of a workgroup information file. (Error 3635)
Send feedback

You are attempting to create a partial replica using a workgroup information file as the source. Workgroup information files cannot be replicated.


Index Object (ADOX)

 Copy code hover
[image]

Index Object (ADOX)
Send feedback

Represents an index from a database table.

Remarks

The following code creates a new Index:

Copy code Copy code
Dim obj As New Index

With the properties and collections of an Index object, you can:

  • Identify the index with the Name property.

  • Access the database columns of the index with the Columns collection.

  • Specify whether the index keys must be unique with the Unique property.

  • Specify whether the index is the primary key for a table with the PrimaryKey property.

  • Specify whether records that have null values in their index fields have index entries with the IndexNulls property.

  • Specify whether the index is clustered with the Clustered property.

  • Access provider-specific index properties with the Properties collection.

Note Note

An error will occur when appending a Column to the Columns collection of an Index if the Column does not exist in a Table object already appended to the Tables collection.

Your data provider may not support all properties of Index objects. An error will occur if you have set a value for a property that is not supported by the provider. For new Index objects, the error will occur when the object is appended to the collection. For existing objects, the error will occur when setting the property.

When creating Index objects, the existence of an appropriate default value for an optional property does not guarantee that your provider supports the property. For more information about which properties your provider supports, see your provider documentation.


Using Bookmarks

 Copy code hover
[image]

Using Bookmarks
Send feedback

It is often useful to return directly to a specific record after having moved around in the Recordset without having to scroll through every record and compare values. For example, if you attempt to search for a record using the Find method but the search returns no records, you are automatically placed at either end of the Recordset. If your provider supports them, bookmarks can be used to mark your place before using the Find method so you can return to your location. A bookmark is a Variant type value that uniquely identifies a record in a Recordset object.

You can also use a variant array of bookmarks with the Recordset Filter method to filter on a selected set of records. For details about this technique, see Filtering the Results in the topic, Working with Recordsets, later in this chapter.

You can use the Bookmark property to get a bookmark for a record, or set the current record in a Recordset object to the record identified by a valid bookmark. The following code uses the Bookmark property to set a bookmark and then return to the bookmarked record after moving on to other records. To determine if your Recordset supports bookmarks, use the Supports method.

Copy code Copy code

'BeginBookmarkEg
 Dim varBookmark As Variant
 Dim blnCanBkmrk As Boolean

 objRs.Open strSQL, strConnStr, adOpenStatic, adLockOptimistic, adCmdText

 If objRs.RecordCount > 4 Then
 objRs.Move 4 ' move to the fifth record
 blnCanBkmrk = objRs.Supports(adBookmark)
 If blnCanBkmrk = True Then
 varBookmark = objRs.Bookmark ' record the bookmark
 objRs.MoveLast ' move to a different record
 objRs.Bookmark = varBookmark ' return to the bookmarked (sixth) record
 End If
 End If
'EndBookmarkEg

The Supports method is covered in more detail later.

Except for the case of cloned Recordsets, bookmarks are unique to the Recordset in which they were created, even if the same command is used. This means that you cannot use a Bookmark obtained from one Recordset to move to the same record in a second Recordset opened with the same command.


Control.GridlineStyleLeft Property (Access)

 Copy code hover
[image]

Control.GridlineStyleLeft Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the width of the bottom gridline for the specified control. Read/write Byte.

Version Information

Version Added: Access 2007

Syntax

expression .GridlineStyleLeft

expression A variable that represents a Control object.

Remarks

The BottomGridlineWidth property uses the following settings.

Setting | Description
0 | Hairline. This is the narrowest border possible on your system.
1 to 6 | The width as indicated in points. The default setting is 1 point.

See also

Concepts

Control Object

Other resources

Control Object Members


Visual C++ Extensions Example

 Copy code hover
[image]

Visual C++ Extensions Example
Send feedback

This program shows how values are retrieved from fields and converted to C/C++ variables.

This example also takes advantage of "smart pointers," which automatically handle the COM-specific details of calling and reference counting for the IADORecordBinding interface.

Without smart pointers, you would code:

Copy code Copy code

IADORecordBinding *picRs = NULL;
...
TESTHR(pRs->QueryInterface(
 __uuidof(IADORecordBinding), (LPVOID*)&picRs));
...
if (picRs) picRs->Release();

With smart pointers, you derive the IADORecordBindingPtr type from the type from the IADORecordBinding interface with this statement:

Copy code Copy code

_COM_SMARTPTR_TYPEDEF(IADORecordBinding, __uuidof(IADORecordBinding));

And instantiate the pointer like this:

Copy code Copy code

IADORecordBindingPtr picRs(pRs);

Because the Visual C++ Extensions are implemented by the Recordset object, the constructor for the smart pointer, picRs , takes the _RecordsetPtr pointer, pRs . The constructor calls QueryInterface using pRs to find the , takes the _RecordsetPtr pointer, pRs . The constructor calls QueryInterface using pRs to find the IADORecordBinding interface.

Copy code Copy code

// Visual C++ Extensions Example
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")

#include <stdio.h>
#include <icrsint.h>
_COM_SMARTPTR_TYPEDEF(IADORecordBinding, __uuidof(IADORecordBinding));

inline void TESTHR(HRESULT _hr) { if FAILED(_hr) _com_issue_error(_hr); }

class CCustomRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CCustomRs)
 ADO_VARIABLE_LENGTH_ENTRY2(2, adVarChar, m_ch_fname,
 sizeof(m_ch_fname), m_ul_fnameStatus, false)
 ADO_VARIABLE_LENGTH_ENTRY2(4, adVarChar, m_ch_lname,
 sizeof(m_ch_lname), m_ul_lnameStatus, false)
END_ADO_BINDING()
public:
 CHAR m_ch_fname[22];
 CHAR m_ch_lname[32];
 ULONG m_ul_fnameStatus;
 ULONG m_ul_lnameStatus;
};

void main(void)
{
 ::CoInitialize(NULL);
 try
 {
 _RecordsetPtr pRs("ADODB.Recordset");
 CCustomRs rs;
 IADORecordBindingPtr picRs(pRs);

 pRs->Open("SELECT * FROM Employee ORDER BY lname",
 "dsn=pubs;uid=sa;pwd=;",
 adOpenStatic, adLockOptimistic, adCmdText);

 TESTHR(picRs->BindToRecordset(&rs));

 while (!pRs->EndOfFile)
 {
 // Process data in the CCustomRs C++ instance variables.
 printf("Name = %s %s\n",
 (rs.m_ul_fnameStatus == adFldOK ? rs.m_ch_fname: "<Error>"),
 (rs.m_ul_lnameStatus == adFldOK ? rs.m_ch_lname: "<Error>"));

 // Move to the next row of the Recordset.
 // Fields in the new row will automatically be
 // placed in the CCustomRs C++ instance variables.

 pRs->MoveNext();
 }
 }
 catch (_com_error &e )
 {
 printf("Error:\n");
 printf("Code = %08lx\n", e.Error());
 printf("Meaning = %s\n", e.ErrorMessage());
 printf("Source = %s\n", (LPCSTR) e.Source());
 printf("Description = %s\n", (LPCSTR) e.Description());
 }
 ::CoUninitialize();
}


CommandButton.ShortcutMenuBar Property (Access)

 Copy code hover
[image]

CommandButton.ShortcutMenuBar Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the ShortcutMenuBar property to specify the shortcut menu that will appear when you right-click on the specified object. Read/write String.

Syntax

expression .ShortcutMenuBar

expression A variable that represents a CommandButton object.

Remarks

Note Note

The ShortcutMenuBar property applies only to controls on a form, not controls on a report.

You can also use the ShortcutMenuBar property to specify the menu bar macro that will be used to display a shortcut menu for a datasheet, form, form control, or report.

To display the built-in shortcut menu for a database, form, form control, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

When used with the Application object, the ShortcutMenuBar property enables you to display a custom shortcut menu as a global shortcut menu. However, if you've set the ShortcutMenuBar property for a form, form control, or report in the database, the custom shortcut menu of that object will be displayed in place of the database's global shortcut menu. You can display a different custom shortcut menu for a specific form, form control, or report by setting its ShortcutMenuBar property to a different shortcut menu. When the form, form control, or report has the focus, the custom shortcut menu for that object is displayed when the user clicks the right mouse button; otherwise, the global shortcut menu for the database is displayed.

Shortcut menus aren't available to any object if the AllowShortcutMenus property is set to False.

Example

The following example sets the "Suppliers_Toolbar" as the custom shortcut menu to display when the user clicks the right mouse button on the "Suppliers" form.

VBA Copy code Copy code
Forms("Suppliers").ShortcutMenuBar = "Suppliers_Toolbar"

See also

Concepts

CommandButton Object

Other resources

CommandButton Object Members


Image.SizeMode Property (Access)

 Copy code hover
[image]

Image.SizeMode Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the SizeMode property to specify how to size a picture or other object in a bound object frame, an unbound object frame, or an image control.

Syntax

expression .SizeMode

expression A variable that represents an Image object.

Remarks

The SizeMode property uses the following settings.

Setting | Visual Basic | Description
Clip | acOLESizeClip | (Default) Displays the object at actual size. If the object is larger than the control, its image is clipped on the right and bottom by the control's borders.
Stretch | acOLESizeStretch | Sizes the object to fill the control. This setting may distort the proportions of the object.
Zoom | acOLESizeZoom | Displays the entire object, resizing it as necessary without distorting the proportions of the object. This setting may leave extra space in the control if the control is resized.

Use the Clip setting for the fastest display. You can use the Stretch setting for bar graphs and line graphs without concern for size adjustments. The Stretch setting can distort circles and photos.

Example

The following example creates a linked OLE object using an unbound object frame named OLE1 and sizes the control to display the object's entire contents when the user clicks a command button.

VBA Copy code Copy code
Sub Command1_Click
 OLE1.Class = "Excel.Sheet" ' Set class name.
 ' Specify type of object.
 OLE1.OLETypeAllowed = acOLELinked
 ' Specify source file.
 OLE1.SourceDoc = "C:\Excel\Oletext.xls"
 ' Specify data to create link to.
 OLE1.SourceItem = "R1C1:R5C5"
 ' Create linked object.
 OLE1.Action = acOLECreateLink
 ' Adjust control size.
 OLE1.SizeMode = acOLESizeZoom
End Sub

See also

Concepts

Image Object

Other resources

Image Object Members


WebBrowserControl.BorderTint Property (Access)

 Copy code hover
[image]

WebBrowserControl.BorderTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint that is applied to the theme color in the BorderColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .BorderTint

expression A variable that represents a WebBrowserControl object.

Remarks

The BorderTint property contains a numeric expression that can be used to lighten the theme color in the BorderColor property. The default value of the BorderTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

Example

The following code example lightens BorderColor by 75%.

VBA Copy code Copy code
Me.ctl.BorderTint=25

See also

Concepts

WebBrowserControl Object

Other resources

WebBrowserControl Object Members


Application.WebServices Property (Access)

 Copy code hover
[image]

Application.WebServices Property (Access)
See also Send feedback

Published: July 16, 2012

Gets the collection of installed Data Service data connections. Read-only WebServices.

Version Information

Version Added: Access 2010

Syntax

expression .WebServices

expression A variable that represents an Application object.

See also

Concepts

Application Object

Other resources

Application Object Members


Image.Move Method (Access)

 Copy code hover
[image]

Image.Move Method (Access)
See also Send feedback

Published: July 16, 2012

Moves the specified object to the coordinates specified by the argument values.

Syntax

expression .Move(Left, Top, Width, Height)

expression A variable that represents an Image object.

Parameters

Name | Required/Optional | Data Type | Description
Left | Required | Variant | The screen position in twips for the left edge of the object relative to the left edge of the Microsoft Access window.
Top | Optional | Variant | The screen position in twips for the top edge of the object relative to the top edge of the Microsoft Access window.
Width | Optional | Variant | The desired width in twips of the object.
Height | Optional | Variant | The desired height in twips of the object.

Remarks

Only the Left argument is required. However, to specify any other arguments, you must specify all the arguments that precede it. For example, you cannot specify Width without specifying Left and Top. Any trailing arguments that are unspecified remain unchanged.

This method overrides the Moveable property.

In Datasheet View or Print Preview, changes made using the Move method are saved if the user explicitly saves the database, but Access does not prompt the user to save such changes.

See also

Concepts

Image Object

Other resources

Image Object Members


TableDef.DateCreated Property (DAO)

 Copy code hover
[image]

TableDef.DateCreated Property (DAO)
Send feedback

Returns the date and time that an object was created (Microsoft Access workspaces only). Read-only Variant.

Syntax

expression .DateCreated

expression A variable that represents a TableDef object.

Remarks

DateCreated and LastUpdated return the date and time that the object was created or last updated. In a multiuser environment, users should get these settings directly from the file server to avoid discrepancies in the DateCreated and LastUpdated property settings.


RenameObject Macro Action

 Copy code hover
[image]

RenameObject Macro Action
Send feedback

You can use the RenameObject action to rename a specified database object.

Note 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.

Setting

The RenameObject action has the following arguments.

Action argument

Description

New Name

A new name for the database object. Enter the object name in the New Name box in the Action Arguments section of the Macro Builder pane. This is a required argument.

Object Type

The type of object you want to rename. Click Table, Query, Form, Report, Macro, Module, Data Access Page, Server View, Diagram, Stored Procedure, or Function. To rename the object selected in the Navigation Pane, leave this argument blank.

Old Name

The name of the object to be renamed. The Old Name box shows all objects in the database of the type selected by the Object Type argument. If you leave the Object Type argument blank, leave this argument blank also.

Note Note

If you run a macro containing the Rename action in a library database, Microsoft Access first looks for the object with this name in the library database, and then in the current database.

Remarks

The new name of the database object must follow the standard naming conventions for Access objects.

You can't rename an open object.

If you leave the Object Type and Old Name arguments blank, Access renames the object selected in the Navigation Pane. To select an object in the Navigation Pane, you can use the SelectObject action with the In Navigation Pane argument set to Yes.

You can also rename an object by right-clicking it in the Navigation Pane, clicking Rename, and entering a new name. With the RenameObject action, you don't have to select the object first in the Navigation Pane, and you don't have to stop the macro to enter the new name.

This action differs from the CopyObject action, which creates a copy of the object under a new name.

To run the RenameObject action in a Visual Basic for Applications (VBA) module, use the Rename method of the DoCmd object.


Recordset.CopyQueryDef Method (DAO)

 Copy code hover
[image]

Recordset.CopyQueryDef Method (DAO)
Send feedback

Returns a QueryDef object that is a copy of the QueryDef used to create the Recordset object represented by the recordset placeholder (Microsoft Access workspaces only). .

Syntax

expression .CopyQueryDef

expression A variable that represents a Recordset object.

Return Value

QueryDef

Remarks

You can use the CopyQueryDef method to create a new QueryDef that is a duplicate of the QueryDef used to create the Recordset.

If a QueryDef wasn't used to create this Recordset, an error occurs. You must first open a Recordset with the OpenRecordset method before using the CopyQueryDef method.

This method is useful when you create a Recordset object from a QueryDef, and pass the Recordset to a function, and the function must re-create the SQL equivalent of the query, for example, to modify it in some way.

Example

This example uses the CopyQueryDef method to create a copy of a QueryDef from an existing Recordset and modifies the copy by adding a clause to the SQL property. When you create a permanent QueryDef, spaces, semicolons, or linefeeds may be added to the SQL property; these extra characters must be stripped before any new clauses can be attached to the SQL statement.

VBA Copy code Copy code
Function CopyQueryNew(rstTemp As Recordset, _
 strAdd As String) As QueryDef

 Dim strSQL As String
 Dim strRightSQL As String

 Set CopyQueryNew = rstTemp.CopyQueryDef
 With CopyQueryNew
 ' Strip extra characters.
 strSQL = .SQL
 strRightSQL = Right(strSQL, 1)
 Do While strRightSQL = " " Or strRightSQL = ";" Or _
 strRightSQL = Chr(10) Or strRightSQL = vbCr
 strSQL = Left(strSQL, Len(strSQL) - 1)
 strRightSQL = Right(strSQL, 1)
 Loop
 .SQL = strSQL & strAdd
 End With

End Function

This example shows

This example shows a possible use of CopyQueryNew().

VBA Copy code Copy code
Sub CopyQueryDefX()

 Dim dbsNorthwind As Database
 Dim qdfEmployees As QueryDef
 Dim rstEmployees As Recordset
 Dim intCommand As Integer
 Dim strOrderBy As String
 Dim qdfCopy As QueryDef
 Dim rstCopy As Recordset

 Set dbsNorthwind = OpenDatabase("Northwind.mdb")
 Set qdfEmployees = dbsNorthwind.CreateQueryDef( _
 "NewQueryDef", "SELECT FirstName, LastName, " & _
 "BirthDate FROM Employees")
 Set rstEmployees = qdfEmployees.OpenRecordset( _
 dbOpenForwardOnly)

 Do While True
 intCommand = Val(InputBox( _
 "Choose field on which to order a new " & _
 "Recordset:" & vbCr & "1 - FirstName" & vbCr & _
 "2 - LastName" & vbCr & "3 - BirthDate" & vbCr & _
 "[Cancel - exit]"))
 Select Case intCommand
 Case 1
 strOrderBy = " ORDER BY FirstName"
 Case 2
 strOrderBy = " ORDER BY LastName"
 Case 3
 strOrderBy = " ORDER BY BirthDate"
 Case Else
 Exit Do
 End Select
 Set qdfCopy = CopyQueryNew(rstEmployees, strOrderBy)
 Set rstCopy = qdfCopy.OpenRecordset(dbOpenSnapshot, _
 dbForwardOnly)
 With rstCopy
 Do While Not .EOF
 Debug.Print !LastName & ", " & !FirstName & _
 " - " & !BirthDate
 .MoveNext
 Loop
 .Close
 End With
 Exit Do
 Loop

 rstEmployees.Close
 ' Delete new QueryDef because this is a demonstration.
 dbsNorthwind.QueryDefs.Delete qdfEmployees.Name
 dbsNorthwind.Close

End Sub


TabControl.GridlineShade Property (Access)

 Copy code hover
[image]

TabControl.GridlineShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineShade

expression A variable that represents an TabControl object.

Remarks

The GridlineShade property contains a numeric expression that can be used to darken the theme color in the GridlineColor property. The default value of the GridlineShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and store the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and store the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


ToggleButton.FontUnderline Property (Access)

 Copy code hover
[image]

ToggleButton.FontUnderline Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the FontUnderline property to specify whether text is underlined in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write Boolean.

Syntax

expression .FontUnderline

expression A variable that represents a ToggleButton object.

Remarks

The FontUnderline property uses the following settings.

Setting | Description
True | The text is underlined.
False | (Default) The text isn't underlined.

For reports, you can use this property only in an event procedure or in a macro specified by the OnPrint event property setting.

You can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

See also

Concepts

ToggleButton Object

Other resources

ToggleButton Object Members


Section I: ActiveX Data Objects (Access)

 Copy code hover
[image]

Section I: ActiveX Data Objects (Access)
Send feedback

In this section

  • Section I: ActiveX Data Objects

  • Chapter 1: ADO Fundamentals (ADO)

  • Chapter 2: Getting Data (ADO)

  • Chapter 3: Examining Data (ADO)

  • Chapter 4: Editing Data (ADO)

  • Chapter 5: Updating and Persisting Data (ADO)

  • Chapter 6: Error Handlinge (ADO)

  • Chapter 7: Handling ADO Events (ADO)

  • Chapter 8: Understanding Cursors and Locks (ADO)

  • Chapter 9: Data Shaping (ADO)

  • Chapter 10: Records and Streams (ADO)


Recordset.Filter Property (DAO)

 Copy code hover
[image]

Recordset.Filter Property (DAO)
Send feedback

Sets or returns a value that determines the records included in a subsequently opened Recordset object (Microsoft Access workspaces only). Read/write String.

Syntax

expression .Filter

expression An expression that returns a Recordset object.

Remarks

The setting or return value is a String data type that contains the WHERE clause of an SQL statement without the reserved word WHERE.

Use the Filter property to apply a filter to a dynaset-, snapshot-, or forward-only-type Recordset object.

You can use the Filter property to restrict the records returned from an existing object when a new Recordset object is opened based on an existing Recordset object.

Use the U.S. date format (month-day-year) when you filter fields containing dates, even if you're not using the U.S. version of the Microsoft Access database engine (in which case you must assemble any dates by concatenating strings, for example, strMonth & "-" & strDay & "-" & strYear). Otherwise, the data may not be filtered as you expect.

In many cases, it's faster to open a new Recordset object by using an SQL statement that includes a WHERE clause.

If you set the property to a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, strFilter = "PRICE > " & lngPrice, and lngPrice = 125,50), an error occurs when you try to open the next Recordset. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and Microsoft Access SQL only accepts U.S. decimal characters.

Example

The following sample shows how to use the Filter property to determine the records to be included in a subsequently opened Recordset.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim rstFiltered As DAO.Recordset
Dim strCity As String

Set dbs = CurrentDb

'Create the first filtered Recordset, returning customer records
'for those visited between 30-60 days ago.
Set rest = dbs.OpenRecordset(_
    "SELECT * FROM Customers WHERE LastVisitDate BETWEEN Date()-60 " & _
    "AND Date()-30 ORDER BY LastVisitDate DESC")

'Begin row processing
Do While Not rst.EOF

    'Retrieve the name of the first city in the selected rows
    strCity = rst!City

    'Now filter the Recordset to return only the customers from that city
    rst.Filter = "City = '" & strCity & "'"
    Set rstFiltered = rst.OpenRecordset

    'Process the rows
    Do While Not rstFiltered.EOF
        rstFiltered.Edit
        rstFiltered!ToBeVisited = True
        rstFiltered.Update
        rstFiltered.MoveNext
    Loop

    'We've done what was needed. Now exit
    Exit Do
    rst.MoveNext

Loop

'Cleanup
rstFiltered.Close
rst.Close

Set rstFiltered = Nothing
Set rst = Nothing

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


ListBox.Properties Property (Access)

 Copy code hover
[image]

ListBox.Properties Property (Access)
See also Send feedback

Published: July 16, 2012

Returns a reference to a control's Properties collection object. Read-only.

Syntax

expression .Properties

expression A variable that represents a ListBox object.

Remarks

The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0 and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.

Example

The following procedure uses the Properties property to print all the properties associated with the controls on a form to the Debug window. To run this code, place a command button named cmdListProperties on a form and paste the following code into the form's Declarations section. Click the command button to print the list of properties in the Debug window.

VBA Copy code Copy code
Private Sub cmdListProperties_Click()
 ListControlProps Me
End Sub

Public Sub ListControlProps(ByRef frm As Form)
 Dim ctl As Control
 Dim prp As Property

 On Error GoTo props_err

 For Each ctl In frm.Controls
 Debug.Print ctl.Properties("Name")
 For Each prp In ctl.Properties
 Debug.Print vbTab & prp.Name & " = " & prp.Value
 Next prp
 Next ctl

props_exit:
 Set ctl = Nothing
 Set prp = Nothing
Exit Sub

props_err:
 If Err = 2187 Then
 Debug.Print vbTab & prp.Name & " = Only available at design time."
 Resume Next
 Else
 Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
 Resume Next
 End If
End Sub

See also

Concepts

ListBox Object

Other resources

ListBox Object Members


OptionButton.Enabled Property (Access)

 Copy code hover
[image]

OptionButton.Enabled Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Enabled property to set or return the status of the conditional format in the FormatCondition object. Read/write Boolean.

Syntax

expression .Enabled

expression A variable that represents an OptionButton object.

Remarks

The Enabled property setting is a value that indicates whether the conditional format is enabled or disabled. True enables the conditional format. False disables the conditional format. The default is True.

When the Enabled property is True, the conditional format can be displayed in the Conditional Formatting dialog box.

See also

Concepts

OptionButton Object

Other resources

OptionButton Object Members


Type Property Example (Field) (VB)

 Copy code hover
[image]

Type Property Example (Field) (VB)
Send feedback

This example demonstrates the Type property by displaying the name of the constant that corresponds to the value of the Type property of all the Field objects in the Employees table. The FieldType function is required for this procedure to run.

Copy code Copy code

'BeginTypeFieldVB
Public Sub Main()
 On Error GoTo ErrorHandler

 'To integrate this code
 'replace the data source and initial catalog values
 'in the connection string

 Dim Cnxn As ADODB.Connection
 Dim rstEmployees As ADODB.Recordset
 Dim fld As ADODB.Field
 Dim strCnxn As String
 Dim strSQLEmployee As String
 Dim FieldType As String

 ' Open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 ' Open recordset with data from Employees table
 Set rstEmployees = New ADODB.Recordset
 strSQLEmployee = "employee"
 rstEmployees.Open strSQLEmployee, Cnxn, , , adCmdTable
 'rstEmployees.Open strSQLEmployee, Cnxn, adOpenStatic, adLockReadOnly, adCmdTable
 ' the above two lines of code are identical

 Debug.Print "Fields in Employees Table:" & vbCr

 ' Enumerate Fields collection of Employees table
 For Each fld In rstEmployees.Fields
 ' translate field-type code to text
 Select Case fld.Type
 Case adChar
 FieldType = "adChar"
 Case adVarChar
 FieldType = "adVarChar"
 Case adSmallInt
 FieldType = "adSmallInt"
 Case adUnsignedTinyInt
 FieldType = "adUnsignedTinyInt"
 Case adDBTimeStamp
 FieldType = "adDBTimeStamp"
 End Select
 ' show results
 Debug.Print " Name: " & fld.Name & vbCr & _
 " Type: " & FieldType & vbCr
 Next fld

 ' clean up
 rstEmployees.Close
 Cnxn.Close
 Set rstEmployees = Nothing
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not rstEmployees Is Nothing Then
 If rstEmployees.State = adStateOpen Then rstEmployees.Close
 End If
 Set rstEmployees = Nothing

 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 Set fld = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndTypeFieldVB


Value Property (ADO)

 Copy code hover
[image]

Value Property (ADO)
Send feedback

Indicates the value assigned to a Field, Parameter, or Property object.

Settings and Return Values

Sets or returns a Variant value that indicates the value of the object. Default value depends on the Type property.

Remarks

Use the Value property to set or return data from Field objects, to set or return parameter values with Parameter objects, or to set or return property settings with Property objects. Whether the Value property is read/write or read-only depends upon numerous factors — see the respective object topics for more information.

ADO allows setting and returning long binary data with the Value property.

Note Note

For Parameter objects, ADO reads the Value property only once from the provider. If a command contains a Parameter whose Value property is empty, and you create a Recordset from the command, ensure that you first close the Recordset before retrieving the Value property. Otherwise, for some providers, the Value property may be empty, and won't contain the correct value.

For new Field objects that have been appended to the Fields collection of a Record object, the Value property must be set before any other Field properties can be specified. First, a specific value for the Value property must have been assigned and Update on the Fields collection called. Then, other properties such as Type or Attributes can be accessed.


Requested exchange failed because

 Copy code hover
[image]

Requested exchange failed because <description>. (Error 3660)
Send feedback

For details about why the exchange failed, look in the exchange history. If you are using Replication Manager, you can view the exchange history by right clicking on the replicated object. You can also view the replication history with the Synchronization History command on the View menu.

If you are conducting replication with Microsoft Access, you can open the exchange history table in Datasheet view to see the exchange history. The exchange history table is a hidden object. Display it in the Database window by selecting the System Objects check box on the View tab of the Options dialog box, which is available by clicking Options on the Tools menu.


StDev Function (Access 2013 custom web app)

 Copy code hover
[image]

StDev Function (Access 2013 custom web app)
Send feedback

Published: July 16, 2012

Returns the statistical standard deviation of all values in the specified expression.

Syntax

StDev (NumericExpression)

The StDev function contains the following argument.

Argument name | Description
NumericExpression | A numeric expression.


SetWarnings Macro Action

 Copy code hover
[image]

SetWarnings Macro Action
Send feedback

You can use the SetWarnings action to turn system messages on or off.

Note 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.

Setting

The SetWarnings action has the following argument.

Action argument | Description
Warnings On | Specifies whether system messages are displayed. Click Yes (to turn on system messages) or No (to turn off system messages) in the Warnings On box in the Action Arguments section of the Macro Builder Pane. The default is No.

Remarks

You can use this action to prevent modal warnings and message boxes from stopping the macro. However, error messages are always displayed. Also, Microsoft Access displays any dialog boxes that require input other than just choosing a button (such as OK, Cancel, Yes, or No) — for example, any dialog box that requires you to enter text or select one of several options.

Carrying out this action with the Warnings On argument set to No has the same effect as pressing ENTER whenever a warning or message box is displayed. Typically, an OK or Yes button is chosen in response to the warning or message.

When the macro finishes, Access automatically turns the display of system messages back on.

Often, you'll use this action with the Echo action, which hides the results of a macro until it's finished. You can use the SetWarnings action to hide the warnings and message boxes as well.

Caution note Caution

Although the SetWarnings action can simplify interactions with macros, you must be careful about turning system messages off. In some situations, you won't want to continue a macro if a certain warning message is displayed. Unless you're confident of the outcome of all macro actions, you should avoid using this action.

To run the SetWarnings action in a Visual Basic for Applications (VBA) module, use the SetWarnings method of the DoCmd object.


Label.OnMouseDown Property (Access)

 Copy code hover
[image]

Label.OnMouseDown Property (Access)
See also Send feedback

Published: July 16, 2012

Sets or returns the value of the On Mouse Down box in the Properties window. Read/write String.

Syntax

expression .OnMouseDown

expression A variable that represents a Label object.

Remarks

This property is helpful for programmatically changing the action Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

The MouseDown event occurs when the user clicks the mouse button while the mouse pointer rests over the object.

The OnMouseDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Mouse Down box in the object's Properties window):

  • If Expression Builder is chosen, the value will be "=expression", where expression is the expression from the Expression Builder window.

  • If Macro Builder is chosen, the value is the name of the macro.

  • If Code Builder is chosen, the value will be "[Event Procedure]".

If the On Mouse Down box is blank, the property value is an empty string.

Example

The following example prints the value of the OnMouseDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

VBA Copy code Copy code
Debug.Print Forms("Order Entry").Controls("OK").OnMouseDown

See also

Concepts

Label Object

Other resources

Label Object Members


Numeric Criteria Expressions

 Copy code hover
[image]

Numeric Criteria Expressions
Send feedback

To specify numeric criteria for an operation, you supply a numeric value as part of the string expression that forms the criteria argument.

Suppose that you are performing the DLookup function on an Employees table to find the last name of a particular employee, and you want to use a value from the EmployeeID field in the function's criteria argument. You could construct a criteria argument like the following example, which returns the last name of the employee whose EmployeeID is 7:

Copy code Copy code
=DLookup("[LastName]", "Employees", "[EmployeeID] = 7")


Counting Rows

 Copy code hover
[image]

Counting Rows
Send feedback

The RecordCount property returns a Long value that indicates the number of records in the Recordset. Use the RecordCount property to find out how many records are in a Recordset object. The property returns -1 when ADO cannot determine the number of records or if the provider or cursor type does not support RecordCount. Reading the RecordCount property on a closed Recordset causes an error.

The RecordCount property depends on the capabilities of the provider and the type of cursor. The RecordCount property will return -1 for a forward-only cursor, the actual count for a static or keyset cursor, and either -1 or the actual count for a dynamic cursor, depending on the data source.

The sample Recordset introduced in Examining Data would return -1 because a forward-only cursor was opened. In order to use the RecordCount property, you would need to open the Recordset with a more sophisticated cursor (static or keyset).

In certain cases, your provider or cursor might be unable to provide the RecordCount value without first fetching all records from the data source. To force this type of fetch, call the Recordset MoveLast method before calling RecordCount.

If you were to replace the line of code that calls the Recordset Open method with the following:

Copy code Copy code

oRs.Open sSQL, sCnStr, adOpenStatic, adLockOptimistic, adCmdText

you would be able to use the RecordCount property because static cursors with the Microsoft OLE DB Provider for SQL Server support RecordCount. For example, the following code would print out the number of records returned by the command to the debug window, assuming the cursor supports the RecordCount property:

Copy code Copy code

Debug.Print oRs.RecordCount ' Output: 4

From this point forward, assume that these more capable (but more expensive) cursor and lock type settings are used.


ChildCount Property (ADO MD)

 Copy code hover
[image]

ChildCount Property (ADO MD)
Send feedback

Indicates the number of members for which the current Member object is the parent in a hierarchy.

Return Values

Returns a Long integer and is read-only.

Remarks

Use the ChildCount property to return an estimate of how many children a Member has. The actual children of a Member can be returned by the Children property.

For Member objects from a Position object, the maximum number returned is 65536. If the actual number of children exceeds 65536, the value returned will still be 65536. Therefore, the application should interpret a ChildCount of 65536 as equal to or greater than 65536 children.

For Member objects from a Level object, use the ADO collection Count property on the Children collection to determine the exact number of children. Determining the exact number of children may be slow if the number of children in the collection is large.


Parameterized Commands with Intervening COMPUTE Commands

 Copy code hover
[image]

Parameterized Commands with Intervening COMPUTE Commands
Send feedback

A typical parameterized shape APPEND command has a clause that creates a parent Recordset with a query command and another clause that creates a child Recordset with a parameterized query command — that is, a command containing a parameter placeholder (a question mark, "?"). The resulting shaped Recordset has two levels, in which the parent occupies the upper level and the child occupies the lower level.

The clause that creates the child Recordset may now be an arbitrary number of nested shape COMPUTE commands, where the most deeply nested command contains the parameterized query. The resulting shaped Recordset has multiple levels, in which the parent occupies the uppermost level, the child occupies the lowermost level, and an arbitrary number of Recordsets generated by the shape COMPUTE commands occupy the intervening levels.

The typical use for this feature is to invoke the aggregate function and grouping abilities of shape COMPUTE commands to create intervening Recordset objects with analytical information about the child Recordset. Furthermore, because this is a parameterized shape command, each time a chapter column of the parent is accessed, a new child Recordset may be retrieved. Because the intervening levels are derived from the child, they also will be recomputed.


INSERT (Microsoft Access SQL reserved word)

 Copy code hover
[image]

INSERT (Microsoft Access SQL reserved word)
Send feedback

Published: July 16, 2012

The INSERT keyword is used in these contexts:

INSERT INTO Statement

CREATE PROCEDURE Statement

GRANT Statement

REVOKE Statement


TabControl.PressedForeShade Property (Access)

 Copy code hover
[image]

TabControl.PressedForeShade Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the shade applied to the theme color in the PressedForeColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .PressedForeShade

expression A variable that represents a TabControl object.

Remarks

The PressedForeShade property contains a numeric expression that can be used to darken the theme color in the PressedForeColor property. The default value of the PressedForeShade property is 100, which is neutral, and does not change the theme color. To darken the color, first determine the percentage by which to darken from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to darken the theme color shade by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

TabControl Object

Other resources

TabControl Object Members


Format of memo file does not match specified external database format. (Error 3286)

 Copy code hover
[image]

Format of memo file does not match specified external database format. (Error 3286)
Send feedback

Your application cannot read the memo file associated with the database you are trying to import or link and consequently cannot import or link the file. The memo file may be in the wrong format; for example, if you selected dBASE IV as the data source and the memo file is in a Microsoft FoxPro format.


Database.Updatable Property (DAO)

 Copy code hover
[image]

Database.Updatable Property (DAO)
Send feedback

Returns a value that indicates whether you can change a DAO object. Read-only Boolean.

Syntax

expression .Updatable

expression A variable that represents a Database object.


Version Property Example (VB)

 Copy code hover
[image]

Version Property Example (VB)
Send feedback

This example uses the Version property of a Connection object to display the current ADO version. It also uses several dynamic properties to show:

  • the current DBMS name and version.

  • OLE DB version.

  • provider name and version.

  • ODBC version.

  • ODBC driver name and version.

Copy code Copy code

'BeginVersionVB
Public Sub Main()
 On Error GoTo ErrorHandler

 Dim Cnxn As ADODB.Connection
 Dim strCnxn As String
 Dim strVersionInfo As String

 ' Open connection
 Set Cnxn = New ADODB.Connection
 strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
 "Initial Catalog='Pubs';Integrated Security='SSPI';"
 Cnxn.Open strCnxn

 strVersionInfo = "ADO Version: " & Cnxn.Version & vbCr
 strVersionInfo = strVersionInfo & "DBMS Name: " & Cnxn.Properties("DBMS Name") & vbCr
 strVersionInfo = strVersionInfo & "DBMS Version: " & Cnxn.Properties("DBMS Version") & vbCr
 strVersionInfo = strVersionInfo & "OLE DB Version: " & Cnxn.Properties("OLE DB Version") & vbCr
 strVersionInfo = strVersionInfo & "Provider Name: " & Cnxn.Properties("Provider Name") & vbCr
 strVersionInfo = strVersionInfo & "Provider Version: " & Cnxn.Properties("Provider Version") & vbCr

 MsgBox strVersionInfo

 ' clean up
 Cnxn.Close
 Set Cnxn = Nothing
 Exit Sub

ErrorHandler:
 ' clean up
 If Not Cnxn Is Nothing Then
 If Cnxn.State = adStateOpen Then Cnxn.Close
 End If
 Set Cnxn = Nothing

 If Err <> 0 Then
 MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Sub
'EndVersionVB


Source Property (ADO Error)

 Copy code hover
[image]

Source Property (ADO Error)
Send feedback

Indicates the name of the object or application that originally generated an error.

Return Value

Returns a String value that indicates the name of an object or application.

Remarks

Use the Source property on an Error object to determine the name of the object or application that originally generated an error. This could be the object's class name or programmatic ID. For errors in ADO, the property value will be ADODB.ObjectName, where ObjectName is the name of the object that triggered the error. For ADOX and ADO MD, the value will be ADOX.ObjectName and ADOMD.ObjectName, respectively.

Based on the error documentation from the Source, Number, and Description properties of Error objects, you can write code that will handle the error appropriately.

The Source property is read-only for Error objects.


Field2.IsComplex Property (DAO)

 Copy code hover
[image]

Field2.IsComplex Property (DAO)
Send feedback

Returns Boolean that indicates whether the specified field is a multi-valued data type. Read-only.

Version Information

Version Added: Access 2007

Syntax

expression .IsComplex

expression A variable that represents a Field2 object.

Example

The following example shows how to navigate a Recordset that contains a multi-value field.

Sample code provided by: The Microsoft Access 2010 Programmer's Reference | About the Contributors

VBA Copy code Copy code
Sub PrintStudentsAndClasses()
    Dim dbs As DAO.Database
    Dim rsStudents As DAO.Recordset2  'Recordset for students
    Dim rsClasses As DAO.Recordset2  'Recordset for classes
    Dim fld As DAO.Field2

    'open the database
    Set dbs = CurrentDb()

    'get the table of students
    Set rsStudents = dbs.OpenRecordset("tblStudents")

    'loop through the students
    Do While Not rsStudents.EOF

        'get the classes field
        Set fld = rsStudents("Classes")

        'get the classes Recordset
        'make sure the field is a multi-valued field before
        'getting a Recordset object
        If fld.IsComplex Then
            Set rsClasses = fld.Value
        End If

        'access all records in the Recordset
        If Not (rsClasses.BOF And rsClasses.EOF) Then
            rsClasses.MoveLast
            rsClasses.MoveFirst
        End If

        'print the student and number of classes
        Debug.Print rsStudents("FirstName") & " " & rsStudents("LastName"), _
            "Number of classes: " & rsClasses.RecordCount

        'print the classes for this student
        Do While Not rsClasses.EOF
            Debug.Print , rsClasses("Value")
            rsClasses.MoveNext
        Loop

        'close the Classes Recordset
        rsClasses.Close

        'get the next student
        rsStudents.MoveNext

    Loop

    'cleanup
    rsStudents.Close

    Set fld = Nothing
    Set rsStudents = Nothing
    Set dbs = Nothing

End Sub

About the Contributors

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.


NavigationButton.KeyDown Event (Access)

 Copy code hover
[image]

NavigationButton.KeyDown Event (Access)
See also Send feedback

Published: July 16, 2012

The KeyDown event occurs when the user presses a key while a form or control has the focus. This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Version Information

Version Added: Access 2010

Syntax

expression .KeyDown(KeyCode, Shift)

expression A variable that represents a NavigationButton object.

Parameters

Name | Required/Optional | Data Type | Description
KeyCode | Required | Integer |
Shift | Required | Integer |

Return Value

nothing

Remarks

To run a macro or event procedure when these events occur, set the OnKeyDown property to the name of the macro or to [Event Procedure].

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.

If you press and hold down a key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key, then the KeyUp event occurs.

Although the KeyDown event occurs when most keys are pressed, it is typically used to recognize or distinguish between:

  • Extended character keys, such as function keys.

  • Navigation keys, such as HOME, END, PAGE UP, PAGE DOWN, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.

  • Combinations of keys and standard keyboard modifiers (SHIFT, CTRL, or ALT keys).

  • The numeric keypad and keyboard number keys.

The KeyDown event does not occur when you press:

  • The ENTER key if the form has a command button for which the Default property is set to Yes.

  • The ESC key if the form has a command button for which the Cancel property is set to Yes.

The KeyDown event occurs when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.

To find out the ANSI character corresponding to the key pressed, use the KeyPress event.

If a modal dialog box is displayed as a result of pressing or sending a key, the KeyDown and KeyPress events occur, but the KeyUp event doesn't occur.

Example

The following example determines whether you have pressed the SHIFT, CTRL, or ALT key.

To try the example, add the following event procedure to a form containing a text box named KeyHandler.

VBA Copy code Copy code
Private Sub KeyHandler_KeyDown(KeyCode As Integer, _
 Shift As Integer)
 Dim intShiftDown As Integer, intAltDown As Integer
 Dim intCtrlDown As Integer

 ' Use bit masks to determine which key was pressed.
 intShiftDown = (Shift And acShiftMask) > 0
 intAltDown = (Shift And acAltMask) > 0
 intCtrlDown = (Shift And acCtrlMask) > 0
 ' Display message telling user which key was pressed.
 If intShiftDown Then MsgBox "You pressed the SHIFT key."
 If intAltDown Then MsgBox "You pressed the ALT key."
 If intCtrlDown Then MsgBox "You pressed the CTRL key."
End Sub

See also

Concepts

NavigationButton Object

Other resources

NavigationButton Object Members


Printers.Item Property (Access)

 Copy code hover
[image]

Printers.Item Property (Access)
See also Send feedback

Published: July 16, 2012

The Item property returns a specific member of a collection either by position or by index. Read-only Printer.

Syntax

expression .Item(Index)

expression A variable that represents a Printers object.

Parameters

Name | Required/Optional | Data Type | Description
Index | Required | Variant | An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the index argument must be the name of a member of the collection

Remarks

If the value provided for the index argument doesn't match any existing member of the collection, an error occurs.

The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent:

VBA Copy code Copy code
Debug.Print Modules(0)
VBA Copy code Copy code
Debug.Print Modules.Item(0)

See also

Concepts

Printers Collection

Other resources

Printers Object Members


Indexes.Refresh Method (DAO)

 Copy code hover
[image]

Indexes.Refresh Method (DAO)
Send feedback

Updates the objects in the specified colletion to reflect the database's current schema.

Syntax

expression .Refresh

expression A variable that represents an Indexes object.

Remarks

Use the Refresh method in multiuser environments in which other users may change the database. You may also need to use it on any collections that are indirectly affected by changes to the database. For example, if you change a Users collection, you may need to refresh a Groups collection before using the Groups collection.

A collection is filled with objects the first time it's referred to and won't automatically reflect subsequent changes other users make. If it's likely that another user has changed a collection, use the Refresh method on the collection immediately before carrying out any task in your application that assumes the presence or absence of a particular object in the collection. This will ensure that the collection is as up-to-date as possible. On the other hand, using Refresh can unnecessarily slow performance.


CustomControl.Default Property (Access)

 Copy code hover
[image]

CustomControl.Default Property (Access)
See also Send feedback

Published: July 16, 2012

You can use the Default property to specify whether a command button is the default button on a form. Read/write Boolean.

Syntax

expression .Default

expression A variable that represents a CustomControl object.

Remarks

The Default property uses the following settings.

Setting | Visual Basic | Description
Yes | True | The command button is the default button.
No | False | (Default) The command button isn't the default button.

When the command button's Default property setting is Yes and the Form window is active, the user can choose the command button by pressing ENTER (if no other command button has the focus) as well as by clicking the command button.

Only one command button on a form can be the default button. When the Default property is set to Yes for one command button, it is automatically set to No for all other command buttons on the form.

For a form that supports irreversible operations, such as deletions, it's a good idea to make the Cancel button the default command button. To do this, set both the Default property and the Cancel property to Yes.

See also

Concepts

CustomControl Object

Other resources

CustomControl Object Members


NavigationControl.GridlineTint Property (Access)

 Copy code hover
[image]

NavigationControl.GridlineTint Property (Access)
See also Send feedback

Published: July 16, 2012

Gets or sets the tint applied to the theme color in the GridlineColor property of the specified object. Read/write Single.

Version Information

Version Added: Access 2010

Syntax

expression .GridlineTint

expression A variable that represents a NavigationControl object.

Remarks

The GridlineTint property contains a numeric expression that can be used to lighten the theme color in the GridlineColor property. The default value of the GridlineTint property is 100, which is neutral, and does not change the theme color. To lighten the color, first determine the percentage by which to lighten from 1 to 100, then subtract that value as a whole number from 100 and use the remainder. For example, to lighten the theme color tint by 75%, subtract 75 from 100 and use the remainder, which is 25.

This property is not surfaced in the property sheet.

See also

Concepts

NavigationControl Object

Other resources

NavigationControl Object Members


Date and Time Criteria Expressions

 Copy code hover
[image]

Date and Time Criteria Expressions
Send feedback

To specify date or time criteria for an operation, you supply a date or time value as part of the string expression that forms the criteria argument. This value must be enclosed in number signs (#).

Note Note

The number signs indicate to Microsoft Access that the criteria argument contains a date or time within a string.

Suppose that you are creating a filter for an Employees form to display records for all employees born on or after January 1, 1960. You could construct the criteria argument for the form's Filter or ServerFilter property as in the following example. Note the placement of the number signs.

Copy code Copy code
Forms!Employees.Filter = "[BirthDate] >= #1-1-1960#"


CheckBox.OptionValue Property (Access)

 Copy code hover
[image]

CheckBox.OptionValue Property (Access)
See also Send feedback

Published: July 16, 2012

Each control in an option group has a numeric value that you can set with the OptionValue property. Read/write Long.

Syntax

expression .OptionValue

expression A variable that represents a CheckBox object.

Remarks

When the control is selected, the number is assigned to the option group. If the option group is bound to a field, the value of the selected control's OptionValue property is stored in the field.

For example, this Region option group is bound to the Region field in a table. The Europe button has an OptionValue property setting of 1, the Asia button has a setting of 2, and the Africa button has a setting of 3. When one of these buttons is selected, the Region option group value will be the same as the OptionValue property setting for the selected control. In this case, because the Region option group is bound to the Region field, the value of this field in the table also equals 2.

The OptionValue property applies only to the check box, option button, and toggle button controls in an option group.

Unless you change the OptionValue property yourself, the first control you place in an option group has a value of 1, the second control has a value of 2, and so on.

The OptionValue property is only available when the control is placed inside an option group control. When a check box, a toggle button, or an option button isn't in an option group, the control has no OptionValue property. Instead, each such control has a ControlSource property, and the value of each control will be either True if selected or False if not selected.

Example

The following example sets the OptionValue property for three option buttons in the "Ship Method Group" option group when a form opens. When an option button is selected in the option group, a message displays indicating the shipper's assigned ID number.

VBA Copy code Copy code
Private Sub Form_Open(Cancel As Integer)

 Me.Controls("ABC Couriers").OptionValue = 15876
 Me.Controls("Speedy Delivery").OptionValue = 742
 Me.Controls("Lightning Express").OptionValue = 1256

End Sub

Private Sub Ship_Method_Group_Click()

 MsgBox "The ID for the selected shipper is " & Me.Controls("Ship Method Group").Value

End Sub

See also

Concepts

CheckBox Object

Other resources

CheckBox Object Members